From db39392411f988c66e4ddc3c21a3221e488d0ee9 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 21 Feb 2018 20:23:22 +0100 Subject: [PATCH] Update MSVC project to compile with lua minor changes to remove need for C features unsupported by MS Visual C --- project/msvc/README.txt | 25 ++++++++++++++++++++++--- project/msvc/grafx2.vcxproj | 16 ++++++++-------- src/factory.c | 15 +++++++++++---- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/project/msvc/README.txt b/project/msvc/README.txt index e014c13c..e43f40fa 100644 --- a/project/msvc/README.txt +++ b/project/msvc/README.txt @@ -1,3 +1,22 @@ -Project files for MS Visual Studio 2010 -Edit project properties to set proper include and libraries directory for SDL 1.2 -and SDL image 1.2 +Project files for MS Visual Studio 2010 : + +By default the project expect SDL 1.2 SDL Image 1.2 and Lua 5.3 to be installed +in directories : + ..\..\..\..\SDL-1.2.15 + ..\..\..\..\SDL_image-1.2.12 + ..\..\..\..\lua + +That is, if grafX2 sources are in C:\stuff\code\grafX2 +Visual studio project files are in C:\stuff\code\grafX2\project\msvc +and it is expected you have C:\stuff\lua etc. + +Download precompiled libraries from : + + https://www.libsdl.org/download-1.2.php : + https://www.libsdl.org/release/SDL-devel-1.2.15-VC.zip + + https://www.libsdl.org/projects/SDL_image/release-1.2.html + https://www.libsdl.org/projects/SDL_image/release/SDL_image-devel-1.2.12-VC.zip + + http://luabinaries.sourceforge.net/ + https://sourceforge.net/projects/luabinaries/files/5.3.4/Windows%20Libraries/Static/ diff --git a/project/msvc/grafx2.vcxproj b/project/msvc/grafx2.vcxproj index 8c7f29f3..d565d621 100644 --- a/project/msvc/grafx2.vcxproj +++ b/project/msvc/grafx2.vcxproj @@ -52,15 +52,15 @@ Level3 Disabled - NOTTF;__no_pnglib__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - ..\..\..\..\SDL_image-1.2.12\include;..\..\..\..\SDL-1.2.15\include;%(AdditionalIncludeDirectories) + NOTTF;__ENABLE_LUA__;__no_pnglib__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + ..\..\..\..\SDL_image-1.2.12\include;..\..\..\..\SDL-1.2.15\include;..\..\..\..\lua\include;%(AdditionalIncludeDirectories) 4244;%(DisableSpecificWarnings) Windows true - SDL.lib;SDLmain.lib;SDL_image.lib;%(AdditionalDependencies) - ..\..\..\..\SDL-1.2.15\lib\x86;..\..\..\..\SDL_image-1.2.12\lib\x86;%(AdditionalLibraryDirectories) + SDL.lib;SDLmain.lib;SDL_image.lib;lua53.lib;%(AdditionalDependencies) + ..\..\..\..\SDL-1.2.15\lib\x86;..\..\..\..\SDL_image-1.2.12\lib\x86;..\..\..\..\lua;%(AdditionalLibraryDirectories) @@ -71,8 +71,8 @@ MaxSpeed true true - NOTTF;__no_pnglib__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - ..\..\..\..\SDL_image-1.2.12\include;..\..\..\..\SDL-1.2.15\include;%(AdditionalIncludeDirectories) + NOTTF;__ENABLE_LUA__;__no_pnglib__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + ..\..\..\..\SDL_image-1.2.12\include;..\..\..\..\SDL-1.2.15\include;..\..\..\..\lua\include;%(AdditionalIncludeDirectories) 4244;%(DisableSpecificWarnings) @@ -80,8 +80,8 @@ true true true - SDL.lib;SDLmain.lib;SDL_image.lib;%(AdditionalDependencies) - ..\..\..\..\SDL-1.2.15\lib\x86;..\..\..\..\SDL_image-1.2.12\lib\x86;%(AdditionalLibraryDirectories) + SDL.lib;SDLmain.lib;SDL_image.lib;lua53.lib;%(AdditionalDependencies) + ..\..\..\..\SDL-1.2.15\lib\x86;..\..\..\..\SDL_image-1.2.12\lib\x86;..\..\..\..\lua;%(AdditionalLibraryDirectories) diff --git a/src/factory.c b/src/factory.c index 38ed92d8..31801301 100644 --- a/src/factory.c +++ b/src/factory.c @@ -59,6 +59,10 @@ char * Bound_script[10]; #include // for DBL_MAX #include //for INT_MIN #include // strncpy() +#if defined(_MSC_VER) +#define strdup _strdup +#define putenv _putenv +#endif /// /// Number of characters for name in fileselector. @@ -84,7 +88,7 @@ static byte Cursor_is_visible; static byte Window_needs_update; /// Helper function to clamp a double to 0-255 range -static inline byte clamp_byte(double value) +static byte clamp_byte(double value) { if (value<0.0) return 0; @@ -981,8 +985,8 @@ int L_SetBackColor(lua_State* L) int L_InputBox(lua_State* L) { - const int max_settings = 9; - const int args_per_setting = 5; +#define max_settings (9) +#define args_per_setting (5) double min_value[max_settings]; double max_value[max_settings]; double decimal_places[max_settings]; @@ -1258,12 +1262,15 @@ int L_InputBox(lua_State* L) lua_pushnumber(L, current_value[setting]); return 1 + nb_settings; +#undef max_settings +#undef args_per_setting } int L_SelectBox(lua_State* L) { - const int max_settings = 10; +#define max_settings (10) const char * label[max_settings]; +#undef max_settings const char * window_caption; unsigned int caption_length;