diff options
| author | xolatile | 2025-08-07 00:32:29 +0200 |
|---|---|---|
| committer | xolatile | 2025-08-07 00:32:29 +0200 |
| commit | 4c8dfb375b4b30dbb6079f9d68024980d81ffa20 (patch) | |
| tree | d7a8164758e9d5cfc5d5c239bccbe45ad19c9da6 /src/engine/world.cpp | |
| parent | 0a1172b75f571685c264a8b9d8ee224bbf11381f (diff) | |
| download | xolatile-badassbug-4c8dfb375b4b30dbb6079f9d68024980d81ffa20.tar.xz xolatile-badassbug-4c8dfb375b4b30dbb6079f9d68024980d81ffa20.tar.zst | |
More cleanups...
Diffstat (limited to 'src/engine/world.cpp')
| -rw-r--r-- | src/engine/world.cpp | 133 |
1 files changed, 6 insertions, 127 deletions
diff --git a/src/engine/world.cpp b/src/engine/world.cpp index 489ea65..f58886f 100644 --- a/src/engine/world.cpp +++ b/src/engine/world.cpp @@ -219,11 +219,6 @@ void findents(int low, int high, bool notspawned, const vec &pos, const vec &rad char *entname(entity &e) { static string fullentname; copystring(fullentname, entities::entname(e.type)); - const char *einfo = entities::entnameinfo(e); - if(*einfo) { - concatstring(fullentname, ": "); - concatstring(fullentname, einfo); - } return fullentname; } @@ -286,71 +281,13 @@ void makeundoent() { if(u) addundo(u); } -void detachentity(extentity &e) { - if(!e.attached) return; - e.attached->attached = NULL; - e.attached = NULL; -} - -VAR(attachradius, 1, 100, 1000); - -void attachentity(extentity &e) { - switch(e.type) { - case ET_SPOTLIGHT: - break; - default: - if(e.type<ET_GAMESPECIFIC || !entities::mayattach(e)) return; - break; - } - detachentity(e); - vector<extentity *> &ents = entities::getents(); - int closest = -1; - float closedist = 1e10f; - loopv(ents) { - extentity *a = ents[i]; - if(a->attached) continue; - switch(e.type) { - case ET_SPOTLIGHT: - if(a->type!=ET_LIGHT) continue; - break; - default: - if(e.type<ET_GAMESPECIFIC || !entities::attachent(e, *a)) continue; - break; - } - float dist = e.o.dist(a->o); - if(dist < closedist) { - closest = i; - closedist = dist; - } - } - if(closedist>attachradius) return; - e.attached = ents[closest]; - ents[closest]->attached = &e; -} - -void attachentities() { - vector<extentity *> &ents = entities::getents(); - loopv(ents) attachentity(*ents[i]); -} - // convenience macros implicitly define: // e entity, currently edited ent // n int, index to currently edited ent #define addimplicit(f) { if(entgroup.empty() && enthover>=0) { entadd(enthover); undonext = (enthover != oldhover); f; entgroup.drop(); } else f; } -#define entfocusv(i, f, v){ int n = efocus = (i); if(n>=0) { extentity &e = *v[n]; f; } } +#define entfocusv(i, f, v){ int n = efocus = (i); if(n>=0) { extentity &e = *v[n]; f; (void) e; } } #define entfocus(i, f) entfocusv(i, f, entities::getents()) -#define enteditv(i, f, v) { \ - \ - entfocusv(i, { \ - \ - int oldtype = e.type; \ - removeentity(n); \ - f; \ - if(oldtype!=e.type) detachentity(e); \ - if(e.type!=ET_EMPTY) { addentity(n); if(oldtype!=e.type) attachentity(e); } \ - entities::editent(n, true); \ - }, v); \ -} +#define enteditv(i, f, v) { entfocusv(i, { int a = 0; (void) a; }, v); } #define entedit(i, f) enteditv(i, f, entities::getents()) #define addgroup(exp) { vector<extentity *> &ents = entities::getents(); loopv(ents) entfocusv(i, if(exp) entadd(n), ents); } #define setgroup(exp) { entcancel(); addgroup(exp); } @@ -490,15 +427,6 @@ void renderentsphere(const extentity &e, float radius) { loopk(3) renderentring(e, radius, k); } -void renderentattachment(const extentity &e) { - if(!e.attached) return; - gle::defvertex(); - gle::begin(GL_LINES); - gle::attrib(e.o); - gle::attrib(e.attached->o); - xtraverts += gle::end(); -} - void renderentarrow(const extentity &e, const vec &dir, float radius) { if(radius <= 0) return; float arrowsize = min(radius/8, 0.5f); @@ -541,17 +469,6 @@ void renderentradius(extentity &e, bool color) { if(color) gle::colorf(e.attr2/255.0f, e.attr3/255.0f, e.attr4/255.0f); renderentsphere(e, e.attr1); break; - case ET_SPOTLIGHT: - if(e.attached) { - if(color) gle::colorf(0, 1, 1); - float radius = e.attached->attr1; - if(!radius) radius = 2*e.o.dist(e.attached->o); - vec dir = vec(e.o).sub(e.attached->o).normalize(); - float angle = clamp(int(e.attr1), 1, 89); - renderentattachment(e); - renderentcone(*e.attached, dir, radius, angle); - } - break; case ET_SOUND: if(color) gle::colorf(0, 1, 1); renderentsphere(e, e.attr2); @@ -559,7 +476,7 @@ void renderentradius(extentity &e, bool color) { case ET_MAPMODEL: case ET_PLAYERSTART: { if(color) gle::colorf(0, 1, 1); - entities::entradius(e, color); + entities::entradius(e); vec dir; vecfromyawpitch(e.attr1, 0, 1, 0, dir); renderentarrow(e, dir, 4); @@ -568,7 +485,7 @@ void renderentradius(extentity &e, bool color) { default: if(e.type>=ET_GAMESPECIFIC) { if(color) gle::colorf(0, 1, 1); - entities::entradius(e, color); + entities::entradius(e); } break; } @@ -744,8 +661,7 @@ bool dropentity(entity &e, int drop = -1) { } switch(drop) { case 1: - if(e.type != ET_LIGHT && e.type != ET_SPOTLIGHT) - dropenttofloor(&e); + dropenttofloor(&e); break; case 2: case 3: @@ -774,13 +690,6 @@ void dropent() { groupedit(dropentity(e)); } -void attachent() { - if(noentedit()) return; - groupedit(attachentity(e)); -} - -COMMAND(attachent, ""); - VARP(entcamdir, 0, 1, 1); static int keepents = 0; @@ -881,24 +790,7 @@ void entset(char *what, int *a1, int *a2, int *a3, int *a4, int *a5) { if(noentedit()) return; int type = findtype(what); if(type != ET_EMPTY) - groupedit(e.type=type; - e.attr1=*a1; - e.attr2=*a2; - e.attr3=*a3; - e.attr4=*a4; - e.attr5=*a5); -} - -void printent(extentity &e, char *buf, int len) { - switch(e.type) { - case ET_PARTICLES: - if(printparticles(e, buf, len)) return; - break; - default: - if(e.type >= ET_GAMESPECIFIC && entities::printent(e, buf, len)) return; - break; - } - nformatstring(buf, len, "%s %d %d %d %d %d", entities::entname(e.type), e.attr1, e.attr2, e.attr3, e.attr4, e.attr5); + groupedit(e.type=type; e.attr1=*a1; e.attr2=*a2; e.attr3=*a3; e.attr4=*a4; e.attr5=*a5); } void nearestent() { @@ -922,7 +814,6 @@ ICOMMAND(enthavesel,"", (), addimplicit(intret(entgroup.length()))); ICOMMAND(entselect, "e", (uint *body), if(!noentedit()) addgroup(e.type != ET_EMPTY && entgroup.find(n)<0 && executebool(body))); ICOMMAND(entloop, "e", (uint *body), if(!noentedit()) addimplicit(groupeditloop(((void)e, execute(body))))); ICOMMAND(insel, "", (), entfocus(efocus, intret(pointinsel(sel, e.o)))); -ICOMMAND(entget, "", (), entfocus(efocus, string s; printent(e, s, sizeof(s)); result(s))); ICOMMAND(entindex, "", (), intret(efocus)); COMMAND(entset, "siiiii"); COMMAND(nearestent, ""); @@ -1153,18 +1044,6 @@ void mpeditent(int i, const vec &o, int type, int attr1, int attr2, int attr3, i extentity *e = newentity(local, o, type, attr1, attr2, attr3, attr4, attr5, i); if(!e) return; addentity(i); - attachentity(*e); - } - else { - extentity &e = *ents[i]; - removeentity(i); - int oldtype = e.type; - if(oldtype!=type) detachentity(e); - e.type = type; - e.o = o; - e.attr1 = attr1; e.attr2 = attr2; e.attr3 = attr3; e.attr4 = attr4; e.attr5 = attr5; - addentity(i); - if(oldtype!=type) attachentity(e); } entities::editent(i, local); } |
