Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source.Engine/ModelLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
28 changes: 26 additions & 2 deletions Source.Engine/Server/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -346,7 +351,26 @@ public int PrecacheDecal(ReadOnlySpan<char> 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<PrecacheUserData> existing = DecalPrecacheTable.GetStringUserData(idx).AsSpan().Cast<byte, PrecacheUserData>();

if (existing.IsEmpty)
p.Flags = flags;
else {
p = existing[0];
p.Flags |= flags;
}

DecalPrecacheTable.SetStringUserData(idx, Unsafe.SizeOf<PrecacheUserData>(), 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<char> name) {
if (DecalPrecacheTable == null)
Expand Down Expand Up @@ -712,7 +736,7 @@ internal bool SpawnServer(ReadOnlySpan<char> mapName, ReadOnlySpan<char> mapFile
ev.SetString("game", Common.Gamedir);
ev.SetString("mapname", GetMapName());
ev.SetInt("maxplayers", GetMaxClients());
ev.SetInt("password", 0); // TODO
ev.SetInt("password", 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why I had this comment in the first place..

#if WIN32
ev.SetString("os", "WIN32");
#elif LINUX
Expand Down
Loading