diff --git a/basegraph.cpp b/basegraph.cpp index 17acf622..067acc84 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -65,24 +65,16 @@ TTF_Font *font[256]; #if CAP_SDL SDL_Surface *s, *s_screen; -int qpixel_pixel_outside; +color_t qpixel_pixel_outside; -int& qpixel(SDL_Surface *surf, int x, int y) { +color_t& qpixel(SDL_Surface *surf, int x, int y) { if(x<0 || y<0 || x >= surf->w || y >= surf->h) return qpixel_pixel_outside; char *p = (char*) surf->pixels; p += y * surf->pitch; - int *pi = (int*) (p); + color_t *pi = (color_t*) (p); return pi[x]; } -int qpixel3(SDL_Surface *surf, int x, int y) { - if(x<0 || y<0 || x >= surf->w || y >= surf->h) return qpixel_pixel_outside; - char *p = (char*) surf->pixels; - p += y * surf->pitch; - p += x; - int *pi = (int*) (p); - return pi[0]; - } #endif #if CAP_SDLTTF @@ -266,7 +258,7 @@ bool model_needs_depth() { return pmodel == mdBall || pmodel == mdHyperboloid || pmodel == mdHemisphere; } -void setGLProjection(int col) { +void setGLProjection(color_t col) { DEBB(DF_GRAPH, (debugfile,"setGLProjection\n")); GLERR("pre_setGLProjection"); @@ -499,7 +491,7 @@ namespace glhr { void texture_vertices(GLfloat *f, int qty, int stride = 2) { GLfloat otver[24]; vector tver(4); -bool gl_print(int x, int y, int shift, int size, const char *s, int color, int align) { +bool gl_print(int x, int y, int shift, int size, const char *s, color_t color, int align) { int gsiz = size; if(size > vid.fsize || size > 72) gsiz = 72; @@ -594,7 +586,7 @@ void gdpush(int t) { graphdata.push_back(t); } -bool displaychr(int x, int y, int shift, int size, char chr, int col) { +bool displaychr(int x, int y, int shift, int size, char chr, color_t col) { gdpush(2); gdpush(x); gdpush(y); gdpush(8); gdpush(col); gdpush(size); gdpush(0); gdpush(1); gdpush(chr); @@ -621,7 +613,7 @@ void gdpush_utf8(const string& s) { graphdata[g] = q; } -bool displayfr(int x, int y, int b, int size, const string &s, int color, int align) { +bool displayfr(int x, int y, int b, int size, const string &s, color_t color, int align) { gdpush(2); gdpush(x); gdpush(y); gdpush(align); gdpush(color); gdpush(size); gdpush(b); gdpush_utf8(s); @@ -633,16 +625,16 @@ bool displayfr(int x, int y, int b, int size, const string &s, int color, int al my >= -size*3/4 && my <= +size*3/4; } -bool displaystr(int x, int y, int shift, int size, const string &s, int color, int align) { +bool displaystr(int x, int y, int shift, int size, const string &s, color_t color, int align) { return displayfr(x,y,0,size,s,color,align); } -bool displaystr(int x, int y, int shift, int size, char const *s, int color, int align) { +bool displaystr(int x, int y, int shift, int size, char const *s, color_t color, int align) { return displayfr(x,y,0,size,s,color,align); } #else -bool displaystr(int x, int y, int shift, int size, const char *str, int color, int align) { +bool displaystr(int x, int y, int shift, int size, const char *str, color_t color, int align) { if(strlen(str) == 0) return false; @@ -687,7 +679,7 @@ bool displaystr(int x, int y, int shift, int size, const char *str, int color, i SDL_Surface* txt2 = SDL_DisplayFormat(txt); SDL_LockSurface(txt2); SDL_LockSurface(s); - int c0 = qpixel(txt2, 0, 0); + color_t c0 = qpixel(txt2, 0, 0); for(int yy=0; yy>8); } -bool displaychr(int x, int y, int shift, int size, char chr, int col) { +bool displaychr(int x, int y, int shift, int size, char chr, color_t col) { char buf[2]; buf[0] = chr; buf[1] = 0; @@ -738,7 +730,7 @@ bool displaychr(int x, int y, int shift, int size, char chr, int col) { } #endif -bool displaynum(int x, int y, int shift, int size, int col, int val, string title) { +bool displaynum(int x, int y, int shift, int size, color_t col, int val, string title) { char buf[64]; sprintf(buf, "%d", val); bool b1 = displayfr(x-8, y, 1, size, buf, col, 16); @@ -803,7 +795,7 @@ void addMessage(string s, char spamtype) { addMessageToLog(m, msgs); } -int colormix(int a, int b, int c) { +color_t colormix(color_t a, color_t b, color_t c) { for(int p=0; p<3; p++) part(a, p) = part(a,p) + (part(b,p) - part(a,p)) * part(c,p) / 255; return a; @@ -825,7 +817,7 @@ ld realradius() { return vradius; } -void drawmessage(const string& s, int& y, int col) { +void drawmessage(const string& s, int& y, color_t col) { int rrad = (int) realradius(); int space; if(y > vid.ycenter + rrad * vid.stretch) @@ -879,7 +871,7 @@ void drawmessages() { for(int j=isize(msgs)-1; j>=0; j--) { int age = msgs[j].flashout * (t - msgs[j].stamp); poly_outline = gradient(bordcolor, backcolor, 0, age, 256*vid.flashtime) << 8; - int col = gradient(forecolor, backcolor, 0, age, 256*vid.flashtime); + color_t col = gradient(forecolor, backcolor, 0, age, 256*vid.flashtime); drawmessage(fullmsg(msgs[j]), y, col); } } @@ -894,19 +886,18 @@ void drawmessages() { } } -int gradient(int c0, int c1, ld v0, ld v, ld v1) { +color_t gradient(color_t c0, color_t c1, ld v0, ld v, ld v1) { int vv = int(256 * ((v-v0) / (v1-v0))); - int c = 0; + color_t c = 0; for(int a=0; a<3; a++) { - int p0 = (c0 >> (8*a)) & 255; - int p1 = (c1 >> (8*a)) & 255; - int p = (p0*(256-vv) + p1*vv + 127) >> 8; - c |= p << (8*a); + int p0 = part(c0, a); + int p1 = part(c1, a); + part(c, a) = (p0*(256-vv) + p1*vv + 127) >> 8; } return c; } -void drawCircle(int x, int y, int size, int color) { +void drawCircle(int x, int y, int size, color_t color) { if(size < 0) size = -size; #if CAP_GL if(vid.usingGL) { @@ -961,7 +952,7 @@ void displaymm(char c, int x, int y, int rad, int size, const string& title, int } } -bool displayButtonS(int x, int y, const string& name, int col, int align, int size) { +bool displayButtonS(int x, int y, const string& name, color_t col, int align, int size) { if(displaystr(x, y, 0, size, name, col, align)) { displaystr(x, y, 0, size, name, 0xFFFF00, align); return true; @@ -969,7 +960,7 @@ bool displayButtonS(int x, int y, const string& name, int col, int align, int si else return false; } -void displayColorButton(int x, int y, const string& name, int key, int align, int rad, int color, int color2) { +void displayColorButton(int x, int y, const string& name, int key, int align, int rad, color_t color, color_t color2) { if(displayfr(x, y, rad, vid.fsize, name, color, align)) { if(color2) displayfr(x, y, rad, vid.fsize, name, color2, align); getcstat = key; diff --git a/blizzard.cpp b/blizzard.cpp index fd19f628..7d90b70b 100644 --- a/blizzard.cpp +++ b/blizzard.cpp @@ -135,7 +135,7 @@ void drawBlizzards() { } */ forCellIdEx(c2, i, bc.c) if(bc.c == mouseover || c2 == mouseover) { - int col = 0x00C00080; + color_t col = 0x00C00080; if(c2 == mouseover) col ^= 0xC0C00000; if(isPlayerOn(c2)) diff --git a/classes.h b/classes.h index ae7d6797..f6938814 100644 --- a/classes.h +++ b/classes.h @@ -1,10 +1,12 @@ namespace hr { +typedef unsigned color_t; + static const int motypes = 162; struct monstertype { char glyph; - int color; + color_t color; const char *name; const char *help; }; @@ -77,7 +79,7 @@ static const int ittypes = 130; struct itemtype { char glyph; - int color; + color_t color; const char *name; const char *help; }; @@ -126,7 +128,7 @@ static const int walltypes = 109; struct walltype { char glyph; - int color; + color_t color; const char *name; const char *help; }; @@ -169,7 +171,7 @@ enum eWall { waNone, waIcewall, waBarrier, waFloorA, waFloorB, waCavewall, waCav static const int landtypes = 85; struct landtype { - int color; + color_t color; const char *name; const char *help; }; diff --git a/conformal.cpp b/conformal.cpp index 1967d026..26df10a3 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -130,7 +130,7 @@ namespace spiral { bool displayhelp = true; - int& bandpixel(int x, int y) { + color_t& bandpixel(int x, int y) { int i = 0; while(i < isize(band) && x >= band[i]->w) x -= band[i]->w, i++; diff --git a/dialogs.cpp b/dialogs.cpp index 605ab76a..9975f739 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -48,11 +48,11 @@ namespace dialog { void stopzoom() { zoomoff = true; } - bool displayfr(int x, int y, int b, int size, const string &s, int color, int align) { + bool displayfr(int x, int y, int b, int size, const string &s, color_t color, int align) { return hr::displayfr(x * zoomf + shiftx, y * zoomf + shifty, b, size * zoomf, s, color, align); } - bool displayfr_highlight(int x, int y, int b, int size, const string &s, int color, int align, int hicolor) { + bool displayfr_highlight(int x, int y, int b, int size, const string &s, color_t color, int align, int hicolor) { bool clicked = hr::displayfr(x * zoomf + shiftx, y * zoomf + shifty, b, size * zoomf, s, color, align); if(clicked) hr::displayfr(x * zoomf + shiftx, y * zoomf + shifty, b, size * zoomf, s, hicolor, align); return clicked; @@ -174,7 +174,7 @@ namespace dialog { items.push_back(it); } - void addInfo(string body, int color) { + void addInfo(string body, color_t color) { item it; it.type = diInfo; it.body = body; @@ -218,7 +218,7 @@ namespace dialog { return items.size()-1; } - void addTitle(string body, int color, int scale) { + void addTitle(string body, color_t color, int scale) { item it; it.type = diTitle; it.body = body; @@ -227,7 +227,7 @@ namespace dialog { items.push_back(it); } - void init(string title, int color, int scale, int brk) { + void init(string title, color_t color, int scale, int brk) { init(); addTitle(title, color, scale); addBreak(brk); @@ -456,17 +456,17 @@ namespace dialog { } } - unsigned int colorhistory[10] = { + color_t colorhistory[10] = { 0x202020FF, 0x800000FF, 0x008000FF, 0x000080FF, 0x404040FF, 0xC0C0C0FF, 0x804000FF, 0xC0C000FF, 0x408040FF, 0xFFD500FF }, lch; - unsigned int *palette; + color_t *palette; int colorp = 0; - unsigned int *colorPointer; + color_t *colorPointer; bool handleKeyColor(int sym, int uni) { unsigned& color = *colorPointer; @@ -524,7 +524,7 @@ namespace dialog { dcenter = vid.xres - dwidth / 2; } - int color = *colorPointer; + color_t color = *colorPointer; int ash = 8; @@ -554,7 +554,7 @@ namespace dialog { for(int i=0; i<4; i++) { int y = vid.yres / 2 + (2-i) * vid.fsize * 2; - int col = ((i==colorp) && !mousing) ? 0xFFD500 : forecolor; + color_t col = ((i==colorp) && !mousing) ? 0xFFD500 : forecolor; displayColorButton(dcenter - dwidth/4, y, "(", 0, 16, 0, col); string rgt = ") "; rgt += "ABGR" [i]; diff --git a/floorshapes.cpp b/floorshapes.cpp index 9bd77447..6f00d6ee 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -608,7 +608,7 @@ void set_floor(const transmatrix& spin, hpcshape& sh) { qfi.usershape = -1; } -void draw_shapevec(cell *c, const transmatrix& V, const vector &shv, int col, PPR prio = PPR::DEFAULT) { +void draw_shapevec(cell *c, const transmatrix& V, const vector &shv, color_t col, PPR prio = PPR::DEFAULT) { if(!c) queuepolyat(V, shv[0], col, prio); else if(GOLDBERG) { int id = gp::get_plainshape_id(c); @@ -640,11 +640,11 @@ void draw_shapevec(cell *c, const transmatrix& V, const vector &shv, i queuepolyat(V, shv[ctof(c)], col, prio); } -void draw_floorshape(cell *c, const transmatrix& V, const floorshape &fsh, int col, PPR prio = PPR::DEFAULT) { +void draw_floorshape(cell *c, const transmatrix& V, const floorshape &fsh, color_t col, PPR prio = PPR::DEFAULT) { draw_shapevec(c, V, fsh.b, col, prio); } -void draw_qfi(cell *c, const transmatrix& V, int col, PPR prio = PPR::DEFAULT, vector floorshape::* tab = &floorshape::b) { +void draw_qfi(cell *c, const transmatrix& V, color_t col, PPR prio = PPR::DEFAULT, vector floorshape::* tab = &floorshape::b) { if(qfi.shape) queuepolyat(V * qfi.spin, *qfi.shape, col, prio); else if(qfi.usershape >= 0) { @@ -653,10 +653,9 @@ void draw_qfi(cell *c, const transmatrix& V, int col, PPR prio = PPR::DEFAULT, v else if(!qfi.fshape) ; #if CAP_TEXTURE else if(qfi.tinf) { - queuetable(V * qfi.spin, qfi.tinf->vertices, isize(qfi.tinf->vertices), texture::config.mesh_color, texture::config.recolor(col), prio == PPR::DEFAULT ? PPR::FLOOR : prio); - lastptd().u.poly.tinf = qfi.tinf; - if(true) - lastptd().u.poly.flags = POLY_INVERSE; + auto& poly = queuetable(V * qfi.spin, qfi.tinf->vertices, isize(qfi.tinf->vertices), texture::config.mesh_color, texture::config.recolor(col), prio == PPR::DEFAULT ? PPR::FLOOR : prio); + poly.tinf = qfi.tinf; + poly.flags = POLY_INVERSE; } #endif else draw_shapevec(c, V, (qfi.fshape->*tab), col, prio); diff --git a/graph.cpp b/graph.cpp index 576ee90b..3f43aadd 100644 --- a/graph.cpp +++ b/graph.cpp @@ -112,7 +112,7 @@ int weakfirecolor(int phase) { return gradient(0xFF8000, 0xFF0000, -1, sin((phase + ticks)/500.0), 1); } -int fc(int ph, int col, int z) { +color_t fc(int ph, color_t col, int z) { if(items[itOrbFire]) col = darkena(firecolor(ph), 0, 0xFF); if(items[itOrbAether]) col = (col &~0XFF) | (col&0xFF) / 2; for(int i=0; iland == laHalloween && !wmblack && !wmascii) @@ -148,7 +148,7 @@ void drawShield(const transmatrix& V, eItem it) { void drawSpeed(const transmatrix& V) { #if CAP_CURVE ld ds = ticks / 10.; - int col = darkena(iinf[itOrbSpeed].color, 0, 0xFF); + color_t col = darkena(iinf[itOrbSpeed].color, 0, 0xFF); for(int b=0; b p(poly_outline, OUTLINE_TRANS); + dynamicval p(poly_outline, OUTLINE_TRANS); queuepolyat(V, bp, SHADOW_MON, prio); } #endif } -void otherbodyparts(const transmatrix& V, int col, eMonster who, double footphase) { +void otherbodyparts(const transmatrix& V, color_t col, eMonster who, double footphase) { #if CAP_POLY @@ -732,7 +732,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, if(it == itOrbUndeath) icol = minf[moFriendlyGhost].color; if(it == itOrbRecall) icol = 0x101010; if(it == itOrbSlaying) icol = 0xFF0000; - int col = darkena(icol, 0, int(0x80 + 0x70 * sin(ticks / 300.))); + color_t col = darkena(icol, 0, int(0x80 + 0x70 * sin(ticks / 300.))); if(it == itOrbFish) queuepolyat(V * spin(ticks / 1500.), shFishTail, col, PPR::ITEM_BELOW); @@ -759,7 +759,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, void drawTerraWarrior(const transmatrix& V, int t, int hp, double footphase) { #if CAP_POLY ShadowV(V, shPBody); - int col = linf[laTerracotta].color; + color_t col = linf[laTerracotta].color; int bcol = darkena(false ? 0xC0B23E : col, 0, 0xFF); otherbodyparts(V, bcol, moDesertman, footphase); queuepoly(VBODY, shPBody, bcol); @@ -772,7 +772,7 @@ void drawTerraWarrior(const transmatrix& V, int t, int hp, double footphase) { #endif } -bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, double footphase) { +bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase) { char xch = minf[m].glyph; @@ -806,7 +806,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou queuepoly(VABODY, shWolfBody, fc(0, cs.skincolor, 0)); queuepoly(VAHEAD, shFamiliarHead, fc(500, cs.haircolor, 2)); if(!shmup::on || shmup::curtime >= shmup::getPlayer()->nextshot) { - int col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); + color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); queuepoly(VAHEAD, shFamiliarEye, col); queuepoly(VAHEAD * Mirror, shFamiliarEye, col); } @@ -822,12 +822,12 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou queuepoly(VAHEAD, shDogHead, fc(150, cs.haircolor, 2)); if(!shmup::on || shmup::curtime >= shmup::getPlayer()->nextshot) { - int col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); + color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); queuepoly(VAHEAD, shWolf1, col); queuepoly(VAHEAD, shWolf2, col); } - int colnose = items[itOrbDiscord] ? watercolor(0) : fc(314, 0xFF, 3); + color_t colnose = items[itOrbDiscord] ? watercolor(0) : fc(314, 0xFF, 3); queuepoly(VAHEAD, shWolf3, colnose); } else if(cs.charid >= 4) { @@ -840,7 +840,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou queuepoly(VABODY, shCatBody, fc(0, cs.skincolor, 0)); queuepoly(VAHEAD, shCatHead, fc(150, cs.haircolor, 2)); if(!shmup::on || shmup::curtime >= shmup::getPlayer()->nextshot) { - int col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); + color_t col = items[itOrbDiscord] ? watercolor(0) : fc(314, cs.swordcolor, 3); queuepoly(VAHEAD * xpush(.04), shWolf1, col); queuepoly(VAHEAD * xpush(.04), shWolf2, col); } @@ -1009,7 +1009,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou queuepoly(VBODY, shPBody, darkena(0xC0C0A0, 0, 0xC0)); queuepoly(VBODY, shPSword, darkena(0xFFFF00, 0, 0xFF)); queuepoly(VBODY, shKnightArmor, darkena(0xD0D0D0, 1, 0xFF)); - int col; + color_t col; if(!eubinary && where && where->master->alt) col = cloakcolor(roundTableRadius(where)); else @@ -1163,7 +1163,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou queuepoly(VAHEAD, shDogHead, darkena(col, 0, 0xFF)); { - dynamicval dp(poly_outline); + dynamicval dp(poly_outline); int eyecolor = 0x202020; bool redeyes = false; if(m == moHunterDog) eyecolor = 0xFF0000, redeyes = true; @@ -1172,10 +1172,8 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou int eyes = darkena(eyecolor, 0, 0xFF); if(redeyes) poly_outline = eyes; - queuepoly(VAHEAD, shWolf1, eyes); - if(redeyes) lastptd().u.poly.flags |= POLY_FORCEWIDE; - queuepoly(VAHEAD, shWolf2, eyes); - if(redeyes) lastptd().u.poly.flags |= POLY_FORCEWIDE; + queuepoly(VAHEAD, shWolf1, eyes).flags |= POLY_FORCEWIDE; + queuepoly(VAHEAD, shWolf2, eyes).flags |= POLY_FORCEWIDE; } queuepoly(VAHEAD, shWolf3, darkena(m == moRunDog ? 0x202020 : 0x000000, 0, 0xFF)); } @@ -1707,8 +1705,8 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou #endif } -bool drawMonsterTypeDH(eMonster m, cell *where, const transmatrix& V, int col, bool dh, ld footphase) { - dynamicval p(poly_outline, poly_outline); +bool drawMonsterTypeDH(eMonster m, cell *where, const transmatrix& V, color_t col, bool dh, ld footphase) { + dynamicval p(poly_outline, poly_outline); if(dh) { poly_outline = OUTLINE_DEAD; darken++; @@ -1838,7 +1836,7 @@ void drawWormSegments() { bool dont_face_pc = false; -bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) { +bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col) { bool darkhistory = conformal::includeHistory && conformal::inkillhistory.count(c); @@ -1925,7 +1923,7 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) { ld wav = hexsnake ? 0 : c->monst < moTentacle ? 1/1.5 : 1; - int col0 = col; + color_t col0 = col; if(c->monst == moWorm || c->monst == moWormwait) col0 = minf[moWormtail].color; else if(thead) @@ -1945,7 +1943,7 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) { else { int hdir = displayspin(c, c->mondir); - int col = darkena(0x606020, 0, 0xFF); + color_t col = darkena(0x606020, 0, 0xFF); for(int u=-1; u<=1; u++) queueline(Vparam*xspinpush0(hdir+M_PI/2, u*crossf/5), Vparam*xspinpush(hdir, crossf)*xspinpush0(hdir+M_PI/2, u*crossf/5), col, 2 + vid.linequality); } @@ -2222,13 +2220,13 @@ void clearaura() { auramemo = 128 * 128 / vid.aurastr; } -void addauraspecial(const hyperpoint& h, int col, int dir) { +void addauraspecial(const hyperpoint& h, color_t col, int dir) { if(!haveaura()) return; int r = int(2*AURA + dir + atan2(h[0], h[1]) * AURA / 2 / M_PI) % AURA; auraspecials.emplace_back(r, col); } -void addaura(const hyperpoint& h, int col, int fd) { +void addaura(const hyperpoint& h, color_t col, int fd) { if(!haveaura()) return; int r = int(2*AURA + atan2(h[0], h[1]) * AURA / 2 / M_PI) % AURA; aurac[r][3] += auramemo << fd; @@ -2304,7 +2302,7 @@ void drawaura() { if(rm<0 || rm >= AURA) continue; - int& p = qpixel(s, x, y); + color_t& p = qpixel(s, x, y); for(int c=0; c<3; c++) { double c1 = aurac[rm][2-c] / (aurac[rm][3]+.1); double c2 = aurac[rm+1][2-c] / (aurac[rm+1][3]+.1); @@ -2465,7 +2463,7 @@ void set_zebrafloor(cell *c) { void set_maywarp_floor(cell *c); -void set_reptile_floor(cell *c, const transmatrix& V, int col, bool nodetails = false) { +void set_reptile_floor(cell *c, const transmatrix& V, color_t col, bool nodetails = false) { auto si = euclid6 ? @@ -2511,7 +2509,7 @@ void set_reptile_floor(cell *c, const transmatrix& V, int col, bool nodetails = if(ecol == -1 || ecol == 0) dcol = darkena(col, 1, 0xFF); else dcol = darkena(ecol, 0, 0x80); - dynamicval p(poly_outline, + dynamicval p(poly_outline, doHighlight() && ecol != -1 && ecol != 0 ? OUTLINE_ENEMY : OUTLINE_DEFAULT); if(!chasmg) { @@ -2527,7 +2525,7 @@ void set_reptile_floor(cell *c, const transmatrix& V, int col, bool nodetails = } } -void draw_reptile(cell *c, const transmatrix &V, int col) { +void draw_reptile(cell *c, const transmatrix &V, color_t col) { auto qfib = qfi; set_reptile_floor(c, V, col, chasmg == 2); draw_qfi(c, V, col); @@ -2591,7 +2589,7 @@ void drawMovementArrows(cell *c, transmatrix V) { if(xc.at == c) { transmatrix fixrot = sphereflip * rgpushxto0(sphereflip * tC0(V)); // make it more transparent - int col = getcs().uicolor; + color_t col = getcs().uicolor; col -= (col & 0xFF) >> 1; poly_outline = OUTLINE_DEFAULT; queuepoly(fixrot * spin(-d * M_PI/4), shArrow, col); @@ -2628,7 +2626,7 @@ int reptilecolor(cell *c) { } } - int fcoltab[4] = {0xe3bb97, 0xc2d1b0, 0xebe5cb, 0xA0A0A0}; + color_t fcoltab[4] = {0xe3bb97, 0xc2d1b0, 0xebe5cb, 0xA0A0A0}; return fcoltab[i]; } @@ -2642,7 +2640,7 @@ ld wavefun(ld x) { const unsigned int nestcolors[8] = { 0x800000, 0x008000, 0x000080, 0x404040, 0x700070, 0x007070, 0x707000, 0x606060 }; -void setcolors(cell *c, int& wcol, int &fcol) { +void setcolors(cell *c, color_t& wcol, color_t& fcol) { wcol = fcol = winf[c->wall].color; @@ -2833,7 +2831,7 @@ void setcolors(cell *c, int& wcol, int &fcol) { case laWhirlwind: if(c->land == laWhirlwind) { - int wcol[4] = {0x404040, 0x404080, 0x2050A0, 0x5050C0}; + color_t wcol[4] = {0x404040, 0x404080, 0x2050A0, 0x5050C0}; fcol = wcol[whirlwind::fzebra3(c)]; } break; @@ -2928,12 +2926,12 @@ void setcolors(cell *c, int& wcol, int &fcol) { float h = HEAT(c); bool showcoc = c->land == laCocytus && chaosmode && !wmescher; - int colorN04 = showcoc ? 0x4080FF : 0x4040FF; - int colorN10 = 0x0000FF; - int color0 = c->land == laBlizzard ? 0x5050C0 : showcoc ? 0x80C0FF : 0x8080FF; - int color02 = 0xFFFFFF; - int color06 = 0xFF0000; - int color08 = 0xFFFF00; + color_t colorN04 = showcoc ? 0x4080FF : 0x4040FF; + color_t colorN10 = 0x0000FF; + color_t color0 = c->land == laBlizzard ? 0x5050C0 : showcoc ? 0x80C0FF : 0x8080FF; + color_t color02 = 0xFFFFFF; + color_t color06 = 0xFF0000; + color_t color08 = 0xFFFF00; if(h < -1) wcol = colorN10; @@ -3133,10 +3131,10 @@ bool use_swapped_duals() { return (masterless && !a4) || GOLDBERG; } -void floorShadow(cell *c, const transmatrix& V, int col) { +void floorShadow(cell *c, const transmatrix& V, color_t col) { if(pmodel == mdHyperboloid || pmodel == mdBall || pmodel == mdHemisphere || noshadow) return; // shadows break the depth testing - dynamicval p(poly_outline, OUTLINE_TRANS); + dynamicval p(poly_outline, OUTLINE_TRANS); if(qfi.shape) { queuepolyat(V * qfi.spin * shadowmulmatrix, *qfi.shape, col, PPR::WALLSHADOW); } @@ -3167,7 +3165,7 @@ void set_maywarp_floor(cell *c) { int wavephase; -void escherSidewall(cell *c, int sidepar, const transmatrix& V, int col) { +void escherSidewall(cell *c, int sidepar, const transmatrix& V, color_t col) { if(sidepar >= SIDE_SLEV && sidepar <= SIDE_SLEV+2) { int sl = sidepar - SIDE_SLEV; for(int z=1; z<=4; z++) if(z == 1 || (z == 4 && detaillevel == 2)) @@ -3196,7 +3194,7 @@ void escherSidewall(cell *c, int sidepar, const transmatrix& V, int col) { } } -bool placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, int col) { +bool placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, color_t col) { if(!qfi.fshape || !qfi.fshape->is_plain || !validsidepar[sidepar] || qfi.usershape >= 0) { escherSidewall(c, sidepar, V, col); @@ -3262,7 +3260,7 @@ void pushdown(cell *c, int& q, const transmatrix &V, double down, bool rezoom, b if(down > 0 && repriority) { int qq = q+1; while(qq < isize(ptds)) - if(qq > q && ptds[qq].prio < ptds[qq-1].prio) { + if(qq > q && ptds[qq]->prio < ptds[qq-1]->prio) { swap(ptds[qq], ptds[qq-1]); qq--; } @@ -3270,35 +3268,35 @@ void pushdown(cell *c, int& q, const transmatrix &V, double down, bool rezoom, b } while(q < isize(ptds)) { - polytodraw& ptd = ptds[q++]; - if(ptd.kind == pkPoly) { + auto pp = dynamic_cast (&*ptds[q++]); + if(!pp) continue; + auto& ptd = *pp; + + double z2; - double z2; + double z = zlevel(tC0(ptd.V)); + double lev = geom3::factor_to_lev(z); + double nlev = lev - down; + + double xyscale = rezoom ? geom3::scale_at_lev(lev) / geom3::scale_at_lev(nlev) : 1; + z2 = geom3::lev_to_factor(nlev); + double zscale = z2 / z; + + // xyscale = xyscale + (zscale-xyscale) * (1+sin(ticks / 1000.0)) / 2; + + ptd.V = xyzscale( V, xyscale*zscale, zscale) + * inverse(V) * ptd.V; - double z = zlevel(tC0(ptd.u.poly.V)); - double lev = geom3::factor_to_lev(z); - double nlev = lev - down; - - double xyscale = rezoom ? geom3::scale_at_lev(lev) / geom3::scale_at_lev(nlev) : 1; - z2 = geom3::lev_to_factor(nlev); - double zscale = z2 / z; - - // xyscale = xyscale + (zscale-xyscale) * (1+sin(ticks / 1000.0)) / 2; - - ptd.u.poly.V = xyzscale( V, xyscale*zscale, zscale) - * inverse(V) * ptd.u.poly.V; - - if(!repriority) ; - else if(nlev < -geom3::lake_bottom-1e-3) { - ptd.prio = PPR::BELOWBOTTOM_FALLANIM; - if(c->wall != waChasm) - ptd.col = 0; // disappear! - } - else if(nlev < -geom3::lake_top-1e-3) - ptd.prio = PPR::INLAKEWALL_FALLANIM; - else if(nlev < 0) - ptd.prio = PPR::LAKEWALL_FALLANIM; - } + if(!repriority) ; + else if(nlev < -geom3::lake_bottom-1e-3) { + ptd.prio = PPR::BELOWBOTTOM_FALLANIM; + if(c->wall != waChasm) + ptd.color = 0; // disappear! + } + else if(nlev < -geom3::lake_top-1e-3) + ptd.prio = PPR::INLAKEWALL_FALLANIM; + else if(nlev < 0) + ptd.prio = PPR::LAKEWALL_FALLANIM; } } @@ -3397,8 +3395,8 @@ int getfd(cell *c) { } } -int getSnakelevColor(cell *c, int i, int last, int fd, int wcol) { - int col; +int getSnakelevColor(cell *c, int i, int last, int fd, color_t wcol) { + color_t col; if(c->wall == waTower) col = 0xD0D0D0-i*0x101010; else if(c->land == laSnakeNest) @@ -3410,14 +3408,14 @@ int getSnakelevColor(cell *c, int i, int last, int fd, int wcol) { return darkena(col, fd, 0xFF); } -void draw_wall(cell *c, const transmatrix& V, int wcol, int& zcol, int ct6, int fd) { +void draw_wall(cell *c, const transmatrix& V, color_t wcol, color_t& zcol, int ct6, int fd) { zcol = wcol; - int wcol0 = wcol; + color_t wcol0 = wcol; int starcol = wcol; if(c->wall == waWarpGate) starcol = 0; if(c->wall == waVinePlant) starcol = 0x60C000; - int wcol2 = gradient(0, wcol0, 0, .8, 1); + color_t wcol2 = gradient(0, wcol0, 0, .8, 1); if(c->wall == waClosedGate) { int hdir = 0; @@ -3482,7 +3480,7 @@ void draw_wall(cell *c, const transmatrix& V, int wcol, int& zcol, int ct6, int bool just_gmatrix; -int colorhash(int i) { +int colorhash(color_t i) { return (i * 0x471211 + i*i*0x124159 + i*i*i*0x982165) & 0xFFFFFF; } @@ -3603,7 +3601,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { return; } - // int col = 0xFFFFFF - 0x20 * c->maxdist - 0x2000 * c->cpdist; + // color_t col = 0xFFFFFF - 0x20 * c->maxdist - 0x2000 * c->cpdist; if(!buggyGeneration && c->mpdist > 8 && !cheater && !autocheat) return; // not yet generated /* if(!buggyGeneration && c->mpdist > 7 && !cheater) { @@ -3618,7 +3616,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } char ch = winf[c->wall].glyph; - int wcol, fcol, asciicol; + color_t wcol, fcol, asciicol; setcolors(c, wcol, fcol); @@ -3634,7 +3632,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { fcol = gradient(fcol, 0xC0C0FF, 0, 0.2, 1); // addaura(tC0(V), wcol); - int zcol = fcol; + color_t zcol = fcol; if(peace::on && peace::hint && c->land != laTortoise) { int d = @@ -3929,7 +3927,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { transmatrix Vdepth = mscale(V2, geom3::WALL); queuepolyat(Vdepth, shSemiFloor[0], darkena(vcol, fd, 0xFF), PPR::WALL3A); - {dynamicval p(poly_outline, OUTLINE_TRANS); queuepolyat(V2 * spin(M_PI*2/3), shSemiFloorShadow, SHADOW_WALL, PPR::WALLSHADOW); } + {dynamicval p(poly_outline, OUTLINE_TRANS); queuepolyat(V2 * spin(M_PI*2/3), shSemiFloorShadow, SHADOW_WALL, PPR::WALLSHADOW); } queuepolyat(V2, shSemiFloorSide[SIDE_WALL], darkena(vcol, fd, 0xFF), PPR::WALL3A-2+away(V2)); if(validsidepar[SIDE_WALL]) forCellIdEx(c2, j, c) { @@ -4209,7 +4207,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } else if(chasmg && wmspatial) { - int col = c->land == laCocytus ? 0x080808FF : 0x101010FF; + color_t col = c->land == laCocytus ? 0x080808FF : 0x101010FF; if(qfi.fshape == &shCloudFloor) set_floor(shCloudSeabed); @@ -4241,13 +4239,13 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } string label = its(si.id & 255); - int col = forecolor ^ colorhash(si.id >> 8); + color_t col = forecolor ^ colorhash(si.id >> 8); queuestr(V, .5, label, 0xFF000000 + col); } #endif if((cmode & sm::NUMBER) && (dialog::editingDetail())) { - int col = + color_t col = dist0 < geom3::highdetail ? 0xFF80FF80 : dist0 >= geom3::middetail ? 0xFFFF8080 : 0XFFFFFF80; @@ -4330,7 +4328,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { case waReptileBridge: { Vboat = &(Vboat0 = V); dynamicval qfi2(qfi, qfi); - int col = reptilecolor(c); + color_t col = reptilecolor(c); chasmg = 0; set_reptile_floor(c, V, col); draw_qfi(c, V, col); @@ -4440,7 +4438,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { case waGlass: if(wmspatial) { - int col = winf[waGlass].color; + color_t col = winf[waGlass].color; int dcol = darkena(col, 0, 0x80); transmatrix Vdepth = mscale((*Vdp), geom3::WALL); draw_floorshape(c, Vdepth, shMFloor, dcol, PPR::WALL); // GLASS @@ -4510,7 +4508,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { poly_outline = (c->land == laMirror) ? OUTLINE_TREASURE : OUTLINE_ORB; if(wmspatial) { - int col = winf[c->wall].color; + color_t col = winf[c->wall].color; int dcol = darkena(col, 0, 0xC0); transmatrix Vdepth = mscale((*Vdp), geom3::WALL); draw_floorshape(c, Vdepth, shMFloor, dcol, PPR::WALL); // GLASS @@ -4559,7 +4557,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { int sha = shallow(c); if(wmspatial && sha) { - int col = (highwall(c) || c->wall == waTower) ? wcol : fcol; + color_t col = (highwall(c) || c->wall == waTower) ? wcol : fcol; if(!chasmg) { #define D(v) darkena(gradient(0, col, 0, v * (sphere ? spherity(V * cellrelmatrix(c,i)) : 1), 1), fd, 0xFF) @@ -4597,9 +4595,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { forCellIdEx(c2, i, c) if(chasmgraph(c2) == 0) { transmatrix V2 = V * cellrelmatrix(c, i); // if(!behindsphere(V2)) continue; - int wcol2, fcol2; + color_t wcol2, fcol2; setcolors(c2, wcol2, fcol2); - int col = (highwall(c2) || c->wall == waTower) ? wcol2 : fcol2; + color_t col = (highwall(c2) || c->wall == waTower) ? wcol2 : fcol2; col = gradient(0, col, 0, spherity(V), 1); int j = c->c.spin(i); if(ticks % 500 < -250) { @@ -4625,7 +4623,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(fa.walltype == waNone) draw_qfi(c, V, darkena(fcol, fd, 0xFF), PPR::FLOOR); else { - int wcol2, fcol2; + color_t wcol2, fcol2; eWall w = c->wall; int p = c->wparam; c->wall = fa.walltype; c->wparam = fa.m; setcolors(c, wcol2, fcol2); @@ -4786,8 +4784,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(vid.linequality > 0) steps <<= vid.linequality; if(vid.linequality < 0) steps >>= -vid.linequality; for(int i=0; i<=steps; i++) curvepoint(V * get_horopoint(y, x1 + (x2-x1) * i / steps)); - queuecurve(gridcolor(c, c->move(dir)), 0, PPR::LINE); - lastptd().u.poly.linewidth = linewidthat(V * get_horopoint(y, (x1+x2)/2), vid.linewidth, 0); + queuecurve(gridcolor(c, c->move(dir)), 0, PPR::LINE).linewidth = linewidthat(V * get_horopoint(y, (x1+x2)/2), vid.linewidth, 0); }; horizontal(yy, 2*xx, xx, 4, binary::bd_up_right); horizontal(yy, xx, -xx, 8, binary::bd_up); @@ -4879,7 +4876,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(vid.grid && c->bardir != NODIR && c->bardir != NOBARRIERS && c->land != laHauntedWall && c->barleft != NOWALLSEP_USED) { - int col = darkena(0x505050, 0, 0xFF); + color_t col = darkena(0x505050, 0, 0xFF); queueline(tC0(V), V*tC0(heptmove[c->bardir]), col, 2 + vid.linequality); queueline(tC0(V), V*tC0(hexmove[c->bardir]), col, 2 + vid.linequality); } @@ -4896,8 +4893,8 @@ struct flashdata { cell *where; double angle; int spd; // 0 for flashes, >0 for particles - int color; - flashdata(int _t, int _s, cell *_w, int col, int sped) { + color_t color; + flashdata(int _t, int _s, cell *_w, color_t col, int sped) { t=_t; size=_s; where=_w; color = col; angle = rand() % 1000; spd = sped; } @@ -4911,11 +4908,11 @@ void drawFlash(cell *c) { void drawBigFlash(cell *c) { flashes.push_back(flashdata(ticks, 2000, c, 0xC0FF00, 0)); } -void drawParticle(cell *c, int col, int maxspeed) { +void drawParticle(cell *c, color_t col, int maxspeed) { if(vid.particles && !confusingGeometry()) flashes.push_back(flashdata(ticks, rand() % 16, c, col, 1+rand() % maxspeed)); } -void drawParticles(cell *c, int col, int qty, int maxspeed) { +void drawParticles(cell *c, color_t col, int qty, int maxspeed) { if(vid.particles) while(qty--) drawParticle(c,col, maxspeed); } @@ -4940,11 +4937,11 @@ void fallingMonsterAnimation(cell *c, eMonster m, int id) { // drawParticles(c, darkenedby(linf[c->land].color, 1), 4, 50); } -void queuecircleat(cell *c, double rad, int col) { +void queuecircleat(cell *c, double rad, color_t col) { if(!c) return; if(!gmatrix.count(c)) return; if(stereo::mode || sphere) { - dynamicval p(poly_outline, col); + dynamicval p(poly_outline, col); queuepolyat(gmatrix[c] * spin(ticks / 100.), shGem[1], 0, PPR::LINE); return; } @@ -5394,7 +5391,7 @@ void drawmovestar(double dx, double dy) { #endif else for(int d=0; d<8; d++) { - int col = starcol; + color_t col = starcol; #if ISPANDORA if(leftclick && (d == 2 || d == 6 || d == 1 || d == 7)) col &= 0xFFFFFF3F; if(rightclick && (d == 2 || d == 6 || d == 3 || d == 5)) col &= 0xFFFFFF3F; @@ -5556,15 +5553,14 @@ void drawfullmap() { } if(rad && !haveaura()) { queuecircle(vid.xcenter, vid.ycenter, rad, ringcolor, - vid.usingGL ? PPR::CIRCLE : PPR::OUTCIRCLE); - if(isbnd) lastptd().u.cir.boundary = true; + vid.usingGL ? PPR::CIRCLE : PPR::OUTCIRCLE, isbnd); } if(pmodel == mdBall) ballgeometry(); } if(pmodel == mdHyperboloid) { #if CAP_QUEUE - int col = darkena(0x80, 0, 0x80); + color_t col = darkena(0x80, 0, 0x80); queueline(hpxyz(0,0,1), hpxyz(0,0,-vid.alpha), col, 0, PPR::CIRCLE); queueline(xpush0(+4), hpxyz(0,0,0), col, 0, PPR::CIRCLE); queueline(xpush0(+4), hpxyz(0,0,-vid.alpha), col, 0, PPR::CIRCLE); @@ -5739,7 +5735,7 @@ void drawscreen() { screens.back()(); #if !ISMOBILE - int col = linf[cwt.at->land].color; + color_t col = linf[cwt.at->land].color; if(cwt.at->land == laRedRock) col = 0xC00000; if(!nohelp) displayfr(vid.xres/2, vid.fsize, 2, vid.fsize, mouseovers, col, 8); @@ -5772,7 +5768,7 @@ void drawscreen() { if((minefieldNearby || tmines) && !items[itOrbAether] && darken == 0 && normal) { string s; if(tmines > 7) tmines = 7; - int col = minecolors[tmines]; + color_t col = minecolors[tmines]; if(tmines == 7) seenSevenMines = true; @@ -5931,7 +5927,7 @@ void animateReplacement(cell *a, cell *b, int layer, int direction_hinta, int di animateMovement(&c1, a, layer, direction_hintb); } -void drawBug(const cellwalker& cw, int col) { +void drawBug(const cellwalker& cw, color_t col) { #if CAP_POLY initquickqueue(); transmatrix V = ggmatrix(cw.at); diff --git a/help.cpp b/help.cpp index 1f68ad1a..07b03ad2 100644 --- a/help.cpp +++ b/help.cpp @@ -177,7 +177,7 @@ string princedesc() { return XLAT("Apparently a princess is kept locked somewhere, but you won't ever find her in this hyperbolic palace. "); } -string helptitle(string s, int col) { +string helptitle(string s, color_t col) { return "@" + its(col) + "\t" + s + "\n"; } diff --git a/hud.cpp b/hud.cpp index 3f4f7605..2a5ba4ef 100644 --- a/hud.cpp +++ b/hud.cpp @@ -163,7 +163,7 @@ bool graphglyph() { return vid.graphglyph == 2 || (vid.graphglyph == 1 && vid.monmode); } -bool displayglyph(int cx, int cy, int buttonsize, char glyph, int color, int qty, int flags, int id) { +bool displayglyph(int cx, int cy, int buttonsize, char glyph, color_t color, int qty, int flags, int id) { bool b = mousex >= cx && mousex < cx+buttonsize && mousey >= cy-buttonsize/2 && mousey <= cy-buttonsize/2+buttonsize; @@ -244,7 +244,7 @@ bool displayglyph(int cx, int cy, int buttonsize, char glyph, int color, int qty void displayglyph2(int cx, int cy, int buttonsize, int i) { char glyph = i < ittypes ? iinf[i].glyph : minf[i-ittypes].glyph; - int color = i < ittypes ? iinf[i].color : minf[i-ittypes].color; + color_t color = i < ittypes ? iinf[i].color : minf[i-ittypes].color; int imp = glyphflags(i); if(displayglyph(cx, cy, buttonsize, glyph, color, ikmerge(i), imp, i)) { @@ -310,12 +310,12 @@ void drawMobileArrow(int i) { transmatrix T; if(!compute_relamatrix(c, cwt.at, i, T)) return; - // int col = getcs().uicolor; + // color_t col = getcs().uicolor; // col -= (col & 0xFF) >> 1; bool invalid = !legalmoves[dir]; - int col = cellcolor(c); + color_t col = cellcolor(c); if(col == OUTLINE_NONE) col = 0xC0C0C0FF; col -= (col & 0xFF) >> 1; if(invalid) col -= (col & 0xFF) >> 1; diff --git a/hyper.h b/hyper.h index 0705b5e9..39473a4c 100644 --- a/hyper.h +++ b/hyper.h @@ -44,6 +44,7 @@ using std::out_of_range; using std::get; using std::move; using std::make_tuple; +using std::unique_ptr; using std::abs; using std::isfinite; @@ -299,6 +300,7 @@ struct gcell { // improved tracking in Trollheim union { int32_t landpar; + unsigned int landpar_color; float heat; char bytes[4]; struct fieldinfo { @@ -324,6 +326,7 @@ struct gcell { }; #define landparam LHU.landpar +#define landparam_color LHU.landpar_color #define fval LHU.fi.fieldval @@ -724,7 +727,7 @@ void activateActiv(cell *c, bool msg); struct charstyle { int charid; - unsigned skincolor, haircolor, dresscolor, swordcolor, dresscolor2, uicolor; + color_t skincolor, haircolor, dresscolor, swordcolor, dresscolor2, uicolor; }; string csname(charstyle& cs); @@ -892,8 +895,8 @@ void resetmusic(); void drawFlash(cell* c); void drawBigFlash(cell* c); -void drawParticle(cell *c, int col, int maxspeed = 100); -void drawParticles(cell *c, int col, int qty, int maxspeed = 100); +void drawParticle(cell *c, color_t col, int maxspeed = 100); +void drawParticles(cell *c, color_t col, int qty, int maxspeed = 100); void drawFireParticles(cell *c, int qty, int maxspeed = 100); int firecolor(int phase); @@ -904,18 +907,20 @@ void movepckeydir(int); void centerpc(ld aspd); +typedef color_t color_t; + void displayButton(int x, int y, const string& name, int key, int align, int rad = 0); -void displayColorButton(int x, int y, const string& name, int key, int align, int rad, int color, int color2 = 0); +void displayColorButton(int x, int y, const string& name, int key, int align, int rad, color_t color, color_t color2 = 0); inline string ONOFF(bool b) { return XLAT(b ? "ON" : "OFF"); } int darkened(int c); extern int getcstat; -bool displaychr(int x, int y, int shift, int size, char chr, int col); -bool displayfr(int x, int y, int b, int size, const string &s, int color, int align); -bool displayfrSP(int x, int y, int sh, int b, int size, const string &s, int color, int align, int p); +bool displaychr(int x, int y, int shift, int size, char chr, color_t col); +bool displayfr(int x, int y, int b, int size, const string &s, color_t color, int align); +bool displayfrSP(int x, int y, int sh, int b, int size, const string &s, color_t color, int align, int p); bool outofmap(hyperpoint h); void applymodel(hyperpoint H, hyperpoint& Hscr); -void drawCircle(int x, int y, int size, int color); +void drawCircle(int x, int y, int size, color_t color); void fixcolor(int& col); ld displayspin(cell *c, int d); hyperpoint gethyper(ld x, ld y); @@ -923,14 +928,14 @@ void resetview(); extern heptspin viewctr; extern cellwalker centerover; void drawthemap(); void drawfullmap(); extern function wrap_drawfullmap; -bool displaystr(int x, int y, int shift, int size, const char *str, int color, int align); -bool displaystr(int x, int y, int shift, int size, const string& str, int color, int align); +bool displaystr(int x, int y, int shift, int size, const char *str, color_t color, int align); +bool displaystr(int x, int y, int shift, int size, const string& str, color_t color, int align); extern int darken, inmirrorcount; void calcparam(); #if CAP_SDL -int& qpixel(SDL_Surface *surf, int x, int y); +color_t& qpixel(SDL_Surface *surf, int x, int y); void setvideomode(); void saveHighQualityShot(const char *fname = NULL, const char *caption = NULL, int fade = 255); #endif @@ -1288,9 +1293,9 @@ void selectEyeGL(int ed); void selectEyeMask(int ed); extern int ticks; -extern unsigned backcolor, bordcolor, forecolor; +extern color_t backcolor, bordcolor, forecolor; -void setGLProjection(int col = backcolor); +void setGLProjection(color_t col = backcolor); // passable flags @@ -1658,7 +1663,7 @@ namespace dialog { string value; string keycaption; int key; - int color, colorv, colork, colors, colorc; + color_t color, colorv, colork, colors, colorc; int scale; double param; int position; @@ -1682,7 +1687,7 @@ namespace dialog { extern reaction_t reaction, extra_options; item& lastItem(); - extern unsigned int *palette; + extern color_t *palette; string keyname(int k); @@ -1691,15 +1696,15 @@ namespace dialog { void addBoolItem(string body, bool value, int key); void addBigItem(string body, int key); void addColorItem(string body, int value, int key); - void openColorDialog(unsigned int& col, unsigned int *pal = palette); + void openColorDialog(color_t& col, color_t *pal = palette); void addHelp(string body); - void addInfo(string body, int color = 0xC0C0C0); + void addInfo(string body, color_t color = 0xC0C0C0); void addItem(string body, int key); int addBreak(int val); - void addTitle(string body, int color, int scale); + void addTitle(string body, color_t color, int scale); void init(); - void init(string title, int color = 0xE8E8E8, int scale = 150, int brk = 60); + void init(string title, color_t color = 0xE8E8E8, int scale = 150, int brk = 60); void display(); void editNumber(ld& x, ld vmin, ld vmax, ld step, ld dft, string title, string help); @@ -1709,8 +1714,8 @@ namespace dialog { void handleNavigation(int &sym, int &uni); namespace zoom { - bool displayfr(int x, int y, int b, int size, const string &s, int color, int align); - bool displayfr_highlight(int x, int y, int b, int size, const string &s, int color, int align, int hicolor = 0xFFFF00); + bool displayfr(int x, int y, int b, int size, const string &s, color_t color, int align); + bool displayfr_highlight(int x, int y, int b, int size, const string &s, color_t color, int align, int hicolor = 0xFFFF00); } bool editingDetail(); @@ -1721,7 +1726,7 @@ namespace dialog { extern bool sidedialog; extern int dialogflags; extern int dcenter; - int displaycolor(unsigned col); + int displaycolor(color_t col); void openFileDialog(string& filename, string fcap, string ext, bool_reaction_t action); @@ -1744,11 +1749,11 @@ void clearMessages(); void resetGeometry(); namespace svg { - void circle(int x, int y, int size, int col); - void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double linewidth); - void text(int x, int y, int size, const string& str, bool frame, int col, int align); + void circle(int x, int y, int size, color_t col); + void polygon(int *polyx, int *polyy, int polyi, color_t col, int outline, double linewidth); + void text(int x, int y, int size, const string& str, bool frame, color_t col, int align); extern bool in; - extern const string *link; + extern string link; void render(const char *fname = NULL, const function& what = drawfullmap); } @@ -1770,7 +1775,7 @@ extern bool ivoryz; #define SHADOW_SL 0x18 #define SHADOW_MON 0x30 -bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, double footphase); +bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase); void drawPlayerEffects(const transmatrix& V, cell *c, bool onPlayer); @@ -1868,7 +1873,7 @@ inline PPR operator - (PPR x, int y) { return PPR(int(x) - y); } inline int operator - (PPR x, PPR y) { return int(x) - int(y); } namespace mapeditor { - bool drawUserShape(const transmatrix& V, eShapegroup group, int id, int color, cell *c, PPR prio = PPR::DEFAULT); + bool drawUserShape(const transmatrix& V, eShapegroup group, int id, color_t color, cell *c, PPR prio = PPR::DEFAULT); } void ShadowV(const transmatrix& V, const struct hpcshape& bp, PPR prio = PPR::MONSTER_SHADOW); @@ -1970,7 +1975,7 @@ void setcameraangle(bool b); #define MODELCOUNT ((int) mdGUARD) -void drawShape(pair* coords, int qty, int color); +void drawShape(pair* coords, int qty, color_t color); extern eModel pmodel; @@ -2149,10 +2154,10 @@ namespace linepatterns { }; void clearAll(); - void setColor(ePattern id, int col); + void setColor(ePattern id, color_t col); void drawAll(); void showMenu(); - void switchAlpha(ePattern id, int col); + void switchAlpha(ePattern id, color_t col); }; transmatrix ddspin(cell *c, int d, ld bonus = 0); @@ -2371,7 +2376,7 @@ bool inmirror(eLand l); bool inmirror(cell *c); bool inmirror(const cellwalker& cw); -void queuemarkerat(const transmatrix& V, int col); +void queuemarkerat(const transmatrix& V, color_t col); void check_total_victory(); void applyBoxNum(int& i, string name = ""); @@ -2380,7 +2385,7 @@ extern int hinttoshow; bool isShmupLifeOrb(eItem it); int orbcharges(eItem it); -int gradient(int c0, int c1, ld v0, ld v, ld v1); +color_t gradient(color_t c0, color_t c1, ld v0, ld v, ld v1); struct hint { time_t last; @@ -2405,10 +2410,10 @@ extern bool longclick; extern bool useRangedOrb; #endif -void addaura(const hyperpoint& h, int col, int fd); -void addauraspecial(const hyperpoint& h, int col, int dir); +void addaura(const hyperpoint& h, color_t col, int fd); +void addauraspecial(const hyperpoint& h, color_t col, int dir); -void drawBug(const cellwalker& cw, int col); +void drawBug(const cellwalker& cw, color_t col); void mainloop(); void mainloopiter(); @@ -2525,60 +2530,60 @@ struct textureinfo { int current_type, symmetries; }; -struct qpoly { - transmatrix V; - const vector *tab; - int offset, cnt; - int outline; - double linewidth; - int flags; - textureinfo *tinf; - }; - -struct qline { - hyperpoint H1, H2; - int prf; - double width; - }; - -#define MAXQCHR 64 - -struct qchr { - char str[MAXQCHR]; - int x, y, shift, size, frame; - int align; - }; - -struct qcir { - int x, y, size; - bool boundary; - }; - -// set a link for SVG -struct qlink { - const string *link; - }; - -enum eKind { pkPoly, pkLine, pkString, pkCircle, pkShape, pkResetModel, pkSpecial, pkLink }; - -union polyunion { - qpoly poly; - qline line; - qchr chr; - qcir cir; - double dvalue; - qlink link; - polyunion() {} - }; - -struct polytodraw { - eKind kind; +struct drawqueueitem { PPR prio; - int col; - polyunion u; - polytodraw() {} + color_t color; + virtual void draw() = 0; + virtual void draw_back() {} + virtual void draw_pre() {} + virtual ~drawqueueitem() {} + void draw_darker(); }; +struct dqi_poly : drawqueueitem { + transmatrix V; + const vector *tab; + int offset, cnt; + int outline; + double linewidth; + int flags; + textureinfo *tinf; + void draw(); + void gldraw(); + void draw_back(); + }; + +struct dqi_line : drawqueueitem { + hyperpoint H1, H2; + int prf; + double width; + void draw(); + void draw_back(); + }; + +struct dqi_string : drawqueueitem { + string str; + int x, y, shift, size, frame; + int align; + void draw(); + }; + +struct dqi_circle : drawqueueitem { + int x, y, size; + void draw(); + }; + +struct dqi_boundary_circle : dqi_circle { + int x, y, size; + void draw_pre(); + }; + +struct dqi_action : drawqueueitem { + reaction_t action; + dqi_action(const reaction_t& a) : action(a) {} + void draw() { action(); } + }; + extern int emeraldtable[100][7]; // extern cell *cwpeek(cellwalker cw, int dir); @@ -2952,7 +2957,7 @@ int emeraldval(cell *c); int inpair(cell *c, int colorpair); int snake_pair(cell *c); -extern const unsigned int nestcolors[8]; +extern const color_t nestcolors[8]; #if CAP_TEXTURE namespace texture { @@ -2967,13 +2972,13 @@ namespace texture { texture_data() { textureid = 0; twidth = 2048; } - vector texture_pixels; + vector texture_pixels; - unsigned& get_texture_pixel(int x, int y) { + color_t& get_texture_pixel(int x, int y) { return texture_pixels[(y&(twidth-1))*twidth+(x&(twidth-1))]; } - vector> undos; + vector> undos; vector > pixels_to_draw; bool loadTextureGL(); @@ -2989,22 +2994,22 @@ namespace texture { struct texture_config { string texturename; string configname; - unsigned paint_color; + color_t paint_color; eTextureState tstate; eTextureState tstate_max; transmatrix itt; - unsigned grid_color; - unsigned mesh_color; - unsigned master_color; - unsigned slave_color; + color_t grid_color; + color_t mesh_color; + color_t master_color; + color_t slave_color; int color_alpha; int gsplits; - int recolor(int col); + int recolor(color_t col); typedef tuple texture_parameters; texture_parameters orig_texture_parameters; @@ -3016,7 +3021,7 @@ namespace texture { string texture_tuner; vector tuned_vertices; - bool apply(cell *c, const transmatrix &V, int col); + bool apply(cell *c, const transmatrix &V, color_t col); void mark_triangles(); void clear_texture_map(); @@ -3062,11 +3067,11 @@ namespace texture { void showMenu(); - void drawPixel(cell *c, hyperpoint h, int col); + void drawPixel(cell *c, hyperpoint h, color_t col); extern cell *where; // compute 'c' automatically, based on the hint in 'where' - void drawPixel(hyperpoint h, int col); - void drawLine(hyperpoint h1, hyperpoint h2, int col, int steps = 10); + void drawPixel(hyperpoint h, color_t col); + void drawLine(hyperpoint h1, hyperpoint h2, color_t col, int steps = 10); extern bool texturesym; @@ -3077,15 +3082,17 @@ namespace texture { } #endif -void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf = 0, PPR prio = PPR::LINE); -void queuelink(const string *link, PPR prio); +dqi_line& queueline(const hyperpoint& H1, const hyperpoint& H2, color_t col, int prf = 0, PPR prio = PPR::LINE); + +dqi_action& queueaction(PPR prio, const reaction_t& action); +void queuereset(eModel m, PPR prio); + extern ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf; extern ld scalefactor, orbsize, floorrad0, floorrad1, zhexf; -unsigned char& part(int& col, int i); -unsigned char& part(unsigned& col, int i); +unsigned char& part(color_t& col, int i); transmatrix applyPatterndir(cell *c, const patterns::patterninfo& si); @@ -3172,7 +3179,7 @@ struct renderbuffer { renderbuffer(int x, int y, bool gl); ~renderbuffer(); void enable(); - void clear(int col); + void clear(color_t col); }; struct resetbuffer { @@ -3283,7 +3290,7 @@ extern void initializeCLI(); static const int max_vec = (1<<14); -string helptitle(string s, int col); +string helptitle(string s, color_t col); pair cell_to_pair(cell *c); extern bool nohud, nofps, nomap; @@ -3296,7 +3303,7 @@ ld hypot3(const hyperpoint& h); extern const hyperpoint Hypc; ld det(const transmatrix& T); -void queuechr(const hyperpoint& h, int size, char chr, int col, int frame = 0); +void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame = 0); string fts(float x); bool model_needs_depth(); @@ -3494,7 +3501,7 @@ template<> struct saver : dsaver { }; #endif -extern vector ptds; +extern vector> ptds; extern ld intval(const hyperpoint &h1, const hyperpoint &h2); extern ld intvalxy(const hyperpoint &h1, const hyperpoint &h2); transmatrix euscalezoom(hyperpoint h); @@ -3520,7 +3527,7 @@ namespace glhr { void set_depthtest(bool b); glmatrix translate(ld x, ld y, ld z); - void color2(int color, ld part = 1); + void color2(color_t color, ld part = 1); void be_textured(); void set_modelview(const glmatrix& m); hyperpoint gltopoint(const glvertex& t); @@ -3563,10 +3570,9 @@ namespace glhr { void prepare(vector& v); } -void prettypoly(const vector& t, int fillcol, int linecol, int lev); -polytodraw& lastptd(); -void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio); -void queuetable(const transmatrix& V, const vector& f, int cnt, int linecol, int fillcol, PPR prio); +void prettypoly(const vector& t, color_t fillcol, color_t linecol, int lev); +dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, PPR prio); +dqi_poly& queuetable(const transmatrix& V, const vector& f, int cnt, color_t linecol, color_t fillcol, PPR prio); struct floorshape; @@ -3593,9 +3599,9 @@ int fix6(int a); int fix7(int a); int fixdir(int a, cell *c); cell *newCell(int type, heptagon *master); -extern int qpixel_pixel_outside; +extern color_t qpixel_pixel_outside; -void queuechr(int x, int y, int shift, int size, char chr, int col, int frame = 0, int align = 8); +void queuechr(int x, int y, int shift, int size, char chr, color_t col, int frame = 0, int align = 8); int zebra3(cell *c); int geosupport_threecolor(); @@ -3717,11 +3723,11 @@ namespace gp { extern bool debug_geometry; -void queuepoly(const transmatrix& V, const hpcshape& h, int col); -void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio); +dqi_poly& queuepoly(const transmatrix& V, const hpcshape& h, color_t col); +dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, PPR prio); -void queuestr(const hyperpoint& h, int size, const string& chr, int col, int frame = 0); -void queuechr(const transmatrix& V, double size, char chr, int col, int frame = 0); +void queuestr(const hyperpoint& h, int size, const string& chr, color_t col, int frame = 0); +void queuechr(const transmatrix& V, double size, char chr, color_t col, int frame = 0); extern bool just_gmatrix; void drawrec(const heptspin& hs, hstate s, const transmatrix& V); @@ -3868,12 +3874,12 @@ namespace geom3 { extern ld BODY; } -void queuestr(const transmatrix& V, double size, const string& chr, int col, int frame = 0, int align = 8); -void queuestr(int x, int y, int shift, int size, string str, int col, int frame = 0, int align = 8); +void queuestr(const transmatrix& V, double size, const string& chr, color_t col, int frame = 0, int align = 8); +void queuestr(int x, int y, int shift, int size, string str, color_t col, int frame = 0, int align = 8); ld frac(ld x); -extern int poly_outline; +extern color_t poly_outline; extern hpcshape shDisk, shTriangle, shHeptaMarker, shSnowball, shDiskT, shDiskS, shDiskSq, shDiskM; diff --git a/inventory.cpp b/inventory.cpp index 0bd5c0a3..171032b0 100644 --- a/inventory.cpp +++ b/inventory.cpp @@ -544,7 +544,7 @@ namespace hr { namespace inv { eLand pl = getPrizeLand(); eOrbLandRelation olr = getOLR(which, pl); - int col = 0; + color_t col = 0; const char *fmsg = NULL; if(olr == olrDangerous) col = 0xC00000, diff --git a/mapeditor.cpp b/mapeditor.cpp index 07f79fb6..89f30e00 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -898,7 +898,7 @@ namespace mapeditor { int dslayer; bool coloring; - unsigned int colortouse = 0xC0C0C0FFu; + color_t colortouse = 0xC0C0C0FFu; // fake key sent to change the color static const int COLORKEY = (-10000); @@ -1180,20 +1180,20 @@ namespace mapeditor { initShape(sg, id); for(int i=0; i (&*ptds[i]); + if(!pp) continue; + auto& ptd = *pp; - auto& p = ptd.u.poly; - int cnt = p.cnt; + int cnt = ptd.cnt; usershapelayer *dsCur = &usershapes[sg][id]->d[layer]; dsCur->list.clear(); - dsCur->color = ptd.col; + dsCur->color = ptd.color; dsCur->sym = false; dsCur->rots = 1; for(auto& v: symmetriesAt) - if(v[0] == p.offset) { + if(v[0] == ptd.offset) { dsCur->rots = v[1]; dsCur->sym = v[2] == 2; } @@ -1201,7 +1201,7 @@ namespace mapeditor { int d = dsCur->rots * (dsCur->sym ? 2 : 1); for(int i=0; i < cnt/d; i++) - dsCur->list.push_back(p.V * glhr::gltopoint((*p.tab)[i+p.offset])); + dsCur->list.push_back(ptd.V * glhr::gltopoint((*ptd.tab)[i+ptd.offset])); layer++; if(layer == USERLAYERS) break; @@ -1699,7 +1699,7 @@ namespace mapeditor { #endif } - bool drawUserShape(const transmatrix& V, eShapegroup group, int id, int color, cell *c, PPR prio) { + bool drawUserShape(const transmatrix& V, eShapegroup group, int id, color_t color, cell *c, PPR prio) { #if !CAP_EDIT return false; #else diff --git a/menus.cpp b/menus.cpp index 01feca7e..59ac2e61 100644 --- a/menus.cpp +++ b/menus.cpp @@ -73,7 +73,7 @@ void showOverview() { eLand l = landlist[lstart + i]; int xr = vid.xres / 64; int i0 = 56 + vid.fsize + i * vf; - int col; + color_t col; if(landUnlocked(l)) col = linf[l].color; else col = 0x404040; if(l == curland) displayfrZ(1, i0, 1, vf-4, "*", forecolor, 0); diff --git a/monstergen.cpp b/monstergen.cpp index c91b183f..c0e1abe1 100644 --- a/monstergen.cpp +++ b/monstergen.cpp @@ -674,9 +674,9 @@ void wandering() { } } -void generateSnake(cell *c, int i, int color) { +void generateSnake(cell *c, int i, int snakecolor) { c->monst = moHexSnake; - c->hitpoints = color; + c->hitpoints = snakecolor; int cpair = (1<move(i))); preventbarriers(c); int len = BITRUNCATED ? ROCKSNAKELENGTH : 2; @@ -691,7 +691,7 @@ void generateSnake(cell *c, int i, int color) { cell *c3 = c2->move(i); if(c3->monst || c3->bardir != NODIR || c3->wall) break; c2 = c3; - c2->monst = moHexSnakeTail; c2->hitpoints = color; + c2->monst = moHexSnakeTail; c2->hitpoints = snakecolor; i = (j + (c2->type%4 == 0 ? c2->type/2 : (len%2 ? 2 : c2->type - 2))) % c2->type; createMov(c2, i); if(!inpair(c2->move(i), cpair)) { diff --git a/netgen.cpp b/netgen.cpp index 7d6d618f..a3d5ca9b 100644 --- a/netgen.cpp +++ b/netgen.cpp @@ -213,13 +213,13 @@ namespace hr { namespace netgen { // Simple graphical functions //============================ - void blackline(vec v1, vec v2, int col = 0x000000FF) { + void blackline(vec v1, vec v2, color_t col = 0x000000FF) { #if CAP_SDLGFX==1 aalineColor(s, int(v1.x), int(v1.y), int(v2.x), int(v2.y), col); #endif } - void drawtriangle(vec v1, vec v2, vec v3, int col) { + void drawtriangle(vec v1, vec v2, vec v3, color_t col) { #if CAP_SDLGFX==1 polyx[0] = int(v1.x); polyx[1] = int(v2.x); @@ -231,7 +231,7 @@ namespace hr { namespace netgen { #endif } - void blackcircle(vec v, int r, int col = 0x000000FF) { + void blackcircle(vec v, int r, color_t col = 0x000000FF) { #if CAP_SDLGFX aacircleColor(s, int(v.x), int(v.y), r, col); #endif @@ -257,7 +257,7 @@ namespace hr { namespace netgen { SDL_Surface *net, *hqsurface; - int& hqpixel(hyperpoint h) { + color_t& hqpixel(hyperpoint h) { int hx, hy, hs; getcoord0(h, hx, hy, hs); return qpixel(hqsurface, hx, hy); @@ -388,7 +388,7 @@ namespace hr { namespace netgen { "!@#$%^&*+=~:;<>?/|\"., [{(\\]})" [(pateks++) % 85]; } - int col = 0xFFFFFFFF; + color_t col = 0xFFFFFFFF; int p = patek[i][e]; col -= 0x8000 * (p&1); p /= 2; col -= 0x800000 * (p&1); p /= 2; @@ -520,7 +520,7 @@ namespace hr { namespace netgen { if(i == bei && e == bee) cedist = norm(v3-mousepos); } - int col = + color_t col = i == bei && e == bee ? 0x40FF40FF: i == nei[bei][bee] && nei[i][e] == bei ? 0x40FF40FF : nei[i][e] == glued[i] ? 0x303030FF : @@ -640,7 +640,7 @@ namespace hr { namespace netgen { int t = ct[i]; int ofs = t == 7 ? 0 : 5; for(int e=0; e= 0 ? 0x303030 : nei[i][e] >= 0 && glued[nei[i][e]] == i ? 0x303030 : nei[i][e] >= 0 ? 0x808080 : diff --git a/pattern2.cpp b/pattern2.cpp index 885c2193..bb93d71b 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -1327,12 +1327,12 @@ namespace patterns { if(whichCanvas == 'r') return hrand(0xFFFFFF + 1); if(whichCanvas == 'e') { - static unsigned int fcol[4] = { 0x404040, 0x800000, 0x008000, 0x000080 }; + static color_t fcol[4] = { 0x404040, 0x800000, 0x008000, 0x000080 }; int fv = emeraldval(c); return fcol[fv&3]; } if(whichCanvas == 'a') { - static unsigned int fcol8[8] = { + static color_t fcol8[8] = { 0x800000, 0x503000, 0x206000, @@ -1344,32 +1344,32 @@ namespace patterns { }; if(c->wall == waNone) { - int col = fcol8[land50(c)]; + color_t col = fcol8[land50(c)]; if(polara50(c)) col += 0x181818; return col; } } if(whichCanvas == 'b') { - static unsigned int fcol[4] = { 0x404040, 0x800000, 0x008000, 0x000080 }; + static color_t fcol[4] = { 0x404040, 0x800000, 0x008000, 0x000080 }; return fcol[polara50(c) + 2 * polarb50(c)]; } if(whichCanvas == 'z') { - static unsigned int fcol[4] = { 0xC0C0C0, 0xE0E0E0, 0x404040, 0x606060 }; + static color_t fcol[4] = { 0xC0C0C0, 0xE0E0E0, 0x404040, 0x606060 }; int fv = zebra40(c); return fcol[fv&3]; } if(whichCanvas == 't') { - static unsigned int fcol[4] = { 0x804040, 0x408040, 0x404080, 0x808040 }; + static color_t fcol[4] = { 0x804040, 0x408040, 0x404080, 0x808040 }; int fv = zebra40(c); if(fv/4 == 4 || fv/4 == 6 || fv/4 == 5 || fv/4 == 10) fv ^= 2; return fcol[fv&3]; } if(whichCanvas == 'x') { - static unsigned int fcol[4] = { 0xC0C0C0, 0x800000, 0x008000, 0x000080 }; + static color_t fcol[4] = { 0xC0C0C0, 0x800000, 0x008000, 0x000080 }; return fcol[zebra3(c)]; } if(whichCanvas == 'w') { - static unsigned int fcol[2] = { 0x303030, 0xC0C0C0 }; + static color_t fcol[2] = { 0x303030, 0xC0C0C0 }; return fcol[randpattern(c, subcanvas) ? 1 : 0]; } if(whichCanvas == 'l') { @@ -1935,16 +1935,16 @@ bool is_master(cell *c) { namespace linepatterns { - int lessalpha(int col, int m) { + color_t lessalpha(color_t col, int m) { part(col, 0) /= m; return col; } - int lessalphaif(int col, bool b) { + color_t lessalphaif(color_t col, bool b) { return b?lessalpha(col, 4):col; } - int lessalphaif(int col, bool b1, bool b2) { + color_t lessalphaif(color_t col, bool b1, bool b2) { if(b1) col = lessalpha(col, 2); if(b2) col = lessalpha(col, 2); return col; @@ -1953,7 +1953,7 @@ namespace linepatterns { struct { int id; const char *lpname; - unsigned int color; + color_t color; } patterns[] = { {patTriNet, "triangle grid: not rings", 0xFFFFFF00}, @@ -1987,17 +1987,17 @@ namespace linepatterns { return false; } - void setColor(ePattern id, int col) { + void setColor(ePattern id, color_t col) { for(int k=0; patterns[k].lpname; k++) if(patterns[k].id == id) patterns[k].color = col; } - void switchAlpha(ePattern id, int col) { + void switchAlpha(ePattern id, color_t col) { for(int k=0; patterns[k].lpname; k++) if(patterns[k].id == id) patterns[k].color ^= col; } - void queuelinef(const hyperpoint& h1, const hyperpoint& h2, int col, int par) { + void queuelinef(const hyperpoint& h1, const hyperpoint& h2, color_t col, int par) { if(!elliptic) queueline(h1, h2, col, par); else { @@ -2012,7 +2012,7 @@ namespace linepatterns { } } - void drawPattern(int id, int col, cell *c, const transmatrix& V) { + void drawPattern(int id, color_t col, cell *c, const transmatrix& V) { switch(id) { @@ -2212,7 +2212,7 @@ namespace linepatterns { transmatrix& V = it->second; for(int k=0; patterns[k].lpname; k++) { - int col = patterns[k].color; + color_t col = patterns[k].color; if(!(col & 255)) continue; int id = patterns[k].id; diff --git a/patterngen.cpp b/patterngen.cpp index 3f4dfd09..5d8c78e0 100644 --- a/patterngen.cpp +++ b/patterngen.cpp @@ -14,7 +14,7 @@ int style = 3; struct state50 { bool polarity1; bool polarity2; - int color, color2, wc2; + color_t color, color2, wc2; }; void progress(cell *c, state50 s); @@ -173,7 +173,7 @@ void patternFiftyAt(cell *c) { int sgn = s.polarity2 ? 1 : -1; int sgn1 = s.polarity1 ? 1 : -1; - int col2 = s.color2, sw = s.wc2; + color_t col2 = s.color2, sw = s.wc2; while(col2 != 7-s.color) { sw += (s.polarity1?1:-1); sw %= 7; diff --git a/polygons.cpp b/polygons.cpp index 08d3ca83..4ce795fc 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -70,7 +70,7 @@ bool first; bool fatborder; -int poly_outline; +color_t poly_outline; // #define STLSORT @@ -81,15 +81,7 @@ extern long double polydata[]; hpcshape *last = NULL; -vector ptds; - -polytodraw& lastptd() { return ptds[isize(ptds)-1]; } - -polytodraw& nextptd() { ptds.resize(isize(ptds)+1); return lastptd(); } - -bool ptdsort(const polytodraw& p1, const polytodraw& p2) { - return p1.prio < p2.prio; - } +vector> ptds; void hpcpush(hyperpoint h) { if(sphere) h = mid(h,h); @@ -131,7 +123,6 @@ SDL_Surface *aux; #endif #if CAP_POLY -vector ptds2; #define POLYMAX 60000 vector> glcoords, ourshape; @@ -315,17 +306,17 @@ void addpoly(const transmatrix& V, const vector &tab, int ofs, int cnt } #if CAP_SDLGFX -void aapolylineColor(SDL_Surface *s, int*x, int *y, int polyi, int col) { +void aapolylineColor(SDL_Surface *s, int*x, int *y, int polyi, color_t col) { for(int i=1; i spx(px, px + polyi); std::vector spy(py, py + polyi); filledPolygonColor(s, spx.data(), spy.data(), polyi, col); @@ -333,7 +324,7 @@ void filledPolygonColorI(SDL_Surface *s, int* px, int *py, int polyi, int col) { #endif #if CAP_TEXTURE -void drawTexturedTriangle(SDL_Surface *s, int *px, int *py, glvertex *tv, int col) { +void drawTexturedTriangle(SDL_Surface *s, int *px, int *py, glvertex *tv, color_t col) { transmatrix source = {{{ld(px[0]),ld(px[1]),ld(px[2])}, {ld(py[0]),ld(py[1]),ld(py[2])}, {1,1,1}}}; transmatrix target = {{{tv[0][0],tv[1][0],tv[2][0]}, {tv[0][1],tv[1][1],tv[2][1]}, {1,1,1}}}; transmatrix isource = inverse(source); @@ -350,7 +341,7 @@ void drawTexturedTriangle(SDL_Surface *s, int *px, int *py, glvertex *tv, int co int tw = texture::config.data.twidth; int x = int(ht[0] * tw) & (tw-1); int y = int(ht[1] * tw) & (tw-1); - int c = texture::config.data.texture_pixels[y * tw + x]; + color_t c = texture::config.data.texture_pixels[y * tw + x]; auto& pix = qpixel(s, mx, my); for(int p=0; p<3; p++) { int alpha = part(c, 3) * part(col, 0); @@ -389,7 +380,8 @@ void glapplymatrix(const transmatrix& V) { #endif #endif -void gldraw(const transmatrix& V, const vector& v, int ps, int pq, int col, int outline, int flags, textureinfo *tinf) { +void dqi_poly::gldraw() { + auto& v = *tab; if(tinf) { #if CAP_TEXTURE @@ -404,32 +396,32 @@ void gldraw(const transmatrix& V, const vector& v, int ps, int pq, int #if !ISANDROID glhr::vertices(v); #else - if(glhr::current_vertices != &v[ps]) { - glhr::current_vertices = &v[ps]; - glVertexAttribPointer(glhr::aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(glvertex), &v[ps]); + if(glhr::current_vertices != &v[offset]) { + glhr::current_vertices = &v[offset]; + glVertexAttribPointer(glhr::aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(glvertex), &v[offset]); // glVertexPointer(3, GL_FLOAT, sizeof(glvertex), &v[ps]); // glhr::vertices(v); } - ps = 0; + offset = 0; #endif } for(int ed = stereo::active() ? -1 : 0; ed<2; ed+=2) { if(ed) stereo::set_projection(ed), stereo::set_viewport(ed); - bool draw = col; + bool draw = color; if(using_perspective) glapplymatrix(V); if(draw) { if((flags & POLY_VCONVEX) && MINIMIZE_GL_CALLS) { glhr::vertices(v); - glhr::color2(col); - glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, ps, pq); + glhr::color2(color); + glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, offset, cnt); } else if((flags & POLY_CCONVEX) && MINIMIZE_GL_CALLS) { glhr::vertices(v); - glhr::color2(col); - glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, ps-1, pq+1); + glhr::color2(color); + glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, offset-1, cnt+1); } else { glEnable(GL_STENCIL_TEST); @@ -439,10 +431,10 @@ void gldraw(const transmatrix& V, const vector& v, int ps, int pq, int glStencilOp( GL_INVERT, GL_INVERT, GL_INVERT); glStencilFunc( GL_ALWAYS, 0x1, 0x1 ); glhr::color2(0xFFFFFFFF); - glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, ps, pq); + glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, offset, cnt); stereo::set_mask(ed); - glhr::color2(col); + glhr::color2(color); glhr::set_depthtest(model_needs_depth()); if(flags & POLY_INVERSE) { @@ -466,7 +458,7 @@ void gldraw(const transmatrix& V, const vector& v, int ps, int pq, int else { glStencilOp( GL_ZERO, GL_ZERO, GL_ZERO); glStencilFunc( GL_EQUAL, 1, 1); - glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, ps, pq); + glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, offset, cnt); } glDisable(GL_STENCIL_TEST); @@ -476,7 +468,7 @@ void gldraw(const transmatrix& V, const vector& v, int ps, int pq, int if(outline) { glhr::color2(outline); glhr::set_depthtest(model_needs_depth()); - glDrawArrays(GL_LINE_STRIP, ps, pq); + glDrawArrays(GL_LINE_STRIP, offset, cnt); } } @@ -606,11 +598,7 @@ void fixMercator(bool tinf) { } -unsigned char& part(int& col, int i) { - unsigned char* c = (unsigned char*) &col; return c[i]; - } - -unsigned char& part(unsigned& col, int i) { +unsigned char& part(color_t& col, int i) { unsigned char* c = (unsigned char*) &col; return c[i]; } @@ -620,27 +608,26 @@ ld glhypot2(glvertex a, glvertex b) { return (a[0]-b[0]) * (a[0]-b[0]) + (a[1]-b[1]) * (a[1]-b[1]) + (a[2]-b[2]) * (a[2]-b[2]); } -void drawpolyline(polytodraw& p) { - auto& pp = p.u.poly; +void dqi_poly::draw() { if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) { bool any = false; - for(int i=0; i 0) any = true; } if(!any) return; } - if(sphere && pp.tinf && pp.cnt > 3) { - int i = pp.cnt; - pp.cnt = 3; + if(sphere && tinf && cnt > 3) { + int i = cnt; + cnt = 3; for(int j=0; j 0) continue; ld c1 = h1[1], c2 = -h2[1]; if(c1 < 0) c1 = -c1, c2 = -c2; @@ -704,54 +691,55 @@ void drawpolyline(polytodraw& p) { } } vector tv; - if(pp.tinf) { - for(int i=0; itvertices[pp.offset+i]); - swap(pp.tinf->tvertices, tv); + if(tinf) { + for(int i=0; itvertices[offset+i]); + swap(tinf->tvertices, tv); } dynamicval d1(pmodel, mdUnchanged); - dynamicval d2(pp.V, Id); - dynamicval d3(pp.offset, 0); - dynamicval d4(pp.tab, pp.tab); + dynamicval d2(V, Id); + dynamicval d3(offset, 0); + dynamicval d4(tab, tab); for(int j=0; j d5(pp.cnt, isize(phases[j])); - pp.tab = &phases[j]; - drawpolyline(p); + dynamicval d5(cnt, isize(phases[j])); + tab = &phases[j]; + draw(); } - if(pp.tinf) swap(pp.tinf->tvertices, tv); + if(tinf) swap(tinf->tvertices, tv); return; } - if(spherespecial && p.prio == PPR::MOBILE_ARROW) { + if(spherespecial && prio == PPR::MOBILE_ARROW) { if(spherephase == 0) return; dynamicval ss(spherespecial, 0); - drawpolyline(p); + draw(); return; } #if CAP_GL if(vid.usingGL && using_perspective) { - glLineWidth(linewidthat(tC0(pp.V), pp.linewidth, pp.flags)); - gldraw(pp.V, *pp.tab, pp.offset, pp.cnt, p.col, pp.outline, pp.flags &~ POLY_INVERSE, pp.tinf); + glLineWidth(linewidthat(tC0(V), linewidth, flags)); + flags &= ~POLY_INVERSE; + gldraw(); return; } #endif glcoords.clear(); - poly_flags = pp.flags; + poly_flags = flags; double d = 0, curradius = 0; if(sphere) { - d = det(pp.V); + d = det(V); curradius = pow(abs(d), 1/3.); } - /* pp.outline = 0x80808080; - p.col = 0; */ + /* outline = 0x80808080; + color = 0; */ last_infront = false; - addpoly(pp.V, *pp.tab, pp.offset, pp.cnt); + addpoly(V, *tab, offset, cnt); if(!(sphere && vid.alpha < .9)) for(int i=1; i 0 || (sphere && equi)) && !(poly_flags & POLY_ISSIDE)) { - if(!pp.tinf) { + if(!tinf) { hyperpoint hscr; - hyperpoint h1 = pp.V * intester; + hyperpoint h1 = V * intester; if(is_behind(h1)) { if(sphere) { for(int i=0; i<3; i++) h1[i] = -h1[i]; @@ -824,7 +812,7 @@ void drawpolyline(polytodraw& p) { if(poly_flags & POLY_CENTERIN) { poly_flags |= POLY_INVERSE; /* nofill = true; - pp.outline = (pp.flags & POLY_CENTERIN) ? 0x00FF00FF : 0xFF0000FF; + outline = (flags & POLY_CENTERIN) ? 0x00FF00FF : 0xFF0000FF; addpoint(hscr); */ } } @@ -866,7 +854,7 @@ void drawpolyline(polytodraw& p) { } if(equi && (poly_flags & POLY_INVERSE)) { - if(abs(zlevel(pp.V * C0) - 1) < 1e-6 && !pp.tinf) { + if(abs(zlevel(V * C0) - 1) < 1e-6 && !tinf) { // we should fill the other side ld h = atan2(glcoords[0][0], glcoords[0][1]); for(int i=0; i<=360; i++) { @@ -885,20 +873,30 @@ void drawpolyline(polytodraw& p) { #if CAP_GL if(vid.usingGL) { // if(pmodel == 0) for(int i=0; i tv; - for(int i=0; itvertices[pp.offset+i]); - swap(pp.tinf->tvertices, tv); - gldraw(Id, glcoords, 0, isize(glcoords), p.col, pp.outline, poly_flags, pp.tinf); - swap(pp.tinf->tvertices, tv); + for(int i=0; itvertices[offset+i]); + swap(tinf->tvertices, tv); + V = Id; + tab = &glcoords; + offset = 0; + cnt = isize(glcoords); + gldraw(); + swap(tinf->tvertices, tv); + } + else { + V = Id; + tab = &glcoords; + offset = 0; + cnt = isize(glcoords); + if(nofill) color = 0, tinf = NULL; + gldraw(); } - else - gldraw(Id, glcoords, 0, isize(glcoords), nofill ? 0 : p.col, pp.outline, poly_flags, nofill ? NULL : pp.tinf); continue; } #endif @@ -906,9 +904,9 @@ void drawpolyline(polytodraw& p) { #if CAP_SVG==1 if(svg::in) { coords_to_poly(); - int col = p.col; + color_t col = color; if(poly_flags & POLY_INVERSE) col = 0; - svg::polygon(polyx, polyy, polyi, col, pp.outline, pp.linewidth); + svg::polygon(polyx, polyy, polyi, col, outline, linewidth); continue; } #endif @@ -916,15 +914,15 @@ void drawpolyline(polytodraw& p) { coords_to_poly(); #if CAP_XGD==1 - gdpush(1); gdpush(p.col); gdpush(pp.outline); gdpush(polyi); + gdpush(1); gdpush(color); gdpush(outline); gdpush(polyi); for(int i=0; itvertices[pp.offset + i], p.col); + drawTexturedTriangle(s, polyx+i, polyy+i, &tinf->tvertices[offset + i], color); #endif } else if(poly_flags & POLY_INVERSE) { @@ -936,17 +934,17 @@ void drawpolyline(polytodraw& p) { polyx[i] = 0; polyy[i] = vid.yres; i++; polyx[i] = 0; polyy[i] = 0; i++; } - filledPolygonColorI(s, polyx, polyy, polyi+5, p.col); + filledPolygonColorI(s, polyx, polyy, polyi+5, color); } else - filledPolygonColorI(s, polyx, polyy, polyi, p.col); + filledPolygonColorI(s, polyx, polyy, polyi, color); - if(stereo::active()) filledPolygonColorI(aux, polyxr, polyy, polyi, p.col); + if(stereo::active()) filledPolygonColorI(aux, polyxr, polyy, polyi, color); - // part(pp.outline, 0) = part(pp.outline, 0) * linewidthat(tC0(pp.V), pp.minwidth); + // part(outline, 0) = part(outline, 0) * linewidthat(tC0(V), minwidth); - ((vid.antialias & AA_NOGL) ?aapolylineColor:polylineColor)(s, polyx, polyy, polyi, pp.outline); - if(stereo::active()) aapolylineColor(aux, polyxr, polyy, polyi, pp.outline); + ((vid.antialias & AA_NOGL) ?aapolylineColor:polylineColor)(s, polyx, polyy, polyi, outline); + if(stereo::active()) aapolylineColor(aux, polyxr, polyy, polyi, outline); if(vid.xres >= 2000 || fatborder) { int xmi = 3000, xma = -3000; @@ -954,7 +952,7 @@ void drawpolyline(polytodraw& p) { if(xma > xmi + 20) for(int x=-1; x<2; x++) for(int y=-1; y<=2; y++) if(x*x+y*y == 1) { for(int t=0; t& t, int fillcol, int linecol, int lev) { +void prettypoly(const vector& t, color_t fillcol, color_t linecol, int lev) { prettylinepoints.clear(); prettypoint(t[0]); for(int i=0; i curvedata; int curvestart = 0; bool keep_curvedata = false; -hookset *hooks_specialdraw; - -void drawqueueitem(polytodraw& ptd) { - // if(ptd.prio == 46) printf("eye size %d\n", polyi); - - switch(ptd.kind) { - case pkLink: - #if CAP_SVG - svg::link = ptd.u.link.link; - #endif - break; - - case pkSpecial: - callhooks(hooks_specialdraw, ptd); - break; - - case pkResetModel: - pmodel = eModel(ptd.col); - stereo::set_projection(0); - break; - - case pkPoly: - drawpolyline(ptd); - break; - - case pkLine: { - dynamicval d(vid.linewidth, ptd.u.line.width); - prettyline(ptd.u.line.H1, ptd.u.line.H2, ptd.col, ptd.u.line.prf); - break; - } - - case pkString: { - qchr& q(ptd.u.chr); - #if ISMOBILE==0 - if(svg::in) - svg::text(q.x, q.y, q.size, q.str, q.frame, ptd.col, q.align); - else { - int fr = q.frame & 255; - displayfrSP(q.x, q.y, q.shift, fr, q.size, q.str, ptd.col, q.align, q.frame >> 8); - } - #else - displayfr(q.x, q.y, q.frame, q.size, q.str, ptd.col, q.align); - #endif - break; - } - - case pkCircle: { - #if ISMOBILE==0 - if(svg::in) - svg::circle(ptd.u.cir.x, ptd.u.cir.y, ptd.u.cir.size, ptd.col); - else - #endif - drawCircle(ptd.u.cir.x, ptd.u.cir.y, ptd.u.cir.size, ptd.col); - break; - } - - case pkShape: ; - } +void queuereset(eModel m, PPR prio) { + queueaction(prio, [m] () { pmodel = m; stereo::set_projection(0); }); } +void dqi_line::draw() { + dynamicval d(vid.linewidth, width); + prettyline(H1, H2, color, prf); + } + +void dqi_string::draw() { + #if ISMOBILE==0 + if(svg::in) + svg::text(x, y, size, str, frame, color, align); + else { + int fr = frame & 255; + displayfrSP(x, y, shift, fr, size, str, color, align, frame >> 8); + } + #else + displayfr(x, y, frame, size, str, color, align); + #endif + } + +void dqi_circle::draw() { + #if ISMOBILE==0 + if(svg::in) { + if(!color) return; + svg::circle(x, y, size, color); + } + else + #endif + drawCircle(x, y, size, color); + } + void initquickqueue() { ptds.clear(); poly_outline = OUTLINE_NONE; @@ -1085,7 +1054,7 @@ void initquickqueue() { void sortquickqueue() { for(int i=1; iprio < ptds[i-1]->prio) { swap(ptds[i], ptds[i-1]); i--; } @@ -1096,7 +1065,7 @@ void quickqueue() { spherespecial = 0; stereo::set_projection(0); int siz = isize(ptds); setcameraangle(false); - for(int i=0; idraw(); ptds.clear(); } @@ -1109,33 +1078,41 @@ ld backbrightness = .25; purehookset hook_drawqueue; -void drawqueue() { - callhooks(hook_drawqueue); +constexpr int PMAX = int(PPR::MAX); +int qp[PMAX], qp0[PMAX]; - int siz = isize(ptds); +void drawqueueitem::draw_darker() { + unsigned c = color; + int alpha = color & 255; + if(vid.alpha <= 1) { + color = 0; + } + else if(alpha == 255) + color = (gradient(backcolor, c>>8, 0, backbrightness, 1)<<8) | 0xFF; + else color = color - alpha + int(backbrightness * alpha); + draw(); + color = c; + } - setcameraangle(true); +void dqi_poly::draw_back() { draw_darker(); } + +void dqi_line::draw_back() { draw_darker(); } + +void dqi_boundary_circle::draw_pre() { + draw(), color = 0; + } + +void sort_drawqueue() { -#if CAP_GL - if(vid.usingGL) - glClear(GL_STENCIL_BUFFER_BIT); -#endif - - profile_start(3); -#ifdef STLSORT - sort(ptds.begin(), ptds.end(), ptdsort); - -#else - - constexpr int PMAX = int(PPR::MAX); - int qp[PMAX], qp0[PMAX]; for(int a=0; aprio - PPR::ZERO; if(pd < 0 || pd >= PMAX) { - printf("Illegal priority %d of kind %d\n", pd, ptds[i].kind); - ptds[i].prio = PPR(rand() % int(PPR::MAX)); + printf("Illegal priority %d\n", pd); + ptds[i]->prio = PPR(rand() % int(PPR::MAX)); } qp[pd]++; } @@ -1145,20 +1122,48 @@ void drawqueue() { int b = qp[a]; qp0[a] = qp[a] = total; total += b; } - + + vector> ptds2; ptds2.resize(siz); - for(int i = 0; iprio)]++] = move(ptds[i]); + swap(ptds, ptds2); + } + +void reverse_priority(PPR p) { + reverse(ptds.begin()+qp0[int(p)], ptds.begin()+qp[int(p)]); + } + +void reverse_side_priorities() { + for(PPR p: {PPR::REDWALLs, PPR::REDWALLs2, PPR::REDWALLs3, PPR::WALL3s, + PPR::LAKEWALL, PPR::INLAKEWALL, PPR::BELOWBOTTOM}) + reverse_priority(p); + } + +void drawqueue() { + callhooks(hook_drawqueue); + + setcameraangle(true); + +#if CAP_GL + if(vid.usingGL) + glClear(GL_STENCIL_BUFFER_BIT); +#endif + + profile_start(3); + + sort_drawqueue(); for(PPR p: {PPR::REDWALLs, PPR::REDWALLs2, PPR::REDWALLs3, PPR::WALL3s, PPR::LAKEWALL, PPR::INLAKEWALL, PPR::BELOWBOTTOM}) - sort(&ptds2[qp0[int(p)]], &ptds2[qp[int(p)]], - [] (polytodraw* p1, polytodraw* p2) { - return xintval(p1->u.poly.V * xpush0(.1)) - < xintval(p2->u.poly.V * xpush0(.1)); + sort(&ptds[qp0[int(p)]], &ptds[qp[int(p)]], + [] (unique_ptr& p1, unique_ptr& p2) { + auto ap1 = (dqi_poly&) *p1; + auto ap2 = (dqi_poly&) *p2; + return xintval(ap1.V * xpush0(.1)) + < xintval(ap2.V * xpush0(.1)); }); -#endif profile_stop(3); #if CAP_SDL @@ -1178,12 +1183,6 @@ void drawqueue() { } #endif - #ifdef STLSORT - #define GET_PTD(i) polytodraw& ptd (ptds[i]); - #else - #define GET_PTD(i) polytodraw& ptd (*ptds2[i]); - #endif - spherespecial = 0; spherephase = 0; stereo::set_projection(0); @@ -1192,49 +1191,21 @@ void drawqueue() { if(sphere && pmodel == 0) { // in SVG, draw boundary circle first - if(svg::in) for(int i=0; idraw_pre(); spherespecial = sphereflipped() ? 1 : -1; stereo::set_projection(0); - #ifndef STLSORT - for(PPR p: {PPR::REDWALLs, PPR::REDWALLs2, PPR::REDWALLs3, PPR::WALL3s, - PPR::LAKEWALL, PPR::INLAKEWALL, PPR::BELOWBOTTOM}) - reverse(&ptds2[qp0[int(p)]], &ptds2[qp[int(p)]]); - #endif - for(int i=siz-1; i>=0; i--) { - GET_PTD(i); - if(ptd.kind == pkPoly || ptd.kind == pkLine) { - unsigned c = ptd.col; - int alpha = ptd.col & 255; - if(vid.alpha <= 1) { - ptd.col = 0; - } - else if(alpha == 255) - ptd.col = (gradient(backcolor, c>>8, 0, backbrightness, 1)<<8) | 0xFF; - else ptd.col = ptd.col - alpha + int(backbrightness * alpha); - drawqueueitem(ptd); - ptd.col = c; - } - } - #ifndef STLSORT - for(PPR p: {PPR::REDWALLs, PPR::REDWALLs2, PPR::REDWALLs3, PPR::WALL3s, - PPR::LAKEWALL, PPR::INLAKEWALL, PPR::BELOWBOTTOM}) - reverse(&ptds2[qp0[int(p)]], &ptds2[qp[int(p)]]); - #endif + reverse_side_priorities(); + for(int i=ptds.size()-1; i>=0; i--) + ptds[i]->draw_back(); + reverse_side_priorities(); spherespecial *= -1; spherephase = 1; stereo::set_projection(0); } - for(int i=0; idraw(); #if CAP_GL if(vid.usingGL) @@ -1369,7 +1340,7 @@ struct usershapelayer { vector list; bool sym; int rots; - int color; + color_t color; hyperpoint shift, spin; hpcshape sh; }; @@ -2416,15 +2387,21 @@ void initShape(int sg, int id) { } } -void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio) { +template T& queuea(PPR prio, U... u) { + ptds.push_back(unique_ptr(new T (u...))); + ptds.back()->prio = prio; + return (T&) *ptds.back(); + } + +dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, PPR prio) { if(prio == PPR::DEFAULT) prio = h.prio; - polytodraw& ptd = nextptd(); - ptd.kind = pkPoly; - ptd.u.poly.V = V; - ptd.u.poly.offset = h.s; - ptd.u.poly.cnt = h.e-h.s; - ptd.u.poly.tab = &ourshape; + auto& ptd = queuea (prio); + + ptd.V = V; + ptd.offset = h.s; + ptd.cnt = h.e-h.s; + ptd.tab = &ourshape; if(cblind) { // protanopia /* int r = (56 * part(col,3) + 43 * part(col,2)) / 100; @@ -2439,115 +2416,99 @@ void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio) { part(col,1) = b; */ part(col,2) = part(col,3) = (part(col,2) * 2 + part(col,3) + 1)/3; } - ptd.col = (darkened(col >> 8) << 8) + (col & 0xFF); - ptd.prio = prio; - ptd.u.poly.outline = poly_outline; - ptd.u.poly.linewidth = vid.linewidth; - ptd.u.poly.flags = h.flags; - ptd.u.poly.tinf = NULL; + ptd.color = (darkened(col >> 8) << 8) + (col & 0xFF); + ptd.outline = poly_outline; + ptd.linewidth = vid.linewidth; + ptd.flags = h.flags; + ptd.tinf = NULL; + return ptd; } void addfloats(vector& v, hyperpoint h) { for(int i=0; i<3; i++) v.push_back(h[i]); } -void queuereset(eModel md, PPR prio) { - polytodraw& ptd = nextptd(); - ptd.kind = pkResetModel; - ptd.col = md; - ptd.prio = prio; +dqi_poly& queuetable(const transmatrix& V, const vector& f, int cnt, color_t linecol, color_t fillcol, PPR prio) { + + auto& ptd = queuea (prio); + + ptd.V = V; + ptd.tab = &f; + ptd.offset = 0; + ptd.cnt = cnt; + ptd.color = fillcol; + ptd.outline = linecol; + ptd.linewidth = vid.linewidth; + ptd.flags = 0; + ptd.tinf = NULL; + return ptd; } -void queuetable(const transmatrix& V, const vector& f, int cnt, int linecol, int fillcol, PPR prio) { - polytodraw& ptd = nextptd(); - ptd.kind = pkPoly; - ptd.u.poly.V = V; - ptd.u.poly.tab = &f; - ptd.u.poly.offset = 0; - ptd.u.poly.cnt = cnt; - ptd.col = fillcol; - ptd.prio = prio; - ptd.u.poly.outline = linecol; - ptd.u.poly.linewidth = vid.linewidth; - ptd.u.poly.flags = 0; - ptd.u.poly.tinf = NULL; +dqi_poly& queuepoly(const transmatrix& V, const hpcshape& h, color_t col) { + return queuepolyat(V,h,col,h.prio); } -void queuepoly(const transmatrix& V, const hpcshape& h, int col) { - queuepolyat(V,h,col,h.prio); - } - -void queuepolyb(const transmatrix& V, const hpcshape& h, int col, int b) { - queuepolyat(V,h,col,PPR(h.prio+b)); +void queuepolyb(const transmatrix& V, const hpcshape& h, color_t col, int b) { + queuepolyat(V,h,col,h.prio+b); } void curvepoint(const hyperpoint& H1) { curvedata.push_back(glhr::pointtogl(H1)); } -void queuecurve(int linecol, int fillcol, PPR prio) { - queuetable(Id, curvedata, isize(curvedata)-curvestart, linecol, fillcol, prio); - lastptd().u.poly.offset = curvestart; +dqi_poly& queuecurve(color_t linecol, color_t fillcol, PPR prio) { + auto &res = queuetable(Id, curvedata, isize(curvedata)-curvestart, linecol, fillcol, prio); + res.offset = curvestart; curvestart = isize(curvedata); + return res; } -void queuelink(const string *link, PPR prio) { - polytodraw& ptd = nextptd(); - ptd.kind = pkLink; - ptd.prio = prio; - ptd.u.link.link = link; +dqi_action& queueaction(PPR prio, const reaction_t& action) { + return queuea (prio, action); } -void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf, PPR prio) { - polytodraw& ptd = nextptd(); - ptd.kind = pkLine; - ptd.u.line.H1 = H1; - ptd.u.line.H2 = H2; - ptd.u.line.prf = prf; - ptd.u.line.width = (linewidthat(H1, vid.linewidth, 0) + linewidthat(H2, vid.linewidth, 0)) / 2; - ptd.col = (darkened(col >> 8) << 8) + (col & 0xFF); - ptd.prio = prio; +dqi_line& queueline(const hyperpoint& H1, const hyperpoint& H2, color_t col, int prf, PPR prio) { + auto& ptd = queuea (prio); + + ptd.H1 = H1; + ptd.H2 = H2; + ptd.prf = prf; + ptd.width = (linewidthat(H1, vid.linewidth, 0) + linewidthat(H2, vid.linewidth, 0)) / 2; + ptd.color = (darkened(col >> 8) << 8) + (col & 0xFF); + + return ptd; } -void queuestr(int x, int y, int shift, int size, string str, int col, int frame, int align) { - polytodraw& ptd = nextptd(); - ptd.kind = pkString; - ptd.u.chr.x = x; - ptd.u.chr.y = y; - int ss = (int) str.size(); if(ss>=MAXQCHR) ss=MAXQCHR-1; - {for(int i=0; i (PPR::TEXT); + ptd.x = x; + ptd.y = y; + ptd.str = str; + ptd.align = align; + ptd.shift = shift; + ptd.size = size; + ptd.color = darkened(col); + ptd.frame = frame ? ((poly_outline & ~ 255)+frame) : 0; } -void queuechr(int x, int y, int shift, int size, char chr, int col, int frame, int align) { - polytodraw& ptd = nextptd(); - ptd.kind = pkString; - ptd.u.chr.x = x; - ptd.u.chr.y = y; - ptd.u.chr.str[0] = chr; - ptd.u.chr.str[1] = 0; - ptd.u.chr.shift = shift; - ptd.u.chr.size = size; - ptd.u.chr.align = align; - ptd.col = col; - ptd.u.chr.frame = frame ? (poly_outline & ~ 255) : 0; - ptd.prio = PPR::TEXT; +void queuechr(int x, int y, int shift, int size, char chr, color_t col, int frame, int align) { + auto& ptd = queuea (PPR::TEXT); + ptd.x = x; + ptd.y = y; + ptd.str = chr; + ptd.shift = shift; + ptd.size = size; + ptd.align = align; + ptd.color = col; + ptd.frame = frame ? (poly_outline & ~ 255) : 0; } -void queuecircle(int x, int y, int size, int color, PPR prio = PPR::CIRCLE) { - polytodraw& ptd = nextptd(); - ptd.kind = pkCircle; - ptd.u.cir.x = x; - ptd.u.cir.y = y; - ptd.u.cir.size = size; - ptd.u.cir.boundary = false; - ptd.col = color; - ptd.prio = prio; +void queuecircle(int x, int y, int size, color_t color, PPR prio = PPR::CIRCLE, bool boundary = false) { + auto& ptd = boundary ? (dqi_circle&) queuea(prio) : queuea(prio); + ptd.x = x; + ptd.y = y; + ptd.size = size; + ptd.color = color; } void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) { @@ -2559,35 +2520,35 @@ void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) { // EYETODO sc = vid.eye * vid.radius * hscr[2]; } -void queuechr(const hyperpoint& h, int size, char chr, int col, int frame) { +void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame) { int xc, yc, sc; getcoord0(h, xc, yc, sc); queuechr(xc, yc, sc, size, chr, col, frame); } -void queuechr(const transmatrix& V, double size, char chr, int col, int frame) { +void queuechr(const transmatrix& V, double size, char chr, color_t col, int frame) { int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc); int xs, ys, ss; getcoord0(V * xpush0(.5), xs, ys, ss); queuechr(xc, yc, sc, int(sqrt(squar(xc-xs)+squar(yc-ys)) * scalefactor * size), chr, col, frame); } -void queuestr(const hyperpoint& h, int size, const string& chr, int col, int frame) { +void queuestr(const hyperpoint& h, int size, const string& chr, color_t col, int frame) { int xc, yc, sc; getcoord0(h, xc, yc, sc); queuestr(xc, yc, sc, size, chr, col, frame); } -void queuestr(const transmatrix& V, double size, const string& chr, int col, int frame, int align) { +void queuestr(const transmatrix& V, double size, const string& chr, color_t col, int frame, int align) { int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc); int xs, ys, ss; getcoord0(V * xpush0(.5), xs, ys, ss); queuestr(xc, yc, sc, int(sqrt(squar(xc-xs)+squar(yc-ys)) * size), chr, col, frame, align); } -void queuecircle(const transmatrix& V, double size, int col) { +void queuecircle(const transmatrix& V, double size, color_t col) { int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc); int xs, ys, ss; getcoord0(V * xpush0(.5), xs, ys, ss); queuecircle(xc, yc, int(sqrt(squar(xc-xs)+squar(yc-ys)) * size), col); } -void queuemarkerat(const transmatrix& V, int col) { +void queuemarkerat(const transmatrix& V, color_t col) { queuepolyat(V, shTriangle, col, PPR::LINE); } diff --git a/renderbuffer.cpp b/renderbuffer.cpp index d323008b..7135888c 100644 --- a/renderbuffer.cpp +++ b/renderbuffer.cpp @@ -184,7 +184,7 @@ renderbuffer::~renderbuffer() { #endif } -void renderbuffer::clear(int col) { +void renderbuffer::clear(color_t col) { #if CAP_GL if(FramebufferName) { setGLProjection(0); diff --git a/rogueviz-banachtarski.cpp b/rogueviz-banachtarski.cpp index c4c61b66..5b772267 100644 --- a/rogueviz-banachtarski.cpp +++ b/rogueviz-banachtarski.cpp @@ -288,11 +288,6 @@ ld alphaof(hyperpoint h) { return atan2(h[1], h[0]); } -struct bantar_special { - polytodraw *actual; - ld xpos, ypos; - }; - #define ForInfos for(auto& cci: infos) void bantar_frame() { @@ -308,7 +303,7 @@ void bantar_frame() { calcparam(); stereo::set_projection(0); - vector subscr[4]; + vector> subscr[4]; compute_graphical_distance(); @@ -399,14 +394,14 @@ void bantar_frame() { subscr[i] = move(ptds); } - map>> xptds; + map>>> xptds; for(int i=0; i<4; i++) for(auto& p: subscr[i]) - xptds[int(p.prio)][i].push_back(p); + xptds[int(p->prio)][i].push_back(move(p)); for(auto& sm: xptds) for(auto& sm2: sm.second) { int i = sm2.first; ptds.clear(); - for(auto& p: sm2.second) ptds.push_back(p); + for(auto& p: sm2.second) ptds.push_back(move(p)); vid.scale = .5; vid.xposition = (!(i&2)) ? xdst : -xdst; diff --git a/rogueviz-kohonen.cpp b/rogueviz-kohonen.cpp index 77ea7ee3..9365ca21 100644 --- a/rogueviz-kohonen.cpp +++ b/rogueviz-kohonen.cpp @@ -6,7 +6,7 @@ namespace rogueviz { namespace kohonen { -int cols; +int columns; typedef vector kohvec; @@ -28,7 +28,7 @@ struct neuron { cell *where; double udist; int lpbak; - int col; + color_t col; int allsamples, drawn_samples, csample, bestsample, max_group_here; neuron() { drawn_samples = allsamples = bestsample = 0; max_group_here = max_group; } }; @@ -41,7 +41,7 @@ vector net; int neuronId(neuron& n) { return &n - &(net[0]); } -void alloc(kohvec& k) { k.resize(cols); } +void alloc(kohvec& k) { k.resize(columns); } bool neurons_indexed = false; @@ -53,7 +53,7 @@ vector whowon; void normalize() { alloc(weights); - for(int k=0; klandparam, pid) = part(vdata[net[i].bestsample].cp.color1, pid+1); + for(int i=0; ilandparam_color, pid) = part(vdata[net[i].bestsample].cp.color1, pid+1); + } } else { @@ -220,7 +221,7 @@ void coloring() { if(maxl-minl < 1e-3) maxl = minl+1e-3; for(int i=0; ilandparam, pid) = (255 * (listing[i] - minl)) / (maxl - minl); + part(net[i].where->landparam_color, pid) = (255 * (listing[i] - minl)) / (maxl - minl); } } } @@ -534,7 +535,7 @@ void step() { // nu *= exp(-t*(double)maxdist/perdist); // nu *= exp(-t/t2); nu *= exp(-sqr(d/sigma)); - for(int k=0; knet[k] += nu * (data[id].val[k] - n2->net[k]); } @@ -659,7 +660,7 @@ void sominit(int initto) { net[i].where->land = laCanvas; alloc(net[i].net); - for(int k=0; kallsamples) + ")\n"; - help += "parameters:"; for(int k=0; knet[k]); + help += "parameters:"; for(int k=0; knet[k]); help += ", u-matrix = " + fts(n->udist); help += "\n"; vector> v; @@ -731,7 +732,7 @@ void describe_cell(cell *c) { for(int i=0; i values; bool modified; }; @@ -751,7 +752,7 @@ namespace levelline { void create() { int xlalpha = part(default_edgetype.color, 0); - for(int i=0; i= '1' && uni <= '3') { int i = uni - '1'; whattodraw[i]++; - if(whattodraw[i] == cols) whattodraw[i] = -5; + if(whattodraw[i] == columns) whattodraw[i] = -5; coloring(); return true; } diff --git a/rogueviz.cpp b/rogueviz.cpp index 6249bd22..0989af2e 100644 --- a/rogueviz.cpp +++ b/rogueviz.cpp @@ -1056,14 +1056,14 @@ void queuedisk(const transmatrix& V, const colorpair& cp, bool legend, const str int p = poly_outline; poly_outline = OUTLINE_TRANS; queuepolyat(V, sh, 0x80, PPR::MONSTER_SHADOW); poly_outline = p; - if(info) queuelink(info, PPR::MONSTER_HEAD); + if(info) queueaction(PPR::MONSTER_HEAD, [info] () { svg::link = *info; }); queuepolyat(V1 = mscale(V, geom3::BODY), sh, cp.color1, PPR::MONSTER_HEAD); - if(info) queuelink(NULL, PPR::MONSTER_HEAD); + if(info) queueaction(PPR::MONSTER_HEAD, [info] () { svg::link = ""; }); } else { - if(info) queuelink(info, sh.prio); + if(info) queueaction(PPR::MONSTER_HEAD, [info] () { svg::link = *info; }); queuepoly(V1 = V, sh, cp.color1); - if(info) queuelink(NULL, sh.prio); + if(info) queueaction(PPR::MONSTER_HEAD, [info] () { svg::link = ""; }); } if(cp.shade == 't') queuepoly(V1, shDiskT, cp.color2); if(cp.shade == 's') queuepoly(V1, shDiskS, cp.color2); @@ -1116,7 +1116,7 @@ bool drawVertex(const transmatrix &V, cell *c, shmup::monster *m) { if(ei->lastdraw < frameid || multidraw) { ei->lastdraw = frameid; - int col = ei->type->color; + color_t col = ei->type->color; auto& alpha = part(col, 0); if(kind == kSAG) { @@ -1173,14 +1173,12 @@ bool drawVertex(const transmatrix &V, cell *c, shmup::monster *m) { hyperpoint l1 = T*tC0(spiral::at(1+ei->i)); for(int z=1; z<=prec; z++) { hyperpoint l2 = T*tC0(spiral::at(1+ei->i+(ei->j-ei->i) * z / (prec+.0))); - queueline(l1, l2, col, vid.linequality); + queueline(l1, l2, col, vid.linequality).prio = PPR::STRUCT0; l1 = l2; - lastptd().prio = PPR::STRUCT0; } } else { - queueline(h1, h2, col, 2 + vid.linequality); - lastptd().prio = PPR::STRUCT0; + queueline(h1, h2, col, 2 + vid.linequality).prio = PPR::STRUCT0; } } else { @@ -1233,9 +1231,10 @@ bool drawVertex(const transmatrix &V, cell *c, shmup::monster *m) { hyperpoint h = tC0(V * m->at); transmatrix V2 = rgpushxto0(h) * ypush(PURE ? .3 : .2); // todo-variation if(doshow && !behindsphere(V2)) { - if(vd.info) queuelink(vd.info, PPR::TEXT); + auto info = vd.info; + if(info) queueaction(PPR::MONSTER_HEAD, [info] () { svg::link = *info; }); queuestr(V2, (svg::in ? .28 : .2) * crossf / hcrossf, vd.name, backcolor ? 0x000000 : 0xFFFF00, svg::in ? 0 : 1); - if(vd.info) queuelink(NULL, PPR::TEXT); + if(info) queueaction(PPR::MONSTER_HEAD, [info] () { svg::link = ""; }); } } diff --git a/rogueviz.h b/rogueviz.h index 9738697f..210cc3d1 100644 --- a/rogueviz.h +++ b/rogueviz.h @@ -32,9 +32,9 @@ namespace rogueviz { }; struct colorpair { - int color1, color2; + color_t color1, color2; char shade; - colorpair(int col = 0xC0C0C0FF) { shade = 0; color1 = col; } + colorpair(color_t col = 0xC0C0C0FF) { shade = 0; color1 = col; } }; struct vertexdata { diff --git a/scores.cpp b/scores.cpp index 6df6b1dd..059983c4 100644 --- a/scores.cpp +++ b/scores.cpp @@ -202,7 +202,7 @@ void show() { for(int i=0; i>= 24; col &= 0xFF; return col / 255.0; } - bool invisible(int col) { return (col & 0xFF) == 0; } + bool invisible(color_t col) { return (col & 0xFF) == 0; } ld gamma = .5; @@ -71,7 +71,7 @@ namespace svg { return buf; } - void circle(int x, int y, int size, int col) { + void circle(int x, int y, int size, color_t col) { int ba = (backcolor << 8) + 0xFF; if(!invisible(col)) { if(vid.stretch == 1) @@ -83,19 +83,19 @@ namespace svg { } } - const string *link; + string link; void startstring() { - if(link) fprintf(f, "", link->c_str()); + if(link != "") fprintf(f, "", link.c_str()); } void stopstring() { - if(link) fprintf(f, ""); + if(link != "") fprintf(f, ""); } string font = "Times"; - void text(int x, int y, int size, const string& str, bool frame, int col, int align) { + void text(int x, int y, int size, const string& str, bool frame, color_t col, int align) { double dfc = (x - vid.xcenter) * (x - vid.xcenter) + (y - vid.ycenter) * (y - vid.ycenter); @@ -136,7 +136,7 @@ namespace svg { } } - void polygon(int *polyx, int *polyy, int polyi, int col, int outline, double linewidth) { + void polygon(int *polyx, int *polyy, int polyi, color_t col, int outline, double linewidth) { if(invisible(col) && invisible(outline)) return; if(polyi < 2) return; @@ -297,7 +297,7 @@ void saveHighQualityShot(const char *fname, const char *caption, int fade) { if(fade < 255) for(int y=0; ypid; if(m->parenttype == moPlayer) col = getcs().swordcolor; @@ -3249,7 +3249,7 @@ bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, trans default: if(m->inBoat) m->footphase = 0; - int col = minf[m->type].color; + color_t col = minf[m->type].color; if(m->type == moMimic) col = mirrorcolor(det(view) < 0); if(m->type == moSlime) { diff --git a/textures.cpp b/textures.cpp index 4446868f..e71d8bc5 100644 --- a/textures.cpp +++ b/textures.cpp @@ -49,7 +49,7 @@ template void scale_colorarray(int origdim, int targetdim, con while(tx < targetdim) { int fv = min(omissing, tmissing); - int c = src(ox); + color_t c = src(ox); for(int p=0; p<4; p++) partials[p] += part(c, p) * fv; omissing -= fv; tmissing -= fv; @@ -57,7 +57,7 @@ template void scale_colorarray(int origdim, int targetdim, con ox++; omissing = targetdim; } if(tmissing == 0) { - int target; + color_t target; for(int p=0; p<4; p++) { part(target, p) = partials[p] / origdim; partials[p] = 0; @@ -151,7 +151,7 @@ bool texture_data::readtexture(string tn) { // read png vector row_pointers(ty); - vector origpixels(ty * tx); + vector origpixels(ty * tx); for(int y = 0; y < ty; y++) row_pointers[y] = (png_bytep) & origpixels[y * tx]; @@ -163,7 +163,7 @@ bool texture_data::readtexture(string tn) { swap(part(origpixels[i], 0), part(origpixels[i], 2)); auto pix = [&] (int x, int y) { - if(x<0 || y<0 || x >= tx || y >= ty) return 0; + if(x<0 || y<0 || x >= tx || y >= ty) return (color_t) 0; return origpixels[y*tx + x]; }; @@ -316,7 +316,7 @@ void texture_config::mapTexture2(textureinfo& mi) { mapTextureTriangle(mi, t.v, t.tv); } -int texture_config::recolor(int col) { +int texture_config::recolor(color_t col) { if(color_alpha == 0) return col; for(int i=1; i<4; i++) part(col, i) = color_alpha + ((255-color_alpha) * part(col,i) + 127) / 255; @@ -329,15 +329,15 @@ bool using_aura() { return texture_aura && config.tstate == texture::tsActive; } -bool texture_config::apply(cell *c, const transmatrix &V, int col) { +bool texture_config::apply(cell *c, const transmatrix &V, color_t col) { if(config.tstate == tsOff || !correctly_mapped) return false; using namespace patterns; auto si = getpatterninfo0(c); if(config.tstate == tsAdjusting) { + dynamicval d(poly_outline, slave_color); draw_floorshape(c, V, shFullFloor, 0, PPR::LINE); - lastptd().u.poly.outline = slave_color; curvepoint(V * C0); for(int i=0; itype; i++) @@ -354,8 +354,8 @@ bool texture_config::apply(cell *c, const transmatrix &V, int col) { qfi.spin = applyPatterndir(c, si); if(grid_color) { + dynamicval d(poly_outline, grid_color); draw_floorshape(c, V, shFullFloor, 0, PPR::FLOOR); - lastptd().u.poly.outline = grid_color; } if(using_aura()) { @@ -472,8 +472,8 @@ void texture_config::finish_mapping() { void texture_config::saveFullTexture(string tn) { addMessage(XLAT("Saving full texture to %1...", tn)); - dynamicval dd(grid_color, 0); - dynamicval dm(mesh_color, 0); + dynamicval dd(grid_color, 0); + dynamicval dm(mesh_color, 0); dynamicval dx(vid.xposition, 0); dynamicval dy(vid.yposition, 0); dynamicval dvs(vid.scale, (pmodel == mdDisk && !euclid) ? 1 : vid.scale); @@ -1339,7 +1339,7 @@ void texture_data::undoLock() { undos.emplace_back(nullptr, 1); } -void filltriangle(const array& v, const array& p, int col, int lev) { +void filltriangle(const array& v, const array& p, color_t col, int lev) { int d2 = texture_distance(p[0], p[1]), d1 = texture_distance(p[0], p[2]), d0 = texture_distance(p[1], p[2]); @@ -1363,7 +1363,7 @@ void filltriangle(const array& v, const array& p, int c filltriangle(make_array(v[c], v[b], v3), make_array(p[c], p[b], p3), col, lev+1); } -void splitseg(const transmatrix& A, const array& angles, const array& h, const array& p, int col, int lev) { +void splitseg(const transmatrix& A, const array& angles, const array& h, const array& p, color_t col, int lev) { ld newangle = (angles[0] + angles[1]) / 2; hyperpoint nh = A * xspinpush0(newangle, penwidth); auto np = ptc(nh); @@ -1377,7 +1377,7 @@ void splitseg(const transmatrix& A, const array& angles, const array 0 && hdist(h1, h2) > penwidth / 3) { hyperpoint h3 = mid(h1, h2); drawLine(h1, h3, col, steps-1); diff --git a/yendor.cpp b/yendor.cpp index 822e919f..b3a63f70 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -702,7 +702,7 @@ namespace tactic { eLand l = landlist[i1]; int i0 = 56 + i * vf; - int col; + color_t col; int ch = chances(l);