mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
Added a save and fixed a crash
If am item were to be added to properties_contents and an item with that Primary Key already existed, the world would crash. This addresses this.
This commit is contained in:
parent
cc9b6c05f6
commit
33b16a56e3
@ -296,6 +296,8 @@ void PropertyManagementComponent::OnFinishBuilding()
|
|||||||
SetPrivacyOption(originalPrivacyOption);
|
SetPrivacyOption(originalPrivacyOption);
|
||||||
|
|
||||||
UpdateApprovedStatus(false);
|
UpdateApprovedStatus(false);
|
||||||
|
|
||||||
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation)
|
void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation)
|
||||||
@ -706,9 +708,12 @@ void PropertyManagementComponent::Save()
|
|||||||
auto* remove = Database::CreatePreppedStmt("DELETE FROM properties_contents WHERE id = ?;");
|
auto* remove = Database::CreatePreppedStmt("DELETE FROM properties_contents WHERE id = ?;");
|
||||||
|
|
||||||
lookup->setUInt64(1, propertyId);
|
lookup->setUInt64(1, propertyId);
|
||||||
|
sql::ResultSet* lookupResult = nullptr;
|
||||||
auto* lookupResult = lookup->executeQuery();
|
try {
|
||||||
|
lookupResult = lookup->executeQuery();
|
||||||
|
} catch (sql::SQLException& ex) {
|
||||||
|
Game::logger->Log("PropertyManagementComponent", "lookup error %s\n", ex.what());
|
||||||
|
}
|
||||||
std::vector<LWOOBJID> present;
|
std::vector<LWOOBJID> present;
|
||||||
|
|
||||||
while (lookupResult->next())
|
while (lookupResult->next())
|
||||||
@ -751,8 +756,11 @@ void PropertyManagementComponent::Save()
|
|||||||
insertion->setDouble(9, rotation.y);
|
insertion->setDouble(9, rotation.y);
|
||||||
insertion->setDouble(10, rotation.z);
|
insertion->setDouble(10, rotation.z);
|
||||||
insertion->setDouble(11, rotation.w);
|
insertion->setDouble(11, rotation.w);
|
||||||
|
try {
|
||||||
insertion->execute();
|
insertion->execute();
|
||||||
|
} catch (sql::SQLException& ex) {
|
||||||
|
Game::logger->Log("PropertyManagementComponent", "Error inserting into properties_contents. Error %s\n", ex.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -765,8 +773,11 @@ void PropertyManagementComponent::Save()
|
|||||||
update->setDouble(7, rotation.w);
|
update->setDouble(7, rotation.w);
|
||||||
|
|
||||||
update->setInt64(8, id);
|
update->setInt64(8, id);
|
||||||
|
try {
|
||||||
update->executeUpdate();
|
update->executeUpdate();
|
||||||
|
} catch (sql::SQLException& ex) {
|
||||||
|
Game::logger->Log("PropertyManagementComponent", "Error updating properties_contents. Error: %s\n", ex.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,8 +789,11 @@ void PropertyManagementComponent::Save()
|
|||||||
}
|
}
|
||||||
|
|
||||||
remove->setInt64(1, id);
|
remove->setInt64(1, id);
|
||||||
|
try {
|
||||||
remove->execute();
|
remove->execute();
|
||||||
|
} catch (sql::SQLException& ex) {
|
||||||
|
Game::logger->Log("PropertyManagementComponent", "Error removing from properties_contents. Error %s\n", ex.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* removeUGC = Database::CreatePreppedStmt("DELETE FROM ugc WHERE id NOT IN (SELECT ugc_id FROM properties_contents);");
|
auto* removeUGC = Database::CreatePreppedStmt("DELETE FROM ugc WHERE id NOT IN (SELECT ugc_id FROM properties_contents);");
|
||||||
|
Loading…
Reference in New Issue
Block a user