Actually perform name changes & world transfers on startup
No changes were being committed
This commit is contained in:
@@ -1575,8 +1575,10 @@ public class Server {
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM namechanges WHERE completionTime IS NULL");
|
||||
ResultSet rs = ps.executeQuery()) {
|
||||
List<Pair<String, String>> changedNames = new LinkedList<>(); //logging only
|
||||
while (rs.next()) {
|
||||
|
||||
con.setAutoCommit(false);
|
||||
try {
|
||||
while (rs.next()) {
|
||||
int nameChangeId = rs.getInt("id");
|
||||
int characterId = rs.getInt("characterId");
|
||||
String oldName = rs.getString("old");
|
||||
@@ -1585,8 +1587,11 @@ public class Server {
|
||||
if (!success) {
|
||||
con.rollback(); //discard changes
|
||||
} else {
|
||||
con.commit();
|
||||
changedNames.add(new Pair<>(oldName, newName));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
con.setAutoCommit(true);
|
||||
}
|
||||
//log
|
||||
@@ -1625,8 +1630,10 @@ public class Server {
|
||||
}
|
||||
rs.beforeFirst();
|
||||
List<Pair<Integer, Pair<Integer, Integer>>> worldTransfers = new LinkedList<>(); //logging only <charid, <oldWorld, newWorld>>
|
||||
while (rs.next()) {
|
||||
|
||||
con.setAutoCommit(false);
|
||||
try {
|
||||
while (rs.next()) {
|
||||
int nameChangeId = rs.getInt("id");
|
||||
if (removedTransfers.contains(nameChangeId)) {
|
||||
continue;
|
||||
@@ -1638,10 +1645,14 @@ public class Server {
|
||||
if (!success) {
|
||||
con.rollback();
|
||||
} else {
|
||||
con.commit();
|
||||
worldTransfers.add(new Pair<>(characterId, new Pair<>(oldWorld, newWorld)));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
con.setAutoCommit(true);
|
||||
}
|
||||
|
||||
//log
|
||||
for (Pair<Integer, Pair<Integer, Integer>> worldTransferPair : worldTransfers) {
|
||||
int charId = worldTransferPair.getLeft();
|
||||
|
||||
Reference in New Issue
Block a user