forked from github/server
Merge branch 'master' of github.com:eressea/server
This commit is contained in:
commit
408febe1e1
|
@ -1,4 +1,6 @@
|
|||
eressea.ini
|
||||
Debug
|
||||
Release
|
||||
|
||||
# SlickEdit
|
||||
*.vtg
|
||||
|
|
|
@ -79,6 +79,6 @@ add_subdirectory (iniparser)
|
|||
add_subdirectory (quicklist)
|
||||
add_subdirectory (critbit)
|
||||
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 core/scripts DESTINATION core FILES_MATCHING PATTERN "*.lua")
|
||||
|
||||
|
|
|
@ -6944,34 +6944,24 @@
|
|||
<text locale="en">none</text>
|
||||
</string>
|
||||
|
||||
<string name="faction_help_one">
|
||||
<text locale="de">Wir helfen der Partei</text>
|
||||
<text locale="en">We are helping the faction</text>
|
||||
<string name="faction_help">
|
||||
<text locale="de">Wir helfen</text>
|
||||
<text locale="en">We are helping</text>
|
||||
</string>
|
||||
|
||||
<string name="faction_help_many">
|
||||
<text locale="de">Wir helfen den Parteien</text>
|
||||
<text locale="en">We are helping the factions</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 name="group_help">
|
||||
<text locale="de">hilft</text>
|
||||
<text locale="en">is helping</text>
|
||||
</string>
|
||||
|
||||
<string name="has_moved_one">
|
||||
<text locale="de">hat die Region durchquert</text>
|
||||
<text locale="en">has traveled through the region</text>
|
||||
<text locale="de">hat die Region durchquert.</text>
|
||||
<text locale="en">passed through the region.</text>
|
||||
</string>
|
||||
|
||||
<string name="has_moved_many">
|
||||
<text locale="de">haben die Region durchquert</text>
|
||||
<text locale="en">have traveled through the region</text>
|
||||
<text locale="de">haben die Region durchquert.</text>
|
||||
<text locale="en">passed through the region.</text>
|
||||
</string>
|
||||
|
||||
<string name="see_travel">
|
||||
|
|
|
@ -804,51 +804,49 @@
|
|||
<arg name="max" type="int"/>
|
||||
</type>
|
||||
<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 name="nr_stat_morale" section="nr">
|
||||
<type>
|
||||
<arg name="morale" type="int"/>
|
||||
</type>
|
||||
<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 name="nr_stat_luxuries" section="nr">
|
||||
<type>
|
||||
<arg name="max" type="int"/>
|
||||
</type>
|
||||
<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 name="nr_stat_salary" section="nr">
|
||||
<type>
|
||||
<arg name="max" type="int"/>
|
||||
</type>
|
||||
<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 name="nr_stat_salary_new" section="nr">
|
||||
<type>
|
||||
<arg name="max" type="int"/>
|
||||
</type>
|
||||
<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 name="nr_stat_people" section="nr">
|
||||
<type>
|
||||
<arg name="max" type="int"/>
|
||||
</type>
|
||||
<text locale="de">"Personen: $int($max)"</text>
|
||||
<text locale="en">"People: $int($max)"</text>
|
||||
<text locale="fr">"People: $int($max)"</text>
|
||||
<text locale="en">"people: $int($max)"</text>
|
||||
</message>
|
||||
<message name="nr_stat_recruits" section="nr">
|
||||
<type>
|
||||
<arg name="max" type="int"/>
|
||||
</type>
|
||||
<text locale="de">"Rekruten: max. $int($max) Bauern"</text>
|
||||
<text locale="en">"Recruits: $int($max) peasants"</text>
|
||||
<text locale="fr">"Recruits: $int($max) peasants"</text>
|
||||
<text locale="en">"recruits: $int($max) peasants"</text>
|
||||
</message>
|
||||
<message name="nr_score" section="nr">
|
||||
<type>
|
||||
|
@ -857,7 +855,6 @@
|
|||
</type>
|
||||
<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="en">"Your faction has a score of $int($score). The average score for similar factions is $int($average)."</text>
|
||||
</message>
|
||||
<message name="nr_header_date" section="nr">
|
||||
<type>
|
||||
|
@ -3732,8 +3729,8 @@
|
|||
<arg name="want" type="int"/>
|
||||
</type>
|
||||
<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 $int($amount) $int($want) people."</text>
|
||||
<text locale="en">"$unit($unit) in $region($region) recruits
|
||||
$int($amount) of $int($want) people."</text>
|
||||
</message>
|
||||
<message name="siege_catapults" section="events">
|
||||
<type>
|
||||
|
@ -8057,7 +8054,8 @@
|
|||
<arg name="race" type="race"/>
|
||||
</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="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 name="forestfire_spread" section="events">
|
||||
|
|
|
@ -15,6 +15,7 @@ MACHINE=`uname -m`
|
|||
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
|
||||
BIN_DIR="build-$MACHINE-$CC-$BUILD"
|
||||
mkdir -p $BIN_DIR
|
||||
ln -sf $BIN_DIR $BUILD
|
||||
cd $BIN_DIR
|
||||
|
||||
MACHINE=$(gcc -dumpmachine)
|
||||
|
|
|
@ -16,4 +16,4 @@ BIN_DIR="build-$MACHINE-$CC-Debug"
|
|||
|
||||
cd $ROOT/$BIN_DIR
|
||||
make install
|
||||
cd $OLDPWD
|
||||
|
||||
|
|
42
s/setup
42
s/setup
|
@ -8,10 +8,11 @@ exit $2 # otherwise
|
|||
|
||||
function 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
|
||||
-f force overwrite of existing game
|
||||
-g game id
|
||||
-n create new eressea.ini file
|
||||
-r name of ruleset
|
||||
-s server installation directory
|
||||
-d override directory name
|
||||
|
@ -21,13 +22,14 @@ USAGE
|
|||
game=0
|
||||
force=0
|
||||
src=server
|
||||
|
||||
while getopts :d:g:r:s:hf o; do
|
||||
edit=1
|
||||
while getopts :d:g:r:s:hfn o; do
|
||||
case "${o}" in
|
||||
h) usage ; exit 0 ;;
|
||||
s) src=${OPTARG} ;;
|
||||
d) dir=${OPTARG} ;;
|
||||
f) force=1 ;;
|
||||
n) edit=0 ;;
|
||||
g) game=${OPTARG} ;;
|
||||
r) rules=${OPTARG} ;;
|
||||
*) echo "not implemented ${o} ${OPTARG}" ;;
|
||||
|
@ -44,7 +46,7 @@ done
|
|||
[ -e $TOOLS ] || TOOLS=$SOURCE/bin
|
||||
[ -z $INIFILE ] && INIFILE=$TOOLS/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
|
||||
if [ -d $dir ] ; then
|
||||
|
@ -55,18 +57,38 @@ cd $dir || abort "could not chdir to game-$game"
|
|||
mkdir -p data reports
|
||||
|
||||
function ini_sec() {
|
||||
if [ $edit -eq 1 ]; then
|
||||
$INIFILE eressea.ini add $1
|
||||
else
|
||||
echo "[$1]" >> eressea.ini
|
||||
fi
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
ini_start
|
||||
ini_sec eressea
|
||||
ini_add eressea:locales de,en
|
||||
ini_add eressea locales de,en
|
||||
ini_sec lua
|
||||
ini_add lua:install $SOURCE
|
||||
ini_add lua:install $SOURCE
|
||||
ini_add lua:paths $SOURCE/scripts:$SOURCE/lunit
|
||||
ini_add lua:rules $rules
|
||||
ini_add lua install $SOURCE
|
||||
ini_add lua paths $SOURCE/scripts:$SOURCE/lunit
|
||||
ini_add lua rules $rules
|
||||
|
||||
ln -f $SOURCE/scripts/run-turn.lua
|
||||
|
|
|
@ -14,6 +14,7 @@ equipment.test.c
|
|||
curse.test.c
|
||||
item.test.c
|
||||
move.test.c
|
||||
order.test.c
|
||||
pool.test.c
|
||||
reports.test.c
|
||||
spellbook.test.c
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
+-------------------+
|
||||
| | Christian Schlittchen <corwin@amber.kn-bremen.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;
|
||||
|
||||
typedef struct order_data {
|
||||
char *_str;
|
||||
const char *_str;
|
||||
# ifdef LOMEM
|
||||
int _refcount:20;
|
||||
int _lindex:4;
|
||||
|
@ -59,8 +59,6 @@ static void release_data(order_data * data)
|
|||
{
|
||||
if (data) {
|
||||
if (--data->_refcount == 0) {
|
||||
if (data->_str)
|
||||
free(data->_str);
|
||||
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)
|
||||
{
|
||||
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];
|
||||
if (data == NULL) {
|
||||
const char *skname = skillname(sk, lang);
|
||||
data = (order_data *)malloc(sizeof(order_data));
|
||||
locale_array[lindex]->study_orders[sk] = data;
|
||||
data->_keyword = kwd;
|
||||
data->_lindex = lindex;
|
||||
assert(data->_lindex >= 0);
|
||||
if (strchr(skname, ' ') != NULL) {
|
||||
const char *spc = strchr(skname, ' ');
|
||||
size_t len = strlen(skname);
|
||||
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);
|
||||
char *dst = mkdata(&data, len + (spc ? 3 : 0), kwd, lindex, spc ? 0 : skname);
|
||||
locale_array[lindex]->study_orders[sk] = data;
|
||||
if (spc) {
|
||||
dst[0] = '\"';
|
||||
memcpy(dst + 1, skname, len);
|
||||
dst[len + 1] = '\"';
|
||||
dst[len + 2] = '\0';
|
||||
}
|
||||
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) {
|
||||
data = locale_array[lindex]->short_orders[kwd];
|
||||
if (data == NULL) {
|
||||
data = (order_data *)malloc(sizeof(order_data));
|
||||
locale_array[lindex]->short_orders[kwd] = data;
|
||||
data->_keyword = kwd;
|
||||
data->_lindex = lindex;
|
||||
assert(data->_lindex >= 0);
|
||||
data->_str = NULL;
|
||||
mkdata(&data, 0, kwd, lindex, 0);
|
||||
data->_refcount = 1;
|
||||
}
|
||||
++data->_refcount;
|
||||
return data;
|
||||
}
|
||||
data = (order_data *)malloc(sizeof(order_data));
|
||||
data->_keyword = kwd;
|
||||
data->_lindex = lindex;
|
||||
assert(data->_lindex >= 0);
|
||||
data->_str = s ? _strdup(s) : NULL;
|
||||
mkdata(&data, s ? strlen(s) : 0, kwd, lindex, s);
|
||||
data->_refcount = 1;
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
285
src/report.c
285
src/report.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -143,7 +143,8 @@ static void centre(FILE * F, const char *s, bool breaking)
|
|||
SP = SP->next;
|
||||
}
|
||||
freestrlist(T);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rpc(F, ' ', (REPORTWIDTH - strlen(s) + 1) / 2);
|
||||
fputs(s, F);
|
||||
putc('\n', F);
|
||||
|
@ -152,7 +153,7 @@ static void centre(FILE * F, const char *s, bool breaking)
|
|||
|
||||
static void
|
||||
rparagraph(FILE * F, const char *str, ptrdiff_t indent, int hanging_indent,
|
||||
char mark)
|
||||
char mark)
|
||||
{
|
||||
static const char *spaces = " ";
|
||||
size_t length = REPORTWIDTH;
|
||||
|
@ -182,9 +183,11 @@ rparagraph(FILE * F, const char *str, ptrdiff_t indent, int hanging_indent,
|
|||
fputc(mark, F);
|
||||
fputc(' ', F);
|
||||
mark = 0;
|
||||
} else if (begin == str) {
|
||||
}
|
||||
else if (begin == str) {
|
||||
fwrite(spaces, sizeof(char), indent, F);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fwrite(spaces, sizeof(char), indent + hanging_indent, F);
|
||||
}
|
||||
while (*end && end <= begin + length - indent) {
|
||||
|
@ -215,10 +218,11 @@ static size_t write_spell_modifier(spell * sp, int flag, const char * str, bool
|
|||
size_t bytes = 0;
|
||||
if (cont) {
|
||||
bytes = strlcpy(bufp, ", ", size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = strlcpy(bufp, " ", size);
|
||||
}
|
||||
bytes += strlcpy(bufp+bytes, str, size-bytes);
|
||||
bytes += strlcpy(bufp + bytes, str, size - bytes);
|
||||
return bytes;
|
||||
}
|
||||
return 0;
|
||||
|
@ -249,11 +253,14 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
}
|
||||
if (sp->sptyp & PRECOMBATSPELL) {
|
||||
bytes = (int)strlcpy(bufp, LOC(lang, "sptype_precombat"), size);
|
||||
} else if (sp->sptyp & COMBATSPELL) {
|
||||
}
|
||||
else if (sp->sptyp & COMBATSPELL) {
|
||||
bytes = (int)strlcpy(bufp, LOC(lang, "sptype_combat"), size);
|
||||
} else if (sp->sptyp & POSTCOMBATSPELL) {
|
||||
}
|
||||
else if (sp->sptyp & POSTCOMBATSPELL) {
|
||||
bytes = (int)strlcpy(bufp, LOC(lang, "sptype_postcombat"), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, LOC(lang, "sptype_normal"), size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -286,7 +293,8 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = _snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1)));
|
||||
if (wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -304,24 +312,24 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
WARN_STATIC_BUFFER();
|
||||
|
||||
startp = bufp;
|
||||
bytes = (int)write_spell_modifier(sp, FARCASTING, LOC(lang, "smod_far"), startp!=bufp, bufp, size);
|
||||
bytes = (int)write_spell_modifier(sp, FARCASTING, LOC(lang, "smod_far"), startp != bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)write_spell_modifier(sp, OCEANCASTABLE, LOC(lang, "smod_sea"), startp!=bufp, bufp, size);
|
||||
bytes = (int)write_spell_modifier(sp, OCEANCASTABLE, LOC(lang, "smod_sea"), startp != bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)write_spell_modifier(sp, ONSHIPCAST, LOC(lang, "smod_ship"), startp!=bufp, bufp, size);
|
||||
bytes = (int)write_spell_modifier(sp, ONSHIPCAST, LOC(lang, "smod_ship"), startp != bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_nofamiliar"), startp!=bufp, bufp, size);
|
||||
bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_nofamiliar"), startp != bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
if (startp==bufp) {
|
||||
bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_none"), startp!=bufp, bufp, size);
|
||||
if (startp == bufp) {
|
||||
bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_none"), startp != bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
|
@ -336,7 +344,8 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
|
||||
if (sp->sptyp & ISCOMBATSPELL) {
|
||||
bytes = (int)strlcpy(bufp, LOC(lang, keyword(K_COMBATSPELL)), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, LOC(lang, keyword(K_CAST)), size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -365,11 +374,11 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
const char *vars;
|
||||
} starget;
|
||||
starget targets[] = {
|
||||
{P_REGION, REGIONSPELL, NULL},
|
||||
{P_UNIT, UNITSPELL, "par_unit"},
|
||||
{P_SHIP, SHIPSPELL, "par_ship"},
|
||||
{P_BUILDING, BUILDINGSPELL, "par_building"},
|
||||
{0, 0, NULL}
|
||||
{ P_REGION, REGIONSPELL, NULL },
|
||||
{ P_UNIT, UNITSPELL, "par_unit" },
|
||||
{ P_SHIP, SHIPSPELL, "par_ship" },
|
||||
{ P_BUILDING, BUILDINGSPELL, "par_building" },
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
starget *targetp;
|
||||
char cp = *params++;
|
||||
|
@ -389,7 +398,8 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else if (cp == 's') {
|
||||
}
|
||||
else if (cp == 's') {
|
||||
targetp = targets + 2;
|
||||
locp = LOC(lang, targetp->vars);
|
||||
bytes = (int)_snprintf(bufp, size, " <%s>", locp);
|
||||
|
@ -401,7 +411,8 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else if (cp == 'r') {
|
||||
}
|
||||
else if (cp == 'r') {
|
||||
bytes = (int)strlcpy(bufp, " <x> <y>", size);
|
||||
if (*params == '+') {
|
||||
++params;
|
||||
|
@ -411,7 +422,8 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else if (cp == 'b') {
|
||||
}
|
||||
else if (cp == 'b') {
|
||||
targetp = targets + 3;
|
||||
locp = LOC(lang, targetp->vars);
|
||||
bytes = (int)_snprintf(bufp, size, " <%s>", locp);
|
||||
|
@ -423,7 +435,8 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else if (cp == 'k') {
|
||||
}
|
||||
else if (cp == 'k') {
|
||||
if (*params == 'c') {
|
||||
/* skip over a potential id */
|
||||
++params;
|
||||
|
@ -456,7 +469,8 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
WARN_STATIC_BUFFER();
|
||||
bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes =
|
||||
(int)_snprintf(bufp, size, " %s", parameters[targetp->param]);
|
||||
}
|
||||
|
@ -469,13 +483,15 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
} else if (cp == 'i' || cp == 'c') {
|
||||
}
|
||||
else if (cp == 'i' || cp == 'c') {
|
||||
const char *cstr;
|
||||
assert(syntaxp);
|
||||
cstr = strchr(syntaxp, ':');
|
||||
if (!cstr) {
|
||||
locp = LOC(lang, mkname("spellpar", syntaxp));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
char substr[32];
|
||||
strncpy(substr, syntaxp, cstr - syntaxp);
|
||||
substr[cstr - syntaxp] = 0;
|
||||
|
@ -524,8 +540,7 @@ void sparagraph(strlist ** SP, const char *s, int indent, char mark)
|
|||
break;
|
||||
}
|
||||
i = j + 1;
|
||||
}
|
||||
while (s[j]);
|
||||
} while (s[j]);
|
||||
|
||||
for (j = 0; j != indent; j++)
|
||||
buf[j] = ' ';
|
||||
|
@ -549,7 +564,7 @@ void sparagraph(strlist ** SP, const char *s, int indent, char mark)
|
|||
|
||||
static void
|
||||
nr_curses(FILE * F, const faction * viewer, const void *obj, objtype_t typ,
|
||||
int indent)
|
||||
int indent)
|
||||
{
|
||||
attrib *a = NULL;
|
||||
int self = 0;
|
||||
|
@ -561,14 +576,15 @@ nr_curses(FILE * F, const faction * viewer, const void *obj, objtype_t typ,
|
|||
* Spezialfälle (besonderes Talent, verursachender Magier usw. werde
|
||||
* bei jedem curse gesondert behandelt. */
|
||||
if (typ == TYP_SHIP) {
|
||||
ship *sh = (ship *) obj;
|
||||
ship *sh = (ship *)obj;
|
||||
unit *owner = ship_owner(sh);
|
||||
a = sh->attribs;
|
||||
r = sh->region;
|
||||
if (owner) {
|
||||
if (owner->faction == viewer) {
|
||||
self = 2;
|
||||
} else { /* steht eine person der Partei auf dem Schiff? */
|
||||
}
|
||||
else { /* steht eine person der Partei auf dem Schiff? */
|
||||
unit *u = NULL;
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->ship == sh) {
|
||||
|
@ -578,15 +594,17 @@ nr_curses(FILE * F, const faction * viewer, const void *obj, objtype_t typ,
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (typ == TYP_BUILDING) {
|
||||
building *b = (building *) obj;
|
||||
}
|
||||
else if (typ == TYP_BUILDING) {
|
||||
building *b = (building *)obj;
|
||||
unit *owner;
|
||||
a = b->attribs;
|
||||
r = b->region;
|
||||
if ((owner = building_owner(b)) != NULL) {
|
||||
if (owner->faction == viewer) {
|
||||
self = 2;
|
||||
} else { /* steht eine Person der Partei in der Burg? */
|
||||
}
|
||||
else { /* steht eine Person der Partei in der Burg? */
|
||||
unit *u = NULL;
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->building == b) {
|
||||
|
@ -596,17 +614,20 @@ nr_curses(FILE * F, const faction * viewer, const void *obj, objtype_t typ,
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (typ == TYP_UNIT) {
|
||||
unit *u = (unit *) obj;
|
||||
}
|
||||
else if (typ == TYP_UNIT) {
|
||||
unit *u = (unit *)obj;
|
||||
a = u->attribs;
|
||||
r = u->region;
|
||||
if (u->faction == viewer) {
|
||||
self = 2;
|
||||
}
|
||||
} else if (typ == TYP_REGION) {
|
||||
r = (region *) obj;
|
||||
}
|
||||
else if (typ == TYP_REGION) {
|
||||
r = (region *)obj;
|
||||
a = r->attribs;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* fehler */
|
||||
}
|
||||
|
||||
|
@ -614,7 +635,7 @@ nr_curses(FILE * F, const faction * viewer, const void *obj, objtype_t typ,
|
|||
char buf[4096];
|
||||
|
||||
if (fval(a->type, ATF_CURSE)) {
|
||||
curse *c = (curse *) a->data.v;
|
||||
curse *c = (curse *)a->data.v;
|
||||
message *msg;
|
||||
|
||||
if (c->type->cansee) {
|
||||
|
@ -628,8 +649,9 @@ nr_curses(FILE * F, const faction * viewer, const void *obj, objtype_t typ,
|
|||
rparagraph(F, buf, indent, 2, 0);
|
||||
msg_release(msg);
|
||||
}
|
||||
} else if (a->type == &at_effect && self) {
|
||||
effect_data *data = (effect_data *) a->data.v;
|
||||
}
|
||||
else if (a->type == &at_effect && self) {
|
||||
effect_data *data = (effect_data *)a->data.v;
|
||||
if (data->value > 0) {
|
||||
sprintf(buf, "Auf der Einheit lieg%s %d Wirkung%s %s.",
|
||||
(data->value == 1 ? "t" : "en"),
|
||||
|
@ -650,7 +672,7 @@ static void rps_nowrap(FILE * F, const char *s)
|
|||
|
||||
if (!x) return;
|
||||
|
||||
while (*x++ == ' ') ;
|
||||
while (*x++ == ' ');
|
||||
indent = x - s - 1;
|
||||
if (*(x - 1) && indent && *x == ' ')
|
||||
indent += 2;
|
||||
|
@ -671,7 +693,7 @@ nr_unit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
attrib *a_otherfaction;
|
||||
char marker;
|
||||
int dh;
|
||||
bool isbattle = (bool) (mode == see_battle);
|
||||
bool isbattle = (bool)(mode == see_battle);
|
||||
char buf[8192];
|
||||
|
||||
if (fval(u_race(u), RCF_INVISIBLE))
|
||||
|
@ -686,16 +708,20 @@ nr_unit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
|
||||
if (u->faction == f) {
|
||||
marker = '*';
|
||||
} else if ALLIED
|
||||
}
|
||||
else if ALLIED
|
||||
(u->faction, f) {
|
||||
marker = 'o';
|
||||
} else if (a_otherfaction && f != u->faction
|
||||
}
|
||||
else if (a_otherfaction && f != u->faction
|
||||
&& get_otherfaction(a_otherfaction) == f && !fval(u, UFL_ANON_FACTION)) {
|
||||
marker = '!';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (dh && !fval(u, UFL_ANON_FACTION)) {
|
||||
marker = '+';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
marker = '-';
|
||||
}
|
||||
}
|
||||
|
@ -708,7 +734,7 @@ nr_unit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
|
||||
static void
|
||||
rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent,
|
||||
bool categorized)
|
||||
bool categorized)
|
||||
{
|
||||
nrsection *section;
|
||||
if (!msgs)
|
||||
|
@ -813,7 +839,8 @@ static void prices(FILE * F, const region * r, const faction * f)
|
|||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_end"), size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else if (n == 1) {
|
||||
}
|
||||
else if (n == 1) {
|
||||
bytes = (int)strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -823,7 +850,8 @@ static void prices(FILE * F, const region * r, const faction * f)
|
|||
bytes = (int)strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_next"), size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -922,11 +950,14 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
|
||||
if (sr->mode == see_travel) {
|
||||
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel"));
|
||||
} else if (sr->mode == see_neighbour) {
|
||||
}
|
||||
else if (sr->mode == see_neighbour) {
|
||||
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour"));
|
||||
} else if (sr->mode == see_lighthouse) {
|
||||
}
|
||||
else if (sr->mode == see_lighthouse) {
|
||||
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = 0;
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -954,12 +985,15 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
if (fval(r, RF_MALLORN)) {
|
||||
if (trees == 1) {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_mallorntree"), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_mallorntree_p"), size);
|
||||
}
|
||||
} else if (trees == 1) {
|
||||
}
|
||||
else if (trees == 1) {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_tree"), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_tree_p"), size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -968,7 +1002,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
}
|
||||
|
||||
/* iron & stone */
|
||||
if (sr->mode == see_unit && f != (faction *) NULL) {
|
||||
if (sr->mode == see_unit && f != (faction *)NULL) {
|
||||
resource_report result[MAX_RAWMATERIALS];
|
||||
int n, numresults = report_resources(sr, result, MAX_RAWMATERIALS, f);
|
||||
|
||||
|
@ -1004,7 +1038,8 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
bytes =
|
||||
(int)strlcpy(bufp, LOC(f->locale, n == 1 ? "rc_orc" : "rc_orc_p"),
|
||||
size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -1080,7 +1115,8 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
bytes = (int)strlcpy(bufp, (char *)a->data.v, size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int nrd = 0;
|
||||
|
||||
/* Nachbarregionen, die gesehen werden, ermitteln */
|
||||
|
@ -1104,7 +1140,8 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_nb_final"), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_nb_next"), size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -1119,7 +1156,8 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
bytes = _snprintf(bufp, size, trailinto(r2, f->locale), regname);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -1132,7 +1170,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
/* Spezielle Richtungen */
|
||||
for (a = a_find(r->attribs, &at_direction); a && a->type == &at_direction;
|
||||
a = a->next) {
|
||||
spec_direction *d = (spec_direction *) (a->data.v);
|
||||
spec_direction *d = (spec_direction *)(a->data.v);
|
||||
bytes = (int)strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -1293,7 +1331,8 @@ static void statistics(FILE * F, const region * r, const faction * f)
|
|||
if (markets_module()) { /* hack */
|
||||
m =
|
||||
msg_message("nr_stat_salary_new", "max", wage(r, NULL, NULL, turn + 1));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
m = msg_message("nr_stat_salary", "max", wage(r, f, f->race, turn + 1));
|
||||
}
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
|
@ -1310,7 +1349,8 @@ static void statistics(FILE * F, const region * r, const faction * f)
|
|||
if (!markets_module()) {
|
||||
if (buildingtype_exists(r, bt_find("caravan"), true)) {
|
||||
m = msg_message("nr_stat_luxuries", "max", (p * 2) / TRADE_FRACTION);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
m = msg_message("nr_stat_luxuries", "max", p / TRADE_FRACTION);
|
||||
}
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
|
@ -1354,9 +1394,9 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
|
|||
|
||||
/* How many are we listing? For grammar. */
|
||||
for (a = abegin; a && a->type == &at_travelunit; a = a->next) {
|
||||
unit *u = (unit *) a->data.v;
|
||||
unit *u = (unit *)a->data.v;
|
||||
|
||||
if (r != u->region && (!u->ship || ship_owner(u->ship)==u)) {
|
||||
if (r != u->region && (!u->ship || ship_owner(u->ship) == u)) {
|
||||
if (cansee_durchgezogen(f, r, u, 0)) {
|
||||
++maxtravel;
|
||||
}
|
||||
|
@ -1371,15 +1411,16 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
|
|||
rnl(F);
|
||||
|
||||
for (a = abegin; a && a->type == &at_travelunit; a = a->next) {
|
||||
unit *u = (unit *) a->data.v;
|
||||
unit *u = (unit *)a->data.v;
|
||||
|
||||
if (r != u->region && (!u->ship || ship_owner(u->ship)==u)) {
|
||||
if (r != u->region && (!u->ship || ship_owner(u->ship) == u)) {
|
||||
if (cansee_durchgezogen(f, r, u, 0)) {
|
||||
++counter;
|
||||
if (u->ship != NULL) {
|
||||
if (counter == 1) {
|
||||
bytes = (int)strlcpy(bufp, "Die ", size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, "die ", size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0) {
|
||||
|
@ -1387,7 +1428,8 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
|
|||
break;
|
||||
}
|
||||
bytes = (int)strlcpy(bufp, shipname(u->ship), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, unitname(u), size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0) {
|
||||
|
@ -1401,7 +1443,8 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
|
|||
WARN_STATIC_BUFFER();
|
||||
break;
|
||||
}
|
||||
} else if (counter + 1 == maxtravel) {
|
||||
}
|
||||
else if (counter + 1 == maxtravel) {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "list_and"), size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -1412,7 +1455,7 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
|
|||
}
|
||||
}
|
||||
/* TODO: finish localization */
|
||||
if (size>0) {
|
||||
if (size > 0) {
|
||||
if (maxtravel == 1) {
|
||||
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "has_moved_one"));
|
||||
}
|
||||
|
@ -1463,7 +1506,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
|||
char buf[8192], *bufp;
|
||||
size_t size;
|
||||
int bytes;
|
||||
bool utf8 = _strcmpl(charset, "utf8")==0 || _strcmpl(charset, "utf-8")==0;
|
||||
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
|
||||
|
||||
if (F == NULL) {
|
||||
perror(filename);
|
||||
|
@ -1521,7 +1564,8 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
|||
if (pl && pl->id != 0) {
|
||||
sprintf(buf, "%s %d,%d,%d ; %s", LOC(f->locale,
|
||||
parameters[P_REGION]), nx, ny, pl->id, rname(r, f->locale));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sprintf(buf, "%s %d,%d ; %s", LOC(f->locale, parameters[P_REGION]),
|
||||
nx, ny, rname(r, f->locale));
|
||||
}
|
||||
|
@ -1542,7 +1586,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
|||
unitid(u), u->name, u->number, get_money(u));
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
if (u->building && building_owner(u->building)==u) {
|
||||
if (u->building && building_owner(u->building) == u) {
|
||||
building *b = u->building;
|
||||
int cost = buildingmaintenance(b, rsilver);
|
||||
|
||||
|
@ -1554,10 +1598,12 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
|||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
} else if (u->ship) {
|
||||
if (ship_owner(u->ship)==u) {
|
||||
}
|
||||
else if (u->ship) {
|
||||
if (ship_owner(u->ship) == u) {
|
||||
bytes = (int)strlcpy(bufp, ",S", size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, ",s", size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -1636,7 +1682,8 @@ show_allies(const faction * f, const ally * allies, char *buf, size_t size)
|
|||
if (dh) {
|
||||
if (i == allierte) {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "list_and"), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, ", ", size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -1654,7 +1701,8 @@ show_allies(const faction * f, const ally * allies, char *buf, size_t size)
|
|||
bytes = (int)strlcpy(bufp, locale_string(f->locale, parameters[P_ANY]), size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (h = 1; h < HELP_ALL; h *= 2) {
|
||||
int p = MAXPARAMS;
|
||||
if ((mode & h) == h) {
|
||||
|
@ -1685,7 +1733,7 @@ show_allies(const faction * f, const ally * allies, char *buf, size_t size)
|
|||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)strlcpy(bufp, parameters[p], size);
|
||||
bytes = (int)strlcpy(bufp, locale_string(f->locale, parameters[p]), size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
hh = 1;
|
||||
|
@ -1710,11 +1758,7 @@ static void allies(FILE * F, const faction * f)
|
|||
if (f->allies) {
|
||||
int bytes;
|
||||
size_t size = sizeof(buf);
|
||||
if (!f->allies->next) {
|
||||
bytes = _snprintf(buf, size, "%s ", LOC(f->locale, "faction_help_one"));
|
||||
} else {
|
||||
bytes = _snprintf(buf, size, "%s ", LOC(f->locale, "faction_help_many"));
|
||||
}
|
||||
bytes = _snprintf(buf, size, "%s ", LOC(f->locale, "faction_help"));
|
||||
size -= bytes;
|
||||
show_allies(f, f->allies, buf + bytes, size);
|
||||
rparagraph(F, buf, 0, 0, 0);
|
||||
|
@ -1725,11 +1769,7 @@ static void allies(FILE * F, const faction * f)
|
|||
if (g->allies) {
|
||||
int bytes;
|
||||
size_t size = sizeof(buf);
|
||||
if (!g->allies->next) {
|
||||
bytes = _snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help_one"));
|
||||
} else {
|
||||
bytes = _snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help_many"));
|
||||
}
|
||||
bytes = _snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help"));
|
||||
size -= bytes;
|
||||
show_allies(f, g->allies, buf + bytes, size);
|
||||
rparagraph(F, buf, 0, 0, 0);
|
||||
|
@ -1765,7 +1805,8 @@ static void guards(FILE * F, const region * r, const faction * see)
|
|||
|
||||
if (f != see && fval(u, UFL_ANON_FACTION)) {
|
||||
tarned = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (i = 0; i != nextguard; ++i)
|
||||
if (guardians[i] == f)
|
||||
break;
|
||||
|
@ -1790,7 +1831,8 @@ static void guards(FILE * F, const region * r, const faction * see)
|
|||
if (i != 0) {
|
||||
if (i == nextguard - (tarned ? 0 : 1)) {
|
||||
bytes = (int)strlcpy(bufp, LOC(see->locale, "list_and"), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, ", ", size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -1798,7 +1840,8 @@ static void guards(FILE * F, const region * r, const faction * see)
|
|||
}
|
||||
if (i < nextguard) {
|
||||
bytes = (int)strlcpy(bufp, factionname(guardians[i]), size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, "unbekannten Einheiten", size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
|
@ -1856,7 +1899,7 @@ static void list_address(FILE * F, const faction * uf, quicklist * seenfactions)
|
|||
|
||||
static void
|
||||
nr_ship(FILE * F, const seen_region * sr, const ship * sh, const faction * f,
|
||||
const unit * captain)
|
||||
const unit * captain)
|
||||
{
|
||||
const region *r = sr->r;
|
||||
char buffer[8192], *bufp = buffer;
|
||||
|
@ -1873,7 +1916,8 @@ nr_ship(FILE * F, const seen_region * sr, const ship * sh, const faction * f,
|
|||
|
||||
bytes = _snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh),
|
||||
LOC(f->locale, sh->type->_name), n, shipcapacity(sh) / 100);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bytes =
|
||||
_snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale,
|
||||
sh->type->_name));
|
||||
|
@ -1930,7 +1974,7 @@ nr_ship(FILE * F, const seen_region * sr, const ship * sh, const faction * f,
|
|||
|
||||
static void
|
||||
nr_building(FILE * F, const seen_region * sr, const building * b,
|
||||
const faction * f)
|
||||
const faction * f)
|
||||
{
|
||||
int i, bytes;
|
||||
const char *name, *bname, *billusion = NULL;
|
||||
|
@ -2078,7 +2122,7 @@ static void nr_paragraph(FILE * F, message * m, faction * f)
|
|||
|
||||
int
|
||||
report_plaintext(const char *filename, report_context * ctx,
|
||||
const char *charset)
|
||||
const char *charset)
|
||||
{
|
||||
int flag = 0;
|
||||
char ch;
|
||||
|
@ -2096,7 +2140,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
seen_region *sr = NULL;
|
||||
char buf[8192];
|
||||
char *bufp;
|
||||
bool utf8 = _strcmpl(charset, "utf8")==0 || _strcmpl(charset, "utf-8")==0;
|
||||
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
|
||||
size_t size;
|
||||
|
||||
/* static variables can cope with writing for different turns */
|
||||
|
@ -2245,7 +2289,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
if (thisseason == 0) {
|
||||
centre(F, LOC(f->locale, "nr_insectwinter"), true);
|
||||
rnl(F);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (nextseason == 0) {
|
||||
centre(F, LOC(f->locale, "nr_insectfall"), true);
|
||||
rnl(F);
|
||||
|
@ -2283,7 +2328,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
rnl(F);
|
||||
centre(F, LOC(f->locale, "section_newspells"), true);
|
||||
while (a && a->type == &at_reportspell) {
|
||||
spellbook_entry *sbe = (spellbook_entry *) a->data.v;
|
||||
spellbook_entry *sbe = (spellbook_entry *)a->data.v;
|
||||
nr_spell(F, sbe, f->locale);
|
||||
a = a->next;
|
||||
}
|
||||
|
@ -2374,7 +2419,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
if (herb && lux) {
|
||||
m = msg_message("nr_market_info_p", "p1 p2",
|
||||
lux ? lux->rtype : 0, herb ? herb->rtype : 0);
|
||||
} else if (lux || herb) {
|
||||
}
|
||||
else if (lux || herb) {
|
||||
m = msg_message("nr_market_info_s", "p1",
|
||||
lux ? lux->rtype : herb->rtype);
|
||||
}
|
||||
|
@ -2383,7 +2429,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
nr_paragraph(F, m, f);
|
||||
}
|
||||
/* */
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!fval(r->terrain, SEA_REGION) && rpeasants(r) / TRADE_FRACTION > 0) {
|
||||
rnl(F);
|
||||
prices(F, r, f);
|
||||
|
@ -2391,15 +2438,18 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
}
|
||||
guards(F, r, f);
|
||||
durchreisende(F, r, f);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (sr->mode == see_far) {
|
||||
describe(F, sr, f);
|
||||
guards(F, r, f);
|
||||
durchreisende(F, r, f);
|
||||
} else if (sr->mode == see_lighthouse) {
|
||||
}
|
||||
else if (sr->mode == see_lighthouse) {
|
||||
describe(F, sr, f);
|
||||
durchreisende(F, r, f);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
describe(F, sr, f);
|
||||
durchreisende(F, r, f);
|
||||
}
|
||||
|
@ -2467,7 +2517,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
if (!anyunits) {
|
||||
rnl(F);
|
||||
rparagraph(F, LOC(f->locale, "nr_youaredead"), 0, 2, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
list_address(F, f, ctx->addresses);
|
||||
}
|
||||
}
|
||||
|
@ -2544,7 +2595,8 @@ static void add_find(faction * f, unit * u, faction * f2)
|
|||
if (!*fp) {
|
||||
fs = *fp = calloc(sizeof(struct fsee), 1);
|
||||
fs->f = f;
|
||||
} else
|
||||
}
|
||||
else
|
||||
fs = *fp;
|
||||
sp = &fs->see;
|
||||
while (*sp && (*sp)->seen != f2)
|
||||
|
@ -2553,7 +2605,8 @@ static void add_find(faction * f, unit * u, faction * f2)
|
|||
ss = *sp = calloc(sizeof(struct see), 1);
|
||||
ss->proof = u;
|
||||
ss->seen = f2;
|
||||
} else
|
||||
}
|
||||
else
|
||||
ss = *sp;
|
||||
ss->proof = u;
|
||||
}
|
||||
|
@ -2586,7 +2639,7 @@ static void update_find(void)
|
|||
bool kann_finden(faction * f1, faction * f2)
|
||||
{
|
||||
update_find();
|
||||
return (bool) (can_find(f1, f2) != NULL);
|
||||
return (bool)(can_find(f1, f2) != NULL);
|
||||
}
|
||||
|
||||
/******* end summary ******/
|
||||
|
|
|
@ -9,36 +9,6 @@
|
|||
CuSuite *get_##name##_suite(void); \
|
||||
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)
|
||||
{
|
||||
CuString *output = CuStringNew();
|
||||
|
@ -56,6 +26,7 @@ int RunAllTests(void)
|
|||
ADD_TESTS(suite, direction);
|
||||
ADD_TESTS(suite, skill);
|
||||
ADD_TESTS(suite, keyword);
|
||||
ADD_TESTS(suite, order);
|
||||
/* util */
|
||||
ADD_TESTS(suite, config);
|
||||
ADD_TESTS(suite, base36);
|
||||
|
|
Loading…
Reference in New Issue