- 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:
Christoph Oelckers 2008-04-11 10:16:29 +00:00
commit 4cba91a936
7 changed files with 77 additions and 10 deletions

View file

@ -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);
}