Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • MY-audio
  • abnormal-shutdown
  • ashnal-dev
  • awful-mix-fucked
  • benice
  • beta
  • beta-b
  • beta-c
  • better-replays
  • chadyes
  • downloads-notice
  • easy-colors
  • findvar
  • fixsignalhandler
  • fixsignalhandler-resurrection
  • freeplay
  • fuckinghell
  • hole
  • http-mserv-12
  • kill-these-please-12
  • kill-these-please-kart-v1-edition
  • less-battle-vote
  • load-shit
  • local-skins
  • lol
  • map-by-name
  • master
  • modern-talk-via-console
  • more-files
  • more-files-take2
  • move-changeviewpoint
  • ms-connectionfail-fix
  • mserv-is-dumb-and-what-else-is-new
  • music-standalone
  • netplayground
  • netreplays-dedicated-sigsegv-fix
  • netreplays-resetview-sigsegv-fix
  • opengl-gif-port
  • optional-focuslost
  • packetversion-112
  • perpetual-modifier-updates
  • public
  • talk-via-console
  • testsignalhandler
  • unconfuse-nodes
  • unpause-resume-sounds
  • V1.0.0
  • v1.0.1
  • v1.0.2
49 results

Target

Select target project
  • KartKrew/Kart-Public
  • SteelT/Kart-Public
  • SSNTails/Kart-Public
  • mazmazz_/Kart-Public
  • james/Kart-Public
  • Latius/Kart-Public
  • alphaRexJames/Kart-Public
  • heyjoeway/Kart-Public
  • Namolos/Kart-Public
  • SinnamonLat/Kart-Public
  • filpAM/Kart-Public
  • wolfy852/Kart-Public
  • bird/Kart-Public
  • TehRealSalt/Kart-Public
  • Snu/Kart-Public
  • Tyron/Kart-Public
  • kimmy/Kart-Public
  • Spice/Kart-Public
  • Callmore/Kart-Public
  • JugadorXEI/Kart-Public
  • Fafabis/Kart-Public
  • cspotcode/Kart-Public
  • Lonsfor_/Kart-Public
  • brokenspleentec/Kart-Public
  • minenice/Kart-Public
  • Lighto97/Kart-Public
  • X.organic/Kart-Public
  • Superjustinbros/srb2kart-custom-color-expansion
  • Galactice/Kart-Public
  • haya_/Kart-Public
  • QuantumToasted/Kart-Public
  • Indev/Kart-Public
  • chreas/kart-public-vr
  • alufolie91/Kart-Public2
  • Alam/Kart-Public
  • koi/Kart-Public
  • Alam/kart-public-vr
  • Hanicef/Kart-Public
  • hero0fnin/kart-public-batocera-edit
  • NepDisk/Kart-Public
  • Nep2Disk/Kart-Public
41 results
Select Git revision
  • alias-argh
  • better-bans
  • cap-splitscreen-fov
  • chat-flood-fix
  • cherrypicks-from-netreplays
  • clear-all-controls
  • color-def-fixes
  • color-flip
  • deployer-test
  • extra-travis-deploy
  • findfile-with-threads
  • fix-clang-compile
  • fix-damn-springs
  • fix-double-bombs
  • fix-fade-timeout
  • fix-nocurl
  • followme
  • fuckinghell
  • gamepad-tweaks
  • gitlab-ci_timeout
  • gl-framedrops
  • http-ms-rules
  • http-ms-startup-print
  • ignore-posthumous-ackret
  • itemodds-fallthrough-fix
  • join-passwords
  • latency-tweaks
  • majormods
  • make-bumpcode-perfecter
  • master
  • master-server-is-a-bad-name
  • merge-srb2
  • more-files
  • more-files-take2
  • ms-address-warning
  • mserv-fdset-bullshit
  • new_netreplays
  • next
  • no-turn-easing-v1
  • opengl-billboarding
  • opengl-maybe-uninitialised
  • opengl_match_software_wallclip
  • playerinfo_mscompat
  • prevent-permissions-footgun
  • revert-mserv
  • rr-item-cruncher
  • shrink-removed-checks
  • software-fov
  • sound_strikethrough
  • spb-blockmap-fix
  • spectator-little-things
  • spinout-changes
  • srb2-merge
  • test-many-mrs
  • thunder-fixes
  • uncapped-hud
  • uncapped-master
  • unfuck-gamepads
  • unfuck-icon-mac
  • version-prep
  • V1.0.0
  • v1.0.1
  • v1.0.2
  • v1.0.3
  • v1.0.4
  • v1.1
  • v1.2
  • v1.3
  • v1.4
  • v1.5
  • v1.6
71 results
Show changes
......@@ -1550,6 +1550,7 @@ static char music_name[7]; // up to 6-character name
static void *music_data;
static UINT16 music_flags;
static boolean music_looping;
static UINT32 music_position;/* for resuming */
static char queue_name[7];
static UINT16 queue_flags;
......@@ -1977,8 +1978,11 @@ static void S_ChangeMusicToQueue(void)
void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms)
{
char oldmusic[7];
char newmusic[7];
boolean resume;
#if defined (DC) || defined (_WIN32_WCE) || defined (PSP) || defined(GP2X)
S_ClearSfx();
#endif
......@@ -2014,6 +2018,39 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
}
else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET))
{
strcpy(oldmusic, music_name);
resume = false;
/* Set resume position for later, if we switch from map music. */
if (
strcasecmp(oldmusic, mapmusname) == 0 &&
strcasecmp(newmusic, mapmusname))
{
music_position = I_GetSongPosition();
}
/* Resume map music */
else if (
strcasecmp(oldmusic, mapmusname) &&
strcasecmp(newmusic, mapmusname) == 0)
{
if (
strcasecmp(oldmusic, "kinvnc") == 0)
{
fadeinms = cv_supermusicfadein.value;
}
else if (
strcasecmp(oldmusic, "kgrow") == 0)
{
fadeinms = cv_growmusicfadein.value;
}
else
fadeinms = cv_defaultmusicfadein.value;
if (cv_resumemusic.value)
resume = true;
}
CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic);
S_StopMusic();
......@@ -2033,8 +2070,13 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
return;
}
if (resume)
I_SetSongPosition(music_position);
else
{
if (position)
I_SetSongPosition(position);
}
I_SetSongTrack(mflags & MUSIC_TRACKMASK);
}
......@@ -2194,6 +2236,11 @@ void S_Start(void)
{
if (mapmusflags & MUSIC_RELOADRESET)
{
if (! cv_crossovermusic.value ||
strcasecmp(mapmusname, mapheaderinfo[gamemap-1]->musname))
{
music_position = 0;
}
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7);
mapmusname[6] = 0;
mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK);
......
......@@ -1907,7 +1907,7 @@ static void ST_overlayDrawer(void)
V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_ALLOWLOWERCASE, player_names[stplyr-players]);
}
}
else if (!demo.title)
else if (!demo.title && cv_showviewpoint.value)
{
if (!splitscreen)
......
......@@ -1380,6 +1380,151 @@ UINT8 *V_GetStringColormap(INT32 colorflags)
#endif
}
const char *V_ApproximateSkinColorCode(INT32 color)
{
const char *cstart;
cstart = "\x83";
switch (color)
{
case SKINCOLOR_WHITE:
case SKINCOLOR_SILVER:
case SKINCOLOR_SLATE:
cstart = "\x80"; // White
break;
case SKINCOLOR_GREY:
case SKINCOLOR_NICKEL:
case SKINCOLOR_BLACK:
case SKINCOLOR_SKUNK:
case SKINCOLOR_JET:
cstart = "\x86"; // V_GRAYMAP
break;
case SKINCOLOR_SEPIA:
case SKINCOLOR_BEIGE:
case SKINCOLOR_WALNUT:
case SKINCOLOR_BROWN:
case SKINCOLOR_LEATHER:
case SKINCOLOR_RUST:
case SKINCOLOR_WRISTWATCH:
cstart = "\x8e"; // V_BROWNMAP
break;
case SKINCOLOR_FAIRY:
case SKINCOLOR_SALMON:
case SKINCOLOR_PINK:
case SKINCOLOR_ROSE:
case SKINCOLOR_BRICK:
case SKINCOLOR_LEMONADE:
case SKINCOLOR_BUBBLEGUM:
case SKINCOLOR_LILAC:
cstart = "\x8d"; // V_PINKMAP
break;
case SKINCOLOR_CINNAMON:
case SKINCOLOR_RUBY:
case SKINCOLOR_RASPBERRY:
case SKINCOLOR_CHERRY:
case SKINCOLOR_RED:
case SKINCOLOR_CRIMSON:
case SKINCOLOR_MAROON:
case SKINCOLOR_FLAME:
case SKINCOLOR_SCARLET:
case SKINCOLOR_KETCHUP:
cstart = "\x85"; // V_REDMAP
break;
case SKINCOLOR_DAWN:
case SKINCOLOR_SUNSET:
case SKINCOLOR_CREAMSICLE:
case SKINCOLOR_ORANGE:
case SKINCOLOR_PUMPKIN:
case SKINCOLOR_ROSEWOOD:
case SKINCOLOR_BURGUNDY:
case SKINCOLOR_TANGERINE:
cstart = "\x87"; // V_ORANGEMAP
break;
case SKINCOLOR_PEACH:
case SKINCOLOR_CARAMEL:
case SKINCOLOR_CREAM:
cstart = "\x8f"; // V_PEACHMAP
break;
case SKINCOLOR_GOLD:
case SKINCOLOR_ROYAL:
case SKINCOLOR_BRONZE:
case SKINCOLOR_COPPER:
case SKINCOLOR_THUNDER:
cstart = "\x8A"; // V_GOLDMAP
break;
case SKINCOLOR_POPCORN:
case SKINCOLOR_QUARRY:
case SKINCOLOR_YELLOW:
case SKINCOLOR_MUSTARD:
case SKINCOLOR_CROCODILE:
case SKINCOLOR_OLIVE:
cstart = "\x82"; // V_YELLOWMAP
break;
case SKINCOLOR_ARTICHOKE:
case SKINCOLOR_VOMIT:
case SKINCOLOR_GARDEN:
case SKINCOLOR_TEA:
case SKINCOLOR_PISTACHIO:
cstart = "\x8b"; // V_TEAMAP
break;
case SKINCOLOR_LIME:
case SKINCOLOR_HANDHELD:
case SKINCOLOR_MOSS:
case SKINCOLOR_CAMOUFLAGE:
case SKINCOLOR_ROBOHOOD:
case SKINCOLOR_MINT:
case SKINCOLOR_GREEN:
case SKINCOLOR_PINETREE:
case SKINCOLOR_EMERALD:
case SKINCOLOR_SWAMP:
case SKINCOLOR_DREAM:
case SKINCOLOR_PLAGUE:
case SKINCOLOR_ALGAE:
cstart = "\x83"; // V_GREENMAP
break;
case SKINCOLOR_CARIBBEAN:
case SKINCOLOR_AZURE:
case SKINCOLOR_AQUA:
case SKINCOLOR_TEAL:
case SKINCOLOR_CYAN:
case SKINCOLOR_JAWZ:
case SKINCOLOR_CERULEAN:
case SKINCOLOR_NAVY:
case SKINCOLOR_SAPPHIRE:
cstart = "\x88"; // V_SKYMAP
break;
case SKINCOLOR_PIGEON:
case SKINCOLOR_PLATINUM:
case SKINCOLOR_STEEL:
cstart = "\x8c"; // V_STEELMAP
break;
case SKINCOLOR_PERIWINKLE:
case SKINCOLOR_BLUE:
case SKINCOLOR_BLUEBERRY:
case SKINCOLOR_NOVA:
cstart = "\x84"; // V_BLUEMAP
break;
case SKINCOLOR_ULTRAVIOLET:
case SKINCOLOR_PURPLE:
case SKINCOLOR_FUCHSIA:
cstart = "\x81"; // V_PURPLEMAP
break;
case SKINCOLOR_PASTEL:
case SKINCOLOR_MOONSLAM:
case SKINCOLOR_DUSK:
case SKINCOLOR_TOXIC:
case SKINCOLOR_MAUVE:
case SKINCOLOR_LAVENDER:
case SKINCOLOR_BYZANTIUM:
case SKINCOLOR_POMEGRANATE:
cstart = "\x89"; // V_LAVENDERMAP
break;
default:
break;
}
return cstart;
}
// Writes a single character (draw WHITE if bit 7 set)
//
void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed)
......
......@@ -168,6 +168,8 @@ void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed, UI
UINT8 *V_GetStringColormap(INT32 colorflags);
const char *V_ApproximateSkinColorCode(INT32 skincolor);
void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string);
// wordwrap a string using the hu_font
......
......@@ -107,7 +107,20 @@ static UINT16 lumpnumcacheindex = 0;
// GLOBALS
//===========================================================================
UINT16 numwadfiles = 0; // number of active wadfiles
wadfile_t *wadfiles[MAX_WADFILES]; // 0 to numwadfiles-1 are valid
wadfile_t *wadfiles[TOTAL_WADFILES]; // 0 to numwadfiles-1 are valid
static void
FreeWAD (wadfile_t *wad)
{
if (wad->handle)
fclose(wad->handle);
if (wad->filename)
Z_Free(wad->filename);
while (wad->numlumps--)
Z_Free(wad->lumpinfo[wad->numlumps].name2);
Z_Free(wad->lumpinfo);
Z_Free(wad);
}
// W_Shutdown
// Closes all of the WAD files before quitting
......@@ -116,14 +129,11 @@ wadfile_t *wadfiles[MAX_WADFILES]; // 0 to numwadfiles-1 are valid
// being ejected
void W_Shutdown(void)
{
if (wadfiles[WAD_MUSIC])
FreeWAD(wadfiles[WAD_MUSIC]);
while (numwadfiles--)
{
fclose(wadfiles[numwadfiles]->handle);
Z_Free(wadfiles[numwadfiles]->filename);
while (wadfiles[numwadfiles]->numlumps--)
Z_Free(wadfiles[numwadfiles]->lumpinfo[wadfiles[numwadfiles]->numlumps].name2);
Z_Free(wadfiles[numwadfiles]->lumpinfo);
Z_Free(wadfiles[numwadfiles]);
FreeWAD(wadfiles[numwadfiles]);
}
}
......@@ -315,40 +325,179 @@ static void W_InvalidateLumpnumCache(void)
memset(lumpnumcache, 0, sizeof (lumpnumcache));
}
static int
ExtCheck (
const char *filename, int filename_length,
const char *ext, int ext_length)
{
int n;
n = filename_length - ( ext_length + 1 );/* include . */
if (n > 0)
{
if (filename[n] == '.')
return ( strcmp(&filename[n + 1], ext) == 0 );
}
return 0;
}
/** Detect a file type.
* \todo Actually detect the wad/pkzip headers and whatnot, instead of just checking the extensions.
*/
static restype_t ResourceFileDetect (const char* filename)
{
if (!stricmp(&filename[strlen(filename) - 4], ".pk3"))
int n;
n = strlen(filename);
#define X( name ) ExtCheck(filename, n, name, sizeof name - 1)
if (X ("wad") || X ("srb") || X ("kart"))
return RET_WAD;
if (X ("pk3"))
return RET_PK3;
if (!stricmp(&filename[strlen(filename) - 4], ".soc"))
if (X ("soc"))
return RET_SOC;
if (!stricmp(&filename[strlen(filename) - 4], ".lua"))
if (X ("lua"))
return RET_LUA;
return RET_WAD;
#undef X
return RET_UNKNOWN;
}
/** Create a 1-lump lumpinfo_t for standalone files.
*/
static lumpinfo_t* ResGetLumpsStandalone (FILE* handle, UINT16* numlumps, const char* lumpname)
static void
GetFileLump (lumpinfo_t *lumpinfo, FILE *handle)
{
lumpinfo_t* lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
lumpinfo->position = 0;
fseek(handle, 0, SEEK_END);
lumpinfo->size = ftell(handle);
fseek(handle, 0, SEEK_SET);
strcpy(lumpinfo->name, lumpname);
// Allocate the lump's full name.
lumpinfo->name2 = Z_Malloc(9 * sizeof(char), PU_STATIC, NULL);
strcpy(lumpinfo->name2, lumpname);
lumpinfo->name2[8] = '\0';
}
/** Create a 1-lump lumpinfo_t for standalone files.
*/
static lumpinfo_t* ResGetLumpsStandalone (FILE* handle, UINT16* numlumps, const char* lumpname)
{
lumpinfo_t* lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
GetFileLump(lumpinfo, handle);
strlcpy(lumpinfo->name, lumpname, 9);
lumpinfo->name2 = Z_StrDup(lumpname);
*numlumps = 1;
return lumpinfo;
}
static lumpinfo_t *
ResGetLumpsSpecial (FILE *fp, UINT16 *lumpcp, const char *filename, const char *musicname)
{
char meme[9];
wadfile_t *wad;
int lump;
lumpinfo_t *lumpinfo;
lumpinfo_t *p;
int n;
int i;
char *t;
/* Compose music lump name */
if (! musicname)
{
nameonly(( t = va("%s", filename) ));
musicname = t;
if (( t = strrchr(t, '.') ))
*t = 0;
}
snprintf(meme, 9, "O_%s", musicname);
strupr(meme);
p = 0;
if (( wad = wadfiles[WAD_MUSIC] ))
{
fclose(wad->handle);
if (( lump = W_CheckNumForNamePwad(meme,
WAD_MUSIC, 0) ) != INT16_MAX)
{
p = &wad->lumpinfo[lump];
wad->filesize -= p->size;/* remove from total too */
}
}
else
{
wad = Z_Malloc(sizeof *wad, PU_STATIC, &wadfiles[WAD_MUSIC]);
wad->filename = 0;
wad->numlumps = 0;
wad->lumpinfo = 0;
wad->filesize = 0;
wad->type = RET_UNKNOWN;
wad->handlelump = -1;
wad->lumpcache = 0;
}
/* We need to add another lump */
if (p)
{
lumpinfo = wad->lumpinfo;
Z_Free(p->name2);
/* Remove old cache, if any */
Z_Free(wad->lumpcache[lump]);
wad->lumpcache[lump] = 0;
}
else
{
lump = wad->numlumps++;
lumpinfo = Z_Realloc(wad->lumpinfo,
wad->numlumps * sizeof *lumpinfo, PU_STATIC, &wad->lumpinfo);
p = &lumpinfo[lump];
memset(p, 0, sizeof *p);
strcpy(p->name, meme);
/* Free cached lumps... */
if (wad->lumpcache)
{
for (i = 0; i < lump; ++i)
Z_Free(wad->lumpcache[i]);
}
n = wad->numlumps * sizeof *wad->lumpcache;
Z_Realloc(wad->lumpcache, n, PU_STATIC, &wad->lumpcache);
memset(wad->lumpcache, 0, n);
}
wad->handle = fp;
wad->handlelump = lump;
p->name2 = Z_StrDup(filename);
GetFileLump(p, fp);
wad->filesize += p->size;
(*lumpcp) = wad->numlumps;
/*
SPECIAL CASE
What if this music is already playing? Then we
may have a problem, if the cache is used again...
So just use the new music instead.
*/
if (strncasecmp(S_MusicName(), musicname, 6) == 0)
{
S_ChangeMusicEx(musicname,
mapmusflags|MUSIC_FORCERESET, true, mapmusposition, 0, 0);
}
return lumpinfo;
}
/** Create a lumpinfo_t array for a WAD file.
*/
static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filename)
......@@ -644,7 +793,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
//
// Can now load dehacked files (.soc)
//
UINT16 W_InitFile(const char *filename)
UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump)
{
FILE *handle;
lumpinfo_t *lumpinfo = NULL;
......@@ -668,6 +817,19 @@ UINT16 W_InitFile(const char *filename)
else
refreshdirname = NULL;
type = ResourceFileDetect(filename);
if (type != RET_UNKNOWN)
{
/* Trying to circumvent netplay are you? */
if (lumpname)
{
CONS_Alert(CONS_NOTICE,
"You cannot add normal WAD files using this method.\n");
refreshdirmenu |= REFRESHDIR_MAX;
return INT16_MAX;
}
//CONS_Debug(DBG_SETUP, "Loading %s\n", filename);
//
// check if limit of active wadfiles
......@@ -678,11 +840,14 @@ UINT16 W_InitFile(const char *filename)
refreshdirmenu |= REFRESHDIR_MAX;
return INT16_MAX;
}
}
// open wad file
if ((handle = W_OpenWadFile(&filename, true)) == NULL)
return INT16_MAX;
if (type != RET_UNKNOWN)
{
important = !W_VerifyNMUSlumps(filename);
#ifndef NOMD5
......@@ -704,8 +869,9 @@ UINT16 W_InitFile(const char *filename)
}
}
#endif
}
switch(type = ResourceFileDetect(filename))
switch(type)
{
case RET_SOC:
lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "OBJCTCFG");
......@@ -722,9 +888,13 @@ UINT16 W_InitFile(const char *filename)
lumpinfo = ResGetLumpsWad(handle, &numlumps, filename);
break;
default:
CONS_Alert(CONS_ERROR, "Unsupported file format\n");
lumpinfo = ResGetLumpsSpecial(handle, &numlumps, filename, lumpname);
}
if (type == RET_UNKNOWN)
wadfile = wadfiles[WAD_MUSIC];
else
{
if (lumpinfo == NULL)
{
fclose(handle);
......@@ -756,12 +926,22 @@ UINT16 W_InitFile(const char *filename)
// allocates GLPatch info structures and store them in a tree
wadfile->hwrcache = M_AATreeAlloc(AATREE_ZUSER);
#endif
}
//
// add the wadfile
//
CONS_Printf(M_GetText("Added file %s (%u lumps)\n"), filename, numlumps);
if (type == RET_UNKNOWN)
{
if (wadnump)
(*wadnump) = WAD_MUSIC;
}
else
{
wadfiles[numwadfiles] = wadfile;
if (wadnump)
(*wadnump) = numwadfiles;
numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded
// TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now.
......@@ -785,6 +965,7 @@ UINT16 W_InitFile(const char *filename)
default:
break;
}
}
if (refreshdirmenu & REFRESHDIR_GAMEDATA)
G_LoadGameData();
......@@ -837,18 +1018,18 @@ void W_UnloadWadFile(UINT16 num)
* \return 1 if all files were loaded, 0 if at least one was missing or
* invalid.
*/
INT32 W_InitMultipleFiles(char **filenames, boolean addons)
INT32 W_InitMultipleFiles(char *(*filenames)[2], boolean addons)
{
INT32 rc = 1;
// will be realloced as lumps are added
for (; *filenames; filenames++)
for (; (*filenames)[0]; filenames++)
{
if (addons && !W_VerifyNMUSlumps(*filenames))
if (addons && !W_VerifyNMUSlumps((*filenames)[0]))
G_SetGameModified(true, false);
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
rc &= (W_InitFile(*filenames) != INT16_MAX) ? 1 : 0;
rc &= (W_InitFile((*filenames)[0], (*filenames)[1], 0) != INT16_MAX) ? 1 : 0;
}
if (!numwadfiles)
......@@ -991,6 +1172,14 @@ lumpnum_t W_CheckNumForName(const char *name)
}
}
if (strncasecmp(name, "O_", 2) == 0)
{
i = WAD_MUSIC;
check = W_CheckNumForNamePwad(name,i,0);
}
if (check == INT16_MAX)
{
// scan wad files backwards so patch lump files take precedence
for (i = numwadfiles - 1; i >= 0; i--)
{
......@@ -998,6 +1187,7 @@ lumpnum_t W_CheckNumForName(const char *name)
if (check != INT16_MAX)
break; //found it
}
}
if (check == INT16_MAX) return LUMPERROR;
else
......@@ -1091,14 +1281,26 @@ lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, con
// Used by Lua. Case sensitive lump checking, quickly...
#include "fastcmp.h"
static boolean
FindLump (const char *name, int wad)
{
INT32 j;
for (j = 0; j < wadfiles[wad]->numlumps; ++j)
if (fastcmp(wadfiles[wad]->lumpinfo[j].name,name))
return true;
return false;
}
UINT8 W_LumpExists(const char *name)
{
INT32 i,j;
INT32 i;
if (wadfiles[WAD_MUSIC])
{
if (FindLump(name, WAD_MUSIC))
return true;
}
for (i = numwadfiles - 1; i >= 0; i--)
{
lumpinfo_t *lump_p = wadfiles[i]->lumpinfo;
for (j = 0; j < wadfiles[i]->numlumps; ++j, ++lump_p)
if (fastcmp(lump_p->name,name))
if (FindLump(name, i))
return true;
}
return false;
......@@ -1215,6 +1417,17 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
// Let's get the raw lump data.
// We setup the desired file handle to read the lump data.
l = wadfiles[wad]->lumpinfo + lump;
if (wadfiles[wad]->type == RET_UNKNOWN && wadfiles[wad]->handlelump != lump)
{
if (wadfiles[wad]->handle)
fclose(wadfiles[wad]->handle);
if (!( wadfiles[wad]->handle = fopen(l->name2, "rb") ))
{
CONS_Alert(CONS_ERROR, "oops %s: %s\n", l->name2, strerror(errno));
return 0;
}
wadfiles[wad]->handlelump = lump;
}
handle = wadfiles[wad]->handle;
fseek(handle, (long)(l->position + offset), SEEK_SET);
......@@ -1612,24 +1825,21 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist,
FILE *handle;
size_t i, j;
int goodfile = false;
int type;
if (!checklist)
I_Error("No checklist for %s\n", filename);
// open wad file
if ((handle = W_OpenWadFile(&filename, false)) == NULL)
return -1;
// detect wad file by the absence of the other supported extensions
if (stricmp(&filename[strlen(filename) - 4], ".soc")
#ifdef HAVE_BLUA
&& stricmp(&filename[strlen(filename) - 4], ".lua")
#endif
&& stricmp(&filename[strlen(filename) - 4], ".pk3"))
type = ResourceFileDetect(filename);
if (type == RET_WAD)
{
// assume wad file
wadinfo_t header;
filelump_t lumpinfo;
// open wad file
if ((handle = W_OpenWadFile(&filename, false)) == NULL)
return -1;
// read the header
if (fread(&header, 1, sizeof header, handle) == sizeof header
&& header.numlumps < INT16_MAX
......@@ -1680,8 +1890,12 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist,
if (!goodfile)
break;
}
}
fclose(handle);
}
else if (type == RET_UNKNOWN)
goodfile = true;
return goodfile;
}
......
......@@ -108,16 +108,24 @@ typedef struct wadfile_s
#endif
UINT16 numlumps; // this wad's number of resources
FILE *handle;
int handlelump;/* special WADs don't open EVERY file--only one */
UINT32 filesize; // for network
UINT8 md5sum[16];
boolean important;
} wadfile_t;
enum
{
WAD_MUSIC = MAX_WADFILES,
TOTAL_WADFILES
};
#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word
#define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad
extern UINT16 numwadfiles;
extern wadfile_t *wadfiles[MAX_WADFILES];
extern wadfile_t *wadfiles[TOTAL_WADFILES];
// =========================================================================
......@@ -126,14 +134,14 @@ void W_Shutdown(void);
// Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened
FILE *W_OpenWadFile(const char **filename, boolean useerrors);
// Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
UINT16 W_InitFile(const char *filename);
UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump);
#ifdef DELFILE
void W_UnloadWadFile(UINT16 num);
#endif
// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise,
// so that it stops with a message if a file was not found, but not if all is okay.
INT32 W_InitMultipleFiles(char **filenames, boolean addons);
INT32 W_InitMultipleFiles(char *(*filenames)[2], boolean addons);
const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump);
const char *W_CheckNameForNum(lumpnum_t lumpnum);
......