diff options
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/3dgui.cpp | 2 | ||||
| -rw-r--r-- | src/engine/animmodel.h | 14 | ||||
| -rw-r--r-- | src/engine/client.cpp | 4 | ||||
| -rw-r--r-- | src/engine/decal.cpp | 11 | ||||
| -rw-r--r-- | src/engine/dynlight.cpp | 181 | ||||
| -rw-r--r-- | src/engine/engine.h | 21 | ||||
| -rw-r--r-- | src/engine/lightmap.cpp | 22 | ||||
| -rw-r--r-- | src/engine/main.cpp | 12 | ||||
| -rw-r--r-- | src/engine/octa.h | 1 | ||||
| -rw-r--r-- | src/engine/octaedit.cpp | 12 | ||||
| -rw-r--r-- | src/engine/physics.cpp | 14 | ||||
| -rw-r--r-- | src/engine/rendergl.cpp | 7 | ||||
| -rw-r--r-- | src/engine/rendermodel.cpp | 19 | ||||
| -rw-r--r-- | src/engine/renderparticles.cpp | 18 | ||||
| -rw-r--r-- | src/engine/renderva.cpp | 33 | ||||
| -rw-r--r-- | src/engine/server.cpp | 7 | ||||
| -rw-r--r-- | src/engine/serverbrowser.cpp | 4 | ||||
| -rw-r--r-- | src/engine/shader.cpp | 65 | ||||
| -rw-r--r-- | src/engine/shadowmap.cpp | 13 | ||||
| -rw-r--r-- | src/engine/skelmodel.h | 4 | ||||
| -rw-r--r-- | src/engine/sound.cpp | 77 | ||||
| -rw-r--r-- | src/engine/texture.cpp | 90 | ||||
| -rw-r--r-- | src/engine/world.cpp | 16 | ||||
| -rw-r--r-- | src/engine/worldio.cpp | 1 |
24 files changed, 107 insertions, 541 deletions
diff --git a/src/engine/3dgui.cpp b/src/engine/3dgui.cpp index 19eed54..f9cdbfc 100644 --- a/src/engine/3dgui.cpp +++ b/src/engine/3dgui.cpp @@ -754,7 +754,7 @@ struct gui : g3d_gui { hudmatrix.rotate_around_x(-90*RAD); hudmatrix.scale(-scale.x, scale.y, scale.z); vec dir; - lightreaching(origin, light, dir, false, 0, 0.5f); + lightreaching(origin, light, dir, 0, 0.5f); float intensity = vec(yaw, 0.0f).dot(dir); light.mul(1.0f + max(intensity, 0.0f)); } diff --git a/src/engine/animmodel.h b/src/engine/animmodel.h index 51d09e8..07143a2 100644 --- a/src/engine/animmodel.h +++ b/src/engine/animmodel.h @@ -86,7 +86,7 @@ struct animmodel : model { void setkey() { key = &shaderparamskey::keys[*this]; } - void setshaderparams(mesh *m, const animstate *as) { + void setshaderparams(const animstate *as) { if(!Shader::lastshader) return; float mincolor = as->cur.anim&ANIM_FULLBRIGHT ? fullbrightmodels/100.0f : 0.0f; if(fullbright) { @@ -140,7 +140,7 @@ struct animmodel : model { //~if(force) cleanup(); loadshader(); } - void setshader(mesh *m, const animstate *as) { + void setshader(mesh *m) { m->setshader(loadshader()); } void bind(mesh *b, const animstate *as) { @@ -152,8 +152,8 @@ struct animmodel : model { else /*if(as->cur.anim&ANIM_SHADOW)*/ SETMODELSHADER(b, notexturemodel); return; } - setshader(b, as); - setshaderparams(b, as); + setshader(b); + setshaderparams(as); int activetmu = 0; if(tex!=lasttex) { glBindTexture(GL_TEXTURE_2D, tex->id); @@ -366,8 +366,8 @@ struct animmodel : model { bool hasframes(int i, int n) const { return i>=0 && i+n<=totalframes(); } int clipframes(int i, int n) const { return min(n, totalframes() - i); } virtual void cleanup() {} - virtual void preload(part *p) {} - virtual void render(const animstate *as, float pitch, const vec &axis, const vec &forward, dynent *d, part *p) {} + virtual void preload(part *) {} + virtual void render(const animstate *, float , const vec &, const vec &, dynent *, part *) {} void bindpos(GLuint ebuf, GLuint vbuf, void *v, int stride) { if(lastebuf!=ebuf) { gle::bindebo(ebuf); @@ -423,7 +423,7 @@ struct animmodel : model { } } }; - virtual meshgroup *loadmeshes(const char *name, va_list args) { return NULL; } + virtual meshgroup *loadmeshes(const char *, va_list ) { return NULL; } meshgroup *sharemeshes(const char *name, ...) { static hashnameset<meshgroup *> meshgroups; if(!meshgroups.access(name)) { diff --git a/src/engine/client.cpp b/src/engine/client.cpp index 6ae6c27..a8da043 100644 --- a/src/engine/client.cpp +++ b/src/engine/client.cpp @@ -54,7 +54,7 @@ ICOMMAND(connectedport, "", (), { void abortconnect() { if(!connpeer) return; - game::connectfail(); + memset(game::connectpass, 0, sizeof(game::connectpass)); if(connpeer->state!=ENET_PEER_STATE_DISCONNECTED) enet_peer_reset(connpeer); connpeer = NULL; if(curpeer) return; @@ -101,7 +101,7 @@ void connectserv(const char *servername, int serverport, const char *serverpassw enet_host_flush(clienthost); connmillis = totalmillis; connattempts = 0; - game::connectattempt(servername ? servername : "", serverpassword ? serverpassword : "", address); + copystring(game::connectpass, serverpassword ? serverpassword : ""); } void reconnect(const char *serverpassword) { diff --git a/src/engine/decal.cpp b/src/engine/decal.cpp index bc39c1f..6c9cad6 100644 --- a/src/engine/decal.cpp +++ b/src/engine/decal.cpp @@ -244,12 +244,8 @@ struct decalrenderer { decalcenter = center; decalradius = radius; decalnormal = dir; -#if 0 - decaltangent.orthogonal(dir); -#else decaltangent = vec(dir.z, -dir.x, dir.y); decaltangent.sub(vec(dir).mul(decaltangent.dot(dir))); -#endif if(flags&DF_ROTATE) decaltangent.rotate(rnd(360)*RAD, dir); decaltangent.normalize(); decalbitangent.cross(decaltangent, dir); @@ -341,17 +337,10 @@ struct decalrenderer { float facing = n.dot(decalnormal); if(facing <= 0) continue; vec p = vec(pos[0]).sub(decalcenter); -#if 0 - // intersect ray along decal normal with plane - float dist = n.dot(p) / facing; - if(fabs(dist) > decalradius) continue; - vec pcenter = vec(decalnormal).mul(dist).add(decalcenter); -#else // travel back along plane normal from the decal center float dist = n.dot(p); if(fabs(dist) > decalradius) continue; vec pcenter = vec(n).mul(dist).add(decalcenter); -#endif vec ft, fb; ft.orthogonal(n); ft.normalize(); diff --git a/src/engine/dynlight.cpp b/src/engine/dynlight.cpp deleted file mode 100644 index 0c2a08d..0000000 --- a/src/engine/dynlight.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#include "engine.h" - -VARP(maxdynlights, 0, min(3, MAXDYNLIGHTS), MAXDYNLIGHTS); -VARP(dynlightdist, 0, 1024, 10000); - -struct dynlight { - vec o, hud; - float radius, initradius, curradius, dist; - vec color, initcolor, curcolor; - int fade, peak, expire, flags; - physent *owner; - void calcradius() { - if(fade + peak > 0) { - int remaining = expire - lastmillis; - if(flags&DL_EXPAND) - curradius = initradius + (radius - initradius) * (1.0f - remaining/float(fade + peak)); - else if(!(flags&DL_FLASH) && remaining > fade) - curradius = initradius + (radius - initradius) * (1.0f - float(remaining - fade)/peak); - else if(flags&DL_SHRINK) - curradius = (radius*remaining)/fade; - else curradius = radius; - } - else curradius = radius; - } - void calccolor() { - if(flags&DL_FLASH || peak <= 0) curcolor = color; - else { - int peaking = expire - lastmillis - fade; - if(peaking <= 0) curcolor = color; - else curcolor.lerp(initcolor, color, 1.0f - float(peaking)/peak); - } - float intensity = 1.0f; - if(fade > 0) { - int fading = expire - lastmillis; - if(fading < fade) intensity = float(fading)/fade; - } - curcolor.mul(intensity); - // KLUGE: this prevents nvidia drivers from trying to recompile dynlight fragment programs - loopk(3) if(fmod(curcolor[k], 1.0f/256) < 0.001f) curcolor[k] += 0.001f; - } -}; - -vector<dynlight> dynlights; -vector<dynlight *> closedynlights; - -void adddynlight(const vec &o, float radius, const vec &color, int fade, int peak, int flags, float initradius, const vec &initcolor, physent *owner) { - if(!maxdynlights) return; - if(o.dist(camera1->o) > dynlightdist || radius <= 0) return; - int insert = 0, expire = fade + peak + lastmillis; - loopvrev(dynlights) if(expire>=dynlights[i].expire) { insert = i+1; break; } - dynlight d; - d.o = d.hud = o; - d.radius = radius; - d.initradius = initradius; - d.color = color; - d.initcolor = initcolor; - d.fade = fade; - d.peak = peak; - d.expire = expire; - d.flags = flags; - d.owner = owner; - dynlights.insert(insert, d); -} - -void cleardynlights() { - int faded = -1; - loopv(dynlights) if(lastmillis<dynlights[i].expire) { faded = i; break; } - if(faded<0) dynlights.setsize(0); - else if(faded>0) dynlights.remove(0, faded); -} - -void removetrackeddynlights(physent *owner) { - loopvrev(dynlights) if(owner ? dynlights[i].owner == owner : dynlights[i].owner != NULL) dynlights.remove(i); -} - -void updatedynlights() { - cleardynlights(); - game::adddynlights(); - loopv(dynlights) { - dynlight &d = dynlights[i]; - if(d.owner) game::dynlighttrack(d.owner, d.o, d.hud); - d.calcradius(); - d.calccolor(); - } -} - -int finddynlights() { - closedynlights.setsize(0); - if(!maxdynlights) return 0; - physent e; - e.type = ENT_CAMERA; - loopvj(dynlights) { - dynlight &d = dynlights[j]; - if(d.curradius <= 0) continue; - d.dist = camera1->o.dist(d.o) - d.curradius; - if(d.dist > dynlightdist) - continue; - e.o = d.o; - e.radius = e.xradius = e.yradius = e.eyeheight = e.aboveeye = d.curradius; - if(!collide(&e, vec(0, 0, 0), 0, false)) continue; - int insert = 0; - loopvrev(closedynlights) if(d.dist >= closedynlights[i]->dist) { insert = i+1; break; } - closedynlights.insert(insert, &d); - if(closedynlights.length() >= DYNLIGHTMASK) break; - } - return closedynlights.length(); -} - -bool getdynlight(int n, vec &o, float &radius, vec &color) { - if(!closedynlights.inrange(n)) return false; - dynlight &d = *closedynlights[n]; - o = d.o; - radius = d.curradius; - color = d.curcolor; - return true; -} - -void dynlightreaching(const vec &target, vec &color, vec &dir, bool hud) { - vec dyncolor(0, 0, 0);//, dyndir(0, 0, 0); - loopv(dynlights) { - dynlight &d = dynlights[i]; - if(d.curradius<=0) continue; - vec ray(hud ? d.hud : d.o); - ray.sub(target); - float mag = ray.squaredlen(); - if(mag >= d.curradius*d.curradius) continue; - vec color = d.curcolor; - color.mul(1 - sqrtf(mag)/d.curradius); - dyncolor.add(color); - //dyndir.add(ray.mul(intensity/mag)); - } -#if 0 - if(!dyndir.iszero()) { - dyndir.normalize(); - float x = dyncolor.magnitude(), y = color.magnitude(); - if(x+y>0) { - dir.mul(x); - dyndir.mul(y); - dir.add(dyndir).div(x+y); - if(dir.iszero()) dir = vec(0, 0, 1); - else dir.normalize(); - } - } -#endif - color.add(dyncolor); -} - -void calcdynlightmask(vtxarray *va) { - uint mask = 0; - int offset = 0; - loopv(closedynlights) { - dynlight &d = *closedynlights[i]; - if(d.o.dist_to_bb(va->geommin, va->geommax) >= d.curradius) continue; - mask |= (i+1)<<offset; - offset += DYNLIGHTBITS; - if(offset >= maxdynlights*DYNLIGHTBITS) break; - } - va->dynlightmask = mask; -} - -int setdynlights(vtxarray *va) { - if(closedynlights.empty() || !va->dynlightmask) return 0; - extern bool minimizedynlighttcusage(); - static vec4 posv[MAXDYNLIGHTS]; - static vec colorv[MAXDYNLIGHTS]; - int index = 0; - for(uint mask = va->dynlightmask; mask; mask >>= DYNLIGHTBITS, index++) { - dynlight &d = *closedynlights[(mask&DYNLIGHTMASK)-1]; - float scale = 1.0f/d.curradius; - vec origin = vec(d.o).mul(-scale); - if(index>0 && minimizedynlighttcusage()) { - scale /= posv[0].w; - origin.sub(vec(posv[0]).mul(scale)); - } - posv[index] = vec4(origin, scale); - colorv[index] = d.curcolor; - } - GLOBALPARAMV(dynlightpos, posv, index); - GLOBALPARAMV(dynlightcolor, colorv, index); - return index; -} diff --git a/src/engine/engine.h b/src/engine/engine.h index 5d3fec3..29bfaff 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -60,13 +60,13 @@ extern void reloadfonts(); extern int hwtexsize, hwcubetexsize, hwmaxaniso, maxtexsize; extern Texture *textureload(const char *name, int clamp = 0, bool mipit = true, bool msg = true); -extern int texalign(const void *data, int w, int bpp); +extern int texalign(int w, int bpp); extern void cleanuptexture(Texture *t); extern uchar *loadalphamask(Texture *t); extern void loadlayermasks(); extern void loadshaders(); -extern void setuptexparameters(int tnum, void *pixels, int clamp, int filter, GLenum format = GL_RGB, GLenum target = GL_TEXTURE_2D, bool swizzle = false); -extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_2D, int pw = 0, int ph = 0, int pitch = 0, bool resize = true, GLenum format = GL_FALSE, bool swizzle = false); +extern void setuptexparameters(int tnum, int clamp, int filter, GLenum format = GL_RGB, GLenum target = GL_TEXTURE_2D); +extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_2D, int pw = 0, int ph = 0, int pitch = 0, bool resize = true, GLenum format = GL_FALSE); extern void blurtexture(int n, int bpp, int w, int h, uchar *dst, const uchar *src, int margin = 0); extern void blurnormals(int n, int w, int h, bvec *dst, const bvec *src, int margin = 0); extern bool reloadtexture(Texture &tex); @@ -247,14 +247,6 @@ extern void drawbb(const ivec &bo, const ivec &br); extern int oqfrags; -// dynlight - -extern void updatedynlights(); -extern int finddynlights(); -extern void calcdynlightmask(vtxarray *va); -extern int setdynlights(vtxarray *va); -extern bool getdynlight(int n, vec &o, float &radius, vec &color); - // material extern int showmat; @@ -281,7 +273,7 @@ extern void localconnect(); // serverbrowser extern bool resolverwait(const char *name, ENetAddress *address); -extern int connectwithtimeout(ENetSocket sock, const char *hostname, const ENetAddress &address); +extern int connectwithtimeout(ENetSocket sock, const ENetAddress &address); extern void addserver(const char *name, int port = 0, const char *password = NULL, bool keep = false); extern void writeservercfg(); @@ -340,7 +332,7 @@ extern void renderbackground(const char *caption = NULL, Texture *mapshot = NULL extern void renderprogress(float bar, const char *text, GLuint tex = 0, bool background = false); extern void getfps(int &fps, int &bestdiff, int &worstdiff); -extern void swapbuffers(bool overlay = true); +extern void swapbuffers(); extern int getclockmillis(); enum { KR_CONSOLE = 1<<0, KR_GUI = 1<<1, KR_EDITMODE = 1<<2 }; @@ -427,10 +419,7 @@ extern void clearmainmenu(); extern void g3d_mainmenu(); // sound -extern void clearmapsounds(); -extern void checkmapsounds(); extern void updatesounds(); -extern void preloadmapsounds(); #endif diff --git a/src/engine/lightmap.cpp b/src/engine/lightmap.cpp index 0a9daf1..c15e4b6 100644 --- a/src/engine/lightmap.cpp +++ b/src/engine/lightmap.cpp @@ -194,7 +194,7 @@ void show_calclight_progress() { int bpp = lm.bpp; if(tasklock) SDL_UnlockMutex(tasklock); glBindTexture(GL_TEXTURE_2D, progresstex); - glPixelStorei(GL_UNPACK_ALIGNMENT, texalign(data, LM_PACKW, bpp)); + glPixelStorei(GL_UNPACK_ALIGNMENT, texalign(LM_PACKW, bpp)); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LM_PACKW, LM_PACKH, bpp > 3 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, data); } renderprogress(bar1, text1, progresstexticks ? progresstex : 0); @@ -428,7 +428,7 @@ static bool lumelsample(const vec &sample, int aasample, int stride) { return false; } -static inline void generatealpha(lightmapworker *w, float tolerance, const vec &pos, uchar &alpha) { +static inline void generatealpha(lightmapworker *w, const vec &pos, uchar &alpha) { alpha = 0; if(w->slot->layermask) { static const int sdim[] = { 1, 0, 0 }, tdim[] = { 2, 2, 1 }; @@ -664,7 +664,6 @@ static int finishlightmap(lightmapworker *w) { static int previewlightmapalpha(lightmapworker *w, float lpu, const vec &origin1, const vec &xstep1, const vec &ystep1, const vec &origin2, const vec &xstep2, const vec &ystep2, float side0, float sidestep) { extern int fullbrightlevel; - float tolerance = 0.5 / lpu; uchar *dst = w->colorbuf; uchar minalpha = 255, maxalpha = 0; float sidex = side0; @@ -674,7 +673,7 @@ static int previewlightmapalpha(lightmapworker *w, float lpu, const vec &origin1 vec(xstep1).mul(x).add(vec(ystep1).mul(y)).add(origin1) : vec(xstep2).mul(x).add(vec(ystep2).mul(y)).add(origin2); loopk(3) dst[k] = fullbrightlevel; - generatealpha(w, tolerance, u, dst[3]); + generatealpha(w, u, dst[3]); minalpha = min(minalpha, dst[3]); maxalpha = max(maxalpha, dst[3]); } @@ -771,7 +770,7 @@ const vector<int> &checklightcache(int x, int y) { return lce.lights; } -static inline void addlight(lightmapworker *w, const extentity &light, int cx, int cy, int cz, int size, const vec *v, const vec *n, int numv) { +static inline void addlight(lightmapworker *w, const extentity &light, int cx, int cy, int cz, int size, const vec *v, const vec *n) { int radius = light.attr1; if(radius > 0) { if(light.o.x + radius < cx || light.o.x - radius > cx + size || @@ -790,7 +789,7 @@ static inline void addlight(lightmapworker *w, const extentity &light, int cx, i } } -static bool findlights(lightmapworker *w, int cx, int cy, int cz, int size, const vec *v, const vec *n, int numv, const Slot &slot, const VSlot &vslot) { +static bool findlights(lightmapworker *w, int cx, int cy, int cz, int size, const vec *v, const vec *n, const VSlot &vslot) { w->lights.setsize(0); const vector<extentity *> &ents = entities::getents(); static volatile bool usinglightcache = false; @@ -800,7 +799,7 @@ static bool findlights(lightmapworker *w, int cx, int cy, int cz, int size, cons loopv(lights) { const extentity &light = *ents[lights[i]]; switch(light.type) { - case ET_LIGHT: addlight(w, light, cx, cy, cz, size, v, n, numv); break; + case ET_LIGHT: addlight(w, light, cx, cy, cz, size, v, n); break; } } if(lightlock) { usinglightcache = false; SDL_UnlockMutex(lightlock); } @@ -808,7 +807,7 @@ static bool findlights(lightmapworker *w, int cx, int cy, int cz, int size, cons else loopv(ents) { const extentity &light = *ents[i]; switch(light.type) { - case ET_LIGHT: addlight(w, light, cx, cy, cz, size, v, n, numv); break; + case ET_LIGHT: addlight(w, light, cx, cy, cz, size, v, n); break; } } if(vslot.layer) return true; @@ -1132,7 +1131,7 @@ static lightmapinfo *setupsurfaces(lightmapworker *w, lightmaptask &task) { numlitverts += numverts; } } - if(!findlights(w, mo.x, mo.y, mo.z, msz, pos, n, numverts, *vslot.slot, vslot)) { + if(!findlights(w, mo.x, mo.y, mo.z, msz, pos, n, vslot)) { if(surf.numverts&MAXFACEVERTS) surf.numverts |= LAYER_TOP; continue; } @@ -1391,6 +1390,7 @@ bool lightmapworker::setupthread() { } static Uint32 calclighttimer(Uint32 interval, void *param) { + (void) param; check_calclight_progress = true; return interval; } @@ -1683,7 +1683,7 @@ void lightent(extentity &e, float height) { } else if(e.type>=ET_GAMESPECIFIC) ambient = 0.4f; vec target(e.o.x, e.o.y, e.o.z + height); - lightreaching(target, e.light.color, e.light.dir, false, &e, ambient); + lightreaching(target, e.light.color, e.light.dir, &e, ambient); } void lightents(bool force) { @@ -1705,7 +1705,7 @@ void initlights() { shouldlightents = true; } -void lightreaching(const vec &target, vec &color, vec &dir, bool fast, extentity *t, float ambient) { +void lightreaching(const vec &target, vec &color, vec &dir, extentity *t, float ambient) { if((fullbright && editmode) || lightmaps.empty()) { color = vec(1, 1, 1); dir = vec(0, 0, 1); diff --git a/src/engine/main.cpp b/src/engine/main.cpp index aa9b2fe..83aebaa 100644 --- a/src/engine/main.cpp +++ b/src/engine/main.cpp @@ -249,7 +249,7 @@ void renderbackground(const char *caption, Texture *mapshot, const char *mapname } } glDisable(GL_BLEND); - if(!restore) swapbuffers(false); + if(!restore) swapbuffers(); } if(!restore) setbackgroundinfo(caption, mapshot, mapname, mapinfo); } @@ -338,7 +338,7 @@ void renderprogress(float bar, const char *text, GLuint tex, bool background) { bgquad(x, y, sz, sz); glDisable(GL_BLEND); } - swapbuffers(false); + swapbuffers(); } int keyrepeatmask = 0, textinputmask = 0; @@ -659,6 +659,7 @@ template <int SIZE> static inline bool pumpevents(queue<SDL_Event, SIZE> &events static int interceptkeysym = 0; static int interceptevents(void *data, SDL_Event *event) { + (void) data; switch(event->type) { case SDL_MOUSEMOTION: return 0; case SDL_KEYDOWN: @@ -812,7 +813,7 @@ void checkinput() { if(mousemoved) resetmousemotion(); } -void swapbuffers(bool overlay) { +void swapbuffers() { gle::disable(); SDL_GL_SwapWindow(screen); } @@ -877,11 +878,6 @@ COMMANDN(getfps, getfps_, "i"); bool inbetweenframes = false, renderedframe = true; -static bool findarg(int argc, char **argv, const char *str) { - for(int i = 1; i<argc; i++) if(strstr(argv[i], str)==argv[i]) return true; - return false; -} - static int clockrealbase = 0, clockvirtbase = 0; static void clockreset() { clockrealbase = SDL_GetTicks(); clockvirtbase = totalmillis; } VARFP(clockerror, 990000, 1000000, 1010000, clockreset()); diff --git a/src/engine/octa.h b/src/engine/octa.h index 60cc507..0bc4762 100644 --- a/src/engine/octa.h +++ b/src/engine/octa.h @@ -110,7 +110,6 @@ struct vtxarray { occludequery *query; vector<octaentities *> mapmodels; int hasmerges, mergelevel; - uint dynlightmask; bool shadowed; }; diff --git a/src/engine/octaedit.cpp b/src/engine/octaedit.cpp index 80e2b03..61d8917 100644 --- a/src/engine/octaedit.cpp +++ b/src/engine/octaedit.cpp @@ -291,7 +291,7 @@ bool editmoveplane(const vec &o, const vec &ray, int d, float off, vec &handle, extern void entdrag(const vec &ray); extern bool hoveringonent(int ent, int orient); -extern void renderentselection(const vec &o, bool entmoving); +extern void renderentselection(bool entmoving); extern float rayent(const vec &o, const vec &ray, float radius, int mode, int size, int &orient, int &ent); VAR(gridlookup, 0, 0, 1); @@ -411,7 +411,7 @@ void rendereditcursor() { glBlendFunc(GL_ONE, GL_ONE); // cursors notextureshader->set(); - renderentselection(player->o, entmoving!=0); + renderentselection(entmoving!=0); boxoutline = outline!=0; enablepolygonoffset(GL_POLYGON_OFFSET_LINE); if(!moving && !hovering && !hidecursor) { @@ -537,14 +537,6 @@ void selgridmap(selinfo &sel, uchar *g) { // generates a map of the cube VARP(nompedit, 0, 1, 1); -static inline int countblock(cube *c, int n = 8) { - int r = 0; - loopi(n) if(c[i].children) r += countblock(c[i].children); else ++r; - return r; -} - -static int countblock(block3 *b) { return countblock(b->c(), b->size()); } - vector<editinfo *> editinfos; editinfo *localedit = NULL; diff --git a/src/engine/physics.cpp b/src/engine/physics.cpp index 868bcc1..17dfb37 100644 --- a/src/engine/physics.cpp +++ b/src/engine/physics.cpp @@ -1083,12 +1083,6 @@ void falling(physent *d, vec &dir, const vec &floor) { } void landing(physent *d, vec &dir, const vec &floor, bool collided) { -#if 0 - if(d->physstate == PHYS_FALL) { - d->timeinair = 0; - if(dir.z < 0.0f) dir.z = d->vel.z = 0.0f; - } -#endif switchfloor(d, dir, floor); d->timeinair = 0; if((d->physstate!=PHYS_STEP_UP && d->physstate!=PHYS_STEP_DOWN) || !collided) @@ -1310,7 +1304,7 @@ FVAR(straferoll, 0, 0.033f, 90); FVAR(faderoll, 0, 0.95f, 1); VAR(floatspeed, 1, 100, 10000); -void modifyvelocity(physent *pl, bool local, bool floating, int curtime) { +void modifyvelocity(physent *pl, bool floating, int curtime) { bool allowmove = game::allowmove(pl); if(floating) { if(pl->jumping && allowmove) { @@ -1371,13 +1365,14 @@ void modifygravity(physent *pl, int curtime) { // local is false for multiplayer prediction bool moveplayer(physent *pl, int moveres, bool local, int curtime) { + (void) local; int material = lookupmaterial(vec(pl->o.x, pl->o.y, pl->o.z + (3*pl->aboveeye - pl->eyeheight)/4)); bool floating = pl->type==ENT_PLAYER && (pl->state==CS_EDITING || pl->state==CS_SPECTATOR); float secs = curtime/1000.f; // apply gravity if(!floating) modifygravity(pl, curtime); // apply any player generated changes in velocity - modifyvelocity(pl, local, floating, curtime); + modifyvelocity(pl, floating, curtime); vec d(pl->vel); if(!floating) d.mul(0.5f); d.add(pl->falling); @@ -1390,8 +1385,7 @@ bool moveplayer(physent *pl, int moveres, bool local, int curtime) { pl->falling = vec(0, 0, 0); } pl->o.add(d); - } - else { // apply velocity with collision { + } else { // apply velocity with collision { const float f = 1.0f/moveres; const int timeinair = pl->timeinair; int collisions = 0; diff --git a/src/engine/rendergl.cpp b/src/engine/rendergl.cpp index 4243ac7..e448415 100644 --- a/src/engine/rendergl.cpp +++ b/src/engine/rendergl.cpp @@ -397,9 +397,6 @@ void gl_checkextensions() { glIsVertexArray_ = (PFNGLISVERTEXARRAYPROC) getprocaddress("glIsVertexArrayAPPLE"); hasVAO = true; } - if(glversion >= 330 || hasext("GL_ARB_texture_swizzle") || hasext("GL_EXT_texture_swizzle")) { - hasTSW = true; - } if(hasext("GL_EXT_texture_compression_s3tc")) { hasS3TC = true; if(!mesa) usetexcompress = 2; @@ -425,8 +422,7 @@ void gl_checkextensions() { } if(glversion >= 300 || hasext("GL_EXT_gpu_shader4")) { // on DX10 or above class cards (i.e. GF8 or RadeonHD) enable expensive features - extern int maxdynlights, texcompress; - maxdynlights = MAXDYNLIGHTS; + extern int texcompress; texcompress = max(texcompress, 1024 + 1); } } @@ -957,7 +953,6 @@ int xtraverts, xtravertsva; void gl_drawframe() { if(deferdrawtextures) drawtextures(); - updatedynlights(); int w = screenw, h = screenh; aspect = forceaspect ? forceaspect : w/float(h); fovy = 2*atan2(tan(curfov/2*RAD), aspect)/RAD; diff --git a/src/engine/rendermodel.cpp b/src/engine/rendermodel.cpp index 0355213..cfdf326 100644 --- a/src/engine/rendermodel.cpp +++ b/src/engine/rendermodel.cpp @@ -265,10 +265,6 @@ void mmodel(char *name) { mmi.m = NULL; } -void mapmodelcompat(int *rad, int *h, int *tex, char *name, char *shadow) { - mmodel(name); -} - void mapmodelreset(int *n) { if(!(identflags&IDF_OVERRIDDEN) && !game::allowedittoggle()) return; mapmodels.shrink(clamp(*n, 0, mapmodels.length())); @@ -278,7 +274,6 @@ mapmodelinfo *getmminfo(int i) { return mapmodels.inrange(i) ? &mapmodels[i] : 0 const char *mapmodelname(int i) { return mapmodels.inrange(i) ? mapmodels[i].name : NULL; } COMMAND(mmodel, "s"); -COMMANDN(mapmodel, mapmodelcompat, "iiiss"); COMMAND(mapmodelreset, "i"); ICOMMAND(mapmodelname, "i", (int *index), { result(mapmodels.inrange(*index) ? mapmodels[*index].name : ""); }); ICOMMAND(mapmodelloaded, "i", (int *index), { intret(mapmodels.inrange(*index) && mapmodels[*index].m ? 1 : 0); }); @@ -620,7 +615,7 @@ static inline void disablecullmodelquery() { endbb(); } -static inline int cullmodel(model *m, const vec ¢er, float radius, int flags, dynent *d = NULL, bool shadow = false) { +static inline int cullmodel(const vec ¢er, float radius, int flags, dynent *d = NULL) { if(flags&MDL_CULL_DIST && center.dist(camera1->o)/radius>maxmodelradiusdistance) return MDL_CULL_DIST; if(flags&MDL_CULL_VFC) { if(shadowmapping && !isshadowmapcaster(center, radius)) return MDL_CULL_VFC; @@ -664,7 +659,7 @@ void rendermodel(entitylight *light, const char *mdl, int anim, const vec &o, fl center.rotate_around_z(yaw*RAD); center.add(o); } - int culled = cullmodel(m, center, radius, flags, d, shadow); + int culled = cullmodel(center, radius, flags, d); if(culled) { if(culled&(MDL_CULL_OCCLUDED|MDL_CULL_QUERY) && flags&MDL_CULL_QUERY) { enablecullmodelquery(); @@ -703,24 +698,20 @@ void rendermodel(entitylight *light, const char *mdl, int anim, const vec &o, fl pos.z += radius/2; } else if(d->type < ENT_CAMERA) pos.z += 0.75f*(d->eyeheight + d->aboveeye); - lightreaching(pos, light->color, light->dir, (flags&MDL_LIGHT_FAST)!=0); - dynlightreaching(pos, light->color, light->dir, (flags&MDL_HUD)!=0); + lightreaching(pos, light->color, light->dir); light->millis = lastmillis; } } else if(flags&MDL_LIGHT) { if(!light) { - lightreaching(pos, lightcolor, lightdir, (flags&MDL_LIGHT_FAST)!=0); - dynlightreaching(pos, lightcolor, lightdir, (flags&MDL_HUD)!=0); + lightreaching(pos, lightcolor, lightdir); } else if(light->millis!=lastmillis) { - lightreaching(pos, light->color, light->dir, (flags&MDL_LIGHT_FAST)!=0); - dynlightreaching(pos, light->color, light->dir, (flags&MDL_HUD)!=0); + lightreaching(pos, light->color, light->dir); light->millis = lastmillis; } } if(light) { lightcolor = light->color; lightdir = light->dir; } - if(flags&MDL_DYNLIGHT) dynlightreaching(pos, lightcolor, lightdir, (flags&MDL_HUD)!=0); } if(a) for(int i = 0; a[i].tag; i++) { if(a[i].name) a[i].m = loadmodel(a[i].name); diff --git a/src/engine/renderparticles.cpp b/src/engine/renderparticles.cpp index dbdf855..637dcb2 100644 --- a/src/engine/renderparticles.cpp +++ b/src/engine/renderparticles.cpp @@ -146,7 +146,7 @@ struct partrenderer { virtual void render() = 0; virtual bool haswork() = 0; virtual void cleanup() {} - virtual void seedemitter(particleemitter &pe, const vec &o, const vec &d, int fade, float size, int gravity) { + virtual void seedemitter(particleemitter &, const vec &, const vec &, int , float , int ) { } //blend = 0 => remove it void calc(particle *p, int &blend, int &ts, vec &o, vec &d, bool step = true) { @@ -409,16 +409,8 @@ struct texticonrenderer : listrenderer { static texticonrenderer texticons("packages/hud/items.png", PT_TEXTICON|PT_LERP); template<int T> -static inline void modifyblend(const vec &o, int &blend) { - blend = min(blend<<2, 255); -} - -template<> -inline void modifyblend<PT_TAPE>(const vec &o, int &blend) { -} - -template<int T> static inline void genpos(const vec &o, const vec &d, float size, int grav, int ts, partvert *vs) { + (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs; vec udir = vec(camup).sub(camright).mul(size); vec vdir = vec(camup).add(camright).mul(size); vs[0].pos = vec(o.x + udir.x, o.y + udir.y, o.z + udir.z); @@ -429,6 +421,7 @@ static inline void genpos(const vec &o, const vec &d, float size, int grav, int template<> inline void genpos<PT_TAPE>(const vec &o, const vec &d, float size, int ts, int grav, partvert *vs) { + (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs; vec dir1 = d, dir2 = d, c; dir1.sub(o); dir2.sub(camera1->o); @@ -441,6 +434,7 @@ inline void genpos<PT_TAPE>(const vec &o, const vec &d, float size, int ts, int template<> inline void genpos<PT_TRAIL>(const vec &o, const vec &d, float size, int ts, int grav, partvert *vs) { + (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs; vec e = d; if(grav) e.z -= float(ts)/grav; e.div(-75.0f).add(o); @@ -449,6 +443,7 @@ inline void genpos<PT_TRAIL>(const vec &o, const vec &d, float size, int ts, int template<int T> static inline void genrotpos(const vec &o, const vec &d, float size, int grav, int ts, partvert *vs, int rot) { + (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs; (void) rot; genpos<T>(o, d, size, grav, ts, vs); } @@ -467,6 +462,7 @@ static const vec rotcoeffs[32][4] = { template<> inline void genrotpos<PT_PART>(const vec &o, const vec &d, float size, int grav, int ts, partvert *vs, int rot) { + (void) o; (void) size; (void) d; (void) grav; (void) ts; (void) vs; (void) rot; const vec *coeffs = rotcoeffs[rot]; (vs[0].pos = o).add(vec(camright).mul(coeffs[0].x*size)).add(vec(camup).mul(coeffs[0].y*size)); (vs[1].pos = o).add(vec(camright).mul(coeffs[1].x*size)).add(vec(camup).mul(coeffs[1].y*size)); @@ -577,7 +573,7 @@ struct varenderer : partrenderer { int blend, ts; calc(p, blend, ts, o, d); if(blend <= 1 || p->fade <= 5) p->fade = -1; //mark to remove on next pass (i.e. after render) - modifyblend<T>(o, blend); + blend = min(blend<<2, 255); if(regen) { p->flags &= ~0x80; #define SETTEXCOORDS(u1c, u2c, v1c, v2c, body) { \ diff --git a/src/engine/renderva.cpp b/src/engine/renderva.cpp index dada6d3..a98614a 100644 --- a/src/engine/renderva.cpp +++ b/src/engine/renderva.cpp @@ -528,9 +528,7 @@ struct renderstate { VSlot *vslot, *texgenvslot; vec2 texgenscroll; int texgendim; - int visibledynlights; - uint dynlightmask; - renderstate() : colormask(true), depthmask(true), blending(false), alphaing(0), vbuf(0), vattribs(false), vquery(false), colorscale(1, 1, 1), alphascale(0), slot(NULL), texgenslot(NULL), vslot(NULL), texgenvslot(NULL), texgenscroll(0, 0), texgendim(-1), visibledynlights(0), dynlightmask(0) { + renderstate() : colormask(true), depthmask(true), blending(false), alphaing(0), vbuf(0), vattribs(false), vquery(false), colorscale(1, 1, 1), alphascale(0), slot(NULL), texgenslot(NULL), vslot(NULL), texgenvslot(NULL), texgenscroll(0, 0), texgendim(-1) { loopk(8) textures[k] = 0; } }; @@ -580,8 +578,6 @@ struct geombatch { int compare(const geombatch &b) const { if(va->vbuf < b.va->vbuf) return -1; if(va->vbuf > b.va->vbuf) return 1; - if(va->dynlightmask < b.va->dynlightmask) return -1; - if(va->dynlightmask > b.va->dynlightmask) return 1; if(vslot.slot->shader < b.vslot.slot->shader) return -1; if(vslot.slot->shader > b.vslot.slot->shader) return 1; if(vslot.slot->params.length() < b.vslot.slot->params.length()) return -1; @@ -718,10 +714,6 @@ static void changebatchtmus(renderstate &cur, int pass, geombatch &b) { tmu++; } if(changed) glActiveTexture_(GL_TEXTURE0); - if(cur.dynlightmask != b.va->dynlightmask) { - cur.visibledynlights = setdynlights(b.va); - cur.dynlightmask = b.va->dynlightmask; - } } static void changeslottmus(renderstate &cur, int pass, Slot &slot, VSlot &vslot) { @@ -758,16 +750,6 @@ static void changeslottmus(renderstate &cur, int pass, Slot &slot, VSlot &vslot) cur.vslot = &vslot; } -static void changeshader(renderstate &cur, Shader *s, Slot &slot, VSlot &vslot, bool shadowed) { - if(!cur.blending && !cur.alphaing) { - if(shadowed) s->setvariant(cur.visibledynlights, 3, slot, vslot); - else s->setvariant(cur.visibledynlights, 2, slot, vslot); - } - else if(shadowed) s->setvariant(cur.visibledynlights, 1, slot, vslot); - else if(!cur.visibledynlights) s->set(slot, vslot); - else s->setvariant(cur.visibledynlights-1, 0, slot, vslot); -} - static void changetexgen(renderstate &cur, int dim, Slot &slot, VSlot &vslot) { if(cur.texgenslot != &slot || cur.texgenvslot != &vslot) { Texture *curtex = !cur.texgenslot || cur.texgenslot->sts.empty() ? notexture : cur.texgenslot->sts[0].t, @@ -803,7 +785,6 @@ static void renderbatch(renderstate &cur, int pass, geombatch &b) { ushort len = curbatch->es.length[curbatch->va->shadowed ? 0 : 1]; if(len) { if(rendered < 0) { - changeshader(cur, b.vslot.slot->shader, *b.vslot.slot, b.vslot, false); rendered = 0; gbatches++; } @@ -818,7 +799,6 @@ static void renderbatch(renderstate &cur, int pass, geombatch &b) { if(shadowed) for(geombatch *curbatch = shadowed;; curbatch = &geombatches[curbatch->batch]) { if(curbatch->va->shadowed && curbatch->es.length[1] > curbatch->es.length[0]) { if(rendered < 1) { - changeshader(cur, b.vslot.slot->shader, *b.vslot.slot, b.vslot, true); rendered = 1; gbatches++; } @@ -912,10 +892,8 @@ void renderva(renderstate &cur, vtxarray *va, int pass = RENDERPASS_LIGHTMAP, bo case RENDERPASS_LIGHTMAP: if(!cur.alphaing) vverts += va->verts; va->shadowed = false; - va->dynlightmask = 0; if(!drawtex && !cur.alphaing) { va->shadowed = isshadowmapreceiver(va); - calcdynlightmask(va); } if(doquery) startvaquery(va, { if(geombatches.length()) renderbatches(cur, pass); }); mergetexs(cur, va); @@ -943,7 +921,7 @@ void cleanupva() { cleanupbb(); } -void setupgeom(renderstate &cur) { +void setupgeom() { GLOBALPARAMF(colorparams, 2, 2, 2, 1); GLOBALPARAM(camera, camera1->o); GLOBALPARAMF(ambient, ambientcolor.x/255.0f, ambientcolor.y/255.0f, ambientcolor.z/255.0f); @@ -970,10 +948,9 @@ void rendergeom(void) { } if(!doZP) { if(shadowmap && mainpass) rendershadowmap(); - setupgeom(cur); + setupgeom(); if(doSM) pushshadowmap(); } - finddynlights(); resetbatches(); int blends = 0; for(vtxarray *va = visibleva; va; va = va->next) { @@ -1015,7 +992,7 @@ void rendergeom(void) { if(doZP) { glFlush(); if(shadowmap && mainpass) rendershadowmap(); - setupgeom(cur); + setupgeom(); if(doSM) pushshadowmap(); if(!multipassing) { multipassing = true; glDepthFunc(GL_LEQUAL); } cur.texgendim = -1; @@ -1087,7 +1064,7 @@ void renderalphageom(void) { glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); if(cur.vattribs) disablevattribs(cur, false); if(cur.vbuf) disablevbuf(cur); - setupgeom(cur); + setupgeom(); glDepthFunc(GL_LEQUAL); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/engine/server.cpp b/src/engine/server.cpp index c23e4fa..10c1e80 100644 --- a/src/engine/server.cpp +++ b/src/engine/server.cpp @@ -39,6 +39,7 @@ void fatal(const char *fmt, ...) { } void conoutfv(int type, const char *fmt, va_list args) { + (void) type; logoutfv(fmt, args); } #endif @@ -263,7 +264,7 @@ bool resolverwait(const char *name, ENetAddress *address) { return enet_address_set_host(address, name) >= 0; } -int connectwithtimeout(ENetSocket sock, const char *hostname, const ENetAddress &remoteaddress) { +int connectwithtimeout(ENetSocket sock, const ENetAddress &remoteaddress) { return enet_socket_connect(sock, &remoteaddress); } #endif @@ -307,7 +308,7 @@ ENetSocket connectmaster(bool wait) { if(wait || serveraddress.host == ENET_HOST_ANY || !enet_socket_bind(sock, &serveraddress)) { enet_socket_set_option(sock, ENET_SOCKOPT_NONBLOCK, 1); if(wait) { - if(!connectwithtimeout(sock, mastername, masteraddress)) return sock; + if(!connectwithtimeout(sock, masteraddress)) return sock; } else if(!enet_socket_connect(sock, &masteraddress)) return sock; } @@ -662,7 +663,7 @@ COMMAND(stoplistenserver, ""); #endif #ifdef STANDALONE -int main(int argc, char **argv) { +int main(void) { if(enet_initialize()<0) fatal("Unable to initialise network module"); atexit(enet_deinitialize); enet_time_set(0); diff --git a/src/engine/serverbrowser.cpp b/src/engine/serverbrowser.cpp index a839c35..d821c76 100644 --- a/src/engine/serverbrowser.cpp +++ b/src/engine/serverbrowser.cpp @@ -156,8 +156,8 @@ bool resolverwait(const char *name, ENetAddress *address) { #define CONNLIMIT 20000 -int connectwithtimeout(ENetSocket sock, const char *hostname, const ENetAddress &address) { - defformatstring(text, "connecting to %s... (esc to abort)", hostname); +int connectwithtimeout(ENetSocket sock, const ENetAddress &address) { + defformatstring(text, "connecting to server... (esc to abort)"); renderprogress(0, text); ENetSocketSet readset, writeset; if(!enet_socket_connect(sock, &address)) for(int starttime = SDL_GetTicks(), timeout = 0; timeout <= CONNLIMIT;) { diff --git a/src/engine/shader.cpp b/src/engine/shader.cpp index 86e4546..eb10720 100644 --- a/src/engine/shader.cpp +++ b/src/engine/shader.cpp @@ -445,7 +445,7 @@ void Shader::cleanup(bool invalid) { bool Shader::isnull(const Shader *s) { return !s; } -static void genattriblocs(Shader &s, const char *vs, const char *ps, Shader *reusevs, Shader *reuseps) { +static void genattriblocs(Shader &s, const char *vs, Shader *reusevs) { static int len = strlen("//:attrib"); string name; int loc; @@ -457,7 +457,7 @@ static void genattriblocs(Shader &s, const char *vs, const char *ps, Shader *reu } } -static void genuniformlocs(Shader &s, const char *vs, const char *ps, Shader *reusevs, Shader *reuseps) { +static void genuniformlocs(Shader &s, const char *vs, Shader *reusevs) { static int len = strlen("//:uniform"); string name, blockname; int binding, stride; @@ -503,8 +503,8 @@ Shader *newshader(int type, const char *name, const char *vs, const char *ps, Sh else loopv(slotparams) s.defaultparams.add(slotparams[i]); s.attriblocs.setsize(0); s.uniformlocs.setsize(0); - genattriblocs(s, vs, ps, s.reusevs, s.reuseps); - genuniformlocs(s, vs, ps, s.reusevs, s.reuseps); + genattriblocs(s, vs, s.reusevs); + genuniformlocs(s, vs, s.reusevs); if(!s.compile()) { s.cleanup(true); if(variant) shaders.remove(rname); @@ -622,60 +622,6 @@ static void gengenericvariant(Shader &s, const char *sname, const char *vs, cons newshader(s.type, varname, vschanged ? vsv.getbuf() : reuse, pschanged ? psv.getbuf() : reuse, &s, row); } -bool minimizedynlighttcusage() { return glversion < 300 && maxvaryings < 48; } - -static void gendynlightvariant(Shader &s, const char *sname, const char *vs, const char *ps, int row = 0) { - int numlights = minimizedynlighttcusage() ? 1 : MAXDYNLIGHTS; - const char *vspragma = strstr(vs, "//:dynlight"), *pspragma = strstr(ps, "//:dynlight"); - if(!vspragma || !pspragma) return; - string pslight; - vspragma += strcspn(vspragma, "\n"); - if(*vspragma) vspragma++; - if(sscanf(pspragma, "//:dynlight %100s", pslight)!=1) return; - pspragma += strcspn(pspragma, "\n"); - if(*pspragma) pspragma++; - const char *vsmain = findglslmain(vs), *psmain = findglslmain(ps); - if(vsmain > vspragma) vsmain = vs; - if(psmain > pspragma) psmain = ps; - vector<char> vsdl, psdl; - loopi(MAXDYNLIGHTS) { - vsdl.setsize(0); - psdl.setsize(0); - if(vsmain >= vs) vsdl.put(vs, vsmain - vs); - if(psmain >= ps) psdl.put(ps, psmain - ps); - defformatstring(pos, "uniform vec4 dynlightpos[%d];\n", i+1); - vsdl.put(pos, strlen(pos)); - psdl.put(pos, strlen(pos)); - defformatstring(color, "uniform vec3 dynlightcolor[%d];\n", i+1); - psdl.put(color, strlen(color)); - loopk(min(i+1, numlights)) { - defformatstring(dir, "%sdynlight%ddir%s", !k ? "varying vec3 " : " ", k, k==i || k+1==numlights ? ";\n" : ","); - vsdl.put(dir, strlen(dir)); - psdl.put(dir, strlen(dir)); - } - vsdl.put(vsmain, vspragma-vsmain); - psdl.put(psmain, pspragma-psmain); - loopk(i+1) { - defformatstring(tc, - k<numlights ? - "dynlight%ddir = vvertex.xyz*dynlightpos[%d].w + dynlightpos[%d].xyz;\n" : - "vec3 dynlight%ddir = dynlight0dir*dynlightpos[%d].w + dynlightpos[%d].xyz;\n", - k, k, k); - if(k < numlights) vsdl.put(tc, strlen(tc)); - else psdl.put(tc, strlen(tc)); - defformatstring(dl, - "%s.rgb += dynlightcolor[%d] * (1.0 - clamp(dot(dynlight%ddir, dynlight%ddir), 0.0, 1.0));\n", - pslight, k, k, k); - psdl.put(dl, strlen(dl)); - } - vsdl.put(vspragma, strlen(vspragma)+1); - psdl.put(pspragma, strlen(pspragma)+1); - defformatstring(name, "<dynlight %d>%s", i+1, sname); - Shader *variant = newshader(s.type, name, vsdl.getbuf(), psdl.getbuf(), &s, row); - if(!variant) return; - } -} - static void genshadowmapvariant(Shader &s, const char *sname, const char *vs, const char *ps, int row = 1) { const char *vspragma = strstr(vs, "//:shadowmap"), *pspragma = strstr(ps, "//:shadowmap"); if(!vspragma || !pspragma) return; @@ -724,7 +670,6 @@ static void genshadowmapvariant(Shader &s, const char *sname, const char *vs, co defformatstring(name, "<shadowmap>%s", sname); Shader *variant = newshader(s.type, name, vssm.getbuf(), pssm.getbuf(), &s, row); if(!variant) return; - if(strstr(vs, "//:dynlight")) gendynlightvariant(s, name, vssm.getbuf(), pssm.getbuf(), row); } static void genuniformdefs(vector<char> &vsbuf, vector<char> &psbuf, const char *vs, const char *ps, Shader *variant = NULL) { @@ -842,7 +787,6 @@ void shader(int *type, char *name, char *vs, char *ps) { Shader *s = newshader(*type, name, vs, ps); if(s) { if(strstr(vs, "//:shadowmap")) genshadowmapvariant(*s, s->name, vs, ps); - if(strstr(vs, "//:dynlight")) gendynlightvariant(*s, s->name, vs, ps); } slotparams.shrink(0); } @@ -862,7 +806,6 @@ void variantshader(int *type, char *name, int *row, char *vs, char *ps) { GENSHADER(s->defaultparams.length(), genuniformdefs(vsbuf, psbuf, vs, ps, s)); Shader *v = newshader(*type, varname, vs, ps, s, *row); if(v) { - if(strstr(vs, "//:dynlight")) gendynlightvariant(*s, varname, vs, ps, *row); if(strstr(ps, "//:variant") || strstr(vs, "//:variant")) gengenericvariant(*s, varname, vs, ps, *row); } } diff --git a/src/engine/shadowmap.cpp b/src/engine/shadowmap.cpp index 1eefe4b..e86f65f 100644 --- a/src/engine/shadowmap.cpp +++ b/src/engine/shadowmap.cpp @@ -185,19 +185,6 @@ bool isshadowmapreceiver(vtxarray *va) { vec center = vec(va->shadowmapmin).add(vec(va->shadowmapmax)).mul(0.5f); calcshadowmapbb(center, xyrad, zrad, x1, y1, x2, y2); return shadowmaptex.checkblurtiles(x1, y1, x2, y2, 2); - -#if 0 - // cheaper inexact test - float dz = va->o.z + va->size/2 - shadowfocus.z; - float cx = shadowfocus.x + dz*shadowdir.x, cy = shadowfocus.y + dz*shadowdir.y; - float skew = va->size/2*SHADOWSKEW; - if(!shadowmap || !shadowmaptex || - va->o.z + va->size <= shadowfocus.z - shadowmapdist || va->o.z >= shadowmapmaxz || - va->o.x + va->size <= cx - shadowmapradius-skew || va->o.x >= cx + shadowmapradius+skew || - va->o.y + va->size <= cy - shadowmapradius-skew || va->o.y >= cy + shadowmapradius+skew) - return false; - return true; -#endif } bool isshadowmapcaster(const vec &o, float rad) { diff --git a/src/engine/skelmodel.h b/src/engine/skelmodel.h index e823337..ad5d34e 100644 --- a/src/engine/skelmodel.h +++ b/src/engine/skelmodel.h @@ -243,13 +243,13 @@ struct skelmodel : animmodel { return numverts; } template<class T> - static inline void fillvert(T &vv, int j, vert &v) { + static inline void fillvert(T &vv, vert &v) { vv.tc = v.tc; } template<class T> void fillverts(T *vdata) { vdata += voffset; - loopi(numverts) fillvert(vdata[i], i, verts[i]); + loopi(numverts) fillvert(vdata[i], verts[i]); } void interpverts(const dualquat * RESTRICT bdata1, const dualquat * RESTRICT bdata2, bool tangents, void * RESTRICT vdata, skin &s) { const int blendoffset = ((skelmeshgroup *)group)->skel->numgpubones; diff --git a/src/engine/sound.cpp b/src/engine/sound.cpp index 62cab3e..d9b2473 100644 --- a/src/engine/sound.cpp +++ b/src/engine/sound.cpp @@ -58,7 +58,7 @@ struct soundchannel { vector<soundchannel> channels; int maxchannels = 0; -soundchannel &newchannel(int n, soundslot *slot, const vec *loc = NULL, extentity *ent = NULL, int flags = 0, int radius = 0) { +soundchannel &newchannel(int n, soundslot *slot, const vec *loc = NULL, extentity *ent = NULL, int radius = 0) { if(ent) { loc = &ent->o; ent->flags |= EF_SOUND; @@ -443,33 +443,21 @@ static struct soundtype { bool playing(const soundchannel &chan, const soundconfig &config) const { return chan.inuse && config.hasslot(chan.slot, slots); } -} gamesounds, mapsounds; +} gamesounds; void registersound(char *name, int *vol) { intret(gamesounds.addsound(name, *vol, 0)); } COMMAND(registersound, "si"); -void mapsound(char *name, int *vol, int *maxuses) { intret(mapsounds.addsound(name, *vol, *maxuses < 0 ? 0 : max(1, *maxuses))); } -COMMAND(mapsound, "sii"); - void altsound(char *name, int *vol) { gamesounds.addalt(name, *vol); } COMMAND(altsound, "si"); -void altmapsound(char *name, int *vol) { mapsounds.addalt(name, *vol); } -COMMAND(altmapsound, "si"); - ICOMMAND(numsounds, "", (), intret(gamesounds.configs.length())); -ICOMMAND(nummapsounds, "", (), intret(mapsounds.configs.length())); void soundreset() { gamesounds.reset(); } COMMAND(soundreset, ""); -void mapsoundreset() { - mapsounds.reset(); -} -COMMAND(mapsoundreset, ""); - void resetchannels() { loopv(channels) if(channels[i].inuse) freechannel(i); channels.shrink(0); @@ -480,46 +468,11 @@ void clear_sound() { stopmusic(); cleanupsamples(); gamesounds.clear(); - mapsounds.clear(); samples.clear(); Mix_CloseAudio(); resetchannels(); } -void stopmapsounds() { - loopv(channels) if(channels[i].inuse && channels[i].ent) { - Mix_HaltChannel(i); - freechannel(i); - } -} - -void clearmapsounds() { - stopmapsounds(); - mapsounds.clear(); -} - -void stopmapsound(extentity *e) { - loopv(channels) { - soundchannel &chan = channels[i]; - if(chan.inuse && chan.ent == e) { - Mix_HaltChannel(i); - freechannel(i); - } - } -} - -void checkmapsounds() { - const vector<extentity *> &ents = entities::getents(); - loopv(ents) { - extentity &e = *ents[i]; - if(e.type!=ET_SOUND) continue; - if(camera1->o.dist(e.o) < e.attr2) { - if(!(e.flags&EF_SOUND)) playsound(e.attr1, NULL, &e, SND_MAP, -1); - } - else if(e.flags&EF_SOUND) stopmapsound(&e); - } -} - VAR(stereo, 0, 1, 1); bool updatechannel(soundchannel &chan) { @@ -573,8 +526,6 @@ void updatesounds() { if(minimized && !minimizedsounds) stopsounds(); else { reclaimchannels(); - if(mainmenu) stopmapsounds(); - else checkmapsounds(); syncchannels(); } if(music) { @@ -589,21 +540,9 @@ void preloadsound(int n) { gamesounds.preloadsound(n); } -void preloadmapsound(int n) { - mapsounds.preloadsound(n); -} - -void preloadmapsounds() { - const vector<extentity *> &ents = entities::getents(); - loopv(ents) { - extentity &e = *ents[i]; - if(e.type==ET_SOUND) mapsounds.preloadsound(e.attr1); - } -} - -int playsound(int n, const vec *loc, extentity *ent, int flags, int loops, int fade, int chanid, int radius, int expire) { +int playsound(int n, const vec *loc, extentity *ent, int loops, int fade, int chanid, int radius, int expire) { if(nosound || !soundvol || (minimized && !minimizedsounds)) return -1; - soundtype &sounds = ent || flags&SND_MAP ? mapsounds : gamesounds; + soundtype &sounds = gamesounds; if(!sounds.configs.inrange(n)) { conoutf(CON_WARN, "unregistered sound: %d", n); return -1; } soundconfig &config = sounds.configs[n]; if(loc) { @@ -638,14 +577,14 @@ int playsound(int n, const vec *loc, extentity *ent, int flags, int loops, int f } } if(fade < 0) return -1; - soundslot &slot = sounds.slots[config.chooseslot(flags)]; + soundslot &slot = sounds.slots[config.chooseslot(0)]; if(!slot.sample->chunk && !slot.sample->load()) return -1; chanid = -1; loopv(channels) if(!channels[i].inuse) { chanid = i; break; } if(chanid < 0 && channels.length() < maxchannels) chanid = channels.length(); if(chanid < 0) loopv(channels) if(!channels[i].volume) { chanid = i; break; } if(chanid < 0) return -1; - soundchannel &chan = newchannel(chanid, &slot, loc, ent, flags, radius); + soundchannel &chan = newchannel(chanid, &slot, loc, ent, radius); updatechannel(chan); int playing = -1; if(fade) { @@ -674,11 +613,11 @@ bool stopsound(int n, int chanid, int fade) { return true; } -int playsoundname(const char *s, const vec *loc, int vol, int flags, int loops, int fade, int chanid, int radius, int expire) { +int playsoundname(const char *s, const vec *loc, int vol, int loops, int fade, int chanid, int radius, int expire) { if(!vol) vol = 100; int id = gamesounds.findsound(s, vol); if(id < 0) id = gamesounds.addsound(s, vol); - return playsound(id, loc, NULL, flags, loops, fade, chanid, radius, expire); + return playsound(id, loc, NULL, loops, fade, chanid, radius, expire); } ICOMMAND(sound, "i", (int *n), playsound(*n)); diff --git a/src/engine/texture.cpp b/src/engine/texture.cpp index 0f7a5df..744996e 100644 --- a/src/engine/texture.cpp +++ b/src/engine/texture.cpp @@ -223,7 +223,7 @@ static void reorients3tc(GLenum format, int blocksize, int w, int h, uchar *src, } } -static void reorientrgtc(GLenum format, int blocksize, int w, int h, uchar *src, uchar *dst, bool flipx, bool flipy, bool swapxy) { +static void reorientrgtc(int blocksize, int w, int h, uchar *src, uchar *dst, bool flipx, bool flipy, bool swapxy) { int bx1 = 0, by1 = 0, bx2 = min(w, 4), by2 = min(h, 4), bw = (w+3)/4, bh = (h+3)/4, stridex = blocksize, stridey = blocksize; if(swapxy) stridex *= bw; else stridey *= bh; if(flipx) { dst += (bw-1)*stridex; stridex = -stridex; bx1 += 4-bx2; bx2 = 4; } @@ -333,19 +333,6 @@ void forcergbaimage(ImageData &s) { s.replace(d); } -void swizzleimage(ImageData &s) { - if(s.bpp==2) { - ImageData d(s.w, s.h, 4); - readwritetex(d, s, { dst[0] = dst[1] = dst[2] = src[0]; dst[3] = src[1]; }); - s.replace(d); - } - else if(s.bpp==1) { - ImageData d(s.w, s.h, 3); - readwritetex(d, s, { dst[0] = dst[1] = dst[2] = src[0]; }); - s.replace(d); - } -} - void texreorient(ImageData &s, bool flipx, bool flipy, bool swapxy, int type = TEX_DIFFUSE) { ImageData d(swapxy ? s.h : s.w, swapxy ? s.w : s.h, s.bpp, s.levels, s.align, s.compressed); switch(s.compressed) { @@ -373,7 +360,7 @@ void texreorient(ImageData &s, bool flipx, bool flipy, bool swapxy, int type = T case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: { uchar *dst = d.data, *src = s.data; loopi(s.levels) { - reorientrgtc(s.compressed, s.bpp, max(s.w>>i, 1), max(s.h>>i, 1), src, dst, flipx, flipy, swapxy); + reorientrgtc(s.bpp, max(s.w>>i, 1), max(s.h>>i, 1), src, dst, flipx, flipy, swapxy); src += s.calclevelsize(i); dst += d.calclevelsize(i); } @@ -423,8 +410,6 @@ void texoffset(ImageData &s, int xoffset, int yoffset) { } void texmad(ImageData &s, const vec &mul, const vec &add) { - if(s.bpp < 3 && (mul.x != mul.y || mul.y != mul.z || add.x != add.y || add.y != add.z)) - swizzleimage(s); int maxk = min(int(s.bpp), 3); writetex(s, loopk(maxk) dst[k] = uchar(clamp(dst[k]*mul[k] + 255*add[k], 0.0f, 255.0f)); @@ -646,7 +631,7 @@ void resizetexture(int w, int h, bool mipmap, bool canreduce, GLenum target, int } } -void uploadtexture(int tnum, GLenum target, GLenum internal, int tw, int th, GLenum format, GLenum type, void *pixels, int pw, int ph, int pitch, bool mipmap) { +void uploadtexture(GLenum target, GLenum internal, int tw, int th, GLenum format, GLenum type, void *pixels, int pw, int ph, int pitch, bool mipmap) { int bpp = formatsize(format), row = 0, rowalign = 0; if(!pitch) pitch = pw*bpp; uchar *buf = NULL; @@ -656,7 +641,7 @@ void uploadtexture(int tnum, GLenum target, GLenum internal, int tw, int th, GLe } else if(tw*bpp != pitch) { row = pitch/bpp; - rowalign = texalign(pixels, pitch, 1); + rowalign = texalign(pitch, 1); while(rowalign > 0 && ((row*bpp + rowalign - 1)/rowalign)*rowalign != pitch) rowalign >>= 1; if(!rowalign) { row = 0; @@ -667,7 +652,7 @@ void uploadtexture(int tnum, GLenum target, GLenum internal, int tw, int th, GLe for(int level = 0, align = 0, mw = tw, mh = th;; level++) { uchar *src = buf ? buf : (uchar *)pixels; if(buf) pitch = mw*bpp; - int srcalign = row > 0 ? rowalign : texalign(src, pitch, 1); + int srcalign = row > 0 ? rowalign : texalign(pitch, 1); if(align != srcalign) glPixelStorei(GL_UNPACK_ALIGNMENT, align = srcalign); if(row > 0) glPixelStorei(GL_UNPACK_ROW_LENGTH, row); glTexImage2D(target, level, internal, mw, mh, 0, format, type, src); @@ -715,17 +700,7 @@ GLenum textarget(GLenum subtarget) { return subtarget; } -const GLint *swizzlemask(GLenum format) { - static const GLint luminance[4] = { GL_RED, GL_RED, GL_RED, GL_ONE }; - static const GLint luminancealpha[4] = { GL_RED, GL_RED, GL_RED, GL_GREEN }; - switch(format) { - case GL_RED: return luminance; - case GL_RG: return luminancealpha; - } - return NULL; -} - -void setuptexparameters(int tnum, void *pixels, int clamp, int filter, GLenum format, GLenum target, bool swizzle) { +void setuptexparameters(int tnum, int clamp, int filter, GLenum format, GLenum target) { glBindTexture(target, tnum); glTexParameteri(target, GL_TEXTURE_WRAP_S, clamp&1 ? GL_CLAMP_TO_EDGE : (clamp&0x100 ? GL_MIRRORED_REPEAT : GL_REPEAT)); glTexParameteri(target, GL_TEXTURE_WRAP_T, clamp&2 ? GL_CLAMP_TO_EDGE : (clamp&0x200 ? GL_MIRRORED_REPEAT : GL_REPEAT)); @@ -737,10 +712,6 @@ void setuptexparameters(int tnum, void *pixels, int clamp, int filter, GLenum fo (bilinear ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR) : (bilinear ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_NEAREST)) : (filter && bilinear ? GL_LINEAR : GL_NEAREST)); - if(swizzle && hasTRG && hasTSW) { - const GLint *mask = swizzlemask(format); - if(mask) glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, mask); - } } static GLenum textype(GLenum &component, GLenum &format) { @@ -828,9 +799,9 @@ static GLenum textype(GLenum &component, GLenum &format) { return type; } -void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component, GLenum subtarget, int pw, int ph, int pitch, bool resize, GLenum format, bool swizzle) { +void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component, GLenum subtarget, int pw, int ph, int pitch, bool resize, GLenum format) { GLenum target = textarget(subtarget), type = textype(component, format); - if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, pixels, clamp, filter, format, target, swizzle); + if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, clamp, filter, format, target); if(!pw) pw = w; if(!ph) ph = h; int tw = w, th = h; @@ -839,12 +810,12 @@ void createtexture(int tnum, int w, int h, void *pixels, int clamp, int filter, resizetexture(w, h, mipmap, false, target, 0, tw, th); if(mipmap) component = compressedformat(component, tw, th); } - uploadtexture(tnum, subtarget, component, tw, th, format, type, pixels, pw, ph, pitch, mipmap); + uploadtexture(subtarget, component, tw, th, format, type, pixels, pw, ph, pitch, mipmap); } -void createcompressedtexture(int tnum, int w, int h, uchar *data, int align, int blocksize, int levels, int clamp, int filter, GLenum format, GLenum subtarget, bool swizzle = false) { +void createcompressedtexture(int tnum, int w, int h, uchar *data, int align, int blocksize, int levels, int clamp, int filter, GLenum format, GLenum subtarget) { GLenum target = textarget(subtarget); - if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, data, clamp, filter, format, target); + if(filter >= 0 && clamp >= 0) setuptexparameters(tnum, clamp, filter, format, target); uploadcompressedtexture(target, subtarget, format, w, h, data, align, blocksize, levels, filter > 1); } @@ -852,10 +823,10 @@ hashnameset<Texture> textures; Texture *notexture = NULL; // used as default, ensured to be loaded -static GLenum texformat(int bpp, bool swizzle = false) { +static GLenum texformat(int bpp) { switch(bpp) { - case 1: return hasTRG && (hasTSW || !glcompat || !swizzle) ? GL_RED : GL_LUMINANCE; - case 2: return hasTRG && (hasTSW || !glcompat || !swizzle) ? GL_RG : GL_LUMINANCE_ALPHA; + case 1: return hasTRG && (hasTSW || !glcompat) ? GL_RED : GL_LUMINANCE; + case 2: return hasTRG && (hasTSW || !glcompat) ? GL_RG : GL_LUMINANCE_ALPHA; case 3: return GL_RGB; case 4: return GL_RGBA; default: return 0; @@ -874,7 +845,7 @@ static bool alphaformat(GLenum format) { } } -int texalign(const void *data, int w, int bpp) { +int texalign(int w, int bpp) { int stride = w*bpp; if(stride&1) return 1; if(stride&2) return 2; @@ -897,7 +868,6 @@ static Texture *newtexture(Texture *t, const char *rname, ImageData &s, int clam t->w = t->h = t->xs = t->ys = t->bpp = 0; return t; } - bool swizzle = !(clamp&0x10000); GLenum format; if(s.compressed) { format = uncompressedformat(s.compressed); @@ -905,13 +875,8 @@ static Texture *newtexture(Texture *t, const char *rname, ImageData &s, int clam t->type |= Texture::COMPRESSED; } else { - format = texformat(s.bpp, swizzle); + format = texformat(s.bpp); t->bpp = s.bpp; - if(swizzle && hasTRG && !hasTSW && swizzlemask(format)) { - swizzleimage(s); - format = texformat(s.bpp, swizzle); - t->bpp = s.bpp; - } } if(alphaformat(format)) t->type |= Texture::ALPHA; t->w = t->xs = s.w; @@ -934,12 +899,12 @@ static Texture *newtexture(Texture *t, const char *rname, ImageData &s, int clam if(t->w > 1) t->w /= 2; if(t->h > 1) t->h /= 2; } - createcompressedtexture(t->id, t->w, t->h, data, s.align, s.bpp, levels, clamp, filter, s.compressed, GL_TEXTURE_2D, swizzle); + createcompressedtexture(t->id, t->w, t->h, data, s.align, s.bpp, levels, clamp, filter, s.compressed, GL_TEXTURE_2D); } else { resizetexture(t->w, t->h, mipit, canreduce, GL_TEXTURE_2D, compress, t->w, t->h); GLenum component = compressedformat(format, t->w, t->h, compress); - createtexture(t->id, t->w, t->h, s.data, clamp, filter, component, GL_TEXTURE_2D, t->xs, t->ys, s.pitch, false, format, swizzle); + createtexture(t->id, t->w, t->h, s.data, clamp, filter, component, GL_TEXTURE_2D, t->xs, t->ys, s.pitch, false, format); } return t; } @@ -1275,9 +1240,6 @@ static bool texturedata(ImageData &d, const char *tname, Slot::Tex *tex = NULL, if(matchstring(cmd, len, "mirror")) { if(wrap) *wrap |= 0x300; } - else if(matchstring(cmd, len, "noswizzle")) { - if(wrap) *wrap |= 0x10000; - } } return true; } @@ -1860,7 +1822,7 @@ static void mergealpha(ImageData &c, ImageData &s) { else { readwritergbatex(c, s, dst[3] = src[3]; ); } } -static void addname(vector<char> &key, Slot &slot, Slot::Tex &t, bool combined = false, const char *prefix = NULL) { +static void addname(vector<char> &key, Slot::Tex &t, bool combined = false, const char *prefix = NULL) { if(combined) key.add('&'); if(prefix) { while(*prefix) key.add(*prefix++); } defformatstring(tname, "packages/%s", t.name); @@ -1869,7 +1831,7 @@ static void addname(vector<char> &key, Slot &slot, Slot::Tex &t, bool combined = static void texcombine(Slot &s, int index, Slot::Tex &t, bool forceload = false) { vector<char> key; - addname(key, s, t); + addname(key, t); int texmask = 0; if(!forceload) switch(t.type) { case TEX_DIFFUSE: @@ -1878,7 +1840,7 @@ static void texcombine(Slot &s, int index, Slot::Tex &t, bool forceload = false) if(i<0) break; texmask |= 1<<s.sts[i].type; s.sts[i].combined = index; - addname(key, s, s.sts[i], true); + addname(key, s.sts[i], true); break; } } @@ -1955,17 +1917,17 @@ Texture *loadthumbnail(Slot &slot) { linkslotshader(slot, false); linkvslotshader(vslot, false); vector<char> name; - if(vslot.colorscale == vec(1, 1, 1)) addname(name, slot, slot.sts[0], false, "<thumbnail>"); + if(vslot.colorscale == vec(1, 1, 1)) addname(name, slot.sts[0], false, "<thumbnail>"); else { defformatstring(prefix, "<thumbnail:%.2f/%.2f/%.2f>", vslot.colorscale.x, vslot.colorscale.y, vslot.colorscale.z); - addname(name, slot, slot.sts[0], false, prefix); + addname(name, slot.sts[0], false, prefix); } VSlot *layer = vslot.layer ? &lookupvslot(vslot.layer, false) : NULL; if(layer) { - if(layer->colorscale == vec(1, 1, 1)) addname(name, *layer->slot, layer->slot->sts[0], true, "<layer>"); + if(layer->colorscale == vec(1, 1, 1)) addname(name, layer->slot->sts[0], true, "<layer>"); else { defformatstring(prefix, "<layer:%.2f/%.2f/%.2f>", vslot.colorscale.x, vslot.colorscale.y, vslot.colorscale.z); - addname(name, *layer->slot, layer->slot->sts[0], true, prefix); + addname(name, layer->slot->sts[0], true, prefix); } } name.add('\0'); @@ -2248,7 +2210,7 @@ void screenshot(char *filename) { concatstring(buf, imageexts[format]); } ImageData image(screenw, screenh, 3); - glPixelStorei(GL_PACK_ALIGNMENT, texalign(image.data, screenw, 3)); + glPixelStorei(GL_PACK_ALIGNMENT, texalign(screenw, 3)); glReadPixels(0, 0, screenw, screenh, GL_RGB, GL_UNSIGNED_BYTE, image.data); saveimage(path(buf), format, image, true); } diff --git a/src/engine/world.cpp b/src/engine/world.cpp index cbe3fad..69a78d0 100644 --- a/src/engine/world.cpp +++ b/src/engine/world.cpp @@ -280,19 +280,17 @@ vec getselpos() { void entflip() { if(noentedit()) return; - int d = dimension(sel.orient); - float mid = sel.s[d]*sel.grid/2+sel.o[d]; - groupeditpure(e.o[d] -= (e.o[d]-mid)*2); + int d = dimension(sel.orient); (void) d; + groupeditpure(e.o[d] -= (e.o[d]-(sel.s[d]*sel.grid/2+sel.o[d]))*2); } void entrotate(int *cw) { if(noentedit()) return; int d = dimension(sel.orient); int dd = (*cw<0) == dimcoord(sel.orient) ? R[d] : C[d]; - float mid = sel.s[dd]*sel.grid/2+sel.o[dd]; vec s(sel.o.v); groupeditpure( - e.o[dd] -= (e.o[dd]-mid)*2; + e.o[dd] -= (e.o[dd]-(sel.s[dd]*sel.grid/2+sel.o[dd]))*2; e.o.sub(s); swap(e.o[R[d]], e.o[C[d]]); e.o.add(s); @@ -335,7 +333,7 @@ int entmoving = 0; void entdrag(const vec &ray) { if(noentedit() || !haveselent()) return; - float r = 0, c = 0; + float r = 0, c = 0; (void) r; (void) c; static vec v, handle; vec eo, es; int d = dimension(entorient), @@ -459,7 +457,7 @@ static void renderentbox(const vec &eo, vec es) { gle::attrib(eo.x, es.y, eo.z); gle::attrib(eo.x, es.y, es.z); } -void renderentselection(const vec &o, bool entmoving) { +void renderentselection(bool entmoving) { if(noentedit()) return; vec eo, es; if(entgroup.length()) { @@ -723,7 +721,6 @@ void entpaste() { keepents = max(keepents, idx+1); } keepents = 0; - int j = 0; } COMMAND(newent, "siiiii"); @@ -733,6 +730,7 @@ COMMAND(entcopy, ""); COMMAND(entpaste, ""); void entset(char *what, int *a1, int *a2, int *a3, int *a4, int *a5) { + (void) a1; (void) a2; (void) a3; (void) a4; (void) a5; if(noentedit()) return; int type = findtype(what); if(type != ET_EMPTY) @@ -775,6 +773,7 @@ void enttype(char *type, int *numargs) { } void entattr(int *attr, int *val, int *numargs) { + (void) val; if(*numargs >= 2) { if(*attr >= 0 && *attr <= 4) groupedit( @@ -880,7 +879,6 @@ void splitocta(cube *c, int size) { void resetmap() { clearoverrides(); - clearmapsounds(); resetlightmaps(); clearslots(); clearparticles(); diff --git a/src/engine/worldio.cpp b/src/engine/worldio.cpp index e64e0da..7244220 100644 --- a/src/engine/worldio.cpp +++ b/src/engine/worldio.cpp @@ -718,7 +718,6 @@ bool load_world(const char *mname, const char *cname) { // still supports all m preloadusedmapmodels(true); game::preload(); flushpreloadedmodels(); - preloadmapsounds(); entitiesinoctanodes(); initlights(); allchanged(true); |
