mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 17:26:30 +00:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d7cf4235c | |||
| 187ee10218 | |||
| 6bd758b3dd | |||
| 9938755517 | |||
| 630da0eee6 | |||
| 3158386aa3 | |||
| 12ada57ee8 | |||
| 7a841c11c5 | |||
| a49d1446b7 | |||
| b2d0fa6a2f | |||
| 62ac015fff | |||
| 4977a7c2e0 | |||
| 9967384ab8 | |||
| d3da2e5501 | |||
| 33f5c4c6a7 | |||
| e4aa6a6957 | |||
| e4d812f4b4 | |||
| bcedfe7032 | |||
| c1df3fbcb0 | |||
| 011e1d05e7 | |||
| 3f0f95976c | |||
| 77de9619b5 | |||
| 20d3ab2ac5 | |||
| 0ea47fadee | |||
| 1ce51ca3b0 | |||
| 25ef3d2cdb | |||
| 95249889a6 | |||
| 428cccfa50 | |||
| 41dd8a5754 | |||
| d02d766563 | |||
| dfd2729b28 | |||
| b92eafd21b | |||
| d6d5d992cb | |||
| d524cb6a5a | |||
| e6469878ce | |||
| 9583099ace | |||
| cf3483b402 | |||
| 311af7bbe9 | |||
| be42b73f5c | |||
| f76c798910 | |||
| ae198ae043 | |||
| 520943ebf1 | |||
| 9ac306fe67 | |||
| 7a1d69d0d4 |
+154
@@ -1,3 +1,157 @@
|
|||||||
|
## [22.60.0] 11/25/2024
|
||||||
|
|
||||||
|
### Bazaar
|
||||||
|
|
||||||
|
* Further refinements for instanced bazaar ([#4544](https://github.com/EQEmu/Server/pull/4544)) @neckkola 2024-11-16
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
* Fix build with older C++ libraries ([#4549](https://github.com/EQEmu/Server/pull/4549)) @hgtw 2024-11-24
|
||||||
|
|
||||||
|
### Config
|
||||||
|
|
||||||
|
* Fix World TCP Address Configuration Default ([#4551](https://github.com/EQEmu/Server/pull/4551)) @Akkadius 2024-11-24
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
* Fix Issue with Perl EVENT_PAYLOAD ([#4545](https://github.com/EQEmu/Server/pull/4545)) @Kinglykrab 2024-11-24
|
||||||
|
* Fix Possible Item Loss in Trades ([#4554](https://github.com/EQEmu/Server/pull/4554)) @Kinglykrab 2024-11-24
|
||||||
|
* Fix Strings::Commify bug with #mystats ([#4547](https://github.com/EQEmu/Server/pull/4547)) @carolus21rex 2024-11-22
|
||||||
|
* Fix an edge case with augmented items inside parceled containers ([#4546](https://github.com/EQEmu/Server/pull/4546)) @neckkola 2024-11-21
|
||||||
|
* Fix for bazaar search of containers. ([#4540](https://github.com/EQEmu/Server/pull/4540)) @neckkola 2024-11-15
|
||||||
|
* Fix for mult-instanced bazaar zones ([#4541](https://github.com/EQEmu/Server/pull/4541)) @neckkola 2024-11-15
|
||||||
|
* Fix for sending money via Parcel, then changing your mind ([#4552](https://github.com/EQEmu/Server/pull/4552)) @neckkola 2024-11-24
|
||||||
|
* Fix issue where NPC's are being hidden as traders ([#4539](https://github.com/EQEmu/Server/pull/4539)) @Akkadius 2024-11-15
|
||||||
|
* Players could become flagged as a Trader when they were not trading ([#4553](https://github.com/EQEmu/Server/pull/4553)) @neckkola 2024-11-24
|
||||||
|
|
||||||
|
### Rules
|
||||||
|
|
||||||
|
* Add Rule to Disable NPCs Facing Target ([#4543](https://github.com/EQEmu/Server/pull/4543)) @Kinglykrab 2024-11-24
|
||||||
|
|
||||||
|
### Tasks
|
||||||
|
|
||||||
|
* Update tasks in all zones if invalid zone set ([#4550](https://github.com/EQEmu/Server/pull/4550)) @hgtw 2024-11-25
|
||||||
|
|
||||||
|
## [22.59.1] 11/13/2024
|
||||||
|
|
||||||
|
### Hotfix
|
||||||
|
|
||||||
|
* Fix faulty database migration condition with databuckets (9285)
|
||||||
|
|
||||||
|
## [22.59.0] 11/13/2024
|
||||||
|
|
||||||
|
### Databuckets
|
||||||
|
|
||||||
|
* Add database index to data_buckets ([#4535](https://github.com/EQEmu/Server/pull/4535)) @Akkadius 2024-11-09
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
* Bazaar two edge case issues resolved ([#4533](https://github.com/EQEmu/Server/pull/4533)) @neckkola 2024-11-09
|
||||||
|
* Check if the mob is already in the close mobs list before inserting @Akkadius 2024-11-11
|
||||||
|
* ScanCloseMobs - Ensure scanning mob has an entity ID @Akkadius 2024-11-10
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
* Improvements to ScanCloseMobs logic ([#4534](https://github.com/EQEmu/Server/pull/4534)) @Akkadius 2024-11-08
|
||||||
|
|
||||||
|
### Quest API
|
||||||
|
|
||||||
|
* Add Native Database Querying Interface ([#4531](https://github.com/EQEmu/Server/pull/4531)) @hgtw 2024-11-13
|
||||||
|
|
||||||
|
### Rules
|
||||||
|
|
||||||
|
* Add Rule for restricting client versions to world server ([#4527](https://github.com/EQEmu/Server/pull/4527)) @knervous 2024-11-12
|
||||||
|
|
||||||
|
## [22.58.0] 11/5/2024
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
* Add mysql prepared statement support ([#4530](https://github.com/EQEmu/Server/pull/4530)) @hgtw 2024-11-06
|
||||||
|
* Update perlbind to 1.1.0 ([#4529](https://github.com/EQEmu/Server/pull/4529)) @hgtw 2024-11-06
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
|
||||||
|
* Focus Skill Attack Spells ([#4528](https://github.com/EQEmu/Server/pull/4528)) @mmcgarvey 2024-10-31
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
* Add Missing Lua Registers ([#4525](https://github.com/EQEmu/Server/pull/4525)) @Kinglykrab 2024-10-24
|
||||||
|
* Fix cross_zone_set_entity_variable_by_char_id in Lua ([#4526](https://github.com/EQEmu/Server/pull/4526)) @Kinglykrab 2024-10-24
|
||||||
|
|
||||||
|
### Loginserver
|
||||||
|
|
||||||
|
* Automatifc Opcode File Creation ([#4521](https://github.com/EQEmu/Server/pull/4521)) @KimLS 2024-10-22
|
||||||
|
|
||||||
|
### Quest API
|
||||||
|
|
||||||
|
* Add Spawn Circle/Grid Methods to Perl/Lua ([#4524](https://github.com/EQEmu/Server/pull/4524)) @Kinglykrab 2024-10-24
|
||||||
|
|
||||||
|
## [22.57.1] 10/22/2024
|
||||||
|
|
||||||
|
### Bots
|
||||||
|
|
||||||
|
* Enable Bot Commands Only if Rule Enabled ([#4519](https://github.com/EQEmu/Server/pull/4519)) @Kinglykrab 2024-10-22
|
||||||
|
* Fix pet buffs from saving duplicates every save ([#4520](https://github.com/EQEmu/Server/pull/4520)) @nytmyr 2024-10-22
|
||||||
|
|
||||||
|
### Loginserver
|
||||||
|
|
||||||
|
* Automatic Opcode File Creation ([#4521](https://github.com/EQEmu/Server/pull/4521)) @KimLS 2024-10-22
|
||||||
|
|
||||||
|
## [22.57.0] 10/20/2024
|
||||||
|
|
||||||
|
### Bots
|
||||||
|
|
||||||
|
* Add "silent" option to ^spawn and mute raid spawn ([#4494](https://github.com/EQEmu/Server/pull/4494)) @nytmyr 2024-10-05
|
||||||
|
* Add attack flag when told to attack ([#4490](https://github.com/EQEmu/Server/pull/4490)) @nytmyr 2024-09-29
|
||||||
|
* Fix timers loading on spawn and zone ([#4516](https://github.com/EQEmu/Server/pull/4516)) @nytmyr 2024-10-20
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
* Fixed a typo in Zoning.cpp ([#4515](https://github.com/EQEmu/Server/pull/4515)) @carolus21rex 2024-10-20
|
||||||
|
* Optimization Code Cleanup ([#4489](https://github.com/EQEmu/Server/pull/4489)) @Akkadius 2024-09-30
|
||||||
|
* Remove Extra Skill in EQ::skills::GetExtraDamageSkills() ([#4486](https://github.com/EQEmu/Server/pull/4486)) @Kinglykrab 2024-10-03
|
||||||
|
|
||||||
|
### Crash
|
||||||
|
|
||||||
|
* Fixes a crash when the faction_list db table is empty. ([#4511](https://github.com/EQEmu/Server/pull/4511)) @KimLS 2024-10-14
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
* Add character_instance_safereturns to tables_to_zero_id ([#4485](https://github.com/EQEmu/Server/pull/4485)) @Morzain 2024-09-26
|
||||||
|
* Correctly limit max targets of PBAOE ([#4507](https://github.com/EQEmu/Server/pull/4507)) @catapultam-habeo 2024-10-11
|
||||||
|
* FindBestZ selecting false zone floor as bestz - Results in roambox failures ([#4504](https://github.com/EQEmu/Server/pull/4504)) @fryguy503 2024-10-13
|
||||||
|
* Fix #set motd Crash ([#4495](https://github.com/EQEmu/Server/pull/4495)) @Kinglykrab 2024-10-05
|
||||||
|
* Fix `character_exp_modifiers` Default Values ([#4502](https://github.com/EQEmu/Server/pull/4502)) @Kinglykrab 2024-10-09
|
||||||
|
* Fix a display error regarding a few trader/buyer query errors ([#4514](https://github.com/EQEmu/Server/pull/4514)) @neckkola 2024-10-17
|
||||||
|
* Fix Group ID 0 in Group::SaveGroupLeaderAA() ([#4487](https://github.com/EQEmu/Server/pull/4487)) @Kinglykrab 2024-10-03
|
||||||
|
* Fix Mercenary Encounter Crash ([#4509](https://github.com/EQEmu/Server/pull/4509)) @Kinglykrab 2024-10-12
|
||||||
|
* Fix NPC::CanTalk() Crash ([#4499](https://github.com/EQEmu/Server/pull/4499)) @Kinglykrab 2024-10-07
|
||||||
|
* Fix Spells:DefaultAOEMaxTargets Default Value ([#4508](https://github.com/EQEmu/Server/pull/4508)) @Kinglykrab 2024-10-12
|
||||||
|
* Fix Targeted AOE Max Targets Rule ([#4488](https://github.com/EQEmu/Server/pull/4488)) @Kinglykrab 2024-10-03
|
||||||
|
* fixed a bug where it would use npc value instead of faction value in the database. ([#4491](https://github.com/EQEmu/Server/pull/4491)) @regneq 2024-09-29
|
||||||
|
* Master of Disguise should apply to illusions casted by others. ([#4506](https://github.com/EQEmu/Server/pull/4506)) @fryguy503 2024-10-11
|
||||||
|
* Spells - Self Only (Yellow) cast when non group member is targeted ([#4503](https://github.com/EQEmu/Server/pull/4503)) @fryguy503 2024-10-11
|
||||||
|
|
||||||
|
### Loginserver
|
||||||
|
|
||||||
|
* Larion loginserver support ([#4492](https://github.com/EQEmu/Server/pull/4492)) @KimLS 2024-10-03
|
||||||
|
* Login Fatal Error Spamming ([#4476](https://github.com/EQEmu/Server/pull/4476)) @KimLS 2024-10-09
|
||||||
|
|
||||||
|
### Logs
|
||||||
|
|
||||||
|
* Add NPC Trades to Player Events ([#4505](https://github.com/EQEmu/Server/pull/4505)) @Kinglykrab 2024-10-13
|
||||||
|
|
||||||
|
### Quest API
|
||||||
|
|
||||||
|
* Add Buff Fade Methods to Perl/Lua ([#4501](https://github.com/EQEmu/Server/pull/4501)) @Kinglykrab 2024-10-09
|
||||||
|
* Add EVENT_READ_ITEM to Perl/Lua ([#4497](https://github.com/EQEmu/Server/pull/4497)) @Kinglykrab 2024-10-08
|
||||||
|
* Add NPC List Filter Methods to Perl/Lua ([#4493](https://github.com/EQEmu/Server/pull/4493)) @Kinglykrab 2024-10-04
|
||||||
|
* Add Scripting Support to Mercenaries ([#4500](https://github.com/EQEmu/Server/pull/4500)) @Kinglykrab 2024-10-11
|
||||||
|
|
||||||
|
### Rules
|
||||||
|
|
||||||
|
* Add Rule to disable PVP Regions ([#4513](https://github.com/EQEmu/Server/pull/4513)) @Kinglykrab 2024-10-17
|
||||||
|
|
||||||
## [22.56.3] 9/23/2024
|
## [22.56.3] 9/23/2024
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ SET(common_sources
|
|||||||
mutex.cpp
|
mutex.cpp
|
||||||
mysql_request_result.cpp
|
mysql_request_result.cpp
|
||||||
mysql_request_row.cpp
|
mysql_request_row.cpp
|
||||||
|
mysql_stmt.cpp
|
||||||
opcode_map.cpp
|
opcode_map.cpp
|
||||||
opcodemgr.cpp
|
opcodemgr.cpp
|
||||||
packet_dump.cpp
|
packet_dump.cpp
|
||||||
@@ -586,6 +587,7 @@ SET(common_headers
|
|||||||
mutex.h
|
mutex.h
|
||||||
mysql_request_result.h
|
mysql_request_result.h
|
||||||
mysql_request_row.h
|
mysql_request_row.h
|
||||||
|
mysql_stmt.h
|
||||||
op_codes.h
|
op_codes.h
|
||||||
opcode_dispatch.h
|
opcode_dispatch.h
|
||||||
opcodemgr.h
|
opcodemgr.h
|
||||||
|
|||||||
+2
-1
@@ -235,7 +235,8 @@ Bazaar::GetSearchResults(
|
|||||||
std::vector<ItemSearchType> item_search_types = {
|
std::vector<ItemSearchType> item_search_types = {
|
||||||
{EQ::item::ItemType::ItemTypeAll, true},
|
{EQ::item::ItemType::ItemTypeAll, true},
|
||||||
{EQ::item::ItemType::ItemTypeBook, item->ItemClass == EQ::item::ItemType::ItemTypeBook},
|
{EQ::item::ItemType::ItemTypeBook, item->ItemClass == EQ::item::ItemType::ItemTypeBook},
|
||||||
{EQ::item::ItemType::ItemTypeContainer, item->ItemClass == EQ::item::ItemType::ItemTypeContainer},
|
{EQ::item::ItemType::ItemTypeContainer, item->ItemClass == EQ::item::ItemType::ItemTypeContainer ||
|
||||||
|
item->IsClassBag()},
|
||||||
{EQ::item::ItemType::ItemTypeAllEffects, item->Scroll.Effect > 0 && item->Scroll.Effect < 65000},
|
{EQ::item::ItemType::ItemTypeAllEffects, item->Scroll.Effect > 0 && item->Scroll.Effect < 65000},
|
||||||
{EQ::item::ItemType::ItemTypeUnknown9, item->Worn.Effect == 998},
|
{EQ::item::ItemType::ItemTypeUnknown9, item->Worn.Effect == 998},
|
||||||
{EQ::item::ItemType::ItemTypeUnknown10, item->Worn.Effect >= 1298 && item->Worn.Effect <= 1307},
|
{EQ::item::ItemType::ItemTypeUnknown10, item->Worn.Effect >= 1298 && item->Worn.Effect <= 1307},
|
||||||
|
|||||||
@@ -514,12 +514,6 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
|
|||||||
c.raid_auto_consent = pp->raidAutoconsent;
|
c.raid_auto_consent = pp->raidAutoconsent;
|
||||||
c.guild_auto_consent = pp->guildAutoconsent;
|
c.guild_auto_consent = pp->guildAutoconsent;
|
||||||
c.RestTimer = pp->RestTimer;
|
c.RestTimer = pp->RestTimer;
|
||||||
c.cold_resist = pp->cold_resist;
|
|
||||||
c.fire_resist = pp->fire_resist;
|
|
||||||
c.magic_resist = pp->magic_resist;
|
|
||||||
c.disease_resist = pp->disease_resist;
|
|
||||||
c.poison_resist = pp->poison_resist;
|
|
||||||
c.corruption_resist = pp->corruption_resist;
|
|
||||||
|
|
||||||
CharacterDataRepository::ReplaceOne(*this, c);
|
CharacterDataRepository::ReplaceOne(*this, c);
|
||||||
|
|
||||||
|
|||||||
@@ -5758,6 +5758,18 @@ ALTER TABLE `inventory_snapshots`
|
|||||||
ALTER TABLE `character_exp_modifiers`
|
ALTER TABLE `character_exp_modifiers`
|
||||||
MODIFY COLUMN `aa_modifier` float NOT NULL DEFAULT 1.0 AFTER `instance_version`,
|
MODIFY COLUMN `aa_modifier` float NOT NULL DEFAULT 1.0 AFTER `instance_version`,
|
||||||
MODIFY COLUMN `exp_modifier` float NOT NULL DEFAULT 1.0 AFTER `aa_modifier`;
|
MODIFY COLUMN `exp_modifier` float NOT NULL DEFAULT 1.0 AFTER `aa_modifier`;
|
||||||
|
)"
|
||||||
|
},
|
||||||
|
ManifestEntry{
|
||||||
|
.version = 9285,
|
||||||
|
.description = "2024_11_08_data_buckets_indexes.sql",
|
||||||
|
.check = "SHOW CREATE TABLE `data_buckets`",
|
||||||
|
.condition = "missing",
|
||||||
|
.match = "idx_character_expires",
|
||||||
|
.sql = R"(
|
||||||
|
CREATE INDEX idx_character_expires ON data_buckets (character_id, expires);
|
||||||
|
CREATE INDEX idx_npc_expires ON data_buckets (npc_id, expires);
|
||||||
|
CREATE INDEX idx_bot_expires ON data_buckets (bot_id, expires);
|
||||||
)"
|
)"
|
||||||
}
|
}
|
||||||
// -- template; copy/paste this when you need to create a new entry
|
// -- template; copy/paste this when you need to create a new entry
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#include "dbcore.h"
|
#include "dbcore.h"
|
||||||
|
#include "mysql_stmt.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -436,3 +437,8 @@ MySQLRequestResult DBcore::QueryDatabaseMulti(const std::string &query)
|
|||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mysql::PreparedStmt DBcore::Prepare(std::string query)
|
||||||
|
{
|
||||||
|
return mysql::PreparedStmt(*mysql, std::move(query), m_mutex);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#define CR_SERVER_GONE_ERROR 2006
|
#define CR_SERVER_GONE_ERROR 2006
|
||||||
#define CR_SERVER_LOST 2013
|
#define CR_SERVER_LOST 2013
|
||||||
|
|
||||||
|
namespace mysql { class PreparedStmt; }
|
||||||
|
|
||||||
class DBcore {
|
class DBcore {
|
||||||
public:
|
public:
|
||||||
enum eStatus {
|
enum eStatus {
|
||||||
@@ -48,6 +50,11 @@ public:
|
|||||||
}
|
}
|
||||||
void SetMutex(Mutex *mutex);
|
void SetMutex(Mutex *mutex);
|
||||||
|
|
||||||
|
// only safe on connections shared with other threads if results buffered
|
||||||
|
// unsafe to use off main thread due to internal server logging
|
||||||
|
// throws std::runtime_error on failure
|
||||||
|
mysql::PreparedStmt Prepare(std::string query);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Open(
|
bool Open(
|
||||||
const char *iHost,
|
const char *iHost,
|
||||||
|
|||||||
@@ -1121,12 +1121,6 @@ struct PlayerProfile_Struct
|
|||||||
/*19559*/ uint8 unknown19595[5]; // ***Placeholder (6/29/2005)
|
/*19559*/ uint8 unknown19595[5]; // ***Placeholder (6/29/2005)
|
||||||
/*19564*/ uint32 RestTimer;
|
/*19564*/ uint32 RestTimer;
|
||||||
/*19568*/ uint32 char_id; // Found as part of bazaar revamp (5/15/2024)
|
/*19568*/ uint32 char_id; // Found as part of bazaar revamp (5/15/2024)
|
||||||
/*19572*/ uint32 cold_resist;
|
|
||||||
/*19576*/ uint32 fire_resist;
|
|
||||||
/*19580*/ uint32 magic_resist;
|
|
||||||
/*19584*/ uint32 disease_resist;
|
|
||||||
/*19588*/ uint32 poison_resist;
|
|
||||||
/*19592*/ uint32 corruption_resist;
|
|
||||||
|
|
||||||
// All player profile packets are translated and this overhead is ignored in out-bound packets
|
// All player profile packets are translated and this overhead is ignored in out-bound packets
|
||||||
PlayerProfile_Struct() : m_player_profile_version(EQ::versions::MobVersion::Unknown) { }
|
PlayerProfile_Struct() : m_player_profile_version(EQ::versions::MobVersion::Unknown) { }
|
||||||
@@ -3227,6 +3221,7 @@ struct BuyerMessaging_Struct {
|
|||||||
char item_name[64];
|
char item_name[64];
|
||||||
uint32 slot;
|
uint32 slot;
|
||||||
uint32 seller_quantity;
|
uint32 seller_quantity;
|
||||||
|
uint32 purchase_method; // 0 direct merchant, 1 via /barter window
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BuyerAddBuyertoBarterWindow_Struct {
|
struct BuyerAddBuyertoBarterWindow_Struct {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ void EQEmuConfig::parse_config()
|
|||||||
auto_database_updates = true;
|
auto_database_updates = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldIP = _root["server"]["world"]["tcp"].get("host", "127.0.0.1").asString();
|
WorldIP = _root["server"]["world"]["tcp"].get("ip", "127.0.0.1").asString();
|
||||||
WorldTCPPort = Strings::ToUnsignedInt(_root["server"]["world"]["tcp"].get("port", "9000").asString());
|
WorldTCPPort = Strings::ToUnsignedInt(_root["server"]["world"]["tcp"].get("port", "9000").asString());
|
||||||
|
|
||||||
TelnetIP = _root["server"]["world"]["telnet"].get("ip", "127.0.0.1").asString();
|
TelnetIP = _root["server"]["world"]["telnet"].get("ip", "127.0.0.1").asString();
|
||||||
@@ -171,6 +171,7 @@ void EQEmuConfig::parse_config()
|
|||||||
PluginDir = _root["server"]["directories"].get("plugins", "plugins/").asString();
|
PluginDir = _root["server"]["directories"].get("plugins", "plugins/").asString();
|
||||||
LuaModuleDir = _root["server"]["directories"].get("lua_modules", "lua_modules/").asString();
|
LuaModuleDir = _root["server"]["directories"].get("lua_modules", "lua_modules/").asString();
|
||||||
PatchDir = _root["server"]["directories"].get("patches", "./").asString();
|
PatchDir = _root["server"]["directories"].get("patches", "./").asString();
|
||||||
|
OpcodeDir = _root["server"]["directories"].get("opcodes", "./").asString();
|
||||||
SharedMemDir = _root["server"]["directories"].get("shared_memory", "shared/").asString();
|
SharedMemDir = _root["server"]["directories"].get("shared_memory", "shared/").asString();
|
||||||
LogDir = _root["server"]["directories"].get("logs", "logs/").asString();
|
LogDir = _root["server"]["directories"].get("logs", "logs/").asString();
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ class EQEmuConfig
|
|||||||
std::string PluginDir;
|
std::string PluginDir;
|
||||||
std::string LuaModuleDir;
|
std::string LuaModuleDir;
|
||||||
std::string PatchDir;
|
std::string PatchDir;
|
||||||
|
std::string OpcodeDir;
|
||||||
std::string SharedMemDir;
|
std::string SharedMemDir;
|
||||||
std::string LogDir;
|
std::string LogDir;
|
||||||
|
|
||||||
|
|||||||
@@ -789,50 +789,36 @@ std::string PlayerEventDiscordFormatter::FormatNPCHandinEvent(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string npc_info = fmt::format(
|
||||||
|
"{} ({})\n",
|
||||||
|
e.npc_name,
|
||||||
|
e.npc_id
|
||||||
|
);
|
||||||
|
|
||||||
|
npc_info += fmt::format(
|
||||||
|
"Is Quest Handin: {}",
|
||||||
|
e.is_quest_handin ? "Yes" : "No"
|
||||||
|
);
|
||||||
|
|
||||||
std::vector<DiscordField> f = {};
|
std::vector<DiscordField> f = {};
|
||||||
|
|
||||||
|
|
||||||
|
BuildDiscordField(&f, "NPC", npc_info);
|
||||||
|
|
||||||
if (!handin_items_info.empty()) {
|
if (!handin_items_info.empty()) {
|
||||||
BuildDiscordField(
|
BuildDiscordField(&f, "Handin Items", handin_items_info);
|
||||||
&f,
|
|
||||||
"Handin Items",
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
handin_items_info
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handin_money_info.empty()) {
|
if (!handin_money_info.empty()) {
|
||||||
BuildDiscordField(
|
BuildDiscordField(&f, "Handin Money", handin_money_info);
|
||||||
&f,
|
|
||||||
"Handin Money",
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
handin_money_info
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!return_items_info.empty()) {
|
if (!return_items_info.empty()) {
|
||||||
BuildDiscordField(
|
BuildDiscordField(&f, "Return Items", return_items_info);
|
||||||
&f,
|
|
||||||
"Return Items",
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
return_items_info
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!return_money_info.empty()) {
|
if (!return_money_info.empty()) {
|
||||||
BuildDiscordField(
|
BuildDiscordField(&f, "Return Money", return_money_info);
|
||||||
&f,
|
|
||||||
"Return Money",
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
return_money_info
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<DiscordEmbed> embeds = {};
|
std::vector<DiscordEmbed> embeds = {};
|
||||||
|
|||||||
@@ -862,6 +862,8 @@ namespace PlayerEvent {
|
|||||||
public:
|
public:
|
||||||
uint32 item_id;
|
uint32 item_id;
|
||||||
std::string item_name;
|
std::string item_name;
|
||||||
|
std::vector<uint32> augment_ids;
|
||||||
|
std::vector<std::string> augment_names;
|
||||||
uint16 charges;
|
uint16 charges;
|
||||||
bool attuned;
|
bool attuned;
|
||||||
|
|
||||||
@@ -872,6 +874,8 @@ namespace PlayerEvent {
|
|||||||
ar(
|
ar(
|
||||||
CEREAL_NVP(item_id),
|
CEREAL_NVP(item_id),
|
||||||
CEREAL_NVP(item_name),
|
CEREAL_NVP(item_name),
|
||||||
|
CEREAL_NVP(augment_ids),
|
||||||
|
CEREAL_NVP(augment_names),
|
||||||
CEREAL_NVP(charges),
|
CEREAL_NVP(charges),
|
||||||
CEREAL_NVP(attuned)
|
CEREAL_NVP(attuned)
|
||||||
);
|
);
|
||||||
@@ -905,6 +909,7 @@ namespace PlayerEvent {
|
|||||||
HandinMoney handin_money;
|
HandinMoney handin_money;
|
||||||
std::vector<HandinEntry> return_items;
|
std::vector<HandinEntry> return_items;
|
||||||
HandinMoney return_money;
|
HandinMoney return_money;
|
||||||
|
bool is_quest_handin;
|
||||||
|
|
||||||
// cereal
|
// cereal
|
||||||
template<class Archive>
|
template<class Archive>
|
||||||
@@ -916,7 +921,8 @@ namespace PlayerEvent {
|
|||||||
CEREAL_NVP(handin_items),
|
CEREAL_NVP(handin_items),
|
||||||
CEREAL_NVP(handin_money),
|
CEREAL_NVP(handin_money),
|
||||||
CEREAL_NVP(return_items),
|
CEREAL_NVP(return_items),
|
||||||
CEREAL_NVP(return_money)
|
CEREAL_NVP(return_money),
|
||||||
|
CEREAL_NVP(is_quest_handin)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,600 @@
|
|||||||
|
#include "mysql_stmt.h"
|
||||||
|
#include "eqemu_logsys.h"
|
||||||
|
#include "mutex.h"
|
||||||
|
#include "timer.h"
|
||||||
|
#include <charconv>
|
||||||
|
|
||||||
|
namespace mysql
|
||||||
|
{
|
||||||
|
|
||||||
|
void PreparedStmt::StmtDeleter::operator()(MYSQL_STMT* stmt) noexcept
|
||||||
|
{
|
||||||
|
// The connection must be locked when closing the stmt to avoid mysql errors
|
||||||
|
// in case another thread tries to use it during the close. If the mutex is
|
||||||
|
// changed to one that throws then exceptions need to be caught here.
|
||||||
|
LockMutex lock(mutex);
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedStmt::PreparedStmt(MYSQL& mysql, std::string query, Mutex* mutex, StmtOptions opts)
|
||||||
|
: m_stmt(mysql_stmt_init(&mysql), { mutex }), m_query(std::move(query)), m_mutex(mutex), m_options(opts)
|
||||||
|
{
|
||||||
|
LockMutex lock(m_mutex);
|
||||||
|
if (mysql_stmt_prepare(m_stmt.get(), m_query.c_str(), static_cast<unsigned long>(m_query.size())) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Prepare error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_params.resize(mysql_stmt_param_count(m_stmt.get()));
|
||||||
|
m_inputs.resize(m_params.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::ThrowError(const std::string& error)
|
||||||
|
{
|
||||||
|
LogMySQLError("{}", error);
|
||||||
|
throw std::runtime_error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PreparedStmt::GetStmtError()
|
||||||
|
{
|
||||||
|
auto err = mysql_stmt_errno(m_stmt.get());
|
||||||
|
auto str = mysql_stmt_error(m_stmt.get());
|
||||||
|
return fmt::format("({}) [{}] for query [{}]", err, str, m_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void PreparedStmt::BindInput(size_t index, T value)
|
||||||
|
{
|
||||||
|
if (index >= m_inputs.size())
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Cannot bind input, index {} out of range", index));
|
||||||
|
}
|
||||||
|
|
||||||
|
impl::Bind& arg = m_inputs[index];
|
||||||
|
arg.is_null = std::is_same_v<T, std::nullptr_t>;
|
||||||
|
|
||||||
|
MYSQL_BIND& bind = m_params[index];
|
||||||
|
bind.is_unsigned = std::is_unsigned_v<T>;
|
||||||
|
bind.is_null = &arg.is_null;
|
||||||
|
bind.length = &arg.length;
|
||||||
|
|
||||||
|
auto old_type = bind.buffer_type;
|
||||||
|
|
||||||
|
if constexpr (std::is_arithmetic_v<T>)
|
||||||
|
{
|
||||||
|
if (arg.buffer.size() < sizeof(T))
|
||||||
|
{
|
||||||
|
arg.buffer.resize(std::max(sizeof(T), sizeof(int64_t)));
|
||||||
|
bind.buffer = arg.buffer.data();
|
||||||
|
m_need_bind = true;
|
||||||
|
}
|
||||||
|
memcpy(arg.buffer.data(), &value, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (std::is_same_v<T, int8_t> || std::is_same_v<T, uint8_t> || std::is_same_v<T, bool>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_TINY;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, int16_t> || std::is_same_v<T, uint16_t>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_SHORT;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, int32_t> || std::is_same_v<T, uint32_t>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_LONG;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, int64_t> || std::is_same_v<T, uint64_t>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_LONGLONG;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, float>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_FLOAT;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, double>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_DOUBLE;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, std::string_view>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_STRING;
|
||||||
|
if (arg.buffer.empty() || arg.buffer.size() < value.size())
|
||||||
|
{
|
||||||
|
arg.buffer.resize(static_cast<size_t>((value.size() + 1) * 1.5));
|
||||||
|
bind.buffer = arg.buffer.data();
|
||||||
|
bind.buffer_length = static_cast<unsigned long>(arg.buffer.size());
|
||||||
|
m_need_bind = true;
|
||||||
|
}
|
||||||
|
std::copy(value.begin(), value.end(), arg.buffer.begin());
|
||||||
|
arg.length = static_cast<unsigned long>(value.size());
|
||||||
|
}
|
||||||
|
else if constexpr (!std::is_same_v<T, std::nullptr_t>)
|
||||||
|
{
|
||||||
|
static_assert(false_v<T>, "Cannot bind unsupported type");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old_type != bind.buffer_type)
|
||||||
|
{
|
||||||
|
m_need_bind = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::BindInput(size_t index, const char* str)
|
||||||
|
{
|
||||||
|
BindInput(index, std::string_view(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::BindInput(size_t index, const std::string& str)
|
||||||
|
{
|
||||||
|
BindInput(index, std::string_view(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtResult PreparedStmt::Execute()
|
||||||
|
{
|
||||||
|
CheckArgs(0);
|
||||||
|
return DoExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtResult PreparedStmt::Execute(const std::vector<param_t>& args)
|
||||||
|
{
|
||||||
|
CheckArgs(args.size());
|
||||||
|
for (size_t i = 0; i < args.size(); ++i)
|
||||||
|
{
|
||||||
|
std::visit([&](const auto& arg) { BindInput(i, arg); }, args[i]);
|
||||||
|
}
|
||||||
|
return DoExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
StmtResult PreparedStmt::Execute(const std::vector<T>& args)
|
||||||
|
{
|
||||||
|
CheckArgs(args.size());
|
||||||
|
for (size_t i = 0; i < args.size(); ++i)
|
||||||
|
{
|
||||||
|
BindInput(i, args[i]);
|
||||||
|
}
|
||||||
|
return DoExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::CheckArgs(size_t argc)
|
||||||
|
{
|
||||||
|
if (argc != m_params.size())
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Bad arg count (got {}, expected {}) for [{}]", argc, m_params.size(), m_query));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtResult PreparedStmt::DoExecute()
|
||||||
|
{
|
||||||
|
BenchTimer timer;
|
||||||
|
LockMutex lock(m_mutex);
|
||||||
|
|
||||||
|
if (m_need_bind && mysql_stmt_bind_param(m_stmt.get(), m_params.data()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Bind param error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_need_bind = false;
|
||||||
|
|
||||||
|
if (mysql_stmt_execute(m_stmt.get()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Execute error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
my_bool attr = m_options.use_max_length;
|
||||||
|
mysql_stmt_attr_set(m_stmt.get(), STMT_ATTR_UPDATE_MAX_LENGTH, &attr);
|
||||||
|
|
||||||
|
if (m_options.buffer_results && mysql_stmt_store_result(m_stmt.get()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Store result error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Result buffers are bound on first execute and re-used if needed
|
||||||
|
if (m_results.empty())
|
||||||
|
{
|
||||||
|
BindResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtResult res(m_stmt.get(), m_results.size());
|
||||||
|
|
||||||
|
if (m_results.empty())
|
||||||
|
{
|
||||||
|
LogMySQLQuery("{} -- ({} row(s) affected) ({:.6f}s)", m_query, res.RowsAffected(), timer.elapsed());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogMySQLQuery("{} -- ({} row(s) returned) ({:.6f}s)", m_query, res.RowCount(), timer.elapsed());
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::BindResults()
|
||||||
|
{
|
||||||
|
MYSQL_RES* res = mysql_stmt_result_metadata(m_stmt.get());
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
return; // did not produce a result set
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_FIELD* fields = mysql_fetch_fields(res);
|
||||||
|
m_columns.resize(mysql_num_fields(res));
|
||||||
|
m_results.resize(m_columns.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < static_cast<int>(m_columns.size()); ++i)
|
||||||
|
{
|
||||||
|
impl::BindColumn& col = m_columns[i].m_col;
|
||||||
|
MYSQL_BIND& bind = m_results[i];
|
||||||
|
|
||||||
|
col.index = i;
|
||||||
|
col.name = fields[i].name;
|
||||||
|
col.buffer_type = fields[i].type;
|
||||||
|
col.is_unsigned = (fields[i].flags & UNSIGNED_FLAG) != 0;
|
||||||
|
col.buffer.resize(GetResultBufferSize(fields[i]));
|
||||||
|
|
||||||
|
bind.buffer_type = col.buffer_type;
|
||||||
|
bind.buffer = col.buffer.data();
|
||||||
|
bind.buffer_length = static_cast<unsigned long>(col.buffer.size());
|
||||||
|
bind.is_unsigned = col.is_unsigned;
|
||||||
|
bind.is_null = &col.is_null;
|
||||||
|
bind.length = &col.length;
|
||||||
|
bind.error = &col.error;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_free_result(res);
|
||||||
|
|
||||||
|
if (!m_results.empty() && mysql_stmt_bind_result(m_stmt.get(), m_results.data()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Bind result error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int PreparedStmt::GetResultBufferSize(const MYSQL_FIELD& field) const
|
||||||
|
{
|
||||||
|
switch (field.type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
return sizeof(int8_t);
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
return sizeof(int16_t);
|
||||||
|
case MYSQL_TYPE_INT24:
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
return sizeof(int32_t);
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
return sizeof(int64_t);
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
return sizeof(float);
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
return sizeof(double);
|
||||||
|
case MYSQL_TYPE_TIME:
|
||||||
|
case MYSQL_TYPE_DATE:
|
||||||
|
case MYSQL_TYPE_DATETIME:
|
||||||
|
case MYSQL_TYPE_TIMESTAMP:
|
||||||
|
return sizeof(MYSQL_TIME);
|
||||||
|
default: // if max_length is unavailable for strings buffers are resized on fetch
|
||||||
|
return field.max_length + 1; // ensure valid buffer created
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtRow PreparedStmt::Fetch()
|
||||||
|
{
|
||||||
|
StmtRow row;
|
||||||
|
if (!m_columns.empty())
|
||||||
|
{
|
||||||
|
int rc = mysql_stmt_fetch(m_stmt.get());
|
||||||
|
if (rc == 1)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Fetch error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc != MYSQL_NO_DATA)
|
||||||
|
{
|
||||||
|
if (rc == MYSQL_DATA_TRUNCATED)
|
||||||
|
{
|
||||||
|
FetchTruncated();
|
||||||
|
}
|
||||||
|
row = StmtRow(m_columns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::FetchTruncated()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < static_cast<int>(m_columns.size()); ++i)
|
||||||
|
{
|
||||||
|
impl::BindColumn& col = m_columns[i].m_col;
|
||||||
|
if (col.error)
|
||||||
|
{
|
||||||
|
MYSQL_BIND& bind = m_results[i];
|
||||||
|
col.buffer.resize(static_cast<size_t>(col.length * 1.5));
|
||||||
|
bind.buffer = col.buffer.data();
|
||||||
|
bind.buffer_length = static_cast<unsigned long>(col.buffer.size());
|
||||||
|
|
||||||
|
mysql_stmt_fetch_column(m_stmt.get(), &bind, i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mysql_stmt_bind_result(m_stmt.get(), m_results.data()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Fetch rebind result error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
StmtResult::StmtResult(MYSQL_STMT* stmt, size_t columns)
|
||||||
|
{
|
||||||
|
m_num_cols = static_cast<int>(columns);
|
||||||
|
m_num_rows = mysql_stmt_num_rows(stmt); // requires buffered results
|
||||||
|
m_affected = mysql_stmt_affected_rows(stmt);
|
||||||
|
m_insert_id = mysql_stmt_insert_id(stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const StmtColumn* StmtRow::GetColumn(size_t index) const
|
||||||
|
{
|
||||||
|
return index < m_columns.size() ? &m_columns[index] : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StmtColumn* StmtRow::GetColumn(std::string_view name) const
|
||||||
|
{
|
||||||
|
auto it = std::ranges::find_if(m_columns,
|
||||||
|
[name](const StmtColumn& col) { return col.Name() == name; });
|
||||||
|
|
||||||
|
return it != m_columns.end() ? &(*it) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtRow::operator[](size_t index) const
|
||||||
|
{
|
||||||
|
return GetStr(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtRow::operator[](std::string_view name) const
|
||||||
|
{
|
||||||
|
return GetStr(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtRow::GetStr(size_t index) const
|
||||||
|
{
|
||||||
|
const StmtColumn* col = GetColumn(index);
|
||||||
|
return col ? col->GetStr() : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtRow::GetStr(std::string_view name) const
|
||||||
|
{
|
||||||
|
const StmtColumn* col = GetColumn(name);
|
||||||
|
return col ? col->GetStr() : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> StmtRow::Get(size_t index) const
|
||||||
|
{
|
||||||
|
const StmtColumn* col = GetColumn(index);
|
||||||
|
return col ? col->Get<T>() : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> StmtRow::Get(std::string_view name) const
|
||||||
|
{
|
||||||
|
const StmtColumn* col = GetColumn(name);
|
||||||
|
return col ? col->Get<T>() : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static time_t MakeTime(const MYSQL_TIME& mt)
|
||||||
|
{
|
||||||
|
// buffer mt given in mysql session time zone (assumes local)
|
||||||
|
std::tm tm{};
|
||||||
|
tm.tm_year = mt.year - 1900;
|
||||||
|
tm.tm_mon = mt.month - 1;
|
||||||
|
tm.tm_mday = mt.day;
|
||||||
|
tm.tm_hour = mt.hour;
|
||||||
|
tm.tm_min = mt.minute;
|
||||||
|
tm.tm_sec = mt.second;
|
||||||
|
tm.tm_isdst = -1;
|
||||||
|
return std::mktime(&tm);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int MakeSeconds(const MYSQL_TIME& mt)
|
||||||
|
{
|
||||||
|
return (mt.neg ? -1 : 1) * static_cast<int>(mt.hour * 3600 + mt.minute * 60 + mt.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t MakeBits(std::span<const uint8_t> data)
|
||||||
|
{
|
||||||
|
// byte stream for bits is in big endian
|
||||||
|
uint64_t bits = 0;
|
||||||
|
for (size_t i = 0; i < data.size() && i < sizeof(uint64_t); ++i)
|
||||||
|
{
|
||||||
|
bits |= static_cast<uint64_t>(data[data.size() - i - 1] & 0xff) << (i * 8);
|
||||||
|
}
|
||||||
|
return bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept has_from_chars = requires (const char* first, const char* last, T value)
|
||||||
|
{
|
||||||
|
std::from_chars(first, last, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static T FromString(std::string_view sv)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_same_v<T, bool>)
|
||||||
|
{
|
||||||
|
// return false for empty (zero-length) strings
|
||||||
|
return !sv.empty();
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, float> && !has_from_chars<T>)
|
||||||
|
{
|
||||||
|
return std::strtof(std::string(sv).c_str(), nullptr);
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, double> && !has_from_chars<T>)
|
||||||
|
{
|
||||||
|
return std::strtod(std::string(sv).c_str(), nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// non numbers return a zero initialized T (could return nullopt instead)
|
||||||
|
T value = {};
|
||||||
|
std::from_chars(sv.data(), sv.data() + sv.size(), value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string FormatTime(enum_field_types type, const MYSQL_TIME& mt)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TIME: // hhh:mm:ss '-838:59:59' to '838:59:59'
|
||||||
|
return fmt::format("{}{:02d}:{:02d}:{:02d}", mt.neg ? "-" : "", mt.hour, mt.minute, mt.second);
|
||||||
|
case MYSQL_TYPE_DATE: // YYYY-MM-DD '1000-01-01' to '9999-12-31'
|
||||||
|
return fmt::format("{}-{:02d}-{:02d}", mt.year, mt.month, mt.day);
|
||||||
|
case MYSQL_TYPE_DATETIME: // YYYY-MM-DD hh:mm:ss '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
|
||||||
|
case MYSQL_TYPE_TIMESTAMP: // YYYY-MM-DD hh:mm:ss '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
|
||||||
|
return fmt::format("{}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}", mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second);
|
||||||
|
default:
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string_view> StmtColumn::GetStrView() const
|
||||||
|
{
|
||||||
|
if (m_col.is_null)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_col.buffer_type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
|
case MYSQL_TYPE_TINY_BLOB:
|
||||||
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||||
|
case MYSQL_TYPE_LONG_BLOB:
|
||||||
|
case MYSQL_TYPE_BLOB:
|
||||||
|
case MYSQL_TYPE_VAR_STRING:
|
||||||
|
case MYSQL_TYPE_STRING:
|
||||||
|
return std::make_optional<std::string_view>(reinterpret_cast<const char*>(m_col.buffer.data()), m_col.length);
|
||||||
|
default:
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtColumn::GetStr() const
|
||||||
|
{
|
||||||
|
if (m_col.is_null)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_col.buffer_type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
return m_col.is_unsigned ? fmt::format_int(BitCast<uint8_t>()).c_str() : fmt::format_int(BitCast<int8_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
return m_col.is_unsigned ? fmt::format_int(BitCast<uint16_t>()).c_str() : fmt::format_int(BitCast<int16_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_INT24:
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
return m_col.is_unsigned ? fmt::format_int(BitCast<uint32_t>()).c_str() : fmt::format_int(BitCast<int32_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
return m_col.is_unsigned ? fmt::format_int(BitCast<uint64_t>()).c_str() : fmt::format_int(BitCast<int64_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
return fmt::format("{}", BitCast<float>());
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
return fmt::format("{}", BitCast<double>());
|
||||||
|
case MYSQL_TYPE_TIME:
|
||||||
|
case MYSQL_TYPE_DATE:
|
||||||
|
case MYSQL_TYPE_DATETIME:
|
||||||
|
case MYSQL_TYPE_TIMESTAMP:
|
||||||
|
return FormatTime(m_col.buffer_type, BitCast<MYSQL_TIME>());
|
||||||
|
case MYSQL_TYPE_BIT:
|
||||||
|
return fmt::format_int(*Get<uint64_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
|
case MYSQL_TYPE_TINY_BLOB:
|
||||||
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||||
|
case MYSQL_TYPE_LONG_BLOB:
|
||||||
|
case MYSQL_TYPE_BLOB:
|
||||||
|
case MYSQL_TYPE_VAR_STRING:
|
||||||
|
case MYSQL_TYPE_STRING:
|
||||||
|
return std::make_optional<std::string>(reinterpret_cast<const char*>(m_col.buffer.data()), m_col.length);
|
||||||
|
default:
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> StmtColumn::Get() const
|
||||||
|
{
|
||||||
|
if (m_col.is_null)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_col.buffer_type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
return m_col.is_unsigned ? static_cast<T>(BitCast<uint8_t>()) : static_cast<T>(BitCast<int8_t>());
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
return m_col.is_unsigned ? static_cast<T>(BitCast<uint16_t>()) : static_cast<T>(BitCast<int16_t>());
|
||||||
|
case MYSQL_TYPE_INT24:
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
return m_col.is_unsigned ? static_cast<T>(BitCast<uint32_t>()) : static_cast<T>(BitCast<int32_t>());
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
return m_col.is_unsigned ? static_cast<T>(BitCast<uint64_t>()) : static_cast<T>(BitCast<int64_t>());
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
return static_cast<T>(BitCast<float>());
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
return static_cast<T>(BitCast<double>());
|
||||||
|
case MYSQL_TYPE_TIME: // return as total seconds
|
||||||
|
return static_cast<T>(MakeSeconds(BitCast<MYSQL_TIME>()));
|
||||||
|
case MYSQL_TYPE_DATE:
|
||||||
|
case MYSQL_TYPE_DATETIME:
|
||||||
|
case MYSQL_TYPE_TIMESTAMP: // return as epoch timestamp
|
||||||
|
return static_cast<T>(MakeTime(BitCast<MYSQL_TIME>()));
|
||||||
|
case MYSQL_TYPE_BIT:
|
||||||
|
return static_cast<T>(MakeBits({ m_col.buffer.data(), m_col.length }));
|
||||||
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
|
case MYSQL_TYPE_TINY_BLOB:
|
||||||
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||||
|
case MYSQL_TYPE_LONG_BLOB:
|
||||||
|
case MYSQL_TYPE_BLOB:
|
||||||
|
case MYSQL_TYPE_VAR_STRING:
|
||||||
|
case MYSQL_TYPE_STRING:
|
||||||
|
return FromString<T>({ reinterpret_cast<const char*>(m_col.buffer.data()), m_col.length });
|
||||||
|
default:
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// explicit template instantiations for supported types
|
||||||
|
template void PreparedStmt::BindInput(size_t, std::string_view);
|
||||||
|
template void PreparedStmt::BindInput(size_t, std::nullptr_t);
|
||||||
|
template StmtResult PreparedStmt::Execute(const std::vector<std::string_view>&);
|
||||||
|
template StmtResult PreparedStmt::Execute(const std::vector<std::string>&);
|
||||||
|
template StmtResult PreparedStmt::Execute(const std::vector<const char*>&);
|
||||||
|
|
||||||
|
#define INSTANTIATE(T) \
|
||||||
|
template void PreparedStmt::BindInput(size_t, T); \
|
||||||
|
template StmtResult PreparedStmt::Execute(const std::vector<T>&); \
|
||||||
|
template std::optional<T> StmtRow::Get(size_t) const; \
|
||||||
|
template std::optional<T> StmtRow::Get(std::string_view) const; \
|
||||||
|
template std::optional<T> StmtColumn::Get() const;
|
||||||
|
|
||||||
|
INSTANTIATE(bool);
|
||||||
|
INSTANTIATE(int8_t);
|
||||||
|
INSTANTIATE(uint8_t);
|
||||||
|
INSTANTIATE(int16_t);
|
||||||
|
INSTANTIATE(uint16_t);
|
||||||
|
INSTANTIATE(int32_t);
|
||||||
|
INSTANTIATE(uint32_t);
|
||||||
|
INSTANTIATE(int64_t);
|
||||||
|
INSTANTIATE(uint64_t);
|
||||||
|
INSTANTIATE(float);
|
||||||
|
INSTANTIATE(double);
|
||||||
|
|
||||||
|
} // namespace mysql
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "mysql.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <span>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class Mutex;
|
||||||
|
|
||||||
|
namespace mysql
|
||||||
|
{
|
||||||
|
|
||||||
|
// support MySQL 8.0.1+ API which removed the my_bool type
|
||||||
|
#if !defined(MARIADB_VERSION_ID) && MYSQL_VERSION_ID >= 80001
|
||||||
|
using my_bool = bool;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename>
|
||||||
|
inline constexpr bool false_v = false;
|
||||||
|
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Bind
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> buffer;
|
||||||
|
unsigned long length = 0;
|
||||||
|
my_bool is_null = false;
|
||||||
|
my_bool error = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BindColumn : Bind
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
std::string name;
|
||||||
|
bool is_unsigned = false;
|
||||||
|
enum_field_types buffer_type = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct StmtOptions
|
||||||
|
{
|
||||||
|
// Enable buffering (storing) entire result set after executing a statement
|
||||||
|
bool buffer_results = true;
|
||||||
|
|
||||||
|
// Enable MySQL to update max_length of fields in execute result set (requires buffering)
|
||||||
|
bool use_max_length = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Holds ownership of bound column value buffer
|
||||||
|
class StmtColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int Index() const { return m_col.index; }
|
||||||
|
bool IsNull() const { return m_col.is_null; }
|
||||||
|
bool IsUnsigned() const { return m_col.is_unsigned; }
|
||||||
|
enum_field_types Type() const { return m_col.buffer_type; }
|
||||||
|
const std::string& Name() const { return m_col.name; }
|
||||||
|
|
||||||
|
// Get view of column value buffer
|
||||||
|
std::span<const uint8_t> GetBuf() const { return { m_col.buffer.data(), m_col.length }; }
|
||||||
|
|
||||||
|
// Get view of column string value. Returns nullopt if value is NULL or not a string
|
||||||
|
std::optional<std::string_view> GetStrView() const;
|
||||||
|
|
||||||
|
// Get column value as string. Returns nullopt if value is NULL or field type unsupported
|
||||||
|
std::optional<std::string> GetStr() const;
|
||||||
|
|
||||||
|
// Get column value as numeric T. Returns nullopt if value NULL or field type unsupported
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> Get() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// uses memcpy for type punning buffer data to avoid UB with strict aliasing
|
||||||
|
template <typename T>
|
||||||
|
T BitCast() const
|
||||||
|
{
|
||||||
|
T val;
|
||||||
|
assert(sizeof(T) == m_col.length);
|
||||||
|
memcpy(&val, m_col.buffer.data(), sizeof(T));
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend class PreparedStmt; // access to allocate and bind buffers
|
||||||
|
friend class StmtResult; // access to resize truncated buffers
|
||||||
|
impl::BindColumn m_col;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Provides a non-owning view of PreparedStmt column value buffers
|
||||||
|
// Evaluates false if it does not contain a valid row
|
||||||
|
class StmtRow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StmtRow() = default;
|
||||||
|
StmtRow(std::span<const StmtColumn> columns) : m_columns(columns) {};
|
||||||
|
|
||||||
|
explicit operator bool() const noexcept { return !m_columns.empty(); }
|
||||||
|
|
||||||
|
int ColumnCount() const { return static_cast<int>(m_columns.size()); }
|
||||||
|
const StmtColumn* GetColumn(size_t index) const;
|
||||||
|
const StmtColumn* GetColumn(std::string_view name) const;
|
||||||
|
|
||||||
|
// Get specified column value as string
|
||||||
|
// Returns nullopt if column invalid, value is NULL, or field type unsupported
|
||||||
|
std::optional<std::string> operator[](size_t index) const;
|
||||||
|
std::optional<std::string> operator[](std::string_view name) const;
|
||||||
|
std::optional<std::string> GetStr(size_t index) const;
|
||||||
|
std::optional<std::string> GetStr(std::string_view name) const;
|
||||||
|
|
||||||
|
// Get specified column value as numeric T
|
||||||
|
// Returns nullopt if column invalid, value is NULL, or field type unsupported
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> Get(size_t index) const;
|
||||||
|
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> Get(std::string_view name) const;
|
||||||
|
|
||||||
|
auto begin() const { return m_columns.begin(); }
|
||||||
|
auto end() const { return m_columns.end(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::span<const StmtColumn> m_columns;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Result meta data for an executed prepared statement
|
||||||
|
class StmtResult
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StmtResult() = default;
|
||||||
|
StmtResult(MYSQL_STMT* stmt, size_t columns);
|
||||||
|
|
||||||
|
int ColumnCount() const { return m_num_cols; }
|
||||||
|
uint64_t RowCount() const { return m_num_rows; }
|
||||||
|
uint64_t RowsAffected() const { return m_affected; }
|
||||||
|
uint64_t LastInsertID() const { return m_insert_id; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_num_cols = 0;
|
||||||
|
uint64_t m_num_rows = 0;
|
||||||
|
uint64_t m_affected = 0;
|
||||||
|
uint64_t m_insert_id = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class PreparedStmt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Supported argument types for execute
|
||||||
|
using param_t = std::variant<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
|
||||||
|
int64_t, uint64_t, float, double, bool, std::string_view, std::nullptr_t>;
|
||||||
|
|
||||||
|
PreparedStmt() = delete;
|
||||||
|
PreparedStmt(MYSQL& mysql, std::string query, Mutex* mutex, StmtOptions opts = {});
|
||||||
|
|
||||||
|
const std::string& GetQuery() const { return m_query; }
|
||||||
|
StmtOptions GetOptions() const { return m_options; }
|
||||||
|
void SetOptions(StmtOptions options) { m_options = options; }
|
||||||
|
void FreeResult() { mysql_stmt_free_result(m_stmt.get()); }
|
||||||
|
|
||||||
|
// Execute the prepared statement with specified arguments
|
||||||
|
// Throws exception on error
|
||||||
|
template <typename T>
|
||||||
|
StmtResult Execute(const std::vector<T>& args);
|
||||||
|
StmtResult Execute(const std::vector<param_t>& args);
|
||||||
|
StmtResult Execute();
|
||||||
|
|
||||||
|
// Fetch the next row into column buffers (overwrites previous row values)
|
||||||
|
// Return value evaluates false if no more rows to fetch
|
||||||
|
// Throws exception on error
|
||||||
|
StmtRow Fetch();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CheckArgs(size_t argc);
|
||||||
|
StmtResult DoExecute();
|
||||||
|
void BindResults();
|
||||||
|
void FetchTruncated();
|
||||||
|
int GetResultBufferSize(const MYSQL_FIELD& field) const;
|
||||||
|
void ThrowError(const std::string& error);
|
||||||
|
std::string GetStmtError();
|
||||||
|
|
||||||
|
// bind an input value to a query parameter by index
|
||||||
|
template <typename T>
|
||||||
|
void BindInput(size_t index, T value);
|
||||||
|
void BindInput(size_t index, const char* str);
|
||||||
|
void BindInput(size_t index, const std::string& str);
|
||||||
|
|
||||||
|
struct StmtDeleter
|
||||||
|
{
|
||||||
|
Mutex* mutex = nullptr;
|
||||||
|
void operator()(MYSQL_STMT* stmt) noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<MYSQL_STMT, StmtDeleter> m_stmt;
|
||||||
|
std::vector<MYSQL_BIND> m_params; // input binds
|
||||||
|
std::vector<MYSQL_BIND> m_results; // result binds
|
||||||
|
std::vector<impl::Bind> m_inputs; // execute buffers (addresses bound)
|
||||||
|
std::vector<StmtColumn> m_columns; // fetch buffers (addresses bound)
|
||||||
|
std::string m_query;
|
||||||
|
StmtOptions m_options = {};
|
||||||
|
bool m_need_bind = true;
|
||||||
|
Mutex* m_mutex = nullptr; // connection mutex
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mysql
|
||||||
@@ -2288,13 +2288,13 @@ namespace RoF
|
|||||||
outapp->WriteSInt32(345); // Mana Total ?
|
outapp->WriteSInt32(345); // Mana Total ?
|
||||||
|
|
||||||
// these are needed to fix display bugs
|
// these are needed to fix display bugs
|
||||||
outapp->WriteUInt32(emu->cold_resist); // base CR
|
outapp->WriteUInt32(0x19); // base CR
|
||||||
outapp->WriteUInt32(emu->fire_resist); // base FR
|
outapp->WriteUInt32(0x19); // base FR
|
||||||
outapp->WriteUInt32(emu->magic_resist); // base MR
|
outapp->WriteUInt32(0x19); // base MR
|
||||||
outapp->WriteUInt32(emu->disease_resist); // base DR
|
outapp->WriteUInt32(0xf); // base DR
|
||||||
outapp->WriteUInt32(emu->poison_resist); // base PR
|
outapp->WriteUInt32(0xf); // base PR
|
||||||
outapp->WriteUInt32(0xf); // base PhR?
|
outapp->WriteUInt32(0xf); // base PhR?
|
||||||
outapp->WriteUInt32(emu->corruption_resist); // base Corrup
|
outapp->WriteUInt32(0xf); // base Corrup
|
||||||
outapp->WriteUInt32(0); // Unknown
|
outapp->WriteUInt32(0); // Unknown
|
||||||
outapp->WriteUInt32(0); // Unknown
|
outapp->WriteUInt32(0); // Unknown
|
||||||
outapp->WriteUInt32(0); // Unknown
|
outapp->WriteUInt32(0); // Unknown
|
||||||
|
|||||||
@@ -2806,13 +2806,13 @@ namespace RoF2
|
|||||||
outapp->WriteSInt32(345); // Mana Total ?
|
outapp->WriteSInt32(345); // Mana Total ?
|
||||||
|
|
||||||
// these are needed to fix display bugs
|
// these are needed to fix display bugs
|
||||||
outapp->WriteUInt32(emu->cold_resist); // base CR
|
outapp->WriteUInt32(0x19); // base CR
|
||||||
outapp->WriteUInt32(emu->fire_resist); // base FR
|
outapp->WriteUInt32(0x19); // base FR
|
||||||
outapp->WriteUInt32(emu->magic_resist); // base MR
|
outapp->WriteUInt32(0x19); // base MR
|
||||||
outapp->WriteUInt32(emu->disease_resist); // base DR
|
outapp->WriteUInt32(0xf); // base DR
|
||||||
outapp->WriteUInt32(emu->poison_resist); // base PR
|
outapp->WriteUInt32(0xf); // base PR
|
||||||
outapp->WriteUInt32(0xf); // base PhR?
|
outapp->WriteUInt32(0xf); // base PhR?
|
||||||
outapp->WriteUInt32(emu->corruption_resist); // base Corrup
|
outapp->WriteUInt32(0xf); // base Corrup
|
||||||
outapp->WriteUInt32(0); // Unknown
|
outapp->WriteUInt32(0); // Unknown
|
||||||
outapp->WriteUInt32(0); // Unknown
|
outapp->WriteUInt32(0); // Unknown
|
||||||
outapp->WriteUInt32(0); // Unknown
|
outapp->WriteUInt32(0); // Unknown
|
||||||
|
|||||||
+7
-19
@@ -1669,27 +1669,15 @@ namespace SoD
|
|||||||
// OUT(unknown19584[4]);
|
// OUT(unknown19584[4]);
|
||||||
// OUT(unknown19588);
|
// OUT(unknown19588);
|
||||||
|
|
||||||
const uint8 unknown12864_bytes[] = {
|
const uint8 bytes[] = {
|
||||||
0xa3, 0x02, 0x00, 0x00, 0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0xa3, 0x02, 0x00, 0x00, 0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00,
|
||||||
|
0x19, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00,
|
||||||
|
0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1F, 0x85, 0xEB, 0x3E, 0x33, 0x33, 0x33, 0x3F,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
memcpy(eq->unknown12864, unknown12864_bytes, sizeof(unknown12864_bytes));
|
memcpy(eq->unknown12864, bytes, sizeof(bytes));
|
||||||
|
|
||||||
eq->cold_resist = emu->cold_resist;
|
|
||||||
eq->fire_resist = emu->fire_resist;
|
|
||||||
eq->magic_resist = emu->magic_resist;
|
|
||||||
eq->disease_resist = emu->disease_resist;
|
|
||||||
eq->poison_resist = emu->poison_resist;
|
|
||||||
eq->physical_resist = 15;
|
|
||||||
eq->corruption_resist = emu->corruption_resist;
|
|
||||||
|
|
||||||
const uint8 unknown15112_bytes[] = {
|
|
||||||
0x1F, 0x85, 0xEB, 0x3E, 0x33, 0x33, 0x33, 0x3F, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
memcpy(eq->unknown15112, unknown15112_bytes, sizeof(unknown15112_bytes));
|
|
||||||
|
|
||||||
//set the checksum...
|
//set the checksum...
|
||||||
CRC32::SetEQChecksum(__packet->pBuffer, sizeof(structs::PlayerProfile_Struct) - 4);
|
CRC32::SetEQChecksum(__packet->pBuffer, sizeof(structs::PlayerProfile_Struct) - 4);
|
||||||
|
|||||||
@@ -944,15 +944,7 @@ struct PlayerProfile_Struct
|
|||||||
/*14700*/ PotionBelt_Struct potionbelt; // [360] potion belt 72 extra octets by adding 1 more belt slot
|
/*14700*/ PotionBelt_Struct potionbelt; // [360] potion belt 72 extra octets by adding 1 more belt slot
|
||||||
/*15060*/ uint8 unknown12852[8];
|
/*15060*/ uint8 unknown12852[8];
|
||||||
/*15068*/ uint32 available_slots;
|
/*15068*/ uint32 available_slots;
|
||||||
/*15072*/ uint8 unknown12864[12]; //#### uint8 uint8 unknown12864[76]; in Titanium ####[80]
|
/*15072*/ uint8 unknown12864[80]; //#### uint8 uint8 unknown12864[76]; in Titanium ####[80]
|
||||||
/*15084*/ uint32 cold_resist;
|
|
||||||
/*15088*/ uint32 fire_resist;
|
|
||||||
/*15092*/ uint32 magic_resist;
|
|
||||||
/*15096*/ uint32 disease_resist;
|
|
||||||
/*15100*/ uint32 poison_resist;
|
|
||||||
/*15104*/ uint32 physical_resist;
|
|
||||||
/*15108*/ uint32 corruption_resist;
|
|
||||||
/*15112*/ uint8 unknown15112[40];
|
|
||||||
//END SUB-STRUCT used for shrouding.
|
//END SUB-STRUCT used for shrouding.
|
||||||
/*15152*/ char name[64]; // Name of player
|
/*15152*/ char name[64]; // Name of player
|
||||||
/*15216*/ char last_name[32]; // Last name of player
|
/*15216*/ char last_name[32]; // Last name of player
|
||||||
|
|||||||
+7
-19
@@ -1339,27 +1339,15 @@ namespace SoF
|
|||||||
// OUT(unknown19584[4]);
|
// OUT(unknown19584[4]);
|
||||||
// OUT(unknown19588);
|
// OUT(unknown19588);
|
||||||
|
|
||||||
const uint8 unknown12864_bytes[] = {
|
const uint8 bytes[] = {
|
||||||
0xa3, 0x02, 0x00, 0x00, 0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0xa3, 0x02, 0x00, 0x00, 0x95, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00,
|
||||||
|
0x19, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00,
|
||||||
|
0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x1F, 0x85, 0xEB, 0x3E, 0x33, 0x33, 0x33, 0x3F,
|
||||||
|
0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
memcpy(eq->unknown12864, unknown12864_bytes, sizeof(unknown12864_bytes));
|
memcpy(eq->unknown12864, bytes, sizeof(bytes));
|
||||||
|
|
||||||
eq->cold_resist = emu->cold_resist;
|
|
||||||
eq->fire_resist = emu->fire_resist;
|
|
||||||
eq->magic_resist = emu->magic_resist;
|
|
||||||
eq->disease_resist = emu->disease_resist;
|
|
||||||
eq->poison_resist = emu->poison_resist;
|
|
||||||
eq->physical_resist = 15;
|
|
||||||
eq->corruption_resist = emu->corruption_resist;
|
|
||||||
|
|
||||||
const uint8 unknown15112_bytes[] = {
|
|
||||||
0x1F, 0x85, 0xEB, 0x3E, 0x33, 0x33, 0x33, 0x3F, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
memcpy(eq->unknown15112, unknown15112_bytes, sizeof(unknown15112_bytes));
|
|
||||||
|
|
||||||
//set the checksum...
|
//set the checksum...
|
||||||
CRC32::SetEQChecksum(__packet->pBuffer, sizeof(structs::PlayerProfile_Struct) - 4);
|
CRC32::SetEQChecksum(__packet->pBuffer, sizeof(structs::PlayerProfile_Struct) - 4);
|
||||||
|
|||||||
@@ -944,16 +944,7 @@ struct PlayerProfile_Struct //23576 Octets
|
|||||||
/*14700*/ PotionBelt_Struct potionbelt; // [360] potion belt 72 extra octets by adding 1 more belt slot
|
/*14700*/ PotionBelt_Struct potionbelt; // [360] potion belt 72 extra octets by adding 1 more belt slot
|
||||||
/*15060*/ uint8 unknown12852[8];
|
/*15060*/ uint8 unknown12852[8];
|
||||||
/*15068*/ uint32 available_slots;
|
/*15068*/ uint32 available_slots;
|
||||||
/*15072*/ uint8 unknown12864[12]; //#### uint8 uint8 unknown12864[76]; in Titanium ####[80]
|
/*15072*/ uint8 unknown12864[80]; //#### uint8 uint8 unknown12864[76]; in Titanium ####[80]
|
||||||
/*15084*/ uint32 cold_resist;
|
|
||||||
/*15088*/ uint32 fire_resist;
|
|
||||||
/*15092*/ uint32 magic_resist;
|
|
||||||
/*15096*/ uint32 disease_resist;
|
|
||||||
/*15100*/ uint32 poison_resist;
|
|
||||||
/*15104*/ uint32 physical_resist;
|
|
||||||
/*15108*/ uint32 corruption_resist;
|
|
||||||
/*15112*/ uint8 unknown15112[40];
|
|
||||||
|
|
||||||
//END SUB-STRUCT used for shrouding.
|
//END SUB-STRUCT used for shrouding.
|
||||||
/*15120*/ char name[64]; // Name of player
|
/*15120*/ char name[64]; // Name of player
|
||||||
/*15184*/ char last_name[32]; // Last name of player
|
/*15184*/ char last_name[32]; // Last name of player
|
||||||
|
|||||||
@@ -1600,25 +1600,14 @@ namespace Titanium
|
|||||||
// OUT(unknown19584[4]);
|
// OUT(unknown19584[4]);
|
||||||
// OUT(unknown19588);
|
// OUT(unknown19588);
|
||||||
|
|
||||||
const uint8 unknown12864_bytes[] = {
|
|
||||||
0x78, 0x03, 0x00, 0x00, 0x1A, 0x04, 0x00, 0x00, 0x1A, 0x04, 0x00, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
memcpy(eq->unknown12864, unknown12864_bytes, sizeof(unknown12864_bytes));
|
const uint8 bytes[] = {
|
||||||
|
0x78, 0x03, 0x00, 0x00, 0x1A, 0x04, 0x00, 0x00, 0x1A, 0x04, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00,
|
||||||
eq->cold_resist = emu->cold_resist;
|
0x19, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00,
|
||||||
eq->fire_resist = emu->fire_resist;
|
0x0F, 0x00, 0x00, 0x00, 0x1F, 0x85, 0xEB, 0x3E, 0x33, 0x33, 0x33, 0x3F, 0x09, 0x00, 0x00, 0x00,
|
||||||
eq->magic_resist = emu->magic_resist;
|
|
||||||
eq->disease_resist = emu->disease_resist;
|
|
||||||
eq->poison_resist = emu->poison_resist;
|
|
||||||
eq->physical_resist = 15;
|
|
||||||
|
|
||||||
const uint8 unknown12900_bytes[] = {
|
|
||||||
0x1F, 0x85, 0xEB, 0x3E, 0x33, 0x33, 0x33, 0x3F, 0x09, 0x00, 0x00, 0x00,
|
|
||||||
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14
|
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14
|
||||||
};
|
};
|
||||||
|
memcpy(eq->unknown12864, bytes, sizeof(bytes));
|
||||||
memcpy(eq->unknown12900, unknown12900_bytes, sizeof(unknown12900_bytes));
|
|
||||||
|
|
||||||
//set the checksum...
|
//set the checksum...
|
||||||
CRC32::SetEQChecksum(__packet->pBuffer, sizeof(structs::PlayerProfile_Struct) - 4);
|
CRC32::SetEQChecksum(__packet->pBuffer, sizeof(structs::PlayerProfile_Struct) - 4);
|
||||||
|
|||||||
@@ -879,14 +879,7 @@ struct PlayerProfile_Struct
|
|||||||
/*12564*/ PotionBelt_Struct potionbelt; // potion belt
|
/*12564*/ PotionBelt_Struct potionbelt; // potion belt
|
||||||
/*12852*/ uint8 unknown12852[8];
|
/*12852*/ uint8 unknown12852[8];
|
||||||
/*12860*/ uint32 available_slots;
|
/*12860*/ uint32 available_slots;
|
||||||
/*12864*/ uint8 unknown12864[12];
|
/*12864*/ uint8 unknown12864[76];
|
||||||
/*12876*/ uint32 cold_resist;
|
|
||||||
/*12880*/ uint32 fire_resist;
|
|
||||||
/*12884*/ uint32 magic_resist;
|
|
||||||
/*12888*/ uint32 disease_resist;
|
|
||||||
/*12892*/ uint32 poison_resist;
|
|
||||||
/*12896*/ uint32 physical_resist;
|
|
||||||
/*12900*/ uint8 unknown12900[40];
|
|
||||||
/*12940*/ char name[64]; // Name of player
|
/*12940*/ char name[64]; // Name of player
|
||||||
/*13004*/ char last_name[32]; // Last name of player
|
/*13004*/ char last_name[32]; // Last name of player
|
||||||
/*13036*/ uint32 guild_id; // guildid
|
/*13036*/ uint32 guild_id; // guildid
|
||||||
|
|||||||
@@ -74,6 +74,11 @@ void PathManager::LoadPaths()
|
|||||||
m_patch_path = fs::relative(fs::path{m_server_path + "/" + c->PatchDir}).string();
|
m_patch_path = fs::relative(fs::path{m_server_path + "/" + c->PatchDir}).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// patches
|
||||||
|
if (File::Exists(fs::path{ m_server_path + "/" + c->OpcodeDir }.string())) {
|
||||||
|
m_opcode_path = fs::relative(fs::path{ m_server_path + "/" + c->OpcodeDir }).string();
|
||||||
|
}
|
||||||
|
|
||||||
// shared_memory_path
|
// shared_memory_path
|
||||||
if (File::Exists(fs::path{m_server_path + "/" + c->SharedMemDir}.string())) {
|
if (File::Exists(fs::path{m_server_path + "/" + c->SharedMemDir}.string())) {
|
||||||
m_shared_memory_path = fs::relative(fs::path{ m_server_path + "/" + c->SharedMemDir }).string();
|
m_shared_memory_path = fs::relative(fs::path{ m_server_path + "/" + c->SharedMemDir }).string();
|
||||||
@@ -89,6 +94,7 @@ void PathManager::LoadPaths()
|
|||||||
LogInfo("lua_modules path [{}]", m_lua_modules_path);
|
LogInfo("lua_modules path [{}]", m_lua_modules_path);
|
||||||
LogInfo("maps path [{}]", m_maps_path);
|
LogInfo("maps path [{}]", m_maps_path);
|
||||||
LogInfo("patches path [{}]", m_patch_path);
|
LogInfo("patches path [{}]", m_patch_path);
|
||||||
|
LogInfo("opcode path [{}]", m_opcode_path);
|
||||||
LogInfo("plugins path [{}]", m_plugins_path);
|
LogInfo("plugins path [{}]", m_plugins_path);
|
||||||
LogInfo("quests path [{}]", m_quests_path);
|
LogInfo("quests path [{}]", m_quests_path);
|
||||||
LogInfo("shared_memory path [{}]", m_shared_memory_path);
|
LogInfo("shared_memory path [{}]", m_shared_memory_path);
|
||||||
@@ -129,6 +135,11 @@ const std::string &PathManager::GetPatchPath() const
|
|||||||
return m_patch_path;
|
return m_patch_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetOpcodePath() const
|
||||||
|
{
|
||||||
|
return m_opcode_path;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string &PathManager::GetLuaModulesPath() const
|
const std::string &PathManager::GetLuaModulesPath() const
|
||||||
{
|
{
|
||||||
return m_lua_modules_path;
|
return m_lua_modules_path;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public:
|
|||||||
[[nodiscard]] const std::string &GetLuaModulesPath() const;
|
[[nodiscard]] const std::string &GetLuaModulesPath() const;
|
||||||
[[nodiscard]] const std::string &GetMapsPath() const;
|
[[nodiscard]] const std::string &GetMapsPath() const;
|
||||||
[[nodiscard]] const std::string &GetPatchPath() const;
|
[[nodiscard]] const std::string &GetPatchPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetOpcodePath() const;
|
||||||
[[nodiscard]] const std::string &GetPluginsPath() const;
|
[[nodiscard]] const std::string &GetPluginsPath() const;
|
||||||
[[nodiscard]] const std::string &GetQuestsPath() const;
|
[[nodiscard]] const std::string &GetQuestsPath() const;
|
||||||
[[nodiscard]] const std::string &GetServerPath() const;
|
[[nodiscard]] const std::string &GetServerPath() const;
|
||||||
@@ -24,6 +25,7 @@ private:
|
|||||||
std::string m_lua_modules_path;
|
std::string m_lua_modules_path;
|
||||||
std::string m_maps_path;
|
std::string m_maps_path;
|
||||||
std::string m_patch_path;
|
std::string m_patch_path;
|
||||||
|
std::string m_opcode_path;
|
||||||
std::string m_plugins_path;
|
std::string m_plugins_path;
|
||||||
std::string m_quests_path;
|
std::string m_quests_path;
|
||||||
std::string m_server_path;
|
std::string m_server_path;
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ public:
|
|||||||
uint32_t alloc_int;
|
uint32_t alloc_int;
|
||||||
uint32_t alloc_wis;
|
uint32_t alloc_wis;
|
||||||
uint32_t alloc_cha;
|
uint32_t alloc_cha;
|
||||||
uint32_t base_cr;
|
|
||||||
uint32_t base_fr;
|
|
||||||
uint32_t base_mr;
|
|
||||||
uint32_t base_dr;
|
|
||||||
uint32_t base_pr;
|
|
||||||
uint32_t base_corrup;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
@@ -65,12 +59,6 @@ public:
|
|||||||
"alloc_int",
|
"alloc_int",
|
||||||
"alloc_wis",
|
"alloc_wis",
|
||||||
"alloc_cha",
|
"alloc_cha",
|
||||||
"base_cr",
|
|
||||||
"base_fr",
|
|
||||||
"base_mr",
|
|
||||||
"base_dr",
|
|
||||||
"base_pr",
|
|
||||||
"base_corrup",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,12 +80,6 @@ public:
|
|||||||
"alloc_int",
|
"alloc_int",
|
||||||
"alloc_wis",
|
"alloc_wis",
|
||||||
"alloc_cha",
|
"alloc_cha",
|
||||||
"base_cr",
|
|
||||||
"base_fr",
|
|
||||||
"base_mr",
|
|
||||||
"base_dr",
|
|
||||||
"base_pr",
|
|
||||||
"base_corrup",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,12 +135,6 @@ public:
|
|||||||
e.alloc_int = 0;
|
e.alloc_int = 0;
|
||||||
e.alloc_wis = 0;
|
e.alloc_wis = 0;
|
||||||
e.alloc_cha = 0;
|
e.alloc_cha = 0;
|
||||||
e.base_cr = 0;
|
|
||||||
e.base_fr = 0;
|
|
||||||
e.base_mr = 0;
|
|
||||||
e.base_dr = 0;
|
|
||||||
e.base_pr = 0;
|
|
||||||
e.base_corrup = 0;
|
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -210,12 +186,6 @@ public:
|
|||||||
e.alloc_int = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
e.alloc_int = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||||
e.alloc_wis = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
e.alloc_wis = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||||
e.alloc_cha = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
e.alloc_cha = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||||
e.base_cr = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
|
|
||||||
e.base_fr = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
|
|
||||||
e.base_mr = row[17] ? static_cast<uint32_t>(strtoul(row[17], nullptr, 10)) : 0;
|
|
||||||
e.base_dr = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
|
|
||||||
e.base_pr = row[19] ? static_cast<uint32_t>(strtoul(row[19], nullptr, 10)) : 0;
|
|
||||||
e.base_corrup = row[20] ? static_cast<uint32_t>(strtoul(row[20], nullptr, 10)) : 0;
|
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -264,12 +234,6 @@ public:
|
|||||||
v.push_back(columns[12] + " = " + std::to_string(e.alloc_int));
|
v.push_back(columns[12] + " = " + std::to_string(e.alloc_int));
|
||||||
v.push_back(columns[13] + " = " + std::to_string(e.alloc_wis));
|
v.push_back(columns[13] + " = " + std::to_string(e.alloc_wis));
|
||||||
v.push_back(columns[14] + " = " + std::to_string(e.alloc_cha));
|
v.push_back(columns[14] + " = " + std::to_string(e.alloc_cha));
|
||||||
v.push_back(columns[15] + " = " + std::to_string(e.base_cr));
|
|
||||||
v.push_back(columns[16] + " = " + std::to_string(e.base_fr));
|
|
||||||
v.push_back(columns[17] + " = " + std::to_string(e.base_mr));
|
|
||||||
v.push_back(columns[18] + " = " + std::to_string(e.base_dr));
|
|
||||||
v.push_back(columns[19] + " = " + std::to_string(e.base_pr));
|
|
||||||
v.push_back(columns[20] + " = " + std::to_string(e.base_corrup));
|
|
||||||
|
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@@ -306,12 +270,6 @@ public:
|
|||||||
v.push_back(std::to_string(e.alloc_int));
|
v.push_back(std::to_string(e.alloc_int));
|
||||||
v.push_back(std::to_string(e.alloc_wis));
|
v.push_back(std::to_string(e.alloc_wis));
|
||||||
v.push_back(std::to_string(e.alloc_cha));
|
v.push_back(std::to_string(e.alloc_cha));
|
||||||
v.push_back(std::to_string(e.base_cr));
|
|
||||||
v.push_back(std::to_string(e.base_fr));
|
|
||||||
v.push_back(std::to_string(e.base_mr));
|
|
||||||
v.push_back(std::to_string(e.base_dr));
|
|
||||||
v.push_back(std::to_string(e.base_pr));
|
|
||||||
v.push_back(std::to_string(e.base_corrup));
|
|
||||||
|
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@@ -356,12 +314,6 @@ public:
|
|||||||
v.push_back(std::to_string(e.alloc_int));
|
v.push_back(std::to_string(e.alloc_int));
|
||||||
v.push_back(std::to_string(e.alloc_wis));
|
v.push_back(std::to_string(e.alloc_wis));
|
||||||
v.push_back(std::to_string(e.alloc_cha));
|
v.push_back(std::to_string(e.alloc_cha));
|
||||||
v.push_back(std::to_string(e.base_cr));
|
|
||||||
v.push_back(std::to_string(e.base_fr));
|
|
||||||
v.push_back(std::to_string(e.base_mr));
|
|
||||||
v.push_back(std::to_string(e.base_dr));
|
|
||||||
v.push_back(std::to_string(e.base_pr));
|
|
||||||
v.push_back(std::to_string(e.base_corrup));
|
|
||||||
|
|
||||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
}
|
}
|
||||||
@@ -410,12 +362,6 @@ public:
|
|||||||
e.alloc_int = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
e.alloc_int = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||||
e.alloc_wis = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
e.alloc_wis = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||||
e.alloc_cha = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
e.alloc_cha = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||||
e.base_cr = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
|
|
||||||
e.base_fr = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
|
|
||||||
e.base_mr = row[17] ? static_cast<uint32_t>(strtoul(row[17], nullptr, 10)) : 0;
|
|
||||||
e.base_dr = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
|
|
||||||
e.base_pr = row[19] ? static_cast<uint32_t>(strtoul(row[19], nullptr, 10)) : 0;
|
|
||||||
e.base_corrup = row[20] ? static_cast<uint32_t>(strtoul(row[20], nullptr, 10)) : 0;
|
|
||||||
|
|
||||||
all_entries.push_back(e);
|
all_entries.push_back(e);
|
||||||
}
|
}
|
||||||
@@ -455,12 +401,6 @@ public:
|
|||||||
e.alloc_int = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
e.alloc_int = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||||
e.alloc_wis = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
e.alloc_wis = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||||
e.alloc_cha = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
e.alloc_cha = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||||
e.base_cr = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
|
|
||||||
e.base_fr = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
|
|
||||||
e.base_mr = row[17] ? static_cast<uint32_t>(strtoul(row[17], nullptr, 10)) : 0;
|
|
||||||
e.base_dr = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
|
|
||||||
e.base_pr = row[19] ? static_cast<uint32_t>(strtoul(row[19], nullptr, 10)) : 0;
|
|
||||||
e.base_corrup = row[20] ? static_cast<uint32_t>(strtoul(row[20], nullptr, 10)) : 0;
|
|
||||||
|
|
||||||
all_entries.push_back(e);
|
all_entries.push_back(e);
|
||||||
}
|
}
|
||||||
@@ -550,12 +490,6 @@ public:
|
|||||||
v.push_back(std::to_string(e.alloc_int));
|
v.push_back(std::to_string(e.alloc_int));
|
||||||
v.push_back(std::to_string(e.alloc_wis));
|
v.push_back(std::to_string(e.alloc_wis));
|
||||||
v.push_back(std::to_string(e.alloc_cha));
|
v.push_back(std::to_string(e.alloc_cha));
|
||||||
v.push_back(std::to_string(e.base_cr));
|
|
||||||
v.push_back(std::to_string(e.base_fr));
|
|
||||||
v.push_back(std::to_string(e.base_mr));
|
|
||||||
v.push_back(std::to_string(e.base_dr));
|
|
||||||
v.push_back(std::to_string(e.base_pr));
|
|
||||||
v.push_back(std::to_string(e.base_corrup));
|
|
||||||
|
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@@ -593,12 +527,6 @@ public:
|
|||||||
v.push_back(std::to_string(e.alloc_int));
|
v.push_back(std::to_string(e.alloc_int));
|
||||||
v.push_back(std::to_string(e.alloc_wis));
|
v.push_back(std::to_string(e.alloc_wis));
|
||||||
v.push_back(std::to_string(e.alloc_cha));
|
v.push_back(std::to_string(e.alloc_cha));
|
||||||
v.push_back(std::to_string(e.base_cr));
|
|
||||||
v.push_back(std::to_string(e.base_fr));
|
|
||||||
v.push_back(std::to_string(e.base_mr));
|
|
||||||
v.push_back(std::to_string(e.base_dr));
|
|
||||||
v.push_back(std::to_string(e.base_pr));
|
|
||||||
v.push_back(std::to_string(e.base_corrup));
|
|
||||||
|
|
||||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,12 +123,6 @@ public:
|
|||||||
uint32_t aa_points_old;
|
uint32_t aa_points_old;
|
||||||
uint32_t e_last_invsnapshot;
|
uint32_t e_last_invsnapshot;
|
||||||
time_t deleted_at;
|
time_t deleted_at;
|
||||||
uint32_t cold_resist;
|
|
||||||
uint32_t fire_resist;
|
|
||||||
uint32_t magic_resist;
|
|
||||||
uint32_t disease_resist;
|
|
||||||
uint32_t poison_resist;
|
|
||||||
uint32_t corruption_resist;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
@@ -243,12 +237,6 @@ public:
|
|||||||
"aa_points_old",
|
"aa_points_old",
|
||||||
"e_last_invsnapshot",
|
"e_last_invsnapshot",
|
||||||
"deleted_at",
|
"deleted_at",
|
||||||
"cold_resist",
|
|
||||||
"fire_resist",
|
|
||||||
"magic_resist",
|
|
||||||
"disease_resist",
|
|
||||||
"poison_resist",
|
|
||||||
"corruption_resist",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,12 +347,6 @@ public:
|
|||||||
"aa_points_old",
|
"aa_points_old",
|
||||||
"e_last_invsnapshot",
|
"e_last_invsnapshot",
|
||||||
"UNIX_TIMESTAMP(deleted_at)",
|
"UNIX_TIMESTAMP(deleted_at)",
|
||||||
"cold_resist",
|
|
||||||
"fire_resist",
|
|
||||||
"magic_resist",
|
|
||||||
"disease_resist",
|
|
||||||
"poison_resist",
|
|
||||||
"corruption_resist",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,12 +491,6 @@ public:
|
|||||||
e.aa_points_old = 0;
|
e.aa_points_old = 0;
|
||||||
e.e_last_invsnapshot = 0;
|
e.e_last_invsnapshot = 0;
|
||||||
e.deleted_at = 0;
|
e.deleted_at = 0;
|
||||||
e.cold_resist = 0;
|
|
||||||
e.fire_resist = 0;
|
|
||||||
e.magic_resist = 0;
|
|
||||||
e.disease_resist = 0;
|
|
||||||
e.poison_resist = 0;
|
|
||||||
e.corruption_resist = 0;
|
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -655,12 +631,6 @@ public:
|
|||||||
e.aa_points_old = row[101] ? static_cast<uint32_t>(strtoul(row[101], nullptr, 10)) : 0;
|
e.aa_points_old = row[101] ? static_cast<uint32_t>(strtoul(row[101], nullptr, 10)) : 0;
|
||||||
e.e_last_invsnapshot = row[102] ? static_cast<uint32_t>(strtoul(row[102], nullptr, 10)) : 0;
|
e.e_last_invsnapshot = row[102] ? static_cast<uint32_t>(strtoul(row[102], nullptr, 10)) : 0;
|
||||||
e.deleted_at = strtoll(row[103] ? row[103] : "-1", nullptr, 10);
|
e.deleted_at = strtoll(row[103] ? row[103] : "-1", nullptr, 10);
|
||||||
e.cold_resist = row[104] ? static_cast<uint32_t>(strtoul(row[104], nullptr, 10)) : 0;
|
|
||||||
e.fire_resist = row[105] ? static_cast<uint32_t>(strtoul(row[105], nullptr, 10)) : 0;
|
|
||||||
e.magic_resist = row[106] ? static_cast<uint32_t>(strtoul(row[106], nullptr, 10)) : 0;
|
|
||||||
e.disease_resist = row[107] ? static_cast<uint32_t>(strtoul(row[107], nullptr, 10)) : 0;
|
|
||||||
e.poison_resist = row[108] ? static_cast<uint32_t>(strtoul(row[108], nullptr, 10)) : 0;
|
|
||||||
e.corruption_resist = row[109] ? static_cast<uint32_t>(strtoul(row[109], nullptr, 10)) : 0;
|
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -797,12 +767,6 @@ public:
|
|||||||
v.push_back(columns[101] + " = " + std::to_string(e.aa_points_old));
|
v.push_back(columns[101] + " = " + std::to_string(e.aa_points_old));
|
||||||
v.push_back(columns[102] + " = " + std::to_string(e.e_last_invsnapshot));
|
v.push_back(columns[102] + " = " + std::to_string(e.e_last_invsnapshot));
|
||||||
v.push_back(columns[103] + " = FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
v.push_back(columns[103] + " = FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
||||||
v.push_back(columns[104] + " = " + std::to_string(e.cold_resist));
|
|
||||||
v.push_back(columns[105] + " = " + std::to_string(e.fire_resist));
|
|
||||||
v.push_back(columns[106] + " = " + std::to_string(e.magic_resist));
|
|
||||||
v.push_back(columns[107] + " = " + std::to_string(e.disease_resist));
|
|
||||||
v.push_back(columns[108] + " = " + std::to_string(e.poison_resist));
|
|
||||||
v.push_back(columns[109] + " = " + std::to_string(e.corruption_resist));
|
|
||||||
|
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@@ -928,12 +892,6 @@ public:
|
|||||||
v.push_back(std::to_string(e.aa_points_old));
|
v.push_back(std::to_string(e.aa_points_old));
|
||||||
v.push_back(std::to_string(e.e_last_invsnapshot));
|
v.push_back(std::to_string(e.e_last_invsnapshot));
|
||||||
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
||||||
v.push_back(std::to_string(e.cold_resist));
|
|
||||||
v.push_back(std::to_string(e.fire_resist));
|
|
||||||
v.push_back(std::to_string(e.magic_resist));
|
|
||||||
v.push_back(std::to_string(e.disease_resist));
|
|
||||||
v.push_back(std::to_string(e.poison_resist));
|
|
||||||
v.push_back(std::to_string(e.corruption_resist));
|
|
||||||
|
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@@ -1067,12 +1025,6 @@ public:
|
|||||||
v.push_back(std::to_string(e.aa_points_old));
|
v.push_back(std::to_string(e.aa_points_old));
|
||||||
v.push_back(std::to_string(e.e_last_invsnapshot));
|
v.push_back(std::to_string(e.e_last_invsnapshot));
|
||||||
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
||||||
v.push_back(std::to_string(e.cold_resist));
|
|
||||||
v.push_back(std::to_string(e.fire_resist));
|
|
||||||
v.push_back(std::to_string(e.magic_resist));
|
|
||||||
v.push_back(std::to_string(e.disease_resist));
|
|
||||||
v.push_back(std::to_string(e.poison_resist));
|
|
||||||
v.push_back(std::to_string(e.corruption_resist));
|
|
||||||
|
|
||||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
}
|
}
|
||||||
@@ -1210,12 +1162,6 @@ public:
|
|||||||
e.aa_points_old = row[101] ? static_cast<uint32_t>(strtoul(row[101], nullptr, 10)) : 0;
|
e.aa_points_old = row[101] ? static_cast<uint32_t>(strtoul(row[101], nullptr, 10)) : 0;
|
||||||
e.e_last_invsnapshot = row[102] ? static_cast<uint32_t>(strtoul(row[102], nullptr, 10)) : 0;
|
e.e_last_invsnapshot = row[102] ? static_cast<uint32_t>(strtoul(row[102], nullptr, 10)) : 0;
|
||||||
e.deleted_at = strtoll(row[103] ? row[103] : "-1", nullptr, 10);
|
e.deleted_at = strtoll(row[103] ? row[103] : "-1", nullptr, 10);
|
||||||
e.cold_resist = row[104] ? static_cast<uint32_t>(strtoul(row[104], nullptr, 10)) : 0;
|
|
||||||
e.fire_resist = row[105] ? static_cast<uint32_t>(strtoul(row[105], nullptr, 10)) : 0;
|
|
||||||
e.magic_resist = row[106] ? static_cast<uint32_t>(strtoul(row[106], nullptr, 10)) : 0;
|
|
||||||
e.disease_resist = row[107] ? static_cast<uint32_t>(strtoul(row[107], nullptr, 10)) : 0;
|
|
||||||
e.poison_resist = row[108] ? static_cast<uint32_t>(strtoul(row[108], nullptr, 10)) : 0;
|
|
||||||
e.corruption_resist = row[109] ? static_cast<uint32_t>(strtoul(row[109], nullptr, 10)) : 0;
|
|
||||||
|
|
||||||
all_entries.push_back(e);
|
all_entries.push_back(e);
|
||||||
}
|
}
|
||||||
@@ -1344,12 +1290,6 @@ public:
|
|||||||
e.aa_points_old = row[101] ? static_cast<uint32_t>(strtoul(row[101], nullptr, 10)) : 0;
|
e.aa_points_old = row[101] ? static_cast<uint32_t>(strtoul(row[101], nullptr, 10)) : 0;
|
||||||
e.e_last_invsnapshot = row[102] ? static_cast<uint32_t>(strtoul(row[102], nullptr, 10)) : 0;
|
e.e_last_invsnapshot = row[102] ? static_cast<uint32_t>(strtoul(row[102], nullptr, 10)) : 0;
|
||||||
e.deleted_at = strtoll(row[103] ? row[103] : "-1", nullptr, 10);
|
e.deleted_at = strtoll(row[103] ? row[103] : "-1", nullptr, 10);
|
||||||
e.cold_resist = row[104] ? static_cast<uint32_t>(strtoul(row[104], nullptr, 10)) : 0;
|
|
||||||
e.fire_resist = row[105] ? static_cast<uint32_t>(strtoul(row[105], nullptr, 10)) : 0;
|
|
||||||
e.magic_resist = row[106] ? static_cast<uint32_t>(strtoul(row[106], nullptr, 10)) : 0;
|
|
||||||
e.disease_resist = row[107] ? static_cast<uint32_t>(strtoul(row[107], nullptr, 10)) : 0;
|
|
||||||
e.poison_resist = row[108] ? static_cast<uint32_t>(strtoul(row[108], nullptr, 10)) : 0;
|
|
||||||
e.corruption_resist = row[109] ? static_cast<uint32_t>(strtoul(row[109], nullptr, 10)) : 0;
|
|
||||||
|
|
||||||
all_entries.push_back(e);
|
all_entries.push_back(e);
|
||||||
}
|
}
|
||||||
@@ -1528,12 +1468,6 @@ public:
|
|||||||
v.push_back(std::to_string(e.aa_points_old));
|
v.push_back(std::to_string(e.aa_points_old));
|
||||||
v.push_back(std::to_string(e.e_last_invsnapshot));
|
v.push_back(std::to_string(e.e_last_invsnapshot));
|
||||||
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
||||||
v.push_back(std::to_string(e.cold_resist));
|
|
||||||
v.push_back(std::to_string(e.fire_resist));
|
|
||||||
v.push_back(std::to_string(e.magic_resist));
|
|
||||||
v.push_back(std::to_string(e.disease_resist));
|
|
||||||
v.push_back(std::to_string(e.poison_resist));
|
|
||||||
v.push_back(std::to_string(e.corruption_resist));
|
|
||||||
|
|
||||||
auto results = db.QueryDatabase(
|
auto results = db.QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@@ -1660,12 +1594,6 @@ public:
|
|||||||
v.push_back(std::to_string(e.aa_points_old));
|
v.push_back(std::to_string(e.aa_points_old));
|
||||||
v.push_back(std::to_string(e.e_last_invsnapshot));
|
v.push_back(std::to_string(e.e_last_invsnapshot));
|
||||||
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")");
|
||||||
v.push_back(std::to_string(e.cold_resist));
|
|
||||||
v.push_back(std::to_string(e.fire_resist));
|
|
||||||
v.push_back(std::to_string(e.magic_resist));
|
|
||||||
v.push_back(std::to_string(e.disease_resist));
|
|
||||||
v.push_back(std::to_string(e.poison_resist));
|
|
||||||
v.push_back(std::to_string(e.corruption_resist));
|
|
||||||
|
|
||||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,6 +236,10 @@ public:
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (buyers.empty()) {
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> char_ids{};
|
std::vector<std::string> char_ids{};
|
||||||
for (auto const &bl : buyers) {
|
for (auto const &bl : buyers) {
|
||||||
char_ids.push_back((std::to_string(bl.char_id)));
|
char_ids.push_back((std::to_string(bl.char_id)));
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeleteWhere(db, fmt::format("`char_id` = '{}';", char_id));
|
DeleteWhere(db, fmt::format("`char_id` = '{}';", char_id));
|
||||||
|
if (buy_line_ids.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
BaseBuyerBuyLinesRepository::DeleteWhere(
|
BaseBuyerBuyLinesRepository::DeleteWhere(
|
||||||
db,
|
db,
|
||||||
fmt::format("`id` IN({})", Strings::Implode(", ", buy_line_ids))
|
fmt::format("`id` IN({})", Strings::Implode(", ", buy_line_ids))
|
||||||
|
|||||||
@@ -164,38 +164,36 @@ public:
|
|||||||
return UpdateOne(db, m);
|
return UpdateOne(db, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Trader GetItemBySerialNumber(Database &db, uint32 serial_number)
|
static Trader GetItemBySerialNumber(Database &db, uint32 serial_number, uint32 trader_id)
|
||||||
{
|
{
|
||||||
Trader e{};
|
Trader e{};
|
||||||
const auto trader_item = GetWhere(
|
const auto trader_item = GetWhere(
|
||||||
db,
|
db,
|
||||||
fmt::format("`item_sn` = '{}' LIMIT 1", serial_number)
|
fmt::format("`char_id` = '{}' AND `item_sn` = '{}' LIMIT 1", trader_id, serial_number)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (trader_item.empty()) {
|
if (trader_item.empty()) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return trader_item.at(0);
|
return trader_item.at(0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static Trader GetItemBySerialNumber(Database &db, std::string serial_number)
|
static Trader GetItemBySerialNumber(Database &db, std::string serial_number, uint32 trader_id)
|
||||||
{
|
{
|
||||||
Trader e{};
|
Trader e{};
|
||||||
auto sn = Strings::ToUnsignedBigInt(serial_number);
|
auto sn = Strings::ToUnsignedBigInt(serial_number);
|
||||||
const auto trader_item = GetWhere(
|
const auto trader_item = GetWhere(
|
||||||
db,
|
db,
|
||||||
fmt::format("`item_sn` = '{}' LIMIT 1", sn)
|
fmt::format("`char_id` = '{}' AND `item_sn` = '{}' LIMIT 1", trader_id, sn)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (trader_item.empty()) {
|
if (trader_item.empty()) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return trader_item.at(0);
|
return trader_item.at(0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static int UpdateActiveTransaction(Database &db, uint32 id, bool status)
|
static int UpdateActiveTransaction(Database &db, uint32 id, bool status)
|
||||||
{
|
{
|
||||||
@@ -217,6 +215,10 @@ public:
|
|||||||
delete_ids.push_back(std::to_string(e.id));
|
delete_ids.push_back(std::to_string(e.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (delete_ids.empty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return DeleteWhere(db, fmt::format("`id` IN({})", Strings::Implode(",", delete_ids)));
|
return DeleteWhere(db, fmt::format("`id` IN({})", Strings::Implode(",", delete_ids)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-1
@@ -338,6 +338,8 @@ RULE_STRING(World, IPExemptionZones, "", "Comma-delimited list of zones to exclu
|
|||||||
RULE_STRING(World, MOTD, "", "Server MOTD sent on login, change from empty to have this be used instead of variables table 'motd' value")
|
RULE_STRING(World, MOTD, "", "Server MOTD sent on login, change from empty to have this be used instead of variables table 'motd' value")
|
||||||
RULE_STRING(World, Rules, "", "Server Rules, change from empty to have this be used instead of variables table 'rules' value, lines are pipe (|) separated, example: A|B|C")
|
RULE_STRING(World, Rules, "", "Server Rules, change from empty to have this be used instead of variables table 'rules' value, lines are pipe (|) separated, example: A|B|C")
|
||||||
RULE_BOOL(World, EnableAutoLogin, false, "Enables or disables auto login of characters, allowing people to log characters in directly from loginserver to ingame")
|
RULE_BOOL(World, EnableAutoLogin, false, "Enables or disables auto login of characters, allowing people to log characters in directly from loginserver to ingame")
|
||||||
|
RULE_BOOL(World, EnablePVPRegions, true, "Enables or disables PVP Regions automatically setting your PVP flag")
|
||||||
|
RULE_STRING(World, SupportedClients, "", "Comma-delimited list of clients to restrict to. Supported values are Titanium | SoF | SoD | UF | RoF | RoF2. Example: Titanium,RoF2")
|
||||||
RULE_CATEGORY_END()
|
RULE_CATEGORY_END()
|
||||||
|
|
||||||
RULE_CATEGORY(Zone)
|
RULE_CATEGORY(Zone)
|
||||||
@@ -516,7 +518,8 @@ RULE_INT(Spells, HealAmountMessageFilterThreshold, 100, "Lifetaps below this thr
|
|||||||
RULE_BOOL(Spells, SnareOverridesSpeedBonuses, false, "Enabling will allow snares to override any speed bonuses the entity may have. Default: False")
|
RULE_BOOL(Spells, SnareOverridesSpeedBonuses, false, "Enabling will allow snares to override any speed bonuses the entity may have. Default: False")
|
||||||
RULE_INT(Spells, TargetedAOEMaxTargets, 4, "Max number of targets a Targeted AOE spell can cast on. Set to 0 for no limit.")
|
RULE_INT(Spells, TargetedAOEMaxTargets, 4, "Max number of targets a Targeted AOE spell can cast on. Set to 0 for no limit.")
|
||||||
RULE_INT(Spells, PointBlankAOEMaxTargets, 0, "Max number of targets a Point-Blank AOE spell can cast on. Set to 0 for no limit.")
|
RULE_INT(Spells, PointBlankAOEMaxTargets, 0, "Max number of targets a Point-Blank AOE spell can cast on. Set to 0 for no limit.")
|
||||||
RULE_INT(Spells, DefaultAOEMaxTargets, 4, "Max number of targets that an AOE spell which does not meet other descriptions can cast on. Set to 0 for no limit.")
|
RULE_INT(Spells, DefaultAOEMaxTargets, 0, "Max number of targets that an AOE spell which does not meet other descriptions can cast on. Set to 0 for no limit.")
|
||||||
|
RULE_BOOL(Spells, AllowFocusOnSkillDamageSpells, false, "Allow focus effects 185, 459, and 482 to enhance SkillAttack spell effect 193")
|
||||||
RULE_CATEGORY_END()
|
RULE_CATEGORY_END()
|
||||||
|
|
||||||
RULE_CATEGORY(Combat)
|
RULE_CATEGORY(Combat)
|
||||||
@@ -678,6 +681,7 @@ RULE_BOOL(NPC, DisableLastNames, false, "Enable to disable NPC Last Names")
|
|||||||
RULE_BOOL(NPC, NPCIgnoreLevelBasedHasteCaps, false, "Ignores hard coded level based haste caps.")
|
RULE_BOOL(NPC, NPCIgnoreLevelBasedHasteCaps, false, "Ignores hard coded level based haste caps.")
|
||||||
RULE_INT(NPC, NPCHasteCap, 150, "Haste cap for non-v3(over haste) haste")
|
RULE_INT(NPC, NPCHasteCap, 150, "Haste cap for non-v3(over haste) haste")
|
||||||
RULE_INT(NPC, NPCHastev3Cap, 25, "Haste cap for v3(over haste) haste")
|
RULE_INT(NPC, NPCHastev3Cap, 25, "Haste cap for v3(over haste) haste")
|
||||||
|
RULE_STRING(NPC, ExcludedFaceTargetRaces, "52,72,73,141,233,328,329,372,376,377,378,379,380,381,382,383,404,422,423,424,425,426,428,429,445,449,460,462,463,500,501,502,503,504,505,506,507,508,509,510,511,513,514,515,516,533,534,535,536,537,538,539,540,541,542,543,544,545,546,550,551,552,553,554,555,556,557,567,573,577,586,589,590,591,592,593,595,596,599,601,616,619,621,628,629,630,633,634,635,636,665,683,684,685,691,692,693,694,702,703,705,706,707,710,711,714,720,2250,2254", "Race IDs excluded from facing target when hailed")
|
||||||
RULE_CATEGORY_END()
|
RULE_CATEGORY_END()
|
||||||
|
|
||||||
RULE_CATEGORY(Aggro)
|
RULE_CATEGORY(Aggro)
|
||||||
|
|||||||
@@ -1945,6 +1945,7 @@ struct ServerOP_GuildMessage_Struct {
|
|||||||
struct TraderMessaging_Struct {
|
struct TraderMessaging_Struct {
|
||||||
uint32 action;
|
uint32 action;
|
||||||
uint32 zone_id;
|
uint32 zone_id;
|
||||||
|
uint32 instance_id;
|
||||||
uint32 trader_id;
|
uint32 trader_id;
|
||||||
uint32 entity_id;
|
uint32 entity_id;
|
||||||
char trader_name[64];
|
char trader_name[64];
|
||||||
|
|||||||
+4
-3
@@ -83,7 +83,8 @@ struct ActivityInformation {
|
|||||||
if (zone_ids.empty()) {
|
if (zone_ids.empty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool found_zone = std::find(zone_ids.begin(), zone_ids.end(), zone_id) != zone_ids.end();
|
bool found_zone = std::any_of(zone_ids.begin(), zone_ids.end(),
|
||||||
|
[zone_id](int id) { return id <= 0 || id == zone_id; });
|
||||||
|
|
||||||
return found_zone && (zone_version == version || zone_version == -1);
|
return found_zone && (zone_version == version || zone_version == -1);
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@ struct ActivityInformation {
|
|||||||
out.WriteInt32(activity_type == TaskActivityType::GiveCash ? 1 : goal_count);
|
out.WriteInt32(activity_type == TaskActivityType::GiveCash ? 1 : goal_count);
|
||||||
out.WriteLengthString(skill_list); // used in SkillOn objective type string, "-1" for none
|
out.WriteLengthString(skill_list); // used in SkillOn objective type string, "-1" for none
|
||||||
out.WriteLengthString(spell_list); // used in CastOn objective type string, "0" for none
|
out.WriteLengthString(spell_list); // used in CastOn objective type string, "0" for none
|
||||||
out.WriteString(zones); // used in objective zone column and task select "begins in" (may have multiple, "0" for "unknown zone", empty for "ALL")
|
out.WriteString(zones); // used in ui zone columns and task select "begins in" (may have multiple, invalid id for "Unknown Zone", empty for "ALL")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -114,7 +115,7 @@ struct ActivityInformation {
|
|||||||
out.WriteString(description_override);
|
out.WriteString(description_override);
|
||||||
|
|
||||||
if (client_version >= EQ::versions::ClientVersion::RoF) {
|
if (client_version >= EQ::versions::ClientVersion::RoF) {
|
||||||
out.WriteString(zones); // serialized again after description (seems unused)
|
out.WriteString(zones); // target zone version internal id (unused client side)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
// Build variables
|
// Build variables
|
||||||
// these get injected during the build pipeline
|
// these get injected during the build pipeline
|
||||||
#define CURRENT_VERSION "22.56.3-dev" // always append -dev to the current version for custom-builds
|
#define CURRENT_VERSION "22.60.0-dev" // always append -dev to the current version for custom-builds
|
||||||
#define LOGIN_VERSION "0.8.0"
|
#define LOGIN_VERSION "0.8.0"
|
||||||
#define COMPILE_DATE __DATE__
|
#define COMPILE_DATE __DATE__
|
||||||
#define COMPILE_TIME __TIME__
|
#define COMPILE_TIME __TIME__
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CURRENT_BINARY_DATABASE_VERSION 9284
|
#define CURRENT_BINARY_DATABASE_VERSION 9285
|
||||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9045
|
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9045
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -251,4 +251,6 @@ private:
|
|||||||
scalar m_value;
|
scalar m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using ref = reference;
|
||||||
|
|
||||||
} // namespace perlbind
|
} // namespace perlbind
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ struct pusher
|
|||||||
++m_pushed;
|
++m_pushed;
|
||||||
}
|
}
|
||||||
void push(const std::string& value) { mPUSHp(value.c_str(), value.size()); ++m_pushed; }
|
void push(const std::string& value) { mPUSHp(value.c_str(), value.size()); ++m_pushed; }
|
||||||
void push(scalar value) { mPUSHs(value.release()); ++m_pushed; };
|
void push(scalar value) { mPUSHs(value.release()); ++m_pushed; }
|
||||||
void push(reference value) { mPUSHs(value.release()); ++m_pushed; };
|
void push(reference value) { mPUSHs(value.release()); ++m_pushed; }
|
||||||
|
|
||||||
void push(array value)
|
void push(array value)
|
||||||
{
|
{
|
||||||
@@ -38,7 +38,8 @@ struct pusher
|
|||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
// mortalizes one reference to array element to avoid copying
|
// mortalizes one reference to array element to avoid copying
|
||||||
PUSHs(sv_2mortal(SvREFCNT_inc(value[i].sv())));
|
SV** sv = av_fetch(static_cast<AV*>(value), i, true);
|
||||||
|
mPUSHs(SvREFCNT_inc(*sv));
|
||||||
}
|
}
|
||||||
m_pushed += count;
|
m_pushed += count;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ struct read_as<hash>
|
|||||||
static bool check(PerlInterpreter* my_perl, int i, int ax, int items)
|
static bool check(PerlInterpreter* my_perl, int i, int ax, int items)
|
||||||
{
|
{
|
||||||
int remaining = items - i;
|
int remaining = items - i;
|
||||||
return remaining > 0 && remaining % 2 == 0 && SvTYPE(ST(i)) == SVt_PV;
|
return remaining > 0 && remaining % 2 == 0 && SvTYPE(ST(i)) < SVt_PVAV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static hash get(PerlInterpreter* my_perl, int i, int ax, int items)
|
static hash get(PerlInterpreter* my_perl, int i, int ax, int items)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
constexpr int perlbind_version_major = 1;
|
constexpr int perlbind_version_major = 1;
|
||||||
constexpr int perlbind_version_minor = 0;
|
constexpr int perlbind_version_minor = 1;
|
||||||
constexpr int perlbind_version_patch = 0;
|
constexpr int perlbind_version_patch = 0;
|
||||||
|
|
||||||
constexpr int perlbind_version()
|
constexpr int perlbind_version()
|
||||||
|
|||||||
@@ -7,6 +7,79 @@ extern bool run_server;
|
|||||||
#include "../common/eqemu_logsys.h"
|
#include "../common/eqemu_logsys.h"
|
||||||
#include "../common/misc.h"
|
#include "../common/misc.h"
|
||||||
#include "../common/path_manager.h"
|
#include "../common/path_manager.h"
|
||||||
|
#include "../common/file.h"
|
||||||
|
|
||||||
|
void CheckTitaniumOpcodeFile(const std::string &path) {
|
||||||
|
if (File::Exists(path)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto f = fopen(path.c_str(), "w");
|
||||||
|
if (f) {
|
||||||
|
fprintf(f, "#EQEmu Public Login Server OPCodes\n");
|
||||||
|
fprintf(f, "OP_SessionReady=0x0001\n");
|
||||||
|
fprintf(f, "OP_Login=0x0002\n");
|
||||||
|
fprintf(f, "OP_ServerListRequest=0x0004\n");
|
||||||
|
fprintf(f, "OP_PlayEverquestRequest=0x000d\n");
|
||||||
|
fprintf(f, "OP_PlayEverquestResponse=0x0021\n");
|
||||||
|
fprintf(f, "OP_ChatMessage=0x0016\n");
|
||||||
|
fprintf(f, "OP_LoginAccepted=0x0017\n");
|
||||||
|
fprintf(f, "OP_ServerListResponse=0x0018\n");
|
||||||
|
fprintf(f, "OP_Poll=0x0029\n");
|
||||||
|
fprintf(f, "OP_EnterChat=0x000f\n");
|
||||||
|
fprintf(f, "OP_PollResponse=0x0011\n");
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckSoDOpcodeFile(const std::string& path) {
|
||||||
|
if (File::Exists(path)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto f = fopen(path.c_str(), "w");
|
||||||
|
if (f) {
|
||||||
|
fprintf(f, "#EQEmu Public Login Server OPCodes\n");
|
||||||
|
fprintf(f, "OP_SessionReady=0x0001\n");
|
||||||
|
fprintf(f, "OP_Login=0x0002\n");
|
||||||
|
fprintf(f, "OP_ServerListRequest=0x0004\n");
|
||||||
|
fprintf(f, "OP_PlayEverquestRequest=0x000d\n");
|
||||||
|
fprintf(f, "OP_PlayEverquestResponse=0x0022\n");
|
||||||
|
fprintf(f, "OP_ChatMessage=0x0017\n");
|
||||||
|
fprintf(f, "OP_LoginAccepted=0x0018\n");
|
||||||
|
fprintf(f, "OP_ServerListResponse=0x0019\n");
|
||||||
|
fprintf(f, "OP_Poll=0x0029\n");
|
||||||
|
fprintf(f, "OP_LoginExpansionPacketData=0x0031\n");
|
||||||
|
fprintf(f, "OP_EnterChat=0x000f\n");
|
||||||
|
fprintf(f, "OP_PollResponse=0x0011\n");
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckLarionOpcodeFile(const std::string& path) {
|
||||||
|
if (File::Exists(path)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto f = fopen(path.c_str(), "w");
|
||||||
|
if (f) {
|
||||||
|
fprintf(f, "#EQEmu Public Login Server OPCodes\n");
|
||||||
|
fprintf(f, "OP_SessionReady=0x0001\n");
|
||||||
|
fprintf(f, "OP_Login=0x0002\n");
|
||||||
|
fprintf(f, "OP_ServerListRequest=0x0004\n");
|
||||||
|
fprintf(f, "OP_PlayEverquestRequest=0x000d\n");
|
||||||
|
fprintf(f, "OP_PlayEverquestResponse=0x0022\n");
|
||||||
|
fprintf(f, "OP_ChatMessage=0x0017\n");
|
||||||
|
fprintf(f, "OP_LoginAccepted=0x0018\n");
|
||||||
|
fprintf(f, "OP_ServerListResponse=0x0019\n");
|
||||||
|
fprintf(f, "OP_Poll=0x0029\n");
|
||||||
|
fprintf(f, "OP_EnterChat=0x000f\n");
|
||||||
|
fprintf(f, "OP_PollResponse=0x0011\n");
|
||||||
|
fprintf(f, "OP_SystemFingerprint=0x0016\n");
|
||||||
|
fprintf(f, "OP_ExpansionList=0x0030\n");
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ClientManager::ClientManager()
|
ClientManager::ClientManager()
|
||||||
{
|
{
|
||||||
@@ -19,14 +92,12 @@ ClientManager::ClientManager()
|
|||||||
|
|
||||||
std::string opcodes_path = fmt::format(
|
std::string opcodes_path = fmt::format(
|
||||||
"{}/{}",
|
"{}/{}",
|
||||||
path.GetServerPath(),
|
path.GetOpcodePath(),
|
||||||
server.config.GetVariableString(
|
|
||||||
"client_configuration",
|
|
||||||
"titanium_opcodes",
|
|
||||||
"login_opcodes.conf"
|
"login_opcodes.conf"
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CheckTitaniumOpcodeFile(opcodes_path);
|
||||||
|
|
||||||
if (!titanium_ops->LoadOpcodes(opcodes_path.c_str())) {
|
if (!titanium_ops->LoadOpcodes(opcodes_path.c_str())) {
|
||||||
LogError(
|
LogError(
|
||||||
"ClientManager fatal error: couldn't load opcodes for Titanium file [{0}]",
|
"ClientManager fatal error: couldn't load opcodes for Titanium file [{0}]",
|
||||||
@@ -58,14 +129,12 @@ ClientManager::ClientManager()
|
|||||||
|
|
||||||
opcodes_path = fmt::format(
|
opcodes_path = fmt::format(
|
||||||
"{}/{}",
|
"{}/{}",
|
||||||
path.GetServerPath(),
|
path.GetOpcodePath(),
|
||||||
server.config.GetVariableString(
|
"login_opcodes_sod.conf"
|
||||||
"client_configuration",
|
|
||||||
"sod_opcodes",
|
|
||||||
"login_opcodes.conf"
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CheckSoDOpcodeFile(opcodes_path);
|
||||||
|
|
||||||
if (!sod_ops->LoadOpcodes(opcodes_path.c_str())) {
|
if (!sod_ops->LoadOpcodes(opcodes_path.c_str())) {
|
||||||
LogError(
|
LogError(
|
||||||
"ClientManager fatal error: couldn't load opcodes for SoD file {0}",
|
"ClientManager fatal error: couldn't load opcodes for SoD file {0}",
|
||||||
@@ -98,14 +167,12 @@ ClientManager::ClientManager()
|
|||||||
|
|
||||||
opcodes_path = fmt::format(
|
opcodes_path = fmt::format(
|
||||||
"{}/{}",
|
"{}/{}",
|
||||||
path.GetServerPath(),
|
path.GetOpcodePath(),
|
||||||
server.config.GetVariableString(
|
"login_opcodes_larion.conf"
|
||||||
"client_configuration",
|
|
||||||
"larion_opcodes",
|
|
||||||
"login_opcodes.conf"
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CheckLarionOpcodeFile(opcodes_path);
|
||||||
|
|
||||||
if (!larion_ops->LoadOpcodes(opcodes_path.c_str())) {
|
if (!larion_ops->LoadOpcodes(opcodes_path.c_str())) {
|
||||||
LogError(
|
LogError(
|
||||||
"ClientManager fatal error: couldn't load opcodes for Larion file [{0}]",
|
"ClientManager fatal error: couldn't load opcodes for Larion file [{0}]",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "eqemu-server",
|
"name": "eqemu-server",
|
||||||
"version": "22.56.3",
|
"version": "22.60.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/EQEmu/Server.git"
|
"url": "https://github.com/EQEmu/Server.git"
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ SET(world_headers
|
|||||||
login_server.h
|
login_server.h
|
||||||
login_server_list.h
|
login_server_list.h
|
||||||
queryserv.h
|
queryserv.h
|
||||||
race_combos.h
|
|
||||||
shared_task_manager.h
|
shared_task_manager.h
|
||||||
shared_task_world_messaging.h
|
shared_task_world_messaging.h
|
||||||
sof_char_create_data.h
|
sof_char_create_data.h
|
||||||
|
|||||||
+276
-312
@@ -47,7 +47,6 @@
|
|||||||
#include "clientlist.h"
|
#include "clientlist.h"
|
||||||
#include "wguild_mgr.h"
|
#include "wguild_mgr.h"
|
||||||
#include "sof_char_create_data.h"
|
#include "sof_char_create_data.h"
|
||||||
#include "race_combos.h"
|
|
||||||
#include "../common/zone_store.h"
|
#include "../common/zone_store.h"
|
||||||
#include "../common/repositories/account_repository.h"
|
#include "../common/repositories/account_repository.h"
|
||||||
#include "../common/repositories/player_event_logs_repository.h"
|
#include "../common/repositories/player_event_logs_repository.h"
|
||||||
@@ -86,8 +85,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<CharCreatePointAllocation> character_create_allocations;
|
std::vector<RaceClassAllocation> character_create_allocations;
|
||||||
std::vector<CharCreateCombination> character_create_race_class_combos;
|
std::vector<RaceClassCombos> character_create_race_class_combos;
|
||||||
|
|
||||||
extern ZSList zoneserver_list;
|
extern ZSList zoneserver_list;
|
||||||
extern LoginServerList loginserverlist;
|
extern LoginServerList loginserverlist;
|
||||||
@@ -527,10 +526,28 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app)
|
|||||||
SendEnterWorld(cle->name());
|
SendEnterWorld(cle->name());
|
||||||
SendPostEnterWorld();
|
SendPostEnterWorld();
|
||||||
if (!is_player_zoning) {
|
if (!is_player_zoning) {
|
||||||
|
const auto supported_clients = RuleS(World, SupportedClients);
|
||||||
|
bool skip_char_info = false;
|
||||||
|
if (!supported_clients.empty()) {
|
||||||
|
const std::string& name = EQ::versions::ClientVersionName(m_ClientVersion);
|
||||||
|
const auto& clients = Strings::Split(supported_clients, ",");
|
||||||
|
if (std::find(clients.begin(), clients.end(), name) == clients.end()) {
|
||||||
|
SendUnsupportedClientPacket(
|
||||||
|
fmt::format(
|
||||||
|
"Client Not In Supported List [{}]",
|
||||||
|
supported_clients
|
||||||
|
)
|
||||||
|
);
|
||||||
|
skip_char_info = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!skip_char_info) {
|
||||||
SendExpansionInfo();
|
SendExpansionInfo();
|
||||||
SendCharInfo();
|
SendCharInfo();
|
||||||
database.LoginIP(cle->AccountID(), long2ip(GetIP()));
|
database.LoginIP(cle->AccountID(), long2ip(GetIP()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cle->SetIP(GetIP());
|
cle->SetIP(GetIP());
|
||||||
return true;
|
return true;
|
||||||
@@ -1643,6 +1660,229 @@ void Client::SendApproveWorld()
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
|
||||||
|
{
|
||||||
|
PlayerProfile_Struct pp;
|
||||||
|
EQ::InventoryProfile inv;
|
||||||
|
|
||||||
|
pp.SetPlayerProfileVersion(EQ::versions::ConvertClientVersionToMobVersion(EQ::versions::ConvertClientVersionBitToClientVersion(m_ClientVersionBit)));
|
||||||
|
inv.SetInventoryVersion(EQ::versions::ConvertClientVersionBitToClientVersion(m_ClientVersionBit));
|
||||||
|
inv.SetGMInventory(false); // character cannot have gm flag at this point
|
||||||
|
|
||||||
|
time_t bday = time(nullptr);
|
||||||
|
in_addr in;
|
||||||
|
|
||||||
|
const uint32 stats_sum = (
|
||||||
|
cc->AGI +
|
||||||
|
cc->CHA +
|
||||||
|
cc->DEX +
|
||||||
|
cc->INT +
|
||||||
|
cc->STA +
|
||||||
|
cc->STR +
|
||||||
|
cc->WIS
|
||||||
|
);
|
||||||
|
|
||||||
|
in.s_addr = GetIP();
|
||||||
|
|
||||||
|
LogInfo(
|
||||||
|
"Character creation request from [{}] LS [{}] [{}] [{}]",
|
||||||
|
GetCLE()->LSName(),
|
||||||
|
GetCLE()->LSID(),
|
||||||
|
inet_ntoa(in),
|
||||||
|
GetPort()
|
||||||
|
);
|
||||||
|
LogInfo("Name [{}]", name);
|
||||||
|
LogInfo(
|
||||||
|
"race [{}] class [{}] gender [{}] deity [{}] start_zone [{}] tutorial [{}]",
|
||||||
|
cc->race,
|
||||||
|
cc->class_,
|
||||||
|
cc->gender,
|
||||||
|
cc->deity,
|
||||||
|
cc->start_zone,
|
||||||
|
cc->tutorial ? "true" : "false"
|
||||||
|
);
|
||||||
|
LogInfo(
|
||||||
|
"AGI [{}] CHA [{}] DEX [{}] INT [{}] STA [{}] STR [{}] WIS [{}] Total [{}]",
|
||||||
|
cc->AGI,
|
||||||
|
cc->CHA,
|
||||||
|
cc->DEX,
|
||||||
|
cc->INT,
|
||||||
|
cc->STA,
|
||||||
|
cc->STR,
|
||||||
|
cc->WIS,
|
||||||
|
stats_sum
|
||||||
|
);
|
||||||
|
LogInfo("Face [{}] Eye Colors [{}] [{}]", cc->face, cc->eyecolor1, cc->eyecolor2);
|
||||||
|
LogInfo("Hair [{}] Hair Color [{}]", cc->hairstyle, cc->haircolor);
|
||||||
|
LogInfo("Beard [{}] Beard Color [{}]", cc->beard, cc->beardcolor);
|
||||||
|
|
||||||
|
/* Validate the char creation struct */
|
||||||
|
if (m_ClientVersionBit & EQ::versions::maskSoFAndLater) {
|
||||||
|
if (!CheckCharCreateInfoSoF(cc)) {
|
||||||
|
LogInfo("CheckCharCreateInfo did not validate the request (bad race/class/stats)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!CheckCharCreateInfoTitanium(cc)) {
|
||||||
|
LogInfo("CheckCharCreateInfo did not validate the request (bad race/class/stats)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert incoming cc_s to the new PlayerProfile_Struct */
|
||||||
|
memset(&pp, 0, sizeof(PlayerProfile_Struct)); // start building the profile
|
||||||
|
|
||||||
|
strn0cpy(pp.name, name, sizeof(pp.name));
|
||||||
|
|
||||||
|
pp.race = cc->race;
|
||||||
|
pp.class_ = cc->class_;
|
||||||
|
pp.gender = cc->gender;
|
||||||
|
pp.deity = cc->deity;
|
||||||
|
pp.STR = cc->STR;
|
||||||
|
pp.STA = cc->STA;
|
||||||
|
pp.AGI = cc->AGI;
|
||||||
|
pp.DEX = cc->DEX;
|
||||||
|
pp.WIS = cc->WIS;
|
||||||
|
pp.INT = cc->INT;
|
||||||
|
pp.CHA = cc->CHA;
|
||||||
|
pp.face = cc->face;
|
||||||
|
pp.eyecolor1 = cc->eyecolor1;
|
||||||
|
pp.eyecolor2 = cc->eyecolor2;
|
||||||
|
pp.hairstyle = cc->hairstyle;
|
||||||
|
pp.haircolor = cc->haircolor;
|
||||||
|
pp.beard = cc->beard;
|
||||||
|
pp.beardcolor = cc->beardcolor;
|
||||||
|
pp.drakkin_heritage = cc->drakkin_heritage;
|
||||||
|
pp.drakkin_tattoo = cc->drakkin_tattoo;
|
||||||
|
pp.drakkin_details = cc->drakkin_details;
|
||||||
|
pp.birthday = bday;
|
||||||
|
pp.lastlogin = bday;
|
||||||
|
pp.level = 1;
|
||||||
|
pp.points = 5;
|
||||||
|
pp.cur_hp = 1000;
|
||||||
|
pp.hunger_level = 6000;
|
||||||
|
pp.thirst_level = 6000;
|
||||||
|
|
||||||
|
/* Set default skills for everybody */
|
||||||
|
pp.skills[EQ::skills::SkillSwimming] = RuleI(Skills, SwimmingStartValue);
|
||||||
|
pp.skills[EQ::skills::SkillSenseHeading] = RuleI(Skills, SenseHeadingStartValue);
|
||||||
|
|
||||||
|
/* Set Racial and Class specific language and skills */
|
||||||
|
SetRacialLanguages(&pp);
|
||||||
|
SetRaceStartingSkills(&pp);
|
||||||
|
SetClassStartingSkills(&pp);
|
||||||
|
SetClassLanguages(&pp);
|
||||||
|
|
||||||
|
memset(pp.spell_book, std::numeric_limits<uint8>::max(), (sizeof(uint32) * EQ::spells::SPELLBOOK_SIZE));
|
||||||
|
memset(pp.mem_spells, std::numeric_limits<uint8>::max(), (sizeof(uint32) * EQ::spells::SPELL_GEM_COUNT));
|
||||||
|
|
||||||
|
for (auto& b : pp.buffs) {
|
||||||
|
b.spellid = std::numeric_limits<uint16>::max();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If server is PVP by default, make all character set to it. */
|
||||||
|
pp.pvp = database.GetServerType() == 1 ? 1 : 0;
|
||||||
|
|
||||||
|
/* If it is an SoF Client and the SoF Start Zone rule is set, send new chars there */
|
||||||
|
if (m_ClientVersionBit & EQ::versions::maskSoFAndLater) {
|
||||||
|
LogInfo("Found [SoFStartZoneID] rule setting [{}]", RuleI(World, SoFStartZoneID));
|
||||||
|
if (RuleI(World, SoFStartZoneID) > 0) {
|
||||||
|
pp.zone_id = RuleI(World, SoFStartZoneID);
|
||||||
|
cc->start_zone = pp.zone_id;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogInfo("Found [TitaniumStartZoneID] rule setting [{}]", RuleI(World, TitaniumStartZoneID));
|
||||||
|
if (RuleI(World, TitaniumStartZoneID) > 0) { /* if there's a startzone variable put them in there */
|
||||||
|
pp.zone_id = RuleI(World, TitaniumStartZoneID);
|
||||||
|
cc->start_zone = pp.zone_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* use normal starting zone logic to either get defaults, or if startzone was set, load that from the db table.*/
|
||||||
|
const bool is_valid_start_zone = content_db.GetStartZone(&pp, cc, m_ClientVersionBit & EQ::versions::maskTitaniumAndEarlier);
|
||||||
|
if (!is_valid_start_zone){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pp.zone_id) {
|
||||||
|
pp.zone_id = Zones::QEYNOS;
|
||||||
|
|
||||||
|
pp.x = pp.y = pp.z = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8 slot_id = 1; slot_id < 5; slot_id++) {
|
||||||
|
pp.binds[slot_id].zone_id = pp.zone_id;
|
||||||
|
pp.binds[slot_id].x = pp.x;
|
||||||
|
pp.binds[slot_id].y = pp.y;
|
||||||
|
pp.binds[slot_id].z = pp.z;
|
||||||
|
pp.binds[slot_id].heading = pp.heading;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Overrides if we have the tutorial flag set! */
|
||||||
|
if (cc->tutorial && RuleB(World, EnableTutorialButton)) {
|
||||||
|
pp.zone_id = RuleI(World, TutorialZoneID);
|
||||||
|
|
||||||
|
auto z = GetZone(pp.zone_id);
|
||||||
|
if (z) {
|
||||||
|
pp.x = z->safe_x;
|
||||||
|
pp.y = z->safe_y;
|
||||||
|
pp.z = z->safe_z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Will either be the same as home or tutorial if enabled. */
|
||||||
|
if (RuleB(World, StartZoneSameAsBindOnCreation)) {
|
||||||
|
pp.binds[0].zone_id = pp.zone_id;
|
||||||
|
pp.binds[0].x = pp.x;
|
||||||
|
pp.binds[0].y = pp.y;
|
||||||
|
pp.binds[0].z = pp.z;
|
||||||
|
pp.binds[0].heading = pp.heading;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetZone(pp.zone_id)) {
|
||||||
|
LogInfo(
|
||||||
|
"Current location zone_short_name [{}] zone_id [{}] x [{:.2f}] y [{:.2f}] z [{:.2f}] heading [{:.2f}]",
|
||||||
|
ZoneName(pp.zone_id),
|
||||||
|
pp.zone_id,
|
||||||
|
pp.x,
|
||||||
|
pp.y,
|
||||||
|
pp.z,
|
||||||
|
pp.heading
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetZone(pp.binds[0].zone_id)) {
|
||||||
|
LogInfo(
|
||||||
|
"Bind location zone_short_name [{}] zone_id [{}] x [{:.2f}] y [{:.2f}] z [{:.2f}] heading [{:.2f}]",
|
||||||
|
ZoneName(pp.binds[0].zone_id),
|
||||||
|
pp.binds[0].zone_id,
|
||||||
|
pp.binds[0].x,
|
||||||
|
pp.binds[0].y,
|
||||||
|
pp.binds[0].z,
|
||||||
|
pp.binds[4].heading
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetZone(pp.binds[4].zone_id)) {
|
||||||
|
LogInfo(
|
||||||
|
"Home location zone_short_name [{}] zone_id [{}] x [{:.2f}] y [{:.2f}] z [{:.2f}] heading [{:.2f}]",
|
||||||
|
ZoneName(pp.binds[4].zone_id),
|
||||||
|
pp.binds[4].zone_id,
|
||||||
|
pp.binds[4].x,
|
||||||
|
pp.binds[4].y,
|
||||||
|
pp.binds[4].z,
|
||||||
|
pp.binds[4].heading
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
content_db.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin());
|
||||||
|
|
||||||
|
const bool success = StoreCharacter(GetAccountID(), &pp, &inv);
|
||||||
|
|
||||||
|
LogInfo("Character creation {} for [{}]", success ? "succeeded" : "failed", pp.name);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
// returns true if the request is ok, false if there's an error
|
// returns true if the request is ok, false if there's an error
|
||||||
bool CheckCharCreateInfoSoF(CharCreate_Struct *cc)
|
bool CheckCharCreateInfoSoF(CharCreate_Struct *cc)
|
||||||
{
|
{
|
||||||
@@ -1651,7 +1891,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct* cc)
|
|||||||
|
|
||||||
LogInfo("Validating char creation info");
|
LogInfo("Validating char creation info");
|
||||||
|
|
||||||
CharCreateCombination class_combo;
|
RaceClassCombos class_combo;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int combos = character_create_race_class_combos.size();
|
int combos = character_create_race_class_combos.size();
|
||||||
for (int i = 0; i < combos; ++i) {
|
for (int i = 0; i < combos; ++i) {
|
||||||
@@ -1671,7 +1911,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct* cc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 allocs = character_create_allocations.size();
|
uint32 allocs = character_create_allocations.size();
|
||||||
CharCreatePointAllocation allocation = { 0 };
|
RaceClassAllocation allocation = {0};
|
||||||
found = false;
|
found = false;
|
||||||
for (int i = 0; i < allocs; ++i) {
|
for (int i = 0; i < allocs; ++i) {
|
||||||
if (character_create_allocations[i].Index == class_combo.AllocationIndex) {
|
if (character_create_allocations[i].Index == class_combo.AllocationIndex) {
|
||||||
@@ -1910,313 +2150,6 @@ bool CheckCharCreateInfoTitanium(CharCreate_Struct* cc)
|
|||||||
return Charerrors == 0;
|
return Charerrors == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: these hard coded values should be settable somewhere somehow.
|
|
||||||
//Also they're not 100% accurate so if I don't make them settable somehow
|
|
||||||
//we need to go back and match them to the logic that was ripped out of zone
|
|
||||||
void GetResistsForCharacterCreate(CharCreate_Struct* cc,
|
|
||||||
bool sofAndLater,
|
|
||||||
uint32 &cold_resist,
|
|
||||||
uint32& fire_resist,
|
|
||||||
uint32& magic_resist,
|
|
||||||
uint32& disease_resist,
|
|
||||||
uint32& poison_resist,
|
|
||||||
uint32& corruption_resist)
|
|
||||||
{
|
|
||||||
if (!sofAndLater) {
|
|
||||||
cold_resist = 25;
|
|
||||||
fire_resist = 25;
|
|
||||||
magic_resist = 25;
|
|
||||||
disease_resist = 15;
|
|
||||||
poison_resist = 15;
|
|
||||||
corruption_resist = 15;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharCreateCombination class_combo;
|
|
||||||
bool found = false;
|
|
||||||
int combos = character_create_race_class_combos.size();
|
|
||||||
for (int i = 0; i < combos; ++i) {
|
|
||||||
if (character_create_race_class_combos[i].Class == cc->class_ &&
|
|
||||||
character_create_race_class_combos[i].Race == cc->race &&
|
|
||||||
character_create_race_class_combos[i].Deity == cc->deity &&
|
|
||||||
character_create_race_class_combos[i].Zone == cc->start_zone) {
|
|
||||||
class_combo = character_create_race_class_combos[i];
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
cold_resist = 25;
|
|
||||||
fire_resist = 25;
|
|
||||||
magic_resist = 25;
|
|
||||||
disease_resist = 15;
|
|
||||||
poison_resist = 15;
|
|
||||||
corruption_resist = 15;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharCreatePointAllocation allocation;
|
|
||||||
found = false;
|
|
||||||
combos = character_create_allocations.size();
|
|
||||||
for (int i = 0; i < combos; ++i) {
|
|
||||||
if (character_create_allocations[i].Index == class_combo.AllocationIndex) {
|
|
||||||
allocation = character_create_allocations[i];
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
cold_resist = 25;
|
|
||||||
fire_resist = 25;
|
|
||||||
magic_resist = 25;
|
|
||||||
disease_resist = 15;
|
|
||||||
poison_resist = 15;
|
|
||||||
corruption_resist = 15;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cold_resist = allocation.BaseResists[0];
|
|
||||||
fire_resist = allocation.BaseResists[1];
|
|
||||||
magic_resist = allocation.BaseResists[2];
|
|
||||||
disease_resist = allocation.BaseResists[3];
|
|
||||||
poison_resist = allocation.BaseResists[4];
|
|
||||||
corruption_resist = allocation.BaseResists[5];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
|
|
||||||
{
|
|
||||||
PlayerProfile_Struct pp;
|
|
||||||
EQ::InventoryProfile inv;
|
|
||||||
|
|
||||||
pp.SetPlayerProfileVersion(EQ::versions::ConvertClientVersionToMobVersion(EQ::versions::ConvertClientVersionBitToClientVersion(m_ClientVersionBit)));
|
|
||||||
inv.SetInventoryVersion(EQ::versions::ConvertClientVersionBitToClientVersion(m_ClientVersionBit));
|
|
||||||
inv.SetGMInventory(false); // character cannot have gm flag at this point
|
|
||||||
|
|
||||||
time_t bday = time(nullptr);
|
|
||||||
in_addr in;
|
|
||||||
|
|
||||||
const uint32 stats_sum = (
|
|
||||||
cc->AGI +
|
|
||||||
cc->CHA +
|
|
||||||
cc->DEX +
|
|
||||||
cc->INT +
|
|
||||||
cc->STA +
|
|
||||||
cc->STR +
|
|
||||||
cc->WIS
|
|
||||||
);
|
|
||||||
|
|
||||||
in.s_addr = GetIP();
|
|
||||||
|
|
||||||
LogInfo(
|
|
||||||
"Character creation request from [{}] LS [{}] [{}] [{}]",
|
|
||||||
GetCLE()->LSName(),
|
|
||||||
GetCLE()->LSID(),
|
|
||||||
inet_ntoa(in),
|
|
||||||
GetPort()
|
|
||||||
);
|
|
||||||
LogInfo("Name [{}]", name);
|
|
||||||
LogInfo(
|
|
||||||
"race [{}] class [{}] gender [{}] deity [{}] start_zone [{}] tutorial [{}]",
|
|
||||||
cc->race,
|
|
||||||
cc->class_,
|
|
||||||
cc->gender,
|
|
||||||
cc->deity,
|
|
||||||
cc->start_zone,
|
|
||||||
cc->tutorial ? "true" : "false"
|
|
||||||
);
|
|
||||||
LogInfo(
|
|
||||||
"AGI [{}] CHA [{}] DEX [{}] INT [{}] STA [{}] STR [{}] WIS [{}] Total [{}]",
|
|
||||||
cc->AGI,
|
|
||||||
cc->CHA,
|
|
||||||
cc->DEX,
|
|
||||||
cc->INT,
|
|
||||||
cc->STA,
|
|
||||||
cc->STR,
|
|
||||||
cc->WIS,
|
|
||||||
stats_sum
|
|
||||||
);
|
|
||||||
LogInfo("Face [{}] Eye Colors [{}] [{}]", cc->face, cc->eyecolor1, cc->eyecolor2);
|
|
||||||
LogInfo("Hair [{}] Hair Color [{}]", cc->hairstyle, cc->haircolor);
|
|
||||||
LogInfo("Beard [{}] Beard Color [{}]", cc->beard, cc->beardcolor);
|
|
||||||
|
|
||||||
/* Validate the char creation struct */
|
|
||||||
if (m_ClientVersionBit & EQ::versions::maskSoFAndLater) {
|
|
||||||
if (!CheckCharCreateInfoSoF(cc)) {
|
|
||||||
LogInfo("CheckCharCreateInfo did not validate the request (bad race/class/stats)");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!CheckCharCreateInfoTitanium(cc)) {
|
|
||||||
LogInfo("CheckCharCreateInfo did not validate the request (bad race/class/stats)");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert incoming cc_s to the new PlayerProfile_Struct */
|
|
||||||
memset(&pp, 0, sizeof(PlayerProfile_Struct)); // start building the profile
|
|
||||||
|
|
||||||
strn0cpy(pp.name, name, sizeof(pp.name));
|
|
||||||
|
|
||||||
pp.race = cc->race;
|
|
||||||
pp.class_ = cc->class_;
|
|
||||||
pp.gender = cc->gender;
|
|
||||||
pp.deity = cc->deity;
|
|
||||||
pp.STR = cc->STR;
|
|
||||||
pp.STA = cc->STA;
|
|
||||||
pp.AGI = cc->AGI;
|
|
||||||
pp.DEX = cc->DEX;
|
|
||||||
pp.WIS = cc->WIS;
|
|
||||||
pp.INT = cc->INT;
|
|
||||||
pp.CHA = cc->CHA;
|
|
||||||
pp.face = cc->face;
|
|
||||||
pp.eyecolor1 = cc->eyecolor1;
|
|
||||||
pp.eyecolor2 = cc->eyecolor2;
|
|
||||||
pp.hairstyle = cc->hairstyle;
|
|
||||||
pp.haircolor = cc->haircolor;
|
|
||||||
pp.beard = cc->beard;
|
|
||||||
pp.beardcolor = cc->beardcolor;
|
|
||||||
pp.drakkin_heritage = cc->drakkin_heritage;
|
|
||||||
pp.drakkin_tattoo = cc->drakkin_tattoo;
|
|
||||||
pp.drakkin_details = cc->drakkin_details;
|
|
||||||
pp.birthday = bday;
|
|
||||||
pp.lastlogin = bday;
|
|
||||||
pp.level = 1;
|
|
||||||
pp.points = 5;
|
|
||||||
pp.cur_hp = 1000;
|
|
||||||
pp.hunger_level = 6000;
|
|
||||||
pp.thirst_level = 6000;
|
|
||||||
|
|
||||||
GetResistsForCharacterCreate(cc,
|
|
||||||
m_ClientVersionBit & EQ::versions::maskSoFAndLater,
|
|
||||||
pp.cold_resist,
|
|
||||||
pp.fire_resist,
|
|
||||||
pp.magic_resist,
|
|
||||||
pp.disease_resist,
|
|
||||||
pp.poison_resist,
|
|
||||||
pp.corruption_resist);
|
|
||||||
|
|
||||||
/* Set default skills for everybody */
|
|
||||||
pp.skills[EQ::skills::SkillSwimming] = RuleI(Skills, SwimmingStartValue);
|
|
||||||
pp.skills[EQ::skills::SkillSenseHeading] = RuleI(Skills, SenseHeadingStartValue);
|
|
||||||
|
|
||||||
/* Set Racial and Class specific language and skills */
|
|
||||||
SetRacialLanguages(&pp);
|
|
||||||
SetRaceStartingSkills(&pp);
|
|
||||||
SetClassStartingSkills(&pp);
|
|
||||||
SetClassLanguages(&pp);
|
|
||||||
|
|
||||||
memset(pp.spell_book, std::numeric_limits<uint8>::max(), (sizeof(uint32) * EQ::spells::SPELLBOOK_SIZE));
|
|
||||||
memset(pp.mem_spells, std::numeric_limits<uint8>::max(), (sizeof(uint32) * EQ::spells::SPELL_GEM_COUNT));
|
|
||||||
|
|
||||||
for (auto& b : pp.buffs) {
|
|
||||||
b.spellid = std::numeric_limits<uint16>::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If server is PVP by default, make all character set to it. */
|
|
||||||
pp.pvp = database.GetServerType() == 1 ? 1 : 0;
|
|
||||||
|
|
||||||
/* If it is an SoF Client and the SoF Start Zone rule is set, send new chars there */
|
|
||||||
if (m_ClientVersionBit & EQ::versions::maskSoFAndLater) {
|
|
||||||
LogInfo("Found [SoFStartZoneID] rule setting [{}]", RuleI(World, SoFStartZoneID));
|
|
||||||
if (RuleI(World, SoFStartZoneID) > 0) {
|
|
||||||
pp.zone_id = RuleI(World, SoFStartZoneID);
|
|
||||||
cc->start_zone = pp.zone_id;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LogInfo("Found [TitaniumStartZoneID] rule setting [{}]", RuleI(World, TitaniumStartZoneID));
|
|
||||||
if (RuleI(World, TitaniumStartZoneID) > 0) { /* if there's a startzone variable put them in there */
|
|
||||||
pp.zone_id = RuleI(World, TitaniumStartZoneID);
|
|
||||||
cc->start_zone = pp.zone_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* use normal starting zone logic to either get defaults, or if startzone was set, load that from the db table.*/
|
|
||||||
const bool is_valid_start_zone = content_db.GetStartZone(&pp, cc, m_ClientVersionBit & EQ::versions::maskTitaniumAndEarlier);
|
|
||||||
if (!is_valid_start_zone){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pp.zone_id) {
|
|
||||||
pp.zone_id = Zones::QEYNOS;
|
|
||||||
|
|
||||||
pp.x = pp.y = pp.z = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint8 slot_id = 1; slot_id < 5; slot_id++) {
|
|
||||||
pp.binds[slot_id].zone_id = pp.zone_id;
|
|
||||||
pp.binds[slot_id].x = pp.x;
|
|
||||||
pp.binds[slot_id].y = pp.y;
|
|
||||||
pp.binds[slot_id].z = pp.z;
|
|
||||||
pp.binds[slot_id].heading = pp.heading;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Overrides if we have the tutorial flag set! */
|
|
||||||
if (cc->tutorial && RuleB(World, EnableTutorialButton)) {
|
|
||||||
pp.zone_id = RuleI(World, TutorialZoneID);
|
|
||||||
|
|
||||||
auto z = GetZone(pp.zone_id);
|
|
||||||
if (z) {
|
|
||||||
pp.x = z->safe_x;
|
|
||||||
pp.y = z->safe_y;
|
|
||||||
pp.z = z->safe_z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Will either be the same as home or tutorial if enabled. */
|
|
||||||
if (RuleB(World, StartZoneSameAsBindOnCreation)) {
|
|
||||||
pp.binds[0].zone_id = pp.zone_id;
|
|
||||||
pp.binds[0].x = pp.x;
|
|
||||||
pp.binds[0].y = pp.y;
|
|
||||||
pp.binds[0].z = pp.z;
|
|
||||||
pp.binds[0].heading = pp.heading;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetZone(pp.zone_id)) {
|
|
||||||
LogInfo(
|
|
||||||
"Current location zone_short_name [{}] zone_id [{}] x [{:.2f}] y [{:.2f}] z [{:.2f}] heading [{:.2f}]",
|
|
||||||
ZoneName(pp.zone_id),
|
|
||||||
pp.zone_id,
|
|
||||||
pp.x,
|
|
||||||
pp.y,
|
|
||||||
pp.z,
|
|
||||||
pp.heading
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetZone(pp.binds[0].zone_id)) {
|
|
||||||
LogInfo(
|
|
||||||
"Bind location zone_short_name [{}] zone_id [{}] x [{:.2f}] y [{:.2f}] z [{:.2f}] heading [{:.2f}]",
|
|
||||||
ZoneName(pp.binds[0].zone_id),
|
|
||||||
pp.binds[0].zone_id,
|
|
||||||
pp.binds[0].x,
|
|
||||||
pp.binds[0].y,
|
|
||||||
pp.binds[0].z,
|
|
||||||
pp.binds[4].heading
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetZone(pp.binds[4].zone_id)) {
|
|
||||||
LogInfo(
|
|
||||||
"Home location zone_short_name [{}] zone_id [{}] x [{:.2f}] y [{:.2f}] z [{:.2f}] heading [{:.2f}]",
|
|
||||||
ZoneName(pp.binds[4].zone_id),
|
|
||||||
pp.binds[4].zone_id,
|
|
||||||
pp.binds[4].x,
|
|
||||||
pp.binds[4].y,
|
|
||||||
pp.binds[4].z,
|
|
||||||
pp.binds[4].heading
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
content_db.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin());
|
|
||||||
|
|
||||||
const bool success = StoreCharacter(GetAccountID(), &pp, &inv);
|
|
||||||
|
|
||||||
LogInfo("Character creation {} for [{}]", success ? "succeeded" : "failed", pp.name);
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::SetClassStartingSkills(PlayerProfile_Struct *pp)
|
void Client::SetClassStartingSkills(PlayerProfile_Struct *pp)
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i <= EQ::skills::HIGHEST_SKILL; ++i) {
|
for (uint32 i = 0; i <= EQ::skills::HIGHEST_SKILL; ++i) {
|
||||||
@@ -2538,3 +2471,34 @@ void Client::SendGuildTributeOptInToggle(const GuildTributeMemberToggle *in)
|
|||||||
QueuePacket(outapp);
|
QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::SendUnsupportedClientPacket(const std::string& message)
|
||||||
|
{
|
||||||
|
EQApplicationPacket packet(OP_SendCharInfo, sizeof(CharacterSelect_Struct) + sizeof(CharacterSelectEntry_Struct));
|
||||||
|
|
||||||
|
unsigned char* buff_ptr = packet.pBuffer;
|
||||||
|
auto cs = (CharacterSelect_Struct*) buff_ptr;
|
||||||
|
|
||||||
|
cs->CharCount = 1;
|
||||||
|
cs->TotalChars = 1;
|
||||||
|
|
||||||
|
buff_ptr += sizeof(CharacterSelect_Struct);
|
||||||
|
|
||||||
|
auto e = (CharacterSelectEntry_Struct*) buff_ptr;
|
||||||
|
|
||||||
|
strcpy(e->Name, message.c_str());
|
||||||
|
|
||||||
|
e->Race = Race::Human;
|
||||||
|
e->Class = Class::Warrior;
|
||||||
|
e->Level = 1;
|
||||||
|
e->ShroudClass = e->Class;
|
||||||
|
e->ShroudRace = e->Race;
|
||||||
|
e->Zone = std::numeric_limits<uint16>::max();
|
||||||
|
e->Instance = 0;
|
||||||
|
e->Gender = Gender::Male;
|
||||||
|
e->GoHome = 0;
|
||||||
|
e->Tutorial = 0;
|
||||||
|
e->Enabled = 0;
|
||||||
|
|
||||||
|
QueuePacket(&packet);
|
||||||
|
}
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ private:
|
|||||||
EQStreamInterface* eqs;
|
EQStreamInterface* eqs;
|
||||||
bool CanTradeFVNoDropItem();
|
bool CanTradeFVNoDropItem();
|
||||||
void RecordPossibleHack(const std::string& message);
|
void RecordPossibleHack(const std::string& message);
|
||||||
|
void SendUnsupportedClientPacket(const std::string& message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool CheckCharCreateInfoSoF(CharCreate_Struct *cc);
|
||||||
|
bool CheckCharCreateInfoTitanium(CharCreate_Struct *cc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
struct CharCreatePointAllocation
|
|
||||||
{
|
|
||||||
unsigned int Index;
|
|
||||||
unsigned int BaseStats[7];
|
|
||||||
unsigned int DefaultPointAllocation[7];
|
|
||||||
unsigned int BaseResists[7];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CharCreateCombination {
|
|
||||||
unsigned int ExpansionRequired;
|
|
||||||
unsigned int Race;
|
|
||||||
unsigned int Class;
|
|
||||||
unsigned int Deity;
|
|
||||||
unsigned int AllocationIndex;
|
|
||||||
unsigned int Zone;
|
|
||||||
};
|
|
||||||
@@ -294,6 +294,13 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv)
|
|||||||
database.ClearBuyerDetails();
|
database.ClearBuyerDetails();
|
||||||
LogInfo("Clearing buyer table details");
|
LogInfo("Clearing buyer table details");
|
||||||
|
|
||||||
|
if (RuleB(Bots, Enabled)) {
|
||||||
|
LogInfo("Clearing [bot_pet_buffs] table of stale entries");
|
||||||
|
database.QueryDatabase(
|
||||||
|
"DELETE FROM bot_pet_buffs WHERE NOT EXISTS (SELECT * FROM bot_pets WHERE bot_pets.pets_index = bot_pet_buffs.pets_index)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!content_db.LoadItems(hotfix_name)) {
|
if (!content_db.LoadItems(hotfix_name)) {
|
||||||
LogError("Error: Could not load item data. But ignoring");
|
LogError("Error: Could not load item data. But ignoring");
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-11
@@ -25,15 +25,14 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "sof_char_create_data.h"
|
#include "sof_char_create_data.h"
|
||||||
#include "race_combos.h"
|
|
||||||
#include "../common/repositories/character_instance_safereturns_repository.h"
|
#include "../common/repositories/character_instance_safereturns_repository.h"
|
||||||
#include "../common/repositories/criteria/content_filter_criteria.h"
|
#include "../common/repositories/criteria/content_filter_criteria.h"
|
||||||
#include "../common/zone_store.h"
|
#include "../common/zone_store.h"
|
||||||
|
|
||||||
WorldDatabase database;
|
WorldDatabase database;
|
||||||
WorldDatabase content_db;
|
WorldDatabase content_db;
|
||||||
extern std::vector<CharCreatePointAllocation> character_create_allocations;
|
extern std::vector<RaceClassAllocation> character_create_allocations;
|
||||||
extern std::vector<CharCreateCombination> character_create_race_class_combos;
|
extern std::vector<RaceClassCombos> character_create_race_class_combos;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -808,7 +807,7 @@ bool WorldDatabase::LoadCharacterCreateAllocations()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
CharCreatePointAllocation allocate;
|
RaceClassAllocation allocate;
|
||||||
allocate.Index = Strings::ToInt(row[0]);
|
allocate.Index = Strings::ToInt(row[0]);
|
||||||
allocate.BaseStats[0] = Strings::ToInt(row[1]);
|
allocate.BaseStats[0] = Strings::ToInt(row[1]);
|
||||||
allocate.BaseStats[3] = Strings::ToInt(row[2]);
|
allocate.BaseStats[3] = Strings::ToInt(row[2]);
|
||||||
@@ -824,12 +823,6 @@ bool WorldDatabase::LoadCharacterCreateAllocations()
|
|||||||
allocate.DefaultPointAllocation[4] = Strings::ToInt(row[12]);
|
allocate.DefaultPointAllocation[4] = Strings::ToInt(row[12]);
|
||||||
allocate.DefaultPointAllocation[5] = Strings::ToInt(row[13]);
|
allocate.DefaultPointAllocation[5] = Strings::ToInt(row[13]);
|
||||||
allocate.DefaultPointAllocation[6] = Strings::ToInt(row[14]);
|
allocate.DefaultPointAllocation[6] = Strings::ToInt(row[14]);
|
||||||
allocate.BaseResists[0] = Strings::ToInt(row[15]);
|
|
||||||
allocate.BaseResists[1] = Strings::ToInt(row[16]);
|
|
||||||
allocate.BaseResists[2] = Strings::ToInt(row[17]);
|
|
||||||
allocate.BaseResists[3] = Strings::ToInt(row[18]);
|
|
||||||
allocate.BaseResists[4] = Strings::ToInt(row[19]);
|
|
||||||
allocate.BaseResists[5] = Strings::ToInt(row[20]);
|
|
||||||
|
|
||||||
character_create_allocations.push_back(allocate);
|
character_create_allocations.push_back(allocate);
|
||||||
}
|
}
|
||||||
@@ -847,7 +840,7 @@ bool WorldDatabase::LoadCharacterCreateCombos()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
CharCreateCombination combo;
|
RaceClassCombos combo;
|
||||||
combo.AllocationIndex = Strings::ToInt(row[0]);
|
combo.AllocationIndex = Strings::ToInt(row[0]);
|
||||||
combo.Race = Strings::ToInt(row[1]);
|
combo.Race = Strings::ToInt(row[1]);
|
||||||
combo.Class = Strings::ToInt(row[2]);
|
combo.Class = Strings::ToInt(row[2]);
|
||||||
|
|||||||
+15
-3
@@ -1755,7 +1755,11 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
zoneserver_list.SendPacket(Zones::BAZAAR, pack);
|
auto trader = client_list.FindCLEByCharacterID(in->trader_buy_struct.trader_id);
|
||||||
|
if (trader) {
|
||||||
|
zoneserver_list.SendPacket(trader->zone(), trader->instance(), pack);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_BuyerMessaging: {
|
case ServerOP_BuyerMessaging: {
|
||||||
@@ -1775,12 +1779,20 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Barter_SellItem: {
|
case Barter_SellItem: {
|
||||||
zoneserver_list.SendPacket(Zones::BAZAAR, pack);
|
auto buyer = client_list.FindCharacter(in->buyer_name);
|
||||||
|
if (buyer) {
|
||||||
|
zoneserver_list.SendPacket(buyer->zone(), buyer->instance(), pack);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Barter_FailedTransaction:
|
case Barter_FailedTransaction:
|
||||||
case Barter_BuyerTransactionComplete: {
|
case Barter_BuyerTransactionComplete: {
|
||||||
zoneserver_list.SendPacket(in->zone_id, pack);
|
auto seller = client_list.FindCharacter(in->seller_name);
|
||||||
|
if (seller) {
|
||||||
|
zoneserver_list.SendPacket(seller->zone(), seller->instance(), pack);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ SET(zone_sources
|
|||||||
lua_buff.cpp
|
lua_buff.cpp
|
||||||
lua_corpse.cpp
|
lua_corpse.cpp
|
||||||
lua_client.cpp
|
lua_client.cpp
|
||||||
|
lua_database.cpp
|
||||||
lua_door.cpp
|
lua_door.cpp
|
||||||
lua_encounter.cpp
|
lua_encounter.cpp
|
||||||
lua_entity.cpp
|
lua_entity.cpp
|
||||||
@@ -110,6 +111,7 @@ SET(zone_sources
|
|||||||
perl_bot.cpp
|
perl_bot.cpp
|
||||||
perl_buff.cpp
|
perl_buff.cpp
|
||||||
perl_client.cpp
|
perl_client.cpp
|
||||||
|
perl_database.cpp
|
||||||
perl_doors.cpp
|
perl_doors.cpp
|
||||||
perl_entity.cpp
|
perl_entity.cpp
|
||||||
perl_expedition.cpp
|
perl_expedition.cpp
|
||||||
@@ -135,6 +137,7 @@ SET(zone_sources
|
|||||||
qglobals.cpp
|
qglobals.cpp
|
||||||
queryserv.cpp
|
queryserv.cpp
|
||||||
questmgr.cpp
|
questmgr.cpp
|
||||||
|
quest_db.cpp
|
||||||
quest_parser_collection.cpp
|
quest_parser_collection.cpp
|
||||||
raids.cpp
|
raids.cpp
|
||||||
raycast_mesh.cpp
|
raycast_mesh.cpp
|
||||||
@@ -215,6 +218,7 @@ SET(zone_headers
|
|||||||
lua_buff.h
|
lua_buff.h
|
||||||
lua_client.h
|
lua_client.h
|
||||||
lua_corpse.h
|
lua_corpse.h
|
||||||
|
lua_database.h
|
||||||
lua_door.h
|
lua_door.h
|
||||||
lua_encounter.h
|
lua_encounter.h
|
||||||
lua_entity.h
|
lua_entity.h
|
||||||
@@ -251,6 +255,7 @@ SET(zone_headers
|
|||||||
pathfinder_interface.h
|
pathfinder_interface.h
|
||||||
pathfinder_nav_mesh.h
|
pathfinder_nav_mesh.h
|
||||||
pathfinder_null.h
|
pathfinder_null.h
|
||||||
|
perl_database.h
|
||||||
perlpacket.h
|
perlpacket.h
|
||||||
petitions.h
|
petitions.h
|
||||||
pets.h
|
pets.h
|
||||||
@@ -260,6 +265,7 @@ SET(zone_headers
|
|||||||
queryserv.h
|
queryserv.h
|
||||||
quest_interface.h
|
quest_interface.h
|
||||||
questmgr.h
|
questmgr.h
|
||||||
|
quest_db.h
|
||||||
quest_parser_collection.h
|
quest_parser_collection.h
|
||||||
raids.h
|
raids.h
|
||||||
raycast_mesh.h
|
raycast_mesh.h
|
||||||
|
|||||||
+4
-1
@@ -1578,7 +1578,10 @@ bool Bot::Process()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanCloseMobProcess();
|
if (m_scan_close_mobs_timer.Check()) {
|
||||||
|
entity_list.ScanCloseMobs(this);
|
||||||
|
}
|
||||||
|
|
||||||
SpellProcess();
|
SpellProcess();
|
||||||
|
|
||||||
if (tic_timer.Check()) {
|
if (tic_timer.Check()) {
|
||||||
|
|||||||
@@ -828,7 +828,7 @@ bool BotDatabase::LoadTimers(Bot* b)
|
|||||||
BotTimer_Struct t{ };
|
BotTimer_Struct t{ };
|
||||||
|
|
||||||
for (const auto& e : l) {
|
for (const auto& e : l) {
|
||||||
if (t.timer_value < (Timer::GetCurrentTime() + t.recast_time)) {
|
if (e.timer_value < (Timer::GetCurrentTime() + e.recast_time)) {
|
||||||
t.timer_id = e.timer_id;
|
t.timer_id = e.timer_id;
|
||||||
t.timer_value = e.timer_value;
|
t.timer_value = e.timer_value;
|
||||||
t.recast_time = e.recast_time;
|
t.recast_time = e.recast_time;
|
||||||
@@ -1451,7 +1451,7 @@ bool BotDatabase::DeletePetBuffs(const uint32 bot_id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BotPetBuffsRepository::DeleteOne(database, saved_pet_index);
|
BotPetBuffsRepository::DeleteWhere(database, fmt::format("pets_index = {}", saved_pet_index));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+251
-5
@@ -8677,14 +8677,16 @@ int Client::GetAccountAge() {
|
|||||||
|
|
||||||
void Client::CheckRegionTypeChanges()
|
void Client::CheckRegionTypeChanges()
|
||||||
{
|
{
|
||||||
if (!zone->HasWaterMap())
|
if (!zone->HasWaterMap()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto new_region = zone->watermap->ReturnRegionType(glm::vec3(m_Position));
|
auto new_region = zone->watermap->ReturnRegionType(glm::vec3(m_Position));
|
||||||
|
|
||||||
// still same region, do nothing
|
// still same region, do nothing
|
||||||
if (last_region_type == new_region)
|
if (last_region_type == new_region) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If we got out of water clear any water aggro for water only npcs
|
// If we got out of water clear any water aggro for water only npcs
|
||||||
if (last_region_type == RegionTypeWater) {
|
if (last_region_type == RegionTypeWater) {
|
||||||
@@ -8695,14 +8697,16 @@ void Client::CheckRegionTypeChanges()
|
|||||||
last_region_type = new_region;
|
last_region_type = new_region;
|
||||||
|
|
||||||
// PVP is the only state we need to keep track of, so we can just return now for PVP servers
|
// PVP is the only state we need to keep track of, so we can just return now for PVP servers
|
||||||
if (RuleI(World, PVPSettings) > 0)
|
if (RuleI(World, PVPSettings) > 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (last_region_type == RegionTypePVP)
|
if (last_region_type == RegionTypePVP && RuleB(World, EnablePVPRegions)) {
|
||||||
temp_pvp = true;
|
temp_pvp = true;
|
||||||
else if (temp_pvp)
|
} else if (temp_pvp) {
|
||||||
temp_pvp = false;
|
temp_pvp = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Client::ProcessAggroMeter()
|
void Client::ProcessAggroMeter()
|
||||||
{
|
{
|
||||||
@@ -12316,6 +12320,248 @@ void Client::PlayerTradeEventLog(Trade *t, Trade *t2)
|
|||||||
RecordPlayerEventLogWithClient(trader2, PlayerEvent::TRADE, e);
|
RecordPlayerEventLogWithClient(trader2, PlayerEvent::TRADE, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::NPCHandinEventLog(Trade* t, NPC* n)
|
||||||
|
{
|
||||||
|
Client* c = t->GetOwner()->CastToClient();
|
||||||
|
|
||||||
|
std::vector<PlayerEvent::HandinEntry> hi = {};
|
||||||
|
std::vector<PlayerEvent::HandinEntry> ri = {};
|
||||||
|
PlayerEvent::HandinMoney hm{};
|
||||||
|
PlayerEvent::HandinMoney rm{};
|
||||||
|
|
||||||
|
if (
|
||||||
|
c->EntityVariableExists("HANDIN_ITEMS") &&
|
||||||
|
c->EntityVariableExists("HANDIN_MONEY") &&
|
||||||
|
c->EntityVariableExists("RETURN_ITEMS") &&
|
||||||
|
c->EntityVariableExists("RETURN_MONEY")
|
||||||
|
) {
|
||||||
|
const std::string& handin_items = c->GetEntityVariable("HANDIN_ITEMS");
|
||||||
|
const std::string& return_items = c->GetEntityVariable("RETURN_ITEMS");
|
||||||
|
const std::string& handin_money = c->GetEntityVariable("HANDIN_MONEY");
|
||||||
|
const std::string& return_money = c->GetEntityVariable("RETURN_MONEY");
|
||||||
|
|
||||||
|
// Handin Items
|
||||||
|
if (!handin_items.empty()) {
|
||||||
|
if (Strings::Contains(handin_items, ",")) {
|
||||||
|
const auto handin_data = Strings::Split(handin_items, ",");
|
||||||
|
for (const auto& h : handin_data) {
|
||||||
|
const auto item_data = Strings::Split(h, "|");
|
||||||
|
if (
|
||||||
|
item_data.size() == 3 &&
|
||||||
|
Strings::IsNumber(item_data[0]) &&
|
||||||
|
Strings::IsNumber(item_data[1]) &&
|
||||||
|
Strings::IsNumber(item_data[2])
|
||||||
|
) {
|
||||||
|
const uint32 item_id = Strings::ToUnsignedInt(item_data[0]);
|
||||||
|
if (item_id != 0) {
|
||||||
|
const auto* item = database.GetItem(item_id);
|
||||||
|
|
||||||
|
if (item) {
|
||||||
|
hi.emplace_back(
|
||||||
|
PlayerEvent::HandinEntry{
|
||||||
|
.item_id = item_id,
|
||||||
|
.item_name = item->Name,
|
||||||
|
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
||||||
|
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (Strings::Contains(handin_items, "|")) {
|
||||||
|
const auto item_data = Strings::Split(handin_items, "|");
|
||||||
|
if (
|
||||||
|
item_data.size() == 3 &&
|
||||||
|
Strings::IsNumber(item_data[0]) &&
|
||||||
|
Strings::IsNumber(item_data[1]) &&
|
||||||
|
Strings::IsNumber(item_data[2])
|
||||||
|
) {
|
||||||
|
const uint32 item_id = Strings::ToUnsignedInt(item_data[0]);
|
||||||
|
const auto* item = database.GetItem(item_id);
|
||||||
|
|
||||||
|
if (item) {
|
||||||
|
hi.emplace_back(
|
||||||
|
PlayerEvent::HandinEntry{
|
||||||
|
.item_id = item_id,
|
||||||
|
.item_name = item->Name,
|
||||||
|
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
||||||
|
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handin Money
|
||||||
|
if (!handin_money.empty()) {
|
||||||
|
const auto hms = Strings::Split(handin_money, "|");
|
||||||
|
|
||||||
|
hm.copper = Strings::ToUnsignedInt(hms[0]);
|
||||||
|
hm.silver = Strings::ToUnsignedInt(hms[1]);
|
||||||
|
hm.gold = Strings::ToUnsignedInt(hms[2]);
|
||||||
|
hm.platinum = Strings::ToUnsignedInt(hms[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return Items
|
||||||
|
if (!return_items.empty()) {
|
||||||
|
if (Strings::Contains(return_items, ",")) {
|
||||||
|
const auto return_data = Strings::Split(return_items, ",");
|
||||||
|
for (const auto& r : return_data) {
|
||||||
|
const auto item_data = Strings::Split(r, "|");
|
||||||
|
if (
|
||||||
|
item_data.size() == 3 &&
|
||||||
|
Strings::IsNumber(item_data[0]) &&
|
||||||
|
Strings::IsNumber(item_data[1]) &&
|
||||||
|
Strings::IsNumber(item_data[2])
|
||||||
|
) {
|
||||||
|
const uint32 item_id = Strings::ToUnsignedInt(item_data[0]);
|
||||||
|
const auto* item = database.GetItem(item_id);
|
||||||
|
|
||||||
|
if (item) {
|
||||||
|
ri.emplace_back(
|
||||||
|
PlayerEvent::HandinEntry{
|
||||||
|
.item_id = item_id,
|
||||||
|
.item_name = item->Name,
|
||||||
|
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
||||||
|
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (Strings::Contains(return_items, "|")) {
|
||||||
|
const auto item_data = Strings::Split(return_items, "|");
|
||||||
|
if (
|
||||||
|
item_data.size() == 3 &&
|
||||||
|
Strings::IsNumber(item_data[0]) &&
|
||||||
|
Strings::IsNumber(item_data[1]) &&
|
||||||
|
Strings::IsNumber(item_data[2])
|
||||||
|
) {
|
||||||
|
const uint32 item_id = Strings::ToUnsignedInt(item_data[0]);
|
||||||
|
const auto* item = database.GetItem(item_id);
|
||||||
|
|
||||||
|
if (item) {
|
||||||
|
ri.emplace_back(
|
||||||
|
PlayerEvent::HandinEntry{
|
||||||
|
.item_id = item_id,
|
||||||
|
.item_name = item->Name,
|
||||||
|
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
||||||
|
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return Money
|
||||||
|
if (!return_money.empty()) {
|
||||||
|
const auto rms = Strings::Split(return_money, "|");
|
||||||
|
rm.copper = static_cast<uint32>(Strings::ToUnsignedInt(rms[0]));
|
||||||
|
rm.silver = static_cast<uint32>(Strings::ToUnsignedInt(rms[1]));
|
||||||
|
rm.gold = static_cast<uint32>(Strings::ToUnsignedInt(rms[2]));
|
||||||
|
rm.platinum = static_cast<uint32>(Strings::ToUnsignedInt(rms[3]));
|
||||||
|
}
|
||||||
|
|
||||||
|
c->DeleteEntityVariable("HANDIN_ITEMS");
|
||||||
|
c->DeleteEntityVariable("HANDIN_MONEY");
|
||||||
|
c->DeleteEntityVariable("RETURN_ITEMS");
|
||||||
|
c->DeleteEntityVariable("RETURN_MONEY");
|
||||||
|
|
||||||
|
const bool handed_in_money = hm.platinum > 0 || hm.gold > 0 || hm.silver > 0 || hm.copper > 0;
|
||||||
|
|
||||||
|
const bool event_has_data_to_record = (
|
||||||
|
!hi.empty() || handed_in_money
|
||||||
|
);
|
||||||
|
|
||||||
|
if (player_event_logs.IsEventEnabled(PlayerEvent::NPC_HANDIN) && event_has_data_to_record) {
|
||||||
|
auto e = PlayerEvent::HandinEvent{
|
||||||
|
.npc_id = n->GetNPCTypeID(),
|
||||||
|
.npc_name = n->GetCleanName(),
|
||||||
|
.handin_items = hi,
|
||||||
|
.handin_money = hm,
|
||||||
|
.return_items = ri,
|
||||||
|
.return_money = rm,
|
||||||
|
.is_quest_handin = true
|
||||||
|
};
|
||||||
|
|
||||||
|
RecordPlayerEventLogWithClient(c, PlayerEvent::NPC_HANDIN, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 item_count = 0;
|
||||||
|
|
||||||
|
hm.platinum = t->pp;
|
||||||
|
hm.gold = t->gp;
|
||||||
|
hm.silver = t->sp;
|
||||||
|
hm.copper = t->cp;
|
||||||
|
|
||||||
|
for (uint16 i = EQ::invslot::TRADE_BEGIN; i <= EQ::invslot::TRADE_NPC_END; i++) {
|
||||||
|
if (c->GetInv().GetItem(i)) {
|
||||||
|
item_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hi.reserve(item_count);
|
||||||
|
|
||||||
|
if (item_count > 0) {
|
||||||
|
for (uint16 i = EQ::invslot::TRADE_BEGIN; i <= EQ::invslot::TRADE_NPC_END; i++) {
|
||||||
|
const EQ::ItemInstance* inst = c->GetInv().GetItem(i);
|
||||||
|
if (inst) {
|
||||||
|
hi.emplace_back(
|
||||||
|
PlayerEvent::HandinEntry{
|
||||||
|
.item_id = inst->GetItem()->ID,
|
||||||
|
.item_name = inst->GetItem()->Name,
|
||||||
|
.charges = static_cast<uint16>(inst->GetCharges()),
|
||||||
|
.attuned = inst->IsAttuned()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (inst->IsClassBag()) {
|
||||||
|
for (uint8 j = EQ::invbag::SLOT_BEGIN; j <= EQ::invbag::SLOT_END; j++) {
|
||||||
|
inst = c->GetInv().GetItem(i, j);
|
||||||
|
if (inst) {
|
||||||
|
hi.emplace_back(
|
||||||
|
PlayerEvent::HandinEntry{
|
||||||
|
.item_id = inst->GetItem()->ID,
|
||||||
|
.item_name = inst->GetItem()->Name,
|
||||||
|
.charges = static_cast<uint16>(inst->GetCharges()),
|
||||||
|
.attuned = inst->IsAttuned()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool handed_in_money = hm.platinum > 0 || hm.gold > 0 || hm.silver > 0 || hm.copper > 0;
|
||||||
|
|
||||||
|
ri = hi;
|
||||||
|
rm = hm;
|
||||||
|
|
||||||
|
const bool event_has_data_to_record = !hi.empty() || handed_in_money;
|
||||||
|
|
||||||
|
if (player_event_logs.IsEventEnabled(PlayerEvent::NPC_HANDIN) && event_has_data_to_record) {
|
||||||
|
auto e = PlayerEvent::HandinEvent{
|
||||||
|
.npc_id = n->GetNPCTypeID(),
|
||||||
|
.npc_name = n->GetCleanName(),
|
||||||
|
.handin_items = hi,
|
||||||
|
.handin_money = hm,
|
||||||
|
.return_items = ri,
|
||||||
|
.return_money = rm,
|
||||||
|
.is_quest_handin = false
|
||||||
|
};
|
||||||
|
|
||||||
|
RecordPlayerEventLogWithClient(c, PlayerEvent::NPC_HANDIN, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Client::ShowSpells(Client* c, ShowSpellType show_spell_type)
|
void Client::ShowSpells(Client* c, ShowSpellType show_spell_type)
|
||||||
{
|
{
|
||||||
std::string spell_string;
|
std::string spell_string;
|
||||||
|
|||||||
+2
-1
@@ -597,7 +597,7 @@ public:
|
|||||||
inline uint8 GetBaseINT() const { return m_pp.INT; }
|
inline uint8 GetBaseINT() const { return m_pp.INT; }
|
||||||
inline uint8 GetBaseAGI() const { return m_pp.AGI; }
|
inline uint8 GetBaseAGI() const { return m_pp.AGI; }
|
||||||
inline uint8 GetBaseWIS() const { return m_pp.WIS; }
|
inline uint8 GetBaseWIS() const { return m_pp.WIS; }
|
||||||
inline uint8 GetBaseCorrup() const { return m_pp.corruption_resist; }
|
inline uint8 GetBaseCorrup() const { return 15; } // Same for all
|
||||||
inline uint8 GetBasePhR() const { return 0; } // Guessing at 0 as base
|
inline uint8 GetBasePhR() const { return 0; } // Guessing at 0 as base
|
||||||
|
|
||||||
inline virtual int32 GetHeroicSTR() const { return itembonuses.HeroicSTR; }
|
inline virtual int32 GetHeroicSTR() const { return itembonuses.HeroicSTR; }
|
||||||
@@ -2227,6 +2227,7 @@ private:
|
|||||||
bool CanTradeFVNoDropItem();
|
bool CanTradeFVNoDropItem();
|
||||||
void SendMobPositions();
|
void SendMobPositions();
|
||||||
void PlayerTradeEventLog(Trade *t, Trade *t2);
|
void PlayerTradeEventLog(Trade *t, Trade *t2);
|
||||||
|
void NPCHandinEventLog(Trade* t, NPC* n);
|
||||||
|
|
||||||
// full and partial mail key cache
|
// full and partial mail key cache
|
||||||
std::string m_mail_key_full;
|
std::string m_mail_key_full;
|
||||||
|
|||||||
+295
-5
@@ -1009,7 +1009,65 @@ int Client::CalcHaste()
|
|||||||
//in Mob::ResistSpell
|
//in Mob::ResistSpell
|
||||||
int32 Client::CalcMR()
|
int32 Client::CalcMR()
|
||||||
{
|
{
|
||||||
MR = m_pp.magic_resist;
|
//racial bases
|
||||||
|
switch (GetBaseRace()) {
|
||||||
|
case HUMAN:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case BARBARIAN:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case ERUDITE:
|
||||||
|
MR = 30;
|
||||||
|
break;
|
||||||
|
case WOOD_ELF:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case HIGH_ELF:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case DARK_ELF:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case HALF_ELF:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case DWARF:
|
||||||
|
MR = 30;
|
||||||
|
break;
|
||||||
|
case TROLL:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case OGRE:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case HALFLING:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case GNOME:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case IKSAR:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case VAHSHIR:
|
||||||
|
MR = 25;
|
||||||
|
break;
|
||||||
|
case FROGLOK:
|
||||||
|
MR = 30;
|
||||||
|
break;
|
||||||
|
case DRAKKIN:
|
||||||
|
{
|
||||||
|
MR = 25;
|
||||||
|
if (GetDrakkinHeritage() == 2)
|
||||||
|
MR += 10;
|
||||||
|
else if (GetDrakkinHeritage() == 5)
|
||||||
|
MR += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
MR = 20;
|
||||||
|
}
|
||||||
MR += itembonuses.MR + spellbonuses.MR + aabonuses.MR;
|
MR += itembonuses.MR + spellbonuses.MR + aabonuses.MR;
|
||||||
if (GetClass() == Class::Warrior || GetClass() == Class::Berserker) {
|
if (GetClass() == Class::Warrior || GetClass() == Class::Berserker) {
|
||||||
MR += GetLevel() / 2;
|
MR += GetLevel() / 2;
|
||||||
@@ -1025,7 +1083,65 @@ int32 Client::CalcMR()
|
|||||||
|
|
||||||
int32 Client::CalcFR()
|
int32 Client::CalcFR()
|
||||||
{
|
{
|
||||||
FR = m_pp.fire_resist;
|
//racial bases
|
||||||
|
switch (GetBaseRace()) {
|
||||||
|
case HUMAN:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case BARBARIAN:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case ERUDITE:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case WOOD_ELF:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case HIGH_ELF:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case DARK_ELF:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case HALF_ELF:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case DWARF:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case TROLL:
|
||||||
|
FR = 5;
|
||||||
|
break;
|
||||||
|
case OGRE:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case HALFLING:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case GNOME:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case IKSAR:
|
||||||
|
FR = 30;
|
||||||
|
break;
|
||||||
|
case VAHSHIR:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case FROGLOK:
|
||||||
|
FR = 25;
|
||||||
|
break;
|
||||||
|
case DRAKKIN:
|
||||||
|
{
|
||||||
|
FR = 25;
|
||||||
|
if (GetDrakkinHeritage() == 0)
|
||||||
|
FR += 10;
|
||||||
|
else if (GetDrakkinHeritage() == 5)
|
||||||
|
FR += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
FR = 20;
|
||||||
|
}
|
||||||
int c = GetClass();
|
int c = GetClass();
|
||||||
if (c == Class::Ranger) {
|
if (c == Class::Ranger) {
|
||||||
FR += 4;
|
FR += 4;
|
||||||
@@ -1053,7 +1169,65 @@ int32 Client::CalcFR()
|
|||||||
|
|
||||||
int32 Client::CalcDR()
|
int32 Client::CalcDR()
|
||||||
{
|
{
|
||||||
DR = m_pp.disease_resist;
|
//racial bases
|
||||||
|
switch (GetBaseRace()) {
|
||||||
|
case HUMAN:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case BARBARIAN:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case ERUDITE:
|
||||||
|
DR = 10;
|
||||||
|
break;
|
||||||
|
case WOOD_ELF:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case HIGH_ELF:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case DARK_ELF:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case HALF_ELF:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case DWARF:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case TROLL:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case OGRE:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case HALFLING:
|
||||||
|
DR = 20;
|
||||||
|
break;
|
||||||
|
case GNOME:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case IKSAR:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case VAHSHIR:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case FROGLOK:
|
||||||
|
DR = 15;
|
||||||
|
break;
|
||||||
|
case DRAKKIN:
|
||||||
|
{
|
||||||
|
DR = 15;
|
||||||
|
if (GetDrakkinHeritage() == 1)
|
||||||
|
DR += 10;
|
||||||
|
else if (GetDrakkinHeritage() == 5)
|
||||||
|
DR += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
DR = 15;
|
||||||
|
}
|
||||||
int c = GetClass();
|
int c = GetClass();
|
||||||
// the monk one is part of base resist
|
// the monk one is part of base resist
|
||||||
if (c == Class::Monk) {
|
if (c == Class::Monk) {
|
||||||
@@ -1087,7 +1261,65 @@ int32 Client::CalcDR()
|
|||||||
|
|
||||||
int32 Client::CalcPR()
|
int32 Client::CalcPR()
|
||||||
{
|
{
|
||||||
PR = m_pp.poison_resist;
|
//racial bases
|
||||||
|
switch (GetBaseRace()) {
|
||||||
|
case HUMAN:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case BARBARIAN:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case ERUDITE:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case WOOD_ELF:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case HIGH_ELF:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case DARK_ELF:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case HALF_ELF:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case DWARF:
|
||||||
|
PR = 20;
|
||||||
|
break;
|
||||||
|
case TROLL:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case OGRE:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case HALFLING:
|
||||||
|
PR = 20;
|
||||||
|
break;
|
||||||
|
case GNOME:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case IKSAR:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case VAHSHIR:
|
||||||
|
PR = 15;
|
||||||
|
break;
|
||||||
|
case FROGLOK:
|
||||||
|
PR = 30;
|
||||||
|
break;
|
||||||
|
case DRAKKIN:
|
||||||
|
{
|
||||||
|
PR = 15;
|
||||||
|
if (GetDrakkinHeritage() == 3)
|
||||||
|
PR += 10;
|
||||||
|
else if (GetDrakkinHeritage() == 5)
|
||||||
|
PR += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
PR = 15;
|
||||||
|
}
|
||||||
int c = GetClass();
|
int c = GetClass();
|
||||||
// this monk bonus is part of the base
|
// this monk bonus is part of the base
|
||||||
if (c == Class::Monk) {
|
if (c == Class::Monk) {
|
||||||
@@ -1121,7 +1353,65 @@ int32 Client::CalcPR()
|
|||||||
|
|
||||||
int32 Client::CalcCR()
|
int32 Client::CalcCR()
|
||||||
{
|
{
|
||||||
CR = m_pp.cold_resist;
|
//racial bases
|
||||||
|
switch (GetBaseRace()) {
|
||||||
|
case HUMAN:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case BARBARIAN:
|
||||||
|
CR = 35;
|
||||||
|
break;
|
||||||
|
case ERUDITE:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case WOOD_ELF:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case HIGH_ELF:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case DARK_ELF:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case HALF_ELF:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case DWARF:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case TROLL:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case OGRE:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case HALFLING:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case GNOME:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case IKSAR:
|
||||||
|
CR = 15;
|
||||||
|
break;
|
||||||
|
case VAHSHIR:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case FROGLOK:
|
||||||
|
CR = 25;
|
||||||
|
break;
|
||||||
|
case DRAKKIN:
|
||||||
|
{
|
||||||
|
CR = 25;
|
||||||
|
if (GetDrakkinHeritage() == 4)
|
||||||
|
CR += 10;
|
||||||
|
else if (GetDrakkinHeritage() == 5)
|
||||||
|
CR += 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
CR = 25;
|
||||||
|
}
|
||||||
int c = GetClass();
|
int c = GetClass();
|
||||||
if (c == Class::Ranger || c == Class::Beastlord) {
|
if (c == Class::Ranger || c == Class::Beastlord) {
|
||||||
CR += 4;
|
CR += 4;
|
||||||
|
|||||||
@@ -2731,6 +2731,14 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsTrader()) {
|
||||||
|
TraderEndTrader();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsBuyer()) {
|
||||||
|
ToggleBuyerMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
/* Item to Currency Storage */
|
/* Item to Currency Storage */
|
||||||
if (reclaim->reclaim_flag == 1) {
|
if (reclaim->reclaim_flag == 1) {
|
||||||
uint32 removed = NukeItem(item_id, invWhereWorn | invWherePersonal | invWhereCursor);
|
uint32 removed = NukeItem(item_id, invWhereWorn | invWherePersonal | invWhereCursor);
|
||||||
@@ -5013,7 +5021,11 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
|
|||||||
SetMoving(!(cy == m_Position.y && cx == m_Position.x));
|
SetMoving(!(cy == m_Position.y && cx == m_Position.x));
|
||||||
|
|
||||||
CheckClientToNpcAggroTimer();
|
CheckClientToNpcAggroTimer();
|
||||||
|
|
||||||
|
if (m_mob_check_moving_timer.Check()) {
|
||||||
CheckScanCloseMobsMovingTimer();
|
CheckScanCloseMobsMovingTimer();
|
||||||
|
}
|
||||||
|
|
||||||
CheckSendBulkClientPositionUpdate();
|
CheckSendBulkClientPositionUpdate();
|
||||||
|
|
||||||
int32 new_animation = ppu->animation;
|
int32 new_animation = ppu->animation;
|
||||||
|
|||||||
@@ -281,7 +281,9 @@ bool Client::Process() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanCloseMobProcess();
|
if (m_scan_close_mobs_timer.Check()) {
|
||||||
|
entity_list.ScanCloseMobs(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (RuleB(Inventory, LazyLoadBank)) {
|
if (RuleB(Inventory, LazyLoadBank)) {
|
||||||
// poll once a second to see if we are close to a banker and we haven't loaded the bank yet
|
// poll once a second to see if we are close to a banker and we haven't loaded the bank yet
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ int command_init(void)
|
|||||||
command_add("augmentitem", "Force augments an item. Must have the augment item window open.", AccountStatus::GMImpossible, command_augmentitem) ||
|
command_add("augmentitem", "Force augments an item. Must have the augment item window open.", AccountStatus::GMImpossible, command_augmentitem) ||
|
||||||
command_add("ban", "[Character Name] [Reason] - Ban by character name", AccountStatus::GMLeadAdmin, command_ban) ||
|
command_add("ban", "[Character Name] [Reason] - Ban by character name", AccountStatus::GMLeadAdmin, command_ban) ||
|
||||||
command_add("bugs", "[Close|Delete|Review|Search|View] - Handles player bug reports", AccountStatus::QuestTroupe, command_bugs) ||
|
command_add("bugs", "[Close|Delete|Review|Search|View] - Handles player bug reports", AccountStatus::QuestTroupe, command_bugs) ||
|
||||||
command_add("bot", "Type \"#bot help\" or \"^help\" to the see the list of available commands for bots.", AccountStatus::Player, command_bot) ||
|
(RuleB(Bots, Enabled) && command_add("bot", "Type \"#bot help\" or \"^help\" to the see the list of available commands for bots.", AccountStatus::Player, command_bot)) ||
|
||||||
command_add("camerashake", "[Duration (Milliseconds)] [Intensity (1-10)] - Shakes the camera on everyone's screen globally.", AccountStatus::QuestTroupe, command_camerashake) ||
|
command_add("camerashake", "[Duration (Milliseconds)] [Intensity (1-10)] - Shakes the camera on everyone's screen globally.", AccountStatus::QuestTroupe, command_camerashake) ||
|
||||||
command_add("castspell", "[Spell ID] [Instant (0 = False, 1 = True, Default is 1 if Unused)] - Cast a spell", AccountStatus::Guide, command_castspell) ||
|
command_add("castspell", "[Spell ID] [Instant (0 = False, 1 = True, Default is 1 if Unused)] - Cast a spell", AccountStatus::Guide, command_castspell) ||
|
||||||
command_add("chat", "[Channel ID] [Message] - Send a channel message to all zones", AccountStatus::GMMgmt, command_chat) ||
|
command_add("chat", "[Channel ID] [Message] - Send a channel message to all zones", AccountStatus::GMMgmt, command_chat) ||
|
||||||
|
|||||||
+3
-1
@@ -58,6 +58,7 @@ void perl_register_expedition_lock_messages();
|
|||||||
void perl_register_bot();
|
void perl_register_bot();
|
||||||
void perl_register_buff();
|
void perl_register_buff();
|
||||||
void perl_register_merc();
|
void perl_register_merc();
|
||||||
|
void perl_register_database();
|
||||||
#endif // EMBPERL_XS_CLASSES
|
#endif // EMBPERL_XS_CLASSES
|
||||||
#endif // EMBPERL_XS
|
#endif // EMBPERL_XS
|
||||||
|
|
||||||
@@ -1185,6 +1186,7 @@ void PerlembParser::MapFunctions()
|
|||||||
perl_register_bot();
|
perl_register_bot();
|
||||||
perl_register_buff();
|
perl_register_buff();
|
||||||
perl_register_merc();
|
perl_register_merc();
|
||||||
|
perl_register_database();
|
||||||
#endif // EMBPERL_XS_CLASSES
|
#endif // EMBPERL_XS_CLASSES
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1734,7 +1736,7 @@ void PerlembParser::ExportEventVariables(
|
|||||||
case EVENT_PAYLOAD: {
|
case EVENT_PAYLOAD: {
|
||||||
Seperator sep(data);
|
Seperator sep(data);
|
||||||
ExportVar(package_name.c_str(), "payload_id", sep.arg[0]);
|
ExportVar(package_name.c_str(), "payload_id", sep.arg[0]);
|
||||||
ExportVar(package_name.c_str(), "payload_value", sep.arg[1]);
|
ExportVar(package_name.c_str(), "payload_value", sep.argplus[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5978,6 +5978,16 @@ bool Perl__aretaskscompleted(perl::array task_ids)
|
|||||||
return quest_manager.aretaskscompleted(v);
|
return quest_manager.aretaskscompleted(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Perl__SpawnCircle(uint32 npc_id, float x, float y, float z, float heading, float radius, uint32 points)
|
||||||
|
{
|
||||||
|
quest_manager.SpawnCircle(npc_id, glm::vec4(x, y, z, heading), radius, points);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Perl__SpawnGrid(uint32 npc_id, float x, float y, float z, float heading, float spacing, uint32 spawn_count)
|
||||||
|
{
|
||||||
|
quest_manager.SpawnGrid(npc_id, glm::vec4(x, y, z, heading), spacing, spawn_count);
|
||||||
|
}
|
||||||
|
|
||||||
void perl_register_quest()
|
void perl_register_quest()
|
||||||
{
|
{
|
||||||
perl::interpreter perl(PERL_GET_THX);
|
perl::interpreter perl(PERL_GET_THX);
|
||||||
@@ -6287,6 +6297,8 @@ void perl_register_quest()
|
|||||||
package.add("SendMail", &Perl__SendMail);
|
package.add("SendMail", &Perl__SendMail);
|
||||||
package.add("SetAutoLoginCharacterNameByAccountID", &Perl__SetAutoLoginCharacterNameByAccountID);
|
package.add("SetAutoLoginCharacterNameByAccountID", &Perl__SetAutoLoginCharacterNameByAccountID);
|
||||||
package.add("SetRunning", &Perl__SetRunning);
|
package.add("SetRunning", &Perl__SetRunning);
|
||||||
|
package.add("SpawnCircle", &Perl__SpawnCircle);
|
||||||
|
package.add("SpawnGrid", &Perl__SpawnGrid);
|
||||||
package.add("activespeakactivity", &Perl__activespeakactivity);
|
package.add("activespeakactivity", &Perl__activespeakactivity);
|
||||||
package.add("activespeaktask", &Perl__activespeaktask);
|
package.add("activespeaktask", &Perl__activespeaktask);
|
||||||
package.add("activetasksinset", &Perl__activetasksinset);
|
package.add("activetasksinset", &Perl__activetasksinset);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ Eglin
|
|||||||
#include <perlbind/perlbind.h>
|
#include <perlbind/perlbind.h>
|
||||||
namespace perl = perlbind;
|
namespace perl = perlbind;
|
||||||
|
|
||||||
|
#undef connect
|
||||||
|
#undef bind
|
||||||
#undef Null
|
#undef Null
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|||||||
+22
-19
@@ -2945,8 +2945,22 @@ void EntityList::RemoveAuraFromMobs(Mob *aura)
|
|||||||
// entity list (zone wide)
|
// entity list (zone wide)
|
||||||
void EntityList::ScanCloseMobs(Mob *scanning_mob)
|
void EntityList::ScanCloseMobs(Mob *scanning_mob)
|
||||||
{
|
{
|
||||||
|
if (!scanning_mob) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scanning_mob->GetID() <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float scan_range = RuleI(Range, MobCloseScanDistance) * RuleI(Range, MobCloseScanDistance);
|
float scan_range = RuleI(Range, MobCloseScanDistance) * RuleI(Range, MobCloseScanDistance);
|
||||||
|
|
||||||
|
// Reserve memory in m_close_mobs to avoid frequent re-allocations if not already reserved.
|
||||||
|
// Assuming mob_list.size() as an upper bound for reservation.
|
||||||
|
if (scanning_mob->m_close_mobs.bucket_count() < mob_list.size()) {
|
||||||
|
scanning_mob->m_close_mobs.reserve(mob_list.size());
|
||||||
|
}
|
||||||
|
|
||||||
scanning_mob->m_close_mobs.clear();
|
scanning_mob->m_close_mobs.clear();
|
||||||
|
|
||||||
for (auto &e : mob_list) {
|
for (auto &e : mob_list) {
|
||||||
@@ -2957,28 +2971,17 @@ void EntityList::ScanCloseMobs(Mob *scanning_mob)
|
|||||||
|
|
||||||
float distance = DistanceSquared(scanning_mob->GetPosition(), mob->GetPosition());
|
float distance = DistanceSquared(scanning_mob->GetPosition(), mob->GetPosition());
|
||||||
if (distance <= scan_range || mob->GetAggroRange() >= scan_range) {
|
if (distance <= scan_range || mob->GetAggroRange() >= scan_range) {
|
||||||
scanning_mob->m_close_mobs.emplace(std::pair<uint16, Mob *>(mob->GetID(), mob));
|
// add mob to scanning_mob's close list and vice versa
|
||||||
|
// check if the mob is already in the close mobs list before inserting
|
||||||
// add self to other mobs close list
|
if (mob->m_close_mobs.find(scanning_mob->GetID()) == mob->m_close_mobs.end()) {
|
||||||
if (scanning_mob->GetID() > 0) {
|
mob->m_close_mobs[scanning_mob->GetID()] = scanning_mob;
|
||||||
bool has_mob = false;
|
}
|
||||||
|
scanning_mob->m_close_mobs[mob->GetID()] = mob;
|
||||||
for (auto &cm: mob->m_close_mobs) {
|
|
||||||
if (scanning_mob->GetID() == cm.first) {
|
|
||||||
has_mob = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_mob) {
|
LogAIScanClose(
|
||||||
mob->m_close_mobs.insert(std::pair<uint16, Mob *>(scanning_mob->GetID(), scanning_mob));
|
"[{}] Scanning close list > list_size [{}] moving [{}]",
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LogAIScanCloseDetail(
|
|
||||||
"[{}] Scanning Close List | list_size [{}] moving [{}]",
|
|
||||||
scanning_mob->GetCleanName(),
|
scanning_mob->GetCleanName(),
|
||||||
scanning_mob->m_close_mobs.size(),
|
scanning_mob->m_close_mobs.size(),
|
||||||
scanning_mob->IsMoving() ? "true" : "false"
|
scanning_mob->IsMoving() ? "true" : "false"
|
||||||
|
|||||||
@@ -0,0 +1,214 @@
|
|||||||
|
#ifdef LUA_EQEMU
|
||||||
|
|
||||||
|
#include "lua_database.h"
|
||||||
|
#include "zonedb.h"
|
||||||
|
#include <luabind/luabind.hpp>
|
||||||
|
#include <luabind/adopt_policy.hpp>
|
||||||
|
|
||||||
|
// Luabind adopts the PreparedStmt wrapper object allocated with new and deletes it via GC
|
||||||
|
// Lua GC is non-deterministic so handles should be closed explicitly to free db resources
|
||||||
|
// Script errors/exceptions will hold resources until GC deletes the wrapper object
|
||||||
|
|
||||||
|
Lua_MySQLPreparedStmt* Lua_Database::Prepare(lua_State* L, std::string query)
|
||||||
|
{
|
||||||
|
return m_db ? new Lua_MySQLPreparedStmt(L, m_db->Prepare(std::move(query))) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_Database::Close()
|
||||||
|
{
|
||||||
|
m_db.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void Lua_MySQLPreparedStmt::Close()
|
||||||
|
{
|
||||||
|
m_stmt.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_MySQLPreparedStmt::Execute(lua_State* L)
|
||||||
|
{
|
||||||
|
if (m_stmt)
|
||||||
|
{
|
||||||
|
m_res = m_stmt->Execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_MySQLPreparedStmt::Execute(lua_State* L, luabind::object args)
|
||||||
|
{
|
||||||
|
if (m_stmt)
|
||||||
|
{
|
||||||
|
std::vector<mysql::PreparedStmt::param_t> inputs;
|
||||||
|
|
||||||
|
// iterate table until nil like ipairs to guarantee traversal order
|
||||||
|
for (int i = 1, type; (type = luabind::type(args[i])) != LUA_TNIL; ++i)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case LUA_TBOOLEAN:
|
||||||
|
inputs.emplace_back(luabind::object_cast<bool>(args[i]));
|
||||||
|
break;
|
||||||
|
case LUA_TNUMBER: // all numbers are doubles in lua before 5.3
|
||||||
|
inputs.emplace_back(luabind::object_cast<lua_Number>(args[i]));
|
||||||
|
break;
|
||||||
|
case LUA_TSTRING:
|
||||||
|
inputs.emplace_back(luabind::object_cast<const char*>(args[i]));
|
||||||
|
break;
|
||||||
|
case LUA_TTABLE: // let tables substitute for null since nils can't exist
|
||||||
|
inputs.emplace_back(nullptr);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_res = m_stmt->Execute(inputs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_MySQLPreparedStmt::SetOptions(luabind::object table)
|
||||||
|
{
|
||||||
|
if (m_stmt)
|
||||||
|
{
|
||||||
|
mysql::StmtOptions opts = m_stmt->GetOptions();
|
||||||
|
if (luabind::type(table["buffer_results"]) == LUA_TBOOLEAN)
|
||||||
|
{
|
||||||
|
opts.buffer_results = luabind::object_cast<bool>(table["buffer_results"]);
|
||||||
|
}
|
||||||
|
if (luabind::type(table["use_max_length"]) == LUA_TBOOLEAN)
|
||||||
|
{
|
||||||
|
opts.use_max_length = luabind::object_cast<bool>(table["use_max_length"]);
|
||||||
|
}
|
||||||
|
m_stmt->SetOptions(opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PushValue(lua_State* L, const mysql::StmtColumn& col)
|
||||||
|
{
|
||||||
|
if (col.IsNull())
|
||||||
|
{
|
||||||
|
lua_pushnil(L); // clear entry in cache from any previous row
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 64-bit ints are pushed as strings since lua 5.1 only has 53-bit precision
|
||||||
|
switch (col.Type())
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
case MYSQL_TYPE_INT24:
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
lua_pushnumber(L, col.Get<lua_Number>().value());
|
||||||
|
break;
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
case MYSQL_TYPE_BIT:
|
||||||
|
case MYSQL_TYPE_TIME:
|
||||||
|
case MYSQL_TYPE_DATE:
|
||||||
|
case MYSQL_TYPE_DATETIME:
|
||||||
|
case MYSQL_TYPE_TIMESTAMP:
|
||||||
|
{
|
||||||
|
std::string str = col.GetStr().value();
|
||||||
|
lua_pushlstring(L, str.data(), str.size());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: // string types, push raw buffer to avoid copy
|
||||||
|
{
|
||||||
|
std::string_view str = col.GetStrView().value();
|
||||||
|
lua_pushlstring(L, str.data(), str.size());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
luabind::object Lua_MySQLPreparedStmt::FetchArray(lua_State* L)
|
||||||
|
{
|
||||||
|
auto row = m_stmt ? m_stmt->Fetch() : mysql::StmtRow();
|
||||||
|
if (!row)
|
||||||
|
{
|
||||||
|
return luabind::object();
|
||||||
|
}
|
||||||
|
|
||||||
|
// perf: bypass luabind operator[]
|
||||||
|
m_row_array.push(L);
|
||||||
|
for (const mysql::StmtColumn& col : row)
|
||||||
|
{
|
||||||
|
PushValue(L, col);
|
||||||
|
lua_rawseti(L, -2, col.Index() + 1);
|
||||||
|
}
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
return m_row_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
luabind::object Lua_MySQLPreparedStmt::FetchHash(lua_State* L)
|
||||||
|
{
|
||||||
|
auto row = m_stmt ? m_stmt->Fetch() : mysql::StmtRow();
|
||||||
|
if (!row)
|
||||||
|
{
|
||||||
|
return luabind::object();
|
||||||
|
}
|
||||||
|
|
||||||
|
// perf: bypass luabind operator[]
|
||||||
|
m_row_hash.push(L);
|
||||||
|
for (const mysql::StmtColumn& col : row)
|
||||||
|
{
|
||||||
|
PushValue(L, col);
|
||||||
|
lua_setfield(L, -2, col.Name().c_str());
|
||||||
|
}
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
return m_row_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Lua_MySQLPreparedStmt::ColumnCount()
|
||||||
|
{
|
||||||
|
return m_res.ColumnCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Lua_MySQLPreparedStmt::LastInsertID()
|
||||||
|
{
|
||||||
|
return m_res.LastInsertID();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Lua_MySQLPreparedStmt::RowCount()
|
||||||
|
{
|
||||||
|
return m_res.RowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Lua_MySQLPreparedStmt::RowsAffected()
|
||||||
|
{
|
||||||
|
return m_res.RowsAffected();
|
||||||
|
}
|
||||||
|
|
||||||
|
luabind::scope lua_register_database()
|
||||||
|
{
|
||||||
|
return luabind::class_<Lua_Database>("Database")
|
||||||
|
.enum_("constants")
|
||||||
|
[(
|
||||||
|
luabind::value("Default", static_cast<int>(QuestDB::Connection::Default)),
|
||||||
|
luabind::value("Content", static_cast<int>(QuestDB::Connection::Content))
|
||||||
|
)]
|
||||||
|
.def(luabind::constructor<>())
|
||||||
|
.def(luabind::constructor<QuestDB::Connection>())
|
||||||
|
.def(luabind::constructor<QuestDB::Connection, bool>())
|
||||||
|
.def(luabind::constructor<const char*, const char*, const char*, const char*, uint32_t>())
|
||||||
|
.def("close", &Lua_Database::Close)
|
||||||
|
.def("prepare", &Lua_Database::Prepare, luabind::adopt(luabind::result)),
|
||||||
|
|
||||||
|
luabind::class_<Lua_MySQLPreparedStmt>("MySQLPreparedStmt")
|
||||||
|
.def("close", &Lua_MySQLPreparedStmt::Close)
|
||||||
|
.def("execute", static_cast<void(Lua_MySQLPreparedStmt::*)(lua_State*)>(&Lua_MySQLPreparedStmt::Execute))
|
||||||
|
.def("execute", static_cast<void(Lua_MySQLPreparedStmt::*)(lua_State*, luabind::object)>(&Lua_MySQLPreparedStmt::Execute))
|
||||||
|
.def("fetch", &Lua_MySQLPreparedStmt::FetchArray)
|
||||||
|
.def("fetch_array", &Lua_MySQLPreparedStmt::FetchArray)
|
||||||
|
.def("fetch_hash", &Lua_MySQLPreparedStmt::FetchHash)
|
||||||
|
.def("insert_id", &Lua_MySQLPreparedStmt::LastInsertID)
|
||||||
|
.def("num_fields", &Lua_MySQLPreparedStmt::ColumnCount)
|
||||||
|
.def("num_rows", &Lua_MySQLPreparedStmt::RowCount)
|
||||||
|
.def("rows_affected", &Lua_MySQLPreparedStmt::RowsAffected)
|
||||||
|
.def("set_options", &Lua_MySQLPreparedStmt::SetOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LUA_EQEMU
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef LUA_EQEMU
|
||||||
|
|
||||||
|
#include "quest_db.h"
|
||||||
|
#include "../common/mysql_stmt.h"
|
||||||
|
#include <luabind/object.hpp>
|
||||||
|
|
||||||
|
namespace luabind { struct scope; }
|
||||||
|
luabind::scope lua_register_database();
|
||||||
|
|
||||||
|
class Lua_MySQLPreparedStmt;
|
||||||
|
|
||||||
|
class Lua_Database : public QuestDB
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using QuestDB::QuestDB;
|
||||||
|
|
||||||
|
void Close();
|
||||||
|
Lua_MySQLPreparedStmt* Prepare(lua_State*, std::string query);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Lua_MySQLPreparedStmt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Lua_MySQLPreparedStmt(lua_State* L, mysql::PreparedStmt&& stmt)
|
||||||
|
: m_stmt(std::make_unique<mysql::PreparedStmt>(std::move(stmt)))
|
||||||
|
, m_row_array(luabind::newtable(L))
|
||||||
|
, m_row_hash(luabind::newtable(L)) {}
|
||||||
|
|
||||||
|
void Close();
|
||||||
|
void Execute(lua_State*);
|
||||||
|
void Execute(lua_State*, luabind::object args);
|
||||||
|
void SetOptions(luabind::object table_opts);
|
||||||
|
luabind::object FetchArray(lua_State*);
|
||||||
|
luabind::object FetchHash(lua_State*);
|
||||||
|
|
||||||
|
// StmtResult functions accessible through this class to simplify api
|
||||||
|
int ColumnCount();
|
||||||
|
uint64_t LastInsertID();
|
||||||
|
uint64_t RowCount();
|
||||||
|
uint64_t RowsAffected();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<mysql::PreparedStmt> m_stmt;
|
||||||
|
mysql::StmtResult m_res = {};
|
||||||
|
luabind::object m_row_array; // perf: table cache for fetches
|
||||||
|
luabind::object m_row_hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LUA_EQEMU
|
||||||
+13
-3
@@ -5635,6 +5635,16 @@ int lua_are_tasks_completed(luabind::object task_ids)
|
|||||||
return quest_manager.aretaskscompleted(v);
|
return quest_manager.aretaskscompleted(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lua_spawn_circle(uint32 npc_id, float x, float y, float z, float heading, float radius, uint32 points)
|
||||||
|
{
|
||||||
|
quest_manager.SpawnCircle(npc_id, glm::vec4(x, y, z, heading), radius, points);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lua_spawn_grid(uint32 npc_id, float x, float y, float z, float heading, float spacing, uint32 spawn_count)
|
||||||
|
{
|
||||||
|
quest_manager.SpawnGrid(npc_id, glm::vec4(x, y, z, heading), spacing, spawn_count);
|
||||||
|
}
|
||||||
|
|
||||||
#define LuaCreateNPCParse(name, c_type, default_value) do { \
|
#define LuaCreateNPCParse(name, c_type, default_value) do { \
|
||||||
cur = table[#name]; \
|
cur = table[#name]; \
|
||||||
if(luabind::type(cur) != LUA_TNIL) { \
|
if(luabind::type(cur) != LUA_TNIL) { \
|
||||||
@@ -6442,6 +6452,8 @@ luabind::scope lua_register_general() {
|
|||||||
luabind::def("send_parcel", &lua_send_parcel),
|
luabind::def("send_parcel", &lua_send_parcel),
|
||||||
luabind::def("get_zone_uptime", &lua_get_zone_uptime),
|
luabind::def("get_zone_uptime", &lua_get_zone_uptime),
|
||||||
luabind::def("are_tasks_completed", &lua_are_tasks_completed),
|
luabind::def("are_tasks_completed", &lua_are_tasks_completed),
|
||||||
|
luabind::def("spawn_circle", &lua_spawn_circle),
|
||||||
|
luabind::def("spawn_grid", &lua_spawn_grid),
|
||||||
/*
|
/*
|
||||||
Cross Zone
|
Cross Zone
|
||||||
*/
|
*/
|
||||||
@@ -6583,7 +6595,7 @@ luabind::scope lua_register_general() {
|
|||||||
luabind::def("cross_zone_reset_activity_by_guild_id", &lua_cross_zone_reset_activity_by_guild_id),
|
luabind::def("cross_zone_reset_activity_by_guild_id", &lua_cross_zone_reset_activity_by_guild_id),
|
||||||
luabind::def("cross_zone_reset_activity_by_expedition_id", &lua_cross_zone_reset_activity_by_expedition_id),
|
luabind::def("cross_zone_reset_activity_by_expedition_id", &lua_cross_zone_reset_activity_by_expedition_id),
|
||||||
luabind::def("cross_zone_reset_activity_by_client_name", &lua_cross_zone_reset_activity_by_client_name),
|
luabind::def("cross_zone_reset_activity_by_client_name", &lua_cross_zone_reset_activity_by_client_name),
|
||||||
luabind::def("cross_zone_set_entity_variable_by_client_name", &lua_cross_zone_set_entity_variable_by_client_name),
|
luabind::def("cross_zone_set_entity_variable_by_char_id", &lua_cross_zone_set_entity_variable_by_char_id),
|
||||||
luabind::def("cross_zone_set_entity_variable_by_group_id", &lua_cross_zone_set_entity_variable_by_group_id),
|
luabind::def("cross_zone_set_entity_variable_by_group_id", &lua_cross_zone_set_entity_variable_by_group_id),
|
||||||
luabind::def("cross_zone_set_entity_variable_by_raid_id", &lua_cross_zone_set_entity_variable_by_raid_id),
|
luabind::def("cross_zone_set_entity_variable_by_raid_id", &lua_cross_zone_set_entity_variable_by_raid_id),
|
||||||
luabind::def("cross_zone_set_entity_variable_by_guild_id", &lua_cross_zone_set_entity_variable_by_guild_id),
|
luabind::def("cross_zone_set_entity_variable_by_guild_id", &lua_cross_zone_set_entity_variable_by_guild_id),
|
||||||
@@ -6772,7 +6784,6 @@ luabind::scope lua_register_random() {
|
|||||||
)];
|
)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
luabind::scope lua_register_events() {
|
luabind::scope lua_register_events() {
|
||||||
return luabind::class_<Events>("Event")
|
return luabind::class_<Events>("Event")
|
||||||
.enum_("constants")
|
.enum_("constants")
|
||||||
@@ -8008,7 +8019,6 @@ luabind::scope lua_register_journal_mode() {
|
|||||||
)];
|
)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
luabind::scope lua_register_exp_source() {
|
luabind::scope lua_register_exp_source() {
|
||||||
return luabind::class_<ExpSource>("ExpSource")
|
return luabind::class_<ExpSource>("ExpSource")
|
||||||
.enum_("constants")
|
.enum_("constants")
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ luabind::scope lua_register_rules_const();
|
|||||||
luabind::scope lua_register_rulei();
|
luabind::scope lua_register_rulei();
|
||||||
luabind::scope lua_register_ruler();
|
luabind::scope lua_register_ruler();
|
||||||
luabind::scope lua_register_ruleb();
|
luabind::scope lua_register_ruleb();
|
||||||
|
luabind::scope lua_register_rules();
|
||||||
luabind::scope lua_register_journal_speakmode();
|
luabind::scope lua_register_journal_speakmode();
|
||||||
luabind::scope lua_register_journal_mode();
|
luabind::scope lua_register_journal_mode();
|
||||||
|
luabind::scope lua_register_exp_source();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+5
-1
@@ -42,6 +42,7 @@
|
|||||||
#include "lua_spawn.h"
|
#include "lua_spawn.h"
|
||||||
#include "lua_spell.h"
|
#include "lua_spell.h"
|
||||||
#include "lua_stat_bonuses.h"
|
#include "lua_stat_bonuses.h"
|
||||||
|
#include "lua_database.h"
|
||||||
|
|
||||||
const char *LuaEvents[_LargestEventID] = {
|
const char *LuaEvents[_LargestEventID] = {
|
||||||
"event_say",
|
"event_say",
|
||||||
@@ -1312,11 +1313,14 @@ void LuaParser::MapFunctions(lua_State *L) {
|
|||||||
lua_register_rulei(),
|
lua_register_rulei(),
|
||||||
lua_register_ruler(),
|
lua_register_ruler(),
|
||||||
lua_register_ruleb(),
|
lua_register_ruleb(),
|
||||||
|
lua_register_rules(),
|
||||||
lua_register_journal_speakmode(),
|
lua_register_journal_speakmode(),
|
||||||
lua_register_journal_mode(),
|
lua_register_journal_mode(),
|
||||||
lua_register_expedition(),
|
lua_register_expedition(),
|
||||||
lua_register_expedition_lock_messages(),
|
lua_register_expedition_lock_messages(),
|
||||||
lua_register_buff()
|
lua_register_buff(),
|
||||||
|
lua_register_exp_source(),
|
||||||
|
lua_register_database()
|
||||||
)];
|
)];
|
||||||
|
|
||||||
} catch(std::exception &ex) {
|
} catch(std::exception &ex) {
|
||||||
|
|||||||
+13
-5
@@ -31,12 +31,14 @@ Map::~Map() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float Map::FindBestZ(glm::vec3 &start, glm::vec3 *result) const {
|
float Map::FindBestZ(glm::vec3 &start, glm::vec3 *result) const {
|
||||||
if (!imp)
|
if (!imp) {
|
||||||
return BEST_Z_INVALID;
|
return BEST_Z_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 tmp;
|
glm::vec3 tmp;
|
||||||
if(!result)
|
if (!result) {
|
||||||
result = &tmp;
|
result = &tmp;
|
||||||
|
}
|
||||||
|
|
||||||
start.z += RuleI(Map, FindBestZHeightAdjust);
|
start.z += RuleI(Map, FindBestZHeightAdjust);
|
||||||
glm::vec3 from(start.x, start.y, start.z);
|
glm::vec3 from(start.x, start.y, start.z);
|
||||||
@@ -45,16 +47,22 @@ float Map::FindBestZ(glm::vec3 &start, glm::vec3 *result) const {
|
|||||||
bool hit = false;
|
bool hit = false;
|
||||||
|
|
||||||
hit = imp->rm->raycast((const RmReal*)&from, (const RmReal*)&to, (RmReal*)result, nullptr, &hit_distance);
|
hit = imp->rm->raycast((const RmReal*)&from, (const RmReal*)&to, (RmReal*)result, nullptr, &hit_distance);
|
||||||
|
if (hit && zone->newzone_data.underworld != 0.0f && result->z < zone->newzone_data.underworld) {
|
||||||
|
hit = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (hit) {
|
if (hit) {
|
||||||
return result->z;
|
return result->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find nearest Z above us
|
// Find nearest Z above us
|
||||||
|
|
||||||
to.z = -BEST_Z_INVALID;
|
to.z = -BEST_Z_INVALID;
|
||||||
hit = imp->rm->raycast((const RmReal*)&from, (const RmReal*)&to, (RmReal*)result, nullptr, &hit_distance);
|
hit = imp->rm->raycast((const RmReal*)&from, (const RmReal*)&to, (RmReal*)result, nullptr, &hit_distance);
|
||||||
if (hit)
|
if (zone->newzone_data.max_z != 0.0f && result->z > zone->newzone_data.max_z) {
|
||||||
{
|
hit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hit) {
|
||||||
return result->z;
|
return result->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-37
@@ -1266,8 +1266,6 @@ void Mob::CreateSpawnPacket(EQApplicationPacket* app, NewSpawn_Struct* ns) {
|
|||||||
} else {
|
} else {
|
||||||
strcpy(ns2->spawn.lastName, ns->spawn.lastName);
|
strcpy(ns2->spawn.lastName, ns->spawn.lastName);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&app->pBuffer[sizeof(Spawn_Struct)-7], 0xFF, 7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
|
void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
|
||||||
@@ -2050,19 +2048,19 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
|
|||||||
case 0: {
|
case 0: {
|
||||||
mod2a_name = "Avoidance";
|
mod2a_name = "Avoidance";
|
||||||
mod2b_name = "Combat Effects";
|
mod2b_name = "Combat Effects";
|
||||||
mod2a_cap = Strings::Commify(RuleI(Character, ItemAvoidanceCap));
|
mod2a_cap = RuleI(Character, ItemAvoidanceCap);
|
||||||
mod2b_cap = Strings::Commify(RuleI(Character, ItemCombatEffectsCap));
|
mod2b_cap = RuleI(Character, ItemCombatEffectsCap);
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
mod2a = Strings::Commify(CastToBot()->GetAvoidance());
|
mod2a = CastToBot()->GetAvoidance();
|
||||||
} else if (IsClient()) {
|
} else if (IsClient()) {
|
||||||
mod2a = Strings::Commify(CastToClient()->GetAvoidance());
|
mod2a = CastToClient()->GetAvoidance();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
mod2b = Strings::Commify(CastToBot()->GetCombatEffects());
|
mod2b = CastToBot()->GetCombatEffects();
|
||||||
} else if (IsClient()) {
|
} else if (IsClient()) {
|
||||||
mod2b = Strings::Commify(CastToClient()->GetCombatEffects());
|
mod2b = CastToClient()->GetCombatEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -2070,19 +2068,19 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
|
|||||||
case 1: {
|
case 1: {
|
||||||
mod2a_name = "Accuracy";
|
mod2a_name = "Accuracy";
|
||||||
mod2b_name = "Strikethrough";
|
mod2b_name = "Strikethrough";
|
||||||
mod2a_cap = Strings::Commify(RuleI(Character, ItemAccuracyCap));
|
mod2a_cap = RuleI(Character, ItemAccuracyCap);
|
||||||
mod2b_cap = Strings::Commify(RuleI(Character, ItemStrikethroughCap));
|
mod2b_cap = RuleI(Character, ItemStrikethroughCap);
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
mod2a = Strings::Commify(CastToBot()->GetAccuracy());
|
mod2a = CastToBot()->GetAccuracy();
|
||||||
} else if (IsClient()) {
|
} else if (IsClient()) {
|
||||||
mod2a = Strings::Commify(CastToClient()->GetAccuracy());
|
mod2a = CastToClient()->GetAccuracy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
mod2b = Strings::Commify(CastToBot()->GetStrikeThrough());
|
mod2b = CastToBot()->GetStrikeThrough();
|
||||||
} else if (IsClient()) {
|
} else if (IsClient()) {
|
||||||
mod2b = Strings::Commify(CastToClient()->GetStrikeThrough());
|
mod2b = CastToClient()->GetStrikeThrough();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -2090,20 +2088,20 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
|
|||||||
case 2: {
|
case 2: {
|
||||||
mod2a_name = "Shielding";
|
mod2a_name = "Shielding";
|
||||||
mod2b_name = "Spell Shielding";
|
mod2b_name = "Spell Shielding";
|
||||||
mod2a_cap = Strings::Commify(RuleI(Character, ItemShieldingCap));
|
mod2a_cap = RuleI(Character, ItemShieldingCap);
|
||||||
mod2b_cap = Strings::Commify(RuleI(Character, ItemSpellShieldingCap));
|
mod2b_cap = RuleI(Character, ItemSpellShieldingCap);
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
mod2a = Strings::Commify(CastToBot()->GetShielding());
|
mod2a = CastToBot()->GetShielding();
|
||||||
} else if (IsClient()) {
|
} else if (IsClient()) {
|
||||||
mod2a = Strings::Commify(CastToClient()->GetShielding());
|
mod2a = CastToClient()->GetShielding();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
mod2b = Strings::Commify(CastToBot()->GetSpellShield());
|
mod2b = CastToBot()->GetSpellShield();
|
||||||
} else if (IsClient()) {
|
} else if (IsClient()) {
|
||||||
mod2b = Strings::Commify(CastToClient()->GetSpellShield());
|
mod2b = CastToClient()->GetSpellShield();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -2111,19 +2109,19 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
|
|||||||
case 3: {
|
case 3: {
|
||||||
mod2a_name = "Stun Resist";
|
mod2a_name = "Stun Resist";
|
||||||
mod2b_name = "DOT Shielding";
|
mod2b_name = "DOT Shielding";
|
||||||
mod2a_cap = Strings::Commify(RuleI(Character, ItemStunResistCap));
|
mod2a_cap = RuleI(Character, ItemStunResistCap);
|
||||||
mod2b_cap = Strings::Commify(RuleI(Character, ItemDoTShieldingCap));
|
mod2b_cap = RuleI(Character, ItemDoTShieldingCap);
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
mod2a = Strings::Commify(CastToBot()->GetStunResist());
|
mod2a = CastToBot()->GetStunResist();
|
||||||
} else if (IsClient()) {
|
} else if (IsClient()) {
|
||||||
mod2a = Strings::Commify(CastToClient()->GetStunResist());
|
mod2a = CastToClient()->GetStunResist();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsBot()) {
|
if (IsBot()) {
|
||||||
mod2b = Strings::Commify(CastToBot()->GetDoTShield());
|
mod2b = CastToBot()->GetDoTShield();
|
||||||
} else if (IsClient()) {
|
} else if (IsClient()) {
|
||||||
mod2b = Strings::Commify(CastToClient()->GetDoTShield());
|
mod2b = CastToClient()->GetDoTShield();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -8584,6 +8582,7 @@ bool Mob::HasBotAttackFlag(Mob* tar) {
|
|||||||
const uint16 scan_close_mobs_timer_moving = 6000; // 6 seconds
|
const uint16 scan_close_mobs_timer_moving = 6000; // 6 seconds
|
||||||
const uint16 scan_close_mobs_timer_idle = 60000; // 60 seconds
|
const uint16 scan_close_mobs_timer_idle = 60000; // 60 seconds
|
||||||
|
|
||||||
|
// If the moving timer triggers, lets see if we are moving or idle to restart the appropriate dynamic timer
|
||||||
void Mob::CheckScanCloseMobsMovingTimer()
|
void Mob::CheckScanCloseMobsMovingTimer()
|
||||||
{
|
{
|
||||||
LogAIScanCloseDetail(
|
LogAIScanCloseDetail(
|
||||||
@@ -8593,9 +8592,6 @@ void Mob::CheckScanCloseMobsMovingTimer()
|
|||||||
m_scan_close_mobs_timer.GetRemainingTime()
|
m_scan_close_mobs_timer.GetRemainingTime()
|
||||||
);
|
);
|
||||||
|
|
||||||
// If the moving timer triggers, lets see if we are moving or idle to restart the appropriate
|
|
||||||
// dynamic timer
|
|
||||||
if (m_mob_check_moving_timer.Check()) {
|
|
||||||
// If the mob is still moving, restart the moving timer
|
// If the mob is still moving, restart the moving timer
|
||||||
if (moving) {
|
if (moving) {
|
||||||
if (m_scan_close_mobs_timer.GetRemainingTime() > scan_close_mobs_timer_moving) {
|
if (m_scan_close_mobs_timer.GetRemainingTime() > scan_close_mobs_timer_moving) {
|
||||||
@@ -8612,14 +8608,6 @@ void Mob::CheckScanCloseMobsMovingTimer()
|
|||||||
m_scan_close_mobs_timer.Start(scan_close_mobs_timer_idle);
|
m_scan_close_mobs_timer.Start(scan_close_mobs_timer_idle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Mob::ScanCloseMobProcess()
|
|
||||||
{
|
|
||||||
if (m_scan_close_mobs_timer.Check()) {
|
|
||||||
entity_list.ScanCloseMobs(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_map<uint16, Mob *> &Mob::GetCloseMobList(float distance)
|
std::unordered_map<uint16, Mob *> &Mob::GetCloseMobList(float distance)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1488,7 +1488,6 @@ public:
|
|||||||
|
|
||||||
bool IsCloseToBanker();
|
bool IsCloseToBanker();
|
||||||
|
|
||||||
void ScanCloseMobProcess();
|
|
||||||
std::unordered_map<uint16, Mob *> &GetCloseMobList(float distance = 0.0f);
|
std::unordered_map<uint16, Mob *> &GetCloseMobList(float distance = 0.0f);
|
||||||
void CheckScanCloseMobsMovingTimer();
|
void CheckScanCloseMobsMovingTimer();
|
||||||
|
|
||||||
|
|||||||
+41
-9
@@ -601,8 +601,13 @@ bool NPC::Process()
|
|||||||
DepopSwarmPets();
|
DepopSwarmPets();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanCloseMobProcess();
|
if (m_scan_close_mobs_timer.Check()) {
|
||||||
|
entity_list.ScanCloseMobs(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_mob_check_moving_timer.Check()) {
|
||||||
CheckScanCloseMobsMovingTimer();
|
CheckScanCloseMobsMovingTimer();
|
||||||
|
}
|
||||||
|
|
||||||
if (hp_regen_per_second > 0 && hp_regen_per_second_timer.Check()) {
|
if (hp_regen_per_second > 0 && hp_regen_per_second_timer.Check()) {
|
||||||
if (GetHP() < GetMaxHP()) {
|
if (GetHP() < GetMaxHP()) {
|
||||||
@@ -2151,6 +2156,7 @@ void NPC::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
|
|||||||
UpdateActiveLight();
|
UpdateActiveLight();
|
||||||
ns->spawn.light = GetActiveLightType();
|
ns->spawn.light = GetActiveLightType();
|
||||||
ns->spawn.show_name = NPCTypedata->show_name;
|
ns->spawn.show_name = NPCTypedata->show_name;
|
||||||
|
ns->spawn.trader = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::PetOnSpawn(NewSpawn_Struct* ns)
|
void NPC::PetOnSpawn(NewSpawn_Struct* ns)
|
||||||
@@ -3291,16 +3297,28 @@ uint32 NPC::GetSpawnKillCount()
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::DoQuestPause(Mob *other) {
|
void NPC::DoQuestPause(Mob* m)
|
||||||
if(IsMoving() && !IsOnHatelist(other)) {
|
{
|
||||||
PauseWandering(RuleI(NPC, SayPauseTimeInSec));
|
if (!m) {
|
||||||
if (other && !other->sneaking)
|
return;
|
||||||
FaceTarget(other);
|
|
||||||
} else if(!IsMoving()) {
|
|
||||||
if (other && !other->sneaking && GetAppearance() != eaSitting && GetAppearance() != eaDead)
|
|
||||||
FaceTarget(other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsMoving() && !IsOnHatelist(m)) {
|
||||||
|
PauseWandering(RuleI(NPC, SayPauseTimeInSec));
|
||||||
|
|
||||||
|
if (FacesTarget() && !m->sneaking) {
|
||||||
|
FaceTarget(m);
|
||||||
|
}
|
||||||
|
} else if (!IsMoving()) {
|
||||||
|
if (
|
||||||
|
FacesTarget() &&
|
||||||
|
!m->sneaking &&
|
||||||
|
GetAppearance() != eaSitting &&
|
||||||
|
GetAppearance() != eaDead
|
||||||
|
) {
|
||||||
|
FaceTarget(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::ChangeLastName(std::string last_name)
|
void NPC::ChangeLastName(std::string last_name)
|
||||||
@@ -4232,3 +4250,17 @@ void NPC::DoNpcToNpcAggroScan()
|
|||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NPC::FacesTarget()
|
||||||
|
{
|
||||||
|
const std::string& excluded_races_rule = RuleS(NPC, ExcludedFaceTargetRaces);
|
||||||
|
|
||||||
|
if (excluded_races_rule.empty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& v = Strings::Split(excluded_races_rule, ",");
|
||||||
|
|
||||||
|
return std::find(v.begin(), v.end(), std::to_string(GetBaseRace())) == v.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -482,7 +482,8 @@ public:
|
|||||||
NPC_Emote_Struct* GetNPCEmote(uint32 emote_id, uint8 event_);
|
NPC_Emote_Struct* GetNPCEmote(uint32 emote_id, uint8 event_);
|
||||||
void DoNPCEmote(uint8 event_, uint32 emote_id, Mob* t = nullptr);
|
void DoNPCEmote(uint8 event_, uint32 emote_id, Mob* t = nullptr);
|
||||||
bool CanTalk();
|
bool CanTalk();
|
||||||
void DoQuestPause(Mob *other);
|
void DoQuestPause(Mob* m);
|
||||||
|
bool FacesTarget();
|
||||||
|
|
||||||
inline void SetSpellScale(float amt) { spellscale = amt; }
|
inline void SetSpellScale(float amt) { spellscale = amt; }
|
||||||
inline float GetSpellScale() { return spellscale; }
|
inline float GetSpellScale() { return spellscale; }
|
||||||
|
|||||||
+14
-2
@@ -278,6 +278,19 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parcel_in->money_flag && parcel_in->item_slot != INVALID_INDEX) {
|
||||||
|
Message(
|
||||||
|
Chat::Yellow,
|
||||||
|
fmt::format(
|
||||||
|
"{} tells you, 'I am confused! Do you want to send money or an item?'",
|
||||||
|
merchant->GetCleanName()
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
DoParcelCancel();
|
||||||
|
SendParcelAck();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto num_of_parcels = GetParcelCount();
|
auto num_of_parcels = GetParcelCount();
|
||||||
if (num_of_parcels >= RuleI(Parcel, ParcelMaxItems)) {
|
if (num_of_parcels >= RuleI(Parcel, ParcelMaxItems)) {
|
||||||
SendParcelIconStatus();
|
SendParcelIconStatus();
|
||||||
@@ -406,9 +419,8 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
|
|||||||
|
|
||||||
std::vector<CharacterParcelsContainersRepository::CharacterParcelsContainers> all_entries{};
|
std::vector<CharacterParcelsContainersRepository::CharacterParcelsContainers> all_entries{};
|
||||||
if (inst->IsNoneEmptyContainer()) {
|
if (inst->IsNoneEmptyContainer()) {
|
||||||
CharacterParcelsContainersRepository::CharacterParcelsContainers cpc{};
|
|
||||||
|
|
||||||
for (auto const &kv: *inst->GetContents()) {
|
for (auto const &kv: *inst->GetContents()) {
|
||||||
|
CharacterParcelsContainersRepository::CharacterParcelsContainers cpc{};
|
||||||
cpc.parcels_id = result.id;
|
cpc.parcels_id = result.id;
|
||||||
cpc.slot_id = kv.first;
|
cpc.slot_id = kv.first;
|
||||||
cpc.item_id = kv.second->GetID();
|
cpc.item_id = kv.second->GetID();
|
||||||
|
|||||||
@@ -0,0 +1,255 @@
|
|||||||
|
#include "../common/features.h"
|
||||||
|
|
||||||
|
#ifdef EMBPERL_XS_CLASSES
|
||||||
|
|
||||||
|
#include "embperl.h"
|
||||||
|
#include "perl_database.h"
|
||||||
|
#include "zonedb.h"
|
||||||
|
|
||||||
|
// Perl takes ownership of returned objects allocated with new and deletes
|
||||||
|
// them via the DESTROY method when the last perl reference goes out of scope
|
||||||
|
|
||||||
|
void Perl_Database::Destroy(Perl_Database* ptr)
|
||||||
|
{
|
||||||
|
delete ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Perl_Database* Perl_Database::Connect()
|
||||||
|
{
|
||||||
|
return new Perl_Database();
|
||||||
|
}
|
||||||
|
|
||||||
|
Perl_Database* Perl_Database::Connect(Connection type)
|
||||||
|
{
|
||||||
|
return new Perl_Database(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
Perl_Database* Perl_Database::Connect(Connection type, bool connect)
|
||||||
|
{
|
||||||
|
return new Perl_Database(type, connect);
|
||||||
|
}
|
||||||
|
|
||||||
|
Perl_Database* Perl_Database::Connect(const char* host, const char* user, const char* pass, const char* db, uint32_t port)
|
||||||
|
{
|
||||||
|
return new Perl_Database(host, user, pass, db, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
Perl_MySQLPreparedStmt* Perl_Database::Prepare(std::string query)
|
||||||
|
{
|
||||||
|
return m_db ? new Perl_MySQLPreparedStmt(m_db->Prepare(std::move(query))) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Perl_Database::Close()
|
||||||
|
{
|
||||||
|
m_db.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void Perl_MySQLPreparedStmt::Destroy(Perl_MySQLPreparedStmt* ptr)
|
||||||
|
{
|
||||||
|
delete ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Perl_MySQLPreparedStmt::Close()
|
||||||
|
{
|
||||||
|
m_stmt.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Perl_MySQLPreparedStmt::Execute()
|
||||||
|
{
|
||||||
|
if (m_stmt)
|
||||||
|
{
|
||||||
|
m_res = m_stmt->Execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Perl_MySQLPreparedStmt::Execute(perl::array args)
|
||||||
|
{
|
||||||
|
// passes all script args as strings
|
||||||
|
if (m_stmt)
|
||||||
|
{
|
||||||
|
std::vector<mysql::PreparedStmt::param_t> inputs;
|
||||||
|
for (const perl::scalar& arg : args)
|
||||||
|
{
|
||||||
|
if (arg.is_null())
|
||||||
|
{
|
||||||
|
inputs.emplace_back(nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inputs.emplace_back(arg.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_res = m_stmt->Execute(inputs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Perl_MySQLPreparedStmt::SetOptions(perl::hash hash)
|
||||||
|
{
|
||||||
|
if (m_stmt)
|
||||||
|
{
|
||||||
|
mysql::StmtOptions opts = m_stmt->GetOptions();
|
||||||
|
if (hash.exists("buffer_results"))
|
||||||
|
{
|
||||||
|
opts.buffer_results = hash["buffer_results"].as<bool>();
|
||||||
|
}
|
||||||
|
if (hash.exists("use_max_length"))
|
||||||
|
{
|
||||||
|
opts.use_max_length = hash["use_max_length"].as<bool>();
|
||||||
|
}
|
||||||
|
m_stmt->SetOptions(opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PushValue(PerlInterpreter* my_perl, SV* sv, const mysql::StmtColumn& col)
|
||||||
|
{
|
||||||
|
if (col.IsNull())
|
||||||
|
{
|
||||||
|
sv_setsv(sv, &PL_sv_undef);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (col.Type())
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
case MYSQL_TYPE_INT24:
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
case MYSQL_TYPE_BIT:
|
||||||
|
if (col.IsUnsigned())
|
||||||
|
{
|
||||||
|
sv_setuv(sv, col.Get<UV>().value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sv_setiv(sv, col.Get<IV>().value());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
sv_setnv(sv, col.Get<NV>().value());
|
||||||
|
break;
|
||||||
|
case MYSQL_TYPE_TIME:
|
||||||
|
case MYSQL_TYPE_DATE:
|
||||||
|
case MYSQL_TYPE_DATETIME:
|
||||||
|
case MYSQL_TYPE_TIMESTAMP:
|
||||||
|
{
|
||||||
|
std::string str = col.GetStr().value();
|
||||||
|
sv_setpvn(sv, str.data(), str.size());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: // string types, push raw buffer to avoid copy
|
||||||
|
{
|
||||||
|
std::string_view str = col.GetStrView().value();
|
||||||
|
sv_setpvn(sv, str.data(), str.size());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
perl::array Perl_MySQLPreparedStmt::FetchArray()
|
||||||
|
{
|
||||||
|
auto row = m_stmt ? m_stmt->Fetch() : mysql::StmtRow();
|
||||||
|
if (!row)
|
||||||
|
{
|
||||||
|
return perl::array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// perf: bypass perlbind operator[]/push and use cache to limit SV allocs
|
||||||
|
dTHX;
|
||||||
|
AV* av = static_cast<AV*>(m_row_array);
|
||||||
|
for (const mysql::StmtColumn& col : row)
|
||||||
|
{
|
||||||
|
SV** sv = av_fetch(av, col.Index(), true);
|
||||||
|
PushValue(my_perl, *sv, col);
|
||||||
|
}
|
||||||
|
|
||||||
|
SvREFCNT_inc(av); // return a ref to our cache (no copy)
|
||||||
|
return perl::array(std::move(av));
|
||||||
|
}
|
||||||
|
|
||||||
|
perl::reference Perl_MySQLPreparedStmt::FetchArrayRef()
|
||||||
|
{
|
||||||
|
perl::array array = FetchArray();
|
||||||
|
return array.size() == 0 ? perl::reference() : perl::reference(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
perl::reference Perl_MySQLPreparedStmt::FetchHashRef()
|
||||||
|
{
|
||||||
|
auto row = m_stmt ? m_stmt->Fetch() : mysql::StmtRow();
|
||||||
|
if (!row)
|
||||||
|
{
|
||||||
|
return perl::reference();
|
||||||
|
}
|
||||||
|
|
||||||
|
// perf: bypass perlbind operator[] and use cache to limit SV allocs
|
||||||
|
dTHX;
|
||||||
|
HV* hv = static_cast<HV*>(m_row_hash);
|
||||||
|
for (const mysql::StmtColumn& col : row)
|
||||||
|
{
|
||||||
|
SV** sv = hv_fetch(hv, col.Name().c_str(), static_cast<I32>(col.Name().size()), true);
|
||||||
|
PushValue(my_perl, *sv, col);
|
||||||
|
}
|
||||||
|
|
||||||
|
SvREFCNT_inc(hv); // return a ref to our cache (no copy)
|
||||||
|
return perl::reference(std::move(hv));
|
||||||
|
}
|
||||||
|
|
||||||
|
int Perl_MySQLPreparedStmt::ColumnCount()
|
||||||
|
{
|
||||||
|
return m_res.ColumnCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Perl_MySQLPreparedStmt::LastInsertID()
|
||||||
|
{
|
||||||
|
return m_res.LastInsertID();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Perl_MySQLPreparedStmt::RowCount()
|
||||||
|
{
|
||||||
|
return m_res.RowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Perl_MySQLPreparedStmt::RowsAffected()
|
||||||
|
{
|
||||||
|
return m_res.RowsAffected();
|
||||||
|
}
|
||||||
|
|
||||||
|
void perl_register_database()
|
||||||
|
{
|
||||||
|
perl::interpreter perl(PERL_GET_THX);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto package = perl.new_class<Perl_Database>("Database");
|
||||||
|
package.add_const("Default", static_cast<int>(QuestDB::Connection::Default));
|
||||||
|
package.add_const("Content", static_cast<int>(QuestDB::Connection::Content));
|
||||||
|
package.add("DESTROY", &Perl_Database::Destroy);
|
||||||
|
package.add("new", static_cast<Perl_Database*(*)()>(&Perl_Database::Connect));
|
||||||
|
package.add("new", static_cast<Perl_Database*(*)(QuestDB::Connection)>(&Perl_Database::Connect));
|
||||||
|
package.add("new", static_cast<Perl_Database*(*)(QuestDB::Connection, bool)>(&Perl_Database::Connect));
|
||||||
|
package.add("new", static_cast<Perl_Database*(*)(const char*, const char*, const char*, const char*, uint32_t)>(&Perl_Database::Connect));
|
||||||
|
package.add("close", &Perl_Database::Close);
|
||||||
|
package.add("prepare", &Perl_Database::Prepare);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto package = perl.new_class<Perl_MySQLPreparedStmt>("MySQLPreparedStmt");
|
||||||
|
package.add("DESTROY", &Perl_MySQLPreparedStmt::Destroy);
|
||||||
|
package.add("close", &Perl_MySQLPreparedStmt::Close);
|
||||||
|
package.add("execute", static_cast<void(Perl_MySQLPreparedStmt::*)()>(&Perl_MySQLPreparedStmt::Execute));
|
||||||
|
package.add("execute", static_cast<void(Perl_MySQLPreparedStmt::*)(perl::array)>(&Perl_MySQLPreparedStmt::Execute));
|
||||||
|
package.add("fetch", &Perl_MySQLPreparedStmt::FetchArray);
|
||||||
|
package.add("fetch_array", &Perl_MySQLPreparedStmt::FetchArray);
|
||||||
|
package.add("fetch_arrayref", &Perl_MySQLPreparedStmt::FetchArrayRef);
|
||||||
|
package.add("fetch_hashref", &Perl_MySQLPreparedStmt::FetchHashRef);
|
||||||
|
package.add("insert_id", &Perl_MySQLPreparedStmt::LastInsertID);
|
||||||
|
package.add("num_fields", &Perl_MySQLPreparedStmt::ColumnCount);
|
||||||
|
package.add("num_rows", &Perl_MySQLPreparedStmt::RowCount);
|
||||||
|
package.add("rows_affected", &Perl_MySQLPreparedStmt::RowsAffected);
|
||||||
|
package.add("set_options", &Perl_MySQLPreparedStmt::SetOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EMBPERL_XS_CLASSES
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "quest_db.h"
|
||||||
|
#include "../common/mysql_stmt.h"
|
||||||
|
|
||||||
|
class Perl_MySQLPreparedStmt;
|
||||||
|
|
||||||
|
class Perl_Database : public QuestDB
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using QuestDB::QuestDB;
|
||||||
|
|
||||||
|
static void Destroy(Perl_Database* ptr);
|
||||||
|
static Perl_Database* Connect();
|
||||||
|
static Perl_Database* Connect(Connection type);
|
||||||
|
static Perl_Database* Connect(Connection type, bool connect);
|
||||||
|
static Perl_Database* Connect(const char* host, const char* user, const char* pass, const char* db, uint32_t port);
|
||||||
|
|
||||||
|
void Close();
|
||||||
|
Perl_MySQLPreparedStmt* Prepare(std::string query);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Perl_MySQLPreparedStmt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Perl_MySQLPreparedStmt(mysql::PreparedStmt&& stmt)
|
||||||
|
: m_stmt(std::make_unique<mysql::PreparedStmt>(std::move(stmt))) {}
|
||||||
|
|
||||||
|
static void Destroy(Perl_MySQLPreparedStmt* ptr);
|
||||||
|
|
||||||
|
void Close();
|
||||||
|
void Execute();
|
||||||
|
void Execute(perl::array args);
|
||||||
|
void SetOptions(perl::hash hash_opts);
|
||||||
|
perl::array FetchArray();
|
||||||
|
perl::reference FetchArrayRef();
|
||||||
|
perl::reference FetchHashRef();
|
||||||
|
|
||||||
|
// StmtResult functions accessible through this class to simplify api
|
||||||
|
int ColumnCount();
|
||||||
|
uint64_t LastInsertID();
|
||||||
|
uint64_t RowCount();
|
||||||
|
uint64_t RowsAffected();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<mysql::PreparedStmt> m_stmt;
|
||||||
|
mysql::StmtResult m_res = {};
|
||||||
|
perl::array m_row_array; // perf: cache for fetches
|
||||||
|
perl::hash m_row_hash;
|
||||||
|
};
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
#include "quest_db.h"
|
||||||
|
#include "zonedb.h"
|
||||||
|
#include "zone_config.h"
|
||||||
|
|
||||||
|
// New connections avoid concurrency issues and allow use of unbuffered results
|
||||||
|
// with prepared statements. Using zone connections w/o buffering would cause
|
||||||
|
// "Commands out of sync" errors if any queries occur before results consumed.
|
||||||
|
QuestDB::QuestDB(Connection type, bool connect)
|
||||||
|
{
|
||||||
|
if (connect)
|
||||||
|
{
|
||||||
|
m_db = std::unique_ptr<Database, Deleter>(new Database(), Deleter(true));
|
||||||
|
|
||||||
|
const auto config = EQEmuConfig::get();
|
||||||
|
|
||||||
|
if (type == Connection::Default || type == Connection::Content && config->ContentDbHost.empty())
|
||||||
|
{
|
||||||
|
m_db->Connect(config->DatabaseHost, config->DatabaseUsername, config->DatabasePassword,
|
||||||
|
config->DatabaseDB, config->DatabasePort, "questdb");
|
||||||
|
}
|
||||||
|
else if (type == Connection::Content)
|
||||||
|
{
|
||||||
|
m_db->Connect(config->ContentDbHost, config->ContentDbUsername, config->ContentDbPassword,
|
||||||
|
config->ContentDbName, config->ContentDbPort, "questdb");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == Connection::Default)
|
||||||
|
{
|
||||||
|
m_db = std::unique_ptr<Database, Deleter>(&database, Deleter(false));
|
||||||
|
}
|
||||||
|
else if (type == Connection::Content)
|
||||||
|
{
|
||||||
|
m_db = std::unique_ptr<Database, Deleter>(&content_db, Deleter(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_db || (connect && m_db->GetStatus() != DBcore::Connected))
|
||||||
|
{
|
||||||
|
throw std::runtime_error(fmt::format("Failed to connect to db type [{}]", static_cast<int>(type)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestDB::QuestDB(const char* host, const char* user, const char* pass, const char* db, uint32_t port)
|
||||||
|
: m_db(new Database(), Deleter(true))
|
||||||
|
{
|
||||||
|
if (!m_db->Connect(host, user, pass, db, port, "questdb"))
|
||||||
|
{
|
||||||
|
throw std::runtime_error(fmt::format("Failed to connect to db [{}:{}]", host, port));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuestDB::Deleter::operator()(Database* ptr) noexcept
|
||||||
|
{
|
||||||
|
if (owner)
|
||||||
|
{
|
||||||
|
delete ptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class Database;
|
||||||
|
|
||||||
|
// Base class for quest apis to manage connection to a MySQL database
|
||||||
|
class QuestDB
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class Connection { Default = 0, Content };
|
||||||
|
|
||||||
|
// Throws std::runtime_error on connection failure
|
||||||
|
QuestDB() : QuestDB(Connection::Default) {}
|
||||||
|
QuestDB(Connection type) : QuestDB(type, false) {}
|
||||||
|
QuestDB(Connection type, bool connect);
|
||||||
|
QuestDB(const char* host, const char* user, const char* pass, const char* db, uint32_t port);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// allow optional ownership of pointer to support using zone db connections
|
||||||
|
struct Deleter
|
||||||
|
{
|
||||||
|
Deleter() : owner(true) {}
|
||||||
|
Deleter(bool owner_) : owner(owner_) {}
|
||||||
|
bool owner = true;
|
||||||
|
void operator()(Database* ptr) noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<Database, Deleter> m_db;
|
||||||
|
};
|
||||||
+75
-172
@@ -4611,181 +4611,9 @@ int8 QuestManager::DoesAugmentFit(EQ::ItemInstance* inst, uint32 augment_id, uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuestManager::SendPlayerHandinEvent() {
|
void QuestManager::SendPlayerHandinEvent() {
|
||||||
QuestManagerCurrentQuestVars();
|
|
||||||
if (!owner || !owner->IsNPC() || !initiator) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
!initiator->EntityVariableExists("HANDIN_ITEMS") &&
|
|
||||||
!initiator->EntityVariableExists("HANDIN_MONEY") &&
|
|
||||||
!initiator->EntityVariableExists("RETURN_ITEMS") &&
|
|
||||||
!initiator->EntityVariableExists("RETURN_MONEY")
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto handin_items = initiator->GetEntityVariable("HANDIN_ITEMS");
|
|
||||||
auto return_items = initiator->GetEntityVariable("RETURN_ITEMS");
|
|
||||||
auto handin_money = initiator->GetEntityVariable("HANDIN_MONEY");
|
|
||||||
auto return_money = initiator->GetEntityVariable("RETURN_MONEY");
|
|
||||||
|
|
||||||
std::vector<PlayerEvent::HandinEntry> hi = {};
|
|
||||||
std::vector<PlayerEvent::HandinEntry> ri = {};
|
|
||||||
PlayerEvent::HandinMoney hm{};
|
|
||||||
PlayerEvent::HandinMoney rm{};
|
|
||||||
|
|
||||||
// Handin Items
|
|
||||||
if (!handin_items.empty()) {
|
|
||||||
if (Strings::Contains(handin_items, ",")) {
|
|
||||||
const auto handin_data = Strings::Split(handin_items, ",");
|
|
||||||
for (const auto &h: handin_data) {
|
|
||||||
const auto item_data = Strings::Split(h, "|");
|
|
||||||
if (
|
|
||||||
item_data.size() == 3 &&
|
|
||||||
Strings::IsNumber(item_data[0]) &&
|
|
||||||
Strings::IsNumber(item_data[1]) &&
|
|
||||||
Strings::IsNumber(item_data[2])
|
|
||||||
) {
|
|
||||||
const auto item_id = static_cast<uint32>(Strings::ToUnsignedInt(item_data[0]));
|
|
||||||
if (item_id != 0) {
|
|
||||||
const auto *item = database.GetItem(item_id);
|
|
||||||
|
|
||||||
if (item) {
|
|
||||||
hi.emplace_back(
|
|
||||||
PlayerEvent::HandinEntry{
|
|
||||||
.item_id = item_id,
|
|
||||||
.item_name = item->Name,
|
|
||||||
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
|
||||||
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Strings::Contains(handin_items, "|")) {
|
|
||||||
const auto item_data = Strings::Split(handin_items, "|");
|
|
||||||
if (
|
|
||||||
item_data.size() == 3 &&
|
|
||||||
Strings::IsNumber(item_data[0]) &&
|
|
||||||
Strings::IsNumber(item_data[1]) &&
|
|
||||||
Strings::IsNumber(item_data[2])
|
|
||||||
) {
|
|
||||||
const auto item_id = static_cast<uint32>(Strings::ToUnsignedInt(item_data[0]));
|
|
||||||
const auto *item = database.GetItem(item_id);
|
|
||||||
|
|
||||||
if (item) {
|
|
||||||
hi.emplace_back(
|
|
||||||
PlayerEvent::HandinEntry{
|
|
||||||
.item_id = item_id,
|
|
||||||
.item_name = item->Name,
|
|
||||||
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
|
||||||
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handin Money
|
|
||||||
if (!handin_money.empty()) {
|
|
||||||
const auto hms = Strings::Split(handin_money, "|");
|
|
||||||
hm.copper = static_cast<uint32>(Strings::ToUnsignedInt(hms[0]));
|
|
||||||
hm.silver = static_cast<uint32>(Strings::ToUnsignedInt(hms[1]));
|
|
||||||
hm.gold = static_cast<uint32>(Strings::ToUnsignedInt(hms[2]));
|
|
||||||
hm.platinum = static_cast<uint32>(Strings::ToUnsignedInt(hms[3]));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return Items
|
|
||||||
if (!return_items.empty()) {
|
|
||||||
if (Strings::Contains(return_items, ",")) {
|
|
||||||
const auto return_data = Strings::Split(return_items, ",");
|
|
||||||
for (const auto &r: return_data) {
|
|
||||||
const auto item_data = Strings::Split(r, "|");
|
|
||||||
if (
|
|
||||||
item_data.size() == 3 &&
|
|
||||||
Strings::IsNumber(item_data[0]) &&
|
|
||||||
Strings::IsNumber(item_data[1]) &&
|
|
||||||
Strings::IsNumber(item_data[2])
|
|
||||||
) {
|
|
||||||
const auto item_id = static_cast<uint32>(Strings::ToUnsignedInt(item_data[0]));
|
|
||||||
const auto *item = database.GetItem(item_id);
|
|
||||||
|
|
||||||
if (item) {
|
|
||||||
ri.emplace_back(
|
|
||||||
PlayerEvent::HandinEntry{
|
|
||||||
.item_id = item_id,
|
|
||||||
.item_name = item->Name,
|
|
||||||
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
|
||||||
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Strings::Contains(return_items, "|")) {
|
|
||||||
const auto item_data = Strings::Split(return_items, "|");
|
|
||||||
if (
|
|
||||||
item_data.size() == 3 &&
|
|
||||||
Strings::IsNumber(item_data[0]) &&
|
|
||||||
Strings::IsNumber(item_data[1]) &&
|
|
||||||
Strings::IsNumber(item_data[2])
|
|
||||||
) {
|
|
||||||
const auto item_id = static_cast<uint32>(Strings::ToUnsignedInt(item_data[0]));
|
|
||||||
const auto *item = database.GetItem(item_id);
|
|
||||||
|
|
||||||
if (item) {
|
|
||||||
ri.emplace_back(
|
|
||||||
PlayerEvent::HandinEntry{
|
|
||||||
.item_id = item_id,
|
|
||||||
.item_name = item->Name,
|
|
||||||
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
|
||||||
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return Money
|
|
||||||
if (!return_money.empty()) {
|
|
||||||
const auto rms = Strings::Split(return_money, "|");
|
|
||||||
rm.copper = static_cast<uint32>(Strings::ToUnsignedInt(rms[0]));
|
|
||||||
rm.silver = static_cast<uint32>(Strings::ToUnsignedInt(rms[1]));
|
|
||||||
rm.gold = static_cast<uint32>(Strings::ToUnsignedInt(rms[2]));
|
|
||||||
rm.platinum = static_cast<uint32>(Strings::ToUnsignedInt(rms[3]));
|
|
||||||
}
|
|
||||||
|
|
||||||
initiator->DeleteEntityVariable("HANDIN_ITEMS");
|
|
||||||
initiator->DeleteEntityVariable("HANDIN_MONEY");
|
|
||||||
initiator->DeleteEntityVariable("RETURN_ITEMS");
|
|
||||||
initiator->DeleteEntityVariable("RETURN_MONEY");
|
|
||||||
|
|
||||||
bool handed_in_money = hm.platinum > 0 || hm.gold > 0 || hm.silver > 0 || hm.copper > 0;
|
|
||||||
|
|
||||||
bool event_has_data_to_record = (
|
|
||||||
!hi.empty() || handed_in_money
|
|
||||||
);
|
|
||||||
|
|
||||||
if (player_event_logs.IsEventEnabled(PlayerEvent::NPC_HANDIN) && event_has_data_to_record) {
|
|
||||||
auto e = PlayerEvent::HandinEvent{
|
|
||||||
.npc_id = owner->CastToNPC()->GetNPCTypeID(),
|
|
||||||
.npc_name = owner->GetCleanName(),
|
|
||||||
.handin_items = hi,
|
|
||||||
.handin_money = hm,
|
|
||||||
.return_items = ri,
|
|
||||||
.return_money = rm
|
|
||||||
};
|
|
||||||
|
|
||||||
RecordPlayerEventLogWithClient(initiator, PlayerEvent::NPC_HANDIN, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string QuestManager::GetAutoLoginCharacterNameByAccountID(uint32 account_id)
|
std::string QuestManager::GetAutoLoginCharacterNameByAccountID(uint32 account_id)
|
||||||
{
|
{
|
||||||
return AccountRepository::GetAutoLoginCharacterNameByAccountID(database, account_id);
|
return AccountRepository::GetAutoLoginCharacterNameByAccountID(database, account_id);
|
||||||
@@ -4795,3 +4623,78 @@ bool QuestManager::SetAutoLoginCharacterNameByAccountID(uint32 account_id, const
|
|||||||
{
|
{
|
||||||
return AccountRepository::SetAutoLoginCharacterNameByAccountID(database, account_id, character_name);
|
return AccountRepository::SetAutoLoginCharacterNameByAccountID(database, account_id, character_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuestManager::SpawnCircle(uint32 npc_id, glm::vec4 position, float radius, uint32 points)
|
||||||
|
{
|
||||||
|
const NPCType* t = content_db.LoadNPCTypesData(npc_id);
|
||||||
|
if (!t) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec4 npc_position = position;
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < points; i++) {
|
||||||
|
float angle = 2 * M_PI * i / points;
|
||||||
|
|
||||||
|
npc_position.x = position.x + radius * std::cos(angle);
|
||||||
|
npc_position.y = position.y + radius * std::sin(angle);
|
||||||
|
|
||||||
|
NPC* n = new NPC(t, nullptr, npc_position, GravityBehavior::Water);
|
||||||
|
|
||||||
|
n->FixZ();
|
||||||
|
|
||||||
|
n->AddLootTable();
|
||||||
|
|
||||||
|
if (n->DropsGlobalLoot()) {
|
||||||
|
n->CheckGlobalLootTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
entity_list.AddNPC(n, true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuestManager::SpawnGrid(uint32 npc_id, glm::vec4 position, float spacing, uint32 spawn_count)
|
||||||
|
{
|
||||||
|
const NPCType* t = content_db.LoadNPCTypesData(npc_id);
|
||||||
|
if (!t) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec4 npc_position = position;
|
||||||
|
|
||||||
|
uint32 columns = std::ceil(std::sqrt(spawn_count));
|
||||||
|
uint32 rows = std::ceil(spawn_count / columns);
|
||||||
|
|
||||||
|
float total_width = ((columns - 1) * spacing);
|
||||||
|
float total_height = ((rows - 1) * spacing);
|
||||||
|
|
||||||
|
float start_x = position.x - total_width / 2;
|
||||||
|
float start_y = position.y - total_height / 2;
|
||||||
|
|
||||||
|
uint32 spawned = 0;
|
||||||
|
|
||||||
|
for (uint32 row = 0; row < rows; row++) {
|
||||||
|
for (uint32 column = 0; column < columns; column++) {
|
||||||
|
if (spawned >= spawn_count) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
npc_position.x = start_x + column * spacing;
|
||||||
|
npc_position.y = start_y + row * spacing;
|
||||||
|
|
||||||
|
NPC* n = new NPC(t, nullptr, npc_position, GravityBehavior::Water);
|
||||||
|
|
||||||
|
n->FixZ();
|
||||||
|
|
||||||
|
n->AddLootTable();
|
||||||
|
|
||||||
|
if (n->DropsGlobalLoot()) {
|
||||||
|
n->CheckGlobalLootTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
entity_list.AddNPC(n, true, true);
|
||||||
|
|
||||||
|
spawned++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -357,6 +357,8 @@ public:
|
|||||||
void SendChannelMessage(Client* from, const char* to, uint8 channel_number, uint32 guild_id, uint8 language_id, uint8 language_skill, const char* message);
|
void SendChannelMessage(Client* from, const char* to, uint8 channel_number, uint32 guild_id, uint8 language_id, uint8 language_skill, const char* message);
|
||||||
std::string GetAutoLoginCharacterNameByAccountID(uint32 account_id);
|
std::string GetAutoLoginCharacterNameByAccountID(uint32 account_id);
|
||||||
bool SetAutoLoginCharacterNameByAccountID(uint32 account_id, const std::string& character_name);
|
bool SetAutoLoginCharacterNameByAccountID(uint32 account_id, const std::string& character_name);
|
||||||
|
void SpawnCircle(uint32 npc_id, glm::vec4 position, float radius, uint32 points);
|
||||||
|
void SpawnGrid(uint32 npc_id, glm::vec4 position, float spacing, uint32 spawn_count);
|
||||||
|
|
||||||
Bot *GetBot() const;
|
Bot *GetBot() const;
|
||||||
Client *GetInitiator() const;
|
Client *GetInitiator() const;
|
||||||
|
|||||||
@@ -2416,15 +2416,17 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16 focus = RuleB(Spells, AllowFocusOnSkillDamageSpells) ? caster->GetMeleeDamageMod_SE(spells[spell_id].skill) : 0;
|
||||||
|
|
||||||
switch(spells[spell_id].skill) {
|
switch(spells[spell_id].skill) {
|
||||||
case EQ::skills::SkillThrowing:
|
case EQ::skills::SkillThrowing:
|
||||||
caster->DoThrowingAttackDmg(this, nullptr, nullptr, spells[spell_id].base_value[i],spells[spell_id].limit_value[i], 0, ReuseTime, 0, 0, 4.0f, true);
|
caster->DoThrowingAttackDmg(this, nullptr, nullptr, spells[spell_id].base_value[i],spells[spell_id].limit_value[i], focus, ReuseTime, 0, 0, 4.0f, true);
|
||||||
break;
|
break;
|
||||||
case EQ::skills::SkillArchery:
|
case EQ::skills::SkillArchery:
|
||||||
caster->DoArcheryAttackDmg(this, nullptr, nullptr, spells[spell_id].base_value[i],spells[spell_id].limit_value[i], 0, ReuseTime, 0, 0, nullptr, 0, 4.0f, true);
|
caster->DoArcheryAttackDmg(this, nullptr, nullptr, spells[spell_id].base_value[i],spells[spell_id].limit_value[i], focus, ReuseTime, 0, 0, nullptr, 0, 4.0f, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
caster->DoMeleeSkillAttackDmg(this, spells[spell_id].base_value[i], spells[spell_id].skill, spells[spell_id].limit_value[i], 0, false, ReuseTime);
|
caster->DoMeleeSkillAttackDmg(this, spells[spell_id].base_value[i], spells[spell_id].skill, spells[spell_id].limit_value[i], focus, false, ReuseTime);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+30
-13
@@ -664,6 +664,8 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(tradingWith && tradingWith->IsNPC()) {
|
else if(tradingWith && tradingWith->IsNPC()) {
|
||||||
|
NPCHandinEventLog(trade, tradingWith->CastToNPC());
|
||||||
|
|
||||||
QSPlayerLogHandin_Struct* qs_audit = nullptr;
|
QSPlayerLogHandin_Struct* qs_audit = nullptr;
|
||||||
bool qs_log = false;
|
bool qs_log = false;
|
||||||
|
|
||||||
@@ -775,6 +777,8 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
|||||||
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
||||||
PushItemOnCursor(*inst, true);
|
PushItemOnCursor(*inst, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
items.clear();
|
||||||
}
|
}
|
||||||
// Only enforce trade rules if the NPC doesn't have an EVENT_TRADE
|
// Only enforce trade rules if the NPC doesn't have an EVENT_TRADE
|
||||||
// subroutine. That overrides all.
|
// subroutine. That overrides all.
|
||||||
@@ -832,13 +836,13 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto loot_drop_entry = LootdropEntriesRepository::NewNpcEntity();
|
auto lde = LootdropEntriesRepository::NewNpcEntity();
|
||||||
loot_drop_entry.equip_item = 1;
|
lde.equip_item = 1;
|
||||||
loot_drop_entry.item_charges = static_cast<int8>(baginst->GetCharges());
|
lde.item_charges = static_cast<int8>(baginst->GetCharges());
|
||||||
|
|
||||||
tradingWith->CastToNPC()->AddLootDrop(
|
tradingWith->CastToNPC()->AddLootDrop(
|
||||||
bagitem,
|
bagitem,
|
||||||
loot_drop_entry,
|
lde,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
// Return quest items being traded to non-quest NPC when the rule is true
|
// Return quest items being traded to non-quest NPC when the rule is true
|
||||||
@@ -857,18 +861,18 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
auto lde = LootdropEntriesRepository::NewNpcEntity();
|
||||||
auto new_loot_drop_entry = LootdropEntriesRepository::NewNpcEntity();
|
lde.equip_item = 1;
|
||||||
new_loot_drop_entry.equip_item = 1;
|
lde.item_charges = static_cast<int8>(inst->GetCharges());
|
||||||
new_loot_drop_entry.item_charges = static_cast<int8>(inst->GetCharges());
|
|
||||||
|
|
||||||
tradingWith->CastToNPC()->AddLootDrop(
|
tradingWith->CastToNPC()->AddLootDrop(
|
||||||
item,
|
item,
|
||||||
new_loot_drop_entry,
|
lde,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Return quest items being traded to non-quest NPC when the rule is true
|
// Return quest items being traded to non-quest NPC when the rule is true
|
||||||
else if (restrict_quest_items_to_quest_npc && (!is_quest_npc && item->IsQuestItem())) {
|
else if (restrict_quest_items_to_quest_npc && (!is_quest_npc && item->IsQuestItem())) {
|
||||||
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
||||||
@@ -2604,6 +2608,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app)
|
|||||||
data->zone_id = GetZoneID();
|
data->zone_id = GetZoneID();
|
||||||
data->slot = sell_line.slot;
|
data->slot = sell_line.slot;
|
||||||
data->seller_quantity = sell_line.seller_quantity;
|
data->seller_quantity = sell_line.seller_quantity;
|
||||||
|
data->purchase_method = sell_line.purchase_method;
|
||||||
strn0cpy(data->item_name, sell_line.item_name, sizeof(data->item_name));
|
strn0cpy(data->item_name, sell_line.item_name, sizeof(data->item_name));
|
||||||
strn0cpy(data->buyer_name, sell_line.buyer_name.c_str(), sizeof(data->buyer_name));
|
strn0cpy(data->buyer_name, sell_line.buyer_name.c_str(), sizeof(data->buyer_name));
|
||||||
strn0cpy(data->seller_name, GetCleanName(), sizeof(data->seller_name));
|
strn0cpy(data->seller_name, GetCleanName(), sizeof(data->seller_name));
|
||||||
@@ -2914,6 +2919,7 @@ void Client::SendBecomeTraderToWorld(Client *trader, BazaarTraderBarterActions a
|
|||||||
data->entity_id = trader->GetID();
|
data->entity_id = trader->GetID();
|
||||||
data->trader_id = trader->CharacterID();
|
data->trader_id = trader->CharacterID();
|
||||||
data->zone_id = trader->GetZoneID();
|
data->zone_id = trader->GetZoneID();
|
||||||
|
data->instance_id = trader->GetInstanceID();
|
||||||
strn0cpy(data->trader_name, trader->GetName(), sizeof(data->trader_name));
|
strn0cpy(data->trader_name, trader->GetName(), sizeof(data->trader_name));
|
||||||
|
|
||||||
worldserver.SendPacket(outapp);
|
worldserver.SendPacket(outapp);
|
||||||
@@ -3232,7 +3238,10 @@ void Client::SendBulkBazaarTraders()
|
|||||||
|
|
||||||
void Client::DoBazaarInspect(const BazaarInspect_Struct &in)
|
void Client::DoBazaarInspect(const BazaarInspect_Struct &in)
|
||||||
{
|
{
|
||||||
auto items = TraderRepository::GetWhere(database, fmt::format("item_sn = {}", in.serial_number));
|
auto items = TraderRepository::GetWhere(
|
||||||
|
database, fmt::format("`char_id` = '{}' AND `item_sn` = '{}'", in.trader_id, in.serial_number)
|
||||||
|
);
|
||||||
|
|
||||||
if (items.empty()) {
|
if (items.empty()) {
|
||||||
LogInfo("Failed to find item with serial number [{}]", in.serial_number);
|
LogInfo("Failed to find item with serial number [{}]", in.serial_number);
|
||||||
return;
|
return;
|
||||||
@@ -3301,7 +3310,7 @@ std::string Client::DetermineMoneyString(uint64 cp)
|
|||||||
void Client::BuyTraderItemOutsideBazaar(TraderBuy_Struct *tbs, const EQApplicationPacket *app)
|
void Client::BuyTraderItemOutsideBazaar(TraderBuy_Struct *tbs, const EQApplicationPacket *app)
|
||||||
{
|
{
|
||||||
auto in = (TraderBuy_Struct *) app->pBuffer;
|
auto in = (TraderBuy_Struct *) app->pBuffer;
|
||||||
auto trader_item = TraderRepository::GetItemBySerialNumber(database, tbs->serial_number);
|
auto trader_item = TraderRepository::GetItemBySerialNumber(database, tbs->serial_number, tbs->trader_id);
|
||||||
if (!trader_item.id) {
|
if (!trader_item.id) {
|
||||||
LogTrading("Attempt to purchase an item outside of the Bazaar trader_id <red>[{}] item serial_number "
|
LogTrading("Attempt to purchase an item outside of the Bazaar trader_id <red>[{}] item serial_number "
|
||||||
"<red>[{}] The Traders data was outdated.",
|
"<red>[{}] The Traders data was outdated.",
|
||||||
@@ -3495,7 +3504,7 @@ void Client::BuyTraderItemOutsideBazaar(TraderBuy_Struct *tbs, const EQApplicati
|
|||||||
ps.item_slot = parcel_out.slot_id;
|
ps.item_slot = parcel_out.slot_id;
|
||||||
strn0cpy(ps.send_to, GetCleanName(), sizeof(ps.send_to));
|
strn0cpy(ps.send_to, GetCleanName(), sizeof(ps.send_to));
|
||||||
|
|
||||||
if (trader_item.item_charges <= static_cast<int32>(tbs->quantity)) {
|
if (trader_item.item_charges <= static_cast<int32>(tbs->quantity) || !buy_item->IsStackable()) {
|
||||||
TraderRepository::DeleteOne(database, trader_item.id);
|
TraderRepository::DeleteOne(database, trader_item.id);
|
||||||
} else {
|
} else {
|
||||||
TraderRepository::UpdateQuantity(
|
TraderRepository::UpdateQuantity(
|
||||||
@@ -4250,6 +4259,14 @@ bool Client::DoBarterSellerChecks(BuyerLineSellItem_Struct &sell_line)
|
|||||||
Message(Chat::Red, "The item that you are trying to sell is augmented. Please remove augments first");
|
Message(Chat::Red, "The item that you are trying to sell is augmented. Please remove augments first");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sell_item && !sell_item->IsDroppable()) {
|
||||||
|
seller_error = true;
|
||||||
|
LogTradingDetail("Seller item <red>[{}] is non-tradeable therefore cannot be sold.",
|
||||||
|
sell_line.item_name
|
||||||
|
);
|
||||||
|
Message(Chat::Red, "The item that you are trying to sell is non-tradeable and therefore cannot be sold.");
|
||||||
|
}
|
||||||
|
|
||||||
if (seller_error) {
|
if (seller_error) {
|
||||||
LogTradingDetail("Seller Error <red>[{}] Barter Sell/Buy Transaction Failed.", seller_error);
|
LogTradingDetail("Seller Error <red>[{}] Barter Sell/Buy Transaction Failed.", seller_error);
|
||||||
SendBarterBuyerClientMessage(sell_line, Barter_SellerTransactionComplete, Barter_Failure, Barter_Failure);
|
SendBarterBuyerClientMessage(sell_line, Barter_SellerTransactionComplete, Barter_Failure, Barter_Failure);
|
||||||
|
|||||||
@@ -3942,7 +3942,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|||||||
c.second->QueuePacket(outapp);
|
c.second->QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
if (zone && zone->GetZoneID() == Zones::BAZAAR) {
|
if (zone && zone->GetZoneID() == Zones::BAZAAR && in->instance_id == zone->GetInstanceID()) {
|
||||||
if (in->action == TraderOn) {
|
if (in->action == TraderOn) {
|
||||||
c.second->SendBecomeTrader(TraderOn, in->entity_id);
|
c.second->SendBecomeTrader(TraderOn, in->entity_id);
|
||||||
}
|
}
|
||||||
@@ -4044,6 +4044,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|||||||
sell_line.buyer_name = in->buyer_name;
|
sell_line.buyer_name = in->buyer_name;
|
||||||
sell_line.seller_quantity = in->seller_quantity;
|
sell_line.seller_quantity = in->seller_quantity;
|
||||||
sell_line.slot = in->slot;
|
sell_line.slot = in->slot;
|
||||||
|
sell_line.purchase_method = in->purchase_method;
|
||||||
strn0cpy(sell_line.item_name, in->item_name, sizeof(sell_line.item_name));
|
strn0cpy(sell_line.item_name, in->item_name, sizeof(sell_line.item_name));
|
||||||
|
|
||||||
uint64 total_cost = (uint64) sell_line.item_cost * (uint64) sell_line.seller_quantity;
|
uint64 total_cost = (uint64) sell_line.item_cost * (uint64) sell_line.seller_quantity;
|
||||||
|
|||||||
+3
-12
@@ -561,12 +561,6 @@ bool ZoneDatabase::LoadCharacterData(uint32 character_id, PlayerProfile_Struct*
|
|||||||
m_epp->expended_aa = e.e_expended_aa_spent;
|
m_epp->expended_aa = e.e_expended_aa_spent;
|
||||||
m_epp->last_invsnapshot_time = e.e_last_invsnapshot;
|
m_epp->last_invsnapshot_time = e.e_last_invsnapshot;
|
||||||
m_epp->next_invsnapshot_time = m_epp->last_invsnapshot_time + (RuleI(Character, InvSnapshotMinIntervalM) * 60);
|
m_epp->next_invsnapshot_time = m_epp->last_invsnapshot_time + (RuleI(Character, InvSnapshotMinIntervalM) * 60);
|
||||||
pp->cold_resist = e.cold_resist;
|
|
||||||
pp->fire_resist = e.fire_resist;
|
|
||||||
pp->magic_resist = e.magic_resist;
|
|
||||||
pp->disease_resist = e.disease_resist;
|
|
||||||
pp->poison_resist = e.poison_resist;
|
|
||||||
pp->corruption_resist = e.corruption_resist;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1164,12 +1158,6 @@ bool ZoneDatabase::SaveCharacterData(
|
|||||||
e.e_expended_aa_spent = m_epp->expended_aa;
|
e.e_expended_aa_spent = m_epp->expended_aa;
|
||||||
e.e_last_invsnapshot = m_epp->last_invsnapshot_time;
|
e.e_last_invsnapshot = m_epp->last_invsnapshot_time;
|
||||||
e.mailkey = c->GetMailKeyFull();
|
e.mailkey = c->GetMailKeyFull();
|
||||||
e.cold_resist = pp->cold_resist;
|
|
||||||
e.fire_resist = pp->fire_resist;
|
|
||||||
e.magic_resist = pp->magic_resist;
|
|
||||||
e.disease_resist = pp->disease_resist;
|
|
||||||
e.poison_resist = pp->poison_resist;
|
|
||||||
e.corruption_resist = pp->corruption_resist;
|
|
||||||
|
|
||||||
const int replaced = CharacterDataRepository::ReplaceOne(database, e);
|
const int replaced = CharacterDataRepository::ReplaceOne(database, e);
|
||||||
|
|
||||||
@@ -3484,6 +3472,9 @@ bool ZoneDatabase::LoadFactionData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto& fmr_row = faction_max_results.begin();
|
auto& fmr_row = faction_max_results.begin();
|
||||||
|
if (fmr_row[0] == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
max_faction = Strings::ToUnsignedInt(fmr_row[0]);
|
max_faction = Strings::ToUnsignedInt(fmr_row[0]);
|
||||||
faction_array = new Faction *[max_faction + 1];
|
faction_array = new Faction *[max_faction + 1];
|
||||||
|
|||||||
+1
-1
@@ -737,7 +737,7 @@ void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y,
|
|||||||
ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
|
ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogError("Client::ProcessMovePC received a reguest to perform an unsupported client zone operation");
|
LogError("Received a request to perform an unsupported client zone operation");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user