From 04eab4332c011c1bb8cde236055daf8b6bcd311c Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 8 Apr 2018 01:54:07 +1000 Subject: [PATCH] Add strcpy to reduce explicit use of strzone/strunzone --- qcsrc/client/hud/hud.qc | 12 +-- qcsrc/client/hud/hud.qh | 4 +- qcsrc/client/hud/hud_config.qc | 4 +- qcsrc/client/hud/panel/centerprint.qc | 4 +- qcsrc/client/hud/panel/chat.qc | 4 +- qcsrc/client/hud/panel/modicons.qc | 4 +- qcsrc/client/hud/panel/quickmenu.qc | 12 +-- qcsrc/client/hud/panel/radar.qc | 4 +- qcsrc/client/hud/panel/scoreboard.qc | 16 ++-- qcsrc/client/hud/panel/vote.qc | 4 +- qcsrc/client/hud/panel/weapons.qc | 9 +-- qcsrc/client/main.qc | 77 ++++++------------- qcsrc/client/miscfunctions.qc | 4 +- qcsrc/client/mutators/events.qh | 2 +- qcsrc/client/wall.qc | 10 +-- qcsrc/common/effects/qc/globalsound.qc | 6 +- qcsrc/common/ent_cs.qc | 10 +-- qcsrc/common/minigames/minigame/bd.qc | 21 ++--- qcsrc/common/minigames/minigame/ps.qc | 3 +- qcsrc/common/monsters/sv_monsters.qc | 4 +- .../mutator/damagetext/cl_damagetext.qc | 3 +- .../mutators/mutator/sandbox/sv_sandbox.qc | 9 +-- .../mutator/waypoints/waypointsprites.qc | 12 +-- qcsrc/common/notifications/all.qc | 3 +- qcsrc/common/triggers/func/pointparticles.qc | 8 +- qcsrc/common/triggers/target/music.qc | 8 +- qcsrc/common/util.qc | 17 ++-- qcsrc/lib/matrix/command.qc | 6 +- qcsrc/lib/oo.qh | 8 +- qcsrc/lib/replicate.qh | 2 +- qcsrc/lib/string.qh | 7 ++ qcsrc/menu/item/label.qc | 6 +- qcsrc/menu/menu.qc | 9 +-- qcsrc/menu/mutators/events.qh | 2 +- qcsrc/menu/xonotic/campaign.qc | 8 +- qcsrc/menu/xonotic/crosshairpreview.qc | 4 +- qcsrc/menu/xonotic/cvarlist.qc | 12 +-- .../dialog_multiplayer_create_mapinfo.qc | 18 ++--- .../dialog_multiplayer_create_mutators.qc | 8 +- .../dialog_multiplayer_media_screenshot.qc | 4 +- ...log_multiplayer_media_screenshot_viewer.qc | 4 +- qcsrc/menu/xonotic/maplist.qc | 12 +-- qcsrc/menu/xonotic/playermodel.qc | 17 +--- qcsrc/menu/xonotic/screenshotimage.qc | 4 +- qcsrc/menu/xonotic/serverlist.qc | 12 +-- qcsrc/menu/xonotic/util.qc | 3 +- qcsrc/server/bot/default/scripting.qc | 4 +- qcsrc/server/campaign.qc | 3 +- qcsrc/server/client.qc | 3 +- qcsrc/server/g_world.qc | 4 +- qcsrc/server/miscfunctions.qc | 7 +- qcsrc/server/mutators/events.qh | 2 +- qcsrc/server/race.qc | 12 +-- qcsrc/server/scores.qc | 8 +- qcsrc/server/teamplay.qc | 8 +- qcsrc/server/weapons/weaponsystem.qc | 3 +- 56 files changed, 142 insertions(+), 332 deletions(-) diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index 9bcdd3d66..01799cacc 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -579,12 +579,8 @@ void HUD_Main() // Drawing stuff if (hud_skin_prev != autocvar_hud_skin) { - if (hud_skin_path) - strunzone(hud_skin_path); - hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin)); - if (hud_skin_prev) - strunzone(hud_skin_prev); - hud_skin_prev = strzone(autocvar_hud_skin); + strcpy(hud_skin_path, strcat("gfx/hud/", autocvar_hud_skin)); + strcpy(hud_skin_prev, autocvar_hud_skin); } // draw the dock @@ -659,9 +655,7 @@ void HUD_Main() LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder"); cvar_set("_hud_panelorder", s); - if(hud_panelorder_prev) - strunzone(hud_panelorder_prev); - hud_panelorder_prev = strzone(s); + strcpy(hud_panelorder_prev, s); //now properly set panel_order tokenize_console(s); diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index d070dce38..dcc72efff 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -264,9 +264,7 @@ REGISTER_HUD_PANEL(SCOREBOARD, Scoreboard_Draw, PANEL_CONFIG_NO } \ } \ } \ - if (panel.current_panel_bg) \ - strunzone(panel.current_panel_bg); \ - panel.current_panel_bg = strzone(panel_bg); \ + strcpy(panel.current_panel_bg, panel_bg); \ } MACRO_END // Get value for panel_bg_color: if "" fetch default, else use panel_bg_color. Convert pants, shirt or teamcolor into a vector. diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index ec07ee409..3c93a6d64 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -1029,9 +1029,7 @@ void HUD_Panel_FirstInDrawQ(float id) s = strcat(s, ftos(panel_order[i]), " "); } cvar_set("_hud_panelorder", s); - if(hud_panelorder_prev) - strunzone(hud_panelorder_prev); - hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here + strcpy(hud_panelorder_prev, autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here } void HUD_Panel_Highlight(float allow_move) diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index a92bdc692..b29cc507b 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -75,9 +75,7 @@ void centerprint_generic(int new_id, string strMessage, float duration, int coun cpm_index = CENTERPRINT_MAX_MSGS - 1; j = cpm_index; } - if(centerprint_messages[j]) - strunzone(centerprint_messages[j]); - centerprint_messages[j] = strzone(strMessage); + strcpy(centerprint_messages[j], strMessage); centerprint_msgID[j] = new_id; if (duration < 0) { diff --git a/qcsrc/client/hud/panel/chat.qc b/qcsrc/client/hud/panel/chat.qc index 74d4b6d0f..5f309d0b0 100644 --- a/qcsrc/client/hud/panel/chat.qc +++ b/qcsrc/client/hud/panel/chat.qc @@ -48,9 +48,7 @@ void HUD_Chat() panel_bg = strcat(hud_skin_path, "/border_default"); if(precache_pic(panel_bg) == "") panel_bg = "gfx/hud/default/border_default"; - if(panel.current_panel_bg) - strunzone(panel.current_panel_bg); - panel.current_panel_bg = strzone(panel_bg); + strcpy(panel.current_panel_bg, panel_bg); chat_panel_modified = true; } panel_bg_alpha = max(0.75, panel_bg_alpha); diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 65682b3ec..b596fb7bd 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -583,9 +583,7 @@ void HUD_Mod_Race(vector pos, vector mySize) if (race_status != race_status_prev || race_status_name != race_status_name_prev) { race_status_time = time + 5; race_status_prev = race_status; - if (race_status_name_prev) - strunzone(race_status_name_prev); - race_status_name_prev = strzone(race_status_name); + strcpy(race_status_name_prev, race_status_name); } // race "awards" diff --git a/qcsrc/client/hud/panel/quickmenu.qc b/qcsrc/client/hud/panel/quickmenu.qc index ba3e5f0cb..03a84aeae 100644 --- a/qcsrc/client/hud/panel/quickmenu.qc +++ b/qcsrc/client/hud/panel/quickmenu.qc @@ -45,12 +45,8 @@ void QuickMenu_Page_LoadEntry(int i, string s, string s1) { TC(int, i); //LOG_INFOF("^xc80 entry %d: %s, %s\n", i, s, s1); - if (QuickMenu_Page_Description[i]) - strunzone(QuickMenu_Page_Description[i]); - QuickMenu_Page_Description[i] = strzone(s); - if (QuickMenu_Page_Command[i]) - strunzone(QuickMenu_Page_Command[i]); - QuickMenu_Page_Command[i] = strzone(s1); + strcpy(QuickMenu_Page_Description[i], s); + strcpy(QuickMenu_Page_Command[i], s1); } void QuickMenu_Page_ClearEntry(int i) @@ -273,9 +269,7 @@ bool QuickMenu_Page_Load(string target_submenu, bool new_page) ++QuickMenu_Page; z_submenu = strzone(target_submenu); - if (QuickMenu_CurrentSubMenu) - strunzone(QuickMenu_CurrentSubMenu); - QuickMenu_CurrentSubMenu = strzone(z_submenu); + strcpy(QuickMenu_CurrentSubMenu, z_submenu); QuickMenu_IsLastPage = true; QuickMenu_Page_Entries = 0; diff --git a/qcsrc/client/hud/panel/radar.qc b/qcsrc/client/hud/panel/radar.qc index b1cc222cc..f0ec01c9e 100644 --- a/qcsrc/client/hud/panel/radar.qc +++ b/qcsrc/client/hud/panel/radar.qc @@ -214,9 +214,7 @@ void HUD_Radar() panel_bg = "gfx/hud/default/border_default"; // fallback if(!radar_panel_modified && panel_bg != panel.current_panel_bg) radar_panel_modified = true; - if(panel.current_panel_bg) - strunzone(panel.current_panel_bg); - panel.current_panel_bg = strzone(panel_bg); + strcpy(panel.current_panel_bg, panel_bg); switch(hud_panel_radar_maximized_zoommode) { diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 5e4a31f1e..96d30aa52 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -448,8 +448,7 @@ void Cmd_Scoreboard_SetFields(int argc) continue; } - strunzone(sbt_field_title[sbt_num_fields]); - sbt_field_title[sbt_num_fields] = strzone(TranslateScoresLabel(str)); + strcpy(sbt_field_title[sbt_num_fields], TranslateScoresLabel(str)); sbt_field_size[sbt_num_fields] = stringwidth(sbt_field_title[sbt_num_fields], false, hud_fontsize); str = strtolower(str); @@ -540,8 +539,7 @@ LABEL(found) } else if(!have_separator) { - strunzone(sbt_field_title[sbt_num_fields]); - sbt_field_title[sbt_num_fields] = strzone("|"); + strcpy(sbt_field_title[sbt_num_fields], "|"); sbt_field_size[sbt_num_fields] = stringwidth("|", false, hud_fontsize); sbt_field[sbt_num_fields] = SP_SEPARATOR; ++sbt_num_fields; @@ -549,8 +547,7 @@ LABEL(found) } if(!have_secondary) { - strunzone(sbt_field_title[sbt_num_fields]); - sbt_field_title[sbt_num_fields] = strzone(TranslateScoresLabel(scores_label(ps_secondary))); + strcpy(sbt_field_title[sbt_num_fields], TranslateScoresLabel(scores_label(ps_secondary))); sbt_field_size[sbt_num_fields] = stringwidth(sbt_field_title[sbt_num_fields], false, hud_fontsize); sbt_field[sbt_num_fields] = ps_secondary; ++sbt_num_fields; @@ -558,8 +555,7 @@ LABEL(found) } if(!have_primary) { - strunzone(sbt_field_title[sbt_num_fields]); - sbt_field_title[sbt_num_fields] = strzone(TranslateScoresLabel(scores_label(ps_primary))); + strcpy(sbt_field_title[sbt_num_fields], TranslateScoresLabel(scores_label(ps_primary))); sbt_field_size[sbt_num_fields] = stringwidth(sbt_field_title[sbt_num_fields], false, hud_fontsize); sbt_field[sbt_num_fields] = ps_primary; ++sbt_num_fields; @@ -1489,9 +1485,7 @@ void Scoreboard_Draw() { hud_fontsize = HUD_GetFontsize("hud_fontsize"); Scoreboard_initFieldSizes(); - if(hud_fontsize_str) - strunzone(hud_fontsize_str); - hud_fontsize_str = strzone(autocvar_hud_fontsize); + strcpy(hud_fontsize_str, autocvar_hud_fontsize); } } else { diff --git a/qcsrc/client/hud/panel/vote.qc b/qcsrc/client/hud/panel/vote.qc index 15e18e8f4..57b32039d 100644 --- a/qcsrc/client/hud/panel/vote.qc +++ b/qcsrc/client/hud/panel/vote.qc @@ -27,9 +27,7 @@ void HUD_Vote() LOG_INFO(_("^1You must answer before entering hud configure mode")); cvar_set("_hud_configure", "0"); } - if(vote_called_vote) - strunzone(vote_called_vote); - vote_called_vote = strzone(_("^2Name ^7instead of \"^1Anonymous player^7\" in stats")); + strcpy(vote_called_vote, _("^2Name ^7instead of \"^1Anonymous player^7\" in stats")); uid2name_dialog = 1; } diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index 70c4c1013..4506f69a0 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -94,13 +94,8 @@ void HUD_Weapons() if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0]) { int weapon_cnt; - if(weaponorder_bypriority) - strunzone(weaponorder_bypriority); - if(weaponorder_byimpulse) - strunzone(weaponorder_byimpulse); - - weaponorder_bypriority = strzone(autocvar_cl_weaponpriority); - weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority)))); + strcpy(weaponorder_bypriority, autocvar_cl_weaponpriority); + strcpy(weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority)))); weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " "); weapon_cnt = 0; diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 9c146c09b..eb1ad9f40 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -575,9 +575,7 @@ NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew) if(nags & BIT(7)) { - if(vote_called_vote) - strunzone(vote_called_vote); - vote_called_vote = strzone(ReadString()); + strcpy(vote_called_vote, ReadString()); } if(nags & 1) @@ -959,14 +957,12 @@ NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew) teamplay = _MapInfo_GetTeamPlayBool(gametype); HUD_ModIcons_SetFunc(); FOREACH(Scores, true, { - if (scores_label(it)) strunzone(scores_label(it)); - scores_label(it) = strzone(ReadString()); + strcpy(scores_label(it), ReadString()); scores_flags(it) = ReadByte(); }); for (int i = 0; i < MAX_TEAMSCORE; ++i) { - if (teamscores_label(i)) strunzone(teamscores_label(i)); - teamscores_label(i) = strzone(ReadString()); + strcpy(teamscores_label(i), ReadString()); teamscores_flags(i) = ReadByte(); } return = true; @@ -987,8 +983,7 @@ NET_HANDLE(ENT_CLIENT_INIT, bool isnew) arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t()); arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t()); - if (forcefog) strunzone(forcefog); - forcefog = strzone(ReadString()); + strcpy(forcefog, ReadString()); armorblockpercent = ReadByte() / 255.0; damagepush_speedfactor = ReadByte() / 255.0; @@ -1051,17 +1046,15 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_time = ReadInt24_t(); race_previousbesttime = ReadInt24_t(); race_mypreviousbesttime = ReadInt24_t(); - if(race_previousbestname) - strunzone(race_previousbestname); string pbestname = ReadString(); if(autocvar_cl_race_cptimes_onlyself) { race_previousbesttime = race_mypreviousbesttime; race_mypreviousbesttime = 0; - race_previousbestname = strzone(""); + strcpy(race_previousbestname, ""); } else - race_previousbestname = strzone(pbestname); + strcpy(race_previousbestname, pbestname); race_checkpointtime = time; @@ -1087,17 +1080,15 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_nextbesttime = ReadInt24_t(); if(b != RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING) // not while spectating (matches server) race_mybesttime = ReadInt24_t(); - if(race_nextbestname) - strunzone(race_nextbestname); string newname = ReadString(); if(autocvar_cl_race_cptimes_onlyself && b != RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING) { race_nextbesttime = race_mybesttime; race_mybesttime = 0; - race_nextbestname = strzone(""); + strcpy(race_nextbestname, ""); } else - race_nextbestname = strzone(newname); + strcpy(race_nextbestname, newname); break; case RACE_NET_CHECKPOINT_HIT_RACE: @@ -1107,13 +1098,11 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_mycheckpointlapsdelta = ReadByte(); if(race_mycheckpointlapsdelta >= 128) race_mycheckpointlapsdelta -= 256; - if(race_mycheckpointenemy) - strunzone(race_mycheckpointenemy); int who = ReadByte(); if(who) - race_mycheckpointenemy = strzone(entcs_GetName(who - 1)); + strcpy(race_mycheckpointenemy, entcs_GetName(who - 1)); else - race_mycheckpointenemy = strzone(""); // TODO: maybe string_null works fine here? + strcpy(race_mycheckpointenemy, ""); // TODO: maybe string_null works fine here? break; case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT: @@ -1123,31 +1112,25 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_othercheckpointlapsdelta = ReadByte(); if(race_othercheckpointlapsdelta >= 128) race_othercheckpointlapsdelta -= 256; - if(race_othercheckpointenemy) - strunzone(race_othercheckpointenemy); int what = ReadByte(); if(what) - race_othercheckpointenemy = strzone(entcs_GetName(what - 1)); + strcpy(race_othercheckpointenemy, entcs_GetName(what - 1)); else - race_othercheckpointenemy = strzone(""); // TODO: maybe string_null works fine here? + strcpy(race_othercheckpointenemy, ""); // TODO: maybe string_null works fine here? break; case RACE_NET_PENALTY_RACE: race_penaltyeventtime = time; race_penaltytime = ReadShort(); //race_penaltyaccumulator += race_penaltytime; - if(race_penaltyreason) - strunzone(race_penaltyreason); - race_penaltyreason = strzone(ReadString()); + strcpy(race_penaltyreason, ReadString()); break; case RACE_NET_PENALTY_QUALIFYING: race_penaltyeventtime = time; race_penaltytime = ReadShort(); race_penaltyaccumulator += race_penaltytime; - if(race_penaltyreason) - strunzone(race_penaltyreason); - race_penaltyreason = strzone(ReadString()); + strcpy(race_penaltyreason, ReadString()); break; case RACE_NET_SERVER_RECORD: @@ -1155,21 +1138,13 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) break; case RACE_NET_SPEED_AWARD: race_speedaward = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit); - if(race_speedaward_holder) - strunzone(race_speedaward_holder); - race_speedaward_holder = strzone(ReadString()); - if(race_speedaward_unit) - strunzone(race_speedaward_unit); - race_speedaward_unit = strzone(GetSpeedUnit(autocvar_hud_panel_physics_speed_unit)); + strcpy(race_speedaward_holder, ReadString()); + strcpy(race_speedaward_unit, GetSpeedUnit(autocvar_hud_panel_physics_speed_unit)); break; case RACE_NET_SPEED_AWARD_BEST: race_speedaward_alltimebest = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit); - if(race_speedaward_alltimebest_holder) - strunzone(race_speedaward_alltimebest_holder); - race_speedaward_alltimebest_holder = strzone(ReadString()); - if(race_speedaward_alltimebest_unit) - strunzone(race_speedaward_alltimebest_unit); - race_speedaward_alltimebest_unit = strzone(GetSpeedUnit(autocvar_hud_panel_physics_speed_unit)); + strcpy(race_speedaward_alltimebest_holder, ReadString()); + strcpy(race_speedaward_alltimebest_unit, GetSpeedUnit(autocvar_hud_panel_physics_speed_unit)); break; case RACE_NET_SERVER_RANKINGS: float prevpos, del; @@ -1182,9 +1157,7 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) if (prevpos) { for (i=prevpos-1;i>pos-1;--i) { grecordtime[i] = grecordtime[i-1]; - if(grecordholder[i]) - strunzone(grecordholder[i]); - grecordholder[i] = strzone(grecordholder[i-1]); + strcpy(grecordholder[i], grecordholder[i-1]); } } else if (del) { // a record has been deleted by the admin for (i=pos-1; i<= RANKINGS_CNT-1; ++i) { @@ -1196,17 +1169,13 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) } else { grecordtime[i] = grecordtime[i+1]; - if (grecordholder[i]) - strunzone(grecordholder[i]); - grecordholder[i] = strzone(grecordholder[i+1]); + strcpy(grecordholder[i], grecordholder[i+1]); } } } else { // player has no ranked record yet for (i=RANKINGS_CNT-1;i>pos-1;--i) { grecordtime[i] = grecordtime[i-1]; - if(grecordholder[i]) - strunzone(grecordholder[i]); - grecordholder[i] = strzone(grecordholder[i-1]); + strcpy(grecordholder[i], grecordholder[i-1]); } } @@ -1220,9 +1189,7 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) break; case RACE_NET_SERVER_STATUS: race_status = ReadShort(); - if(race_status_name) - strunzone(race_status_name); - race_status_name = strzone(ReadString()); + strcpy(race_status_name, ReadString()); } return true; } diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index fd1647ddc..01409280a 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -577,9 +577,7 @@ void Accuracy_LoadLevels() { if(autocvar_accuracy_color_levels != acc_color_levels) { - if(acc_color_levels) - strunzone(acc_color_levels); - acc_color_levels = strzone(autocvar_accuracy_color_levels); + strcpy(acc_color_levels, autocvar_accuracy_color_levels); acc_levels = tokenize_console(acc_color_levels); if(acc_levels > MAX_ACCURACY_LEVELS) acc_levels = MAX_ACCURACY_LEVELS; diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 5edb84ae0..cc6fced9b 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -3,7 +3,7 @@ #include // register all possible hooks here - + // to use a hook, first register your mutator using REGISTER_MUTATOR // then create your function using MUTATOR_HOOKFUNCTION diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc index b57280954..d847e50ae 100644 --- a/qcsrc/client/wall.qc +++ b/qcsrc/client/wall.qc @@ -186,17 +186,15 @@ NET_HANDLE(ENT_CLIENT_WALL, bool isnew) this.mins = this.maxs = '0 0 0'; setsize(this, this.mins, this.maxs); - if(this.bgmscript) - strunzone(this.bgmscript); - this.bgmscript = ReadString(); - if(substring(this.bgmscript, 0, 1) == "<") + string s = ReadString(); + if(substring(s, 0, 1) == "<") { - this.bgmscript = strzone(substring(this.bgmscript, 1, -1)); + strcpy(this.bgmscript, substring(s, 1, -1)); this.bgmscriptangular = 1; } else { - this.bgmscript = strzone(this.bgmscript); + strcpy(this.bgmscript, s); this.bgmscriptangular = 0; } if(this.bgmscript != "") diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index 4875a40ee..80f940b91 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -269,8 +269,7 @@ } string file = argv(1); string variants = argv(2); - if (this.(field)) strunzone(this.(field)); - this.(field) = strzone(strcat(file, " ", variants)); + strcpy(this.(field), strcat(file, " ", variants)); } fclose(fh); return true; @@ -284,8 +283,7 @@ void UpdatePlayerSounds(entity this) { if (this.model == this.model_for_playersound && this.skin == this.skin_for_playersound) return; - if (this.model_for_playersound) strunzone(this.model_for_playersound); - this.model_for_playersound = strzone(this.model); + strcpy(this.model_for_playersound, this.model); this.skin_for_playersound = this.skin; ClearPlayerSounds(this); LoadPlayerSounds(this, "sound/player/default.sounds", true); diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index 12abc21b1..681b732a9 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -39,8 +39,7 @@ MACRO_END /** the engine player name strings are mutable! */ #define ENTCS_SET_MUTABLE_STRING(var, x) MACRO_BEGIN \ - if (var) strunzone(var); \ - var = strzone(x); \ + strcpy(var, x); \ MACRO_END ENTCS_PROP(ENTNUM, false, sv_entnum, ENTCS_SET_NORMAL, {}, {}) /* sentinel */ @@ -63,11 +62,11 @@ ENTCS_PROP(ARMOR, false, armorvalue, ENTCS_SET_NORMAL, ENTCS_PROP(NAME, true, netname, ENTCS_SET_MUTABLE_STRING, { WriteString(chan, ent.netname); }, - { if (ent.netname) strunzone(ent.netname); ent.netname = strzone(ReadString()); }) + { strcpy(ent.netname, ReadString()); }) ENTCS_PROP(MODEL, true, model, ENTCS_SET_NORMAL, { WriteString(chan, ent.model); }, - { if (ent.model) strunzone(ent.model); ent.model = strzone(ReadString()); }) + { strcpy(ent.model, ReadString()); }) ENTCS_PROP(SKIN, true, skin, ENTCS_SET_NORMAL, { WriteByte(chan, ent.skin); }, @@ -188,8 +187,7 @@ ENTCS_PROP(FRAGS, true, frags, ENTCS_SET_NORMAL, // `cl_forceplayermodels 1` sounds will be wrong until the player has been in the PVS, but so be it if (this.model != e.model) { - if (this.model) strunzone(this.model); - this.model = strzone(e.model); + strcpy(this.model, e.model); } } diff --git a/qcsrc/common/minigames/minigame/bd.qc b/qcsrc/common/minigames/minigame/bd.qc index 4790f1f1f..55f4a81a7 100644 --- a/qcsrc/common/minigames/minigame/bd.qc +++ b/qcsrc/common/minigames/minigame/bd.qc @@ -309,8 +309,7 @@ bool bd_move_dozer(entity minigame, entity dozer) case BD_TILE_BRICK1: return false; } - if(hit.netname) { strunzone(hit.netname); } - hit.netname = strzone(testpos); + strcpy(hit.netname, testpos); minigame_server_sendflags(hit,MINIG_SF_UPDATE); break; } @@ -330,8 +329,7 @@ bool bd_move_dozer(entity minigame, entity dozer) case BD_TILE_BRICK1: return false; } - if(dozer.netname) { strunzone(dozer.netname); } - dozer.netname = strzone(newpos); + strcpy(dozer.netname, newpos); return true; } @@ -598,8 +596,7 @@ void bd_do_next_match(entity minigame, entity player) if(minigame.bd_nextlevel && minigame.bd_nextlevel != "") { - if(minigame.bd_levelname) { strunzone(minigame.bd_levelname); } - minigame.bd_levelname = strzone(minigame.bd_nextlevel); + strcpy(minigame.bd_levelname, minigame.bd_nextlevel); } bd_setup_pieces(minigame); @@ -609,8 +606,7 @@ void bd_do_next_match(entity minigame, entity player) void bd_set_next_match(entity minigame, string next) { - if(minigame.bd_nextlevel) { strunzone(minigame.bd_nextlevel); } - minigame.bd_nextlevel = strzone(next); + strcpy(minigame.bd_nextlevel, next); } void bd_next_match(entity minigame, entity player, string next) @@ -678,8 +674,7 @@ void bd_set_nextlevel(entity minigame, string s) { tokenize_console(s); - if(minigame.bd_nextlevel) { strunzone(minigame.bd_nextlevel); } - minigame.bd_nextlevel = strzone(argv(2)); + strcpy(minigame.bd_nextlevel, argv(2)); } int bd_fix_dir(vector dir) @@ -854,8 +849,7 @@ int bd_server_event(entity minigame, string event, ...) { case "start": { - if(minigame.bd_levelname) { strunzone(minigame.bd_levelname); } - minigame.bd_levelname = strzone(autocvar_sv_minigames_bulldozer_startlevel); + strcpy(minigame.bd_levelname, autocvar_sv_minigames_bulldozer_startlevel); bd_setup_pieces(minigame); minigame.minigame_flags = BD_TURN_MOVE; @@ -1386,8 +1380,7 @@ int bd_client_event(entity minigame, string event, ...) { int letter = ReadByte(); int number = ReadByte(); - if(sent.netname) { strunzone(sent.netname); } - sent.netname = strzone(minigame_tile_buildname(letter, number)); + strcpy(sent.netname, minigame_tile_buildname(letter, number)); sent.bd_tiletype = ReadByte(); diff --git a/qcsrc/common/minigames/minigame/ps.qc b/qcsrc/common/minigames/minigame/ps.qc index cd5c001e7..e3f42ce2d 100644 --- a/qcsrc/common/minigames/minigame/ps.qc +++ b/qcsrc/common/minigames/minigame/ps.qc @@ -142,8 +142,7 @@ bool ps_move_piece(entity minigame, entity piece, string pos, int leti, int numb if(middle.netname) { strunzone(middle.netname); } delete(middle); - if(piece.netname) { strunzone(piece.netname); } - piece.netname = strzone(pos); + strcpy(piece.netname, pos); minigame_server_sendflags(piece,MINIG_SF_ALL); diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index bf019b9cf..8700601da 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -311,9 +311,7 @@ bool Monster_Sounds_Load(entity this, string f, int first) field = Monster_Sound_SampleField(argv(0)); if(GetMonsterSoundSampleField_notFound) continue; - if (this.(field)) - strunzone(this.(field)); - this.(field) = strzone(strcat(argv(1), " ", argv(2))); + strcpy(this.(field), strcat(argv(1), " ", argv(2))); } fclose(fh); return true; diff --git a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc index 0977b62ce..d4f487112 100644 --- a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc @@ -155,8 +155,7 @@ CLASS(DamageText, Object) ); } - if (this.text) strunzone(this.text); - this.text = strzone(s); + strcpy(this.text, s); this.m_size = map_bound_ranges(potential, autocvar_cl_damagetext_size_min_damage, autocvar_cl_damagetext_size_max_damage, diff --git a/qcsrc/common/mutators/mutator/sandbox/sv_sandbox.qc b/qcsrc/common/mutators/mutator/sandbox/sv_sandbox.qc index d121cf109..539525a15 100644 --- a/qcsrc/common/mutators/mutator/sandbox/sv_sandbox.qc +++ b/qcsrc/common/mutators/mutator/sandbox/sv_sandbox.qc @@ -718,8 +718,7 @@ MUTATOR_HOOKFUNCTION(sandbox, SV_ParseClientCommand) } // update last editing time - if(e.message2) strunzone(e.message2); - e.message2 = strzone(strftime(true, "%d-%m-%Y %H:%M:%S")); + strcpy(e.message2, strftime(true, "%d-%m-%Y %H:%M:%S")); if(autocvar_g_sandbox_info > 1) LOG_INFO("^3SANDBOX - SERVER: ^7", player.netname, " edited property ^3", argv(2), " ^7of an object at origin ^3", vtos(e.origin)); @@ -745,8 +744,7 @@ MUTATOR_HOOKFUNCTION(sandbox, SV_ParseClientCommand) // also update the player's nickname if he changed it (but has the same player UID) if(e.netname != player.netname) { - if(e.netname) strunzone(e.netname); - e.netname = strzone(player.netname); + strcpy(e.netname, player.netname); print_to(player, "^2SANDBOX - INFO: ^7Object owner name updated"); } @@ -756,8 +754,7 @@ MUTATOR_HOOKFUNCTION(sandbox, SV_ParseClientCommand) return true; } - if(e.crypto_idfp) strunzone(e.crypto_idfp); - e.crypto_idfp = strzone(player.crypto_idfp); + strcpy(e.crypto_idfp, player.crypto_idfp); print_to(player, "^2SANDBOX - INFO: ^7Object claimed successfully"); } diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index be5b40c14..3f1883b6f 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -169,23 +169,17 @@ void Ent_WaypointSprite(entity this, bool isnew) if (sendflags & 2) { - if (this.netname) - strunzone(this.netname); - this.netname = strzone(ReadString()); + strcpy(this.netname, ReadString()); } if (sendflags & 4) { - if (this.netname2) - strunzone(this.netname2); - this.netname2 = strzone(ReadString()); + strcpy(this.netname2, ReadString()); } if (sendflags & 8) { - if (this.netname3) - strunzone(this.netname3); - this.netname3 = strzone(ReadString()); + strcpy(this.netname3, ReadString()); } if (sendflags & 16) diff --git a/qcsrc/common/notifications/all.qc b/qcsrc/common/notifications/all.qc index b9350758a..57f0ed8c0 100644 --- a/qcsrc/common/notifications/all.qc +++ b/qcsrc/common/notifications/all.qc @@ -1063,8 +1063,7 @@ void Local_Notification_sound(int soundchannel, string soundfile, float soundvol _sound(NULL, soundchannel, AnnouncerFilename(soundfile), soundvolume, soundposition); - if (prev_soundfile) strunzone(prev_soundfile); - prev_soundfile = strzone(soundfile); + strcpy(prev_soundfile, soundfile); prev_soundtime = time; } else diff --git a/qcsrc/common/triggers/func/pointparticles.qc b/qcsrc/common/triggers/func/pointparticles.qc index 54fe212ae..93eb83610 100644 --- a/qcsrc/common/triggers/func/pointparticles.qc +++ b/qcsrc/common/triggers/func/pointparticles.qc @@ -323,17 +323,13 @@ NET_HANDLE(ENT_CLIENT_POINTPARTICLES, bool isnew) this.waterlevel = 0; this.count = 1; } - if(this.noise) - strunzone(this.noise); - if(this.bgmscript) - strunzone(this.bgmscript); - this.noise = strzone(ReadString()); + strcpy(this.noise, ReadString()); if(this.noise != "") { this.atten = ReadByte() / 64.0; this.volume = ReadByte() / 255.0; } - this.bgmscript = strzone(ReadString()); + strcpy(this.bgmscript, ReadString()); if(this.bgmscript != "") { this.bgmscriptattack = ReadByte() / 64.0; diff --git a/qcsrc/common/triggers/target/music.qc b/qcsrc/common/triggers/target/music.qc index 7ec335138..4e7952170 100644 --- a/qcsrc/common/triggers/target/music.qc +++ b/qcsrc/common/triggers/target/music.qc @@ -215,9 +215,7 @@ void Net_TargetMusic() } if(e.noise != noi) { - if(e.noise) - strunzone(e.noise); - e.noise = strzone(noi); + strcpy(e.noise, noi); precache_sound(e.noise); _sound(e, CH_BGM_SINGLE, e.noise, 0, ATTEN_NONE); if(getsoundtime(e, CH_BGM_SINGLE) < 0) @@ -292,9 +290,7 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew) this.fade_time = ReadByte() / 16.0; this.fade_rate = ReadByte() / 16.0; string s = this.noise; - if(this.noise) - strunzone(this.noise); - this.noise = strzone(ReadString()); + strcpy(this.noise, ReadString()); if(this.noise != s) { precache_sound(this.noise); diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index deba86c28..e50c4d016 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -453,14 +453,12 @@ void get_mi_min_max(float mode) { vector mi, ma; - if(mi_shortname) - strunzone(mi_shortname); - mi_shortname = mapname; - if(!strcasecmp(substring(mi_shortname, 0, 5), "maps/")) - mi_shortname = substring(mi_shortname, 5, strlen(mi_shortname) - 5); - if(!strcasecmp(substring(mi_shortname, strlen(mi_shortname) - 4, 4), ".bsp")) - mi_shortname = substring(mi_shortname, 0, strlen(mi_shortname) - 4); - mi_shortname = strzone(mi_shortname); + string s = mapname; + if(!strcasecmp(substring(s, 0, 5), "maps/")) + s = substring(s, 5, strlen(s) - 5); + if(!strcasecmp(substring(s, strlen(s) - 4, 4), ".bsp")) + s = substring(s, 0, strlen(s) - 4); + strcpy(mi_shortname, s); #ifdef CSQC mi = world.mins; @@ -1406,9 +1404,8 @@ void queue_to_execute_next_frame(string s) if(to_execute_next_frame) { s = strcat(s, "\n", to_execute_next_frame); - strunzone(to_execute_next_frame); } - to_execute_next_frame = strzone(s); + strcpy(to_execute_next_frame, s); } .float FindConnectedComponent_processing; diff --git a/qcsrc/lib/matrix/command.qc b/qcsrc/lib/matrix/command.qc index 449aa373b..1b58eb1b9 100644 --- a/qcsrc/lib/matrix/command.qc +++ b/qcsrc/lib/matrix/command.qc @@ -5,12 +5,10 @@ GENERIC_COMMAND(mx, "Send a matrix command") { switch (argv(1)) { case "user": - if (matrix_user) strunzone(matrix_user); - matrix_user = strzone(substring(command, argv_start_index(2), -1)); + strcpy(matrix_user, substring(command, argv_start_index(2), -1)); break; case "token": - if (matrix_access_token) strunzone(matrix_access_token); - matrix_access_token = strzone(substring(command, argv_start_index(2), -1)); + strcpy(matrix_access_token, substring(command, argv_start_index(2), -1)); break; case "messages": MX_Messages(string_null); diff --git a/qcsrc/lib/oo.qh b/qcsrc/lib/oo.qh index bd1d34666..08de37474 100644 --- a/qcsrc/lib/oo.qh +++ b/qcsrc/lib/oo.qh @@ -261,18 +261,14 @@ STATIC_INIT(RegisterClasses) class(cname).type name; \ INIT(cname) \ { \ - if (this.name) \ - strunzone(this.name); \ - this.name = strzone(val); \ + strcpy(this.name, val); \ } #define STATIC_ATTRIB_STRZONE(cname, name, type, val) \ type cname##_##name; \ _INIT_STATIC(cname) \ { \ - if (cname##_##name) \ - strunzone(cname##_##name); \ - cname##_##name = val; \ + strcpy(cname##_##name, val); \ } #define ATTRIBARRAY(cname, name, type, cnt) \ diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index c7a42042d..3dc3cf22b 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -18,7 +18,7 @@ #define REPLICATE_4(fld, type, var, func) REPLICATE_##type(fld, var, func) #define REPLICATE_string(fld, var, func) \ REPLICATE_7(fld, string, var, , \ - { if (field) strunzone(field); field = strzone(it); }, \ + { strcpy(field, it); }, \ { if (field) strunzone(field); field = string_null; }, \ { \ /* also initialize to the default value of func when requesting cvars */ \ diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index 812eb72c8..d79552187 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -27,6 +27,13 @@ } #endif +#define strcpy(this, s) MACRO_BEGIN \ + if (this) { \ + strunzone(this); \ + } \ + this = strzone(s); \ +MACRO_END + ERASEABLE string seconds_tostring(float sec) { diff --git a/qcsrc/menu/item/label.qc b/qcsrc/menu/item/label.qc index d21b5676b..f7a782dab 100644 --- a/qcsrc/menu/item/label.qc +++ b/qcsrc/menu/item/label.qc @@ -9,8 +9,7 @@ me.text = txt; if (txt != me.currentText) { - if (me.currentText) strunzone(me.currentText); - me.currentText = strzone(txt); + strcpy(me.currentText, txt); me.recalcPos = 1; } } @@ -112,8 +111,7 @@ t = me.textEntity.toString(me.textEntity); if (t != me.currentText) { - if (me.currentText) strunzone(me.currentText); - me.currentText = strzone(t); + strcpy(me.currentText, t); me.recalcPos = 1; } } diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index af14e0842..ea5ce8561 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -550,8 +550,7 @@ void m_tooltip(vector pos) { // fade out if tooltip of a certain item has changed menuTooltipState = 3; - if (prev_tooltip) strunzone(prev_tooltip); - prev_tooltip = strzone(it.tooltip); + strcpy(prev_tooltip, it.tooltip); } else if (menuTooltipItem && !m_testmousetooltipbox(pos)) { @@ -584,8 +583,7 @@ void m_tooltip(vector pos) menuTooltipOrigin.x = -1; // unallocated - if (menuTooltipText) strunzone(menuTooltipText); - menuTooltipText = strzone(gettooltip()); + strcpy(menuTooltipText, gettooltip()); int i = 0; float w = 0; @@ -953,8 +951,7 @@ void m_goto(string itemname) { if (!menuInitialized) { - if (m_goto_buffer) strunzone(m_goto_buffer); - m_goto_buffer = strzone(itemname); + strcpy(m_goto_buffer, itemname); return; } if (itemname == "") // this can be called by GameCommand diff --git a/qcsrc/menu/mutators/events.qh b/qcsrc/menu/mutators/events.qh index 0c5056b97..af1b7f632 100644 --- a/qcsrc/menu/mutators/events.qh +++ b/qcsrc/menu/mutators/events.qh @@ -3,7 +3,7 @@ #include // register all possible hooks here - + // to use a hook, first register your mutator using REGISTER_MUTATOR // then create your function using MUTATOR_HOOKFUNCTION diff --git a/qcsrc/menu/xonotic/campaign.qc b/qcsrc/menu/xonotic/campaign.qc index cb418a4e1..ac9dc8618 100644 --- a/qcsrc/menu/xonotic/campaign.qc +++ b/qcsrc/menu/xonotic/campaign.qc @@ -70,12 +70,8 @@ void XonoticCampaignList_destroy(entity me) void XonoticCampaignList_loadCvars(entity me) { // read campaign cvars - if(campaign_name) - strunzone(campaign_name); - if(me.cvarName) - strunzone(me.cvarName); - campaign_name = strzone(cvar_string("g_campaign_name")); - me.cvarName = strzone(strcat("g_campaign", campaign_name, "_index")); + strcpy(campaign_name, cvar_string("g_campaign_name")); + strcpy(me.cvarName, strcat("g_campaign", campaign_name, "_index")); registercvar(me.cvarName, "", 0); // saved by server QC anyway CampaignFile_Unload(); CampaignFile_Load(0, CAMPAIGN_MAX_ENTRIES); diff --git a/qcsrc/menu/xonotic/crosshairpreview.qc b/qcsrc/menu/xonotic/crosshairpreview.qc index e11d7dcc0..f3c3fe24f 100644 --- a/qcsrc/menu/xonotic/crosshairpreview.qc +++ b/qcsrc/menu/xonotic/crosshairpreview.qc @@ -25,9 +25,7 @@ void XonoticCrosshairPreview_draw(entity me) float a; rgb = stov(cvar_string("crosshair_color")); a = cvar("crosshair_alpha"); - if(me.src) - strunzone(me.src); - me.src = strzone(strcat("/gfx/crosshair", cvar_string("crosshair"))); + strcpy(me.src, strcat("/gfx/crosshair", cvar_string("crosshair"))); sz = draw_PictureSize(me.src); sz = globalToBoxSize(sz, me.size); diff --git a/qcsrc/menu/xonotic/cvarlist.qc b/qcsrc/menu/xonotic/cvarlist.qc index 12bb2810b..98dba015d 100644 --- a/qcsrc/menu/xonotic/cvarlist.qc +++ b/qcsrc/menu/xonotic/cvarlist.qc @@ -107,17 +107,11 @@ void XonoticCvarList_setSelected(entity me, float i) if(me.nItems == 0) return; - if(me.cvarName) - strunzone(me.cvarName); - if(me.cvarDescription) - strunzone(me.cvarDescription); if(me.cvarType) strunzone(me.cvarType); - if(me.cvarDefault) - strunzone(me.cvarDefault); - me.cvarName = strzone(bufstr_get(me.handle, me.selectedItem)); - me.cvarDescription = strzone(cvar_description(me.cvarName)); - me.cvarDefault = strzone(cvar_defstring(me.cvarName)); + strcpy(me.cvarName, bufstr_get(me.handle, me.selectedItem)); + strcpy(me.cvarDescription, cvar_description(me.cvarName)); + strcpy(me.cvarDefault, cvar_defstring(me.cvarName)); me.cvarNameBox.setText(me.cvarNameBox, me.cvarName); me.cvarDescriptionBox.setText(me.cvarDescriptionBox, me.cvarDescription); float needsForcing = me.updateCvarType(me); diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc index 2f2ab901a..87ffadf38 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc @@ -12,19 +12,11 @@ void XonoticMapInfoDialog_loadMapInfo(entity me, int i, entity mlb) me.startButton.onClickEntity = mlb; MapInfo_Get_ByID(i); - if(me.currentMapBSPName) - { - strunzone(me.currentMapBSPName); - strunzone(me.currentMapTitle); - strunzone(me.currentMapAuthor); - strunzone(me.currentMapDescription); - strunzone(me.currentMapPreviewImage); - } - me.currentMapBSPName = strzone(MapInfo_Map_bspname); - me.currentMapTitle = strzone(strdecolorize(MapInfo_Map_title)); - me.currentMapAuthor = strzone(strdecolorize(MapInfo_Map_author)); - me.currentMapDescription = strzone(MapInfo_Map_description); - me.currentMapPreviewImage = strzone(strcat("/maps/", MapInfo_Map_bspname)); + strcpy(me.currentMapBSPName, MapInfo_Map_bspname); + strcpy(me.currentMapTitle, strdecolorize(MapInfo_Map_title)); + strcpy(me.currentMapAuthor, strdecolorize(MapInfo_Map_author)); + strcpy(me.currentMapDescription, MapInfo_Map_description); + strcpy(me.currentMapPreviewImage, strcat("/maps/", MapInfo_Map_bspname)); me.frame.setText(me.frame, me.currentMapBSPName); me.titleLabel.setText(me.titleLabel, me.currentMapTitle); diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc index 022bed03d..994c5a7c9 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc @@ -30,12 +30,8 @@ string WeaponArenaString() return _("Most Weapons Arena"); if(s == weaponarenastring_cvar) return weaponarenastring; - if(weaponarenastring) - strunzone(weaponarenastring); - if(weaponarenastring_cvar) - strunzone(weaponarenastring_cvar); - weaponarenastring_cvar = strzone(s); + strcpy(weaponarenastring_cvar, s); n = tokenize_console(s); s = ""; @@ -48,7 +44,7 @@ string WeaponArenaString() } s = sprintf(_("%s Arena"), s); - weaponarenastring = strzone(s); + strcpy(weaponarenastring, s); return weaponarenastring; } diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot.qc b/qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot.qc index 1229be714..afde0914a 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot.qc @@ -19,9 +19,7 @@ void XonoticScreenshotBrowserTab_loadPreviewScreenshot(entity me, string scrImag { if (me.currentScrPath == scrImage) return; - if (me.currentScrPath) - strunzone(me.currentScrPath); - me.currentScrPath = strzone(scrImage); + strcpy(me.currentScrPath, scrImage); me.screenshotImage.load(me.screenshotImage, me.currentScrPath); } void XonoticScreenshotBrowserTab_fill(entity me) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot_viewer.qc b/qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot_viewer.qc index d6d545eee..57dd75679 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot_viewer.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot_viewer.qc @@ -24,9 +24,7 @@ void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage) if (me.currentScrPath == scrImage) return; - if (me.currentScrPath) - strunzone(me.currentScrPath); - me.currentScrPath = strzone(scrImage); + strcpy(me.currentScrPath, scrImage); me.screenshotImage.load(me.screenshotImage, me.currentScrPath); me.frame.setText(me.frame, me.screenshotImage.screenshotTitle); } diff --git a/qcsrc/menu/xonotic/maplist.qc b/qcsrc/menu/xonotic/maplist.qc index 111744e96..20ee6673f 100644 --- a/qcsrc/menu/xonotic/maplist.qc +++ b/qcsrc/menu/xonotic/maplist.qc @@ -181,8 +181,6 @@ void XonoticMapList_refilter(entity me) for(i = 0; i < MapInfo_count; ++i) draw_PreloadPicture(strcat("/maps/", MapInfo_BSPName_ByID(i))); - if(me.g_maplistCache) - strunzone(me.g_maplistCache); s = "0"; for(i = 1; i < MapInfo_count; i *= 2) s = strcat(s, s); @@ -201,7 +199,7 @@ void XonoticMapList_refilter(entity me) ); } } - me.g_maplistCache = strzone(s); + strcpy(me.g_maplistCache, s); if(gt != me.lastGametype || f != me.lastFeatures) { me.lastGametype = gt; @@ -345,9 +343,7 @@ float XonoticMapList_keyDown(entity me, float scan, float ascii, float shift) if(time < me.typeToSearchTime) { save = substring(me.typeToSearchString, 0, strlen(me.typeToSearchString) - 1); - if(me.typeToSearchString) - strunzone(me.typeToSearchString); - me.typeToSearchString = strzone(save); + strcpy(me.typeToSearchString, save); me.typeToSearchTime = time + 0.5; if(strlen(me.typeToSearchString)) { @@ -364,9 +360,7 @@ float XonoticMapList_keyDown(entity me, float scan, float ascii, float shift) save = ch; else save = strcat(me.typeToSearchString, ch); - if(me.typeToSearchString) - strunzone(me.typeToSearchString); - me.typeToSearchString = strzone(save); + strcpy(me.typeToSearchString, save); me.typeToSearchTime = time + 0.5; MapInfo_FindName(me.typeToSearchString); if(MapInfo_FindName_firstResult >= 0) diff --git a/qcsrc/menu/xonotic/playermodel.qc b/qcsrc/menu/xonotic/playermodel.qc index c679d4449..1ad651bdb 100644 --- a/qcsrc/menu/xonotic/playermodel.qc +++ b/qcsrc/menu/xonotic/playermodel.qc @@ -113,21 +113,12 @@ void XonoticPlayerModelSelector_go(entity me, float d) { me.idxModels = mod(me.idxModels + d + me.numModels, me.numModels); - if(me.currentModel) - strunzone(me.currentModel); - if(me.currentModelTitle) - strunzone(me.currentModelTitle); - if(me.currentModelImage) - strunzone(me.currentModelImage); - if(me.currentModelDescription) - strunzone(me.currentModelDescription); - // select model #i! - me.currentModelTitle = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_TITLE)); - me.currentModelImage = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_IMAGE)); + strcpy(me.currentModelTitle, bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_TITLE)); + strcpy(me.currentModelImage, bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_IMAGE)); me.currentSkin = stof(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_SKIN)); - me.currentModel = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_MODEL)); - me.currentModelDescription = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_DESC)); + strcpy(me.currentModel, bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_MODEL)); + strcpy(me.currentModelDescription, bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_DESC)); // fix the image if(draw_PictureSize(me.currentModelImage) == '0 0 0') diff --git a/qcsrc/menu/xonotic/screenshotimage.qc b/qcsrc/menu/xonotic/screenshotimage.qc index 8e8f3ccf7..af987e7b5 100644 --- a/qcsrc/menu/xonotic/screenshotimage.qc +++ b/qcsrc/menu/xonotic/screenshotimage.qc @@ -19,9 +19,7 @@ void XonoticScreenshotImage_load(entity me, string theImage) { me.screenshotTime = time; me.src = theImage; - if (me.screenshotTitle) - strunzone(me.screenshotTitle); - me.screenshotTitle = strzone(substring(me.src, 13, strlen(theImage) - 13)); //strip "/screenshots/" + strcpy(me.screenshotTitle, substring(me.src, 13, strlen(theImage) - 13)); //strip "/screenshots/" me.initZoom(me); // this image may have a different size me.setZoom(me, 0, 0); diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 5e6a567b6..11ab47116 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -308,9 +308,7 @@ void XonoticServerList_setSelected(entity me, int i) if(gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT) != me.nItems) return; // sorry, it would be wrong - if(me.selectedServer) - strunzone(me.selectedServer); - me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); + strcpy(me.selectedServer, gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); me.ipAddressBox.setText(me.ipAddressBox, me.selectedServer); me.ipAddressBox.cursorPos = strlen(me.selectedServer); @@ -559,9 +557,7 @@ void XonoticServerList_draw(entity me) { if(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem) != me.selectedServer) { - if(me.selectedServer) - strunzone(me.selectedServer); - me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); + strcpy(me.selectedServer, gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); } found = true; } @@ -586,9 +582,7 @@ void XonoticServerList_draw(entity me) // selected server disappeared, select the last server (scrolling to it) if(me.selectedItem >= me.nItems) SUPER(XonoticServerList).setSelected(me, me.nItems - 1); - if(me.selectedServer) - strunzone(me.selectedServer); - me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); + strcpy(me.selectedServer, gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); } } diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index 602862820..cb8369ff0 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -612,8 +612,7 @@ void preMenuDraw() } else { - strunzone(campaign_name_previous); - campaign_name_previous = strzone(campaign_name); + strcpy(campaign_name_previous, campaign_name); campaign_won_previous = cvar(strcat("g_campaign", campaign_name, "_won")); } } diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index e69050beb..ba2fc3df7 100644 --- a/qcsrc/server/bot/default/scripting.qc +++ b/qcsrc/server/bot/default/scripting.qc @@ -308,9 +308,7 @@ float bot_decodecommand(string cmdstring) bot_cmd.bot_cmd_parm_float = stof(parm); break; case BOT_CMD_PARAMETER_STRING: - if(bot_cmd.bot_cmd_parm_string) - strunzone(bot_cmd.bot_cmd_parm_string); - bot_cmd.bot_cmd_parm_string = strzone(parm); + strcpy(bot_cmd.bot_cmd_parm_string, parm); break; case BOT_CMD_PARAMETER_VECTOR: if(substring(parm, 0, 1) != "\'") diff --git a/qcsrc/server/campaign.qc b/qcsrc/server/campaign.qc index e80769cc2..e90d66603 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -52,8 +52,7 @@ void cvar_set_campaignwrapper(string theCvar, string theValue) { if(cvar_string_campaignwrapper(theCvar) == theValue) return; - string s; - s = cvar_campaignwrapper_list; + string s = cvar_campaignwrapper_list; cvar_campaignwrapper_list = strzone(strcat("; ", theCvar, " ", theValue, s)); strunzone(s); //print(cvar_campaignwrapper_list, "\n"); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index df2c78566..08b85b4ce 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2481,8 +2481,7 @@ void PlayerPreThink (entity this) } if (!assume_unchanged && autocvar_sv_eventlog) GameLogEcho(strcat(":name:", ftos(this.playerid), ":", playername(this, false))); - if (CS(this).netname_previous) strunzone(CS(this).netname_previous); - CS(this).netname_previous = strzone(this.netname); + strcpy(CS(this).netname_previous, this.netname); } // version nagging diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index a3bb6eb21..d74c4b800 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -1199,9 +1199,7 @@ void Maplist_Init() error("empty maplist, cannot select a new map"); Map_Current = bound(0, GetMaplistPosition(), Map_Count - 1); - if(Map_Current_Name) - strunzone(Map_Current_Name); - Map_Current_Name = strzone(argv(Map_Current)); // will be automatically freed on exit thanks to DP + strcpy(Map_Current_Name, argv(Map_Current)); // will be automatically freed on exit thanks to DP // this may or may not be correct, but who cares, in the worst case a map // isn't chosen in the first pass that should have been } diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index ff762e904..c905c2773 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -306,9 +306,7 @@ void GetCvars_handleString(entity this, entity store, string thisname, float f, { if (thisname == name) { - if (store.(field)) - strunzone(store.(field)); - store.(field) = strzone(argv(f + 1)); + strcpy(store.(field), argv(f + 1)); } } else @@ -323,8 +321,7 @@ void GetCvars_handleString_Fixup(entity this, entity store, string thisname, flo string s = func(this, strcat1(store.(field))); if (s != store.(field)) { - strunzone(store.(field)); - store.(field) = strzone(s); + strcpy(store.(field), s); } } } diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index cc8920800..c101be0cc 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -3,7 +3,7 @@ #include // register all possible hooks here - + // to use a hook, first register your mutator using REGISTER_MUTATOR // then create your function using MUTATOR_HOOKFUNCTION diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 8804063dc..80b811a45 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -316,9 +316,7 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e, } race_SendRankings(newpos, player_prevpos, 0, MSG_ALL); - if(rankings_reply) - strunzone(rankings_reply); - rankings_reply = strzone(getrankings()); + strcpy(rankings_reply, getrankings()); if(newpos == player_prevpos) { @@ -366,9 +364,7 @@ void race_deleteTime(string map, float pos) if(pos == 1) race_send_recordtime(MSG_ALL); - if(rankings_reply) - strunzone(rankings_reply); - rankings_reply = strzone(getrankings()); + strcpy(rankings_reply, getrankings()); } void race_SendTime(entity e, float cp, float t, float tvalid) @@ -442,9 +438,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) if(t < recordtime || recordtime == 0) { race_checkpoint_records[cp] = t; - if(race_checkpoint_recordholders[cp]) - strunzone(race_checkpoint_recordholders[cp]); - race_checkpoint_recordholders[cp] = strzone(e.netname); + strcpy(race_checkpoint_recordholders[cp], e.netname); if(g_race_qualifying) FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it.race_checkpoint == cp, { race_SendNextCheckpoint(it, 0); }); } diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 3f1db4290..67c115c8a 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -535,9 +535,7 @@ void WinningConditionHelper(entity this) } } - if(worldstatus) - strunzone(worldstatus); - worldstatus = strzone(s); + strcpy(worldstatus, s); FOREACH_CLIENT(true, { string s = ""; @@ -556,9 +554,7 @@ void WinningConditionHelper(entity this) s = "-666"; } - if(it.clientstatus) - strunzone(it.clientstatus); - it.clientstatus = strzone(s); + strcpy(it.clientstatus, s); }); } diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index cf21de4bf..43aa4a26b 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -131,12 +131,8 @@ string getwelcomemessage(entity this) if(cache_lastmutatormsg != autocvar_g_mutatormsg) { - if(cache_lastmutatormsg) - strunzone(cache_lastmutatormsg); - if(cache_mutatormsg) - strunzone(cache_mutatormsg); - cache_lastmutatormsg = strzone(autocvar_g_mutatormsg); - cache_mutatormsg = strzone(cache_lastmutatormsg); + strcpy(cache_lastmutatormsg, autocvar_g_mutatormsg); + strcpy(cache_mutatormsg, cache_lastmutatormsg); } if (cache_mutatormsg != "") { diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index d63c226bc..8bfcbb79c 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -743,8 +743,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen this.reload_ammo_min = sent_ammo_min; this.reload_ammo_amount = e.reloading_ammo; this.reload_time = e.reloading_time; - if (actor.reload_sound) strunzone(actor.reload_sound); - actor.reload_sound = strzone(Sound_fixpath(sent_sound)); + strcpy(actor.reload_sound, Sound_fixpath(sent_sound)); // don't reload weapons that don't have the RELOADABLE flag if (!(e.spawnflags & WEP_FLAG_RELOADABLE)) -- 2.39.2