diff --git a/Source.Engine/ModelLoader.cs b/Source.Engine/ModelLoader.cs index f0e35b7b..2590a015 100644 --- a/Source.Engine/ModelLoader.cs +++ b/Source.Engine/ModelLoader.cs @@ -2324,6 +2324,10 @@ void UnloadModel(Model model) { // Let it free data or call destructors.. Map_UnloadModel(model); +#if GMOD_DLL + fileSystem.Games().Refresh(); +#endif + // Remove from file system fileSystem.RemoveSearchPath(model.StrName, "GAME"); diff --git a/Source.Engine/Server/GameServer.cs b/Source.Engine/Server/GameServer.cs index 05442e42..3d681fea 100644 --- a/Source.Engine/Server/GameServer.cs +++ b/Source.Engine/Server/GameServer.cs @@ -110,6 +110,11 @@ internal bool IsLevelMainMenuBackground() { public override void Clear() { host_state.SetWorldModel(null); + NumEdicts = 0; + MaxEdicts = 0; + FreeEdicts = 0; + Edicts = null; + for (ServerClass? cls = serverGameDLL.GetAllServerClasses(); cls != null; cls = cls.Next) cls.InstanceBaselineIndex = INetworkStringTable.INVALID_STRING_INDEX; @@ -346,7 +351,26 @@ public int PrecacheDecal(ReadOnlySpan name, Res flags) { int idx = DecalPrecacheTable.AddString(true, name); if (idx == INetworkStringTable.INVALID_STRING_INDEX) return -1; - throw new NotImplementedException(); + + // todo: MapReslistGenerator().OnResourcePrecached(name); + + PrecacheUserData p = new(); + Span existing = DecalPrecacheTable.GetStringUserData(idx).AsSpan().Cast(); + + if (existing.IsEmpty) + p.Flags = flags; + else { + p = existing[0]; + p.Flags |= flags; + } + + DecalPrecacheTable.SetStringUserData(idx, Unsafe.SizeOf(), MemoryMarshal.AsBytes(MemoryMarshal.CreateSpan(ref p, 1))); + + PrecacheItem slot = DecalPrecache[idx]; + slot ??= DecalPrecache[idx] = new PrecacheItem(); + slot.SetDecal(new(name)); + + return idx; } public int LookupDecalIndex(ReadOnlySpan name) { if (DecalPrecacheTable == null) @@ -712,7 +736,7 @@ internal bool SpawnServer(ReadOnlySpan mapName, ReadOnlySpan mapFile ev.SetString("game", Common.Gamedir); ev.SetString("mapname", GetMapName()); ev.SetInt("maxplayers", GetMaxClients()); - ev.SetInt("password", 0); // TODO + ev.SetInt("password", 0); #if WIN32 ev.SetString("os", "WIN32"); #elif LINUX