Compare commits
2 Commits
65dccaf2db
...
030249f713
Author | SHA1 | Date |
---|---|---|
Marco Cawthorne | 030249f713 | |
Marco Cawthorne | f317282571 |
|
@ -976,28 +976,28 @@ static void CLQ2_ParseDelta (entity_state_t *from, entity_state_t *to, int numbe
|
|||
if (bits & Q2U_FRAME8)
|
||||
to->frame = MSG_ReadByte ();
|
||||
if (bits & Q2U_FRAME16)
|
||||
to->frame = MSG_ReadShort ();
|
||||
to->frame = MSG_ReadUInt16();
|
||||
|
||||
if ((bits & Q2U_SKIN8) && (bits & Q2U_SKIN16)) //used for laser colors
|
||||
to->skinnum = MSG_ReadLong();
|
||||
else if (bits & Q2U_SKIN8)
|
||||
to->skinnum = MSG_ReadByte();
|
||||
else if (bits & Q2U_SKIN16)
|
||||
to->skinnum = MSG_ReadShort();
|
||||
to->skinnum = MSG_ReadUInt16();
|
||||
|
||||
if ( (bits & (Q2U_EFFECTS8|Q2U_EFFECTS16)) == (Q2U_EFFECTS8|Q2U_EFFECTS16) )
|
||||
to->effects = MSG_ReadLong();
|
||||
else if (bits & Q2U_EFFECTS8)
|
||||
to->effects = MSG_ReadByte();
|
||||
else if (bits & Q2U_EFFECTS16)
|
||||
to->effects = MSG_ReadShort();
|
||||
to->effects = MSG_ReadUInt16();
|
||||
|
||||
if ( (bits & (Q2U_RENDERFX8|Q2U_RENDERFX16)) == (Q2U_RENDERFX8|Q2U_RENDERFX16) )
|
||||
to->u.q2.renderfx = MSG_ReadLong() & 0x0007ffff; //only the standard ones actually supported by vanilla q2.
|
||||
else if (bits & Q2U_RENDERFX8)
|
||||
to->u.q2.renderfx = MSG_ReadByte();
|
||||
else if (bits & Q2U_RENDERFX16)
|
||||
to->u.q2.renderfx = MSG_ReadShort();
|
||||
to->u.q2.renderfx = MSG_ReadUInt16();
|
||||
|
||||
if (bits & Q2U_ORIGIN1)
|
||||
to->origin[0] = MSG_ReadCoord ();
|
||||
|
@ -1031,7 +1031,7 @@ static void CLQ2_ParseDelta (entity_state_t *from, entity_state_t *to, int numbe
|
|||
if (bits & Q2U_SOUND)
|
||||
{
|
||||
if (bits & Q2UX_INDEX16)
|
||||
to->u.q2.sound = MSG_ReadShort();
|
||||
to->u.q2.sound = MSG_ReadUInt16();
|
||||
else
|
||||
to->u.q2.sound = MSG_ReadByte ();
|
||||
}
|
||||
|
|
|
@ -86,11 +86,10 @@ static float QDECL OV_Query(struct sfx_s *sfx, struct sfxcache_s *buf, char *nam
|
|||
if (!dec)
|
||||
return -1;
|
||||
|
||||
if (dec->timetotal < 0)
|
||||
{
|
||||
dec->pcmtotal = p_ov_pcm_total(&dec->vf, -1);
|
||||
dec->timetotal = p_ov_time_total(&dec->vf, -1);
|
||||
}
|
||||
// if (dec->pcmtotal == 0)
|
||||
// dec->pcmtotal = p_ov_pcm_total(&dec->vf, -1);
|
||||
// if (dec->timetotal < 0)
|
||||
// dec->timetotal = p_ov_time_total(&dec->vf, -1);
|
||||
|
||||
if (buf)
|
||||
{
|
||||
|
@ -199,9 +198,9 @@ static sfxcache_t *QDECL OV_DecodeSome(struct sfx_s *sfx, struct sfxcache_s *buf
|
|||
if (dec->failed || start+length <= dec->decodedbytestart + dec->decodedbytecount)
|
||||
break;
|
||||
|
||||
if (dec->decodedbufferbytes < start+length - dec->decodedbytestart + 4096) //expand if needed. 4096 seems to be the recommended size.
|
||||
if (dec->decodedbufferbytes < start+length - dec->decodedbytestart + 4096 && !dec->nopurge) //expand if needed. 4096 seems to be the recommended size.
|
||||
{
|
||||
// Con_Printf("Expand buffer\n");
|
||||
// Con_Printf("Expand buffer for %s\n", sfx->name);
|
||||
dec->decodedbufferbytes = (start+length - dec->decodedbytestart) + max(outspeed, 4096); //over allocate, because we can.
|
||||
dec->decodedbuffer = BZ_Realloc(dec->decodedbuffer, dec->decodedbufferbytes);
|
||||
}
|
||||
|
@ -489,8 +488,21 @@ static qboolean OV_StartDecode(unsigned char *start, unsigned long length, ovdec
|
|||
buffer->start = BZ_Malloc(length);
|
||||
memcpy(buffer->start, start, length);
|
||||
|
||||
buffer->timetotal = -1;
|
||||
buffer->pcmtotal = p_ov_pcm_total(&buffer->vf, -1);
|
||||
buffer->timetotal = buffer->pcmtotal / (float)buffer->srcspeed;
|
||||
|
||||
if (buffer->timetotal < 5) //short sounds might as well remain cached.
|
||||
buffer->nopurge = true;
|
||||
|
||||
if (buffer->nopurge)
|
||||
{ //waste more memory upfront to avoid reallocs later.
|
||||
buffer->decodedbufferbytes = buffer->pcmtotal;
|
||||
buffer->decodedbufferbytes += 4096; //ogg vorbis apparently lies/fails sometimes.
|
||||
buffer->decodedbufferbytes *= (double)snd_speed / buffer->srcspeed; //from src rate to dst rate
|
||||
buffer->decodedbufferbytes *= 2*buffer->srcchannels; //convert from frames to bytes.
|
||||
buffer->decodedbufferbytes += 4096; //just general paranoia.
|
||||
buffer->decodedbuffer = BZ_Realloc(buffer->decodedbuffer, buffer->decodedbufferbytes);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -533,9 +545,6 @@ qboolean QDECL S_LoadOVSound (sfx_t *s, qbyte *data, size_t datalen, int sndspee
|
|||
|
||||
s->decoder.decodedata(s, NULL, 0, 100);
|
||||
|
||||
if (p_ov_time_total(&buffer->vf, -1) < 5) //short sounds might as well remain cached.
|
||||
buffer->nopurge = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2183,6 +2183,30 @@ int MSG_ReadShort (void)
|
|||
return c;
|
||||
}
|
||||
|
||||
int MSG_ReadUInt16 (void)
|
||||
{
|
||||
int c;
|
||||
unsigned int msg_readcount;
|
||||
|
||||
if (msg_readmsg->packing!=SZ_RAWBYTES)
|
||||
return (short)MSG_ReadBits(16);
|
||||
|
||||
msg_readcount = msg_readmsg->currentbit>>3;
|
||||
if (msg_readcount+2 > msg_readmsg->cursize)
|
||||
{
|
||||
msg_badread = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = (unsigned short)(msg_readmsg->data[msg_readcount]
|
||||
+ (msg_readmsg->data[msg_readcount+1]<<8));
|
||||
|
||||
msg_readcount += 2;
|
||||
msg_readmsg->currentbit = msg_readcount<<3;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int MSG_ReadLong (void)
|
||||
{
|
||||
int c;
|
||||
|
|
|
@ -352,6 +352,7 @@ int MSG_ReadChar (void);
|
|||
int MSG_ReadBits(int bits);
|
||||
int MSG_ReadByte (void);
|
||||
int MSG_ReadShort (void);
|
||||
int MSG_ReadUInt16 (void);
|
||||
int MSG_ReadLong (void);
|
||||
qint64_t MSG_ReadInt64 (void);
|
||||
quint64_t MSG_ReadUInt64 (void);
|
||||
|
|
Loading…
Reference in New Issue