[Scummvm-git-logs] scummvm master -> e05829ca4ded05a49478541d13b7c4129c9b702a

dreammaster dreammaster at scummvm.org
Sun Feb 7 03:15:34 UTC 2021


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8d62c2faf6 AGS: Change Allegro error codes to avoid clash on some systems
4f316995a5 AGS: Refactor use of NAN to an arbitrary constant
e05829ca4d AGS: Remove AGS tests as a sub-engine


Commit: 8d62c2faf61fd5bd3b985a8246d37737d0f7c69d
    https://github.com/scummvm/scummvm/commit/8d62c2faf61fd5bd3b985a8246d37737d0f7c69d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-02-06T19:14:48-08:00

Commit Message:
AGS: Change Allegro error codes to avoid clash on some systems

Changed paths:
    engines/ags/engine/ac/file.cpp
    engines/ags/engine/platform/base/agsplatformdriver.h
    engines/ags/engine/platform/linux/acpllnx.cpp
    engines/ags/lib/allegro.cpp
    engines/ags/lib/allegro/base.h
    engines/ags/lib/allegro/error.cpp
    engines/ags/lib/allegro/error.h
    engines/ags/lib/allegro/fixed.cpp
    engines/ags/lib/allegro/math.cpp
    engines/ags/shared/util/string_utils.cpp


diff --git a/engines/ags/engine/ac/file.cpp b/engines/ags/engine/ac/file.cpp
index 28b0814d61..47f392fb6b 100644
--- a/engines/ags/engine/ac/file.cpp
+++ b/engines/ags/engine/ac/file.cpp
@@ -91,7 +91,7 @@ int File_Delete(const char *fnmm) {
 
 	if (::remove(rp.FullPath) == 0)
 		return 1;
-	if (errnum == ENOENT && !rp.AltPath.IsEmpty() && rp.AltPath.Compare(rp.FullPath) != 0)
+	if (errnum == AL_ENOENT && !rp.AltPath.IsEmpty() && rp.AltPath.Compare(rp.FullPath) != 0)
 		return ::remove(rp.AltPath) == 0 ? 1 : 0;
 	return 0;
 }
diff --git a/engines/ags/engine/platform/base/agsplatformdriver.h b/engines/ags/engine/platform/base/agsplatformdriver.h
index 95c7c68b3d..a925fbaf3e 100644
--- a/engines/ags/engine/platform/base/agsplatformdriver.h
+++ b/engines/ags/engine/platform/base/agsplatformdriver.h
@@ -73,7 +73,7 @@ struct AGSPlatformDriver
 	virtual void DisplayAlert(const char *, ...) = 0;
 	virtual void AttachToParentConsole();
 	virtual int  GetLastSystemError() {
-		return errnum;
+		return (int)errnum;
 	}
 	// Get root directory for storing per-game shared data
 	virtual const char *GetAllUsersDataDirectory() {
diff --git a/engines/ags/engine/platform/linux/acpllnx.cpp b/engines/ags/engine/platform/linux/acpllnx.cpp
index 87e78d7140..a6964c009b 100644
--- a/engines/ags/engine/platform/linux/acpllnx.cpp
+++ b/engines/ags/engine/platform/linux/acpllnx.cpp
@@ -104,10 +104,10 @@ size_t BuildXDGPath(char *destPath, size_t destSize) {
 		// No evironment variable, so we fall back to home dir in /etc/passwd
 		struct passwd *p = getpwuid(getuid());
 		l = snprintf(destPath, destSize, "%s/.local", p->pw_dir);
-		if (mkdir(destPath, 0755) != 0 && errnum != EEXIST)
+		if (mkdir(destPath, 0755) != 0 && errnum != AL_EEXIST)
 			return 0;
 		l += snprintf(destPath + l, destSize - l, "/share");
-		if (mkdir(destPath, 0755) != 0 && errnum != EEXIST)
+		if (mkdir(destPath, 0755) != 0 && errnum != AL_EEXIST)
 			return 0;
 	}
 	return l;
diff --git a/engines/ags/lib/allegro.cpp b/engines/ags/lib/allegro.cpp
index ec92eb3f24..f2ee08555e 100644
--- a/engines/ags/lib/allegro.cpp
+++ b/engines/ags/lib/allegro.cpp
@@ -109,7 +109,7 @@ PALETTE default_palette = {
 
 
 int install_allegro() {
-	errnum = 0;
+	errnum = AL_NOERROR;
 	return 0;
 }
 
diff --git a/engines/ags/lib/allegro/base.h b/engines/ags/lib/allegro/base.h
index 01eb8d0a32..1be1a12797 100644
--- a/engines/ags/lib/allegro/base.h
+++ b/engines/ags/lib/allegro/base.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/algorithm.h"
 #include "common/endian.h"
+#include "ags/lib/allegro/error.h"
 
 namespace AGS3 {
 
@@ -43,8 +44,6 @@ namespace AGS3 {
 
 #define AL_ID MKTAG
 
-extern int *allegro_errno;
-
 /**
  * info about a hardware driver
  */
diff --git a/engines/ags/lib/allegro/error.cpp b/engines/ags/lib/allegro/error.cpp
index 4c78014fb3..053c121f75 100644
--- a/engines/ags/lib/allegro/error.cpp
+++ b/engines/ags/lib/allegro/error.cpp
@@ -24,7 +24,7 @@
 
 namespace AGS3 {
 
-int errnum;
-int *allegro_errno = &errnum;
+AllegroError errnum;
+AllegroError *allegro_errno = &errnum;
 
 } // namespace AGS3
diff --git a/engines/ags/lib/allegro/error.h b/engines/ags/lib/allegro/error.h
index c7942c9eda..bfbf79edf9 100644
--- a/engines/ags/lib/allegro/error.h
+++ b/engines/ags/lib/allegro/error.h
@@ -28,53 +28,50 @@
 namespace AGS3 {
 
 // Error codes
-#define EPERM           1
-#define ENOENT          2
-#define ESRCH           3
-#define EINTR           4
-#define EIO             5
-#define ENXIO           6
-#define E2BIG           7
-#define ENOEXEC         8
-#define EBADF           9
-#define ECHILD          10
-#define EAGAIN          11
-#define ENOMEM          12
-#define EACCES          13
-#define EFAULT          14
-#define EBUSY           16
-#define EEXIST          17
-#define EXDEV           18
-#define ENODEV          19
-#define ENOTDIR         20
-#define EISDIR          21
-#define ENFILE          23
-#define EMFILE          24
-#define ENOTTY          25
-#define EFBIG           27
-#define ENOSPC          28
-#define ESPIPE          29
-#define EROFS           30
-#define EMLINK          31
-#define EPIPE           32
-#define EDOM            33
-#define EDEADLK         36
-#define ENAMETOOLONG    38
-#define ENOLCK          39
-#define ENOSYS          40
-#define ENOTEMPTY       41
+enum AllegroError {
+	AL_NOERROR = 0,
+	AL_EPERM = 1,
+	AL_ENOENT = 2,
+	AL_ESRCH = 3,
+	AL_EINTR = 4,
+	AL_EIO = 5,
+	AL_ENXIO = 6,
+	AL_E2BIG = 7,
+	AL_ENOEXEC = 8,
+	AL_EBADF = 9,
+	AL_ECHILD = 10,
+	AL_EAGAIN = 11,
+	AL_ENOMEM = 12,
+	AL_EACCES = 13,
+	AL_EFAULT = 14,
+	AL_EBUSY = 16,
+	AL_EEXIST = 17,
+	AL_EXDEV = 18,
+	AL_ENODEV = 19,
+	AL_ENOTDIR = 20,
+	AL_EISDIR = 21,
+	AL_EINVAL = 22,
+	AL_ENFILE = 23,
+	AL_EMFILE = 24,
+	AL_ENOTTY = 25,
+	AL_EFBIG = 27,
+	AL_ENOSPC = 28,
+	AL_ESPIPE = 29,
+	AL_EROFS = 30,
+	AL_EMLINK = 31,
+	AL_EPIPE = 32,
+	AL_EDOM = 33,
+	AL_ERANGE = 34,
+	AL_EDEADLK = 36,
+	AL_ENAMETOOLONG = 38,
+	AL_ENOLCK = 39,
+	AL_ENOSYS = 40,
+	AL_ENOTEMPTY = 41,
+	AL_EILSEQ = 42
+};
 
-// Error codes used in the Secure CRT functions
-#ifndef RC_INVOKED
-#define _SECURECRT_ERRCODE_VALUES_DEFINED
-#define EINVAL          22
-#define ERANGE          34
-#define EILSEQ          42
-#define STRUNCATE       80
-#endif
-
-extern int errnum;
-extern int *allegro_errno;
+extern AllegroError errnum;
+extern AllegroError *allegro_errno;
 
 } // namespace AGS3
 
diff --git a/engines/ags/lib/allegro/fixed.cpp b/engines/ags/lib/allegro/fixed.cpp
index be16f6ae40..29ac103c37 100644
--- a/engines/ags/lib/allegro/fixed.cpp
+++ b/engines/ags/lib/allegro/fixed.cpp
@@ -30,12 +30,12 @@ fixed radtofix_r;
 
 fixed ftofix(double x) {
 	if (x > 32767.0) {
-		*allegro_errno = ERANGE;
+		*allegro_errno = AL_ERANGE;
 		return 0x7FFFFFFF;
 	}
 
 	if (x < -32767.0) {
-		*allegro_errno = ERANGE;
+		*allegro_errno = AL_ERANGE;
 		return (fixed) - 0x7FFFFFFF;
 	}
 
@@ -51,13 +51,13 @@ fixed fixadd(fixed x, fixed y) {
 
 	if (result >= 0) {
 		if ((x < 0) && (y < 0)) {
-			*allegro_errno = ERANGE;
+			*allegro_errno = AL_ERANGE;
 			return (fixed) - 0x7FFFFFFF;
 		} else
 			return result;
 	} else {
 		if ((x > 0) && (y > 0)) {
-			*allegro_errno = ERANGE;
+			*allegro_errno = AL_ERANGE;
 			return 0x7FFFFFFF;
 		} else
 			return result;
@@ -69,13 +69,13 @@ fixed fixsub(fixed x, fixed y) {
 
 	if (result >= 0) {
 		if ((x < 0) && (y > 0)) {
-			*allegro_errno = ERANGE;
+			*allegro_errno = AL_ERANGE;
 			return (fixed) - 0x7FFFFFFF;
 		} else
 			return result;
 	} else {
 		if ((x > 0) && (y < 0)) {
-			*allegro_errno = ERANGE;
+			*allegro_errno = AL_ERANGE;
 			return 0x7FFFFFFF;
 		} else
 			return result;
@@ -88,10 +88,10 @@ fixed fixmul(fixed x, fixed y) {
 	int64 lres = (lx * ly);
 
 	if (lres > 0x7FFFFFFF0000LL) {
-		*allegro_errno = ERANGE;
+		*allegro_errno = AL_ERANGE;
 		return 0x7FFFFFFF;
 	} else if (lres < -0x7FFFFFFF0000LL) {
-		*allegro_errno = ERANGE;
+		*allegro_errno = AL_ERANGE;
 		return 0x80000000;
 	} else {
 		int res = lres >> 16;
@@ -101,7 +101,7 @@ fixed fixmul(fixed x, fixed y) {
 
 fixed fixdiv(fixed x, fixed y) {
 	if (y == 0) {
-		*allegro_errno = ERANGE;
+		*allegro_errno = AL_ERANGE;
 		return (fixed)(x < 0) ? -0x7FFFFFFF : 0x7FFFFFFF;
 	} else
 		return ftofix(fixtof(x) / fixtof(y));
@@ -118,7 +118,7 @@ int fixfloor(fixed x) {
 
 int fixceil(fixed x) {
 	if (x > 0x7FFF0000) {
-		*allegro_errno = ERANGE;
+		*allegro_errno = AL_ERANGE;
 		return 0x7FFF;
 	}
 
@@ -152,7 +152,7 @@ fixed fixtan(fixed x) {
 
 fixed fixacos(fixed x) {
 	if ((x < -65536) || (x > 65536)) {
-		*allegro_errno = EDOM;
+		*allegro_errno = AL_EDOM;
 		return 0;
 	}
 
@@ -162,7 +162,7 @@ fixed fixacos(fixed x) {
 
 fixed fixasin(fixed x) {
 	if ((x < -65536) || (x > 65536)) {
-		*allegro_errno = EDOM;
+		*allegro_errno = AL_EDOM;
 		return 0;
 	}
 
diff --git a/engines/ags/lib/allegro/math.cpp b/engines/ags/lib/allegro/math.cpp
index 19413b2cf6..64617e2b56 100644
--- a/engines/ags/lib/allegro/math.cpp
+++ b/engines/ags/lib/allegro/math.cpp
@@ -248,17 +248,17 @@ fixed fixatan2(fixed y, fixed x) {
 
 	if (x == 0) {
 		if (y == 0) {
-			*allegro_errno = EDOM;
+			*allegro_errno = AL_EDOM;
 			return 0L;
 		} else
 			return ((y < 0) ? -0x00400000L : 0x00400000L);
 	}
 
-	*allegro_errno = 0;
+	*allegro_errno = AL_NOERROR;
 	r = fixdiv(y, x);
 
 	if (*allegro_errno) {
-		*allegro_errno = 0;
+		*allegro_errno = AL_NOERROR;
 		return ((y < 0) ? -0x00400000L : 0x00400000L);
 	}
 
diff --git a/engines/ags/shared/util/string_utils.cpp b/engines/ags/shared/util/string_utils.cpp
index 9d33819956..17ee27e2f1 100644
--- a/engines/ags/shared/util/string_utils.cpp
+++ b/engines/ags/shared/util/string_utils.cpp
@@ -59,11 +59,11 @@ StrUtil::ConversionError StrUtil::StringToInt(const String &s, int &val, int def
 	if (!s.GetCStr())
 		return StrUtil::kFailed;
 	char *stop_ptr;
-	errnum = 0;
+	errnum = AL_NOERROR;
 	long lval = strtol(s.GetCStr(), &stop_ptr, 0);
 	if (stop_ptr != s.GetCStr() + s.GetLength())
 		return StrUtil::kFailed;
-	if (lval > INT_MAX || lval < INT_MIN || errnum == ERANGE)
+	if (lval > INT_MAX || lval < INT_MIN || errnum == AL_ERANGE)
 		return StrUtil::kOutOfRange;
 	val = (int)lval;
 	return StrUtil::kNoError;


Commit: 4f316995a55469a2158d87f2023e14a21e1587fa
    https://github.com/scummvm/scummvm/commit/4f316995a55469a2158d87f2023e14a21e1587fa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-02-06T19:14:48-08:00

Commit Message:
AGS: Refactor use of NAN to an arbitrary constant

Changed paths:
    engines/ags/engine/ac/draw.cpp
    engines/ags/engine/debugging/debug.cpp
    engines/ags/engine/main/game_run.cpp
    engines/ags/lib/std/limits.h
    engines/ags/lib/std/math.h


diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp
index 69714f99ea..29ff6b9ea1 100644
--- a/engines/ags/engine/ac/draw.cpp
+++ b/engines/ags/engine/ac/draw.cpp
@@ -1934,7 +1934,7 @@ void draw_fps(const Rect &viewport) {
 
 	char fps_buffer[60];
 	// Don't display fps if we don't have enough information (because loop count was just reset)
-	if (!std::isnan(fps)) {
+	if (!std::isUndefined(fps)) {
 		snprintf(fps_buffer, sizeof(fps_buffer), "FPS: %2.1f / %s", fps, base_buffer);
 	} else {
 		snprintf(fps_buffer, sizeof(fps_buffer), "FPS: --.- / %s", base_buffer);
diff --git a/engines/ags/engine/debugging/debug.cpp b/engines/ags/engine/debugging/debug.cpp
index 44147bdefe..09602126ff 100644
--- a/engines/ags/engine/debugging/debug.cpp
+++ b/engines/ags/engine/debugging/debug.cpp
@@ -85,7 +85,7 @@ int debug_flags = 0;
 String debug_line[DEBUG_CONSOLE_NUMLINES];
 int first_debug_line = 0, last_debug_line = 0, display_console = 0;
 
-float fps = std::numeric_limits<float>::quiet_NaN();
+float fps = std::numeric_limits<float>::quiet_undefined();
 FPSDisplayMode display_fps = kFPS_Hide;
 
 std::unique_ptr<MessageBuffer> DebugMsgBuff;
diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index 30e5eef2ff..166f7104b8 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -726,7 +726,7 @@ void set_loop_counter(unsigned int new_counter) {
 	loopcounter = new_counter;
 	t1 = AGS_Clock::now();
 	lastcounter = loopcounter;
-	fps = std::numeric_limits<float>::quiet_NaN();
+	fps = std::numeric_limits<float>::quiet_undefined();
 }
 
 void UpdateGameOnce(bool checkControls, IDriverDependantBitmap *extraBitmap, int extraX, int extraY) {
diff --git a/engines/ags/lib/std/limits.h b/engines/ags/lib/std/limits.h
index 31e6cf6ad9..612082f777 100644
--- a/engines/ags/lib/std/limits.h
+++ b/engines/ags/lib/std/limits.h
@@ -20,7 +20,7 @@
  *
  */
 
-#include <cmath>
+#include "ags/lib/std/math.h"
 
 #ifndef AGS_STD_LIMITS_H
 #define AGS_STD_LIMITS_H
@@ -38,8 +38,8 @@ class numeric_limits : public _Num_base {
 template <>
 class numeric_limits<float> {
 public:
-	static constexpr float quiet_NaN() {
-		return NAN;
+	static constexpr float quiet_undefined() {
+		return FLOAT_UNASSIGNED;
 	}
 };
 
diff --git a/engines/ags/lib/std/math.h b/engines/ags/lib/std/math.h
index 14cc226822..cb9899c4c7 100644
--- a/engines/ags/lib/std/math.h
+++ b/engines/ags/lib/std/math.h
@@ -29,12 +29,10 @@
 namespace AGS3 {
 namespace std {
 
-#ifndef NAN
-#define NAN        ((float)(INFINITY * 0.0F))
-#endif
+#define FLOAT_UNASSIGNED (float)999999.0
 
 template<class T>
-inline bool isnan(T val) { return val == NAN; }
+inline bool isUndefined(T val) { return val == FLOAT_UNASSIGNED; }
 
 } // namespace std
 } // namespace AGS3


Commit: e05829ca4ded05a49478541d13b7c4129c9b702a
    https://github.com/scummvm/scummvm/commit/e05829ca4ded05a49478541d13b7c4129c9b702a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-02-06T19:14:48-08:00

Commit Message:
AGS: Remove AGS tests as a sub-engine

Daily buidls with all engines enabled was turning on the tests,
which prevent any AGS game from playing

Changed paths:
    engines/ags/configure.engine


diff --git a/engines/ags/configure.engine b/engines/ags/configure.engine
index 18e126e167..54d048b5fa 100644
--- a/engines/ags/configure.engine
+++ b/engines/ags/configure.engine
@@ -1,4 +1,3 @@
 # This file is included from the main "configure" script
 # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
-add_engine ags "Adventure Game Studio" no "ags_tests" "" "cxx11 16bit"
-add_engine ags_tests "AGS Tests" no "" "" ""
+add_engine ags "Adventure Game Studio" no "" "" "cxx11 16bit"




More information about the Scummvm-git-logs mailing list