mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Remove unused sound index that were used for non visible players
This commit is contained in:
parent
211ce09c0b
commit
bcea5af30f
2 changed files with 80 additions and 9 deletions
|
@ -274,6 +274,12 @@ typedef struct {
|
||||||
cdKeyState_e cdkeyState;
|
cdKeyState_e cdkeyState;
|
||||||
} challenge_t;
|
} challenge_t;
|
||||||
|
|
||||||
|
// Added in OPM
|
||||||
|
typedef struct {
|
||||||
|
qboolean inUse;
|
||||||
|
int deleteTime;
|
||||||
|
} nonpvs_sound_cache_t;
|
||||||
|
|
||||||
// this structure will be cleared only when the game dll changes
|
// this structure will be cleared only when the game dll changes
|
||||||
typedef struct {
|
typedef struct {
|
||||||
qboolean initialized; // sv_init has completed
|
qboolean initialized; // sv_init has completed
|
||||||
|
@ -309,6 +315,7 @@ typedef struct {
|
||||||
int tm_loopcount;
|
int tm_loopcount;
|
||||||
int tm_offset;
|
int tm_offset;
|
||||||
|
|
||||||
|
nonpvs_sound_cache_t nonpvs_sound_cache[MAX_SOUNDS]; // Added in OPM
|
||||||
#ifndef DEDICATED
|
#ifndef DEDICATED
|
||||||
soundsystemsavegame_t soundSystem;
|
soundsystemsavegame_t soundSystem;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -294,20 +294,27 @@ static int QDECL SV_QsortEntityNumbers( const void *a, const void *b ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
===============
|
||||||
|
SV_AddNonPVSSound
|
||||||
|
===============
|
||||||
|
*/
|
||||||
static void SV_AddNonPVSSound(client_t* client, gentity_t* ent) {
|
static void SV_AddNonPVSSound(client_t* client, gentity_t* ent) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ent->r.num_nonpvs_sounds; i++) {
|
for (i = 0; i < ent->r.num_nonpvs_sounds; i++) {
|
||||||
|
nonpvs_sound_t *npvs = &ent->r.nonpvs_sounds[i];
|
||||||
|
|
||||||
SV_ClientSound(
|
SV_ClientSound(
|
||||||
client,
|
client,
|
||||||
&ent->s.origin,
|
&ent->s.origin,
|
||||||
ENTITYNUM_NONE,
|
ENTITYNUM_NONE,
|
||||||
1,
|
1,
|
||||||
ent->r.nonpvs_sounds[i].index,
|
npvs->index,
|
||||||
ent->r.nonpvs_sounds[i].volume,
|
npvs->volume,
|
||||||
ent->r.nonpvs_sounds[i].minDist,
|
npvs->minDist,
|
||||||
ent->r.nonpvs_sounds[i].pitch,
|
npvs->pitch,
|
||||||
ent->r.nonpvs_sounds[i].maxDist,
|
npvs->maxDist,
|
||||||
qfalse
|
qfalse
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1189,6 +1196,57 @@ void SV_SendClientSnapshot( client_t *client ) {
|
||||||
SV_SendMessageToClient( &msg, client );
|
SV_SendMessageToClient( &msg, client );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=======================
|
||||||
|
SV_CacheNonPVSSound
|
||||||
|
=======================
|
||||||
|
*/
|
||||||
|
void SV_CacheNonPVSSound(void)
|
||||||
|
{
|
||||||
|
gentity_t* ent;
|
||||||
|
nonpvs_sound_t* npvs;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < sv.num_entities; i++) {
|
||||||
|
ent = SV_GentityNum(i);
|
||||||
|
|
||||||
|
for (j = 0; j < ent->r.num_nonpvs_sounds; j++) {
|
||||||
|
npvs = &ent->r.nonpvs_sounds[j];
|
||||||
|
if (npvs->index) {
|
||||||
|
svs.nonpvs_sound_cache[npvs->index].inUse = qtrue;
|
||||||
|
svs.nonpvs_sound_cache[npvs->index].deleteTime = svs.time + 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=======================
|
||||||
|
SV_CleanupNonPVSSound
|
||||||
|
=======================
|
||||||
|
*/
|
||||||
|
void SV_CleanupNonPVSSound(void)
|
||||||
|
{
|
||||||
|
nonpvs_sound_cache_t* cache;
|
||||||
|
int i, j, k, l;
|
||||||
|
|
||||||
|
for (i = 1; i < MAX_SOUNDS; i++) {
|
||||||
|
cache = &svs.nonpvs_sound_cache[i];
|
||||||
|
|
||||||
|
if (!sv.configstrings[i]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cache->inUse) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (svs.time >= cache->deleteTime) {
|
||||||
|
SV_SetConfigstring(CS_SOUNDS + i, NULL);
|
||||||
|
cache->inUse = qfalse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=======================
|
=======================
|
||||||
|
@ -1197,9 +1255,12 @@ SV_SendClientMessages
|
||||||
*/
|
*/
|
||||||
void SV_SendClientMessages(void)
|
void SV_SendClientMessages(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i, j;
|
||||||
int rate;
|
int rate;
|
||||||
client_t *c;
|
client_t *c;
|
||||||
|
gentity_t *ent;
|
||||||
|
|
||||||
|
SV_CacheNonPVSSound();
|
||||||
|
|
||||||
// send a message to each connected client
|
// send a message to each connected client
|
||||||
for(i=0; i < sv_maxclients->integer; i++)
|
for(i=0; i < sv_maxclients->integer; i++)
|
||||||
|
@ -1245,9 +1306,12 @@ void SV_SendClientMessages(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sv.num_entities; i++) {
|
for (i = 0; i < sv.num_entities; i++) {
|
||||||
gentity_t* ent = SV_GentityNum(i);
|
ent = SV_GentityNum(i);
|
||||||
ent->r.num_nonpvs_sounds = 0;
|
ent->r.num_nonpvs_sounds = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Free up sound indices
|
||||||
|
SV_CleanupNonPVSSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean SV_IsValidSnapshotClient(client_t* client) {
|
qboolean SV_IsValidSnapshotClient(client_t* client) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue