forked from github/server
Merge pull request #829 from ennorehling/develop
ongoing updates, new releases
This commit is contained in:
commit
3e793f11be
17 changed files with 74 additions and 228 deletions
|
@ -1,172 +0,0 @@
|
||||||
#.rst:
|
|
||||||
# FindLua
|
|
||||||
# -------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Locate Lua library This module defines
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# LUA_FOUND - if false, do not try to link to Lua
|
|
||||||
# LUA_LIBRARIES - both lua and lualib
|
|
||||||
# LUA_INCLUDE_DIR - where to find lua.h
|
|
||||||
# LUA_VERSION_STRING - the version of Lua found
|
|
||||||
# LUA_VERSION_MAJOR - the major version of Lua
|
|
||||||
# LUA_VERSION_MINOR - the minor version of Lua
|
|
||||||
# LUA_VERSION_PATCH - the patch version of Lua
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Note that the expected include convention is
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# #include "lua.h"
|
|
||||||
#
|
|
||||||
# and not
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# #include <lua/lua.h>
|
|
||||||
#
|
|
||||||
# This is because, the lua location is not standardized and may exist in
|
|
||||||
# locations other than lua/
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Copyright 2007-2009 Kitware, Inc.
|
|
||||||
# Copyright 2013 Rolf Eike Beer <eike@sf-mail.de>
|
|
||||||
#
|
|
||||||
# Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
# see accompanying file Copyright.txt for details.
|
|
||||||
#
|
|
||||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
# See the License for more information.
|
|
||||||
#=============================================================================
|
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
|
||||||
# License text for the above reference.)
|
|
||||||
|
|
||||||
unset(_lua_include_subdirs)
|
|
||||||
unset(_lua_library_names)
|
|
||||||
|
|
||||||
# this is a function only to have all the variables inside go away automatically
|
|
||||||
function(set_lua_version_vars)
|
|
||||||
set(LUA_VERSIONS5 5.3 5.2 5.1 5.0)
|
|
||||||
|
|
||||||
if (Lua_FIND_VERSION_EXACT)
|
|
||||||
if (Lua_FIND_VERSION_COUNT GREATER 1)
|
|
||||||
set(lua_append_versions ${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR})
|
|
||||||
endif ()
|
|
||||||
elseif (Lua_FIND_VERSION)
|
|
||||||
# once there is a different major version supported this should become a loop
|
|
||||||
if (NOT Lua_FIND_VERSION_MAJOR GREATER 5)
|
|
||||||
if (Lua_FIND_VERSION_COUNT EQUAL 1)
|
|
||||||
set(lua_append_versions ${LUA_VERSIONS5})
|
|
||||||
else ()
|
|
||||||
foreach (subver IN LISTS LUA_VERSIONS5)
|
|
||||||
if (NOT subver VERSION_LESS ${Lua_FIND_VERSION})
|
|
||||||
list(APPEND lua_append_versions ${subver})
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
else ()
|
|
||||||
# once there is a different major version supported this should become a loop
|
|
||||||
set(lua_append_versions ${LUA_VERSIONS5})
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
foreach (ver IN LISTS lua_append_versions)
|
|
||||||
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
|
|
||||||
list(APPEND _lua_include_subdirs
|
|
||||||
include/lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
|
|
||||||
include/lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
include/lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
)
|
|
||||||
list(APPEND _lua_library_names
|
|
||||||
lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
|
|
||||||
lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
lua.${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
|
||||||
)
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE)
|
|
||||||
set(_lua_library_names "${_lua_library_names}" PARENT_SCOPE)
|
|
||||||
endfunction(set_lua_version_vars)
|
|
||||||
|
|
||||||
set_lua_version_vars()
|
|
||||||
|
|
||||||
find_path(LUA_INCLUDE_DIR lua.h
|
|
||||||
HINTS
|
|
||||||
ENV LUA_DIR
|
|
||||||
PATH_SUFFIXES ${_lua_include_subdirs} include/lua include
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/sw # Fink
|
|
||||||
/opt/local # DarwinPorts
|
|
||||||
/opt/csw # Blastwave
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
unset(_lua_include_subdirs)
|
|
||||||
|
|
||||||
find_library(LUA_LIBRARY
|
|
||||||
NAMES ${_lua_library_names} lua
|
|
||||||
HINTS
|
|
||||||
ENV LUA_DIR
|
|
||||||
PATH_SUFFIXES lib
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/sw
|
|
||||||
/opt/local
|
|
||||||
/opt/csw
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
unset(_lua_library_names)
|
|
||||||
|
|
||||||
if (LUA_LIBRARY)
|
|
||||||
# include the math library for Unix
|
|
||||||
if (UNIX AND NOT APPLE AND NOT BEOS)
|
|
||||||
find_library(LUA_MATH_LIBRARY m)
|
|
||||||
set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
|
|
||||||
# For Windows and Mac, don't need to explicitly include the math library
|
|
||||||
else ()
|
|
||||||
set(LUA_LIBRARIES "${LUA_LIBRARY}")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
|
||||||
# At least 5.[012] have different ways to express the version
|
|
||||||
# so all of them need to be tested. Lua 5.2 defines LUA_VERSION
|
|
||||||
# and LUA_RELEASE as joined by the C preprocessor, so avoid those.
|
|
||||||
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_strings
|
|
||||||
REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
|
|
||||||
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};")
|
|
||||||
if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$")
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};")
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};")
|
|
||||||
set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
|
|
||||||
else ()
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
|
|
||||||
if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$")
|
|
||||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
|
|
||||||
endif ()
|
|
||||||
string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}")
|
|
||||||
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}")
|
|
||||||
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
unset(lua_version_strings)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
|
|
||||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
|
||||||
VERSION_VAR LUA_VERSION_STRING)
|
|
||||||
|
|
||||||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)
|
|
|
@ -19,7 +19,7 @@ function test_undead_reserve_self()
|
||||||
assert_equal(1, u1:get_item("log"))
|
assert_equal(1, u1:get_item("log"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function skip_undead_reserve_other()
|
function test_undead_reserve_other()
|
||||||
local r1 = region.create(0, 0, "plain")
|
local r1 = region.create(0, 0, "plain")
|
||||||
local f1 = faction.create("human")
|
local f1 = faction.create("human")
|
||||||
local u1 = unit.create(f1, r1, 1)
|
local u1 = unit.create(f1, r1, 1)
|
||||||
|
@ -28,9 +28,10 @@ function skip_undead_reserve_other()
|
||||||
u1.race = "undead"
|
u1.race = "undead"
|
||||||
u1:clear_orders()
|
u1:clear_orders()
|
||||||
u1:add_order("RESERVIERE 1 Holz")
|
u1:add_order("RESERVIERE 1 Holz")
|
||||||
|
u1.name = 'Xolgrim'
|
||||||
process_orders()
|
process_orders()
|
||||||
|
|
||||||
-- Intermittent Failure (clang): expected 0 but was 2
|
-- Intermittent Failure: expected 0 but was 2
|
||||||
assert_equal(0, u1:get_item("log"))
|
assert_equal(0, u1:get_item("log"))
|
||||||
|
|
||||||
assert_equal(2, u2:get_item("log"))
|
assert_equal(2, u2:get_item("log"))
|
||||||
|
|
|
@ -260,6 +260,7 @@ static int *keys_update(int *base, int key, int val)
|
||||||
ptrdiff_t diff = kv - base;
|
ptrdiff_t diff = kv - base;
|
||||||
sz = keys_size(n + 1);
|
sz = keys_size(n + 1);
|
||||||
base = realloc(base, (sz * 2 + 1) * sizeof(int));
|
base = realloc(base, (sz * 2 + 1) * sizeof(int));
|
||||||
|
if (!base) abort();
|
||||||
kv = base + diff;
|
kv = base + diff;
|
||||||
}
|
}
|
||||||
base[0] = n + 1;
|
base[0] = n + 1;
|
||||||
|
|
|
@ -107,10 +107,10 @@ int findoption(const char *s, const struct locale *lang)
|
||||||
/* -- Erschaffung neuer Einheiten ------------------------------ */
|
/* -- Erschaffung neuer Einheiten ------------------------------ */
|
||||||
|
|
||||||
static int *forbidden_ids;
|
static int *forbidden_ids;
|
||||||
|
static const char *forbidden[] = { "t", "te", "tem", "temp", NULL };
|
||||||
|
|
||||||
bool forbiddenid(int id)
|
bool forbiddenid(int id)
|
||||||
{
|
{
|
||||||
static const char *forbidden[] = { "t", "te", "tem", "temp", NULL };
|
|
||||||
static size_t len;
|
static size_t len;
|
||||||
size_t i;
|
size_t i;
|
||||||
if (id <= 0) {
|
if (id <= 0) {
|
||||||
|
|
|
@ -40,8 +40,9 @@
|
||||||
#define FACTION_UID_VERSION 362 /* f->uid contains a database id */
|
#define FACTION_UID_VERSION 362 /* f->uid contains a database id */
|
||||||
#define CRYPT_VERSION 363 /* passwords are encrypted */
|
#define CRYPT_VERSION 363 /* passwords are encrypted */
|
||||||
#define FAMILIAR_FIXMAGE_VERSION 364 /* familiar links are fixed */
|
#define FAMILIAR_FIXMAGE_VERSION 364 /* familiar links are fixed */
|
||||||
|
#define FAMILIAR_FIXSPELLBOOK_VERSION 365 /* familiar spells are fixed */
|
||||||
|
|
||||||
#define RELEASE_VERSION FAMILIAR_FIXMAGE_VERSION /* current datafile */
|
#define RELEASE_VERSION FAMILIAR_FIXSPELLBOOK_VERSION /* current datafile */
|
||||||
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
|
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
|
||||||
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "unit.h"
|
#include "unit.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "faction.h"
|
#include "faction.h"
|
||||||
|
#include "race.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
#include "skill.h"
|
#include "skill.h"
|
||||||
|
|
||||||
|
@ -42,6 +43,30 @@ void test_reservation(CuTest *tc) {
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_pool_get_item(CuTest *tc) {
|
||||||
|
unit *u1, *u2;
|
||||||
|
faction *f;
|
||||||
|
region *r;
|
||||||
|
race *rc;
|
||||||
|
struct resource_type *rtype;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
rtype = rt_get_or_create("money");
|
||||||
|
rtype->flags |= RTF_POOLED;
|
||||||
|
it_get_or_create(rtype);
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
r = test_create_plain(0, 0);
|
||||||
|
u1 = test_create_unit(f, r);
|
||||||
|
u_setrace(u1, rc = test_create_race("undead"));
|
||||||
|
rc->ec_flags &= ~ECF_GETITEM;
|
||||||
|
u2 = test_create_unit(f, r);
|
||||||
|
i_change(&u2->items, rtype->itype, 2);
|
||||||
|
CuAssertIntEquals(tc, 0, get_pooled(u1, rtype, GET_DEFAULT, 1));
|
||||||
|
CuAssertIntEquals(tc, 0, i_get(u1->items, rtype->itype));
|
||||||
|
CuAssertIntEquals(tc, 2, i_get(u2->items, rtype->itype));
|
||||||
|
test_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
void test_pool(CuTest *tc) {
|
void test_pool(CuTest *tc) {
|
||||||
unit *u1, *u2, *u3;
|
unit *u1, *u2, *u3;
|
||||||
faction *f;
|
faction *f;
|
||||||
|
@ -49,11 +74,11 @@ void test_pool(CuTest *tc) {
|
||||||
struct resource_type *rtype;
|
struct resource_type *rtype;
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
test_create_world();
|
|
||||||
rtype = rt_get_or_create("money");
|
rtype = rt_get_or_create("money");
|
||||||
|
rtype->flags |= RTF_POOLED;
|
||||||
it_get_or_create(rtype);
|
it_get_or_create(rtype);
|
||||||
f = test_create_faction(NULL);
|
f = test_create_faction(NULL);
|
||||||
r = findregion(0, 0);
|
r = test_create_plain(0, 0);
|
||||||
assert(r && f && rtype && rtype->itype);
|
assert(r && f && rtype && rtype->itype);
|
||||||
u1 = test_create_unit(f, r);
|
u1 = test_create_unit(f, r);
|
||||||
u2 = test_create_unit(f, r);
|
u2 = test_create_unit(f, r);
|
||||||
|
@ -188,6 +213,7 @@ CuSuite *get_pool_suite(void)
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_reservation);
|
SUITE_ADD_TEST(suite, test_reservation);
|
||||||
SUITE_ADD_TEST(suite, test_pool);
|
SUITE_ADD_TEST(suite, test_pool);
|
||||||
|
SUITE_ADD_TEST(suite, test_pool_get_item);
|
||||||
SUITE_ADD_TEST(suite, test_pool_bug_2042);
|
SUITE_ADD_TEST(suite, test_pool_bug_2042);
|
||||||
SUITE_ADD_TEST(suite, test_pool_use);
|
SUITE_ADD_TEST(suite, test_pool_use);
|
||||||
SUITE_ADD_TEST(suite, test_change_resource);
|
SUITE_ADD_TEST(suite, test_change_resource);
|
||||||
|
|
|
@ -1528,7 +1528,7 @@ int read_game(gamedata *data)
|
||||||
if (data->version < FAMILIAR_FIX_VERSION) {
|
if (data->version < FAMILIAR_FIX_VERSION) {
|
||||||
fix_familiars(fix_fam_triggers);
|
fix_familiars(fix_fam_triggers);
|
||||||
}
|
}
|
||||||
if (data->version < FAMILIAR_FIXMAGE_VERSION) {
|
if (data->version < FAMILIAR_FIXSPELLBOOK_VERSION) {
|
||||||
fix_familiars(fix_fam_mage);
|
fix_familiars(fix_fam_mage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -982,9 +982,8 @@ void set_number(unit * u, int count)
|
||||||
void remove_skill(unit * u, skill_t sk)
|
void remove_skill(unit * u, skill_t sk)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
skill *sv;
|
|
||||||
for (i = 0; i != u->skill_size; ++i) {
|
for (i = 0; i != u->skill_size; ++i) {
|
||||||
sv = u->skills + i;
|
skill *sv = u->skills + i;
|
||||||
if (sv->id == sk) {
|
if (sv->id == sk) {
|
||||||
if (u->skill_size - i - 1 > 0) {
|
if (u->skill_size - i - 1 > 0) {
|
||||||
memmove(sv, sv + 1, (u->skill_size - i - 1) * sizeof(skill));
|
memmove(sv, sv + 1, (u->skill_size - i - 1) * sizeof(skill));
|
||||||
|
|
|
@ -3434,10 +3434,7 @@ static int reserve_i(unit * u, struct order *ord, int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
int reserve_cmd(unit * u, struct order *ord) {
|
int reserve_cmd(unit * u, struct order *ord) {
|
||||||
if ((u_race(u)->ec_flags & ECF_GETITEM)) {
|
return reserve_i(u, ord, GET_DEFAULT);
|
||||||
return reserve_i(u, ord, GET_DEFAULT);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int reserve_self(unit * u, struct order *ord) {
|
int reserve_self(unit * u, struct order *ord) {
|
||||||
|
|
|
@ -2090,7 +2090,7 @@ castorder *create_castorder(castorder * co, unit *caster, unit * familiar, const
|
||||||
co->sp = sp;
|
co->sp = sp;
|
||||||
co->level = lev;
|
co->level = lev;
|
||||||
co->force = MagicPower(force);
|
co->force = MagicPower(force);
|
||||||
co->_rtarget = r ? r : (familiar ? familiar->region : (caster ? caster->region : 0));
|
co->_rtarget = r ? r : (familiar ? familiar->region : (caster ? caster->region : NULL));
|
||||||
co->distance = range;
|
co->distance = range;
|
||||||
co->order = copy_order(ord);
|
co->order = copy_order(ord);
|
||||||
co->par = p;
|
co->par = p;
|
||||||
|
|
|
@ -637,6 +637,7 @@ void move_ship(ship * sh, region * from, region * to, region_list * route)
|
||||||
unit **iunit = &from->units;
|
unit **iunit = &from->units;
|
||||||
unit **ulist = &to->units;
|
unit **ulist = &to->units;
|
||||||
|
|
||||||
|
assert(sh);
|
||||||
if (from != to) {
|
if (from != to) {
|
||||||
translist(&from->ships, &to->ships, sh);
|
translist(&from->ships, &to->ships, sh);
|
||||||
sh->region = to;
|
sh->region = to;
|
||||||
|
@ -1676,10 +1677,9 @@ static bool ship_ready(const region * r, unit * u, order * ord)
|
||||||
unit *owner_buildingtyp(const region * r, const building_type * bt)
|
unit *owner_buildingtyp(const region * r, const building_type * bt)
|
||||||
{
|
{
|
||||||
building *b;
|
building *b;
|
||||||
unit *owner;
|
|
||||||
|
|
||||||
for (b = rbuildings(r); b; b = b->next) {
|
for (b = rbuildings(r); b; b = b->next) {
|
||||||
owner = building_owner(b);
|
unit *owner = building_owner(b);
|
||||||
if (b->type == bt && owner != NULL) {
|
if (b->type == bt && owner != NULL) {
|
||||||
if (building_finished(b)) {
|
if (building_finished(b)) {
|
||||||
return owner;
|
return owner;
|
||||||
|
@ -1971,7 +1971,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
|
||||||
/* Hafengebühren ? */
|
/* Hafengebühren ? */
|
||||||
|
|
||||||
harbourmaster = owner_buildingtyp(current_point, bt_find("harbour"));
|
harbourmaster = owner_buildingtyp(current_point, bt_find("harbour"));
|
||||||
if (sh && harbourmaster != NULL) {
|
if (harbourmaster != NULL) {
|
||||||
item *itm;
|
item *itm;
|
||||||
unit *u2;
|
unit *u2;
|
||||||
item *trans = NULL;
|
item *trans = NULL;
|
||||||
|
|
22
src/report.c
22
src/report.c
|
@ -432,7 +432,7 @@ void nr_spell_syntax(char *buf, size_t size, spellbook_entry * sbe, const struct
|
||||||
|
|
||||||
void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *lang)
|
void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *lang)
|
||||||
{
|
{
|
||||||
int k, itemanz, costtyp;
|
int k;
|
||||||
bool cont;
|
bool cont;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
const spell *sp = spellref_get(&sbe->spref);
|
const spell *sp = spellref_get(&sbe->spref);
|
||||||
|
@ -471,8 +471,8 @@ void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *la
|
||||||
paragraph(out, LOC(lang, "nr_spell_components"), 0, 0, 0);
|
paragraph(out, LOC(lang, "nr_spell_components"), 0, 0, 0);
|
||||||
for (k = 0; sp->components[k].type; ++k) {
|
for (k = 0; sp->components[k].type; ++k) {
|
||||||
const resource_type *rtype = sp->components[k].type;
|
const resource_type *rtype = sp->components[k].type;
|
||||||
itemanz = sp->components[k].amount;
|
int itemanz = sp->components[k].amount;
|
||||||
costtyp = sp->components[k].cost;
|
int costtyp = sp->components[k].cost;
|
||||||
if (itemanz > 0) {
|
if (itemanz > 0) {
|
||||||
sbs_init(&sbs, buf, sizeof(buf));
|
sbs_init(&sbs, buf, sizeof(buf));
|
||||||
if (sp->sptyp & SPELLLEVEL) {
|
if (sp->sptyp & SPELLLEVEL) {
|
||||||
|
@ -519,7 +519,6 @@ static void
|
||||||
nr_curses_i(struct stream *out, int indent, const faction *viewer, objtype_t typ, const void *obj, attrib *a, int self)
|
nr_curses_i(struct stream *out, int indent, const faction *viewer, objtype_t typ, const void *obj, attrib *a, int self)
|
||||||
{
|
{
|
||||||
for (; a; a = a->next) {
|
for (; a; a = a->next) {
|
||||||
char buf[4096];
|
|
||||||
message *msg = 0;
|
message *msg = 0;
|
||||||
|
|
||||||
if (a->type == &at_curse) {
|
if (a->type == &at_curse) {
|
||||||
|
@ -536,6 +535,7 @@ nr_curses_i(struct stream *out, int indent, const faction *viewer, objtype_t typ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg) {
|
if (msg) {
|
||||||
|
char buf[4096];
|
||||||
newline(out);
|
newline(out);
|
||||||
nr_render(msg, viewer->locale, buf, sizeof(buf), viewer);
|
nr_render(msg, viewer->locale, buf, sizeof(buf), viewer);
|
||||||
paragraph(out, buf, indent, 2, 0);
|
paragraph(out, buf, indent, 2, 0);
|
||||||
|
@ -847,7 +847,6 @@ static void report_region_resource(sbstring *sbp, const struct locale *lang, con
|
||||||
static void report_region_description(struct stream *out, const region * r, faction * f, const bool see[])
|
static void report_region_description(struct stream *out, const region * r, faction * f, const bool see[])
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
bool dh;
|
|
||||||
int trees;
|
int trees;
|
||||||
int saplings;
|
int saplings;
|
||||||
attrib *a;
|
attrib *a;
|
||||||
|
@ -986,6 +985,7 @@ static void report_region_description(struct stream *out, const region * r, fact
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int d, nrd = 0;
|
int d, nrd = 0;
|
||||||
|
bool dh = false;
|
||||||
|
|
||||||
/* Nachbarregionen, die gesehen werden, ermitteln */
|
/* Nachbarregionen, die gesehen werden, ermitteln */
|
||||||
for (d = 0; d != MAXDIRECTIONS; d++) {
|
for (d = 0; d != MAXDIRECTIONS; d++) {
|
||||||
|
@ -994,7 +994,6 @@ static void report_region_description(struct stream *out, const region * r, fact
|
||||||
}
|
}
|
||||||
|
|
||||||
/* list directions */
|
/* list directions */
|
||||||
dh = false;
|
|
||||||
for (d = 0; d != MAXDIRECTIONS; d++) {
|
for (d = 0; d != MAXDIRECTIONS; d++) {
|
||||||
if (see[d]) {
|
if (see[d]) {
|
||||||
region *r2 = rconnect(r, d);
|
region *r2 = rconnect(r, d);
|
||||||
|
@ -1037,7 +1036,6 @@ static void report_region_description(struct stream *out, const region * r, fact
|
||||||
sbs_strcat(&sbs, " (\"");
|
sbs_strcat(&sbs, " (\"");
|
||||||
sbs_strcat(&sbs, LOC(f->locale, spd->keyword));
|
sbs_strcat(&sbs, LOC(f->locale, spd->keyword));
|
||||||
sbs_strcat(&sbs, "\").");
|
sbs_strcat(&sbs, "\").");
|
||||||
dh = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pump_paragraph(&sbs, out, REPORTWIDTH, true);
|
pump_paragraph(&sbs, out, REPORTWIDTH, true);
|
||||||
|
@ -1889,7 +1887,6 @@ static void cb_write_travelthru(region *r, unit *u, void *cbdata) {
|
||||||
void report_travelthru(struct stream *out, region *r, const faction *f)
|
void report_travelthru(struct stream *out, region *r, const faction *f)
|
||||||
{
|
{
|
||||||
int maxtravel;
|
int maxtravel;
|
||||||
char buf[8192];
|
|
||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
assert(f);
|
assert(f);
|
||||||
|
@ -1901,6 +1898,7 @@ void report_travelthru(struct stream *out, region *r, const faction *f)
|
||||||
maxtravel = count_travelthru(r, f);
|
maxtravel = count_travelthru(r, f);
|
||||||
if (maxtravel > 0) {
|
if (maxtravel > 0) {
|
||||||
cb_data cbdata;
|
cb_data cbdata;
|
||||||
|
char buf[8192];
|
||||||
|
|
||||||
init_cb(&cbdata, out, buf, sizeof(buf), f);
|
init_cb(&cbdata, out, buf, sizeof(buf), f);
|
||||||
cbdata.maxtravel = maxtravel;
|
cbdata.maxtravel = maxtravel;
|
||||||
|
@ -1960,12 +1958,11 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
|
|
||||||
if (f->age <= 2) {
|
if (f->age <= 2) {
|
||||||
const char *email;
|
const char *email;
|
||||||
const char *subject;
|
|
||||||
email = config_get("game.email");
|
email = config_get("game.email");
|
||||||
if (!email)
|
if (!email)
|
||||||
log_error("game.email not set");
|
log_error("game.email not set");
|
||||||
else {
|
else {
|
||||||
subject = get_mailcmd(f->locale);
|
const char *subject = get_mailcmd(f->locale);
|
||||||
|
|
||||||
m = msg_message("newbie_info_game", "email subject", email, subject);
|
m = msg_message("newbie_info_game", "email subject", email, subject);
|
||||||
if (m) {
|
if (m) {
|
||||||
|
@ -2068,9 +2065,9 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
for (a = a_find(f->attribs, &at_showitem); a && a->type == &at_showitem;
|
for (a = a_find(f->attribs, &at_showitem); a && a->type == &at_showitem;
|
||||||
a = a->next) {
|
a = a->next) {
|
||||||
const item_type *itype = (const item_type *)a->data.v;
|
const item_type *itype = (const item_type *)a->data.v;
|
||||||
const char *description = NULL;
|
|
||||||
if (itype) {
|
if (itype) {
|
||||||
const char *pname = resourcename(itype->rtype, 0);
|
const char *pname = resourcename(itype->rtype, 0);
|
||||||
|
const char *description;
|
||||||
|
|
||||||
if (ch == 0) {
|
if (ch == 0) {
|
||||||
newline(out);
|
newline(out);
|
||||||
|
@ -2102,8 +2099,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
}
|
}
|
||||||
centre(out, buf, true);
|
centre(out, buf, true);
|
||||||
newline(out);
|
newline(out);
|
||||||
description = mkname("describe", pname);
|
description = LOC(f->locale, mkname("describe", pname));
|
||||||
description = LOC(f->locale, description);
|
|
||||||
centre(out, description, true);
|
centre(out, description, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,11 +319,11 @@ report_items(const unit *u, item * result, int size, const unit * owner,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (itm = items; itm; itm = itm->next) {
|
for (itm = items; itm; itm = itm->next) {
|
||||||
item *ishow;
|
|
||||||
const char *ic;
|
const char *ic;
|
||||||
|
|
||||||
report_item(owner, itm, viewer, NULL, &ic, NULL, false);
|
report_item(owner, itm, viewer, NULL, &ic, NULL, false);
|
||||||
if (ic && *ic) {
|
if (ic && *ic) {
|
||||||
|
item *ishow;
|
||||||
for (ishow = result; ishow != result + n; ++ishow) {
|
for (ishow = result; ishow != result + n; ++ishow) {
|
||||||
const char *sc;
|
const char *sc;
|
||||||
|
|
||||||
|
@ -1783,9 +1783,9 @@ static void var_free_regions(variant x) /*-V524 */
|
||||||
|
|
||||||
const char *trailinto(const region * r, const struct locale *lang)
|
const char *trailinto(const region * r, const struct locale *lang)
|
||||||
{
|
{
|
||||||
static char ref[32];
|
|
||||||
const char *s;
|
|
||||||
if (r) {
|
if (r) {
|
||||||
|
static char ref[32];
|
||||||
|
const char *s;
|
||||||
const char *tname = terrain_name(r);
|
const char *tname = terrain_name(r);
|
||||||
size_t sz;
|
size_t sz;
|
||||||
|
|
||||||
|
|
|
@ -601,14 +601,14 @@ static void test_prepare_lighthouse_owners(CuTest *tc)
|
||||||
f = test_create_faction(NULL);
|
f = test_create_faction(NULL);
|
||||||
r1 = test_create_region(0, 0, t_plain);
|
r1 = test_create_region(0, 0, t_plain);
|
||||||
r2 = test_create_region(1, 0, t_ocean);
|
r2 = test_create_region(1, 0, t_ocean);
|
||||||
r3 = test_create_region(2, 0, t_ocean);
|
test_create_region(2, 0, t_ocean);
|
||||||
r3 = test_create_region(3, 0, t_ocean);
|
r3 = test_create_region(3, 0, t_ocean);
|
||||||
btype = test_create_buildingtype("lighthouse");
|
btype = test_create_buildingtype("lighthouse");
|
||||||
b = test_create_building(r1, btype);
|
b = test_create_building(r1, btype);
|
||||||
b->flags |= BLD_MAINTAINED;
|
b->flags |= BLD_MAINTAINED;
|
||||||
b->size = 10;
|
b->size = 10;
|
||||||
update_lighthouse(b);
|
update_lighthouse(b);
|
||||||
u = test_create_unit(f, r1);
|
test_create_unit(f, r1);
|
||||||
u = test_create_unit(test_create_faction(NULL), r1);
|
u = test_create_unit(test_create_faction(NULL), r1);
|
||||||
u->building = b;
|
u->building = b;
|
||||||
region_set_owner(b->region, f, 0);
|
region_set_owner(b->region, f, 0);
|
||||||
|
|
12
src/spells.c
12
src/spells.c
|
@ -2346,7 +2346,6 @@ static int sp_earthquake(castorder * co)
|
||||||
static void patzer_peasantmob(const castorder * co)
|
static void patzer_peasantmob(const castorder * co)
|
||||||
{
|
{
|
||||||
unit *u;
|
unit *u;
|
||||||
attrib *a;
|
|
||||||
region *r;
|
region *r;
|
||||||
unit *mage = co_get_magician(co);
|
unit *mage = co_get_magician(co);
|
||||||
r = mage->region->land ? mage->region : co_get_region(co);
|
r = mage->region->land ? mage->region : co_get_region(co);
|
||||||
|
@ -2355,6 +2354,7 @@ static void patzer_peasantmob(const castorder * co)
|
||||||
faction *f = get_monsters();
|
faction *f = get_monsters();
|
||||||
const struct locale *lang = f->locale;
|
const struct locale *lang = f->locale;
|
||||||
message *msg;
|
message *msg;
|
||||||
|
attrib *a;
|
||||||
int anteil, n;
|
int anteil, n;
|
||||||
|
|
||||||
anteil = 6 + rng_int() % 4;
|
anteil = 6 + rng_int() % 4;
|
||||||
|
@ -2410,7 +2410,6 @@ static void patzer_peasantmob(const castorder * co)
|
||||||
static int sp_forest_fire(castorder * co)
|
static int sp_forest_fire(castorder * co)
|
||||||
{
|
{
|
||||||
unit *u;
|
unit *u;
|
||||||
region *nr;
|
|
||||||
direction_t i;
|
direction_t i;
|
||||||
region *r = co_get_region(co);
|
region *r = co_get_region(co);
|
||||||
unit *caster = co_get_caster(co);
|
unit *caster = co_get_caster(co);
|
||||||
|
@ -2442,7 +2441,7 @@ static int sp_forest_fire(castorder * co)
|
||||||
msg_release(msg);
|
msg_release(msg);
|
||||||
|
|
||||||
for (i = 0; i < MAXDIRECTIONS; i++) {
|
for (i = 0; i < MAXDIRECTIONS; i++) {
|
||||||
nr = rconnect(r, i);
|
region *nr = rconnect(r, i);
|
||||||
assert(nr);
|
assert(nr);
|
||||||
destroyed = 0;
|
destroyed = 0;
|
||||||
vernichtet_schoesslinge = 0;
|
vernichtet_schoesslinge = 0;
|
||||||
|
@ -5629,7 +5628,6 @@ int sp_disruptastral(castorder * co)
|
||||||
attrib *a;
|
attrib *a;
|
||||||
double effect;
|
double effect;
|
||||||
region *r2 = rl2->data;
|
region *r2 = rl2->data;
|
||||||
spec_direction *sd;
|
|
||||||
int inhab_regions = 0;
|
int inhab_regions = 0;
|
||||||
region_list *trl = NULL;
|
region_list *trl = NULL;
|
||||||
|
|
||||||
|
@ -5649,7 +5647,7 @@ int sp_disruptastral(castorder * co)
|
||||||
|
|
||||||
while (a != NULL && a->type == &at_direction) {
|
while (a != NULL && a->type == &at_direction) {
|
||||||
attrib *a2 = a->next;
|
attrib *a2 = a->next;
|
||||||
sd = (spec_direction *)(a->data.v);
|
spec_direction *sd = (spec_direction *)(a->data.v);
|
||||||
if (sd->duration != -1)
|
if (sd->duration != -1)
|
||||||
a_remove(&r->attribs, a);
|
a_remove(&r->attribs, a);
|
||||||
a = a2;
|
a = a2;
|
||||||
|
@ -6161,7 +6159,6 @@ int sp_speed2(castorder * co)
|
||||||
*/
|
*/
|
||||||
int sp_break_curse(castorder * co)
|
int sp_break_curse(castorder * co)
|
||||||
{
|
{
|
||||||
attrib **ap;
|
|
||||||
int obj;
|
int obj;
|
||||||
curse *c;
|
curse *c;
|
||||||
region *r = co_get_region(co);
|
region *r = co_get_region(co);
|
||||||
|
@ -6169,7 +6166,6 @@ int sp_break_curse(castorder * co)
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
double force = co->force;
|
double force = co->force;
|
||||||
spellparameter *pa = co->par;
|
spellparameter *pa = co->par;
|
||||||
const char *ts = NULL;
|
|
||||||
|
|
||||||
if (pa->length < 2) {
|
if (pa->length < 2) {
|
||||||
/* Das Zielobjekt wurde vergessen */
|
/* Das Zielobjekt wurde vergessen */
|
||||||
|
@ -6186,6 +6182,8 @@ int sp_break_curse(castorder * co)
|
||||||
"unit region command", mage, mage->region, co->order));
|
"unit region command", mage, mage->region, co->order));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
const char *ts = NULL;
|
||||||
|
attrib **ap;
|
||||||
switch (obj) {
|
switch (obj) {
|
||||||
case SPP_REGION:
|
case SPP_REGION:
|
||||||
ap = &r->attribs;
|
ap = &r->attribs;
|
||||||
|
|
|
@ -205,15 +205,17 @@ log_t *log_to_file(int flags, FILE *out) {
|
||||||
return log_create(flags, out, log_stdio);
|
return log_create(flags, out, log_stdio);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
/*
|
||||||
/* https://social.msdn.microsoft.com/Forums/vstudio/en-US/53a4fd75-9f97-48b2-aa63-2e2e5a15efa3/stdcversion-problem?forum=vclanguage */
|
* Notes for va_copy compatibility:
|
||||||
#define VA_COPY(c, a) va_copy(c, a)
|
* MSVC: https://social.msdn.microsoft.com/Forums/vstudio/en-US/53a4fd75-9f97-48b2-aa63-2e2e5a15efa3/stdcversion-problem?forum=vclanguage
|
||||||
#elif !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
|
* GNU: https://www.gnu.org/software/libc/manual/html_node/Argument-Macros.html
|
||||||
/* GNU only: https://www.gnu.org/software/libc/manual/html_node/Argument-Macros.html */
|
*/
|
||||||
#define VA_COPY(c, a) __va_copy(c, a)
|
static void vlog(log_t *lg, int level, const char *format, va_list args) {
|
||||||
#else
|
va_list copy;
|
||||||
#define VA_COPY(c, a) va_copy(c, a)
|
va_copy(copy, args);
|
||||||
#endif
|
lg->log(lg->data, level, NULL, format, copy);
|
||||||
|
va_end(copy);
|
||||||
|
}
|
||||||
|
|
||||||
static void log_write(int flags, const char *module, const char *format, va_list args) {
|
static void log_write(int flags, const char *module, const char *format, va_list args) {
|
||||||
log_t *lg;
|
log_t *lg;
|
||||||
|
@ -225,10 +227,7 @@ static void log_write(int flags, const char *module, const char *format, va_list
|
||||||
dupe = check_dupe(format, level);
|
dupe = check_dupe(format, level);
|
||||||
}
|
}
|
||||||
if (dupe == 0) {
|
if (dupe == 0) {
|
||||||
va_list copy;
|
vlog(lg, level, format, args);
|
||||||
VA_COPY(copy, args);
|
|
||||||
lg->log(lg->data, level, NULL, format, copy);
|
|
||||||
va_end(copy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifndef PATH_MAX
|
||||||
/* @see https://insanecoding.blogspot.no/2007/11/pathmax-simply-isnt.html */
|
/* @see https://insanecoding.blogspot.no/2007/11/pathmax-simply-isnt.html */
|
||||||
#define PATH_MAX 260
|
#define PATH_MAX 260
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue