Index: binaries/data/mods/public/gui/credits/texts/programming.json =================================================================== --- binaries/data/mods/public/gui/credits/texts/programming.json +++ binaries/data/mods/public/gui/credits/texts/programming.json @@ -130,6 +130,7 @@ {"nick": "Louhike"}, {"nick": "lsdh"}, {"nick": "Ludovic", "name": "Ludovic Rousseau"}, + {"nick": "LukeV1", "name": "Luka Treftz"}, {"nick": "madmax", "name": "Abhijit Nandy"}, {"nick": "madpilot", "name": "Guido Falsi"}, {"nick": "m0l0t0ph", "name": "Christoph Gielisch"}, Index: source/lib/status.h =================================================================== --- source/lib/status.h +++ source/lib/status.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -356,6 +356,15 @@ }\ while(0) +// return -1 if expression is false, i.e. zero. +#define RETURN_ERROR_IF_FALSE(expression)\ +do\ + {\ +if (!(expression))\ + return -1; \ + }\ +while (0) + // warn if expression is false, i.e. zero. #define WARN_IF_FALSE(expression)\ do\ Index: source/lib/sysdep/os/win/wposix/wfilesystem.cpp =================================================================== --- source/lib/sysdep/os/win/wposix/wfilesystem.cpp +++ source/lib/sysdep/os/win/wposix/wfilesystem.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -284,9 +284,9 @@ HANDLE hFile = CreateFileW(OsString(pathname).c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); ENSURE(hFile != INVALID_HANDLE_VALUE); LARGE_INTEGER ofs; ofs.QuadPart = length; - WARN_IF_FALSE(SetFilePointerEx(hFile, ofs, 0, FILE_BEGIN)); - WARN_IF_FALSE(SetEndOfFile(hFile)); - WARN_IF_FALSE(CloseHandle(hFile)); + RETURN_ERROR_IF_FALSE(SetFilePointerEx(hFile, ofs, 0, FILE_BEGIN)); + RETURN_ERROR_IF_FALSE(SetEndOfFile(hFile)); + RETURN_ERROR_IF_FALSE(CloseHandle(hFile)); return 0; } Index: source/ps/XML/Xeromyces.h =================================================================== --- source/ps/XML/Xeromyces.h +++ source/ps/XML/Xeromyces.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -29,6 +29,8 @@ ERROR_TYPE(Xeromyces, XMLOpenFailed); ERROR_TYPE(Xeromyces, XMLParseError); +#include "ps/FileIo.h" // This is only needed to use the macro PSRETURN_File_WriteFailed of Errors.h + #include "XeroXMB.h" #include "lib/file/vfs/vfs.h" Index: source/ps/XML/Xeromyces.cpp =================================================================== --- source/ps/XML/Xeromyces.cpp +++ source/ps/XML/Xeromyces.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -186,8 +186,13 @@ xmlFreeDoc(doc); - // Save the file to disk, so it can be loaded quickly next time - vfs->CreateFile(xmbPath, writeBuffer.Data(), writeBuffer.Size()); + // Save the file to disk, so it can be loaded quickly next time. Check for possible truncate error + if (vfs->CreateFile(xmbPath, writeBuffer.Data(), writeBuffer.Size()) != INFO::OK) + { + // Log the error and pass it to the caller, it might fail there + LOGERROR("CXeromyces: failed to load or save the following file: %s. Check directory permissions.", xmbPath.string8()); + return PSRETURN_File_WriteFailed; + } m_XMBBuffer = writeBuffer.Data(); // add a reference