1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 17:10:36 +00:00

fixed a crash when drawing inventory items while drawcell is also NULL; priority functions now use PPR_DEFAULT not -1; priority is passed as PPR not int

This commit is contained in:
Zeno Rogue 2018-08-28 13:45:11 +02:00
parent 7ff722ba59
commit 25c09154dc
5 changed files with 122 additions and 117 deletions

View File

@ -131,7 +131,7 @@ void generate_matrices_scale(ld scale, int noft) {
}
}
void bshape2(hpcshape& sh, int p, int shapeid, matrixlist& m) {
void bshape2(hpcshape& sh, PPR prio, int shapeid, matrixlist& m) {
auto& matrices = m.v;
int osym = m.o.sym;
int nsym = m.n.sym;
@ -175,7 +175,7 @@ void bshape2(hpcshape& sh, int p, int shapeid, matrixlist& m) {
rots /= rep;
}
bshape(sh, p);
bshape(sh, prio);
for(int r=0; r<nsym; r+=osym/rots) {
for(hyperpoint h: lst) {
@ -604,7 +604,7 @@ void set_floor(const transmatrix& spin, hpcshape& sh) {
qfi.usershape = -1;
}
void draw_shapevec(cell *c, const transmatrix& V, const vector<hpcshape> &shv, int col, int prio = -1) {
void draw_shapevec(cell *c, const transmatrix& V, const vector<hpcshape> &shv, int col, PPR prio = PPR_DEFAULT) {
if(!c) queuepolyat(V, shv[0], col, prio);
else if(gp::on) {
int id = gp::get_plainshape_id(c);
@ -636,11 +636,11 @@ void draw_shapevec(cell *c, const transmatrix& V, const vector<hpcshape> &shv, i
queuepolyat(V, shv[ctof(c)], col, prio);
}
void draw_floorshape(cell *c, const transmatrix& V, const floorshape &fsh, int col, int prio = -1) {
void draw_floorshape(cell *c, const transmatrix& V, const floorshape &fsh, int col, PPR prio = PPR_DEFAULT) {
draw_shapevec(c, V, fsh.b, col, prio);
}
void draw_qfi(cell *c, const transmatrix& V, int col, int prio = -1, vector<hpcshape> floorshape::* tab = &floorshape::b) {
void draw_qfi(cell *c, const transmatrix& V, int col, PPR prio = PPR_DEFAULT, vector<hpcshape> floorshape::* tab = &floorshape::b) {
if(qfi.shape)
queuepolyat(V * qfi.spin, *qfi.shape, col, prio);
else if(qfi.usershape >= 0) {
@ -649,7 +649,7 @@ void draw_qfi(cell *c, const transmatrix& V, int col, int prio = -1, vector<hpcs
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 == -1 ? PPR_FLOOR : prio);
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;

View File

@ -466,7 +466,7 @@ void animallegs(const transmatrix& V, eMonster mo, int col, double footphase) {
bool noshadow;
void ShadowV(const transmatrix& V, const hpcshape& bp, int prio) {
void ShadowV(const transmatrix& V, const hpcshape& bp, PPR prio) {
#if CAP_POLY
if(mmspatial) {
if(pmodel == mdHyperboloid || pmodel == mdBall || pmodel == mdHemisphere || noshadow)
@ -565,6 +565,10 @@ bool drawstar(cell *c) {
return true;
}
bool drawing_usershape_on(cell *c, mapeditor::eShapegroup sg) {
return c && c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == mapeditor::sgItem;
}
bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, bool hidden) {
char xch = iinf[it].glyph;
#if !CAP_POLY
@ -604,9 +608,6 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks,
if(c && conformal::includeHistory && conformal::infindhistory.count(c)) poly_outline = OUTLINE_DEAD;
if(c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == mapeditor::sgItem)
mapeditor::drawtrans = V;
if(!mmitem && it) return true;
else if(it == itSavedPrincess) {
@ -691,7 +692,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks,
if(xsh == &shBookCover && mmitem)
queuepoly(V2, shBook, 0x805020FF);
int pr = PPR_ITEM;
PPR pr = PPR_ITEM;
int alpha = hidden ? (it == itKraken ? 0xC0 : 0x40) : 0xF0;
if(c && c->wall == waIcewall) pr = PPR_HIDDEN, alpha = 0x80;
@ -705,9 +706,9 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks,
else if(xch == 'o' || it == itInventory) {
if(it == itOrbFire) icol = firecolor(100);
int pr = PPR_ITEM;
PPR prio = PPR_ITEM;
bool inice = c && c->wall == waIcewall;
if(inice) pr = PPR_HIDDEN;
if(inice) prio = PPR_HIDDEN;
int icol1 = icol;
if(it == itOrbFire) icol = firecolor(200);
@ -724,7 +725,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks,
if(it == itOrbFish)
queuepolyat(V * spin(ticks / 1500.), shFishTail, col, PPR_ITEM_BELOW);
queuepolyat(V, shDisk, darkena(icol1, 0, inice ? 0x80 : hidden ? 0x20 : 0xC0), pr);
queuepolyat(V, shDisk, darkena(icol1, 0, inice ? 0x80 : hidden ? 0x20 : 0xC0), prio);
hpcshape& sh =
it == itOrbLove ? shLoveRing :
isRangedOrb(it) ? shTargetRing :
@ -734,7 +735,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks,
isDirectionalOrb(it) ? shSpearRing :
it == itOrb37 ? shHeptaRing :
shRing;
queuepolyat(V * spin(ticks / 1500.), sh, col, pr);
queuepolyat(V * spin(ticks / 1500.), sh, col, prio);
}
else if(it) return true;
@ -770,9 +771,6 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou
else if(where && !(isMetalBeast(m) && where->stuntime == 1))
drawStunStars(V, where->stuntime);
if(where == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == (m == moPlayer ? mapeditor::sgPlayer : mapeditor::sgMonster))
mapeditor::drawtrans = V;
if(m == moTortoise) {
int bits = where ? tortoise::getb(where) : tortoise::last;
tortoise::draw(V, bits, 0, where ? where->stuntime : 0);
@ -1876,13 +1874,8 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
length = cellgfxdist(c, c->mondir);
}
if(c == mapeditor::drawcell && mapeditor::drawcellShapeGroup() == 1)
mapeditor::drawtrans = Vb;
if(mapeditor::drawUserShape(Vb, mapeditor::sgMonster, c->monst, (col << 8) + 0xFF, c)) {
if(c == mapeditor::drawcell) mapeditor::drawtrans = Vb;
if(mapeditor::drawUserShape(Vb, mapeditor::sgMonster, c->monst, (col << 8) + 0xFF, c))
return false;
}
if(isIvy(c) || isMutantIvy(c) || c->monst == moFriendlyIvy)
queuepoly(Vb, shIBranch, (col << 8) + 0xFF);
@ -3160,28 +3153,28 @@ void escherSidewall(cell *c, int sidepar, const transmatrix& V, int 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))
draw_qfi(c, mscale(V, zgrad0(geom3::slev * sl, geom3::slev * (sl+1), z, 4)), col, PPR_REDWALL-4+z+4*sl);
draw_qfi(c, mscale(V, zgrad0(geom3::slev * sl, geom3::slev * (sl+1), z, 4)), col, PPR(PPR_REDWALL-4+z+4*sl));
}
else if(sidepar == SIDE_WALL) {
const int layers = 2 << detaillevel;
for(int z=1; z<layers; z++)
draw_qfi(c, mscale(V, zgrad0(0, geom3::actual_wall_height(), z, layers)), col, PPR_WALL3+z-layers);
draw_qfi(c, mscale(V, zgrad0(0, geom3::actual_wall_height(), z, layers)), col, PPR(PPR_WALL3+z-layers));
}
else if(sidepar == SIDE_LAKE) {
const int layers = 1 << (detaillevel-1);
if(detaillevel) for(int z=0; z<layers; z++)
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_top, 0, z, layers)), col, PPR_FLOOR+z-layers);
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_top, 0, z, layers)), col, PPR(PPR_FLOOR+z-layers));
}
else if(sidepar == SIDE_LTOB) {
const int layers = 1 << (detaillevel-1);
if(detaillevel) for(int z=0; z<layers; z++)
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_bottom, -geom3::lake_top, z, layers)), col, PPR_INLAKEWALL+z-layers);
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_bottom, -geom3::lake_top, z, layers)), col, PPR(PPR_INLAKEWALL+z-layers));
}
else if(sidepar == SIDE_BTOI) {
const int layers = 1 << detaillevel;
draw_qfi(c, mscale(V, geom3::INFDEEP), col, PPR_MINUSINF);
for(int z=1; z<layers; z++)
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_bottom, -geom3::lake_top, -z, 1)), col, PPR_LAKEBOTTOM+z-layers);
draw_qfi(c, mscale(V, zgrad0(-geom3::lake_bottom, -geom3::lake_top, -z, 1)), col, PPR(PPR_LAKEBOTTOM+z-layers));
}
}
@ -3195,14 +3188,14 @@ bool placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, int col) {
if(qfi.fshape == &shBigTriangle && pseudohept(c->move(i))) return false;
if(qfi.fshape == &shTriheptaFloor && !pseudohept(c) && !pseudohept(c->move(i))) return false;
int prio;
PPR prio;
/* if(mirr) prio = PPR_GLASS - 2;
else */ if(sidepar == SIDE_WALL) prio = PPR_WALL3 - 2;
else if(sidepar == SIDE_WTS3) prio = PPR_WALL3 - 2;
else */ if(sidepar == SIDE_WALL) prio = PPR(PPR_WALL3 - 2);
else if(sidepar == SIDE_WTS3) prio = PPR(PPR_WALL3 - 2);
else if(sidepar == SIDE_LAKE) prio = PPR_LAKEWALL;
else if(sidepar == SIDE_LTOB) prio = PPR_INLAKEWALL;
else if(sidepar == SIDE_BTOI) prio = PPR_BELOWBOTTOM;
else prio = PPR_REDWALL-2+4*(sidepar-SIDE_SLEV);
else prio = PPR(PPR_REDWALL-2+4*(sidepar-SIDE_SLEV));
transmatrix V2 = V * ddspin(c, i);
@ -3422,7 +3415,7 @@ void draw_wall(cell *c, const transmatrix& V, int wcol, int& zcol, int ct6, int
for(int z=1; z<layers; z++) {
double zg = zgrad0(0, geom3::actual_wall_height(), z, layers);
draw_qfi(c, xyzscale(V, zg*(layers-z)/layers, zg),
darkena(gradient(0, wcol, -layers, z, layers), 0, 0xFF), PPR_WALL3+z-layers+2);
darkena(gradient(0, wcol, -layers, z, layers), 0, 0xFF), PPR(PPR_WALL3+z-layers+2));
}
floorShadow(c, V, SHADOW_WALL);
}
@ -3759,7 +3752,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
int flooralpha = 255;
if((cmode & sm::DRAW) && mapeditor::drawcell && mapeditor::drawcellShapeGroup() == 3)
if((cmode & sm::DRAW) && mapeditor::drawcell && mapeditor::drawcellShapeGroup() == mapeditor::sgFloor)
flooralpha = 0xC0;
if(c->wall == waMagma) fd = 0;
@ -3795,7 +3788,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
bool eoh = euclid || nonbitrunc;
if(c == mapeditor::drawcell)
if(drawing_usershape_on(c, mapeditor::sgFloor))
mapeditor::drawtrans = V * applyPatterndir(c, si);
if(c->wall == waChasm) {
@ -3858,7 +3851,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(wmspatial) {
const int layers = 2 << detaillevel;
for(int z=1; z<layers; z++)
queuepolyat(mscale(V2, zgrad0(0, geom3::actual_wall_height(), z, layers)), shHalfMirror[2], 0xC0C0C080, PPR_WALL3+z-layers);
queuepolyat(mscale(V2, zgrad0(0, geom3::actual_wall_height(), z, layers)), shHalfMirror[2], 0xC0C0C080, PPR(PPR_WALL3+z-layers));
}
else
queuepolyat(V2, shHalfMirror[2], 0xC0C0C080, PPR_WALL3);
@ -3876,7 +3869,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(wmspatial) {
const int layers = 2 << detaillevel;
for(int z=1; z<layers; z++)
queuepolyat(mscale(V2, zgrad0(0, geom3::actual_wall_height(), z, layers)), shHalfMirror[ct6], 0xC0C0C080, PPR_WALL3+z-layers);
queuepolyat(mscale(V2, zgrad0(0, geom3::actual_wall_height(), z, layers)), shHalfMirror[ct6], 0xC0C0C080, PPR(PPR_WALL3+z-layers));
}
else
queuepolyat(V2, shHalfMirror[ct6], 0xC0C0C080, PPR_WALL3);
@ -3914,7 +3907,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
queuepolyat(Vdepth, shSemiFloor[0], darkena(vcol, fd, 0xFF), PPR_WALL3A);
{dynamicval<int> 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));
queuepolyat(V2, shSemiFloorSide[SIDE_WALL], darkena(vcol, fd, 0xFF), PPR(PPR_WALL3A-2+away(V2)));
if(validsidepar[SIDE_WALL]) forCellIdEx(c2, j, c) {
int dis = i-j;
@ -4275,20 +4268,20 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(detaillevel >= 2)
queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 1, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR_REDWALL);
if(detaillevel >= 1)
queuepolyat(mmscale(V, geom3::SLEV[1]) * pispin, shWeakBranch, darkena(wcol, 0, 0xFF), PPR_REDWALL+1);
queuepolyat(mmscale(V, geom3::SLEV[1]) * pispin, shWeakBranch, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+1));
if(detaillevel >= 2)
queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 3, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR_REDWALL+2);
queuepolyat(mmscale(V, geom3::SLEV[2]), shSolidBranch, darkena(wcol, 0, 0xFF), PPR_REDWALL+3);
queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 3, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+2));
queuepolyat(mmscale(V, geom3::SLEV[2]), shSolidBranch, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+3));
break;
case waSmallBush:
if(detaillevel >= 2)
queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 1, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR_REDWALL);
if(detaillevel >= 1)
queuepolyat(mmscale(V, geom3::SLEV[1]) * pispin, shWeakBranch, darkena(wcol, 0, 0xFF), PPR_REDWALL+1);
queuepolyat(mmscale(V, geom3::SLEV[1]) * pispin, shWeakBranch, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+1));
if(detaillevel >= 2)
queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 3, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR_REDWALL+2);
queuepolyat(mmscale(V, geom3::SLEV[2]), shWeakBranch, darkena(wcol, 0, 0xFF), PPR_REDWALL+3);
queuepolyat(mmscale(V, zgrad0(0, geom3::slev, 3, 2)), shHeptaMarker, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+2));
queuepolyat(mmscale(V, geom3::SLEV[2]), shWeakBranch, darkena(wcol, 0, 0xFF), PPR(PPR_REDWALL+3));
break;
case waSolidBranch:
@ -4305,8 +4298,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
draw_floorshape(c, V, shMFloor2, 0x000000FF);
}
else {
draw_floorshape(c, V, shFloor, 0x804000FF, PPR_FLOOR+1);
draw_floorshape(c, V, shMFloor, 0x000000FF, PPR_FLOOR+2);
draw_floorshape(c, V, shFloor, 0x804000FF, PPR(PPR_FLOOR+1));
draw_floorshape(c, V, shMFloor, 0x000000FF, PPR(PPR_FLOOR+2));
}
break;
@ -4458,7 +4451,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
for(int z=1; z<layers; z++) {
double zg = zgrad0(-geom3::lake_top, geom3::actual_wall_height(), z, layers);
draw_qfi(c, xyzscale(V, zg*(layers-z)/layers, zg),
darkena(gradient(0, wcol, -layers, z, layers), 0, 0xFF), PPR_WALL3+z-layers+2);
darkena(gradient(0, wcol, -layers, z, layers), 0, 0xFF), PPR(PPR_WALL3+z-layers+2));
}
}
else goto wa_default;
@ -4475,7 +4468,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
wa_default:
if(sl && wmspatial) {
draw_qfi(c, (*Vdp), darkena(wcol, fd, 0xFF), PPR_REDWALL-4+4*sl);
draw_qfi(c, (*Vdp), darkena(wcol, fd, 0xFF), PPR(PPR_REDWALL-4+4*sl));
floorShadow(c, V, SHADOW_SL * sl);
for(int s=0; s<sl; s++)
forCellIdEx(c2, i, c) {

29
hyper.h
View File

@ -1103,7 +1103,6 @@ namespace mapeditor {
enum eShapegroup { sgPlayer, sgMonster, sgItem, sgFloor };
static const int USERSHAPEGROUPS = 4;
bool drawUserShape(transmatrix V, eShapegroup group, int id, int color, cell *c, int priority = -1);
bool haveUserShape(eShapegroup group, int id);
}
@ -1841,10 +1840,15 @@ enum PPR {
PPR_MINEMARK, PPR_ARROW,
PPR_MOBILE_ARROW,
PPR_LINE, PPR_TEXT, PPR_CIRCLE,
PPR_MAX
PPR_MAX,
PPR_DEFAULT = -1
};
void ShadowV(const transmatrix& V, const struct hpcshape& bp, int prio = PPR_MONSTER_SHADOW);
namespace mapeditor {
bool drawUserShape(const transmatrix& V, eShapegroup group, int id, int color, cell *c, PPR prio = PPR_DEFAULT);
}
void ShadowV(const transmatrix& V, const struct hpcshape& bp, PPR prio = PPR_MONSTER_SHADOW);
#define OUTLINE_NONE 0x000000FF
#define OUTLINE_FRIEND 0x00FF00FF
@ -2546,7 +2550,8 @@ union polyunion {
struct polytodraw {
eKind kind;
int prio, col;
PPR prio;
int col;
polyunion u;
polytodraw() {}
};
@ -3051,8 +3056,8 @@ namespace texture {
}
#endif
void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf = 0, int prio = PPR_LINE);
void queuelink(const string *link, int prio);
void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf = 0, PPR prio = PPR_LINE);
void queuelink(const string *link, PPR prio);
extern ld tessf, crossf, hexf, hcrossf, hexhexdist, hexvdist, hepvdist, rhexf;
unsigned char& part(int& col, int i);
@ -3539,8 +3544,8 @@ namespace glhr {
void prettypoly(const vector<hyperpoint>& t, int fillcol, int linecol, int lev);
polytodraw& lastptd();
void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio);
void queuetable(const transmatrix& V, const vector<glvertex>& f, int cnt, int linecol, int fillcol, int prio);
void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio);
void queuetable(const transmatrix& V, const vector<glvertex>& f, int cnt, int linecol, int fillcol, PPR prio);
struct floorshape;
@ -3556,7 +3561,8 @@ extern qfloorinfo qfi;
extern int chasmg;
struct hpcshape {
int s, e, prio;
int s, e;
PPR prio;
int flags;
};
@ -3690,7 +3696,7 @@ 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, int prio);
void queuepolyat(const transmatrix& V, const hpcshape& h, int 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);
@ -3748,7 +3754,8 @@ void set_blizzard_frame(cell *c, int frameid);
struct floorshape {
bool is_plain;
int shapeid, prio;
int shapeid;
PPR prio;
vector<hpcshape> b, shadow, side[SIDEPARS], gpside[SIDEPARS][MAX_EDGE];
floorshape() { prio = PPR_FLOOR; }
};

View File

@ -546,7 +546,7 @@ namespace mapeditor {
return si.id + patterns::subcode(drawcell, si);
}
bool editingShape(int group, int id) {
bool editingShape(eShapegroup group, int id) {
if(group != mapeditor::drawcellShapeGroup()) return false;
return id == drawcellShapeID();
}
@ -1701,11 +1701,14 @@ namespace mapeditor {
#endif
}
bool drawUserShape(transmatrix V, eShapegroup group, int id, int color, cell *c, int priority) {
bool drawUserShape(const transmatrix& V, eShapegroup group, int id, int color, cell *c, PPR prio) {
#if !CAP_EDIT
return false;
#else
if(c == drawcell && editingShape(group, id) && prio == PPR_DEFAULT)
drawtrans = V;
usershape *us = usershapes[group][id];
if(us) {
for(int i=0; i<USERLAYERS; i++) {
@ -1714,7 +1717,7 @@ namespace mapeditor {
hpcshape& sh(ds.sh);
if(sh.s != sh.e)
queuepolyat(V, sh, ds.color ? ds.color : color, priority);
queuepolyat(V, sh, ds.color ? ds.color : color, prio);
}
}

View File

@ -72,7 +72,6 @@ bool fatborder;
int poly_outline;
#define PSHIFT 0
// #define STLSORT
#define NEWSHAPE (-13.5)
@ -1134,7 +1133,7 @@ void drawqueue() {
for(int i = 0; i<siz; i++) {
if(ptds[i].prio < 0 || ptds[i].prio >= PPR_MAX) {
printf("Illegal priority %d of kind %d\n", ptds[i].prio, ptds[i].kind);
ptds[i].prio = rand() % PPR_MAX;
ptds[i].prio = PPR(rand() % PPR_MAX);
}
qp[ptds[i].prio]++;
}
@ -1458,11 +1457,11 @@ void finishshape() {
printf("bad end\n"); */
}
void bshape(hpcshape& sh, int p) {
void bshape(hpcshape& sh, PPR prio) {
if(last) finishshape();
hpc.push_back(hpxy(0,0));
last = &sh;
last->s = isize(hpc), last->prio = p;
last->s = isize(hpc), last->prio = prio;
last->flags = 0;
first = true;
}
@ -1474,8 +1473,8 @@ static const
#endif
double bscale7 = 1, brot7 = 0, bscale6 = 1, brot6 = 0;
void bshape(hpcshape& sh, int p, double shzoom, int shapeid, double bonus = 0, flagtype flags = 0) {
bshape(sh, p);
void bshape(hpcshape& sh, PPR prio, double shzoom, int shapeid, double bonus = 0, flagtype flags = 0) {
bshape(sh, prio);
int whereis = 0;
while(polydata[whereis] != NEWSHAPE || polydata[whereis+1] != shapeid) whereis++;
int rots = polydata[whereis+2]; int sym = polydata[whereis+3];
@ -1537,14 +1536,14 @@ void bshape(hpcshape& sh, int p, double shzoom, int shapeid, double bonus = 0, f
hpcpush(ipoint(0, 1));
}
void copyshape(hpcshape& sh, hpcshape& orig, int p) {
void copyshape(hpcshape& sh, hpcshape& orig, PPR prio) {
if(last) last->e = isize(hpc);
sh = orig; sh.prio = p;
sh = orig; sh.prio = prio;
}
void zoomShape(hpcshape& old, hpcshape& newsh, double factor, int lev) {
void zoomShape(hpcshape& old, hpcshape& newsh, double factor, PPR prio) {
bshape(newsh, lev);
bshape(newsh, prio);
for(int i=old.s; i<old.e; i++) {
hyperpoint H = hpc[i];
H = hpxyz(factor*H[0], factor*H[1], H[2]);
@ -2011,11 +2010,11 @@ void buildpolys() {
}
}
bshape(shSlime, 33);
bshape(shSlime, PPR_MONSTER_BODY);
PRING(i)
hpcpush(ddi(i, xcrossf * (0.7 + .2 * sin(i * M_PI * 2 / S84 * 9))) * C0);
bshape(shJelly, 33);
bshape(shJelly, PPR_MONSTER_BODY);
PRING(i)
hpcpush(ddi(i, xcrossf * (0.4 + .03 * sin(i * M_PI * 2 / S84 * 7))) * C0);
@ -2381,40 +2380,43 @@ void buildpolys() {
for(int u=0; u<=2; u+=2) {
int sh = u ? PPR_ITEM : PPR_MONSTER_LEG;
PPR sh = u ? PPR_ITEM : PPR_MONSTER_LEG;
int uz = u?2:1;
bshape(shTortoise[0][0+u], sh+1, scalef/uz, 207);
bshape(shTortoise[1][0+u], sh+2, scalef/uz, 208);
bshape(shTortoise[2][0+u], sh+2, scalef/uz, 209);
bshape(shTortoise[3][0+u], sh+2, scalef/uz, 210);
bshape(shTortoise[4][0+u], sh+2, scalef/uz, 211);
bshape(shTortoise[5][0+u], sh+2, scalef/uz, 212);
bshape(shTortoise[6][0+u], sh+2, scalef/uz, 213);
bshape(shTortoise[7][0+u], sh+2, scalef/uz, 214);
PPR sh1 = PPR(sh + 1);
PPR sh2 = PPR(sh + 2);
bshape(shTortoise[0][0+u], sh1, scalef/uz, 207);
bshape(shTortoise[1][0+u], sh2, scalef/uz, 208);
bshape(shTortoise[2][0+u], sh2, scalef/uz, 209);
bshape(shTortoise[3][0+u], sh2, scalef/uz, 210);
bshape(shTortoise[4][0+u], sh2, scalef/uz, 211);
bshape(shTortoise[5][0+u], sh2, scalef/uz, 212);
bshape(shTortoise[6][0+u], sh2, scalef/uz, 213);
bshape(shTortoise[7][0+u], sh2, scalef/uz, 214);
bshape(shTortoise[8][0+u], sh, scalef/uz, 215);
bshape(shTortoise[9][0+u], sh, scalef/uz, 217);
bshape(shTortoise[10][0+u], sh, scalef/uz, 218);
bshape(shTortoise[11][0+u], sh, scalef/uz, 219);
bshape(shTortoise[12][0+u], sh+2, scalef/uz, 216);
bshape(shTortoise[12][0+u], sh2, scalef/uz, 216);
bshape(shTortoise[0][1+u], sh+1, scalef/uz, 220);
bshape(shTortoise[1][1+u], sh+2, scalef/uz, 221);
bshape(shTortoise[2][1+u], sh+2, scalef/uz, 222);
bshape(shTortoise[3][1+u], sh+2, scalef/uz, 223);
bshape(shTortoise[4][1+u], sh+2, scalef/uz, 224);
bshape(shTortoise[5][1+u], sh+2, scalef/uz, 225);
bshape(shTortoise[6][1+u], sh+2, scalef/uz, 226);
bshape(shTortoise[7][1+u], sh+2, scalef/uz, 227);
bshape(shTortoise[0][1+u], sh1, scalef/uz, 220);
bshape(shTortoise[1][1+u], sh2, scalef/uz, 221);
bshape(shTortoise[2][1+u], sh2, scalef/uz, 222);
bshape(shTortoise[3][1+u], sh2, scalef/uz, 223);
bshape(shTortoise[4][1+u], sh2, scalef/uz, 224);
bshape(shTortoise[5][1+u], sh2, scalef/uz, 225);
bshape(shTortoise[6][1+u], sh2, scalef/uz, 226);
bshape(shTortoise[7][1+u], sh2, scalef/uz, 227);
bshape(shTortoise[8][1+u], sh, scalef/uz, 228);
bshape(shTortoise[9][1+u], sh, scalef/uz, 230);
bshape(shTortoise[10][1+u], sh, scalef/uz, 231);
bshape(shTortoise[11][1+u], sh, scalef/uz, 232);
bshape(shTortoise[12][1+u], sh+2, scalef/uz, 229);
bshape(shTortoise[12][1+u], sh2, scalef/uz, 229);
}
for(int v=0; v<13; v++) for(int z=0; z<2; z++)
copyshape(shTortoise[v][4+z], shTortoise[v][2+z], shTortoise[v][2+z].prio + (PPR_CARRIED-PPR_ITEM));
copyshape(shTortoise[v][4+z], shTortoise[v][2+z], PPR(shTortoise[v][2+z].prio + (PPR_CARRIED-PPR_ITEM)));
if(nonbitrunc) bshape(shMagicSword, PPR_MAGICSWORD, euclid4 ? gp::scale * irr::scale / 2 : gp::scale * irr::scale, 243);
else bshape(shMagicSword, PPR_MAGICSWORD, 1, 244);
@ -2422,8 +2424,8 @@ void buildpolys() {
if(nonbitrunc) bshape(shMagicShovel, PPR_MAGICSWORD, euclid4 ? gp::scale * irr::scale / 2 : gp::scale * irr::scale, 333);
else bshape(shMagicShovel, PPR_MAGICSWORD, 1, 333);
bshape(shBead0, 20, 1, 250);
bshape(shBead1, 20, 1, 251);
bshape(shBead0, PPR(20), 1, 250);
bshape(shBead1, PPR(20), 1, 251);
bshape(shArrow, PPR_ARROW, 1, 252);
bshapeend();
@ -2469,7 +2471,7 @@ void initShape(int sg, int id) {
usershapes[sg][id] = us;
for(int i=0; i<USERLAYERS; i++) {
us->d[i].sh.prio = (sg >= 3 ? 1:50) + i;
us->d[i].sh.prio = PPR((sg >= 3 ? 1:50) + i);
us->d[i].rots = 1;
us->d[i].sym = 0;
@ -2480,8 +2482,8 @@ void initShape(int sg, int id) {
}
}
void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio) {
if(prio == -1) prio = h.prio;
void queuepolyat(const transmatrix& V, const hpcshape& h, int col, PPR prio) {
if(prio == PPR_DEFAULT) prio = h.prio;
polytodraw& ptd = nextptd();
ptd.kind = pkPoly;
@ -2504,7 +2506,7 @@ void queuepolyat(const transmatrix& V, const hpcshape& h, int col, int prio) {
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 << PSHIFT;
ptd.prio = prio;
ptd.u.poly.outline = poly_outline;
ptd.u.poly.linewidth = vid.linewidth;
ptd.u.poly.flags = h.flags;
@ -2515,14 +2517,14 @@ void addfloats(vector<GLfloat>& v, hyperpoint h) {
for(int i=0; i<3; i++) v.push_back(h[i]);
}
void queuereset(eModel md, int prio) {
void queuereset(eModel md, PPR prio) {
polytodraw& ptd = nextptd();
ptd.kind = pkResetModel;
ptd.col = md;
ptd.prio = prio << PSHIFT;
ptd.prio = prio;
}
void queuetable(const transmatrix& V, const vector<glvertex>& f, int cnt, int linecol, int fillcol, int prio) {
void queuetable(const transmatrix& V, const vector<glvertex>& f, int cnt, int linecol, int fillcol, PPR prio) {
polytodraw& ptd = nextptd();
ptd.kind = pkPoly;
ptd.u.poly.V = V;
@ -2530,7 +2532,7 @@ void queuetable(const transmatrix& V, const vector<glvertex>& f, int cnt, int li
ptd.u.poly.offset = 0;
ptd.u.poly.cnt = cnt;
ptd.col = fillcol;
ptd.prio = prio << PSHIFT;
ptd.prio = prio;
ptd.u.poly.outline = linecol;
ptd.u.poly.linewidth = vid.linewidth;
ptd.u.poly.flags = 0;
@ -2542,27 +2544,27 @@ void queuepoly(const transmatrix& V, const hpcshape& h, int col) {
}
void queuepolyb(const transmatrix& V, const hpcshape& h, int col, int b) {
queuepolyat(V,h,col,h.prio+b);
queuepolyat(V,h,col,PPR(h.prio+b));
}
void curvepoint(const hyperpoint& H1) {
curvedata.push_back(glhr::pointtogl(H1));
}
void queuecurve(int linecol, int fillcol, int prio) {
void queuecurve(int linecol, int fillcol, PPR prio) {
queuetable(Id, curvedata, isize(curvedata)-curvestart, linecol, fillcol, prio);
lastptd().u.poly.offset = curvestart;
curvestart = isize(curvedata);
}
void queuelink(const string *link, int prio) {
void queuelink(const string *link, PPR prio) {
polytodraw& ptd = nextptd();
ptd.kind = pkLink;
ptd.prio = prio << PSHIFT;
ptd.prio = prio;
ptd.u.link.link = link;
}
void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf, int prio) {
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;
@ -2570,7 +2572,7 @@ void queueline(const hyperpoint& H1, const hyperpoint& H2, int col, int prf, int
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 << PSHIFT;
ptd.prio = prio;
}
void queuestr(int x, int y, int shift, int size, string str, int col, int frame, int align) {
@ -2585,7 +2587,7 @@ void queuestr(int x, int y, int shift, int size, string str, int col, int frame,
ptd.u.chr.size = size;
ptd.col = darkened(col);
ptd.u.chr.frame = frame ? ((poly_outline & ~ 255)+frame) : 0;
ptd.prio = PPR_TEXT << PSHIFT;
ptd.prio = PPR_TEXT;
}
void queuechr(int x, int y, int shift, int size, char chr, int col, int frame, int align) {
@ -2600,10 +2602,10 @@ void queuechr(int x, int y, int shift, int size, char chr, int col, int frame, i
ptd.u.chr.align = align;
ptd.col = col;
ptd.u.chr.frame = frame ? (poly_outline & ~ 255) : 0;
ptd.prio = PPR_TEXT << PSHIFT;
ptd.prio = PPR_TEXT;
}
void queuecircle(int x, int y, int size, int color, int prio = PPR_CIRCLE) {
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;
@ -2611,7 +2613,7 @@ void queuecircle(int x, int y, int size, int color, int prio = PPR_CIRCLE) {
ptd.u.cir.size = size;
ptd.u.cir.boundary = false;
ptd.col = color;
ptd.prio = prio << PSHIFT;
ptd.prio = prio;
}
void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) {