From ba2a07fb26fe47e4c11d9df0bcf330eec4d6b0e0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 2 Sep 2013 09:08:47 +0200 Subject: [PATCH 1/4] - removed all uses of single precision floats from FraggleScript code. --- src/fragglescript/t_func.cpp | 7 +++---- src/fragglescript/t_script.h | 2 +- src/fragglescript/t_variable.cpp | 9 +++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 448c200d8..2513a68a8 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -73,7 +73,6 @@ static FRandom pr_script("FScript"); #define AngleToFixed(x) ((((double) x) / ((double) ANG45/45)) * FRACUNIT) #define FixedToAngle(x) ((((double) x) / FRACUNIT) * ANG45/45) -#define FIXED_TO_FLOAT(f) ((f)/(float)FRACUNIT) // functions. FParser::SF_ means Script Function not, well.. heh, me @@ -1417,11 +1416,11 @@ void FParser::SF_PointToDist(void) if (CheckArgs(4)) { // Doing this in floating point is actually faster with modern computers! - float x = floatvalue(t_argv[2]) - floatvalue(t_argv[0]); - float y = floatvalue(t_argv[3]) - floatvalue(t_argv[1]); + double x = floatvalue(t_argv[2]) - floatvalue(t_argv[0]); + double y = floatvalue(t_argv[3]) - floatvalue(t_argv[1]); t_return.type = svt_fixed; - t_return.value.f = (fixed_t)(sqrtf(x*x+y*y)*65536.f); + t_return.value.f = FLOAT2FIXED(sqrt(x*x+y*y)*65536.f); } } diff --git a/src/fragglescript/t_script.h b/src/fragglescript/t_script.h index e3db7da3d..ffa2dae3c 100644 --- a/src/fragglescript/t_script.h +++ b/src/fragglescript/t_script.h @@ -110,7 +110,7 @@ struct svalue_t int intvalue(const svalue_t & v); fixed_t fixedvalue(const svalue_t & v); -float floatvalue(const svalue_t & v); +double floatvalue(const svalue_t & v); const char *stringvalue(const svalue_t & v); AActor *actorvalue(const svalue_t &svalue); diff --git a/src/fragglescript/t_variable.cpp b/src/fragglescript/t_variable.cpp index 7326fe4eb..7076a395b 100644 --- a/src/fragglescript/t_variable.cpp +++ b/src/fragglescript/t_variable.cpp @@ -89,11 +89,12 @@ fixed_t fixedvalue(const svalue_t &v) // //========================================================================== -float floatvalue(const svalue_t &v) +double floatvalue(const svalue_t &v) { - return (float)( (v.type == svt_string ? atof(v.string) : - v.type == svt_fixed ? (float)(v.value.f / (float)FRACUNIT) : - v.type == svt_mobj ? -1.f : (float)v.value.i )); + return + v.type == svt_string ? atof(v.string) : + v.type == svt_fixed ? FIXED2DBL(v.value.f) : + v.type == svt_mobj ? -1. : (double)v.value.i; } //========================================================================== From b6baeecd9a18c5e0cb46e58059f52672a16e83e4 Mon Sep 17 00:00:00 2001 From: Alex Qyoun-ae Date: Tue, 3 Sep 2013 03:49:39 +0400 Subject: [PATCH 2/4] Fixed compilation with LLVM compilers --- src/sdl/i_system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index def35606a..ba126bf54 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -699,7 +699,7 @@ bool I_WriteIniFailed () static const char *pattern; -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(__llvm__) static int matchfile (struct dirent *ent) #else static int matchfile (const struct dirent *ent) From 75dd5503cf953238e749d075673d0bb6a6fe0691 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Sep 2013 08:24:47 +0200 Subject: [PATCH 3/4] - fixed: Cost strings for dialogues must not be added in the dialogue parser but while displaying the message to properly handle stringtable entries. --- src/p_conversation.cpp | 5 ++++- src/p_usdf.cpp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 350c46478..e51389ce8 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -752,7 +752,10 @@ public: { ReplyText = GStrings(ReplyText + 1); } - FBrokenLines *ReplyLines = V_BreakLines (SmallFont, 320-50-10, ReplyText); + FString ReplyString = ReplyText; + if (reply->NeedsGold) ReplyString.AppendFormat(" for %u", reply->ItemCheck[0].Amount); + + FBrokenLines *ReplyLines = V_BreakLines (SmallFont, 320-50-10, ReplyString); mResponses.Push(mResponseLines.Size()); for (j = 0; ReplyLines[j].Width >= 0; ++j) diff --git a/src/p_usdf.cpp b/src/p_usdf.cpp index 95c8f5dc0..6ea32b308 100644 --- a/src/p_usdf.cpp +++ b/src/p_usdf.cpp @@ -224,7 +224,6 @@ class USDFParser : public UDMFParserBase if (reply->ItemCheck.Size() > 0) { if (reply->ItemCheck[0].Amount <= 0) reply->NeedsGold = false; - if (reply->NeedsGold) ReplyString.AppendFormat(" for %u", reply->ItemCheck[0].Amount); } reply->Reply = ncopystring(ReplyString); From 11c026ee840684333327e307673bd0f48332704a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Sep 2013 08:34:55 +0200 Subject: [PATCH 4/4] - fixed: displaying sprites on the automap ignored both the actor's scale and translation. --- src/am_map.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 610ba4825..ad34995d0 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2388,10 +2388,11 @@ void AM_drawThings () if (texture == NULL) goto drawTriangle; // fall back to standard display if no sprite can be found. - const fixed_t spriteScale = 10 * scale_mtof; + const fixed_t spriteXScale = FixedMul(t->scaleX, 10 * scale_mtof); + const fixed_t spriteYScale = FixedMul(t->scaleY, 10 * scale_mtof); DrawMarker (texture, p.x, p.y, 0, !!(frame->Flip & (1 << rotation)), - spriteScale, spriteScale, 0, FRACUNIT, 0, LegacyRenderStyles[STYLE_Normal]); + spriteXScale, spriteYScale, t->Translation, FRACUNIT, 0, LegacyRenderStyles[STYLE_Normal]); } else {