mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- improved error reporting for badly defined translations.
This needs to be handled by the caller for all use cases because the translation parser lacks the context to do a proper error report.
This commit is contained in:
parent
a96b86b13b
commit
a38e75db00
4 changed files with 150 additions and 138 deletions
|
@ -633,8 +633,6 @@ bool FRemapTable::AddToTranslation(const char *range)
|
|||
sc.OpenMem("translation", range, int(strlen(range)));
|
||||
sc.SetCMode(true);
|
||||
|
||||
try
|
||||
{
|
||||
sc.MustGetToken(TK_IntConst);
|
||||
start = sc.Number;
|
||||
sc.MustGetToken(':');
|
||||
|
@ -771,12 +769,6 @@ bool FRemapTable::AddToTranslation(const char *range)
|
|||
return AddIndexRange(start, end, pal1, pal2);
|
||||
}
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
Printf("Error in translation '%s':\n%s\n", range, err.GetMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -1529,7 +1521,16 @@ void R_ParseTrnslate()
|
|||
do
|
||||
{
|
||||
sc.MustGetToken(TK_StringConst);
|
||||
|
||||
try
|
||||
{
|
||||
NewTranslation.AddToTranslation(sc.String);
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
sc.ScriptMessage("Error in translation '%s':\n" TEXTCOLOR_YELLOW "%s\n", sc.String, err.GetMessage());
|
||||
}
|
||||
|
||||
} while (sc.CheckToken(','));
|
||||
|
||||
int trans = NewTranslation.StoreTranslation(TRANSLATION_Custom);
|
||||
|
|
|
@ -1120,7 +1120,7 @@ void FScanner::ScriptMessage (const char *message, ...)
|
|||
va_end (arglist);
|
||||
}
|
||||
|
||||
Printf (TEXTCOLOR_RED "Script error, \"%s\" line %d:\n" TEXTCOLOR_RED "%s\n", ScriptName.GetChars(),
|
||||
Printf (TEXTCOLOR_RED "Script error, \"%s\"" TEXTCOLOR_RED "line %d:\n" TEXTCOLOR_RED "%s\n", ScriptName.GetChars(),
|
||||
AlreadyGot? AlreadyGotLine : Line, composed.GetChars());
|
||||
}
|
||||
|
||||
|
|
|
@ -729,7 +729,6 @@ DEFINE_PROPERTY(translation, L, Actor)
|
|||
else
|
||||
{
|
||||
FRemapTable CurrentTranslation;
|
||||
bool success = true;
|
||||
|
||||
CurrentTranslation.MakeIdentity();
|
||||
for(int i = 1; i < PROP_PARM_COUNT; i++)
|
||||
|
@ -744,14 +743,17 @@ DEFINE_PROPERTY(translation, L, Actor)
|
|||
else
|
||||
{
|
||||
// parse all ranges to get a complete list of errors, if more than one range fails.
|
||||
success |= CurrentTranslation.AddToTranslation(str);
|
||||
try
|
||||
{
|
||||
CurrentTranslation.AddToTranslation(str);
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
bag.ScriptPosition.Message(MSG_WARNING, "Error in translation '%s':\n" TEXTCOLOR_CYAN "%s\n", str, err.GetMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
defaults->Translation = CurrentTranslation.StoreTranslation (TRANSLATION_Decorate);
|
||||
if (!success)
|
||||
{
|
||||
bag.ScriptPosition.Message(MSG_WARNING, "Failed to parse translation");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "v_video.h"
|
||||
#include "v_text.h"
|
||||
#include "cmdlib.h"
|
||||
#include "doomerrors.h"
|
||||
|
||||
// On the Alpha, accessing the shorts directly if they aren't aligned on a
|
||||
// 4-byte boundary causes unaligned access warnings. Why it does this at
|
||||
|
@ -954,8 +955,16 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, TexInit &init)
|
|||
do
|
||||
{
|
||||
sc.MustGetString();
|
||||
|
||||
try
|
||||
{
|
||||
part.Translation->AddToTranslation(sc.String);
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
sc.ScriptMessage("Error in translation '%s':\n" TEXTCOLOR_YELLOW "%s\n", sc.String, err.GetMessage());
|
||||
}
|
||||
}
|
||||
while (sc.CheckString(","));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue