From 064a2a83be2d881d78cacf9684d0b7490127e683 Mon Sep 17 00:00:00 2001 From: div0 Date: Mon, 28 Jan 2008 09:12:33 +0000 Subject: [PATCH] possibly kill the tempstring warnings when saving games, possibly break everything git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3294 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/common/mapinfo.qc | 30 +++++++++++++++---- data/qcsrc/common/mapinfo.qh | 2 ++ data/qcsrc/common/util.qc | 6 +++- .../dialog_multiplayer_create_mapinfo.c | 2 ++ data/qcsrc/menu/nexuiz/maplist.c | 2 ++ 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/data/qcsrc/common/mapinfo.qc b/data/qcsrc/common/mapinfo.qc index df5a37fce..aa8d47ca2 100644 --- a/data/qcsrc/common/mapinfo.qc +++ b/data/qcsrc/common/mapinfo.qc @@ -1,4 +1,4 @@ -// internal toy + // internal toy void cvar_settemp(string pKey, string pValue) { //localcmd(strcat("\nsettemp ", t, " \"", s, "\"\n")); @@ -226,8 +226,7 @@ float MapInfo_FilterGametype(float pGametype, float pFeatures, float pAbortOnGen } _MapInfo_filtered = strzone(_MapInfo_filtered); MapInfo_count = HugeSetOfIntegers_length(_MapInfo_filtered); - //print("Filter ", ftos(pGametype), "/", ftos(pFeatures), " has ", ftos(MapInfo_count), "\n"); - // TODO clear cache + MapInfo_ClearTemps(); return 1; } @@ -674,7 +673,7 @@ float MapInfo_CurrentGametype() return MAPINFO_TYPE_DEATHMATCH; } -float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise +float _MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise { if(!MapInfo_Get_ByName(s, 1, 0)) return 0; @@ -685,6 +684,14 @@ float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with th return 1; } +float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise +{ + float r; + r = _MapInfo_CheckMap(s); + MapInfo_ClearTemps(); + return r; +} + void MapInfo_SwitchGameType(float t) { cvar_set("gamecfg", "0"); @@ -729,7 +736,7 @@ string MapInfo_ListAllowedMaps() void MapInfo_LoadMapSettings(string s) // to be called from worldspawn { float t; - if(!MapInfo_CheckMap(s)) + if(!_MapInfo_CheckMap(s)) // with underscore, it keeps temps { if(MapInfo_Map_supportedGametypes <= 0) error("Mapinfo system is not functional at all. BAILED OUT.\n"); @@ -746,4 +753,17 @@ void MapInfo_LoadMapSettings(string s) // to be called from worldspawn } cvar_settemp_restore(); MapInfo_Get_ByName(s, 1, MapInfo_CurrentGametype()); + MapInfo_ClearTemps(); +} + +void MapInfo_ClearTemps() +{ + MapInfo_Map_bspname = string_null; + MapInfo_Map_title = string_null; + MapInfo_Map_description = string_null; + MapInfo_Map_author = string_null; + MapInfo_Map_supportedGametypes = 0; + MapInfo_Map_supportedFeatures = 0; + MapInfo_Map_diameter = 0; + MapInfo_Map_spawnpoints = 0; } diff --git a/data/qcsrc/common/mapinfo.qh b/data/qcsrc/common/mapinfo.qh index c565b1da1..af6483ce9 100644 --- a/data/qcsrc/common/mapinfo.qh +++ b/data/qcsrc/common/mapinfo.qh @@ -63,3 +63,5 @@ void MapInfo_LoadMapSettings(string s); void MapInfo_Cache_Destroy(); // disable caching void MapInfo_Cache_Create(); // enable caching void MapInfo_Cache_Invalidate(); // delete cache if any, but keep enabled + +void MapInfo_ClearTemps(); // call this when done with mapinfo for this frame diff --git a/data/qcsrc/common/util.qc b/data/qcsrc/common/util.qc index 4addf0fc5..b97454caf 100644 --- a/data/qcsrc/common/util.qc +++ b/data/qcsrc/common/util.qc @@ -7,9 +7,12 @@ void wordwrap_buffer_put(string s) string wordwrap(string s, float l) { + string r; wordwrap_buffer = ""; wordwrap_cb(s, l, wordwrap_buffer_put); - return wordwrap_buffer; + r = wordwrap_buffer; + wordwrap_buffer = ""; + return r; } #ifndef MENUQC @@ -29,6 +32,7 @@ void wordwrap_sprint(string s, float l) wordwrap_cb(s, l, wordwrap_buffer_sprint); if(wordwrap_buffer != "") sprint(self, strcat(wordwrap_buffer, "\n")); + wordwrap_buffer = ""; return; } #endif diff --git a/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mapinfo.c b/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mapinfo.c index d63d037e2..45bf4f2f5 100644 --- a/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mapinfo.c +++ b/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mapinfo.c @@ -76,6 +76,8 @@ void loadMapInfoNexuizMapInfoDialog(entity me, float i) me.typeAssaultLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ASSAULT); if(me.typeOnslaughtLabel) me.typeOnslaughtLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ONSLAUGHT); + + MapInfo_ClearTemps(); } void fillNexuizMapInfoDialog(entity me) { diff --git a/data/qcsrc/menu/nexuiz/maplist.c b/data/qcsrc/menu/nexuiz/maplist.c index c651302a7..29a0717bd 100644 --- a/data/qcsrc/menu/nexuiz/maplist.c +++ b/data/qcsrc/menu/nexuiz/maplist.c @@ -182,6 +182,8 @@ void drawListBoxItemNexuizMapList(entity me, float i, vector absSize, float isSe draw_Text(me.realUpperMargin1 * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0) * me.realFontSize_x)) * eX, s, me.realFontSize, SKINCOLOR_MAPLIST_TITLE, theAlpha, 0); s = draw_TextShortenToWidth(MapInfo_Map_author, me.columnNameSize / me.realFontSize_x, 0); draw_Text(me.realUpperMargin2 * eY + (me.columnNameOrigin + 1.00 * (me.columnNameSize - draw_TextWidth(s, 0) * me.realFontSize_x)) * eX, s, me.realFontSize, SKINCOLOR_MAPLIST_AUTHOR, theAlpha, 0); + + MapInfo_ClearTemps(); } void refilterNexuizMapList(entity me) -- 2.39.2