new version numbering in version.h

eliminate buildno.h
TODO: update build scripts
This commit is contained in:
Enno Rehling 2016-09-10 17:41:44 +02:00
parent c352ab9f8e
commit e200952e87
7 changed files with 27 additions and 8 deletions

View File

@ -1,3 +0,0 @@
#define VERSION_MAJOR 3
#define VERSION_MINOR 10
#define VERSION_BUILD 0

View File

@ -9,6 +9,7 @@ without prior permission by the authors of Eressea.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/version.h>
#include "buildno.h" #include "buildno.h"
#include "creport.h" #include "creport.h"
#include "seen.h" #include "seen.h"
@ -1515,7 +1516,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
fprintf(F, "%d;Basis\n", 36); fprintf(F, "%d;Basis\n", 36);
fprintf(F, "%d;Runde\n", turn); fprintf(F, "%d;Runde\n", turn);
fprintf(F, "%d;Zeitalter\n", era); fprintf(F, "%d;Zeitalter\n", era);
fprintf(F, "\"%d.%d.%d\";Build\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); fprintf(F, "\"%s\";Build\n", ERESSEA_VERSION);
if (mailto != NULL) { if (mailto != NULL) {
fprintf(F, "\"%s\";mailto\n", mailto); fprintf(F, "\"%s\";mailto\n", mailto);
fprintf(F, "\"%s\";mailcmd\n", LOC(f->locale, "mailcmd")); fprintf(F, "\"%s\";mailcmd\n", LOC(f->locale, "mailcmd"));

View File

@ -18,6 +18,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/version.h>
#include "save.h" #include "save.h"
#include <buildno.h> #include <buildno.h>
@ -1859,6 +1860,12 @@ static void clear_npc_orders(faction *f)
} }
} }
int version_no(const char *str) {
int maj = 0, min = 0, bld = 0;
sscanf(str, "%d.%d.%d", &maj, &min, &bld);
return (maj << 16) | (min << 8) | bld;
}
int writegame(const char *filename) int writegame(const char *filename)
{ {
int n; int n;
@ -1889,7 +1896,7 @@ int writegame(const char *filename)
fstream_init(&strm, F); fstream_init(&strm, F);
binstore_init(&store, &strm); binstore_init(&store, &strm);
WRITE_INT(&store, VERSION_BUILD); WRITE_INT(&store, version_no(ERESSEA_VERSION));
n = write_game(&gdata); n = write_game(&gdata);
binstore_done(&store); binstore_done(&store);
fstream_done(&strm); fstream_done(&strm);

View File

@ -79,6 +79,7 @@ extern "C" {
int write_game(struct gamedata *data); int write_game(struct gamedata *data);
int read_game(struct gamedata *data); int read_game(struct gamedata *data);
int version_no(const char *str);
/* test-only functions that give access to internal implementation details (BAD) */ /* test-only functions that give access to internal implementation details (BAD) */
void _test_write_password(struct gamedata *data, const struct faction *f); void _test_write_password(struct gamedata *data, const struct faction *f);

View File

@ -312,6 +312,12 @@ static void test_read_password_external(CuTest *tc) {
test_cleanup(); test_cleanup();
} }
static void test_version_no(CuTest *tc) {
CuAssertIntEquals(tc, 0, version_no("0.0.0-devel"));
CuAssertIntEquals(tc, 0x10000, version_no("1.0.0-test"));
CuAssertIntEquals(tc, 0x10203, version_no("1.2.3-what.is.42"));
}
CuSuite *get_save_suite(void) CuSuite *get_save_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
@ -324,5 +330,7 @@ CuSuite *get_save_suite(void)
SUITE_ADD_TEST(suite, test_readwrite_dead_faction_group); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_group);
SUITE_ADD_TEST(suite, test_read_password); SUITE_ADD_TEST(suite, test_read_password);
SUITE_ADD_TEST(suite, test_read_password_external); SUITE_ADD_TEST(suite, test_read_password_external);
SUITE_ADD_TEST(suite, test_version_no);
return suite; return suite;
} }

View File

@ -8,5 +8,9 @@
This program may not be used, modified or distributed This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#ifndef ERESSEA_VERSION
// the version number, if it was not passed to make with -D
#define ERESSEA_VERSION "3.10.0-devel"
#endif

View File

@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/log.h> #include <util/log.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/version.h>
#include <kernel/save.h> #include <kernel/save.h>
#include <util/filereader.h> #include <util/filereader.h>
#include <util/language.h> #include <util/language.h>
@ -165,8 +166,8 @@ static int parse_args(int argc, char **argv, int *exitcode)
if (strcmp(argi + 2, "version") == 0) { if (strcmp(argi + 2, "version") == 0) {
printf("\n%s PBEM host\n" printf("\n%s PBEM host\n"
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n" "Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %d.%d.%d\n\n", "Compilation: " __DATE__ " at " __TIME__ "\nVersion: %s\n\n",
game_name(), VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); game_name(), ERESSEA_VERSION);
#ifdef USE_CURSES #ifdef USE_CURSES
} }
else if (strcmp(argi + 2, "color") == 0) { else if (strcmp(argi + 2, "color") == 0) {