SVN r46 (trunk)

This commit is contained in:
Christoph Oelckers 2006-04-15 15:00:29 +00:00
parent 153d3b4681
commit 8a7ba616f4
15 changed files with 2001 additions and 86 deletions

View file

@ -1,12 +1,20 @@
April 15, 2006 (Changes by Graf Zahl)
- Extended Makewad so it can write Zip files in addition to WAD files.
April 14, 2006 (Changes by Graf Zahl)
- Moved SC_CheckFloat into sc_man.cpp.
- Fixed several issues with the DECORATE parser:
* Floating point parameters couldn't be parsed correctly
* Some code pointers used parameters incorrectly.
* Parameters with default value 1 didn't work as expected
- Added GZDoom's HI_START/HI_END lump namespace. Even though it doesn't do
anything (yet) suppporting it allows to make WADs that use hires texture
replacements but are able to run with ZDoom as well.
- Added GZDoom's Zip-support but changed it so that lumps are sorted
alphabetically.
- Added the missing file 'flac/private/float.h' to the repository.
- Added: In preparation for Zip-support the sound code has to be able to
load music data from memory, not just from files.
- Added: For Zip-support the sound code has to be able to load music data
from memory, not just from files.
- Re-added I_SetMusicVolume to optionally reduce the music volume in Strife
conversations.
- Fixed: The total game time must not be restored when loading a snapshot

View file

@ -1966,7 +1966,9 @@ void D_DoomMain (void)
C_ExecCmdLineParams (); // [RH] do all +set commands on the command line
DArgs *files = Args.GatherFiles ("-file", ".wad", true);
if (files->NumArgs() > 0)
DArgs *files1 = Args.GatherFiles (NULL, ".zip", false);
DArgs *files2 = Args.GatherFiles (NULL, ".pk3", false);
if (files->NumArgs() > 0 || files1->NumArgs() > 0 || files2->NumArgs() > 0)
{
// Check for -file in shareware
if (gameinfo.flags & GI_SHAREWARE)
@ -1979,8 +1981,18 @@ void D_DoomMain (void)
{
D_AddWildFile (files->GetArg (i));
}
for (int i = 0; i < files1->NumArgs(); i++)
{
D_AddWildFile (files1->GetArg (i));
}
for (int i = 0; i < files2->NumArgs(); i++)
{
D_AddWildFile (files2->GetArg (i));
}
}
delete files;
delete files1;
delete files2;
Wads.InitMultipleFiles (&wadfiles);

View file

@ -550,6 +550,35 @@ BOOL SC_CheckNumber (void)
}
}
//==========================================================================
//
// SC_CheckFloat
// [GRB] Same as SC_CheckNumber, only for floats
//
//==========================================================================
BOOL SC_CheckFloat (void)
{
char *stopper;
//CheckOpen ();
if (SC_GetString())
{
sc_Float = strtod (sc_String, &stopper);
if (*stopper != 0)
{
SC_UnGet();
return false;
}
return true;
}
else
{
return false;
}
}
//==========================================================================
//
// SC_GetFloat

View file

@ -17,6 +17,7 @@ bool SC_CheckString (const char *name);
BOOL SC_GetNumber (void);
void SC_MustGetNumber (void);
BOOL SC_CheckNumber (void);
BOOL SC_CheckFloat (void);
BOOL SC_GetFloat (void);
void SC_MustGetFloat (void);
void SC_UnGet (void);

View file

@ -65,6 +65,7 @@
#include "a_hexenglobal.h"
#include "a_weaponpiece.h"
#include "p_conversation.h"
#include "thingdef.h"
@ -637,7 +638,7 @@ AFuncDesc AFTable[]=
FUNC(A_Jump, "XL" )
FUNC(A_CustomMissile, "MXXxxx" )
FUNC(A_CustomBulletAttack, "XXXXmx" )
FUNC(A_CustomRailgun, "Xxccyyx" )
FUNC(A_CustomRailgun, "Xxccxxx" )
FUNC(A_JumpIfHealthLower, "XL" )
FUNC(A_JumpIfCloser, "XL" )
FUNC(A_JumpIfInventory, "MXL" )
@ -667,7 +668,7 @@ AFuncDesc AFTable[]=
FUNC(A_CustomPunch, "Xxymx" )
FUNC(A_FireBullets, "XXXXmyx" )
FUNC(A_FireCustomMissile, "Mxyxx" )
FUNC(A_RailAttack, "Xxyccyx" )
FUNC(A_RailAttack, "Xxyccxx" )
FUNC(A_Recoil, "X")
FUNC(A_JumpIfInTargetInventory, "MXL" )
FUNC(A_GiveToTarget, "Mx" )
@ -1050,41 +1051,6 @@ typedef ActorProps (*ActorPropHandler) (register const char *str, register unsig
static const ActorProps *is_actorprop (const char *str);
int ParseExpression (bool _not)
{
SC_MustGetNumber();
return _not? !sc_Number : sc_Number;
}
//==========================================================================
//
// SC_CheckFloat
// [GRB] Same as SC_CheckNumber, only for floats
//
//==========================================================================
BOOL SC_CheckFloat (void)
{
char *stopper;
//CheckOpen ();
if (SC_GetString())
{
sc_Float = strtod (sc_String, &stopper);
if (*stopper != 0)
{
SC_UnGet();
return false;
}
return true;
}
else
{
return false;
}
}
//==========================================================================
//
// Some functions which check for simple tokens

10
src/thingdef.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef __THINGDEF_H
#define __THINGDEF_H
int ParseExpression (bool _not);
int EvalExpressionI (int id, AActor *self);
float EvalExpressionF (int id, AActor *self);
bool EvalExpressionN (int id, AActor *self);
#endif

View file

@ -63,6 +63,7 @@
#include "vectors.h"
#include "a_sharedglobal.h"
#include "a_doomglobal.h"
#include "thingdef.h"
static FRandom pr_camissile ("CustomActorfire");
@ -78,10 +79,6 @@ static FRandom pr_spawndebris ("SpawnDebris");
static FRandom pr_jiggle ("Jiggle");
int EvalExpressionI (int id, AActor *self) { return id; }
float EvalExpressionF (int id, AActor *self) { return id; }
// A truly awful hack to get to the state that called an action function
// without knowing whether it has been called from a weapon or actor.
FState * CallingState;
@ -694,7 +691,7 @@ void A_FireBullets (AActor *self)
int NumberOfBullets=EvalExpressionI (StateParameters[index+2], self);
int DamagePerBullet=EvalExpressionI (StateParameters[index+3], self);
const char * PuffTypeName=(const char *)StateParameters[index+4];
bool UseNoAmmo=!EvalExpressionI (StateParameters[index+5], self);
bool UseAmmo=EvalExpressionN (StateParameters[index+5], self);
fixed_t Range=fixed_t(EvalExpressionF (StateParameters[index+6], self) * FRACUNIT);
const TypeInfo * PuffType;
@ -706,7 +703,7 @@ void A_FireBullets (AActor *self)
int bangle;
int bslope;
if (!UseNoAmmo && weapon)
if (UseAmmo && weapon)
{
if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo
}
@ -755,14 +752,14 @@ void A_FireCustomMissile (AActor * self)
const char * MissileName=(const char *)StateParameters[index];
angle_t Angle=angle_t(EvalExpressionF (StateParameters[index+1], self) * ANGLE_1);
bool UseNoAmmo=!EvalExpressionI (StateParameters[index+2], self);
bool UseAmmo=EvalExpressionN (StateParameters[index+2], self);
int SpawnOfs_XY=EvalExpressionI (StateParameters[index+3], self);
fixed_t SpawnHeight=fixed_t(EvalExpressionF (StateParameters[index+4], self) * FRACUNIT);
player_t *player=self->player;
AWeapon * weapon=player->ReadyWeapon;
if (!UseNoAmmo && weapon)
if (UseAmmo && weapon)
{
if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo
}
@ -807,7 +804,7 @@ void A_CustomPunch (AActor *self)
int Damage=EvalExpressionI (StateParameters[index], self);
bool norandom=!!EvalExpressionI (StateParameters[index+1], self);
bool UseNoAmmo=!EvalExpressionI (StateParameters[index+2], self);
bool UseAmmo=EvalExpressionN (StateParameters[index+2], self);
const char * PuffTypeName=(const char *)StateParameters[index+3];
fixed_t Range=fixed_t(EvalExpressionF (StateParameters[index+4], self) * FRACUNIT);
@ -827,7 +824,7 @@ void A_CustomPunch (AActor *self)
pitch = P_AimLineAttack (self, angle, MELEERANGE);
// only use ammo when actually hitting something!
if (!UseNoAmmo && linetarget && weapon)
if (UseAmmo && linetarget && weapon)
{
if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo
}
@ -863,16 +860,16 @@ void A_RailAttack (AActor * self)
int Damage=EvalExpressionI (StateParameters[index], self);
int Spawnofs_XY=EvalExpressionI (StateParameters[index+1], self);
bool UseNoAmmo=!EvalExpressionI (StateParameters[index+2], self);
bool UseAmmo=EvalExpressionN (StateParameters[index+2], self);
int Color1=StateParameters[index+3];
int Color2=StateParameters[index+4];
bool Silent=!EvalExpressionI (StateParameters[index+5], self);
bool Silent=!!EvalExpressionI (StateParameters[index+5], self);
float MaxDiff=EvalExpressionF (StateParameters[index+6], self);
AWeapon * weapon=self->player->ReadyWeapon;
// only use ammo when actually hitting something!
if (!UseNoAmmo)
if (UseAmmo)
{
if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo
}
@ -905,8 +902,8 @@ void A_CustomRailgun (AActor *actor)
int Spawnofs_XY=EvalExpressionI (StateParameters[index+1], actor);
int Color1=StateParameters[index+2];
int Color2=StateParameters[index+3];
bool Silent=!EvalExpressionI (StateParameters[index+4], actor);
bool aim=!EvalExpressionI (StateParameters[index+5], actor);
bool Silent=!!EvalExpressionI (StateParameters[index+4], actor);
bool aim=!!EvalExpressionI (StateParameters[index+5], actor);
float MaxDiff=EvalExpressionF (StateParameters[index+6], actor);
// [RH] Andy Baker's stealth monsters
@ -1064,7 +1061,7 @@ void A_SpawnItem(AActor * self)
const TypeInfo * missile= TypeInfo::FindType((const char *)StateParameters[index]);
int distance = EvalExpressionI (StateParameters[index+1], self);
fixed_t zheight = fixed_t(EvalExpressionF (StateParameters[index+2], self) * FRACUNIT);
bool useammo = !EvalExpressionI (StateParameters[index+3], self);
bool useammo = EvalExpressionN (StateParameters[index+3], self);
if (!missile)
{
@ -1162,7 +1159,7 @@ void A_ThrowGrenade(AActor * self)
fixed_t zheight = fixed_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT);
fixed_t xymom = fixed_t(EvalExpressionF (StateParameters[index+2], self) * FRACUNIT);
fixed_t zmom = fixed_t(EvalExpressionF (StateParameters[index+3], self) * FRACUNIT);
bool useammo = !EvalExpressionI (StateParameters[index+4], self);
bool useammo = EvalExpressionN (StateParameters[index+4], self);
if (self->player && CallingState != self->state && CallingState != StateCall.State)
{
@ -1394,7 +1391,7 @@ void A_ExtChase(AActor * self)
A_DoChase(self, false,
EvalExpressionI (StateParameters[index], self) ? self->MeleeState:NULL,
EvalExpressionI (StateParameters[index+1], self) ? self->MissileState:NULL,
!EvalExpressionI (StateParameters[index+2], self),
EvalExpressionN (StateParameters[index+2], self),
!!EvalExpressionI (StateParameters[index+3], self));
}

31
src/thingdef_exp.cpp Normal file
View file

@ -0,0 +1,31 @@
#include "sc_man.h"
// A stub to simulate the interface of .96x's expression evaluator.
int ParseExpression (bool _not)
{
SC_MustGetFloat();
if (_not)
{
if (sc_Float==0.f) sc_Float=1.f;
else sc_Float=0.f;
}
return (int)(fixed_t)(sc_Float * FRACUNIT);
}
int EvalExpressionI (int id, AActor *self)
{
return id>>FRACBITS;
}
bool EvalExpressionN(int id, AActor * self)
{
return !EvalExpressionI(id, self);
}
float EvalExpressionF (int id, AActor *self)
{
return (float)id/FRACUNIT;
}

177
tools/makewad/ioapi.c Normal file
View file

@ -0,0 +1,177 @@
/* ioapi.c -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../../zlib/zlib.h"
#include "ioapi.h"
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
voidpf ZCALLBACK fopen_file_func OF((
voidpf opaque,
const char* filename,
int mode));
uLong ZCALLBACK fread_file_func OF((
voidpf opaque,
voidpf stream,
void* buf,
uLong size));
uLong ZCALLBACK fwrite_file_func OF((
voidpf opaque,
voidpf stream,
const void* buf,
uLong size));
long ZCALLBACK ftell_file_func OF((
voidpf opaque,
voidpf stream));
long ZCALLBACK fseek_file_func OF((
voidpf opaque,
voidpf stream,
uLong offset,
int origin));
int ZCALLBACK fclose_file_func OF((
voidpf opaque,
voidpf stream));
int ZCALLBACK ferror_file_func OF((
voidpf opaque,
voidpf stream));
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
voidpf opaque;
const char* filename;
int mode;
{
FILE* file = NULL;
const char* mode_fopen = NULL;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
mode_fopen = "rb";
else
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
mode_fopen = "r+b";
else
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
mode_fopen = "wb";
if ((filename!=NULL) && (mode_fopen != NULL))
file = fopen(filename, mode_fopen);
return file;
}
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
void* buf;
uLong size;
{
uLong ret;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}
uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
const void* buf;
uLong size;
{
uLong ret;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}
long ZCALLBACK ftell_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
long ret;
ret = ftell((FILE *)stream);
return ret;
}
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
voidpf opaque;
voidpf stream;
uLong offset;
int origin;
{
int fseek_origin=0;
long ret;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
fseek_origin = SEEK_CUR;
break;
case ZLIB_FILEFUNC_SEEK_END :
fseek_origin = SEEK_END;
break;
case ZLIB_FILEFUNC_SEEK_SET :
fseek_origin = SEEK_SET;
break;
default: return -1;
}
ret = 0;
fseek((FILE *)stream, offset, fseek_origin);
return ret;
}
int ZCALLBACK fclose_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
int ret;
ret = fclose((FILE *)stream);
return ret;
}
int ZCALLBACK ferror_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
int ret;
ret = ferror((FILE *)stream);
return ret;
}
void fill_fopen_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def;
{
pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
pzlib_filefunc_def->ztell_file = ftell_file_func;
pzlib_filefunc_def->zseek_file = fseek_file_func;
pzlib_filefunc_def->zclose_file = fclose_file_func;
pzlib_filefunc_def->zerror_file = ferror_file_func;
pzlib_filefunc_def->opaque = NULL;
}

75
tools/makewad/ioapi.h Normal file
View file

@ -0,0 +1,75 @@
/* ioapi.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
*/
#ifndef _ZLIBIOAPI_H
#define _ZLIBIOAPI_H
#define ZLIB_FILEFUNC_SEEK_CUR (1)
#define ZLIB_FILEFUNC_SEEK_END (2)
#define ZLIB_FILEFUNC_SEEK_SET (0)
#define ZLIB_FILEFUNC_MODE_READ (1)
#define ZLIB_FILEFUNC_MODE_WRITE (2)
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
#define ZLIB_FILEFUNC_MODE_CREATE (8)
#ifndef ZCALLBACK
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
#define ZCALLBACK CALLBACK
#else
#define ZCALLBACK
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
typedef struct zlib_filefunc_def_s
{
open_file_func zopen_file;
read_file_func zread_file;
write_file_func zwrite_file;
tell_file_func ztell_file;
seek_file_func zseek_file;
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc_def;
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
#ifdef __cplusplus
}
#endif
#endif

View file

@ -7,6 +7,9 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <time.h>
#include "zip.h"
#define MAX_LUMPS 4096
@ -64,8 +67,84 @@ int appendlump (FILE *wadfile, char *filename)
return ret;
}
int appendtozip (zipFile zipfile, const char * zipname, const char *filename)
{
char *readbuf;
FILE *lumpfile;
size_t readlen;
int ret = 0;
size_t len;
zip_fileinfo zip_inf;
time_t currenttime;
tm * ltime;
time(&currenttime);
ltime = localtime(&currenttime);
memset(&zip_inf, 0, sizeof(zip_inf));
if (ltime != NULL)
{
zip_inf.tmz_date.tm_sec = ltime->tm_sec;
zip_inf.tmz_date.tm_min = ltime->tm_min;
zip_inf.tmz_date.tm_hour = ltime->tm_hour;
zip_inf.tmz_date.tm_mday = ltime->tm_mday;
zip_inf.tmz_date.tm_mon = ltime->tm_mon;
zip_inf.tmz_date.tm_year = ltime->tm_year;
}
lumpfile = fopen (filename, "rb");
if (lumpfile == NULL)
{
fprintf (stderr, "Could not open %s: %s\n", filename, strerror(errno));
return 1;
}
fseek (lumpfile, 0, SEEK_END);
len = ftell(lumpfile);
fseek (lumpfile, 0, SEEK_SET);
readbuf = (char*)malloc(len);
if (readbuf == NULL)
{
fclose(lumpfile);
fprintf (stderr, "Could not allocate %d bytes\n", len);
return 1;
}
readlen = fread (readbuf, 1, len, lumpfile);
fclose(lumpfile);
if (readlen != len)
{
free (readbuf);
fprintf (stderr, "Unable to read %s\n", filename);
return 1;
}
if (Z_OK != zipOpenNewFileInZip(zipfile, zipname, &zip_inf, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_BEST_COMPRESSION))
{
free (readbuf);
fprintf (stderr, "Unable to open zip for writing %s\n", filename);
return 1;
}
if (Z_OK != zipWriteInFileInZip(zipfile, readbuf, (unsigned)len))
{
free (readbuf);
fprintf (stderr, "Unable to write %s to zip\n", filename);
return 1;
}
free (readbuf);
if (Z_OK != zipCloseFileInZip(zipfile))
{
fprintf (stderr, "Unable to close %s in zip\n", filename);
return 1;
}
return 0;
}
int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
{
zipFile zipfile = NULL;
wadinfo_t header;
filelump_t directory[MAX_LUMPS];
char str[256];
@ -81,6 +160,8 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
header.numlumps = 0;
memset (directory, 0, sizeof(directory));
//__asm int 3
while (fgets (str, sizeof(str), listfile))
{
lineno++;
@ -101,13 +182,38 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
if (*pt == '@')
{ // Rest of line is wadfile to create
if (wadfile != NULL)
if (wadfile != NULL || zipfile != NULL)
{
fprintf (stderr, "Line %d: Tried to reopen wadfile as %s.\n", lineno, pt + 1);
fclose (wadfile);
if (wadfile != NULL) fclose (wadfile);
if (zipfile != NULL) zipClose (zipfile, NULL);
return 1;
}
filename = makefile ? makefile : pt+1;
if (!makefile)
{
int ln = (int)strlen(pt+1);
filename = pt+1;
if (ln >= 4)
{
// If the output file has an extension '.zip' or '.pk3' it will be in Zip format.
if (!stricmp(filename+ln-3, "ZIP") || !stricmp(filename+ln-3, "PK3"))
{
zipfile = zipOpen(filename, APPEND_STATUS_CREATE);
if (zipfile == NULL)
{
fprintf (stderr, "Line %d: Could not open %s: %s\n", lineno, filename, strerror(errno));
return 1;
}
}
}
}
else filename = makefile;
if (!zipfile)
{
wadfile = fopen (filename, makefile ? "w" : "wb");
if (wadfile == NULL)
{
@ -123,6 +229,7 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
// The correct header will be written once the wad is complete
fwrite (&header, sizeof(header), 1, wadfile);
}
}
continue;
}
@ -143,7 +250,7 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
}
if (wadfile == NULL)
if (wadfile == NULL && zipfile == NULL)
{
fprintf (stderr, "Line %d: No wad specified before lumps.\n", lineno);
return 1;
@ -164,6 +271,8 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
}
}
else
{
if (zipfile == NULL)
{
for (i = 0; lumpname[i]; ++i)
{
@ -174,8 +283,17 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
if (filename != NULL)
{
ret |= appendlump (wadfile, filename);
}
directory[header.numlumps].size = ftell (wadfile) - directory[header.numlumps].filepos;
}
else if (filename != NULL)
{
for (i = 0; lumpname[i]; ++i)
{
lumpname[i] = tolower(lumpname[i]);
}
ret |= appendtozip(zipfile, lumpname, filename);
}
header.numlumps++;
}
}
@ -218,10 +336,18 @@ int buildwad (FILE *listfile, char *listfilename, char *makecmd, char *makefile)
}
fclose (wadfile);
}
else if (zipfile != NULL)
{
zipClose(zipfile, NULL);
}
return ret;
}
int main (int argc, char **argv)
#if !defined(_MSC_VER)
#define __cdecl
#endif
int __cdecl main (int argc, char **argv)
{
FILE *listfile = NULL;
char *listfilename = NULL;

View file

@ -23,11 +23,12 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
@ -69,11 +70,13 @@
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
@ -111,8 +114,32 @@
<References>
</References>
<Files>
<File
RelativePath=".\ioapi.c">
</File>
<File
RelativePath=".\ioapi.h">
</File>
<File
RelativePath=".\makewad.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
CompileAs="2"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
CompileAs="2"/>
</FileConfiguration>
</File>
<File
RelativePath=".\zip.c">
</File>
<File
RelativePath=".\zip.h">
</File>
</Files>
<Globals>

1220
tools/makewad/zip.c Normal file

File diff suppressed because it is too large Load diff

235
tools/makewad/zip.h Normal file
View file

@ -0,0 +1,235 @@
/* zip.h -- IO for compress .zip files using zlib
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
WinZip, InfoZip tools and compatible.
Multi volume ZipFile (span) are not supported.
Encryption compatible with pkzip 2.04g only supported
Old compressions used by old PKZip 1.x are not supported
For uncompress .zip file, look at unzip.h
I WAIT FEEDBACK at mail info@winimage.com
Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
Condition of use and distribution are the same than zlib :
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* for more info about .ZIP format, see
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
http://www.info-zip.org/pub/infozip/doc/
PkWare has also a specification at :
ftp://ftp.pkware.com/probdesc.zip
*/
#ifndef _zip_H
#define _zip_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ZLIB_H
#include "../../zlib/zlib.h"
#endif
#ifndef _ZLIBIOAPI_H
#include "ioapi.h"
#endif
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagzipFile__ { int unused; } zipFile__;
typedef zipFile__ *zipFile;
#else
typedef voidp zipFile;
#endif
#define ZIP_OK (0)
#define ZIP_EOF (0)
#define ZIP_ERRNO (Z_ERRNO)
#define ZIP_PARAMERROR (-102)
#define ZIP_BADZIPFILE (-103)
#define ZIP_INTERNALERROR (-104)
#ifndef DEF_MEM_LEVEL
# if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
# else
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
# endif
#endif
/* default memLevel */
/* tm_zip contain date/time info */
typedef struct tm_zip_s
{
uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */
} tm_zip;
typedef struct
{
tm_zip tmz_date; /* date in understandable format */
uLong dosDate; /* if dos_date == 0, tmu_date is used */
/* uLong flag; */ /* general purpose bit flag 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
} zip_fileinfo;
typedef const char* zipcharpc;
#define APPEND_STATUS_CREATE (0)
#define APPEND_STATUS_CREATEAFTER (1)
#define APPEND_STATUS_ADDINZIP (2)
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
/*
Create a zipfile.
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
an Unix computer "zlib/zlib113.zip".
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
will be created at the end of the file.
(useful if the file contain a self extractor code)
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
add files in existing zip (be sure you don't add file that doesn't exist)
If the zipfile cannot be opened, the return value is NULL.
Else, the return value is a zipFile Handle, usable with other function
of this zip package.
*/
/* Note : there is no delete function into a zipfile.
If you want delete file into a zipfile, you must open a zipfile, and create another
Of couse, you can use RAW reading and writing to copy the file you did not want delte
*/
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc_def* pzlib_filefunc_def));
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level));
/*
Open a file in the ZIP for writing.
filename : the filename in zip (if NULL, '-' without quote will be used
*zipfi contain supplemental information
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
contains the extrafield data the the local header
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
contains the extrafield data the the local header
if comment != NULL, comment contain the comment string
method contain the compression method (0 for store, Z_DEFLATED for deflate)
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
*/
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw));
/*
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
*/
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCtypting));
/*
Same than zipOpenNewFileInZip2, except
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
password : crypting password (NULL for no crypting)
crcForCtypting : crc of file to compress (needed for crypting)
*/
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
const void* buf,
unsigned len));
/*
Write data in the zipfile
*/
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
/*
Close the current file in the zipfile
*/
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
uLong uncompressed_size,
uLong crc32));
/*
Close the current file in the zipfile, for fiel opened with
parameter raw=1 in zipOpenNewFileInZip2
uncompressed_size and crc32 are value for the uncompressed size
*/
extern int ZEXPORT zipClose OF((zipFile file,
const char* global_comment));
/*
Close the zipfile
*/
#ifdef __cplusplus
}
#endif
#endif /* _zip_H */

View file

@ -30,6 +30,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc", "wadsrc\wadsrc.vcp
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makewad", "tools\makewad\makewad.vcproj", "{24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}"
ProjectSection(ProjectDependencies) = postProject
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xlatcc", "tools\xlatcc\xlatcc.vcproj", "{3FFA68B3-9449-4B03-ADEE-194C3638623B}"