Skip to content

Commit

Permalink
server: enabled precaching sounds from matdef entries
Browse files Browse the repository at this point in the history
  • Loading branch information
SNMetamorph committed Oct 1, 2023
1 parent f67dc74 commit 3a7fada
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
14 changes: 14 additions & 0 deletions game_shared/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ matdef_t *COM_DefaultMatdef()
return com_defaultmat;
}

static void COM_PrecacheMatdefSounds(matdef_t *mat)
{
#ifndef CLIENT_DLL
for (size_t i = 0; mat->step_sounds[i] && i < MAX_MAT_SOUNDS; i++) {
PRECACHE_SOUND(mat->step_sounds[i]);
}
for (size_t i = 0; mat->impact_sounds[i] && i < MAX_MAT_SOUNDS; i++) {
PRECACHE_SOUND(mat->impact_sounds[i]);
}
#endif
}

void COM_InitMatdef()
{
ALERT( at_aiconsole, "loading materials.def\n" );
Expand Down Expand Up @@ -293,6 +305,8 @@ void COM_InitMatdef()
}
else ALERT( at_warning, "Unknown material token %s\n", token );
}

COM_PrecacheMatdefSounds(mat);
}
getout:
FREE_FILE( afile );
Expand Down
3 changes: 0 additions & 3 deletions server/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "game.h"
#include "cbase.h"
#include "client.h"
#include "sv_materials.h"

cvar_t displaysoundlist = {"displaysoundlist","0"};

Expand Down Expand Up @@ -946,8 +945,6 @@ void GameDLLInit( void )

WorldPhysic->InitPhysic(); // initialize physic world
LinkUserMessages(); // yes in the Xash3D we can register messages here
COM_InitMatdef();
SV_InitMaterials();
}

void GameDLLShutdown( void )
Expand Down
5 changes: 5 additions & 0 deletions server/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "teamplay_gamerules.h"
#include "physcallback.h"
#include "meshdesc_factory.h"
#include "sv_materials.h"

extern CGraph WorldGraph;
extern CSoundEnt *pSoundEnt;
Expand Down Expand Up @@ -696,6 +697,10 @@ void CWorld :: Precache( void )

ClientPrecache();

// initialize material system
COM_InitMatdef();
SV_InitMaterials();

// sounds used from C physics code
PRECACHE_SOUND("common/null.wav"); // clears sound channels
PRECACHE_MODEL("sprites/null.spr");
Expand Down

0 comments on commit 3a7fada

Please sign in to comment.