@@ -452,7 +452,7 @@ public int finishLogin() {
452
452
loggedIn = false ;
453
453
return 7 ;
454
454
}
455
- updateLoginState (MapleClient .LOGIN_LOGGEDIN , getSessionIPAddress () == "/127.0.0.1" ? null : getSessionIPAddress ());
455
+ updateLoginState (MapleClient .LOGIN_LOGGEDIN , /* getSessionIPAddress() == "/127.0.0.1" ? null :*/ getSessionIPAddress ());
456
456
} finally {
457
457
login_mutex .unlock ();
458
458
}
@@ -502,10 +502,9 @@ public int fblogin(String login, String pwd, boolean ipMacBanned) {
502
502
boolean updatePasswordHashtosha1 = false ;
503
503
504
504
// Check if the passwords are correct here. :B
505
-
506
- // if (password_otp.equals(pwd)) { // Check if a
507
- // password upgrade is needed. loginok = 0;
508
- if ((LoginCryptoLegacy .isLegacyPassword (passhash )) && (LoginCryptoLegacy .checkPassword (pwd , passhash ))) {
505
+ // if (password_otp.equals(pwd)) { // Check if a
506
+ // password upgrade is needed. loginok = 0;
507
+ if ((LoginCryptoLegacy .isLegacyPassword (passhash )) && (LoginCryptoLegacy .checkPassword (pwd , passhash ))) {
509
508
loginok = 0 ;
510
509
updatePasswordHash = true ;
511
510
} else if ((salt == null ) && (LoginCrypto .checkSha1Hash (passhash , pwd ))) {
@@ -538,7 +537,7 @@ public int fblogin(String login, String pwd, boolean ipMacBanned) {
538
537
}
539
538
return loginok ;
540
539
}
541
-
540
+
542
541
public int login (String login , String pwd , boolean ipMacBanned ) {
543
542
int loginok = 5 ;
544
543
try {
@@ -575,7 +574,7 @@ public int login(String login, String pwd, boolean ipMacBanned) {
575
574
//如果卡号了,这个if会导致账号登陆不进去,为了解决卡号问题,把这里设置成永远false
576
575
//!ServerConfig.防卡号=true来控制强制登陆,为了让卡号了也能进游戏
577
576
//if (!ServerConstants.防卡号 && getLoginState() > MapleClient.LOGIN_NOTLOGGEDIN) { // already loggedin
578
- if (loginstate > MapleClient .LOGIN_NOTLOGGEDIN ) { // already loggedin
577
+ if (loginstate > MapleClient .LOGIN_NOTLOGGEDIN ) { // already loggedin
579
578
loggedIn = false ;
580
579
loginok = 7 ;
581
580
} else {
@@ -999,13 +998,33 @@ public final void disconnect(final boolean RemoveInChannelServer, final boolean
999
998
}
1000
999
}
1001
1000
}
1002
- if (!serverTransition && isLoggedIn ()) {
1001
+ if (!serverTransition && isLoggedIn () && getAccID () > 0 ) {
1003
1002
updateLoginState (MapleClient .LOGIN_NOTLOGGEDIN , getSessionIPAddress ());
1004
1003
}
1005
1004
}
1006
1005
1007
1006
public final String getSessionIPAddress () {
1008
- return session .getRemoteAddress ().toString ().split (":" )[0 ];
1007
+ if (session != null && session .getRemoteAddress () != null ) {
1008
+ return session .getRemoteAddress ().toString ().split (":" )[0 ];
1009
+ }
1010
+ return getLastIPAddress ();
1011
+ }
1012
+
1013
+ public final String getLastIPAddress () {
1014
+ String sessionIP = null ;
1015
+ try {
1016
+ final PreparedStatement ps = DatabaseConnection .getConnection ().prepareStatement ("SELECT SessionIP FROM accounts WHERE id = ?" );
1017
+ ps .setInt (1 , this .accId );
1018
+ final ResultSet rs = ps .executeQuery ();
1019
+ if (rs .next ()) {
1020
+ sessionIP = rs .getString ("SessionIP" );
1021
+ }
1022
+ rs .close ();
1023
+ ps .close ();
1024
+ } catch (final SQLException e ) {
1025
+ System .err .println ("Failed in getLastIPAddress for client." );
1026
+ }
1027
+ return sessionIP == null ? "" : sessionIP ;
1009
1028
}
1010
1029
1011
1030
public final boolean CheckIPAddress () {
0 commit comments