From 1017a955336ffea041442a10138486f16f8273f1 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 8 Apr 2018 14:51:25 +1000 Subject: [PATCH] Add strfree to reduce explicit use of strunzone/string_null --- qcsrc/client/bgmscript.qc | 3 +- qcsrc/client/commands/cl_cmd.qc | 4 +- qcsrc/client/hud/panel/centerprint.qc | 4 +- qcsrc/client/hud/panel/modicons.qc | 8 +-- qcsrc/client/hud/panel/quickmenu.qc | 19 ++---- qcsrc/client/main.qc | 12 +--- qcsrc/client/view.qc | 8 +-- qcsrc/client/wall.qc | 4 +- qcsrc/common/campaign_file.qc | 13 ++-- qcsrc/common/debug.qh | 2 +- qcsrc/common/effects/qc/globalsound.qc | 3 +- qcsrc/common/ent_cs.qc | 6 +- qcsrc/common/minigames/minigame/bd.qc | 17 +++-- qcsrc/common/minigames/minigame/c4.qc | 5 +- qcsrc/common/minigames/minigame/nmm.qc | 6 +- qcsrc/common/minigames/minigame/pp.qc | 7 +- qcsrc/common/minigames/minigame/ps.qc | 7 +- qcsrc/common/minigames/minigame/ttt.qc | 5 +- qcsrc/common/minigames/sv_minigames.qc | 2 +- qcsrc/common/monsters/sv_monsters.qc | 2 +- .../mutator/damagetext/cl_damagetext.qc | 2 +- .../mutators/mutator/sandbox/sv_sandbox.qc | 22 +++--- .../mutator/waypoints/waypointsprites.qc | 6 +- qcsrc/common/notifications/all.qc | 2 +- qcsrc/common/playerstats.qc | 3 +- qcsrc/common/t_items.qc | 6 +- qcsrc/common/triggers/func/ladder.qc | 3 +- qcsrc/common/triggers/func/pointparticles.qc | 12 +--- qcsrc/common/triggers/misc/corner.qc | 23 ++----- qcsrc/common/triggers/misc/teleport_dest.qc | 9 +-- qcsrc/common/triggers/target/music.qc | 10 +-- qcsrc/common/triggers/trigger/jumppads.qc | 9 +-- qcsrc/common/triggers/trigger/keylock.qc | 23 ++----- qcsrc/common/triggers/triggers.qc | 35 ++++------ qcsrc/common/util.qc | 3 +- qcsrc/lib/matrix/matrix.qc | 3 +- qcsrc/lib/net.qh | 6 +- qcsrc/lib/replicate.qh | 5 +- qcsrc/lib/string.qh | 7 ++ qcsrc/lib/urllib.qc | 18 ++--- qcsrc/menu/item/inputbox.qc | 2 +- qcsrc/menu/menu.qc | 9 +-- qcsrc/menu/xonotic/campaign.qc | 3 +- qcsrc/menu/xonotic/cvarlist.qc | 3 +- qcsrc/menu/xonotic/demolist.qc | 3 +- .../menu/xonotic/dialog_multiplayer_create.qc | 12 +--- .../dialog_multiplayer_join_serverinfo.qc | 68 ++++--------------- qcsrc/menu/xonotic/hudskinlist.qc | 10 +-- qcsrc/menu/xonotic/keybinder.qc | 8 +-- qcsrc/menu/xonotic/maplist.qc | 5 +- qcsrc/menu/xonotic/screenshotlist.qc | 5 +- qcsrc/menu/xonotic/serverlist.qc | 15 ++-- qcsrc/menu/xonotic/soundlist.qc | 5 +- qcsrc/menu/xonotic/util.qc | 3 +- qcsrc/server/bot/default/bot.qc | 16 ++--- qcsrc/server/bot/default/scripting.qc | 3 +- qcsrc/server/client.qc | 6 +- qcsrc/server/command/vote.qc | 10 +-- qcsrc/server/g_world.qc | 8 +-- qcsrc/server/ipban.qc | 8 +-- qcsrc/server/mapvoting.qc | 12 +--- qcsrc/server/miscfunctions.qc | 14 +--- qcsrc/server/mutators/mutator/gamemode_ctf.qc | 3 +- qcsrc/server/mutators/mutator/gamemode_cts.qc | 3 +- .../server/mutators/mutator/gamemode_race.qc | 3 +- qcsrc/server/race.qc | 4 +- 66 files changed, 186 insertions(+), 399 deletions(-) diff --git a/qcsrc/client/bgmscript.qc b/qcsrc/client/bgmscript.qc index 2db9e54cf..ae3ff64d3 100644 --- a/qcsrc/client/bgmscript.qc +++ b/qcsrc/client/bgmscript.qc @@ -139,8 +139,7 @@ void BGMScript_InitEntity(entity e) if(i >= bgmscriptbufsize) { LOG_INFOF("ERROR: bgmscript does not define %s", e.bgmscript); - strunzone(e.bgmscript); - e.bgmscript = string_null; + strfree(e.bgmscript); } } } diff --git a/qcsrc/client/commands/cl_cmd.qc b/qcsrc/client/commands/cl_cmd.qc index 8faf0f387..8eea240d4 100644 --- a/qcsrc/client/commands/cl_cmd.qc +++ b/qcsrc/client/commands/cl_cmd.qc @@ -418,7 +418,7 @@ void LocalCommand_sendcvar(int request, int argc) if (argv(1)) { // W_FixWeaponOrder will trash argv, so save what we need. - string thiscvar = strzone(argv(1)); + string thiscvar = string_null; strcpy(thiscvar, argv(1)); string s = cvar_string(thiscvar); if (thiscvar == "cl_weaponpriority") @@ -427,7 +427,7 @@ void LocalCommand_sendcvar(int request, int argc) s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0); localcmd("cmd sentcvar ", thiscvar, " \"", s, "\"\n"); - strunzone(thiscvar); + strfree(thiscvar); return; } } diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index b29cc507b..f8f70c818 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -110,9 +110,7 @@ void reset_centerprint_messages() centerprint_expire_time[i] = 0; centerprint_time[i] = 1; centerprint_msgID[i] = 0; - if(centerprint_messages[i]) - strunzone(centerprint_messages[i]); - centerprint_messages[i] = string_null; + strfree(centerprint_messages[i]); } } float hud_configure_cp_generation_time; diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index b596fb7bd..0bbcb4148 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -619,12 +619,8 @@ void HUD_Mod_Race(vector pos, vector mySize) if (race_status_time - time <= 0) { race_status_prev = -1; race_status = -1; - if(race_status_name) - strunzone(race_status_name); - race_status_name = string_null; - if(race_status_name_prev) - strunzone(race_status_name_prev); - race_status_name_prev = string_null; + strfree(race_status_name); + strfree(race_status_name_prev); } } diff --git a/qcsrc/client/hud/panel/quickmenu.qc b/qcsrc/client/hud/panel/quickmenu.qc index 03a84aeae..b84066b84 100644 --- a/qcsrc/client/hud/panel/quickmenu.qc +++ b/qcsrc/client/hud/panel/quickmenu.qc @@ -52,12 +52,8 @@ void QuickMenu_Page_LoadEntry(int i, string s, string s1) void QuickMenu_Page_ClearEntry(int i) { TC(int, i); - if (QuickMenu_Page_Description[i]) - strunzone(QuickMenu_Page_Description[i]); - QuickMenu_Page_Description[i] = string_null; - if (QuickMenu_Page_Command[i]) - strunzone(QuickMenu_Page_Command[i]); - QuickMenu_Page_Command[i] = string_null; + strfree(QuickMenu_Page_Description[i]); + strfree(QuickMenu_Page_Command[i]); QuickMenu_Page_Command_Type[i] = 0; } @@ -193,9 +189,7 @@ void QuickMenu_Buffer_Close() void QuickMenu_Close() { - if (QuickMenu_CurrentSubMenu) - strunzone(QuickMenu_CurrentSubMenu); - QuickMenu_CurrentSubMenu = string_null; + strfree(QuickMenu_CurrentSubMenu); int i; for (i = 0; i < QUICKMENU_MAXLINES; ++i) QuickMenu_Page_ClearEntry(i); @@ -213,18 +207,17 @@ void QuickMenu_Close() // It assumes submenu open tag is already detected void QuickMenu_skip_submenu(string submenu) { - string s, z_submenu; - z_submenu = strzone(submenu); + string z_submenu = string_null; strcpy(z_submenu, submenu); for(++QuickMenu_Buffer_Index ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index) { - s = QuickMenu_Buffer_Get(); + string s = QuickMenu_Buffer_Get(); if(substring(s, 0, 1) != QM_TAG_SUBMENU) continue; if(substring(s, 1, -1) == z_submenu) // submenu end break; QuickMenu_skip_submenu(substring(s, 1, -1)); } - strunzone(z_submenu); + strfree(z_submenu); } bool QuickMenu_IsOpened() diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index eb1ad9f40..37027d25c 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -555,9 +555,7 @@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew) if(!(nags & BIT(2))) { - if(vote_called_vote) - strunzone(vote_called_vote); - vote_called_vote = string_null; + strfree(vote_called_vote); vote_active = 0; } else @@ -1163,9 +1161,7 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) for (i=pos-1; i<= RANKINGS_CNT-1; ++i) { if (i == RANKINGS_CNT-1) { // clear out last record grecordtime[i] = 0; - if (grecordholder[i]) - strunzone(grecordholder[i]); - grecordholder[i] = string_null; + strfree(grecordholder[i]); } else { grecordtime[i] = grecordtime[i+1]; @@ -1180,9 +1176,7 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) } // store new ranking - if(grecordholder[pos-1] != "") - strunzone(grecordholder[pos-1]); - grecordholder[pos-1] = strzone(ReadString()); + strcpy(grecordholder[pos-1], ReadString()); grecordtime[pos-1] = ReadInt24_t(); if(strdecolorize(grecordholder[pos-1]) == strdecolorize(entcs_GetName(player_localnum))) race_myrank = pos; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index dd184bee9..42a8820e7 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1375,12 +1375,8 @@ void HUD_Crosshair(entity this) wcross_scale_goal_prev = 0; wcross_alpha_goal_prev = 0; wcross_changedonetime = 0; - if(wcross_name_goal_prev) - strunzone(wcross_name_goal_prev); - wcross_name_goal_prev = string_null; - if(wcross_name_goal_prev_prev) - strunzone(wcross_name_goal_prev_prev); - wcross_name_goal_prev_prev = string_null; + strfree(wcross_name_goal_prev); + strfree(wcross_name_goal_prev_prev); wcross_name_changestarttime = 0; wcross_name_changedonetime = 0; wcross_name_alpha_goal_prev = 0; diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc index d847e50ae..600bf5fa8 100644 --- a/qcsrc/client/wall.qc +++ b/qcsrc/client/wall.qc @@ -111,9 +111,7 @@ void Ent_Wall_Draw(entity this) void Ent_Wall_Remove(entity this) { - if(this.bgmscript) - strunzone(this.bgmscript); - this.bgmscript = string_null; + strfree(this.bgmscript); } NET_HANDLE(ENT_CLIENT_WALL, bool isnew) diff --git a/qcsrc/common/campaign_file.qc b/qcsrc/common/campaign_file.qc index d3efe77e8..bc2620339 100644 --- a/qcsrc/common/campaign_file.qc +++ b/qcsrc/common/campaign_file.qc @@ -88,16 +88,15 @@ void CampaignFile_Unload() { if(campaign_title) { - strunzone(campaign_title); + strfree(campaign_title); for(int i = 0; i < campaign_entries; ++i) { - strunzone(campaign_gametype[i]); - strunzone(campaign_mapname[i]); - strunzone(campaign_mutators[i]); - strunzone(campaign_shortdesc[i]); - strunzone(campaign_longdesc[i]); + strfree(campaign_gametype[i]); + strfree(campaign_mapname[i]); + strfree(campaign_mutators[i]); + strfree(campaign_shortdesc[i]); + strfree(campaign_longdesc[i]); } campaign_entries = 0; - campaign_title = string_null; } } diff --git a/qcsrc/common/debug.qh b/qcsrc/common/debug.qh index 936f1e028..983b073b4 100644 --- a/qcsrc/common/debug.qh +++ b/qcsrc/common/debug.qh @@ -411,7 +411,7 @@ CLASS(DebugText3d, Object) } DESTRUCTOR(DebugText3d) { - strunzone(this.message); + strfree(this.message); } void DebugText3d_draw2d(DebugText3d this) { diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index 80f940b91..8c0dfd508 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -237,8 +237,7 @@ .string fld = it.m_playersoundfld; if (this.(fld)) { - strunzone(this.(fld)); - this.(fld) = string_null; + strfree(this.(fld)); } }); } diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index 681b732a9..0eeddc349 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -167,10 +167,8 @@ ENTCS_PROP(FRAGS, true, frags, ENTCS_SET_NORMAL, int n = this.sv_entnum; entity e = entcs_receiver(n); entcs_receiver(n, NULL); - if (e.netname) strunzone(e.netname); - e.netname = string_null; - if (e.model) strunzone(e.model); - e.model = string_null; + strfree(e.netname); + strfree(e.model); if (e != this) delete(e); } diff --git a/qcsrc/common/minigames/minigame/bd.qc b/qcsrc/common/minigames/minigame/bd.qc index 55f4a81a7..b4195c057 100644 --- a/qcsrc/common/minigames/minigame/bd.qc +++ b/qcsrc/common/minigames/minigame/bd.qc @@ -420,7 +420,7 @@ void bd_editor_place(entity minigame, entity player, string pos, int thetile, st if(!piece) return; // how?! - if(piece.netname) { strunzone(piece.netname); } + strfree(piece.netname); delete(piece); minigame_server_sendflags(minigame,MINIG_SF_UPDATE); return; @@ -486,12 +486,12 @@ void bd_unfill_recurse(entity minigame, entity player, int thetype, int letter, if(targ && thetype == targ.bd_tiletype) { - if(targ.netname) { strunzone(targ.netname); } + strfree(targ.netname); delete(targ); } else if(piece && thetype == piece.bd_tiletype) { - if(piece.netname) { strunzone(piece.netname); } + strfree(piece.netname); delete(piece); } else return; @@ -566,7 +566,7 @@ void bd_setup_pieces(entity minigame) while( (e = findentity(e, owner, minigame)) ) if(e.classname == "minigame_board_piece") { - if(e.netname) { strunzone(e.netname); } + strfree(e.netname); delete(e); } e = NULL; @@ -861,7 +861,7 @@ int bd_server_event(entity minigame, string event, ...) while( (e = findentity(e, owner, minigame)) ) if(e.classname == "minigame_board_piece") { - if(e.netname) { strunzone(e.netname); } + strfree(e.netname); delete(e); } e = NULL; @@ -871,8 +871,8 @@ int bd_server_event(entity minigame, string event, ...) delete(e); } - if(minigame.bd_nextlevel) { strunzone(minigame.bd_nextlevel); } - if(minigame.bd_levelname) { strunzone(minigame.bd_levelname); } + strfree(minigame.bd_nextlevel); + strfree(minigame.bd_levelname); return false; } case "join": @@ -1203,8 +1203,7 @@ void bd_editor_fill(entity minigame) void bd_set_curr_pos(string s) { - if ( bd_curr_pos ) - strunzone(bd_curr_pos); + strfree(bd_curr_pos); if ( s ) s = strzone(s); bd_curr_pos = s; diff --git a/qcsrc/common/minigames/minigame/c4.qc b/qcsrc/common/minigames/minigame/c4.qc index b3f5885c2..c8f8184f5 100644 --- a/qcsrc/common/minigames/minigame/c4.qc +++ b/qcsrc/common/minigames/minigame/c4.qc @@ -201,7 +201,7 @@ int c4_server_event(entity minigame, string event, ...) while( (e = findentity(e, owner, minigame)) ) if(e.classname == "minigame_board_piece") { - if(e.netname) { strunzone(e.netname); } + strfree(e.netname); delete(e); } return false; @@ -399,8 +399,7 @@ void c4_make_move(entity minigame) void c4_set_curr_pos(string s) { - if ( c4_curr_pos ) - strunzone(c4_curr_pos); + strfree(c4_curr_pos); if ( s ) s = strzone(s); c4_curr_pos = s; diff --git a/qcsrc/common/minigames/minigame/nmm.qc b/qcsrc/common/minigames/minigame/nmm.qc index 82e09c324..65ac9dee0 100644 --- a/qcsrc/common/minigames/minigame/nmm.qc +++ b/qcsrc/common/minigames/minigame/nmm.qc @@ -126,9 +126,9 @@ void nmm_kill_tiles(entity minig) while ( ( e = findentity(e,owner,minig) ) ) if ( e.classname == "minigame_nmm_tile" ) { - strunzone(e.netname); - strunzone(e.nmm_tile_hmill); - strunzone(e.nmm_tile_vmill); + strfree(e.netname); + strfree(e.nmm_tile_hmill); + strfree(e.nmm_tile_vmill); delete(e); } } diff --git a/qcsrc/common/minigames/minigame/pp.qc b/qcsrc/common/minigames/minigame/pp.qc index 40ddcca08..0b1d74344 100644 --- a/qcsrc/common/minigames/minigame/pp.qc +++ b/qcsrc/common/minigames/minigame/pp.qc @@ -121,7 +121,7 @@ void pp_move(entity minigame, entity player, string pos ) if(existing) { - if(existing.netname) { strunzone(existing.netname); } + strfree(existing.netname); delete(existing); } @@ -215,7 +215,7 @@ int pp_server_event(entity minigame, string event, ...) while( (e = findentity(e, owner, minigame)) ) if(e.classname == "minigame_board_piece") { - if(e.netname) { strunzone(e.netname); } + strfree(e.netname); delete(e); } return false; @@ -471,8 +471,7 @@ void pp_make_move(entity minigame) void pp_set_curr_pos(string s) { - if ( pp_curr_pos ) - strunzone(pp_curr_pos); + strfree(pp_curr_pos); if ( s ) s = strzone(s); pp_curr_pos = s; diff --git a/qcsrc/common/minigames/minigame/ps.qc b/qcsrc/common/minigames/minigame/ps.qc index e3f42ce2d..c8851f2ac 100644 --- a/qcsrc/common/minigames/minigame/ps.qc +++ b/qcsrc/common/minigames/minigame/ps.qc @@ -139,7 +139,7 @@ bool ps_move_piece(entity minigame, entity piece, string pos, int leti, int numb if(!middle) return false; - if(middle.netname) { strunzone(middle.netname); } + strfree(middle.netname); delete(middle); strcpy(piece.netname, pos); @@ -231,7 +231,7 @@ int ps_server_event(entity minigame, string event, ...) while( (e = findentity(e, owner, minigame)) ) if(e.classname == "minigame_board_piece") { - if(e.netname) { strunzone(e.netname); } + strfree(e.netname); delete(e); } return false; @@ -513,8 +513,7 @@ void ps_make_move(entity minigame) void ps_set_curr_pos(string s) { - if ( ps_curr_pos ) - strunzone(ps_curr_pos); + strfree(ps_curr_pos); if ( s ) s = strzone(s); ps_curr_pos = s; diff --git a/qcsrc/common/minigames/minigame/ttt.qc b/qcsrc/common/minigames/minigame/ttt.qc index c5a658054..a6cc50237 100644 --- a/qcsrc/common/minigames/minigame/ttt.qc +++ b/qcsrc/common/minigames/minigame/ttt.qc @@ -147,7 +147,7 @@ int ttt_server_event(entity minigame, string event, ...) while( (e = findentity(e, owner, minigame)) ) if(e.classname == "minigame_board_piece") { - if(e.netname) { strunzone(e.netname); } + strfree(e.netname); delete(e); } return false; @@ -540,8 +540,7 @@ void ttt_make_move(entity minigame) void ttt_set_curr_pos(string s) { - if ( ttt_curr_pos ) - strunzone(ttt_curr_pos); + strfree(ttt_curr_pos); if ( s ) s = strzone(s); ttt_curr_pos = s; diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index 415417b46..5c6af2661 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -248,7 +248,7 @@ void end_minigame(entity minigame_session) delete(e); } - strunzone(minigame_session.netname); + strfree(minigame_session.netname); delete(minigame_session); } diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 8700601da..ccd10ee45 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -276,7 +276,7 @@ void Monster_Sounds_Precache(entity this) void Monster_Sounds_Clear(entity this) { -#define _MSOUND(m) if(this.monstersound_##m) { strunzone(this.monstersound_##m); this.monstersound_##m = string_null; } +#define _MSOUND(m) strfree(this.monstersound_##m); ALLMONSTERSOUNDS #undef _MSOUND } diff --git a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc index d4f487112..5f8d8e682 100644 --- a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc @@ -179,7 +179,7 @@ CLASS(DamageText, Object) } DESTRUCTOR(DamageText) { - if (this.text) strunzone(this.text); + strfree(this.text); if (this == DamageText_screen_first) { // start from 0 offset again, hopefully, others (if any) will have faded away by now DamageText_screen_first = NULL; diff --git a/qcsrc/common/mutators/mutator/sandbox/sv_sandbox.qc b/qcsrc/common/mutators/mutator/sandbox/sv_sandbox.qc index 539525a15..d80b21d5a 100644 --- a/qcsrc/common/mutators/mutator/sandbox/sv_sandbox.qc +++ b/qcsrc/common/mutators/mutator/sandbox/sv_sandbox.qc @@ -212,11 +212,11 @@ void sandbox_ObjectRemove(entity e) // if the object being removed has been selected for attachment by a player, unset it FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.object_attach == e, { it.object_attach = NULL; }); - if(e.material) { strunzone(e.material); e.material = string_null; } - if(e.crypto_idfp) { strunzone(e.crypto_idfp); e.crypto_idfp = string_null; } - if(e.netname) { strunzone(e.netname); e.netname = string_null; } - if(e.message) { strunzone(e.message); e.message = string_null; } - if(e.message2) { strunzone(e.message2); e.message2 = string_null; } + strfree(e.material); + strfree(e.crypto_idfp); + strfree(e.netname); + strfree(e.message); + strfree(e.message2); delete(e); e = NULL; @@ -357,14 +357,14 @@ entity sandbox_ObjectPort_Load(entity this, string s, float database) e.old_movetype = stof(argv(argv_num)); ++argv_num; set_movetype(e, e.old_movetype); e.damageforcescale = stof(argv(argv_num)); ++argv_num; - if(e.material) strunzone(e.material); if(argv(argv_num) != "") e.material = strzone(argv(argv_num)); else e.material = string_null; ++argv_num; + strfree(e.material); if(argv(argv_num) != "") e.material = strzone(argv(argv_num)); else e.material = string_null; ++argv_num; if(database) { // properties stored only for the database - if(e.crypto_idfp) strunzone(e.crypto_idfp); if(argv(argv_num) != "") e.crypto_idfp = strzone(argv(argv_num)); else e.crypto_idfp = string_null; ++argv_num; - if(e.netname) strunzone(e.netname); e.netname = strzone(argv(argv_num)); ++argv_num; - if(e.message) strunzone(e.message); e.message = strzone(argv(argv_num)); ++argv_num; - if(e.message2) strunzone(e.message2); e.message2 = strzone(argv(argv_num)); ++argv_num; + strfree(e.crypto_idfp); if(argv(argv_num) != "") e.crypto_idfp = strzone(argv(argv_num)); else e.crypto_idfp = string_null; ++argv_num; + strcpy(e.netname, argv(argv_num)); ++argv_num; + strcpy(e.message, argv(argv_num)); ++argv_num; + strcpy(e.message2, argv(argv_num)); ++argv_num; } // attach last @@ -702,7 +702,7 @@ MUTATOR_HOOKFUNCTION(sandbox, SV_ParseClientCommand) e.damageforcescale = stof(argv(3)); break; case "material": - if(e.material) strunzone(e.material); + strfree(e.material); if(argv(3)) { for (j = 1; j <= 5; j++) // precache material sounds, 5 in total diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 3f1883b6f..0faf7068c 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -106,9 +106,9 @@ NET_HANDLE(waypointsprites, bool isnew) { void Ent_RemoveWaypointSprite(entity this) { - if (this.netname) strunzone(this.netname); - if (this.netname2) strunzone(this.netname2); - if (this.netname3) strunzone(this.netname3); + strfree(this.netname); + strfree(this.netname2); + strfree(this.netname3); } /** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */ diff --git a/qcsrc/common/notifications/all.qc b/qcsrc/common/notifications/all.qc index 57f0ed8c0..644d049d3 100644 --- a/qcsrc/common/notifications/all.qc +++ b/qcsrc/common/notifications/all.qc @@ -1466,7 +1466,7 @@ void Net_Notification_Remove(entity this) this.owner.nent_name )); #endif - for (int i = 0; i < this.nent_stringcount; ++i) { if (this.nent_strings[i]) strunzone(this.nent_strings[i]); } + for (int i = 0; i < this.nent_stringcount; ++i) { strfree(this.nent_strings[i]); } delete(this); } diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index 0fcd70dfc..cde6a5190 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -154,8 +154,7 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) } } - strunzone(p.playerstats_id); - p.playerstats_id = string_null; + strfree(p.playerstats_id); } void PlayerStats_GameReport(float finished) diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 02a0dc171..ae1a46a61 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -148,8 +148,7 @@ void Item_PreDraw(entity this) void ItemRemove(entity this) { - if(this.mdl) - strunzone(this.mdl); + strfree(this.mdl); } NET_HANDLE(ENT_CLIENT_ITEM, bool isnew) @@ -211,8 +210,7 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew) if(!warpzone_warpzones_exist && this.fade_start && !autocvar_cl_items_nofade) setpredraw(this, Item_PreDraw); - if(this.mdl) - strunzone(this.mdl); + strfree(this.mdl); this.mdl = ""; string _fn = ReadString(); diff --git a/qcsrc/common/triggers/func/ladder.qc b/qcsrc/common/triggers/func/ladder.qc index 92f361a14..020ecca08 100644 --- a/qcsrc/common/triggers/func/ladder.qc +++ b/qcsrc/common/triggers/func/ladder.qc @@ -126,8 +126,7 @@ spawnfunc(func_water) void func_ladder_remove(entity this) { - if(this.classname) { strunzone(this.classname); } - this.classname = string_null; + strfree(this.classname); } NET_HANDLE(ENT_CLIENT_LADDER, bool isnew) diff --git a/qcsrc/common/triggers/func/pointparticles.qc b/qcsrc/common/triggers/func/pointparticles.qc index 93eb83610..602082d18 100644 --- a/qcsrc/common/triggers/func/pointparticles.qc +++ b/qcsrc/common/triggers/func/pointparticles.qc @@ -253,15 +253,9 @@ void Draw_PointParticles(entity this) void Ent_PointParticles_Remove(entity this) { - if(this.noise) - strunzone(this.noise); - this.noise = string_null; - if(this.bgmscript) - strunzone(this.bgmscript); - this.bgmscript = string_null; - if(this.mdl) - strunzone(this.mdl); - this.mdl = string_null; + strfree(this.noise); + strfree(this.bgmscript); + strfree(this.mdl); } NET_HANDLE(ENT_CLIENT_POINTPARTICLES, bool isnew) diff --git a/qcsrc/common/triggers/misc/corner.qc b/qcsrc/common/triggers/misc/corner.qc index 6c9093318..a0f67b759 100644 --- a/qcsrc/common/triggers/misc/corner.qc +++ b/qcsrc/common/triggers/misc/corner.qc @@ -39,23 +39,12 @@ spawnfunc(path_corner) void corner_remove(entity this) { - if(this.target) { strunzone(this.target); } - this.target = string_null; - - if(this.target2) { strunzone(this.target2); } - this.target2 = string_null; - - if(this.target3) { strunzone(this.target3); } - this.target3 = string_null; - - if(this.target4) { strunzone(this.target4); } - this.target4 = string_null; - - if(this.targetname) { strunzone(this.targetname); } - this.targetname = string_null; - - if(this.platmovetype) { strunzone(this.platmovetype); } - this.platmovetype = string_null; + strfree(this.target); + strfree(this.target2); + strfree(this.target3); + strfree(this.target4); + strfree(this.targetname); + strfree(this.platmovetype); } NET_HANDLE(ENT_CLIENT_CORNER, bool isnew) diff --git a/qcsrc/common/triggers/misc/teleport_dest.qc b/qcsrc/common/triggers/misc/teleport_dest.qc index 40c7d46c4..6d32f3c36 100644 --- a/qcsrc/common/triggers/misc/teleport_dest.qc +++ b/qcsrc/common/triggers/misc/teleport_dest.qc @@ -57,13 +57,8 @@ spawnfunc(misc_teleporter_dest) void teleport_dest_remove(entity this) { - //if(this.classname) - //strunzone(this.classname); - //this.classname = string_null; - - if(this.targetname) - strunzone(this.targetname); - this.targetname = string_null; + // strfree(this.classname); + strfree(this.targetname); } NET_HANDLE(ENT_CLIENT_TELEPORT_DEST, bool isnew) diff --git a/qcsrc/common/triggers/target/music.qc b/qcsrc/common/triggers/target/music.qc index 4e7952170..47977f267 100644 --- a/qcsrc/common/triggers/target/music.qc +++ b/qcsrc/common/triggers/target/music.qc @@ -221,8 +221,7 @@ void Net_TargetMusic() if(getsoundtime(e, CH_BGM_SINGLE) < 0) { LOG_TRACEF("Cannot initialize sound %s", e.noise); - strunzone(e.noise); - e.noise = string_null; + strfree(e.noise); } } e.volume = vol; @@ -260,9 +259,7 @@ void Ent_TriggerMusic_Think(entity this) void Ent_TriggerMusic_Remove(entity this) { - if(this.noise) - strunzone(this.noise); - this.noise = string_null; + strfree(this.noise); } NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew) @@ -298,8 +295,7 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew) if(getsoundtime(this, CH_BGM_SINGLE) < 0) { LOG_TRACEF("Cannot initialize sound %s", this.noise); - strunzone(this.noise); - this.noise = string_null; + strfree(this.noise); } } } diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index fde6e1fb9..10a726391 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -606,13 +606,8 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew) void target_push_remove(entity this) { - //if(this.classname) - //strunzone(this.classname); - //this.classname = string_null; - - if(this.targetname) - strunzone(this.targetname); - this.targetname = string_null; + // strfree(this.classname); + strfree(this.targetname); } NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew) diff --git a/qcsrc/common/triggers/trigger/keylock.qc b/qcsrc/common/triggers/trigger/keylock.qc index bf20d1e97..67db14421 100644 --- a/qcsrc/common/triggers/trigger/keylock.qc +++ b/qcsrc/common/triggers/trigger/keylock.qc @@ -164,23 +164,12 @@ spawnfunc(trigger_keylock) #elif defined(CSQC) void keylock_remove(entity this) { - if(this.target) { strunzone(this.target); } - this.target = string_null; - - if(this.target2) { strunzone(this.target2); } - this.target2 = string_null; - - if(this.target3) { strunzone(this.target3); } - this.target3 = string_null; - - if(this.target4) { strunzone(this.target4); } - this.target4 = string_null; - - if(this.killtarget) { strunzone(this.killtarget); } - this.killtarget = string_null; - - if(this.targetname) { strunzone(this.targetname); } - this.targetname = string_null; + strfree(this.target); + strfree(this.target2); + strfree(this.target3); + strfree(this.target4); + strfree(this.killtarget); + strfree(this.targetname); } NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew) diff --git a/qcsrc/common/triggers/triggers.qc b/qcsrc/common/triggers/triggers.qc index f7287212a..0957699b3 100644 --- a/qcsrc/common/triggers/triggers.qc +++ b/qcsrc/common/triggers/triggers.qc @@ -116,12 +116,12 @@ void trigger_common_read(entity this, bool withtarget) if(withtarget) { - if(this.target) { strunzone(this.target); } - if(this.target2) { strunzone(this.target2); } - if(this.target3) { strunzone(this.target3); } - if(this.target4) { strunzone(this.target4); } - if(this.targetname) { strunzone(this.targetname); } - if(this.killtarget) { strunzone(this.killtarget); } + strfree(this.target); + strfree(this.target2); + strfree(this.target3); + strfree(this.target4); + strfree(this.targetname); + strfree(this.killtarget); int targbits = ReadByte(); @@ -158,23 +158,12 @@ void trigger_common_read(entity this, bool withtarget) void trigger_remove_generic(entity this) { - if(this.target) { strunzone(this.target); } - this.target = string_null; - - if(this.target2) { strunzone(this.target2); } - this.target2 = string_null; - - if(this.target3) { strunzone(this.target3); } - this.target3 = string_null; - - if(this.target4) { strunzone(this.target4); } - this.target4 = string_null; - - if(this.targetname) { strunzone(this.targetname); } - this.target = string_null; - - if(this.killtarget) { strunzone(this.killtarget); } - this.killtarget = string_null; + strfree(this.target); + strfree(this.target2); + strfree(this.target3); + strfree(this.target4); + strfree(this.targetname); + strfree(this.killtarget); } #endif diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index e50c4d016..35ec9b2c5 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -1395,8 +1395,7 @@ void execute_next_frame() if(to_execute_next_frame) { localcmd("\n", to_execute_next_frame, "\n"); - strunzone(to_execute_next_frame); - to_execute_next_frame = string_null; + strfree(to_execute_next_frame); } } void queue_to_execute_next_frame(string s) diff --git a/qcsrc/lib/matrix/matrix.qc b/qcsrc/lib/matrix/matrix.qc index c399c2aa6..57754d04e 100644 --- a/qcsrc/lib/matrix/matrix.qc +++ b/qcsrc/lib/matrix/matrix.qc @@ -204,7 +204,8 @@ void MX_Say_(entity fh, entity pass, int status) fh.url_verb = "PUT"; fh.url_content_type = "application/json"; url_fputs(fh, sprintf("{\"msgtype\": \"m.text\", \"body\": \"%s\"}", pass.message)); - strunzone(pass.message); delete(pass); + strfree(pass.message); + delete(pass); url_fclose(fh); break; } diff --git a/qcsrc/lib/net.qh b/qcsrc/lib/net.qh index fe2952e2c..30e973f6c 100644 --- a/qcsrc/lib/net.qh +++ b/qcsrc/lib/net.qh @@ -202,8 +202,7 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); } { if (g_buf == "") return; localcmd("\ncmd c2s \"", strreplace("$", "$$", g_buf), "\"\n"); - strunzone(g_buf); - g_buf = string_null; + strfree(g_buf); } #endif @@ -301,8 +300,7 @@ MACRO_END string s = string_null; yenc_single(b, s); string tmp = strcat(g_buf, s); - if (g_buf) strunzone(g_buf); - g_buf = strzone(tmp); + strcpy(g_buf, tmp); } void WriteShort(int to, int b) { diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index 3dc3cf22b..795f4bde6 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -19,14 +19,13 @@ #define REPLICATE_string(fld, var, func) \ REPLICATE_7(fld, string, var, , \ { strcpy(field, it); }, \ - { if (field) strunzone(field); field = string_null; }, \ + { strfree(field); }, \ { \ /* also initialize to the default value of func when requesting cvars */ \ string s = func(field); \ if (s != field) \ { \ - strunzone(field); \ - field = strzone(s); \ + strcpy(field, s); \ } \ }) #define REPLICATE_float(fld, var, func) REPLICATE_7(fld, float, var, func, { field = stof(it); }, , ) diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index 7142f334c..96e8a3a27 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -53,6 +53,13 @@ this = strzone(s); \ MACRO_END +#define strfree(this) MACRO_BEGIN \ + if (this) { \ + strunzone(this); \ + } \ + this = string_null; \ +MACRO_END + ERASEABLE string seconds_tostring(float sec) { diff --git a/qcsrc/lib/urllib.qc b/qcsrc/lib/urllib.qc index 1572fec07..2ad7bda24 100644 --- a/qcsrc/lib/urllib.qc +++ b/qcsrc/lib/urllib.qc @@ -55,7 +55,7 @@ float url_URI_Get_Callback(int id, float status, string data) { LOG_INFO("url_URI_Get_Callback: out of memory in buf_create"); e.url_ready(e, e.url_ready_pass, URL_READY_ERROR); - strunzone(e.url_url); + strfree(e.url_url); delete(e); return 1; } @@ -64,7 +64,7 @@ float url_URI_Get_Callback(int id, float status, string data) { LOG_INFO("url_URI_Get_Callback: out of memory in buf_create"); e.url_ready(e, e.url_ready_pass, URL_READY_ERROR); - strunzone(e.url_url); + strfree(e.url_url); delete(e); return 1; } @@ -77,7 +77,7 @@ float url_URI_Get_Callback(int id, float status, string data) { // an ERROR e.url_ready(e, e.url_ready_pass, -fabs(status)); - strunzone(e.url_url); + strfree(e.url_url); delete(e); return 1; } @@ -108,7 +108,7 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) { LOG_INFO("url_single_fopen: out of memory in buf_create"); rdy(e, pass, URL_READY_ERROR); - strunzone(e.url_url); + strfree(e.url_url); delete(e); return; } @@ -231,7 +231,7 @@ void url_fclose(entity e) LOG_INFO("url_fclose: too many concurrent requests"); e.url_ready(e, e.url_ready_pass, URL_READY_ERROR); buf_del(e.url_wbuf); - strunzone(e.url_url); + strfree(e.url_url); delete(e); return; } @@ -243,7 +243,7 @@ void url_fclose(entity e) LOG_INFO("url_fclose: failure in crypto_uri_postbuf"); e.url_ready(e, e.url_ready_pass, URL_READY_ERROR); buf_del(e.url_wbuf); - strunzone(e.url_url); + strfree(e.url_url); delete(e); return; } @@ -264,7 +264,7 @@ void url_fclose(entity e) // we have READ all data, just close e.url_ready(e, e.url_ready_pass, URL_READY_CLOSED); buf_del(e.url_rbuf); - strunzone(e.url_url); + strfree(e.url_url); delete(e); } } @@ -341,7 +341,7 @@ void url_multi_ready(entity fh, entity me, float status) { LOG_INFO("uri_multi_ready: got HTTP error 422, data is in unusable format - not continuing"); me.url_ready(fh, me.url_ready_pass, status); - strunzone(me.url_url); + strfree(me.url_url); delete(me); return; } @@ -350,7 +350,7 @@ void url_multi_ready(entity fh, entity me, float status) if (n <= me.url_attempt) { me.url_ready(fh, me.url_ready_pass, status); - strunzone(me.url_url); + strfree(me.url_url); delete(me); return; } diff --git a/qcsrc/menu/item/inputbox.qc b/qcsrc/menu/item/inputbox.qc index a418dc2ce..d02f4661f 100644 --- a/qcsrc/menu/item/inputbox.qc +++ b/qcsrc/menu/item/inputbox.qc @@ -22,7 +22,7 @@ void InputBox_setText(entity me, string txt) { - if (me.text) strunzone(me.text); + strfree(me.text); SUPER(InputBox).setText(me, strzone(txt)); } diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index ea5ce8561..fb6c4aeed 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -217,8 +217,7 @@ void m_init_delayed() if (m_goto_buffer) { m_goto(m_goto_buffer); - strunzone(m_goto_buffer); - m_goto_buffer = string_null; + strfree(m_goto_buffer); } if (Menu_Active) m_display(); // delayed menu display @@ -633,11 +632,7 @@ void m_tooltip(vector pos) if (menuTooltipItem == NULL) { - if (menuTooltipText) - { - strunzone(menuTooltipText); - menuTooltipText = string_null; - } + strfree(menuTooltipText); return; } else diff --git a/qcsrc/menu/xonotic/campaign.qc b/qcsrc/menu/xonotic/campaign.qc index ac9dc8618..9f953f66f 100644 --- a/qcsrc/menu/xonotic/campaign.qc +++ b/qcsrc/menu/xonotic/campaign.qc @@ -14,8 +14,7 @@ void rewrapCampaign(float w, float l0, float emptyheight, vector theFontSize) for(i = 0; i < campaign_entries; ++i) { l = l0; - if(campaign_longdesc_wrapped[i]) - strunzone(campaign_longdesc_wrapped[i]); + strfree(campaign_longdesc_wrapped[i]); n = tokenizebyseparator(campaign_longdesc[i], "\n"); r = ""; for(j = 0; j < n; ++j) diff --git a/qcsrc/menu/xonotic/cvarlist.qc b/qcsrc/menu/xonotic/cvarlist.qc index 98dba015d..9587d5432 100644 --- a/qcsrc/menu/xonotic/cvarlist.qc +++ b/qcsrc/menu/xonotic/cvarlist.qc @@ -107,8 +107,7 @@ void XonoticCvarList_setSelected(entity me, float i) if(me.nItems == 0) return; - if(me.cvarType) - strunzone(me.cvarType); + strfree(me.cvarType); strcpy(me.cvarName, bufstr_get(me.handle, me.selectedItem)); strcpy(me.cvarDescription, cvar_description(me.cvarName)); strcpy(me.cvarDefault, cvar_defstring(me.cvarName)); diff --git a/qcsrc/menu/xonotic/demolist.qc b/qcsrc/menu/xonotic/demolist.qc index b527542a5..16d5370f5 100644 --- a/qcsrc/menu/xonotic/demolist.qc +++ b/qcsrc/menu/xonotic/demolist.qc @@ -129,8 +129,7 @@ void DemoList_Refresh_Click(entity btn, entity me) void DemoList_Filter_Change(entity box, entity me) { - if(me.filterString) - strunzone(me.filterString); + strfree(me.filterString); if(box.text != "") { diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc index 481914200..2a2144598 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc @@ -27,16 +27,8 @@ void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, // clear old values for(i = 0; i < e.nValues; ++i); { - if(e.(valueStrings[i])) - { - strunzone(e.(valueStrings[i])); - e.(valueStrings[i]) = string_null; - } - if(e.(valueIdentifiers[i])) - { - strunzone(e.(valueIdentifiers[i])); - e.(valueIdentifiers[i]) = string_null; - } + strfree(e.(valueStrings[i])); + strfree(e.(valueIdentifiers[i])); } e.clearValues(e); diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc index baeb9a51b..5745ce072 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc @@ -16,61 +16,21 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i) // ==================================== // First clear and unzone the strings // ==================================== - if(me.currentServerName) - strunzone(me.currentServerName); - me.currentServerName = string_null; - - if(me.currentServerCName) - strunzone(me.currentServerCName); - me.currentServerCName = string_null; - - if(me.currentServerType) - strunzone(me.currentServerType); - me.currentServerType = string_null; - - if(me.currentServerMap) - strunzone(me.currentServerMap); - me.currentServerMap = string_null; - - if(me.currentServerPlayers) - strunzone(me.currentServerPlayers); - me.currentServerPlayers = string_null; - - if(me.currentServerNumPlayers) - strunzone(me.currentServerNumPlayers); - me.currentServerNumPlayers = string_null; - - if(me.currentServerNumBots) - strunzone(me.currentServerNumBots); - me.currentServerNumBots = string_null; - - if(me.currentServerNumFreeSlots) - strunzone(me.currentServerNumFreeSlots); - me.currentServerNumFreeSlots = string_null; - - if(me.currentServerMod) - strunzone(me.currentServerMod); - me.currentServerMod = string_null; - - if(me.currentServerVersion) - strunzone(me.currentServerVersion); - me.currentServerVersion = string_null; - + strfree(me.currentServerName); + strfree(me.currentServerCName); + strfree(me.currentServerType); + strfree(me.currentServerMap); + strfree(me.currentServerPlayers); + strfree(me.currentServerNumPlayers); + strfree(me.currentServerNumBots); + strfree(me.currentServerNumFreeSlots); + strfree(me.currentServerMod); + strfree(me.currentServerVersion); // not zoned! - //if(me.currentServerEncrypt) - // strunzone(me.currentServerEncrypt); - //me.currentServerEncrypt = string_null; - if(me.currentServerPure) - strunzone(me.currentServerPure); - me.currentServerPure = string_null; - - if(me.currentServerKey) - strunzone(me.currentServerKey); - me.currentServerKey = string_null; - - if(me.currentServerID) - strunzone(me.currentServerID); - me.currentServerID = string_null; + // strfree(me.currentServerEncrypt); + strfree(me.currentServerPure); + strfree(me.currentServerKey); + strfree(me.currentServerID); // ========================== // Now, fill in the strings diff --git a/qcsrc/menu/xonotic/hudskinlist.qc b/qcsrc/menu/xonotic/hudskinlist.qc index 66c96046d..d97d7131a 100644 --- a/qcsrc/menu/xonotic/hudskinlist.qc +++ b/qcsrc/menu/xonotic/hudskinlist.qc @@ -188,19 +188,15 @@ void HUDSkinList_Refresh_Click(entity btn, entity me) void HUDSkinList_SavedName_Change(entity box, entity me) { - if(me.savedName) - strunzone(me.savedName); + strfree(me.savedName); if(box.text != "") me.savedName = strzone(box.text); - else - me.savedName = string_null; } void HUDSkinList_Filter_Change(entity box, entity me) { - if(me.filterString) - strunzone(me.filterString); + strfree(me.filterString); if(box.text != "") { @@ -209,8 +205,6 @@ void HUDSkinList_Filter_Change(entity box, entity me) else me.filterString = strzone(strcat("*", box.text, "*")); } - else - me.filterString = string_null; me.getHUDSkins(me); } diff --git a/qcsrc/menu/xonotic/keybinder.qc b/qcsrc/menu/xonotic/keybinder.qc index 1f28a1bdf..cde80d693 100644 --- a/qcsrc/menu/xonotic/keybinder.qc +++ b/qcsrc/menu/xonotic/keybinder.qc @@ -246,12 +246,8 @@ void XonoticKeyBinder_destroy(entity me) for(int i = 0; i < MAX_KEYBINDS; ++i) { - if(Xonotic_KeyBinds_Functions[i]) - strunzone(Xonotic_KeyBinds_Functions[i]); - Xonotic_KeyBinds_Functions[i] = string_null; - if(Xonotic_KeyBinds_Descriptions[i]) - strunzone(Xonotic_KeyBinds_Descriptions[i]); - Xonotic_KeyBinds_Descriptions[i] = string_null; + strfree(Xonotic_KeyBinds_Functions[i]); + strfree(Xonotic_KeyBinds_Descriptions[i]); } Xonotic_KeyBinds_Count = 0; } diff --git a/qcsrc/menu/xonotic/maplist.qc b/qcsrc/menu/xonotic/maplist.qc index 20ee6673f..73ef8a32a 100644 --- a/qcsrc/menu/xonotic/maplist.qc +++ b/qcsrc/menu/xonotic/maplist.qc @@ -215,12 +215,9 @@ void XonoticMapList_refilterCallback(entity me, entity cb) void MapList_StringFilterBox_Change(entity box, entity me) { - if(me.stringFilter) - strunzone(me.stringFilter); + strfree(me.stringFilter); if(box.text != "") me.stringFilter = strzone(box.text); - else - me.stringFilter = string_null; me.refilter(me); } diff --git a/qcsrc/menu/xonotic/screenshotlist.qc b/qcsrc/menu/xonotic/screenshotlist.qc index a948ce86f..de0adc793 100644 --- a/qcsrc/menu/xonotic/screenshotlist.qc +++ b/qcsrc/menu/xonotic/screenshotlist.qc @@ -153,8 +153,7 @@ void ScreenshotList_Refresh_Click(entity btn, entity me) void ScreenshotList_Filter_Change(entity box, entity me) { - if(me.filterString) - strunzone(me.filterString); + strfree(me.filterString); if(box.text != "") { @@ -163,8 +162,6 @@ void ScreenshotList_Filter_Change(entity box, entity me) else me.filterString = strzone(strcat("*", box.text, "*")); } - else - me.filterString = string_null; ScreenshotList_Refresh_Click(NULL, me); } diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 11ab47116..325dfdc57 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -37,8 +37,7 @@ void RegisterSLCategories() } } \ if(catnum) \ { \ - strunzone(categories[i].override_string); \ - categories[i].override_string = string_null; \ + strfree(categories[i].override_string); \ categories[i].override_field = catnum; \ continue; \ } \ @@ -51,8 +50,7 @@ void RegisterSLCategories() ); \ } \ } \ - strunzone(categories[i].override_string); \ - categories[i].override_string = string_null; \ + strfree(categories[i].override_string); \ categories[i].override_field = 0; \ } PROCESS_OVERRIDE(cat_enoverride_string, cat_enoverride) @@ -660,12 +658,9 @@ void ServerList_TypeSort_Click(entity btn, entity me) } void ServerList_Filter_Change(entity box, entity me) { - if(me.filterString) - strunzone(me.filterString); + strfree(me.filterString); if(box.text != "") me.filterString = strzone(box.text); - else - me.filterString = string_null; me.refreshServerList(me, REFRESHSERVERLIST_REFILTER); me.ipAddressBox.setText(me.ipAddressBox, ""); @@ -711,9 +706,7 @@ void XonoticServerList_setSortOrder(entity me, int fld, int direction) me.sortButton4.forcePressed = 0; me.sortButton5.forcePressed = (fld == SLIST_FIELD_NUMHUMANS); me.selectedItem = 0; - if(me.selectedServer) - strunzone(me.selectedServer); - me.selectedServer = string_null; + strfree(me.selectedServer); me.refreshServerList(me, REFRESHSERVERLIST_REFILTER); } void XonoticServerList_positionSortButton(entity me, entity btn, float theOrigin, float theSize, string theTitle, void(entity, entity) theFunc) diff --git a/qcsrc/menu/xonotic/soundlist.qc b/qcsrc/menu/xonotic/soundlist.qc index 13e6ba34c..6d77e1adf 100644 --- a/qcsrc/menu/xonotic/soundlist.qc +++ b/qcsrc/menu/xonotic/soundlist.qc @@ -104,13 +104,10 @@ void SoundList_Menu_Track_Reset(entity box, entity me) void SoundList_Filter_Change(entity box, entity me) { - if(me.filterString) - strunzone(me.filterString); + strfree(me.filterString); if(box.text != "") me.filterString = strzone(box.text); - else - me.filterString = string_null; me.getSounds(me); } diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index cb8369ff0..c9cd001ba 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -267,8 +267,7 @@ void setZonedTooltip(entity e, string theTooltip, string theCvar) theTooltip = string_null; } - if(e.tooltip) - strunzone(e.tooltip); + strfree(e.tooltip); e.tooltip = (theTooltip != "") ? strzone(theTooltip) : string_null; } diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index a605fc068..b4272e3e0 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -396,18 +396,10 @@ void bot_clientdisconnect(entity this) if (!IS_BOT_CLIENT(this)) return; bot_clearqueue(this); - if(this.cleanname) - strunzone(this.cleanname); - if(this.netname_freeme) - strunzone(this.netname_freeme); - if(this.playermodel_freeme) - strunzone(this.playermodel_freeme); - if(this.playerskin_freeme) - strunzone(this.playerskin_freeme); - this.cleanname = string_null; - this.netname_freeme = string_null; - this.playermodel_freeme = string_null; - this.playerskin_freeme = string_null; + strfree(this.cleanname); + strfree(this.netname_freeme); + strfree(this.playermodel_freeme); + strfree(this.playerskin_freeme); if(this.bot_cmd_current) delete(this.bot_cmd_current); if(bot_waypoint_queue_owner == this) diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index ba2fc3df7..82d82cb59 100644 --- a/qcsrc/server/bot/default/scripting.qc +++ b/qcsrc/server/bot/default/scripting.qc @@ -1168,8 +1168,7 @@ void bot_resetqueues() it.bot_barrier = 0; for(int i = 0; i < it.bot_places_count; ++i) { - strunzone(it.(bot_placenames[i])); - it.(bot_placenames[i]) = string_null; + strfree(it.(bot_placenames[i])); } it.bot_places_count = 0; }); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 08b85b4ce..663d16ed7 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1352,8 +1352,8 @@ void ClientDisconnect(entity this) MUTATOR_CALLHOOK(ClientDisconnect, this); - if (CS(this).netname_previous) strunzone(CS(this).netname_previous); // needs to be before the CS entity is removed! - if (CS(this).weaponorder_byimpulse) strunzone(CS(this).weaponorder_byimpulse); + strfree(CS(this).netname_previous); // needs to be before the CS entity is removed! + strfree(CS(this).weaponorder_byimpulse); ClientState_detach(this); Portal_ClearAll(this); @@ -1373,7 +1373,7 @@ void ClientDisconnect(entity this) bot_relinkplayerlist(); - if (this.clientstatus) strunzone(this.clientstatus); + strfree(this.clientstatus); if (this.personal) delete(this.personal); this.playerid = 0; diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 7a30d1ddc..638dbb156 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -128,19 +128,15 @@ void VoteReset() if (vote_called) { - strunzone(vote_called_command); - strunzone(vote_called_display); - strunzone(vote_caller_name); + strfree(vote_called_command); + strfree(vote_called_display); + strfree(vote_caller_name); } vote_called = VOTE_NULL; vote_caller = NULL; - vote_caller_name = string_null; vote_endtime = 0; - vote_called_command = string_null; - vote_called_display = string_null; - vote_parsed_command = string_null; vote_parsed_display = string_null; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index d74c4b800..b9c626431 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -145,12 +145,8 @@ void cvar_changes_init() string k, v, d; float n, i, adding, pureadding; - if(cvar_changes) - strunzone(cvar_changes); - cvar_changes = string_null; - if(cvar_purechanges) - strunzone(cvar_purechanges); - cvar_purechanges = string_null; + strfree(cvar_changes); + strfree(cvar_purechanges); cvar_purechanges_count = 0; h = buf_create(); diff --git a/qcsrc/server/ipban.qc b/qcsrc/server/ipban.qc index 98dbf5c55..cf0eb13b7 100644 --- a/qcsrc/server/ipban.qc +++ b/qcsrc/server/ipban.qc @@ -211,12 +211,8 @@ void OnlineBanList_Think(entity this) if(argc == 0) goto killme; - if(OnlineBanList_Servers) - strunzone(OnlineBanList_Servers); - OnlineBanList_Servers = argv(0); - for(i = 1; i < argc; ++i) - OnlineBanList_Servers = strcat(OnlineBanList_Servers, ";", argv(i)); - OnlineBanList_Servers = strzone(OnlineBanList_Servers); + string s = argv(0); for(i = 1; i < argc; ++i) s = strcat(s, ";", argv(i)); + strcpy(OnlineBanList_Servers, s); uri = strcat( "action=list&hostname=", uri_escape(autocvar_hostname)); uri = strcat(uri, "&servers=", uri_escape(OnlineBanList_Servers)); diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index 209ac7af9..816945d2a 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -109,16 +109,8 @@ void MapVote_UnzoneStrings() { for(int j = 0; j < mapvote_count; ++j) { - if ( mapvote_maps[j] ) - { - strunzone(mapvote_maps[j]); - mapvote_maps[j] = string_null; - } - if ( mapvote_maps_pakfile[j] ) - { - strunzone(mapvote_maps_pakfile[j]); - mapvote_maps_pakfile[j] = string_null; - } + strfree(mapvote_maps[j]); + strfree(mapvote_maps_pakfile[j]); } } diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index c905c2773..bbbefd5a8 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -298,9 +298,7 @@ void GetCvars_handleString(entity this, entity store, string thisname, float f, { if (f < 0) { - if (store.(field)) - strunzone(store.(field)); - store.(field) = string_null; + strfree(store.(field)); } else if (f > 0) { @@ -363,14 +361,8 @@ void GetCvars_handleFloatOnce(entity this, entity store, string thisname, float } string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo) { - string o; - o = W_FixWeaponOrder_ForceComplete(wo); - if(CS(this).weaponorder_byimpulse) - { - strunzone(CS(this).weaponorder_byimpulse); - CS(this).weaponorder_byimpulse = string_null; - } - CS(this).weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(o)); + string o = W_FixWeaponOrder_ForceComplete(wo); + strcpy(CS(this).weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(o)); return o; } diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index b34e3f59f..e0d25e9e8 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -2249,8 +2249,7 @@ MUTATOR_HOOKFUNCTION(ctf, GetPressedKeys) if(player.stored_netname != player.netname) { db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname); - strunzone(player.stored_netname); - player.stored_netname = strzone(player.netname); + strcpy(player.stored_netname, player.netname); } } } diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index daaf8a969..1363411aa 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -286,8 +286,7 @@ MUTATOR_HOOKFUNCTION(cts, GetPressedKeys) if(player.stored_netname != player.netname) { db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname); - strunzone(player.stored_netname); - player.stored_netname = strzone(player.netname); + strcpy(player.stored_netname, player.netname); } } diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index aa6d12a83..e4109b72a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -325,8 +325,7 @@ MUTATOR_HOOKFUNCTION(rc, GetPressedKeys) if(player.stored_netname != player.netname) { db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname); - strunzone(player.stored_netname); - player.stored_netname = strzone(player.netname); + strcpy(player.stored_netname, player.netname); } } diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 80b811a45..743d02d03 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -1083,9 +1083,7 @@ void race_ClearRecords() for(int j = 0; j < MAX_CHECKPOINTS; ++j) { race_checkpoint_records[j] = 0; - if(race_checkpoint_recordholders[j]) - strunzone(race_checkpoint_recordholders[j]); - race_checkpoint_recordholders[j] = string_null; + strfree(race_checkpoint_recordholders[j]); } FOREACH_CLIENT(true, { -- 2.39.2