From acc26dba67a9e67d32c1ed3561052be334b93c72 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 13 Jan 2008 19:36:05 +0000 Subject: [PATCH] Applied Mosc's patch (plus a small change to variable_data.cpp) to fix #605 and #557, both related to $ variables in the middle of tags being wiped by different features. Originally committed to SVN as r1698. --- aegisub/ass_override.cpp | 27 ++++++++++++++++++--------- aegisub/variable_data.cpp | 3 +++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/aegisub/ass_override.cpp b/aegisub/ass_override.cpp index d481f8a2a..3fdb62306 100644 --- a/aegisub/ass_override.cpp +++ b/aegisub/ass_override.cpp @@ -663,15 +663,21 @@ end_tokenizing: // Determine parameter type and set value switch (curproto->type) { case VARDATA_INT: { - long temp = 0; - curtok.ToLong(&temp); - newparam->SetInt(temp); + if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) { + long temp = 0; + curtok.ToLong(&temp); + newparam->SetInt(temp); + } + else newparam->SetText(curtok); break; } case VARDATA_FLOAT: { - double temp = 0.0; - curtok.ToDouble(&temp); - newparam->SetFloat(temp); + if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) { + double temp = 0.0; + curtok.ToDouble(&temp); + newparam->SetFloat(temp); + } + else newparam->SetText(curtok); break; } case VARDATA_TEXT: { @@ -679,9 +685,12 @@ end_tokenizing: break; } case VARDATA_BOOL: { - long temp = false; - curtok.ToLong(&temp); - newparam->SetBool(temp != 0); + if (!(curtok.StartsWith(_T("!")) || curtok.StartsWith(_T("$")))) { + long temp = false; + curtok.ToLong(&temp); + newparam->SetBool(temp != 0); + } + else newparam->SetText(curtok); break; } case VARDATA_BLOCK: { diff --git a/aegisub/variable_data.cpp b/aegisub/variable_data.cpp index ba7ddaf74..67e024495 100644 --- a/aegisub/variable_data.cpp +++ b/aegisub/variable_data.cpp @@ -172,6 +172,7 @@ int VariableData::AsInt() const { if (type == VARDATA_BOOL) return (*value_bool)?1:0; if (type == VARDATA_INT) return *value_int; if (type == VARDATA_FLOAT) return (int)(*value_float); + if (type == VARDATA_TEXT) return 0; throw _T("Wrong parameter type, should be int"); } @@ -182,6 +183,7 @@ double VariableData::AsFloat() const { if (!value) throw _T("Null parameter"); if (type == VARDATA_FLOAT) return *value_float; if (type == VARDATA_INT) return (float)(*value_int); + if (type == VARDATA_TEXT) return 0.0f; throw _T("Wrong parameter type, should be float"); } @@ -193,6 +195,7 @@ bool VariableData::AsBool() const { if (type == VARDATA_BOOL) return *value_bool; if (type == VARDATA_INT) return ((*value_int)!=0); if (type == VARDATA_FLOAT) return ((*value_float)!=0); + if (type == VARDATA_TEXT) return false; throw _T("Wrong parameter type, should be bool"); }