Merge pull request #570 from ennorehling/develop

improved versioning through version.c
This commit is contained in:
Enno Rehling 2016-09-16 17:05:51 +02:00 committed by GitHub
commit 7e0abeb9fc
13 changed files with 54 additions and 31 deletions

View File

@ -60,7 +60,7 @@ CONFIGURE_FILE (
${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in ${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in
${CMAKE_BINARY_DIR}/include/autoconf.h) ${CMAKE_BINARY_DIR}/include/autoconf.h)
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_AUTOCONF") add_definitions(-DUSE_AUTOCONF)
add_subdirectory (cutest) add_subdirectory (cutest)
add_subdirectory (cJSON) add_subdirectory (cJSON)

View File

@ -20,6 +20,6 @@ $ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests.lua
$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e2.lua $ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e2.lua
$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua $ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua
$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e4.lua $ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e4.lua
rm -rf data reports orders.txt score score.alliances rm -rf data reports orders.txt score score.alliances datum turn
cd $OLDWPD cd $OLDWPD

View File

@ -3,6 +3,8 @@ local autoseed = {}
-- minimum required resources in the 7-hex neighborhood: -- minimum required resources in the 7-hex neighborhood:
local peasants = 10000 local peasants = 10000
local trees = 800 local trees = 800
-- minimum resources in the region itself:
local min_peasants = 2000
-- number of starters per region: -- number of starters per region:
local per_region = 2 local per_region = 2
@ -23,6 +25,7 @@ local function select_regions(regions, peasants, trees)
local sel = {} local sel = {}
for r in regions do for r in regions do
if not r.plane and r.terrain~="ocean" and not r.units() then if not r.plane and r.terrain~="ocean" and not r.units() then
if r:get_resource("peasant") >= min_peasants then
sp = score(r, "peasant") sp = score(r, "peasant")
st = score(r, "tree") st = score(r, "tree")
if sp >= peasants then if sp >= peasants then
@ -32,6 +35,7 @@ local function select_regions(regions, peasants, trees)
end end
end end
end end
end
return sel return sel
end end

View File

@ -13,14 +13,16 @@ include_directories (${BSON_INCLUDE_DIR})
include_directories (${INIPARSER_INCLUDE_DIR}) include_directories (${INIPARSER_INCLUDE_DIR})
IF(DEFINED ERESSEA_VERSION) IF(DEFINED ERESSEA_VERSION)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DERESSEA_VERSION=\\\"${ERESSEA_VERSION}\\\"") set_source_files_properties(kernel/version.c PROPERTIES
COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}")
ENDIF() ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion") # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DHAVE__BOOL") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
add_definitions(-DHAVE__BOOL)
ELSEIF(MSVC) ELSEIF(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG set(CMAKE_EXE_LINKER_FLAGS_DEBUG
@ -171,8 +173,10 @@ set (SERVER_SRC ${SERVER_SRC}
) )
endif(CURSES_FOUND) endif(CURSES_FOUND)
add_library(version STATIC ${VERSION_SRC})
add_library(game ${ERESSEA_SRC}) add_library(game ${ERESSEA_SRC})
add_executable(eressea ${SERVER_SRC}) add_executable(eressea ${SERVER_SRC})
target_link_libraries(game version)
target_link_libraries(eressea target_link_libraries(eressea
game game
${TOLUA_LIBRARIES} ${TOLUA_LIBRARIES}
@ -251,18 +255,18 @@ install(TARGETS eressea DESTINATION "bin")
if (SQLITE3_FOUND) if (SQLITE3_FOUND)
target_link_libraries(eressea ${SQLITE3_LIBRARIES}) target_link_libraries(eressea ${SQLITE3_LIBRARIES})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SQLITE") add_definitions(-DUSE_SQLITE)
endif(SQLITE3_FOUND) endif(SQLITE3_FOUND)
if (CURSES_FOUND) if (CURSES_FOUND)
include_directories (${CURSES_INCLUDE_DIR}) include_directories (${CURSES_INCLUDE_DIR})
target_link_libraries(eressea ${CURSES_LIBRARIES}) target_link_libraries(eressea ${CURSES_LIBRARIES})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CURSES") add_definitions(-DUSE_CURSES)
endif(CURSES_FOUND) endif(CURSES_FOUND)
if (LIBXML2_FOUND) if (LIBXML2_FOUND)
include_directories (${LIBXML2_INCLUDE_DIR}) include_directories (${LIBXML2_INCLUDE_DIR})
target_link_libraries(eressea ${LIBXML2_LIBRARIES}) target_link_libraries(eressea ${LIBXML2_LIBRARIES})
target_link_libraries(test_eressea ${LIBXML2_LIBRARIES}) target_link_libraries(test_eressea ${LIBXML2_LIBRARIES})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_LIBXML2") add_definitions(-DUSE_LIBXML2)
endif (LIBXML2_FOUND) endif (LIBXML2_FOUND)

View File

@ -1515,7 +1515,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, "\"%s\";Build\n", ERESSEA_VERSION); 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

@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 2.6)
project(kernel C) project(kernel C)
SET(_TEST_FILES SET(_TEST_FILES
@ -64,6 +65,8 @@ xmlreader.c
jsonconf.c jsonconf.c
) )
SET(VERSION_SRC ${PROJECT_NAME}/version.c PARENT_SCOPE)
FOREACH(_FILE ${_FILES}) FOREACH(_FILE ${_FILES})
LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE}) LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE})
ENDFOREACH(_FILE) ENDFOREACH(_FILE)

View File

@ -1858,12 +1858,6 @@ 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;
@ -1898,7 +1892,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_no(ERESSEA_VERSION)); 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,7 +79,6 @@ 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

@ -5,6 +5,7 @@
#include <attributes/key.h> #include <attributes/key.h>
#include "save.h" #include "save.h"
#include "version.h"
#include "unit.h" #include "unit.h"
#include "group.h" #include "group.h"
#include "ally.h" #include "ally.h"

17
src/kernel/version.c Normal file
View File

@ -0,0 +1,17 @@
#include "version.h"
#include <stdio.h>
#ifndef ERESSEA_VERSION
// the version number, if it was not passed to make with -D
#define ERESSEA_VERSION "3.10.0-devel"
#endif
const char *eressea_version(void) {
return ERESSEA_VERSION;
}
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;
}

View File

@ -1,16 +1,17 @@
#pragma once
/* /*
+-------------------+ +-------------------+
| | Enno Rehling <enno@eressea.de> | | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de> | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
| (c) 1998 - 2007 | Christian Schlittchen <corwin@amber.kn-bremen.de> | (c) 1998 - 2016 | Christian Schlittchen <corwin@amber.kn-bremen.de>
| | | | https://github.com/eressea/server
+-------------------+ +-------------------+
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/ */
#ifndef ERESSEA_VERSION #ifndef H_KERNEL_VERSION
// the version number, if it was not passed to make with -D #define H_KERNEL_VERSION
#define ERESSEA_VERSION "3.10.0-devel"
const char *eressea_version(void);
int version_no(const char *str);
#endif #endif

View File

@ -166,7 +166,7 @@ static int parse_args(int argc, char **argv, int *exitcode)
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: %s\n\n", "Compilation: " __DATE__ " at " __TIME__ "\nVersion: %s\n\n",
game_name(), ERESSEA_VERSION); game_name(), eressea_version());
#ifdef USE_CURSES #ifdef USE_CURSES
} }
else if (strcmp(argi + 2, "color") == 0) { else if (strcmp(argi + 2, "color") == 0) {

View File

@ -11,4 +11,4 @@ SET SERVER=%BUILD%\eressea.exe
%SERVER% ..\scripts\run-tests-e4.lua %SERVER% ..\scripts\run-tests-e4.lua
PAUSE PAUSE
RMDIR /s /q reports RMDIR /s /q reports
DEL score score.alliances DEL score score.alliances datum turn