mirror of
https://git.muiegratis.online/suikoakari/Campofinale
synced 2025-12-12 09:34:34 +01:00
some fix
This commit is contained in:
@@ -265,6 +265,7 @@ namespace Campofinale.Game
|
||||
public bool alreadyLoaded = false;
|
||||
[BsonIgnore, JsonIgnore]
|
||||
public List<ulong> activeScripts = new();
|
||||
|
||||
public List<LevelScript> scripts = new();
|
||||
public int GetCollection(string id)
|
||||
{
|
||||
@@ -294,7 +295,7 @@ namespace Campofinale.Game
|
||||
public void Unload()
|
||||
{
|
||||
List<ulong> guids = new();
|
||||
foreach(Entity e in entities)
|
||||
foreach(Entity e in GetEntityExcludingChar().FindAll(e => e.spawned))
|
||||
{
|
||||
guids.Add(e.guid);
|
||||
}
|
||||
@@ -307,8 +308,6 @@ namespace Campofinale.Game
|
||||
}
|
||||
public void Load()
|
||||
{
|
||||
if (info().isSeamless && alreadyLoaded) return;
|
||||
//alreadyLoaded = true;
|
||||
Unload();
|
||||
LevelScene lv_scene = ResourceManager.GetLevelData(sceneNumId);
|
||||
|
||||
@@ -362,7 +361,7 @@ namespace Campofinale.Game
|
||||
lv_scene.levelData.npcs.ForEach(en =>
|
||||
{
|
||||
|
||||
if (en.npcGroupId.Contains("chr")) return;
|
||||
if (en.npcGroupId.Contains("chr") && sceneNumId == 98) return;
|
||||
EntityNpc entity = new(en.entityDataIdKey,ownerId,en.position,en.rotation, sceneNumId, en.levelLogicId)
|
||||
{
|
||||
belongLevelScriptId = en.belongLevelScriptId,
|
||||
@@ -373,11 +372,11 @@ namespace Campofinale.Game
|
||||
entity.defaultHide = en.defaultHide;
|
||||
entities.Add(entity);
|
||||
});
|
||||
|
||||
|
||||
UpdateShowEntities();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
UpdateShowEntities();
|
||||
}
|
||||
|
||||
public void SpawnEntity(Entity en,bool spawnedCheck=true)
|
||||
@@ -399,10 +398,12 @@ namespace Campofinale.Game
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void UpdateShowEntities()
|
||||
//Bug on scene 101: spawning entities in this way make the game break if you try to load another scene from scene 101
|
||||
public async void UpdateShowEntities()
|
||||
{
|
||||
|
||||
List<Entity> toSpawn = new();
|
||||
foreach(Entity e in GetEntityExcludingChar())
|
||||
foreach(Entity e in GetEntityExcludingChar().FindAll(e=>e.spawned==false))
|
||||
{
|
||||
if(e.spawned==false && (GetActiveScript(e.belongLevelScriptId) || e.belongLevelScriptId==0))
|
||||
{
|
||||
@@ -415,9 +416,17 @@ namespace Campofinale.Game
|
||||
}
|
||||
|
||||
}
|
||||
if(toSpawn.Count > 0)
|
||||
GetOwner().Send(new PacketScObjectEnterView(GetOwner(), toSpawn));
|
||||
|
||||
if (toSpawn.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < toSpawn.Count; i += 5)
|
||||
{
|
||||
int chunkSize = Math.Min(5, toSpawn.Count - i);
|
||||
var chunk = toSpawn.GetRange(i, chunkSize);
|
||||
|
||||
GetOwner().Send(new PacketScObjectEnterView(GetOwner(), chunk));
|
||||
}
|
||||
}
|
||||
|
||||
/* foreach(Entity en in GetEntityExcludingChar())
|
||||
{
|
||||
float minDis = 100;
|
||||
|
||||
@@ -47,17 +47,23 @@
|
||||
s_notifyReqGroup = handlers.ToImmutable();
|
||||
}
|
||||
|
||||
public static void Notify(Player session, CsMsgId cmdId, Network.Packet packet)
|
||||
public static async void Notify(Player session, CsMsgId cmdId, Network.Packet packet)
|
||||
{
|
||||
if (s_notifyReqGroup.TryGetValue(cmdId, out var handler))
|
||||
await Task.Run(() =>
|
||||
{
|
||||
handler.Item2.Invoke(session, ((int)cmdId), packet);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Server.csMessageToHide.Contains(cmdId) && Server.config.logOptions.packets)
|
||||
Logger.PrintWarn($"Can't find handler for {(Enum.GetName(typeof(CsMsgId), cmdId)).ToString().Pastel(Color.FromArgb(165, 229, 250))} ({(cmdId).ToString().Pastel(Color.FromArgb(165, 229, 250))})");
|
||||
}
|
||||
|
||||
if (s_notifyReqGroup.TryGetValue(cmdId, out var handler))
|
||||
{
|
||||
|
||||
handler.Item2.Invoke(session, ((int)cmdId), packet);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Server.csMessageToHide.Contains(cmdId) && Server.config.logOptions.packets)
|
||||
Logger.PrintWarn($"Can't find handler for {(Enum.GetName(typeof(CsMsgId), cmdId)).ToString().Pastel(Color.FromArgb(165, 229, 250))} ({(cmdId).ToString().Pastel(Color.FromArgb(165, 229, 250))})");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void AddReqGroupHandler(Type type)
|
||||
|
||||
@@ -18,11 +18,7 @@ namespace Campofinale.Packets.Cs
|
||||
session.sceneManager.LoadCurrentTeamEntities();
|
||||
session.sceneManager.LoadCurrent();
|
||||
session.LoadFinish = true;
|
||||
session.Send(ScMsgId.ScSceneClientIdInfo, new ScSceneClientIdInfo()
|
||||
{
|
||||
RoleIdx = (uint)session.roleId,
|
||||
LastMaxIdx = session.random.usedGuids.Max()
|
||||
});
|
||||
|
||||
if (session.curSceneNumId == 98)
|
||||
{
|
||||
session.Send(new PacketScSyncGameMode(session, "spaceship"));
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace Campofinale.Packets.Cs
|
||||
public static void Handle(Player session, CsMsgId cmdId, Packet packet)
|
||||
{
|
||||
CsSceneMoveStateSet req = packet.DecodeBody<CsSceneMoveStateSet>();
|
||||
|
||||
//req.
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,15 @@ namespace Campofinale.Packets.Cs
|
||||
if (session.curSceneNumId != req.SceneNumId)
|
||||
{
|
||||
session.EnterScene(req.SceneNumId, new Resource.ResourceManager.Vector3f(req.Position), new Resource.ResourceManager.Vector3f(req.Rotation));
|
||||
/* ScSceneTeleport t = new()
|
||||
{
|
||||
TeleportReason = req.TeleportReason,
|
||||
PassThroughData = req.PassThroughData,
|
||||
Position = req.Position,
|
||||
Rotation = req.Rotation,
|
||||
SceneNumId = req.SceneNumId,
|
||||
};
|
||||
session.Send(ScMsgId.ScSceneTeleport, t);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -81,18 +81,23 @@ namespace Campofinale.Packets.Sc
|
||||
};
|
||||
l.properties.ForEach(p =>
|
||||
{
|
||||
if(!sceneScript.properties.ContainsKey(p.key))
|
||||
sceneScript.properties.Add(p.key,p.ToScriptProperty());
|
||||
});
|
||||
|
||||
session.sceneManager.GetCurScene().scripts.Add(sceneScript);
|
||||
}
|
||||
script.State = sceneScript.state;
|
||||
int i = 0;
|
||||
foreach (var item in sceneScript.properties)
|
||||
{
|
||||
if(item.Value != null)
|
||||
{
|
||||
DynamicParameter p = item.Value.ToProto();
|
||||
if (p != null)
|
||||
script.Properties.Add(l.GetPropertyId(item.Key, script.Properties.Keys.ToList()), p);
|
||||
}
|
||||
|
||||
DynamicParameter p=item.Value.ToProto();
|
||||
if (p != null)
|
||||
script.Properties.Add(l.GetPropertyId(item.Key,script.Properties.Keys.ToList()), p);
|
||||
}
|
||||
sceneInfo.LevelScripts.Add(script);
|
||||
});
|
||||
|
||||
@@ -436,7 +436,7 @@ namespace Campofinale
|
||||
{
|
||||
Send(Packet.EncodePacket((int)id, mes, seq, totalPackCount, currentPackIndex));
|
||||
}
|
||||
public void Send(Packet packet)
|
||||
public async void Send(Packet packet)
|
||||
{
|
||||
byte[] datas = packet.set_body.ToByteArray();
|
||||
int maxChunkSize = 65535;
|
||||
@@ -463,11 +463,11 @@ namespace Campofinale
|
||||
Send(Packet.EncodePacket(packet.cmdId, data, seqNext, (uint)chunks.Count, (uint)i));
|
||||
}
|
||||
}
|
||||
public void Send(byte[] data)
|
||||
public async void Send(byte[] data)
|
||||
{
|
||||
try
|
||||
{
|
||||
socket.Send(data);
|
||||
await socket.SendAsync(data);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user