Skip to content

Commit

Permalink
Merge pull request #122 from Ferk/master
Browse files Browse the repository at this point in the history
Fixes for eternall.wad and musinfo
  • Loading branch information
inactive123 authored Oct 20, 2019
2 parents ae95543 + 0d955dd commit aca275c
Show file tree
Hide file tree
Showing 18 changed files with 143 additions and 44 deletions.
40 changes: 38 additions & 2 deletions libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <unistd.h>
#endif
#include <errno.h>
#include <stdarg.h>

#include <libretro.h>
#include <file/file_path.h>
Expand Down Expand Up @@ -351,7 +352,7 @@ void retro_set_controller_port_device(unsigned port, unsigned device)
break;
default:
if (log_cb)
log_cb(RETRO_LOG_ERROR, "[libretro]: Invalid device, setting type to RETROPAD_CLASSIC ...\n");
log_cb(RETRO_LOG_ERROR, "Invalid libretro controller device, using default: RETROPAD_CLASSIC\n");
doom_devices[port] = RETROPAD_CLASSIC;
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, gp_classic.desc);
}
Expand Down Expand Up @@ -1426,7 +1427,42 @@ void R_InitInterpolation(void)
tic_vars.sample_step = info.timing.sample_rate / tic_vars.fps;

if (log_cb)
log_cb(RETRO_LOG_INFO, "[libretro]: Framerate set to %.2f FPS\n", info.timing.fps);
log_cb(RETRO_LOG_INFO, "R_InitInterpolation: Framerate set to %.2f FPS\n", info.timing.fps);
}
tic_vars.frac = FRACUNIT;
}

int lprintf(OutputLevels pri, const char *s, ...)
{
int r=0;
char msg[MAX_LOG_MESSAGE_SIZE];

va_list v;
va_start(v,s);
#ifdef HAVE_VSNPRINTF
r = vsnprintf(msg,sizeof(msg),s,v); /* print message in buffer */
#else
r = vsprintf(msg,s,v);
#endif
va_end(v);

if (log_cb) {
enum retro_log_level lvl;
switch(pri) {
case LO_DEBUG: lvl = RETRO_LOG_DEBUG; break;
case LO_CONFIRM:
case LO_INFO: lvl = RETRO_LOG_INFO; break;
case LO_WARN: lvl = RETRO_LOG_WARN; break;
case LO_ERROR:
case LO_FATAL:
default: lvl = RETRO_LOG_ERROR; break;
}
log_cb(lvl, "%s", msg);
}
else
r=fprintf(stderr,"%s",msg); /* select output at console */

return r;
}


5 changes: 5 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */

#ifndef __CONFIG_H__
#define __CONFIG_H__

/* Define to be the path where Doom WADs are stored */
#define DOOMWADDIR "/usr/local/share/games/doom"

Expand Down Expand Up @@ -77,3 +80,5 @@ extern int SCREENHEIGHT;

/* Define to strncasecmp, if we have it */
#define strnicmp strncasecmp

#endif
4 changes: 1 addition & 3 deletions src/d_deh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,9 +1791,7 @@ static void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
}

if (fpout) fprintf(fpout,"Thing %d (%s) -> line: '%s'\n", indexnum+1,
((indexnum >= 0 && indexnum < NUMMOBJTYPES)?
mobjinfo[indexnum].actorname : "undefined"),
inbuffer);
mobjinfo[indexnum].actorname, inbuffer);

// now process the stuff
// Note that for Things we can look up the key and use its offset
Expand Down
10 changes: 5 additions & 5 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,10 @@ static char *FindIWADFile(void)
char * iwad = NULL;

i = M_CheckParm("-iwad");
lprintf(LO_ALWAYS, "i: %d\n", i);
lprintf(LO_DEBUG, "i: %d\n", i);

for(x = 0; x < 32; x++)
lprintf(LO_ALWAYS, "myargv[%d]: %s\n", x, myargv[x]);
lprintf(LO_DEBUG, "myargv[%d]: %s\n", x, myargv[x]);

if (i && (++i < myargc)) {
iwad = I_FindFile(myargv[i], NULL);
Expand Down Expand Up @@ -732,7 +732,7 @@ static bool IdentifyVersion (void)
// set save path to -save parm or current dir

strcpy(basesavegame,I_DoomExeDir());
lprintf(LO_ALWAYS, "IdentifyVersion: basesavegame: %s\n", basesavegame);
lprintf(LO_INFO, "IdentifyVersion: basesavegame: %s\n", basesavegame);
#ifndef __CELLOS_LV2__
if ((i=M_CheckParm("-save")) && i<myargc-1) //jff 3/24/98 if -save present
{
Expand All @@ -749,7 +749,7 @@ static bool IdentifyVersion (void)
// locate the IWAD and determine game mode from it

iwad = FindIWADFile();
lprintf(LO_ALWAYS, "iwad: %s\n", iwad);
lprintf(LO_INFO, "iwad: %s\n", iwad);

if (iwad && *iwad)
{
Expand Down Expand Up @@ -1157,7 +1157,7 @@ bool D_DoomMainSetup(void)
}

/* cphipps - the main display. This shows the build date, copyright, and game type */
lprintf(LO_ALWAYS,"PrBoom, playing: %s\n"
lprintf(LO_INFO,"PrBoom, playing: %s\n"
"PrBoom is released under the GNU General Public license v2.0.\n"
"You are welcome to redistribute it under certain conditions.\n"
"It comes with ABSOLUTELY NO WARRANTY. See the file COPYING for details.\n",
Expand Down
4 changes: 4 additions & 0 deletions src/dbopl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef __DBOPL_H__
#define __DBOPL_H__

#include <stdint.h>

#ifdef _MSC_VER
Expand Down Expand Up @@ -212,5 +215,6 @@ void DBOPL_InitTables( void );
void Chip__Chip(Chip *self);
void Chip__WriteReg(Chip *self, Bit32u reg, Bit8u val );
void Chip__GenerateBlock2(Chip *self, Bitu total, Bit32s* output );
#endif

#endif
6 changes: 2 additions & 4 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,8 @@ static void G_DoLoadLevel (void)
{
int i;

lprintf(LO_ALWAYS,
"---------------------------------\n"
"G_DoLoadLevel: Episode %d - Map %.2d\n"
"---------------------------------\n",
lprintf(LO_INFO, "------------------------------\n"
"G_DoLoadLevel: ===== Episode %d - Map %.2d =====\n",
gameepisode, gamemap);

/* Set the sky map for the episode.
Expand Down
7 changes: 4 additions & 3 deletions src/lprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
/* cphipps - enlarged message buffer and made non-static
* We still have to be careful here, this function can be called after exit
*/
#define MAX_MESSAGE_SIZE 2048

#ifndef __LIBRETRO__
int lprintf(OutputLevels pri, const char *s, ...)
{
int r=0;
char msg[MAX_MESSAGE_SIZE];
char msg[MAX_LOG_MESSAGE_SIZE];

va_list v;
va_start(v,s);
Expand All @@ -67,6 +67,7 @@ int lprintf(OutputLevels pri, const char *s, ...)

return r;
}
#endif

/*
* I_Error
Expand All @@ -79,7 +80,7 @@ int lprintf(OutputLevels pri, const char *s, ...)

bool I_Error(const char *error, ...)
{
char errmsg[MAX_MESSAGE_SIZE];
char errmsg[MAX_LOG_MESSAGE_SIZE];
va_list argptr;
va_start(argptr,error);
#ifdef HAVE_VSNPRINTF
Expand Down
5 changes: 5 additions & 0 deletions src/lprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@

#include <boolean.h>

/* cphipps - enlarged message buffer and made non-static
* We still have to be careful here, this function can be called after exit
*/
#define MAX_LOG_MESSAGE_SIZE 2048

typedef enum /* Logical output levels */
{
LO_INFO=1, /* One of these is used in each physical output */
Expand Down
4 changes: 2 additions & 2 deletions src/m_argv.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const char * const * myargv; // CPhipps - not sure if ANSI C allows you to
int M_CheckParm(const char *check)
{
#if 0
lprintf(LO_ALWAYS, "M_CheckParm: Checking %s...\n", check);
lprintf(LO_ALWAYS, "M_CheckParm: myargc: %d, myargc - 1: %d\n", myargc, myargc-1);
lprintf(LO_DEBUG, "M_CheckParm: Checking %s...\n", check);
lprintf(LO_DEBUG, "M_CheckParm: myargc: %d, myargc - 1: %d\n", myargc, myargc-1);
#endif
signed int i = myargc;
while (--i>0)
Expand Down
5 changes: 5 additions & 0 deletions src/p_checksum.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#ifndef __PCHECKSUM_H__
#define __PCHECKSUM_H__

extern void (*P_Checksum)(int);
extern void P_ChecksumFinal(void);
void P_RecordChecksum(const char *file);
//void P_VerifyChecksum(const char *file);

#endif
2 changes: 1 addition & 1 deletion src/p_pspr.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ void A_FireOldBFG(player_t *player, pspdef_t *psp)
th->momz = finetangent[an2>>ANGLETOFINESHIFT] * 25;
P_CheckMissileSpawn(th);
}
while ((type != MT_PLASMA2) && (type = MT_PLASMA2)); //killough: obfuscated!
while ((type != MT_PLASMA2) && (type = MT_PLASMA2)); //killough: obfuscated! // lgtm[cpp/assign-where-compare-meant]
}

//
Expand Down
5 changes: 5 additions & 0 deletions src/r_demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*---------------------------------------------------------------------
*/

#ifndef __RDEMO_H__
#define __RDEMO_H__

#include "doomstat.h"

#define SMOOTH_PLAYING_MAXFACTOR 16
Expand All @@ -43,3 +46,5 @@ void R_SmoothPlaying_Reset(player_t *player);
void R_SmoothPlaying_Add(int delta);
angle_t R_SmoothPlaying_Get(angle_t defangle);
void R_ResetAfterTeleport(player_t *player);

#endif
3 changes: 3 additions & 0 deletions src/r_segs.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ void R_StoreWallRange(const int start, const int stop)
ds_p->scalestep = rw_scalestep = (ds_p->scale2-rw_scale) / (stop-start);
}
else
{
ds_p->scale2 = ds_p->scale1;
ds_p->scalestep = 0;
}

// calculate texture boundaries
// and decide if floor / ceiling marks are needed
Expand Down
7 changes: 6 additions & 1 deletion src/s_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,12 @@ void S_ChangeMusicByName(char* lumpname, int looping)
musicinfo_t *music = &S_music[NUMMUSIC];
int lumpnum = W_CheckNumForName(lumpname);

if ((lumpnum < -1) || (mus_playing && mus_playing->lumpnum == lumpnum))
if (lumpnum <= -1)
{
I_Error("S_ChangeMusicByName: invalid lump name '%s'", lumpname);
return;
}
if(mus_playing && mus_playing->lumpnum == lumpnum)
return;

// shutdown old music
Expand Down
56 changes: 33 additions & 23 deletions src/u_musinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,50 +78,56 @@ void U_ParseMusInfo(const char *mapid)

S_music[NUMMUSIC].lumpnum = -1;

int musinfolump = W_GetNumForName("MUSINFO");
int musinfolump = W_CheckNumForName("MUSINFO");
if (musinfolump != -1)
{
const char *data = W_CacheLumpNum(musinfolump);
int datalength = W_LumpLength(musinfolump);
int lumpnum;
int inMap = false;
int i, lumpnum, musitem;
boolean inMap = false;

// Clear any previous value
for(i=0; i<MAX_MUS_ENTRIES; i++)
musinfo.items[i] = -1;

u_scanner_t s = U_ScanOpen(data, datalength, "MUSINFO");
while (U_HasTokensLeft(&s))
{
if (inMap || U_CheckToken(&s, TK_Identifier))
if (inMap || (U_CheckToken(&s, TK_Identifier) && !strcasecmp(s.string, mapid)))
{
if (!inMap)
inMap = true;
{
inMap = true; // begin first line parsing
}

// If there's a new map as identifier, stop search
if (U_CheckToken(&s, TK_Identifier) &&
(s.string[0] == 'E' || s.string[0] == 'e' ||
s.string[0] == 'M' || s.string[0] == 'm'))
// If we were already parsing and found a map as identifier, stop search
else if (s.string[0] == 'E' || s.string[0] == 'e' ||
s.string[0] == 'M' || s.string[0] == 'm')
{
break;
}

U_MustGetInteger(&s);

// Check number in range
if (s.number > 0 && s.number < MAX_MUS_ENTRIES)
if (U_MustGetInteger(&s))
{
if (U_MustGetToken(&s, TK_Identifier))
musitem = s.number;
// Check number in range
if (musitem > 0 && musitem < MAX_MUS_ENTRIES)
{
lumpnum = W_CheckNumForName(s.string);

if (lumpnum >= 0)
musinfo.items[s.number] = lumpnum;
else
U_Error(&s, "U_ParseMusInfo: Unknown MUS lump %s", s.string);
if (U_MustGetToken(&s, TK_Identifier))
{
lumpnum = W_CheckNumForName(s.string);
if (lumpnum >= 0)
musinfo.items[musitem] = lumpnum;
else
U_Error(&s, "U_ParseMusInfo: Unknown MUS lump '%s'", s.string);
}
}
else
U_Error(&s, "U_ParseMusInfo: Number %d out of range (1- %d)", musitem, MAX_MUS_ENTRIES);
}
else
U_Error(&s, "U_ParseMusInfo: Number not in range 1 to %d", MAX_MUS_ENTRIES);
}
else
U_GetNextToken(&s, TRUE);
U_GetNextLineToken(&s);
}

U_ScanClose(&s);
Expand Down Expand Up @@ -161,7 +167,11 @@ void P_MapMusicThinker(void)
char* musicname = W_GetNameForNum(musinfo.items[musitem]);
if (musicname)
S_ChangeMusicByName(musicname, true);
else
I_Error("P_MapMusicThinker: MUSINFO item not found: %d", musitem);
}
else
I_Error("P_MapMusicThinker: MUSINFO item out of range: %d", musitem);
musinfo.tics = -1;
}
}
18 changes: 18 additions & 0 deletions src/u_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ boolean U_GetNextToken(u_scanner_t* scanner, boolean expandState)
else
break;
}
// If we reached end of input while reading, set it as the end of token
if(scanner->scanPos == scanner->length && start == end)
end = scanner->length;
}

if(end-start > 0 || stringFinished)
Expand Down Expand Up @@ -443,6 +446,21 @@ boolean U_GetNextToken(u_scanner_t* scanner, boolean expandState)
return FALSE;
}

/**
* Skips all Tokens in current line and parses the first token on
* the next line.
*/
boolean U_GetNextLineToken(u_scanner_t* scanner)
{
unsigned int line = scanner->line;
boolean retval = FALSE;

do retval = U_GetNextToken(scanner, TRUE);
while (retval && scanner->line == line);

return retval;
}


void U_ErrorToken(u_scanner_t* s, int token)
{
Expand Down
Loading

0 comments on commit aca275c

Please sign in to comment.