diff --git a/desktop_version/src/Ent.cpp b/desktop_version/src/Ent.cpp index 35db8bf6..f159547f 100644 --- a/desktop_version/src/Ent.cpp +++ b/desktop_version/src/Ent.cpp @@ -11,7 +11,7 @@ entclass::entclass(void) void entclass::clear(void) { invis = false; - type = 0; + type = EntityType_PLAYER; size = 0; tile = 0; rule = 0; @@ -650,8 +650,8 @@ void entclass::updatecolour(void) bool entclass::ishumanoid(void) { - return type == 0 - || type == 12 - || type == 14 - || type == 55; + return type == EntityType_PLAYER + || type == EntityType_CREWMATE + || type == EntityType_SUPERCREWMATE + || type == EntityType_COLLECTABLE_CREWMATE; } diff --git a/desktop_version/src/Ent.h b/desktop_version/src/Ent.h index f4ddd43c..d422a519 100644 --- a/desktop_version/src/Ent.h +++ b/desktop_version/src/Ent.h @@ -5,6 +5,34 @@ #define rn( rx, ry) ((rx) + ((ry) * 100)) +enum EntityType +{ + EntityType_INVALID = -1, + EntityType_PLAYER, + EntityType_MOVING, + EntityType_DISAPPEARING_PLATFORM, + EntityType_QUICKSAND, + EntityType_GRAVITY_TOKEN, + EntityType_PARTICLE, + EntityType_COIN, + EntityType_TRINKET, + EntityType_CHECKPOINT, + EntityType_HORIZONTAL_GRAVITY_LINE, + EntityType_VERTICAL_GRAVITY_LINE, + EntityType_WARP_TOKEN, + EntityType_CREWMATE, + EntityType_TERMINAL, + EntityType_SUPERCREWMATE, + EntityType_TROPHY, + EntityType_GRAVITRON_ENEMY = 23, + EntityType_WARP_LINE_LEFT = 51, + EntityType_WARP_LINE_RIGHT = 52, + EntityType_WARP_LINE_TOP = 53, + EntityType_WARP_LINE_BOTTOM = 54, + EntityType_COLLECTABLE_CREWMATE = 55, + EntityType_TELEPORTER = 100 +}; + class entclass { public: @@ -26,7 +54,8 @@ public: public: //Fundamentals bool invis; - int type, size, tile, rule; + EntityType type; + int size, tile, rule; int state, statedelay; int behave, animate; float para; diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 5023b16b..d329e3a8 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -123,7 +123,7 @@ void entityclass::swnenemiescol( int t ) //change the colour of all SWN enemies to the current one for (size_t i = 0; i < entities.size(); i++) { - if (entities[i].type == 23) + if (entities[i].type == EntityType_GRAVITRON_ENEMY) { entities[i].colour = swncolour(t); } @@ -1133,7 +1133,7 @@ bool entityclass::disableentity(int t) entities[t].invis = true; entities[t].size = -1; - entities[t].type = -1; + entities[t].type = EntityType_INVALID; entities[t].rule = -1; entities[t].isplatform = false; @@ -1269,7 +1269,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int { if (entities[i].invis && entities[i].size == -1 - && entities[i].type == -1 + && entities[i].type == EntityType_INVALID && entities[i].rule == -1 && !entities[i].isplatform) { @@ -1318,7 +1318,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int entclass& entity = *entptr; entity.xp = xp; entity.yp = yp; - entity.type = t; + entity.type = EntityType_INVALID; switch(t) { case 0: //Player @@ -1330,6 +1330,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int entity.w = 12; entity.h = 21; entity.dir = 1; + entity.type = EntityType_PLAYER; /* Fix wrong y-position if spawning in on conveyor */ entity.newxp = xp; @@ -1358,6 +1359,8 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int entity.animate = 0; entity.colour = 8; + entity.type = EntityType_MOVING; + if (game.roomy == 111 && (game.roomx >= 113 && game.roomx <= 117)) { entity.setenemy(0); @@ -1386,7 +1389,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 2: //A moving platform entity.rule = 2; - entity.type = 1; + entity.type = EntityType_MOVING; entity.size = 2; entity.tile = 1; @@ -1454,7 +1457,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 3: //Disappearing platforms entity.rule = 3; - entity.type = 2; + entity.type = EntityType_DISAPPEARING_PLATFORM; entity.size = 2; entity.tile = 2; //appearance again depends on location @@ -1484,7 +1487,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 4: //Breakable blocks entity.rule = 6; - entity.type = 3; + entity.type = EntityType_QUICKSAND; entity.size = 1; entity.tile = 10; entity.cy = -1; @@ -1499,7 +1502,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 5: //Gravity Tokens entity.rule = 3; - entity.type = 4; + entity.type = EntityType_GRAVITY_TOKEN; entity.size = 0; entity.tile = 11; entity.w = 16; @@ -1511,7 +1514,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 6: //Decorative particles entity.rule = 2; - entity.type = 5; //Particles + entity.type = EntityType_PARTICLE; //Particles entity.colour = 1; entity.size = 3; entity.vx = meta1; @@ -1521,7 +1524,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 7: //Decorative particles entity.rule = 2; - entity.type = 5; //Particles + entity.type = EntityType_PARTICLE; //Particles entity.colour = 2; entity.size = 3; entity.vx = meta1; @@ -1531,7 +1534,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 8: //Small collectibles entity.rule = 3; - entity.type = 6; + entity.type = EntityType_COIN; entity.size = 4; entity.tile = 48; entity.w = 8; @@ -1545,7 +1548,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 9: //Something Shiny entity.rule = 3; - entity.type = 7; + entity.type = EntityType_TRINKET; entity.size = 0; entity.tile = 22; entity.w = 16; @@ -1560,7 +1563,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 10: //Savepoint entity.rule = 3; - entity.type = 8; + entity.type = EntityType_CHECKPOINT; entity.size = 0; entity.tile = 20 + meta1; entity.w = 16; @@ -1583,7 +1586,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 11: //Horizontal Gravity Line entity.rule = 4; - entity.type = 9; + entity.type = EntityType_HORIZONTAL_GRAVITY_LINE; entity.size = 5; entity.life = 0; entity.w = meta1; @@ -1592,7 +1595,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 12: //Vertical Gravity Line entity.rule = 5; - entity.type = 10; + entity.type = EntityType_VERTICAL_GRAVITY_LINE; entity.size = 6; entity.life = 0; entity.w = 1; @@ -1602,7 +1605,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 13: //Warp token entity.rule = 3; - entity.type = 11; + entity.type = EntityType_WARP_TOKEN; entity.size = 0; entity.tile = 18; entity.w = 16; @@ -1616,7 +1619,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 14: // Teleporter entity.rule = 3; - entity.type = 100; + entity.type = EntityType_TELEPORTER; entity.size = 7; entity.tile = 1; //inactive entity.w = 96; @@ -1628,7 +1631,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 15: // Crew Member (warp zone) entity.rule = 6; - entity.type = 12; //A special case! + entity.type = EntityType_CREWMATE; //A special case! entity.tile = 144; entity.colour = 13; //144 for sad :( entity.cx = 6; @@ -1643,7 +1646,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 16: // Crew Member, upside down (space station) entity.rule = 7; - entity.type = 12; //A special case! + entity.type = EntityType_CREWMATE; //A special case! entity.tile = 144+6; entity.colour = 14; //144 for sad (upside down+12):( entity.cx = 6; @@ -1658,7 +1661,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 17: // Crew Member (Lab) entity.rule = 6; - entity.type = 12; //A special case! + entity.type = EntityType_CREWMATE; //A special case! entity.tile = 144; entity.colour = 16; //144 for sad :( entity.cx = 6; @@ -1674,7 +1677,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int case 18: // Crew Member (Ship) //This is the scriping crewmember entity.rule = 6; - entity.type = 12; //A special case! + entity.type = EntityType_CREWMATE; //A special case! entity.colour = meta1; if (meta2 == 0) { @@ -1702,7 +1705,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 19: // Crew Member (Ship) More tests! entity.rule = 6; - entity.type = 12; //A special case! + entity.type = EntityType_CREWMATE; //A special case! entity.tile = 0; entity.colour = 6; //54 for sad :( entity.cx = 6; @@ -1717,7 +1720,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 20: //Terminal entity.rule = 3; - entity.type = 13; + entity.type = EntityType_TERMINAL; entity.size = 0; entity.tile = 16 + meta1; entity.w = 16; @@ -1729,7 +1732,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 21: //as above, except doesn't highlight entity.rule = 3; - entity.type = 13; + entity.type = EntityType_TERMINAL; entity.size = 0; entity.tile = 16 + meta1; entity.w = 16; @@ -1741,7 +1744,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 22: //Fake trinkets, only appear if you've collected them entity.rule = 3; - entity.type = 7; + entity.type = EntityType_TRINKET; entity.size = 0; entity.tile = 22; entity.w = 16; @@ -1757,7 +1760,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int case 23: //SWN Enemies //Given a different behavior, these enemies are especially for SWN mode and disappear outside the screen. entity.rule = 1; - entity.type = 23; + entity.type = EntityType_GRAVITRON_ENEMY; entity.behave = meta1; entity.para = meta2; entity.w = 16; @@ -1786,7 +1789,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int case 24: // Super Crew Member //This special crewmember is way more advanced than the usual kind, and can interact with game objects entity.rule = 6; - entity.type = 14; //A special case! + entity.type = EntityType_SUPERCREWMATE; //A special case! entity.colour = meta1; if (meta1 == 16) { @@ -1828,7 +1831,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 25: //Trophies entity.rule = 3; - entity.type = 15; + entity.type = EntityType_TROPHY; entity.size = 0; entity.w = 16; entity.h = 16; @@ -2003,7 +2006,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 26: //Epilogue super warp token entity.rule = 3; - entity.type = 11; + entity.type = EntityType_WARP_TOKEN; entity.size = 0; entity.tile = 18; entity.w = 16; @@ -2020,7 +2023,23 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int case 52: /* Vertical */ case 53: /* Horizontal */ case 54: /* Horizontal */ - entity.type = t; + if (t == 51) + { + entity.type = EntityType_WARP_LINE_LEFT; + } + else if (t == 52) + { + entity.type = EntityType_WARP_LINE_RIGHT; + } + else if (t == 53) + { + entity.type = EntityType_WARP_LINE_TOP; + } + else + { + entity.type = EntityType_WARP_LINE_BOTTOM; + } + entity.onentity = 1; entity.invis = true; entity.life = 0; @@ -2052,7 +2071,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int //1 - position in array //2 - colour entity.rule = 3; - entity.type = 55; + entity.type = EntityType_COLLECTABLE_CREWMATE; if(INBOUNDS_ARR(meta2, customcrewmoods) && customcrewmoods[meta2]==1){ entity.tile = 144; @@ -2078,7 +2097,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int break; case 56: //Custom enemy entity.rule = 1; - entity.type = 1; + entity.type = EntityType_MOVING; entity.behave = meta1; entity.para = meta2; entity.w = 16; @@ -2154,6 +2173,9 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int entityclonefix(&entity); break; + case 100: // Invalid enemy, but gets treated as a teleporter + entity.type = EntityType_TELEPORTER; + break; } entity.lerpoldxp = entity.xp; @@ -2169,7 +2191,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int * This is a bit kludge-y but it's better than copy-pasting * and is okay to do because entity 12 does not change state on its own */ - if (entity.type == 12) + if (entity.type == EntityType_CREWMATE) { size_t indice; if (reuse) @@ -2222,9 +2244,9 @@ bool entityclass::updateentities( int i ) { switch(entities[i].type) { - case 0: //Player + case EntityType_PLAYER: //Player break; - case 1: //Movement behaviors + case EntityType_MOVING: //Movement behaviors //Enemies can have a number of different behaviors: switch(entities[i].behave) { @@ -2454,7 +2476,7 @@ bool entityclass::updateentities( int i ) { for (size_t j = 0; j < entities.size(); j++) { - if (entities[j].type == 2 && entities[j].state== 3 && entities[j].xp == (entities[i].xp-32) ) + if (entities[j].type == EntityType_DISAPPEARING_PLATFORM && entities[j].state== 3 && entities[j].xp == (entities[i].xp-32) ) { entities[i].state = 3; bool entitygone = updateentities(i); @@ -2484,7 +2506,7 @@ bool entityclass::updateentities( int i ) { for (size_t j = 0; j < entities.size(); j++) { - if (entities[j].type == 2 && entities[j].state==3 && entities[j].xp==entities[i].xp+32) + if (entities[j].type == EntityType_DISAPPEARING_PLATFORM && entities[j].state==3 && entities[j].xp==entities[i].xp+32) { entities[i].state = 3; bool entitygone = updateentities(i); @@ -2582,7 +2604,7 @@ bool entityclass::updateentities( int i ) break; } break; - case 2: //Disappearing platforms + case EntityType_DISAPPEARING_PLATFORM: //Disappearing platforms //wait for collision if (entities[i].state == 1) { @@ -2629,7 +2651,7 @@ bool entityclass::updateentities( int i ) } } break; - case 3: //Breakable blocks + case EntityType_QUICKSAND: //Breakable blocks //Only counts if vy of player entity is non zero if (entities[i].state == 1) { @@ -2649,7 +2671,7 @@ bool entityclass::updateentities( int i ) } } break; - case 4: //Gravity token + case EntityType_GRAVITY_TOKEN: //Gravity token //wait for collision if (entities[i].state == 1) { @@ -2659,7 +2681,7 @@ bool entityclass::updateentities( int i ) } break; - case 5: //Particle sprays + case EntityType_PARTICLE: //Particle sprays if (entities[i].state == 0) { entities[i].life--; @@ -2669,7 +2691,7 @@ bool entityclass::updateentities( int i ) } } break; - case 6: //Small pickup + case EntityType_COIN: //Small pickup //wait for collision if (entities[i].state == 1) { @@ -2682,7 +2704,7 @@ bool entityclass::updateentities( int i ) return disableentity(i); } break; - case 7: //Found a trinket + case EntityType_TRINKET: //Found a trinket //wait for collision if (entities[i].state == 1) { @@ -2710,14 +2732,14 @@ bool entityclass::updateentities( int i ) return disableentity(i); } break; - case 8: //Savepoints + case EntityType_CHECKPOINT: //Savepoints //wait for collision if (entities[i].state == 1) { //First, deactivate all other savepoints for (size_t j = 0; j < entities.size(); j++) { - if (entities[j].type == 8) + if (entities[j].type == EntityType_CHECKPOINT) { entities[j].colour = 4; entities[j].onentity = 1; @@ -2753,7 +2775,7 @@ bool entityclass::updateentities( int i ) game.checkpoint_save(); } break; - case 9: //Gravity Lines + case EntityType_HORIZONTAL_GRAVITY_LINE: //Gravity Lines if (entities[i].state == 1) { entities[i].life--; @@ -2766,7 +2788,7 @@ bool entityclass::updateentities( int i ) } } break; - case 10: //Vertical gravity Lines + case EntityType_VERTICAL_GRAVITY_LINE: //Vertical gravity Lines if (entities[i].state == 1) { entities[i].onentity = 3; @@ -2808,7 +2830,7 @@ bool entityclass::updateentities( int i ) entities[i].state = 2; } break; - case 11: //Warp point + case EntityType_WARP_TOKEN: //Warp point //wait for collision if (entities[i].state == 1) { @@ -2826,7 +2848,7 @@ bool entityclass::updateentities( int i ) if (int(entities[i].xp) == 21*8) game.teleportxpos = 4; } break; - case 12: //Crew member + case EntityType_CREWMATE: //Crew member //Somewhat complex AI: exactly what they do depends on room, location, state etc //At state 0, do nothing at all. if (entities[i].state == 1) @@ -3161,7 +3183,7 @@ bool entityclass::updateentities( int i ) } } break; - case 13: //Terminals (very similar to savepoints) + case EntityType_TERMINAL: //Terminals (very similar to savepoints) //wait for collision if (entities[i].state == 1) { @@ -3172,7 +3194,7 @@ bool entityclass::updateentities( int i ) entities[i].state = 0; } break; - case 14: //Super Crew member + case EntityType_SUPERCREWMATE: //Super Crew member //Actually needs less complex AI than the scripting crewmember if (entities[i].state == 0) { @@ -3228,7 +3250,7 @@ bool entityclass::updateentities( int i ) } } break; - case 15: //Trophy + case EntityType_TROPHY: //Trophy //wait for collision if (entities[i].state == 1) { @@ -3239,7 +3261,7 @@ bool entityclass::updateentities( int i ) entities[i].state = 0; } break; - case 23: + case EntityType_GRAVITRON_ENEMY: //swn game! switch(entities[i].behave) { @@ -3266,7 +3288,7 @@ bool entityclass::updateentities( int i ) } break; - case 51: //Vertical warp line + case EntityType_WARP_LINE_LEFT: //Vertical warp line if (entities[i].state == 2){ int j=getplayer(); if(INBOUNDS_VEC(j, entities) && entities[j].xp<=307){ @@ -3281,7 +3303,7 @@ bool entityclass::updateentities( int i ) customwarpmodevon=true; } break; - case 52: //Vertical warp line + case EntityType_WARP_LINE_RIGHT: //Vertical warp line if (entities[i].state == 2){ int j=getplayer(); if(INBOUNDS_VEC(j, entities) && entities[j].xp<=307){ @@ -3296,7 +3318,7 @@ bool entityclass::updateentities( int i ) customwarpmodevon=true; } break; - case 53: //Warp lines Horizonal + case EntityType_WARP_LINE_TOP: //Warp lines Horizonal if (entities[i].state == 2){ customwarpmodehon=false; entities[i].state = 0; @@ -3308,7 +3330,7 @@ bool entityclass::updateentities( int i ) customwarpmodehon=true; } break; - case 54: //Warp lines Horizonal + case EntityType_WARP_LINE_BOTTOM: //Warp lines Horizonal if (entities[i].state == 2){ customwarpmodehon=false; entities[i].state = 0; @@ -3320,7 +3342,7 @@ bool entityclass::updateentities( int i ) customwarpmodehon=true; } break; - case 55: //Collectable crewmate + case EntityType_COLLECTABLE_CREWMATE: //Collectable crewmate //wait for collision if (entities[i].state == 0) { @@ -3357,7 +3379,7 @@ bool entityclass::updateentities( int i ) return disableentity(i); } break; - case 100: //The teleporter + case EntityType_TELEPORTER: //The teleporter if (entities[i].state == 1) { //if inactive, activate! @@ -3383,7 +3405,7 @@ bool entityclass::updateentities( int i ) //First, deactivate all other savepoints for (size_t j = 0; j < entities.size(); j++) { - if (entities[j].type == 8) + if (entities[j].type == EntityType_CHECKPOINT) { entities[j].colour = 4; entities[j].onentity = 1; @@ -3422,6 +3444,8 @@ bool entityclass::updateentities( int i ) entities[i].state = 0; } break; + case EntityType_INVALID: // Invalid entity, do nothing! + break; } } else @@ -3448,7 +3472,7 @@ void entityclass::animateentities( int _i ) { switch(entities[_i].type) { - case 0: + case EntityType_PLAYER: entities[_i].framedelay--; if(entities[_i].dir==1) { @@ -3497,8 +3521,8 @@ void entityclass::animateentities( int _i ) if (game.gravitycontrol == 1) entities[_i].drawframe += 2; } break; - case 1: - case 23: + case EntityType_MOVING: + case EntityType_GRAVITRON_ENEMY: //Variable animation switch(entities[_i].animate) { @@ -3686,10 +3710,10 @@ void entityclass::animateentities( int _i ) break; } break; - case 2: //Disappearing platforms + case EntityType_DISAPPEARING_PLATFORM: //Disappearing platforms entities[_i].drawframe = entities[_i].tile + entities[_i].walkingframe; break; - case 11: + case EntityType_WARP_TOKEN: entities[_i].drawframe = entities[_i].tile; if(entities[_i].animate==2) { @@ -3709,9 +3733,9 @@ void entityclass::animateentities( int _i ) entities[_i].drawframe += entities[_i].walkingframe; } break; - case 12: - case 55: - case 14: //Crew member! Very similar to hero + case EntityType_CREWMATE: + case EntityType_COLLECTABLE_CREWMATE: + case EntityType_SUPERCREWMATE: //Crew member! Very similar to hero entities[_i].framedelay--; if(entities[_i].dir==1) { @@ -3754,7 +3778,7 @@ void entityclass::animateentities( int _i ) //if (game.gravitycontrol == 1) entities[_i].drawframe += 2; } break; - case 100: //the teleporter! + case EntityType_TELEPORTER: //the teleporter! if (entities[_i].tile == 1 || game.noflashingmode) { //it's inactive @@ -3880,7 +3904,7 @@ void entityclass::animatehumanoidcollision(const int i) { ++entity->collisiondrawframe; - if (entity->type == 0 && game.gravitycontrol == 1) + if (entity->type == EntityType_PLAYER && game.gravitycontrol == 1) { entity->collisiondrawframe += 6; } @@ -3896,8 +3920,8 @@ void entityclass::animatehumanoidcollision(const int i) entity->collisiondrawframe = 12; } - if ((entity->type == 0 && game.gravitycontrol == 1) - || (entity->type != 0 && entity->rule == 7)) + if ((entity->type == EntityType_PLAYER && game.gravitycontrol == 1) + || (entity->type != EntityType_PLAYER && entity->rule == 7)) { entity->collisiondrawframe += 2; } @@ -3927,7 +3951,7 @@ int entityclass::getplayer(void) //Returns the index of the first player entity for (size_t i = 0; i < entities.size(); i++) { - if(entities[i].type==0) + if (entities[i].type == EntityType_PLAYER) { return i; } @@ -3941,7 +3965,7 @@ int entityclass::getscm(void) //Returns the supercrewmate for (size_t i = 0; i < entities.size(); i++) { - if(entities[i].type==14) + if (entities[i].type == EntityType_SUPERCREWMATE) { return i; } @@ -3973,7 +3997,7 @@ int entityclass::getcrewman( int t, int fallback /*= 0*/ ) for (size_t i = 0; i < entities.size(); i++) { - if ((entities[i].type == 12 || entities[i].type == 14) + if ((entities[i].type == EntityType_CREWMATE || entities[i].type == EntityType_SUPERCREWMATE) && (entities[i].rule == 6 || entities[i].rule == 7)) { if(entities[i].colour==t) @@ -3998,9 +4022,9 @@ int entityclass::getcustomcrewman( int t ) for (size_t i = 0; i < entities.size(); i++) { - if (entities[i].type == 55) + if (entities[i].type == EntityType_COLLECTABLE_CREWMATE) { - if(entities[i].colour==t) + if (entities[i].colour == t) { return i; } @@ -4014,7 +4038,7 @@ int entityclass::getteleporter(void) { for (size_t i = 0; i < entities.size(); i++) { - if(entities[i].type==100) + if (entities[i].type == EntityType_TELEPORTER) { return i; } @@ -4053,7 +4077,7 @@ bool entityclass::checkdamage(bool scm /*= false*/) //Returns true if player (or supercrewmate) collides with a damagepoint for(size_t i=0; i < entities.size(); i++) { - if((scm && entities[i].type == 14) || (!scm && entities[i].rule == 0)) + if((scm && entities[i].type == EntityType_SUPERCREWMATE) || (!scm && entities[i].rule == 0)) { SDL_Rect temprect; temprect.x = entities[i].xp + entities[i].cx; @@ -4468,7 +4492,7 @@ bool entityclass::testwallsx( int t, int tx, int ty, const bool skipdirblocks ) temprect.w = entities[t].w; temprect.h = entities[t].h; - bool skipblocks = entities[t].rule < 2 || entities[t].type == 14; + bool skipblocks = entities[t].rule < 2 || entities[t].type == EntityType_SUPERCREWMATE; float dx = 0; float dy = 0; if (entities[t].rule == 0) dx = entities[t].vx; @@ -4514,7 +4538,7 @@ bool entityclass::testwallsy( int t, int tx, int ty ) temprect.w = entities[t].w; temprect.h = entities[t].h; - bool skipblocks = entities[t].rule < 2 || entities[t].type == 14; + bool skipblocks = entities[t].rule < 2 || entities[t].type == EntityType_SUPERCREWMATE; float dx = 0; float dy = 0; @@ -4696,13 +4720,13 @@ void entityclass::customwarplinecheck(int i) { for (int j = 0; j < (int) entities.size(); j++) { if (i != j) { if (entities[i].rule == 0 && entities[j].rule == 5 //Player vs vertical line! - && (entities[j].type == 51 || entities[j].type == 52) + && (entities[j].type == EntityType_WARP_LINE_LEFT || entities[j].type == EntityType_WARP_LINE_RIGHT) && entitywarpvlinecollide(i, j)) { customwarpmodevon = true; } if (entities[i].rule == 0 && entities[j].rule == 7 //Player vs horizontal WARP line - && (entities[j].type == 53 || entities[j].type == 54) + && (entities[j].type == EntityType_WARP_LINE_TOP || entities[j].type == EntityType_WARP_LINE_BOTTOM) && entitywarphlinecollide(i, j)) { customwarpmodehon = true; } @@ -4715,7 +4739,7 @@ void entityclass::entitycollisioncheck(void) for (size_t i = 0; i < entities.size(); i++) { bool player = entities[i].rule == 0; - bool scm = game.supercrewmate && entities[i].type == 14; + bool scm = game.supercrewmate && entities[i].type == EntityType_SUPERCREWMATE; if (!player && !scm) { continue; diff --git a/desktop_version/src/LevelDebugger.cpp b/desktop_version/src/LevelDebugger.cpp index b0f64810..b180b704 100644 --- a/desktop_version/src/LevelDebugger.cpp +++ b/desktop_version/src/LevelDebugger.cpp @@ -282,11 +282,11 @@ namespace level_debugger graphics.draw_rect(bounding_box.x, bounding_box.y, bounding_box.w, bounding_box.h, graphics.getRGB(15, 90, 90)); // For gravity lines, show the true hitbox. - if (obj.entities[i].type == 9) + if (obj.entities[i].type == EntityType_HORIZONTAL_GRAVITY_LINE) { graphics.draw_rect(bounding_box.x - 1, bounding_box.y + 1, bounding_box.w + 2, bounding_box.h, graphics.getRGB(90, 90, 15)); } - else if (obj.entities[i].type == 10) + else if (obj.entities[i].type == EntityType_VERTICAL_GRAVITY_LINE) { graphics.fill_rect(bounding_box.x - 2, bounding_box.y - 1, bounding_box.w + 1, bounding_box.h + 2, graphics.getRGB(90, 90, 15)); } @@ -390,33 +390,35 @@ namespace level_debugger // Mostly contains duplicates, but for ease of use switch (entity->type) { - case 0: + case EntityType_PLAYER: // Player render_info(line++, "Gravity", help.String(game.gravitycontrol)); render_info(line++, "Checkpoint", help.String(game.savepoint)); break; - case 1: + case EntityType_MOVING: // Moving platforms and enemies render_info(line++, "Speed", help.String(entity->para)); render_info(line++, "Movement type", help.String(entity->behave)); break; - case 7: + case EntityType_TRINKET: // Trinkets render_info(line++, "ID", help.String(entity->para)); break; - case 8: + case EntityType_CHECKPOINT: // Checkpoints render_info(line++, "ID", help.String(entity->para)); render_info(line++, "Active", game.savepoint == entity->para ? "True" : "False"); break; - case 9: + case EntityType_HORIZONTAL_GRAVITY_LINE: // Horizontal gravity lines render_info(line++, "Horizontal"); break; - case 10: + case EntityType_VERTICAL_GRAVITY_LINE: // Vertical gravity lines render_info(line++, "Vertical"); break; + default: + break; } diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 67dd637a..958bc8b2 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -373,7 +373,7 @@ void gamelogic(void) { if (game.roomx == 111 && game.roomy == 107 && !map.custommode) { - if (obj.entities[i].type == 1) + if (obj.entities[i].type == EntityType_MOVING) { if (obj.entities[i].xp < 152) { @@ -391,7 +391,7 @@ void gamelogic(void) } } } - if (obj.entities[i].type == 2 && obj.entities[i].state == 3) + if (obj.entities[i].type == EntityType_DISAPPEARING_PLATFORM && obj.entities[i].state == 3) { //Ok! super magical exception for the room with the intention death for the shiny trinket //fix this when the maps are finalised @@ -405,7 +405,7 @@ void gamelogic(void) map.settile(18, 9, 59); } } - else if (obj.entities[i].type == 2 && obj.entities[i].state == 2) + else if (obj.entities[i].type == EntityType_DISAPPEARING_PLATFORM && obj.entities[i].state == 2) { //ok, unfortunate case where the disappearing platform hasn't fully disappeared. Accept a little //graphical uglyness to avoid breaking the room! @@ -421,7 +421,7 @@ void gamelogic(void) } if (!entitygone) obj.entities[i].state = 4; } - else if (obj.entities[i].type == 23 && game.swnmode && game.deathseq<15) + else if (obj.entities[i].type == EntityType_GRAVITRON_ENEMY && game.swnmode && game.deathseq<15) { //if playing SWN, get the enemies offscreen. obj.entities[i].xp += obj.entities[i].vx*5; @@ -730,7 +730,7 @@ void gamelogic(void) bool square_onscreen = false; for (size_t i = 0; i < obj.entities.size(); i++) { - if (obj.entities[i].type == 23) + if (obj.entities[i].type == EntityType_GRAVITRON_ENEMY) { square_onscreen = true; break; @@ -1036,9 +1036,11 @@ void gamelogic(void) size_t i; for (i = 0; i < obj.entities.size(); ++i) { - if ((obj.entities[i].type >= 51 - && obj.entities[i].type <= 54) /* Don't warp warp lines */ - || obj.entities[i].size == 12) /* Don't warp gravitron squares */ + if (obj.entities[i].type == EntityType_WARP_LINE_LEFT + || obj.entities[i].type == EntityType_WARP_LINE_RIGHT + || obj.entities[i].type == EntityType_WARP_LINE_TOP + || obj.entities[i].type == EntityType_WARP_LINE_BOTTOM /* Don't warp warp lines */ + || obj.entities[i].size == 12) /* Don't warp gravitron squares */ { continue; } @@ -1094,8 +1096,10 @@ void gamelogic(void) size_t i; for (i = 0; i < obj.entities.size(); ++i) { - if (obj.entities[i].type >= 51 - && obj.entities[i].type <= 54) /* Don't warp warp lines */ + if (obj.entities[i].type == EntityType_WARP_LINE_LEFT + || obj.entities[i].type == EntityType_WARP_LINE_RIGHT + || obj.entities[i].type == EntityType_WARP_LINE_TOP + || obj.entities[i].type == EntityType_WARP_LINE_BOTTOM) /* Don't warp warp lines */ { continue; } @@ -1126,9 +1130,11 @@ void gamelogic(void) size_t i; for (i = 0; i < obj.entities.size(); ++i) { - if ((obj.entities[i].type >= 51 - && obj.entities[i].type <= 54) /* Don't warp warp lines */ - || obj.entities[i].rule == 0) /* Don't warp the player */ + if ((obj.entities[i].type == EntityType_WARP_LINE_LEFT + || obj.entities[i].type == EntityType_WARP_LINE_RIGHT + || obj.entities[i].type == EntityType_WARP_LINE_TOP + || obj.entities[i].type == EntityType_WARP_LINE_BOTTOM) /* Don't warp warp lines */ + || obj.entities[i].rule == 0) /* Don't warp the player */ { continue; } diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index c6cca16b..c06d21a6 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -519,7 +519,7 @@ void mapclass::changefinalcol(int t) //Next, entities for (size_t i = 0; i < obj.entities.size(); i++) { - if (obj.entities[i].type == 1) //something with a movement behavior + if (obj.entities[i].type == EntityType_MOVING) { if (obj.entities[i].animate == 10 || obj.entities[i].animate == 11) //treadmill { @@ -542,7 +542,7 @@ void mapclass::changefinalcol(int t) obj.entities[i].colour = maptiletoenemycol(temp); } } - else if (obj.entities[i].type == 2) //disappearing platforms + else if (obj.entities[i].type == EntityType_DISAPPEARING_PLATFORM) { obj.entities[i].tile = 915+(temp*40); } @@ -892,7 +892,7 @@ void mapclass::gotoroom(int rx, int ry) //Ok, let's save the position of all lines on the screen for (size_t i = 0; i < obj.entities.size(); i++) { - if (obj.entities[i].type == 9) + if (obj.entities[i].type == EntityType_HORIZONTAL_GRAVITY_LINE) { //It's a horizontal line if (obj.entities[i].xp <= 0 || (obj.entities[i].xp + obj.entities[i].w) >= 312) @@ -1030,7 +1030,7 @@ void mapclass::gotoroom(int rx, int ry) for (size_t i = 0; i < obj.entities.size(); i++) { - if (obj.entities[i].type == 9) + if (obj.entities[i].type == EntityType_HORIZONTAL_GRAVITY_LINE) { //It's a horizontal line if (obj.entities[i].xp <= 0 || obj.entities[i].xp + obj.entities[i].w >= 312) @@ -2058,7 +2058,7 @@ void mapclass::loadlevel(int rx, int ry) for (size_t i = 0; i < obj.entities.size(); i++) { - if (obj.entities[i].type == 1 && obj.entities[i].behave >= 8 && obj.entities[i].behave < 10) + if (obj.entities[i].type == EntityType_MOVING && obj.entities[i].behave >= 8 && obj.entities[i].behave < 10) { //put a block underneath int temp = obj.entities[i].xp / 8.0f; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 75c518d8..5aa50fe5 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -295,7 +295,7 @@ void scriptclass::run(void) { for (size_t edi = 0; edi < obj.entities.size(); edi++) { - if (obj.entities[edi].type == 9 || obj.entities[edi].type == 10) + if (obj.entities[edi].type == EntityType_HORIZONTAL_GRAVITY_LINE || obj.entities[edi].type == EntityType_VERTICAL_GRAVITY_LINE) { obj.disableentity(edi); } @@ -305,7 +305,7 @@ void scriptclass::run(void) { for (size_t edi = 0; edi < obj.entities.size(); edi++) { - if (obj.entities[edi].type == 11) + if (obj.entities[edi].type == EntityType_WARP_TOKEN) { obj.disableentity(edi); } @@ -332,7 +332,7 @@ void scriptclass::run(void) for (size_t edi = 0; edi < obj.entities.size(); edi++) { obj.disableblockat(obj.entities[edi].xp, obj.entities[edi].yp); - if (obj.entities[edi].type == 2 && obj.entities[edi].rule == 3) + if (obj.entities[edi].type == EntityType_DISAPPEARING_PLATFORM && obj.entities[edi].rule == 3) { obj.disableentity(edi); } @@ -1648,7 +1648,7 @@ void scriptclass::run(void) { for (j = 0; j < (int) obj.entities.size(); j++) { - if (obj.entities[j].type == 13) + if (obj.entities[j].type == EntityType_TERMINAL) { obj.entities[j].colour = 4; }