MapleSolaxiaV2 Revision 1

Minor changes about how ranking moves are reflected in-game.
This commit is contained in:
ronancpl
2015-11-06 13:27:46 -02:00
parent 4cb24a5e3f
commit 7c9f9c9fde
4 changed files with 29 additions and 8 deletions

View File

@@ -27,6 +27,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import client.MapleJob;
import tools.DatabaseConnection;
import constants.ServerConstants;
/**
* @author Matze
@@ -35,11 +36,17 @@ import tools.DatabaseConnection;
public class RankingWorker implements Runnable {
private Connection con;
private long lastUpdate = System.currentTimeMillis();
public void run() {
try {
con = DatabaseConnection.getConnection();
con.setAutoCommit(false);
if(ServerConstants.USE_REFRESH_RANK_MOVE == true) {
resetMoveRank(true);
resetMoveRank(false);
}
updateRanking(null);
for (int i = 0; i < 3; i += 2) {
for (int j = 1; j < 6; j++) {
@@ -50,13 +57,22 @@ public class RankingWorker implements Runnable {
con.setAutoCommit(true);
lastUpdate = System.currentTimeMillis();
} catch (SQLException ex) {
ex.printStackTrace();
try {
con.rollback();
con.setAutoCommit(true);
} catch (SQLException ex2) {
ex2.printStackTrace();
}
}
}
private void resetMoveRank(boolean job) throws SQLException {
String query = "UPDATE characters SET " + (job == true ? "jobRankMove = 0" : "rankMove = 0");
PreparedStatement reset = con.prepareStatement(query);
ResultSet rs = reset.executeQuery();
}
private void updateRanking(MapleJob job) throws SQLException {
String sqlCharSelect = "SELECT c.id, " + (job != null ? "c.jobRank, c.jobRankMove" : "c.rank, c.rankMove") + ", a.lastlogin AS lastlogin, a.loggedin FROM characters AS c LEFT JOIN accounts AS a ON c.accountid = a.id WHERE c.gm = 0 ";