From 799f6c6e2698ced2667ce5d7581e2ca7f170df6f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 23 Jan 2017 22:20:07 +0200 Subject: [PATCH 1/4] Fixed compilation error with GCC/Clang src/scripting/zscript/zcc_compile.cpp:1039:11: error: no viable conversion from 'FName' to 'FString' --- src/scripting/zscript/zcc_compile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 1925a2eb6..57bfbd0ec 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1036,7 +1036,7 @@ bool ZCCCompiler::CompileFields(PStruct *type, TArray &Fiel { auto field = Fields[0]; FieldDesc *fd = nullptr; - FString str = FName(field->Names[0].Name); + FString str = FName(field->Names[0].Name).GetChars(); PType *fieldtype = DetermineType(type, field, field->Names->Name, field->Type, true, true); From 3f999a990c25004c2c961658c55fc8d710b7f34e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 23 Jan 2017 23:06:29 +0100 Subject: [PATCH 2/4] - removed a line of debug code that made GCC/Clang go nuclear. --- src/scripting/zscript/zcc_compile.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 1925a2eb6..43f5b6774 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1036,7 +1036,6 @@ bool ZCCCompiler::CompileFields(PStruct *type, TArray &Fiel { auto field = Fields[0]; FieldDesc *fd = nullptr; - FString str = FName(field->Names[0].Name); PType *fieldtype = DetermineType(type, field, field->Names->Name, field->Type, true, true); From 17ed23bfcc864e290cc4f8f3e7e1d110f4f4d865 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 24 Jan 2017 00:12:06 +0100 Subject: [PATCH 3/4] - don't read the full height of a player from the defaults, because that cannot be changed by A_SetHeight. Instead a new member, FullHeight is used for this now. --- src/d_player.h | 1 + src/p_actionfunctions.cpp | 4 ++++ src/p_user.cpp | 12 +++++++----- wadsrc/static/zscript/shared/player.txt | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 05facd9fe..e09db38a3 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -150,6 +150,7 @@ public: int MugShotMaxHealth; int RunHealth; int PlayerFlags; + double FullHeight; TObjPtr InvFirst; // first inventory item displayed on inventory bar TObjPtr InvSel; // selected inventory item diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 5f7185a07..f89a560ab 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -6906,6 +6906,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetSize) self->LinkToWorld(&ctx); ACTION_RETURN_BOOL(false); } + if (self->player && self->player->mo == self) + { + self->player->mo->FullHeight = newheight; + } ACTION_RETURN_BOOL(true); } diff --git a/src/p_user.cpp b/src/p_user.cpp index af1fbbf2d..c6b0a7d58 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -689,7 +689,8 @@ void APlayerPawn::Serialize(FSerializer &arc) ("userange", UseRange, def->UseRange) ("aircapacity", AirCapacity, def->AirCapacity) ("viewheight", ViewHeight, def->ViewHeight) - ("viewbob", ViewBob, def->ViewBob); + ("viewbob", ViewBob, def->ViewBob) + ("fullheight", FullHeight, def->FullHeight); } //=========================================================================== @@ -714,7 +715,7 @@ void APlayerPawn::BeginPlay () { Super::BeginPlay (); ChangeStatNum (STAT_PLAYER); - + FullHeight = Height; // Check whether a PWADs normal sprite is to be combined with the base WADs // crouch sprite. In such a case the sprites normally don't match and it is // best to disable the crouch sprite. @@ -766,11 +767,11 @@ void APlayerPawn::Tick() { if (player != NULL && player->mo == this && player->CanCrouch() && player->playerstate != PST_DEAD) { - Height = GetDefault()->Height * player->crouchfactor; + Height = FullHeight * player->crouchfactor; } else { - if (health > 0) Height = GetDefault()->Height; + if (health > 0) Height = FullHeight; } Super::Tick(); } @@ -2309,7 +2310,7 @@ void P_DeathThink (player_t *player) void P_CrouchMove(player_t * player, int direction) { - double defaultheight = player->mo->GetDefault()->Height; + double defaultheight = player->mo->FullHeight; double savedheight = player->mo->Height; double crouchspeed = direction * CROUCHSPEED; double oldheight = player->viewheight; @@ -3245,6 +3246,7 @@ DEFINE_FIELD(APlayerPawn, AirCapacity) DEFINE_FIELD(APlayerPawn, FlechetteType) DEFINE_FIELD(APlayerPawn, DamageFade) DEFINE_FIELD(APlayerPawn, ViewBob) +DEFINE_FIELD(APlayerPawn, FullHeight) DEFINE_FIELD(PClassPlayerPawn, HealingRadiusType) DEFINE_FIELD(PClassPlayerPawn, DisplayName) diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index 73b00a269..d4992e97f 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -37,6 +37,7 @@ class PlayerPawn : Actor native native Class FlechetteType; native color DamageFade; // [CW] Fades for when you are being damaged. native double ViewBob; // [SP] ViewBob Multiplier + native double FullHeight; Default { From c12dfd7e4dc533dd0d13167452dfa6185c276c56 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 24 Jan 2017 10:04:46 +0100 Subject: [PATCH 4/4] - fixed: only explicit class type casts must obey strict namespace rules, i.e. only '(class)(variable_to_cast)' The general rule is as follows: A class name as a string will always be looked up fully, even if the class name gets shadows by another variable because strings are not identifiers. It is only class names as identifiers that must obey the rule that if it is not known yet or hidden by something else that it may not be found to ensure that the older variable does not take over the name if it gets reused. --- src/scripting/codegeneration/codegen.cpp | 15 +++++++++------ src/scripting/codegeneration/codegen.h | 3 ++- src/scripting/decorate/thingdef_parse.cpp | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 1d16b182f..d090fa6e4 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -1613,7 +1613,7 @@ FxExpression *FxTypeCast::Resolve(FCompileContext &ctx) } else if (ValueType->IsKindOf(RUNTIME_CLASS(PClassPointer))) { - FxExpression *x = new FxClassTypeCast(static_cast(ValueType), basex); + FxExpression *x = new FxClassTypeCast(static_cast(ValueType), basex, Explicit); x = x->Resolve(ctx); basex = nullptr; delete this; @@ -4412,7 +4412,7 @@ FxExpression *FxTypeCheck::Resolve(FCompileContext& ctx) if (left->ValueType->IsKindOf(RUNTIME_CLASS(PClassPointer))) { - left = new FxClassTypeCast(NewClassPointer(RUNTIME_CLASS(DObject)), left); + left = new FxClassTypeCast(NewClassPointer(RUNTIME_CLASS(DObject)), left, false); ClassCheck = true; } else @@ -4420,7 +4420,7 @@ FxExpression *FxTypeCheck::Resolve(FCompileContext& ctx) left = new FxTypeCast(left, NewPointer(RUNTIME_CLASS(DObject)), false); ClassCheck = false; } - right = new FxClassTypeCast(NewClassPointer(RUNTIME_CLASS(DObject)), right); + right = new FxClassTypeCast(NewClassPointer(RUNTIME_CLASS(DObject)), right, false); RESOLVE(left, ctx); RESOLVE(right, ctx); @@ -9922,12 +9922,13 @@ VMFunction *FxReturnStatement::GetDirectFunction() // //========================================================================== -FxClassTypeCast::FxClassTypeCast(PClassPointer *dtype, FxExpression *x) +FxClassTypeCast::FxClassTypeCast(PClassPointer *dtype, FxExpression *x, bool explicitily) : FxExpression(EFX_ClassTypeCast, x->ScriptPosition) { ValueType = dtype; desttype = dtype->ClassRestriction; basex=x; + Explicit = explicitily; } //========================================================================== @@ -9991,7 +9992,9 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) if (clsname != NAME_None) { - cls = FindClassType(clsname, ctx); + if (Explicit) cls = FindClassType(clsname, ctx); + else cls = PClass::FindClass(clsname); + if (cls == nullptr) { /* lax */ @@ -10141,7 +10144,7 @@ FxExpression *FxClassPtrCast::Resolve(FCompileContext &ctx) } else if (basex->ValueType == TypeString || basex->ValueType == TypeName) { - FxExpression *x = new FxClassTypeCast(to, basex); + FxExpression *x = new FxClassTypeCast(to, basex, true); basex = nullptr; delete this; return x->Resolve(ctx); diff --git a/src/scripting/codegeneration/codegen.h b/src/scripting/codegeneration/codegen.h index 7c18589c5..42d5b0ccf 100644 --- a/src/scripting/codegeneration/codegen.h +++ b/src/scripting/codegeneration/codegen.h @@ -1913,10 +1913,11 @@ class FxClassTypeCast : public FxExpression { PClass *desttype; FxExpression *basex; + bool Explicit; public: - FxClassTypeCast(PClassPointer *dtype, FxExpression *x); + FxClassTypeCast(PClassPointer *dtype, FxExpression *x, bool explicitly); ~FxClassTypeCast(); FxExpression *Resolve(FCompileContext&); ExpEmit Emit(VMFunctionBuilder *build); diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index 81ab765f5..9b78ef3d5 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -197,7 +197,7 @@ FxExpression *ParseParameter(FScanner &sc, PClassActor *cls, PType *type) sc.SetEscape(true); sc.MustGetString(); sc.SetEscape(false); - x = new FxClassTypeCast(static_cast(type), new FxConstant(FName(sc.String), sc)); + x = new FxClassTypeCast(static_cast(type), new FxConstant(FName(sc.String), sc), false); } else {