From 4a31bea3b9e138e285c92af405cff1c270c5b77e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 8 Jun 2015 09:46:07 +0200 Subject: [PATCH 1/6] increase build number, new version installed --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index 0ffd496d9..d1f3c3fcf 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 5 -#define VERSION_BUILD 1 +#define VERSION_BUILD 2 From 04bf7153f09211ef0101b33c043d6e2fec952acb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 21 Jun 2015 17:49:22 +0200 Subject: [PATCH 2/6] remove a faction from its alliance when it is dead. --- src/kernel/alliance.test.c | 3 +++ src/kernel/faction.c | 3 +++ src/kernel/faction.test.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/kernel/alliance.test.c b/src/kernel/alliance.test.c index ad936fac9..98e60e943 100644 --- a/src/kernel/alliance.test.c +++ b/src/kernel/alliance.test.c @@ -55,6 +55,9 @@ static void test_alliance_join(CuTest *tc) { setalliance(fix.f2, al); CuAssertPtrEquals(tc, fix.f1, alliance_get_leader(al)); CuAssertTrue(tc, is_allied(fix.f1, fix.f2)); + setalliance(fix.f1, 0); + CuAssertPtrEquals(tc, fix.f2, alliance_get_leader(al)); + CuAssertTrue(tc, !is_allied(fix.f1, fix.f2)); test_cleanup(); } diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 72643c3cb..95d3b7392 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -651,6 +651,9 @@ void remove_empty_factions(void) *fp = f->next; funhash(f); free_faction(f); + if (f->alliance && f->alliance->_leader == f) { + setalliance(f, 0); + } free(f); } else diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 4852b08dc..ef22b40cd 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,22 @@ static void test_remove_empty_factions_allies(CuTest *tc) { test_cleanup(); } +static void test_remove_empty_factions_alliance(CuTest *tc) { + faction *f; + struct alliance *al; + region *r; + + test_cleanup(); + r = test_create_region(0, 0, 0); + f = test_create_faction(0); + al = makealliance(0, "Hodor"); + setalliance(f, al); + CuAssertPtrEquals(tc, f, alliance_get_leader(al)); + remove_empty_factions(); + CuAssertPtrEquals(tc, 0, al->_leader); + test_cleanup(); +} + static void test_remove_empty_factions(CuTest *tc) { faction *f, *fm; int fno; @@ -130,6 +147,7 @@ CuSuite *get_faction_suite(void) SUITE_ADD_TEST(suite, test_addfaction); SUITE_ADD_TEST(suite, test_remove_empty_factions); SUITE_ADD_TEST(suite, test_remove_empty_factions_allies); + SUITE_ADD_TEST(suite, test_remove_empty_factions_alliance); SUITE_ADD_TEST(suite, test_remove_dead_factions); SUITE_ADD_TEST(suite, test_get_monsters); SUITE_ADD_TEST(suite, test_set_origin); From a085442b8f03264e0cc9a396560d394d2a271023 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 21 Jun 2015 17:54:39 +0200 Subject: [PATCH 3/6] eliminate unused variable. --- src/kernel/faction.test.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index ef22b40cd..8b3c7e0af 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -34,10 +34,8 @@ static void test_remove_empty_factions_allies(CuTest *tc) { static void test_remove_empty_factions_alliance(CuTest *tc) { faction *f; struct alliance *al; - region *r; test_cleanup(); - r = test_create_region(0, 0, 0); f = test_create_faction(0); al = makealliance(0, "Hodor"); setalliance(f, al); From 9b42824a5ebdfdfa668d19fcf52853e8e25d62db Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 26 Jun 2015 14:26:42 +0200 Subject: [PATCH 4/6] Bug 2112: volcano stops smoking after it has erupted. https://bugs.eressea.de/view.php?id=2112 --- src/randenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/randenc.c b/src/randenc.c index 3c7988a20..12b1aec58 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -1126,6 +1126,7 @@ void randomevents(void) } else if (r->age > 20 && rng_int() % 100 < 8) { volcano_outbreak(r); + rsetterrain(r, T_VOLCANO); } } } From 3ba2b3d4d72efb182dd4bae69869a83bf0bdc377 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 26 Jun 2015 14:31:21 +0200 Subject: [PATCH 5/6] indentation fixes (tab->spaces) --- src/battle.c | 76 ++++++++++++++++++++++---------------------- src/battle.h | 8 ++--- src/bind_building.c | 16 +++++----- src/creport.c | 14 ++++---- src/kernel/race.c | 2 +- src/laws.c | 14 ++++---- src/reports.c | 30 ++++++++--------- src/util/bsdstring.c | 2 +- 8 files changed, 81 insertions(+), 81 deletions(-) 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 { From 94ec39d7bbb2e6b5d2bb435a559b382e45e65ece Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 26 Jun 2015 14:44:28 +0200 Subject: [PATCH 6/6] Bug 2114: broken army listing during combat. https://bugs.eressea.de/view.php?id=2114 --- src/battle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle.c b/src/battle.c index 8499ae3db..9761f2978 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3760,7 +3760,7 @@ static int battle_report(battle * b) char buffer[32]; if (komma) { - strlcpy(bufp, ", ", size); + bytes = strlcpy(bufp, ", ", size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); }