From 954fe7ee7fa428d03841c2ec3fd28c0b266390a7 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Wed, 31 May 2017 03:00:38 +0200 Subject: [PATCH] cleanup edithide - replace by simple bitmask - rewrite showedithide, setedithide and seteditshow in cubescript - menu added for convenient use setedithide and seteditshow no longer accept entity type numbers as parameters - only entity type names showedithide, setedithide and seteditshow are considered deprecated edithideentmask Integer variable containing a bitmask of hidden entity types. DOCREF showedithide setedithide seteditshow edithideentmask --- config/menus_edit.cfg | 7 ++++ config/opt/compatibility.cfg | 39 +++++++++++++++++++++++ source/src/cube.h | 1 - source/src/entities.cpp | 62 ++---------------------------------- source/src/protos.h | 1 + source/src/world.cpp | 4 +-- 6 files changed, 50 insertions(+), 64 deletions(-) diff --git a/config/menus_edit.cfg b/config/menus_edit.cfg index 48cee3e0..ae0ecb1b 100644 --- a/config/menus_edit.cfg +++ b/config/menus_edit.cfg @@ -668,8 +668,15 @@ menuitem "Select the next closest entity" nextclosestent menuitem "Copy the current closest entity" copyent menuitem "Paste a previously copied entity" pasteent menuitemslider "Select only these entities: " 0 15 "$_closestenttypestatus" 1 [All Light Playerstart Pistol Ammobox Grenades Health Armour Akimbo Mapmodel Ladder CTF-flag Sound Clip Helmet PlayerClip] [ _closestentslider $arg1 ] +menuitem "Hide entity sparklies\i\3" [ showmenu [Hide entity sparklies] ] _closestentslider = [ closestenttype (at ["" light playerstart pistol ammobox grenades health armour akimbo mapmodel ladder ctf-flag sound clip helmet plclip] $arg1); _closestenttypestatus = $arg1 ] +//// Main > Editing > Map operations > Hide entity sparklies //// + +newmenu [Hide entity sparklies] +looplisti (listoptions ents) e [ + menuitemcheckbox (concat Hide $e sparklies:) (concat "(&b $edithideentmask" (+ 0 (powf 2 $i)) ")") (concat "edithideentmask (^b $edithideentmask" (+ 0 (powf 2 $i)) ")") +] //// Main > Editing > Map settings //// diff --git a/config/opt/compatibility.cfg b/config/opt/compatibility.cfg index 6a4172d9..16686287 100644 --- a/config/opt/compatibility.cfg +++ b/config/opt/compatibility.cfg @@ -62,3 +62,42 @@ switch = [ execute (getalias (format arg%1 (+ $arg1 2))) ] ] + +const showedithide [ + if $edithideentmask [ + push n "Hidden entities:" + push m 1 + looplist (listoptions ents) e [ + if (&b $edithideentmask $m) [ + n = (concat $n $e) + ] + += m $m + ] + echo (pop n m) + ] [ + echo "all entities are visible" + ] +] + +const setedithide [ + edithideentmask 0 + looplist $arg1 e [ + push n (findlist (listoptions ents) $e) + if (< $n 0) [ + echo "\f3" $e is not an entity type + ] [ + edithideentmask (|b $edithideentmask (powf 2 $n)) + ] + pop n + ] +] + +const seteditshow [ + push n (findlist (listoptions ents) $arg1) + if (< $n 0) [ + echo "\f3" $arg1 is not an entity type + ] [ + edithideentmask (- (- (powf 2 (listlen (listoptions ents))) 1) (powf 2 $n)) + ] + pop n +] diff --git a/source/src/cube.h b/source/src/cube.h index 4102b76d..8f59d162 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -38,7 +38,6 @@ extern vector bounceents; extern bool editmode; extern int unsavededits; extern vector ents; // map entities -extern vector eh_ents; // edithide entities extern vec worldpos, camup, camright, camdir; // current target of the crosshair in the world extern int lastmillis, totalmillis, skipmillis; // last time extern int curtime; // current frame time diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 6eaf12bd..325f845b 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -6,9 +6,9 @@ VAR(showclips, 0, 1, 1); VARP(showmodelclipping, 0, 0, 1); VARP(showladderentities, 0, 0, 1); VARP(showplayerstarts, 0, 0, 1); +VAR(edithideentmask, 0, 0, INT_MAX); vector ents; -vector eh_ents; // edithide entities const char *entmdlnames[] = { @@ -82,62 +82,6 @@ void rendermapmodels() } } -void showedithide() -{ - if(eh_ents.length()) - { - conoutf("Hidden entities:"); - loopv(eh_ents) - { - if(eh_ents[i]>0 && eh_ents[i]0 && sno).dot(camdir) < 0) continue; //particle_splash(i == closest ? PART_ELIGHT : PART_ECLOSEST, 2, 40, v); diff --git a/source/src/protos.h b/source/src/protos.h index 70afc1d7..593605af 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -923,6 +923,7 @@ extern void checkweaponstate(); extern int burstshotssettings[NUMGUNS]; // entities +extern int edithideentmask; extern void pickupeffects(int n, playerent *d); extern void renderentities(); extern void rendermapmodels(); diff --git a/source/src/world.cpp b/source/src/world.cpp index e2652a11..1b4d28ed 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -175,9 +175,7 @@ int closestent() // used for delent and edit mode ent display entity &e = ents[i]; if(e.type==NOTUSED) continue; if(clenttype != NOTUSED && e.type != clenttype) continue; - bool ice = false; - loopk(eh_ents.length()) if(eh_ents[k]==e.type) ice = true; - if(ice) continue; + if(edithideentmask & (1 << (e.type - 1))) continue; if(!intersectangular(camera1->o, worldpos, vec(e.x, e.y, e.z), maxangle, dist)) continue; if(j) {