summaryrefslogtreecommitdiff
path: root/src/engine/world.cpp
diff options
context:
space:
mode:
authorxolatile2025-07-21 06:06:50 +0200
committerxolatile2025-07-21 06:06:50 +0200
commit09a43565940be30b233fa8730e65d531a454a03b (patch)
treee7ee95b2964b68611701643376ed500bb7d2ddcd /src/engine/world.cpp
parent39de2c68c8a3f9cd7cffef9364a59c9d412b907e (diff)
downloadxolatile-badassbug-09a43565940be30b233fa8730e65d531a454a03b.tar.xz
xolatile-badassbug-09a43565940be30b233fa8730e65d531a454a03b.tar.zst
Cleaned 95% of -Wall -Wextra...
Diffstat (limited to 'src/engine/world.cpp')
-rw-r--r--src/engine/world.cpp71
1 files changed, 37 insertions, 34 deletions
diff --git a/src/engine/world.cpp b/src/engine/world.cpp
index fcf64c2..a2e1766 100644
--- a/src/engine/world.cpp
+++ b/src/engine/world.cpp
@@ -42,6 +42,7 @@ bool getentboundingbox(const extentity &e, ivec &o, ivec &r)
break;
}
}
+ [[fallthrough]];
// invisible mapmodels use entselradius
default:
o = ivec(vec(e.o).sub(entselradius));
@@ -86,6 +87,7 @@ void modifyoctaentity(int flags, int id, extentity &e, cube *c, const ivec &cor,
break;
}
// invisible mapmodel
+ [[fallthrough]];
default:
oe.other.add(id);
break;
@@ -122,12 +124,13 @@ void modifyoctaentity(int flags, int id, extentity &e, cube *c, const ivec &cor,
oe.bbmax.min(ivec(oe.o).add(oe.size));
break;
}
+ [[fallthrough]];
// invisible mapmodel
default:
oe.other.removeobj(id);
break;
}
- if(oe.mapmodels.empty() && oe.other.empty())
+ if(oe.mapmodels.empty() && oe.other.empty())
freeoctaentities(c[i]);
}
if(c[i].ext && c[i].ext->ents) c[i].ext->ents->query = NULL;
@@ -151,7 +154,7 @@ static bool modifyoctaent(int flags, int id, extentity &e)
ivec o, r;
if(!getentboundingbox(e, o, r)) return false;
- if(!insideworld(e.o))
+ if(!insideworld(e.o))
{
int idx = outsideents.find(id);
if(flags&MODOE_ADD)
@@ -221,7 +224,7 @@ static inline void findents(cube *c, const ivec &o, int size, const ivec &bo, co
loopoctabox(o, size, bo, br)
{
if(c[i].ext && c[i].ext->ents) findents(*c[i].ext->ents, low, high, notspawned, pos, invradius, found);
- if(c[i].children && size > octaentsize)
+ if(c[i].children && size > octaentsize)
{
ivec co(i, o, size);
findents(c[i].children, co, size>>1, bo, br, low, high, notspawned, pos, invradius, found);
@@ -365,8 +368,8 @@ void attachentity(extentity &e)
if(a->attached) continue;
switch(e.type)
{
- case ET_SPOTLIGHT:
- if(a->type!=ET_LIGHT) continue;
+ case ET_SPOTLIGHT:
+ if(a->type!=ET_LIGHT) continue;
break;
default:
@@ -476,30 +479,30 @@ void entrotate(int *cw)
);
}
-void entselectionbox(const entity &e, vec &eo, vec &es)
+void entselectionbox(const entity &e, vec &eo, vec &es)
{
model *m = NULL;
const char *mname = entities::entmodel(e);
if(mname && (m = loadmodel(mname)))
- {
+ {
m->collisionbox(eo, es);
if(es.x > es.y) es.y = es.x; else es.x = es.y; // square
es.z = (es.z + eo.z + 1 + entselradius)/2; // enclose ent radius box and model box
eo.x += e.o.x;
eo.y += e.o.y;
eo.z = e.o.z - entselradius + es.z;
- }
+ }
else if(e.type == ET_MAPMODEL && (m = loadmapmodel(e.attr2)))
{
mmcollisionbox(e, m, eo, es);
es.max(entselradius);
eo.add(e.o);
- }
+ }
else
{
es = vec(entselradius);
eo = e.o;
- }
+ }
eo.sub(es);
es.mul(2);
}
@@ -524,19 +527,19 @@ void entdrag(const vec &ray)
int d = dimension(entorient),
dc= dimcoord(entorient);
- entfocus(entgroup.last(),
+ entfocus(entgroup.last(),
entselectionbox(e, eo, es);
if(!editmoveplane(e.o, ray, d, eo[d] + (dc ? es[d] : 0), handle, v, entmoving==1))
- return;
+ return;
ivec g(v);
int z = g[d]&(~(sel.grid-1));
g.add(sel.grid/2).mask(~(sel.grid-1));
g[d] = z;
-
+
r = (entselsnap ? g[R[d]] : v[R[d]]) - e.o[R[d]];
- c = (entselsnap ? g[C[d]] : v[C[d]]) - e.o[C[d]];
+ c = (entselsnap ? g[C[d]] : v[C[d]]) - e.o[C[d]];
);
if(entmoving==1) makeundoent();
@@ -641,7 +644,7 @@ void renderentradius(extentity &e, bool color)
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);
+ renderentcone(*e.attached, dir, radius, angle);
}
break;
@@ -670,7 +673,7 @@ void renderentradius(extentity &e, bool color)
}
default:
- if(e.type>=ET_GAMESPECIFIC)
+ if(e.type>=ET_GAMESPECIFIC)
{
if(color) gle::colorf(0, 1, 1);
entities::entradius(e, color);
@@ -703,7 +706,7 @@ static void renderentbox(const vec &eo, vec es)
}
void renderentselection(const vec &o, const vec &ray, bool entmoving)
-{
+{
if(noentedit()) return;
vec eo, es;
@@ -728,8 +731,8 @@ void renderentselection(const vec &o, const vec &ray, bool entmoving)
{
vec a, b;
gle::colorub(20, 20, 20);
- (a = eo).x = eo.x - fmod(eo.x, worldsize); (b = es).x = a.x + worldsize; boxs3D(a, b, 1);
- (a = eo).y = eo.y - fmod(eo.y, worldsize); (b = es).y = a.x + worldsize; boxs3D(a, b, 1);
+ (a = eo).x = eo.x - fmod(eo.x, worldsize); (b = es).x = a.x + worldsize; boxs3D(a, b, 1);
+ (a = eo).y = eo.y - fmod(eo.y, worldsize); (b = es).y = a.x + worldsize; boxs3D(a, b, 1);
(a = eo).z = eo.z - fmod(eo.z, worldsize); (b = es).z = a.x + worldsize; boxs3D(a, b, 1);
}
gle::colorub(150,0,0);
@@ -807,11 +810,11 @@ void entpush(int *dir)
if(noentedit()) return;
int d = dimension(entorient);
int s = dimcoord(entorient) ? -*dir : *dir;
- if(entmoving)
+ if(entmoving)
{
groupeditpure(e.o[d] += float(s*sel.grid)); // editdrag supplies the undo
}
- else
+ else
groupedit(e.o[d] += float(s*sel.grid));
if(entitysurf==1)
{
@@ -821,7 +824,7 @@ void entpush(int *dir)
}
VAR(entautoviewdist, 0, 25, 100);
-void entautoview(int *dir)
+void entautoview(int *dir)
{
if(!haveselent()) return;
static int s = 0;
@@ -993,7 +996,7 @@ void entcopy()
if(noentedit()) return;
entcopygrid = sel.grid;
entcopybuf.shrink(0);
- loopv(entgroup)
+ loopv(entgroup)
entfocus(entgroup[i], entcopybuf.add(e).o.sub(vec(sel.o)));
}
@@ -1043,9 +1046,9 @@ void printent(extentity &e, char *buf, int len)
switch(e.type)
{
case ET_PARTICLES:
- if(printparticles(e, buf, len)) return;
+ if(printparticles(e, buf, len)) return;
break;
-
+
default:
if(e.type >= ET_GAMESPECIFIC && entities::printent(e, buf, len)) return;
break;
@@ -1086,9 +1089,9 @@ void enttype(char *type, int *numargs)
{
if(*numargs >= 1)
{
- int typeidx = findtype(type);
+ int typeidx = findtype(type);
if(typeidx != ET_EMPTY) groupedit(e.type = typeidx);
- }
+ }
else entfocus(efocus,
{
result(entities::entname(e.type));
@@ -1109,7 +1112,7 @@ void entattr(int *attr, int *val, int *numargs)
case 3: e.attr4 = *val; break;
case 4: e.attr5 = *val; break;
}
- );
+ );
}
else entfocus(efocus,
{
@@ -1131,7 +1134,7 @@ int findentity(int type, int index, int attr1, int attr2)
{
const vector<extentity *> &ents = entities::getents();
if(index > ents.length()) index = ents.length();
- else for(int i = index; i<ents.length(); i++)
+ else for(int i = index; i<ents.length(); i++)
{
extentity &e = *ents[i];
if(e.type==type && (attr1<0 || e.attr1==attr1) && (attr2<0 || e.attr2==attr2))
@@ -1243,7 +1246,7 @@ void startmap(const char *name)
bool emptymap(int scale, bool force, const char *mname, bool usecfg) // main empty world creation routine
{
- if(!force && !editmode)
+ if(!force && !editmode)
{
conoutf(CON_ERROR, "newmap only allowed in edit mode");
return false;
@@ -1253,7 +1256,7 @@ bool emptymap(int scale, bool force, const char *mname, bool usecfg) // main
setvar("mapscale", scale<10 ? 10 : (scale>16 ? 16 : scale), true, false);
setvar("mapsize", 1<<worldscale, true, false);
-
+
texmru.shrink(0);
freeocta(worldroot);
worldroot = newcubes(F_EMPTY);
@@ -1332,16 +1335,16 @@ void shrinkmap()
cube *root = worldroot[octant].children;
worldroot[octant].children = NULL;
freeocta(worldroot);
- worldroot = root;
+ worldroot = root;
worldscale--;
- worldsize /= 2;
+ worldsize /= 2;
ivec offset(octant, ivec(0, 0, 0), worldsize);
vector<extentity *> &ents = entities::getents();
loopv(ents) ents[i]->o.sub(vec(offset));
shrinkblendmap(octant);
-
+
allchanged();
conoutf("shrunk map to size %d", worldscale);