diff --git a/libs/console/menu.c b/libs/console/menu.c index 7d2698add..b0c76d2e3 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -484,7 +484,7 @@ Menu_Load (void) menu_pr_state.progs = 0; if ((size = QFS_FOpenFile (menu_pr_state.progs_name, &file)) != -1) { - PR_LoadProgsFile (&menu_pr_state, file, size, 0, 512 * 1024); + PR_LoadProgsFile (&menu_pr_state, file, size, 0, 1024 * 1024); Qclose (file); if (!PR_RunLoadFuncs (&menu_pr_state)) { diff --git a/libs/ruamoko/rua_qfile.c b/libs/ruamoko/rua_qfile.c index db7eb973a..26f6b5268 100644 --- a/libs/ruamoko/rua_qfile.c +++ b/libs/ruamoko/rua_qfile.c @@ -39,6 +39,7 @@ static __attribute__ ((used)) const char rcsid[] = # include #endif +#include "QF/dstring.h" #include "QF/progs.h" #include "QF/quakefs.h" #include "QF/va.h" @@ -201,6 +202,23 @@ bi_Qgetline (progs_t *pr) R_STRING (pr) = 0; } +static void +bi_Qreadstring (progs_t *pr) +{ + int handle = P_INT (pr, 0); + int len = P_INT (pr, 1); + qfile_t *h = get_handle (pr, __FUNCTION__, handle); + string_t str = PR_NewMutableString (pr); + dstring_t *dstr = PR_GetMutableString (pr, str); + + dstr->size = len + 1; + dstring_adjust (dstr); + len = Qread (h->file, dstr->str, len); + dstr->size = len + 1; + dstr->str[len] = 0; + R_STRING (pr) = str; +} + static void check_buffer (progs_t *pr, pr_type_t *buf, int count, const char *name) { @@ -340,6 +358,7 @@ static builtin_t insecure_builtins[] = { static builtin_t builtins[] = { {"Qclose", bi_Qclose, -1}, {"Qgetline", bi_Qgetline, -1}, + {"Qreadstring", bi_Qreadstring, -1}, {"Qread", bi_Qread, -1}, {"Qwrite", bi_Qwrite, -1}, {"Qputs", bi_Qputs, -1}, diff --git a/ruamoko/cl_menu/client_menu.qc b/ruamoko/cl_menu/client_menu.qc index 9d191cbb0..f463c3c1f 100644 --- a/ruamoko/cl_menu/client_menu.qc +++ b/ruamoko/cl_menu/client_menu.qc @@ -93,11 +93,11 @@ integer save_cursor; string (QFile f) get_comment = { local string line; - local string plist_data = str_new (); + local string plist_data; local PLItem plist; + local integer pos = Qtell (f); - while ((line = Qgetline (f))) - str_cat (plist_data, line); + plist_data = Qreadstring (f, Qfilesize (f) - pos); plist = [PLItem newFromString:plist_data]; str_free (plist_data); line = [(PLString) [plist getObjectForKey:"comment"] string]; diff --git a/ruamoko/include/qfile.h b/ruamoko/include/qfile.h index e1fa259b6..8acb8b265 100644 --- a/ruamoko/include/qfile.h +++ b/ruamoko/include/qfile.h @@ -9,6 +9,7 @@ typedef struct _qfile_t [] QFile; @extern QFile (string path, string mode) Qopen; @extern void (QFile file) Qclose; @extern string (QFile file) Qgetline; +@extern string (QFile file, integer len) Qreadstring; @extern integer (QFile file, void [] buf, integer count) Qread; @extern integer (QFile file, void [] buf, integer count) Qwrite; @extern integer (QFile file, string str) Qputs; diff --git a/ruamoko/lib/qfile.r b/ruamoko/lib/qfile.r index be48b7184..2cca4ef03 100644 --- a/ruamoko/lib/qfile.r +++ b/ruamoko/lib/qfile.r @@ -5,6 +5,7 @@ integer (string path) Qremove = #0; QFile (string path, string mode) Qopen = #0; void (QFile file) Qclose = #0; string (QFile file) Qgetline = #0; +string (QFile file, integer length) Qreadstring = #0; integer (QFile file, void [] buf, integer count) Qread = #0; integer (QFile file, void [] buf, integer count) Qwrite = #0; integer (QFile file, string str) Qputs = #0;