Merge fix

This commit is contained in:
KimLS
2018-11-11 01:05:44 -08:00
17 changed files with 754 additions and 415 deletions
+10 -6
View File
@@ -1012,7 +1012,12 @@ void Client::Handle_Connect_OP_ReqNewZone(const EQApplicationPacket *app)
memcpy(outapp->pBuffer, &zone->newzone_data, sizeof(NewZone_Struct));
strcpy(nz->char_name, m_pp.name);
FastQueuePacket(&outapp);
// This was using FastQueuePacket and the packet was never getting sent...
// Not sure if this was timing.... but the NewZone was never logged until
// I changed it.
outapp->priority = 6;
QueuePacket(outapp);
safe_delete(outapp);
return;
}
@@ -1638,11 +1643,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
/* Task Packets */
LoadClientTaskState();
if (ClientVersion() >= EQEmu::versions::ClientVersion::RoF) {
outapp = new EQApplicationPacket(OP_ReqNewZone, 0);
Handle_Connect_OP_ReqNewZone(outapp);
safe_delete(outapp);
}
if (m_ClientVersionBit & EQEmu::versions::bit_UFAndLater) {
outapp = new EQApplicationPacket(OP_XTargetResponse, 8);
@@ -1668,6 +1668,10 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
QueuePacket(outapp);
safe_delete(outapp);
if (ClientVersion() >= EQEmu::versions::ClientVersion::RoF) {
Handle_Connect_OP_ReqNewZone(nullptr);
}
SetAttackTimer();
conn_state = ZoneInfoSent;
zoneinpacket_timer.Start();
+26 -1
View File
@@ -76,6 +76,31 @@ std::string DataBucket::GetData(std::string bucket_key) {
return std::string(row[0]);
}
/**
* Retrieves data expires time via bucket_name as key
* @param bucket_key
* @return
*/
std::string DataBucket::GetDataExpires(std::string bucket_key) {
std::string query = StringFormat(
"SELECT `expires` from `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0) LIMIT 1",
bucket_key.c_str(),
(long long) std::time(nullptr)
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return std::string();
}
if (results.RowCount() != 1)
return std::string();
auto row = results.begin();
return std::string(row[0]);
}
/**
* Checks for bucket existence by bucket_name key
* @param bucket_key
@@ -107,7 +132,7 @@ uint64 DataBucket::DoesBucketExist(std::string bucket_key) {
*/
bool DataBucket::DeleteData(std::string bucket_key) {
std::string query = StringFormat(
"DELETE FROM `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0)",
"DELETE FROM `data_buckets` WHERE `key` = '%s'",
EscapeString(bucket_key).c_str()
);
+1
View File
@@ -14,6 +14,7 @@ public:
static void SetData(std::string bucket_key, std::string bucket_value, std::string expires_time = "");
static bool DeleteData(std::string bucket_key);
static std::string GetData(std::string bucket_key);
static std::string GetDataExpires(std::string bucket_key);
private:
static uint64 DoesBucketExist(std::string bucket_key);
static uint32 ParseStringTimeToInt(std::string time_string);
+15
View File
@@ -3596,6 +3596,21 @@ XS(XS__get_data) {
XSRETURN(1);
}
XS(XS__get_data_expires);
XS(XS__get_data_expires) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::get_data_expires(string bucket_key)");
dXSTARG;
std::string key = (std::string) SvPV_nolen(ST(0));
sv_setpv(TARG, DataBucket::GetDataExpires(key).c_str());
XSprePUSH;
PUSHTARG;
XSRETURN(1);
}
XS(XS__set_data);
XS(XS__set_data) {
dXSARGS;
+4
View File
@@ -822,6 +822,10 @@ std::string lua_get_data(std::string bucket_key) {
return DataBucket::GetData(bucket_key);
}
std::string lua_get_data_expires(std::string bucket_key) {
return DataBucket::GetDataExpires(bucket_key);
}
void lua_set_data(std::string bucket_key, std::string bucket_value) {
DataBucket::SetData(bucket_key, bucket_value);
}
+37
View File
@@ -328,6 +328,36 @@ void Lua_NPC::AI_SetRoambox(float dist, float max_x, float min_x, float max_y, f
self->AI_SetRoambox(dist, max_x, min_x, max_y, min_y, delay, mindelay);
}
void Lua_NPC::SetFollowID(int id) {
Lua_Safe_Call_Void();
self->SetFollowID(id);
}
void Lua_NPC::SetFollowDistance(int dist) {
Lua_Safe_Call_Void();
self->SetFollowDistance(dist);
}
void Lua_NPC::SetFollowCanRun(bool v) {
Lua_Safe_Call_Void();
self->SetFollowCanRun(v);
}
int Lua_NPC::GetFollowID() {
Lua_Safe_Call_Int();
return self->GetFollowID();
}
int Lua_NPC::GetFollowDistance() {
Lua_Safe_Call_Int();
return self->GetFollowDistance();
}
bool Lua_NPC::GetFollowCanRun() {
Lua_Safe_Call_Bool();
return self->GetFollowCanRun();
}
int Lua_NPC::GetNPCSpellsID() {
Lua_Safe_Call_Int();
return self->GetNPCSpellsID();
@@ -566,6 +596,13 @@ luabind::scope lua_register_npc() {
.def("IsGuarding", (bool(Lua_NPC::*)(void))&Lua_NPC::IsGuarding)
.def("AI_SetRoambox", (void(Lua_NPC::*)(float,float,float,float,float))&Lua_NPC::AI_SetRoambox)
.def("AI_SetRoambox", (void(Lua_NPC::*)(float,float,float,float,float,uint32,uint32))&Lua_NPC::AI_SetRoambox)
.def("SetFollowID", (void(Lua_NPC::*)(int))&Lua_NPC::SetFollowID)
.def("SetFollowDistance", (void(Lua_NPC::*)(int))&Lua_NPC::SetFollowDistance)
.def("SetFollowCanRun", (void(Lua_NPC::*)(bool))&Lua_NPC::SetFollowCanRun)
.def("GetFollowID", (int(Lua_NPC::*)(void))&Lua_NPC::GetFollowID)
.def("GetFollowDistance", (int(Lua_NPC::*)(void))&Lua_NPC::GetFollowDistance)
.def("GetFollowCanRun", (bool(Lua_NPC::*)(void))&Lua_NPC::GetFollowCanRun)
.def("GetNPCSpellsID", (int(Lua_NPC::*)(void))&Lua_NPC::GetNPCSpellsID)
.def("GetNPCSpellsID", (int(Lua_NPC::*)(void))&Lua_NPC::GetNPCSpellsID)
.def("GetSpawnPointID", (int(Lua_NPC::*)(void))&Lua_NPC::GetSpawnPointID)
.def("GetSpawnPointX", (float(Lua_NPC::*)(void))&Lua_NPC::GetSpawnPointX)
+6
View File
@@ -91,6 +91,12 @@ public:
bool IsGuarding();
void AI_SetRoambox(float dist, float max_x, float min_x, float max_y, float min_y);
void AI_SetRoambox(float dist, float max_x, float min_x, float max_y, float min_y, uint32 delay, uint32 mindelay);
void SetFollowID(int id);
void SetFollowDistance(int dist);
void SetFollowCanRun(bool v);
int GetFollowID();
int GetFollowDistance();
bool GetFollowCanRun();
int GetNPCSpellsID();
int GetSpawnPointID();
float GetSpawnPointX();
+2 -1
View File
@@ -379,8 +379,9 @@ Mob::Mob(const char* in_name,
m_CurrentWayPoint = glm::vec4();
cur_wp_pause = 0;
patrol = 0;
follow = 0;
follow_id = 0;
follow_dist = 100; // Default Distance for Follow
follow_run = true; // We can run if distance great enough
no_target_hotkey = false;
flee_mode = false;
currently_fleeing = false;
+6 -3
View File
@@ -679,10 +679,12 @@ public:
virtual bool IsAttackAllowed(Mob *target, bool isSpellAttack = false);
bool IsTargeted() const { return (targeted > 0); }
inline void IsTargeted(int in_tar) { targeted += in_tar; if(targeted < 0) targeted = 0;}
void SetFollowID(uint32 id) { follow = id; }
void SetFollowID(uint32 id) { follow_id = id; }
void SetFollowDistance(uint32 dist) { follow_dist = dist; }
uint32 GetFollowID() const { return follow; }
void SetFollowCanRun(bool v) { follow_run = v; }
uint32 GetFollowID() const { return follow_id; }
uint32 GetFollowDistance() const { return follow_dist; }
bool GetFollowCanRun() const { return follow_run; }
inline bool IsRareSpawn() const { return rare_spawn; }
inline void SetRareSpawn(bool in) { rare_spawn = in; }
@@ -1229,8 +1231,9 @@ protected:
uint16 ownerid;
PetType typeofpet;
int16 petpower;
uint32 follow;
uint32 follow_id;
uint32 follow_dist;
bool follow_run;
bool no_target_hotkey;
bool rare_spawn;
+4 -2
View File
@@ -1523,6 +1523,8 @@ void Mob::AI_Process() {
Mob *follow = entity_list.GetMob(static_cast<uint16>(GetFollowID()));
if (!follow) {
SetFollowID(0);
SetFollowDistance(100);
SetFollowCanRun(true);
}
else {
@@ -1534,8 +1536,8 @@ void Mob::AI_Process() {
*/
if (distance >= follow_distance) {
bool running = false;
if (distance >= follow_distance + 150) {
// maybe we want the NPC to only walk doing follow logic
if (GetFollowCanRun() && distance >= follow_distance + 150) {
running = true;
}