Clean up Client - visibleWorlds & canRequestCharlist
canRequestCharlist is a relic from the past when "View all char" functionality was hacked together with wrong packets. visibleWorlds I'm less sure about. I suppose it's useful if you add world (via command) while someone is still on the login screen. But the functionality of adding/removing worlds live is a recipe for disaster and will eventually (likely) be removed.
This commit is contained in:
@@ -1497,11 +1497,8 @@ public class Server {
|
||||
}
|
||||
}
|
||||
|
||||
public SortedMap<Integer, List<Character>> loadAccountCharlist(int accountId, int visibleWorlds) {
|
||||
public SortedMap<Integer, List<Character>> loadAccountCharlist(int accountId) {
|
||||
List<World> worlds = this.getWorlds();
|
||||
if (worlds.size() > visibleWorlds) {
|
||||
worlds = worlds.subList(0, visibleWorlds);
|
||||
}
|
||||
|
||||
SortedMap<Integer, List<Character>> worldChrs = new TreeMap<>();
|
||||
int chrTotal = 0;
|
||||
|
||||
@@ -29,21 +29,16 @@ import net.server.Server;
|
||||
import net.server.world.World;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class ServerlistRequestHandler extends AbstractPacketHandler {
|
||||
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
Server server = Server.getInstance();
|
||||
List<World> worlds = server.getWorlds();
|
||||
c.requestedServerlist(worlds.size());
|
||||
|
||||
for (World world : worlds) {
|
||||
for (World world : server.getWorlds()) {
|
||||
c.sendPacket(PacketCreator.getServerList(world.getId(), GameConstants.WORLD_NAMES[world.getId()], world.getFlag(), world.getEventMessage(), world.getChannels()));
|
||||
}
|
||||
c.sendPacket(PacketCreator.getEndOfServerList());
|
||||
c.sendPacket(PacketCreator.selectWorld(0));//too lazy to make a check lol
|
||||
c.sendPacket(PacketCreator.sendRecommended(server.worldRecommendedList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +37,7 @@ public final class ViewAllCharHandler extends AbstractPacketHandler {
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
try {
|
||||
if (!c.canRequestCharlist()) { // client breaks if the charlist request pops too soon
|
||||
c.sendPacket(PacketCreator.showAllCharacter(0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
SortedMap<Integer, List<Character>> worldChrs = Server.getInstance().loadAccountCharlist(c.getAccID(), c.getVisibleWorlds());
|
||||
SortedMap<Integer, List<Character>> worldChrs = Server.getInstance().loadAccountCharlist(c.getAccID());
|
||||
worldChrs = limitTotalChrs(worldChrs, CHARACTER_LIMIT);
|
||||
|
||||
padChrsIfNeeded(worldChrs);
|
||||
|
||||
Reference in New Issue
Block a user