Move Blender version string handling to its own function

Planning to use this util function in 2.8 for doversioning (to communicate converted layers)
This commit is contained in:
Dalai Felinto
2017-03-15 14:10:20 +01:00
parent af1d9ecd40
commit c6c85a8c6b
2 changed files with 14 additions and 4 deletions

View File

@@ -100,6 +100,18 @@ void BKE_blender_free(void)
free_nodesystem();
}
void BKE_blender_version_string(char *version_str, size_t maxncpy, short version, short subversion, bool v_prefix, bool include_subversion)
{
const char *prefix = v_prefix ? "v" : "";
if (include_subversion && subversion > 0) {
BLI_snprintf(version_str, maxncpy, "%s%d.%02d.%d", prefix, version / 100, subversion % 100, subversion);
}
else {
BLI_snprintf(version_str, maxncpy, "%s%d.%02d", prefix, version / 100, version % 100);
}
}
void BKE_blender_globals_init(void)
{
memset(&G, 0, sizeof(Global));
@@ -110,10 +122,7 @@ void BKE_blender_globals_init(void)
strcpy(G.ima, "//");
if (BLENDER_SUBVERSION)
BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
else
BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION / 100, BLENDER_VERSION % 100);
BKE_blender_version_string(versionstr, sizeof(versionstr), BLENDER_VERSION, BLENDER_SUBVERSION, true, true);
#ifndef WITH_PYTHON_SECURITY /* default */
G.f |= G_SCRIPT_AUTOEXEC;