Merge branch 'master' into shared_tasks

This commit is contained in:
Michael Cook (mackal)
2018-10-22 20:29:02 -04:00
9 changed files with 625 additions and 346 deletions
+10 -6
View File
@@ -1116,7 +1116,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;
}
@@ -1742,11 +1747,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);
@@ -1772,6 +1772,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
@@ -3613,6 +3613,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
@@ -848,6 +848,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);
}