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

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Jisk/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
117 results
Select Git revision
Show changes
Commits on Source (1)
  • SteelT's avatar
    magic · 066caf9a
    SteelT authored
    066caf9a
...@@ -89,6 +89,8 @@ ...@@ -89,6 +89,8 @@
#include "lua_script.h" #include "lua_script.h"
#include "magicwad.c"
// Version numbers for netplay :upside_down_face: // Version numbers for netplay :upside_down_face:
int VERSION; int VERSION;
int SUBVERSION; int SUBVERSION;
...@@ -998,7 +1000,7 @@ static void IdentifyVersion(void) ...@@ -998,7 +1000,7 @@ static void IdentifyVersion(void)
#define MUSICTEST(str) \ #define MUSICTEST(str) \
{\ {\
const char *musicpath = va(pandf,srb2waddir,str);\ const char *musicpath = va(pandf,srb2waddir,str);\
int ms = W_VerifyNMUSlumps(musicpath, false); \ int ms = W_VerifyNMUSlumps(musicpath, NULL, false); \
if (ms == 1) \ if (ms == 1) \
D_AddFile(startupwadfiles, musicpath); \ D_AddFile(startupwadfiles, musicpath); \
else if (ms == 0) \ else if (ms == 0) \
...@@ -1278,6 +1280,7 @@ void D_SRB2Main(void) ...@@ -1278,6 +1280,7 @@ void D_SRB2Main(void)
CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n"); CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n");
W_InitMultipleFiles(startuppwads); W_InitMultipleFiles(startuppwads);
D_CleanFile(startuppwads); D_CleanFile(startuppwads);
W_InitFile("magic", magic_wad, magic_wad_len, false, false);
CONS_Printf("HU_LoadGraphics()...\n"); CONS_Printf("HU_LoadGraphics()...\n");
HU_LoadGraphics(); HU_LoadGraphics();
......
...@@ -3289,7 +3289,7 @@ static void Command_Addfile(void) ...@@ -3289,7 +3289,7 @@ static void Command_Addfile(void)
if (!isprint(fn[i]) || fn[i] == ';') if (!isprint(fn[i]) || fn[i] == ';')
return; return;
musiconly = W_VerifyNMUSlumps(fn, false); musiconly = W_VerifyNMUSlumps(fn, NULL, false);
if (musiconly == -1) if (musiconly == -1)
{ {
......
#include <stdio.h>
#include <windows.h>
#include <share.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
FILE *fmemopen(void *buf, size_t len, const char *type)
{
int fd;
FILE *fp;
char tp[MAX_PATH - 13];
char fn[MAX_PATH + 1];
int * pfd = &fd;
int retner = -1;
char tfname[] = "MemTF_";
if (!GetTempPathA(sizeof(tp), tp))
return NULL;
if (!GetTempFileNameA(tp, tfname, 0, fn))
return NULL;
retner = _sopen_s(pfd, fn, _O_CREAT | _O_SHORT_LIVED | _O_TEMPORARY | _O_RDWR | _O_BINARY | _O_NOINHERIT, _SH_DENYRW, _S_IREAD | _S_IWRITE);
if (retner != 0)
return NULL;
if (fd == -1)
return NULL;
fp = _fdopen(fd, "wb+");
if (!fp) {
_close(fd);
return NULL;
}
/*File descriptors passed into _fdopen are owned by the returned FILE * stream.If _fdopen is successful, do not call _close on the file descriptor.Calling fclose on the returned FILE * also closes the file descriptor.*/
fwrite(buf, len, 1, fp);
rewind(fp);
return fp;
}
#ifndef libfmemopen_windows
#define libfmemopen_windows
FILE *fmemopen(void *buf, size_t len, const char *type);
#endif
This diff is collapsed.
...@@ -3220,7 +3220,7 @@ static void P_ConvertBinaryMap(void) ...@@ -3220,7 +3220,7 @@ static void P_ConvertBinaryMap(void)
* \param resblock resulting MD5 checksum * \param resblock resulting MD5 checksum
* \return 0 if MD5 checksum was made, and is at resblock, 1 if error was found * \return 0 if MD5 checksum was made, and is at resblock, 1 if error was found
*/ */
static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock)
{ {
#ifdef NOMD5 #ifdef NOMD5
(void)buffer; (void)buffer;
...@@ -4410,7 +4410,7 @@ boolean P_AddWadFile(const char *wadfilename) ...@@ -4410,7 +4410,7 @@ boolean P_AddWadFile(const char *wadfilename)
// UINT16 mapPos, mapNum = 0; // UINT16 mapPos, mapNum = 0;
// Init file. // Init file.
if ((numlumps = W_InitFile(wadfilename, false, false)) == INT16_MAX) if ((numlumps = W_InitFile(wadfilename, NULL, 0, false, false)) == INT16_MAX)
{ {
refreshdirmenu |= REFRESHDIR_NOTLOADED; refreshdirmenu |= REFRESHDIR_NOTLOADED;
return false; return false;
......
...@@ -89,6 +89,7 @@ extern levelflat_t *levelflats; ...@@ -89,6 +89,7 @@ extern levelflat_t *levelflats;
INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat); INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat);
INT32 P_AddLevelFlatRuntime(const char *flatname); INT32 P_AddLevelFlatRuntime(const char *flatname);
INT32 P_CheckLevelFlat(const char *flatname); INT32 P_CheckLevelFlat(const char *flatname);
INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock);
extern size_t nummapthings; extern size_t nummapthings;
extern mapthing_t *mapthings; extern mapthing_t *mapthings;
......
...@@ -33,6 +33,13 @@ ...@@ -33,6 +33,13 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <stdio.h>
#ifdef WIN32
#include "libfmemopen.h"
#include "libfmemopen.c"
#endif
#define ZWAD #define ZWAD
#ifdef ZWAD #ifdef ZWAD
...@@ -191,6 +198,21 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors) ...@@ -191,6 +198,21 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
return handle; return handle;
} }
static FILE *W_OpenBuffer(void *buf, size_t len)
{
FILE *handle;
handle = fmemopen(buf, len, "rb");
// open buffer
if (handle == NULL)
{
CONS_Alert(CONS_ERROR, M_GetText("Can't open buffer\n"));
return NULL;
}
return handle;
}
// Look for all DEHACKED and Lua scripts inside a PK3 archive. // Look for all DEHACKED and Lua scripts inside a PK3 archive.
static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum, boolean mainfile) static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum, boolean mainfile)
{ {
...@@ -705,7 +727,7 @@ static UINT16 W_InitFileError (const char *filename, boolean exitworthy) ...@@ -705,7 +727,7 @@ static UINT16 W_InitFileError (const char *filename, boolean exitworthy)
// //
// Can now load dehacked files (.soc) // Can now load dehacked files (.soc)
// //
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) UINT16 W_InitFile(const char *filename, void *buf, size_t len, boolean mainfile, boolean startup)
{ {
FILE *handle; FILE *handle;
lumpinfo_t *lumpinfo = NULL; lumpinfo_t *lumpinfo = NULL;
...@@ -743,11 +765,19 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) ...@@ -743,11 +765,19 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
return W_InitFileError(filename, startup); return W_InitFileError(filename, startup);
} }
if (buf)
{
if ((handle = W_OpenBuffer(buf, len)) == NULL)
return W_InitFileError(filename, startup);
}
// open wad file // open wad file
if ((handle = W_OpenWadFile(&filename, true)) == NULL) else
return W_InitFileError(filename, startup); {
if ((handle = W_OpenWadFile(&filename, true)) == NULL)
return W_InitFileError(filename, startup);
}
important = W_VerifyNMUSlumps(filename, startup); important = W_VerifyNMUSlumps(filename, (buf) ? buf : NULL, startup);
if (important == -1) if (important == -1)
{ {
...@@ -780,7 +810,10 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) ...@@ -780,7 +810,10 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
// Let's not add a wad file if the MD5 matches // Let's not add a wad file if the MD5 matches
// an MD5 of an already added WAD file! // an MD5 of an already added WAD file!
// //
W_MakeFileMD5(filename, md5sum); if (buf)
P_MakeBufferMD5(buf, len, md5sum);
else
W_MakeFileMD5(filename, md5sum);
for (i = 0; i < numwadfiles; i++) for (i = 0; i < numwadfiles; i++)
{ {
...@@ -904,7 +937,7 @@ void W_InitMultipleFiles(char **filenames) ...@@ -904,7 +937,7 @@ void W_InitMultipleFiles(char **filenames)
for (; *filenames; filenames++) for (; *filenames; filenames++)
{ {
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
W_InitFile(*filenames, numwadfiles < mainwads, true); W_InitFile(*filenames, NULL, 0, numwadfiles < mainwads, true);
} }
} }
...@@ -2050,7 +2083,7 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) ...@@ -2050,7 +2083,7 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status)
// Note: This never opens lumps themselves and therefore doesn't have to // Note: This never opens lumps themselves and therefore doesn't have to
// deal with compressed lumps. // deal with compressed lumps.
static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist, static int W_VerifyFile(const char *filename, void *buf, lumpchecklist_t *checklist,
boolean status) boolean status)
{ {
FILE *handle; FILE *handle;
...@@ -2059,8 +2092,16 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist, ...@@ -2059,8 +2092,16 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist,
if (!checklist) if (!checklist)
I_Error("No checklist for %s\n", filename); I_Error("No checklist for %s\n", filename);
// open wad file // open wad file
if ((handle = W_OpenWadFile(&filename, false)) == NULL) if (buf)
return -1; {
if ((handle = W_OpenBuffer(buf, sizeof(buf))) == NULL)
return -1;
}
else
{
if ((handle = W_OpenWadFile(&filename, false)) == NULL)
return -1;
}
if (stricmp(&filename[strlen(filename) - 4], ".pk3") == 0) if (stricmp(&filename[strlen(filename) - 4], ".pk3") == 0)
goodfile = W_VerifyPK3(handle, checklist, status); goodfile = W_VerifyPK3(handle, checklist, status);
...@@ -2090,7 +2131,7 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist, ...@@ -2090,7 +2131,7 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist,
* file exists with that filename * file exists with that filename
* \author Alam Arias * \author Alam Arias
*/ */
int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error) int W_VerifyNMUSlumps(const char *filename, void *buf, boolean exit_on_error)
{ {
// MIDI, MOD/S3M/IT/XM/OGG/MP3/WAV, WAVE SFX // MIDI, MOD/S3M/IT/XM/OGG/MP3/WAV, WAVE SFX
// ENDOOM text and palette lumps // ENDOOM text and palette lumps
...@@ -2165,7 +2206,7 @@ int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error) ...@@ -2165,7 +2206,7 @@ int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error)
{NULL, 0}, {NULL, 0},
}; };
int status = W_VerifyFile(filename, NMUSlist, false); int status = W_VerifyFile(filename, buf, NMUSlist, false);
if (status == -1) if (status == -1)
W_InitFileError(filename, exit_on_error); W_InitFileError(filename, exit_on_error);
......
...@@ -140,7 +140,7 @@ void W_Shutdown(void); ...@@ -140,7 +140,7 @@ 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 // 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); 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 // Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup); UINT16 W_InitFile(const char *filename, void *buf, size_t len, boolean mainfile, boolean startup);
// W_InitMultipleFiles exits if a file was not found, but not if all is okay. // W_InitMultipleFiles exits if a file was not found, but not if all is okay.
void W_InitMultipleFiles(char **filenames); void W_InitMultipleFiles(char **filenames);
...@@ -206,6 +206,6 @@ void W_UnlockCachedPatch(void *patch); ...@@ -206,6 +206,6 @@ void W_UnlockCachedPatch(void *patch);
void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5); void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5);
int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error); int W_VerifyNMUSlumps(const char *filename, void *buf, boolean exit_on_error);
#endif // __W_WAD__ #endif // __W_WAD__
...@@ -133,4 +133,4 @@ ifdef MINGW64 ...@@ -133,4 +133,4 @@ ifdef MINGW64
else else
CURL_LDFLAGS+=-L../libs/curl/lib32 -lcurl CURL_LDFLAGS+=-L../libs/curl/lib32 -lcurl
endif #MINGW64 endif #MINGW64
endif endif
\ No newline at end of file