Skip to content

Commit 9e82623

Browse files
committed
Load all replay frame cells into memory instead of only 8 (read more)
We ran into a fun bug with srcwr💾. If you used https://github.com/KawaiiClan/bhoptimer-savestate and then got a WR replay with the run: the replay would be FUCKED. Why: - srcwr💾 reinterprets the ArrayList memory using the blocksize. This means that it writes out 8 cells a frame when frames originate from ReadReplayFrames(). - sourcepawn version tries to read 10 cells from the ArrayList, only reads 8 into the buffer, then writes 10 cells (with two cells being zero) to the replay file. If we read 10 cells into memory, a 5h replay would be 14.4MB more in memory than before. That's fine. Fuck it. This was a bit annoying to track down.
1 parent 5ca44fe commit 9e82623

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

addons/sourcemod/scripting/include/shavit/replay-file.inc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,23 @@ stock bool LoadReplayCache(frame_cache_t cache, int style, int track, const char
120120
stock bool ReadReplayFrames(File file, replay_header_t header, frame_cache_t cache)
121121
{
122122
int total_cells = 6;
123-
int used_cells = 6;
124123
bool is_btimes = false;
125124

126125
if (header.iReplayVersion > 0x01)
127126
{
128127
total_cells = 8;
129-
used_cells = 8;
130128
}
131129

132-
// We have differing total_cells & used_cells because we want to save memory during playback since the latest two cells added (vel & mousexy) aren't needed and are only useful for replay file anticheat usage stuff....
133130
if (header.iReplayVersion >= 0x06)
134131
{
135132
total_cells = 10;
136-
used_cells = 8;
137133
}
138134

139135
any aReplayData[sizeof(frame_t)];
140136

141137
delete cache.aFrames;
142138
int iTotalSize = header.iFrameCount + header.iPreFrames + header.iPostFrames;
143-
cache.aFrames = new ArrayList(used_cells, iTotalSize);
139+
cache.aFrames = new ArrayList(total_cells, iTotalSize);
144140

145141
if (!header.sReplayFormat[0]) // old replay format. no header.
146142
{
@@ -177,7 +173,7 @@ stock bool ReadReplayFrames(File file, replay_header_t header, frame_cache_t cac
177173
{
178174
if(file.Read(aReplayData, total_cells, 4) >= 0)
179175
{
180-
cache.aFrames.SetArray(i, aReplayData, used_cells);
176+
cache.aFrames.SetArray(i, aReplayData);
181177

182178
if (is_btimes && (aReplayData[5] & IN_BULLRUSH))
183179
{

0 commit comments

Comments
 (0)