MCPcopy Create free account
hub / github.com/assaultcube/AC / addfavcategory

Function addfavcategory

source/src/serverbrowser.cpp:776–799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774}
775
776void addfavcategory(const char *refdes)
777{
778 string text, val;
779 char alx[FC_NUM];
780 if(!refdes) { intret(0); return; }
781 filtertext(text, refdes, FTXT__FAVCATEGORY);
782 if(!text[0]) { intret(0); return; }
783 loopv(favcats) if(!strcmp(favcats[i], text)) { intret(i + 1); return; }
784 favcats.add(newstring(text));
785 bool oldpersist = persistidents;
786 persistidents = false; // only keep changed values
787 loopi(FC_NUM) alx[i] = getalias(favcatargname(text, i)) ? 1 : 0;
788 loopi(3)
789 {
790 formatstring(val)("%d", *text & (1 << i) ? 90 : 10);
791 if(!alx[i + FC_RED]) alias(favcatargname(text, i + FC_RED), val);
792 }
793 formatstring(val)("favourites %d", favcats.length());
794 const int defk[] = { FC_WEIGHT, FC_DESC, FC_TAG, FC_KEYS, FC_IGNORE, FC_ALPHA };
795 const char *defv[] = { "0", val, refdes, "", "", "20" };
796 loopi(sizeof(defk)/sizeof(defk[0])) { if(!alx[defk[i]]) alias(favcatargname(text, defk[i]), defv[i]); }
797 persistidents = oldpersist;
798 intret(favcats.length());
799}
800
801void listfavcats()
802{

Callers

nothing calls this directly

Calls 10

intretFunction · 0.85
filtertextFunction · 0.85
newstringFunction · 0.85
getaliasFunction · 0.85
favcatargnameFunction · 0.85
aliasFunction · 0.85
loopvFunction · 0.70
loopiFunction · 0.70
addMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected