]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'TimePath/strfree' into 'master'
authorMario <zacjardine@y7mail.com>
Sun, 8 Apr 2018 12:15:42 +0000 (12:15 +0000)
committerMario <zacjardine@y7mail.com>
Sun, 8 Apr 2018 12:15:42 +0000 (12:15 +0000)
Add strfree to reduce explicit use of strunzone/string_null

See merge request xonotic/xonotic-data.pk3dir!552

1  2 
qcsrc/client/bgmscript.qc
qcsrc/common/triggers/func/pointparticles.qc
qcsrc/lib/net.qh
qcsrc/lib/replicate.qh
qcsrc/menu/xonotic/serverlist.qc

index ba1fdd268d86f67dfd42ded858aaf97cc42527b7,ae3ff64d316f8c136aec1ab3cd1e1cd679a42d5b..02739194a858b799752f06dca40e36b8aade1bae
@@@ -11,12 -11,12 +11,12 @@@ float bgmscriptbuf
  float bgmscriptbufsize;
  float bgmscriptbufloaded;
  
 -class(BGMScript) .float bgmscriptline;
 -class(BGMScript) .float bgmscriptline0;
 -class(BGMScript) .float bgmscriptvolume;
 -class(BGMScript) .float bgmscripttime;
 -class(BGMScript) .float bgmscriptstate;
 -class(BGMScript) .float bgmscriptstatetime;
 +classfield(BGMScript) .float bgmscriptline;
 +classfield(BGMScript) .float bgmscriptline0;
 +classfield(BGMScript) .float bgmscriptvolume;
 +classfield(BGMScript) .float bgmscripttime;
 +classfield(BGMScript) .float bgmscriptstate;
 +classfield(BGMScript) .float bgmscriptstatetime;
  
  float GetAttackDecaySustainAmplitude(float a, float d, float s, float t)
  {
@@@ -139,8 -139,7 +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);
                }
        }
  }
index 9286f2adbce19fb8ec741d1c827fa1ad2b2b63fc,602082d182f50065502096c41421c419255cfad1..e028b4c837d7b20bddc47223b060dcff0ff40c9e
@@@ -169,17 -169,17 +169,17 @@@ spawnfunc(func_sparks
  .int dphitcontentsmask;
  
  entityclass(PointParticles);
 -class(PointParticles) .int cnt; // effect number
 -class(PointParticles) .vector velocity; // particle velocity
 -class(PointParticles) .float waterlevel; // direction jitter
 -class(PointParticles) .int count; // count multiplier
 -class(PointParticles) .int impulse; // density
 -class(PointParticles) .string noise; // sound
 -class(PointParticles) .float atten;
 -class(PointParticles) .float volume;
 -class(PointParticles) .float absolute; // 1 = count per second is absolute, 2 = only spawn at toggle
 -class(PointParticles) .vector movedir; // trace direction
 -class(PointParticles) .float glow_color; // palette index
 +classfield(PointParticles) .int cnt; // effect number
 +classfield(PointParticles) .vector velocity; // particle velocity
 +classfield(PointParticles) .float waterlevel; // direction jitter
 +classfield(PointParticles) .int count; // count multiplier
 +classfield(PointParticles) .int impulse; // density
 +classfield(PointParticles) .string noise; // sound
 +classfield(PointParticles) .float atten;
 +classfield(PointParticles) .float volume;
 +classfield(PointParticles) .float absolute; // 1 = count per second is absolute, 2 = only spawn at toggle
 +classfield(PointParticles) .vector movedir; // trace direction
 +classfield(PointParticles) .float glow_color; // palette index
  
  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 --combined qcsrc/lib/net.qh
index 4769a21388e77d677fa6a8dc38a52298ff51af4c,30e973f6c51fcbe7cd165782efd11c2e2bcfc6de..c1edb5cd3a3600dc60dfd15915509aadd1458513
@@@ -50,7 -50,7 +50,7 @@@ STATIC_INIT(RegisterTempEntities_renumb
  
  #ifdef CSQC
        #define REGISTER_NET_LINKED(id) \
 -              [[accumulate]] NET_HANDLE(id, bool isnew) \
 +              ACCUMULATE NET_HANDLE(id, bool isnew) \
                { \
                        this = __self; \
                        this.sourceLoc = __FILE__ ":" STR(__LINE__); \
@@@ -202,8 -202,7 +202,7 @@@ STATIC_INIT(C2S_Protocol_renumber) { FO
        {
                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 +300,7 @@@ MACRO_EN
                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 --combined qcsrc/lib/replicate.qh
index 4031352fedbe8c34eb264ca20c22682c4f2e1c0a,795f4bde6efbed29e10cf6d12ac85c2e2ebfb552..656989782672e60c948199c0b8deb94f2f10b0a6
        #define REPLICATE(...) EVAL_REPLICATE(OVERLOAD(REPLICATE, __VA_ARGS__))
        #define EVAL_REPLICATE(...) __VA_ARGS__
  
 -      [[accumulate]] void ReplicateVars(entity this, entity store, string thisname, int i) {}
 +      ACCUMULATE void ReplicateVars(entity this, entity store, string thisname, int i) {}
  
        #define REPLICATE_3(fld, type, var) REPLICATE_4(fld, type, var, )
        #define REPLICATE_4(fld, type, var, func) REPLICATE_##type(fld, var, func)
        #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); },          , )
index 694e85d91d0484fe67778a1de7047ee89dcf2b73,325dfdc570bc70bf34dc450cbf2c3dff19501490..503a975c326fe09ba82aab79ac0b5131d6cb41a5
@@@ -37,8 -37,7 +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 +50,7 @@@
                                        ); \
                                } \
                        } \
-                       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)
@@@ -547,9 -545,9 +545,9 @@@ void XonoticServerList_draw(entity me
        }
        else { me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); }
  
 -      me.connectButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == ""));
 -      me.infoButton.disabled = ((me.nItems == 0) || !owned);
 -      me.favoriteButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == ""));
 +      me.connectButton.disabled = (me.lockedSelectedItem || (me.nItems == 0 && me.ipAddressBox.text == ""));
 +      me.infoButton.disabled = (me.lockedSelectedItem || me.nItems == 0 || !owned);
 +      me.favoriteButton.disabled = (me.lockedSelectedItem || (me.nItems == 0 && me.ipAddressBox.text == ""));
  
        if(me.lockedSelectedItem)
        {
@@@ -660,12 -658,9 +658,9 @@@ void ServerList_TypeSort_Click(entity b
  }
  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 +706,7 @@@ void XonoticServerList_setSortOrder(ent
        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)
@@@ -769,10 -762,11 +762,10 @@@ void XonoticServerList_resizeNotify(ent
  }
  void ServerList_Connect_Click(entity btn, entity me)
  {
 -      localcmd(sprintf("connect %s\n",
 -              ((me.ipAddressBox.text != "") ?
 -                      me.ipAddressBox.text : me.selectedServer
 -              )
 -      ));
 +      if (me.lockedSelectedItem)
 +              return;
 +      string sv = (me.ipAddressBox.text != "") ? me.ipAddressBox.text : me.selectedServer;
 +      localcmd(sprintf("connect %s\n", sv));
  }
  void ServerList_Favorite_Click(entity btn, entity this)
  {
@@@ -850,7 -844,7 +843,7 @@@ void XonoticServerList_drawListBoxItem(
                }
        }
  
 -      if(isSelected)
 +      if(isSelected && !me.lockedSelectedItem)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
        else if(isFocused)
        {