deprecate report_kampfstatus and implement a replacement function.

This commit is contained in:
Enno Rehling 2015-10-27 12:32:32 +01:00
parent 61cee2606b
commit e23a7fc87d
6 changed files with 25 additions and 11 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

@ -120,29 +120,36 @@ 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 len;
}
const char * report_kampfstatus(const unit * u, const struct locale *lang) {
static char fsbuf[64]; // FIXME: static variable.
report_status(u, lang, fsbuf, sizeof(fsbuf));
return fsbuf; return fsbuf;
} }
const char *hp_status(const unit * u) const char *hp_status(const unit * u)
{ {
double p; double p;
@ -564,6 +571,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);
// FIXME: use report_status
bufp = STRLCPY(bufp, report_kampfstatus(u, f->locale), size); bufp = STRLCPY(bufp, report_kampfstatus(u, f->locale), size);
if (c || fval(u, UFL_HUNGER)) { if (c || fval(u, UFL_HUNGER)) {
bufp = STRLCPY(bufp, " (", size); bufp = STRLCPY(bufp, " (", size);

View File

@ -85,8 +85,10 @@ extern "C" {
const char *trailinto(const struct region *r, const char *trailinto(const struct region *r,
const struct locale *lang); const struct locale *lang);
size_t report_status(const struct unit *u,
const struct locale *lang, char *buf, size_t siz);
const char *report_kampfstatus(const struct unit *u, const char *report_kampfstatus(const struct unit *u,
const struct locale *lang); const struct locale *lang); // FIXME: kill this (static variable)
void register_reports(void); void register_reports(void);

View File

@ -59,7 +59,7 @@ 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); const char *str = report_kampfstatus(target, u->faction->locale); // FIXME: use report_status instead
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, str));