forked from github/server
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
641239e388
32 changed files with 158 additions and 219 deletions
|
@ -60,7 +60,9 @@ 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)
|
||||||
add_definitions(-DUSE_AUTOCONF)
|
|
||||||
|
## skip compiler/libc detection and force cmake autoconf:
|
||||||
|
#add_definitions(-DUSE_AUTOCONF)
|
||||||
|
|
||||||
add_subdirectory (cutest)
|
add_subdirectory (cutest)
|
||||||
add_subdirectory (cJSON)
|
add_subdirectory (cJSON)
|
||||||
|
|
123
autoconf.h.in
123
autoconf.h.in
|
@ -33,127 +33,4 @@
|
||||||
#cmakedefine HAVE_DIRECT_MKDIR 1
|
#cmakedefine HAVE_DIRECT_MKDIR 1
|
||||||
#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
|
#endif
|
||||||
|
|
2
s/build
2
s/build
|
@ -39,5 +39,5 @@ echo "build eressea"
|
||||||
cd $ROOT/$BUILD
|
cd $ROOT/$BUILD
|
||||||
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
|
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
|
||||||
cmake -DERESSEA_VERSION="$VERSION" ..
|
cmake -DERESSEA_VERSION="$VERSION" ..
|
||||||
make -k $MAKEOPTS && make test
|
make $MAKEOPTS && make test
|
||||||
cd $OLDPWD
|
cd $OLDPWD
|
||||||
|
|
|
@ -9,17 +9,18 @@ while [ ! -d $ROOT/.git ]; do
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z $BUILD ] && BUILD=Debug
|
[ -z $BUILD ] && BUILD=Debug
|
||||||
MACHINE=`uname -m`
|
|
||||||
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
|
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
|
||||||
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
|
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
|
||||||
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
|
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
|
||||||
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
|
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
|
||||||
|
|
||||||
|
MACHINE=`$CC -dumpmachine`
|
||||||
|
[ -z $MACHINE ] && MACHINE=`uname -m`
|
||||||
BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD"
|
BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD"
|
||||||
mkdir -p $BIN_DIR
|
mkdir -p $BIN_DIR
|
||||||
rm -f $BUILD
|
rm -f $BUILD
|
||||||
ln -sf $BIN_DIR $BUILD
|
ln -sf $BIN_DIR $BUILD
|
||||||
|
|
||||||
MACHINE=$(gcc -dumpmachine)
|
|
||||||
rm -f CMakeCache.txt
|
rm -f CMakeCache.txt
|
||||||
|
|
||||||
# use anything installed in /opt or /usr
|
# use anything installed in /opt or /usr
|
||||||
|
@ -41,6 +42,8 @@ ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \
|
||||||
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
|
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
|
||||||
-DCMAKE_INSTALL_PREFIX=$HOME/eressea/server"
|
-DCMAKE_INSTALL_PREFIX=$HOME/eressea/server"
|
||||||
|
|
||||||
|
git submodule update --init
|
||||||
|
|
||||||
path="$(which tolua)"
|
path="$(which tolua)"
|
||||||
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
|
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
|
||||||
echo "tolua is not installed, building from source"
|
echo "tolua is not installed, building from source"
|
||||||
|
|
|
@ -84,6 +84,7 @@ TOLUA_BINDING(settings.pkg kenel/config.h)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
set (ERESSEA_SRC
|
set (ERESSEA_SRC
|
||||||
|
vortex.c
|
||||||
calendar.c
|
calendar.c
|
||||||
move.c
|
move.c
|
||||||
piracy.c
|
piracy.c
|
||||||
|
@ -92,7 +93,6 @@ set (ERESSEA_SRC
|
||||||
alchemy.c
|
alchemy.c
|
||||||
academy.c
|
academy.c
|
||||||
upkeep.c
|
upkeep.c
|
||||||
vortex.c
|
|
||||||
names.c
|
names.c
|
||||||
lighthouse.c
|
lighthouse.c
|
||||||
reports.c
|
reports.c
|
||||||
|
|
|
@ -21,6 +21,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
attrib_type at_fleechance = {
|
attrib_type at_fleechance = {
|
||||||
"fleechance",
|
"fleechance",
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <CuTest.h>
|
#include <CuTest.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void test_get_set_keys(CuTest *tc) {
|
static void test_get_set_keys(CuTest *tc) {
|
||||||
attrib *a = 0;
|
attrib *a = 0;
|
||||||
|
|
|
@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "matmod.h"
|
#include "matmod.h"
|
||||||
|
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
attrib_type at_matmod = {
|
attrib_type at_matmod = {
|
||||||
"matmod",
|
"matmod",
|
||||||
|
|
|
@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#ifndef H_LUA_CONSOLE
|
#ifndef H_LUA_CONSOLE
|
||||||
#define H_LUA_CONSOLE
|
#define H_LUA_CONSOLE
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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 */
|
/* main function of the creport. creates the header and traverses all regions */
|
||||||
static int
|
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;
|
static int era = -1;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1488,9 +1488,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
perror(filename);
|
perror(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (_strcmpl(charset, "utf-8") == 0 || _strcmpl(charset, "utf8") == 0) {
|
else if (bom) {
|
||||||
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
fwrite(bom, 1, strlen(bom), F);
|
||||||
fwrite(utf8_bom, 1, 3, F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* must call this to get all the neighbour regions */
|
/* 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 */
|
/* initialisations, header and lists */
|
||||||
|
|
||||||
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
|
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
|
||||||
fprintf(F, "\"%s\";charset\n", charset);
|
fprintf(F, "\"utf-8\";charset\n\"%s\";locale\n",
|
||||||
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
|
locale_name(f->locale));
|
||||||
fprintf(F, "%d;noskillpoints\n", 1);
|
fprintf(F, "%d;noskillpoints\n", 1);
|
||||||
fprintf(F, "%lld;date\n", (long long)ctx->report_time);
|
fprintf(F, "%lld;date\n", (long long)ctx->report_time);
|
||||||
fprintf(F, "\"%s\";Spiel\n", game_name());
|
fprintf(F, "\"%s\";Spiel\n", game_name());
|
||||||
|
|
|
@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <kernel/types.h>
|
#include <kernel/types.h>
|
||||||
#include <util/variant.h>
|
#include <util/variant.h>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -599,13 +599,6 @@ void kernel_done(void)
|
||||||
translation_done();
|
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)
|
bool rule_stealth_other(void)
|
||||||
{
|
{
|
||||||
static int rule, config;
|
static int rule, config;
|
||||||
|
|
|
@ -24,6 +24,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this should always be the first thing included after platform.h */
|
/* this should always be the first thing included after platform.h */
|
||||||
|
#include <stddef.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
struct param;
|
struct param;
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ const curse_type *ct_find(const char *c)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size_t k = _min(c_len, strlen(type->cname));
|
size_t k = _min(c_len, strlen(type->cname));
|
||||||
if (!_memicmp(c, type->cname, k)) {
|
if (!memcmp(c, type->cname, k)) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,14 @@
|
||||||
|
|
||||||
#ifndef KRNL_ORDER_H
|
#ifndef KRNL_ORDER_H
|
||||||
#define KRNL_ORDER_H
|
#define KRNL_ORDER_H
|
||||||
|
|
||||||
|
#include "keyword.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "keyword.h"
|
|
||||||
|
|
||||||
/* Encapsulation of an order
|
/* Encapsulation of an order
|
||||||
*
|
*
|
||||||
* This structure contains one order given by a unit. These used to be
|
* This structure contains one order given by a unit. These used to be
|
||||||
|
|
|
@ -18,13 +18,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#ifndef H_KRNL_RACE_H
|
#ifndef H_KRNL_RACE_H
|
||||||
#define H_KRNL_RACE_H
|
#define H_KRNL_RACE_H
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "magic.h" /* wegen MAXMAGIETYP */
|
||||||
|
#include "skill.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "magic.h" /* wegen MAXMAGIETYP */
|
|
||||||
#include "skill.h"
|
|
||||||
|
|
||||||
#define AT_NONE 0
|
#define AT_NONE 0
|
||||||
#define AT_STANDARD 1
|
#define AT_STANDARD 1
|
||||||
#define AT_DRAIN_EXP 2
|
#define AT_DRAIN_EXP 2
|
||||||
|
|
|
@ -18,13 +18,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#ifndef H_KRNL_SHIP
|
#ifndef H_KRNL_SHIP
|
||||||
#define H_KRNL_SHIP
|
#define H_KRNL_SHIP
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DAMAGE_SCALE 100 /* multiplier for sh->damage */
|
#define DAMAGE_SCALE 100 /* multiplier for sh->damage */
|
||||||
|
|
||||||
/* ship_type::flags */
|
/* ship_type::flags */
|
||||||
|
|
|
@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/variant.h>
|
#include <util/variant.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "skills.h"
|
#include "skills.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -70,11 +70,6 @@ static void load_inifile(dictionary * d)
|
||||||
|
|
||||||
lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0;
|
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);
|
verbosity = iniparser_getint(d, "eressea:verbose", 2);
|
||||||
battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0;
|
battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#ifndef SCORE_H
|
#ifndef SCORE_H
|
||||||
#define SCORE_H
|
#define SCORE_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#ifndef H_KRNL_NAMES
|
#ifndef H_KRNL_NAMES
|
||||||
#define H_KRNL_NAMES
|
#define H_KRNL_NAMES
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
122
src/platform.h
122
src/platform.h
|
@ -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.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef CONFIG_H
|
#ifndef PLATFORM_H
|
||||||
#define CONFIG_H
|
#define PLATFORM_H
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define LOMEM
|
#define LOMEM
|
||||||
#endif
|
#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
|
#ifdef _MSC_VER
|
||||||
# define VC_EXTRALEAN
|
#undef USE_AUTOCONF
|
||||||
# define WIN32_LEAN_AND_MEAN
|
#define HAVE_STDBOOL_H
|
||||||
|
#define HAVE_DIRECT__MKDIR
|
||||||
|
#define HAVE__ACCESS
|
||||||
|
|
||||||
|
#define VC_EXTRALEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable:4820 4255 4668)
|
#pragma warning(disable:4820 4255 4668)
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
@ -60,7 +78,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
/* warning C4100: <name> was declared deprecated */
|
/* warning C4100: <name> was declared deprecated */
|
||||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
# define _CRT_SECURE_NO_DEPRECATE
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
#endif
|
#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.
|
* single-threaded I/O model and use the _nolock forms of the functions.
|
||||||
*/
|
*/
|
||||||
#ifndef _CRT_DISABLE_PERFCRIT_LOCKS
|
#ifndef _CRT_DISABLE_PERFCRIT_LOCKS
|
||||||
# define _CRT_DISABLE_PERFCRIT_LOCKS
|
#define _CRT_DISABLE_PERFCRIT_LOCKS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* define CRTDBG to enable MSVC CRT Debug library functions */
|
#elif __GNUC__
|
||||||
#if defined(_DEBUG) && defined(CRTDBG)
|
#undef USE_AUTOCONF
|
||||||
# include <crtdbg.h>
|
#define HAVE_SNPRINTF
|
||||||
# define _CRTDBG_MAP_ALLOC
|
#define HAVE_SYS_STAT_MKDIR
|
||||||
|
#define HAVE_STRDUP
|
||||||
|
#define HAVE_UNISTD_H
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _MSC_VER_ */
|
#ifdef USE_AUTOCONF
|
||||||
|
// unknown toolchain, using autoconf
|
||||||
#if defined __GNUC__
|
#include <autoconf.h>
|
||||||
# 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
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define unused_arg (void)
|
#define unused_arg (void)
|
||||||
|
|
||||||
#ifndef INLINE_FUNCTION
|
|
||||||
# define INLINE_FUNCTION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define iswxspace(c) (c==160 || iswspace(c))
|
#define iswxspace(c) (c==160 || iswspace(c))
|
||||||
#define isxspace(c) (c==160 || isspace(c))
|
#define isxspace(c) (c==160 || isspace(c))
|
||||||
|
|
||||||
#define TOLUA_CAST (char*)
|
#define TOLUA_CAST (char*)
|
||||||
|
|
||||||
#ifdef USE_AUTOCONF
|
|
||||||
# include <autoconf.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(MAX_PATH)
|
#if !defined(MAX_PATH)
|
||||||
#if defined(PATH_MAX)
|
#if defined(PATH_MAX)
|
||||||
# define MAX_PATH 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>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STRINGS_H
|
#if defined(HAVE_STDBOOL_H)
|
||||||
#include <strings.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
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
16
src/report.c
16
src/report.c
|
@ -1379,7 +1379,7 @@ static int buildingmaintenance(const building * b, const resource_type * rtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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);
|
const resource_type *rsilver = get_resourcetype(R_SILVER);
|
||||||
faction *f = ctx->f;
|
faction *f = ctx->f;
|
||||||
|
@ -1389,7 +1389,6 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
char buf[8192], *bufp;
|
char buf[8192], *bufp;
|
||||||
size_t size;
|
size_t size;
|
||||||
int bytes;
|
int bytes;
|
||||||
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
|
|
||||||
const curse_type *nocost_ct = ct_find("nocostbuilding");
|
const curse_type *nocost_ct = ct_find("nocostbuilding");
|
||||||
|
|
||||||
if (F == NULL) {
|
if (F == NULL) {
|
||||||
|
@ -1398,9 +1397,8 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
}
|
}
|
||||||
fstream_init(&strm, F);
|
fstream_init(&strm, F);
|
||||||
|
|
||||||
if (utf8) {
|
if (bom) {
|
||||||
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
swrite(bom, 1, strlen(bom), out);
|
||||||
swrite(utf8_bom, 1, 3, out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newline(out);
|
newline(out);
|
||||||
|
@ -2026,7 +2024,7 @@ void write_travelthru(struct stream *out, region *r, const faction *f)
|
||||||
|
|
||||||
int
|
int
|
||||||
report_plaintext(const char *filename, report_context * ctx,
|
report_plaintext(const char *filename, report_context * ctx,
|
||||||
const char *charset)
|
const char *bom)
|
||||||
{
|
{
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
char ch;
|
char ch;
|
||||||
|
@ -2044,7 +2042,6 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
stream strm = { 0 }, *out = &strm;
|
stream strm = { 0 }, *out = &strm;
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
char *bufp;
|
char *bufp;
|
||||||
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
|
|
||||||
size_t size;
|
size_t size;
|
||||||
int thisseason;
|
int thisseason;
|
||||||
int nextseason;
|
int nextseason;
|
||||||
|
@ -2061,9 +2058,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
}
|
}
|
||||||
fstream_init(&strm, F);
|
fstream_init(&strm, F);
|
||||||
|
|
||||||
if (utf8) {
|
if (bom) {
|
||||||
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
fwrite(bom, 1, strlen(bom), F);
|
||||||
fwrite(utf8_bom, 1, 3, F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strftime(pzTime, 64, "%A, %d. %B %Y, %H:%M", localtime(&ctx->report_time));
|
strftime(pzTime, 64, "%A, %d. %B %Y, %H:%M", localtime(&ctx->report_time));
|
||||||
|
|
|
@ -1401,12 +1401,10 @@ void finish_reports(report_context *ctx) {
|
||||||
|
|
||||||
int write_reports(faction * f, time_t ltime)
|
int write_reports(faction * f, time_t ltime)
|
||||||
{
|
{
|
||||||
unsigned int backup = 1, maxbackup = 128 * 1000;
|
|
||||||
bool gotit = false;
|
bool gotit = false;
|
||||||
struct report_context ctx;
|
struct report_context ctx;
|
||||||
const char *encoding = "UTF-8";
|
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
||||||
report_type *rtype;
|
report_type *rtype;
|
||||||
|
|
||||||
if (noreports) {
|
if (noreports) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1423,19 +1421,12 @@ int write_reports(faction * f, time_t ltime)
|
||||||
rtype->extension);
|
rtype->extension);
|
||||||
join_path(reportpath(), filename, path, sizeof(path));
|
join_path(reportpath(), filename, path, sizeof(path));
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (rtype->write(path, &ctx, encoding) == 0) {
|
if (rtype->write(path, &ctx, (const char *)utf8_bom) == 0) {
|
||||||
gotit = true;
|
gotit = true;
|
||||||
}
|
}
|
||||||
if (errno) {
|
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;
|
error = errno;
|
||||||
|
log_fatal("error %d during %s report for faction %s: %s", errno, rtype->extension, factionname(f), strerror(error));
|
||||||
errno = 0;
|
errno = 0;
|
||||||
}
|
}
|
||||||
} while (error);
|
} while (error);
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <kernel/messages.h>
|
#include <kernel/messages.h>
|
||||||
#include <util/language.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)
|
static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, const struct curse * c, int self)
|
||||||
{
|
{
|
||||||
if (typ == TYP_UNIT) {
|
if (typ == TYP_UNIT) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ static void unicode_warning(const char *bp)
|
||||||
log_warning("invalid sequence in UTF-8 string: %s\n", 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;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
#ifndef H_UTIL_NRMESSAGE
|
#ifndef H_UTIL_NRMESSAGE
|
||||||
#define H_UTIL_NRMESSAGE
|
#define H_UTIL_NRMESSAGE
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
#ifndef UTIL_PARSER_H
|
#ifndef UTIL_PARSER_H
|
||||||
#define UTIL_PARSER_H
|
#define UTIL_PARSER_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#ifndef STRINGS_H
|
#ifndef STRINGS_H
|
||||||
#define STRINGS_H
|
#define STRINGS_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
#ifndef H_UTIL_TRANSLATION
|
#ifndef H_UTIL_TRANSLATION
|
||||||
#define H_UTIL_TRANSLATION
|
#define H_UTIL_TRANSLATION
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
#include <storage.h>
|
#include <storage.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct dir_lookup {
|
typedef struct dir_lookup {
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -32,7 +33,7 @@ void register_special_direction(struct locale *lang, const char *name)
|
||||||
if (token) {
|
if (token) {
|
||||||
void **tokens = get_translations(lang, UT_SPECDIR);
|
void **tokens = get_translations(lang, UT_SPECDIR);
|
||||||
variant var;
|
variant var;
|
||||||
char *str = _strdup(name);
|
char *str = strdup(name);
|
||||||
|
|
||||||
var.v = str;
|
var.v = str;
|
||||||
addtoken((struct tnode **)tokens, token, var);
|
addtoken((struct tnode **)tokens, token, var);
|
||||||
|
|
2
storage
2
storage
|
@ -1 +1 @@
|
||||||
Subproject commit 18cc3bb8f8906237915eb31c9899f95340318087
|
Subproject commit 2117191d4ad75e1eb14809878bc71d15b20a5d86
|
Loading…
Reference in a new issue