Refactor version stuff a bit

This commit is contained in:
MysterD 2023-04-17 16:54:30 -07:00
parent e43ef39206
commit b38d044cde
3 changed files with 8 additions and 7 deletions

View File

@ -1,12 +1,13 @@
#include <stdio.h> #include <stdio.h>
#include "version.h" #include "version.h"
#include "version_text.h"
#include "types.h" #include "types.h"
static char sVersionString[MAX_VERSION_LENGTH] = { 0 }; static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
static char sLocalVersionString[MAX_LOCAL_VERSION_LENGTH] = { 0 }; static char sLocalVersionString[MAX_LOCAL_VERSION_LENGTH] = { 0 };
char* get_version(void) { char* get_version(void) {
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER); snprintf(sVersionString, MAX_VERSION_LENGTH, "%s", VERSION_TEXT);
return sVersionString; return sVersionString;
} }
@ -14,6 +15,6 @@ char* get_version_local(void) {
if (PATCH_VERSION_NUMBER <= 0) { if (PATCH_VERSION_NUMBER <= 0) {
return get_version(); return get_version();
} }
snprintf(sLocalVersionString, MAX_LOCAL_VERSION_LENGTH, "%s %d.%d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER, PATCH_VERSION_NUMBER); snprintf(sLocalVersionString, MAX_LOCAL_VERSION_LENGTH, "%s.%d", VERSION_TEXT, PATCH_VERSION_NUMBER);
return sLocalVersionString; return sLocalVersionString;
} }

View File

@ -1,13 +1,11 @@
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H
#define VERSION_TEXT "beta"
#define VERSION_NUMBER 34
#define MINOR_VERSION_NUMBER 0
#define PATCH_VERSION_NUMBER 0 #define PATCH_VERSION_NUMBER 0
#define MAX_VERSION_LENGTH 10 #define MAX_VERSION_LENGTH 28
#define MAX_LOCAL_VERSION_LENGTH 12 #define MAX_LOCAL_VERSION_LENGTH 32
char* get_version(void); char* get_version(void);
char* get_version_local(void); char* get_version_local(void);

View File

@ -0,0 +1,2 @@
#pragma once
#define VERSION_TEXT "beta 34"