diff --git a/src/battle.c b/src/battle.c index 73c0a74ec..8499ae3db 100644 --- a/src/battle.c +++ b/src/battle.c @@ -4236,48 +4236,48 @@ static void battle_flee(battle * b) } static bool is_enemy(battle *b, unit *u1, unit *u2) { - if (u1->faction != u2->faction) { - if (b) { - side *es, *s1 = 0, *s2 = 0; - for (es = b->sides; es != b->sides + b->nsides; ++es) { - if (!s1 && es->faction == u1->faction) s1 = es; - else if (!s2 && es->faction == u2->faction) s2 = es; - if (s1 && s2) break; - } - return enemy(s1, s2); - } - else { - return !help_enter(u1, u2); - } - } - return false; + if (u1->faction != u2->faction) { + if (b) { + side *es, *s1 = 0, *s2 = 0; + for (es = b->sides; es != b->sides + b->nsides; ++es) { + if (!s1 && es->faction == u1->faction) s1 = es; + else if (!s2 && es->faction == u2->faction) s2 = es; + if (s1 && s2) break; + } + return enemy(s1, s2); + } + else { + return !help_enter(u1, u2); + } + } + return false; } void force_leave(region *r, battle *b) { - unit *u; + unit *u; - for (u = r->units; u; u = u->next) { - unit *uo = NULL; - if (u->building) { - uo = building_owner(u->building); - } - if (u->ship && r->land) { - uo = ship_owner(u->ship); - } - if (uo && is_enemy(b, uo, u)) { - message *msg = NULL; - if (u->building) { - msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building); - } - else { - msg = msg_message("force_leave_ship", "unit owner ship", u, uo, u->ship); - } - if (msg) { - ADDMSG(&u->faction->msgs, msg); - } - leave(u, false); - } - } + for (u = r->units; u; u = u->next) { + unit *uo = NULL; + if (u->building) { + uo = building_owner(u->building); + } + if (u->ship && r->land) { + uo = ship_owner(u->ship); + } + if (uo && is_enemy(b, uo, u)) { + message *msg = NULL; + if (u->building) { + msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building); + } + else { + msg = msg_message("force_leave_ship", "unit owner ship", u, uo, u->ship); + } + if (msg) { + ADDMSG(&u->faction->msgs, msg); + } + leave(u, false); + } + } } diff --git a/src/battle.h b/src/battle.h index 8d29d733a..618850d31 100644 --- a/src/battle.h +++ b/src/battle.h @@ -130,13 +130,13 @@ extern "C" { } weapon; /*** fighter::person::flags ***/ -#define FL_TIRED 1 +#define FL_TIRED 1 #define FL_DAZZLED 2 /* durch Untote oder Dämonen eingeschüchtert */ #define FL_PANICED 4 #define FL_COURAGE 8 /* Helden fliehen nie */ #define FL_SLEEPING 16 -#define FL_STUNNED 32 /* eine Runde keinen Angriff */ -#define FL_HIT 64 /* the person at attacked */ +#define FL_STUNNED 32 /* eine Runde keinen Angriff */ +#define FL_HIT 64 /* the person at attacked */ typedef struct troop { struct fighter *fighter; @@ -270,7 +270,7 @@ extern "C" { const struct group * g, unsigned int flags, const struct faction * stealthfaction); int skilldiff(troop at, troop dt, int dist); - void force_leave(struct region *r, struct battle *b); + void force_leave(struct region *r, struct battle *b); #ifdef __cplusplus } diff --git a/src/bind_building.c b/src/bind_building.c index aa9ba8e79..714b915dd 100644 --- a/src/bind_building.c +++ b/src/bind_building.c @@ -1,4 +1,4 @@ -/* +/* +-------------------+ | | Enno Rehling | Eressea PBEM host | Christian Schlittchen @@ -191,13 +191,13 @@ static int tolua_building_create(lua_State * L) { region *r = (region *)tolua_tousertype(L, 1, 0); const char *bname = tolua_tostring(L, 2, 0); - if (!r) { - log_error("building.create expects a region as argument 1"); - } - if (!bname) { - log_error("building.create expects a name as argument 2"); - } - if (bname) { + if (!r) { + log_error("building.create expects a region as argument 1"); + } + if (!bname) { + log_error("building.create expects a name as argument 2"); + } + if (bname) { const building_type *btype = bt_find(bname); if (btype) { building *b = new_building(btype, r, default_locale); diff --git a/src/creport.c b/src/creport.c index f33d29c1c..59fa60ecb 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1441,13 +1441,13 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr) } } if (sr->mode == see_unit || sr->mode == see_travel) { - cr_output_messages(F, r->msgs, f); - { - message_list *mlist = r_getmessages(r, f); - if (mlist) - cr_output_messages(F, mlist, f); - } - } + cr_output_messages(F, r->msgs, f); + { + message_list *mlist = r_getmessages(r, f); + if (mlist) + cr_output_messages(F, mlist, f); + } + } /* buildings */ for (b = rbuildings(r); b; b = b->next) { int fno = -1; diff --git a/src/kernel/race.c b/src/kernel/race.c index 2c86c5e51..53771a24c 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -183,7 +183,7 @@ race *rc_get_or_create(const char *zName) rc->recruit_multi = 1.0F; rc->regaura = 1.0F; rc->speed = 1.0F; - rc->battle_flags = BF_CANATTACK; + rc->battle_flags = BF_CANATTACK; if (strchr(zName, ' ') != NULL) { log_error("race '%s' has an invalid name. remove spaces\n", zName); assert(strchr(zName, ' ') == NULL); diff --git a/src/laws.c b/src/laws.c index fb4daa76f..40d224e7f 100755 --- a/src/laws.c +++ b/src/laws.c @@ -4312,7 +4312,7 @@ bool help_enter(unit *uo, unit *u) { } static void do_force_leave(region *r) { - force_leave(r, NULL); + force_leave(r, NULL); } bool rule_force_leave(int flags) { @@ -4356,11 +4356,11 @@ void init_processor(void) { int p; - while (processors) { - processor * next = processors->next; - free(processors); - processors = next; - } + while (processors) { + processor * next = processors->next; + free(processors); + processors = next; + } p = 10; add_proc_global(p, new_units, "Neue Einheiten erschaffen"); @@ -4514,7 +4514,7 @@ void processorders(void) { init_processor(); - update_spells(); + update_spells(); process(); /*************************************************/ diff --git a/src/reports.c b/src/reports.c index be2114f97..51ce2c53b 100644 --- a/src/reports.c +++ b/src/reports.c @@ -114,18 +114,18 @@ const char *combatstatus[] = { const char *report_kampfstatus(const unit * u, const struct locale *lang) { static char fsbuf[64]; // FIXME: static return value - const char * status = LOC(lang, combatstatus[u->status]); + const char * status = LOC(lang, combatstatus[u->status]); - if (!status) { - const char *lname = locale_name(lang); - struct locale *wloc = get_or_create_locale(lname); - log_error("no translation for combat status %s in %s", combatstatus[u->status], lname); - locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]); - strlcpy(fsbuf, combatstatus[u->status], sizeof(fsbuf)); - } - else { - strlcpy(fsbuf, status, sizeof(fsbuf)); - } + if (!status) { + const char *lname = locale_name(lang); + struct locale *wloc = get_or_create_locale(lname); + log_error("no translation for combat status %s in %s", combatstatus[u->status], lname); + locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]); + strlcpy(fsbuf, combatstatus[u->status], sizeof(fsbuf)); + } + else { + strlcpy(fsbuf, status, sizeof(fsbuf)); + } if (fval(u, UFL_NOAID)) { strcat(fsbuf, ", "); strcat(fsbuf, LOC(lang, "status_noaid")); @@ -139,7 +139,7 @@ const char *hp_status(const unit * u) double p; int max_hp = u->number * unit_max_hp(u); - if (u->hp == max_hp) + if (u->hp == max_hp) return NULL; p = (double)((double)u->hp / (double)(max_hp)); @@ -978,7 +978,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned assert(width <= REPORTWIDTH); width -= indent; - firstline = (mark!=0 && indent>2); + firstline = (mark != 0 && indent > 2); *SP = 0; while (len > 0) { @@ -1002,7 +1002,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned if (!cut) { cut = s + _min(len, REPORTWIDTH); } - strncpy(buf+indent, s, cut - s); + strncpy(buf + indent, s, cut - s); buf[indent + (cut - s)] = 0; addstrlist(SP, buf); // TODO: too much string copying, cut out this function while (*cut == ' ') { @@ -2445,7 +2445,7 @@ static void eval_trail(struct opstack **stack, const void *userdata) } } *bufp = 0; - var.v = strcpy(balloc((size_t)(bufp - buf +1)), buf); + var.v = strcpy(balloc((size_t)(bufp - buf + 1)), buf); opush(stack, var); #ifdef _SECURECRT_ERRCODE_VALUES_DEFINED if (errno == ERANGE) { diff --git a/src/util/bsdstring.c b/src/util/bsdstring.c index 865e0198e..5ec87bfa1 100644 --- a/src/util/bsdstring.c +++ b/src/util/bsdstring.c @@ -31,7 +31,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz) register const char *s = src; register size_t n = siz; - assert(src && dst); + assert(src && dst); /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { do {