optimize npc group load & fix some NPE in suite

This commit is contained in:
Akka
2022-07-02 11:30:29 +08:00
committed by Melledy
parent bd40ecee2a
commit 9951bec6b7
6 changed files with 123 additions and 98 deletions

View File

@@ -1,6 +1,6 @@
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.entity.EntityNPC;
import emu.grasscutter.data.binout.SceneNpcBornEntry;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GroupSuiteNotifyOuterClass;
@@ -10,14 +10,18 @@ import java.util.List;
public class PacketGroupSuiteNotify extends BasePacket {
/**
* control which npc suite is loaded
* Real control which npc suite is loaded
* EntityNPC is useless
*/
public PacketGroupSuiteNotify(List<EntityNPC> list) {
public PacketGroupSuiteNotify(List<SceneNpcBornEntry> npcBornEntries) {
super(PacketOpcodes.GroupSuiteNotify);
var proto = GroupSuiteNotifyOuterClass.GroupSuiteNotify.newBuilder();
list.forEach(item -> proto.putGroupMap(item.getGroupId(), item.getSuiteId()));
npcBornEntries.forEach(x ->
x.getSuiteIdList().forEach(y ->
proto.putGroupMap(x.getGroupId(), y)
));
this.setData(proto);

View File

@@ -0,0 +1,20 @@
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GroupUnloadNotifyOuterClass;
import java.util.List;
public class PacketGroupUnloadNotify extends BasePacket {
public PacketGroupUnloadNotify(List<Integer> groupList) {
super(PacketOpcodes.GroupUnloadNotify);
var proto = GroupUnloadNotifyOuterClass.GroupUnloadNotify.newBuilder();
proto.addAllGroupList(groupList);
this.setData(proto);
}
}