diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c763ab3b8..2618d4077 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -257,7 +257,7 @@ set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL "Enable hardware renderer (OpenGL) FBO downsampling support") -set(SRB2_CONFIG_PHOBOS ON CACHE BOOL +set(SRB2_CONFIG_PHOBOS OFF CACHE BOOL " Compile the Phobos client. Which contains things not compatible with vanilla, such as raised skinlimits, 32 player support, bugfixes, etc.") if(${SRB2_CONFIG_DEDICATED}) @@ -586,7 +586,7 @@ if(${SRB2_CONFIG_SATURNJOIN}) add_definitions(-DDOSATURNJOIN) endif() -if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_SCREENFBO}) +if(${SRB2_CONFIG_PHOBOS}) add_definitions(-DPHOBOS_BUILD) endif() diff --git a/src/doomdef.h b/src/doomdef.h index 5a62d0a86..f37a79bfc 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -128,8 +128,13 @@ extern char logfilename[1024]; // most interface strings are ignored in development mode. // we use comprevision and compbranch instead. #else +#ifdef PHOBOS_BUILD +#define VERSION 1 // Game version +#define SUBVERSION 69 // more precise version number +#else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number +#endif #ifdef PHOBOS_BUILD #define CLIENTNAME "Phobos" @@ -139,8 +144,8 @@ extern char logfilename[1024]; #define CLIENTNAMEW L"Saturn" #endif -#define VERSIONSTRING CLIENTNAME " v10" -#define VERSIONSTRINGW CLIENTNAMEW L" v10" +#define VERSIONSTRING CLIENTNAME " v10.1" +#define VERSIONSTRINGW CLIENTNAMEW L" v10.1" #define SATURN_TESTING // comment out for saturn release builds! diff --git a/src/k_kart.c b/src/k_kart.c index 07fbacfdf..aaa5b4962 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4399,8 +4399,7 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) mobj_t *cachenext; killnext: - - if (!banana) + if (P_MobjWasRemovedCompat(banana)) return; cachenext = banana->hnext; @@ -4439,10 +4438,21 @@ void K_UpdateHnextList(player_t *player, boolean clean) nextwork = work->hnext; if (!clean && (!work->movedir || work->movedir <= (UINT16)player->kartstuff[k_itemamount])) + { continue; + } P_RemoveMobj(work); } + +#ifdef PHOBOS_BUILD + if (P_MobjWasRemoved(player->mo->hnext)) + { + // Like below, try to clean up the pointer if it's NULL. + // Maybe this was a cause of the shrink/eggbox fails? + P_SetTarget(&player->mo->hnext, NULL); + } +#endif } // For getting hit! @@ -4507,7 +4517,9 @@ void K_DropHnextList(player_t *player) } dropwork = P_SpawnMobj(work->x, work->y, work->z, type); + P_SetTarget(&dropwork->target, player->mo); + dropwork->angle = work->angle; dropwork->flags2 = work->flags2; dropwork->flags |= MF_NOCLIPTHING; @@ -4575,10 +4587,13 @@ void K_DropHnextList(player_t *player) // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... P_SetTarget(&player->mo->hnext, NULL); + player->kartstuff[k_bananadrag] = 0; if (player->kartstuff[k_eggmanheld]) + { player->kartstuff[k_eggmanheld] = 0; + } else if (player->kartstuff[k_itemheld] && (dropall || (--player->kartstuff[k_itemamount] <= 0))) { @@ -4879,7 +4894,9 @@ static void K_MoveHeldObjects(player_t *player) player->kartstuff[k_bananadrag] = 0; if (player->kartstuff[k_eggmanheld]) + { player->kartstuff[k_eggmanheld] = 0; + } else if (player->kartstuff[k_itemheld]) { player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; @@ -4896,7 +4913,9 @@ static void K_MoveHeldObjects(player_t *player) player->kartstuff[k_bananadrag] = 0; if (player->kartstuff[k_eggmanheld]) + { player->kartstuff[k_eggmanheld] = 0; + } else if (player->kartstuff[k_itemheld]) { player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; @@ -4912,7 +4931,12 @@ static void K_MoveHeldObjects(player_t *player) case MT_JAWZ_SHIELD: { mobj_t *cur = player->mo->hnext; - fixed_t speed = ((8 - min(4, player->kartstuff[k_itemamount])) * cur->info->speed) / 7; + fixed_t speed = 0; + + if (cur == NULL) + return; + + speed = ((8 - min(4, player->kartstuff[k_itemamount])) * cur->info->speed) / 7; player->kartstuff[k_bananadrag] = 0; // Just to make sure @@ -4959,8 +4983,13 @@ static void K_MoveHeldObjects(player_t *player) cur->flags &= ~MF_NOCLIPTHING; if (!P_TryMove(cur, player->mo->x + cur->momx, player->mo->y + cur->momy, true)) + { P_SlideMove(cur, true); + if (P_MobjWasRemovedCompat(cur)) + continue; + } + if (P_IsObjectOnGround(player->mo)) { if (P_MobjFlip(cur) > 0) diff --git a/src/p_inter.c b/src/p_inter.c index 0bb273ace..94e026ed9 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2016,7 +2016,7 @@ static inline void P_NiGHTSDamage(mobj_t *target, mobj_t *source) } } -static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) +static boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) { player_t *player = target->player; (void)damage; //unused parm diff --git a/src/p_local.h b/src/p_local.h index 4f59246fc..86662d12f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -418,6 +418,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch); void P_DelSeclist(msecnode_t *node); void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y); +void P_Initsecnode(void); void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist); diff --git a/src/p_map.c b/src/p_map.c index 49870bf88..52690909f 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3983,19 +3983,51 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) Lots of new Boom functions that work faster and add functionality. */ +#ifndef PHOBOS_BUILD +static msecnode_t *headsecnode = NULL; +#endif + +void P_Initsecnode(void) +{ +#ifndef PHOBOS_BUILD + headsecnode = NULL; +#endif +} + // P_GetSecnode() retrieves a node from the freelist. The calling routine // should make sure it sets all fields properly. static msecnode_t *P_GetSecnode(void) { +#ifdef PHOBOS_BUILD return Z_LevelPoolCalloc(sizeof(msecnode_t)); +#else + msecnode_t *node; + + if (headsecnode) + { + // vanilla does not clear this + // so for compat reasons we also dont + // means we just reuse stale data which causes weird interactions with orbiting items in some cases + node = headsecnode; + headsecnode = headsecnode->m_thinglist_next; + } + else + node = Z_LevelPoolCalloc(sizeof(msecnode_t)); + + return node; +#endif } // P_PutSecnode() returns a node to the freelist. - static inline void P_PutSecnode(msecnode_t *node) { +#ifdef PHOBOS_BUILD Z_LevelPoolFree(node, sizeof(msecnode_t)); +#else + node->m_thinglist_next = headsecnode; + headsecnode = node; +#endif } // P_AddSecnode() searches the current list to see if this sector is diff --git a/src/p_mobj.c b/src/p_mobj.c index fbb821e88..5b9deaaf7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10338,13 +10338,25 @@ void P_RemoveMobj(mobj_t *mobj) if (!P_MobjWasRemoved(mobj->hnext)) { - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); +#ifdef PHOBOS_BUILD + if (mobj->hnext->hprev == mobj) +#endif + { + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + } + P_SetTarget(&mobj->hnext, NULL); } if (!P_MobjWasRemoved(mobj->hprev)) { - P_SetTarget(&mobj->hprev->hnext, cachenext); +#ifdef PHOBOS_BUILD + if (mobj->hprev->hnext == mobj) +#endif + { + P_SetTarget(&mobj->hprev->hnext, cachenext); + } + P_SetTarget(&mobj->hprev, NULL); } diff --git a/src/p_setup.c b/src/p_setup.c index 2201c0b9f..485c5e274 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3001,6 +3001,9 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) CON_Drawer(); // let the user know what we are going to do I_FinishUpdate(); // page flip or blit buffer + // Initialize sector node list. + P_Initsecnode(); + if (netgame || multiplayer) cv_debug = botskin = 0; @@ -3328,6 +3331,7 @@ static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i) return false; } + // // P_CheckReplacMapReplacements // diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 24073a4d4..3746f50a9 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -174,15 +174,10 @@ static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt) { frontrgba = pGammaCorrectedPalette[fg]; -#if 0 // perfect implementation - result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); - result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt); - table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); -#else // performance scrabbler result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt); + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut_corrected, result.s.red, result.s.green, result.s.blue); // pGammaCorrectedPalette -#endif } } } @@ -190,6 +185,7 @@ static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt) static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) { INT16 bg, fg; + RGBA_t backrgba, frontrgba, result; if (table == NULL) I_Error("BlendTab_Subtractive: input table was NULL!"); @@ -202,11 +198,11 @@ static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) for (bg = 0; bg < 0x100; bg++) { + backrgba = pLocalPalette[bg]; // intentionally uses pLocalPalette + for (fg = 0; fg < 0x100; fg++) { - RGBA_t backrgba = V_GetColor(bg); - RGBA_t frontrgba = V_GetColor(fg); - RGBA_t result; + frontrgba = pLocalPalette[fg]; result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); result.s.red = std::max(0, result.s.red - blendamt); @@ -221,17 +217,19 @@ static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) static void BlendTab_Modulative(UINT8 *table) { INT16 bg, fg; + RGBA_t backrgba, frontrgba, result; if (table == NULL) I_Error("BlendTab_Modulative: input table was NULL!"); for (bg = 0; bg < 0x100; bg++) { + backrgba = pGammaCorrectedPalette[bg]; + for (fg = 0; fg < 0x100; fg++) { - RGBA_t backrgba = V_GetColor(bg); - RGBA_t frontrgba = V_GetColor(fg); - RGBA_t result; + frontrgba = pGammaCorrectedPalette[fg]; + result.rgba = ASTBlendPixel(backrgba, frontrgba, AST_MODULATE, 0); table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut_corrected, result.s.red, result.s.green, result.s.blue); }