mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 04:11:30 +00:00
[Character] Convert NoRentExpired to Repositories (#3860)
* [Character] Convert NoRentExpired to Repositories - Create a custom `GetSecondsSinceLastLogin` repository method to use in `NoRentExpired`. * Update character_data_repository.h
This commit is contained in:
parent
44d63c47d9
commit
20778ad7d9
@ -46,6 +46,24 @@ public:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Custom extended repository methods here
|
// Custom extended repository methods here
|
||||||
|
static uint32 GetSecondsSinceLastLogin(Database &db, const std::string& name)
|
||||||
|
{
|
||||||
|
auto results = db.QueryDatabase(
|
||||||
|
fmt::format(
|
||||||
|
"SELECT (UNIX_TIMESTAMP(NOW()) - last_login) FROM {} WHERE name = '{}'",
|
||||||
|
TableName(),
|
||||||
|
Strings::Escape(name)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!results.RowCount() || !results.Success()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
|
||||||
|
return Strings::ToUnsignedInt(row[0]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EQEMU_CHARACTER_DATA_REPOSITORY_H
|
#endif //EQEMU_CHARACTER_DATA_REPOSITORY_H
|
||||||
|
|||||||
@ -763,10 +763,12 @@ void Client::BulkSendInventoryItems()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deletenorent = database.NoRentExpired(GetName());
|
const bool delete_no_rent = database.NoRentExpired(GetName());
|
||||||
if (deletenorent) { //client was offline for more than 30 minutes, delete no rent items
|
if (delete_no_rent) { //client was offline for more than 30 minutes, delete no rent items
|
||||||
if (RuleB(Inventory, TransformSummonedBags))
|
if (RuleB(Inventory, TransformSummonedBags)) {
|
||||||
DisenchantSummonedBags(false);
|
DisenchantSummonedBags(false);
|
||||||
|
}
|
||||||
|
|
||||||
RemoveNoRent(false);
|
RemoveNoRent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
#include "../common/repositories/character_alt_currency_repository.h"
|
#include "../common/repositories/character_alt_currency_repository.h"
|
||||||
#include "../common/repositories/character_item_recast_repository.h"
|
#include "../common/repositories/character_item_recast_repository.h"
|
||||||
#include "../common/repositories/account_repository.h"
|
#include "../common/repositories/account_repository.h"
|
||||||
|
#include "../common/repositories/character_data_repository.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -1389,19 +1390,11 @@ bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 slo
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::NoRentExpired(const char* name){
|
bool ZoneDatabase::NoRentExpired(const std::string& name)
|
||||||
std::string query = StringFormat("SELECT (UNIX_TIMESTAMP(NOW()) - last_login) FROM `character_data` WHERE name = '%s'", name);
|
{
|
||||||
auto results = QueryDatabase(query);
|
const uint32 seconds = CharacterDataRepository::GetSecondsSinceLastLogin(*this, name);
|
||||||
if (!results.Success())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (results.RowCount() != 1)
|
return seconds > 1800;
|
||||||
return false;
|
|
||||||
|
|
||||||
auto& row = results.begin();
|
|
||||||
uint32 seconds = Strings::ToInt(row[0]);
|
|
||||||
|
|
||||||
return (seconds>1800);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::SaveCharacterInvSnapshot(uint32 character_id) {
|
bool ZoneDatabase::SaveCharacterInvSnapshot(uint32 character_id) {
|
||||||
|
|||||||
@ -464,7 +464,7 @@ public:
|
|||||||
void SetEXPModifier(uint32 character_id, uint32 zone_id, double exp_modifier, int16 instance_version = -1);
|
void SetEXPModifier(uint32 character_id, uint32 zone_id, double exp_modifier, int16 instance_version = -1);
|
||||||
|
|
||||||
/* Character Inventory */
|
/* Character Inventory */
|
||||||
bool NoRentExpired(const char* name);
|
bool NoRentExpired(const std::string& name);
|
||||||
bool SaveCharacterInvSnapshot(uint32 character_id);
|
bool SaveCharacterInvSnapshot(uint32 character_id);
|
||||||
int CountCharacterInvSnapshots(uint32 character_id);
|
int CountCharacterInvSnapshots(uint32 character_id);
|
||||||
void ClearCharacterInvSnapshots(uint32 character_id, bool from_now = false);
|
void ClearCharacterInvSnapshots(uint32 character_id, bool from_now = false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user