forked from github/server
Merge branch 'develop' of github.com:eressea/server into develop
This commit is contained in:
commit
d802b297e9
|
@ -30,6 +30,9 @@ CHECK_SYMBOL_EXISTS (sleep "unistd.h" HAVE_SLEEP)
|
||||||
CHECK_SYMBOL_EXISTS (usleep "unistd.h" HAVE_USLEEP)
|
CHECK_SYMBOL_EXISTS (usleep "unistd.h" HAVE_USLEEP)
|
||||||
CHECK_SYMBOL_EXISTS (access "unistd.h" HAVE_ACCESS)
|
CHECK_SYMBOL_EXISTS (access "unistd.h" HAVE_ACCESS)
|
||||||
ENDIF(HAVE_UNISTD_H)
|
ENDIF(HAVE_UNISTD_H)
|
||||||
|
CHECK_SYMBOL_EXISTS (strlcpy "string.h" HAVE_STRLCPY)
|
||||||
|
CHECK_SYMBOL_EXISTS (strlcat "string.h" HAVE_STRLCAT)
|
||||||
|
CHECK_SYMBOL_EXISTS (slprintf "string.h" HAVE_SLPRINTF)
|
||||||
CHECK_SYMBOL_EXISTS (strcasecmp "string.h" HAVE_STRCASECMP)
|
CHECK_SYMBOL_EXISTS (strcasecmp "string.h" HAVE_STRCASECMP)
|
||||||
CHECK_SYMBOL_EXISTS (strncasecmp "string.h" HAVE_STRNCASECMP)
|
CHECK_SYMBOL_EXISTS (strncasecmp "string.h" HAVE_STRNCASECMP)
|
||||||
CHECK_SYMBOL_EXISTS (_strlwr "string.h" HAVE__STRLWR)
|
CHECK_SYMBOL_EXISTS (_strlwr "string.h" HAVE__STRLWR)
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#cmakedefine HAVE_MEMICMP 1
|
#cmakedefine HAVE_MEMICMP 1
|
||||||
#cmakedefine HAVE__STRLWR 1
|
#cmakedefine HAVE__STRLWR 1
|
||||||
#cmakedefine HAVE_STRLWR 1
|
#cmakedefine HAVE_STRLWR 1
|
||||||
|
#cmakedefine HAVE_STRLCPY 1
|
||||||
|
#cmakedefine HAVE_STRLCAT 1
|
||||||
|
#cmakedefine HAVE_SLPRINTF 1
|
||||||
#cmakedefine HAVE_SYS_STAT_MKDIR 1
|
#cmakedefine HAVE_SYS_STAT_MKDIR 1
|
||||||
#cmakedefine HAVE_DIRECT_MKDIR 1
|
#cmakedefine HAVE_DIRECT_MKDIR 1
|
||||||
#cmakedefine HAVE_DIRECT__MKDIR 1
|
#cmakedefine HAVE_DIRECT__MKDIR 1
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
<param name="hunger.long" value="1"/>
|
<param name="hunger.long" value="1"/>
|
||||||
<param name="init_spells" value="0"/>
|
<param name="init_spells" value="0"/>
|
||||||
<param name="rules.reserve.twophase" value="1"/>
|
<param name="rules.reserve.twophase" value="1"/>
|
||||||
|
<param name="rules.give.max_men" value="10000"/>
|
||||||
<param name="rules.check_overload" value="0"/>
|
<param name="rules.check_overload" value="0"/>
|
||||||
<param name="rules.limit.faction" value="2500"/>
|
<param name="rules.limit.faction" value="2500"/>
|
||||||
<param name="rules.maxskills.magic" value="5"/>
|
<param name="rules.maxskills.magic" value="5"/>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<resource name="money">
|
<resource name="money">
|
||||||
<item weight="0"/>
|
<item weight="1"/>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="ao_healing" appearance="amulet">
|
<resource name="ao_healing" appearance="amulet">
|
||||||
|
|
6
s/build
6
s/build
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
ROOT=$(pwd)
|
ROOT=`pwd`
|
||||||
while [ ! -d $ROOT/.git ]; do
|
while [ ! -d $ROOT/.git ]; do
|
||||||
ROOT=$(dirname $ROOT)
|
ROOT=`dirname $ROOT`
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z $BUILD ] && BUILD=Debug
|
[ -z $BUILD ] && BUILD=Debug
|
||||||
|
@ -11,7 +11,7 @@ MACHINE=`uname -m`
|
||||||
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
|
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
|
||||||
BIN_DIR="build-$MACHINE-$CC-$BUILD"
|
BIN_DIR="build-$MACHINE-$CC-$BUILD"
|
||||||
|
|
||||||
[ -z "$JOBS" ] && JOBS=$(nproc)
|
[ -z "$JOBS" ] && [ "" != "which nproc" ] && JOBS=`nproc`
|
||||||
DISTCC=`which distcc`
|
DISTCC=`which distcc`
|
||||||
if [ ! -z "$DISTCC" ] ; then
|
if [ ! -z "$DISTCC" ] ; then
|
||||||
JOBS=`distcc -j`
|
JOBS=`distcc -j`
|
||||||
|
|
|
@ -4,5 +4,5 @@ if config.install then
|
||||||
end
|
end
|
||||||
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||||
require 'eressea'
|
require 'eressea'
|
||||||
require 'eressea.xmlconf'
|
require 'eressea.xmlconf' -- read xml data
|
||||||
return require('eressea.rules')
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ function wedding.update()
|
||||||
if peacegate and hellgate then
|
if peacegate and hellgate then
|
||||||
wedding_exchange(peacegate, hellgate)
|
wedding_exchange(peacegate, hellgate)
|
||||||
else
|
else
|
||||||
eressea.log.error("hellgate or peacegate not found!", hellgate, peacegate)
|
eressea.log.error("hellgate or peacegate not found!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ path = 'scripts'
|
||||||
if config.install then
|
if config.install then
|
||||||
path = config.install .. '/' .. path
|
path = config.install .. '/' .. path
|
||||||
package.path = package.path .. ';' .. config.install .. '/lunit/?.lua'
|
package.path = package.path .. ';' .. config.install .. '/lunit/?.lua'
|
||||||
--needed to find lunit if not run form eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder)
|
--needed to find lunit if not run from eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder)
|
||||||
end
|
end
|
||||||
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||||
|
|
||||||
|
|
|
@ -712,7 +712,7 @@ function test_golem_use_four_iron()
|
||||||
assert_equal(4, u1:get_item("towershield"))
|
assert_equal(4, u1:get_item("towershield"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function skip_test_silver_weight_stops_movement()
|
function test_silver_weight_stops_movement()
|
||||||
local r1 = region.create(1, 1, "plain")
|
local r1 = region.create(1, 1, "plain")
|
||||||
local r2 = region.create(2, 1, "plain")
|
local r2 = region.create(2, 1, "plain")
|
||||||
region.create(3, 1, "plain")
|
region.create(3, 1, "plain")
|
||||||
|
@ -729,7 +729,7 @@ function skip_test_silver_weight_stops_movement()
|
||||||
assert_equal(r2, u1.region)
|
assert_equal(r2, u1.region)
|
||||||
end
|
end
|
||||||
|
|
||||||
function skip_test_silver_weight_stops_ship()
|
function test_silver_weight_stops_ship()
|
||||||
local r1 = region.create(1, 1, "ocean")
|
local r1 = region.create(1, 1, "ocean")
|
||||||
local r2 = region.create(2, 1, "ocean")
|
local r2 = region.create(2, 1, "ocean")
|
||||||
region.create(3, 1, "ocean")
|
region.create(3, 1, "ocean")
|
||||||
|
@ -771,15 +771,6 @@ function test_building_owner_can_enter_ship()
|
||||||
assert_equal(null, u1.building, "owner of the building can not go into a ship")
|
assert_equal(null, u1.building, "owner of the building can not go into a ship")
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_weightless_silver()
|
|
||||||
local r1 = region.create(1, 2, "plain")
|
|
||||||
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
|
||||||
local u1 = unit.create(f1, r1, 1)
|
|
||||||
assert_equal(1000, u1.weight)
|
|
||||||
u1:add_item("money", 540)
|
|
||||||
assert_equal(1000, u1.weight)
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_only_building_owner_can_set_not_paid()
|
function test_only_building_owner_can_set_not_paid()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||||
|
|
|
@ -5,7 +5,15 @@ module ('tests.eressea.faction', package.seeall, lunit.testcase)
|
||||||
local f
|
local f
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
|
conf = [[{
|
||||||
|
"races": {
|
||||||
|
"human" : {}
|
||||||
|
}
|
||||||
|
}]]
|
||||||
|
eressea.config.reset()
|
||||||
|
assert(eressea.config.parse(conf)==0)
|
||||||
f = faction.create("faction@eressea.de", "human", "de")
|
f = faction.create("faction@eressea.de", "human", "de")
|
||||||
|
assert(f~=nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_faction_flags()
|
function test_faction_flags()
|
||||||
|
|
|
@ -344,14 +344,14 @@ static int tolua_faction_create(lua_State * L)
|
||||||
const char *email = tolua_tostring(L, 1, 0);
|
const char *email = tolua_tostring(L, 1, 0);
|
||||||
const char *racename = tolua_tostring(L, 2, 0);
|
const char *racename = tolua_tostring(L, 2, 0);
|
||||||
const char *lang = tolua_tostring(L, 3, 0);
|
const char *lang = tolua_tostring(L, 3, 0);
|
||||||
struct locale *loc = get_locale(lang);
|
struct locale *loc = lang ? get_locale(lang) : default_locale;
|
||||||
faction *f = NULL;
|
faction *f = NULL;
|
||||||
const struct race *frace = rc_find(racename);
|
const struct race *frace = rc_find(racename ? racename : "human");
|
||||||
if (frace != NULL) {
|
if (frace != NULL) {
|
||||||
f = addfaction(email, NULL, frace, loc, 0);
|
f = addfaction(email, NULL, frace, loc, 0);
|
||||||
}
|
}
|
||||||
if (!f) {
|
if (!f) {
|
||||||
log_error("faction.create(%s, %s, %s)\n", email, racename, lang);
|
log_error("faction.create(%s, %s, %s)\n", email, frace->_name, locale_name(loc));
|
||||||
}
|
}
|
||||||
tolua_pushusertype(L, f, TOLUA_CAST "faction");
|
tolua_pushusertype(L, f, TOLUA_CAST "faction");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -48,10 +48,13 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* Wieviel Fremde eine Partei pro Woche aufnehmen kangiven */
|
/* Wieviel Fremde eine Partei pro Woche aufnehmen kangiven */
|
||||||
#define MAXNEWBIES 5
|
|
||||||
#define RESERVE_DONATIONS /* shall we reserve objects given to us by other factions? */
|
#define RESERVE_DONATIONS /* shall we reserve objects given to us by other factions? */
|
||||||
#define RESERVE_GIVE /* reserve anything that's given from one unit to another? */
|
#define RESERVE_GIVE /* reserve anything that's given from one unit to another? */
|
||||||
|
|
||||||
|
static int max_transfers(void) {
|
||||||
|
return get_param_int(global.parameters, "rules.give.max_men", 5);
|
||||||
|
}
|
||||||
|
|
||||||
static int GiveRestriction(void)
|
static int GiveRestriction(void)
|
||||||
{
|
{
|
||||||
static int value = -1;
|
static int value = -1;
|
||||||
|
@ -300,7 +303,7 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
error = 96;
|
error = 96;
|
||||||
}
|
}
|
||||||
else if (u->faction != u2->faction) {
|
else if (u->faction != u2->faction) {
|
||||||
if (u2->faction->newbies + n > MAXNEWBIES) {
|
if (u2->faction->newbies + n > max_transfers()) {
|
||||||
error = 129;
|
error = 129;
|
||||||
}
|
}
|
||||||
else if (u_race(u) != u2->faction->race) {
|
else if (u_race(u) != u2->faction->race) {
|
||||||
|
@ -473,7 +476,7 @@ void give_unit(unit * u, unit * u2, order * ord)
|
||||||
cmistake(u, ord, 105, MSG_COMMERCE);
|
cmistake(u, ord, 105, MSG_COMMERCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (u2->faction->newbies + n > MAXNEWBIES) {
|
if (u2->faction->newbies + n > max_transfers()) {
|
||||||
cmistake(u, ord, 129, MSG_COMMERCE);
|
cmistake(u, ord, 129, MSG_COMMERCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,36 @@ static void test_give_men(CuTest * tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_give_men_limit(CuTest * tc) {
|
||||||
|
struct give env;
|
||||||
|
message *msg;
|
||||||
|
test_cleanup();
|
||||||
|
env.f2 = test_create_faction(0);
|
||||||
|
env.f1 = test_create_faction(0);
|
||||||
|
setup_give(&env);
|
||||||
|
set_param(&global.parameters, "rules.give.max_men", "1");
|
||||||
|
|
||||||
|
/* below the limit, give men, increase newbies counter */
|
||||||
|
usetcontact(env.dst, env.src);
|
||||||
|
msg = give_men(1, env.src, env.dst, NULL);
|
||||||
|
CuAssertStrEquals(tc, "give_person", (const char *)msg->parameters[0].v);
|
||||||
|
CuAssertIntEquals(tc, 2, env.dst->number);
|
||||||
|
CuAssertIntEquals(tc, 0, env.src->number);
|
||||||
|
CuAssertIntEquals(tc, 1, env.f2->newbies);
|
||||||
|
msg_release(msg);
|
||||||
|
|
||||||
|
/* beyond the limit, do nothing */
|
||||||
|
usetcontact(env.src, env.dst);
|
||||||
|
msg = give_men(2, env.dst, env.src, NULL);
|
||||||
|
CuAssertStrEquals(tc, "error129", (const char *)msg->parameters[3].v);
|
||||||
|
CuAssertIntEquals(tc, 2, env.dst->number);
|
||||||
|
CuAssertIntEquals(tc, 0, env.src->number);
|
||||||
|
CuAssertIntEquals(tc, 0, env.f1->newbies);
|
||||||
|
msg_release(msg);
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_give_men_in_ocean(CuTest * tc) {
|
static void test_give_men_in_ocean(CuTest * tc) {
|
||||||
struct give env;
|
struct give env;
|
||||||
message * msg;
|
message * msg;
|
||||||
|
@ -247,6 +277,7 @@ CuSuite *get_give_suite(void)
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_give);
|
SUITE_ADD_TEST(suite, test_give);
|
||||||
SUITE_ADD_TEST(suite, test_give_men);
|
SUITE_ADD_TEST(suite, test_give_men);
|
||||||
|
SUITE_ADD_TEST(suite, test_give_men_limit);
|
||||||
SUITE_ADD_TEST(suite, test_give_men_in_ocean);
|
SUITE_ADD_TEST(suite, test_give_men_in_ocean);
|
||||||
SUITE_ADD_TEST(suite, test_give_men_none);
|
SUITE_ADD_TEST(suite, test_give_men_none);
|
||||||
SUITE_ADD_TEST(suite, test_give_men_too_many);
|
SUITE_ADD_TEST(suite, test_give_men_too_many);
|
||||||
|
|
|
@ -81,7 +81,6 @@ extern "C" {
|
||||||
#define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */
|
#define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */
|
||||||
#define NAMESIZE 128 /* max. Länge eines Namens, incl trailing 0 */
|
#define NAMESIZE 128 /* max. Länge eines Namens, incl trailing 0 */
|
||||||
#define IDSIZE 16 /* max. Länge einer no (als String), incl trailing 0 */
|
#define IDSIZE 16 /* max. Länge einer no (als String), incl trailing 0 */
|
||||||
#define KEYWORDSIZE 16 /* max. Länge eines Keyword, incl trailing 0 */
|
|
||||||
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. Länge der Strings, die
|
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. Länge der Strings, die
|
||||||
* von struct unitname, etc. zurückgegeben werden. ohne die 0 */
|
* von struct unitname, etc. zurückgegeben werden. ohne die 0 */
|
||||||
|
|
||||||
|
|
|
@ -611,8 +611,8 @@ int rpeasants(const region * r)
|
||||||
|
|
||||||
void rsetpeasants(region * r, int value)
|
void rsetpeasants(region * r, int value)
|
||||||
{
|
{
|
||||||
((r)->land ? ((r)->land->peasants =
|
if (r->land) r->land->peasants = value;
|
||||||
(value)) : (assert((value) >= 0), (value)), 0);
|
else assert(value>=0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rmoney(const region * r)
|
int rmoney(const region * r)
|
||||||
|
@ -634,8 +634,8 @@ int rhorses(const region * r)
|
||||||
|
|
||||||
void rsetmoney(region * r, int value)
|
void rsetmoney(region * r, int value)
|
||||||
{
|
{
|
||||||
((r)->land ? ((r)->land->money =
|
if (r->land) r->land->money = value;
|
||||||
(value)) : (assert((value) >= 0), (value)), 0);
|
else assert(value >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void r_setdemand(region * r, const luxury_type * ltype, int value)
|
void r_setdemand(region * r, const luxury_type * ltype, int value)
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
const char * keyword(keyword_t kwd)
|
const char * keyword(keyword_t kwd)
|
||||||
{
|
{
|
||||||
static char result[KEYWORDSIZE]; // FIXME: static return value
|
static char result[32]; // FIXME: static return value
|
||||||
if (!result[0]) {
|
if (!result[0]) {
|
||||||
strcpy(result, "keyword::");
|
strcpy(result, "keyword::");
|
||||||
}
|
}
|
||||||
|
|
|
@ -545,7 +545,7 @@ static int sp_summon_familiar(castorder * co)
|
||||||
cmistake(mage, co->order, 199, MSG_MAGIC);
|
cmistake(mage, co->order, 199, MSG_MAGIC);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rc = select_familiar(mage->faction->race, mage->faction->magiegebiet);
|
rc = select_familiar(mage->_race, mage->faction->magiegebiet);
|
||||||
if (rc == NULL) {
|
if (rc == NULL) {
|
||||||
log_error("could not find suitable familiar for %s.\n", mage->faction->race->_name);
|
log_error("could not find suitable familiar for %s.\n", mage->faction->race->_name);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue