Fixed double login bug, added gm permissions, added checks to gm commands, update your postgresql db

This commit is contained in:
Light2
2013-12-14 22:14:45 +01:00
parent 5fd06f87c1
commit 6daca0347c
11 changed files with 59 additions and 15 deletions
+17 -3
View File
@@ -133,6 +133,7 @@ public class LoginService implements INetworkDispatch{
client.setAccountId(id);
//client.setAccountEmail(email);
client.setSession(session);
client.setGM(checkForGmPermission(id));
core.addClient((Integer)session.getAttribute("connectionId"), client);
@@ -143,7 +144,7 @@ public class LoginService implements INetworkDispatch{
persistSession(client);
LoginEnumCluster servers = getLoginCluster();
LoginClusterStatus serverStatus = getLoginClusterStatus();
LoginClusterStatus serverStatus = getLoginClusterStatus(client);
EnumerateCharacterId characters = getEnumerateCharacterId(id);
LoginClientToken clientToken = new LoginClientToken(client.getSessionKey(), id, user);
@@ -205,6 +206,18 @@ public class LoginService implements INetworkDispatch{
}
public boolean checkForGmPermission(int id) {
PreparedStatement preparedStatement;
try {
preparedStatement = databaseConnection1.preparedStatement("SELECT * FROM characters WHERE \"accountId\"=" + id + "");
ResultSet resultSet = preparedStatement.executeQuery();
return resultSet.getBoolean("gmflag");
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
* Saves session data to DB so Zone Server can link sessions to accounts.
* @param client Client that needs a session save.
@@ -287,7 +300,7 @@ public class LoginService implements INetworkDispatch{
* Generates LoginClusterStatus packet.
* @return LoginClusterStatus packet.
*/
public LoginClusterStatus getLoginClusterStatus() {
public LoginClusterStatus getLoginClusterStatus(Client client) {
LoginClusterStatus clusterStatus = new LoginClusterStatus();
ResultSet resultSet;
try {
@@ -302,7 +315,8 @@ public class LoginService implements INetworkDispatch{
100,
resultSet.getInt("statusId"),
1,
core.getActiveZoneClients());
core.getActiveZoneClients(),
client);
} catch (SQLException e) {
e.printStackTrace();
}