EDuke32: new demo system should be stable now; Made the $EDUKE32_MUSIC_CMD env var work (SDL only).

Mapster32: Helper feature -- pressing SHIFT on a 2-sided wall makes the PGUP/PGDN etc. commands operate on the sector at the other end of the wall; replaced searchstat numbers by #defined names and eliminated the worst cases of code duplication in astub.c

git-svn-id: https://svn.eduke32.com/eduke32@1598 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2010-02-13 21:46:42 +00:00
parent eb464d45f9
commit 512535c53f
7 changed files with 422 additions and 692 deletions

View file

@ -9504,53 +9504,49 @@ void getmousevalues(int32_t *mousx, int32_t *mousy, int32_t *bstatus)
# include <execinfo.h> # include <execinfo.h>
# define KRD_MAXCALLS 262144 # define KRD_MAXCALLS 262144
# define KRD_DEPTH 8 # define KRD_DEPTH 8
static int krd_numcalls=0; static int32_t krd_numcalls=0;
static int krd_randomseed[KRD_MAXCALLS];
static int krd_totalclock[KRD_MAXCALLS];
static void *krd_fromwhere[KRD_MAXCALLS][KRD_DEPTH]; static void *krd_fromwhere[KRD_MAXCALLS][KRD_DEPTH];
static int32_t krd_enabled=0; static int32_t krd_enabled=0;
void krd_enable() void krd_enable(int which) // 0: disable, 1: rec, 2: play
{ {
krd_enabled = 1; krd_enabled = which;
if (which)
Bmemset(krd_fromwhere, 0, sizeof(krd_fromwhere));
} }
int32_t krd_print(const char *filename) int32_t krd_print(const char *filename)
{ {
FILE *krd_fp = fopen(filename, "w"); FILE *fp;
int i, j, k, ototalclk=0; int32_t i, j;
if (!krd_enabled) return 1;
krd_enabled = 0; krd_enabled = 0;
if (!krd_fp) { printf("KRANDDEBUG: Couldn't open file!"); return 1; }
fp = fopen(filename, "wb");
if (!fp) { OSD_Printf("krd_print (2): fopen"); return 1; }
for (i=0; i<krd_numcalls; i++) for (i=0; i<krd_numcalls; i++)
{ {
k = (ototalclk != krd_totalclock[i]);
if (k)
{
ototalclk = krd_totalclock[i];
fprintf(krd_fp, "#%d:", ototalclk);
}
fprintf(krd_fp, " %08x:", krd_randomseed[i]);
for (j=1;; j++) // skip self entry for (j=1;; j++) // skip self entry
{ {
if (j>=KRD_DEPTH || krd_fromwhere[i][j]==NULL) if (j>=KRD_DEPTH || krd_fromwhere[i][j]==NULL)
{ {
fprintf(krd_fp, "\n"); fprintf(fp, "\n");
break; break;
} }
fprintf(krd_fp, " [%p]", krd_fromwhere[i][j]); fprintf(fp, " [%p]", krd_fromwhere[i][j]);
} }
} }
krd_numcalls = 0; krd_numcalls = 0;
fclose(krd_fp); fclose(fp);
return 0; return 0;
} }
#endif #endif // KRANDDEBUG
// //
// krand // krand
@ -9564,11 +9560,7 @@ int32_t krand(void)
if (krd_enabled) if (krd_enabled)
if (krd_numcalls < KRD_MAXCALLS) if (krd_numcalls < KRD_MAXCALLS)
{ {
int32_t i; backtrace(krd_fromwhere[krd_numcalls], KRD_DEPTH);
krd_randomseed[krd_numcalls] = randomseed;
krd_totalclock[krd_numcalls] = totalclock;
for (i=backtrace(krd_fromwhere[krd_numcalls],KRD_DEPTH); i<KRD_DEPTH; i++)
krd_fromwhere[krd_numcalls][i] = NULL;
krd_numcalls++; krd_numcalls++;
} }
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -9200,8 +9200,7 @@ GAME_STATIC void G_HandleLocalKeys(void)
if (KB_KeyPressed(sc_Return) && ud.multimode==1) if (KB_KeyPressed(sc_Return) && ud.multimode==1)
{ {
KB_ClearKeyDown(sc_Return); KB_ClearKeyDown(sc_Return);
ud.reccnt = 0; g_demo_cnt = g_demo_goalCnt = ud.reccnt = ud.pause_on = ud.recstat = ud.m_recstat = 0;
ud.recstat = 0;
kclose(g_demo_recFilePtr); kclose(g_demo_recFilePtr);
g_player[myconnectindex].ps->gm = MODE_GAME; g_player[myconnectindex].ps->gm = MODE_GAME;
// ready2send=0; // ready2send=0;
@ -12019,7 +12018,7 @@ GAME_STATIC int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine
ud.reccnt = 0; ud.reccnt = 0;
ud.god = ud.cashman = ud.eog = ud.showallmap = 0; ud.god = ud.cashman = ud.eog = ud.showallmap = 0;
ud.clipping = ud.scrollmode = ud.overhead_on = ud.pause_on = 0; ud.clipping = ud.scrollmode = ud.overhead_on = 0; //= ud.pause_on = 0;
// G_NewGame(ud.volume_number,ud.level_number,ud.player_skill); // G_NewGame(ud.volume_number,ud.level_number,ud.player_skill);
// G_ResetTimers(); // G_ResetTimers();
@ -12043,7 +12042,7 @@ corrupt:
} }
#if KRANDDEBUG #if KRANDDEBUG
extern int32_t krd_enable(); extern void krd_enable(int32_t which);
extern int32_t krd_print(const char *filename); extern int32_t krd_print(const char *filename);
#endif #endif
@ -12059,16 +12058,15 @@ void G_OpenDemoWrite(void)
{ {
Bstrcpy(ScriptQuotes[122], "CANNOT START DEMO RECORDING WHEN DEAD!"); Bstrcpy(ScriptQuotes[122], "CANNOT START DEMO RECORDING WHEN DEAD!");
P_DoQuote(122, g_player[myconnectindex].ps); P_DoQuote(122, g_player[myconnectindex].ps);
ud.recstat = 0; ud.recstat = ud.m_recstat = 0;
return; return;
} }
if (demorec_diffs_cvar && !demorec_force_cvar) if (demorec_diffs_cvar && !demorec_force_cvar)
for (i=1; i<g_scriptSize; i++) for (i=1; i<g_scriptSize-2; i++)
{ {
intptr_t w=script[i]; intptr_t w=script[i];
if ((w&0x0fff)==CON_RESIZEARRAY && (w>>12) && i<g_scriptSize-2 && if ((w&0x0fff)==CON_RESIZEARRAY && (w>>12) && script[i+1]>=0 && script[i+1]<g_gameArrayCount)
script[i+1]>=0 && script[i+1]<g_gameArrayCount)
{ {
OSD_Printf("\nThe CON code possibly contains a RESIZEARRAY command.\n"); OSD_Printf("\nThe CON code possibly contains a RESIZEARRAY command.\n");
OSD_Printf("Gamearrays that change their size during the game are unsupported by\n"); OSD_Printf("Gamearrays that change their size during the game are unsupported by\n");
@ -12078,7 +12076,7 @@ void G_OpenDemoWrite(void)
OSD_Printf("with the `demorec_diffs' cvar.\n\n"); OSD_Printf("with the `demorec_diffs' cvar.\n\n");
Bstrcpy(ScriptQuotes[122], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS."); Bstrcpy(ScriptQuotes[122], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS.");
P_DoQuote(122, g_player[myconnectindex].ps); P_DoQuote(122, g_player[myconnectindex].ps);
ud.recstat = 0; ud.recstat = ud.m_recstat = 0;
return; return;
} }
} }
@ -12101,7 +12099,7 @@ void G_OpenDemoWrite(void)
Bstrcpy(ScriptQuotes[122], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS."); Bstrcpy(ScriptQuotes[122], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS.");
P_DoQuote(122, g_player[myconnectindex].ps); P_DoQuote(122, g_player[myconnectindex].ps);
Bfclose(g_demo_filePtr), g_demo_filePtr=NULL; Bfclose(g_demo_filePtr), g_demo_filePtr=NULL;
ud.recstat = 0; ud.recstat = ud.m_recstat = 0;
return; return;
} }
demorec_seeds = demorec_seeds_cvar; demorec_seeds = demorec_seeds_cvar;
@ -12113,10 +12111,10 @@ void G_OpenDemoWrite(void)
P_DoQuote(122, g_player[myconnectindex].ps); P_DoQuote(122, g_player[myconnectindex].ps);
ud.reccnt = 0; ud.reccnt = 0;
ud.recstat = 1; // ud.recstat = ud.m_recstat = 1; //
#if KRANDDEBUG #if KRANDDEBUG
krd_enable(); krd_enable(1);
#endif #endif
g_demo_cnt = 1; g_demo_cnt = 1;
@ -12301,7 +12299,7 @@ RECHECK:
lastsyncclock = totalclock; lastsyncclock = totalclock;
outofsync = 0; outofsync = 0;
#if KRANDDEBUG #if KRANDDEBUG
krd_enable(); krd_enable(2);
#endif #endif
} }
@ -12322,10 +12320,6 @@ RECHECK:
{ {
if (foundemo && (!g_demo_paused || g_demo_goalCnt)) if (foundemo && (!g_demo_paused || g_demo_goalCnt))
{ {
static int32_t t1=0;
if (t1==0 && g_demo_goalCnt)
t1=getticks();
if (g_demo_goalCnt>0 && g_demo_goalCnt < g_demo_cnt) // rewind if (g_demo_goalCnt>0 && g_demo_goalCnt < g_demo_cnt) // rewind
{ {
k = g_player[myconnectindex].ps->gm&MODE_MENU; k = g_player[myconnectindex].ps->gm&MODE_MENU;
@ -12354,8 +12348,8 @@ RECHECK:
g_demo_cnt = 1; g_demo_cnt = 1;
ud.reccnt = 0; ud.reccnt = 0;
ud.god = ud.cashman = ud.eog = ud.showallmap = 0; // ud.god = ud.cashman = ud.eog = ud.showallmap = 0;
ud.clipping = ud.scrollmode = ud.overhead_on = ud.pause_on = 0; // ud.clipping = ud.scrollmode = ud.overhead_on = ud.pause_on = 0;
totalclock = ototalclock = lockclock = 0; totalclock = ototalclock = lockclock = 0;
} }
@ -12414,9 +12408,6 @@ RECHECK:
goto nextdemo; goto nextdemo;
else CORRUPT(12); else CORRUPT(12);
if (demo_hasseeds)
outofsync = (uint16_t)(randomseed>>24) != g_demo_seedbuf[bigi];
if (0) if (0)
{ {
corrupt: corrupt:
@ -12435,6 +12426,9 @@ nextdemo:
} }
} }
if (demo_hasseeds)
outofsync = (uint8_t)(randomseed>>24) != g_demo_seedbuf[bigi];
TRAVERSE_CONNECT(j) TRAVERSE_CONNECT(j)
{ {
copybufbyte(&recsync[bigi], &inputfifo[0][j], sizeof(input_t)); copybufbyte(&recsync[bigi], &inputfifo[0][j], sizeof(input_t));
@ -12595,7 +12589,12 @@ nextdemo:
if (g_player[myconnectindex].ps->gm==MODE_END || g_player[myconnectindex].ps->gm==MODE_GAME) if (g_player[myconnectindex].ps->gm==MODE_END || g_player[myconnectindex].ps->gm==MODE_GAME)
{ {
if (foundemo) if (foundemo)
{
#if KRANDDEBUG
krd_print("krandplay.log");
#endif
kclose(g_demo_recFilePtr); kclose(g_demo_recFilePtr);
}
return 0; return 0;
} }
} }
@ -12618,7 +12617,8 @@ nextdemo:
if (g_player[myconnectindex].ps->gm&MODE_MENU) goto RECHECK; if (g_player[myconnectindex].ps->gm&MODE_MENU) goto RECHECK;
#if KRANDDEBUG #if KRANDDEBUG
krd_print("krandplay.log"); if (foundemo)
krd_print("krandplay.log");
#endif #endif
return 1; return 1;
} }
@ -12702,7 +12702,7 @@ GAME_STATIC int32_t G_DoMoveThings(void)
ud.camerasprite = -1; ud.camerasprite = -1;
lockclock += TICSPERFRAME; lockclock += TICSPERFRAME;
if (g_earthquakeTime > 0) g_earthquakeTime--; //if (g_earthquakeTime > 0) g_earthquakeTime--; moved lower so it is restored correctly by diffs
if (g_RTSPlaying > 0) g_RTSPlaying--; if (g_RTSPlaying > 0) g_RTSPlaying--;
for (i=0; i<MAXUSERQUOTES; i++) for (i=0; i<MAXUSERQUOTES; i++)
@ -12757,7 +12757,7 @@ GAME_STATIC int32_t G_DoMoveThings(void)
} }
} }
everyothertime++; // everyothertime++; moved lower so it is restored correctly by diffs
if (g_netServer || g_netClient) if (g_netServer || g_netClient)
randomseed = ticrandomseed; randomseed = ticrandomseed;
@ -12787,6 +12787,9 @@ GAME_STATIC int32_t G_DoMoveThings(void)
if (ud.recstat == 1) G_DemoRecord(); if (ud.recstat == 1) G_DemoRecord();
everyothertime++;
if (g_earthquakeTime > 0) g_earthquakeTime--;
#ifdef POLYMER #ifdef POLYMER
if (ud.pause_on == 0) if (ud.pause_on == 0)
gamelightcount = 0; gamelightcount = 0;

View file

@ -2807,7 +2807,7 @@ cheat_for_port_credits:
} }
if ((g_player[myconnectindex].ps->gm&MODE_GAME) && ud.m_recstat != 1) if ((g_player[myconnectindex].ps->gm&MODE_GAME) && ud.m_recstat != 1)
enabled = 0; enabled = 0;
mgametextpal(d,yy,ud.m_recstat?((ud.m_recstat && enabled && g_player[myconnectindex].ps->gm&MODE_GAME)?"Running":"On"):"Off",enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE,enabled?0:1); mgametextpal(d,yy,ud.m_recstat?((enabled && g_player[myconnectindex].ps->gm&MODE_GAME)?"Running":"On"):"Off",enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE,enabled?0:1);
break; break;
case 12: case 12:
if (x==io) ChangeToMenu(201); if (x==io) ChangeToMenu(201);

View file

@ -935,7 +935,7 @@ typedef struct dataspec_
} dataspec_t; } dataspec_t;
#define SV_MAJOR_VER 0 #define SV_MAJOR_VER 0
#define SV_MINOR_VER 1 #define SV_MINOR_VER 2
#define SV_DEFAULTCOMPRTHRES 8 #define SV_DEFAULTCOMPRTHRES 8
static uint8_t savegame_diffcompress; // 0:none, 1:Ken's LZW in cache1d.c static uint8_t savegame_diffcompress; // 0:none, 1:Ken's LZW in cache1d.c
static uint8_t savegame_comprthres; static uint8_t savegame_comprthres;
@ -966,7 +966,7 @@ static int32_t ds_getcnt(const dataspec_t *sp)
} }
} }
static void ds_get(const dataspec_t *sp, void **ptr, int32_t *cnt) static void ds_get(const dataspec_t *sp, const void **ptr, int32_t *cnt)
{ {
*cnt = ds_getcnt(sp); *cnt = ds_getcnt(sp);
@ -1067,7 +1067,7 @@ static int32_t readspecdata(const dataspec_t *spec, int32_t fil, uint8_t **dumpv
continue; continue;
} }
ds_get(sp, &ptr, &cnt); ds_get(sp, (const void **)&ptr, &cnt);
if (cnt < 0) { OSD_Printf("rsd: cnt<0... wtf?\n"); return -1; } if (cnt < 0) { OSD_Printf("rsd: cnt<0... wtf?\n"); return -1; }
if (fil>=0) if (fil>=0)
@ -1360,6 +1360,7 @@ static void sv_prespriteextsave();
static void sv_postspriteext(); static void sv_postspriteext();
static void sv_calcbitptrsize(); static void sv_calcbitptrsize();
static void sv_prescriptsave_once(); static void sv_prescriptsave_once();
static void sv_prescriptload_once();
static void sv_postscript_once(); static void sv_postscript_once();
static void sv_preactordatasave(); static void sv_preactordatasave();
static void sv_postactordata(); static void sv_postactordata();
@ -1413,6 +1414,7 @@ static const dataspec_t svgm_udnetw[] =
{ DS_NOCHK, &ud.ffire, sizeof(ud.ffire), 1 }, { DS_NOCHK, &ud.ffire, sizeof(ud.ffire), 1 },
{ DS_NOCHK, &ud.noexits, sizeof(ud.noexits), 1 }, { DS_NOCHK, &ud.noexits, sizeof(ud.noexits), 1 },
{ DS_NOCHK, &ud.playerai, sizeof(ud.playerai), 1 }, { DS_NOCHK, &ud.playerai, sizeof(ud.playerai), 1 },
{ 0, &ud.pause_on, sizeof(ud.pause_on), 1 },
{ DS_NOCHK, &currentboardfilename[0], BMAX_PATH, 1 }, { DS_NOCHK, &currentboardfilename[0], BMAX_PATH, 1 },
{ DS_LOADFN, (void *)&sv_postudload, 0, 1 }, { DS_LOADFN, (void *)&sv_postudload, 0, 1 },
{ 0, &connecthead, sizeof(connecthead), 1 }, { 0, &connecthead, sizeof(connecthead), 1 },
@ -1472,6 +1474,7 @@ static const dataspec_t svgm_script[] =
{ DS_SAVEFN|DS_NOCHK, (void *)&sv_prescriptsave_once, 0, 1 }, { DS_SAVEFN|DS_NOCHK, (void *)&sv_prescriptsave_once, 0, 1 },
{ DS_NOCHK, &actorscrptr[0], sizeof(actorscrptr[0]), MAXTILES }, { DS_NOCHK, &actorscrptr[0], sizeof(actorscrptr[0]), MAXTILES },
{ DS_LOADFN|DS_NOCHK, (void *)&sv_prescriptload_once, 0, 1 },
{ DS_DYNAMIC|DS_CNT(g_scriptSize)|DS_NOCHK, &script, sizeof(script[0]), (intptr_t)&g_scriptSize }, { DS_DYNAMIC|DS_CNT(g_scriptSize)|DS_NOCHK, &script, sizeof(script[0]), (intptr_t)&g_scriptSize },
{ DS_NOCHK, &actorLoadEventScrptr[0], sizeof(actorLoadEventScrptr[0]), MAXTILES }, { DS_NOCHK, &actorLoadEventScrptr[0], sizeof(actorLoadEventScrptr[0]), MAXTILES },
// { DS_NOCHK, &apScriptGameEvent[0], sizeof(apScriptGameEvent[0]), MAXGAMEEVENTS }, // { DS_NOCHK, &apScriptGameEvent[0], sizeof(apScriptGameEvent[0]), MAXGAMEEVENTS },
@ -1498,6 +1501,9 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &camsprite, sizeof(camsprite), 1 }, { 0, &camsprite, sizeof(camsprite), 1 },
{ 0, &msx[0], sizeof(msx[0]), sizeof(msx)/sizeof(msx[0]) }, { 0, &msx[0], sizeof(msx[0]), sizeof(msx)/sizeof(msx[0]) },
{ 0, &msy[0], sizeof(msy[0]), sizeof(msy)/sizeof(msy[0]) }, { 0, &msy[0], sizeof(msy[0]), sizeof(msy)/sizeof(msy[0]) },
{ 0, &g_spriteDeleteQueuePos, sizeof(g_spriteDeleteQueuePos), 1 },
{ DS_NOCHK, &g_spriteDeleteQueueSize, sizeof(g_spriteDeleteQueueSize), 1 },
{ DS_CNT(g_spriteDeleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_spriteDeleteQueueSize },
{ 0, &show2dsector[0], sizeof(uint8_t), MAXSECTORS>>3 }, { 0, &show2dsector[0], sizeof(uint8_t), MAXSECTORS>>3 },
{ DS_NOCHK, &g_numClouds, sizeof(g_numClouds), 1 }, { DS_NOCHK, &g_numClouds, sizeof(g_numClouds), 1 },
{ 0, &clouds[0], sizeof(clouds), 1 }, { 0, &clouds[0], sizeof(clouds), 1 },
@ -1543,7 +1549,7 @@ static uint8_t *svdiff;
#include "gamedef.h" #include "gamedef.h"
#define SV_SKIPMASK (GAMEVAR_SYSTEM|GAMEVAR_READONLY|GAMEVAR_INTPTR| \ #define SV_SKIPMASK (/*GAMEVAR_SYSTEM|*/GAMEVAR_READONLY|GAMEVAR_INTPTR| \
GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR /*|GAMEVAR_NORESET*/ |GAMEVAR_SPECIAL) GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR /*|GAMEVAR_NORESET*/ |GAMEVAR_SPECIAL)
// setup gamevar data spec for snapshotting and diffing... gamevars must be loaded when called // setup gamevar data spec for snapshotting and diffing... gamevars must be loaded when called
static void sv_makevarspec() static void sv_makevarspec()
@ -1811,6 +1817,7 @@ int32_t sv_readdiff(int32_t fil)
static void sv_postudload() static void sv_postudload()
{ {
Bmemcpy(&boardfilename[0], &currentboardfilename[0], BMAX_PATH); Bmemcpy(&boardfilename[0], &currentboardfilename[0], BMAX_PATH);
#if 0
ud.m_level_number = ud.level_number; ud.m_level_number = ud.level_number;
ud.m_volume_number = ud.volume_number; ud.m_volume_number = ud.volume_number;
ud.m_player_skill = ud.player_skill; ud.m_player_skill = ud.player_skill;
@ -1822,11 +1829,10 @@ static void sv_postudload()
ud.m_marker = ud.marker; ud.m_marker = ud.marker;
ud.m_ffire = ud.ffire; ud.m_ffire = ud.ffire;
ud.m_noexits = ud.noexits; ud.m_noexits = ud.noexits;
#endif
} }
//static int32_t lockclock_dummy; //static int32_t lockclock_dummy;
#if defined(POLYMOST) && defined(USE_OPENGL) #if defined(POLYMOST) && defined(USE_OPENGL)
static void sv_prespriteextsave() static void sv_prespriteextsave()
{ {
@ -1865,6 +1871,12 @@ static void sv_prescriptsave_once()
if (actorLoadEventScrptr[i]) if (actorLoadEventScrptr[i])
actorLoadEventScrptr[i] = (intptr_t *)(actorLoadEventScrptr[i]-&script[0]); actorLoadEventScrptr[i] = (intptr_t *)(actorLoadEventScrptr[i]-&script[0]);
} }
static void sv_prescriptload_once()
{
if (script)
Bfree(script);
script = Bmalloc(g_scriptSize * sizeof(script[0]));
}
static void sv_postscript_once() static void sv_postscript_once()
{ {
int32_t i; int32_t i;
@ -2107,7 +2119,7 @@ static int32_t doloadplayer2(int32_t spot, int32_t fil, uint8_t **memptr)
if (spot >= 0 && ud.multimode!=numplayers) if (spot >= 0 && ud.multimode!=numplayers)
return 2; return 2;
if (numplayers > 1) if (spot<0 || numplayers > 1)
{ {
if (LOADRDU(&tbuf, 19, 1)) return -3; if (LOADRDU(&tbuf, 19, 1)) return -3;
} }

View file

@ -117,7 +117,11 @@ int32_t MUSIC_Init(int32_t SoundCard, int32_t Address)
external_midi = (command != NULL && command[0] != 0); external_midi = (command != NULL && command[0] != 0);
if (external_midi) if (external_midi)
Mix_SetMusicCMD(command); {
initprintf("Setting music command to `%s'.\n", command);
if (Mix_SetMusicCMD(command)==-1)
perror("Mix_SetMusicCMD");
}
else else
{ {
char *s[] = { "/etc/timidity.cfg", "/etc/timidity/timidity.cfg", "/etc/timidity/freepats.cfg" }; char *s[] = { "/etc/timidity.cfg", "/etc/timidity/timidity.cfg", "/etc/timidity/freepats.cfg" };
@ -253,11 +257,30 @@ int32_t MUSIC_StopSong(void)
// void MUSIC_PlayMusic(char *_filename) // void MUSIC_PlayMusic(char *_filename)
int32_t MUSIC_PlaySong(char *song, int32_t loopflag) int32_t MUSIC_PlaySong(char *song, int32_t loopflag)
{ {
static char *tempfn = "/tmp/eduke32-music.mid";
FILE *fp;
MUSIC_StopSong(); MUSIC_StopSong();
music_musicchunk = Mix_LoadMUS_RW(SDL_RWFromMem((char *) song, g_musicSize));
if (external_midi)
{
fp = Bfopen(tempfn, "wb");
if (fp)
{
fwrite(song, 1, g_musicSize, fp);
Bfclose(fp);
music_musicchunk = Mix_LoadMUS(tempfn);
if (!music_musicchunk)
initprintf("Mix_LoadMUS: %s\n", Mix_GetError());
}
else initprintf("MUSIC_PlaySong: fopen: %s\n", strerror(errno));
}
else
music_musicchunk = Mix_LoadMUS_RW(SDL_RWFromMem((char *) song, g_musicSize));
if (music_musicchunk != NULL) if (music_musicchunk != NULL)
Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_LoopSong)?-1:0); if (Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_LoopSong)?-1:0) == -1)
initprintf("Mix_PlayMusic: %s\n", Mix_GetError());
return MUSIC_Ok; return MUSIC_Ok;
} }

View file

@ -329,7 +329,7 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel)
if (fp < 0) if (fp < 0)
{ {
OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open '%s' for playback!",fn); OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open '%s' for playback!\n",fn);
return 0; return 0;
} }