Merge pull request #322 from ennorehling/feature/fixme-kampfstatus-static

Feature/fixme kampfstatus static
This commit is contained in:
Enno Rehling 2015-10-27 13:29:17 +01:00
commit 6d52cd14ed
8 changed files with 23 additions and 17 deletions

View file

@ -4,7 +4,6 @@ while [ ! -d $ROOT/.git ]; do
ROOT=`dirname $ROOT` ROOT=`dirname $ROOT`
done done
[ -z "$CC" ] && CC=clang
[ -z "$BUILD" ] && BUILD=Debug [ -z "$BUILD" ] && BUILD=Debug
[ -z "$JOBS" ] && [ "" != "which nproc" ] && JOBS=`nproc` [ -z "$JOBS" ] && [ "" != "which nproc" ] && JOBS=`nproc`
@ -14,11 +13,15 @@ JOBS=`distcc -j`
if [ -z "$JOBS" ] ; then if [ -z "$JOBS" ] ; then
JOBS=1 JOBS=1
elif [ $JOBS -gt 1 ] ; then elif [ $JOBS -gt 1 ] ; then
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
CC="$DISTCC $CC" CC="$DISTCC $CC"
MAKEOPTS=-j$JOBS MAKEOPTS=-j$JOBS
fi fi
fi fi
echo "Building with CC=$CC and $JOBS jobs" echo "Building with $JOBS jobs"
if [ ! -d $ROOT/$BUILD ]; then if [ ! -d $ROOT/$BUILD ]; then
echo "cannot find build directory $BUILD in $ROOT. did you run cmake-init?" echo "cannot find build directory $BUILD in $ROOT. did you run cmake-init?"

View file

@ -10,7 +10,7 @@ done
[ -z $BUILD ] && BUILD=Debug [ -z $BUILD ] && BUILD=Debug
MACHINE=`uname -m` MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" [ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"

View file

@ -11,6 +11,7 @@ done
DEST=$(dirname $ROOT)/server DEST=$(dirname $ROOT)/server
MACHINE=`uname -m` MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" [ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"

View file

@ -1691,7 +1691,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
if (was == DO_PRECOMBATSPELL) { if (was == DO_PRECOMBATSPELL) {
for (s = b->sides; s != b->sides + b->nsides; ++s) { for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *fig = 0; fighter *fig = 0;
if (fval(s->faction, FFL_CURSED) && s->bf->attacker) { if (s->bf->attacker && fval(s->faction, FFL_CURSED)) {
spell *sp = find_spell("igjarjuk"); spell *sp = find_spell("igjarjuk");
if (sp) { if (sp) {
int si; int si;

View file

@ -113,7 +113,7 @@ spell *find_spell(const char *name)
cb_get_kv(match, &sp, sizeof(sp)); cb_get_kv(match, &sp, sizeof(sp));
} }
else { else {
log_warning("find_spell: could not find spell '%s'\n", name); log_debug("find_spell: could not find spell '%s'\n", name);
} }
return sp; return sp;
} }

View file

@ -120,27 +120,27 @@ const char *combatstatus[] = {
"status_avoid", "status_flee" "status_avoid", "status_flee"
}; };
const char *report_kampfstatus(const unit * u, const struct locale *lang) size_t report_status(const unit * u, const struct locale *lang, char *fsbuf, size_t buflen)
{ {
static char fsbuf[64]; // FIXME: static return value
const char * status = LOC(lang, combatstatus[u->status]); const char * status = LOC(lang, combatstatus[u->status]);
size_t len = 0;
if (!status) { if (!status) {
const char *lname = locale_name(lang); const char *lname = locale_name(lang);
struct locale *wloc = get_or_create_locale(lname); struct locale *wloc = get_or_create_locale(lname);
log_error("no translation for combat status %s in %s", combatstatus[u->status], lname); log_error("no translation for combat status %s in %s", combatstatus[u->status], lname);
locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]); locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]);
strlcpy(fsbuf, combatstatus[u->status], sizeof(fsbuf)); len = strlcpy(fsbuf, combatstatus[u->status], buflen);
} }
else { else {
strlcpy(fsbuf, status, sizeof(fsbuf)); len = strlcpy(fsbuf, status, buflen);
} }
if (fval(u, UFL_NOAID)) { if (fval(u, UFL_NOAID)) {
strcat(fsbuf, ", "); len += strlcat(fsbuf+len, ", ", buflen-len);
strcat(fsbuf, LOC(lang, "status_noaid")); len += strlcat(fsbuf+len, LOC(lang, "status_noaid"), buflen-len);
} }
return fsbuf; return len;
} }
const char *hp_status(const unit * u) const char *hp_status(const unit * u)
@ -564,7 +564,7 @@ size_t size)
const char *c = hp_status(u); const char *c = hp_status(u);
c = c ? LOC(f->locale, c) : 0; c = c ? LOC(f->locale, c) : 0;
bufp = STRLCPY(bufp, ", ", size); bufp = STRLCPY(bufp, ", ", size);
bufp = STRLCPY(bufp, report_kampfstatus(u, f->locale), size); bufp += report_status(u, f->locale, bufp, size);
if (c || fval(u, UFL_HUNGER)) { if (c || fval(u, UFL_HUNGER)) {
bufp = STRLCPY(bufp, " (", size); bufp = STRLCPY(bufp, " (", size);
if (c) { if (c) {

View file

@ -85,8 +85,8 @@ extern "C" {
const char *trailinto(const struct region *r, const char *trailinto(const struct region *r,
const struct locale *lang); const struct locale *lang);
const char *report_kampfstatus(const struct unit *u, size_t report_status(const struct unit *u,
const struct locale *lang); const struct locale *lang, char *buf, size_t siz);
void register_reports(void); void register_reports(void);

View file

@ -59,10 +59,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* Spionage des Spions */ * Spionage des Spions */
void spy_message(int spy, const unit * u, const unit * target) void spy_message(int spy, const unit * u, const unit * target)
{ {
const char *str = report_kampfstatus(target, u->faction->locale); char status[32];
report_status(target, u->faction->locale, status, sizeof(status));
ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u, ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u,
target, str)); target, status));
if (spy > 20) { if (spy > 20) {
sc_mage *mage = get_mage(target); sc_mage *mage = get_mage(target);
/* for mages, spells and magic school */ /* for mages, spells and magic school */