aboutsummaryrefslogtreecommitdiff
path: root/src/connections.cc
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-07-11 12:30:22 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-07-11 12:30:22 -0300
commitac41dc912dbdee28a01a4db0404bdb363d5530dc (patch)
tree30b026b1cfa17fa1e6b9650184ae20503f3d7f5f /src/connections.cc
parent3ab6d1d312e2b1ecbd858be56bd7a5d6bc451a85 (diff)
downloadquerymanager-ac41dc912dbdee28a01a4db0404bdb363d5530dc.tar.gz
querymanager-ac41dc912dbdee28a01a4db0404bdb363d5530dc.zip
add `TransactionScope`
Diffstat (limited to 'src/connections.cc')
-rw-r--r--src/connections.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/connections.cc b/src/connections.cc
index b2b3daf..cfb0a01 100644
--- a/src/connections.cc
+++ b/src/connections.cc
@@ -623,9 +623,11 @@ void ProcessInsertHousesQuery(TConnection *Connection, TReadBuffer *Buffer){
return;
}
- // TODO(fusion): Have some TransactionGuard type that will either commit or
- // rollback a transaction when we leave its scope, based on whether some
- // `Commit` function was called.
+ TransactionScope Tx("UpdateHouses");
+ if(!Tx.Begin()){
+ SendQueryStatusFailed(Connection);
+ return;
+ }
if(!DeleteHouses(Connection->WorldID)){
SendQueryStatusFailed(Connection);
@@ -654,6 +656,11 @@ void ProcessInsertHousesQuery(TConnection *Connection, TReadBuffer *Buffer){
}
}
+ if(!Tx.Commit()){
+ SendQueryStatusFailed(Connection);
+ return;
+ }
+
SendQueryStatusOk(Connection);
}
@@ -680,9 +687,12 @@ void ProcessCreatePlayerlistQuery(TConnection *Connection, TReadBuffer *Buffer){
return;
}
- // TODO(fusion): Have some TransactionGuard type that will either commit or
- // rollback a transaction when we leave its scope, based on whether some
- // `Commit` function was called.
+
+ TransactionScope Tx("OnlineList");
+ if(!Tx.Begin()){
+ SendQueryStatusFailed(Connection);
+ return;
+ }
if(!DeleteOnlineCharacters(Connection->WorldID)){
SendQueryStatusFailed(Connection);
@@ -710,6 +720,11 @@ void ProcessCreatePlayerlistQuery(TConnection *Connection, TReadBuffer *Buffer){
}
}
+ if(!Tx.Commit()){
+ SendQueryStatusFailed(Connection);
+ return;
+ }
+
TWriteBuffer WriteBuffer = PrepareResponse(Connection, QUERY_STATUS_OK);
WriteBuffer.WriteFlag(NewRecord);
SendResponse(Connection, &WriteBuffer);