Core/Housing: stage 25 professionalize room removal persistence comments

This commit is contained in:
Gexo91
2026-09-12 16:25:20 +03:00
parent 34fb54526f
commit 101f67e18b
@@ -181,9 +181,9 @@ namespace Housing
if (loadResult != Result::Success) if (loadResult != Result::Success)
return loadResult; return loadResult;
// Stage 14 resolves every surviving side before opening the delete // Resolve every surviving side before opening the delete transaction. If a
// transaction. If a bidirectional edge or its verified visual pair is // bidirectional edge or its verified visual pair is malformed, fail closed and
// malformed, fail closed and leave the complete persisted graph untouched. // leave the complete persisted graph untouched.
RoomRemovalConnectionPlan connectionPlan; RoomRemovalConnectionPlan connectionPlan;
if (!sHousingRoomRemovalService.Prepare(player, state, connectionPlan)) if (!sHousingRoomRemovalService.Prepare(player, state, connectionPlan))
{ {
@@ -212,12 +212,12 @@ namespace Housing
houseGuid, persistedRoomGuid, SafetyMaxPlacedDecorPerHouse + 1), houseGuid, persistedRoomGuid, SafetyMaxPlacedDecorPerHouse + 1),
SafetyMaxPlacedDecorPerHouse, childEntityGuids); SafetyMaxPlacedDecorPerHouse, childEntityGuids);
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); CharacterDatabaseTransaction transaction = CharacterDatabase.BeginTransaction();
// Restore every surviving doorway wall and delete both directions of each // Restore every surviving doorway wall and delete both directions of each
// Room connection in this same transaction. No intermediate database state // Room connection in this same transaction. No intermediate database state
// can commit with a deleted Room and a neighbor still pointing at its GUID. // can commit with a deleted Room and a neighbor still pointing at its GUID.
if (!sHousingRoomRemovalService.AppendPersistence(trans, connectionPlan)) if (!sHousingRoomRemovalService.AppendPersistence(transaction, connectionPlan))
{ {
TC_LOG_ERROR("housing", "Room REMOVE failed to append safe connection cleanup for room {}", TC_LOG_ERROR("housing", "Room REMOVE failed to append safe connection cleanup for room {}",
state.RoomGuid.ToString()); state.RoomGuid.ToString());
@@ -226,21 +226,21 @@ namespace Housing
// Room removal must never destroy owned decor. Return every decor instance // Room removal must never destroy owned decor. Return every decor instance
// placed in this room to storage before removing the placement rows. // placed in this room to storage before removing the placement rows.
trans->PAppend( transaction->PAppend(
"UPDATE housing_decor_instance i INNER JOIN housing_placed_decor p ON p.DecorGuid = i.DecorGuid " "UPDATE housing_decor_instance i INNER JOIN housing_placed_decor p ON p.DecorGuid = i.DecorGuid "
"SET i.HouseGuid = '', i.PlacementStatus = 0 " "SET i.HouseGuid = '', i.PlacementStatus = 0 "
"WHERE p.HouseGuid = '{}' AND p.RoomGuid = '{}'", "WHERE p.HouseGuid = '{}' AND p.RoomGuid = '{}'",
houseGuid, persistedRoomGuid); houseGuid, persistedRoomGuid);
trans->PAppend( transaction->PAppend(
"DELETE FROM housing_placed_decor WHERE HouseGuid = '{}' AND RoomGuid = '{}'", "DELETE FROM housing_placed_decor WHERE HouseGuid = '{}' AND RoomGuid = '{}'",
houseGuid, persistedRoomGuid); houseGuid, persistedRoomGuid);
trans->PAppend( transaction->PAppend(
"DELETE FROM housing_room_component_entity WHERE HouseGuid = '{}' AND RoomGuid = '{}'", "DELETE FROM housing_room_component_entity WHERE HouseGuid = '{}' AND RoomGuid = '{}'",
houseGuid, persistedRoomGuid); houseGuid, persistedRoomGuid);
trans->PAppend( transaction->PAppend(
"DELETE FROM housing_room_entity WHERE HouseGuid = '{}' AND RoomGuid = '{}'", "DELETE FROM housing_room_entity WHERE HouseGuid = '{}' AND RoomGuid = '{}'",
houseGuid, persistedRoomGuid); houseGuid, persistedRoomGuid);
CharacterDatabase.DirectCommitTransaction(trans); CharacterDatabase.DirectCommitTransaction(transaction);
// Persistence is now authoritative. Synchronize surviving live Rooms before // Persistence is now authoritative. Synchronize surviving live Rooms before
// the packet handler despawns children/parent of the removed Room. This sends // the packet handler despawns children/parent of the removed Room. This sends