text = f;
while (COM_ParseToken(&text, false))
{
- strncpy(shadername, com_token, sizeof(shadername));
+ strlcpy (shadername, com_token, sizeof (shadername));
flags = 0;
sky[0] = 0;
if (COM_ParseToken(&text, false) && !strcasecmp(com_token, "{"))
hostcache[n].ping = 100000;
hostcache[n].querytime = realtime;
// build description strings for the things users care about
- strncpy(hostcache[n].line1, "?", sizeof(hostcache[n].line1));
- strncpy(hostcache[n].line2, ipstring, sizeof(hostcache[n].line2));
+ strlcpy (hostcache[n].line1, "?", sizeof (hostcache[n].line1));
+ strlcpy (hostcache[n].line2, ipstring, sizeof (hostcache[n].line2));
// if not in the slist menu we should print the server to console
if (m_state != m_slist)
Con_Printf("querying %s\n", ipstring);
switch (type)
{
case ev_string:
- strncpy(line, PR_GetString(val->string), sizeof(line));
+ strlcpy (line, PR_GetString (val->string), sizeof (line));
break;
case ev_entity:
//n = NoCrash_NUM_FOR_EDICT(PROG_TO_EDICT(val->edict));
break;
case ev_function:
f = pr_functions + val->function;
- strncpy(line, PR_GetString(f->s_name), sizeof(line));
+ strlcpy (line, PR_GetString (f->s_name), sizeof (line));
break;
case ev_field:
def = ED_FieldAtOfs ( val->_int );
if (strlen(name) > 256)
{
- strncpy(tempstring2, name, 256);
+ memcpy (tempstring2, name, 256);
tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
tempstring2[259] = 0;
name = tempstring2;
name = PR_ValueString(d->type, (eval_t *)v);
if (strlen(name) > 256)
{
- strncpy(tempstring2, name, 256);
+ memcpy(tempstring2, name, 256);
tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
tempstring2[259] = 0;
name = tempstring2;
}
if (strlen(name) > 256)
{
- strncpy(tempstring2, name, 256);
+ memcpy(tempstring2, name, 256);
tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
tempstring2[259] = 0;
name = tempstring2;
switch (type)
{
case ev_string:
- strncpy(line, PRVM_GetString(val->string), sizeof(line));
+ strlcpy (line, PRVM_GetString (val->string), sizeof (line));
break;
case ev_entity:
n = val->edict;
break;
case ev_function:
f = pr_functions + val->function;
- strncpy(line, PRVM_GetString(f->s_name), sizeof(line));
+ strlcpy (line, PRVM_GetString (f->s_name), sizeof (line));
break;
case ev_field:
def = PRVM_ED_FieldAtOfs ( val->_int );
if (strlen(name) > 256)
{
- strncpy(tempstring2, name, 256);
+ memcpy (tempstring2, name, 256);
tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
tempstring2[259] = 0;
name = tempstring2;
name = PRVM_ValueString(d->type, (prvm_eval_t *)v);
if (strlen(name) > 256)
{
- strncpy(tempstring2, name, 256);
+ memcpy (tempstring2, name, 256);
tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
tempstring2[259] = 0;
name = tempstring2;
}
if (strlen(name) > 256)
{
- strncpy(tempstring2, name, 256);
+ memcpy (tempstring2, name, 256);
tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
tempstring2[259] = 0;
name = tempstring2;
sfx = &known_sfx[num_sfx++];
memset(sfx, 0, sizeof(*sfx));
- strncpy(sfx->name, name, sizeof(sfx->name));
+ strlcpy (sfx->name, name, sizeof (sfx->name));
return sfx;
}
continue;
// don't override looped sounds
- if (ch->forceloop || (ch->sfx != NULL && ch->sfx->loopstart >= 0))
+ if ((ch->flags & CHANNELFLAG_FORCELOOP) != 0 ||
+ (ch->sfx != NULL && ch->sfx->loopstart >= 0))
continue;
if (ch->end - paintedtime < life_left)
}
target_chan->sfx = sfx;
+ target_chan->flags = CHANNELFLAG_NONE;
target_chan->pos = 0.0;
target_chan->end = paintedtime + sfx->total_length;
target_chan->lastptime = paintedtime;
ss = &channels[total_channels++];
memset(ss, 0, sizeof(*ss));
- ss->forceloop = true;
+ ss->flags = CHANNELFLAG_FORCELOOP;
ss->sfx = sfx;
VectorCopy (origin, ss->origin);
ss->master_vol = vol;
(ambient_sfx[ambient_channel]->flags & SFXFLAG_SILENTLYMISSING))
continue;
chan = &channels[ambient_channel];
- chan->forceloop = true;
+ chan->flags |= CHANNELFLAG_FORCELOOP;
chan->sfx = ambient_sfx[ambient_channel];
vol = ambient_level.value * ambientlevels[ambient_channel];
{
int loopstart;
- if (ch->forceloop)
+ if (ch->flags & CHANNELFLAG_FORCELOOP)
loopstart = 0;
else
loopstart = -1;
if (ltime >= ch->end)
{
// if at end of loop, restart
- if ((sfx->loopstart >= 0 || ch->forceloop) && !stop_paint)
+ if ((sfx->loopstart >= 0 || (ch->flags & CHANNELFLAG_FORCELOOP)) && !stop_paint)
{
ch->pos = bound(0, sfx->loopstart, (int)sfx->total_length - 1);
ch->end = ltime + sfx->total_length - ch->pos;
} snd_format_t;
// sfx_t flags
+#define SFXFLAG_NONE 0
#define SFXFLAG_SILENTLYMISSING (1 << 0) // if the sfx is missing and loaded with complain = false
#define SFXFLAG_USED (1 << 1)
int bufferlength; // used only by certain drivers
} dma_t;
+// channel_t flags
+#define CHANNELFLAG_NONE 0
+#define CHANNELFLAG_FORCELOOP (1 << 0) // force looping even if the sound is not looped
+
typedef struct
{
- sfx_t *sfx; // sfx number
- int forceloop; // force looping even if the sound is not looped
- int leftvol; // 0-255 volume
- int rightvol; // 0-255 volume
- int end; // end time in global paintsamples
- int lastptime; // last time this channel was painted
- int pos; // sample position in sfx
- int looping; // where to loop, -1 = no looping
- int entnum; // to allow overriding a specific sound
- int entchannel;
- vec3_t origin; // origin of sound effect
- vec_t dist_mult; // distance multiplier (attenuation/clipK)
- int master_vol; // 0-255 master volume
- void *fetcher_data; // Per-channel data for the sound fetching function
+ sfx_t *sfx; // sfx number
+ unsigned int flags; // cf CHANNELFLAG_* defines
+ int leftvol; // 0-255 volume
+ int rightvol; // 0-255 volume
+ int end; // end time in global paintsamples
+ int lastptime; // last time this channel was painted
+ int pos; // sample position in sfx
+ int looping; // where to loop, -1 = no looping
+ int entnum; // to allow overriding a specific sound
+ int entchannel;
+ vec3_t origin; // origin of sound effect
+ vec_t dist_mult; // distance multiplier (attenuation/clipK)
+ int master_vol; // 0-255 master volume
+ void *fetcher_data; // Per-channel data for the sound fetching function
} channel_t;
typedef const sfxbuffer_t* (*snd_fetcher_getsb_t) (channel_t* ch, unsigned int start, unsigned int nbsamples);
if (timestamps.integer)
snprintf(final, sizeof(final), "%s%s", Sys_TimeString(timeformat.string), msg);
else
- strncpy(final, msg, sizeof(final));
+ strlcpy (final, msg, sizeof (final));
// LordHavoc: make sure the string is terminated
final[MAXPRINTMSG-1] = 0;