
Originally Posted by
chunkarama
That's the world name. Like when you /find it says 'NAME-1' e.g Bera-1.
I never tried it because i've been working on more than one, but my start of it was at the serverlist. Upon getServerList packet is a serverId. You can try changing that id to 4 (Windia) and see if it'd work or not. Considering you could back on TitanMS dayz, I bet you could here too.
Ahh ok, I'm familiar with how /find showed the world name and channel number from MoopleDev. I'm using BubblesDev, and multi-world is not supported yet. So, getServerList in MaplePacketCreator:
PHP Code:
/**
* Gets a packet detailing a server and its channels.
*
* [MENTION=1333357818]param[/MENTION] serverIndex The index of the server to create information about.
* [MENTION=1333357818]param[/MENTION] serverName The name of the server.
* [MENTION=1333357818]param[/MENTION] channelLoad Load of the channel - 1200 seems to be max.
* [MENTION=850422]return[/MENTION] The server info packet.
*/
public static MaplePacket getServerList(int serverId, String serverName, Map<Integer, Integer> channelLoad) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.SERVERLIST);
mplew.write(serverId);
mplew.writeMapleAsciiString(serverName);
mplew.write(ServerConstants.FLAG);
mplew.writeMapleAsciiString(ServerConstants.EVENT_MESSAGE);
mplew.write(0x64); // rate modifier, don't ask O.O!
mplew.write(0x0); // event xp * 2.6 O.O!
mplew.write(0x64); // rate modifier, don't ask O.O!
mplew.write(0x0); // drop rate * 2.6
mplew.write(0x0);
int lastChannel = 1;
Set<Integer> channels = channelLoad.keySet();
for (int i = 30; i > 0; i--) {
if (channels.contains(i)) {
lastChannel = i;
break;
}
}
mplew.write(lastChannel);
int load;
for (int i = 1; i <= lastChannel; i++) {
if (channels.contains(i)) {
load = channelLoad.get(i) * 1200 / ServerConstants.CHANNEL_LOAD;
} else {
load = ServerConstants.CHANNEL_LOAD; // full
}
mplew.writeMapleAsciiString(serverName + "-" + i);
mplew.writeInt(load);
mplew.write(1);
mplew.writeShort(i - 1);
}
mplew.writeShort(0);
return mplew.getPacket();
}
The full ServerlistRequestHandler:
PHP Code:
package net.login.handler;
import client.MapleClient;
import constants.ServerConstants;
import java.rmi.RemoteException;
import net.AbstractMaplePacketHandler;
import net.MaplePacket;
import net.SendPacketOpcode;
import net.login.LoginServer;
import tools.HexTool;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;
import tools.data.output.MaplePacketLittleEndianWriter;
public final class ServerlistRequestHandler extends AbstractMaplePacketHandler {
private static final String[] names = {"Scania", "Bera", "Broa", "Windia", "Khaini", "Bellocan", "Mardia", "Kradia", "Yellonde", "Demethos", "Elnido", "Kastia", "Judis", "Arkenia", "Plana", "Galicia", "Kalluna", "Stius", "Croa", "Zenith", "Medere"};
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
for (int i = 0; i < ServerConstants.NUM_WORLDS; i++) {//input world numbers here change 1 to number of worlds
try {
c.getSession().write(MaplePacketCreator.getServerList(i, names[i], LoginServer.getInstance().getWorldInterface().getChannelLoad(i)));
} catch (RemoteException e) {
c.getChannelServer().reconnectWorld();
}
}
c.getSession().write(MaplePacketCreator.getEndOfServerList());
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(6);
mplew.writeShort(SendPacketOpcode.ENABLE_RECOMMENDED);
mplew.writeInt(3);
c.getSession().write(mplew.getPacket());
c.getSession().write(sendRecommendedServers());
}
private static MaplePacket sendRecommendedServers() {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.SEND_RECOMMENDED);
mplew.write(HexTool.getByteArrayFromHexString("01 00 00 00 00")); // first byte is number, second byte is server
mplew.writeMapleAsciiString("The newest of the Maple Worlds, Galicia is best suited for players just starting out in MapleStory or those that want a fresh beginning.");
return mplew.getPacket();
}
}
The full ServerStatusRequestHandler:
PHP Code:
package net.login.handler;
import client.MapleClient;
import constants.ServerConstants;
import java.rmi.RemoteException;
import net.AbstractMaplePacketHandler;
import net.login.LoginServer;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;
public final class ServerStatusRequestHandler extends AbstractMaplePacketHandler {
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int worldIndex = slea.readShort(); // we dont support multiple worlds..
int status;
int num = 0;
try {
for (int load : LoginServer.getInstance().getWorldInterface().getChannelLoad(worldIndex).keySet()) {
num += load;
}
} catch (RemoteException re) {
System.out.println("Failed to get channel load.");
}
if (num >= ServerConstants.CHANNEL_LOAD) {
status = 2;
} else if (num >= ServerConstants.CHANNEL_LOAD * .8) { // More than 80 percent o___o
status = 1;
} else {
status = 0;
}
c.getSession().write(MaplePacketCreator.getServerStatus(status));
}
}
And the variables from ServerConstants:
PHP Code:
// Login Configuration
public static final int LOGIN_PORT = 8484;
public static final byte NUM_WORLDS = 1;
public static final byte FLAG = 3;
public static final int CHANNEL_NUMBER = 8;
public static final int CHANNEL_LOAD = 100;
public static final String EVENT_MESSAGE = "Welcome to DstroyerMS v83!";
public static final long RANKING_INTERVAL = 3600000;
public static final boolean REMOTE_DETECT_ENABLED = false;
I thought the ServerlistRequestHandler was assigning the serverID based on number of worlds, but I'll admit I'm a bit lost.