Files
AyeZeeBB f289666c2c Entity limit 4x, replay crash guard, -map launch option, memory tools; pause-menu fixes
Memory
- The entity and pending-update pages are four times the game's own size
  (524,288 slots), down from eight times. At eight, the game kept a
  3.5 GB block for them that was fully in RAM on custom maps; the largest
  map load seen needs about 150,000 slots. The render-instance pool and
  spatial buckets stay at eight times.
- The log has a "Memory:" line when the game's memory, the players in the
  session or the skaters built change: committed, in RAM, players, skaters
  built, player distance and map.
- Console: `perf memory` lists the game's memory by block size.
  `perf memory mark` remembers it, and the next `perf memory` says what
  was added since. `perf memory trace` also records who asked for each
  block until `perf memory stop`. `perf memory big` lists the largest
  blocks with how much of each is in RAM and a sample of what is in them.
  RESKATE_MEMORY_TRACE=<megabytes|all> starts the trace with the game.

Replay crash guard
- The game's replay recorder crashes when its stream has no room for the
  next chunk: it writes to the chunk it was not given (Skate.exe+0x48efa34,
  crash reports of 2026-10-10). The function now runs under a handler
  that, for that one fault alone, returns as if no chunk was ended, and
  says so in the log. Any other fault still goes to the crash reporter.
  The skip path has not been triggered in testing.

Launcher
- `-map <name>` (also --map, -map=<name>) loads that map as soon as the
  game is up, named as the console's `load` names one. With --no-gui and
  no other options the launch still uses the saved launcher settings.

Pause menu
- The Multiplayer and Mod Options pages step aside while the game's side
  menu, or a screen opened from it such as Settings, is over them. They
  drew over both before.
- A button still held when a page comes back is not a press on it: the
  Back that closed the side menu no longer dismissed the page as well.

Multiplayer cosmetics
- A player whose mods add or remove cosmetic slots (stickers, say) no
  longer has the whole outfit refused. Their items go to this game's slots
  by slot: a slot they lack stays empty, an item in a slot this game
  lacks is left out, and the log says how many of each.
2026-10-10 16:15:59 -05:00

70 lines
2.9 KiB
C++

#include "replay_guard.h"
#include "Engine/Core/Hooks/hooks.h"
#include "Engine/Core/Log/logging.h"
#include "Engine/Core/Platform/memory.h"
#include "Engine/Game/Build/addresses.h"
#include "Engine/Game/Build/20260929/replay_recorder.h"
#include <Windows.h>
#include <array>
#include <atomic>
namespace dingosdk::replay_guard {
namespace {
namespace rr = addr::replay_recorder;
// (Two arguments are read; the others are passed on as they came.)
using EndChunk = std::uint64_t (*)(void*, std::uint64_t, std::uint64_t, std::uint64_t);
EndChunk original{};
std::uintptr_t fault_at{};
std::atomic<bool> installed{};
std::atomic<std::uint64_t> skips{};
// Only the write to the chunk head the stream did not give: nothing else is this guard's.
int ours(const EXCEPTION_POINTERS* info) noexcept {
const auto& record = *info->ExceptionRecord;
return record.ExceptionCode == EXCEPTION_ACCESS_VIOLATION &&
reinterpret_cast<std::uintptr_t>(record.ExceptionAddress) == fault_at
? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
}
// Said the first time and then now and again: it can happen every few frames once it starts.
__declspec(noinline) void note_skip() noexcept {
const auto count = skips.fetch_add(1, std::memory_order_relaxed) + 1;
if (count != 1 && count % 1000) return;
try {
logging::log(logging::Level::warning, logging::Channel::runtime,
"Replay recording: the game had no room for its next chunk and would have crashed; the chunk was skipped "
"({} so far). Replays of this stretch may have gaps.", count);
} catch (...) {}
}
std::uint64_t guarded(void* recorder, std::uint64_t force, std::uint64_t third, std::uint64_t fourth) {
__try {
return original(recorder, force, third, fourth);
} __except (ours(GetExceptionInformation())) {
note_skip();
return 0; // no chunk was ended
}
}
} // namespace
bool install(std::uintptr_t base) noexcept {
if (installed.exchange(true)) return original != nullptr;
if (!base) return false;
std::array<unsigned char, 32> bytes{};
if (!memory::peek(base + rr::end_chunk.rva, bytes) || bytes != rr::end_chunk.bytes) {
logging::log(logging::Level::warning, logging::Channel::runtime,
"Replay guard: this build's replay recorder differs; it is left as it is.");
return false;
}
fault_at = base + rr::end_chunk_head_store;
const auto target = reinterpret_cast<void*>(base + rr::end_chunk.rva);
if (hook_prepare(target, reinterpret_cast<void*>(&guarded), reinterpret_cast<void**>(&original)) != HookOk ||
hook_enable(target) != HookOk) {
original = nullptr;
logging::log(logging::Level::warning, logging::Channel::runtime, "Replay guard: the replay recorder could not be hooked.");
return false;
}
return true;
}
std::uint64_t skipped() noexcept { return skips.load(std::memory_order_relaxed); }
} // namespace dingosdk::replay_guard