1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-09 10:29:45 +01:00

De-duplicate reference to edentity

'edentity[edi]' is a bit long-winded when you really just want to access
the attributes of the edentity. How about just 'ent'?
This commit is contained in:
Misa 2020-07-09 02:40:18 -07:00 committed by Ethan Lee
parent 4b6406d08e
commit 729f24d732

View file

@ -1680,15 +1680,16 @@ void mapclass::loadlevel(int rx, int ry)
int tempscriptbox=0; int tempscriptbox=0;
for(size_t edi=0; edi<edentity.size(); edi++){ for(size_t edi=0; edi<edentity.size(); edi++){
//If entity is in this room, create it //If entity is in this room, create it
const int tsx = edentity[edi].x / 40; const edentities& ent = edentity[edi];
const int tsy = edentity[edi].y / 30; const int tsx = ent.x / 40;
const int tsy = ent.y / 30;
if (tsx != rx-100 || tsy != ry-100) if (tsx != rx-100 || tsy != ry-100)
{ {
continue; continue;
} }
const int ex = (edentity[edi].x % 40) * 8; const int ex = (ent.x % 40) * 8;
const int ey = (edentity[edi].y % 30) * 8; const int ey = (ent.y % 30) * 8;
switch(edentity[edi].t){ switch(ent.t){
case 1: //Enemies case 1: //Enemies
int bx1, by1, bx2, by2; int bx1, by1, bx2, by2;
bx1=ed.level[rx-100+((ry-100)*ed.maxwidth)].enemyx1; bx1=ed.level[rx-100+((ry-100)*ed.maxwidth)].enemyx1;
@ -1701,10 +1702,10 @@ void mapclass::loadlevel(int rx, int ry)
obj.customenemy=ed.level[tsx+((ed.maxwidth)*tsy)].enemytype; obj.customenemy=ed.level[tsx+((ed.maxwidth)*tsy)].enemytype;
obj.createentity(ex, ey, 56, obj.createentity(ex, ey, 56,
edentity[edi].p1, 4, bx1, by1, bx2, by2); ent.p1, 4, bx1, by1, bx2, by2);
break; break;
case 2: //Platforms and Threadmills case 2: //Platforms and Threadmills
if(edentity[edi].p1<=4){ if(ent.p1<=4){
int bx1, by1, bx2, by2; int bx1, by1, bx2, by2;
bx1=ed.level[rx-100+((ry-100)*ed.maxwidth)].platx1; bx1=ed.level[rx-100+((ry-100)*ed.maxwidth)].platx1;
by1=ed.level[rx-100+((ry-100)*ed.maxwidth)].platy1; by1=ed.level[rx-100+((ry-100)*ed.maxwidth)].platy1;
@ -1715,10 +1716,10 @@ void mapclass::loadlevel(int rx, int ry)
if(warpy){ if(by1==0 && by2==240){ by1=-100; by2=340; } } if(warpy){ if(by1==0 && by2==240){ by1=-100; by2=340; } }
obj.createentity(ex, ey, 2, obj.createentity(ex, ey, 2,
edentity[edi].p1, ed.level[rx-100+((ry-100)*ed.mapwidth)].platv, bx1, by1, bx2, by2); ent.p1, ed.level[rx-100+((ry-100)*ed.mapwidth)].platv, bx1, by1, bx2, by2);
}else if(edentity[edi].p1>=5 && edentity[edi].p1<=8){ //Threadmill }else if(ent.p1 >= 5 && ent.p1 <= 8){ //Threadmill
obj.createentity(ex, ey, 2, obj.createentity(ex, ey, 2,
edentity[edi].p1+3, 4); ent.p1 + 3, 4);
} }
break; break;
case 3: //Disappearing platforms case 3: //Disappearing platforms
@ -1729,21 +1730,21 @@ void mapclass::loadlevel(int rx, int ry)
break; break;
case 10: //Checkpoints case 10: //Checkpoints
obj.createentity(ex, ey, 10, obj.createentity(ex, ey, 10,
edentity[edi].p1,((rx+(ry*100))*20)+tempcheckpoints); ent.p1, ((rx+(ry*100))*20)+tempcheckpoints);
tempcheckpoints++; tempcheckpoints++;
break; break;
case 11: //Gravity Lines case 11: //Gravity Lines
if(edentity[edi].p1==0){ //Horizontal if(ent.p1==0){ //Horizontal
obj.createentity((edentity[edi].p2*8), ey + 4, 11, edentity[edi].p3); obj.createentity(ent.p2 * 8, ey + 4, 11, ent.p3);
}else{ //Vertical }else{ //Vertical
obj.createentity(ex + 3,(edentity[edi].p2*8), 12, edentity[edi].p3); obj.createentity(ex + 3, ent.p2 * 8, 12, ent.p3);
} }
break; break;
case 13: //Warp Tokens case 13: //Warp Tokens
obj.createentity(ex, ey, 13, edentity[edi].p1, edentity[edi].p2); obj.createentity(ex, ey, 13, ent.p1, ent.p2);
break; break;
case 15: //Collectable crewmate case 15: //Collectable crewmate
obj.createentity(ex - 4, ey + 1, 55, ed.findcrewmate(edi), edentity[edi].p1, edentity[edi].p2); obj.createentity(ex - 4, ey + 1, 55, ed.findcrewmate(edi), ent.p1, ent.p2);
break; break;
case 17: //Roomtext! case 17: //Roomtext!
{ {
@ -1751,15 +1752,15 @@ void mapclass::loadlevel(int rx, int ry)
Roomtext text; Roomtext text;
text.x = ex / 8; text.x = ex / 8;
text.y = ey / 8; text.y = ey / 8;
text.text = edentity[edi].scriptname; text.text = ent.scriptname;
roomtext.push_back(text); roomtext.push_back(text);
break; break;
} }
case 18: //Terminals case 18: //Terminals
{ {
obj.customscript=edentity[edi].scriptname; obj.customscript = ent.scriptname;
int usethistile = edentity[edi].p1; int usethistile = ent.p1;
int usethisy = ey; int usethisy = ey;
// This isn't a boolean: we just swap 0 and 1 around and leave the rest alone // This isn't a boolean: we just swap 0 and 1 around and leave the rest alone
@ -1780,22 +1781,22 @@ void mapclass::loadlevel(int rx, int ry)
case 19: //Script Box case 19: //Script Box
if (INBOUNDS_ARR(tempscriptbox, game.customscript)) if (INBOUNDS_ARR(tempscriptbox, game.customscript))
{ {
game.customscript[tempscriptbox]=edentity[edi].scriptname; game.customscript[tempscriptbox]=ent.scriptname;
} }
obj.createblock(1, ex, ey, obj.createblock(1, ex, ey,
edentity[edi].p1*8, edentity[edi].p2*8, 300+tempscriptbox, "custom_" + edentity[edi].scriptname); ent.p1*8, ent.p2*8, 300+tempscriptbox, "custom_" + ent.scriptname);
tempscriptbox++; tempscriptbox++;
break; break;
case 50: //Warp Lines case 50: //Warp Lines
obj.customwarpmode=true; obj.customwarpmode=true;
if(edentity[edi].p1==0){ // if(ent.p1==0){ //
obj.createentity(ex + 4,(edentity[edi].p2*8), 51, edentity[edi].p3); obj.createentity(ex + 4, ent.p2 * 8, 51, ent.p3);
}else if(edentity[edi].p1==1){ //Horizontal, right }else if(ent.p1==1){ //Horizontal, right
obj.createentity(ex + 4,(edentity[edi].p2*8), 52, edentity[edi].p3); obj.createentity(ex + 4, ent.p2 * 8, 52, ent.p3);
}else if(edentity[edi].p1==2){ //Vertical, top }else if(ent.p1==2){ //Vertical, top
obj.createentity((edentity[edi].p2*8), ey + 7, 53, edentity[edi].p3); obj.createentity(ent.p2 * 8, ey + 7, 53, ent.p3);
}else if(edentity[edi].p1==3){ }else if(ent.p1==3){
obj.createentity((edentity[edi].p2*8), ey, 54, edentity[edi].p3); obj.createentity(ent.p2 * 8, ey, 54, ent.p3);
} }
break; break;
} }