forked from len0rd/rockbox
Some fixes to doom dehacked loading - make embedded dehacked files actually load, fix end of file detection in the string loader, fix ammo changes, fix bex code pointers. Also added the * flag to sscanf - still only tested against rockdoom sscanf calls.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13547 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7428b79de3
commit
aec5814d43
4 changed files with 63 additions and 26 deletions
|
@ -85,7 +85,7 @@ char *dehfgets(char *buf, size_t n, DEHFILE *fp)
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
|
|
||||||
while (--n > 0)
|
while (n-- > 0)
|
||||||
{
|
{
|
||||||
unsigned char c = *fp->inp++;
|
unsigned char c = *fp->inp++;
|
||||||
fp->size--;
|
fp->size--;
|
||||||
|
@ -111,7 +111,7 @@ int dehfeof(DEHFILE *fp)
|
||||||
return (size <= 0 || offset < 0 || offset >= size) ? 1 : 0;
|
return (size <= 0 || offset < 0 || offset >= size) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (fp->size == 0 || *fp->inp == '\0') ? 1 : 0;
|
return (fp->size <= 0 || *fp->inp == '\0') ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dehfgetc(DEHFILE *fp)
|
int dehfgetc(DEHFILE *fp)
|
||||||
|
@ -1509,6 +1509,7 @@ void ProcessDehFile(const char *filename, const char *outfilename, int lumpnum)
|
||||||
int size = W_LumpLength(lumpnum);
|
int size = W_LumpLength(lumpnum);
|
||||||
infile.size = (size < 0) ? 0 : (ssize_t)size;
|
infile.size = (size < 0) ? 0 : (ssize_t)size;
|
||||||
infile.inp = W_CacheLumpNum(lumpnum);
|
infile.inp = W_CacheLumpNum(lumpnum);
|
||||||
|
infile.fd=-1;
|
||||||
filename = "(WAD)";
|
filename = "(WAD)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1983,7 +1984,7 @@ void deh_procPointer(DEHFILE *fpin, int fpout, char *line) // done
|
||||||
// NOTE: different format from normal
|
// NOTE: different format from normal
|
||||||
|
|
||||||
// killough 8/98: allow hex numbers in input, fix error case:
|
// killough 8/98: allow hex numbers in input, fix error case:
|
||||||
if (sscanf(inbuffer,"%*s %*i (%s %i)",key, &indexnum) != 2)
|
if (sscanf(inbuffer,"%*s %*d (%s %d)",key, &indexnum) != 2)
|
||||||
{
|
{
|
||||||
if (fpout) fdprintf(fpout,"Bad data pair in '%s'\n",inbuffer);
|
if (fpout) fdprintf(fpout,"Bad data pair in '%s'\n",inbuffer);
|
||||||
return;
|
return;
|
||||||
|
@ -2122,7 +2123,7 @@ void deh_procAmmo(DEHFILE *fpin, int fpout, char *line)
|
||||||
strncpy(inbuffer,line,DEH_BUFFERMAX);
|
strncpy(inbuffer,line,DEH_BUFFERMAX);
|
||||||
|
|
||||||
// killough 8/98: allow hex numbers in input:
|
// killough 8/98: allow hex numbers in input:
|
||||||
sscanf(inbuffer,"%s %i",key, &indexnum);
|
sscanf(inbuffer,"%s %d",key, &indexnum);
|
||||||
if (fpout) fdprintf(fpout,"Processing Ammo at index %d: %s\n",
|
if (fpout) fdprintf(fpout,"Processing Ammo at index %d: %s\n",
|
||||||
indexnum, key);
|
indexnum, key);
|
||||||
if (indexnum < 0 || indexnum >= NUMAMMO)
|
if (indexnum < 0 || indexnum >= NUMAMMO)
|
||||||
|
|
|
@ -82,7 +82,7 @@ boolean clfastparm; // checkparm of -fast
|
||||||
boolean nomonsters; // working -nomonsters
|
boolean nomonsters; // working -nomonsters
|
||||||
boolean respawnparm; // working -respawn
|
boolean respawnparm; // working -respawn
|
||||||
boolean fastparm; // working -fast
|
boolean fastparm; // working -fast
|
||||||
boolean dehout=false;
|
boolean dehout=true;
|
||||||
|
|
||||||
boolean singletics = false; // debug flag to cancel adaptiveness
|
boolean singletics = false; // debug flag to cancel adaptiveness
|
||||||
|
|
||||||
|
@ -731,7 +731,7 @@ void D_DoomMainSetup(void)
|
||||||
W_Init();
|
W_Init();
|
||||||
|
|
||||||
if ((p = W_CheckNumForName("DEHACKED")) != -1) // cph - add dehacked-in-a-wad support
|
if ((p = W_CheckNumForName("DEHACKED")) != -1) // cph - add dehacked-in-a-wad support
|
||||||
ProcessDehFile(NULL, dehout ? NULL : "/dehlog.txt", p);
|
ProcessDehFile(NULL, dehout ? "/dehlog.txt" : NULL, p);
|
||||||
|
|
||||||
V_InitColorTranslation(); //jff 4/24/98 load color translation lumps
|
V_InitColorTranslation(); //jff 4/24/98 load color translation lumps
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@ struct plugin_api* rb;
|
||||||
|
|
||||||
bool noprintf=0; // Variable disables printf lcd updates to protect grayscale lib/direct lcd updates
|
bool noprintf=0; // Variable disables printf lcd updates to protect grayscale lib/direct lcd updates
|
||||||
|
|
||||||
|
#ifndef SIMULATOR
|
||||||
// Here is a hacked up printf command to get the output from the game.
|
// Here is a hacked up printf command to get the output from the game.
|
||||||
int printf(const char *fmt, ...)
|
int printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -129,6 +130,7 @@ int printf(const char *fmt, ...)
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
char *my_strtok( char * s, const char * delim )
|
char *my_strtok( char * s, const char * delim )
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,18 +54,23 @@ static int parse_dec(int (*peek)(void *userp),
|
||||||
static int parse_chars(int (*peek)(void *userp),
|
static int parse_chars(int (*peek)(void *userp),
|
||||||
void (*pop)(void *userp),
|
void (*pop)(void *userp),
|
||||||
void *userp,
|
void *userp,
|
||||||
char *vp)
|
char *vp,
|
||||||
|
bool fake)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
char *pt=vp;
|
char *pt=vp;
|
||||||
|
|
||||||
while (!isspace((*peek)(userp)))
|
while (!isspace((*peek)(userp)))
|
||||||
{
|
{
|
||||||
|
if(fake==false)
|
||||||
*(pt++) = (*peek)(userp);
|
*(pt++) = (*peek)(userp);
|
||||||
|
|
||||||
n++;
|
n++;
|
||||||
(*pop)(userp);
|
(*pop)(userp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(fake==false)
|
||||||
(*pt)='\0';
|
(*pt)='\0';
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
|
@ -125,6 +130,7 @@ static int scan(int (*peek)(void *userp),
|
||||||
int n_chars = 0;
|
int n_chars = 0;
|
||||||
int r;
|
int r;
|
||||||
long lval;
|
long lval;
|
||||||
|
bool skip=false;
|
||||||
unsigned long ulval;
|
unsigned long ulval;
|
||||||
|
|
||||||
while ((ch = *fmt++) != '\0')
|
while ((ch = *fmt++) != '\0')
|
||||||
|
@ -135,14 +141,27 @@ static int scan(int (*peek)(void *userp),
|
||||||
{
|
{
|
||||||
ch = *fmt++;
|
ch = *fmt++;
|
||||||
|
|
||||||
|
if(ch== '*') /* We should process this, but not store it in an arguement */
|
||||||
|
{
|
||||||
|
ch=*fmt++;
|
||||||
|
skip=true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skip=false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case 'x':
|
case 'x':
|
||||||
n_chars += skip_spaces(peek, pop, userp);
|
n_chars += skip_spaces(peek, pop, userp);
|
||||||
if ((r = parse_hex(peek, pop, userp, &ulval)) >= 0)
|
if ((r = parse_hex(peek, pop, userp, &ulval)) >= 0)
|
||||||
|
{
|
||||||
|
if(skip==false)
|
||||||
{
|
{
|
||||||
*(va_arg(ap, unsigned int *)) = ulval;
|
*(va_arg(ap, unsigned int *)) = ulval;
|
||||||
n++;
|
n++;
|
||||||
|
}
|
||||||
n_chars += r;
|
n_chars += r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -151,17 +170,23 @@ static int scan(int (*peek)(void *userp),
|
||||||
case 'd':
|
case 'd':
|
||||||
n_chars += skip_spaces(peek, pop, userp);
|
n_chars += skip_spaces(peek, pop, userp);
|
||||||
if ((r = parse_dec(peek, pop, userp, &lval)) >= 0)
|
if ((r = parse_dec(peek, pop, userp, &lval)) >= 0)
|
||||||
|
{
|
||||||
|
if(skip==false)
|
||||||
{
|
{
|
||||||
*(va_arg(ap, int *)) = lval;
|
*(va_arg(ap, int *)) = lval;
|
||||||
n++;
|
n++;
|
||||||
|
}
|
||||||
n_chars += r;
|
n_chars += r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return n;
|
return n;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
|
if(skip==false)
|
||||||
|
{
|
||||||
*(va_arg(ap, int *)) = n_chars;
|
*(va_arg(ap, int *)) = n_chars;
|
||||||
n++;
|
n++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
n_chars += skip_spaces(peek, pop, userp);
|
n_chars += skip_spaces(peek, pop, userp);
|
||||||
|
@ -170,9 +195,12 @@ static int scan(int (*peek)(void *userp),
|
||||||
{
|
{
|
||||||
case 'x':
|
case 'x':
|
||||||
if ((r = parse_hex(peek, pop, userp, &ulval)) >= 0)
|
if ((r = parse_hex(peek, pop, userp, &ulval)) >= 0)
|
||||||
|
{
|
||||||
|
if(skip==false)
|
||||||
{
|
{
|
||||||
*(va_arg(ap, unsigned long *)) = ulval;
|
*(va_arg(ap, unsigned long *)) = ulval;
|
||||||
n++;
|
n++;
|
||||||
|
}
|
||||||
n_chars += r;
|
n_chars += r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -180,9 +208,12 @@ static int scan(int (*peek)(void *userp),
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if ((r = parse_dec(peek, pop, userp, &lval)) >= 0)
|
if ((r = parse_dec(peek, pop, userp, &lval)) >= 0)
|
||||||
|
{
|
||||||
|
if(skip==false)
|
||||||
{
|
{
|
||||||
*(va_arg(ap, long *)) = lval;
|
*(va_arg(ap, long *)) = lval;
|
||||||
n++;
|
n++;
|
||||||
|
}
|
||||||
n_chars += r;
|
n_chars += r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -197,8 +228,11 @@ static int scan(int (*peek)(void *userp),
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
n_chars += skip_spaces(peek, pop, userp);
|
n_chars += skip_spaces(peek, pop, userp);
|
||||||
n_chars += parse_chars(peek,pop, userp,va_arg(ap, char *) );
|
n_chars += parse_chars(peek,pop, userp,skip?0:va_arg(ap, char *), skip );
|
||||||
|
if(skip==false)
|
||||||
|
{
|
||||||
n++;
|
n++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '\0':
|
case '\0':
|
||||||
return n;
|
return n;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue