Add a fix to load the music from save

This commit implements code to get/set sample offset in an OpenAL channel and saves the music filename/offset into the file. This only works by using the experimental sound system, so it partially fixes #327
This commit is contained in:
smallmodel 2024-07-22 20:07:32 +02:00
parent 2198bdec21
commit 757b4849f8
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
9 changed files with 151 additions and 17 deletions

View file

@ -1955,6 +1955,7 @@ qboolean SV_ArchiveServerFile( qboolean loading, qboolean autosave )
time_t aclock;
Com_DPrintf( "SV_ArchiveServerFile(%s)\n", autosave ? "true" : "false" );
memset(&save, 0, sizeof(save));
name = Com_GetArchiveFileName( svs.gameName, "ssv" );
if( !loading )
@ -1995,6 +1996,17 @@ qboolean SV_ArchiveServerFile( qboolean loading, qboolean autosave )
strncpy( save.saveName, svs.gameName, sizeof( save.saveName ) );
save.mapTime = svs.time - svs.startTime;
name = S_GetMusicFilename();
if (name) {
Q_strncpyz(save.tm_filename, name, sizeof(save.tm_filename));
save.tm_offset = S_GetMusicOffset();
save.tm_loopcount = S_GetMusicLoopCount();
} else {
save.tm_filename[0] = 0;
save.tm_offset = 0;
save.tm_loopcount = 0;
}
FS_Write( &save, sizeof( savegamestruct_t ), f );
S_Save( f );
CM_WritePortalState( f );