Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Enno Rehling 2016-11-26 17:18:36 +01:00
commit 641239e388
32 changed files with 158 additions and 219 deletions

View File

@ -60,7 +60,9 @@ CONFIGURE_FILE (
${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in
${CMAKE_BINARY_DIR}/include/autoconf.h)
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include)
add_definitions(-DUSE_AUTOCONF)
## skip compiler/libc detection and force cmake autoconf:
#add_definitions(-DUSE_AUTOCONF)
add_subdirectory (cutest)
add_subdirectory (cJSON)

View File

@ -33,127 +33,4 @@
#cmakedefine HAVE_DIRECT_MKDIR 1
#cmakedefine HAVE_DIRECT__MKDIR 1
#if defined(HAVE_STRINGS_H)
#include <strings.h>
#endif
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#if defined(HAVE_IO_H)
#include <io.h>
#endif
#if defined(HAVE_WINDOWS_H)
#include <windows.h>
#endif
#if defined(HAVE_STDBOOL_H)
# include <stdbool.h>
#else
# if ! HAVE__BOOL
# ifdef __cplusplus
typedef bool _Bool;
# else
typedef unsigned char _Bool;
# endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
#endif
#ifndef HAVE__ACCESS
#ifdef HAVE_ACCESS
#define _access(path, mode) access(path, mode)
#endif
#endif
#ifndef _A_RDONLY
#ifdef R_OK
#define _A_RDONLY R_OK
#endif
#endif
#if !defined(HAVE__MEMICMP)
#if defined(HAVE_MEMICMP)
#define _memicmp(a, b, n) memicmp(a, b, n)
#elif defined(HAVE_STRNCASECMP)
#define _memicmp(a, b, n) strncasecmp(a, b, n)
#else
#define _memicmp(a, b, n) lcp_memicmp(a, b, n)
#endif
#endif
#if !defined(HAVE__STRCMPL)
#if defined(HAVE_STRCMPL)
#define _strcmpl(a, b) strcmpl(a, b)
#elif defined(HAVE__STRICMP)
#define _strcmpl(a, b) _stricmp(a, b)
#elif defined(HAVE_STRICMP)
#define _strcmpl(a, b) stricmp(a, b)
#elif defined(HAVE_STRCASECMP)
#define _strcmpl(a, b) strcasecmp(a, b)
#else
#define _strcmpl(a, b) lcp_strcmpl(a, b)
#endif
#endif
#if defined(HAVE_DIRECT__MKDIR)
#include <direct.h>
#elif defined(HAVE_DIRECT_MKDIR)
#include <direct.h>
#define _mkdir(a) mkdir(a)
#elif defined(HAVE_SYS_STAT_MKDIR)
#include <sys/stat.h>
#define _mkdir(a) mkdir(a, 0777)
#endif
#if !defined(HAVE__STRLWR)
#if defined(HAVE_STRLWR)
#define _strlwr(a) strlwr(a)
#else
#define _strlwr(a) lcp_strlwr(a)
#endif
#endif
#if !defined(HAVE__STRDUP)
#if defined(HAVE_STRDUP)
#define _strdup(a) strdup(a)
#else
#define _strdup(a) lcp_strdup(a)
#endif
#endif
#if !defined(HAVE__SLEEP)
#if defined(HAVE_USLEEP)
#define _sleep(a) usleep(a)
#elif defined(HAVE_SLEEP)
#define _sleep(a) sleep((a)/1000)
#else
#define _sleep(a) lcp_sleep(a)
#endif
#endif
#if !defined(HAVE__SNPRINTF)
#if defined(HAVE_SNPRINTF)
#define _snprintf snprintf
#else
#define _snprintf lcp_snprintf
#endif
#endif
#ifndef _min
#define _min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef _max
#define _max(a,b) ((a) > (b) ? (a) : (b))
#endif
#if !defined(DBG_UNREFERENCED_PARAMETER)
#define DBG_UNREFERENCED_PARAMETER(x) x
#endif
#endif

View File

@ -39,5 +39,5 @@ echo "build eressea"
cd $ROOT/$BUILD
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
cmake -DERESSEA_VERSION="$VERSION" ..
make -k $MAKEOPTS && make test
make $MAKEOPTS && make test
cd $OLDPWD

View File

@ -9,17 +9,18 @@ while [ ! -d $ROOT/.git ]; do
done
[ -z $BUILD ] && BUILD=Debug
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
MACHINE=`$CC -dumpmachine`
[ -z $MACHINE ] && MACHINE=`uname -m`
BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD"
mkdir -p $BIN_DIR
rm -f $BUILD
ln -sf $BIN_DIR $BUILD
MACHINE=$(gcc -dumpmachine)
rm -f CMakeCache.txt
# use anything installed in /opt or /usr
@ -41,6 +42,8 @@ ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
-DCMAKE_INSTALL_PREFIX=$HOME/eressea/server"
git submodule update --init
path="$(which tolua)"
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
echo "tolua is not installed, building from source"

View File

@ -84,6 +84,7 @@ TOLUA_BINDING(settings.pkg kenel/config.h)
ENDIF()
set (ERESSEA_SRC
vortex.c
calendar.c
move.c
piracy.c
@ -92,7 +93,6 @@ set (ERESSEA_SRC
alchemy.c
academy.c
upkeep.c
vortex.c
names.c
lighthouse.c
reports.c

View File

@ -21,6 +21,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/attrib.h>
#include <stdlib.h>
attrib_type at_fleechance = {
"fleechance",
NULL,

View File

@ -3,6 +3,7 @@
#include <util/attrib.h>
#include <CuTest.h>
#include <stdlib.h>
static void test_get_set_keys(CuTest *tc) {
attrib *a = 0;

View File

@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "matmod.h"
#include <util/attrib.h>
#include <stddef.h>
attrib_type at_matmod = {
"matmod",

View File

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_LUA_CONSOLE
#define H_LUA_CONSOLE
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -1468,7 +1468,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
/* main function of the creport. creates the header and traverses all regions */
static int
report_computer(const char *filename, report_context * ctx, const char *charset)
report_computer(const char *filename, report_context * ctx, const char *bom)
{
static int era = -1;
int i;
@ -1488,9 +1488,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
perror(filename);
return -1;
}
else if (_strcmpl(charset, "utf-8") == 0 || _strcmpl(charset, "utf8") == 0) {
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
fwrite(utf8_bom, 1, 3, F);
else if (bom) {
fwrite(bom, 1, strlen(bom), F);
}
/* must call this to get all the neighbour regions */
@ -1498,8 +1497,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
/* initialisations, header and lists */
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
fprintf(F, "\"%s\";charset\n", charset);
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
fprintf(F, "\"utf-8\";charset\n\"%s\";locale\n",
locale_name(f->locale));
fprintf(F, "%d;noskillpoints\n", 1);
fprintf(F, "%lld;date\n", (long long)ctx->report_time);
fprintf(F, "\"%s\";Spiel\n", game_name());

View File

@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/types.h>
#include <util/variant.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -599,13 +599,6 @@ void kernel_done(void)
translation_done();
}
#ifndef HAVE_STRDUP
char *_strdup(const char *s)
{
return strcpy((char *)malloc(sizeof(char) * (strlen(s) + 1)), s);
}
#endif
bool rule_stealth_other(void)
{
static int rule, config;

View File

@ -24,6 +24,7 @@ extern "C" {
#endif
/* this should always be the first thing included after platform.h */
#include <stddef.h>
#include "types.h"
struct param;

View File

@ -349,7 +349,7 @@ const curse_type *ct_find(const char *c)
}
else {
size_t k = _min(c_len, strlen(type->cname));
if (!_memicmp(c, type->cname, k)) {
if (!memcmp(c, type->cname, k)) {
return type;
}
}

View File

@ -12,12 +12,14 @@
#ifndef KRNL_ORDER_H
#define KRNL_ORDER_H
#include "keyword.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "keyword.h"
/* Encapsulation of an order
*
* This structure contains one order given by a unit. These used to be

View File

@ -18,13 +18,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_RACE_H
#define H_KRNL_RACE_H
#include <stddef.h>
#include "magic.h" /* wegen MAXMAGIETYP */
#include "skill.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "magic.h" /* wegen MAXMAGIETYP */
#include "skill.h"
#define AT_NONE 0
#define AT_STANDARD 1
#define AT_DRAIN_EXP 2

View File

@ -18,13 +18,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_SHIP
#define H_KRNL_SHIP
#ifdef __cplusplus
extern "C" {
#endif
#include "types.h"
#include "direction.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DAMAGE_SCALE 100 /* multiplier for sh->damage */
/* ship_type::flags */

View File

@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/variant.h>
#include "types.h"
#include "skills.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -70,11 +70,6 @@ static void load_inifile(dictionary * d)
lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0;
str = iniparser_getstring(d, "eressea:encoding", NULL);
if (str && (_strcmpl(str, "utf8") == 0 || _strcmpl(str, "utf-8") == 0)) {
enc_gamedata = ENCODING_UTF8;
}
verbosity = iniparser_getint(d, "eressea:verbose", 2);
battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0;

View File

@ -18,6 +18,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef SCORE_H
#define SCORE_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_NAMES
#define H_KRNL_NAMES
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -16,16 +16,34 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/
#ifndef CONFIG_H
#define CONFIG_H
#ifndef PLATFORM_H
#define PLATFORM_H
#ifdef NDEBUG
#define LOMEM
#endif
// enable X/Open 7 extensions (like strdup):
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700
#endif
// enable bsd string extensions, since glibc 2.12 (_BSD_SOURCE is dead):
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#ifndef USE_AUTOCONF
#define USE_AUTOCONF
#ifdef _MSC_VER
# define VC_EXTRALEAN
# define WIN32_LEAN_AND_MEAN
#undef USE_AUTOCONF
#define HAVE_STDBOOL_H
#define HAVE_DIRECT__MKDIR
#define HAVE__ACCESS
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#pragma warning(push)
#pragma warning(disable:4820 4255 4668)
# include <windows.h>
@ -60,7 +78,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* warning C4100: <name> was declared deprecated */
#ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
/*
@ -69,50 +87,30 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* single-threaded I/O model and use the _nolock forms of the functions.
*/
#ifndef _CRT_DISABLE_PERFCRIT_LOCKS
# define _CRT_DISABLE_PERFCRIT_LOCKS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
/* define CRTDBG to enable MSVC CRT Debug library functions */
#if defined(_DEBUG) && defined(CRTDBG)
# include <crtdbg.h>
# define _CRTDBG_MAP_ALLOC
#elif __GNUC__
#undef USE_AUTOCONF
#define HAVE_SNPRINTF
#define HAVE_SYS_STAT_MKDIR
#define HAVE_STRDUP
#define HAVE_UNISTD_H
#endif
#endif
#endif /* _MSC_VER_ */
#if defined __GNUC__
# undef _BSD_SOURCE
# define _BSD_SOURCE
# undef __USE_BSD
# define __USE_BSD
#endif
#ifdef _BSD_SOURCE
# undef __EXTENSIONS__
# define __EXTENSIONS__
#endif
#ifdef SOLARIS
# define _SYS_PROCSET_H
#undef _XOPEN_SOURCE
# define _XOPEN_SOURCE
#ifdef USE_AUTOCONF
// unknown toolchain, using autoconf
#include <autoconf.h>
#endif
#define unused_arg (void)
#ifndef INLINE_FUNCTION
# define INLINE_FUNCTION
#endif
#define iswxspace(c) (c==160 || iswspace(c))
#define isxspace(c) (c==160 || isspace(c))
#define TOLUA_CAST (char*)
#ifdef USE_AUTOCONF
# include <autoconf.h>
#endif
#if !defined(MAX_PATH)
#if defined(PATH_MAX)
# define MAX_PATH PATH_MAX
@ -125,8 +123,56 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <unistd.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#if defined(HAVE_STDBOOL_H)
# include <stdbool.h>
#else
# ifndef HAVE__BOOL
# ifdef __cplusplus
typedef bool _Bool;
# else
typedef unsigned char _Bool;
# endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
#endif
#ifndef HAVE__ACCESS
#ifdef HAVE_ACCESS
#define _access(path, mode) access(path, mode)
#endif
#endif
#if defined(HAVE_DIRECT__MKDIR)
#include <direct.h>
#elif defined(HAVE_DIRECT_MKDIR)
#include <direct.h>
#define _mkdir(a) mkdir(a)
#elif defined(HAVE_SYS_STAT_MKDIR)
#include <sys/stat.h>
#define _mkdir(a) mkdir(a, 0777)
#endif
#ifndef _min
#define _min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef _max
#define _max(a,b) ((a) > (b) ? (a) : (b))
#endif
#if !defined(HAVE__STRDUP)
#if defined(HAVE_STRDUP)
#undef _strdup
#define _strdup strdup
#endif
#endif
#if !defined(HAVE__SNPRINTF)
#if defined(HAVE_SNPRINTF)
#define _snprintf snprintf
#endif
#endif
#endif

View File

@ -1379,7 +1379,7 @@ static int buildingmaintenance(const building * b, const resource_type * rtype)
}
static int
report_template(const char *filename, report_context * ctx, const char *charset)
report_template(const char *filename, report_context * ctx, const char *bom)
{
const resource_type *rsilver = get_resourcetype(R_SILVER);
faction *f = ctx->f;
@ -1389,7 +1389,6 @@ report_template(const char *filename, report_context * ctx, const char *charset)
char buf[8192], *bufp;
size_t size;
int bytes;
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
const curse_type *nocost_ct = ct_find("nocostbuilding");
if (F == NULL) {
@ -1398,9 +1397,8 @@ report_template(const char *filename, report_context * ctx, const char *charset)
}
fstream_init(&strm, F);
if (utf8) {
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
swrite(utf8_bom, 1, 3, out);
if (bom) {
swrite(bom, 1, strlen(bom), out);
}
newline(out);
@ -2026,7 +2024,7 @@ void write_travelthru(struct stream *out, region *r, const faction *f)
int
report_plaintext(const char *filename, report_context * ctx,
const char *charset)
const char *bom)
{
int flag = 0;
char ch;
@ -2044,7 +2042,6 @@ report_plaintext(const char *filename, report_context * ctx,
stream strm = { 0 }, *out = &strm;
char buf[8192];
char *bufp;
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
size_t size;
int thisseason;
int nextseason;
@ -2061,9 +2058,8 @@ report_plaintext(const char *filename, report_context * ctx,
}
fstream_init(&strm, F);
if (utf8) {
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
fwrite(utf8_bom, 1, 3, F);
if (bom) {
fwrite(bom, 1, strlen(bom), F);
}
strftime(pzTime, 64, "%A, %d. %B %Y, %H:%M", localtime(&ctx->report_time));

View File

@ -1401,12 +1401,10 @@ void finish_reports(report_context *ctx) {
int write_reports(faction * f, time_t ltime)
{
unsigned int backup = 1, maxbackup = 128 * 1000;
bool gotit = false;
struct report_context ctx;
const char *encoding = "UTF-8";
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
report_type *rtype;
if (noreports) {
return false;
}
@ -1423,19 +1421,12 @@ int write_reports(faction * f, time_t ltime)
rtype->extension);
join_path(reportpath(), filename, path, sizeof(path));
errno = 0;
if (rtype->write(path, &ctx, encoding) == 0) {
if (rtype->write(path, &ctx, (const char *)utf8_bom) == 0) {
gotit = true;
}
if (errno) {
char zText[64];
log_warning("retrying, error %d during %s report for faction %s", errno, rtype->extension, factionname(f));
sprintf(zText, "waiting %u seconds before we retry", backup);
perror(zText);
_sleep(backup);
if (backup < maxbackup) {
backup *= 2;
}
error = errno;
log_fatal("error %d during %s report for faction %s: %s", errno, rtype->extension, factionname(f), strerror(error));
errno = 0;
}
} while (error);

View File

@ -3,6 +3,8 @@
#include <kernel/messages.h>
#include <util/language.h>
#include <stdlib.h>
static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, const struct curse * c, int self)
{
if (typ == TYP_UNIT) {

View File

@ -18,7 +18,7 @@ static void unicode_warning(const char *bp)
log_warning("invalid sequence in UTF-8 string: %s\n", bp);
}
INLINE_FUNCTION int eatwhite(const char *ptr, size_t * total_size)
static int eatwhite(const char *ptr, size_t * total_size)
{
int ret = 0;

View File

@ -12,6 +12,9 @@
#ifndef H_UTIL_NRMESSAGE
#define H_UTIL_NRMESSAGE
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -10,6 +10,9 @@
#ifndef UTIL_PARSER_H
#define UTIL_PARSER_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef STRINGS_H
#define STRINGS_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -12,6 +12,9 @@
#ifndef H_UTIL_TRANSLATION
#define H_UTIL_TRANSLATION
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -14,8 +14,9 @@
#include <storage.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
typedef struct dir_lookup {
char *name;
@ -32,7 +33,7 @@ void register_special_direction(struct locale *lang, const char *name)
if (token) {
void **tokens = get_translations(lang, UT_SPECDIR);
variant var;
char *str = _strdup(name);
char *str = strdup(name);
var.v = str;
addtoken((struct tnode **)tokens, token, var);

@ -1 +1 @@
Subproject commit 18cc3bb8f8906237915eb31c9899f95340318087
Subproject commit 2117191d4ad75e1eb14809878bc71d15b20a5d86