assorted fixes

master
an 2019-11-25 19:41:36 -05:00
parent 16e7b4373d
commit 0f96a959d3
8 changed files with 108 additions and 161 deletions

View File

@ -49,8 +49,6 @@ int host_framecount;
int host_hunklevel;
int minimum_memory;
client_t *host_client; // current client
jmp_buf host_abortserver;
@ -807,15 +805,18 @@ Host_Init
*/
void Host_Init (void)
{
int minimum_memory;
if (standard_quake)
minimum_memory = MINIMUM_MEMORY;
else minimum_memory = MINIMUM_MEMORY_LEVELPAK;
else
minimum_memory = MINIMUM_MEMORY_LEVELPAK;
if (COM_CheckParm ("-minmemory"))
host_parms->memsize = minimum_memory;
if (host_parms->memsize < minimum_memory)
Sys_Error ("Only %4.1f megs of memory available, can't execute game", host_parms->memsize / (float)0x100000);
Sys_Error ("Only %4.1f MiB of memory available, can't execute game", host_parms->memsize / (float)0x100000);
com_argc = host_parms->argc;
com_argv = host_parms->argv;

View File

@ -65,11 +65,6 @@ typedef int sys_socket_t;
#define INVALID_SOCKET (-1)
#define SOCKET_ERROR (-1)
#if defined(__APPLE__) && defined(SO_NKE) && !defined(SO_NOADDRERR)
/* ancient Mac OS X SDKs 10.2 and older are missing socklen_t */
typedef int socklen_t; /* defining as signed int to match the old api */
#endif /* ancient OSX SDKs */
#define SOCKETERRNO errno
#define ioctlsocket ioctl
#define closesocket close
@ -104,16 +99,7 @@ typedef int sys_socket_t;
#define INVALID_SOCKET (-1)
#define SOCKET_ERROR (-1)
#if !(defined(__AROS__) || defined(__amigaos4__))
typedef LONG socklen_t; /* int32_t */
#endif
#if !defined(__amigaos4__)
#if (LONG_MAX <= 2147483647L)
typedef unsigned long in_addr_t; /* u_int32_t */
#else
typedef uint32_t in_addr_t; /* u_int32_t */
#endif
#endif
typedef uint32_t in_addr_t;
#define SOCKETERRNO Errno()
#define ioctlsocket IoctlSocket

View File

@ -51,7 +51,6 @@
#include <string.h>
_Static_assert(sizeof(float) == 4, "float not correct size");
_Static_assert(sizeof(long) >= 4, "long not correct size");
_Static_assert(sizeof(int) == 4, "int not correct size");
/* make sure enums are the size of ints for structure packing */

View File

@ -36,11 +36,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "q_stdinc.h"
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
#define CACHE_SIZE 32 // used to align key data structures
#define Q_UNUSED(x) (x = x) // for pesky compiler / lint warnings
#define MINIMUM_MEMORY 0x550000
#define MINIMUM_MEMORY_LEVELPAK (MINIMUM_MEMORY + 0x100000)
@ -60,7 +55,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ON_EPSILON 0.1 // point on plane side epsilon
#define DIST_EPSILON (0.03125) // 1/32 epsilon to keep floating point happy (moved from world.c)
#define DIST_EPSILON 0.03125 // 1/32 epsilon to keep floating point happy (moved from world.c)
#define MAX_MSGLEN 64000 // max length of a reliable message //ericw -- was 32000
#define MAX_DATAGRAM 32000 // max length of unreliable message //johnfitz -- was 1024
@ -299,7 +294,5 @@ extern int current_skill; // skill level for currently loaded level (in case
extern bool isDedicated;
extern int minimum_memory;
#endif /* QUAKEDEFS_H */

View File

@ -388,127 +388,6 @@ static int mp3_stopread(snd_stream_t *stream)
return 0;
}
static int mp3_madseek(snd_stream_t *stream, unsigned long offset)
{
mp3_priv_t *p = (mp3_priv_t *) stream->priv;
size_t initial_bitrate = p->Frame.header.bitrate;
size_t tagsize = 0, consumed = 0;
int vbr = 0; /* Variable Bit Rate, bool */
bool depadded = false;
unsigned long to_skip_samples = 0;
/* Reset all */
FS_rewind(&stream->fh);
mad_timer_reset(&p->Timer);
p->FrameCount = 0;
/* They where opened in startread */
mad_synth_finish(&p->Synth);
mad_frame_finish(&p->Frame);
mad_stream_finish(&p->Stream);
mad_stream_init(&p->Stream);
mad_frame_init(&p->Frame);
mad_synth_init(&p->Synth);
offset /= stream->info.channels;
to_skip_samples = offset;
while (1) /* Read data from the MP3 file */
{
int bytes_read, padding = 0;
size_t leftover = p->Stream.bufend - p->Stream.next_frame;
memcpy(p->mp3_buffer, p->Stream.this_frame, leftover);
bytes_read = FS_fread(p->mp3_buffer + leftover, (size_t) 1,
MP3_BUFFER_SIZE - leftover, &stream->fh);
if (bytes_read <= 0)
{
Con_DPrintf("seek failure. unexpected EOF (frames=%lu leftover=%lu)\n",
(unsigned long)p->FrameCount, (unsigned long)leftover);
break;
}
for ( ; !depadded && padding < bytes_read && !p->mp3_buffer[padding]; ++padding)
;
depadded = true;
mad_stream_buffer(&p->Stream, p->mp3_buffer + padding, leftover + bytes_read - padding);
while (1) /* Decode frame headers */
{
static uint16_t samples;
p->Stream.error = MAD_ERROR_NONE;
/* Not an audio frame */
if (mad_header_decode(&p->Frame.header, &p->Stream) == -1)
{
if (p->Stream.error == MAD_ERROR_BUFLEN)
break; /* Normal behaviour; get some more data from the file */
if (!MAD_RECOVERABLE(p->Stream.error))
{
Con_DPrintf("unrecoverable MAD error\n");
break;
}
if (p->Stream.error == MAD_ERROR_LOSTSYNC)
{
unsigned long available = (p->Stream.bufend - p->Stream.this_frame);
tagsize = mp3_tagsize(p->Stream.this_frame, (size_t) available);
if (tagsize)
{ /* It's some ID3 tags, so just skip */
if (tagsize >= available)
{
FS_fseek(&stream->fh, (long)(tagsize - available), SEEK_CUR);
depadded = false;
}
mad_stream_skip(&p->Stream, q_min(tagsize, available));
}
else
{
Con_DPrintf("MAD lost sync\n");
}
}
else
{
Con_DPrintf("recoverable MAD error\n");
}
continue;
}
consumed += p->Stream.next_frame - p->Stream.this_frame;
vbr |= (p->Frame.header.bitrate != initial_bitrate);
samples = 32 * MAD_NSBSAMPLES(&p->Frame.header);
p->FrameCount++;
mad_timer_add(&p->Timer, p->Frame.header.duration);
if (to_skip_samples <= samples)
{
mad_frame_decode(&p->Frame,&p->Stream);
mad_synth_frame(&p->Synth, &p->Frame);
p->cursamp = to_skip_samples;
return 0;
}
else to_skip_samples -= samples;
/* If not VBR, we can extrapolate frame size */
if (p->FrameCount == 64 && !vbr)
{
p->FrameCount = offset / samples;
to_skip_samples = offset % samples;
if (0 != FS_fseek(&stream->fh, (p->FrameCount * consumed / 64) + tagsize, SEEK_SET))
return -1;
/* Reset Stream for refilling buffer */
mad_stream_finish(&p->Stream);
mad_stream_init(&p->Stream);
break;
}
}
}
return -1;
}
static bool S_MP3_CodecInitialize (void)
{
return true;
@ -561,12 +440,103 @@ static void S_MP3_CodecCloseStream (snd_stream_t *stream)
static int S_MP3_CodecRewindStream (snd_stream_t *stream)
{
/*
mp3_stopread(stream);
mp3_priv_t *p = (mp3_priv_t *) stream->priv;
size_t initial_bitrate = p->Frame.header.bitrate;
size_t tagsize = 0, consumed = 0;
int vbr = 0; /* Variable Bit Rate, bool */
bool depadded = false;
/* Reset all */
FS_rewind(&stream->fh);
return mp3_startread(stream);
*/
return mp3_madseek(stream, 0);
mad_timer_reset(&p->Timer);
p->FrameCount = 0;
/* They where opened in startread */
mad_synth_finish(&p->Synth);
mad_frame_finish(&p->Frame);
mad_stream_finish(&p->Stream);
mad_stream_init(&p->Stream);
mad_frame_init(&p->Frame);
mad_synth_init(&p->Synth);
while (1) /* Read data from the MP3 file */
{
int bytes_read, padding = 0;
size_t leftover = p->Stream.bufend - p->Stream.next_frame;
memcpy(p->mp3_buffer, p->Stream.this_frame, leftover);
bytes_read = FS_fread(p->mp3_buffer + leftover, (size_t) 1,
MP3_BUFFER_SIZE - leftover, &stream->fh);
if (bytes_read <= 0)
{
Con_DPrintf("seek failure. unexpected EOF (frames=%u leftover=%u)\n",
p->FrameCount, leftover);
break;
}
for ( ; !depadded && padding < bytes_read && !p->mp3_buffer[padding]; ++padding)
;
depadded = true;
mad_stream_buffer(&p->Stream, p->mp3_buffer + padding, leftover + bytes_read - padding);
while (1) /* Decode frame headers */
{
static uint16_t samples;
p->Stream.error = MAD_ERROR_NONE;
/* Not an audio frame */
if (mad_header_decode(&p->Frame.header, &p->Stream) == -1)
{
if (p->Stream.error == MAD_ERROR_BUFLEN)
break; /* Normal behaviour; get some more data from the file */
if (!MAD_RECOVERABLE(p->Stream.error))
{
Con_DPrintf("unrecoverable MAD error\n");
break;
}
if (p->Stream.error == MAD_ERROR_LOSTSYNC)
{
size_t available = (p->Stream.bufend - p->Stream.this_frame);
tagsize = mp3_tagsize(p->Stream.this_frame, (size_t) available);
if (tagsize)
{ /* It's some ID3 tags, so just skip */
if (tagsize >= available)
{
FS_fseek(&stream->fh,
(ptrdiff_t)tagsize - (ptrdiff_t)available,
SEEK_CUR);
depadded = false;
}
mad_stream_skip(&p->Stream, q_min(tagsize, available));
}
else
{
Con_DPrintf("MAD lost sync\n");
}
}
else
{
Con_DPrintf("recoverable MAD error\n");
}
continue;
}
consumed += p->Stream.next_frame - p->Stream.this_frame;
vbr |= (p->Frame.header.bitrate != initial_bitrate);
samples = 32 * MAD_NSBSAMPLES(&p->Frame.header);
p->FrameCount++;
mad_timer_add(&p->Timer, p->Frame.header.duration);
mad_frame_decode(&p->Frame,&p->Stream);
mad_synth_frame(&p->Synth, &p->Frame);
p->cursamp = 0;
return 0;
}
}
return -1;
}
snd_codec_t mp3_codec =

View File

@ -60,7 +60,7 @@ double Sys_DoubleTime (void);
const char *Sys_ConsoleInput (void);
void Sys_Sleep (unsigned long msecs);
void Sys_Sleep (uint32_t msecs);
// yield for about 'msecs' milliseconds.
void Sys_SendKeyEvents (void);

View File

@ -465,10 +465,9 @@ const char *Sys_ConsoleInput (void)
return NULL;
}
void Sys_Sleep (unsigned long msecs)
void Sys_Sleep (uint32_t msecs)
{
/* usleep (msecs * 1000);*/
SDL_Delay (msecs);
SDL_Delay(msecs);
}
void Sys_SendKeyEvents (void)

View File

@ -420,10 +420,9 @@ const char *Sys_ConsoleInput (void)
return NULL;
}
void Sys_Sleep (unsigned long msecs)
void Sys_Sleep (uint32_t msecs)
{
/* Sleep (msecs);*/
SDL_Delay (msecs);
SDL_Delay(msecs);
}
void Sys_SendKeyEvents (void)