From cc2b0b0dcf3939df104b9604705e3051522ddfe6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Oct 2009 15:26:19 +0000 Subject: [PATCH] - made max. view pitch a property of the renderer so that it's overridable without changing game code. - made SpawningMapThing an argument of AActor::StaticSpawn instead of a global variable. - added a stub to the DECORATE parser for defining dynamic lights directly in DECORATE. This is needed so that ZDoom remains compatible with any DECORATE which uses this GZDoom feature in the future. SVN r1935 (trunk) --- docs/rh-log.txt | 9 +++++++ src/actor.h | 2 +- src/d_player.h | 3 --- src/g_level.cpp | 18 ++++++++++++++ src/info.h | 2 ++ src/m_options.cpp | 2 +- src/p_3dfloors.cpp | 1 + src/p_mobj.cpp | 10 ++++---- src/p_user.cpp | 6 ++--- src/r_data.h | 1 + src/r_main.cpp | 8 +++---- src/thingdef/thingdef_states.cpp | 15 ++++++++++++ src/v_video.cpp | 41 ++++++++++++++++++++++++++++++++ src/v_video.h | 9 +++++++ 14 files changed, 109 insertions(+), 18 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 3764a67d4a..905f273264 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,12 @@ +October 24, 2009 (Changes by Graf Zahl) +- made max. view pitch a property of the renderer so that it's overridable without + changing game code. +- made SpawningMapThing an argument of AActor::StaticSpawn instead of a global + variable. +- added a stub to the DECORATE parser for defining dynamic lights directly + in DECORATE. This is needed so that ZDoom remains compatible with any DECORATE + which uses this GZDoom feature in the future. + October 24, 2009 - Removed the Actor uservar array and replaced it with user-defined variables. A_SetUserVar/SetUserVariable/GetUserVariable now take a variable name diff --git a/src/actor.h b/src/actor.h index 730b9006f0..8dbfdf1941 100644 --- a/src/actor.h +++ b/src/actor.h @@ -547,7 +547,7 @@ public: void Serialize (FArchive &arc); - static AActor *StaticSpawn (const PClass *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); + static AActor *StaticSpawn (const PClass *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement, bool SpawningMapThing = false); inline AActor *GetDefault () const { diff --git a/src/d_player.h b/src/d_player.h index fa936b5522..b23d0616da 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -414,9 +414,6 @@ void P_CheckPlayerSprites(); #define CROUCHSPEED (FRACUNIT/12) -#define MAX_DN_ANGLE 56 // Max looking down angle -#define MAX_UP_ANGLE 32 // Max looking up angle - // [GRB] Custom player classes enum diff --git a/src/g_level.cpp b/src/g_level.cpp index 948e89b63f..a2bd300eda 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -84,6 +84,16 @@ #include "g_hub.h" +#ifndef STAT +#define STAT_NEW(map) +#define STAT_END(newl) +#define STAT_SAVE(arc, hub) +#else +void STAT_NEW(const char *lev); +void STAT_END(const char *newl); +void STAT_SAVE(FArchive &arc, bool hubload); +#endif + EXTERN_CVAR (Float, sv_gravity) EXTERN_CVAR (Float, sv_aircontrol) EXTERN_CVAR (Int, disableautosave) @@ -495,6 +505,8 @@ void G_InitNew (const char *mapname, bool bTitleLevel) // force players to be initialized upon first level load for (i = 0; i < MAXPLAYERS; i++) players[i].playerstate = PST_ENTER; // [BC] + + STAT_NEW(mapname); } usergame = !bTitleLevel; // will be set false if a demo @@ -596,6 +608,8 @@ void G_ChangeLevel(const char *levelname, int position, bool keepFacing, int nex FBehavior::StaticStartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true); unloading = false; + STAT_END(nextlevel); + if (thiscluster && (thiscluster->flags & CLUSTER_HUB)) { if ((level.flags & LEVEL_NOINTERMISSION) || (nextcluster == thiscluster)) @@ -1389,6 +1403,8 @@ void G_AirControlChanged () void G_SerializeLevel (FArchive &arc, bool hubLoad) { int i = level.totaltime; + + screen->StartSerialize(arc); arc << level.flags << level.flags2 @@ -1507,6 +1523,8 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) } } } + screen->EndSerialize(arc); + STAT_SAVE(arc, hubLoad); } //========================================================================== diff --git a/src/info.h b/src/info.h index 5e06bcc10d..da248b9ce7 100644 --- a/src/info.h +++ b/src/info.h @@ -59,6 +59,7 @@ struct FState long Misc2; // Was changed to BYTE, reverted to long for MBF compat BYTE Frame; BYTE DefineFlags; // Unused byte so let's use it during state creation. + short Light; FState *NextState; actionf_p ActionFunc; int ParameterIndex; @@ -211,5 +212,6 @@ extern FDoomEdMap DoomEdMap; int GetSpriteIndex(const char * spritename); TArray &MakeStateNameList(const char * fname); +void AddStateLight(FState *state, const char *lname); #endif // __INFO_H__ diff --git a/src/m_options.cpp b/src/m_options.cpp index 8048b52ea6..ac297a2f2b 100644 --- a/src/m_options.cpp +++ b/src/m_options.cpp @@ -346,7 +346,7 @@ menu_t JoystickConfigMenu = * *=======================================*/ -static menuitem_t ControlsItems[] = +menuitem_t ControlsItems[] = { { redtext,"ENTER to change, BACKSPACE to clear", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} }, { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} }, diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index d1509c6497..b9b82a566e 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -130,6 +130,7 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag if (ffloor->top.plane->a || ffloor->top.plane->b || ffloor->bottom.plane->a || ffloor->bottom.plane->b) { ffloor->alpha = FRACUNIT; + ffloor->flags &= ~FF_ADDITIVETRANS; } sec->e->XFloor.ffloors.Push(ffloor); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index f03bdbd461..9b9824264e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -85,7 +85,6 @@ EXTERN_CVAR (Int, cl_rockettrails) // PRIVATE DATA DEFINITIONS ------------------------------------------------ -static bool SpawningMapThing; static FRandom pr_explodemissile ("ExplodeMissile"); FRandom pr_bounce ("Bounce"); static FRandom pr_reflect ("Reflect"); @@ -560,6 +559,7 @@ bool AActor::SetState (FState *newstate) newstate = newstate->GetNextState(); } while (tics == 0); + screen->StateChanged(this); return true; } @@ -619,6 +619,7 @@ bool AActor::SetStateNF (FState *newstate) newstate = newstate->GetNextState(); } while (tics == 0); + screen->StateChanged(this); return true; } @@ -3459,7 +3460,7 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) // //========================================================================== -AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t iz, replace_t allowreplacement) +AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t iz, replace_t allowreplacement, bool SpawningMapThing) { if (type == NULL) { @@ -3623,6 +3624,7 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t { level.total_items++; } + screen->StateChanged(actor); return actor; } @@ -4339,9 +4341,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) else z = ONFLOORZ; - SpawningMapThing = true; - mobj = Spawn (i, x, y, z, NO_REPLACE); - SpawningMapThing = false; + mobj = AActor::StaticSpawn (i, x, y, z, NO_REPLACE, true); if (z == ONFLOORZ) mobj->z += mthing->z; diff --git a/src/p_user.cpp b/src/p_user.cpp index 7b6e34048e..374442a188 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2156,13 +2156,11 @@ void P_PlayerThink (player_t *player) player->mo->pitch -= look; if (look > 0) { // look up - if (player->mo->pitch < -ANGLE_1*MAX_UP_ANGLE) - player->mo->pitch = -ANGLE_1*MAX_UP_ANGLE; + player->mo->pitch = MAX(player->mo->pitch, screen->GetMaxViewPitch(false)); } else { // look down - if (player->mo->pitch > ANGLE_1*MAX_DN_ANGLE) - player->mo->pitch = ANGLE_1*MAX_DN_ANGLE; + player->mo->pitch = MIN(player->mo->pitch, screen->GetMaxViewPitch(true)); } } } diff --git a/src/r_data.h b/src/r_data.h index acd70284de..487860e589 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -93,6 +93,7 @@ public: void Unload (); bool CheckModified (); void RenderView (AActor *viewpoint, int fov); + void NeedUpdate() { bNeedsUpdate=true; } protected: DSimpleCanvas *Canvas; diff --git a/src/r_main.cpp b/src/r_main.cpp index e5caada3de..bcec61c73c 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -852,11 +852,11 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi // Avoid overflowing viewpitch (can happen when a netgame is stalled) if (viewpitch + delta <= viewpitch) { - viewpitch = +ANGLE_1*MAX_DN_ANGLE; + viewpitch = screen->GetMaxViewPitch(true); } else { - viewpitch = MIN(viewpitch + delta, +ANGLE_1*MAX_DN_ANGLE); + viewpitch = MIN(viewpitch + delta, screen->GetMaxViewPitch(true)); } } else if (delta < 0) @@ -864,11 +864,11 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi // Avoid overflowing viewpitch (can happen when a netgame is stalled) if (viewpitch + delta >= viewpitch) { - viewpitch = -ANGLE_1*MAX_UP_ANGLE; + viewpitch = screen->GetMaxViewPitch(false); } else { - viewpitch = MAX(viewpitch + delta, -ANGLE_1*MAX_UP_ANGLE); + viewpitch = MAX(viewpitch + delta, screen->GetMaxViewPitch(false)); } } } diff --git a/src/thingdef/thingdef_states.cpp b/src/thingdef/thingdef_states.cpp index d7252c4197..c04193718d 100644 --- a/src/thingdef/thingdef_states.cpp +++ b/src/thingdef/thingdef_states.cpp @@ -55,6 +55,7 @@ #include "i_system.h" #include "colormatcher.h" #include "thingdef_exp.h" +#include "version.h" //========================================================================== //*** @@ -258,6 +259,20 @@ do_stop: sc.MustGetStringName(")"); continue; } + if (sc.Compare("LIGHT")) + { + sc.MustGetStringName("("); + do + { + sc.MustGetString(); + #ifdef DYNLIGHT + AddStateLight(&state, sc.String); + #endif + } + while (sc.CheckString(",")); + sc.MustGetStringName(")"); + continue; + } // Make the action name lowercase to satisfy the gperf hashers strlwr (sc.String); diff --git a/src/v_video.cpp b/src/v_video.cpp index acd481f68b..ca8eb7fdc4 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1269,7 +1269,48 @@ void DFrameBuffer::DrawRemainingPlayerSprites() R_DrawRemainingPlayerSprites(); } +//=========================================================================== +// +// notify the renderer that an actor has changed state +// +//=========================================================================== +void DFrameBuffer::StateChanged(AActor *actor) +{ +} + +//=========================================================================== +// +// notify the renderer that serialization of the curent level is about to start/end +// +//=========================================================================== + +void DFrameBuffer::StartSerialize(FArchive &arc) +{ +} + +void DFrameBuffer::EndSerialize(FArchive &arc) +{ +} + +//=========================================================================== +// +// Get max. view angle (renderer specific information so it goes here now) +// +//=========================================================================== +#define MAX_DN_ANGLE 56 // Max looking down angle +#define MAX_UP_ANGLE 32 // Max looking up angle + +int DFrameBuffer::GetMaxViewPitch(bool down) +{ + return down? MAX_DN_ANGLE*ANGLE_1 : -MAX_UP_ANGLE*ANGLE_1; +} + +//=========================================================================== +// +// +// +//=========================================================================== FNativePalette::~FNativePalette() { diff --git a/src/v_video.h b/src/v_video.h index a6f30a43af..3109901bb2 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -351,6 +351,15 @@ public: // draws player sprites with hardware acceleration (only useful for software rendering) virtual void DrawRemainingPlayerSprites(); + // notifies the renderer that an actor has changed state. + virtual void StateChanged(AActor *actor); + + // notify the renderer that serialization of the curent level is about to start/end + virtual void StartSerialize(FArchive &arc); + virtual void EndSerialize(FArchive &arc); + + virtual int GetMaxViewPitch(bool down); + bool Accel2D; // If true, 2D drawing can be accelerated. // Begin 2D drawing operations. This is like Update, but it doesn't end