Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

H5 LS y Freya GS misma DB

Iniciado por Swarlog, Ago 16, 2022, 02:33 AM

Tema anterior - Siguiente tema

Swarlog

### Eclipse Workspace Patch 1.0
#P L2J_Server
Index: java/com/l2jserver/gameserver/LoginServerThread.java
===================================================================
--- java/com/l2jserver/gameserver/LoginServerThread.java (revision 4679)
+++ java/com/l2jserver/gameserver/LoginServerThread.java (working copy)
@@ -26,6 +26,11 @@
 import java.security.interfaces.RSAPublicKey;
 import java.security.spec.RSAKeyGenParameterSpec;
 import java.security.spec.RSAPublicKeySpec;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -37,6 +42,7 @@
 import javolution.util.FastMap;
 
 import com.l2jserver.Config;
+import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.L2GameClient;
@@ -49,12 +55,14 @@
 import com.l2jserver.gameserver.network.gameserverpackets.PlayerInGame;
 import com.l2jserver.gameserver.network.gameserverpackets.PlayerLogout;
 import com.l2jserver.gameserver.network.gameserverpackets.PlayerTracert;
+import com.l2jserver.gameserver.network.gameserverpackets.ReplyCharacters;
 import com.l2jserver.gameserver.network.gameserverpackets.ServerStatus;
 import com.l2jserver.gameserver.network.loginserverpackets.AuthResponse;
 import com.l2jserver.gameserver.network.loginserverpackets.InitLS;
 import com.l2jserver.gameserver.network.loginserverpackets.KickPlayer;
 import com.l2jserver.gameserver.network.loginserverpackets.LoginServerFail;
 import com.l2jserver.gameserver.network.loginserverpackets.PlayerAuthResponse;
+import com.l2jserver.gameserver.network.loginserverpackets.RequestCharacters;
 import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
 import com.l2jserver.gameserver.network.serverpackets.LoginFail;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
@@ -201,11 +209,13 @@
  InitLS init = new InitLS(decrypt);
  if (Config.DEBUG)
  _log.info("Init received");
- if (init.getRevision() != REVISION)
+ int loginServerRevision;
+ if ((loginServerRevision = init.getRevision()) != REVISION)
  {
  //TODO: revision mismatch
- _log.warning("/!\\ Revision mismatch between LS and GS /!\\");
- break;
+ _log.warning(String.format("<!> Revision mismatch between LS(0x%04X) and GS(0x%04X) <!>", loginServerRevision, REVISION));
+ if (loginServerRevision != 0x0105 && loginServerRevision != 0x0106) //if High Five then pass
+ break;
  }
  try
  {
@@ -334,6 +344,10 @@
  KickPlayer kp = new KickPlayer(decrypt);
  doKickPlayer(kp.getAccount());
  break;
+ case 0x05:
+ RequestCharacters rc = new RequestCharacters(decrypt);
+ getCharsOnServer(rc.getAccount());
+ break;
  }
  }
  }
@@ -342,6 +356,14 @@
  if (Config.DEBUG)
  _log.log(Level.WARNING, "", e);
  }
+ catch (java.net.ConnectException e)
+ {
+ _log.log(Level.WARNING, "Cannot connect LoginServer.");
+ }
+ catch (java.net.SocketException e)
+ {
+ _log.warning("LoginServer not avaible, trying to reconnect...");
+ }
  catch (IOException e)
  {
  _log.log(Level.WARNING, "Disconnected from Login, Trying to reconnect: " + e.getMessage(), e);
@@ -482,6 +504,48 @@
  }
  }
 
+ private void getCharsOnServer(String account)
+ {
+ Connection con = null;
+ int chars = 0;
+ List<Long> charToDel = new ArrayList<Long>();
+ try
+ {
+ con = L2DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = con.prepareStatement("SELECT deletetime FROM characters WHERE account_name=?");
+ statement.setString(1, account);
+ ResultSet rset = statement.executeQuery();
+ while (rset.next())
+ {
+ chars++;
+ long delTime = rset.getLong("deletetime");
+ if (delTime != 0)
+ charToDel.add(delTime);
+ }
+ rset.close();
+ statement.close();
+ }
+ catch (SQLException e)
+ {
+ _log.log(Level.WARNING, "Exception: getCharsOnServer: " + e.getMessage(), e);
+ }
+ finally
+ {
+ L2DatabaseFactory.close(con);
+ }
+
+ ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
+ try
+ {
+ sendPacket(rec);
+ }
+ catch (IOException e)
+ {
+ if (Config.DEBUG)
+ _log.log(Level.WARNING, "", e);
+ }
+
+ }
 
 
  /**
Index: java/com/l2jserver/gameserver/network/gameserverpackets/ReplyCharacters.java
===================================================================
--- java/com/l2jserver/gameserver/network/gameserverpackets/ReplyCharacters.java (revision 0)
+++ java/com/l2jserver/gameserver/network/gameserverpackets/ReplyCharacters.java (revision 0)
@@ -0,0 +1,47 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.network.gameserverpackets;
+
+import java.io.IOException;
+import java.util.List;
+
+import com.l2jserver.util.network.BaseSendablePacket;
+
+/**
+ * @author mrTJO
+ * Thanks to mochitto
+ */
+public class ReplyCharacters extends BaseSendablePacket
+{
+
+ public ReplyCharacters(String account, int chars, List<Long> timeToDel)
+ {
+ writeC(0x08);
+ writeS(account);
+ writeC(chars);
+ writeC(timeToDel.size());
+ for (long time : timeToDel)
+ {
+ writeQ(time);
+ }
+ }
+
+ @Override
+ public byte[] getContent() throws IOException
+ {
+ return getBytes();
+ }
+
+}
Index: java/com/l2jserver/gameserver/network/loginserverpackets/RequestCharacters.java
===================================================================
--- java/com/l2jserver/gameserver/network/loginserverpackets/RequestCharacters.java (revision 0)
+++ java/com/l2jserver/gameserver/network/loginserverpackets/RequestCharacters.java (revision 0)
@@ -0,0 +1,40 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.network.loginserverpackets;
+
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * @author mrTJO
+ * Thanks to mochitto
+ */
+public class RequestCharacters extends BaseRecievePacket
+{
+ private String _account;
+
+ public RequestCharacters(byte[] decrypt)
+ {
+ super(decrypt);
+ _account = readS();
+ }
+
+ /**
+ * @return Return account name
+ */
+ public String getAccount()
+ {
+ return _account;
+ }
+}

By tukune, thx ^^!