From 14e8ac702f29b413ea9e9af3f7ff672ffab017f9 Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Sat, 31 Oct 2015 14:45:42 -0400 Subject: [PATCH 001/239] Added freeslots for SPR2. Make sure your MAINCFG / LUA lump comes _before_ the S_SKIN section. --- src/dehacked.c | 45 ++++++++++++++++++++++++++++++++++++++++----- src/info.c | 1 + src/info.h | 5 ++++- src/lua_infolib.c | 6 +++--- src/r_things.c | 2 +- 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 0ba054f07..a35025494 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -671,6 +671,22 @@ static void readfreeslots(MYFILE *f) break; } } + else if (fastcmp(type, "SPR2_")) + { + // Search if we already have an SPR2 by that name... + for (i = SPR_FIRSTFREESLOT; i < free_spr2; i++) + if (memcmp(spr2names[i],word,4) == 0) + break; + // We found it? (Two mods using the same SPR2 name?) Then don't allocate another one. + if (i != free_spr2) + continue; + // Copy in the spr2 name and increment free_spr2. + if (free_spr2 < NUMPLAYERSPRITES) { + strncpy(spr2names[free_spr2],word,4); + spr2names[free_spr2++][4] = 0; + } else + CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n"); + } else deh_warning("Freeslots: unknown enum class '%s' for '%s_%s'", type, type, word); } @@ -8292,7 +8308,7 @@ static inline int lib_freeslot(lua_State *L) lua_pushinteger(L, sfx); r++; } else - return r; + CONS_Alert(CONS_WARNING, "Ran out of free SFX slots!\n"); } else if (fastcmp(type, "SPR")) { @@ -8319,7 +8335,7 @@ static inline int lib_freeslot(lua_State *L) break; } if (j > SPR_LASTFREESLOT) - return r; + CONS_Alert(CONS_WARNING, "Ran out of free sprite slots!\n"); } else if (fastcmp(type, "S")) { @@ -8334,7 +8350,7 @@ static inline int lib_freeslot(lua_State *L) break; } if (i == NUMSTATEFREESLOTS) - return r; + CONS_Alert(CONS_WARNING, "Ran out of free State slots!\n"); } else if (fastcmp(type, "MT")) { @@ -8349,7 +8365,26 @@ static inline int lib_freeslot(lua_State *L) break; } if (i == NUMMOBJFREESLOTS) - return r; + CONS_Alert(CONS_WARNING, "Ran out of free MobjType slots!\n"); + } + else if (fastcmp(type, "SPR2")) + { + // Search if we already have an SPR2 by that name... + enum playersprite i; + for (i = SPR_FIRSTFREESLOT; i < free_spr2; i++) + if (memcmp(spr2names[i],word,4) == 0) + break; + // We don't, so allocate a new one. + if (i == free_spr2) { + if (free_spr2 < NUMPLAYERSPRITES) + { + CONS_Printf("Sprite SPR2_%s allocated.\n",word); + strncpy(spr2names[free_spr2],word,4); + spr2names[free_spr2++][4] = 0; + } else + CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n"); + } + r++; } Z_Free(s); lua_remove(L, 1); @@ -8516,7 +8551,7 @@ static inline int lib_getenum(lua_State *L) } else if (fastncmp("SPR2_",word,4)) { p = word+5; - for (i = 0; i < NUMPLAYERSPRITES; i++) + for (i = 0; i < free_spr2; i++) if (!spr2names[i][4]) { // special 3-char cases, e.g. SPR2_RUN diff --git a/src/info.c b/src/info.c index 8d7c249ad..d6ccab1f9 100644 --- a/src/info.c +++ b/src/info.c @@ -99,6 +99,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "SRID", "SFLT" }; +enum playersprite free_spr2 = SPR2_FIRSTFREESLOT; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) state_t states[NUMSTATES] = diff --git a/src/info.h b/src/info.h index e313526b9..67602b301 100644 --- a/src/info.h +++ b/src/info.h @@ -618,6 +618,8 @@ enum playersprite SPR2_SRID, SPR2_SFLT, + SPR2_FIRSTFREESLOT, + SPR2_LASTFREESLOT = SPR2_FIRSTFREESLOT + NUMSPRITEFREESLOTS - 1, NUMPLAYERSPRITES }; @@ -3528,8 +3530,9 @@ typedef struct extern state_t states[NUMSTATES]; extern char sprnames[NUMSPRITES + 1][5]; -char spr2names[NUMPLAYERSPRITES][5]; +extern char spr2names[NUMPLAYERSPRITES][5]; extern state_t *astate; +extern enum playersprite free_spr2; typedef enum mobj_type { diff --git a/src/lua_infolib.c b/src/lua_infolib.c index a983bb002..1925ffd35 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -105,7 +105,7 @@ static int lib_getSpr2name(lua_State *L) if (lua_isnumber(L, 1)) { i = lua_tonumber(L, 1); - if (i > NUMPLAYERSPRITES) + if (i >= free_spr2) return 0; lua_pushlstring(L, spr2names[i], 4); return 1; @@ -113,7 +113,7 @@ static int lib_getSpr2name(lua_State *L) else if (lua_isstring(L, 1)) { const char *name = lua_tostring(L, 1); - for (i = 0; i < NUMPLAYERSPRITES; i++) + for (i = 0; i < free_spr2; i++) if (fastcmp(name, spr2names[i])) { lua_pushinteger(L, i); @@ -125,7 +125,7 @@ static int lib_getSpr2name(lua_State *L) static int lib_spr2namelen(lua_State *L) { - lua_pushinteger(L, NUMPLAYERSPRITES); + lua_pushinteger(L, free_spr2); return 1; } diff --git a/src/r_things.c b/src/r_things.c index 60fbad1af..461ac978c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2671,7 +2671,7 @@ next_token: if (z < lastlump) lastlump = z; // load all sprite sets we are aware of. - for (sprite2 = 0; sprite2 < NUMPLAYERSPRITES; sprite2++) + for (sprite2 = 0; sprite2 < free_spr2; sprite2++) R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[sprite2], wadnum, lump, lastlump); } From 24ab56691e6fd1cb194039322da2bac4cdae7dad Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Tue, 10 Nov 2015 20:33:01 -0500 Subject: [PATCH 002/239] Fixed spr2 freslot logic bug. --- src/dehacked.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index a35025494..3a9782074 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -671,7 +671,7 @@ static void readfreeslots(MYFILE *f) break; } } - else if (fastcmp(type, "SPR2_")) + else if (fastcmp(type, "SPR2")) { // Search if we already have an SPR2 by that name... for (i = SPR_FIRSTFREESLOT; i < free_spr2; i++) From 4e2cc2c2001a01130020206c6467cb4c2d3e9213 Mon Sep 17 00:00:00 2001 From: Yukita Mayako Date: Tue, 10 Nov 2015 20:45:53 -0500 Subject: [PATCH 003/239] Fixed more logic bugs. SPR_FIRSTFREESLOT is not the same as SPR2_FIRSTFREESLOT. What was I, drunk? --- src/dehacked.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 3a9782074..09da3ee6e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -674,11 +674,11 @@ static void readfreeslots(MYFILE *f) else if (fastcmp(type, "SPR2")) { // Search if we already have an SPR2 by that name... - for (i = SPR_FIRSTFREESLOT; i < free_spr2; i++) + for (i = SPR2_FIRSTFREESLOT; i < free_spr2; i++) if (memcmp(spr2names[i],word,4) == 0) break; // We found it? (Two mods using the same SPR2 name?) Then don't allocate another one. - if (i != free_spr2) + if (i < free_spr2) continue; // Copy in the spr2 name and increment free_spr2. if (free_spr2 < NUMPLAYERSPRITES) { @@ -8371,11 +8371,11 @@ static inline int lib_freeslot(lua_State *L) { // Search if we already have an SPR2 by that name... enum playersprite i; - for (i = SPR_FIRSTFREESLOT; i < free_spr2; i++) + for (i = SPR2_FIRSTFREESLOT; i < free_spr2; i++) if (memcmp(spr2names[i],word,4) == 0) break; // We don't, so allocate a new one. - if (i == free_spr2) { + if (i >= free_spr2) { if (free_spr2 < NUMPLAYERSPRITES) { CONS_Printf("Sprite SPR2_%s allocated.\n",word); From ebd2bdd1c82eaef65526de767dc9a40401f63393 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Fri, 1 Jan 2016 14:53:29 -0600 Subject: [PATCH 004/239] Add CA_DASHMODE to the game This works fine in single player on vanilla builds, multiplayer is untested. This might not be the best way to handle the ability, so modifications for efficiency/sanity might be necessary. --- src/d_player.h | 3 ++- src/dehacked.c | 1 + src/p_user.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index e2a1081b0..08c98b7a3 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -57,7 +57,8 @@ typedef enum CA_FALLSWITCH, CA_JUMPBOOST, CA_AIRDRILL, - CA_JUMPTHOK + CA_JUMPTHOK, + CA_DASHMODE } charability_t; //Secondary skin abilities diff --git a/src/dehacked.c b/src/dehacked.c index 0ba054f07..3fd05ffe6 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7623,6 +7623,7 @@ struct { {"CA_JUMPBOOST",CA_JUMPBOOST}, {"CA_AIRDRILL",CA_AIRDRILL}, {"CA_JUMPTHOK",CA_JUMPTHOK}, + {"CA_DASHMODE",CA_DASHMODE}, // Secondary {"CA2_NONE",CA2_NONE}, // now slot 0! {"CA2_SPINDASH",CA2_SPINDASH}, diff --git a/src/p_user.c b/src/p_user.c index 8854d8d64..4b307feca 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4072,6 +4072,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) case CA_THOK: case CA_HOMINGTHOK: case CA_JUMPTHOK: // Credit goes to CZ64 and Sryder13 for the original + case CA_DASHMODE: // Credit goes to Iceman404 // Now it's Sonic's abilities turn! // THOK! if (!(player->pflags & PF_THOKKED) || (player->charability2 == CA2_MULTIABILITY)) @@ -8664,6 +8665,8 @@ void P_DoPityCheck(player_t *player) // boolean playerdeadview; // show match/chaos/tag/capture the flag rankings while in death view +INT32 dashmode = 0; // initial variable set for CA_DASHMODE +boolean dashmodeflag = false; void P_PlayerThink(player_t *player) { @@ -9148,6 +9151,63 @@ void P_PlayerThink(player_t *player) player->pflags &= ~PF_SLIDING; + // Dash mode ability for Metal Sonic + if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. + { + fixed_t defspeed = skins[player->skin].normalspeed; // Default normalspeed. + fixed_t maxtop = skins[player->skin].normalspeed * 55/36; + + if (!(player->speed > player->normalspeed)) //are we currently exceeding our normalspeed? + player->actionspd = player->normalspeed; //if not, force thok to normalspeed + else + player->actionspd = player->speed; //otherwise, thok at your current speed (this fixes super and speedshoes thok slowing you down) + + if (player->speed >= (defspeed - 5*FRACUNIT) || (player->pflags & PF_STARTDASH)) + { + dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. + if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. + S_StartSound(player->mo, sfx_s3ka2); // If the player enters dashmode, play this sound on the the tic it starts. + } + else if (!(player->pflags & PF_SPINNING)) + { + if (dashmode > 0) + dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! + else if (dashmode < 0) + dashmode = 0; + } + + if (dashmode >= 3*TICRATE && P_IsObjectOnGround(player->mo)) // Dash Mode can continue counting in the air, but will only activate on floor touch. + dashmodeflag = true; + + if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. + { + player->normalspeed = defspeed; // Reset to default if not capable of entering dash mode. + player->jumpfactor = 1*FRACUNIT; + dashmodeflag = false; + } + + //WHEN PARAMETERS ARE MET, REWARD THE DASH MODE EFFECTS + if (dashmodeflag) + { + if (player->normalspeed < maxtop) // If the player is not currently at 50 normalspeed in dash mode, add speed each tic + { + player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. + if (player->jumpfactor < 5*FRACUNIT/4) + player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; // Boosts his jumpheight. Remember fractions instead of decimals. "1.5*FRACUNIT = 3*FRACUNIT/2" + } + } + + //COSMETIC STUPIDITY! + if (dashmode > 108) //Dash Mode will go down a tic a bit above activation, this makes dust spawn every other tic. + dashmode = 107; + + if (player->normalspeed >= maxtop) + { + mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages + ghost->fuse = 2; // Makes the images fade quickly + } + } + /* // Colormap verification { From a15a4ace7e8bac122a90ddc6645f76f76de1ff87 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 22:34:55 -0600 Subject: [PATCH 005/239] Do dashmode thok speed adjustments at thok instead of modifying actionspd --- src/p_user.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 4b307feca..034bab498 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4079,13 +4079,19 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { // Catapult the player fixed_t actionspd = player->actionspd; + + if (player->charability == CA_DASHMODE) + actionspd = max(player->normalspeed, FixedDiv(player->speed, player->mo->scale)); + if (player->mo->eflags & MFE_UNDERWATER) actionspd >>= 1; + if ((player->charability == CA_JUMPTHOK) && !(player->pflags & PF_THOKKED)) { player->pflags &= ~PF_JUMPED; P_DoJump(player, false); } + P_InstaThrust(player->mo, player->mo->angle, FixedMul(actionspd, player->mo->scale)); if (maptol & TOL_2D) From ba8c0dfc6e55e1116aa93b3ce4b030711340d114 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 22:58:35 -0600 Subject: [PATCH 006/239] Clean up dash mode and make multiplayer-compatible Actionspd is now the running speed in dashmode. --- src/p_user.c | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 034bab498..802e7f9c3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8671,8 +8671,6 @@ void P_DoPityCheck(player_t *player) // boolean playerdeadview; // show match/chaos/tag/capture the flag rankings while in death view -INT32 dashmode = 0; // initial variable set for CA_DASHMODE -boolean dashmodeflag = false; void P_PlayerThink(player_t *player) { @@ -9160,15 +9158,10 @@ void P_PlayerThink(player_t *player) // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { - fixed_t defspeed = skins[player->skin].normalspeed; // Default normalspeed. +#define dashmode player->glidetime fixed_t maxtop = skins[player->skin].normalspeed * 55/36; - if (!(player->speed > player->normalspeed)) //are we currently exceeding our normalspeed? - player->actionspd = player->normalspeed; //if not, force thok to normalspeed - else - player->actionspd = player->speed; //otherwise, thok at your current speed (this fixes super and speedshoes thok slowing you down) - - if (player->speed >= (defspeed - 5*FRACUNIT) || (player->pflags & PF_STARTDASH)) + if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. @@ -9176,42 +9169,32 @@ void P_PlayerThink(player_t *player) } else if (!(player->pflags & PF_SPINNING)) { - if (dashmode > 0) + if (dashmode > 3) dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! - else if (dashmode < 0) + else dashmode = 0; } - - if (dashmode >= 3*TICRATE && P_IsObjectOnGround(player->mo)) // Dash Mode can continue counting in the air, but will only activate on floor touch. - dashmodeflag = true; if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { - player->normalspeed = defspeed; // Reset to default if not capable of entering dash mode. - player->jumpfactor = 1*FRACUNIT; - dashmodeflag = false; + player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. + player->jumpfactor = skins[player->skin].jumpfactor; } - - //WHEN PARAMETERS ARE MET, REWARD THE DASH MODE EFFECTS - if (dashmodeflag) + else if (P_IsObjectOnGround(player->mo)) // Activate dash mode if we're on the ground. { - if (player->normalspeed < maxtop) // If the player is not currently at 50 normalspeed in dash mode, add speed each tic - { + if (player->normalspeed < skins[player->skin].actionspd) // If the player normalspeed is not currently at actionspd in dash mode, add speed each tic player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. - if (player->jumpfactor < 5*FRACUNIT/4) - player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; // Boosts his jumpheight. Remember fractions instead of decimals. "1.5*FRACUNIT = 3*FRACUNIT/2" - } + + if (player->jumpfactor < FixedMul(skins[player->skin].jumpfactor, 5*FRACUNIT/4)) // Boost jump height. + player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; } - - //COSMETIC STUPIDITY! - if (dashmode > 108) //Dash Mode will go down a tic a bit above activation, this makes dust spawn every other tic. - dashmode = 107; - - if (player->normalspeed >= maxtop) + + if (player->normalspeed >= skins[player->skin].actionspd) { mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages ghost->fuse = 2; // Makes the images fade quickly } +#undef dashmode } /* From c38af2c6a2751336da1512d9e3a15ec1e75c565e Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 23:26:22 -0600 Subject: [PATCH 007/239] Remove unused maxtop variable --- src/p_user.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 802e7f9c3..3b0d48628 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9159,8 +9159,6 @@ void P_PlayerThink(player_t *player) if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { #define dashmode player->glidetime - fixed_t maxtop = skins[player->skin].normalspeed * 55/36; - if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. From 732003bcb97d9a5cd152f39f9e98493d285bbd9d Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 14 Jan 2016 17:11:16 +0000 Subject: [PATCH 008/239] Quick fixes for unsigned-signed compiler warnings probably not the most ideal way of doing this to be fair though --- src/dehacked.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 09da3ee6e..f3d1fa1bf 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -674,11 +674,11 @@ static void readfreeslots(MYFILE *f) else if (fastcmp(type, "SPR2")) { // Search if we already have an SPR2 by that name... - for (i = SPR2_FIRSTFREESLOT; i < free_spr2; i++) + for (i = SPR2_FIRSTFREESLOT; i < (int)free_spr2; i++) if (memcmp(spr2names[i],word,4) == 0) break; // We found it? (Two mods using the same SPR2 name?) Then don't allocate another one. - if (i < free_spr2) + if (i < (int)free_spr2) continue; // Copy in the spr2 name and increment free_spr2. if (free_spr2 < NUMPLAYERSPRITES) { @@ -8551,7 +8551,7 @@ static inline int lib_getenum(lua_State *L) } else if (fastncmp("SPR2_",word,4)) { p = word+5; - for (i = 0; i < free_spr2; i++) + for (i = 0; i < (fixed_t)free_spr2; i++) if (!spr2names[i][4]) { // special 3-char cases, e.g. SPR2_RUN From 95d6cba18405b5ce7f9224e1849b3f0751bc6f02 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Mon, 25 Jan 2016 01:49:37 -0600 Subject: [PATCH 009/239] [HACK] Make dashmode work again Fixed one of Red's mistakes, and used a different struct variable for dashmode. This needs to be changed though, because everything will break if someone loads a circuit map. --- src/p_user.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 3b0d48628..91bbfc6f2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9158,7 +9158,7 @@ void P_PlayerThink(player_t *player) // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { -#define dashmode player->glidetime +#define dashmode player->laps if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. @@ -9168,10 +9168,13 @@ void P_PlayerThink(player_t *player) else if (!(player->pflags & PF_SPINNING)) { if (dashmode > 3) - dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! + dashmode -= 3; // Rather than lose it all, it gently counts back down! else dashmode = 0; } + + if (dashmode > 254) + dashmode = 3*TICRATE+1; if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { From 67b92d727344ab66bb5e070a9d45e8e647942c87 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 Jan 2016 11:47:33 +0000 Subject: [PATCH 010/239] Went and fixed the dashmode variable hack nonsense once and for all myself would have gone for "dashtime", but then I was reminded that was already a name for something to do with spindash. Oh well --- src/d_clisrv.c | 2 ++ src/d_clisrv.h | 1 + src/d_player.h | 1 + src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 2 ++ src/p_user.c | 11 ++++++----- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 31738e9b2..ee2d18961 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -531,6 +531,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->deadtimer = players[i].deadtimer; rsp->exiting = (tic_t)LONG(players[i].exiting); rsp->homing = players[i].homing; + rsp->dashmode = (tic_t)LONG(players[i].dashmode); rsp->cmomx = (fixed_t)LONG(players[i].cmomx); rsp->cmomy = (fixed_t)LONG(players[i].cmomy); rsp->rmomx = (fixed_t)LONG(players[i].rmomx); @@ -656,6 +657,7 @@ static void resynch_read_player(resynch_pak *rsp) players[i].deadtimer = rsp->deadtimer; players[i].exiting = (tic_t)LONG(rsp->exiting); players[i].homing = rsp->homing; + players[i].dashmode = (tic_t)LONG(rsp->dashmode); players[i].cmomx = (fixed_t)LONG(rsp->cmomx); players[i].cmomy = (fixed_t)LONG(rsp->cmomy); players[i].rmomx = (fixed_t)LONG(rsp->rmomx); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 6bc06f13a..2bcfad176 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -191,6 +191,7 @@ typedef struct INT32 deadtimer; tic_t exiting; UINT8 homing; + tic_t dashmode; fixed_t cmomx; fixed_t cmomy; fixed_t rmomx; diff --git a/src/d_player.h b/src/d_player.h index 08c98b7a3..a3acb8728 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -352,6 +352,7 @@ typedef struct player_s tic_t exiting; // Exitlevel timer UINT8 homing; // Are you homing? + tic_t dashmode; // counter for dashmode ability tic_t skidtime; // Skid timer diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 64513ab97..b03833354 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -202,6 +202,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->exiting); else if (fastcmp(field,"homing")) lua_pushinteger(L, plr->homing); + else if (fastcmp(field,"dashmode")) + lua_pushinteger(L, plr->dashmode); else if (fastcmp(field,"skidtime")) lua_pushinteger(L, plr->skidtime); else if (fastcmp(field,"cmomx")) @@ -452,6 +454,8 @@ static int player_set(lua_State *L) plr->exiting = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"homing")) plr->homing = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"dashmode")) + plr->dashmode = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"skidtime")) plr->skidtime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"cmomx")) diff --git a/src/p_saveg.c b/src/p_saveg.c index 07e7b3564..a574afb55 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -162,6 +162,7 @@ static inline void P_NetArchivePlayers(void) WRITEINT32(save_p, players[i].deadtimer); WRITEUINT32(save_p, players[i].exiting); WRITEUINT8(save_p, players[i].homing); + WRITEUINT32(save_p, players[i].dashmode); WRITEUINT32(save_p, players[i].skidtime); //////////////////////////// @@ -337,6 +338,7 @@ static inline void P_NetUnArchivePlayers(void) players[i].deadtimer = READINT32(save_p); // End game if game over lasts too long players[i].exiting = READUINT32(save_p); // Exitlevel timer players[i].homing = READUINT8(save_p); // Are you homing? + players[i].dashmode = READUINT32(save_p); // counter for dashmode ability players[i].skidtime = READUINT32(save_p); // Skid timer //////////////////////////// diff --git a/src/p_user.c b/src/p_user.c index 91bbfc6f2..8a6d8b871 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9155,10 +9155,10 @@ void P_PlayerThink(player_t *player) player->pflags &= ~PF_SLIDING; +#define dashmode player->dashmode // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { -#define dashmode player->laps if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. @@ -9172,10 +9172,10 @@ void P_PlayerThink(player_t *player) else dashmode = 0; } - + if (dashmode > 254) dashmode = 3*TICRATE+1; - + if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. @@ -9195,9 +9195,10 @@ void P_PlayerThink(player_t *player) mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages ghost->fuse = 2; // Makes the images fade quickly } -#undef dashmode } - + else + dashmode = 0; +#undef dashmode /* // Colormap verification { From e314b442b2762d79df4f07d5a6da0ae0d6c6c57c Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Mon, 25 Jan 2016 20:26:31 -0600 Subject: [PATCH 011/239] Remove dashmode limit since tic_t is UINT32 This might be overpowered as hell. Needs testing for sure. --- src/p_user.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 8a6d8b871..3c86c3621 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9173,9 +9173,6 @@ void P_PlayerThink(player_t *player) dashmode = 0; } - if (dashmode > 254) - dashmode = 3*TICRATE+1; - if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. From 560d7d9aae52260626266d45f9112ed6532b9f6b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 3 Mar 2016 22:38:06 +0000 Subject: [PATCH 012/239] Sideways springs, horizontal hog-launchers, perpendicular plungers... Call them what you like, they're in the game now --- src/dehacked.c | 33 ++++++++++++ src/info.c | 133 +++++++++++++++++++++++++++++++++++++++++++++---- src/info.h | 36 +++++++++++++ 3 files changed, 191 insertions(+), 11 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 7b527eeef..45e2486e0 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5463,6 +5463,36 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_RDIAG7", "S_RDIAG8", + // Yellow Side Spring + "S_YHORIZ1", + "S_YHORIZ2", + "S_YHORIZ3", + "S_YHORIZ4", + "S_YHORIZ5", + "S_YHORIZ6", + "S_YHORIZ7", + "S_YHORIZ8", + + // Red Side Spring + "S_RHORIZ1", + "S_RHORIZ2", + "S_RHORIZ3", + "S_RHORIZ4", + "S_RHORIZ5", + "S_RHORIZ6", + "S_RHORIZ7", + "S_RHORIZ8", + + // Blue Side Spring + "S_BHORIZ1", + "S_BHORIZ2", + "S_BHORIZ3", + "S_BHORIZ4", + "S_BHORIZ5", + "S_BHORIZ6", + "S_BHORIZ7", + "S_BHORIZ8", + // Rain "S_RAIN1", "S_RAINRETURN", @@ -6222,6 +6252,9 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s "MT_REDSPRING", "MT_YELLOWDIAG", // Yellow Diagonal Spring "MT_REDDIAG", // Red Diagonal Spring + "MT_YELLOWHORIZ", // Yellow Side Spring + "MT_REDHORIZ", // Red Side Spring + "MT_BLUEHORIZ", // Blue Side Spring // Interactive Objects "MT_BUBBLES", // Bubble source diff --git a/src/info.c b/src/info.c index ec1a8926e..cb5d436cf 100644 --- a/src/info.c +++ b/src/info.c @@ -43,17 +43,17 @@ char sprnames[NUMSPRITES + 1][5] = "DFLM","XMS1","XMS2","XMS3","BSZ1","BSZ2","BSZ3","BSZ4","BSZ5","BSZ6", "BSZ7","BSZ8","STLG","DBAL","RCRY","ARMA","ARMF","ARMB","WIND","MAGN", "ELEM","FORC","PITY","IVSP","SSPK","GOAL","BIRD","BUNY","MOUS","CHIC", - "COWZ","RBRD","SPRY","SPRR","SPRB","YSPR","RSPR","RAIN","SNO1","SPLH", - "SPLA","SMOK","BUBP","BUBO","BUBN","BUBM","POPP","TFOG","SEED","PRTL", - "SCOR","DRWN","TTAG","GFLG","RRNG","RNGB","RNGR","RNGI","RNGA","RNGE", - "RNGS","RNGG","PIKB","PIKR","PIKA","PIKE","PIKS","PIKG","TAUT","TGRE", - "TSCR","COIN","CPRK","GOOM","BGOM","FFWR","FBLL","SHLL","PUMA","HAMM", - "KOOP","BFLM","MAXE","MUS1","MUS2","TOAD","NDRN","SUPE","SUPZ","NDRL", - "NSPK","NBMP","HOOP","NSCR","NPRU","CAPS","SUPT","SPRK","BOM1","BOM2", - "BOM3","BOM4","ROIA","ROIB","ROIC","ROID","ROIE","ROIF","ROIG","ROIH", - "ROII","ROIJ","ROIK","ROIL","ROIM","ROIN","ROIO","ROIP","BBAL","GWLG", - "GWLR","SRBA","SRBB","SRBC","SRBD","SRBE","SRBF","SRBG","SRBH","SRBI", - "SRBJ","SRBK","SRBL","SRBM","SRBN","SRBO", + "COWZ","RBRD","SPRY","SPRR","SPRB","YSPR","RSPR","SSWY","SSWR","SSWB", + "RAIN","SNO1","SPLH","SPLA","SMOK","BUBP","BUBO","BUBN","BUBM","POPP", + "TFOG","SEED","PRTL","SCOR","DRWN","TTAG","GFLG","RRNG","RNGB","RNGR", + "RNGI","RNGA","RNGE","RNGS","RNGG","PIKB","PIKR","PIKA","PIKE","PIKS", + "PIKG","TAUT","TGRE","TSCR","COIN","CPRK","GOOM","BGOM","FFWR","FBLL", + "SHLL","PUMA","HAMM","KOOP","BFLM","MAXE","MUS1","MUS2","TOAD","NDRN", + "SUPE","SUPZ","NDRL","NSPK","NBMP","HOOP","NSCR","NPRU","CAPS","SUPT", + "SPRK","BOM1","BOM2","BOM3","BOM4","ROIA","ROIB","ROIC","ROID","ROIE", + "ROIF","ROIG","ROIH","ROII","ROIJ","ROIK","ROIL","ROIM","ROIN","ROIO", + "ROIP","BBAL","GWLG","GWLR","SRBA","SRBB","SRBC","SRBD","SRBE","SRBF", + "SRBG","SRBH","SRBI","SRBJ","SRBK","SRBL","SRBM","SRBN","SRBO", }; char spr2names[NUMPLAYERSPRITES][5] = @@ -1850,6 +1850,36 @@ state_t states[NUMSTATES] = {SPR_RSPR, 2, 1, {NULL}, 0, 0, S_RDIAG8}, // S_RDIAG7 {SPR_RSPR, 1, 1, {NULL}, 0, 0, S_RDIAG1}, // S_RDIAG8 + // Yellow Side Spring + {SPR_SSWY, 0, -1, {NULL}, 0, 0, S_NULL}, // S_YHORIZ1 + {SPR_SSWY, 1, 1, {A_Pain}, 0, 0, S_YHORIZ3}, // S_YHORIZ2 + {SPR_SSWY, 2, 1, {NULL}, 0, 0, S_YHORIZ4}, // S_YHORIZ3 + {SPR_SSWY, 3, 1, {NULL}, 0, 0, S_YHORIZ5}, // S_YHORIZ4 + {SPR_SSWY, 4, 1, {NULL}, 0, 0, S_YHORIZ6}, // S_YHORIZ5 + {SPR_SSWY, 3, 1, {NULL}, 0, 0, S_YHORIZ7}, // S_YHORIZ6 + {SPR_SSWY, 2, 1, {NULL}, 0, 0, S_YHORIZ8}, // S_YHORIZ7 + {SPR_SSWY, 1, 1, {NULL}, 0, 0, S_YHORIZ1}, // S_YHORIZ8 + + // Red Side Spring + {SPR_SSWR, 0, -1, {NULL}, 0, 0, S_NULL}, // S_RHORIZ1 + {SPR_SSWR, 1, 1, {A_Pain}, 0, 0, S_RHORIZ3}, // S_RHORIZ2 + {SPR_SSWR, 2, 1, {NULL}, 0, 0, S_RHORIZ4}, // S_RHORIZ3 + {SPR_SSWR, 3, 1, {NULL}, 0, 0, S_RHORIZ5}, // S_RHORIZ4 + {SPR_SSWR, 4, 1, {NULL}, 0, 0, S_RHORIZ6}, // S_RHORIZ5 + {SPR_SSWR, 3, 1, {NULL}, 0, 0, S_RHORIZ7}, // S_RHORIZ6 + {SPR_SSWR, 2, 1, {NULL}, 0, 0, S_RHORIZ8}, // S_RHORIZ7 + {SPR_SSWR, 1, 1, {NULL}, 0, 0, S_RHORIZ1}, // S_RHORIZ8 + + // Blue Side Spring + {SPR_SSWB, 0, -1, {NULL}, 0, 0, S_NULL}, // S_BHORIZ1 + {SPR_SSWB, 1, 1, {A_Pain}, 0, 0, S_BHORIZ3}, // S_BHORIZ2 + {SPR_SSWB, 2, 1, {NULL}, 0, 0, S_BHORIZ4}, // S_BHORIZ3 + {SPR_SSWB, 3, 1, {NULL}, 0, 0, S_BHORIZ5}, // S_BHORIZ4 + {SPR_SSWB, 4, 1, {NULL}, 0, 0, S_BHORIZ6}, // S_BHORIZ5 + {SPR_SSWB, 3, 1, {NULL}, 0, 0, S_BHORIZ7}, // S_BHORIZ6 + {SPR_SSWB, 2, 1, {NULL}, 0, 0, S_BHORIZ8}, // S_BHORIZ7 + {SPR_SSWB, 1, 1, {NULL}, 0, 0, S_BHORIZ1}, // S_BHORIZ8 + // Rain {SPR_RAIN, FF_TRANS50, -1, {NULL}, 0, 0, S_NULL}, // S_RAIN1 {SPR_RAIN, FF_TRANS50, 1, {NULL}, 0, 0, S_RAIN1}, // S_RAINRETURN @@ -5283,6 +5313,87 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_RDIAG2 // raisestate }, + { // MT_YELLOWHORIZ + 558, // doomednum + S_YHORIZ1, // spawnstate + 1, // spawnhealth + S_YHORIZ2, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_spring, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 16*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 0, // mass + 16*FRACUNIT, // damage + sfx_None, // activesound + MF_SOLID|MF_SPRING|MF_NOGRAVITY, // flags + S_YHORIZ2 // raisestate + }, + + { // MT_REDHORIZ + 559, // doomednum + S_RHORIZ1, // spawnstate + 1, // spawnhealth + S_RHORIZ2, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_spring, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 16*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 0, // mass + 64*FRACUNIT, // damage + sfx_None, // activesound + MF_SOLID|MF_SPRING|MF_NOGRAVITY, // flags + S_RHORIZ2 // raisestate + }, + + { // MT_BLUEHORIZ + 560, // doomednum + S_BHORIZ1, // spawnstate + 1, // spawnhealth + S_BHORIZ2, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_spring, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 16*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 0, // mass + 4*FRACUNIT, // damage + sfx_None, // activesound + MF_SOLID|MF_SPRING|MF_NOGRAVITY, // flags + S_BHORIZ2 // raisestate + }, + { // MT_BUBBLES 500, // doomednum S_BUBBLES1, // spawnstate diff --git a/src/info.h b/src/info.h index 677d0f9e4..83faf87c4 100644 --- a/src/info.h +++ b/src/info.h @@ -448,6 +448,9 @@ typedef enum sprite SPR_SPRB, // Blue springs SPR_YSPR, // Yellow Diagonal Spring SPR_RSPR, // Red Diagonal Spring + SPR_SSWY, // Yellow Side Spring + SPR_SSWR, // Red Side Spring + SPR_SSWB, // Blue Side Spring // Environmental Effects SPR_RAIN, // Rain @@ -2348,6 +2351,36 @@ typedef enum state S_RDIAG7, S_RDIAG8, + // Yellow Side Spring + S_YHORIZ1, + S_YHORIZ2, + S_YHORIZ3, + S_YHORIZ4, + S_YHORIZ5, + S_YHORIZ6, + S_YHORIZ7, + S_YHORIZ8, + + // Red Side Spring + S_RHORIZ1, + S_RHORIZ2, + S_RHORIZ3, + S_RHORIZ4, + S_RHORIZ5, + S_RHORIZ6, + S_RHORIZ7, + S_RHORIZ8, + + // Blue Side Spring + S_BHORIZ1, + S_BHORIZ2, + S_BHORIZ3, + S_BHORIZ4, + S_BHORIZ5, + S_BHORIZ6, + S_BHORIZ7, + S_BHORIZ8, + // Rain S_RAIN1, S_RAINRETURN, @@ -3125,6 +3158,9 @@ typedef enum mobj_type MT_REDSPRING, MT_YELLOWDIAG, // Yellow Diagonal Spring MT_REDDIAG, // Red Diagonal Spring + MT_YELLOWHORIZ, // Yellow Side Spring + MT_REDHORIZ, // Red Side Spring + MT_BLUEHORIZ, // Blue Side Spring // Interactive Objects MT_BUBBLES, // Bubble source From 928c6acf4b7fa009599c508fa2337578c2b8f3ca Mon Sep 17 00:00:00 2001 From: yoshibot Date: Tue, 17 May 2016 22:56:49 -0500 Subject: [PATCH 013/239] Simplify OS X bundle resource discovery, fix a sigsegv --- src/sdl/macosx/mac_resources.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/sdl/macosx/mac_resources.c b/src/sdl/macosx/mac_resources.c index dacc8014b..706c5e7fc 100644 --- a/src/sdl/macosx/mac_resources.c +++ b/src/sdl/macosx/mac_resources.c @@ -9,23 +9,21 @@ void OSX_GetResourcesPath(char * buffer) mainBundle = CFBundleGetMainBundle(); if (mainBundle) { + const int BUF_SIZE = 256; // because we somehow always know that + CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle); CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); - CFStringRef resources = CFStringCreateWithCString(kCFAllocatorMalloc, "/Contents/Resources", kCFStringEncodingASCII); - const void* rawarray[2] = {macPath, resources}; - CFArrayRef array = CFArrayCreate(kCFAllocatorMalloc, rawarray, 2, NULL); - CFStringRef separator = CFStringCreateWithCString(kCFAllocatorMalloc, "", kCFStringEncodingASCII); - CFStringRef fullPath = CFStringCreateByCombiningStrings(kCFAllocatorMalloc, array, separator); - const char * path = CFStringGetCStringPtr(fullPath, kCFStringEncodingASCII); - strcpy(buffer, path); - CFRelease(fullPath); - path = NULL; - CFRelease(array); - CFRelease(resources); + + const char* rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII); + + if (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE) + { + strcpy(buffer, rawPath); + strcat(buffer, "/Contents/Resources"); + } + CFRelease(macPath); CFRelease(appUrlRef); - //CFRelease(mainBundle); - CFRelease(separator); } - -} \ No newline at end of file + CFRelease(mainBundle); +} From df89563882d8eb7e2bc848944a0b76853d086970 Mon Sep 17 00:00:00 2001 From: yoshibot Date: Wed, 18 May 2016 19:14:53 -0500 Subject: [PATCH 014/239] Add a way to build OS X binaries (not .app) through Makefiles --- src/Makefile | 14 ++++++++++++++ src/Makefile.cfg | 11 +++++++++++ src/doomtype.h | 2 +- src/sdl/MakeNIX.cfg | 9 +++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 701cdcfb1..deee38545 100644 --- a/src/Makefile +++ b/src/Makefile @@ -189,6 +189,10 @@ ifdef FREEBSD UNIXCOMMON=1 endif +ifdef MACOSX +UNIXCOMMON=1 +endif + ifdef NDS NOPNG=1 NONET=1 @@ -588,11 +592,16 @@ ifndef WINDOWSHELL -$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt endif endif + +# i dont know why, but the os x executable absolutely hates +# being touched by objcopy. so let's not do it +ifndef MACOSX ifndef PSP $(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME) $(OBJCOPY) --strip-debug $(BIN)/$(EXENAME) -$(OBJCOPY) --add-gnu-debuglink=$(BIN)/$(DBGNAME) $(BIN)/$(EXENAME) endif +endif ifndef NOUPX -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) endif @@ -737,6 +746,11 @@ $(OBJDIR)/%.o: %.c $(OBJDIR)/%.o: $(INTERFACE)/%.c $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ +ifdef MACOSX +$(OBJDIR)/%.o: sdl/macosx/%.c + $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ +endif + $(OBJDIR)/%.o: hardware/%.c $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ diff --git a/src/Makefile.cfg b/src/Makefile.cfg index fa8896a7c..7acb45596 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -403,6 +403,17 @@ else WINDRES=windres endif +# because Apple screws with us on this +# need to get bintools from homebrew +# need to get gzip from homebrew (it's in dupes) +ifdef MACOSX + CC=clang + CXX=clang + OBJCOPY=gobjcopy + OBJDUMP=gobjdump + GZIP=/usr/local/bin/gzip +endif + OBJDUMP_OPTS?=--wide --source --line-numbers LD=$(CC) diff --git a/src/doomtype.h b/src/doomtype.h index d833176f7..6bc2c5731 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -92,7 +92,7 @@ typedef long ssize_t; #endif #ifdef __APPLE_CC__ -#define DIRECTFULLSCREEN +#define DIRECTFULLSCREEN 1 #define DEBUG_LOG #define NOIPX #endif diff --git a/src/sdl/MakeNIX.cfg b/src/sdl/MakeNIX.cfg index f5c9b2075..1a0b54210 100644 --- a/src/sdl/MakeNIX.cfg +++ b/src/sdl/MakeNIX.cfg @@ -56,6 +56,15 @@ ifdef FREEBSD LIBS+=-lipx -lkvm endif +# +#here is Mac OS X +# +ifdef MACOSX + OBJS+=$(OBJDIR)/mac_resources.o + OBJS+=$(OBJDIR)/mac_alert.o + LIBS+=-framework CoreFoundation +endif + # #here is GP2x (arm-gp2x-linux) # From bb90c8366a4cd16ead76b96819065acf332ca3d3 Mon Sep 17 00:00:00 2001 From: yoshibot Date: Wed, 18 May 2016 22:13:53 -0500 Subject: [PATCH 015/239] Fixed bugs in OS X alert code and simplified; added more NULL checks in OS X resource code --- src/sdl/macosx/mac_alert.c | 37 +++++++++++++++++++++++++--------- src/sdl/macosx/mac_resources.c | 18 ++++++++++++----- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/sdl/macosx/mac_alert.c b/src/sdl/macosx/mac_alert.c index 455e36509..2a139041a 100644 --- a/src/sdl/macosx/mac_alert.c +++ b/src/sdl/macosx/mac_alert.c @@ -25,19 +25,38 @@ #include "mac_alert.h" #include +#define CFSTRINGIFY(x) CFStringCreateWithCString(NULL, x, kCFStringEncodingASCII) + int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3) { CFOptionFlags results; - CFUserNotificationDisplayAlert(0, - kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag, - NULL, NULL, NULL, - CFStringCreateWithCString(NULL, title, kCFStringEncodingASCII), - CFStringCreateWithCString(NULL, message, kCFStringEncodingASCII), - button1 != NULL ? CFStringCreateWithCString(NULL, button1, kCFStringEncodingASCII) : NULL, - button2 != NULL ? CFStringCreateWithCString(NULL, button2, kCFStringEncodingASCII) : NULL, - button3 != NULL ? CFStringCreateWithCString(NULL, button3, kCFStringEncodingASCII) : NULL, - &results); + CFStringRef cf_title = CFSTRINGIFY(title); + CFStringRef cf_message = CFSTRINGIFY(message); + CFStringRef cf_button1 = NULL; + CFStringRef cf_button2 = NULL; + CFStringRef cf_button3 = NULL; + + if (button1 != NULL) + cf_button1 = CFSTRINGIFY(button1); + if (button2 != NULL) + cf_button2 = CFSTRINGIFY(button2); + if (button3 != NULL) + cf_button3 = CFSTRINGIFY(button3); + + CFOptionFlags alert_flags = kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag; + + CFUserNotificationDisplayAlert(0, alert_flags, NULL, NULL, NULL, cf_title, cf_message, + cf_button1, cf_button2, cf_button3, &results); + + if (cf_button1 != NULL) + CFRelease(cf_button1); + if (cf_button2 != NULL) + CFRelease(cf_button2); + if (cf_button3 != NULL) + CFRelease(cf_button3); + CFRelease(cf_message); + CFRelease(cf_title); return (int)results; } diff --git a/src/sdl/macosx/mac_resources.c b/src/sdl/macosx/mac_resources.c index 706c5e7fc..d67b92580 100644 --- a/src/sdl/macosx/mac_resources.c +++ b/src/sdl/macosx/mac_resources.c @@ -12,11 +12,20 @@ void OSX_GetResourcesPath(char * buffer) const int BUF_SIZE = 256; // because we somehow always know that CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle); - CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); + CFStringRef macPath; + if (appUrlRef != NULL) + macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); + else + macPath = NULL; - const char* rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII); - - if (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE) + const char* rawPath; + + if (macPath != NULL) + rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII); + else + rawPath = NULL; + + if (rawPath != NULL && (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE)) { strcpy(buffer, rawPath); strcat(buffer, "/Contents/Resources"); @@ -25,5 +34,4 @@ void OSX_GetResourcesPath(char * buffer) CFRelease(macPath); CFRelease(appUrlRef); } - CFRelease(mainBundle); } From 8fbc0d7f69cd683bd23253522fcf696fd10674e8 Mon Sep 17 00:00:00 2001 From: yoshibot Date: Wed, 18 May 2016 23:52:06 -0500 Subject: [PATCH 016/239] remove bogus homebrew gzip; objdump allowed to fail in that way --- src/Makefile | 3 +-- src/Makefile.cfg | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index deee38545..cbd362ae1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -593,8 +593,7 @@ ifndef WINDOWSHELL endif endif -# i dont know why, but the os x executable absolutely hates -# being touched by objcopy. so let's not do it +# mac os x lsdlsrb2 does not like objcopy ifndef MACOSX ifndef PSP $(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 7acb45596..2e67474ca 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -405,13 +405,11 @@ endif # because Apple screws with us on this # need to get bintools from homebrew -# need to get gzip from homebrew (it's in dupes) ifdef MACOSX CC=clang CXX=clang OBJCOPY=gobjcopy OBJDUMP=gobjdump - GZIP=/usr/local/bin/gzip endif OBJDUMP_OPTS?=--wide --source --line-numbers From f94d3a1fb0a407f31c35854f370883a6bceaf361 Mon Sep 17 00:00:00 2001 From: Hank Brannock Date: Sun, 22 May 2016 22:38:16 -0400 Subject: [PATCH 017/239] The code in i_net.c doesn't actually seem to be used in SRB2. I was able to compile a build without it, and hosting and joining netgames worked just fine (well, as fine as they can with the current state of the netcode...). Do we really need to keep it around? If not, I say get rid of it. It seems like useless clutter that is just going to confuse people who are trying to understand the source code. --- src/Makefile.cfg | 1 - src/d_net.c | 2 +- src/i_net.h | 3 - src/sdl/Srb2SDL-vc10.vcxproj | 1 - src/sdl/Srb2SDL-vc10.vcxproj.filters | 3 - src/sdl/i_net.c | 442 --------------------------- src/sdl12/i_net.c | 442 --------------------------- 7 files changed, 1 insertion(+), 893 deletions(-) delete mode 100644 src/sdl/i_net.c delete mode 100644 src/sdl12/i_net.c diff --git a/src/Makefile.cfg b/src/Makefile.cfg index fa8896a7c..5fdea8474 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -207,7 +207,6 @@ endif #determine the interface directory (where you put all i_*.c) i_cdmus_o=$(OBJDIR)/i_cdmus.o -i_net_o=$(OBJDIR)/i_net.o i_system_o=$(OBJDIR)/i_system.o i_sound_o=$(OBJDIR)/i_sound.o i_main_o=$(OBJDIR)/i_main.o diff --git a/src/d_net.c b/src/d_net.c index 03e126b50..4b6678c23 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1080,7 +1080,7 @@ boolean D_CheckNetGame(void) multiplayer = false; // only dos version with external driver will return true - netgame = I_InitNetwork(); + netgame = false; // I_InitNetwork() is no longer used if (!netgame && !I_NetOpenSocket) { D_SetDoomcom(); diff --git a/src/i_net.h b/src/i_net.h index e378f5723..ae4697015 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -148,7 +148,4 @@ extern const char *(*I_GetBanMask) (size_t ban); extern boolean (*I_SetBanAddress) (const char *address,const char *mask); extern boolean *bannednode; -/// \brief Called by D_SRB2Main to be defined by extern network driver -boolean I_InitNetwork(void); - #endif diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 452b47ed1..5dc01cfd9 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -398,7 +398,6 @@ - diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 9396b4823..b037140e5 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -837,9 +837,6 @@ SDLApp - - SDLApp - SDLApp diff --git a/src/sdl/i_net.c b/src/sdl/i_net.c deleted file mode 100644 index ee4a34c13..000000000 --- a/src/sdl/i_net.c +++ /dev/null @@ -1,442 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL network interface - -#include "../doomdef.h" - -#include "../i_system.h" -#include "../d_event.h" -#include "../d_net.h" -#include "../m_argv.h" - -#include "../doomstat.h" - -#include "../i_net.h" - -#include "../z_zone.h" - -#include "../i_tcp.h" - -#ifdef HAVE_SDL - -#ifdef HAVE_SDLNET - -#include "SDL_net.h" - -#define MAXBANS 20 - -static IPaddress clientaddress[MAXNETNODES+1]; -static IPaddress banned[MAXBANS]; - -static UDPpacket mypacket; -static UDPsocket mysocket = NULL; -static SDLNet_SocketSet myset = NULL; - -static size_t numbans = 0; -static boolean NET_bannednode[MAXNETNODES+1]; /// \note do we really need the +1? -static boolean init_SDLNet_driver = false; - -static const char *NET_AddrToStr(IPaddress* sk) -{ - static char s[22]; // 255.255.255.255:65535 - strcpy(s, SDLNet_ResolveIP(sk)); - if (sk->port != 0) strcat(s, va(":%d", sk->port)); - return s; -} - -static const char *NET_GetNodeAddress(INT32 node) -{ - if (!nodeconnected[node]) - return NULL; - return NET_AddrToStr(&clientaddress[node]); -} - -static const char *NET_GetBanAddress(size_t ban) -{ - if (ban > numbans) - return NULL; - return NET_AddrToStr(&banned[ban]); -} - -static boolean NET_cmpaddr(IPaddress* a, IPaddress* b) -{ - return (a->host == b->host && (b->port == 0 || a->port == b->port)); -} - -static boolean NET_CanGet(void) -{ - return myset?(SDLNet_CheckSockets(myset,0) == 1):false; -} - -static void NET_Get(void) -{ - INT32 mystatus; - INT32 newnode; - mypacket.len = MAXPACKETLENGTH; - if (!NET_CanGet()) - { - doomcom->remotenode = -1; // no packet - return; - } - mystatus = SDLNet_UDP_Recv(mysocket,&mypacket); - if (mystatus != -1) - { - if (mypacket.channel != -1) - { - doomcom->remotenode = mypacket.channel+1; // good packet from a game player - doomcom->datalength = mypacket.len; - return; - } - newnode = SDLNet_UDP_Bind(mysocket,-1,&mypacket.address); - if (newnode != -1) - { - size_t i; - newnode++; - M_Memcpy(&clientaddress[newnode], &mypacket.address, sizeof (IPaddress)); - DEBFILE(va("New node detected: node:%d address:%s\n", newnode, - NET_GetNodeAddress(newnode))); - doomcom->remotenode = newnode; // good packet from a game player - doomcom->datalength = mypacket.len; - for (i = 0; i < numbans; i++) - { - if (NET_cmpaddr(&mypacket.address, &banned[i])) - { - DEBFILE("This dude has been banned\n"); - NET_bannednode[newnode] = true; - break; - } - } - if (i == numbans) - NET_bannednode[newnode] = false; - return; - } - else - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } - else if (mystatus == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } - - DEBFILE("New node detected: No more free slots\n"); - doomcom->remotenode = -1; // no packet -} - -#if 0 -static boolean NET_CanSend(void) -{ - return true; -} -#endif - -static void NET_Send(void) -{ - if (!doomcom->remotenode) - return; - mypacket.len = doomcom->datalength; - if (SDLNet_UDP_Send(mysocket,doomcom->remotenode-1,&mypacket) == 0) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } -} - -static void NET_FreeNodenum(INT32 numnode) -{ - // can't disconnect from self :) - if (!numnode) - return; - - DEBFILE(va("Free node %d (%s)\n", numnode, NET_GetNodeAddress(numnode))); - - SDLNet_UDP_Unbind(mysocket,numnode-1); - - memset(&clientaddress[numnode], 0, sizeof (IPaddress)); -} - -static UDPsocket NET_Socket(void) -{ - UDPsocket temp = NULL; - Uint16 portnum = 0; - IPaddress tempip = {INADDR_BROADCAST,0}; - //Hurdler: I'd like to put a server and a client on the same computer - //Logan: Me too - //BP: in fact for client we can use any free port we want i have read - // in some doc that connect in udp can do it for us... - //Alam: where? - if (M_CheckParm("-clientport")) - { - if (!M_IsNextParm()) - I_Error("syntax: -clientport "); - portnum = atoi(M_GetNextParm()); - } - else - portnum = sock_port; - temp = SDLNet_UDP_Open(portnum); - if (!temp) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return NULL; - } - if (SDLNet_UDP_Bind(temp,BROADCASTADDR-1,&tempip) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - SDLNet_UDP_Close(temp); - return NULL; - } - clientaddress[BROADCASTADDR].port = sock_port; - clientaddress[BROADCASTADDR].host = INADDR_BROADCAST; - - doomcom->extratics = 1; // internet is very high ping - - return temp; -} - -static void I_ShutdownSDLNetDriver(void) -{ - if (myset) SDLNet_FreeSocketSet(myset); - myset = NULL; - SDLNet_Quit(); - init_SDLNet_driver = false; -} - -static void I_InitSDLNetDriver(void) -{ - if (init_SDLNet_driver) - I_ShutdownSDLNetDriver(); - if (SDLNet_Init() == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return; // No good! - } - D_SetDoomcom(); - mypacket.data = doomcom->data; - init_SDLNet_driver = true; -} - -static void NET_CloseSocket(void) -{ - if (mysocket) - SDLNet_UDP_Close(mysocket); - mysocket = NULL; -} - -static SINT8 NET_NetMakeNodewPort(const char *hostname, const char *port) -{ - INT32 newnode; - UINT16 portnum = sock_port; - IPaddress hostnameIP; - - // retrieve portnum from address! - if (port && !port[0]) - portnum = atoi(port); - - if (SDLNet_ResolveHost(&hostnameIP,hostname,portnum) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return -1; - } - newnode = SDLNet_UDP_Bind(mysocket,-1,&hostnameIP); - if (newnode == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return newnode; - } - newnode++; - M_Memcpy(&clientaddress[newnode],&hostnameIP,sizeof (IPaddress)); - return (SINT8)newnode; -} - - -static boolean NET_OpenSocket(void) -{ - memset(clientaddress, 0, sizeof (clientaddress)); - - //I_OutputMsg("SDL_Net Code starting up\n"); - - I_NetSend = NET_Send; - I_NetGet = NET_Get; - I_NetCloseSocket = NET_CloseSocket; - I_NetFreeNodenum = NET_FreeNodenum; - I_NetMakeNodewPort = NET_NetMakeNodewPort; - - //I_NetCanSend = NET_CanSend; - - // build the socket but close it first - NET_CloseSocket(); - mysocket = NET_Socket(); - - if (!mysocket) - return false; - - // for select - myset = SDLNet_AllocSocketSet(1); - if (!myset) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return false; - } - if (SDLNet_UDP_AddSocket(myset,mysocket) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return false; - } - return true; -} - -static boolean NET_Ban(INT32 node) -{ - if (numbans == MAXBANS) - return false; - - M_Memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress)); - banned[numbans].port = 0; - numbans++; - return true; -} - -static boolean NET_SetBanAddress(const char *address, const char *mask) -{ - (void)mask; - if (bans == MAXBANS) - return false; - - if (SDLNet_ResolveHost(&banned[numbans], address, 0) == -1) - return false; - numbans++; - return true; -} - -static void NET_ClearBans(void) -{ - numbans = 0; -} -#endif - -// -// I_InitNetwork -// Only required for DOS, so this is more a dummy -// -boolean I_InitNetwork(void) -{ -#ifdef HAVE_SDLNET - char serverhostname[255]; - boolean ret = false; - SDL_version SDLcompiled; - const SDL_version *SDLlinked = SDLNet_Linked_Version(); - SDL_NET_VERSION(&SDLcompiled) - I_OutputMsg("Compiled for SDL_Net version: %d.%d.%d\n", - SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch); - I_OutputMsg("Linked with SDL_Net version: %d.%d.%d\n", - SDLlinked->major, SDLlinked->minor, SDLlinked->patch); - //if (!M_CheckParm ("-sdlnet")) - // return false; - // initilize the driver - I_InitSDLNetDriver(); - I_AddExitFunc(I_ShutdownSDLNetDriver); - if (!init_SDLNet_driver) - return false; - - if (M_CheckParm("-udpport")) - { - if (M_IsNextParm()) - sock_port = (UINT16)atoi(M_GetNextParm()); - else - sock_port = 0; - } - - // parse network game options, - if (M_CheckParm("-server") || dedicated) - { - server = true; - - // If a number of clients (i.e. nodes) is specified, the server will wait for the clients - // to connect before starting. - // If no number is specified here, the server starts with 1 client, and others can join - // in-game. - // Since Boris has implemented join in-game, there is no actual need for specifying a - // particular number here. - // FIXME: for dedicated server, numnodes needs to be set to 0 upon start -/* if (M_IsNextParm()) - doomcom->numnodes = (INT16)atoi(M_GetNextParm()); - else */if (dedicated) - doomcom->numnodes = 0; - else - doomcom->numnodes = 1; - - if (doomcom->numnodes < 0) - doomcom->numnodes = 0; - if (doomcom->numnodes > MAXNETNODES) - doomcom->numnodes = MAXNETNODES; - - // server - servernode = 0; - // FIXME: - // ??? and now ? - // server on a big modem ??? 4*isdn - net_bandwidth = 16000; - hardware_MAXPACKETLENGTH = INETPACKETLENGTH; - - ret = true; - } - else if (M_CheckParm("-connect")) - { - if (M_IsNextParm()) - strcpy(serverhostname, M_GetNextParm()); - else - serverhostname[0] = 0; // assuming server in the LAN, use broadcast to detect it - - // server address only in ip - if (serverhostname[0]) - { - COM_BufAddText("connect \""); - COM_BufAddText(serverhostname); - COM_BufAddText("\"\n"); - - // probably modem - hardware_MAXPACKETLENGTH = INETPACKETLENGTH; - } - else - { - // so we're on a LAN - COM_BufAddText("connect any\n"); - - net_bandwidth = 800000; - hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - } - } - - mypacket.maxlen = hardware_MAXPACKETLENGTH; - I_NetOpenSocket = NET_OpenSocket; - I_Ban = NET_Ban; - I_ClearBans = NET_ClearBans; - I_GetNodeAddress = NET_GetNodeAddress; - I_GetBenAddress = NET_GetBenAddress; - I_SetBanAddress = NET_SetBanAddress; - bannednode = NET_bannednode; - - return ret; -#else - if ( M_CheckParm ("-net") ) - { - I_Error("-net not supported, use -server and -connect\n" - "see docs for more\n"); - } - return false; -#endif -} -#endif diff --git a/src/sdl12/i_net.c b/src/sdl12/i_net.c deleted file mode 100644 index ee4a34c13..000000000 --- a/src/sdl12/i_net.c +++ /dev/null @@ -1,442 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL network interface - -#include "../doomdef.h" - -#include "../i_system.h" -#include "../d_event.h" -#include "../d_net.h" -#include "../m_argv.h" - -#include "../doomstat.h" - -#include "../i_net.h" - -#include "../z_zone.h" - -#include "../i_tcp.h" - -#ifdef HAVE_SDL - -#ifdef HAVE_SDLNET - -#include "SDL_net.h" - -#define MAXBANS 20 - -static IPaddress clientaddress[MAXNETNODES+1]; -static IPaddress banned[MAXBANS]; - -static UDPpacket mypacket; -static UDPsocket mysocket = NULL; -static SDLNet_SocketSet myset = NULL; - -static size_t numbans = 0; -static boolean NET_bannednode[MAXNETNODES+1]; /// \note do we really need the +1? -static boolean init_SDLNet_driver = false; - -static const char *NET_AddrToStr(IPaddress* sk) -{ - static char s[22]; // 255.255.255.255:65535 - strcpy(s, SDLNet_ResolveIP(sk)); - if (sk->port != 0) strcat(s, va(":%d", sk->port)); - return s; -} - -static const char *NET_GetNodeAddress(INT32 node) -{ - if (!nodeconnected[node]) - return NULL; - return NET_AddrToStr(&clientaddress[node]); -} - -static const char *NET_GetBanAddress(size_t ban) -{ - if (ban > numbans) - return NULL; - return NET_AddrToStr(&banned[ban]); -} - -static boolean NET_cmpaddr(IPaddress* a, IPaddress* b) -{ - return (a->host == b->host && (b->port == 0 || a->port == b->port)); -} - -static boolean NET_CanGet(void) -{ - return myset?(SDLNet_CheckSockets(myset,0) == 1):false; -} - -static void NET_Get(void) -{ - INT32 mystatus; - INT32 newnode; - mypacket.len = MAXPACKETLENGTH; - if (!NET_CanGet()) - { - doomcom->remotenode = -1; // no packet - return; - } - mystatus = SDLNet_UDP_Recv(mysocket,&mypacket); - if (mystatus != -1) - { - if (mypacket.channel != -1) - { - doomcom->remotenode = mypacket.channel+1; // good packet from a game player - doomcom->datalength = mypacket.len; - return; - } - newnode = SDLNet_UDP_Bind(mysocket,-1,&mypacket.address); - if (newnode != -1) - { - size_t i; - newnode++; - M_Memcpy(&clientaddress[newnode], &mypacket.address, sizeof (IPaddress)); - DEBFILE(va("New node detected: node:%d address:%s\n", newnode, - NET_GetNodeAddress(newnode))); - doomcom->remotenode = newnode; // good packet from a game player - doomcom->datalength = mypacket.len; - for (i = 0; i < numbans; i++) - { - if (NET_cmpaddr(&mypacket.address, &banned[i])) - { - DEBFILE("This dude has been banned\n"); - NET_bannednode[newnode] = true; - break; - } - } - if (i == numbans) - NET_bannednode[newnode] = false; - return; - } - else - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } - else if (mystatus == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } - - DEBFILE("New node detected: No more free slots\n"); - doomcom->remotenode = -1; // no packet -} - -#if 0 -static boolean NET_CanSend(void) -{ - return true; -} -#endif - -static void NET_Send(void) -{ - if (!doomcom->remotenode) - return; - mypacket.len = doomcom->datalength; - if (SDLNet_UDP_Send(mysocket,doomcom->remotenode-1,&mypacket) == 0) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } -} - -static void NET_FreeNodenum(INT32 numnode) -{ - // can't disconnect from self :) - if (!numnode) - return; - - DEBFILE(va("Free node %d (%s)\n", numnode, NET_GetNodeAddress(numnode))); - - SDLNet_UDP_Unbind(mysocket,numnode-1); - - memset(&clientaddress[numnode], 0, sizeof (IPaddress)); -} - -static UDPsocket NET_Socket(void) -{ - UDPsocket temp = NULL; - Uint16 portnum = 0; - IPaddress tempip = {INADDR_BROADCAST,0}; - //Hurdler: I'd like to put a server and a client on the same computer - //Logan: Me too - //BP: in fact for client we can use any free port we want i have read - // in some doc that connect in udp can do it for us... - //Alam: where? - if (M_CheckParm("-clientport")) - { - if (!M_IsNextParm()) - I_Error("syntax: -clientport "); - portnum = atoi(M_GetNextParm()); - } - else - portnum = sock_port; - temp = SDLNet_UDP_Open(portnum); - if (!temp) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return NULL; - } - if (SDLNet_UDP_Bind(temp,BROADCASTADDR-1,&tempip) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - SDLNet_UDP_Close(temp); - return NULL; - } - clientaddress[BROADCASTADDR].port = sock_port; - clientaddress[BROADCASTADDR].host = INADDR_BROADCAST; - - doomcom->extratics = 1; // internet is very high ping - - return temp; -} - -static void I_ShutdownSDLNetDriver(void) -{ - if (myset) SDLNet_FreeSocketSet(myset); - myset = NULL; - SDLNet_Quit(); - init_SDLNet_driver = false; -} - -static void I_InitSDLNetDriver(void) -{ - if (init_SDLNet_driver) - I_ShutdownSDLNetDriver(); - if (SDLNet_Init() == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return; // No good! - } - D_SetDoomcom(); - mypacket.data = doomcom->data; - init_SDLNet_driver = true; -} - -static void NET_CloseSocket(void) -{ - if (mysocket) - SDLNet_UDP_Close(mysocket); - mysocket = NULL; -} - -static SINT8 NET_NetMakeNodewPort(const char *hostname, const char *port) -{ - INT32 newnode; - UINT16 portnum = sock_port; - IPaddress hostnameIP; - - // retrieve portnum from address! - if (port && !port[0]) - portnum = atoi(port); - - if (SDLNet_ResolveHost(&hostnameIP,hostname,portnum) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return -1; - } - newnode = SDLNet_UDP_Bind(mysocket,-1,&hostnameIP); - if (newnode == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return newnode; - } - newnode++; - M_Memcpy(&clientaddress[newnode],&hostnameIP,sizeof (IPaddress)); - return (SINT8)newnode; -} - - -static boolean NET_OpenSocket(void) -{ - memset(clientaddress, 0, sizeof (clientaddress)); - - //I_OutputMsg("SDL_Net Code starting up\n"); - - I_NetSend = NET_Send; - I_NetGet = NET_Get; - I_NetCloseSocket = NET_CloseSocket; - I_NetFreeNodenum = NET_FreeNodenum; - I_NetMakeNodewPort = NET_NetMakeNodewPort; - - //I_NetCanSend = NET_CanSend; - - // build the socket but close it first - NET_CloseSocket(); - mysocket = NET_Socket(); - - if (!mysocket) - return false; - - // for select - myset = SDLNet_AllocSocketSet(1); - if (!myset) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return false; - } - if (SDLNet_UDP_AddSocket(myset,mysocket) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return false; - } - return true; -} - -static boolean NET_Ban(INT32 node) -{ - if (numbans == MAXBANS) - return false; - - M_Memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress)); - banned[numbans].port = 0; - numbans++; - return true; -} - -static boolean NET_SetBanAddress(const char *address, const char *mask) -{ - (void)mask; - if (bans == MAXBANS) - return false; - - if (SDLNet_ResolveHost(&banned[numbans], address, 0) == -1) - return false; - numbans++; - return true; -} - -static void NET_ClearBans(void) -{ - numbans = 0; -} -#endif - -// -// I_InitNetwork -// Only required for DOS, so this is more a dummy -// -boolean I_InitNetwork(void) -{ -#ifdef HAVE_SDLNET - char serverhostname[255]; - boolean ret = false; - SDL_version SDLcompiled; - const SDL_version *SDLlinked = SDLNet_Linked_Version(); - SDL_NET_VERSION(&SDLcompiled) - I_OutputMsg("Compiled for SDL_Net version: %d.%d.%d\n", - SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch); - I_OutputMsg("Linked with SDL_Net version: %d.%d.%d\n", - SDLlinked->major, SDLlinked->minor, SDLlinked->patch); - //if (!M_CheckParm ("-sdlnet")) - // return false; - // initilize the driver - I_InitSDLNetDriver(); - I_AddExitFunc(I_ShutdownSDLNetDriver); - if (!init_SDLNet_driver) - return false; - - if (M_CheckParm("-udpport")) - { - if (M_IsNextParm()) - sock_port = (UINT16)atoi(M_GetNextParm()); - else - sock_port = 0; - } - - // parse network game options, - if (M_CheckParm("-server") || dedicated) - { - server = true; - - // If a number of clients (i.e. nodes) is specified, the server will wait for the clients - // to connect before starting. - // If no number is specified here, the server starts with 1 client, and others can join - // in-game. - // Since Boris has implemented join in-game, there is no actual need for specifying a - // particular number here. - // FIXME: for dedicated server, numnodes needs to be set to 0 upon start -/* if (M_IsNextParm()) - doomcom->numnodes = (INT16)atoi(M_GetNextParm()); - else */if (dedicated) - doomcom->numnodes = 0; - else - doomcom->numnodes = 1; - - if (doomcom->numnodes < 0) - doomcom->numnodes = 0; - if (doomcom->numnodes > MAXNETNODES) - doomcom->numnodes = MAXNETNODES; - - // server - servernode = 0; - // FIXME: - // ??? and now ? - // server on a big modem ??? 4*isdn - net_bandwidth = 16000; - hardware_MAXPACKETLENGTH = INETPACKETLENGTH; - - ret = true; - } - else if (M_CheckParm("-connect")) - { - if (M_IsNextParm()) - strcpy(serverhostname, M_GetNextParm()); - else - serverhostname[0] = 0; // assuming server in the LAN, use broadcast to detect it - - // server address only in ip - if (serverhostname[0]) - { - COM_BufAddText("connect \""); - COM_BufAddText(serverhostname); - COM_BufAddText("\"\n"); - - // probably modem - hardware_MAXPACKETLENGTH = INETPACKETLENGTH; - } - else - { - // so we're on a LAN - COM_BufAddText("connect any\n"); - - net_bandwidth = 800000; - hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - } - } - - mypacket.maxlen = hardware_MAXPACKETLENGTH; - I_NetOpenSocket = NET_OpenSocket; - I_Ban = NET_Ban; - I_ClearBans = NET_ClearBans; - I_GetNodeAddress = NET_GetNodeAddress; - I_GetBenAddress = NET_GetBenAddress; - I_SetBanAddress = NET_SetBanAddress; - bannednode = NET_bannednode; - - return ret; -#else - if ( M_CheckParm ("-net") ) - { - I_Error("-net not supported, use -server and -connect\n" - "see docs for more\n"); - } - return false; -#endif -} -#endif From a2aeece419b3632ea3d783a38a424195290b3384 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 May 2016 21:53:29 +0100 Subject: [PATCH 018/239] Significant rework of main seg-rendering code, to eliminate the possibility of drawing off-screen and crashing the game as result NOTE: HOMs sometimes appear in the sky in maps like AGZ (map40), so this isn't completely fine yet. I'll fix that later --- src/r_segs.c | 110 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 42 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 11b4c8aef..931b79a66 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1453,34 +1453,45 @@ static void R_RenderSegLoop (void) frontscale[rw_x] = rw_scale; // draw the wall tiers - if (midtexture && yl <= yh && yh < vid.height && yh > 0) + if (midtexture) { // single sided line - dc_yl = yl; - dc_yh = yh; - dc_texturemid = rw_midtexturemid; - dc_source = R_GetColumn(midtexture,texturecolumn); - dc_texheight = textureheight[midtexture]>>FRACBITS; + if (yl <= yh && yh >= 0 && yl < viewheight) + { + dc_yl = yl; + dc_yh = yh; + dc_texturemid = rw_midtexturemid; + dc_source = R_GetColumn(midtexture,texturecolumn); + dc_texheight = textureheight[midtexture]>>FRACBITS; - //profile stuff --------------------------------------------------------- + //profile stuff --------------------------------------------------------- #ifdef TIMING - ProfZeroTimer(); + ProfZeroTimer(); #endif - colfunc(); + colfunc(); #ifdef TIMING - RDMSR(0x10,&mycount); - mytotal += mycount; //64bit add + RDMSR(0x10,&mycount); + mytotal += mycount; //64bit add - if (nombre--==0) - I_Error("R_DrawColumn CPU Spy reports: 0x%d %d\n", *((INT32 *)&mytotal+1), - (INT32)mytotal); + if (nombre--==0) + I_Error("R_DrawColumn CPU Spy reports: 0x%d %d\n", *((INT32 *)&mytotal+1), + (INT32)mytotal); #endif - //profile stuff --------------------------------------------------------- + //profile stuff --------------------------------------------------------- - // dont draw anything more for this column, since - // a midtexture blocks the view - ceilingclip[rw_x] = (INT16)viewheight; - floorclip[rw_x] = -1; + // dont draw anything more for this column, since + // a midtexture blocks the view + ceilingclip[rw_x] = (INT16)viewheight; + floorclip[rw_x] = -1; + } + else + { + // note: don't use min/max macros here + if (markceiling && yl >= 0) + ceilingclip[rw_x] = (yl-1 > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + if (markfloor && yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + } } else { @@ -1494,21 +1505,27 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (mid >= yl && yh < vid.height && yh > 0) + if (yl < 0) + ; // do nothing, off-screen + else if (mid >= yl && yl < viewheight) { - dc_yl = yl; - dc_yh = mid; - dc_texturemid = rw_toptexturemid; - dc_source = R_GetColumn(toptexture,texturecolumn); - dc_texheight = textureheight[toptexture]>>FRACBITS; - colfunc(); - ceilingclip[rw_x] = (INT16)mid; + if (mid >= 0) + { + dc_yl = yl; + dc_yh = mid; + dc_texturemid = rw_toptexturemid; + dc_source = R_GetColumn(toptexture,texturecolumn); + dc_texheight = textureheight[toptexture]>>FRACBITS; + colfunc(); + ceilingclip[rw_x] = (INT16)mid; + } + // else do nothing, off-screen } else - ceilingclip[rw_x] = (INT16)((INT16)yl - 1); + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); } - else if (markceiling) // no top wall - ceilingclip[rw_x] = (INT16)((INT16)yl - 1); + else if (markceiling && yl >= 0) // no top wall + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); if (bottomtexture) { @@ -1520,24 +1537,33 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (mid <= yh && yh < vid.height && yh > 0) + if (yh >= viewheight) + ; // do nothing, off-screen + else if (mid <= yh && yh >= 0) { - dc_yl = mid; - dc_yh = yh; - dc_texturemid = rw_bottomtexturemid; - dc_source = R_GetColumn(bottomtexture, - texturecolumn); - dc_texheight = textureheight[bottomtexture]>>FRACBITS; - colfunc(); - floorclip[rw_x] = (INT16)mid; + if (mid < viewheight) + { + dc_yl = mid; + dc_yh = yh; + dc_texturemid = rw_bottomtexturemid; + dc_source = R_GetColumn(bottomtexture, + texturecolumn); + dc_texheight = textureheight[bottomtexture]>>FRACBITS; + colfunc(); + floorclip[rw_x] = (INT16)mid; + } + // else do nothing, off-screen } else - floorclip[rw_x] = (INT16)((INT16)yh + 1); + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); } - else if (markfloor) // no bottom wall - floorclip[rw_x] = (INT16)((INT16)yh + 1); + else if (markfloor && yh < viewheight) // no bottom wall + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1), -1; } + if (floorclip[rw_x] > viewheight) + I_Error("floorclip[%d] > viewheight (value is %d)", rw_x, floorclip[rw_x]); + if (maskedtexture || numthicksides) { // save texturecol From eb90f4f50deec77b35d31224a456144683cd096a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 May 2016 22:53:22 +0100 Subject: [PATCH 019/239] welp no success in fixing the sky HOMs yet, committing progress anyway --- src/r_segs.c | 58 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 931b79a66..99324d03f 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1487,10 +1487,20 @@ static void R_RenderSegLoop (void) else { // note: don't use min/max macros here - if (markceiling && yl >= 0) - ceilingclip[rw_x] = (yl-1 > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - if (markfloor && yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + if (markceiling) + { + if (yl >= 0) + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; + } + else if (markfloor) + { + if (yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; + } } } else @@ -1505,9 +1515,7 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (yl < 0) - ; // do nothing, off-screen - else if (mid >= yl && yl < viewheight) + if (mid >= yl && yl < viewheight) { if (mid >= 0) { @@ -1519,13 +1527,21 @@ static void R_RenderSegLoop (void) colfunc(); ceilingclip[rw_x] = (INT16)mid; } - // else do nothing, off-screen + else + ceilingclip[rw_x] = -1; } - else + else if (yl >= 0) ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; + } + else if (markceiling) // no top wall + { + if (yl >= 0) + ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); + else + ceilingclip[rw_x] = -1; } - else if (markceiling && yl >= 0) // no top wall - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); if (bottomtexture) { @@ -1537,9 +1553,7 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (yh >= viewheight) - ; // do nothing, off-screen - else if (mid <= yh && yh >= 0) + if (mid <= yh && yh >= 0) { if (mid < viewheight) { @@ -1552,13 +1566,21 @@ static void R_RenderSegLoop (void) colfunc(); floorclip[rw_x] = (INT16)mid; } - // else do nothing, off-screen + else + floorclip[rw_x] = (INT16)viewheight; } - else + else if (yh < viewheight) floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; + } + else if (markfloor) // no bottom wall + { + if (yh < viewheight) + floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); + else + floorclip[rw_x] = (INT16)viewheight; } - else if (markfloor && yh < viewheight) // no bottom wall - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1), -1; } if (floorclip[rw_x] > viewheight) From fa002e58ad0f11f362a5bdfdb0629c9494906a1b Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 15:01:19 +0100 Subject: [PATCH 020/239] Did a bunch of things to/for slopes. *The No Physics flag now works (Red, you might want to doublecheck this to see whether I haven't missed any eosteric stuff out). Going downhill is a little bumpy, and I'm not sure whether that's good or not. Someone help me out here? *The SRB2CB typeshims are now behind #ifdef ESLOPE_TYPESHIM instead of #if 1 for easier disabling. *Slopes' downhill thrusts are now scaled with regards to object gravity. This is actually untested in gravities other than normal and reverse normal but it's one line which can be easily reverted in that circumstance. I also checked with MI to make sure this is how it's calculated elsewhere, so fingers crossed this doesn't cause any edge cases. *As a consequence of the above point, there's now a function in p_mobj.c/h that returns an object's internal gravity - seperated out from the logic of P_CheckGravity, which really didn't need to be so monolithic. Multiply by global gravity to get the thrust. This should probably be available to Lua somehow, but I have absolutely no idea where to start with that. Wolfs, maybe? Non-comprehensive test file available at /toaster/slptst3.wad on the ftp. --- src/doomdef.h | 6 ++++++ src/p_mobj.c | 31 ++++++++++++++++++++++--------- src/p_mobj.h | 3 +++ src/p_slopes.c | 50 ++++++++++++++++++++++++++++++++++---------------- src/p_user.c | 8 ++++---- 5 files changed, 69 insertions(+), 29 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 9a1e5af9e..e645c0848 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -431,6 +431,12 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Kalaron/Eternity Engine slope code (SRB2CB ported) #define ESLOPE +#if defined(ESLOPE) +/// Backwards compatibility with SRB2CB's slope linedef types. +/// \note A simple shim that prints a warning. +#define ESLOPE_TYPESHIM +#endif + /// Delete file while the game is running. /// \note EXTREMELY buggy, tends to crash game. //#define DELFILE diff --git a/src/p_mobj.c b/src/p_mobj.c index 68fb1696f..775cd9d6d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1252,13 +1252,12 @@ static void P_PlayerFlip(mobj_t *mo) } // -// P_CheckGravity +// P_GetMobjGravity // -// Checks the current gravity state -// of the object. If affect is true, -// a gravity force will be applied. +// Returns the current gravity +// value of the object. // -void P_CheckGravity(mobj_t *mo, boolean affect) +fixed_t P_GetMobjGravity(mobj_t *mo) { fixed_t gravityadd = 0; boolean no3dfloorgrav = true; // Custom gravity @@ -1400,11 +1399,25 @@ void P_CheckGravity(mobj_t *mo, boolean affect) if (goopgravity) gravityadd = -gravityadd/5; - if (affect) - mo->momz += FixedMul(gravityadd, mo->scale); - if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip) P_PlayerFlip(mo); + + return gravityadd; +} + +// +// P_CheckGravity +// +// Checks the current gravity state +// of the object. If affect is true, +// a gravity force will be applied. +// +void P_CheckGravity(mobj_t *mo, boolean affect) +{ + fixed_t gravityadd = P_GetMobjGravity(mo); + + if (affect) + mo->momz += FixedMul(gravityadd, mo->scale); if (mo->type == MT_SKIM && mo->z + mo->momz <= mo->watertop && mo->z >= mo->watertop) { @@ -1480,7 +1493,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) && abs(player->rmomy) < FixedMul(STOPSPEED, mo->scale) && (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) #ifdef ESLOPE - && !(player->mo->standingslope && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) + && !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)) #endif ) { diff --git a/src/p_mobj.h b/src/p_mobj.h index 9542ce8ba..de7f0c8d5 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -425,6 +425,9 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum); // check mobj against water content, before movement code void P_MobjCheckWater(mobj_t *mobj); +// get mobj gravity +fixed_t P_GetMobjGravity(mobj_t *mo); + // Player spawn points void P_SpawnPlayer(INT32 playernum); void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing); diff --git a/src/p_slopes.c b/src/p_slopes.c index 6393ca4b5..f4ef4dcc2 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -16,6 +16,7 @@ #include "m_bbox.h" #include "z_zone.h" #include "p_local.h" +#include "p_mobj.h" #include "p_spec.h" #include "p_slopes.h" #include "p_setup.h" @@ -881,7 +882,7 @@ void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum) // Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes void P_ResetDynamicSlopes(void) { size_t i; -#if 1 // Rewrite old specials to new ones, and give a console warning +#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning boolean warned = false; #endif @@ -894,7 +895,7 @@ void P_ResetDynamicSlopes(void) { { switch (lines[i].special) { -#if 1 // Rewrite old specials to new ones, and give a console warning +#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning #define WARNME if (!warned) {warned = true; CONS_Alert(CONS_WARNING, "This level uses old slope specials.\nA conversion will be needed before 2.2's release.\n");} case 386: case 387: @@ -1018,6 +1019,9 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y) // When given a vector, rotates it and aligns it to a slope void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) { + if (slope->flags & SL_NOPHYSICS) + return; // No physics, no quantizing. + vector3_t axis; axis.x = -slope->d.y; axis.y = slope->d.x; @@ -1032,26 +1036,37 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) // Handles slope ejection for objects void P_SlopeLaunch(mobj_t *mo) { - // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the - // vertical launch given from slopes while increasing the horizontal launch - // given. Good for SRB2's gravity and horizontal speeds. - vector3_t slopemom; - slopemom.x = mo->momx; - slopemom.y = mo->momy; - slopemom.z = mo->momz*2; - P_QuantizeMomentumToSlope(&slopemom, mo->standingslope); - - mo->momx = slopemom.x; - mo->momy = slopemom.y; - mo->momz = slopemom.z/2; + if (!(mo->standingslope->flags & SL_NOPHYSICS)) // If there's physics, time for launching. + { + // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the + // vertical launch given from slopes while increasing the horizontal launch + // given. Good for SRB2's gravity and horizontal speeds. + vector3_t slopemom; + slopemom.x = mo->momx; + slopemom.y = mo->momy; + slopemom.z = mo->momz*2; + P_QuantizeMomentumToSlope(&slopemom, mo->standingslope); + mo->momx = slopemom.x; + mo->momy = slopemom.y; + mo->momz = slopemom.z/2; + } + //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; } // Function to help handle landing on slopes void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) -{ +{ + if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. + if (P_MobjFlip(thing)*(thing->momz) < 0) { // falling, land on slope + thing->momz = -P_MobjFlip(thing); + thing->standingslope = slope; + } + return; + } + vector3_t mom; mom.x = thing->momx; mom.y = thing->momy; @@ -1081,6 +1096,9 @@ void P_ButteredSlope(mobj_t *mo) if (!mo->standingslope) return; + + if (mo->standingslope->flags & SL_NOPHYSICS) + return; // No physics, no butter. if (mo->flags & (MF_NOCLIPHEIGHT|MF_NOGRAVITY)) return; // don't slide down slopes if you can't touch them or you're not affected by gravity @@ -1116,7 +1134,7 @@ void P_ButteredSlope(mobj_t *mo) // This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down // Multiply by gravity - thrust = FixedMul(thrust, gravity); // TODO account for per-sector gravity etc + thrust = FixedMul(thrust, FixedMul(gravity, abs(P_GetMobjGravity(mo)))); // Now uses the absolute of mobj gravity. You're welcome. // Multiply by scale (gravity strength depends on mobj scale) thrust = FixedMul(thrust, mo->scale); diff --git a/src/p_user.c b/src/p_user.c index 4117cfc4c..461497bcb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3741,7 +3741,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) { if ((cmd->buttons & BT_USE) && player->speed < FixedMul(5<mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING) #ifdef ESLOPE - && (!player->mo->standingslope || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) + && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) #endif ) { @@ -3774,7 +3774,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) else if ((cmd->buttons & BT_USE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20)) && !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<mo->scale) #ifdef ESLOPE - || (player->mo->standingslope && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) + || (player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) #endif ) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING)) { @@ -3790,7 +3790,7 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) if (onground && player->pflags & PF_SPINNING && !(player->pflags & PF_STARTDASH) && player->speed < FixedMul(5*FRACUNIT,player->mo->scale) #ifdef ESLOPE - && (!player->mo->standingslope || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) + && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) #endif ) { @@ -4776,7 +4776,7 @@ static void P_3dMovement(player_t *player) #ifdef ESLOPE if ((totalthrust.x || totalthrust.y) - && player->mo->standingslope && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) { + && player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) { // Factor thrust to slope, but only for the part pushing up it! // The rest is unaffected. angle_t thrustangle = R_PointToAngle2(0, 0, totalthrust.x, totalthrust.y)-player->mo->standingslope->xydirection; From ad61050bb07825453b83fdd8735c2e85460d6ac2 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 16:01:05 +0100 Subject: [PATCH 021/239] Whitespace removal. --- src/p_mobj.c | 2 +- src/p_slopes.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 775cd9d6d..35d8f1ad2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1401,7 +1401,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip) P_PlayerFlip(mo); - + return gravityadd; } diff --git a/src/p_slopes.c b/src/p_slopes.c index f4ef4dcc2..462f7c3cb 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -1021,7 +1021,7 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) { if (slope->flags & SL_NOPHYSICS) return; // No physics, no quantizing. - + vector3_t axis; axis.x = -slope->d.y; axis.y = slope->d.x; @@ -1051,14 +1051,14 @@ void P_SlopeLaunch(mobj_t *mo) mo->momy = slopemom.y; mo->momz = slopemom.z/2; } - + //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; } // Function to help handle landing on slopes void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) -{ +{ if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. if (P_MobjFlip(thing)*(thing->momz) < 0) { // falling, land on slope thing->momz = -P_MobjFlip(thing); @@ -1096,7 +1096,7 @@ void P_ButteredSlope(mobj_t *mo) if (!mo->standingslope) return; - + if (mo->standingslope->flags & SL_NOPHYSICS) return; // No physics, no butter. From 8b2b49fb043ee32a8269ff4a0fe2db74c47e3d1a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 31 May 2016 16:08:29 +0100 Subject: [PATCH 022/239] Just some final cleanup of the code I changed --- src/r_segs.c | 59 ++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 99324d03f..ec3eaa180 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1486,21 +1486,11 @@ static void R_RenderSegLoop (void) } else { - // note: don't use min/max macros here + // note: don't use min/max macros, since casting from INT32 to INT16 is involved here if (markceiling) - { - if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - else - ceilingclip[rw_x] = -1; - } - else if (markfloor) - { - if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); - else - floorclip[rw_x] = (INT16)viewheight; - } + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; + if (markfloor) + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } } else @@ -1515,9 +1505,11 @@ static void R_RenderSegLoop (void) if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (mid >= yl && yl < viewheight) + if (mid >= yl) // back ceiling lower than front ceiling ? { - if (mid >= 0) + if (yl >= viewheight) // entirely off bottom of screen + ceilingclip[rw_x] = (INT16)viewheight; + else if (mid >= 0) // safe to draw top texture { dc_yl = yl; dc_yh = mid; @@ -1527,21 +1519,14 @@ static void R_RenderSegLoop (void) colfunc(); ceilingclip[rw_x] = (INT16)mid; } - else + else // entirely off top of screen ceilingclip[rw_x] = -1; } - else if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); else - ceilingclip[rw_x] = -1; + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; } else if (markceiling) // no top wall - { - if (yl >= 0) - ceilingclip[rw_x] = (yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1); - else - ceilingclip[rw_x] = -1; - } + ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; if (bottomtexture) { @@ -1553,9 +1538,11 @@ static void R_RenderSegLoop (void) if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (mid <= yh && yh >= 0) + if (mid <= yh) // back floor higher than front floor ? { - if (mid < viewheight) + if (yh < 0) // entirely off top of screen + floorclip[rw_x] = -1; + else if (mid < viewheight) // safe to draw bottom texture { dc_yl = mid; dc_yh = yh; @@ -1566,26 +1553,16 @@ static void R_RenderSegLoop (void) colfunc(); floorclip[rw_x] = (INT16)mid; } - else + else // entirely off bottom of screen floorclip[rw_x] = (INT16)viewheight; } - else if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); else - floorclip[rw_x] = (INT16)viewheight; + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } else if (markfloor) // no bottom wall - { - if (yh < viewheight) - floorclip[rw_x] = (yh < -1) ? -1 : (INT16)((INT16)yh + 1); - else - floorclip[rw_x] = (INT16)viewheight; - } + floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; } - if (floorclip[rw_x] > viewheight) - I_Error("floorclip[%d] > viewheight (value is %d)", rw_x, floorclip[rw_x]); - if (maskedtexture || numthicksides) { // save texturecol From 6058eec1c9c4c0b5129c72f94dce0e4a7dca01d8 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 16:14:21 +0100 Subject: [PATCH 023/239] Holy shit. I spent two hours staring at how garbage this code was and didn't even realise it was #ifdef'd out behind a define not even mentioned in doomdef.h. It's not actually used anywhere (superseded entirely by the much nicer, much more relevant P_NewVertexSlope()... out with you, ancient, foul demons who should've been SPRINGCLEANed long ago. --- src/p_slopes.c | 255 ------------------------------------------------- src/p_slopes.h | 20 ---- 2 files changed, 275 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 462f7c3cb..cb5f07b2b 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -624,261 +624,6 @@ pslope_t *P_SlopeById(UINT16 id) return ret; } -#ifdef SPRINGCLEAN -#include "byteptr.h" - -#include "p_setup.h" -#include "p_local.h" - -//========================================================================== -// -// P_SetSlopesFromVertexHeights -// -//========================================================================== -void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum) -{ - mapthing_t *mt; - boolean vt_found = false; - size_t i, j, k, l, q; - - //size_t i; - //mapthing_t *mt; - char *data; - char *datastart; - - // SRB2CBTODO: WHAT IS (5 * sizeof (short))?! It = 10 - // anything else seems to make a map not load properly, - // but this hard-coded value MUST have some reason for being what it is - size_t snummapthings = W_LumpLength(lumpnum) / (5 * sizeof (short)); - mapthing_t *smapthings = Z_Calloc(snummapthings * sizeof (*smapthings), PU_LEVEL, NULL); - fixed_t x, y; - sector_t *sector; - // Spawn axis points first so they are - // at the front of the list for fast searching. - data = datastart = W_CacheLumpNum(lumpnum, PU_LEVEL); - mt = smapthings; - for (i = 0; i < snummapthings; i++, mt++) - { - mt->x = READINT16(data); - mt->y = READINT16(data); - mt->angle = READINT16(data); - mt->type = READINT16(data); - mt->options = READINT16(data); - // mt->z hasn't been set yet! - //mt->extrainfo = (byte)(mt->type >> 12); // slope things are special, they have a bigger range of types - - //mt->type &= 4095; // SRB2CBTODO: WHAT IS THIS???? Mobj type limits?!!!! - x = mt->x*FRACUNIT; - y = mt->y*FRACUNIT; - sector = R_PointInSubsector(x, y)->sector; - // Z for objects -#ifdef ESLOPE - if (sector->f_slope) - mt->z = (short)(P_GetZAt(sector->f_slope, x, y)>>FRACBITS); - else -#endif - mt->z = (short)(sector->floorheight>>FRACBITS); - - mt->z = mt->z + (mt->options >> ZSHIFT); - - if (mt->type == THING_VertexFloorZ || mt->type == THING_VertexCeilingZ) // THING_VertexFloorZ - { - for(l = 0; l < numvertexes; l++) - { - if (vertexes[l].x == mt->x*FRACUNIT && vertexes[l].y == mt->y*FRACUNIT) - { - if (mt->type == THING_VertexFloorZ) - { - vertexes[l].z = mt->z*FRACUNIT; - //I_Error("Z value: %i", vertexes[l].z/FRACUNIT); - - } - else - { - vertexes[l].z = mt->z*FRACUNIT; // celing floor - } - vt_found = true; - } - } - //mt->type = 0; // VPHYSICS: Dynamic slopes - - - - - - - if (vt_found) - { - for (k = 0; k < numsectors; k++) - { - sector_t *sec = §ors[k]; - if (sec->linecount != 3) continue; // only works with triangular sectors - - v3float_t vt1, vt2, vt3; // cross = ret->normalf - v3float_t vec1, vec2; - - int vi1, vi2, vi3; - - vi1 = (int)(sec->lines[0]->v1 - vertexes); - vi2 = (int)(sec->lines[0]->v2 - vertexes); - vi3 = (sec->lines[1]->v1 == sec->lines[0]->v1 || sec->lines[1]->v1 == sec->lines[0]->v2)? - (int)(sec->lines[1]->v2 - vertexes) : (int)(sec->lines[1]->v1 - vertexes); - - //if (vertexes[vi1].z) - // I_Error("OSNAP %i", vertexes[vi1].z/FRACUNIT); - //if (vertexes[vi2].z) - // I_Error("OSNAP %i", vertexes[vi2].z/FRACUNIT); - //if (vertexes[vi3].z) - // I_Error("OSNAP %i", vertexes[vi3].z/FRACUNIT); - - //I_Error("%i, %i", mt->z*FRACUNIT, vertexes[vi1].z); - - //I_Error("%i, %i, %i", mt->x, mt->y, mt->z); - //P_SpawnMobj(mt->x*FRACUNIT, mt->y*FRACUNIT, mt->z*FRACUNIT, MT_RING); - - // TODO: Make sure not to spawn in the same place 2x! (we need an object in every vertex of the - // triangle sector to setup the real vertex slopes - // Check for the vertexes of all sectors - for(q = 0; q < numvertexes; q++) - { - if (vertexes[q].x == mt->x*FRACUNIT && vertexes[q].y == mt->y*FRACUNIT) - { - //I_Error("yeah %i", vertexes[q].z); - P_SpawnMobj(vertexes[q].x, vertexes[q].y, vertexes[q].z, MT_RING); -#if 0 - if ((mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z) - && !(mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z) - && !(mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z)) - P_SpawnMobj(vertexes[vi1].x, vertexes[vi1].y, vertexes[vi1].z, MT_RING); - else if ((mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z) - && !(mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z) - && !(mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z)) - P_SpawnMobj(vertexes[vi2].x, vertexes[vi2].y, vertexes[vi2].z, MT_BOUNCETV); - else if ((mt->y*FRACUNIT == vertexes[vi3].y && mt->x*FRACUNIT == vertexes[vi3].x && mt->z*FRACUNIT == vertexes[vi3].z) - && !(mt->y*FRACUNIT == vertexes[vi2].y && mt->x*FRACUNIT == vertexes[vi2].x && mt->z*FRACUNIT == vertexes[vi2].z) - && !(mt->y*FRACUNIT == vertexes[vi1].y && mt->x*FRACUNIT == vertexes[vi1].x && mt->z*FRACUNIT == vertexes[vi1].z)) - P_SpawnMobj(vertexes[vi3].x, vertexes[vi3].y, vertexes[vi3].z, MT_GFZFLOWER1); - else -#endif - continue; - } - } - - vt1.x = FIXED_TO_FLOAT(vertexes[vi1].x); - vt1.y = FIXED_TO_FLOAT(vertexes[vi1].y); - vt2.x = FIXED_TO_FLOAT(vertexes[vi2].x); - vt2.y = FIXED_TO_FLOAT(vertexes[vi2].y); - vt3.x = FIXED_TO_FLOAT(vertexes[vi3].x); - vt3.y = FIXED_TO_FLOAT(vertexes[vi3].y); - - for(j = 0; j < 2; j++) - { - - fixed_t z3; - //I_Error("Lo hicimos"); - - vt1.z = mt->z;//FIXED_TO_FLOAT(j==0 ? sec->floorheight : sec->ceilingheight); - vt2.z = mt->z;//FIXED_TO_FLOAT(j==0? sec->floorheight : sec->ceilingheight); - z3 = mt->z;//j==0? sec->floorheight : sec->ceilingheight; // Destination height - vt3.z = FIXED_TO_FLOAT(z3); - - if (P_PointOnLineSide(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) - { - vec1.x = vt2.x - vt3.x; - vec1.y = vt2.y - vt3.y; - vec1.z = vt2.z - vt3.z; - - vec2.x = vt1.x - vt3.x; - vec2.y = vt1.y - vt3.y; - vec2.z = vt1.z - vt3.z; - } - else - { - vec1.x = vt1.x - vt3.x; - vec1.y = vt1.y - vt3.y; - vec1.z = vt1.z - vt3.z; - - vec2.x = vt2.x - vt3.x; - vec2.y = vt2.y - vt3.y; - vec2.z = vt2.z - vt3.z; - } - - - pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); - memset(ret, 0, sizeof(*ret)); - - { - M_CrossProduct3f(&ret->normalf, &vec1, &vec2); - - // Cross product length - float len = (float)sqrt(ret->normalf.x * ret->normalf.x + - ret->normalf.y * ret->normalf.y + - ret->normalf.z * ret->normalf.z); - - if (len == 0) - { - // Only happens when all vertices in this sector are on the same line. - // Let's just ignore this case. - //CONS_Printf("Slope thing at (%d,%d) lies directly on its target line.\n", (int)(x>>16), (int)(y>>16)); - return; - } - // cross/len - ret->normalf.x /= len; - ret->normalf.y /= len; - ret->normalf.z /= len; - - // ZDoom cross = ret->normalf - // Fix backward normals - if ((ret->normalf.z < 0 && j == 0) || (ret->normalf.z > 0 && j == 1)) - { - // cross = -cross - ret->normalf.x = -ret->normalf.x; - ret->normalf.y = -ret->normalf.x; - ret->normalf.z = -ret->normalf.x; - } - } - - secplane_t *srcplane = Z_Calloc(sizeof(*srcplane), PU_LEVEL, NULL); - - srcplane->a = FLOAT_TO_FIXED (ret->normalf.x); - srcplane->b = FLOAT_TO_FIXED (ret->normalf.y); - srcplane->c = FLOAT_TO_FIXED (ret->normalf.z); - //srcplane->ic = FixedDiv(FRACUNIT, srcplane->c); - srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].x, - srcplane->b, vertexes[vi3].y, - srcplane->c, z3); - - if (j == 0) - { - sec->f_slope = ret; - sec->f_slope->secplane = *srcplane; - } - else if (j == 1) - { - sec->c_slope = ret; - sec->c_slope->secplane = *srcplane; - } - } - } - } - - - - - - - - - } - } - Z_Free(datastart); - - - - -} -#endif - // Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes void P_ResetDynamicSlopes(void) { size_t i; diff --git a/src/p_slopes.h b/src/p_slopes.h index 80921a84b..dd9b6f2d2 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -21,26 +21,6 @@ void P_RunDynamicSlopes(void); // sectors. void P_SpawnSlope_Line(int linenum); -#ifdef SPRINGCLEAN -// Loads just map objects that make slopes, -// terrain affecting objects have to be spawned first -void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum); - -typedef enum -{ - THING_SlopeFloorPointLine = 9500, - THING_SlopeCeilingPointLine = 9501, - THING_SetFloorSlope = 9502, - THING_SetCeilingSlope = 9503, - THING_CopyFloorPlane = 9510, - THING_CopyCeilingPlane = 9511, - THING_VavoomFloor=1500, - THING_VavoomCeiling=1501, - THING_VertexFloorZ=1504, - THING_VertexCeilingZ=1505, -} slopething_e; -#endif - // // P_CopySectorSlope // From da2abbb39ff5302ee7a86e0dd717f1185af0a00a Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 16:24:51 +0100 Subject: [PATCH 024/239] Failed a build because C is an obnoxious language. --- src/p_slopes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index cb5f07b2b..bd354c500 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -764,10 +764,11 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y) // When given a vector, rotates it and aligns it to a slope void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) { + vector3_t axis; // Fuck you, C90. + if (slope->flags & SL_NOPHYSICS) return; // No physics, no quantizing. - vector3_t axis; axis.x = -slope->d.y; axis.y = slope->d.x; axis.z = 0; @@ -804,6 +805,8 @@ void P_SlopeLaunch(mobj_t *mo) // Function to help handle landing on slopes void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) { + vector3_t mom; // Ditto. + if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. if (P_MobjFlip(thing)*(thing->momz) < 0) { // falling, land on slope thing->momz = -P_MobjFlip(thing); @@ -812,7 +815,6 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) return; } - vector3_t mom; mom.x = thing->momx; mom.y = thing->momy; mom.z = thing->momz*2; From d998ddfae46f0250d1336488fe3e99ca1d2c4c95 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 17:07:28 +0100 Subject: [PATCH 025/239] When you haven't found all the vertices, it's just not safe to carry on. Hit them with a descriptive I_Error so they don't get confused as hell like Glaber did. http://mb.srb2.org/showthread.php?t=41455 for reference. Also took the opportunity to nuke or otherwise neuter a bunch of Kalaron's bizzare ramblings (most are questions which have long-been answered by Red's efforts) at the same time. --- src/p_slopes.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index bd354c500..659f8b330 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -200,7 +200,6 @@ static fixed_t P_GetExtent(sector_t *sector, line_t *line) // Find furthest vertex from the reference line. It, along with the two ends // of the line, will define the plane. - // SRB2CBTODO: Use a formula to get the slope to slide objects depending on how steep for(i = 0; i < sector->linecount; i++) { line_t *li = sector->lines[i]; @@ -232,7 +231,6 @@ static fixed_t P_GetExtent(sector_t *sector, line_t *line) // // Creates one or more slopes based on the given line type and front/back // sectors. -// Kalaron: Check if dynamic slopes need recalculation // void P_SpawnSlope_Line(int linenum) { @@ -277,7 +275,7 @@ void P_SpawnSlope_Line(int linenum) ny = -FixedDiv(line->dx, len); } - // SRB2CBTODO: Transform origin relative to the bounds of an individual FOF + // TODO: Transform origin relative to the bounds of an individual FOF origin.x = line->v1->x + (line->v2->x - line->v1->x)/2; origin.y = line->v1->y + (line->v2->y - line->v1->y)/2; @@ -328,7 +326,7 @@ void P_SpawnSlope_Line(int linenum) // fslope->normal is a 3D line perpendicular to the 3D vector // Sync the linedata of the line that started this slope - // SRB2CBTODO: Anything special for remote(control sector)-based slopes later? + // TODO: Anything special for control sector based slopes later? fslope->sourceline = line; // To find the real highz/lowz of a slope, you need to check all the vertexes @@ -380,7 +378,7 @@ void P_SpawnSlope_Line(int linenum) cslope->refpos = 2; // Sync the linedata of the line that started this slope - // SRB2CBTODO: Anything special for remote(control sector)-based slopes later? + // TODO: Anything special for control sector based slopes later? cslope->sourceline = line; // Remember the way the slope is formed @@ -446,7 +444,7 @@ void P_SpawnSlope_Line(int linenum) fslope->refpos = 3; // Sync the linedata of the line that started this slope - // SRB2CBTODO: Anything special for remote(control sector)-based slopes later? + // TODO: Anything special for control sector based slopes later? fslope->sourceline = line; // Remember the way the slope is formed @@ -489,7 +487,7 @@ void P_SpawnSlope_Line(int linenum) cslope->refpos = 4; // Sync the linedata of the line that started this slope - // SRB2CBTODO: Anything special for remote(control sector)-based slopes later? + // TODO: Anything special for control sector based slopes later? cslope->sourceline = line; // Remember the way the slope is formed @@ -555,16 +553,11 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag ret->vertices[2] = mt; } - if (!ret->vertices[0]) - CONS_Printf("PANIC 0\n"); - if (!ret->vertices[1]) - CONS_Printf("PANIC 1\n"); - if (!ret->vertices[2]) - CONS_Printf("PANIC 2\n"); - // Now set heights for each vertex, because they haven't been set yet for (i = 0; i < 3; i++) { mt = ret->vertices[i]; + if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?) + I_Error("Slope vertex %d (for linedef tag %d) not found.", i, tag1); if (mt->extrainfo) mt->z = mt->options; else From d4d44777f43297f398247f8db81302d493f25763 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 17:43:27 +0100 Subject: [PATCH 026/239] Okay, now vertex slopes aren't placement-order-dependent any more. Hopefully this is the best way to handle things. --- src/p_slopes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/p_slopes.c b/src/p_slopes.c index 659f8b330..d9e2cef66 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -546,9 +546,17 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag continue; if (!ret->vertices[0] && mt->angle == tag1) + { ret->vertices[0] = mt; + mt = mapthings; + i = 0; + } else if (!ret->vertices[1] && mt->angle == tag2) + { ret->vertices[1] = mt; + mt = mapthings; + i = 0; + } else if (!ret->vertices[2] && mt->angle == tag3) ret->vertices[2] = mt; } From 7071fbe29e5c078631c6dae366ca81bcbc570e34 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 31 May 2016 18:13:17 +0100 Subject: [PATCH 027/239] I made a mistake. Fuck git reverts, they are a nightmare, let's just do this the old fashioned way. --- src/p_slopes.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index d9e2cef66..659f8b330 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -546,17 +546,9 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag continue; if (!ret->vertices[0] && mt->angle == tag1) - { ret->vertices[0] = mt; - mt = mapthings; - i = 0; - } else if (!ret->vertices[1] && mt->angle == tag2) - { ret->vertices[1] = mt; - mt = mapthings; - i = 0; - } else if (!ret->vertices[2] && mt->angle == tag3) ret->vertices[2] = mt; } From 62c4338d60740d8147fab5503f23130f7604444f Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 1 Jun 2016 13:19:44 +0100 Subject: [PATCH 028/239] Added P_GetMobjGravity to Lua. Check /toaster/gravitytest.lua for sample script. --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 7678c7c49..05ba00d68 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -13,6 +13,7 @@ #include "doomdef.h" #ifdef HAVE_BLUA #include "p_local.h" +#include "p_mobj.h" // So we can have P_GetMobjGravity #include "p_setup.h" // So we can have P_SetupLevelSky #include "z_zone.h" #include "r_main.h" @@ -437,6 +438,16 @@ static int lib_pMobjFlip(lua_State *L) return 1; } +static int lib_pGetMobjGravity(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + //HUDSAFE + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushinteger(L, P_GetMobjGravity(mobj)); + return 1; +} + static int lib_pWeaponOrPanel(lua_State *L) { mobjtype_t type = luaL_checkinteger(L, 1); @@ -2008,6 +2019,7 @@ static luaL_Reg lib[] = { {"P_SPMAngle",lib_pSPMAngle}, {"P_SpawnPlayerMissile",lib_pSpawnPlayerMissile}, {"P_MobjFlip",lib_pMobjFlip}, + {"P_GetMobjGravity",lib_pGetMobjGravity}, {"P_WeaponOrPanel",lib_pWeaponOrPanel}, {"P_FlashPal",lib_pFlashPal}, {"P_GetClosestAxis",lib_pGetClosestAxis}, From 76d108d760a004a6e522c3364452c89074c68f0b Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 1 Jun 2016 14:49:14 +0100 Subject: [PATCH 029/239] Whoops, didn't realise pushing fixed and integer were different. My mistake. --- src/lua_baselib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 05ba00d68..c88ece50c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -444,7 +444,7 @@ static int lib_pGetMobjGravity(lua_State *L) //HUDSAFE if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); - lua_pushinteger(L, P_GetMobjGravity(mobj)); + lua_pushfixed(L, P_GetMobjGravity(mobj)); return 1; } From ae8b45965c4eb13856faffa1d4330634d200250d Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 1 Jun 2016 16:45:10 +0100 Subject: [PATCH 030/239] No Size_t --> int in an I_Error print! [/rhyme] --- src/p_slopes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 659f8b330..4a8eadc5f 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -557,7 +557,7 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag for (i = 0; i < 3; i++) { mt = ret->vertices[i]; if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?) - I_Error("Slope vertex %d (for linedef tag %d) not found.", i, tag1); + I_Error("Slope vertex %s (for linedef tag %d) not found.", sizeu1(i), tag1); if (mt->extrainfo) mt->z = mt->options; else From 44a6e8bb54db02e7085ddf7098fad38c56928210 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 1 Jun 2016 19:52:12 +0100 Subject: [PATCH 031/239] I_Error description syntax consistency (buzzword buzzword buzzword). --- src/p_slopes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 4a8eadc5f..72abf02bb 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -557,7 +557,7 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag for (i = 0; i < 3; i++) { mt = ret->vertices[i]; if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?) - I_Error("Slope vertex %s (for linedef tag %d) not found.", sizeu1(i), tag1); + I_Error("P_NewVertexSlope: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1); if (mt->extrainfo) mt->z = mt->options; else From 1493537dfc7f0d2544d621fbf30157a34693d29d Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 2 Jun 2016 14:39:41 +0100 Subject: [PATCH 032/239] Moved the standingslope check in P_ZMovement to after the FOF and height adjustment as it is in P_PlayerZMovement, as reccomended. Doesn't actually stop Crawla jittering, but might as well make it happen for consistency's sake. --- src/p_mobj.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 35d8f1ad2..acf5b1b36 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2165,16 +2165,6 @@ static boolean P_ZMovement(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); -#ifdef ESLOPE - if (mo->standingslope) - { - if (mo->flags & MF_NOCLIPHEIGHT) - mo->standingslope = NULL; - else if (!P_IsObjectOnGround(mo)) - P_SlopeLaunch(mo); - } -#endif - // Intercept the stupid 'fall through 3dfloors' bug if (mo->subsector->sector->ffloors) P_AdjustMobjFloorZ_FFloors(mo, mo->subsector->sector, 0); @@ -2189,6 +2179,16 @@ static boolean P_ZMovement(mobj_t *mo) } mo->z += mo->momz; +#ifdef ESLOPE + if (mo->standingslope) + { + if (mo->flags & MF_NOCLIPHEIGHT) + mo->standingslope = NULL; + else if (!P_IsObjectOnGround(mo)) + P_SlopeLaunch(mo); + } +#endif + switch (mo->type) { case MT_THROWNBOUNCE: From 213a9632ca4b5cd68902bc805cc625d5b24d3e41 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 2 Jun 2016 16:09:33 +0100 Subject: [PATCH 033/239] Let's multiply the thrust by the mobj's friction. You should have less chance of purchase on a slippery slope (tee hee) and more on a rough one, but the slopes were basically identical during testing before I implemented this change. --- src/p_slopes.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 72abf02bb..ec07ab2fe 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -864,8 +864,6 @@ void P_ButteredSlope(mobj_t *mo) mult = FINECOSINE(angle >> ANGLETOFINESHIFT); } - //CONS_Printf("%d\n", mult); - thrust = FixedMul(thrust, FRACUNIT*2/3 + mult/8); } @@ -873,11 +871,18 @@ void P_ButteredSlope(mobj_t *mo) thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16); // This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down - // Multiply by gravity - thrust = FixedMul(thrust, FixedMul(gravity, abs(P_GetMobjGravity(mo)))); // Now uses the absolute of mobj gravity. You're welcome. - // Multiply by scale (gravity strength depends on mobj scale) + // The strength of gravity depends on the global gravity base setting... + thrust = FixedMul(thrust, gravity); + + // ...the sector-based gravity strength... + thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo))); + + // ...and the scale of the object. thrust = FixedMul(thrust, mo->scale); + // Let's also multiply by friction for good measure. + thrust = FixedMul(thrust, mo->friction); + P_Thrust(mo, mo->standingslope->xydirection, thrust); } From 882622d2e70616376e81f82b8471645a1ac75721 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 2 Jun 2016 16:42:07 +0100 Subject: [PATCH 034/239] ...I made two major mistakes with P_GetMobjGravity. *Didn't take into account object scale *Doubled force when on the ground (ignore what the comment of the line I moved says, it was relevant for slopes...) This also led to a mistake with slopes, where I was double-multiplying by the gravity constant to get half (because of a quirk of numbers...) --- src/p_mobj.c | 10 ++++++---- src/p_slopes.c | 12 +++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index acf5b1b36..843123d57 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1316,9 +1316,6 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->eflags & MFE_UNDERWATER && !goopgravity) gravityadd = gravityadd/3; - if (!mo->momz) // mobj at stop, no floor, so feel the push of gravity! - gravityadd <<= 1; - if (mo->player) { if (mo->player->charability == CA_FLY && (mo->player->powers[pw_tailsfly] @@ -1402,6 +1399,8 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip) P_PlayerFlip(mo); + gravityadd = FixedMul(gravityadd, mo->scale); + return gravityadd; } @@ -1416,8 +1415,11 @@ void P_CheckGravity(mobj_t *mo, boolean affect) { fixed_t gravityadd = P_GetMobjGravity(mo); + if (!mo->momz) // mobj at stop, no floor, so feel the push of gravity! + gravityadd <<= 1; + if (affect) - mo->momz += FixedMul(gravityadd, mo->scale); + mo->momz += gravityadd; if (mo->type == MT_SKIM && mo->z + mo->momz <= mo->watertop && mo->z >= mo->watertop) { diff --git a/src/p_slopes.c b/src/p_slopes.c index ec07ab2fe..ed25f00f3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -812,7 +812,7 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) mom.y = thing->momy; mom.z = thing->momz*2; - //CONS_Printf("langing on slope\n"); + //CONS_Printf("Landing on slope\n"); // Reverse quantizing might could use its own function later slope->zangle = ANGLE_MAX-slope->zangle; @@ -871,16 +871,10 @@ void P_ButteredSlope(mobj_t *mo) thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16); // This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down - // The strength of gravity depends on the global gravity base setting... - thrust = FixedMul(thrust, gravity); - - // ...the sector-based gravity strength... + // Let's get the gravity strength for the object... thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo))); - // ...and the scale of the object. - thrust = FixedMul(thrust, mo->scale); - - // Let's also multiply by friction for good measure. + // ... and its friction against the ground for good measure. thrust = FixedMul(thrust, mo->friction); P_Thrust(mo, mo->standingslope->xydirection, thrust); From c1caf2132328985fc5abdbe65f08dc22bbd0aa8e Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 2 Jun 2016 16:51:12 +0100 Subject: [PATCH 035/239] Reccomended by MI: Dividing by the original friction value just so slopes with normal friction don't behave differently between next and this branch. --- src/p_slopes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index ed25f00f3..797c6a558 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -874,8 +874,8 @@ void P_ButteredSlope(mobj_t *mo) // Let's get the gravity strength for the object... thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo))); - // ... and its friction against the ground for good measure. - thrust = FixedMul(thrust, mo->friction); + // ... and its friction against the ground for good measure (divided by original friction to keep behaviour for normal slopes the same). + thrust = FixedMul(thrust, FixedDiv(mo->friction, ORIG_FRICTION)); P_Thrust(mo, mo->standingslope->xydirection, thrust); } From ba528a075ee578bd4b10d4f1bb56b424c6e1ae44 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sat, 4 Jun 2016 19:47:40 +0100 Subject: [PATCH 036/239] Last few changes as reccomended by Red. (<3 u, no hetero) --- src/doomdef.h | 2 +- src/p_slopes.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index e645c0848..cec46a32c 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -431,7 +431,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Kalaron/Eternity Engine slope code (SRB2CB ported) #define ESLOPE -#if defined(ESLOPE) +#ifdef ESLOPE /// Backwards compatibility with SRB2CB's slope linedef types. /// \note A simple shim that prints a warning. #define ESLOPE_TYPESHIM diff --git a/src/p_slopes.c b/src/p_slopes.c index 797c6a558..b6338d95d 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -275,7 +275,6 @@ void P_SpawnSlope_Line(int linenum) ny = -FixedDiv(line->dx, len); } - // TODO: Transform origin relative to the bounds of an individual FOF origin.x = line->v1->x + (line->v2->x - line->v1->x)/2; origin.y = line->v1->y + (line->v2->y - line->v1->y)/2; From 69f556d40a281caa75697bf2241703418c763648 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 5 Jun 2016 21:29:40 +0100 Subject: [PATCH 037/239] Split AA trees code from m_misc.c/.h into m_aatree.c/.h Also updated any relevant project files that I can think of to include the new files, as well as the makefile of course. Some of the other project files haven't been touched in years so I'll leave those alone ...unless someone objects --- SRB2.cbp | 33 +++++ src/CMakeLists.txt | 2 + src/Makefile | 1 + src/m_aatree.c | 167 +++++++++++++++++++++++++ src/m_aatree.h | 31 +++++ src/m_misc.c | 155 ----------------------- src/m_misc.h | 13 -- src/sdl/Srb2SDL-vc10.vcxproj | 2 + src/sdl/Srb2SDL-vc10.vcxproj.filters | 6 + src/w_wad.h | 4 +- src/win32/Srb2win-vc10.vcxproj | 2 + src/win32/Srb2win-vc10.vcxproj.filters | 6 + 12 files changed, 251 insertions(+), 171 deletions(-) create mode 100644 src/m_aatree.c create mode 100644 src/m_aatree.h diff --git a/SRB2.cbp b/SRB2.cbp index 43696ee2e..99a712264 100644 --- a/SRB2.cbp +++ b/SRB2.cbp @@ -2815,6 +2815,39 @@ HW3SOUND for 3D hardware sound support