SHARE
TWEET

Hotfix to SQL Account Creation - aCis 387

HseOwk Jan 14th, 2020 152 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: aCis_gameserver/java/net/sf/l2j/loginserver/data/sql/AccountTable.java
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>ISO-8859-1
  5. ===================================================================
  6. --- aCis_gameserver/java/net/sf/l2j/loginserver/data/sql/AccountTable.java  (revision b632a002ae382c051cb4fe11254f903d94dc5a2c)
  7. +++ aCis_gameserver/java/net/sf/l2j/loginserver/data/sql/AccountTable.java  (date 1579035091890)
  8. @@ -19,6 +19,7 @@
  9.     private static final CLogger LOGGER = new CLogger(AccountTable.class.getName());
  10.    
  11.     private static final String SELECT_ACCOUNTS = "SELECT login, password, access_level, last_server FROM accounts";
  12. +   private static final String SELECT_ACCOUNT = "SELECT login, password, access_level, last_server FROM accounts WHERE login=? LIMIT 1";
  13.     private static final String INSERT_ACCOUNT = "INSERT INTO accounts (login, password, last_active) VALUES (?, ?, ?)";
  14.     private static final String UPDATE_ACCOUNT_LAST_TIME = "UPDATE accounts SET last_active = ? WHERE login = ?";
  15.     private static final String UPDATE_ACCOUNT_LAST_SERVER = "UPDATE accounts SET last_server = ? WHERE login = ?";
  16. @@ -82,6 +83,27 @@
  17.        
  18.         return account;
  19.     }
  20. +
  21. +   public Account getAccountFromDB(String login)
  22. +   {
  23. +       try (Connection con = L2DatabaseFactory.getInstance().getConnection();
  24. +            PreparedStatement ps = con.prepareStatement(SELECT_ACCOUNT))
  25. +       {
  26. +           ps.setString(1, login);
  27. +           ResultSet rs = ps.executeQuery();
  28. +
  29. +           if (rs.next())
  30. +               _accounts.put(login, new Account(login, rs.getString("password"), rs.getInt("access_level"), rs.getInt("last_server")));
  31. +       }
  32. +       catch (Exception e)
  33. +       {
  34. +           LOGGER.error("Exception retrieving '" + login + "' account info.", e);
  35. +       }
  36. +
  37. +       LOGGER.info("Loaded account '{}' from database.", login);
  38. +
  39. +       return _accounts.get(login);
  40. +   }
  41.    
  42.     /**
  43.      * @param login : The {@link String} used as login.
  44. Index: aCis_gameserver/java/net/sf/l2j/loginserver/LoginController.java
  45. IDEA additional info:
  46. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  47. <+>ISO-8859-1
  48. ===================================================================
  49. --- aCis_gameserver/java/net/sf/l2j/loginserver/LoginController.java    (revision b632a002ae382c051cb4fe11254f903d94dc5a2c)
  50. +++ aCis_gameserver/java/net/sf/l2j/loginserver/LoginController.java    (date 1579034651209)
  51. @@ -137,6 +137,9 @@
  52.        
  53.         // Retrieve or create (if auto-create is on) an Account based on given login and password.
  54.         Account account = AccountTable.getInstance().getAccount(login);
  55. +
  56. +       if (account == null)
  57. +           account = AccountTable.getInstance().getAccountFromDB(login);
  58.        
  59.         if (account == null)
  60.         {
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top