mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-05-06 22:51:13 +00:00
fix: lastUpdatedTime updating (#1784)
* Create new LastSave() Method for Database and renew LastUpdatedTime in Save() * Attach UpdateLastSave() to sqlite and mysql * Fix compilation issues * Add updateTime functionality to UpdatePropertyDetails()
This commit is contained in:
parent
b31f9670d1
commit
4f97ecc073
@ -53,6 +53,9 @@ public:
|
|||||||
// Update the property details for the given property id.
|
// Update the property details for the given property id.
|
||||||
virtual void UpdatePropertyDetails(const IProperty::Info& info) = 0;
|
virtual void UpdatePropertyDetails(const IProperty::Info& info) = 0;
|
||||||
|
|
||||||
|
// Update the last updated time for the given property id.
|
||||||
|
virtual void UpdateLastSave(const IProperty::Info& info) = 0;
|
||||||
|
|
||||||
// Update the property performance cost for the given property id.
|
// Update the property performance cost for the given property id.
|
||||||
virtual void UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) = 0;
|
virtual void UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) = 0;
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ public:
|
|||||||
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
||||||
void UpdatePropertyModerationInfo(const IProperty::Info& info) override;
|
void UpdatePropertyModerationInfo(const IProperty::Info& info) override;
|
||||||
void UpdatePropertyDetails(const IProperty::Info& info) override;
|
void UpdatePropertyDetails(const IProperty::Info& info) override;
|
||||||
|
void UpdateLastSave(const IProperty::Info& info) override;
|
||||||
void InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) override;
|
void InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) override;
|
||||||
std::vector<IPropertyContents::Model> GetPropertyModels(const LWOOBJID& propertyId) override;
|
std::vector<IPropertyContents::Model> GetPropertyModels(const LWOOBJID& propertyId) override;
|
||||||
void RemoveUnreferencedUgcModels() override;
|
void RemoveUnreferencedUgcModels() override;
|
||||||
|
@ -173,6 +173,10 @@ void MySQLDatabase::UpdatePropertyDetails(const IProperty::Info& info) {
|
|||||||
ExecuteUpdate("UPDATE properties SET name = ?, description = ? WHERE id = ? LIMIT 1;", info.name, info.description, info.id);
|
ExecuteUpdate("UPDATE properties SET name = ?, description = ? WHERE id = ? LIMIT 1;", info.name, info.description, info.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MySQLDatabase::UpdateLastSave(const IProperty::Info& info) {
|
||||||
|
ExecuteUpdate("UPDATE properties SET last_updated = ? WHERE id = ?;", info.lastUpdatedTime, info.id);
|
||||||
|
}
|
||||||
|
|
||||||
void MySQLDatabase::UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) {
|
void MySQLDatabase::UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) {
|
||||||
ExecuteUpdate("UPDATE properties SET performance_cost = ? WHERE zone_id = ? AND clone_id = ? LIMIT 1;", performanceCost, zoneId.GetMapID(), zoneId.GetCloneID());
|
ExecuteUpdate("UPDATE properties SET performance_cost = ? WHERE zone_id = ? AND clone_id = ? LIMIT 1;", performanceCost, zoneId.GetMapID(), zoneId.GetCloneID());
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ public:
|
|||||||
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
||||||
void UpdatePropertyModerationInfo(const IProperty::Info& info) override;
|
void UpdatePropertyModerationInfo(const IProperty::Info& info) override;
|
||||||
void UpdatePropertyDetails(const IProperty::Info& info) override;
|
void UpdatePropertyDetails(const IProperty::Info& info) override;
|
||||||
|
void UpdateLastSave(const IProperty::Info& info) override;
|
||||||
void InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) override;
|
void InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) override;
|
||||||
std::vector<IPropertyContents::Model> GetPropertyModels(const LWOOBJID& propertyId) override;
|
std::vector<IPropertyContents::Model> GetPropertyModels(const LWOOBJID& propertyId) override;
|
||||||
void RemoveUnreferencedUgcModels() override;
|
void RemoveUnreferencedUgcModels() override;
|
||||||
|
@ -175,6 +175,10 @@ void SQLiteDatabase::UpdatePropertyDetails(const IProperty::Info& info) {
|
|||||||
ExecuteUpdate("UPDATE properties SET name = ?, description = ? WHERE id = ?;", info.name, info.description, info.id);
|
ExecuteUpdate("UPDATE properties SET name = ?, description = ? WHERE id = ?;", info.name, info.description, info.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SQLiteDatabase::UpdateLastSave(const IProperty::Info& info) {
|
||||||
|
ExecuteUpdate("UPDATE properties SET last_updated = ? WHERE id = ?;", info.lastUpdatedTime, info.id);
|
||||||
|
}
|
||||||
|
|
||||||
void SQLiteDatabase::UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) {
|
void SQLiteDatabase::UpdatePerformanceCost(const LWOZONEID& zoneId, const float performanceCost) {
|
||||||
ExecuteUpdate("UPDATE properties SET performance_cost = ? WHERE zone_id = ? AND clone_id = ?;", performanceCost, zoneId.GetMapID(), zoneId.GetCloneID());
|
ExecuteUpdate("UPDATE properties SET performance_cost = ? WHERE zone_id = ? AND clone_id = ?;", performanceCost, zoneId.GetMapID(), zoneId.GetCloneID());
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,10 @@ void TestSQLDatabase::UpdatePropertyDetails(const IProperty::Info& info) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestSQLDatabase::UpdateLastSave(const IProperty::Info& info) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TestSQLDatabase::InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) {
|
void TestSQLDatabase::InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ class TestSQLDatabase : public GameDatabase {
|
|||||||
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
||||||
void UpdatePropertyModerationInfo(const IProperty::Info& info) override;
|
void UpdatePropertyModerationInfo(const IProperty::Info& info) override;
|
||||||
void UpdatePropertyDetails(const IProperty::Info& info) override;
|
void UpdatePropertyDetails(const IProperty::Info& info) override;
|
||||||
|
void UpdateLastSave(const IProperty::Info& info) override;
|
||||||
void InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) override;
|
void InsertNewProperty(const IProperty::Info& info, const uint32_t templateId, const LWOZONEID& zoneId) override;
|
||||||
std::vector<IPropertyContents::Model> GetPropertyModels(const LWOOBJID& propertyId) override;
|
std::vector<IPropertyContents::Model> GetPropertyModels(const LWOOBJID& propertyId) override;
|
||||||
void RemoveUnreferencedUgcModels() override;
|
void RemoveUnreferencedUgcModels() override;
|
||||||
|
@ -165,7 +165,9 @@ void PropertyManagementComponent::UpdatePropertyDetails(std::string name, std::s
|
|||||||
info.id = propertyId;
|
info.id = propertyId;
|
||||||
info.name = propertyName;
|
info.name = propertyName;
|
||||||
info.description = propertyDescription;
|
info.description = propertyDescription;
|
||||||
|
info.lastUpdatedTime = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
|
||||||
|
Database::Get()->UpdateLastSave(info);
|
||||||
Database::Get()->UpdatePropertyDetails(info);
|
Database::Get()->UpdatePropertyDetails(info);
|
||||||
|
|
||||||
OnQueryPropertyData(GetOwner(), UNASSIGNED_SYSTEM_ADDRESS);
|
OnQueryPropertyData(GetOwner(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
@ -688,6 +690,10 @@ void PropertyManagementComponent::Save() {
|
|||||||
|
|
||||||
Database::Get()->RemoveModel(model.id);
|
Database::Get()->RemoveModel(model.id);
|
||||||
}
|
}
|
||||||
|
IProperty::Info info;
|
||||||
|
info.id = propertyId;
|
||||||
|
info.lastUpdatedTime = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
Database::Get()->UpdateLastSave(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyManagementComponent::AddModel(LWOOBJID modelId, LWOOBJID spawnerId) {
|
void PropertyManagementComponent::AddModel(LWOOBJID modelId, LWOOBJID spawnerId) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user