mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 08:41:59 +00:00
- Added a Gets function to the FileReader class which I planned to use
to enable Timidity to read its config from Zips. I put this on hold though after finding out that the sound quality isn't even near that of Timidity++. - GCC-Fixes (FString::GetChars() for Printf calls) - Added a dummy Weapon.NOLMS flag so that Skulltag weapons using this flag can be loaded SVN r901 (trunk)
This commit is contained in:
parent
10c0d67b78
commit
4cba91a936
7 changed files with 77 additions and 10 deletions
|
@ -1861,7 +1861,7 @@ static const char *BaseFileSearch (const char *file, const char *ext, bool lookf
|
|||
|
||||
if (lookfirstinprogdir)
|
||||
{
|
||||
sprintf (wad, "%s%s%s", progdir, progdir[strlen (progdir) - 1] != '/' ? "/" : "", file);
|
||||
sprintf (wad, "%s%s%s", progdir.GetChars(), progdir[progdir.Len() - 1] != '/' ? "/" : "", file);
|
||||
if (FileExists (wad))
|
||||
{
|
||||
return wad;
|
||||
|
|
|
@ -132,6 +132,38 @@ long FileReader::Read (void *buffer, long len)
|
|||
return len;
|
||||
}
|
||||
|
||||
char *FileReader::Gets(char *strbuf, int len)
|
||||
{
|
||||
if (FilePos + len > StartPos + Length)
|
||||
{
|
||||
len = Length - FilePos + StartPos;
|
||||
}
|
||||
if (len <= 0) return 0;
|
||||
char *p = fgets(strbuf, len, File);
|
||||
FilePos += len;
|
||||
return p;
|
||||
}
|
||||
|
||||
char *FileReader::GetsFromBuffer(const char * bufptr, char *strbuf, int len)
|
||||
{
|
||||
if (len>Length-FilePos) len=Length-FilePos;
|
||||
if (len <= 0) return NULL;
|
||||
|
||||
char *p = strbuf;
|
||||
while (len > 1 && bufptr[FilePos] != 0)
|
||||
{
|
||||
if (bufptr[FilePos] != '\r')
|
||||
{
|
||||
*p++ = bufptr[FilePos];
|
||||
len--;
|
||||
if (bufptr[FilePos] == '\n') break;
|
||||
}
|
||||
FilePos++;
|
||||
}
|
||||
*p++=0;
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
long FileReader::CalcFileLen() const
|
||||
{
|
||||
long endpos;
|
||||
|
@ -265,3 +297,9 @@ long MemoryReader::Read (void *buffer, long len)
|
|||
FilePos+=len;
|
||||
return len;
|
||||
}
|
||||
|
||||
char *MemoryReader::Gets(char *strbuf, int len)
|
||||
{
|
||||
return GetsFromBuffer(bufptr, strbuf, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
virtual long Tell () const;
|
||||
virtual long Seek (long offset, int origin);
|
||||
virtual long Read (void *buffer, long len);
|
||||
virtual char *Gets(char *strbuf, int len);
|
||||
long GetLength () const { return Length; }
|
||||
|
||||
// If you use the underlying FILE without going through this class,
|
||||
|
@ -58,10 +59,13 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
FileReader (const FileReader &other, long length);
|
||||
FileReader ();
|
||||
|
||||
char *GetsFromBuffer(const char * bufptr, char *strbuf, int len);
|
||||
|
||||
FILE *File;
|
||||
long Length;
|
||||
long StartPos;
|
||||
|
@ -145,6 +149,7 @@ public:
|
|||
virtual long Tell () const;
|
||||
virtual long Seek (long offset, int origin);
|
||||
virtual long Read (void *buffer, long len);
|
||||
virtual char *Gets(char *strbuf, int len);
|
||||
|
||||
protected:
|
||||
const char * bufptr;
|
||||
|
|
|
@ -167,8 +167,6 @@ typedef struct
|
|||
} d;
|
||||
} intercept_t;
|
||||
|
||||
extern TArray<intercept_t> intercepts;
|
||||
|
||||
typedef bool (*traverser_t) (intercept_t *in);
|
||||
|
||||
fixed_t P_AproxDistance (fixed_t dx, fixed_t dy);
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
// [RH] Keep GCC quiet by not using offsetof on Actor types.
|
||||
#define DEFINE_FLAG(prefix, name, type, variable) { prefix##_##name, #name, (int)(size_t)&((type*)1)->variable - 1 }
|
||||
#define DEFINE_FLAG2(symbol, name, type, variable) { symbol, #name, (int)(size_t)&((type*)1)->variable - 1 }
|
||||
#define DEFINE_DEPRECATED_FLAG(name, type) { DEPF_##name, #name, -1 }
|
||||
#define DEFINE_DEPRECATED_FLAG(name) { DEPF_##name, #name, -1 }
|
||||
#define DEFINE_DUMMY_FLAG(name) { DEPF_UNUSED, #name, -1 }
|
||||
|
||||
struct flagdef
|
||||
{
|
||||
|
@ -91,6 +92,7 @@ struct flagdef
|
|||
|
||||
enum
|
||||
{
|
||||
DEPF_UNUSED,
|
||||
DEPF_FIREDAMAGE,
|
||||
DEPF_ICEDAMAGE,
|
||||
DEPF_LOWGRAVITY,
|
||||
|
@ -248,11 +250,11 @@ static flagdef ActorFlags[]=
|
|||
DEFINE_FLAG(RF, FORCEXYBILLBOARD, AActor, renderflags),
|
||||
|
||||
// Deprecated flags. Handling must be performed in HandleDeprecatedFlags
|
||||
DEFINE_DEPRECATED_FLAG(FIREDAMAGE, AActor),
|
||||
DEFINE_DEPRECATED_FLAG(ICEDAMAGE, AActor),
|
||||
DEFINE_DEPRECATED_FLAG(LOWGRAVITY, AActor),
|
||||
DEFINE_DEPRECATED_FLAG(SHORTMISSILERANGE, AActor),
|
||||
DEFINE_DEPRECATED_FLAG(LONGMELEERANGE, AActor),
|
||||
DEFINE_DEPRECATED_FLAG(FIREDAMAGE),
|
||||
DEFINE_DEPRECATED_FLAG(ICEDAMAGE),
|
||||
DEFINE_DEPRECATED_FLAG(LOWGRAVITY),
|
||||
DEFINE_DEPRECATED_FLAG(SHORTMISSILERANGE),
|
||||
DEFINE_DEPRECATED_FLAG(LONGMELEERANGE),
|
||||
};
|
||||
|
||||
static flagdef InventoryFlags[] =
|
||||
|
@ -271,7 +273,7 @@ static flagdef InventoryFlags[] =
|
|||
DEFINE_FLAG(IF, IGNORESKILL, AInventory, ItemFlags),
|
||||
DEFINE_FLAG(IF, ADDITIVETIME, AInventory, ItemFlags),
|
||||
|
||||
DEFINE_DEPRECATED_FLAG(PICKUPFLASH, AInventory),
|
||||
DEFINE_DEPRECATED_FLAG(PICKUPFLASH),
|
||||
|
||||
};
|
||||
|
||||
|
@ -296,6 +298,8 @@ static flagdef WeaponFlags[] =
|
|||
DEFINE_FLAG(WIF, CHEATNOTWEAPON, AWeapon, WeaponFlags),
|
||||
DEFINE_FLAG(WIF, NO_AUTO_SWITCH, AWeapon, WeaponFlags),
|
||||
//WIF_BOT_REACTION_SKILL_THING = 1<<31, // I don't understand this
|
||||
|
||||
DEFINE_DUMMY_FLAG(NOLMS),
|
||||
};
|
||||
|
||||
static const struct { const PClass *Type; flagdef *Defs; int NumDefs; } FlagLists[] =
|
||||
|
|
|
@ -2274,6 +2274,27 @@ long FWadLump::Read (void *buffer, long len)
|
|||
return numread;
|
||||
}
|
||||
|
||||
char *FWadLump::Gets(char *strbuf, int len)
|
||||
{
|
||||
// Blood, you are so mean to me with your encryption.
|
||||
// ... and since this function will never read from Blood
|
||||
// files let's just return an error here.
|
||||
if (Encrypted && FilePos - StartPos < 256)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SourceData != NULL)
|
||||
{
|
||||
return GetsFromBuffer(SourceData, strbuf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FileReader::Gets(strbuf, len);
|
||||
}
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
// FMemLump -----------------------------------------------------------------
|
||||
|
||||
FMemLump::FMemLump ()
|
||||
|
|
|
@ -119,6 +119,7 @@ public:
|
|||
|
||||
long Seek (long offset, int origin);
|
||||
long Read (void *buffer, long len);
|
||||
char *Gets(char *strbuf, int len);
|
||||
|
||||
private:
|
||||
FWadLump (const FileReader &reader, long length, bool encrypted);
|
||||
|
|
Loading…
Reference in a new issue