add new stdio replacement FS_fgetc() and use it in snd_mikmod.c.

git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@869 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2013-09-27 19:51:26 +00:00
parent a990f3db36
commit 45d808d13c
3 changed files with 20 additions and 17 deletions

View file

@ -1212,9 +1212,6 @@ static void COM_CheckRegistered (void)
if (h == -1) if (h == -1)
{ {
Cvar_SetROM ("registered", "0"); Cvar_SetROM ("registered", "0");
#if WINDED
Sys_Error ("This dedicated server requires a full registered copy of Quake");
#endif
Con_Printf ("Playing shareware version.\n"); Con_Printf ("Playing shareware version.\n");
if (com_modified) if (com_modified)
Sys_Error ("You must have the registered version to use modified games"); Sys_Error ("You must have the registered version to use modified games");
@ -2166,6 +2163,18 @@ int FS_ferror(fshandle_t *fh)
return ferror(fh->file); return ferror(fh->file);
} }
int FS_fgetc(fshandle_t *fh)
{
if (!fh) {
errno = EBADF;
return EOF;
}
if (fh->pos >= fh->length)
return EOF;
fh->pos += 1;
return fgetc(fh->file);
}
char *FS_fgets(char *s, int size, fshandle_t *fh) char *FS_fgets(char *s, int size, fshandle_t *fh)
{ {
char *ret; char *ret;

View file

@ -245,16 +245,15 @@ void FS_rewind(fshandle_t *fh);
int FS_feof(fshandle_t *fh); int FS_feof(fshandle_t *fh);
int FS_ferror(fshandle_t *fh); int FS_ferror(fshandle_t *fh);
int FS_fclose(fshandle_t *fh); int FS_fclose(fshandle_t *fh);
int FS_fgetc(fshandle_t *fh);
char *FS_fgets(char *s, int size, fshandle_t *fh); char *FS_fgets(char *s, int size, fshandle_t *fh);
long FS_filelength (fshandle_t *fh); long FS_filelength (fshandle_t *fh);
extern struct cvar_s registered; extern struct cvar_s registered;
extern qboolean standard_quake, rogue, hipnotic; extern qboolean standard_quake, rogue, hipnotic;
extern qboolean fitzmode; extern qboolean fitzmode;
/* if true, runs in fitzquake mode disabling custom quakespasm hacks. */ /* if true, run in fitzquake mode disabling custom quakespasm hacks */
#endif /* _Q_COMMON_H */ #endif /* _Q_COMMON_H */

View file

@ -59,12 +59,7 @@ static BOOL MIK_Read (MREADER *r, void *ptr, size_t siz)
static int MIK_Get (MREADER *r) static int MIK_Get (MREADER *r)
{ {
unsigned char c; return FS_fgetc(((mik_priv_t *)r)->fh);
if (FS_feof(((mik_priv_t *)r)->fh))
return EOF;
if (FS_fread(&c, 1, 1, ((mik_priv_t *)r)->fh))
return (int)c;
return EOF;
} }
static BOOL MIK_Eof (MREADER *r) static BOOL MIK_Eof (MREADER *r)
@ -94,10 +89,10 @@ static qboolean S_MIKMOD_CodecInitialize (void)
* md_pansep (stereo channels separation) default 128 is OK. * md_pansep (stereo channels separation) default 128 is OK.
* no reverbation (md_reverb 0 (up to 15)) is OK. * no reverbation (md_reverb 0 (up to 15)) is OK.
* md_musicvolume and md_sndfxvolume defaults are 128: OK. * md_musicvolume and md_sndfxvolume defaults are 128: OK.
* just tone down overall volume md_volume from 128 to 96: */ * just tone down overall volume md_volume from 128 to 96? */
md_volume = 96; md_volume = 96;
MikMod_RegisterDriver(&drv_nos); MikMod_RegisterDriver(&drv_nos); /* only need the "nosound" driver, none else */
MikMod_RegisterAllLoaders(); MikMod_RegisterAllLoaders();
if (MikMod_Init(NULL)) if (MikMod_Init(NULL))
{ {