Fix compilation with recoil with MSVC

Also fix handling of long extensions (more than 3 characters)
This commit is contained in:
Thomas Bernard 2018-03-05 17:07:42 +01:00
parent 0fd3fb80fd
commit c29f1c9161
4 changed files with 42 additions and 2 deletions

View File

@ -1,6 +1,6 @@
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
By default the project expects 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
@ -20,3 +20,8 @@ Download precompiled libraries from :
http://luabinaries.sourceforge.net/
https://sourceforge.net/projects/luabinaries/files/5.3.4/Windows%20Libraries/Static/
Download recoil-4.2.0.tar.gz from https://sourceforge.net/projects/recoil/files/recoil/4.2.0/
and copy recoil.c and recoil.h to src subdirectory.
You can also disable RECOIL by defining the NORECOIL macro.

View File

@ -125,6 +125,7 @@
<ClInclude Include="..\..\src\readini.h" />
<ClInclude Include="..\..\src\readline.h" />
<ClInclude Include="..\..\src\realpath.h" />
<ClInclude Include="..\..\src\recoil.h" />
<ClInclude Include="..\..\src\saveini.h" />
<ClInclude Include="..\..\src\SDLMain.h" />
<ClInclude Include="..\..\src\sdlscreen.h" />
@ -161,6 +162,7 @@
<ClCompile Include="..\..\src\keyboard.c" />
<ClCompile Include="..\..\src\layers.c" />
<ClCompile Include="..\..\src\libraw2crtc.c" />
<ClCompile Include="..\..\src\loadrecoil.c" />
<ClCompile Include="..\..\src\loadsave.c" />
<ClCompile Include="..\..\src\main.c" />
<ClCompile Include="..\..\src\misc.c" />
@ -184,6 +186,7 @@
<ClCompile Include="..\..\src\readini.c" />
<ClCompile Include="..\..\src\readline.c" />
<ClCompile Include="..\..\src\realpath.c" />
<ClCompile Include="..\..\src\recoil.c" />
<ClCompile Include="..\..\src\saveini.c" />
<ClCompile Include="..\..\src\sdlscreen.c" />
<ClCompile Include="..\..\src\setup.c" />

View File

@ -174,6 +174,9 @@
<ClInclude Include="..\..\src\unicode.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
<ClInclude Include="..\..\src\recoil.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\gfx2.rc">
@ -340,5 +343,11 @@
<ClCompile Include="..\..\src\version.c">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="..\..\src\loadrecoil.c">
<Filter>Fichiers sources</Filter>
</ClCompile>
<ClCompile Include="..\..\src\recoil.c">
<Filter>Fichiers sources</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -18,6 +18,12 @@
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/
#ifdef _MSC_VER
#include <stdio.h>
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#endif
#include "struct.h"
#include "global.h"
@ -93,8 +99,25 @@ void Load_Recoil_Image(T_IO_Context *context)
recoil = RECOIL_New();
if (recoil)
{
#ifdef WIN32
char tempfilename[MAX_PATH_CHARACTERS];
#endif
const char * filename = context->File_name;
*(const RECOILVtbl **)recoil = &vtbl; // set Vtable
if (RECOIL_Decode(recoil, context->File_name, file_content, file_length))
#ifdef WIN32
if (context->File_name_unicode != NULL && context->File_name_unicode[0] != 0)
{
// get the full file extension from the long filename (unicode)
// RECOIL doesn't recognize file if the "short" extension is passed,
// ie .DEE instead of .deep
int i;
for (i = 0; context->File_name_unicode[i] != 0 && i < sizeof(tempfilename) - 1; i++)
tempfilename[i] = (context->File_name_unicode[i] < 256) ? (char)context->File_name_unicode[i] : '_';
tempfilename[i] = '\0';
filename = tempfilename;
}
#endif
if (RECOIL_Decode(recoil, filename, file_content, file_length))
{
int width, height;
int original_width, original_height;