Merge remote-tracking branch 'upstream/development' into dev-mail

This commit is contained in:
Benjamin Elsdon
2022-04-26 15:45:58 +08:00
16 changed files with 406 additions and 19 deletions

View File

@@ -43,6 +43,7 @@ public final class DispatchServer {
public String regionListBase64;
public HashMap<String, RegionData> regions;
private HttpServer server;
public DispatchServer() {
this.regions = new HashMap<String, RegionData>();
@@ -54,6 +55,10 @@ public final class DispatchServer {
this.initRegion();
}
public HttpServer getServer() {
return server;
}
public InetSocketAddress getAddress() {
return address;
}
@@ -200,7 +205,6 @@ public final class DispatchServer {
}
public void start() throws Exception {
HttpServer server;
if (Grasscutter.getConfig().getDispatchOptions().UseSSL) {
HttpsServer httpsServer = HttpsServer.create(getAddress(), 0);
SSLContext sslContext = SSLContext.getInstance("TLS");

View File

@@ -10,6 +10,7 @@ import emu.grasscutter.command.CommandMap;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.World;
import emu.grasscutter.game.dungeons.DungeonManager;
import emu.grasscutter.game.gacha.GachaManager;
import emu.grasscutter.game.managers.ChatManager;
@@ -26,6 +27,7 @@ public final class GameServer extends MihoyoKcpServer {
private final GameServerPacketHandler packetHandler;
private final Map<Integer, GenshinPlayer> players;
private final Set<World> worlds;
private final ChatManager chatManager;
private final InventoryManager inventoryManager;
@@ -50,6 +52,7 @@ public final class GameServer extends MihoyoKcpServer {
this.address = address;
this.packetHandler = new GameServerPacketHandler(PacketHandler.class);
this.players = new ConcurrentHashMap<>();
this.worlds = Collections.synchronizedSet(new HashSet<>());
this.chatManager = new ChatManager(this);
this.inventoryManager = new InventoryManager(this);
@@ -84,6 +87,10 @@ public final class GameServer extends MihoyoKcpServer {
return players;
}
public Set<World> getWorlds() {
return worlds;
}
public ChatManager getChatManager() {
return chatManager;
}
@@ -161,12 +168,32 @@ public final class GameServer extends MihoyoKcpServer {
}
public void onTick() throws Exception {
Iterator<World> it = this.getWorlds().iterator();
while (it.hasNext()) {
World world = it.next();
if (world.getPlayerCount() == 0) {
it.remove();
}
world.onTick();
}
for (GenshinPlayer player : this.getPlayers().values()) {
player.onTick();
}
OnGameServerTick.post(new GameServerTickEvent());
}
public void registerWorld(World world) {
this.getWorlds().add(world);
}
public void deregisterWorld(World world) {
// TODO Auto-generated method stub
}
@Override
public void onStartFinish() {

View File

@@ -1,5 +1,8 @@
package emu.grasscutter.server.packet.send;
import java.util.Collection;
import java.util.List;
import emu.grasscutter.game.entity.GenshinEntity;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
@@ -18,4 +21,15 @@ public class PacketSceneEntityDisappearNotify extends GenshinPacket {
this.setData(proto);
}
public PacketSceneEntityDisappearNotify(Collection<GenshinEntity> entities, VisionType disappearType) {
super(PacketOpcodes.SceneEntityDisappearNotify);
SceneEntityDisappearNotify.Builder proto = SceneEntityDisappearNotify.newBuilder()
.setDisappearType(disappearType);
entities.forEach(e -> proto.addEntityList(e.getId()));
this.setData(proto);
}
}