From 7e4d0ecdbf6c1a91c8f70a6c5eb7179f0f956eaf Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 24 Sep 2016 09:00:31 +0200 Subject: [PATCH 1/6] - Fixed GCC/Clang regression post serialization. --- src/g_game.cpp | 4 ++-- src/serializer.cpp | 2 +- src/serializer.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 5d1f83b82..629202ea5 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1884,7 +1884,7 @@ void G_DoLoadGame () } else { - Printf("Savegame is from another ZDoom-based engine: %s\n", engine); + Printf("Savegame is from another ZDoom-based engine: %s\n", engine.GetChars()); } delete resfile; return; @@ -2261,7 +2261,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio } auto picdata = savepic.GetBuffer(); - FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), METHOD_STORED, 0, crc32(0, &(*picdata)[0], picdata->Size()), (char*)&(*picdata)[0] }; + FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), METHOD_STORED, 0, static_cast(crc32(0, &(*picdata)[0], picdata->Size())), (char*)&(*picdata)[0] }; savegame_content.Push(bufpng); savegame_filenames.Push("savepic.png"); diff --git a/src/serializer.cpp b/src/serializer.cpp index ae1c55a7a..a23459ced 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -859,7 +859,7 @@ void FSerializer::ReadObjects(bool hubtravel) PClass *cls = PClass::FindClass(clsname); if (cls == nullptr) { - Printf("Unknown object class '%d' in savegame", clsname.GetChars()); + Printf("Unknown object class '%s' in savegame", clsname.GetChars()); founderrors = true; r->mDObjects[i] = RUNTIME_CLASS(AActor)->CreateNew(); // make sure we got at least a valid pointer for the duration of the loading process. r->mDObjects[i]->Destroy(); // but we do not want to keep this around, so destroy it right away. diff --git a/src/serializer.h b/src/serializer.h index f1d35e1f8..a3e1f531e 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -163,7 +163,7 @@ public: template FSerializer &Enum(const char *key, T &obj) { - auto val = (std::underlying_type::type)obj; + auto val = (typename std::underlying_type::type)obj; Serialize(*this, key, val, nullptr); obj = (T)val; return *this; @@ -299,4 +299,4 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TFlags &flags, } -#endif \ No newline at end of file +#endif From fa52c9d098a04e3d2585edef6b2cb61097885181 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Thu, 22 Sep 2016 18:19:11 -0400 Subject: [PATCH 2/6] Add first level folder contents to SOURCES for PK3 targets, so I can open the files from Visual Studio. (cherry picked from commit c378cd4ff0b901051671932a39e3cb56e82541f4) # Conflicts: # CMakeLists.txt --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d7da1644..50af33916 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,11 +49,13 @@ function( add_pk3 PK3_NAME PK3_DIR ) DEPENDS zipdir ) endif() - # Touch the zipdir executable here so that the pk3s are forced to - # rebuild each time since their dependecy has "changed." - add_custom_target( ${PK3_TARGET} ALL - COMMAND ${CMAKE_COMMAND} -E touch $ - DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ) + file(GLOB PK3_SRCS ${PK3_DIR}/*) + # Touch the zipdir executable here so that the pk3s are forced to + # rebuild each time since their dependecy has "changed." + add_custom_target( ${PK3_TARGET} ALL + COMMAND ${CMAKE_COMMAND} -E touch $ + DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} + SOURCES "${PK3_SRCS}") endfunction() # Macro for building libraries without debugging information From 19c3529d32f467ca0bec0344c450b8c89a9085f0 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Fri, 23 Sep 2016 18:16:42 -0400 Subject: [PATCH 3/6] Add a comment describing my enhancement to the CMake PK3 target rule. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50af33916..7a2b2ca92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ function( add_pk3 PK3_NAME PK3_DIR ) COMMAND zipdir -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR} DEPENDS zipdir ) endif() - + # Grab a list of top-level PK3 folder files, so we can conveniently see them in the IDE file(GLOB PK3_SRCS ${PK3_DIR}/*) # Touch the zipdir executable here so that the pk3s are forced to # rebuild each time since their dependecy has "changed." From e9f31e5f95c6a24040567f58fa8440d46387f4aa Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Fri, 23 Sep 2016 18:24:54 -0400 Subject: [PATCH 4/6] Fix tabbing of recent change to CMakeLists.txt to match previous version. --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a2b2ca92..485d6ea03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,14 +48,14 @@ function( add_pk3 PK3_NAME PK3_DIR ) COMMAND zipdir -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR} DEPENDS zipdir ) endif() - # Grab a list of top-level PK3 folder files, so we can conveniently see them in the IDE - file(GLOB PK3_SRCS ${PK3_DIR}/*) - # Touch the zipdir executable here so that the pk3s are forced to - # rebuild each time since their dependecy has "changed." - add_custom_target( ${PK3_TARGET} ALL - COMMAND ${CMAKE_COMMAND} -E touch $ - DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} - SOURCES "${PK3_SRCS}") + # Grab a list of top-level PK3 folder files, so we can conveniently see them in the IDE + file(GLOB PK3_SRCS ${PK3_DIR}/*) + # Touch the zipdir executable here so that the pk3s are forced to + # rebuild each time since their dependecy has "changed." + add_custom_target( ${PK3_TARGET} ALL + COMMAND ${CMAKE_COMMAND} -E touch $ + DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} + SOURCES "${PK3_SRCS}") endfunction() # Macro for building libraries without debugging information From dfa4f38c8ffafdb9dc5b36d4badd2315f00a7f7d Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sun, 18 Sep 2016 15:07:08 -0500 Subject: [PATCH 5/6] Updated to new save game code. --- src/actor.h | 10 +++- src/namedef.h | 4 ++ src/p_mobj.cpp | 69 +++++++++++++++++++++++++++- src/r_things.cpp | 3 +- src/thingdef/thingdef_codeptr.cpp | 52 +++++++++++++++++++++ src/thingdef/thingdef_data.cpp | 7 +++ src/thingdef/thingdef_properties.cpp | 22 +++++++++ src/version.h | 2 +- wadsrc/static/actors/actor.txt | 3 ++ wadsrc/static/actors/constants.txt | 12 +++++ 10 files changed, 180 insertions(+), 4 deletions(-) diff --git a/src/actor.h b/src/actor.h index 1e939d563..dbb308258 100644 --- a/src/actor.h +++ b/src/actor.h @@ -417,7 +417,10 @@ enum ActorRenderFlag RF_INVISIBLE = 0x8000, // Don't bother drawing this actor RF_ROLLSPRITE = 0x40000, //[marrub]roll the sprite billboard RF_DONTFLIP = 0x80000, // Don't flip it when viewed from behind. - RF_ROLLCENTER = 0x100000, // Rotate from the center of sprite instead of offsets + RF_ROLLCENTER = 0x00100000, // Rotate from the center of sprite instead of offsets + RF_MASKROTATION = 0x00200000, // [MC] Only draw the actor when viewed from a certain angle range. + RF_ABSMASKANGLE = 0x00400000, // [MC] The mask rotation does not offset by the actor's angle. + RF_ABSMASKPITCH = 0x00800000, // [MC] The mask rotation does not offset by the actor's pitch. RF_FORCEYBILLBOARD = 0x10000, // [BB] OpenGL only: draw with y axis billboard, i.e. anchored to the floor (overrides gl_billboard_mode setting) RF_FORCEXYBILLBOARD = 0x20000, // [BB] OpenGL only: draw with xy axis billboard, i.e. unanchored (overrides gl_billboard_mode setting) @@ -959,6 +962,7 @@ public: inline void SetFriendPlayer(player_t *player); bool IsVisibleToPlayer() const; + bool IsInsideVisibleAngles() const; // Calculate amount of missile damage virtual int GetMissileDamage(int mask, int add); @@ -984,6 +988,10 @@ public: DAngle SpriteAngle; DAngle SpriteRotation; + DAngle VisibleStartAngle; + DAngle VisibleStartPitch; + DAngle VisibleEndAngle; + DAngle VisibleEndPitch; DRotator Angles; DVector3 Vel; double Speed; diff --git a/src/namedef.h b/src/namedef.h index f1279d27c..c8b0d1524 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -336,6 +336,10 @@ xx(ReactionTime) xx(MeleeRange) xx(Speed) xx(Clamp) +xx(VisibleStartAngle) +xx(VisibleStartPitch) +xx(VisibleEndAngle) +xx(VisibleEndPitch) // Various actor names which are used internally xx(MapSpot) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 657d5db49..8d6d75237 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -306,7 +306,11 @@ void AActor::Serialize(FSerializer &arc) A("spriteangle", SpriteAngle) A("spriterotation", SpriteRotation) ("alternative", alternative) - A("tag", Tag); + A("tag", Tag) + A("visiblestartangle",VisibleStartAngle) + A("visibleendangle",VisibleEndAngle) + A("visiblestartpitch",VisibleStartPitch) + A("visibleendpitch",VisibleEndPitch); } #undef A @@ -1019,6 +1023,69 @@ bool AActor::CheckLocalView (int playernum) const return false; } +//============================================================================ +// +// AActor :: IsInsideVisibleAngles +// +// Returns true if this actor is within viewing angle/pitch visibility. +// +//============================================================================ + +bool AActor::IsInsideVisibleAngles() const +{ + // Don't bother masking if not wanted. + if (!(renderflags & RF_MASKROTATION)) + return true; + + if (players[consoleplayer].camera == nullptr) + return true; + + DAngle anglestart = VisibleStartAngle.Normalized180(); + DAngle angleend = VisibleEndAngle.Normalized180(); + DAngle pitchstart = VisibleStartPitch.Normalized180(); + DAngle pitchend = VisibleEndPitch.Normalized180(); + + if (anglestart > angleend) + { + DAngle temp = anglestart; + anglestart = angleend; + angleend = temp; + } + + if (pitchstart > angleend) + { + DAngle temp = pitchstart; + pitchstart = pitchend; + pitchend = temp; + } + + player_t* pPlayer = players[consoleplayer].camera->player; + + if (pPlayer && pPlayer->mo) + { + AActor *mo = pPlayer->mo; + DVector3 diffang = Vec3To(mo); + DAngle to = diffang.Angle(); + + if (!(renderflags & RF_ABSMASKANGLE)) + to = deltaangle(Angles.Yaw, to); + + // Note that this check is inversed due to only being able to vectorize + // from one way (this actor to the player). It still means to pass + // if the player is within the visible angles. + if ((to <= anglestart || to >= angleend)) + { + to = diffang.Pitch(); + if (!(renderflags & RF_ABSMASKPITCH)) + to = deltaangle(Angles.Pitch, to); + + return !!(to >= pitchstart && to <= pitchend); + } + else return false; + } + return true; +} + //============================================================================ // // AActor :: IsVisibleToPlayer diff --git a/src/r_things.cpp b/src/r_things.cpp index a62525d08..a45a6826a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -761,7 +761,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor if (thing == NULL || (thing->renderflags & RF_INVISIBLE) || !thing->RenderStyle.IsVisible(thing->Alpha) || - !thing->IsVisibleToPlayer()) + !thing->IsVisibleToPlayer() || + !thing->IsInsideVisibleAngles()) { return; } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 21551364b..153c3b597 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -7344,3 +7344,55 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpriteRotation) mobj->SpriteRotation = angle; ACTION_RETURN_BOOL(true); } + +//========================================================================== +// +// A_SetMaskRotation(anglestart, angleend, pitchstart, pitchend, flags, ptr) +// +// Specifies how much to fake a sprite rotation. +//========================================================================== + +enum VRFFlags +{ + VRF_NOANGLESTART = 1, + VRF_NOANGLEEND = 1 << 1, + VRF_NOPITCHSTART = 1 << 2, + VRF_NOPITCHEND = 1 << 3, +}; + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetVisibleRotation) +{ + PARAM_ACTION_PROLOGUE; + PARAM_ANGLE_OPT(anglestart) { anglestart = 0.; } + PARAM_ANGLE_OPT(angleend) { angleend = 0.; } + PARAM_ANGLE_OPT(pitchstart) { pitchstart = 0.; } + PARAM_ANGLE_OPT(pitchend) { pitchend = 0.; } + PARAM_INT_OPT(flags) { flags = 0; } + PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } + + AActor *mobj = COPY_AAPTR(self, ptr); + + if (mobj == nullptr) + { + ACTION_RETURN_BOOL(false); + } + + if (!(flags & VRF_NOANGLESTART)) + { + mobj->VisibleStartAngle = anglestart; + } + if (!(flags & VRF_NOANGLEEND)) + { + mobj->VisibleEndAngle = angleend; + } + if (!(flags & VRF_NOPITCHSTART)) + { + mobj->VisibleStartPitch = pitchstart; + } + if (!(flags & VRF_NOPITCHEND)) + { + mobj->VisibleEndPitch = pitchend; + } + + ACTION_RETURN_BOOL(true); +} diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 8248634a3..efdd64921 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -275,6 +275,9 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(RF, WALLSPRITE, AActor, renderflags), DEFINE_FLAG(RF, DONTFLIP, AActor, renderflags), DEFINE_FLAG(RF, ROLLCENTER, AActor, renderflags), + DEFINE_FLAG(RF, MASKROTATION, AActor, renderflags), + DEFINE_FLAG(RF, ABSMASKANGLE, AActor, renderflags), + DEFINE_FLAG(RF, ABSMASKPITCH, AActor, renderflags), // Bounce flags DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags), @@ -667,4 +670,8 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_Threshold, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, threshold))); symt.AddSymbol(new PField(NAME_DefThreshold, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, DefThreshold))); symt.AddSymbol(new PField(NAME_Damage, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, DamageVal))); + symt.AddSymbol(new PField(NAME_VisibleStartAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleStartAngle))); + symt.AddSymbol(new PField(NAME_VisibleStartPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleStartPitch))); + symt.AddSymbol(new PField(NAME_VisibleEndAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndAngle))); + symt.AddSymbol(new PField(NAME_VisibleEndPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndPitch))); } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 3cb424ea3..8ada05aa6 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1431,6 +1431,28 @@ DEFINE_PROPERTY(spriterotation, F, Actor) defaults->SpriteRotation = i; } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(visibleangles, Ff, Actor) +{ + PROP_DOUBLE_PARM(visstart, 0); + PROP_DOUBLE_PARM(visend, 0); + defaults->VisibleStartAngle = visstart; + defaults->VisibleEndAngle = visend; +} + +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(visiblepitch, Ff, Actor) +{ + PROP_DOUBLE_PARM(visstart, 0); + PROP_DOUBLE_PARM(visend, 0); + defaults->VisibleStartPitch = visstart; + defaults->VisibleEndPitch = visend; +} + //========================================================================== // //========================================================================== diff --git a/src/version.h b/src/version.h index 439a21a83..4f45aed0c 100644 --- a/src/version.h +++ b/src/version.h @@ -79,7 +79,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4550 +#define SAVEVER 4551 // This is so that derivates can use the same savegame versions without worrying about engine compatibility #define GAMESIG "ZDOOM" diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 374e2472d..3354b91d6 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -38,6 +38,8 @@ ACTOR Actor native //: Thinker SpriteAngle 0 SpriteRotation 0 StencilColor "00 00 00" + VisibleAngles 0, 0 + VisiblePitch 0, 0 // Functions native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); @@ -340,6 +342,7 @@ ACTOR Actor native //: Thinker action native bool A_CopySpriteFrame(int from, int to, int flags = 0); action native bool A_SetSpriteAngle(float angle = 0, int ptr = AAPTR_DEFAULT); action native bool A_SetSpriteRotation(float angle = 0, int ptr = AAPTR_DEFAULT); + action native bool A_SetVisibleRotation(float anglestart = 0, float angleend = 0, float pitchstart = 0, float pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 2a6f1c483..bd6d65643 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -677,4 +677,16 @@ enum { CPSF_NOSPRITE = 1, CPSF_NOFRAME = 1 << 1, +}; + +//Flags for A_SetMaskRotation +enum +{ + VRF_NOANGLESTART = 1, + VRF_NOANGLEEND = 1 << 1, + VRF_NOPITCHSTART = 1 << 2, + VRF_NOPITCHEND = 1 << 3, + + VRF_NOANGLE = VRF_NOANGLESTART|VRF_NOANGLEEND, + VRF_NOPITCH = VRF_NOPITCHSTART|VRF_NOPITCHEND, }; \ No newline at end of file From 3862c77b4b70fdb213478f52e04228a0a7259f5e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Sep 2016 09:18:25 +0200 Subject: [PATCH 6/6] - undid savegame version bump because it's not needed. --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 4f45aed0c..ed7c02095 100644 --- a/src/version.h +++ b/src/version.h @@ -75,11 +75,11 @@ const char *GetVersionString(); #define SAVEGAME_EXT "zds" // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 4545 +#define MINSAVEVER 4550 // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4551 +#define SAVEVER 4550 // This is so that derivates can use the same savegame versions without worrying about engine compatibility #define GAMESIG "ZDOOM"