Add prerelease build flag and warning script

develop
lethosor 2015-12-11 20:27:46 -05:00
parent a73110f7f0
commit 83603fcf45
7 changed files with 60 additions and 0 deletions

@ -99,6 +99,7 @@ endif()
# set up versioning. # set up versioning.
set(DF_VERSION "0.42.02") set(DF_VERSION "0.42.02")
SET(DFHACK_RELEASE "r0") SET(DFHACK_RELEASE "r0")
SET(DFHACK_PRERELEASE TRUE)
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")

@ -263,6 +263,11 @@ SET_PROPERTY(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
DF_VERSION="${DF_VERSION}" DF_VERSION="${DF_VERSION}"
DFHACK_RELEASE="${DFHACK_RELEASE}" DFHACK_RELEASE="${DFHACK_RELEASE}"
) )
IF(DFHACK_PRERELEASE)
SET_PROPERTY(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
DFHACK_PRERELEASE=1
)
ENDIF()
ADD_CUSTOM_TARGET(git-describe ADD_CUSTOM_TARGET(git-describe
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}

@ -2057,6 +2057,12 @@ void Core::onStateChange(color_ostream &out, state_change_event event)
break; break;
} }
if (event == SC_MAP_LOADED && Version::is_prerelease())
{
runCommand(out, "gui/prerelease-warning");
std::cerr << "loaded map in prerelease build" << std::endl;
}
EventManager::onStateChange(out, event); EventManager::onStateChange(out, event);
buildings_onStateChange(out, event); buildings_onStateChange(out, event);

@ -33,5 +33,14 @@ namespace DFHack {
return false; return false;
#endif #endif
} }
bool is_prerelease()
{
#ifdef DFHACK_PRERELEASE
return true;
#else
return false;
#endif
}
} }
} }

@ -1418,6 +1418,7 @@ static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAP_VERSION_FUNC(getGitDescription, git_description), WRAP_VERSION_FUNC(getGitDescription, git_description),
WRAP_VERSION_FUNC(getGitCommit, git_commit), WRAP_VERSION_FUNC(getGitCommit, git_commit),
WRAP_VERSION_FUNC(isRelease, is_release), WRAP_VERSION_FUNC(isRelease, is_release),
WRAP_VERSION_FUNC(isPrerelease, is_prerelease),
{ NULL, NULL } { NULL, NULL }
}; };

@ -7,6 +7,7 @@ namespace DFHack {
const char *git_description(); const char *git_description();
const char *git_commit(); const char *git_commit();
bool is_release(); bool is_release();
bool is_prerelease();
} }
} }
@ -17,4 +18,5 @@ namespace DFHack {
#define DFHACK_GIT_DESCRIPTION (DFHack::Version::git_description()) #define DFHACK_GIT_DESCRIPTION (DFHack::Version::git_description())
#define DFHACK_GIT_COMMIT (DFHack::Version::git_commit()) #define DFHACK_GIT_COMMIT (DFHack::Version::git_commit())
#define DFHACK_IS_RELEASE (DFHack::Version::is_release()) #define DFHACK_IS_RELEASE (DFHack::Version::is_release())
#define DFHACK_IS_PRERELEASE (DFHack::Version::is_prerelease())
#endif #endif

@ -0,0 +1,36 @@
-- Shows the warning about missing configuration file.
--[[=begin
gui/prerelease-warning
======================
Shows a warning on world load for pre-release builds.
=end]]
if not dfhack.isPrerelease() then qerror('not a prerelease build') end
local gui = require 'gui'
local dlg = require 'gui.dialogs'
local message = {
'This is a prerelease build of DFHack. Some structures are likely', NEWLINE,
'to be incorrect, resulting in crashes or save corruption', NEWLINE,
{pen=COLOR_LIGHTRED, text='Make backups of your saves and avoid saving if possible.'}
}
dfhack.print('\n')
for k,v in ipairs(message) do
if type(v) == 'table' then
dfhack.color(v.pen)
dfhack.print(v.text)
else
dfhack.color(COLOR_YELLOW)
dfhack.print(v)
end
end
dfhack.color(COLOR_RESET)
dfhack.print('\n\n')
dlg.showMessage('Warning', message, COLOR_YELLOW)