Merge branch 'master' of github.com:eressea/server

This commit is contained in:
Enno Rehling 2014-08-18 20:33:11 +02:00
commit 408febe1e1
12 changed files with 2352 additions and 2267 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
eressea.ini eressea.ini
Debug
Release
# SlickEdit # SlickEdit
*.vtg *.vtg

View File

@ -79,6 +79,6 @@ add_subdirectory (iniparser)
add_subdirectory (quicklist) add_subdirectory (quicklist)
add_subdirectory (critbit) add_subdirectory (critbit)
add_subdirectory (src eressea) add_subdirectory (src eressea)
install(DIRECTORY res core conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml") install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml")
install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua") install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua")
install(DIRECTORY core/scripts DESTINATION core FILES_MATCHING PATTERN "*.lua")

View File

@ -6944,34 +6944,24 @@
<text locale="en">none</text> <text locale="en">none</text>
</string> </string>
<string name="faction_help_one"> <string name="faction_help">
<text locale="de">Wir helfen der Partei</text> <text locale="de">Wir helfen</text>
<text locale="en">We are helping the faction</text> <text locale="en">We are helping</text>
</string> </string>
<string name="faction_help_many"> <string name="group_help">
<text locale="de">Wir helfen den Parteien</text> <text locale="de">hilft</text>
<text locale="en">We are helping the factions</text> <text locale="en">is helping</text>
</string>
<string name="group_help_one">
<text locale="de">hilft der Partei</text>
<text locale="en">is helping the faction</text>
</string>
<string name="group_help_many">
<text locale="de">hilft den Parteien</text>
<text locale="en">is helping the factions</text>
</string> </string>
<string name="has_moved_one"> <string name="has_moved_one">
<text locale="de">hat die Region durchquert</text> <text locale="de">hat die Region durchquert.</text>
<text locale="en">has traveled through the region</text> <text locale="en">passed through the region.</text>
</string> </string>
<string name="has_moved_many"> <string name="has_moved_many">
<text locale="de">haben die Region durchquert</text> <text locale="de">haben die Region durchquert.</text>
<text locale="en">have traveled through the region</text> <text locale="en">passed through the region.</text>
</string> </string>
<string name="see_travel"> <string name="see_travel">

View File

@ -804,51 +804,49 @@
<arg name="max" type="int"/> <arg name="max" type="int"/>
</type> </type>
<text locale="de">"Unterhaltung: max. $int($max) Silber"</text> <text locale="de">"Unterhaltung: max. $int($max) Silber"</text>
<text locale="en">"Entertainment: max. $int($max) silver"</text> <text locale="en">"entertainment: max. $int($max) silver"</text>
</message> </message>
<message name="nr_stat_morale" section="nr"> <message name="nr_stat_morale" section="nr">
<type> <type>
<arg name="morale" type="int"/> <arg name="morale" type="int"/>
</type> </type>
<text locale="de">"Moral der Bauern: $int($morale)"</text> <text locale="de">"Moral der Bauern: $int($morale)"</text>
<text locale="en">"Peasant morale: $int($morale)"</text> <text locale="en">"peasant morale: $int($morale)"</text>
</message> </message>
<message name="nr_stat_luxuries" section="nr"> <message name="nr_stat_luxuries" section="nr">
<type> <type>
<arg name="max" type="int"/> <arg name="max" type="int"/>
</type> </type>
<text locale="de">"Luxusgüter zum angegebenen Preis: $int($max)"</text> <text locale="de">"Luxusgüter zum angegebenen Preis: $int($max)"</text>
<text locale="en">"Luxury goods at this price: $int($max)"</text> <text locale="en">"luxury goods at this price: $int($max)"</text>
</message> </message>
<message name="nr_stat_salary" section="nr"> <message name="nr_stat_salary" section="nr">
<type> <type>
<arg name="max" type="int"/> <arg name="max" type="int"/>
</type> </type>
<text locale="de">"Lohn für Arbeit: $int($max) Silber"</text> <text locale="de">"Lohn für Arbeit: $int($max) Silber"</text>
<text locale="en">"Worker salary: $int($max) silver"</text> <text locale="en">"worker salary: $int($max) silver"</text>
</message> </message>
<message name="nr_stat_salary_new" section="nr"> <message name="nr_stat_salary_new" section="nr">
<type> <type>
<arg name="max" type="int"/> <arg name="max" type="int"/>
</type> </type>
<text locale="de">"Bauerneinnahmen: $int($max) Silber"</text> <text locale="de">"Bauerneinnahmen: $int($max) Silber"</text>
<text locale="en">"Peasant wages: $int($max) silver"</text> <text locale="en">"peasant wages: $int($max) silver"</text>
</message> </message>
<message name="nr_stat_people" section="nr"> <message name="nr_stat_people" section="nr">
<type> <type>
<arg name="max" type="int"/> <arg name="max" type="int"/>
</type> </type>
<text locale="de">"Personen: $int($max)"</text> <text locale="de">"Personen: $int($max)"</text>
<text locale="en">"People: $int($max)"</text> <text locale="en">"people: $int($max)"</text>
<text locale="fr">"People: $int($max)"</text>
</message> </message>
<message name="nr_stat_recruits" section="nr"> <message name="nr_stat_recruits" section="nr">
<type> <type>
<arg name="max" type="int"/> <arg name="max" type="int"/>
</type> </type>
<text locale="de">"Rekruten: max. $int($max) Bauern"</text> <text locale="de">"Rekruten: max. $int($max) Bauern"</text>
<text locale="en">"Recruits: $int($max) peasants"</text> <text locale="en">"recruits: $int($max) peasants"</text>
<text locale="fr">"Recruits: $int($max) peasants"</text>
</message> </message>
<message name="nr_score" section="nr"> <message name="nr_score" section="nr">
<type> <type>
@ -857,7 +855,6 @@
</type> </type>
<text locale="de">"Deine Partei hat $int($score) Punkte. Der Durchschnitt für Parteien ähnlichen Alters ist $int($average) Punkte."</text> <text locale="de">"Deine Partei hat $int($score) Punkte. Der Durchschnitt für Parteien ähnlichen Alters ist $int($average) Punkte."</text>
<text locale="fr">"Your faction has a score of $int($score). The average score for similar factions is $int($average)."</text> <text locale="fr">"Your faction has a score of $int($score). The average score for similar factions is $int($average)."</text>
<text locale="en">"Your faction has a score of $int($score). The average score for similar factions is $int($average)."</text>
</message> </message>
<message name="nr_header_date" section="nr"> <message name="nr_header_date" section="nr">
<type> <type>
@ -3732,8 +3729,8 @@
<arg name="want" type="int"/> <arg name="want" type="int"/>
</type> </type>
<text locale="de">"$unit($unit) in $region($region) rekrutiert $int($amount) von $int($want) Personen."</text> <text locale="de">"$unit($unit) in $region($region) rekrutiert $int($amount) von $int($want) Personen."</text>
<text locale="fr">"$unit($unit) in $region($region) recruits $int($amount) $int($want) people."</text> <text locale="en">"$unit($unit) in $region($region) recruits
<text locale="en">"$unit($unit) in $region($region) recruits $int($amount) $int($want) people."</text> $int($amount) of $int($want) people."</text>
</message> </message>
<message name="siege_catapults" section="events"> <message name="siege_catapults" section="events">
<type> <type>
@ -8057,7 +8054,8 @@
<arg name="race" type="race"/> <arg name="race" type="race"/>
</type> </type>
<text locale="de">"$unit($unit) in $region($region): $int($number) $race($race,$number) $if($eq($number,1),"verschwand", "verschwanden") über Nacht."</text> <text locale="de">"$unit($unit) in $region($region): $int($number) $race($race,$number) $if($eq($number,1),"verschwand", "verschwanden") über Nacht."</text>
<text locale="en">"$unit($unit) in $region($region): $int($number) $race($race,$number) disappearedin the night."</text> <text locale="en">"$unit($unit) in $region($region): $int($number)
$race($race,$number) disappeared in the night."</text>
</message> </message>
<message name="forestfire_spread" section="events"> <message name="forestfire_spread" section="events">

View File

@ -15,6 +15,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"
mkdir -p $BIN_DIR mkdir -p $BIN_DIR
ln -sf $BIN_DIR $BUILD
cd $BIN_DIR cd $BIN_DIR
MACHINE=$(gcc -dumpmachine) MACHINE=$(gcc -dumpmachine)

View File

@ -16,4 +16,4 @@ BIN_DIR="build-$MACHINE-$CC-Debug"
cd $ROOT/$BIN_DIR cd $ROOT/$BIN_DIR
make install make install
cd $OLDPWD

42
s/setup
View File

@ -8,10 +8,11 @@ exit $2 # otherwise
function usage() { function usage() {
cat <<USAGE cat <<USAGE
Usage: $u [-hf] [-d DIR] [-g <game>] [-r <rules>] [-s DIR] Usage: $u [-hfn] [-d DIR] [-g <game>] [-r <rules>] [-s DIR]
-h print this message -h print this message
-f force overwrite of existing game -f force overwrite of existing game
-g game id -g game id
-n create new eressea.ini file
-r name of ruleset -r name of ruleset
-s server installation directory -s server installation directory
-d override directory name -d override directory name
@ -21,13 +22,14 @@ USAGE
game=0 game=0
force=0 force=0
src=server src=server
edit=1
while getopts :d:g:r:s:hf o; do while getopts :d:g:r:s:hfn o; do
case "${o}" in case "${o}" in
h) usage ; exit 0 ;; h) usage ; exit 0 ;;
s) src=${OPTARG} ;; s) src=${OPTARG} ;;
d) dir=${OPTARG} ;; d) dir=${OPTARG} ;;
f) force=1 ;; f) force=1 ;;
n) edit=0 ;;
g) game=${OPTARG} ;; g) game=${OPTARG} ;;
r) rules=${OPTARG} ;; r) rules=${OPTARG} ;;
*) echo "not implemented ${o} ${OPTARG}" ;; *) echo "not implemented ${o} ${OPTARG}" ;;
@ -44,7 +46,7 @@ done
[ -e $TOOLS ] || TOOLS=$SOURCE/bin [ -e $TOOLS ] || TOOLS=$SOURCE/bin
[ -z $INIFILE ] && INIFILE=$TOOLS/inifile [ -z $INIFILE ] && INIFILE=$TOOLS/inifile
[ -e $INIFILE ] || INIFILE=$TOOLS/iniparser/inifile [ -e $INIFILE ] || INIFILE=$TOOLS/iniparser/inifile
[ -e $INIFILE ] || abort "tool is not installed: $INIFILE" #[ -e $INIFILE ] || abort "tool is not installed: $INIFILE"
cd $ERESSEA cd $ERESSEA
if [ -d $dir ] ; then if [ -d $dir ] ; then
@ -55,18 +57,38 @@ cd $dir || abort "could not chdir to game-$game"
mkdir -p data reports mkdir -p data reports
function ini_sec() { function ini_sec() {
if [ $edit -eq 1 ]; then
$INIFILE eressea.ini add $1 $INIFILE eressea.ini add $1
else
echo "[$1]" >> eressea.ini
fi
} }
function ini_add() { function ini_add() {
$INIFILE eressea.ini add $1 $2 if [ $edit -eq 1 ]; then
$INIFILE eressea.ini add $1:$2 $3
else
echo "$2 = $3" >> eressea.ini
fi
} }
function ini_start() {
if [ -e eressea.ini ]; then
if [ ! -e $INIFILE ] && [ $edit -eq 1 ]; then
abort "missing editor for eressea.ini. use -n to create new file."
fi
rm -f eressea.ini
edit=0
else
edit=0
fi
touch eressea.ini touch eressea.ini
}
ini_start
ini_sec eressea ini_sec eressea
ini_add eressea:locales de,en ini_add eressea locales de,en
ini_sec lua ini_sec lua
ini_add lua:install $SOURCE ini_add lua install $SOURCE
ini_add lua:install $SOURCE ini_add lua paths $SOURCE/scripts:$SOURCE/lunit
ini_add lua:paths $SOURCE/scripts:$SOURCE/lunit ini_add lua rules $rules
ini_add lua:rules $rules
ln -f $SOURCE/scripts/run-turn.lua ln -f $SOURCE/scripts/run-turn.lua

View File

@ -14,6 +14,7 @@ equipment.test.c
curse.test.c curse.test.c
item.test.c item.test.c
move.test.c move.test.c
order.test.c
pool.test.c pool.test.c
reports.test.c reports.test.c
spellbook.test.c spellbook.test.c

View File

@ -2,7 +2,7 @@
+-------------------+ +-------------------+
| | Christian Schlittchen <corwin@amber.kn-bremen.de> | | Christian Schlittchen <corwin@amber.kn-bremen.de>
| Eressea PBEM host | Enno Rehling <enno@eressea.de> | Eressea PBEM host | Enno Rehling <enno@eressea.de>
| (c) 1998 - 2004 | Katja Zedel <katze@felidae.kn-bremen.de> | (c) 1998 - 2014 | Katja Zedel <katze@felidae.kn-bremen.de>
| | | |
+-------------------+ +-------------------+
@ -44,7 +44,7 @@ static struct locale_data *locale_array[16];
static int nlocales = 0; static int nlocales = 0;
typedef struct order_data { typedef struct order_data {
char *_str; const char *_str;
# ifdef LOMEM # ifdef LOMEM
int _refcount:20; int _refcount:20;
int _lindex:4; int _lindex:4;
@ -59,8 +59,6 @@ static void release_data(order_data * data)
{ {
if (data) { if (data) {
if (--data->_refcount == 0) { if (--data->_refcount == 0) {
if (data->_str)
free(data->_str);
free(data); free(data);
} }
} }
@ -182,6 +180,22 @@ void free_orders(order ** olist)
} }
} }
static char *mkdata(order_data **pdata, size_t len, keyword_t kwd, int lindex, const char *str)
{
order_data *data;
char *result;
data = malloc(sizeof(order_data) + len +1);
result = (char *)(data + 1);
data->_keyword = kwd;
data->_lindex = lindex;
data->_refcount = 0;
data->_str = 0;
data->_str = (len > 0) ? result : 0;
if (str) strcpy(result, str);
if (pdata) *pdata = data;
return result;
}
static order_data *create_data(keyword_t kwd, const char *sptr, int lindex) static order_data *create_data(keyword_t kwd, const char *sptr, int lindex)
{ {
const char *s = sptr; const char *s = sptr;
@ -204,21 +218,15 @@ static order_data *create_data(keyword_t kwd, const char *sptr, int lindex)
data = locale_array[lindex]->study_orders[sk]; data = locale_array[lindex]->study_orders[sk];
if (data == NULL) { if (data == NULL) {
const char *skname = skillname(sk, lang); const char *skname = skillname(sk, lang);
data = (order_data *)malloc(sizeof(order_data)); const char *spc = strchr(skname, ' ');
size_t len = strlen(skname);
char *dst = mkdata(&data, len + (spc ? 3 : 0), kwd, lindex, spc ? 0 : skname);
locale_array[lindex]->study_orders[sk] = data; locale_array[lindex]->study_orders[sk] = data;
data->_keyword = kwd; if (spc) {
data->_lindex = lindex; dst[0] = '\"';
assert(data->_lindex >= 0); memcpy(dst + 1, skname, len);
if (strchr(skname, ' ') != NULL) { dst[len + 1] = '\"';
size_t len = strlen(skname); dst[len + 2] = '\0';
data->_str = malloc(len + 3);
data->_str[0] = '\"';
memcpy(data->_str + 1, skname, len);
data->_str[len + 1] = '\"';
data->_str[len + 2] = '\0';
}
else {
data->_str = _strdup(skname);
} }
data->_refcount = 1; data->_refcount = 1;
} }
@ -231,22 +239,13 @@ static order_data *create_data(keyword_t kwd, const char *sptr, int lindex)
else if (kwd != NOKEYWORD && *sptr == 0) { else if (kwd != NOKEYWORD && *sptr == 0) {
data = locale_array[lindex]->short_orders[kwd]; data = locale_array[lindex]->short_orders[kwd];
if (data == NULL) { if (data == NULL) {
data = (order_data *)malloc(sizeof(order_data)); mkdata(&data, 0, kwd, lindex, 0);
locale_array[lindex]->short_orders[kwd] = data;
data->_keyword = kwd;
data->_lindex = lindex;
assert(data->_lindex >= 0);
data->_str = NULL;
data->_refcount = 1; data->_refcount = 1;
} }
++data->_refcount; ++data->_refcount;
return data; return data;
} }
data = (order_data *)malloc(sizeof(order_data)); mkdata(&data, s ? strlen(s) : 0, kwd, lindex, s);
data->_keyword = kwd;
data->_lindex = lindex;
assert(data->_lindex >= 0);
data->_str = s ? _strdup(s) : NULL;
data->_refcount = 1; data->_refcount = 1;
return data; return data;
} }

48
src/kernel/order.test.c Normal file
View File

@ -0,0 +1,48 @@
#include <config.h>
#include "order.h"
#include <util/parser.h>
#include <util/language.h>
#include <CuTest.h>
#include <stdlib.h>
static void test_create_order(CuTest *tc) {
char cmd[32];
order *ord;
struct locale * lang = get_or_create_locale("en");
locale_setstring(lang, "keyword::move", "MOVE");
ord = create_order(K_MOVE, lang, "NORTH");
CuAssertPtrNotNull(tc, ord);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
init_tokens(ord);
CuAssertStrEquals(tc, "MOVE NORTH", get_command(ord, cmd, sizeof(cmd)));
CuAssertStrEquals(tc, "MOVE", getstrtoken());
CuAssertStrEquals(tc, "NORTH", getstrtoken());
free_order(ord);
}
static void test_parse_order(CuTest *tc) {
char cmd[32];
order *ord;
struct locale * lang = get_or_create_locale("en");
locale_setstring(lang, "keyword::move", "MOVE");
ord = parse_order("MOVE NORTH", lang);
CuAssertPtrNotNull(tc, ord);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
init_tokens(ord);
CuAssertStrEquals(tc, "MOVE NORTH", get_command(ord, cmd, sizeof(cmd)));
CuAssertStrEquals(tc, "MOVE", getstrtoken());
CuAssertStrEquals(tc, "NORTH", getstrtoken());
free_order(ord);
}
CuSuite *get_order_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_create_order);
SUITE_ADD_TEST(suite, test_parse_order);
return suite;
}

File diff suppressed because it is too large Load Diff

View File

@ -9,36 +9,6 @@
CuSuite *get_##name##_suite(void); \ CuSuite *get_##name##_suite(void); \
CuSuiteAddSuite(suite, get_##name##_suite()) CuSuiteAddSuite(suite, get_##name##_suite())
CuSuite *get_tests_suite(void);
CuSuite *get_callback_suite(void);
CuSuite *get_jsonconf_suite(void);
CuSuite *get_json_suite(void);
CuSuite *get_economy_suite(void);
CuSuite *get_laws_suite(void);
CuSuite *get_market_suite(void);
CuSuite *get_battle_suite(void);
CuSuite *get_building_suite(void);
CuSuite *get_curse_suite(void);
CuSuite *get_equipment_suite(void);
CuSuite *get_item_suite(void);
CuSuite *get_magic_suite(void);
CuSuite *get_move_suite(void);
CuSuite *get_pool_suite(void);
CuSuite *get_build_suite(void);
CuSuite *get_reports_suite(void);
CuSuite *get_ship_suite(void);
CuSuite *get_spellbook_suite(void);
CuSuite *get_spell_suite(void);
CuSuite *get_base36_suite(void);
CuSuite *get_config_suite(void);
CuSuite *get_bsdstring_suite(void);
CuSuite *get_functions_suite(void);
CuSuite *get_umlaut_suite(void);
CuSuite *get_ally_suite(void);
CuSuite *get_direction_suite(void);
CuSuite *get_skill_suite(void);
CuSuite *get_keyword_suite(void);
int RunAllTests(void) int RunAllTests(void)
{ {
CuString *output = CuStringNew(); CuString *output = CuStringNew();
@ -56,6 +26,7 @@ int RunAllTests(void)
ADD_TESTS(suite, direction); ADD_TESTS(suite, direction);
ADD_TESTS(suite, skill); ADD_TESTS(suite, skill);
ADD_TESTS(suite, keyword); ADD_TESTS(suite, keyword);
ADD_TESTS(suite, order);
/* util */ /* util */
ADD_TESTS(suite, config); ADD_TESTS(suite, config);
ADD_TESTS(suite, base36); ADD_TESTS(suite, base36);