Skip to content

Commit 91dbf8b

Browse files
committed
Improve consistency/flexibility of version-specific comments.
matches_version_specific_tag() now uses the previously-FRED-only scan_fso_version_string() function, meaning it now supports version-specific comments with as few numbers as ;;FSO 3;; to as many numbers as ;;FSO 3.7.3.20151106;;, instead of you being required to supply exactly 3 numbers.
1 parent 0c6bada commit 91dbf8b

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

code/parse/parselo.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,31 +1790,30 @@ bool matches_version_specific_tag(const char *line_start, bool &compatible_versi
17901790
{
17911791
// special version-specific comment
17921792
// formatted like e.g. ;;FSO 3.7.0;;
1793+
// Should now support anything from ;;FSO 3;; to ;;FSO 3.7.3.20151106;; -MageKing17
17931794
if (strnicmp(line_start, ";;FSO ", 6))
17941795
return false;
17951796

1796-
int major, minor, build, num_len;
1797-
const char *ch;
1797+
int major, minor, build, revis;
1798+
int s_num = scan_fso_version_string(line_start, &major, &minor, &build, &revis);
17981799

1799-
ch = line_start + 6;
1800-
if (!get_number_before_separator(major, num_len, ch, '.'))
1800+
if (s_num == 0)
18011801
return false;
18021802

1803-
ch += (num_len + 1);
1804-
if (!get_number_before_separator(minor, num_len, ch, '.'))
1805-
return false;
1806-
1807-
ch += (num_len + 1);
1808-
if (!get_number_before_separator(build, num_len, ch, ';'))
1809-
return false;
1810-
1811-
ch += (num_len + 1);
1812-
if (*ch != ';')
1813-
return false;
1803+
// hack for releases
1804+
if (s_num == 4 && FS_VERSION_REVIS < 1000) {
1805+
s_num = 3;
1806+
}
18141807

1808+
const char *ch = line_start + 6;
1809+
while ((*ch) != ';') {
1810+
Assertion((*ch) != '\0', "String that was already guaranteed to end with semicolons did not end with semicolons; it's possible we have fallen into an alternate universe. Failing string: [%s]\n", line_start);
1811+
ch++;
1812+
}
1813+
ch++;
1814+
Assertion((*ch) == ';', "String that was guaranteed to have double semicolons did not; it's possible we have fallen into an alternate universe. Failing string: [%s]\n", line_start);
18151815
ch++;
18161816

1817-
// tag is a match!
18181817
tag_len = ch - line_start;
18191818
compatible_version = true;
18201819

@@ -1823,18 +1822,25 @@ bool matches_version_specific_tag(const char *line_start, bool &compatible_versi
18231822
{
18241823
compatible_version = false;
18251824
}
1826-
else if (major == FS_VERSION_MAJOR)
1825+
else if (major == FS_VERSION_MAJOR && s_num > 1)
18271826
{
18281827
if (minor > FS_VERSION_MINOR)
18291828
{
18301829
compatible_version = false;
18311830
}
1832-
else if (minor == FS_VERSION_MINOR)
1831+
else if (minor == FS_VERSION_MINOR && s_num > 2)
18331832
{
18341833
if (build > FS_VERSION_BUILD)
18351834
{
18361835
compatible_version = false;
18371836
}
1837+
else if (build == FS_VERSION_BUILD && s_num > 3)
1838+
{
1839+
if (revis > FS_VERSION_REVIS)
1840+
{
1841+
compatible_version = false;
1842+
}
1843+
}
18381844
}
18391845
}
18401846

0 commit comments

Comments
 (0)