Merge remote-tracking branch 'gzdoom/master'
This commit is contained in:
commit
805bce1166
214 changed files with 10327 additions and 6393 deletions
|
|
@ -55,7 +55,7 @@ enum ETexMode
|
|||
};
|
||||
|
||||
// Legacy render styles
|
||||
enum ERenderStyle
|
||||
enum ERenderStyle : int
|
||||
{
|
||||
STYLE_None, // Do not draw
|
||||
STYLE_Normal, // Normal; just copy the image to the screen
|
||||
|
|
|
|||
|
|
@ -200,10 +200,10 @@ void FScanner :: OpenLumpNum (int lump)
|
|||
{
|
||||
Close ();
|
||||
{
|
||||
auto mem = fileSystem.OpenFileReader(lump);
|
||||
auto buff = ScriptBuffer.LockNewBuffer(mem.GetLength());
|
||||
mem.Read(buff, mem.GetLength());
|
||||
buff[mem.GetLength()] = 0;
|
||||
auto len = fileSystem.FileLength(lump);
|
||||
auto buff = ScriptBuffer.LockNewBuffer(len);
|
||||
fileSystem.ReadFile(lump, buff);
|
||||
buff[len] = 0;
|
||||
ScriptBuffer.UnlockBuffer();
|
||||
}
|
||||
ScriptName = fileSystem.GetFileFullPath(lump).c_str();
|
||||
|
|
@ -260,6 +260,7 @@ void FScanner::PrepareScript ()
|
|||
StateOptions = false;
|
||||
StringBuffer[0] = '\0';
|
||||
BigStringBuffer = "";
|
||||
ParseError = false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -1089,13 +1090,14 @@ void FScanner::ScriptError (const char *message, ...)
|
|||
va_end (arglist);
|
||||
}
|
||||
|
||||
ParseError = true;
|
||||
if (NoFatalErrors)
|
||||
{
|
||||
Printf(TEXTCOLOR_RED "Script error, \"%s\"" TEXTCOLOR_RED " line %d:\n" TEXTCOLOR_RED "%s\n", ScriptName.GetChars(),
|
||||
Printf(TEXTCOLOR_RED "%sScript error, \"%s\"" TEXTCOLOR_RED " line %d:\n" TEXTCOLOR_RED "%s\n", PrependMessage.GetChars(), ScriptName.GetChars(),
|
||||
AlreadyGot ? AlreadyGotLine : Line, composed.GetChars());
|
||||
return;
|
||||
}
|
||||
I_Error ("Script error, \"%s\" line %d:\n%s\n", ScriptName.GetChars(),
|
||||
I_Error ("%sScript error, \"%s\" line %d:\n%s\n", PrependMessage.GetChars(), ScriptName.GetChars(),
|
||||
AlreadyGot? AlreadyGotLine : Line, composed.GetChars());
|
||||
}
|
||||
|
||||
|
|
@ -1121,7 +1123,8 @@ void FScanner::ScriptMessage (const char *message, ...)
|
|||
va_end (arglist);
|
||||
}
|
||||
|
||||
Printf (TEXTCOLOR_RED "Script error, \"%s\"" TEXTCOLOR_RED " line %d:\n" TEXTCOLOR_RED "%s\n", ScriptName.GetChars(),
|
||||
ParseError = true;
|
||||
Printf (TEXTCOLOR_RED "%sScript error, \"%s\"" TEXTCOLOR_RED " line %d:\n" TEXTCOLOR_RED "%s\n", PrependMessage.GetChars(), ScriptName.GetChars(),
|
||||
AlreadyGot? AlreadyGotLine : Line, composed.GetChars());
|
||||
}
|
||||
|
||||
|
|
@ -1383,4 +1386,3 @@ int ParseHex(const char* hex, FScriptPosition* sc)
|
|||
return num;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ public:
|
|||
|
||||
void ScriptError(const char *message, ...) GCCPRINTF(2,3);
|
||||
void ScriptMessage(const char *message, ...) GCCPRINTF(2,3);
|
||||
void SetPrependMessage(const FString& message) { PrependMessage = message; }
|
||||
|
||||
bool isText();
|
||||
|
||||
|
|
@ -238,6 +239,7 @@ protected:
|
|||
bool StateOptions;
|
||||
bool Escape;
|
||||
VersionInfo ParseVersion = { 0, 0, 0 }; // no ZScript extensions by default
|
||||
FString PrependMessage = "";
|
||||
|
||||
|
||||
bool ScanValue(bool allowfloat, bool evaluate);
|
||||
|
|
|
|||
|
|
@ -753,7 +753,6 @@ FCompressedBuffer FSerializer::GetCompressedOutput()
|
|||
EndObject();
|
||||
buff.filename = nullptr;
|
||||
buff.mSize = (unsigned)w->mOutString.GetSize();
|
||||
buff.mZipFlags = 0;
|
||||
buff.mCRC32 = crc32(0, (const Bytef*)w->mOutString.GetString(), buff.mSize);
|
||||
|
||||
uint8_t *compressbuf = new uint8_t[buff.mSize+1];
|
||||
|
|
@ -762,9 +761,9 @@ FCompressedBuffer FSerializer::GetCompressedOutput()
|
|||
int err;
|
||||
|
||||
stream.next_in = (Bytef *)w->mOutString.GetString();
|
||||
stream.avail_in = buff.mSize;
|
||||
stream.avail_in = (unsigned)buff.mSize;
|
||||
stream.next_out = (Bytef*)compressbuf;
|
||||
stream.avail_out = buff.mSize;
|
||||
stream.avail_out = (unsigned)buff.mSize;
|
||||
stream.zalloc = (alloc_func)0;
|
||||
stream.zfree = (free_func)0;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
|
|
|||
|
|
@ -47,27 +47,29 @@
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FStringTable::LoadStrings (const char *language)
|
||||
void FStringTable::LoadStrings (FileSys::FileSystem& fileSystem_, const char *language)
|
||||
{
|
||||
int lastlump, lump;
|
||||
|
||||
fileSystem = &fileSystem_;
|
||||
allStrings.Clear();
|
||||
lastlump = 0;
|
||||
while ((lump = fileSystem.FindLump("LMACROS", &lastlump)) != -1)
|
||||
while ((lump = fileSystem->FindLump("LMACROS", &lastlump)) != -1)
|
||||
{
|
||||
readMacros(lump);
|
||||
}
|
||||
|
||||
lastlump = 0;
|
||||
while ((lump = fileSystem.FindLump ("LANGUAGE", &lastlump)) != -1)
|
||||
while ((lump = fileSystem->FindLump ("LANGUAGE", &lastlump)) != -1)
|
||||
{
|
||||
auto lumpdata = fileSystem.ReadFile(lump);
|
||||
auto lumpdata = fileSystem->ReadFile(lump);
|
||||
|
||||
if (!ParseLanguageCSV(lump, lumpdata.GetString(), lumpdata.GetSize()))
|
||||
LoadLanguage (lump, lumpdata.GetString(), lumpdata.GetSize());
|
||||
if (!ParseLanguageCSV(lump, lumpdata.string(), lumpdata.size()))
|
||||
LoadLanguage (lump, lumpdata.string(), lumpdata.size());
|
||||
}
|
||||
UpdateLanguage(language);
|
||||
allMacros.Clear();
|
||||
fileSystem = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -159,9 +161,10 @@ TArray<TArray<FString>> FStringTable::parseCSV(const char* buffer, size_t size)
|
|||
|
||||
bool FStringTable::readMacros(int lumpnum)
|
||||
{
|
||||
auto lumpdata = fileSystem.ReadFile(lumpnum);
|
||||
auto data = parseCSV(lumpdata.GetString(), lumpdata.GetSize());
|
||||
auto lumpdata = fileSystem->ReadFile(lumpnum);
|
||||
auto data = parseCSV(lumpdata.string(), lumpdata.size());
|
||||
|
||||
allMacros.Clear();
|
||||
for (unsigned i = 1; i < data.Size(); i++)
|
||||
{
|
||||
auto macroname = data[i][0];
|
||||
|
|
@ -321,7 +324,7 @@ void FStringTable::LoadLanguage (int lumpnum, const char* buffer, size_t size)
|
|||
}
|
||||
else
|
||||
{
|
||||
sc.ScriptError ("The language code must be 2 or 3 characters long.\n'%s' is %lu characters long.",
|
||||
sc.ScriptError ("The language code must be 2 or 3 characters long.\n'%s' is %zu characters long.",
|
||||
sc.String, len);
|
||||
}
|
||||
}
|
||||
|
|
@ -410,7 +413,7 @@ void FStringTable::DeleteForLabel(int lumpnum, FName label)
|
|||
{
|
||||
decltype(allStrings)::Iterator it(allStrings);
|
||||
decltype(allStrings)::Pair *pair;
|
||||
auto filenum = fileSystem.GetFileContainer(lumpnum);
|
||||
auto filenum = fileSystem->GetFileContainer(lumpnum);
|
||||
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
|
|
@ -432,7 +435,7 @@ void FStringTable::DeleteForLabel(int lumpnum, FName label)
|
|||
void FStringTable::InsertString(int lumpnum, int langid, FName label, const FString &string)
|
||||
{
|
||||
const char *strlangid = (const char *)&langid;
|
||||
TableElement te = { fileSystem.GetFileContainer(lumpnum), { string, string, string, string } };
|
||||
TableElement te = { fileSystem->GetFileContainer(lumpnum), { string, string, string, string } };
|
||||
ptrdiff_t index;
|
||||
while ((index = te.strings[0].IndexOf("@[")) >= 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public:
|
|||
using LangMap = TMap<uint32_t, StringMap>;
|
||||
using StringMacroMap = TMap<FName, StringMacro>;
|
||||
|
||||
void LoadStrings(const char *language);
|
||||
void LoadStrings(FileSys::FileSystem& fileSystem, const char *language);
|
||||
void UpdateLanguage(const char* language);
|
||||
StringMap GetDefaultStrings() { return allStrings[default_table]; } // Dehacked needs these for comparison
|
||||
void SetOverrideStrings(StringMap & map)
|
||||
|
|
@ -108,6 +108,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
FileSys::FileSystem* fileSystem;
|
||||
FString activeLanguage;
|
||||
StringMacroMap allMacros;
|
||||
LangMap allStrings;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue