diff --git a/config/resetbinds.cfg b/config/resetbinds.cfg index 342d72f3..b780e513 100644 --- a/config/resetbinds.cfg +++ b/config/resetbinds.cfg @@ -27,6 +27,7 @@ bind MOUSE1 attack bind MOUSE2 altaction editbind MOUSE2 [ showmenu editing ] bind MOUSE3 weapon +editbind MOUSE3 toggleclosestentpin bind MOUSE4 key_universaldelta_plus bind MOUSE5 key_universaldelta_minus bind BACKSPACE dropflag diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 4eb18e59..4cc9e3e7 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1085,6 +1085,7 @@ void resetmap(bool mrproper) pruneundos(); changedents.setsize(0); deleted_ents.setsize(0); + pinnedclosestent = false; particlereset(); if(mrproper) { diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 57b122c1..eed7afcf 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -106,7 +106,7 @@ char *editinfo() { entity &c = ents[e]; int t = c.type < MAXENTTYPES ? c.type : 0; - formatstring(info)("closest entity: %s (%s)", entnames[t], formatentityattributes(c, true)); + formatstring(info)("%s entity: %s (%s)", pinnedclosestent ? "\fs\f3pinned\fr" : "closest", entnames[t], formatentityattributes(c, true)); const char *slotinfo = "unassigned slot"; if(t == MAPMODEL) { diff --git a/source/src/protos.h b/source/src/protos.h index b3f04618..87952bc3 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -485,6 +485,7 @@ extern void calcmapdims(); extern bool empty_world(int factor, bool force); extern void remip(const block &b, int level = 0); extern void remipmore(const block &b, int level = 0); +extern bool pinnedclosestent; extern int closestent(); extern void deletesoundentity(entity &e); extern int findtype(const char *what); diff --git a/source/src/world.cpp b/source/src/world.cpp index 7ca8e535..a9c8ab52 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -128,9 +128,18 @@ void closestenttype(char *what) COMMAND(nextclosestent, ""); COMMAND(closestenttype, "s"); +bool pinnedclosestent = false; +static int pinnedent = -1; +COMMANDF(toggleclosestentpin, "", () { pinnedclosestent = ents.inrange((pinnedent = pinnedclosestent ? -1 : closestent())); }); + int closestent() // used for delent and edit mode ent display { if(noteditmode("closestent")) return -1; + if(pinnedclosestent) + { + if(ents.inrange(pinnedent) && ents[pinnedent].type != NOTUSED) return pinnedent; + pinnedclosestent = false; // release lock when ent is deleted + } int best = -1, bcnt = 0; float bdist = 99999; loopj(3)