From ccecfeb45ceaacf9e19b8099a35c70f73c11311c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 9 Feb 2017 01:34:07 +0100 Subject: [PATCH 1/6] - to avoid problems with the final garbage collection, the players' PendingWeapon needs to be cleared manually. This is because it can point to a non-standard value which the garbage collector cannot deal with during engine shutdown. --- src/dobjtype.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 34709cddc..25e27b846 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -2817,6 +2817,13 @@ void PClass::StaticShutdown () // This flags DObject::Destroy not to call any scripted OnDestroy methods anymore. bVMOperational = false; + // PendingWeapon must be cleared manually because it is not subjected to the GC if it contains WP_NOCHANGE, which is just RUNTIME_CLASS(AWWeapon). + // But that will get cleared here, confusing the GC if the value is left in. + for (auto &p : players) + { + p.PendingWeapon = nullptr; + } + // Unless something went wrong, anything left here should be class and type objects only, which do not own any scripts. bShutdown = true; TypeTable.Clear(); From 4dd7e02721d60f0184e7cb57bb5901caaa9f9948 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 9 Feb 2017 10:15:05 +0200 Subject: [PATCH 2/6] AActor::GiveInventory() is now functional See https://mantis.zdoom.org/view.php?id=213 --- src/p_mobj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 2650224be..53491f235 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -771,7 +771,7 @@ bool AActor::GiveInventory(PClassActor *type, int amount, bool givecheat) { bool result = true; - if (type != nullptr || !type->IsDescendantOf(RUNTIME_CLASS(AInventory))) return false; + if (type == nullptr || !type->IsDescendantOf(RUNTIME_CLASS(AInventory))) return false; AWeapon *savedPendingWeap = player != NULL ? player->PendingWeapon : NULL; bool hadweap = player != NULL ? player->ReadyWeapon != NULL : true; From 4f0747c59e7ec1ecfd24fa33965c05f386125874 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 9 Feb 2017 11:11:54 +0100 Subject: [PATCH 3/6] - fixed: Class pointers were accepted for objects of the base type 'Object'. --- src/scripting/backend/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index c05ab6d64..71ecfc58c 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -7863,7 +7863,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx) return x->Resolve(ctx); } - if (Self->ValueType->IsKindOf(RUNTIME_CLASS(PPointer))) + if (Self->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)) && !Self->ValueType->IsKindOf(RUNTIME_CLASS(PClassPointer))) { auto ptype = static_cast(Self->ValueType)->PointedType; if (ptype->IsKindOf(RUNTIME_CLASS(PStruct))) From 845f5e083366f109d558659e2fa080d48801c3a0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 9 Feb 2017 11:22:36 +0100 Subject: [PATCH 4/6] - fixed: A_Teleport and A_Warp had incorrect declarations for their state parameter. --- src/p_actionfunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 518d2fb63..69ca13f16 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -5012,7 +5012,7 @@ enum T_Flags DEFINE_ACTION_FUNCTION(AActor, A_Teleport) { PARAM_ACTION_PROLOGUE(AActor); - PARAM_STATE_DEF (teleport_state) + PARAM_STATE_ACTION_DEF (teleport_state) PARAM_CLASS_DEF (target_type, ASpecialSpot) PARAM_CLASS_DEF (fog_type, AActor) PARAM_INT_DEF (flags) @@ -5449,7 +5449,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Warp) PARAM_FLOAT_DEF(zofs) PARAM_ANGLE_DEF(angle) PARAM_INT_DEF(flags) - PARAM_STATE_DEF(success_state) + PARAM_STATE_ACTION_DEF(success_state) PARAM_FLOAT_DEF(heightoffset) PARAM_FLOAT_DEF(radiusoffset) PARAM_ANGLE_DEF(pitch) From a4d146c843570561ac83a83c6d76b5f358e3ba8e Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Thu, 9 Feb 2017 15:06:53 +0800 Subject: [PATCH 5/6] Added DONTCULLBACKFACES MODELDEF flag to forcefully disable backface culling on models --- src/gl/models/gl_models.cpp | 7 ++++++- src/gl/models/gl_models.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 47283b51a..0bfc059a1 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -787,6 +787,10 @@ void gl_InitModels() map[c]=1; } } + else if (sc.Compare("dontcullbackfaces")) + { + smf.flags |= MDL_DONTCULLBACKFACES; + } else { sc.ScriptMessage("Unrecognized string \"%s\"", sc.String); @@ -949,8 +953,9 @@ void gl_RenderModel(GLSprite * spr) gl_RenderState.EnableTexture(true); // [BB] In case the model should be rendered translucent, do back face culling. // This solves a few of the problems caused by the lack of depth sorting. + // [Nash] Don't do back face culling if explicitly specified in MODELDEF // TO-DO: Implement proper depth sorting. - if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + if (!(spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal]) && !(smf->flags & MDL_DONTCULLBACKFACES)) { glEnable(GL_CULL_FACE); glFrontFace(GL_CW); diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index f0267b891..c37b69b5e 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -370,6 +370,7 @@ enum MDL_USEACTORPITCH = 32, MDL_USEACTORROLL = 64, MDL_BADROTATION = 128, + MDL_DONTCULLBACKFACES = 256, }; struct FSpriteModelFrame From 3d9673af44e54c92a963458089016b963f4e40b7 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Thu, 9 Feb 2017 16:35:28 +0800 Subject: [PATCH 6/6] Fixed: Models did not take SpriteRotation into account --- src/gl/models/gl_models.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 0bfc059a1..fe974f4df 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -1017,6 +1017,9 @@ void gl_RenderModel(GLSprite * spr) // Model space => World space gl_RenderState.mModelMatrix.translate(spr->x, spr->z, spr->y ); + // [Nash] take SpriteRotation into account + angle += spr->actor->SpriteRotation.Degrees; + if (spr->actor->renderflags & RF_INTERPOLATEANGLES) { // [Nash] use interpolated angles