[gamecode] Make it possible to check string mutability

This commit is contained in:
Bill Currie 2020-03-26 16:38:09 +09:00
parent ec82d6b027
commit 1586df4dfc
2 changed files with 18 additions and 0 deletions

View file

@ -1251,6 +1251,13 @@ void PR_Strings_Init (progs_t *pr);
*/ */
qboolean PR_StringValid (progs_t *pr, string_t num) __attribute__((pure)); qboolean PR_StringValid (progs_t *pr, string_t num) __attribute__((pure));
/** Check if a string is valid and mutable.
\param pr pointer to ::progs_t VM struct
\param num string index to be checked
\return true if the string is valid and mutable, false otherwise
*/
qboolean PR_StringMutable (progs_t *pr, string_t num) __attribute__((pure));
/** Convert a string index to a C string. /** Convert a string index to a C string.
\param pr pointer to ::progs_t VM struct \param pr pointer to ::progs_t VM struct
\param num string index to be converted \param num string index to be converted

View file

@ -361,6 +361,17 @@ PR_StringValid (progs_t *pr, string_t num)
return get_strref (pr->pr_string_resources, num) != 0; return get_strref (pr->pr_string_resources, num) != 0;
} }
VISIBLE qboolean
PR_StringMutable (progs_t *pr, string_t num)
{
strref_t *sr;
if (num >= 0) {
return 0;
}
sr = get_strref (pr->pr_string_resources, num);
return sr && sr->type == str_mutable;
}
VISIBLE const char * VISIBLE const char *
PR_GetString (progs_t *pr, string_t num) PR_GetString (progs_t *pr, string_t num)
{ {