diff --git a/source/src/command.cpp b/source/src/command.cpp index 1b6f5ca4..fa2f66aa 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -365,9 +365,7 @@ void writecfg() COMMAND(writecfg, ARG_NONE); -vector identnames() +void identnames(vector &names) { - vector names; enumerateht(*idents) names.add(idents->enumc->key); - return names; } diff --git a/source/src/console.cpp b/source/src/console.cpp index 4a937902..34f978af 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -47,7 +47,8 @@ void conoutf(const char *s, ...) s_sprintfdv(sf, s); puts(sf); s = sf; - vector &lines = text_block(s, VIRTW*2-2*CONSPAD-2*FONTH/3); + vector lines; + text_block(s, VIRTW*2-2*CONSPAD-2*FONTH/3, lines); loopv(lines) conline(lines[i], i!=0); lines.deletecontentsa(); } diff --git a/source/src/cube.h b/source/src/cube.h index 14796aec..95979043 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -95,5 +95,7 @@ extern int VIRTW; // virtual screen size for text & HUD #include "protos.h" // external function decls +#define AC_VERSION 920 + #endif diff --git a/source/src/docs.cpp b/source/src/docs.cpp index 246d6de8..fc67c5b8 100644 --- a/source/src/docs.cpp +++ b/source/src/docs.cpp @@ -81,7 +81,8 @@ int stringsort(const char **a, const char **b) { return strcmp(*a, *b); } void doctodo() { - vector inames = identnames(); + vector inames; + identnames(inames); inames.sort(stringsort); conoutf("documentation TODO"); conoutf("undocumented identifiers:"); @@ -174,7 +175,8 @@ void renderdoc(int x, int y) } doclines.add(NULL); - vector desc = text_block(ident->desc, linemax); // desc + vector desc; + text_block(ident->desc, linemax, desc); // desc loopvj(desc) doclines.add(desc[j]); doclines.add(NULL); @@ -219,7 +221,8 @@ void renderdoc(int x, int y) if(ident->remarks.length()) loopvj(ident->remarks) // remarks { - vector remarks = text_block(ident->remarks[j], linemax); + vector remarks; + text_block(ident->remarks[j], linemax, remarks); loopvk(remarks) doclines.add(remarks[k]); } doclines.add(NULL); @@ -264,7 +267,6 @@ int msectionsort(const msection *a, const msection *b) void renderdocsection(void *menu, bool init) { - struct msection { char *name; string cmd; }; static vector msections; msections.setsize(0); @@ -278,15 +280,16 @@ void renderdocsection(void *menu, bool init) loopv(msections) { menumanual(menu, i, msections[i].name, msections[i].cmd); } } +struct maction { string cmd; }; + void renderdocmenu(void *menu, bool init) { - struct action { string cmd; }; - static vector actions; + static vector actions; actions.setsize(0); loopv(sections) { - action &a = actions.add(); + maction &a = actions.add(); s_sprintf(a.cmd)("showmenu [%s]", sections[i].name); menumanual(menu, i, sections[i].name, a.cmd); } diff --git a/source/src/main.cpp b/source/src/main.cpp index 1038096c..1f288308 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -391,5 +391,5 @@ void loadcrosshair(char *c) COMMAND(loadcrosshair, ARG_1STR); -VAR(version, 1, 920, 0); +VAR(version, 1, AC_VERSION, 0); diff --git a/source/src/protos.h b/source/src/protos.h index 260323ac..21bceba5 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -15,7 +15,7 @@ extern void complete(char *s); extern void alias(char *name, char *action); extern char *getalias(char *name); extern void writecfg(); -extern vector identnames(); +extern void identnames(vector &names); // console extern void keypress(int code, bool isdown, int cooked); @@ -180,7 +180,7 @@ extern void draw_textf(const char *fstr, int left, int top, ...); extern int char_width(int c, int x = 0); extern int text_width(const char *str, int limit = -1); extern int text_visible(const char *str, int max); -extern vector text_block(const char *str, int max); +extern void text_block(const char *str, int max, vector &lines); extern void text_startcolumns(); extern void text_endcolumns(); diff --git a/source/src/rendertext.cpp b/source/src/rendertext.cpp index 5af2c169..1116505d 100644 --- a/source/src/rendertext.cpp +++ b/source/src/rendertext.cpp @@ -173,9 +173,8 @@ int text_visible(const char *str, int max) } // cut strings to fit on screen -vector text_block(const char *str, int max) +void text_block(const char *str, int max, vector &lines) { - vector lines; int visible; while((visible = text_visible(str, max))) { @@ -191,7 +190,6 @@ vector text_block(const char *str, int max) s_strncpy(t, str, visible+1); str += visible; } - return lines; } void draw_textf(const char *fstr, int left, int top, ...) @@ -262,4 +260,4 @@ void draw_text(const char *str, int left, int top) xtraverts += 4; x += in_width + 1; } -} \ No newline at end of file +} diff --git a/source/src/serverms.cpp b/source/src/serverms.cpp index 03eac385..5d29225b 100644 --- a/source/src/serverms.cpp +++ b/source/src/serverms.cpp @@ -78,7 +78,7 @@ void updatemasterserver(int seconds) if(seconds>updmaster) // send alive signal to masterserver every hour of uptime { s_sprintfd(path)("%sregister.do?action=add", masterpath); - s_sprintfd(agent)("ActionCube Server %d", getvar("version")); + s_sprintfd(agent)("ActionCube Server %d", AC_VERSION); httpgetsend(masterserver, masterbase, path, "actioncubeserver", agent); masterrep[0] = 0; masterb.data = masterrep; @@ -97,7 +97,7 @@ void checkmasterreply() uchar *retrieveservers(uchar *buf, int buflen) { s_sprintfd(path)("%sretrieve.do?item=list", masterpath); - s_sprintfd(agent)("ActionCube Client %d", getvar("version")); + s_sprintfd(agent)("ActionCube Client %d", AC_VERSION); httpgetsend(masterserver, masterbase, path, "actioncubeclient", agent); ENetBuffer eb; buf[0] = 0;