diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 50411c8d..6e39274c 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -176,7 +176,7 @@ bool collide(physent *d, bool spawn, float drop, float rise) const float eyeheight = d->eyeheight; const float playerheight = eyeheight + d->aboveeye; - for(int x = x1; x<=x2; x++) for(int y = y1; y<=y2; y++) // collide with map + for(int y = y1; y<=y2; y++) for(int x = x1; x<=x2; x++) // collide with map { if(OUTBORD(x,y)) return false; sqr *s = S(x,y); diff --git a/source/src/rendercubes.cpp b/source/src/rendercubes.cpp index 4a0a916e..7845e473 100644 --- a/source/src/rendercubes.cpp +++ b/source/src/rendercubes.cpp @@ -144,7 +144,7 @@ void finishstrips() { stripend(verts); } sqr sbright, sdark; VARP(lighterror, 1, 4, 100); -void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil) // floor/ceil quads +void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l4, sqr *l3, sqr *l2, bool isceil) // floor/ceil quads { if(showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; } @@ -156,7 +156,7 @@ void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr float xo = xf*x; float yo = yf*y; - bool first = !floorstrip || y!=oy+size || striptex!=wtex || h!=oh || x!=ox; + bool first = !floorstrip || x!=ox+size || striptex!=wtex || h!=oh || y!=oy; if(first) // start strip here { @@ -164,17 +164,17 @@ void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr firstindex = verts.length(); striptex = wtex; oh = h; - ox = x; + oy = y; floorstrip = true; if(isceil) { - vert(x+size, y, h, l2, xo+xs, yo); - vert(x, y, h, l1, xo, yo); + vert(x, y, h, l1, xo, yo); + vert(x, y+size, h, l2, xo, yo+ys); } else { - vert(x, y, h, l1, xo, yo); - vert(x+size, y, h, l2, xo+xs, yo); + vert(x, y+size, h, l2, xo, yo+ys); + vert(x, y, h, l1, xo, yo); } ol3r = l1->r; ol3g = l1->g; @@ -208,20 +208,20 @@ void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr if(isceil) { + vert(x+size, y, h, l4, xo+xs, yo); vert(x+size, y+size, h, l3, xo+xs, yo+ys); - vert(x, y+size, h, l4, xo, yo+ys); } else { - vert(x, y+size, h, l4, xo, yo+ys); - vert(x+size, y+size, h, l3, xo+xs, yo+ys); + vert(x+size, y+size, h, l3, xo+xs, yo+ys); + vert(x+size, y, h, l4, xo+xs, yo); } - oy = y; + ox = x; nquads++; } -void render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, float h3, float h4, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil) // floor/ceil quads on a slope +void render_flatdelta(int wtex, int x, int y, int size, float h1, float h4, float h3, float h2, sqr *l1, sqr *l4, sqr *l3, sqr *l2, bool isceil) // floor/ceil quads on a slope { if(showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; } @@ -233,24 +233,24 @@ void render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, floa float xo = xf*x; float yo = yf*y; - bool first = !deltastrip || y!=oy+size || striptex!=wtex || x!=ox; + bool first = !deltastrip || x!=ox+size || striptex!=wtex || y!=oy; if(first) { stripend(verts); firstindex = verts.length(); striptex = wtex; - ox = x; + oy = y; deltastrip = true; if(isceil) { - vert(x+size, y, h2, l2, xo+xs, yo); - vert(x, y, h1, l1, xo, yo); + vert(x, y, h1, l1, xo, yo); + vert(x, y+size, h2, l2, xo, yo+ys); } else { - vert(x, y, h1, l1, xo, yo); - vert(x+size, y, h2, l2, xo+xs, yo); + vert(x, y+size, h2, l2, xo, yo+ys); + vert(x, y, h1, l1, xo, yo); } ol3r = l1->r; ol3g = l1->g; @@ -262,16 +262,16 @@ void render_flatdelta(int wtex, int x, int y, int size, float h1, float h2, floa if(isceil) { + vert(x+size, y, h4, l4, xo+xs, yo); vert(x+size, y+size, h3, l3, xo+xs, yo+ys); - vert(x, y+size, h4, l4, xo, yo+ys); } else { - vert(x, y+size, h4, l4, xo, yo+ys); - vert(x+size, y+size, h3, l3, xo+xs, yo+ys); + vert(x+size, y+size, h3, l3, xo+xs, yo+ys); + vert(x+size, y, h4, l4, xo+xs, yo); } - oy = y; + ox = x; nquads++; } @@ -422,7 +422,7 @@ void rendershadow_tris(int x, int y, bool topleft, sqr *h1, sqr *h2) static void rendershadow_flat(int x, int y, int h) // floor quads { - bool first = !floorstrip || y!=oy+1 || h!=oh || x!=ox; + bool first = !floorstrip || x!=ox+1 || h!=oh || y!=oy; if(first) // start strip here { @@ -430,41 +430,41 @@ static void rendershadow_flat(int x, int y, int h) // floor quads firstindex = shadowverts.length(); striptex = DEFAULT_FLOOR; oh = h; - ox = x; + oy = y; floorstrip = true; - shadowvert(x, y, h); - shadowvert(x+1, y, h); + shadowvert(x, y+1, h); + shadowvert(x, y, h); } else // continue strip { shadowverts.setsizenodelete(shadowverts.length()-2); } - shadowvert(x, y+1, h); shadowvert(x+1, y+1, h); + shadowvert(x+1, y, h); - oy = y; + ox = x; } -static void rendershadow_flatdelta(int x, int y, float h1, float h2, float h3, float h4) // floor quads on a slope +static void rendershadow_flatdelta(int x, int y, float h1, float h4, float h3, float h2) // floor quads on a slope { - bool first = !deltastrip || y!=oy+1 || x!=ox; + bool first = !deltastrip || x!=ox+1 || y!=oy; if(first) { stripend(shadowverts); firstindex = shadowverts.length(); striptex = DEFAULT_FLOOR; - ox = x; + oy = y; deltastrip = true; - shadowvert(x, y, h1); - shadowvert(x+1, y, h2); + shadowvert(x, y+1, h2); + shadowvert(x, y, h1); } - shadowvert(x, y+1, h4); shadowvert(x+1, y+1, h3); + shadowvert(x+1, y, h4); - oy = y; + ox = x; } void rendershadow(int x, int y, int xs, int ys, const vec &texgenS, const vec &texgenT) @@ -479,7 +479,7 @@ void rendershadow(int x, int y, int xs, int ys, const vec &texgenS, const vec &t #define df(x) s->floor-(x->vdelta/4.0f) sqr *w = wmip[0]; - for(int xx = x; xxtype==SPACE || s->type==CHF) diff --git a/source/src/rndmap.cpp b/source/src/rndmap.cpp index ea082fdb..592f3edb 100644 --- a/source/src/rndmap.cpp +++ b/source/src/rndmap.cpp @@ -59,7 +59,7 @@ void perlinarea(block &b, int scale, int seed, int psize) srand(seed); seed = rnd(10000); if(!scale) scale = 10; - for(int x = b.x; x<=b.x+b.xs; x++) for(int y = b.y; y<=b.y+b.ys; y++) + for(int y = b.y; y<=b.y+b.ys; y++) for(int x = b.x; x<=b.x+b.xs; x++) { sqr *s = S(x,y); if(!SOLID(s) && x!=b.x+b.xs && y!=b.y+b.ys) s->type = FHF; diff --git a/source/src/world.cpp b/source/src/world.cpp index 423be36c..0cc8c791 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -29,7 +29,7 @@ void remip(const block &b, int level) if(s.y&1) { s.y--; s.ys++; } s.xs = (s.xs+1)&~1; s.ys = (s.ys+1)&~1; - for(int x = s.x; xtype!=FHF && s->type!=CHF; } void voptimize() // reset vdeltas on non-hf cubes { - loop(x, ssize) loop(y, ssize) + loop(y, ssize) loop(x, ssize) { sqr *s = S(x, y); if(x && y) { if(nhf(s) && nhf(S(x-1, y)) && nhf(S(x-1, y-1)) && nhf(S(x, y-1))) s->vdelta = 0; } @@ -90,7 +90,7 @@ void toptimize() // FIXME: only does 2x2, make atleast for 4x4 also { bool wf[4], uf[4]; sqr *s[4]; - for(int x = 2; xwtex, ut = s[0]->utex; @@ -382,7 +382,7 @@ bool load_world(char *mname) // still supports all map formats that have { if(type<0 || type>=MAXTYPE) { - conoutf("while reading map at %d: type %d out of range", k, type); + conoutf("while reading map at %d: type %d out of range", k, type); gzclose(f); f = NULL; k--; diff --git a/source/src/worldlight.cpp b/source/src/worldlight.cpp index 702eebf4..13502677 100644 --- a/source/src/worldlight.cpp +++ b/source/src/worldlight.cpp @@ -316,14 +316,14 @@ block *blockcopy(const block &s) block *b = (block *)new uchar[sizeof(block)+s.xs*s.ys*sizeof(sqr)]; *b = s; sqr *q = (sqr *)(b+1); - for(int x = s.x; xoccluded = isoccluded(camera1->o.x, camera1->o.y, (float)(ox<occluded==1) continue; \ + #define LOOPH {for(int yy = y; yyoccluded) continue; \ if(s->defer && !s->occluded && mip && xx>=lx && xx=ly && yydefer && !next->occluded) yy++; // collect 2xN rect of lower mip - render_seg_new(vx, vy, vh, mip-1, xx*2, start*2, xx*2+2, yy*2+2); + while(xxdefer && !next->occluded) xx++; // collect 2xN rect of lower mip + render_seg_new(vx, vy, vh, mip-1, start*2, yy*2, xx*2+2, yy*2+2); continue; } stats[mip]++;