From d2d782c761b884b0a779dbcb9976520254e530a2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 8 Sep 2019 13:06:24 +0200 Subject: [PATCH 01/72] Bug 2606: KAUFE braucht eine Burg. --- src/economy.c | 7 ++++--- src/economy.h | 3 +++ src/economy.test.c | 29 +++++++++++++++++++++++++++-- src/tests.c | 4 ++-- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/economy.c b/src/economy.c index ecbd27db0..ffb9b0211 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1174,7 +1174,8 @@ attrib_type at_trades = { NO_READ }; -static bool trade_needs_castle(const region *r, const race *rc) { +bool trade_needs_castle(const terrain_type *terrain, const race *rc) +{ static int rc_change, terrain_change; static const race *rc_insect; static const terrain_type *t_desert, *t_swamp; @@ -1185,7 +1186,7 @@ static bool trade_needs_castle(const region *r, const race *rc) { t_swamp = newterrain(T_SWAMP); t_desert = newterrain(T_DESERT); } - return rc != rc_insect && (r->terrain == t_swamp || r->terrain == t_desert); + return rc != rc_insect && (terrain == t_swamp || terrain == t_desert); } static void buy(unit * u, econ_request ** buyorders, struct order *ord) @@ -1221,7 +1222,7 @@ static void buy(unit * u, econ_request ** buyorders, struct order *ord) /* Entweder man ist Insekt in Sumpf/Wueste, oder es muss * einen Handelsposten in der Region geben: */ - if (trade_needs_castle(r, u_race(u))) { + if (trade_needs_castle(r->terrain, u_race(u))) { building *b = NULL; if (r->buildings) { static int cache; diff --git a/src/economy.h b/src/economy.h index 94c0997c8..2eace8a2d 100644 --- a/src/economy.h +++ b/src/economy.h @@ -49,6 +49,7 @@ extern "C" { struct faction; struct order; struct message; + struct terrain_type; struct item_type; typedef struct econ_request { @@ -85,6 +86,8 @@ extern "C" { void destroy(struct region *r); void produce(struct region *r); void auto_work(struct region *r); + + bool trade_needs_castle(const struct terrain_type *terrain, const struct race *rc); typedef enum income_t { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC, IC_LOOT } income_t; void add_income(struct unit * u, income_t type, int want, int qty); diff --git a/src/economy.test.c b/src/economy.test.c index f4fe84340..a66e3d2ff 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -233,10 +233,31 @@ static unit *setup_trade_unit(CuTest *tc, region *r, const struct race *rc) { return u; } +static void test_trade_needs_castle(CuTest *tc) { + /* Handeln ist nur in Regionen mit Burgen möglich. */ + race *rc; + region *r; + const terrain_type *t_swamp; + + test_setup(); + setup_production(); + test_create_locale(); + setup_terrains(tc); + init_terrains(); + t_swamp = get_terrain("swamp"); + r = setup_trade_region(tc, t_swamp); + rc = test_create_race(NULL); + + CuAssertTrue(tc, trade_needs_castle(t_swamp, rc)); + test_teardown(); +} + static void test_trade_insect(CuTest *tc) { /* Insekten koennen in Wuesten und Suempfen auch ohne Burgen handeln. */ unit *u; region *r; + race *rc; + const terrain_type *t_swamp; const item_type *it_luxury; const item_type *it_silver; @@ -244,14 +265,17 @@ static void test_trade_insect(CuTest *tc) { setup_production(); test_create_locale(); setup_terrains(tc); - r = setup_trade_region(tc, get_terrain("swamp")); init_terrains(); + t_swamp = get_terrain("swamp"); + rc = test_create_race("insect"); + r = setup_trade_region(tc, t_swamp); it_luxury = r_luxury(r); + CuAssertTrue(tc, !trade_needs_castle(t_swamp, rc)); CuAssertPtrNotNull(tc, it_luxury); it_silver = get_resourcetype(R_SILVER)->itype; - u = setup_trade_unit(tc, r, test_create_race("insect")); + u = setup_trade_unit(tc, r, rc); unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", LOC(u->faction->locale, resourcename(it_luxury->rtype, 0)))); @@ -796,6 +820,7 @@ CuSuite *get_economy_suite(void) SUITE_ADD_TEST(suite, test_heroes_dont_recruit); SUITE_ADD_TEST(suite, test_tax_cmd); SUITE_ADD_TEST(suite, test_buy_cmd); + SUITE_ADD_TEST(suite, test_trade_needs_castle); SUITE_ADD_TEST(suite, test_trade_insect); SUITE_ADD_TEST(suite, test_maintain_buildings); SUITE_ADD_TEST(suite, test_recruit); diff --git a/src/tests.c b/src/tests.c index c0350a9de..6dbc84271 100644 --- a/src/tests.c +++ b/src/tests.c @@ -583,7 +583,7 @@ struct message * test_find_messagetype_ex(struct message_list *msgs, const char return ml->msg; } } - return 0; + return NULL; } struct message * test_find_messagetype(struct message_list *msgs, const char *name) @@ -603,7 +603,7 @@ void test_clear_messages(faction *f) { if (f->msgs) { free_messagelist(f->msgs->begin); free(f->msgs); - f->msgs = 0; + f->msgs = NULL; } } From 007721991da2507f7fc1081cff974a7dff90eb77 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 8 Sep 2019 13:29:10 +0200 Subject: [PATCH 02/72] Bug 2606: DRY, share code between buy and sell. --- src/economy.c | 52 ++++++++++++++++++---------------------------- src/economy.test.c | 43 ++++++++++++++++++++++++++------------ src/tests.c | 13 ++++++++++++ src/tests.h | 1 + 4 files changed, 64 insertions(+), 45 deletions(-) diff --git a/src/economy.c b/src/economy.c index ffb9b0211..c5cbe80c8 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1189,6 +1189,18 @@ bool trade_needs_castle(const terrain_type *terrain, const race *rc) return rc != rc_insect && (terrain == t_swamp || terrain == t_desert); } +static building * first_building(region *r, const struct building_type *btype, int minsize) { + building *b = NULL; + if (r->buildings) { + for (b = r->buildings; b; b = b->next) { + if (b->type == btype && b->size >= minsize) { + return b; + } + } + } + return NULL; +} + static void buy(unit * u, econ_request ** buyorders, struct order *ord) { char token[128]; @@ -1223,21 +1235,12 @@ static void buy(unit * u, econ_request ** buyorders, struct order *ord) /* Entweder man ist Insekt in Sumpf/Wueste, oder es muss * einen Handelsposten in der Region geben: */ if (trade_needs_castle(r->terrain, u_race(u))) { - building *b = NULL; - if (r->buildings) { - static int cache; - static const struct building_type *bt_castle; - if (bt_changed(&cache)) { - bt_castle = bt_find("castle"); - } - - for (b = r->buildings; b; b = b->next) { - if (b->type == bt_castle && b->size >= 2) { - break; - } - } + static int cache; + static const struct building_type *castle_bt; + if (bt_changed(&cache)) { + castle_bt = bt_find("castle"); } - if (b == NULL) { + if (first_building(r, castle_bt, 2) == NULL) { cmistake(u, ord, 119, MSG_COMMERCE); return; } @@ -1540,29 +1543,14 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord) return false; } } - /* In der Region muss es eine Burg geben. */ - if (u_race(u) == get_race(RC_INSECT)) { - if (r->terrain != newterrain(T_SWAMP) && r->terrain != newterrain(T_DESERT) - && !rbuildings(r)) { + if (trade_needs_castle(r->terrain, u_race(u))) { + /* In der Region muss es eine Burg geben. */ + if (first_building(r, castle_bt, 2) == NULL) { cmistake(u, ord, 119, MSG_COMMERCE); return false; } } - else { - /* ...oder in der Region muss es eine Burg geben. */ - building *b = 0; - if (r->buildings) { - for (b = r->buildings; b; b = b->next) { - if (b->type == castle_bt && b->size >= 2) break; - } - } - if (!b) { - cmistake(u, ord, 119, MSG_COMMERCE); - return false; - } - } - /* Ein Haendler kann nur 10 Gueter pro Talentpunkt verkaufen. */ i = u->number * 10 * effskill(u, SK_TRADE, NULL); diff --git a/src/economy.test.c b/src/economy.test.c index a66e3d2ff..e84bc17bf 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -237,7 +237,10 @@ static void test_trade_needs_castle(CuTest *tc) { /* Handeln ist nur in Regionen mit Burgen möglich. */ race *rc; region *r; + unit *u; + building *b; const terrain_type *t_swamp; + const item_type *it_luxury; test_setup(); setup_production(); @@ -246,9 +249,32 @@ static void test_trade_needs_castle(CuTest *tc) { init_terrains(); t_swamp = get_terrain("swamp"); r = setup_trade_region(tc, t_swamp); - rc = test_create_race(NULL); + it_luxury = r_luxury(r); + rc = test_create_race(NULL); CuAssertTrue(tc, trade_needs_castle(t_swamp, rc)); + + u = test_create_unit(test_create_faction(rc), r); + unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", + LOC(u->faction->locale, resourcename(it_luxury->rtype, 0)))); + unit_addorder(u, create_order(K_SELL, u->faction->locale, "1 %s", + LOC(u->faction->locale, resourcename(it_luxury->rtype, 0)))); + produce(r); + CuAssertIntEquals(tc, 2, test_count_messagetype(u->faction->msgs, "error119")); + + test_clear_messages(u->faction); + freset(u, UFL_LONGACTION); + b = test_create_building(r, test_create_buildingtype("castle")); + b->size = 1; + produce(r); + CuAssertIntEquals(tc, 2, test_count_messagetype(u->faction->msgs, "error119")); + + test_clear_messages(u->faction); + freset(u, UFL_LONGACTION); + b->size = 2; + test_clear_messages(u->faction); + produce(r); + CuAssertIntEquals(tc, 0, test_count_messagetype(u->faction->msgs, "error119")); test_teardown(); } @@ -259,7 +285,6 @@ static void test_trade_insect(CuTest *tc) { race *rc; const terrain_type *t_swamp; const item_type *it_luxury; - const item_type *it_silver; test_setup(); setup_production(); @@ -273,21 +298,13 @@ static void test_trade_insect(CuTest *tc) { it_luxury = r_luxury(r); CuAssertTrue(tc, !trade_needs_castle(t_swamp, rc)); CuAssertPtrNotNull(tc, it_luxury); - it_silver = get_resourcetype(R_SILVER)->itype; - u = setup_trade_unit(tc, r, rc); unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", LOC(u->faction->locale, resourcename(it_luxury->rtype, 0)))); - - test_set_item(u, it_silver, 10); - CuAssertPtrEquals(tc, r, u->region); - CuAssertPtrEquals(tc, (void *)it_luxury, (void *)r_luxury(u->region)); + unit_addorder(u, create_order(K_SELL, u->faction->locale, "1 %s", + LOC(u->faction->locale, resourcename(it_luxury->rtype, 0)))); produce(u->region); - CuAssertPtrEquals(tc, NULL, test_find_messagetype(u->faction->msgs, "error119")); - CuAssertIntEquals(tc, 1, get_item(u, it_luxury)); - CuAssertIntEquals(tc, 5, get_item(u, it_silver)); - - terraform_region(r, get_terrain("swamp")); + CuAssertIntEquals(tc, 0, test_count_messagetype(u->faction->msgs, "error119")); test_teardown(); } diff --git a/src/tests.c b/src/tests.c index 6dbc84271..727803e2d 100644 --- a/src/tests.c +++ b/src/tests.c @@ -591,6 +591,19 @@ struct message * test_find_messagetype(struct message_list *msgs, const char *na return test_find_messagetype_ex(msgs, name, NULL); } +int test_count_messagetype(struct message_list *msgs, const char *name) +{ + int count = 0; + struct mlist *ml; + if (!msgs) return 0; + for (ml = msgs->begin; ml; ml = ml->next) { + if (strcmp(name, test_get_messagetype(ml->msg)) == 0) { + ++count; + } + } + return count; +} + void test_clear_messagelist(message_list **msgs) { if (*msgs) { free_messagelist((*msgs)->begin); diff --git a/src/tests.h b/src/tests.h index 17da12d4e..b839596a6 100644 --- a/src/tests.h +++ b/src/tests.h @@ -64,6 +64,7 @@ extern "C" { void test_translate_param(const struct locale *lang, enum param_t param, const char *text); const char * test_get_messagetype(const struct message *msg); + int test_count_messagetype(struct message_list *msgs, const char *name); struct message * test_find_messagetype_ex(struct message_list *msgs, const char *name, struct message *prev); struct message * test_find_messagetype(struct message_list *msgs, const char *name); struct message * test_get_last_message(struct message_list *mlist); From cc77ce6f20627a5c2e30965d081704d05c702e9a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 10 Sep 2019 06:39:04 +0200 Subject: [PATCH 03/72] =?UTF-8?q?Tests=20f=C3=BCr=20Einheiten=20mit=20Pfer?= =?UTF-8?q?den.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tests/e2/horses.lua | 118 ++++++++++++++++++++++++++++++++++++ scripts/tests/e2/init.lua | 1 + src/bind_faction.c | 19 ++++++ 3 files changed, 138 insertions(+) create mode 100644 scripts/tests/e2/horses.lua diff --git a/scripts/tests/e2/horses.lua b/scripts/tests/e2/horses.lua new file mode 100644 index 000000000..7d7a67c66 --- /dev/null +++ b/scripts/tests/e2/horses.lua @@ -0,0 +1,118 @@ +require "lunit" + +module("tests.e2.capacity", package.seeall, lunit.testcase) + +function setup() + eressea.free_game() + eressea.settings.set("rules.food.flags", "4") + eressea.settings.set("nmr.timeout", "0") + eressea.settings.set("NewbieImmunity", "0") +end + +function test_walk() + local r1 = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "plain") + local f = faction.create("human", "pirate@eressea.de", "de") + local u1 = unit.create(f, r1, 1) + local u2 = unit.create(f, r1, 2) + local u3 = unit.create(f, r1, 1) + u1:add_item("money", 540) + u1:add_order("NACH O") + u2:add_item("money", 1080) + u2:add_order("NACH O") + u3:add_item("money", 541) + u3:add_order("NACH O") + process_orders() + assert_equal(r2, u1.region) + assert_equal(r2, u2.region) + assert_equal(r1, u3.region) +end + +function test_lead_horses() + local r1 = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "plain") + local r3 = region.create(2, 0, "plain") + local f = faction.create("human") + -- walk (don't ride) a horse to the next region: + local u1 = unit.create(f, r1, 1) + u1:add_item("horse", 1) + u1:add_item("money", 2540) + u1:add_order("NACH O O") + -- too heavy to move: + local u2 = unit.create(f, r1, 1) + u2:add_item("horse", 1) + u2:add_item("money", 2541) + u2:add_order("NACH O O") + -- too many horses: + local u3 = unit.create(f, r1, 1) + u3:add_item("horse", 2) + u3:add_item("money", 2540) + u3:add_order("NACH O O") + -- riders can lead 4 extra horses per level: + local u4 = unit.create(f, r1, 1) + u4:set_skill("riding", 1) + u4:add_item("horse", 5) + u4:add_item("money", 540+2000*5) + u4:add_order("NACH O O") + + process_orders() + assert_equal(r2, u1.region) + assert_equal(r1, u2.region) + assert_equal(r1, u3.region) + assert_equal(r2, u4.region) +end + +function test_ride_horses() + local r0 = region.create(0, 0, "plain") + local r1 = region.create(1, 0, "plain") + local r2 = region.create(2, 0, "plain") + local r3 = region.create(3, 0, "plain") + local f = faction.create("human") + -- ride a horse two regions: + local u1 = unit.create(f, r0, 1) + u1:set_skill("riding", 1) + u1:add_item("horse", 1) + u1:add_item("money", 1000) + u1:add_order("NACH O O O") + -- too heavy to ride, walk the horse: + local u2 = unit.create(f, r0, 1) + u2:set_skill("riding", 1) + u2:add_item("horse", 1) + u2:add_item("money", 2001) + u2:add_order("NACH O O O") + + process_orders() + -- mit 20 GE beladenes Pferd kommt 2 Regionen weit: + assert_equal(r2, u1.region) + -- überladenes Pferd kommt nur eine Region weit, zu Fuss: + assert_equal(r1, u2.region) +end + +function test_rider_leads_horses() + local r0 = region.create(0, 0, "plain") + local r1 = region.create(1, 0, "plain") + local r2 = region.create(2, 0, "plain") + local r3 = region.create(3, 0, "plain") + local f = faction.create("human") + -- lead 1 extra horse per level while riding: + local u1 = unit.create(f, r0, 1) + u1:set_skill("riding", 1) + u1:add_item("horse", 2) + u1:add_order("NACH O O O") + -- too heavy to ride, walk the horses: + local u2 = unit.create(f, r0, 1) + u2:set_skill("riding", 1) + u2:add_item("horse", 2) + u2:add_item("money", 2000 * 2) + u2:add_order("NACH O O") + -- too many horses, but can walk: + local u3 = unit.create(f, r0, 1) + u3:set_skill("riding", 1) + u3:add_item("horse", 5) + u3:add_order("NACH O O") + + process_orders() + assert_equal(r2, u1.region) + assert_equal(r1, u2.region) + assert_equal(r1, u3.region) +end diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 420ba3e06..d4fd0d4e8 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,3 +1,4 @@ +require 'tests.e2.horses' require 'tests.e2.quit' require 'tests.e2.movement' require 'tests.e2.astral' diff --git a/src/bind_faction.c b/src/bind_faction.c index 518dddc27..cfadbc6ab 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -34,6 +34,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include "attributes/key.h" @@ -261,6 +262,23 @@ static int tolua_faction_setkey(lua_State * L) return 0; } +static int tolua_faction_debug_messages(lua_State * L) +{ + faction *self = (faction *)tolua_tousertype(L, 1, NULL); + int i = 1; + mlist *ml; + if (!self->msgs) { + return 0; + } + lua_newtable(L); + for (ml = self->msgs->begin; ml; ml = ml->next, ++i) { + char buf[80]; + nr_render(ml->msg, default_locale, buf, sizeof(buf), NULL); + puts(buf); + } + return 1; +} + static int tolua_faction_get_messages(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, NULL); @@ -592,6 +610,7 @@ void tolua_faction_open(lua_State * L) /* tech debt hack, siehe https://paper.dropbox.com/doc/Weihnachten-2015-5tOx5r1xsgGDBpb0gILrv#:h=Probleme-mit-Tests-(Nachtrag-0 */ tolua_function(L, TOLUA_CAST "count_msg_type", tolua_faction_count_msg_type); tolua_variable(L, TOLUA_CAST "messages", tolua_faction_get_messages, NULL); + tolua_function(L, TOLUA_CAST "debug_messages", tolua_faction_debug_messages); tolua_function(L, TOLUA_CAST "get_key", tolua_faction_getkey); tolua_function(L, TOLUA_CAST "set_key", tolua_faction_setkey); From d9febc30d86d0204ec7581a81fd7a1e5961fca3c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Sep 2019 08:40:27 +0200 Subject: [PATCH 04/72] rostregen bugfix commit ruined indentation --- src/battle.c | 5532 +++++++++++++++++++++++++------------------------- 1 file changed, 2766 insertions(+), 2766 deletions(-) diff --git a/src/battle.c b/src/battle.c index 5384d80f5..0e8e0949b 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1171,2917 +1171,2917 @@ static void destroy_items(troop dt) { } static void calculate_defense_type(troop at, troop dt, int type, bool missile, - const weapon_type **dwtype, int *defskill) { - const weapon *weapon; - weapon = select_weapon(dt, false, true); /* missile=true to get the unmodified best weapon she has */ - *defskill = weapon_effskill(dt, at, weapon, false, false); - if (weapon != NULL) - *dwtype = weapon->type; - } + const weapon_type **dwtype, int *defskill) { + const weapon *weapon; + weapon = select_weapon(dt, false, true); /* missile=true to get the unmodified best weapon she has */ + *defskill = weapon_effskill(dt, at, weapon, false, false); + if (weapon != NULL) + *dwtype = weapon->type; +} - static void calculate_attack_type(troop at, troop dt, int type, bool missile, - const weapon_type **awtype, int *attskill, bool *magic) { - const weapon *weapon; - - switch (type) { - case AT_STANDARD: - weapon = select_weapon(at, true, missile); - *attskill = weapon_effskill(at, dt, weapon, true, missile); - if (weapon) - *awtype = weapon->type; - if (*awtype && fval(*awtype, WTF_MAGICAL)) - *magic = true; - break; - case AT_NATURAL: - *attskill = weapon_effskill(at, dt, NULL, true, missile); - break; - case AT_SPELL: - case AT_COMBATSPELL: +static void calculate_attack_type(troop at, troop dt, int type, bool missile, + const weapon_type **awtype, int *attskill, bool *magic) { + const weapon *weapon; + + switch (type) { + case AT_STANDARD: + weapon = select_weapon(at, true, missile); + *attskill = weapon_effskill(at, dt, weapon, true, missile); + if (weapon) + *awtype = weapon->type; + if (*awtype && fval(*awtype, WTF_MAGICAL)) *magic = true; - break; - default: - break; + break; + case AT_NATURAL: + *attskill = weapon_effskill(at, dt, NULL, true, missile); + break; + case AT_SPELL: + case AT_COMBATSPELL: + *magic = true; + break; + default: + break; + } +} + +static int crit_damage(int attskill, int defskill, const char *damage_formula) { + int damage = 0; + if (rule_damage & DAMAGE_CRITICAL) { + double kritchance = ((double)attskill * 3.0 - (double)defskill) / 200.0; + int maxk = 4; + + kritchance = fmax(kritchance, 0.005); + kritchance = fmin(0.9, kritchance); + + while (maxk-- && chance(kritchance)) { + damage += dice_rand(damage_formula); } } + return damage; +} - static int crit_damage(int attskill, int defskill, const char *damage_formula) { - int damage = 0; - if (rule_damage & DAMAGE_CRITICAL) { - double kritchance = ((double)attskill * 3.0 - (double)defskill) / 200.0; - int maxk = 4; - - kritchance = fmax(kritchance, 0.005); - kritchance = fmin(0.9, kritchance); - - while (maxk-- && chance(kritchance)) { - damage += dice_rand(damage_formula); - } - } - return damage; +static int apply_race_resistance(int reduced_damage, fighter *df, + const weapon_type *awtype, bool magic) { + unit *du = df->unit; + + if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic) + reduced_damage = 0; + else { + unsigned int i = 0; + + if (u_race(du)->battle_flags & BF_RES_PIERCE) + i |= WTF_PIERCE; + if (u_race(du)->battle_flags & BF_RES_CUT) + i |= WTF_CUT; + if (u_race(du)->battle_flags & BF_RES_BASH) + i |= WTF_BLUNT; + + if (i && awtype && fval(awtype, i)) + reduced_damage /= 2; } + return reduced_damage; +} - static int apply_race_resistance(int reduced_damage, fighter *df, - const weapon_type *awtype, bool magic) { - unit *du = df->unit; - - if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic) - reduced_damage = 0; - else { - unsigned int i = 0; - - if (u_race(du)->battle_flags & BF_RES_PIERCE) - i |= WTF_PIERCE; - if (u_race(du)->battle_flags & BF_RES_CUT) - i |= WTF_CUT; - if (u_race(du)->battle_flags & BF_RES_BASH) - i |= WTF_BLUNT; - - if (i && awtype && fval(awtype, i)) - reduced_damage /= 2; - } - return reduced_damage; - } - - static int apply_magicshield(int reduced_damage, fighter *df, - const weapon_type *awtype, battle *b, bool magic) { - side *ds = df->side; - selist *ql; - int qi; - - if (reduced_damage <= 0) - return 0; - - /* Schilde */ - for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { - meffect *me = (meffect *)selist_get(ql, qi); - if (meffect_protection(b, me, ds) != 0) { - assert(0 <= reduced_damage); /* rda sollte hier immer mindestens 0 sein */ +static int apply_magicshield(int reduced_damage, fighter *df, + const weapon_type *awtype, battle *b, bool magic) { + side *ds = df->side; + selist *ql; + int qi; + + if (reduced_damage <= 0) + return 0; + + /* Schilde */ + for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { + meffect *me = (meffect *)selist_get(ql, qi); + if (meffect_protection(b, me, ds) != 0) { + assert(0 <= reduced_damage); /* rda sollte hier immer mindestens 0 sein */ /* jeder Schaden wird um effect% reduziert bis der Schild duration * Trefferpunkte aufgefangen hat */ - if (me->typ == SHIELD_REDUCE) { - int hp = reduced_damage * (me->effect / 100); - reduced_damage -= hp; - me->duration -= hp; - } - /* gibt Ruestung +effect fuer duration Treffer */ - if (me->typ == SHIELD_ARMOR) { - reduced_damage -= me->effect; - if (reduced_damage < 0) reduced_damage = 0; - me->duration--; - } + if (me->typ == SHIELD_REDUCE) { + int hp = reduced_damage * (me->effect / 100); + reduced_damage -= hp; + me->duration -= hp; + } + /* gibt Ruestung +effect fuer duration Treffer */ + if (me->typ == SHIELD_ARMOR) { + reduced_damage -= me->effect; + if (reduced_damage < 0) reduced_damage = 0; + me->duration--; } } - - return reduced_damage; } + + return reduced_damage; +} - bool - terminate(troop dt, troop at, int type, const char *damage_formula, bool missile) - { - fighter *df = dt.fighter; - fighter *af = at.fighter; - unit *au = af->unit; - unit *du = df->unit; - battle *b = df->side->battle; - - int armor_value; - - const weapon_type *dwtype = NULL; - const weapon_type *awtype = NULL; - const armor_type *armor = NULL; - const armor_type *shield = NULL; - - int reduced_damage, attskill = 0, defskill = 0; - bool magic = false; - - int damage = dice_rand(damage_formula); - - assert(du->number > 0); - ++at.fighter->hits; - - calculate_attack_type(at, dt, type, missile, &awtype, &attskill, &magic); - calculate_defense_type(at, dt, type, missile, &dwtype, &defskill); - - if (is_riding(at) && (awtype == NULL || (fval(awtype, WTF_HORSEBONUS) - && !fval(awtype, WTF_MISSILE)))) { - damage += CavalryBonus(au, dt, BONUS_DAMAGE); - } - - armor = select_armor(dt, false); - shield = select_armor(dt, true); - - armor_value = calculate_armor(dt, dwtype, awtype, armor, shield, magic); - if (armor_value < 0) { - return false; - } - - damage = apply_resistance(damage, dt, dwtype, armor, shield, magic); - - if (type != AT_COMBATSPELL && type != AT_SPELL) { - damage += crit_damage(attskill, defskill, damage_formula); - - damage += rc_specialdamage(au, du, awtype); - - if (awtype == NULL || !fval(awtype, WTF_MISSILE)) { - /* melee bonus */ - if (rule_damage & DAMAGE_MELEE_BONUS) { - damage += af->person[at.index].damage; - } - } - - /* Skilldifferenzbonus */ - if (rule_damage & DAMAGE_SKILL_BONUS) { - int b = (attskill - defskill) / DAMAGE_QUOTIENT; - if (b > 0) damage += b; - } - } - - reduced_damage = damage - armor_value; - if (reduced_damage < 0) reduced_damage = 0; - - reduced_damage = apply_race_resistance(reduced_damage, df, awtype, magic); - reduced_damage = apply_magicshield(reduced_damage, df, awtype, b, magic); - - assert(dt.index >= 0 && dt.index < du->number); - if (reduced_damage > 0) { - df->person[dt.index].hp -= reduced_damage; - - vampirism(at, reduced_damage); - - ship_damage(b->turn, du); - } - - if (survives(af, dt, b)) - return false; - - ++at.fighter->kills; - - destroy_items(dt); - - kill_troop(dt); - - return true; +bool +terminate(troop dt, troop at, int type, const char *damage_formula, bool missile) +{ + fighter *df = dt.fighter; + fighter *af = at.fighter; + unit *au = af->unit; + unit *du = df->unit; + battle *b = df->side->battle; + + int armor_value; + + const weapon_type *dwtype = NULL; + const weapon_type *awtype = NULL; + const armor_type *armor = NULL; + const armor_type *shield = NULL; + + int reduced_damage, attskill = 0, defskill = 0; + bool magic = false; + + int damage = dice_rand(damage_formula); + + assert(du->number > 0); + ++at.fighter->hits; + + calculate_attack_type(at, dt, type, missile, &awtype, &attskill, &magic); + calculate_defense_type(at, dt, type, missile, &dwtype, &defskill); + + if (is_riding(at) && (awtype == NULL || (fval(awtype, WTF_HORSEBONUS) + && !fval(awtype, WTF_MISSILE)))) { + damage += CavalryBonus(au, dt, BONUS_DAMAGE); } - - static int - count_side(const side * s, const side * vs, int minrow, int maxrow, int select) - { - fighter *fig; - int people = 0; - int unitrow[NUMROWS]; - - if (maxrow < FIGHT_ROW) - return 0; - if (select & SELECT_ADVANCE) { - memset(unitrow, -1, sizeof(unitrow)); - } - - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->alive - fig->removed > 0) { - int row = statusrow(fig->status); - if (select & SELECT_ADVANCE) { - if (unitrow[row] == -1) { - unitrow[row] = get_unitrow(fig, vs); - } - row = unitrow[row]; - } - if (row >= minrow && row <= maxrow) { - people += fig->alive - fig->removed; - if (people > 0 && (select & SELECT_FIND)) - break; - } + + armor = select_armor(dt, false); + shield = select_armor(dt, true); + + armor_value = calculate_armor(dt, dwtype, awtype, armor, shield, magic); + if (armor_value < 0) { + return false; + } + + damage = apply_resistance(damage, dt, dwtype, armor, shield, magic); + + if (type != AT_COMBATSPELL && type != AT_SPELL) { + damage += crit_damage(attskill, defskill, damage_formula); + + damage += rc_specialdamage(au, du, awtype); + + if (awtype == NULL || !fval(awtype, WTF_MISSILE)) { + /* melee bonus */ + if (rule_damage & DAMAGE_MELEE_BONUS) { + damage += af->person[at.index].damage; } } - return people; + + /* Skilldifferenzbonus */ + if (rule_damage & DAMAGE_SKILL_BONUS) { + int b = (attskill - defskill) / DAMAGE_QUOTIENT; + if (b > 0) damage += b; + } } + + reduced_damage = damage - armor_value; + if (reduced_damage < 0) reduced_damage = 0; + + reduced_damage = apply_race_resistance(reduced_damage, df, awtype, magic); + reduced_damage = apply_magicshield(reduced_damage, df, awtype, b, magic); + + assert(dt.index >= 0 && dt.index < du->number); + if (reduced_damage > 0) { + df->person[dt.index].hp -= reduced_damage; + + vampirism(at, reduced_damage); + + ship_damage(b->turn, du); + } + + if (survives(af, dt, b)) + return false; + + ++at.fighter->kills; + + destroy_items(dt); + + kill_troop(dt); + + return true; +} - /* return the number of live allies warning: this function only considers - * troops that are still alive, not those that are still fighting although - * dead. */ - int - count_allies(const side * as, int minrow, int maxrow, int select, int allytype) - { - battle *b = as->battle; - side *ds; - int count = 0; - - for (ds = b->sides; ds != b->sides + b->nsides; ++ds) { - if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF - && as->faction == ds->faction)) { - count += count_side(ds, NULL, minrow, maxrow, select); - if (count > 0 && (select & SELECT_FIND)) +static int +count_side(const side * s, const side * vs, int minrow, int maxrow, int select) +{ + fighter *fig; + int people = 0; + int unitrow[NUMROWS]; + + if (maxrow < FIGHT_ROW) + return 0; + if (select & SELECT_ADVANCE) { + memset(unitrow, -1, sizeof(unitrow)); + } + + for (fig = s->fighters; fig; fig = fig->next) { + if (fig->alive - fig->removed > 0) { + int row = statusrow(fig->status); + if (select & SELECT_ADVANCE) { + if (unitrow[row] == -1) { + unitrow[row] = get_unitrow(fig, vs); + } + row = unitrow[row]; + } + if (row >= minrow && row <= maxrow) { + people += fig->alive - fig->removed; + if (people > 0 && (select & SELECT_FIND)) break; } } - return count; } + return people; +} - static int - count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow, - int select) - { - side *es, *as = af->side; - int i = 0; +/* return the number of live allies warning: this function only considers + * troops that are still alive, not those that are still fighting although + * dead. */ +int +count_allies(const side * as, int minrow, int maxrow, int select, int allytype) +{ + battle *b = as->battle; + side *ds; + int count = 0; + + for (ds = b->sides; ds != b->sides + b->nsides; ++ds) { + if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF + && as->faction == ds->faction)) { + count += count_side(ds, NULL, minrow, maxrow, select); + if (count > 0 && (select & SELECT_FIND)) + break; + } + } + return count; +} - for (es = b->sides; es != b->sides + b->nsides; ++es) { - if (as == NULL || enemy(es, as)) { - int offset = 0; - if (select & SELECT_DISTANCE) { - offset = get_unitrow(af, es) - FIGHT_ROW; - } - i += count_side(es, as, minrow - offset, maxrow - offset, select); - if (i > 0 && (select & SELECT_FIND)) - break; +static int +count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow, + int select) +{ + side *es, *as = af->side; + int i = 0; + + for (es = b->sides; es != b->sides + b->nsides; ++es) { + if (as == NULL || enemy(es, as)) { + int offset = 0; + if (select & SELECT_DISTANCE) { + offset = get_unitrow(af, es) - FIGHT_ROW; + } + i += count_side(es, as, minrow - offset, maxrow - offset, select); + if (i > 0 && (select & SELECT_FIND)) + break; + } + } + return i; +} + +int + count_enemies(battle * b, const fighter * af, int minrow, int maxrow, + int select) +{ + int sr = statusrow(af->status); + side *as = af->side; + + if (b->alive == b->fast.alive && as == b->fast.side && sr == b->fast.status + && minrow == b->fast.minrow && maxrow == b->fast.maxrow) { + if (b->fast.enemies[select] >= 0) { + return b->fast.enemies[select]; + } + else if (select & SELECT_FIND) { + if (b->fast.enemies[select - SELECT_FIND] >= 0) { + return b->fast.enemies[select - SELECT_FIND]; } } + } + else if (select != SELECT_FIND || b->alive != b->fast.alive) { + b->fast.side = as; + b->fast.status = sr; + b->fast.minrow = minrow; + b->fast.alive = b->alive; + b->fast.maxrow = maxrow; + memset(b->fast.enemies, -1, sizeof(b->fast.enemies)); + } + if (maxrow >= FIRST_ROW) { + int i = count_enemies_i(b, af, minrow, maxrow, select); + b->fast.enemies[select] = i; return i; } + return 0; +} - int - count_enemies(battle * b, const fighter * af, int minrow, int maxrow, - int select) - { - int sr = statusrow(af->status); - side *as = af->side; - - if (b->alive == b->fast.alive && as == b->fast.side && sr == b->fast.status - && minrow == b->fast.minrow && maxrow == b->fast.maxrow) { - if (b->fast.enemies[select] >= 0) { - return b->fast.enemies[select]; - } - else if (select & SELECT_FIND) { - if (b->fast.enemies[select - SELECT_FIND] >= 0) { - return b->fast.enemies[select - SELECT_FIND]; - } - } - } - else if (select != SELECT_FIND || b->alive != b->fast.alive) { - b->fast.side = as; - b->fast.status = sr; - b->fast.minrow = minrow; - b->fast.alive = b->alive; - b->fast.maxrow = maxrow; - memset(b->fast.enemies, -1, sizeof(b->fast.enemies)); - } - if (maxrow >= FIRST_ROW) { - int i = count_enemies_i(b, af, minrow, maxrow, select); - b->fast.enemies[select] = i; - return i; - } - return 0; +troop select_enemy(fighter * af, int minrow, int maxrow, int select) +{ + side *as = af->side; + battle *b = as->battle; + int si, selected; + int enemies; +#ifdef DEBUG_SELECT + troop result = no_troop; +#endif + if (u_race(af->unit)->flags & RCF_FLY) { + /* flying races ignore min- and maxrow and can attack anyone fighting + * them */ + minrow = FIGHT_ROW; + maxrow = BEHIND_ROW; } - troop select_enemy(fighter * af, int minrow, int maxrow, int select) - { - side *as = af->side; - battle *b = as->battle; - int si, selected; - int enemies; -#ifdef DEBUG_SELECT - troop result = no_troop; -#endif - if (u_race(af->unit)->flags & RCF_FLY) { - /* flying races ignore min- and maxrow and can attack anyone fighting - * them */ - minrow = FIGHT_ROW; - maxrow = BEHIND_ROW; + if (minrow < FIGHT_ROW) minrow = FIGHT_ROW; + + enemies = count_enemies(b, af, minrow, maxrow, select); + + /* Niemand ist in der angegebenen Entfernung? */ + if (enemies <= 0) + return no_troop; + + selected = (int)(rng_int() % enemies); + for (si = 0; as->enemies[si]; ++si) { + side *ds = as->enemies[si]; + fighter *df; + int unitrow[NUMROWS]; + int offset = 0; + + if (select & SELECT_DISTANCE) + offset = get_unitrow(af, ds) - FIGHT_ROW; + + if (select & SELECT_ADVANCE) { + int ui; + for (ui = 0; ui != NUMROWS; ++ui) + unitrow[ui] = -1; } - if (minrow < FIGHT_ROW) minrow = FIGHT_ROW; + for (df = ds->fighters; df; df = df->next) { + int dr; - enemies = count_enemies(b, af, minrow, maxrow, select); - - /* Niemand ist in der angegebenen Entfernung? */ - if (enemies <= 0) - return no_troop; - - selected = (int)(rng_int() % enemies); - for (si = 0; as->enemies[si]; ++si) { - side *ds = as->enemies[si]; - fighter *df; - int unitrow[NUMROWS]; - int offset = 0; + dr = statusrow(df->status); + if (select & SELECT_ADVANCE) { + if (unitrow[dr] < 0) { + unitrow[dr] = get_unitrow(df, as); + } + dr = unitrow[dr]; + } if (select & SELECT_DISTANCE) - offset = get_unitrow(af, ds) - FIGHT_ROW; - - if (select & SELECT_ADVANCE) { - int ui; - for (ui = 0; ui != NUMROWS; ++ui) - unitrow[ui] = -1; - } - - for (df = ds->fighters; df; df = df->next) { - int dr; - - dr = statusrow(df->status); - if (select & SELECT_ADVANCE) { - if (unitrow[dr] < 0) { - unitrow[dr] = get_unitrow(df, as); - } - dr = unitrow[dr]; - } - - if (select & SELECT_DISTANCE) - dr += offset; - if (dr < minrow || dr > maxrow) - continue; - if (df->alive - df->removed > selected) { + dr += offset; + if (dr < minrow || dr > maxrow) + continue; + if (df->alive - df->removed > selected) { #ifdef DEBUG_SELECT - if (result.fighter == NULL) { - result.index = selected; - result.fighter = df; - } -#else - troop dt; - dt.index = selected; - dt.fighter = df; - return dt; -#endif + if (result.fighter == NULL) { + result.index = selected; + result.fighter = df; } - selected -= (df->alive - df->removed); - enemies -= (df->alive - df->removed); +#else + troop dt; + dt.index = selected; + dt.fighter = df; + return dt; +#endif } + selected -= (df->alive - df->removed); + enemies -= (df->alive - df->removed); } - if (enemies != 0) { - log_error("select_enemies has a bug.\n"); - } + } + if (enemies != 0) { + log_error("select_enemies has a bug.\n"); + } #ifdef DEBUG_SELECT - return result; + return result; #else - assert(!selected); - return no_troop; + assert(!selected); + return no_troop; #endif - } +} - static int get_tactics(const side * as, const side * ds) - { - battle *b = as->battle; - side *stac; - int result = 0; - int defense = 0; +static int get_tactics(const side * as, const side * ds) +{ + battle *b = as->battle; + side *stac; + int result = 0; + int defense = 0; - if (b->max_tactics > 0) { - for (stac = b->sides; stac != b->sides + b->nsides; ++stac) { - if (stac->leader.value > result && helping(stac, as)) { - assert(ds == NULL || !helping(stac, ds)); - result = stac->leader.value; - } - if (ds && stac->leader.value > defense && helping(stac, ds)) { - assert(!helping(stac, as)); - defense = stac->leader.value; - } + if (b->max_tactics > 0) { + for (stac = b->sides; stac != b->sides + b->nsides; ++stac) { + if (stac->leader.value > result && helping(stac, as)) { + assert(ds == NULL || !helping(stac, ds)); + result = stac->leader.value; + } + if (ds && stac->leader.value > defense && helping(stac, ds)) { + assert(!helping(stac, as)); + defense = stac->leader.value; } } - return result - defense; + } + return result - defense; +} + +double tactics_chance(const unit *u, int skilldiff) { + double tacch = 0.1 * skilldiff; + if (fval(u->region->terrain, SEA_REGION)) { + const ship *sh = u->ship; + if (sh) { + tacch *= sh->type->tac_bonus; + } + } + return tacch; +} + +static troop select_opponent(battle * b, troop at, int mindist, int maxdist) +{ + fighter *af = at.fighter; + troop dt; + + if (u_race(af->unit)->flags & RCF_FLY) { + /* flying races ignore min- and maxrow and can attack anyone fighting + * them */ + dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); + } + else { + if (mindist < FIGHT_ROW) mindist = FIGHT_ROW; + dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE); } - double tactics_chance(const unit *u, int skilldiff) { - double tacch = 0.1 * skilldiff; - if (fval(u->region->terrain, SEA_REGION)) { - const ship *sh = u->ship; - if (sh) { - tacch *= sh->type->tac_bonus; - } - } - return tacch; - } + if (b->turn == 0 && dt.fighter) { + if (rule_tactics_formula == 1) { + int tactics = get_tactics(at.fighter->side, dt.fighter->side); - static troop select_opponent(battle * b, troop at, int mindist, int maxdist) - { - fighter *af = at.fighter; - troop dt; - - if (u_race(af->unit)->flags & RCF_FLY) { - /* flying races ignore min- and maxrow and can attack anyone fighting - * them */ - dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); - } - else { - if (mindist < FIGHT_ROW) mindist = FIGHT_ROW; - dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE); - } - - if (b->turn == 0 && dt.fighter) { - if (rule_tactics_formula == 1) { - int tactics = get_tactics(at.fighter->side, dt.fighter->side); - - /* percentage chance to get this attack */ - if (tactics > 0) { - double tacch = tactics_chance(af->unit, tactics); - if (!chance(tacch)) { - dt.fighter = NULL; - } - } - else { + /* percentage chance to get this attack */ + if (tactics > 0) { + double tacch = tactics_chance(af->unit, tactics); + if (!chance(tacch)) { dt.fighter = NULL; } } - } - - return dt; - } - - selist *select_fighters(battle * b, const side * vs, int mask, select_fun cb, void *cbdata) - { - side *s; - selist *fightervp = 0; - - assert(vs != NULL); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - - if (mask == FS_ENEMY) { - if (!enemy(s, vs)) - continue; - } - else if (mask == FS_HELP) { - if (enemy(s, vs) || !alliedside(s, vs->faction, HELP_FIGHT)) { - continue; - } - } else { - assert(mask == (FS_HELP | FS_ENEMY) || !"invalid alliance state"); - } - for (fig = s->fighters; fig; fig = fig->next) { - if (cb(vs, fig, cbdata)) { - selist_push(&fightervp, fig); - } - } - } - - return fightervp; - } - - struct selector { - int minrow; - int maxrow; - }; - - static bool select_row(const side *vs, const fighter *fig, void *cbdata) - { - struct selector *sel = (struct selector *)cbdata; - int row = get_unitrow(fig, vs); - return (row >= sel->minrow && row <= sel->maxrow); - } - - selist *fighters(battle * b, const side * vs, int minrow, int maxrow, int mask) - { - struct selector sel; - sel.maxrow = maxrow; - sel.minrow = minrow; - return select_fighters(b, vs, mask, select_row, &sel); - } - - static void report_failed_spell(struct battle * b, struct unit * mage, const struct spell *sp) - { - message *m = msg_message("spell_failed", "unit spell", mage, sp); - message_all(b, m); - msg_release(m); - } - - static castorder * create_castorder_combat(castorder *co, fighter *fig, const spell * sp, int level, double force) { - co = create_castorder(co, fig->unit, 0, sp, fig->unit->region, level, force, 0, 0, 0); - co->magician.fig = fig; - return co; - } - - static void summon_igjarjuk(battle *b, spellrank spellranks[]) { - side *s; - castorder *co; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig = 0; - if (s->bf->attacker && fval(s->faction, FFL_CURSED)) { - spell *sp = find_spell("igjarjuk"); - if (sp) { - int si; - for (si = 0; s->enemies[si]; ++si) { - side *se = s->enemies[si]; - if (se && !fval(se->faction, FFL_NPC)) { - fighter *fi; - for (fi = se->fighters; fi; fi = fi->next) { - if (fi && (!fig || fig->unit->number > fi->unit->number)) { - fig = fi; - if (fig->unit->number == 1) { - break; - } - } - } - if (fig && fig->unit->number == 1) { - break; - } - } - } - if (fig) { - co = create_castorder_combat(0, fig, sp, 10, 10); - co->magician.fig = fig; - add_castorder(&spellranks[sp->rank], co); - break; - } - } + dt.fighter = NULL; } } } - void do_combatmagic(battle * b, combatmagic_t was) - { - side *s; - castorder *co; - region *r = b->region; - int level, rank, sl; - spellrank spellranks[MAX_SPELLRANK]; + return dt; +} - memset(spellranks, 0, sizeof(spellranks)); +selist *select_fighters(battle * b, const side * vs, int mask, select_fun cb, void *cbdata) +{ + side *s; + selist *fightervp = 0; - if (rule_igjarjuk_curse && was == DO_PRECOMBATSPELL) { - summon_igjarjuk(b, spellranks); + assert(vs != NULL); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + + if (mask == FS_ENEMY) { + if (!enemy(s, vs)) + continue; } - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - for (fig = s->fighters; fig; fig = fig->next) { - unit *mage = fig->unit; - unit *caster = mage; - - if (fig->alive <= 0) - continue; /* fighter kann im Kampf getoetet worden sein */ - - level = effskill(mage, SK_MAGIC, r); - if (level > 0) { - double power; - const spell *sp; - const struct locale *lang = mage->faction->locale; - order *ord; - - switch (was) { - case DO_PRECOMBATSPELL: - sp = get_combatspell(mage, 0); - sl = get_combatspelllevel(mage, 0); - break; - case DO_POSTCOMBATSPELL: - sp = get_combatspell(mage, 2); - sl = get_combatspelllevel(mage, 2); - break; - default: - /* Fehler! */ - return; - } - if (sp == NULL) - continue; - - ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); - if (!cancast(mage, sp, 1, 1, ord)) { - free_order(ord); - continue; - } - - level = eff_spelllevel(mage, caster, sp, level, 1); - if (sl > 0 && sl < level) { - level = sl; - } - if (level < 0) { - report_failed_spell(b, mage, sp); - free_order(ord); - continue; - } - - power = spellpower(r, mage, sp, level, ord); - free_order(ord); - if (power <= 0) { /* Effekt von Antimagie */ - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - } - else if (fumble(r, mage, sp, level)) { - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - } - else { - co = create_castorder_combat(0, fig, sp, level, power); - add_castorder(&spellranks[sp->rank], co); - } - } + else if (mask == FS_HELP) { + if (enemy(s, vs) || !alliedside(s, vs->faction, HELP_FIGHT)) { + continue; } } - for (rank = 0; rank < MAX_SPELLRANK; rank++) { - for (co = spellranks[rank].begin; co; co = co->next) { - fighter *fig = co->magician.fig; - const spell *sp = co->sp; - - level = cast_spell(co); - if (level > 0) { - pay_spell(fig->unit, NULL, sp, level, 1); - } - } - } - for (rank = 0; rank < MAX_SPELLRANK; rank++) { - free_castorders(spellranks[rank].begin); - } - } - - static int cast_combatspell(troop at, const spell * sp, int level, double force) - { - castorder co; - - create_castorder_combat(&co, at.fighter, sp, level, force); - level = cast_spell(&co); - free_castorder(&co); - if (level > 0) { - pay_spell(at.fighter->unit, NULL, sp, level, 1); - } - return level; - } - - static void do_combatspell(troop at) - { - const spell *sp; - fighter *fi = at.fighter; - unit *mage = fi->unit; - battle *b = fi->side->battle; - region *r = b->region; - selist *ql; - int level, qi; - double power; - int fumblechance = 0; - order *ord; - int sl; - const struct locale *lang = mage->faction->locale; - - sp = get_combatspell(mage, 1); - if (sp == NULL) { - fi->magic = 0; /* Hat keinen Kampfzauber, kaempft nichtmagisch weiter */ - return; - } - ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); - if (!cancast(mage, sp, 1, 1, ord)) { - fi->magic = 0; /* Kann nicht mehr Zaubern, kaempft nichtmagisch weiter */ - return; - } - - level = eff_spelllevel(mage, mage, sp, fi->magic, 1); - sl = get_combatspelllevel(mage, 1); - if (sl > 0 && sl < level) { - level = sl; - } - - if (fumble(r, mage, sp, level)) { - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - return; - } - - for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { - meffect *mblock = (meffect *)selist_get(ql, qi); - if (mblock->typ == SHIELD_BLOCK) { - if (meffect_blocked(b, mblock, fi->side) != 0) { - fumblechance += mblock->duration; - mblock->duration -= mblock->effect; - } - } - } - - /* Antimagie die Fehlschlag erhoeht */ - if (rng_int() % 100 < fumblechance) { - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - free_order(ord); - return; - } - power = spellpower(r, mage, sp, level, ord); - free_order(ord); - if (power <= 0) { /* Effekt von Antimagie */ - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - return; - } - - level = cast_combatspell(at, sp, level, power); - } - - /* Sonderattacken: Monster patzern nicht und zahlen auch keine - * Spruchkosten. Da die Spruchstaerke direkt durch den Level bestimmt - * wird, wirkt auch keine Antimagie (wird sonst in spellpower - * gemacht) */ - - static void do_extra_spell(troop at, const att * a) - { - const spell *sp = spellref_get(a->data.sp); - - if (!sp) { - log_error("no such spell: '%s'", a->data.sp->_name); - } else { - assert(a->level > 0); - cast_combatspell(at, sp, a->level, a->level); + assert(mask == (FS_HELP | FS_ENEMY) || !"invalid alliance state"); + } + for (fig = s->fighters; fig; fig = fig->next) { + if (cb(vs, fig, cbdata)) { + selist_push(&fightervp, fig); + } } } - int skilldiff(troop at, troop dt, int dist) - { - fighter *af = at.fighter, *df = dt.fighter; - unit *au = af->unit, *du = df->unit; - int is_protected = 0, skdiff = 0; - weapon *awp = select_weapon(at, true, dist > 1); - static int rc_cache; - static const race *rc_halfling, *rc_goblin; + return fightervp; +} - if (rc_changed(&rc_cache)) { - rc_halfling = get_race(RC_HALFLING); - rc_goblin = get_race(RC_GOBLIN); - } - skdiff += af->person[at.index].attack; - skdiff -= df->person[dt.index].defense; +struct selector { + int minrow; + int maxrow; +}; - if (df->person[dt.index].flags & FL_SLEEPING) - skdiff += 2; +static bool select_row(const side *vs, const fighter *fig, void *cbdata) +{ + struct selector *sel = (struct selector *)cbdata; + int row = get_unitrow(fig, vs); + return (row >= sel->minrow && row <= sel->maxrow); +} - /* Effekte durch Rassen */ - if (awp != NULL && u_race(au) == rc_halfling && dragonrace(u_race(du))) { - skdiff += 5; - } - else if (u_race(au) == rc_goblin) { - if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) { - skdiff += 1; - } - } +selist *fighters(battle * b, const side * vs, int minrow, int maxrow, int mask) +{ + struct selector sel; + sel.maxrow = maxrow; + sel.minrow = minrow; + return select_fighters(b, vs, mask, select_row, &sel); +} - if (df->building) { - building *b = df->building; - if (b->attribs) { - curse *c = get_curse(b->attribs, &ct_strongwall); - if (curse_active(c)) { - /* wirkt auf alle Gebaeude */ - skdiff -= curse_geteffect_int(c); - is_protected = 2; - } - } - if (b->type->flags & BTF_FORTIFICATION) { - int stage = buildingeffsize(b, false); - int beff = building_protection(b->type, stage); - if (beff > 0) { - skdiff -= beff; - is_protected = 2; - if (b->attribs) { - if (curse_active(get_curse(b->attribs, &ct_magicwalls))) { - /* Verdoppelt Burgenbonus */ - skdiff -= beff; +static void report_failed_spell(struct battle * b, struct unit * mage, const struct spell *sp) +{ + message *m = msg_message("spell_failed", "unit spell", mage, sp); + message_all(b, m); + msg_release(m); +} + +static castorder * create_castorder_combat(castorder *co, fighter *fig, const spell * sp, int level, double force) { + co = create_castorder(co, fig->unit, 0, sp, fig->unit->region, level, force, 0, 0, 0); + co->magician.fig = fig; + return co; +} + +static void summon_igjarjuk(battle *b, spellrank spellranks[]) { + side *s; + castorder *co; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig = 0; + if (s->bf->attacker && fval(s->faction, FFL_CURSED)) { + spell *sp = find_spell("igjarjuk"); + if (sp) { + int si; + for (si = 0; s->enemies[si]; ++si) { + side *se = s->enemies[si]; + if (se && !fval(se->faction, FFL_NPC)) { + fighter *fi; + for (fi = se->fighters; fi; fi = fi->next) { + if (fi && (!fig || fig->unit->number > fi->unit->number)) { + fig = fi; + if (fig->unit->number == 1) { + break; + } + } + } + if (fig && fig->unit->number == 1) { + break; } } } + if (fig) { + co = create_castorder_combat(0, fig, sp, 10, 10); + co->magician.fig = fig; + add_castorder(&spellranks[sp->rank], co); + break; + } } } - /* Effekte der Waffen */ - skdiff += weapon_effskill(at, dt, awp, true, dist > 1); - if (awp && fval(awp->type, WTF_MISSILE)) { - skdiff -= is_protected; - if (awp->type->modifiers) { - int w; - for (w = 0; awp->type->modifiers[w].value != 0; ++w) { - if (awp->type->modifiers[w].flags & WMF_MISSILE_TARGET) { - /* skill decreases by targeting difficulty (bow -2, catapult -4) */ - skdiff -= awp->type->modifiers[w].value; - break; + } +} + +void do_combatmagic(battle * b, combatmagic_t was) +{ + side *s; + castorder *co; + region *r = b->region; + int level, rank, sl; + spellrank spellranks[MAX_SPELLRANK]; + + memset(spellranks, 0, sizeof(spellranks)); + + if (rule_igjarjuk_curse && was == DO_PRECOMBATSPELL) { + summon_igjarjuk(b, spellranks); + } + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + for (fig = s->fighters; fig; fig = fig->next) { + unit *mage = fig->unit; + unit *caster = mage; + + if (fig->alive <= 0) + continue; /* fighter kann im Kampf getoetet worden sein */ + + level = effskill(mage, SK_MAGIC, r); + if (level > 0) { + double power; + const spell *sp; + const struct locale *lang = mage->faction->locale; + order *ord; + + switch (was) { + case DO_PRECOMBATSPELL: + sp = get_combatspell(mage, 0); + sl = get_combatspelllevel(mage, 0); + break; + case DO_POSTCOMBATSPELL: + sp = get_combatspell(mage, 2); + sl = get_combatspelllevel(mage, 2); + break; + default: + /* Fehler! */ + return; + } + if (sp == NULL) + continue; + + ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); + if (!cancast(mage, sp, 1, 1, ord)) { + free_order(ord); + continue; + } + + level = eff_spelllevel(mage, caster, sp, level, 1); + if (sl > 0 && sl < level) { + level = sl; + } + if (level < 0) { + report_failed_spell(b, mage, sp); + free_order(ord); + continue; + } + + power = spellpower(r, mage, sp, level, ord); + free_order(ord); + if (power <= 0) { /* Effekt von Antimagie */ + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + } + else if (fumble(r, mage, sp, level)) { + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + } + else { + co = create_castorder_combat(0, fig, sp, level, power); + add_castorder(&spellranks[sp->rank], co); + } + } + } + } + for (rank = 0; rank < MAX_SPELLRANK; rank++) { + for (co = spellranks[rank].begin; co; co = co->next) { + fighter *fig = co->magician.fig; + const spell *sp = co->sp; + + level = cast_spell(co); + if (level > 0) { + pay_spell(fig->unit, NULL, sp, level, 1); + } + } + } + for (rank = 0; rank < MAX_SPELLRANK; rank++) { + free_castorders(spellranks[rank].begin); + } +} + +static int cast_combatspell(troop at, const spell * sp, int level, double force) +{ + castorder co; + + create_castorder_combat(&co, at.fighter, sp, level, force); + level = cast_spell(&co); + free_castorder(&co); + if (level > 0) { + pay_spell(at.fighter->unit, NULL, sp, level, 1); + } + return level; +} + +static void do_combatspell(troop at) +{ + const spell *sp; + fighter *fi = at.fighter; + unit *mage = fi->unit; + battle *b = fi->side->battle; + region *r = b->region; + selist *ql; + int level, qi; + double power; + int fumblechance = 0; + order *ord; + int sl; + const struct locale *lang = mage->faction->locale; + + sp = get_combatspell(mage, 1); + if (sp == NULL) { + fi->magic = 0; /* Hat keinen Kampfzauber, kaempft nichtmagisch weiter */ + return; + } + ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); + if (!cancast(mage, sp, 1, 1, ord)) { + fi->magic = 0; /* Kann nicht mehr Zaubern, kaempft nichtmagisch weiter */ + return; + } + + level = eff_spelllevel(mage, mage, sp, fi->magic, 1); + sl = get_combatspelllevel(mage, 1); + if (sl > 0 && sl < level) { + level = sl; + } + + if (fumble(r, mage, sp, level)) { + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + return; + } + + for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { + meffect *mblock = (meffect *)selist_get(ql, qi); + if (mblock->typ == SHIELD_BLOCK) { + if (meffect_blocked(b, mblock, fi->side) != 0) { + fumblechance += mblock->duration; + mblock->duration -= mblock->effect; + } + } + } + + /* Antimagie die Fehlschlag erhoeht */ + if (rng_int() % 100 < fumblechance) { + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + free_order(ord); + return; + } + power = spellpower(r, mage, sp, level, ord); + free_order(ord); + if (power <= 0) { /* Effekt von Antimagie */ + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + return; + } + + level = cast_combatspell(at, sp, level, power); +} + +/* Sonderattacken: Monster patzern nicht und zahlen auch keine + * Spruchkosten. Da die Spruchstaerke direkt durch den Level bestimmt + * wird, wirkt auch keine Antimagie (wird sonst in spellpower + * gemacht) */ + +static void do_extra_spell(troop at, const att * a) +{ + const spell *sp = spellref_get(a->data.sp); + + if (!sp) { + log_error("no such spell: '%s'", a->data.sp->_name); + } + else { + assert(a->level > 0); + cast_combatspell(at, sp, a->level, a->level); + } +} + +int skilldiff(troop at, troop dt, int dist) +{ + fighter *af = at.fighter, *df = dt.fighter; + unit *au = af->unit, *du = df->unit; + int is_protected = 0, skdiff = 0; + weapon *awp = select_weapon(at, true, dist > 1); + static int rc_cache; + static const race *rc_halfling, *rc_goblin; + + if (rc_changed(&rc_cache)) { + rc_halfling = get_race(RC_HALFLING); + rc_goblin = get_race(RC_GOBLIN); + } + skdiff += af->person[at.index].attack; + skdiff -= df->person[dt.index].defense; + + if (df->person[dt.index].flags & FL_SLEEPING) + skdiff += 2; + + /* Effekte durch Rassen */ + if (awp != NULL && u_race(au) == rc_halfling && dragonrace(u_race(du))) { + skdiff += 5; + } + else if (u_race(au) == rc_goblin) { + if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) { + skdiff += 1; + } + } + + if (df->building) { + building *b = df->building; + if (b->attribs) { + curse *c = get_curse(b->attribs, &ct_strongwall); + if (curse_active(c)) { + /* wirkt auf alle Gebaeude */ + skdiff -= curse_geteffect_int(c); + is_protected = 2; + } + } + if (b->type->flags & BTF_FORTIFICATION) { + int stage = buildingeffsize(b, false); + int beff = building_protection(b->type, stage); + if (beff > 0) { + skdiff -= beff; + is_protected = 2; + if (b->attribs) { + if (curse_active(get_curse(b->attribs, &ct_magicwalls))) { + /* Verdoppelt Burgenbonus */ + skdiff -= beff; } } } } - if (skill_formula == FORMULA_ORIG) { - weapon *dwp = select_weapon(dt, false, dist > 1); - skdiff -= weapon_effskill(dt, at, dwp, false, dist > 1); + } + /* Effekte der Waffen */ + skdiff += weapon_effskill(at, dt, awp, true, dist > 1); + if (awp && fval(awp->type, WTF_MISSILE)) { + skdiff -= is_protected; + if (awp->type->modifiers) { + int w; + for (w = 0; awp->type->modifiers[w].value != 0; ++w) { + if (awp->type->modifiers[w].flags & WMF_MISSILE_TARGET) { + /* skill decreases by targeting difficulty (bow -2, catapult -4) */ + skdiff -= awp->type->modifiers[w].value; + break; + } + } } - return skdiff; } - - static int setreload(troop at) - { - fighter *af = at.fighter; - const weapon_type *wtype = af->person[at.index].missile->type; - if (wtype->reload == 0) - return 0; - return af->person[at.index].reload = wtype->reload; - } - - int getreload(troop at) - { - return at.fighter->person[at.index].reload; - } - - int hits(troop at, troop dt, weapon * awp) - { - fighter *af = at.fighter, *df = dt.fighter; - const armor_type *armor, *shield = 0; - int skdiff = 0; - int dist = get_unitrow(af, df->side) + get_unitrow(df, af->side) - 1; + if (skill_formula == FORMULA_ORIG) { weapon *dwp = select_weapon(dt, false, dist > 1); + skdiff -= weapon_effskill(dt, at, dwp, false, dist > 1); + } + return skdiff; +} - if (!df->alive) - return 0; - if (getreload(at)) - return 0; - if (dist > 1 && (awp == NULL || !fval(awp->type, WTF_MISSILE))) - return 0; +static int setreload(troop at) +{ + fighter *af = at.fighter; + const weapon_type *wtype = af->person[at.index].missile->type; + if (wtype->reload == 0) + return 0; + return af->person[at.index].reload = wtype->reload; +} - /* mark this person as hit. */ - df->person[dt.index].flags |= FL_HIT; +int getreload(troop at) +{ + return at.fighter->person[at.index].reload; +} - if (af->person[at.index].flags & FL_STUNNED) { - af->person[at.index].flags &= ~FL_STUNNED; - return 0; - } - if ((af->person[at.index].flags & FL_TIRED && rng_int() % 100 < 50) - || (af->person[at.index].flags & FL_SLEEPING)) - return 0; +int hits(troop at, troop dt, weapon * awp) +{ + fighter *af = at.fighter, *df = dt.fighter; + const armor_type *armor, *shield = 0; + int skdiff = 0; + int dist = get_unitrow(af, df->side) + get_unitrow(df, af->side) - 1; + weapon *dwp = select_weapon(dt, false, dist > 1); - /* effect of sp_reeling_arrows combatspell */ - if (af->side->battle->reelarrow && awp && fval(awp->type, WTF_MISSILE) - && rng_double() < 0.5) { - return 0; - } + if (!df->alive) + return 0; + if (getreload(at)) + return 0; + if (dist > 1 && (awp == NULL || !fval(awp->type, WTF_MISSILE))) + return 0; - skdiff = skilldiff(at, dt, dist); - /* Verteidiger bekommt eine Ruestung */ - armor = select_armor(dt, true); - if (dwp == NULL || (dwp->type->flags & WTF_USESHIELD)) { - shield = select_armor(dt, false); - } - if (contest(skdiff, dt, armor, shield)) { - return 1; - } + /* mark this person as hit. */ + df->person[dt.index].flags |= FL_HIT; + + if (af->person[at.index].flags & FL_STUNNED) { + af->person[at.index].flags &= ~FL_STUNNED; + return 0; + } + if ((af->person[at.index].flags & FL_TIRED && rng_int() % 100 < 50) + || (af->person[at.index].flags & FL_SLEEPING)) + return 0; + + /* effect of sp_reeling_arrows combatspell */ + if (af->side->battle->reelarrow && awp && fval(awp->type, WTF_MISSILE) + && rng_double() < 0.5) { return 0; } - void dazzle(battle * b, troop * td) - { - UNUSED_ARG(b); - /* Nicht kumulativ ! */ - if (td->fighter->person[td->index].flags & (FL_COURAGE | FL_DAZZLED)) { - return; - } + skdiff = skilldiff(at, dt, dist); + /* Verteidiger bekommt eine Ruestung */ + armor = select_armor(dt, true); + if (dwp == NULL || (dwp->type->flags & WTF_USESHIELD)) { + shield = select_armor(dt, false); + } + if (contest(skdiff, dt, armor, shield)) { + return 1; + } + return 0; +} - td->fighter->person[td->index].flags |= FL_DAZZLED; - td->fighter->person[td->index].defense--; +void dazzle(battle * b, troop * td) +{ + UNUSED_ARG(b); + /* Nicht kumulativ ! */ + if (td->fighter->person[td->index].flags & (FL_COURAGE | FL_DAZZLED)) { + return; } - void damage_building(battle * b, building * bldg, int damage_abs) - { - assert(bldg); - bldg->size -= damage_abs; - if (bldg->size < 1) bldg->size = 1; + td->fighter->person[td->index].flags |= FL_DAZZLED; + td->fighter->person[td->index].defense--; +} - /* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebaeude passen. */ +void damage_building(battle * b, building * bldg, int damage_abs) +{ + assert(bldg); + bldg->size -= damage_abs; + if (bldg->size < 1) bldg->size = 1; - if (bldg->type->flags & BTF_FORTIFICATION) { - side *s; + /* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebaeude passen. */ - bldg->sizeleft = bldg->size; + if (bldg->type->flags & BTF_FORTIFICATION) { + side *s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->building == bldg) { - if (bldg->sizeleft >= fig->unit->number) { - fig->building = bldg; - bldg->sizeleft -= fig->unit->number; + bldg->sizeleft = bldg->size; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + for (fig = s->fighters; fig; fig = fig->next) { + if (fig->building == bldg) { + if (bldg->sizeleft >= fig->unit->number) { + fig->building = bldg; + bldg->sizeleft -= fig->unit->number; + } + else { + fig->building = NULL; + } + } + } + } + } +} + +static int attacks_per_round(troop t) +{ + return t.fighter->person[t.index].speed; +} + +static void make_heroes(battle * b) +{ + side *s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + for (fig = s->fighters; fig; fig = fig->next) { + unit *u = fig->unit; + if (fval(u, UFL_HERO)) { + int i; + if (!playerrace(u_race(u))) { + log_error("Hero %s is a %s.\n", unitname(u), u_race(u)->_name); + } + for (i = 0; i != u->number; ++i) { + fig->person[i].speed += (rule_hero_speed - 1); + } + } + } + } +} + +static void attack(battle * b, troop ta, const att * a, int numattack) +{ + fighter *af = ta.fighter; + troop td; + unit *au = af->unit; + + switch (a->type) { + case AT_COMBATSPELL: + /* Magier versuchen immer erstmal zu zaubern, erst wenn das + * fehlschlaegt, wird af->magic == 0 und der Magier kaempft + * konventionell weiter */ + if (numattack == 0 && af->magic > 0) { + /* wenn der magier in die potenzielle Reichweite von Attacken des + * Feindes kommt, beginnt er auch bei einem Status von KAEMPFE NICHT, + * Kampfzauber zu schleudern: */ + if (count_enemies(b, af, melee_range[0], missile_range[1], + SELECT_ADVANCE | SELECT_DISTANCE | SELECT_FIND)) { + do_combatspell(ta); + } + } + break; + case AT_STANDARD: /* Waffen, mag. Gegenstaende, Kampfzauber */ + if (numattack > 0 || af->magic <= 0) { + weapon *wp = ta.fighter->person[ta.index].missile; + int melee = + count_enemies(b, af, melee_range[0], melee_range[1], + SELECT_ADVANCE | SELECT_DISTANCE | SELECT_FIND); + if (melee) + wp = preferred_weapon(ta, true); + /* Sonderbehandlungen */ + + if (getreload(ta)) { + ta.fighter->person[ta.index].reload--; + } + else { + bool standard_attack = true; + bool reload = false; + /* spezialattacken der waffe nur, wenn erste attacke in der runde. + * sonst helden mit feuerschwertern zu maechtig */ + if (numattack == 0 && wp && wp->type->attack) { + int dead = 0; + standard_attack = wp->type->attack(&ta, wp->type, &dead); + if (!standard_attack) + reload = true; + af->catmsg += dead; + if (!standard_attack && af->person[ta.index].last_action < b->turn) { + af->person[ta.index].last_action = b->turn; + } + } + if (standard_attack) { + bool missile = false; + if (wp && fval(wp->type, WTF_MISSILE)) + missile = true; + if (missile) { + td = select_opponent(b, ta, missile_range[0], missile_range[1]); + } + else { + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + } + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + reload = true; + if (hits(ta, td, wp)) { + const char *d; + if (wp == NULL) + d = u_race(au)->def_damage; + else if (is_riding(ta)) + d = wp->type->damage[1]; + else + d = wp->type->damage[0]; + terminate(td, ta, a->type, d, missile); + } + } + if (reload && wp && wp->type->reload && !getreload(ta)) { + setreload(ta); + } + } + } + break; + case AT_SPELL: /* Extra-Sprueche. Kampfzauber in AT_COMBATSPELL! */ + do_extra_spell(ta, a); + break; + case AT_NATURAL: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (hits(ta, td, NULL)) { + terminate(td, ta, a->type, a->data.dice, false); + } + break; + case AT_DRAIN_ST: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (hits(ta, td, NULL)) { + int c = dice_rand(a->data.dice); + while (c > 0) { + if (rng_int() % 2) { + td.fighter->person[td.index].attack -= 1; + } + else { + td.fighter->person[td.index].defense -= 1; + } + c--; + } + } + break; + case AT_DRAIN_EXP: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (hits(ta, td, NULL)) { + drain_exp(td.fighter->unit, dice_rand(a->data.dice)); + } + break; + case AT_DAZZLE: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (hits(ta, td, NULL)) { + dazzle(b, &td); + } + break; + case AT_STRUCTURAL: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (td.fighter->unit->ship) { + int dice = dice_rand(a->data.dice); + ship * sh = td.fighter->unit->ship; + damage_ship(sh, dice / sh->type->damage / sh->size); + } + else if (td.fighter->unit->building) { + damage_building(b, td.fighter->unit->building, dice_rand(a->data.dice)); + } + } +} + +void do_attack(fighter * af) +{ + troop ta; + unit *au = af->unit; + side *side = af->side; + battle *b = side->battle; + + ta.fighter = af; + + assert(au && au->number); + /* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen + * Kaempfern beruht, darf die Reihenfolge und Groesse der Einheit keine + * Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der + * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zufaellig + * mit einer grossen Einheit zuerst drankommt, extrem bevorteilt. */ + ta.index = af->fighting; + + while (ta.index--) { + /* Wir suchen eine beliebige Feind-Einheit aus. An der koennen + * wir feststellen, ob noch jemand da ist. */ + int apr, attacks = attacks_per_round(ta); + if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND)) + break; + + for (apr = 0; apr != attacks; ++apr) { + int a; + for (a = 0; a < RACE_ATTACKS && u_race(au)->attack[a].type != AT_NONE; ++a) { + if (apr > 0) { + /* Wenn die Waffe nachladen muss, oder es sich nicht um einen + * Waffen-Angriff handelt, dann gilt der Speed nicht. */ + /* TODO: allow multiple AT_NATURAL attacks? */ + if (u_race(au)->attack[a].type != AT_STANDARD) + continue; + else { + weapon *wp = preferred_weapon(ta, true); + if (wp != NULL && wp->type->reload) + continue; + } + } + attack(b, ta, &(u_race(au)->attack[a]), apr); + } + } + } + /* Der letzte Katapultschuetze setzt die + * Ladezeit neu und generiert die Meldung. */ + if (af->catmsg >= 0) { + struct message *m = + msg_message("killed_battle", "unit dead", au, af->catmsg); + message_all(b, m); + msg_release(m); + af->catmsg = -1; + } +} + +static void add_tactics(tactics * ta, fighter * fig, int value) +{ + if (value == 0 || value < ta->value) + return; + if (value > ta->value) { + selist_free(ta->fighters); + ta->fighters = 0; + } + selist_push(&ta->fighters, fig); + selist_push(&fig->side->battle->leaders, fig); + ta->value = value; +} + +static int horse_fleeing_bonus(const unit * u) +{ + const item_type *it_horse, *it_elvenhorse, *it_charger; + int n1 = 0, n2 = 0, n3 = 0; + item *itm; + int skl = effskill(u, SK_RIDING, NULL); + const resource_type *rtype; + + it_horse = ((rtype = get_resourcetype(R_HORSE)) != NULL) ? rtype->itype : 0; + it_elvenhorse = ((rtype = get_resourcetype(R_UNICORN)) != NULL) ? rtype->itype : 0; + it_charger = ((rtype = get_resourcetype(R_CHARGER)) != NULL) ? rtype->itype : 0; + + for (itm = u->items; itm; itm = itm->next) { + if (itm->type->flags & ITF_ANIMAL) { + if (itm->type == it_elvenhorse) + n3 += itm->number; + else if (itm->type == it_charger) + n2 += itm->number; + else if (itm->type == it_horse) + n1 += itm->number; + } + } + if (skl >= 5 && n3 >= u->number) + return 30; + if (skl >= 2 && n2 + n3 >= u->number) + return 20; + if (n1 + n2 + n3 >= u->number) + return 10; + return 0; +} + +static int fleechance(unit * u) +{ + int p = flee_chance_base; /* Fluchtwahrscheinlichkeit in % */ + /* Einheit u versucht, dem Getuemmel zu entkommen */ + + p += (effskill(u, SK_STEALTH, NULL) * flee_chance_skill_bonus); + p += horse_fleeing_bonus(u); + + if (u_race(u) == get_race(RC_HALFLING)) { + p += flee_chance_base; + if (p > flee_chance_max_percent) { + p = flee_chance_max_percent; + } + } + return p; +} + +/** add a new army to the conflict. + * beware: armies need to be added _at the beginning_ of the list because + * otherwise join_allies() will get into trouble */ +side *make_side(battle * b, const faction * f, const group * g, + unsigned int flags, const faction * stealthfaction) +{ + side *s1 = b->sides + b->nsides; + bfaction *bf; + + if (fval(b->region->terrain, SEA_REGION)) { + /* every fight in an ocean is short */ + flags |= SIDE_HASGUARDS; + } + else { + unit *u; + for (u = b->region->units; u; u = u->next) { + if (is_guard(u)) { + if (alliedunit(u, f, HELP_GUARD)) { + flags |= SIDE_HASGUARDS; + break; + } + } + } + } + + s1->battle = b; + s1->group = g; + s1->flags = flags; + s1->stealthfaction = stealthfaction; + for (bf = b->factions; bf; bf = bf->next) { + faction *f2 = bf->faction; + + if (f2 == f) { + s1->bf = bf; + s1->faction = f2; + s1->index = b->nsides++; + s1->nextF = bf->sides; + bf->sides = s1; + assert(b->nsides <= MAXSIDES); + break; + } + } + assert(bf); + return s1; +} + +troop select_ally(fighter * af, int minrow, int maxrow, int allytype) +{ + side *as = af->side; + battle *b = as->battle; + side *ds; + int allies = count_allies(as, minrow, maxrow, SELECT_ADVANCE, allytype); + + if (!allies) { + return no_troop; + } + allies = (int)(rng_int() % allies); + + for (ds = b->sides; ds != b->sides + b->nsides; ++ds) { + if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF + && as->faction == ds->faction)) { + fighter *df; + for (df = ds->fighters; df; df = df->next) { + int dr = get_unitrow(df, NULL); + if (dr >= minrow && dr <= maxrow) { + if (df->alive - df->removed > allies) { + troop dt; + assert(allies >= 0); + dt.index = allies; + dt.fighter = df; + return dt; + } + allies -= df->alive; + } + } + } + } + assert(!"we should never have gotten here"); + return no_troop; +} + +static int loot_quota(const unit * src, const unit * dst, + const item_type * type, int n) +{ + UNUSED_ARG(type); + if (dst && src && src->faction != dst->faction) { + double divisor = config_get_flt("rules.items.loot_divisor", 1); + assert(divisor <= 0 || divisor >= 1); + if (divisor >= 1) { + double r = n / divisor; + int x = (int)r; + + r = r - x; + if (chance(r)) + ++x; + + return x; + } + } + return n; +} + +static void loot_items(fighter * corpse) +{ + unit *u = corpse->unit; + item *itm = u->items; + battle *b = corpse->side->battle; + int dead = dead_fighters(corpse); + + if (dead <= 0) + return; + + while (itm) { + float lootfactor = (float)dead / (float)u->number; /* only loot the dead! */ + int maxloot = (int)((float)itm->number * lootfactor); + if (maxloot > 0) { + int i = (maxloot > 10) ? 10 : maxloot; + for (; i != 0; --i) { + int loot = maxloot / i; + + if (loot > 0) { + fighter *fig = NULL; + int looting = 0; + int maxrow = 0; + /* mustloot: we absolutely, positively must have somebody loot this thing */ + int mustloot = itm->type->flags & (ITF_CURSED | ITF_NOTLOST); + + itm->number -= loot; + maxloot -= loot; + + if (is_monsters(u->faction) && (rule_loot & LOOT_MONSTERS)) { + looting = 1; + } + else if (rule_loot & LOOT_OTHERS) { + looting = 1; + } + else if (rule_loot & LOOT_SELF) { + looting = 2; + } + if (looting) { + if (mustloot) { + maxrow = LAST_ROW; + } + else if (rule_loot & LOOT_KEEPLOOT) { + int lootchance = 50 + b->keeploot; + if (rng_int() % 100 < lootchance) { + maxrow = BEHIND_ROW; + } } else { - fig->building = NULL; + maxrow = LAST_ROW; } } + if (maxrow > 0) { + if (looting == 1) { + /* enemies get dibs */ + fig = select_enemy(corpse, FIGHT_ROW, maxrow, 0).fighter; + } + if (!fig) { + /* self and allies get second pick */ + fig = select_ally(corpse, FIGHT_ROW, LAST_ROW, ALLY_SELF).fighter; + } + } + + if (fig) { + int trueloot = + mustloot ? loot : loot_quota(corpse->unit, fig->unit, itm->type, + loot); + if (trueloot > 0) { + i_change(&fig->loot, itm->type, trueloot); + } + } + } + } + } + itm = itm->next; + } +} + +bool seematrix(const faction * f, const side * s) +{ + if (f == s->faction) + return true; + if (s->flags & SIDE_STEALTH) + return false; + return true; +} + +static double PopulationDamage(void) +{ + return rule_population_damage / 100.0; +} + +static void battle_effects(battle * b, int dead_players) +{ + region *r = b->region; + int rp = rpeasants(r); + + if (rp > 0) { + int dead_peasants = (int)(dead_players * PopulationDamage()); + if (dead_peasants > rp) { + dead_peasants = rp; + } + if (dead_peasants) { + deathcounts(r, dead_peasants + dead_players); + rsetpeasants(r, rp - dead_peasants); + } + } +} + +static void reorder_fleeing(region * r) +{ + unit **usrc = &r->units; + unit **udst = &r->units; + unit *ufirst = NULL; + unit *u; + + for (; *udst; udst = &u->next) { + u = *udst; + } + + for (u = *usrc; u != ufirst; u = *usrc) { + if (u->next && fval(u, UFL_FLEEING)) { + *usrc = u->next; + *udst = u; + udst = &u->next; + if (!ufirst) + ufirst = u; + } + else { + usrc = &u->next; + } + } + *udst = NULL; +} + +static void aftermath(battle * b) +{ + region *r = b->region; + side *s; + int dead_players = 0; + bfaction *bf; + bool ships_damaged = (b->turn + (b->has_tactics_turn ? 1 : 0) > 2); /* only used for ship damage! */ + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *df; + s->dead = 0; + + for (df = s->fighters; df; df = df->next) { + unit *du = df->unit; + int dead = dead_fighters(df); + + /* tote insgesamt: */ + s->dead += dead; + /* Tote, die wiederbelebt werde koennen: */ + if (playerrace(u_race(df->unit))) { + s->casualties += dead; + } + if (df->hits + df->kills) { + struct message *m = + msg_message("killsandhits", "unit hits kills", du, df->hits, + df->kills); + battle_message_faction(b, du->faction, m); + msg_release(m); + } + } + } + + /* POSTCOMBAT */ + do_combatmagic(b, DO_POSTCOMBATSPELL); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + int snumber = 0; + fighter *df; + bool relevant = false; /* Kampf relevant fuer diese Partei? */ + if (!fval(s, SIDE_HASGUARDS)) { + relevant = true; + } + s->flee = 0; + + for (df = s->fighters; df; df = df->next) { + unit *du = df->unit; + int dead = dead_fighters(df); + int sum_hp = 0; + int n; + int flags = 0; + + for (n = 0; n != df->alive; ++n) { + if (df->person[n].hp > 0) { + sum_hp += df->person[n].hp; + } + } + snumber += du->number; + if (dead == df->unit->number) { + flags = UFL_DEAD; + } + else if (relevant) { + flags = UFL_LONGACTION; + if ((du->status != ST_FLEE) && (df->run.hp <= 0)) { + flags |= UFL_NOTMOVING; + } + } + if (flags) { + fset(du, flags); + } + if (df->alive && df->alive == du->number) { + du->hp = sum_hp; + continue; /* nichts passiert */ + } + else if (df->run.hp) { + if (df->alive == 0) { + /* Report the casualties */ + reportcasualties(b, df, dead); + + /* Zuerst duerfen die Feinde pluendern, die mitgenommenen Items + * stehen in fig->run.items. Dann werden die Fliehenden auf + * die leere (tote) alte Einheit gemapt */ + if (!fval(df, FIG_NOLOOT)) { + loot_items(df); + } + scale_number(du, df->run.number); + du->hp = df->run.hp; + setguard(du, false); + /* must leave ships or buildings, or a stealthy hobbit + * can hold castles indefinitely */ + if (!fval(r->terrain, SEA_REGION)) { + leave(du, true); /* even region owners have to flee */ + } + fset(du, UFL_FLEEING); + } + else { + /* nur teilweise geflohene Einheiten mergen sich wieder */ + df->alive += df->run.number; + s->size[0] += df->run.number; + s->size[statusrow(df->status)] += df->run.number; + s->alive += df->run.number; + sum_hp += df->run.hp; + df->run.number = 0; + df->run.hp = 0; + /* df->run.region = NULL; */ + + reportcasualties(b, df, dead); + + scale_number(du, df->alive); + du->hp = sum_hp; + } + } + else { + if (df->alive == 0) { + /* alle sind tot, niemand geflohen. Einheit aufloesen */ + df->run.number = 0; + df->run.hp = 0; + + /* Report the casualties */ + reportcasualties(b, df, dead); + + /* Distribute Loot */ + loot_items(df); + + setguard(du, false); + scale_number(du, 0); + } + else { + df->run.number = 0; + df->run.hp = 0; + + reportcasualties(b, df, dead); + + scale_number(du, df->alive); + du->hp = sum_hp; + } + } + s->flee += df->run.number; + + if (playerrace(u_race(du))) { + /* tote im kampf werden zu regionsuntoten: + * for each of them, a peasant will die as well */ + dead_players += dead; + } + if (du->hp < du->number) { + log_error("%s has less hitpoints (%u) than people (%u)\n", itoa36(du->no), du->hp, du->number); + du->hp = du->number; + } + } + s->alive += s->healed; + assert(snumber == s->flee + s->alive + s->dead); + } + + battle_effects(b, dead_players); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + message *seen = msg_message("army_report", + "index abbrev dead fled survived", + army_index(s), sideabkz(s, false), s->dead, s->flee, s->alive); + message *unseen = msg_message("army_report", + "index abbrev dead fled survived", + army_index(s), "-?-", s->dead, s->flee, s->alive); + + for (bf = b->factions; bf; bf = bf->next) { + faction *f = bf->faction; + message *m = seematrix(f, s) ? seen : unseen; + + battle_message_faction(b, f, m); + } + + msg_release(seen); + msg_release(unseen); + } + + /* Wir benutzen drifted, um uns zu merken, ob ein Schiff + * schonmal Schaden genommen hat. (moved und drifted + * sollten in flags ueberfuehrt werden */ + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *df; + + for (df = s->fighters; df; df = df->next) { + unit *du = df->unit; + item *l; + + /* Beute verteilen */ + for (l = df->loot; l; l = l->next) { + const item_type *itype = l->type; + message *m = + msg_message("battle_loot", "unit amount item", du, l->number, + itype->rtype); + battle_message_faction(b, du->faction, m); + msg_release(m); + i_change(&du->items, itype, l->number); + } + + /* Wenn sich die Einheit auf einem Schiff befindet, wird + * dieses Schiff beschaedigt. Andernfalls ein Schiff, welches + * evt. zuvor verlassen wurde. */ + if (ships_damaged) { + ship *sh; + if (du->ship) + sh = du->ship; + else + sh = leftship(du); + + if (sh && fval(sh, SF_DAMAGED)) { + int n = b->turn - 2; + if (n > 0) { + double dmg = + config_get_flt("rules.ship.damage.battleround", + 0.05F); + damage_ship(sh, dmg * n); + freset(sh, SF_DAMAGED); + } } } } } - static int attacks_per_round(troop t) - { - return t.fighter->person[t.index].speed; + if (ships_damaged) { + ship **sp = &r->ships; + + while (*sp) { + ship *sh = *sp; + freset(sh, SF_DAMAGED); + if (sh->damage >= sh->size * DAMAGE_SCALE) { + sink_ship(sh); + remove_ship(sp, sh); + } + else { + sp = &sh->next; + } + } } - static void make_heroes(battle * b) - { + reorder_fleeing(r); +} + +static void battle_punit(unit * u, battle * b) +{ + bfaction *bf; + + for (bf = b->factions; bf; bf = bf->next) { + faction *f = bf->faction; + strlist *S = 0, *x; + + spunit(&S, f, u, 4, seen_battle); + for (x = S; x; x = x->next) { + fbattlerecord(b, f, x->s); + } + if (S) + freestrlist(S); + } +} + +static void print_fighters(battle * b, const side * s) +{ + fighter *df; + int row; + + for (row = 1; row != NUMROWS; ++row) { + message *m = NULL; + + for (df = s->fighters; df; df = df->next) { + unit *du = df->unit; + int thisrow = statusrow(df->unit->status); + + if (row == thisrow) { + if (m == NULL) { + m = msg_message("battle_row", "row", row); + message_all(b, m); + } + battle_punit(du, b); + } + } + if (m != NULL) + msg_release(m); + } +} + +bool is_attacker(const fighter * fig) +{ + return fval(fig, FIG_ATTACKER) != 0; +} + +static void set_attacker(fighter * fig) +{ + fset(fig, FIG_ATTACKER); +} + +static void print_stats(battle * b) +{ + side *s2; + side *s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + bfaction *bf; + + for (bf = b->factions; bf; bf = bf->next) { + faction *f = bf->faction; + const char *loc_army = LOC(f->locale, "battle_army"); + char *bufp; + const char *header; + size_t rsize, size; + int komma; + const char *sname = + seematrix(f, s) ? sidename(s) : LOC(f->locale, "unknown_faction"); + message *msg; + char buf[1024]; + + msg = msg_message("para_army_index", "index name", army_index(s), sname); + battle_message_faction(b, f, msg); + msg_release(msg); + + bufp = buf; + size = sizeof(buf); + komma = 0; + header = LOC(f->locale, "battle_opponents"); + + for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { + if (enemy(s2, s)) { + const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; + rsize = slprintf(bufp, size, "%s %s %d(%s)", + komma++ ? "," : (const char *)header, loc_army, army_index(s2), + abbrev); + if (rsize > size) + rsize = size - 1; + size -= rsize; + bufp += rsize; + } + } + if (komma) + fbattlerecord(b, f, buf); + + bufp = buf; + size = sizeof(buf); + komma = 0; + header = LOC(f->locale, "battle_helpers"); + + for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { + if (friendly(s2, s)) { + const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; + rsize = slprintf(bufp, size, "%s %s %d(%s)", + komma++ ? "," : (const char *)header, loc_army, army_index(s2), + abbrev); + if (rsize > size) + rsize = size - 1; + size -= rsize; + bufp += rsize; + } + } + if (komma) + fbattlerecord(b, f, buf); + + bufp = buf; + size = sizeof(buf); + komma = 0; + header = LOC(f->locale, "battle_attack"); + + for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { + if (s->relations[s2->index] & E_ATTACKING) { + const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; + rsize = + slprintf(bufp, size, "%s %s %d(%s)", + komma++ ? "," : (const char *)header, loc_army, army_index(s2), + abbrev); + if (rsize > size) + rsize = size - 1; + size -= rsize; + bufp += rsize; + } + } + if (komma) + fbattlerecord(b, f, buf); + } + + print_fighters(b, s); + } + + /* Besten Taktiker ermitteln */ + + b->max_tactics = 0; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (!selist_empty(s->leader.fighters)) { + if (s->leader.value > b->max_tactics) { + b->max_tactics = s->leader.value; + } + } + } + + if (b->max_tactics > 0) { + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->leader.value == b->max_tactics) { + selist *ql; + int qi; + + for (qi = 0, ql = s->leader.fighters; ql; selist_advance(&ql, &qi, 1)) { + fighter *tf = (fighter *)selist_get(ql, qi); + unit *u = tf->unit; + message *m = NULL; + if (!is_attacker(tf)) { + m = msg_message("para_tactics_lost", "unit", u); + } + else { + m = msg_message("para_tactics_won", "unit", u); + } + message_all(b, m); + msg_release(m); + } + } + } + } +} + +static int weapon_weight(const weapon * w, bool missile) +{ + if (missile == !!(fval(w->type, WTF_MISSILE))) { + return w->attackskill + w->defenseskill; + } + return 0; +} + +side * get_side(battle * b, const struct unit * u) +{ + side * s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->faction == u->faction) { + fighter * fig; + for (fig = s->fighters; fig; fig = fig->next) { + if (fig->unit == u) { + return s; + } + } + } + } + return 0; +} + +side * find_side(battle * b, const faction * f, const group * g, unsigned int flags, const faction * stealthfaction) +{ + side * s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->faction == f && s->group == g) { + unsigned int s1flags = flags | SIDE_HASGUARDS; + unsigned int s2flags = s->flags | SIDE_HASGUARDS; + if (rule_anon_battle && s->stealthfaction != stealthfaction) { + continue; + } + if (s1flags == s2flags) { + return s; + } + } + } + return 0; +} + +fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) +{ +#define WMAX 20 + weapon weapons[WMAX]; + region *r = b->region; + item *itm; + fighter *fig = NULL; + int h, i, tactics = effskill(u, SK_TACTICS, NULL); + int berserk; + int strongmen; + int speeded = 0, speed = 1; + int rest; + const group *g = NULL; + const faction *stealthfaction = get_otherfaction(u); + unsigned int flags = 0; + + assert(u->number); + if (fval(u, UFL_ANON_FACTION) != 0) + flags |= SIDE_STEALTH; + if (!(AllianceAuto() & HELP_FIGHT) && fval(u, UFL_GROUP)) { + g = get_group(u); + } + + /* Illusionen und Zauber kaempfen nicht */ + if (fval(u_race(u), RCF_ILLUSIONARY) || u->number == 0) { + return NULL; + } + if (s1 == NULL) { + s1 = find_side(b, u->faction, g, flags, stealthfaction); + /* aliances are moved out of make_fighter and will be handled later */ + if (!s1) { + s1 = make_side(b, u->faction, g, flags, stealthfaction); + } + else if (!stealthfaction) { + s1->stealthfaction = NULL; + } + /* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit fuer noch + * keinen Kampf ausgewaehlt wurde (sonst wuerde ein fighter existieren) */ + } + fig = (struct fighter*)calloc(1, sizeof(struct fighter)); + + fig->next = s1->fighters; + s1->fighters = fig; + + fig->unit = u; + /* In einer Burg muss man a) nicht Angreifer sein, und b) drin sein, und + * c) noch Platz finden. d) menschanaehnlich sein */ + if (attack) { + set_attacker(fig); + } + else { + building *bld = u->building; + if (bld && bld->sizeleft >= u->number && playerrace(u_race(u))) { + fig->building = bld; + fig->building->sizeleft -= u->number; + } + } + fig->status = u->status; + fig->side = s1; + fig->alive = u->number; + fig->side->alive += u->number; + fig->side->battle->alive += u->number; + fig->catmsg = -1; + + /* Freigeben nicht vergessen! */ + assert(fig->alive > 0); + fig->person = (struct person*)calloc((size_t)fig->alive, sizeof(struct person)); + + h = u->hp / u->number; + assert(h); + rest = u->hp % u->number; + + /* Effekte von Spruechen */ + + if (u->attribs) { + curse *c = get_curse(u->attribs, &ct_speed); + if (c) { + speeded = get_cursedmen(u, c); + speed = curse_geteffect_int(c); + } + } + + /* Effekte von Alchemie */ + berserk = get_effect(u, oldpotiontype[P_BERSERK]); + /* change_effect wird in ageing gemacht */ + + /* Effekte von Artefakten */ + strongmen = trollbelts(u); + if (strongmen > fig->unit->number) strongmen = fig->unit->number; + + /* Hitpoints, Attack- und Defense-Boni fuer alle Personen */ + for (i = 0; i < fig->alive; i++) { + assert(i < fig->unit->number); + fig->person[i].hp = h; + if (i < rest) + fig->person[i].hp++; + + if (i < speeded) + fig->person[i].speed = speed; + else + fig->person[i].speed = 1; + + if (i < berserk) { + fig->person[i].attack++; + } + /* Leute mit Kraftzauber machen +2 Schaden im Nahkampf. */ + if (i < strongmen) { + fig->person[i].damage += 2; + } + } + + /* Fuer alle Waffengattungen wird bestimmt, wie viele der Personen mit + * ihr kaempfen koennten, und was ihr Wert darin ist. */ + if (u_race(u)->battle_flags & BF_EQUIPMENT) { + int owp[WMAX]; + int dwp[WMAX]; + int wcount[WMAX]; + int wused[WMAX]; + int oi = 0, di = 0, w = 0; + for (itm = u->items; itm && w != WMAX; itm = itm->next) { + const weapon_type *wtype = resource2weapon(itm->type->rtype); + if (wtype == NULL || itm->number == 0) + continue; + weapons[w].attackskill = weapon_skill(wtype, u, true); + weapons[w].defenseskill = weapon_skill(wtype, u, false); + if (weapons[w].attackskill >= 0 || weapons[w].defenseskill >= 0) { + weapons[w].type = wtype; + wused[w] = 0; + wcount[w] = itm->number; + ++w; + } + assert(w != WMAX); + } + assert(w >= 0); + fig->weapons = (weapon *)calloc((size_t)(w + 1), sizeof(weapon)); + memcpy(fig->weapons, weapons, (size_t)w * sizeof(weapon)); + + for (i = 0; i != w; ++i) { + int j, o = 0, d = 0; + for (j = 0; j != i; ++j) { + if (weapon_weight(fig->weapons + j, + true) >= weapon_weight(fig->weapons + i, true)) + ++d; + if (weapon_weight(fig->weapons + j, + false) >= weapon_weight(fig->weapons + i, false)) + ++o; + } + for (j = i + 1; j != w; ++j) { + if (weapon_weight(fig->weapons + j, + true) > weapon_weight(fig->weapons + i, true)) + ++d; + if (weapon_weight(fig->weapons + j, + false) > weapon_weight(fig->weapons + i, false)) + ++o; + } + owp[o] = i; + dwp[d] = i; + } + /* jetzt enthalten owp und dwp eine absteigend schlechter werdende Liste der Waffen + * oi and di are the current index to the sorted owp/dwp arrays + * owp, dwp contain indices to the figther::weapons array */ + + /* hand out melee weapons: */ + for (i = 0; i != fig->alive; ++i) { + int wpless = weapon_skill(NULL, u, true); + while (oi != w + && (wused[owp[oi]] == wcount[owp[oi]] + || fval(fig->weapons[owp[oi]].type, WTF_MISSILE))) { + ++oi; + } + if (oi == w) + break; /* no more weapons available */ + if (weapon_weight(fig->weapons + owp[oi], false) <= wpless) { + continue; /* we fight better with bare hands */ + } + fig->person[i].melee = &fig->weapons[owp[oi]]; + ++wused[owp[oi]]; + } + /* hand out missile weapons (from back to front, in case of mixed troops). */ + for (di = 0, i = fig->alive; i-- != 0;) { + while (di != w && (wused[dwp[di]] == wcount[dwp[di]] + || !fval(fig->weapons[dwp[di]].type, WTF_MISSILE))) { + ++di; + } + if (di == w) + break; /* no more weapons available */ + if (weapon_weight(fig->weapons + dwp[di], true) > 0) { + fig->person[i].missile = &fig->weapons[dwp[di]]; + ++wused[dwp[di]]; + } + } + } + + s1->size[statusrow(fig->status)] += u->number; + s1->size[SUM_ROW] += u->number; + if (u_race(u)->battle_flags & BF_NOBLOCK) { + s1->nonblockers[statusrow(fig->status)] += u->number; + } + + if (u_race(fig->unit)->flags & RCF_HORSE) { + fig->horses = fig->unit->number; + fig->elvenhorses = 0; + } + else { + const resource_type *rt_horse = 0; + const resource_type *rt_elvenhorse = 0; + rt_elvenhorse = get_resourcetype(R_UNICORN); + rt_horse = get_resourcetype(R_CHARGER); + if (!rt_horse) { + rt_horse = get_resourcetype(R_HORSE); + } + fig->horses = rt_horse ? i_get(u->items, rt_horse->itype) : 0; + fig->elvenhorses = rt_elvenhorse ? i_get(u->items, rt_elvenhorse->itype) : 0; + } + + if (u_race(u)->battle_flags & BF_EQUIPMENT) { + for (itm = u->items; itm; itm = itm->next) { + if (itm->type->rtype->atype) { + if (i_canuse(u, itm->type)) { + struct armor *adata = (struct armor *)malloc(sizeof(armor)), **aptr; + adata->atype = itm->type->rtype->atype; + adata->count = itm->number; + for (aptr = &fig->armors; *aptr; aptr = &(*aptr)->next) { + if (adata->atype->prot > (*aptr)->atype->prot) { + break; + } + } + adata->next = *aptr; + *aptr = adata; + } + } + } + } + + /* Jetzt muss noch geschaut werden, wo die Einheit die jeweils besten + * Werte hat, das kommt aber erst irgendwo spaeter. Ich entscheide + * waehrend des Kampfes, welche ich nehme, je nach Gegner. Deswegen auch + * keine addierten boni. */ + + /* Zuerst mal die Spezialbehandlung gewisser Sonderfaelle. */ + fig->magic = effskill(u, SK_MAGIC, NULL); + + if (fig->horses) { + if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r) + || effskill(u, SK_RIDING, NULL) < CavalrySkill() + || u_race(u) == get_race(RC_TROLL) || fval(u, UFL_WERE)) + fig->horses = 0; + } + + if (fig->elvenhorses) { + if (effskill(u, SK_RIDING, NULL) < 5 || u_race(u) == get_race(RC_TROLL) + || fval(u, UFL_WERE)) + fig->elvenhorses = 0; + } + + /* Schauen, wie gut wir in Taktik sind. */ + if (tactics > 0 && u_race(u) == get_race(RC_INSECT)) + tactics -= 1 - (int)log10(fig->side->size[SUM_ROW]); +#ifdef TACTICS_MODIFIER + if (tactics > 0 && statusrow(fig->status) == FIGHT_ROW) + tactics += TACTICS_MODIFIER; + if (tactics > 0 && statusrow(fig->status) > BEHIND_ROW) { + tactics -= TACTICS_MODIFIER; + } +#endif + + if (tactics > 0) { + int bonus = 0; + + for (i = 0; i < fig->alive; i++) { + int p_bonus = 0; + int rnd; + + do { + rnd = (int)(rng_int() % 100); + if (rnd >= 40 && rnd <= 69) + p_bonus += 1; + else if (rnd <= 89) + p_bonus += 2; + else + p_bonus += 3; + } while (rnd >= 97); + if (p_bonus > bonus) p_bonus = bonus; + } + tactics += bonus; + } + + add_tactics(&fig->side->leader, fig, tactics); + ++b->nfighters; + return fig; +} + +int join_battle(battle * b, unit * u, bool attack, fighter ** cp) +{ + side *s; + fighter *fc = NULL; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + if (s->faction == u->faction) { + for (fig = s->fighters; fig; fig = fig->next) { + if (fig->unit == u) { + fc = fig; + if (attack) { + set_attacker(fig); + } + break; + } + } + } + } + if (!fc) { + *cp = make_fighter(b, u, NULL, attack); + return *cp != NULL; + } + *cp = fc; + return false; +} + +battle *make_battle(region * r) +{ + unit *u; + bfaction *bf; + building * bld; + battle *b = (battle *)calloc(1, sizeof(battle)); + + assert(b); + /* Alle Mann raus aus der Burg! */ + for (bld = r->buildings; bld != NULL; bld = bld->next) + bld->sizeleft = bld->size; + + b->region = r; + b->plane = getplane(r); + /* Finde alle Parteien, die den Kampf beobachten koennen: */ + for (u = r->units; u; u = u->next) { + if (u->number > 0) { + if (!fval(u->faction, FFL_MARK)) { + fset(u->faction, FFL_MARK); + for (bf = b->factions; bf; bf = bf->next) { + if (bf->faction == u->faction) + break; + } + if (!bf) { + bf = (bfaction *)calloc(1, sizeof(bfaction)); + assert(bf); + ++b->nfactions; + bf->faction = u->faction; + bf->next = b->factions; + b->factions = bf; + } + } + } + } + + for (bf = b->factions; bf; bf = bf->next) { + faction *f = bf->faction; + freset(f, FFL_MARK); + } + return b; +} + +static void free_side(side * si) +{ + selist_free(si->leader.fighters); +} + +static void free_fighter(fighter * fig) +{ + armor **ap = &fig->armors; + while (*ap) { + armor *a = *ap; + *ap = a->next; + free(a); + } + while (fig->loot) { + i_free(i_remove(&fig->loot, fig->loot)); + } + free(fig->person); + free(fig->weapons); + +} + +static void battle_free(battle * b) { + side *s; + + assert(b); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter **fp = &s->fighters; + while (*fp) { + fighter *fig = *fp; + *fp = fig->next; + free_fighter(fig); + free(fig); + } + s->fighters = NULL; + free_side(s); + } + free(b); +} + +void free_battle(battle * b) +{ + while (b->factions) { + bfaction *bf = b->factions; + b->factions = bf->next; + free(bf); + } + + selist_free(b->leaders); + selist_foreach(b->meffects, free); + selist_free(b->meffects); + + battle_free(b); +} + +static int *get_alive(side * s) +{ + return s->size; +} + +static int battle_report(battle * b) +{ + side *s, *s2; + bool cont = false; + bfaction *bf; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->alive - s->removed > 0) { + for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { + if (s2->alive - s2->removed > 0 && enemy(s, s2)) { + cont = true; + break; + } + } + if (cont) + break; + } + } + + fflush(stdout); + + for (bf = b->factions; bf; bf = bf->next) { + faction *fac = bf->faction; + char buf[32 * MAXSIDES]; + message *m; + sbstring sbs; + bool komma = false; + + sbs_init(&sbs, buf, sizeof(buf)); + + if (cont) + m = msg_message("para_lineup_battle", "turn", b->turn); + else + m = msg_message("para_after_battle", ""); + battle_message_faction(b, fac, m); + msg_release(m); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->alive) { + int r, k = 0, *alive = get_alive(s); + int l = FIGHT_ROW; + const char *abbrev = seematrix(fac, s) ? sideabkz(s, false) : "-?-"; + const char *loc_army = LOC(fac->locale, "battle_army"); + char buffer[32]; + + if (komma) { + sbs_strcat(&sbs, ", "); + } + snprintf(buffer, sizeof(buffer), "%s %2d(%s): ", + loc_army, army_index(s), abbrev); + sbs_strcat(&sbs, buffer); + + for (r = FIGHT_ROW; r != NUMROWS; ++r) { + if (alive[r]) { + if (l != FIGHT_ROW) { + sbs_strcat(&sbs, "+"); + } + while (k--) { + sbs_strcat(&sbs, "0+"); + } + sprintf(buffer, "%d", alive[r]); + sbs_strcat(&sbs, buffer); + + k = 0; + l = r + 1; + } + else + ++k; + } + + komma = true; + } + } + fbattlerecord(b, fac, buf); + } + return cont; +} + +static void join_allies(battle * b) +{ + region *r = b->region; + unit *u; + side *s, *s_end = b->sides + b->nsides; + /* make_side might be adding a new faction, but it adds them to the end + * of the list, so we're safe in our iteration here if we remember the end + * up front. */ + for (u = r->units; u; u = u->next) { + /* Was ist mit Schiffen? */ + if (u->status != ST_FLEE && u->status != ST_AVOID + && !fval(u, UFL_LONGACTION | UFL_ISNEW) && u->number > 0) { + faction *f = u->faction; + fighter *c = NULL; + + for (s = b->sides; s != s_end; ++s) { + side *se; + /* Wenn alle attackierten noch FFL_NOAID haben, dann kaempfe nicht mit. */ + if (fval(s->faction, FFL_NOAID)) + continue; + if (s->faction != f) { + /* Wenn wir attackiert haben, kommt niemand mehr hinzu: */ + if (s->bf->attacker) + continue; + /* alliiert muessen wir schon sein, sonst ist's eh egal : */ + if (!alliedunit(u, s->faction, HELP_FIGHT)) + continue; + /* wenn die partei verborgen ist, oder gar eine andere + * vorgespiegelt wird, und er sich uns gegenueber nicht zu + * erkennen gibt, helfen wir ihm nicht */ + if (s->stealthfaction) { + if (!alliedside(s, u->faction, HELP_FSTEALTH)) { + continue; + } + } + } + /* einen alliierten angreifen duerfen sie nicht, es sei denn, der + * ist mit einem alliierten verfeindet, der nicht attackiert + * hat: */ + for (se = b->sides; se != s_end; ++se) { + if (u->faction == se->faction) + continue; + if (alliedunit(u, se->faction, HELP_FIGHT) && !se->bf->attacker) { + continue; + } + if (enemy(s, se)) + break; + } + if (se == s_end) + continue; + /* keine Einwaende, also soll er mitmachen: */ + if (c == NULL) { + if (!join_battle(b, u, false, &c)) { + continue; + } + } + + /* the enemy of my friend is my enemy: */ + for (se = b->sides; se != s_end; ++se) { + if (se->faction != u->faction && enemy(s, se)) { + set_enemy(se, c->side, false); + } + } + } + } + } + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + int si; + side *sa; + faction *f = s->faction; + + /* Den Feinden meiner Feinde gebe ich Deckung (gegen gemeinsame Feinde): */ + for (si = 0; s->enemies[si]; ++si) { + side *se = s->enemies[si]; + int ai; + for (ai = 0; se->enemies[ai]; ++ai) { + side *as = se->enemies[ai]; + if (as == s || !enemy(as, s)) { + set_friendly(as, s); + } + } + } + + for (sa = s + 1; sa != b->sides + b->nsides; ++sa) { + if (!enemy(s, sa) && !friendly(s, sa)) { + if (alliedfaction(f, sa->faction, HELP_FIGHT)) { + if (alliedfaction(sa->faction, f, HELP_FIGHT)) { + set_friendly(s, sa); + } + } + } + } + } +} + +static void flee(const troop dt) +{ + fighter *fig = dt.fighter; + unit *u = fig->unit; + int fchance = fleechance(u); + + if (fig->person[dt.index].flags & FL_PANICED) { + fchance += EFFECT_PANIC_SPELL; + } + if (fchance > flee_chance_max_percent) { + fchance = flee_chance_max_percent; + } + if (rng_int() % 100 < fchance) { + fig->run.hp += fig->person[dt.index].hp; + ++fig->run.number; + + setguard(u, false); + kill_troop(dt); + } +} + +static bool is_calmed(const unit *u, const faction *f) { + attrib *a = a_find(u->attribs, &at_curse); + + while (a && a->type == &at_curse) { + curse *c = (curse *)a->data.v; + if (c->type == &ct_calmmonster && curse_geteffect_int(c) == f->uid) { + if (curse_active(c)) { + return true; + } + } + a = a->next; + } + return false; +} + +static bool start_battle(region * r, battle ** bp) +{ + battle *b = NULL; + unit *u; + bool fighting = false; + + for (u = r->units; u != NULL; u = u->next) { + if (fval(u, UFL_LONGACTION)) + continue; + if (u->number > 0) { + order *ord; + + for (ord = u->orders; ord; ord = ord->next) { + if (getkeyword(ord) == K_ATTACK) { + unit *u2; + fighter *c1, *c2; + ship *lsh = NULL; + plane *pl = rplane(r); + + if (pl && fval(pl, PFL_NOATTACK)) { + cmistake(u, ord, 271, MSG_BATTLE); + continue; + } + + if (u_race(u)->battle_flags & BF_NO_ATTACK) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_no_attack", + "race", u_race(u))); + continue; + } + /** + ** Fehlerbehandlung Angreifer + **/ + if (LongHunger(u)) { + cmistake(u, ord, 225, MSG_BATTLE); + continue; + } + + if (u->status == ST_AVOID || u->status == ST_FLEE) { + cmistake(u, ord, 226, MSG_BATTLE); + continue; + } + + /* ist ein Fluechtling aus einem andern Kampf */ + if (fval(u, UFL_LONGACTION)) + continue; + + if (curse_active(get_curse(r->attribs, &ct_peacezone))) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "peace_active", "")); + continue; + } + + if (curse_active(get_curse(u->attribs, &ct_slavery))) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "slave_active", "")); + continue; + } + + if ((u->ship != NULL && !fval(r->terrain, SEA_REGION)) + || (lsh = leftship(u)) != NULL) { + if (is_guarded(r, u)) { + if (lsh) { + cmistake(u, ord, 234, MSG_BATTLE); + } + else { + /* Fehler: "Das Schiff muss erst verlassen werden" */ + cmistake(u, ord, 19, MSG_BATTLE); + } + continue; + } + } + + /* Ende Fehlerbehandlung Angreifer */ + + init_order_depr(ord); + /* attackierte Einheit ermitteln */ + getunit(r, u->faction, &u2); + + /* Beginn Fehlerbehandlung */ + /* Fehler: "Die Einheit wurde nicht gefunden" */ + if (!u2 || u2->number == 0 || !cansee(u->faction, u->region, u2, 0)) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, + "feedback_unit_not_found", "")); + continue; + } + /* Fehler: "Die Einheit ist eine der unsrigen" */ + if (u2->faction == u->faction) { + cmistake(u, ord, 45, MSG_BATTLE); + continue; + } + /* Fehler: "Die Einheit ist mit uns alliert" */ + if (alliedunit(u, u2->faction, HELP_FIGHT)) { + cmistake(u, ord, 47, MSG_BATTLE); + continue; + } + if (IsImmune(u2->faction)) { + add_message(&u->faction->msgs, + msg_feedback(u, u->thisorder, "newbie_immunity_error", "turns", + NewbieImmunity())); + continue; + } + + /* Fehler: "Die Einheit ist mit uns alliert" */ + if (is_calmed(u, u2->faction)) { + cmistake(u, ord, 47, MSG_BATTLE); + continue; + } + /* Ende Fehlerbehandlung */ + if (b == NULL) { + unit *utmp; + for (utmp = r->units; utmp != NULL; utmp = utmp->next) { + fset(utmp->faction, FFL_NOAID); + } + b = make_battle(r); + } + join_battle(b, u, true, &c1); + join_battle(b, u2, false, &c2); + + if (u2->attribs) { + if (it_mistletoe) { + int effect = get_effect(u2, it_mistletoe); + if (effect >= u->number) { + change_effect(u2, it_mistletoe, -u2->number); + c2->run.hp = u2->hp; + c2->run.number = u2->number; + c2->side->flee += u2->number; + setguard(u2, false); + rmfighter(c2, u2->number); + } + } + } + + /* Hat die attackierte Einheit keinen Noaid-Status, + * wird das Flag von der Faction genommen, andere + * Einheiten greifen ein. */ + if (!fval(u2, UFL_NOAID)) + freset(u2->faction, FFL_NOAID); + + if (c1 && c2 && c2->run.number < c2->unit->number) { + /* Merken, wer Angreifer ist, fuer die Rueckzahlung der + * Praecombataura bei kurzem Kampf. */ + c1->side->bf->attacker = true; + + set_enemy(c1->side, c2->side, true); + fighting = true; + } + } + } + } + } + *bp = b; + return fighting; +} + +/** execute one round of attacks + * fig->fighting is used to determine who attacks, not fig->alive, since + * the latter may be influenced by attacks that already took place. + */ +static void battle_attacks(battle * b) +{ + side *s; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + + if (b->turn != 0 || (b->max_tactics > 0 + && get_tactics(s, NULL) == b->max_tactics)) { + for (fig = s->fighters; fig; fig = fig->next) { + + /* ist in dieser Einheit noch jemand handlungsfaehig? */ + if (fig->fighting <= 0) + continue; + + /* Handle the unit's attack on someone */ + do_attack(fig); + } + } + } +} + +/** updates the number of attacking troops in each fighter struct. + * this has to be calculated _before_ the actual attacks take + * place because otherwise dead troops would not strike in the + * round they die. */ +static void battle_update(battle * b) +{ + side *s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + for (fig = s->fighters; fig; fig = fig->next) { + fig->fighting = fig->alive - fig->removed; + } + } +} + +/** attempt to flee from battle before the next round begins + * there's a double attempt before the first round, but only + * one attempt before round zero, the potential tactics round. */ +static void battle_flee(battle * b) +{ + int attempt, flee_ops = 1; + + if (b->turn == 1) + flee_ops = 2; + + for (attempt = 1; attempt <= flee_ops; ++attempt) { side *s; for (s = b->sides; s != b->sides + b->nsides; ++s) { fighter *fig; for (fig = s->fighters; fig; fig = fig->next) { unit *u = fig->unit; - if (fval(u, UFL_HERO)) { - int i; - if (!playerrace(u_race(u))) { - log_error("Hero %s is a %s.\n", unitname(u), u_race(u)->_name); - } - for (i = 0; i != u->number; ++i) { - fig->person[i].speed += (rule_hero_speed - 1); - } - } - } - } - } + troop dt; + /* Flucht nicht bei mehr als 600 HP. Damit Wyrme toetbar bleiben. */ + int runhp = (int)(0.9 + unit_max_hp(u) * hpflee(u->status)); + if (runhp > 600) runhp = 600; - static void attack(battle * b, troop ta, const att * a, int numattack) - { - fighter *af = ta.fighter; - troop td; - unit *au = af->unit; - - switch (a->type) { - case AT_COMBATSPELL: - /* Magier versuchen immer erstmal zu zaubern, erst wenn das - * fehlschlaegt, wird af->magic == 0 und der Magier kaempft - * konventionell weiter */ - if (numattack == 0 && af->magic > 0) { - /* wenn der magier in die potenzielle Reichweite von Attacken des - * Feindes kommt, beginnt er auch bei einem Status von KAEMPFE NICHT, - * Kampfzauber zu schleudern: */ - if (count_enemies(b, af, melee_range[0], missile_range[1], - SELECT_ADVANCE | SELECT_DISTANCE | SELECT_FIND)) { - do_combatspell(ta); - } - } - break; - case AT_STANDARD: /* Waffen, mag. Gegenstaende, Kampfzauber */ - if (numattack > 0 || af->magic <= 0) { - weapon *wp = ta.fighter->person[ta.index].missile; - int melee = - count_enemies(b, af, melee_range[0], melee_range[1], - SELECT_ADVANCE | SELECT_DISTANCE | SELECT_FIND); - if (melee) - wp = preferred_weapon(ta, true); - /* Sonderbehandlungen */ - - if (getreload(ta)) { - ta.fighter->person[ta.index].reload--; - } - else { - bool standard_attack = true; - bool reload = false; - /* spezialattacken der waffe nur, wenn erste attacke in der runde. - * sonst helden mit feuerschwertern zu maechtig */ - if (numattack == 0 && wp && wp->type->attack) { - int dead = 0; - standard_attack = wp->type->attack(&ta, wp->type, &dead); - if (!standard_attack) - reload = true; - af->catmsg += dead; - if (!standard_attack && af->person[ta.index].last_action < b->turn) { - af->person[ta.index].last_action = b->turn; - } - } - if (standard_attack) { - bool missile = false; - if (wp && fval(wp->type, WTF_MISSILE)) - missile = true; - if (missile) { - td = select_opponent(b, ta, missile_range[0], missile_range[1]); - } - else { - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - } - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - reload = true; - if (hits(ta, td, wp)) { - const char *d; - if (wp == NULL) - d = u_race(au)->def_damage; - else if (is_riding(ta)) - d = wp->type->damage[1]; - else - d = wp->type->damage[0]; - terminate(td, ta, a->type, d, missile); - } - } - if (reload && wp && wp->type->reload && !getreload(ta)) { - setreload(ta); - } - } - } - break; - case AT_SPELL: /* Extra-Sprueche. Kampfzauber in AT_COMBATSPELL! */ - do_extra_spell(ta, a); - break; - case AT_NATURAL: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (hits(ta, td, NULL)) { - terminate(td, ta, a->type, a->data.dice, false); - } - break; - case AT_DRAIN_ST: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (hits(ta, td, NULL)) { - int c = dice_rand(a->data.dice); - while (c > 0) { - if (rng_int() % 2) { - td.fighter->person[td.index].attack -= 1; - } - else { - td.fighter->person[td.index].defense -= 1; - } - c--; - } - } - break; - case AT_DRAIN_EXP: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (hits(ta, td, NULL)) { - drain_exp(td.fighter->unit, dice_rand(a->data.dice)); - } - break; - case AT_DAZZLE: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (hits(ta, td, NULL)) { - dazzle(b, &td); - } - break; - case AT_STRUCTURAL: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (td.fighter->unit->ship) { - int dice = dice_rand(a->data.dice); - ship * sh = td.fighter->unit->ship; - damage_ship(sh, dice / sh->type->damage / sh->size); - } - else if (td.fighter->unit->building) { - damage_building(b, td.fighter->unit->building, dice_rand(a->data.dice)); - } - } - } - - void do_attack(fighter * af) - { - troop ta; - unit *au = af->unit; - side *side = af->side; - battle *b = side->battle; - - ta.fighter = af; - - assert(au && au->number); - /* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen - * Kaempfern beruht, darf die Reihenfolge und Groesse der Einheit keine - * Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der - * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zufaellig - * mit einer grossen Einheit zuerst drankommt, extrem bevorteilt. */ - ta.index = af->fighting; - - while (ta.index--) { - /* Wir suchen eine beliebige Feind-Einheit aus. An der koennen - * wir feststellen, ob noch jemand da ist. */ - int apr, attacks = attacks_per_round(ta); - if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND)) - break; - - for (apr = 0; apr != attacks; ++apr) { - int a; - for (a = 0; a < RACE_ATTACKS && u_race(au)->attack[a].type != AT_NONE; ++a) { - if (apr > 0) { - /* Wenn die Waffe nachladen muss, oder es sich nicht um einen - * Waffen-Angriff handelt, dann gilt der Speed nicht. */ - /* TODO: allow multiple AT_NATURAL attacks? */ - if (u_race(au)->attack[a].type != AT_STANDARD) - continue; - else { - weapon *wp = preferred_weapon(ta, true); - if (wp != NULL && wp->type->reload) - continue; - } - } - attack(b, ta, &(u_race(au)->attack[a]), apr); - } - } - } - /* Der letzte Katapultschuetze setzt die - * Ladezeit neu und generiert die Meldung. */ - if (af->catmsg >= 0) { - struct message *m = - msg_message("killed_battle", "unit dead", au, af->catmsg); - message_all(b, m); - msg_release(m); - af->catmsg = -1; - } - } - - static void add_tactics(tactics * ta, fighter * fig, int value) - { - if (value == 0 || value < ta->value) - return; - if (value > ta->value) { - selist_free(ta->fighters); - ta->fighters = 0; - } - selist_push(&ta->fighters, fig); - selist_push(&fig->side->battle->leaders, fig); - ta->value = value; - } - - static int horse_fleeing_bonus(const unit * u) - { - const item_type *it_horse, *it_elvenhorse, *it_charger; - int n1 = 0, n2 = 0, n3 = 0; - item *itm; - int skl = effskill(u, SK_RIDING, NULL); - const resource_type *rtype; - - it_horse = ((rtype = get_resourcetype(R_HORSE)) != NULL) ? rtype->itype : 0; - it_elvenhorse = ((rtype = get_resourcetype(R_UNICORN)) != NULL) ? rtype->itype : 0; - it_charger = ((rtype = get_resourcetype(R_CHARGER)) != NULL) ? rtype->itype : 0; - - for (itm = u->items; itm; itm = itm->next) { - if (itm->type->flags & ITF_ANIMAL) { - if (itm->type == it_elvenhorse) - n3 += itm->number; - else if (itm->type == it_charger) - n2 += itm->number; - else if (itm->type == it_horse) - n1 += itm->number; - } - } - if (skl >= 5 && n3 >= u->number) - return 30; - if (skl >= 2 && n2 + n3 >= u->number) - return 20; - if (n1 + n2 + n3 >= u->number) - return 10; - return 0; - } - - static int fleechance(unit * u) - { - int p = flee_chance_base; /* Fluchtwahrscheinlichkeit in % */ - /* Einheit u versucht, dem Getuemmel zu entkommen */ - - p += (effskill(u, SK_STEALTH, NULL) * flee_chance_skill_bonus); - p += horse_fleeing_bonus(u); - - if (u_race(u) == get_race(RC_HALFLING)) { - p += flee_chance_base; - if (p > flee_chance_max_percent) { - p = flee_chance_max_percent; - } - } - return p; - } - - /** add a new army to the conflict. - * beware: armies need to be added _at the beginning_ of the list because - * otherwise join_allies() will get into trouble */ - side *make_side(battle * b, const faction * f, const group * g, - unsigned int flags, const faction * stealthfaction) - { - side *s1 = b->sides + b->nsides; - bfaction *bf; - - if (fval(b->region->terrain, SEA_REGION)) { - /* every fight in an ocean is short */ - flags |= SIDE_HASGUARDS; - } - else { - unit *u; - for (u = b->region->units; u; u = u->next) { - if (is_guard(u)) { - if (alliedunit(u, f, HELP_GUARD)) { - flags |= SIDE_HASGUARDS; - break; - } - } - } - } - - s1->battle = b; - s1->group = g; - s1->flags = flags; - s1->stealthfaction = stealthfaction; - for (bf = b->factions; bf; bf = bf->next) { - faction *f2 = bf->faction; - - if (f2 == f) { - s1->bf = bf; - s1->faction = f2; - s1->index = b->nsides++; - s1->nextF = bf->sides; - bf->sides = s1; - assert(b->nsides <= MAXSIDES); - break; - } - } - assert(bf); - return s1; - } - - troop select_ally(fighter * af, int minrow, int maxrow, int allytype) - { - side *as = af->side; - battle *b = as->battle; - side *ds; - int allies = count_allies(as, minrow, maxrow, SELECT_ADVANCE, allytype); - - if (!allies) { - return no_troop; - } - allies = (int)(rng_int() % allies); - - for (ds = b->sides; ds != b->sides + b->nsides; ++ds) { - if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF - && as->faction == ds->faction)) { - fighter *df; - for (df = ds->fighters; df; df = df->next) { - int dr = get_unitrow(df, NULL); - if (dr >= minrow && dr <= maxrow) { - if (df->alive - df->removed > allies) { - troop dt; - assert(allies >= 0); - dt.index = allies; - dt.fighter = df; - return dt; - } - allies -= df->alive; - } - } - } - } - assert(!"we should never have gotten here"); - return no_troop; - } - - static int loot_quota(const unit * src, const unit * dst, - const item_type * type, int n) - { - UNUSED_ARG(type); - if (dst && src && src->faction != dst->faction) { - double divisor = config_get_flt("rules.items.loot_divisor", 1); - assert(divisor <= 0 || divisor >= 1); - if (divisor >= 1) { - double r = n / divisor; - int x = (int)r; - - r = r - x; - if (chance(r)) - ++x; - - return x; - } - } - return n; - } - - static void loot_items(fighter * corpse) - { - unit *u = corpse->unit; - item *itm = u->items; - battle *b = corpse->side->battle; - int dead = dead_fighters(corpse); - - if (dead <= 0) - return; - - while (itm) { - float lootfactor = (float)dead / (float)u->number; /* only loot the dead! */ - int maxloot = (int)((float)itm->number * lootfactor); - if (maxloot > 0) { - int i = (maxloot > 10) ? 10 : maxloot; - for (; i != 0; --i) { - int loot = maxloot / i; - - if (loot > 0) { - fighter *fig = NULL; - int looting = 0; - int maxrow = 0; - /* mustloot: we absolutely, positively must have somebody loot this thing */ - int mustloot = itm->type->flags & (ITF_CURSED | ITF_NOTLOST); - - itm->number -= loot; - maxloot -= loot; - - if (is_monsters(u->faction) && (rule_loot & LOOT_MONSTERS)) { - looting = 1; - } - else if (rule_loot & LOOT_OTHERS) { - looting = 1; - } - else if (rule_loot & LOOT_SELF) { - looting = 2; - } - if (looting) { - if (mustloot) { - maxrow = LAST_ROW; - } - else if (rule_loot & LOOT_KEEPLOOT) { - int lootchance = 50 + b->keeploot; - if (rng_int() % 100 < lootchance) { - maxrow = BEHIND_ROW; - } - } - else { - maxrow = LAST_ROW; - } - } - if (maxrow > 0) { - if (looting == 1) { - /* enemies get dibs */ - fig = select_enemy(corpse, FIGHT_ROW, maxrow, 0).fighter; - } - if (!fig) { - /* self and allies get second pick */ - fig = select_ally(corpse, FIGHT_ROW, LAST_ROW, ALLY_SELF).fighter; - } - } - - if (fig) { - int trueloot = - mustloot ? loot : loot_quota(corpse->unit, fig->unit, itm->type, - loot); - if (trueloot > 0) { - i_change(&fig->loot, itm->type, trueloot); - } - } - } - } - } - itm = itm->next; - } - } - - bool seematrix(const faction * f, const side * s) - { - if (f == s->faction) - return true; - if (s->flags & SIDE_STEALTH) - return false; - return true; - } - - static double PopulationDamage(void) - { - return rule_population_damage / 100.0; - } - - static void battle_effects(battle * b, int dead_players) - { - region *r = b->region; - int rp = rpeasants(r); - - if (rp > 0) { - int dead_peasants = (int)(dead_players * PopulationDamage()); - if (dead_peasants > rp) { - dead_peasants = rp; - } - if (dead_peasants) { - deathcounts(r, dead_peasants + dead_players); - rsetpeasants(r, rp - dead_peasants); - } - } - } - - static void reorder_fleeing(region * r) - { - unit **usrc = &r->units; - unit **udst = &r->units; - unit *ufirst = NULL; - unit *u; - - for (; *udst; udst = &u->next) { - u = *udst; - } - - for (u = *usrc; u != ufirst; u = *usrc) { - if (u->next && fval(u, UFL_FLEEING)) { - *usrc = u->next; - *udst = u; - udst = &u->next; - if (!ufirst) - ufirst = u; - } - else { - usrc = &u->next; - } - } - *udst = NULL; - } - - static void aftermath(battle * b) - { - region *r = b->region; - side *s; - int dead_players = 0; - bfaction *bf; - bool ships_damaged = (b->turn + (b->has_tactics_turn ? 1 : 0) > 2); /* only used for ship damage! */ - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *df; - s->dead = 0; - - for (df = s->fighters; df; df = df->next) { - unit *du = df->unit; - int dead = dead_fighters(df); - - /* tote insgesamt: */ - s->dead += dead; - /* Tote, die wiederbelebt werde koennen: */ - if (playerrace(u_race(df->unit))) { - s->casualties += dead; - } - if (df->hits + df->kills) { - struct message *m = - msg_message("killsandhits", "unit hits kills", du, df->hits, - df->kills); - battle_message_faction(b, du->faction, m); - msg_release(m); - } - } - } - - /* POSTCOMBAT */ - do_combatmagic(b, DO_POSTCOMBATSPELL); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - int snumber = 0; - fighter *df; - bool relevant = false; /* Kampf relevant fuer diese Partei? */ - if (!fval(s, SIDE_HASGUARDS)) { - relevant = true; - } - s->flee = 0; - - for (df = s->fighters; df; df = df->next) { - unit *du = df->unit; - int dead = dead_fighters(df); - int sum_hp = 0; - int n; - int flags = 0; - - for (n = 0; n != df->alive; ++n) { - if (df->person[n].hp > 0) { - sum_hp += df->person[n].hp; - } - } - snumber += du->number; - if (dead == df->unit->number) { - flags = UFL_DEAD; - } - else if (relevant) { - flags = UFL_LONGACTION; - if ((du->status != ST_FLEE) && (df->run.hp <= 0)) { - flags |= UFL_NOTMOVING; - } - } - if (flags) { - fset(du, flags); - } - if (df->alive && df->alive == du->number) { - du->hp = sum_hp; - continue; /* nichts passiert */ - } - else if (df->run.hp) { - if (df->alive == 0) { - /* Report the casualties */ - reportcasualties(b, df, dead); - - /* Zuerst duerfen die Feinde pluendern, die mitgenommenen Items - * stehen in fig->run.items. Dann werden die Fliehenden auf - * die leere (tote) alte Einheit gemapt */ - if (!fval(df, FIG_NOLOOT)) { - loot_items(df); - } - scale_number(du, df->run.number); - du->hp = df->run.hp; - setguard(du, false); - /* must leave ships or buildings, or a stealthy hobbit - * can hold castles indefinitely */ - if (!fval(r->terrain, SEA_REGION)) { - leave(du, true); /* even region owners have to flee */ - } - fset(du, UFL_FLEEING); - } - else { - /* nur teilweise geflohene Einheiten mergen sich wieder */ - df->alive += df->run.number; - s->size[0] += df->run.number; - s->size[statusrow(df->status)] += df->run.number; - s->alive += df->run.number; - sum_hp += df->run.hp; - df->run.number = 0; - df->run.hp = 0; - /* df->run.region = NULL; */ - - reportcasualties(b, df, dead); - - scale_number(du, df->alive); - du->hp = sum_hp; - } - } - else { - if (df->alive == 0) { - /* alle sind tot, niemand geflohen. Einheit aufloesen */ - df->run.number = 0; - df->run.hp = 0; - - /* Report the casualties */ - reportcasualties(b, df, dead); - - /* Distribute Loot */ - loot_items(df); - - setguard(du, false); - scale_number(du, 0); - } - else { - df->run.number = 0; - df->run.hp = 0; - - reportcasualties(b, df, dead); - - scale_number(du, df->alive); - du->hp = sum_hp; - } - } - s->flee += df->run.number; - - if (playerrace(u_race(du))) { - /* tote im kampf werden zu regionsuntoten: - * for each of them, a peasant will die as well */ - dead_players += dead; - } - if (du->hp < du->number) { - log_error("%s has less hitpoints (%u) than people (%u)\n", itoa36(du->no), du->hp, du->number); - du->hp = du->number; - } - } - s->alive += s->healed; - assert(snumber == s->flee + s->alive + s->dead); - } - - battle_effects(b, dead_players); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - message *seen = msg_message("army_report", - "index abbrev dead fled survived", - army_index(s), sideabkz(s, false), s->dead, s->flee, s->alive); - message *unseen = msg_message("army_report", - "index abbrev dead fled survived", - army_index(s), "-?-", s->dead, s->flee, s->alive); - - for (bf = b->factions; bf; bf = bf->next) { - faction *f = bf->faction; - message *m = seematrix(f, s) ? seen : unseen; - - battle_message_faction(b, f, m); - } - - msg_release(seen); - msg_release(unseen); - } - - /* Wir benutzen drifted, um uns zu merken, ob ein Schiff - * schonmal Schaden genommen hat. (moved und drifted - * sollten in flags ueberfuehrt werden */ - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *df; - - for (df = s->fighters; df; df = df->next) { - unit *du = df->unit; - item *l; - - /* Beute verteilen */ - for (l = df->loot; l; l = l->next) { - const item_type *itype = l->type; - message *m = - msg_message("battle_loot", "unit amount item", du, l->number, - itype->rtype); - battle_message_faction(b, du->faction, m); - msg_release(m); - i_change(&du->items, itype, l->number); - } - - /* Wenn sich die Einheit auf einem Schiff befindet, wird - * dieses Schiff beschaedigt. Andernfalls ein Schiff, welches - * evt. zuvor verlassen wurde. */ - if (ships_damaged) { - ship *sh; - if (du->ship) - sh = du->ship; - else - sh = leftship(du); - - if (sh && fval(sh, SF_DAMAGED)) { - int n = b->turn - 2; - if (n > 0) { - double dmg = - config_get_flt("rules.ship.damage.battleround", - 0.05F); - damage_ship(sh, dmg * n); - freset(sh, SF_DAMAGED); - } - } - } - } - } - - if (ships_damaged) { - ship **sp = &r->ships; - - while (*sp) { - ship *sh = *sp; - freset(sh, SF_DAMAGED); - if (sh->damage >= sh->size * DAMAGE_SCALE) { - sink_ship(sh); - remove_ship(sp, sh); - } - else { - sp = &sh->next; - } - } - } - - reorder_fleeing(r); - } - - static void battle_punit(unit * u, battle * b) - { - bfaction *bf; - - for (bf = b->factions; bf; bf = bf->next) { - faction *f = bf->faction; - strlist *S = 0, *x; - - spunit(&S, f, u, 4, seen_battle); - for (x = S; x; x = x->next) { - fbattlerecord(b, f, x->s); - } - if (S) - freestrlist(S); - } - } - - static void print_fighters(battle * b, const side * s) - { - fighter *df; - int row; - - for (row = 1; row != NUMROWS; ++row) { - message *m = NULL; - - for (df = s->fighters; df; df = df->next) { - unit *du = df->unit; - int thisrow = statusrow(df->unit->status); - - if (row == thisrow) { - if (m == NULL) { - m = msg_message("battle_row", "row", row); - message_all(b, m); - } - battle_punit(du, b); - } - } - if (m != NULL) - msg_release(m); - } - } - - bool is_attacker(const fighter * fig) - { - return fval(fig, FIG_ATTACKER) != 0; - } - - static void set_attacker(fighter * fig) - { - fset(fig, FIG_ATTACKER); - } - - static void print_stats(battle * b) - { - side *s2; - side *s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - bfaction *bf; - - for (bf = b->factions; bf; bf = bf->next) { - faction *f = bf->faction; - const char *loc_army = LOC(f->locale, "battle_army"); - char *bufp; - const char *header; - size_t rsize, size; - int komma; - const char *sname = - seematrix(f, s) ? sidename(s) : LOC(f->locale, "unknown_faction"); - message *msg; - char buf[1024]; - - msg = msg_message("para_army_index", "index name", army_index(s), sname); - battle_message_faction(b, f, msg); - msg_release(msg); - - bufp = buf; - size = sizeof(buf); - komma = 0; - header = LOC(f->locale, "battle_opponents"); - - for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (enemy(s2, s)) { - const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; - rsize = slprintf(bufp, size, "%s %s %d(%s)", - komma++ ? "," : (const char *)header, loc_army, army_index(s2), - abbrev); - if (rsize > size) - rsize = size - 1; - size -= rsize; - bufp += rsize; - } - } - if (komma) - fbattlerecord(b, f, buf); - - bufp = buf; - size = sizeof(buf); - komma = 0; - header = LOC(f->locale, "battle_helpers"); - - for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (friendly(s2, s)) { - const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; - rsize = slprintf(bufp, size, "%s %s %d(%s)", - komma++ ? "," : (const char *)header, loc_army, army_index(s2), - abbrev); - if (rsize > size) - rsize = size - 1; - size -= rsize; - bufp += rsize; - } - } - if (komma) - fbattlerecord(b, f, buf); - - bufp = buf; - size = sizeof(buf); - komma = 0; - header = LOC(f->locale, "battle_attack"); - - for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (s->relations[s2->index] & E_ATTACKING) { - const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; - rsize = - slprintf(bufp, size, "%s %s %d(%s)", - komma++ ? "," : (const char *)header, loc_army, army_index(s2), - abbrev); - if (rsize > size) - rsize = size - 1; - size -= rsize; - bufp += rsize; - } - } - if (komma) - fbattlerecord(b, f, buf); - } - - print_fighters(b, s); - } - - /* Besten Taktiker ermitteln */ - - b->max_tactics = 0; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (!selist_empty(s->leader.fighters)) { - if (s->leader.value > b->max_tactics) { - b->max_tactics = s->leader.value; - } - } - } - - if (b->max_tactics > 0) { - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->leader.value == b->max_tactics) { - selist *ql; - int qi; - - for (qi = 0, ql = s->leader.fighters; ql; selist_advance(&ql, &qi, 1)) { - fighter *tf = (fighter *)selist_get(ql, qi); - unit *u = tf->unit; - message *m = NULL; - if (!is_attacker(tf)) { - m = msg_message("para_tactics_lost", "unit", u); - } - else { - m = msg_message("para_tactics_won", "unit", u); - } - message_all(b, m); - msg_release(m); - } - } - } - } - } - - static int weapon_weight(const weapon * w, bool missile) - { - if (missile == !!(fval(w->type, WTF_MISSILE))) { - return w->attackskill + w->defenseskill; - } - return 0; - } - - side * get_side(battle * b, const struct unit * u) - { - side * s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->faction == u->faction) { - fighter * fig; - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->unit == u) { - return s; - } - } - } - } - return 0; - } - - side * find_side(battle * b, const faction * f, const group * g, unsigned int flags, const faction * stealthfaction) - { - side * s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->faction == f && s->group == g) { - unsigned int s1flags = flags | SIDE_HASGUARDS; - unsigned int s2flags = s->flags | SIDE_HASGUARDS; - if (rule_anon_battle && s->stealthfaction != stealthfaction) { + if (u->ship && fval(u->region->terrain, SEA_REGION)) { + /* keine Flucht von Schiffen auf hoher See */ continue; } - if (s1flags == s2flags) { - return s; - } - } - } - return 0; - } - - fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) - { -#define WMAX 20 - weapon weapons[WMAX]; - region *r = b->region; - item *itm; - fighter *fig = NULL; - int h, i, tactics = effskill(u, SK_TACTICS, NULL); - int berserk; - int strongmen; - int speeded = 0, speed = 1; - int rest; - const group *g = NULL; - const faction *stealthfaction = get_otherfaction(u); - unsigned int flags = 0; - - assert(u->number); - if (fval(u, UFL_ANON_FACTION) != 0) - flags |= SIDE_STEALTH; - if (!(AllianceAuto() & HELP_FIGHT) && fval(u, UFL_GROUP)) { - g = get_group(u); - } - - /* Illusionen und Zauber kaempfen nicht */ - if (fval(u_race(u), RCF_ILLUSIONARY) || u->number == 0) { - return NULL; - } - if (s1 == NULL) { - s1 = find_side(b, u->faction, g, flags, stealthfaction); - /* aliances are moved out of make_fighter and will be handled later */ - if (!s1) { - s1 = make_side(b, u->faction, g, flags, stealthfaction); - } - else if (!stealthfaction) { - s1->stealthfaction = NULL; - } - /* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit fuer noch - * keinen Kampf ausgewaehlt wurde (sonst wuerde ein fighter existieren) */ - } - fig = (struct fighter*)calloc(1, sizeof(struct fighter)); - - fig->next = s1->fighters; - s1->fighters = fig; - - fig->unit = u; - /* In einer Burg muss man a) nicht Angreifer sein, und b) drin sein, und - * c) noch Platz finden. d) menschanaehnlich sein */ - if (attack) { - set_attacker(fig); - } - else { - building *bld = u->building; - if (bld && bld->sizeleft >= u->number && playerrace(u_race(u))) { - fig->building = bld; - fig->building->sizeleft -= u->number; - } - } - fig->status = u->status; - fig->side = s1; - fig->alive = u->number; - fig->side->alive += u->number; - fig->side->battle->alive += u->number; - fig->catmsg = -1; - - /* Freigeben nicht vergessen! */ - assert(fig->alive > 0); - fig->person = (struct person*)calloc((size_t)fig->alive, sizeof(struct person)); - - h = u->hp / u->number; - assert(h); - rest = u->hp % u->number; - - /* Effekte von Spruechen */ - - if (u->attribs) { - curse *c = get_curse(u->attribs, &ct_speed); - if (c) { - speeded = get_cursedmen(u, c); - speed = curse_geteffect_int(c); - } - } - - /* Effekte von Alchemie */ - berserk = get_effect(u, oldpotiontype[P_BERSERK]); - /* change_effect wird in ageing gemacht */ - - /* Effekte von Artefakten */ - strongmen = trollbelts(u); - if (strongmen > fig->unit->number) strongmen = fig->unit->number; - - /* Hitpoints, Attack- und Defense-Boni fuer alle Personen */ - for (i = 0; i < fig->alive; i++) { - assert(i < fig->unit->number); - fig->person[i].hp = h; - if (i < rest) - fig->person[i].hp++; - - if (i < speeded) - fig->person[i].speed = speed; - else - fig->person[i].speed = 1; - - if (i < berserk) { - fig->person[i].attack++; - } - /* Leute mit Kraftzauber machen +2 Schaden im Nahkampf. */ - if (i < strongmen) { - fig->person[i].damage += 2; - } - } - - /* Fuer alle Waffengattungen wird bestimmt, wie viele der Personen mit - * ihr kaempfen koennten, und was ihr Wert darin ist. */ - if (u_race(u)->battle_flags & BF_EQUIPMENT) { - int owp[WMAX]; - int dwp[WMAX]; - int wcount[WMAX]; - int wused[WMAX]; - int oi = 0, di = 0, w = 0; - for (itm = u->items; itm && w != WMAX; itm = itm->next) { - const weapon_type *wtype = resource2weapon(itm->type->rtype); - if (wtype == NULL || itm->number == 0) + if (fval(u_race(u), RCF_UNDEAD) || u_race(u) == get_race(RC_SHADOWKNIGHT)) { + /* Untote fliehen nicht. Warum eigentlich? */ continue; - weapons[w].attackskill = weapon_skill(wtype, u, true); - weapons[w].defenseskill = weapon_skill(wtype, u, false); - if (weapons[w].attackskill >= 0 || weapons[w].defenseskill >= 0) { - weapons[w].type = wtype; - wused[w] = 0; - wcount[w] = itm->number; - ++w; } - assert(w != WMAX); - } - assert(w >= 0); - fig->weapons = (weapon *)calloc((size_t)(w + 1), sizeof(weapon)); - memcpy(fig->weapons, weapons, (size_t)w * sizeof(weapon)); - for (i = 0; i != w; ++i) { - int j, o = 0, d = 0; - for (j = 0; j != i; ++j) { - if (weapon_weight(fig->weapons + j, - true) >= weapon_weight(fig->weapons + i, true)) - ++d; - if (weapon_weight(fig->weapons + j, - false) >= weapon_weight(fig->weapons + i, false)) - ++o; - } - for (j = i + 1; j != w; ++j) { - if (weapon_weight(fig->weapons + j, - true) > weapon_weight(fig->weapons + i, true)) - ++d; - if (weapon_weight(fig->weapons + j, - false) > weapon_weight(fig->weapons + i, false)) - ++o; - } - owp[o] = i; - dwp[d] = i; - } - /* jetzt enthalten owp und dwp eine absteigend schlechter werdende Liste der Waffen - * oi and di are the current index to the sorted owp/dwp arrays - * owp, dwp contain indices to the figther::weapons array */ + dt.fighter = fig; + dt.index = fig->alive - fig->removed; + while (s->size[SUM_ROW] && dt.index != 0) { + --dt.index; + assert(dt.index >= 0 && dt.index < fig->unit->number); + assert(fig->person[dt.index].hp > 0); - /* hand out melee weapons: */ - for (i = 0; i != fig->alive; ++i) { - int wpless = weapon_skill(NULL, u, true); - while (oi != w - && (wused[owp[oi]] == wcount[owp[oi]] - || fval(fig->weapons[owp[oi]].type, WTF_MISSILE))) { - ++oi; - } - if (oi == w) - break; /* no more weapons available */ - if (weapon_weight(fig->weapons + owp[oi], false) <= wpless) { - continue; /* we fight better with bare hands */ - } - fig->person[i].melee = &fig->weapons[owp[oi]]; - ++wused[owp[oi]]; - } - /* hand out missile weapons (from back to front, in case of mixed troops). */ - for (di = 0, i = fig->alive; i-- != 0;) { - while (di != w && (wused[dwp[di]] == wcount[dwp[di]] - || !fval(fig->weapons[dwp[di]].type, WTF_MISSILE))) { - ++di; - } - if (di == w) - break; /* no more weapons available */ - if (weapon_weight(fig->weapons + dwp[di], true) > 0) { - fig->person[i].missile = &fig->weapons[dwp[di]]; - ++wused[dwp[di]]; + /* Versuche zu fliehen, wenn + * - Kampfstatus fliehe + * - schwer verwundet und nicht erste kampfrunde + * - in panik (Zauber) + * aber nicht, wenn der Zaubereffekt Held auf dir liegt! + */ + switch (u->status) { + case ST_FLEE: + break; + default: + if ((fig->person[dt.index].flags & FL_HIT) == 0) + continue; + if (fig->person[dt.index].hp <= runhp) + break; + if (fig->person[dt.index].flags & FL_PANICED) { + if ((fig->person[dt.index].flags & FL_COURAGE) == 0) + break; + } + continue; + } + flee(dt); } } } + } +} - s1->size[statusrow(fig->status)] += u->number; - s1->size[SUM_ROW] += u->number; - if (u_race(u)->battle_flags & BF_NOBLOCK) { - s1->nonblockers[statusrow(fig->status)] += u->number; - } - - if (u_race(fig->unit)->flags & RCF_HORSE) { - fig->horses = fig->unit->number; - fig->elvenhorses = 0; +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) { + return enemy(s1, s2); + } + } } else { - const resource_type *rt_horse = 0; - const resource_type *rt_elvenhorse = 0; - rt_elvenhorse = get_resourcetype(R_UNICORN); - rt_horse = get_resourcetype(R_CHARGER); - if (!rt_horse) { - rt_horse = get_resourcetype(R_HORSE); - } - fig->horses = rt_horse ? i_get(u->items, rt_horse->itype) : 0; - fig->elvenhorses = rt_elvenhorse ? i_get(u->items, rt_elvenhorse->itype) : 0; - } - - if (u_race(u)->battle_flags & BF_EQUIPMENT) { - for (itm = u->items; itm; itm = itm->next) { - if (itm->type->rtype->atype) { - if (i_canuse(u, itm->type)) { - struct armor *adata = (struct armor *)malloc(sizeof(armor)), **aptr; - adata->atype = itm->type->rtype->atype; - adata->count = itm->number; - for (aptr = &fig->armors; *aptr; aptr = &(*aptr)->next) { - if (adata->atype->prot > (*aptr)->atype->prot) { - break; - } - } - adata->next = *aptr; - *aptr = adata; - } - } - } - } - - /* Jetzt muss noch geschaut werden, wo die Einheit die jeweils besten - * Werte hat, das kommt aber erst irgendwo spaeter. Ich entscheide - * waehrend des Kampfes, welche ich nehme, je nach Gegner. Deswegen auch - * keine addierten boni. */ - - /* Zuerst mal die Spezialbehandlung gewisser Sonderfaelle. */ - fig->magic = effskill(u, SK_MAGIC, NULL); - - if (fig->horses) { - if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r) - || effskill(u, SK_RIDING, NULL) < CavalrySkill() - || u_race(u) == get_race(RC_TROLL) || fval(u, UFL_WERE)) - fig->horses = 0; - } - - if (fig->elvenhorses) { - if (effskill(u, SK_RIDING, NULL) < 5 || u_race(u) == get_race(RC_TROLL) - || fval(u, UFL_WERE)) - fig->elvenhorses = 0; - } - - /* Schauen, wie gut wir in Taktik sind. */ - if (tactics > 0 && u_race(u) == get_race(RC_INSECT)) - tactics -= 1 - (int)log10(fig->side->size[SUM_ROW]); -#ifdef TACTICS_MODIFIER - if (tactics > 0 && statusrow(fig->status) == FIGHT_ROW) - tactics += TACTICS_MODIFIER; - if (tactics > 0 && statusrow(fig->status) > BEHIND_ROW) { - tactics -= TACTICS_MODIFIER; - } -#endif - - if (tactics > 0) { - int bonus = 0; - - for (i = 0; i < fig->alive; i++) { - int p_bonus = 0; - int rnd; - - do { - rnd = (int)(rng_int() % 100); - if (rnd >= 40 && rnd <= 69) - p_bonus += 1; - else if (rnd <= 89) - p_bonus += 2; - else - p_bonus += 3; - } while (rnd >= 97); - if (p_bonus > bonus) p_bonus = bonus; - } - tactics += bonus; - } - - add_tactics(&fig->side->leader, fig, tactics); - ++b->nfighters; - return fig; - } - - int join_battle(battle * b, unit * u, bool attack, fighter ** cp) - { - side *s; - fighter *fc = NULL; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - if (s->faction == u->faction) { - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->unit == u) { - fc = fig; - if (attack) { - set_attacker(fig); - } - break; - } - } - } - } - if (!fc) { - *cp = make_fighter(b, u, NULL, attack); - return *cp != NULL; - } - *cp = fc; - return false; - } - - battle *make_battle(region * r) - { - unit *u; - bfaction *bf; - building * bld; - battle *b = (battle *)calloc(1, sizeof(battle)); - - assert(b); - /* Alle Mann raus aus der Burg! */ - for (bld = r->buildings; bld != NULL; bld = bld->next) - bld->sizeleft = bld->size; - - b->region = r; - b->plane = getplane(r); - /* Finde alle Parteien, die den Kampf beobachten koennen: */ - for (u = r->units; u; u = u->next) { - if (u->number > 0) { - if (!fval(u->faction, FFL_MARK)) { - fset(u->faction, FFL_MARK); - for (bf = b->factions; bf; bf = bf->next) { - if (bf->faction == u->faction) - break; - } - if (!bf) { - bf = (bfaction *)calloc(1, sizeof(bfaction)); - assert(bf); - ++b->nfactions; - bf->faction = u->faction; - bf->next = b->factions; - b->factions = bf; - } - } - } - } - - for (bf = b->factions; bf; bf = bf->next) { - faction *f = bf->faction; - freset(f, FFL_MARK); - } - return b; - } - - static void free_side(side * si) - { - selist_free(si->leader.fighters); - } - - static void free_fighter(fighter * fig) - { - armor **ap = &fig->armors; - while (*ap) { - armor *a = *ap; - *ap = a->next; - free(a); - } - while (fig->loot) { - i_free(i_remove(&fig->loot, fig->loot)); - } - free(fig->person); - free(fig->weapons); - - } - - static void battle_free(battle * b) { - side *s; - - assert(b); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter **fp = &s->fighters; - while (*fp) { - fighter *fig = *fp; - *fp = fig->next; - free_fighter(fig); - free(fig); - } - s->fighters = NULL; - free_side(s); - } - free(b); - } - - void free_battle(battle * b) - { - while (b->factions) { - bfaction *bf = b->factions; - b->factions = bf->next; - free(bf); - } - - selist_free(b->leaders); - selist_foreach(b->meffects, free); - selist_free(b->meffects); - - battle_free(b); - } - - static int *get_alive(side * s) - { - return s->size; - } - - static int battle_report(battle * b) - { - side *s, *s2; - bool cont = false; - bfaction *bf; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->alive - s->removed > 0) { - for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (s2->alive - s2->removed > 0 && enemy(s, s2)) { - cont = true; - break; - } - } - if (cont) - break; - } - } - - fflush(stdout); - - for (bf = b->factions; bf; bf = bf->next) { - faction *fac = bf->faction; - char buf[32 * MAXSIDES]; - message *m; - sbstring sbs; - bool komma = false; - - sbs_init(&sbs, buf, sizeof(buf)); - - if (cont) - m = msg_message("para_lineup_battle", "turn", b->turn); - else - m = msg_message("para_after_battle", ""); - battle_message_faction(b, fac, m); - msg_release(m); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->alive) { - int r, k = 0, *alive = get_alive(s); - int l = FIGHT_ROW; - const char *abbrev = seematrix(fac, s) ? sideabkz(s, false) : "-?-"; - const char *loc_army = LOC(fac->locale, "battle_army"); - char buffer[32]; - - if (komma) { - sbs_strcat(&sbs, ", "); - } - snprintf(buffer, sizeof(buffer), "%s %2d(%s): ", - loc_army, army_index(s), abbrev); - sbs_strcat(&sbs, buffer); - - for (r = FIGHT_ROW; r != NUMROWS; ++r) { - if (alive[r]) { - if (l != FIGHT_ROW) { - sbs_strcat(&sbs, "+"); - } - while (k--) { - sbs_strcat(&sbs, "0+"); - } - sprintf(buffer, "%d", alive[r]); - sbs_strcat(&sbs, buffer); - - k = 0; - l = r + 1; - } - else - ++k; - } - - komma = true; - } - } - fbattlerecord(b, fac, buf); - } - return cont; - } - - static void join_allies(battle * b) - { - region *r = b->region; - unit *u; - side *s, *s_end = b->sides + b->nsides; - /* make_side might be adding a new faction, but it adds them to the end - * of the list, so we're safe in our iteration here if we remember the end - * up front. */ - for (u = r->units; u; u = u->next) { - /* Was ist mit Schiffen? */ - if (u->status != ST_FLEE && u->status != ST_AVOID - && !fval(u, UFL_LONGACTION | UFL_ISNEW) && u->number > 0) { - faction *f = u->faction; - fighter *c = NULL; - - for (s = b->sides; s != s_end; ++s) { - side *se; - /* Wenn alle attackierten noch FFL_NOAID haben, dann kaempfe nicht mit. */ - if (fval(s->faction, FFL_NOAID)) - continue; - if (s->faction != f) { - /* Wenn wir attackiert haben, kommt niemand mehr hinzu: */ - if (s->bf->attacker) - continue; - /* alliiert muessen wir schon sein, sonst ist's eh egal : */ - if (!alliedunit(u, s->faction, HELP_FIGHT)) - continue; - /* wenn die partei verborgen ist, oder gar eine andere - * vorgespiegelt wird, und er sich uns gegenueber nicht zu - * erkennen gibt, helfen wir ihm nicht */ - if (s->stealthfaction) { - if (!alliedside(s, u->faction, HELP_FSTEALTH)) { - continue; - } - } - } - /* einen alliierten angreifen duerfen sie nicht, es sei denn, der - * ist mit einem alliierten verfeindet, der nicht attackiert - * hat: */ - for (se = b->sides; se != s_end; ++se) { - if (u->faction == se->faction) - continue; - if (alliedunit(u, se->faction, HELP_FIGHT) && !se->bf->attacker) { - continue; - } - if (enemy(s, se)) - break; - } - if (se == s_end) - continue; - /* keine Einwaende, also soll er mitmachen: */ - if (c == NULL) { - if (!join_battle(b, u, false, &c)) { - continue; - } - } - - /* the enemy of my friend is my enemy: */ - for (se = b->sides; se != s_end; ++se) { - if (se->faction != u->faction && enemy(s, se)) { - set_enemy(se, c->side, false); - } - } - } - } - } - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - int si; - side *sa; - faction *f = s->faction; - - /* Den Feinden meiner Feinde gebe ich Deckung (gegen gemeinsame Feinde): */ - for (si = 0; s->enemies[si]; ++si) { - side *se = s->enemies[si]; - int ai; - for (ai = 0; se->enemies[ai]; ++ai) { - side *as = se->enemies[ai]; - if (as == s || !enemy(as, s)) { - set_friendly(as, s); - } - } - } - - for (sa = s + 1; sa != b->sides + b->nsides; ++sa) { - if (!enemy(s, sa) && !friendly(s, sa)) { - if (alliedfaction(f, sa->faction, HELP_FIGHT)) { - if (alliedfaction(sa->faction, f, HELP_FIGHT)) { - set_friendly(s, sa); - } - } - } - } + return !help_enter(u1, u2); } } + return false; +} - static void flee(const troop dt) - { - fighter *fig = dt.fighter; - unit *u = fig->unit; - int fchance = fleechance(u); +void force_leave(region *r, battle *b) { + unit *u; - if (fig->person[dt.index].flags & FL_PANICED) { - fchance += EFFECT_PANIC_SPELL; + for (u = r->units; u; u = u->next) { + unit *uo = NULL; + if (u->building) { + uo = building_owner(u->building); } - if (fchance > flee_chance_max_percent) { - fchance = flee_chance_max_percent; + if (u->ship && r->land) { + uo = ship_owner(u->ship); } - if (rng_int() % 100 < fchance) { - fig->run.hp += fig->person[dt.index].hp; - ++fig->run.number; - - setguard(u, false); - kill_troop(dt); - } - } - - static bool is_calmed(const unit *u, const faction *f) { - attrib *a = a_find(u->attribs, &at_curse); - - while (a && a->type == &at_curse) { - curse *c = (curse *)a->data.v; - if (c->type == &ct_calmmonster && curse_geteffect_int(c) == f->uid) { - if (curse_active(c)) { - return true; - } - } - a = a->next; - } - return false; - } - - static bool start_battle(region * r, battle ** bp) - { - battle *b = NULL; - unit *u; - bool fighting = false; - - for (u = r->units; u != NULL; u = u->next) { - if (fval(u, UFL_LONGACTION)) - continue; - if (u->number > 0) { - order *ord; - - for (ord = u->orders; ord; ord = ord->next) { - if (getkeyword(ord) == K_ATTACK) { - unit *u2; - fighter *c1, *c2; - ship *lsh = NULL; - plane *pl = rplane(r); - - if (pl && fval(pl, PFL_NOATTACK)) { - cmistake(u, ord, 271, MSG_BATTLE); - continue; - } - - if (u_race(u)->battle_flags & BF_NO_ATTACK) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_no_attack", - "race", u_race(u))); - continue; - } - /** - ** Fehlerbehandlung Angreifer - **/ - if (LongHunger(u)) { - cmistake(u, ord, 225, MSG_BATTLE); - continue; - } - - if (u->status == ST_AVOID || u->status == ST_FLEE) { - cmistake(u, ord, 226, MSG_BATTLE); - continue; - } - - /* ist ein Fluechtling aus einem andern Kampf */ - if (fval(u, UFL_LONGACTION)) - continue; - - if (curse_active(get_curse(r->attribs, &ct_peacezone))) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "peace_active", "")); - continue; - } - - if (curse_active(get_curse(u->attribs, &ct_slavery))) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "slave_active", "")); - continue; - } - - if ((u->ship != NULL && !fval(r->terrain, SEA_REGION)) - || (lsh = leftship(u)) != NULL) { - if (is_guarded(r, u)) { - if (lsh) { - cmistake(u, ord, 234, MSG_BATTLE); - } - else { - /* Fehler: "Das Schiff muss erst verlassen werden" */ - cmistake(u, ord, 19, MSG_BATTLE); - } - continue; - } - } - - /* Ende Fehlerbehandlung Angreifer */ - - init_order_depr(ord); - /* attackierte Einheit ermitteln */ - getunit(r, u->faction, &u2); - - /* Beginn Fehlerbehandlung */ - /* Fehler: "Die Einheit wurde nicht gefunden" */ - if (!u2 || u2->number == 0 || !cansee(u->faction, u->region, u2, 0)) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, - "feedback_unit_not_found", "")); - continue; - } - /* Fehler: "Die Einheit ist eine der unsrigen" */ - if (u2->faction == u->faction) { - cmistake(u, ord, 45, MSG_BATTLE); - continue; - } - /* Fehler: "Die Einheit ist mit uns alliert" */ - if (alliedunit(u, u2->faction, HELP_FIGHT)) { - cmistake(u, ord, 47, MSG_BATTLE); - continue; - } - if (IsImmune(u2->faction)) { - add_message(&u->faction->msgs, - msg_feedback(u, u->thisorder, "newbie_immunity_error", "turns", - NewbieImmunity())); - continue; - } - - /* Fehler: "Die Einheit ist mit uns alliert" */ - if (is_calmed(u, u2->faction)) { - cmistake(u, ord, 47, MSG_BATTLE); - continue; - } - /* Ende Fehlerbehandlung */ - if (b == NULL) { - unit *utmp; - for (utmp = r->units; utmp != NULL; utmp = utmp->next) { - fset(utmp->faction, FFL_NOAID); - } - b = make_battle(r); - } - join_battle(b, u, true, &c1); - join_battle(b, u2, false, &c2); - - if (u2->attribs) { - if (it_mistletoe) { - int effect = get_effect(u2, it_mistletoe); - if (effect >= u->number) { - change_effect(u2, it_mistletoe, -u2->number); - c2->run.hp = u2->hp; - c2->run.number = u2->number; - c2->side->flee += u2->number; - setguard(u2, false); - rmfighter(c2, u2->number); - } - } - } - - /* Hat die attackierte Einheit keinen Noaid-Status, - * wird das Flag von der Faction genommen, andere - * Einheiten greifen ein. */ - if (!fval(u2, UFL_NOAID)) - freset(u2->faction, FFL_NOAID); - - if (c1 && c2 && c2->run.number < c2->unit->number) { - /* Merken, wer Angreifer ist, fuer die Rueckzahlung der - * Praecombataura bei kurzem Kampf. */ - c1->side->bf->attacker = true; - - set_enemy(c1->side, c2->side, true); - fighting = true; - } - } - } - } - } - *bp = b; - return fighting; - } - - /** execute one round of attacks - * fig->fighting is used to determine who attacks, not fig->alive, since - * the latter may be influenced by attacks that already took place. - */ - static void battle_attacks(battle * b) - { - side *s; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - - if (b->turn != 0 || (b->max_tactics > 0 - && get_tactics(s, NULL) == b->max_tactics)) { - for (fig = s->fighters; fig; fig = fig->next) { - - /* ist in dieser Einheit noch jemand handlungsfaehig? */ - if (fig->fighting <= 0) - continue; - - /* Handle the unit's attack on someone */ - do_attack(fig); - } - } - } - } - - /** updates the number of attacking troops in each fighter struct. - * this has to be calculated _before_ the actual attacks take - * place because otherwise dead troops would not strike in the - * round they die. */ - static void battle_update(battle * b) - { - side *s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - for (fig = s->fighters; fig; fig = fig->next) { - fig->fighting = fig->alive - fig->removed; - } - } - } - - /** attempt to flee from battle before the next round begins - * there's a double attempt before the first round, but only - * one attempt before round zero, the potential tactics round. */ - static void battle_flee(battle * b) - { - int attempt, flee_ops = 1; - - if (b->turn == 1) - flee_ops = 2; - - for (attempt = 1; attempt <= flee_ops; ++attempt) { - side *s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - for (fig = s->fighters; fig; fig = fig->next) { - unit *u = fig->unit; - troop dt; - /* Flucht nicht bei mehr als 600 HP. Damit Wyrme toetbar bleiben. */ - int runhp = (int)(0.9 + unit_max_hp(u) * hpflee(u->status)); - if (runhp > 600) runhp = 600; - - if (u->ship && fval(u->region->terrain, SEA_REGION)) { - /* keine Flucht von Schiffen auf hoher See */ - continue; - } - if (fval(u_race(u), RCF_UNDEAD) || u_race(u) == get_race(RC_SHADOWKNIGHT)) { - /* Untote fliehen nicht. Warum eigentlich? */ - continue; - } - - dt.fighter = fig; - dt.index = fig->alive - fig->removed; - while (s->size[SUM_ROW] && dt.index != 0) { - --dt.index; - assert(dt.index >= 0 && dt.index < fig->unit->number); - assert(fig->person[dt.index].hp > 0); - - /* Versuche zu fliehen, wenn - * - Kampfstatus fliehe - * - schwer verwundet und nicht erste kampfrunde - * - in panik (Zauber) - * aber nicht, wenn der Zaubereffekt Held auf dir liegt! - */ - switch (u->status) { - case ST_FLEE: - break; - default: - if ((fig->person[dt.index].flags & FL_HIT) == 0) - continue; - if (fig->person[dt.index].hp <= runhp) - break; - if (fig->person[dt.index].flags & FL_PANICED) { - if ((fig->person[dt.index].flags & FL_COURAGE) == 0) - break; - } - continue; - } - flee(dt); - } - } - } - } - } - - 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) { - return enemy(s1, s2); - } - } - } - else { - return !help_enter(u1, u2); - } - } - return false; - } - - void force_leave(region *r, battle *b) { - unit *u; - - for (u = r->units; u; u = u->next) { - unit *uo = NULL; + if (uo && is_enemy(b, uo, u)) { + message *msg = NULL; if (u->building) { - uo = building_owner(u->building); + msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building); } - if (u->ship && r->land) { - uo = ship_owner(u->ship); + else { + msg = msg_message("force_leave_ship", "unit owner ship", u, uo, 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); + if (msg) { + ADDMSG(&u->faction->msgs, msg); } + leave(u, false); } } +} - static void do_battle(region * r) { - battle *b = NULL; - bool fighting; - ship *sh; +static void do_battle(region * r) { + battle *b = NULL; + bool fighting; + ship *sh; - fighting = start_battle(r, &b); + fighting = start_battle(r, &b); - if (b == NULL) - return; - - /* Bevor wir die alliierten hineinziehen, sollten wir schauen, * - * Ob jemand fliehen kann. Dann eruebrigt sich das ganze ja - * vielleicht schon. */ - report_battle_start(b); - if (!fighting) { - /* Niemand mehr da, Kampf kann nicht stattfinden. */ - message *m = msg_message("aborted_battle", ""); - message_all(b, m); - msg_release(m); - free_battle(b); - return; - } - join_allies(b); - make_heroes(b); - - /* make sure no ships are damaged initially */ - for (sh = r->ships; sh; sh = sh->next) - freset(sh, SF_DAMAGED); - - /* Gibt es eine Taktikrunde ? */ - if (!selist_empty(b->leaders)) { - b->turn = 0; - b->has_tactics_turn = true; - } - else { - b->turn = 1; - b->has_tactics_turn = false; - } - - /* PRECOMBATSPELLS */ - do_combatmagic(b, DO_PRECOMBATSPELL); - - print_stats(b); /* gibt die Kampfaufstellung aus */ - log_debug("battle in %s (%d, %d) : ", regionname(r, 0), r->x, r->y); - - for (; battle_report(b) && b->turn <= max_turns; ++b->turn) { - battle_flee(b); - battle_update(b); - battle_attacks(b); - - } - - /* Auswirkungen berechnen: */ - aftermath(b); - if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) { - force_leave(b->region, b); - } - /* Hier ist das Gefecht beendet, und wir koennen die - * Hilfsstrukturen * wieder loeschen: */ + if (b == NULL) + return; + /* Bevor wir die alliierten hineinziehen, sollten wir schauen, * + * Ob jemand fliehen kann. Dann eruebrigt sich das ganze ja + * vielleicht schon. */ + report_battle_start(b); + if (!fighting) { + /* Niemand mehr da, Kampf kann nicht stattfinden. */ + message *m = msg_message("aborted_battle", ""); + message_all(b, m); + msg_release(m); free_battle(b); + return; + } + join_allies(b); + make_heroes(b); + + /* make sure no ships are damaged initially */ + for (sh = r->ships; sh; sh = sh->next) + freset(sh, SF_DAMAGED); + + /* Gibt es eine Taktikrunde ? */ + if (!selist_empty(b->leaders)) { + b->turn = 0; + b->has_tactics_turn = true; + } + else { + b->turn = 1; + b->has_tactics_turn = false; } - void do_battles(void) { - region *r; - init_rules(); - for (r = regions; r; r = r->next) { - do_battle(r); - } + /* PRECOMBATSPELLS */ + do_combatmagic(b, DO_PRECOMBATSPELL); + + print_stats(b); /* gibt die Kampfaufstellung aus */ + log_debug("battle in %s (%d, %d) : ", regionname(r, 0), r->x, r->y); + + for (; battle_report(b) && b->turn <= max_turns; ++b->turn) { + battle_flee(b); + battle_update(b); + battle_attacks(b); + } + + /* Auswirkungen berechnen: */ + aftermath(b); + if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) { + force_leave(b->region, b); + } + /* Hier ist das Gefecht beendet, und wir koennen die + * Hilfsstrukturen * wieder loeschen: */ + + free_battle(b); +} + +void do_battles(void) { + region *r; + init_rules(); + for (r = regions; r; r = r->next) { + do_battle(r); + } +} From ddc8c274898e35687b7f6c2f0c5c5f2df366b7cf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Sep 2019 22:23:50 +0200 Subject: [PATCH 05/72] Bug 2605: testing horses and carts fixing indentation in battle.c --- scripts/tests/common.lua | 13 - scripts/tests/e2/{horses.lua => carts.lua} | 71 +- scripts/tests/e2/init.lua | 2 +- scripts/tests/e2/movement.lua | 60 - src/battle.c | 5500 ++++++++++---------- src/bind_faction.c | 2 +- src/move.c | 25 +- 7 files changed, 2838 insertions(+), 2835 deletions(-) rename scripts/tests/e2/{horses.lua => carts.lua} (61%) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index a2008a69c..96069d4a5 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1134,19 +1134,6 @@ function test_route_pause() assert_equal(r1, u.region) end -function test_bug_2393_cart() - local r1 = region.create(0, 0, "plain") - local r2 = region.create(1, 0, "plain") - local f = faction.create("human", "cart@example.com") - local u = unit.create(f, r1, 2) - u:add_order("NACH O") - u:add_item('stone', 2) - u:add_item('horse', 2) - u:add_item('cart', 1) - process_orders() - assert_equal(r1, u.region) -end - function test_immunity_stops_guard() eressea.settings.set("NewbieImmunity", 2) local f = faction.create('human') diff --git a/scripts/tests/e2/horses.lua b/scripts/tests/e2/carts.lua similarity index 61% rename from scripts/tests/e2/horses.lua rename to scripts/tests/e2/carts.lua index 7d7a67c66..c2acbc25e 100644 --- a/scripts/tests/e2/horses.lua +++ b/scripts/tests/e2/carts.lua @@ -1,6 +1,6 @@ require "lunit" -module("tests.e2.capacity", package.seeall, lunit.testcase) +module("tests.e2.carts", package.seeall, lunit.testcase) function setup() eressea.free_game() @@ -116,3 +116,72 @@ function test_rider_leads_horses() assert_equal(r1, u2.region) assert_equal(r1, u3.region) end + +function test_carts() + local r0 = region.create(0, 0, "plain") + local r1 = region.create(1, 0, "plain") + local r2 = region.create(2, 0, "plain") + local r3 = region.create(3, 0, "plain") + local f = faction.create("human") + -- 1. two walkers, each with two horses and a cart: + local u1 = unit.create(f, r0, 2) + u1:add_item("horse", 2) + u1:add_item("cart", 1) + u1:add_order("NACH O O O") + -- 2. two riders, each with two horses and a cart: + local u2 = unit.create(f, r0, 2) + u2:set_skill("riding", 1) + u2:add_item("horse", 4) + u2:add_item("cart", 2) + u2:add_order("NACH O O O") + -- 2. two riders, each with five horses, and max carts: + local u3 = unit.create(f, r0, 2) + u3:set_skill("riding", 1) + u3:add_item("horse", 10) + u3:add_item("cart", 5) + u3:add_order("NACH O O O") + + process_orders() + assert_equal(r1, u1.region) + assert_equal(r2, u2.region) + assert_equal(r1, u3.region) +end + +function test_walking_carts() + local r0 = region.create(0, 0, "plain") + local r1 = region.create(1, 0, "plain") + local r2 = region.create(2, 0, "plain") + local r3 = region.create(3, 0, "plain") + local f = faction.create("human") + -- 1. ten riders walk with 50 horses and 25 carts, carry 3554 GE: + local u1 = unit.create(f, r0, 10) + u1:set_skill("riding", 1) + u1:add_item("horse", 50) + u1:add_item("cart", 25) + u1:add_item("money", 355400) + u1:add_order("NACH O O O") + + process_orders() + assert_equal(r1, u1.region) +end + +function test_trolls_pull_carts() + local r0 = region.create(0, 0, "plain") + local r1 = region.create(1, 0, "plain") + local r2 = region.create(2, 0, "plain") + local r3 = region.create(3, 0, "plain") + local f = faction.create("troll") + -- 1. 20 trolls can pull 5 loaded carts: + local u1 = unit.create(f, r0, 20) + u1:add_item("cart", 5) + -- trolls carry 10.8 GE, carts carry 100 GE: + u1:add_item("money", 100 * (5 * 100 + 2 * 108)) + u1:add_order("NACH O O O") + + process_orders() + assert_equal(r1, u1.region) + + u1:add_item("money", 1) -- just one wafer thin mint + process_orders() + assert_equal(r1, u1.region) +end diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index d4fd0d4e8..28d7ebc9b 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,4 +1,4 @@ -require 'tests.e2.horses' +require 'tests.e2.carts' require 'tests.e2.quit' require 'tests.e2.movement' require 'tests.e2.astral' diff --git a/scripts/tests/e2/movement.lua b/scripts/tests/e2/movement.lua index c8fc92327..2d8d6b7a7 100644 --- a/scripts/tests/e2/movement.lua +++ b/scripts/tests/e2/movement.lua @@ -134,63 +134,3 @@ function assert_capacity(text, u, silver, r1, r2, rx) process_orders() assert_equal(rx, u.region, text .. "unit should not move") end - -function test_dwarf_example() - local r1 = region.create(0, 0, "plain") - local r2 = region.create(1, 0, "plain") - region.create(2, 0, "plain") - local f = faction.create("dwarf", "dwarf@example.com", "de") - local u = unit.create(f, r1, 5) - u:add_item("horse", 5) - u:add_item("cart", 2) - - -- 5 dwarves + 5 horse - 2 carts = 27 + 100 - 80 = 47.00 - assert_capacity("dwarves", u, 4700, r1, r2) - - u:set_skill("riding", 3) - assert_equal(1, u:eff_skill("riding")) - -- 5 dwarves + 5 horses + 2 carts = 327.00 - assert_capacity("riding", u, 32700, r1, r2) - -end - -function test_troll_example() - local r1 = region.create(0, 0, "plain") - local r2 = region.create(1, 0, "plain") - local r3 = region.create(2, 0, "plain") - local f = faction.create("troll", "troll@example.com", "de") - local u1 = unit.create(f, r1, 3) - - u1:add_item("cart", 1) - u1:clear_orders() - - -- 3 trolls - 1 cart = 320, but not allowed? - u1.name='XXX' - assert_nomove("3 trolls", u1) - - u1.number = 4 - - -- 4 trolls + 1 cart = 14320 - assert_capacity("1 cart", u1, 14320, r1, r2) - - - u1:add_item("horse", 4) - -- 4 horses, 4 trolls, 1 cart - assert_capacity("4 horses", u1, 22320, r1, r2) - - - u1:add_item("cart", 1) - - -- 4 horses + 4 trolls + 1 cart - 1 cart - assert_capacity("2 carts", u1, 18320, r1, r2) - - u1:set_skill("riding", 3) - assert_equal(1, u1:eff_skill("riding")) - - -- 4 horses + 4 trolls + 2 carts = 323.20 - assert_capacity("walking", u1, 32320, r1, r2) - - -- 4 horses + 2 carts - 4 trolls = 200.00 - assert_capacity("riding", u1, 20000, r1, r3, r2) - -end diff --git a/src/battle.c b/src/battle.c index 5384d80f5..a0e043eb9 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1171,2917 +1171,2917 @@ static void destroy_items(troop dt) { } static void calculate_defense_type(troop at, troop dt, int type, bool missile, - const weapon_type **dwtype, int *defskill) { - const weapon *weapon; - weapon = select_weapon(dt, false, true); /* missile=true to get the unmodified best weapon she has */ - *defskill = weapon_effskill(dt, at, weapon, false, false); - if (weapon != NULL) - *dwtype = weapon->type; - } + const weapon_type **dwtype, int *defskill) { + const weapon *weapon; + weapon = select_weapon(dt, false, true); /* missile=true to get the unmodified best weapon she has */ + *defskill = weapon_effskill(dt, at, weapon, false, false); + if (weapon != NULL) + *dwtype = weapon->type; +} - static void calculate_attack_type(troop at, troop dt, int type, bool missile, - const weapon_type **awtype, int *attskill, bool *magic) { - const weapon *weapon; +static void calculate_attack_type(troop at, troop dt, int type, bool missile, + const weapon_type **awtype, int *attskill, bool *magic) { + const weapon *weapon; - switch (type) { - case AT_STANDARD: - weapon = select_weapon(at, true, missile); - *attskill = weapon_effskill(at, dt, weapon, true, missile); - if (weapon) - *awtype = weapon->type; - if (*awtype && fval(*awtype, WTF_MAGICAL)) - *magic = true; - break; - case AT_NATURAL: - *attskill = weapon_effskill(at, dt, NULL, true, missile); - break; - case AT_SPELL: - case AT_COMBATSPELL: + switch (type) { + case AT_STANDARD: + weapon = select_weapon(at, true, missile); + *attskill = weapon_effskill(at, dt, weapon, true, missile); + if (weapon) + *awtype = weapon->type; + if (*awtype && fval(*awtype, WTF_MAGICAL)) *magic = true; - break; - default: - break; + break; + case AT_NATURAL: + *attskill = weapon_effskill(at, dt, NULL, true, missile); + break; + case AT_SPELL: + case AT_COMBATSPELL: + *magic = true; + break; + default: + break; + } +} + +static int crit_damage(int attskill, int defskill, const char *damage_formula) { + int damage = 0; + if (rule_damage & DAMAGE_CRITICAL) { + double kritchance = ((double)attskill * 3.0 - (double)defskill) / 200.0; + int maxk = 4; + + kritchance = fmax(kritchance, 0.005); + kritchance = fmin(0.9, kritchance); + + while (maxk-- && chance(kritchance)) { + damage += dice_rand(damage_formula); } } + return damage; +} - static int crit_damage(int attskill, int defskill, const char *damage_formula) { - int damage = 0; - if (rule_damage & DAMAGE_CRITICAL) { - double kritchance = ((double)attskill * 3.0 - (double)defskill) / 200.0; - int maxk = 4; +static int apply_race_resistance(int reduced_damage, fighter *df, + const weapon_type *awtype, bool magic) { + unit *du = df->unit; - kritchance = fmax(kritchance, 0.005); - kritchance = fmin(0.9, kritchance); + if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic) + reduced_damage = 0; + else { + unsigned int i = 0; - while (maxk-- && chance(kritchance)) { - damage += dice_rand(damage_formula); + if (u_race(du)->battle_flags & BF_RES_PIERCE) + i |= WTF_PIERCE; + if (u_race(du)->battle_flags & BF_RES_CUT) + i |= WTF_CUT; + if (u_race(du)->battle_flags & BF_RES_BASH) + i |= WTF_BLUNT; + + if (i && awtype && fval(awtype, i)) + reduced_damage /= 2; + } + return reduced_damage; +} + +static int apply_magicshield(int reduced_damage, fighter *df, + const weapon_type *awtype, battle *b, bool magic) { + side *ds = df->side; + selist *ql; + int qi; + + if (reduced_damage <= 0) + return 0; + + /* Schilde */ + for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { + meffect *me = (meffect *)selist_get(ql, qi); + if (meffect_protection(b, me, ds) != 0) { + assert(0 <= reduced_damage); /* rda sollte hier immer mindestens 0 sein */ + /* jeder Schaden wird um effect% reduziert bis der Schild duration + * Trefferpunkte aufgefangen hat */ + if (me->typ == SHIELD_REDUCE) { + int hp = reduced_damage * (me->effect / 100); + reduced_damage -= hp; + me->duration -= hp; + } + /* gibt Ruestung +effect fuer duration Treffer */ + if (me->typ == SHIELD_ARMOR) { + reduced_damage -= me->effect; + if (reduced_damage < 0) reduced_damage = 0; + me->duration--; } } - return damage; } - static int apply_race_resistance(int reduced_damage, fighter *df, - const weapon_type *awtype, bool magic) { - unit *du = df->unit; + return reduced_damage; +} - if ((u_race(du)->battle_flags & BF_INV_NONMAGIC) && !magic) - reduced_damage = 0; - else { - unsigned int i = 0; +bool +terminate(troop dt, troop at, int type, const char *damage_formula, bool missile) +{ + fighter *df = dt.fighter; + fighter *af = at.fighter; + unit *au = af->unit; + unit *du = df->unit; + battle *b = df->side->battle; - if (u_race(du)->battle_flags & BF_RES_PIERCE) - i |= WTF_PIERCE; - if (u_race(du)->battle_flags & BF_RES_CUT) - i |= WTF_CUT; - if (u_race(du)->battle_flags & BF_RES_BASH) - i |= WTF_BLUNT; + int armor_value; - if (i && awtype && fval(awtype, i)) - reduced_damage /= 2; - } - return reduced_damage; + const weapon_type *dwtype = NULL; + const weapon_type *awtype = NULL; + const armor_type *armor = NULL; + const armor_type *shield = NULL; + + int reduced_damage, attskill = 0, defskill = 0; + bool magic = false; + + int damage = dice_rand(damage_formula); + + assert(du->number > 0); + ++at.fighter->hits; + + calculate_attack_type(at, dt, type, missile, &awtype, &attskill, &magic); + calculate_defense_type(at, dt, type, missile, &dwtype, &defskill); + + if (is_riding(at) && (awtype == NULL || (fval(awtype, WTF_HORSEBONUS) + && !fval(awtype, WTF_MISSILE)))) { + damage += CavalryBonus(au, dt, BONUS_DAMAGE); } - static int apply_magicshield(int reduced_damage, fighter *df, - const weapon_type *awtype, battle *b, bool magic) { - side *ds = df->side; - selist *ql; - int qi; + armor = select_armor(dt, false); + shield = select_armor(dt, true); - if (reduced_damage <= 0) - return 0; + armor_value = calculate_armor(dt, dwtype, awtype, armor, shield, magic); + if (armor_value < 0) { + return false; + } - /* Schilde */ - for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { - meffect *me = (meffect *)selist_get(ql, qi); - if (meffect_protection(b, me, ds) != 0) { - assert(0 <= reduced_damage); /* rda sollte hier immer mindestens 0 sein */ - /* jeder Schaden wird um effect% reduziert bis der Schild duration - * Trefferpunkte aufgefangen hat */ - if (me->typ == SHIELD_REDUCE) { - int hp = reduced_damage * (me->effect / 100); - reduced_damage -= hp; - me->duration -= hp; - } - /* gibt Ruestung +effect fuer duration Treffer */ - if (me->typ == SHIELD_ARMOR) { - reduced_damage -= me->effect; - if (reduced_damage < 0) reduced_damage = 0; - me->duration--; - } + damage = apply_resistance(damage, dt, dwtype, armor, shield, magic); + + if (type != AT_COMBATSPELL && type != AT_SPELL) { + damage += crit_damage(attskill, defskill, damage_formula); + + damage += rc_specialdamage(au, du, awtype); + + if (awtype == NULL || !fval(awtype, WTF_MISSILE)) { + /* melee bonus */ + if (rule_damage & DAMAGE_MELEE_BONUS) { + damage += af->person[at.index].damage; } } - return reduced_damage; + /* Skilldifferenzbonus */ + if (rule_damage & DAMAGE_SKILL_BONUS) { + int b = (attskill - defskill) / DAMAGE_QUOTIENT; + if (b > 0) damage += b; + } } - bool - terminate(troop dt, troop at, int type, const char *damage_formula, bool missile) - { - fighter *df = dt.fighter; - fighter *af = at.fighter; - unit *au = af->unit; - unit *du = df->unit; - battle *b = df->side->battle; + reduced_damage = damage - armor_value; + if (reduced_damage < 0) reduced_damage = 0; - int armor_value; + reduced_damage = apply_race_resistance(reduced_damage, df, awtype, magic); + reduced_damage = apply_magicshield(reduced_damage, df, awtype, b, magic); - const weapon_type *dwtype = NULL; - const weapon_type *awtype = NULL; - const armor_type *armor = NULL; - const armor_type *shield = NULL; + assert(dt.index >= 0 && dt.index < du->number); + if (reduced_damage > 0) { + df->person[dt.index].hp -= reduced_damage; - int reduced_damage, attskill = 0, defskill = 0; - bool magic = false; + vampirism(at, reduced_damage); - int damage = dice_rand(damage_formula); - - assert(du->number > 0); - ++at.fighter->hits; - - calculate_attack_type(at, dt, type, missile, &awtype, &attskill, &magic); - calculate_defense_type(at, dt, type, missile, &dwtype, &defskill); - - if (is_riding(at) && (awtype == NULL || (fval(awtype, WTF_HORSEBONUS) - && !fval(awtype, WTF_MISSILE)))) { - damage += CavalryBonus(au, dt, BONUS_DAMAGE); - } - - armor = select_armor(dt, false); - shield = select_armor(dt, true); - - armor_value = calculate_armor(dt, dwtype, awtype, armor, shield, magic); - if (armor_value < 0) { - return false; - } - - damage = apply_resistance(damage, dt, dwtype, armor, shield, magic); - - if (type != AT_COMBATSPELL && type != AT_SPELL) { - damage += crit_damage(attskill, defskill, damage_formula); - - damage += rc_specialdamage(au, du, awtype); - - if (awtype == NULL || !fval(awtype, WTF_MISSILE)) { - /* melee bonus */ - if (rule_damage & DAMAGE_MELEE_BONUS) { - damage += af->person[at.index].damage; - } - } - - /* Skilldifferenzbonus */ - if (rule_damage & DAMAGE_SKILL_BONUS) { - int b = (attskill - defskill) / DAMAGE_QUOTIENT; - if (b > 0) damage += b; - } - } - - reduced_damage = damage - armor_value; - if (reduced_damage < 0) reduced_damage = 0; - - reduced_damage = apply_race_resistance(reduced_damage, df, awtype, magic); - reduced_damage = apply_magicshield(reduced_damage, df, awtype, b, magic); - - assert(dt.index >= 0 && dt.index < du->number); - if (reduced_damage > 0) { - df->person[dt.index].hp -= reduced_damage; - - vampirism(at, reduced_damage); - - ship_damage(b->turn, du); - } - - if (survives(af, dt, b)) - return false; - - ++at.fighter->kills; - - destroy_items(dt); - - kill_troop(dt); - - return true; + ship_damage(b->turn, du); } - static int - count_side(const side * s, const side * vs, int minrow, int maxrow, int select) - { - fighter *fig; - int people = 0; - int unitrow[NUMROWS]; + if (survives(af, dt, b)) + return false; - if (maxrow < FIGHT_ROW) - return 0; - if (select & SELECT_ADVANCE) { - memset(unitrow, -1, sizeof(unitrow)); - } + ++at.fighter->kills; - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->alive - fig->removed > 0) { - int row = statusrow(fig->status); - if (select & SELECT_ADVANCE) { - if (unitrow[row] == -1) { - unitrow[row] = get_unitrow(fig, vs); - } - row = unitrow[row]; - } - if (row >= minrow && row <= maxrow) { - people += fig->alive - fig->removed; - if (people > 0 && (select & SELECT_FIND)) - break; - } - } - } - return people; + destroy_items(dt); + + kill_troop(dt); + + return true; +} + +static int +count_side(const side * s, const side * vs, int minrow, int maxrow, int select) +{ + fighter *fig; + int people = 0; + int unitrow[NUMROWS]; + + if (maxrow < FIGHT_ROW) + return 0; + if (select & SELECT_ADVANCE) { + memset(unitrow, -1, sizeof(unitrow)); } - /* return the number of live allies warning: this function only considers - * troops that are still alive, not those that are still fighting although - * dead. */ - int - count_allies(const side * as, int minrow, int maxrow, int select, int allytype) - { - battle *b = as->battle; - side *ds; - int count = 0; - - for (ds = b->sides; ds != b->sides + b->nsides; ++ds) { - if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF - && as->faction == ds->faction)) { - count += count_side(ds, NULL, minrow, maxrow, select); - if (count > 0 && (select & SELECT_FIND)) + for (fig = s->fighters; fig; fig = fig->next) { + if (fig->alive - fig->removed > 0) { + int row = statusrow(fig->status); + if (select & SELECT_ADVANCE) { + if (unitrow[row] == -1) { + unitrow[row] = get_unitrow(fig, vs); + } + row = unitrow[row]; + } + if (row >= minrow && row <= maxrow) { + people += fig->alive - fig->removed; + if (people > 0 && (select & SELECT_FIND)) break; } } - return count; } + return people; +} - static int - count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow, - int select) - { - side *es, *as = af->side; - int i = 0; +/* return the number of live allies warning: this function only considers +* troops that are still alive, not those that are still fighting although +* dead. */ +int +count_allies(const side * as, int minrow, int maxrow, int select, int allytype) +{ + battle *b = as->battle; + side *ds; + int count = 0; - for (es = b->sides; es != b->sides + b->nsides; ++es) { - if (as == NULL || enemy(es, as)) { - int offset = 0; - if (select & SELECT_DISTANCE) { - offset = get_unitrow(af, es) - FIGHT_ROW; - } - i += count_side(es, as, minrow - offset, maxrow - offset, select); - if (i > 0 && (select & SELECT_FIND)) - break; + for (ds = b->sides; ds != b->sides + b->nsides; ++ds) { + if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF + && as->faction == ds->faction)) { + count += count_side(ds, NULL, minrow, maxrow, select); + if (count > 0 && (select & SELECT_FIND)) + break; + } + } + return count; +} + +static int +count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow, + int select) +{ + side *es, *as = af->side; + int i = 0; + + for (es = b->sides; es != b->sides + b->nsides; ++es) { + if (as == NULL || enemy(es, as)) { + int offset = 0; + if (select & SELECT_DISTANCE) { + offset = get_unitrow(af, es) - FIGHT_ROW; + } + i += count_side(es, as, minrow - offset, maxrow - offset, select); + if (i > 0 && (select & SELECT_FIND)) + break; + } + } + return i; +} + +int +count_enemies(battle * b, const fighter * af, int minrow, int maxrow, + int select) +{ + int sr = statusrow(af->status); + side *as = af->side; + + if (b->alive == b->fast.alive && as == b->fast.side && sr == b->fast.status + && minrow == b->fast.minrow && maxrow == b->fast.maxrow) { + if (b->fast.enemies[select] >= 0) { + return b->fast.enemies[select]; + } + else if (select & SELECT_FIND) { + if (b->fast.enemies[select - SELECT_FIND] >= 0) { + return b->fast.enemies[select - SELECT_FIND]; } } + } + else if (select != SELECT_FIND || b->alive != b->fast.alive) { + b->fast.side = as; + b->fast.status = sr; + b->fast.minrow = minrow; + b->fast.alive = b->alive; + b->fast.maxrow = maxrow; + memset(b->fast.enemies, -1, sizeof(b->fast.enemies)); + } + if (maxrow >= FIRST_ROW) { + int i = count_enemies_i(b, af, minrow, maxrow, select); + b->fast.enemies[select] = i; return i; } + return 0; +} - int - count_enemies(battle * b, const fighter * af, int minrow, int maxrow, - int select) - { - int sr = statusrow(af->status); - side *as = af->side; - - if (b->alive == b->fast.alive && as == b->fast.side && sr == b->fast.status - && minrow == b->fast.minrow && maxrow == b->fast.maxrow) { - if (b->fast.enemies[select] >= 0) { - return b->fast.enemies[select]; - } - else if (select & SELECT_FIND) { - if (b->fast.enemies[select - SELECT_FIND] >= 0) { - return b->fast.enemies[select - SELECT_FIND]; - } - } - } - else if (select != SELECT_FIND || b->alive != b->fast.alive) { - b->fast.side = as; - b->fast.status = sr; - b->fast.minrow = minrow; - b->fast.alive = b->alive; - b->fast.maxrow = maxrow; - memset(b->fast.enemies, -1, sizeof(b->fast.enemies)); - } - if (maxrow >= FIRST_ROW) { - int i = count_enemies_i(b, af, minrow, maxrow, select); - b->fast.enemies[select] = i; - return i; - } - return 0; +troop select_enemy(fighter * af, int minrow, int maxrow, int select) +{ + side *as = af->side; + battle *b = as->battle; + int si, selected; + int enemies; +#ifdef DEBUG_SELECT + troop result = no_troop; +#endif + if (u_race(af->unit)->flags & RCF_FLY) { + /* flying races ignore min- and maxrow and can attack anyone fighting + * them */ + minrow = FIGHT_ROW; + maxrow = BEHIND_ROW; } - troop select_enemy(fighter * af, int minrow, int maxrow, int select) - { - side *as = af->side; - battle *b = as->battle; - int si, selected; - int enemies; -#ifdef DEBUG_SELECT - troop result = no_troop; -#endif - if (u_race(af->unit)->flags & RCF_FLY) { - /* flying races ignore min- and maxrow and can attack anyone fighting - * them */ - minrow = FIGHT_ROW; - maxrow = BEHIND_ROW; + if (minrow < FIGHT_ROW) minrow = FIGHT_ROW; + + enemies = count_enemies(b, af, minrow, maxrow, select); + + /* Niemand ist in der angegebenen Entfernung? */ + if (enemies <= 0) + return no_troop; + + selected = (int)(rng_int() % enemies); + for (si = 0; as->enemies[si]; ++si) { + side *ds = as->enemies[si]; + fighter *df; + int unitrow[NUMROWS]; + int offset = 0; + + if (select & SELECT_DISTANCE) + offset = get_unitrow(af, ds) - FIGHT_ROW; + + if (select & SELECT_ADVANCE) { + int ui; + for (ui = 0; ui != NUMROWS; ++ui) + unitrow[ui] = -1; } - if (minrow < FIGHT_ROW) minrow = FIGHT_ROW; + for (df = ds->fighters; df; df = df->next) { + int dr; - enemies = count_enemies(b, af, minrow, maxrow, select); - - /* Niemand ist in der angegebenen Entfernung? */ - if (enemies <= 0) - return no_troop; - - selected = (int)(rng_int() % enemies); - for (si = 0; as->enemies[si]; ++si) { - side *ds = as->enemies[si]; - fighter *df; - int unitrow[NUMROWS]; - int offset = 0; + dr = statusrow(df->status); + if (select & SELECT_ADVANCE) { + if (unitrow[dr] < 0) { + unitrow[dr] = get_unitrow(df, as); + } + dr = unitrow[dr]; + } if (select & SELECT_DISTANCE) - offset = get_unitrow(af, ds) - FIGHT_ROW; - - if (select & SELECT_ADVANCE) { - int ui; - for (ui = 0; ui != NUMROWS; ++ui) - unitrow[ui] = -1; - } - - for (df = ds->fighters; df; df = df->next) { - int dr; - - dr = statusrow(df->status); - if (select & SELECT_ADVANCE) { - if (unitrow[dr] < 0) { - unitrow[dr] = get_unitrow(df, as); - } - dr = unitrow[dr]; - } - - if (select & SELECT_DISTANCE) - dr += offset; - if (dr < minrow || dr > maxrow) - continue; - if (df->alive - df->removed > selected) { + dr += offset; + if (dr < minrow || dr > maxrow) + continue; + if (df->alive - df->removed > selected) { #ifdef DEBUG_SELECT - if (result.fighter == NULL) { - result.index = selected; - result.fighter = df; - } -#else - troop dt; - dt.index = selected; - dt.fighter = df; - return dt; -#endif + if (result.fighter == NULL) { + result.index = selected; + result.fighter = df; } - selected -= (df->alive - df->removed); - enemies -= (df->alive - df->removed); +#else + troop dt; + dt.index = selected; + dt.fighter = df; + return dt; +#endif } + selected -= (df->alive - df->removed); + enemies -= (df->alive - df->removed); } - if (enemies != 0) { - log_error("select_enemies has a bug.\n"); - } + } + if (enemies != 0) { + log_error("select_enemies has a bug.\n"); + } #ifdef DEBUG_SELECT - return result; + return result; #else - assert(!selected); - return no_troop; + assert(!selected); + return no_troop; #endif - } +} - static int get_tactics(const side * as, const side * ds) - { - battle *b = as->battle; - side *stac; - int result = 0; - int defense = 0; +static int get_tactics(const side * as, const side * ds) +{ + battle *b = as->battle; + side *stac; + int result = 0; + int defense = 0; - if (b->max_tactics > 0) { - for (stac = b->sides; stac != b->sides + b->nsides; ++stac) { - if (stac->leader.value > result && helping(stac, as)) { - assert(ds == NULL || !helping(stac, ds)); - result = stac->leader.value; - } - if (ds && stac->leader.value > defense && helping(stac, ds)) { - assert(!helping(stac, as)); - defense = stac->leader.value; - } + if (b->max_tactics > 0) { + for (stac = b->sides; stac != b->sides + b->nsides; ++stac) { + if (stac->leader.value > result && helping(stac, as)) { + assert(ds == NULL || !helping(stac, ds)); + result = stac->leader.value; + } + if (ds && stac->leader.value > defense && helping(stac, ds)) { + assert(!helping(stac, as)); + defense = stac->leader.value; } } - return result - defense; + } + return result - defense; +} + +double tactics_chance(const unit *u, int skilldiff) { + double tacch = 0.1 * skilldiff; + if (fval(u->region->terrain, SEA_REGION)) { + const ship *sh = u->ship; + if (sh) { + tacch *= sh->type->tac_bonus; + } + } + return tacch; +} + +static troop select_opponent(battle * b, troop at, int mindist, int maxdist) +{ + fighter *af = at.fighter; + troop dt; + + if (u_race(af->unit)->flags & RCF_FLY) { + /* flying races ignore min- and maxrow and can attack anyone fighting + * them */ + dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); + } + else { + if (mindist < FIGHT_ROW) mindist = FIGHT_ROW; + dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE); } - double tactics_chance(const unit *u, int skilldiff) { - double tacch = 0.1 * skilldiff; - if (fval(u->region->terrain, SEA_REGION)) { - const ship *sh = u->ship; - if (sh) { - tacch *= sh->type->tac_bonus; - } - } - return tacch; - } + if (b->turn == 0 && dt.fighter) { + if (rule_tactics_formula == 1) { + int tactics = get_tactics(at.fighter->side, dt.fighter->side); - static troop select_opponent(battle * b, troop at, int mindist, int maxdist) - { - fighter *af = at.fighter; - troop dt; - - if (u_race(af->unit)->flags & RCF_FLY) { - /* flying races ignore min- and maxrow and can attack anyone fighting - * them */ - dt = select_enemy(at.fighter, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE); - } - else { - if (mindist < FIGHT_ROW) mindist = FIGHT_ROW; - dt = select_enemy(at.fighter, mindist, maxdist, SELECT_ADVANCE); - } - - if (b->turn == 0 && dt.fighter) { - if (rule_tactics_formula == 1) { - int tactics = get_tactics(at.fighter->side, dt.fighter->side); - - /* percentage chance to get this attack */ - if (tactics > 0) { - double tacch = tactics_chance(af->unit, tactics); - if (!chance(tacch)) { - dt.fighter = NULL; - } - } - else { + /* percentage chance to get this attack */ + if (tactics > 0) { + double tacch = tactics_chance(af->unit, tactics); + if (!chance(tacch)) { dt.fighter = NULL; } } - } - - return dt; - } - - selist *select_fighters(battle * b, const side * vs, int mask, select_fun cb, void *cbdata) - { - side *s; - selist *fightervp = 0; - - assert(vs != NULL); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - - if (mask == FS_ENEMY) { - if (!enemy(s, vs)) - continue; - } - else if (mask == FS_HELP) { - if (enemy(s, vs) || !alliedside(s, vs->faction, HELP_FIGHT)) { - continue; - } - } else { - assert(mask == (FS_HELP | FS_ENEMY) || !"invalid alliance state"); - } - for (fig = s->fighters; fig; fig = fig->next) { - if (cb(vs, fig, cbdata)) { - selist_push(&fightervp, fig); - } - } - } - - return fightervp; - } - - struct selector { - int minrow; - int maxrow; - }; - - static bool select_row(const side *vs, const fighter *fig, void *cbdata) - { - struct selector *sel = (struct selector *)cbdata; - int row = get_unitrow(fig, vs); - return (row >= sel->minrow && row <= sel->maxrow); - } - - selist *fighters(battle * b, const side * vs, int minrow, int maxrow, int mask) - { - struct selector sel; - sel.maxrow = maxrow; - sel.minrow = minrow; - return select_fighters(b, vs, mask, select_row, &sel); - } - - static void report_failed_spell(struct battle * b, struct unit * mage, const struct spell *sp) - { - message *m = msg_message("spell_failed", "unit spell", mage, sp); - message_all(b, m); - msg_release(m); - } - - static castorder * create_castorder_combat(castorder *co, fighter *fig, const spell * sp, int level, double force) { - co = create_castorder(co, fig->unit, 0, sp, fig->unit->region, level, force, 0, 0, 0); - co->magician.fig = fig; - return co; - } - - static void summon_igjarjuk(battle *b, spellrank spellranks[]) { - side *s; - castorder *co; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig = 0; - if (s->bf->attacker && fval(s->faction, FFL_CURSED)) { - spell *sp = find_spell("igjarjuk"); - if (sp) { - int si; - for (si = 0; s->enemies[si]; ++si) { - side *se = s->enemies[si]; - if (se && !fval(se->faction, FFL_NPC)) { - fighter *fi; - for (fi = se->fighters; fi; fi = fi->next) { - if (fi && (!fig || fig->unit->number > fi->unit->number)) { - fig = fi; - if (fig->unit->number == 1) { - break; - } - } - } - if (fig && fig->unit->number == 1) { - break; - } - } - } - if (fig) { - co = create_castorder_combat(0, fig, sp, 10, 10); - co->magician.fig = fig; - add_castorder(&spellranks[sp->rank], co); - break; - } - } + dt.fighter = NULL; } } } - void do_combatmagic(battle * b, combatmagic_t was) - { - side *s; - castorder *co; - region *r = b->region; - int level, rank, sl; - spellrank spellranks[MAX_SPELLRANK]; + return dt; +} - memset(spellranks, 0, sizeof(spellranks)); +selist *select_fighters(battle * b, const side * vs, int mask, select_fun cb, void *cbdata) +{ + side *s; + selist *fightervp = 0; - if (rule_igjarjuk_curse && was == DO_PRECOMBATSPELL) { - summon_igjarjuk(b, spellranks); + assert(vs != NULL); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + + if (mask == FS_ENEMY) { + if (!enemy(s, vs)) + continue; } - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - for (fig = s->fighters; fig; fig = fig->next) { - unit *mage = fig->unit; - unit *caster = mage; - - if (fig->alive <= 0) - continue; /* fighter kann im Kampf getoetet worden sein */ - - level = effskill(mage, SK_MAGIC, r); - if (level > 0) { - double power; - const spell *sp; - const struct locale *lang = mage->faction->locale; - order *ord; - - switch (was) { - case DO_PRECOMBATSPELL: - sp = get_combatspell(mage, 0); - sl = get_combatspelllevel(mage, 0); - break; - case DO_POSTCOMBATSPELL: - sp = get_combatspell(mage, 2); - sl = get_combatspelllevel(mage, 2); - break; - default: - /* Fehler! */ - return; - } - if (sp == NULL) - continue; - - ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); - if (!cancast(mage, sp, 1, 1, ord)) { - free_order(ord); - continue; - } - - level = eff_spelllevel(mage, caster, sp, level, 1); - if (sl > 0 && sl < level) { - level = sl; - } - if (level < 0) { - report_failed_spell(b, mage, sp); - free_order(ord); - continue; - } - - power = spellpower(r, mage, sp, level, ord); - free_order(ord); - if (power <= 0) { /* Effekt von Antimagie */ - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - } - else if (fumble(r, mage, sp, level)) { - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - } - else { - co = create_castorder_combat(0, fig, sp, level, power); - add_castorder(&spellranks[sp->rank], co); - } - } + else if (mask == FS_HELP) { + if (enemy(s, vs) || !alliedside(s, vs->faction, HELP_FIGHT)) { + continue; } } - for (rank = 0; rank < MAX_SPELLRANK; rank++) { - for (co = spellranks[rank].begin; co; co = co->next) { - fighter *fig = co->magician.fig; - const spell *sp = co->sp; - - level = cast_spell(co); - if (level > 0) { - pay_spell(fig->unit, NULL, sp, level, 1); - } - } - } - for (rank = 0; rank < MAX_SPELLRANK; rank++) { - free_castorders(spellranks[rank].begin); - } - } - - static int cast_combatspell(troop at, const spell * sp, int level, double force) - { - castorder co; - - create_castorder_combat(&co, at.fighter, sp, level, force); - level = cast_spell(&co); - free_castorder(&co); - if (level > 0) { - pay_spell(at.fighter->unit, NULL, sp, level, 1); - } - return level; - } - - static void do_combatspell(troop at) - { - const spell *sp; - fighter *fi = at.fighter; - unit *mage = fi->unit; - battle *b = fi->side->battle; - region *r = b->region; - selist *ql; - int level, qi; - double power; - int fumblechance = 0; - order *ord; - int sl; - const struct locale *lang = mage->faction->locale; - - sp = get_combatspell(mage, 1); - if (sp == NULL) { - fi->magic = 0; /* Hat keinen Kampfzauber, kaempft nichtmagisch weiter */ - return; - } - ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); - if (!cancast(mage, sp, 1, 1, ord)) { - fi->magic = 0; /* Kann nicht mehr Zaubern, kaempft nichtmagisch weiter */ - return; - } - - level = eff_spelllevel(mage, mage, sp, fi->magic, 1); - sl = get_combatspelllevel(mage, 1); - if (sl > 0 && sl < level) { - level = sl; - } - - if (fumble(r, mage, sp, level)) { - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - return; - } - - for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { - meffect *mblock = (meffect *)selist_get(ql, qi); - if (mblock->typ == SHIELD_BLOCK) { - if (meffect_blocked(b, mblock, fi->side) != 0) { - fumblechance += mblock->duration; - mblock->duration -= mblock->effect; - } - } - } - - /* Antimagie die Fehlschlag erhoeht */ - if (rng_int() % 100 < fumblechance) { - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - free_order(ord); - return; - } - power = spellpower(r, mage, sp, level, ord); - free_order(ord); - if (power <= 0) { /* Effekt von Antimagie */ - report_failed_spell(b, mage, sp); - pay_spell(mage, NULL, sp, level, 1); - return; - } - - level = cast_combatspell(at, sp, level, power); - } - - /* Sonderattacken: Monster patzern nicht und zahlen auch keine - * Spruchkosten. Da die Spruchstaerke direkt durch den Level bestimmt - * wird, wirkt auch keine Antimagie (wird sonst in spellpower - * gemacht) */ - - static void do_extra_spell(troop at, const att * a) - { - const spell *sp = spellref_get(a->data.sp); - - if (!sp) { - log_error("no such spell: '%s'", a->data.sp->_name); - } else { - assert(a->level > 0); - cast_combatspell(at, sp, a->level, a->level); + assert(mask == (FS_HELP | FS_ENEMY) || !"invalid alliance state"); + } + for (fig = s->fighters; fig; fig = fig->next) { + if (cb(vs, fig, cbdata)) { + selist_push(&fightervp, fig); + } } } - int skilldiff(troop at, troop dt, int dist) - { - fighter *af = at.fighter, *df = dt.fighter; - unit *au = af->unit, *du = df->unit; - int is_protected = 0, skdiff = 0; - weapon *awp = select_weapon(at, true, dist > 1); - static int rc_cache; - static const race *rc_halfling, *rc_goblin; + return fightervp; +} - if (rc_changed(&rc_cache)) { - rc_halfling = get_race(RC_HALFLING); - rc_goblin = get_race(RC_GOBLIN); - } - skdiff += af->person[at.index].attack; - skdiff -= df->person[dt.index].defense; +struct selector { + int minrow; + int maxrow; +}; - if (df->person[dt.index].flags & FL_SLEEPING) - skdiff += 2; +static bool select_row(const side *vs, const fighter *fig, void *cbdata) +{ + struct selector *sel = (struct selector *)cbdata; + int row = get_unitrow(fig, vs); + return (row >= sel->minrow && row <= sel->maxrow); +} - /* Effekte durch Rassen */ - if (awp != NULL && u_race(au) == rc_halfling && dragonrace(u_race(du))) { - skdiff += 5; - } - else if (u_race(au) == rc_goblin) { - if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) { - skdiff += 1; - } - } +selist *fighters(battle * b, const side * vs, int minrow, int maxrow, int mask) +{ + struct selector sel; + sel.maxrow = maxrow; + sel.minrow = minrow; + return select_fighters(b, vs, mask, select_row, &sel); +} - if (df->building) { - building *b = df->building; - if (b->attribs) { - curse *c = get_curse(b->attribs, &ct_strongwall); - if (curse_active(c)) { - /* wirkt auf alle Gebaeude */ - skdiff -= curse_geteffect_int(c); - is_protected = 2; - } - } - if (b->type->flags & BTF_FORTIFICATION) { - int stage = buildingeffsize(b, false); - int beff = building_protection(b->type, stage); - if (beff > 0) { - skdiff -= beff; - is_protected = 2; - if (b->attribs) { - if (curse_active(get_curse(b->attribs, &ct_magicwalls))) { - /* Verdoppelt Burgenbonus */ - skdiff -= beff; +static void report_failed_spell(struct battle * b, struct unit * mage, const struct spell *sp) +{ + message *m = msg_message("spell_failed", "unit spell", mage, sp); + message_all(b, m); + msg_release(m); +} + +static castorder * create_castorder_combat(castorder *co, fighter *fig, const spell * sp, int level, double force) { + co = create_castorder(co, fig->unit, 0, sp, fig->unit->region, level, force, 0, 0, 0); + co->magician.fig = fig; + return co; +} + +static void summon_igjarjuk(battle *b, spellrank spellranks[]) { + side *s; + castorder *co; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig = 0; + if (s->bf->attacker && fval(s->faction, FFL_CURSED)) { + spell *sp = find_spell("igjarjuk"); + if (sp) { + int si; + for (si = 0; s->enemies[si]; ++si) { + side *se = s->enemies[si]; + if (se && !fval(se->faction, FFL_NPC)) { + fighter *fi; + for (fi = se->fighters; fi; fi = fi->next) { + if (fi && (!fig || fig->unit->number > fi->unit->number)) { + fig = fi; + if (fig->unit->number == 1) { + break; + } + } + } + if (fig && fig->unit->number == 1) { + break; } } } + if (fig) { + co = create_castorder_combat(0, fig, sp, 10, 10); + co->magician.fig = fig; + add_castorder(&spellranks[sp->rank], co); + break; + } } } - /* Effekte der Waffen */ - skdiff += weapon_effskill(at, dt, awp, true, dist > 1); - if (awp && fval(awp->type, WTF_MISSILE)) { - skdiff -= is_protected; - if (awp->type->modifiers) { - int w; - for (w = 0; awp->type->modifiers[w].value != 0; ++w) { - if (awp->type->modifiers[w].flags & WMF_MISSILE_TARGET) { - /* skill decreases by targeting difficulty (bow -2, catapult -4) */ - skdiff -= awp->type->modifiers[w].value; - break; + } +} + +void do_combatmagic(battle * b, combatmagic_t was) +{ + side *s; + castorder *co; + region *r = b->region; + int level, rank, sl; + spellrank spellranks[MAX_SPELLRANK]; + + memset(spellranks, 0, sizeof(spellranks)); + + if (rule_igjarjuk_curse && was == DO_PRECOMBATSPELL) { + summon_igjarjuk(b, spellranks); + } + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + for (fig = s->fighters; fig; fig = fig->next) { + unit *mage = fig->unit; + unit *caster = mage; + + if (fig->alive <= 0) + continue; /* fighter kann im Kampf getoetet worden sein */ + + level = effskill(mage, SK_MAGIC, r); + if (level > 0) { + double power; + const spell *sp; + const struct locale *lang = mage->faction->locale; + order *ord; + + switch (was) { + case DO_PRECOMBATSPELL: + sp = get_combatspell(mage, 0); + sl = get_combatspelllevel(mage, 0); + break; + case DO_POSTCOMBATSPELL: + sp = get_combatspell(mage, 2); + sl = get_combatspelllevel(mage, 2); + break; + default: + /* Fehler! */ + return; + } + if (sp == NULL) + continue; + + ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); + if (!cancast(mage, sp, 1, 1, ord)) { + free_order(ord); + continue; + } + + level = eff_spelllevel(mage, caster, sp, level, 1); + if (sl > 0 && sl < level) { + level = sl; + } + if (level < 0) { + report_failed_spell(b, mage, sp); + free_order(ord); + continue; + } + + power = spellpower(r, mage, sp, level, ord); + free_order(ord); + if (power <= 0) { /* Effekt von Antimagie */ + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + } + else if (fumble(r, mage, sp, level)) { + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + } + else { + co = create_castorder_combat(0, fig, sp, level, power); + add_castorder(&spellranks[sp->rank], co); + } + } + } + } + for (rank = 0; rank < MAX_SPELLRANK; rank++) { + for (co = spellranks[rank].begin; co; co = co->next) { + fighter *fig = co->magician.fig; + const spell *sp = co->sp; + + level = cast_spell(co); + if (level > 0) { + pay_spell(fig->unit, NULL, sp, level, 1); + } + } + } + for (rank = 0; rank < MAX_SPELLRANK; rank++) { + free_castorders(spellranks[rank].begin); + } +} + +static int cast_combatspell(troop at, const spell * sp, int level, double force) +{ + castorder co; + + create_castorder_combat(&co, at.fighter, sp, level, force); + level = cast_spell(&co); + free_castorder(&co); + if (level > 0) { + pay_spell(at.fighter->unit, NULL, sp, level, 1); + } + return level; +} + +static void do_combatspell(troop at) +{ + const spell *sp; + fighter *fi = at.fighter; + unit *mage = fi->unit; + battle *b = fi->side->battle; + region *r = b->region; + selist *ql; + int level, qi; + double power; + int fumblechance = 0; + order *ord; + int sl; + const struct locale *lang = mage->faction->locale; + + sp = get_combatspell(mage, 1); + if (sp == NULL) { + fi->magic = 0; /* Hat keinen Kampfzauber, kaempft nichtmagisch weiter */ + return; + } + ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); + if (!cancast(mage, sp, 1, 1, ord)) { + fi->magic = 0; /* Kann nicht mehr Zaubern, kaempft nichtmagisch weiter */ + return; + } + + level = eff_spelllevel(mage, mage, sp, fi->magic, 1); + sl = get_combatspelllevel(mage, 1); + if (sl > 0 && sl < level) { + level = sl; + } + + if (fumble(r, mage, sp, level)) { + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + return; + } + + for (qi = 0, ql = b->meffects; ql; selist_advance(&ql, &qi, 1)) { + meffect *mblock = (meffect *)selist_get(ql, qi); + if (mblock->typ == SHIELD_BLOCK) { + if (meffect_blocked(b, mblock, fi->side) != 0) { + fumblechance += mblock->duration; + mblock->duration -= mblock->effect; + } + } + } + + /* Antimagie die Fehlschlag erhoeht */ + if (rng_int() % 100 < fumblechance) { + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + free_order(ord); + return; + } + power = spellpower(r, mage, sp, level, ord); + free_order(ord); + if (power <= 0) { /* Effekt von Antimagie */ + report_failed_spell(b, mage, sp); + pay_spell(mage, NULL, sp, level, 1); + return; + } + + level = cast_combatspell(at, sp, level, power); +} + +/* Sonderattacken: Monster patzern nicht und zahlen auch keine + * Spruchkosten. Da die Spruchstaerke direkt durch den Level bestimmt + * wird, wirkt auch keine Antimagie (wird sonst in spellpower + * gemacht) */ + +static void do_extra_spell(troop at, const att * a) +{ + const spell *sp = spellref_get(a->data.sp); + + if (!sp) { + log_error("no such spell: '%s'", a->data.sp->_name); + } + else { + assert(a->level > 0); + cast_combatspell(at, sp, a->level, a->level); + } +} + +int skilldiff(troop at, troop dt, int dist) +{ + fighter *af = at.fighter, *df = dt.fighter; + unit *au = af->unit, *du = df->unit; + int is_protected = 0, skdiff = 0; + weapon *awp = select_weapon(at, true, dist > 1); + static int rc_cache; + static const race *rc_halfling, *rc_goblin; + + if (rc_changed(&rc_cache)) { + rc_halfling = get_race(RC_HALFLING); + rc_goblin = get_race(RC_GOBLIN); + } + skdiff += af->person[at.index].attack; + skdiff -= df->person[dt.index].defense; + + if (df->person[dt.index].flags & FL_SLEEPING) + skdiff += 2; + + /* Effekte durch Rassen */ + if (awp != NULL && u_race(au) == rc_halfling && dragonrace(u_race(du))) { + skdiff += 5; + } + else if (u_race(au) == rc_goblin) { + if (af->side->size[SUM_ROW] >= df->side->size[SUM_ROW] * rule_goblin_bonus) { + skdiff += 1; + } + } + + if (df->building) { + building *b = df->building; + if (b->attribs) { + curse *c = get_curse(b->attribs, &ct_strongwall); + if (curse_active(c)) { + /* wirkt auf alle Gebaeude */ + skdiff -= curse_geteffect_int(c); + is_protected = 2; + } + } + if (b->type->flags & BTF_FORTIFICATION) { + int stage = buildingeffsize(b, false); + int beff = building_protection(b->type, stage); + if (beff > 0) { + skdiff -= beff; + is_protected = 2; + if (b->attribs) { + if (curse_active(get_curse(b->attribs, &ct_magicwalls))) { + /* Verdoppelt Burgenbonus */ + skdiff -= beff; } } } } - if (skill_formula == FORMULA_ORIG) { - weapon *dwp = select_weapon(dt, false, dist > 1); - skdiff -= weapon_effskill(dt, at, dwp, false, dist > 1); + } + /* Effekte der Waffen */ + skdiff += weapon_effskill(at, dt, awp, true, dist > 1); + if (awp && fval(awp->type, WTF_MISSILE)) { + skdiff -= is_protected; + if (awp->type->modifiers) { + int w; + for (w = 0; awp->type->modifiers[w].value != 0; ++w) { + if (awp->type->modifiers[w].flags & WMF_MISSILE_TARGET) { + /* skill decreases by targeting difficulty (bow -2, catapult -4) */ + skdiff -= awp->type->modifiers[w].value; + break; + } + } } - return skdiff; } - - static int setreload(troop at) - { - fighter *af = at.fighter; - const weapon_type *wtype = af->person[at.index].missile->type; - if (wtype->reload == 0) - return 0; - return af->person[at.index].reload = wtype->reload; - } - - int getreload(troop at) - { - return at.fighter->person[at.index].reload; - } - - int hits(troop at, troop dt, weapon * awp) - { - fighter *af = at.fighter, *df = dt.fighter; - const armor_type *armor, *shield = 0; - int skdiff = 0; - int dist = get_unitrow(af, df->side) + get_unitrow(df, af->side) - 1; + if (skill_formula == FORMULA_ORIG) { weapon *dwp = select_weapon(dt, false, dist > 1); + skdiff -= weapon_effskill(dt, at, dwp, false, dist > 1); + } + return skdiff; +} - if (!df->alive) - return 0; - if (getreload(at)) - return 0; - if (dist > 1 && (awp == NULL || !fval(awp->type, WTF_MISSILE))) - return 0; +static int setreload(troop at) +{ + fighter *af = at.fighter; + const weapon_type *wtype = af->person[at.index].missile->type; + if (wtype->reload == 0) + return 0; + return af->person[at.index].reload = wtype->reload; +} - /* mark this person as hit. */ - df->person[dt.index].flags |= FL_HIT; +int getreload(troop at) +{ + return at.fighter->person[at.index].reload; +} - if (af->person[at.index].flags & FL_STUNNED) { - af->person[at.index].flags &= ~FL_STUNNED; - return 0; - } - if ((af->person[at.index].flags & FL_TIRED && rng_int() % 100 < 50) - || (af->person[at.index].flags & FL_SLEEPING)) - return 0; +int hits(troop at, troop dt, weapon * awp) +{ + fighter *af = at.fighter, *df = dt.fighter; + const armor_type *armor, *shield = 0; + int skdiff = 0; + int dist = get_unitrow(af, df->side) + get_unitrow(df, af->side) - 1; + weapon *dwp = select_weapon(dt, false, dist > 1); - /* effect of sp_reeling_arrows combatspell */ - if (af->side->battle->reelarrow && awp && fval(awp->type, WTF_MISSILE) - && rng_double() < 0.5) { - return 0; - } + if (!df->alive) + return 0; + if (getreload(at)) + return 0; + if (dist > 1 && (awp == NULL || !fval(awp->type, WTF_MISSILE))) + return 0; - skdiff = skilldiff(at, dt, dist); - /* Verteidiger bekommt eine Ruestung */ - armor = select_armor(dt, true); - if (dwp == NULL || (dwp->type->flags & WTF_USESHIELD)) { - shield = select_armor(dt, false); - } - if (contest(skdiff, dt, armor, shield)) { - return 1; - } + /* mark this person as hit. */ + df->person[dt.index].flags |= FL_HIT; + + if (af->person[at.index].flags & FL_STUNNED) { + af->person[at.index].flags &= ~FL_STUNNED; + return 0; + } + if ((af->person[at.index].flags & FL_TIRED && rng_int() % 100 < 50) + || (af->person[at.index].flags & FL_SLEEPING)) + return 0; + + /* effect of sp_reeling_arrows combatspell */ + if (af->side->battle->reelarrow && awp && fval(awp->type, WTF_MISSILE) + && rng_double() < 0.5) { return 0; } - void dazzle(battle * b, troop * td) - { - UNUSED_ARG(b); - /* Nicht kumulativ ! */ - if (td->fighter->person[td->index].flags & (FL_COURAGE | FL_DAZZLED)) { - return; - } + skdiff = skilldiff(at, dt, dist); + /* Verteidiger bekommt eine Ruestung */ + armor = select_armor(dt, true); + if (dwp == NULL || (dwp->type->flags & WTF_USESHIELD)) { + shield = select_armor(dt, false); + } + if (contest(skdiff, dt, armor, shield)) { + return 1; + } + return 0; +} - td->fighter->person[td->index].flags |= FL_DAZZLED; - td->fighter->person[td->index].defense--; +void dazzle(battle * b, troop * td) +{ + UNUSED_ARG(b); + /* Nicht kumulativ ! */ + if (td->fighter->person[td->index].flags & (FL_COURAGE | FL_DAZZLED)) { + return; } - void damage_building(battle * b, building * bldg, int damage_abs) - { - assert(bldg); - bldg->size -= damage_abs; - if (bldg->size < 1) bldg->size = 1; + td->fighter->person[td->index].flags |= FL_DAZZLED; + td->fighter->person[td->index].defense--; +} - /* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebaeude passen. */ +void damage_building(battle * b, building * bldg, int damage_abs) +{ + assert(bldg); + bldg->size -= damage_abs; + if (bldg->size < 1) bldg->size = 1; - if (bldg->type->flags & BTF_FORTIFICATION) { - side *s; + /* Wenn Burg, dann gucken, ob die Leute alle noch in das Gebaeude passen. */ - bldg->sizeleft = bldg->size; + if (bldg->type->flags & BTF_FORTIFICATION) { + side *s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->building == bldg) { - if (bldg->sizeleft >= fig->unit->number) { - fig->building = bldg; - bldg->sizeleft -= fig->unit->number; + bldg->sizeleft = bldg->size; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + for (fig = s->fighters; fig; fig = fig->next) { + if (fig->building == bldg) { + if (bldg->sizeleft >= fig->unit->number) { + fig->building = bldg; + bldg->sizeleft -= fig->unit->number; + } + else { + fig->building = NULL; + } + } + } + } + } +} + +static int attacks_per_round(troop t) +{ + return t.fighter->person[t.index].speed; +} + +static void make_heroes(battle * b) +{ + side *s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + for (fig = s->fighters; fig; fig = fig->next) { + unit *u = fig->unit; + if (fval(u, UFL_HERO)) { + int i; + if (!playerrace(u_race(u))) { + log_error("Hero %s is a %s.\n", unitname(u), u_race(u)->_name); + } + for (i = 0; i != u->number; ++i) { + fig->person[i].speed += (rule_hero_speed - 1); + } + } + } + } +} + +static void attack(battle * b, troop ta, const att * a, int numattack) +{ + fighter *af = ta.fighter; + troop td; + unit *au = af->unit; + + switch (a->type) { + case AT_COMBATSPELL: + /* Magier versuchen immer erstmal zu zaubern, erst wenn das + * fehlschlaegt, wird af->magic == 0 und der Magier kaempft + * konventionell weiter */ + if (numattack == 0 && af->magic > 0) { + /* wenn der magier in die potenzielle Reichweite von Attacken des + * Feindes kommt, beginnt er auch bei einem Status von KAEMPFE NICHT, + * Kampfzauber zu schleudern: */ + if (count_enemies(b, af, melee_range[0], missile_range[1], + SELECT_ADVANCE | SELECT_DISTANCE | SELECT_FIND)) { + do_combatspell(ta); + } + } + break; + case AT_STANDARD: /* Waffen, mag. Gegenstaende, Kampfzauber */ + if (numattack > 0 || af->magic <= 0) { + weapon *wp = ta.fighter->person[ta.index].missile; + int melee = + count_enemies(b, af, melee_range[0], melee_range[1], + SELECT_ADVANCE | SELECT_DISTANCE | SELECT_FIND); + if (melee) + wp = preferred_weapon(ta, true); + /* Sonderbehandlungen */ + + if (getreload(ta)) { + ta.fighter->person[ta.index].reload--; + } + else { + bool standard_attack = true; + bool reload = false; + /* spezialattacken der waffe nur, wenn erste attacke in der runde. + * sonst helden mit feuerschwertern zu maechtig */ + if (numattack == 0 && wp && wp->type->attack) { + int dead = 0; + standard_attack = wp->type->attack(&ta, wp->type, &dead); + if (!standard_attack) + reload = true; + af->catmsg += dead; + if (!standard_attack && af->person[ta.index].last_action < b->turn) { + af->person[ta.index].last_action = b->turn; + } + } + if (standard_attack) { + bool missile = false; + if (wp && fval(wp->type, WTF_MISSILE)) + missile = true; + if (missile) { + td = select_opponent(b, ta, missile_range[0], missile_range[1]); + } + else { + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + } + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + reload = true; + if (hits(ta, td, wp)) { + const char *d; + if (wp == NULL) + d = u_race(au)->def_damage; + else if (is_riding(ta)) + d = wp->type->damage[1]; + else + d = wp->type->damage[0]; + terminate(td, ta, a->type, d, missile); + } + } + if (reload && wp && wp->type->reload && !getreload(ta)) { + setreload(ta); + } + } + } + break; + case AT_SPELL: /* Extra-Sprueche. Kampfzauber in AT_COMBATSPELL! */ + do_extra_spell(ta, a); + break; + case AT_NATURAL: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (hits(ta, td, NULL)) { + terminate(td, ta, a->type, a->data.dice, false); + } + break; + case AT_DRAIN_ST: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (hits(ta, td, NULL)) { + int c = dice_rand(a->data.dice); + while (c > 0) { + if (rng_int() % 2) { + td.fighter->person[td.index].attack -= 1; + } + else { + td.fighter->person[td.index].defense -= 1; + } + c--; + } + } + break; + case AT_DRAIN_EXP: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (hits(ta, td, NULL)) { + drain_exp(td.fighter->unit, dice_rand(a->data.dice)); + } + break; + case AT_DAZZLE: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (hits(ta, td, NULL)) { + dazzle(b, &td); + } + break; + case AT_STRUCTURAL: + td = select_opponent(b, ta, melee_range[0], melee_range[1]); + if (!td.fighter) + return; + if (ta.fighter->person[ta.index].last_action < b->turn) { + ta.fighter->person[ta.index].last_action = b->turn; + } + if (td.fighter->unit->ship) { + int dice = dice_rand(a->data.dice); + ship * sh = td.fighter->unit->ship; + damage_ship(sh, dice / sh->type->damage / sh->size); + } + else if (td.fighter->unit->building) { + damage_building(b, td.fighter->unit->building, dice_rand(a->data.dice)); + } + } +} + +void do_attack(fighter * af) +{ + troop ta; + unit *au = af->unit; + side *side = af->side; + battle *b = side->battle; + + ta.fighter = af; + + assert(au && au->number); + /* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen + * Kaempfern beruht, darf die Reihenfolge und Groesse der Einheit keine + * Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der + * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zufaellig + * mit einer grossen Einheit zuerst drankommt, extrem bevorteilt. */ + ta.index = af->fighting; + + while (ta.index--) { + /* Wir suchen eine beliebige Feind-Einheit aus. An der koennen + * wir feststellen, ob noch jemand da ist. */ + int apr, attacks = attacks_per_round(ta); + if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND)) + break; + + for (apr = 0; apr != attacks; ++apr) { + int a; + for (a = 0; a < RACE_ATTACKS && u_race(au)->attack[a].type != AT_NONE; ++a) { + if (apr > 0) { + /* Wenn die Waffe nachladen muss, oder es sich nicht um einen + * Waffen-Angriff handelt, dann gilt der Speed nicht. */ + /* TODO: allow multiple AT_NATURAL attacks? */ + if (u_race(au)->attack[a].type != AT_STANDARD) + continue; + else { + weapon *wp = preferred_weapon(ta, true); + if (wp != NULL && wp->type->reload) + continue; + } + } + attack(b, ta, &(u_race(au)->attack[a]), apr); + } + } + } + /* Der letzte Katapultschuetze setzt die + * Ladezeit neu und generiert die Meldung. */ + if (af->catmsg >= 0) { + struct message *m = + msg_message("killed_battle", "unit dead", au, af->catmsg); + message_all(b, m); + msg_release(m); + af->catmsg = -1; + } +} + +static void add_tactics(tactics * ta, fighter * fig, int value) +{ + if (value == 0 || value < ta->value) + return; + if (value > ta->value) { + selist_free(ta->fighters); + ta->fighters = 0; + } + selist_push(&ta->fighters, fig); + selist_push(&fig->side->battle->leaders, fig); + ta->value = value; +} + +static int horse_fleeing_bonus(const unit * u) +{ + const item_type *it_horse, *it_elvenhorse, *it_charger; + int n1 = 0, n2 = 0, n3 = 0; + item *itm; + int skl = effskill(u, SK_RIDING, NULL); + const resource_type *rtype; + + it_horse = ((rtype = get_resourcetype(R_HORSE)) != NULL) ? rtype->itype : 0; + it_elvenhorse = ((rtype = get_resourcetype(R_UNICORN)) != NULL) ? rtype->itype : 0; + it_charger = ((rtype = get_resourcetype(R_CHARGER)) != NULL) ? rtype->itype : 0; + + for (itm = u->items; itm; itm = itm->next) { + if (itm->type->flags & ITF_ANIMAL) { + if (itm->type == it_elvenhorse) + n3 += itm->number; + else if (itm->type == it_charger) + n2 += itm->number; + else if (itm->type == it_horse) + n1 += itm->number; + } + } + if (skl >= 5 && n3 >= u->number) + return 30; + if (skl >= 2 && n2 + n3 >= u->number) + return 20; + if (n1 + n2 + n3 >= u->number) + return 10; + return 0; +} + +static int fleechance(unit * u) +{ + int p = flee_chance_base; /* Fluchtwahrscheinlichkeit in % */ + /* Einheit u versucht, dem Getuemmel zu entkommen */ + + p += (effskill(u, SK_STEALTH, NULL) * flee_chance_skill_bonus); + p += horse_fleeing_bonus(u); + + if (u_race(u) == get_race(RC_HALFLING)) { + p += flee_chance_base; + if (p > flee_chance_max_percent) { + p = flee_chance_max_percent; + } + } + return p; +} + +/** add a new army to the conflict. + * beware: armies need to be added _at the beginning_ of the list because + * otherwise join_allies() will get into trouble */ +side *make_side(battle * b, const faction * f, const group * g, + unsigned int flags, const faction * stealthfaction) +{ + side *s1 = b->sides + b->nsides; + bfaction *bf; + + if (fval(b->region->terrain, SEA_REGION)) { + /* every fight in an ocean is short */ + flags |= SIDE_HASGUARDS; + } + else { + unit *u; + for (u = b->region->units; u; u = u->next) { + if (is_guard(u)) { + if (alliedunit(u, f, HELP_GUARD)) { + flags |= SIDE_HASGUARDS; + break; + } + } + } + } + + s1->battle = b; + s1->group = g; + s1->flags = flags; + s1->stealthfaction = stealthfaction; + for (bf = b->factions; bf; bf = bf->next) { + faction *f2 = bf->faction; + + if (f2 == f) { + s1->bf = bf; + s1->faction = f2; + s1->index = b->nsides++; + s1->nextF = bf->sides; + bf->sides = s1; + assert(b->nsides <= MAXSIDES); + break; + } + } + assert(bf); + return s1; +} + +troop select_ally(fighter * af, int minrow, int maxrow, int allytype) +{ + side *as = af->side; + battle *b = as->battle; + side *ds; + int allies = count_allies(as, minrow, maxrow, SELECT_ADVANCE, allytype); + + if (!allies) { + return no_troop; + } + allies = (int)(rng_int() % allies); + + for (ds = b->sides; ds != b->sides + b->nsides; ++ds) { + if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF + && as->faction == ds->faction)) { + fighter *df; + for (df = ds->fighters; df; df = df->next) { + int dr = get_unitrow(df, NULL); + if (dr >= minrow && dr <= maxrow) { + if (df->alive - df->removed > allies) { + troop dt; + assert(allies >= 0); + dt.index = allies; + dt.fighter = df; + return dt; + } + allies -= df->alive; + } + } + } + } + assert(!"we should never have gotten here"); + return no_troop; +} + +static int loot_quota(const unit * src, const unit * dst, + const item_type * type, int n) +{ + UNUSED_ARG(type); + if (dst && src && src->faction != dst->faction) { + double divisor = config_get_flt("rules.items.loot_divisor", 1); + assert(divisor <= 0 || divisor >= 1); + if (divisor >= 1) { + double r = n / divisor; + int x = (int)r; + + r = r - x; + if (chance(r)) + ++x; + + return x; + } + } + return n; +} + +static void loot_items(fighter * corpse) +{ + unit *u = corpse->unit; + item *itm = u->items; + battle *b = corpse->side->battle; + int dead = dead_fighters(corpse); + + if (dead <= 0) + return; + + while (itm) { + float lootfactor = (float)dead / (float)u->number; /* only loot the dead! */ + int maxloot = (int)((float)itm->number * lootfactor); + if (maxloot > 0) { + int i = (maxloot > 10) ? 10 : maxloot; + for (; i != 0; --i) { + int loot = maxloot / i; + + if (loot > 0) { + fighter *fig = NULL; + int looting = 0; + int maxrow = 0; + /* mustloot: we absolutely, positively must have somebody loot this thing */ + int mustloot = itm->type->flags & (ITF_CURSED | ITF_NOTLOST); + + itm->number -= loot; + maxloot -= loot; + + if (is_monsters(u->faction) && (rule_loot & LOOT_MONSTERS)) { + looting = 1; + } + else if (rule_loot & LOOT_OTHERS) { + looting = 1; + } + else if (rule_loot & LOOT_SELF) { + looting = 2; + } + if (looting) { + if (mustloot) { + maxrow = LAST_ROW; + } + else if (rule_loot & LOOT_KEEPLOOT) { + int lootchance = 50 + b->keeploot; + if (rng_int() % 100 < lootchance) { + maxrow = BEHIND_ROW; + } } else { - fig->building = NULL; + maxrow = LAST_ROW; } } + if (maxrow > 0) { + if (looting == 1) { + /* enemies get dibs */ + fig = select_enemy(corpse, FIGHT_ROW, maxrow, 0).fighter; + } + if (!fig) { + /* self and allies get second pick */ + fig = select_ally(corpse, FIGHT_ROW, LAST_ROW, ALLY_SELF).fighter; + } + } + + if (fig) { + int trueloot = + mustloot ? loot : loot_quota(corpse->unit, fig->unit, itm->type, + loot); + if (trueloot > 0) { + i_change(&fig->loot, itm->type, trueloot); + } + } + } + } + } + itm = itm->next; + } +} + +bool seematrix(const faction * f, const side * s) +{ + if (f == s->faction) + return true; + if (s->flags & SIDE_STEALTH) + return false; + return true; +} + +static double PopulationDamage(void) +{ + return rule_population_damage / 100.0; +} + +static void battle_effects(battle * b, int dead_players) +{ + region *r = b->region; + int rp = rpeasants(r); + + if (rp > 0) { + int dead_peasants = (int)(dead_players * PopulationDamage()); + if (dead_peasants > rp) { + dead_peasants = rp; + } + if (dead_peasants) { + deathcounts(r, dead_peasants + dead_players); + rsetpeasants(r, rp - dead_peasants); + } + } +} + +static void reorder_fleeing(region * r) +{ + unit **usrc = &r->units; + unit **udst = &r->units; + unit *ufirst = NULL; + unit *u; + + for (; *udst; udst = &u->next) { + u = *udst; + } + + for (u = *usrc; u != ufirst; u = *usrc) { + if (u->next && fval(u, UFL_FLEEING)) { + *usrc = u->next; + *udst = u; + udst = &u->next; + if (!ufirst) + ufirst = u; + } + else { + usrc = &u->next; + } + } + *udst = NULL; +} + +static void aftermath(battle * b) +{ + region *r = b->region; + side *s; + int dead_players = 0; + bfaction *bf; + bool ships_damaged = (b->turn + (b->has_tactics_turn ? 1 : 0) > 2); /* only used for ship damage! */ + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *df; + s->dead = 0; + + for (df = s->fighters; df; df = df->next) { + unit *du = df->unit; + int dead = dead_fighters(df); + + /* tote insgesamt: */ + s->dead += dead; + /* Tote, die wiederbelebt werde koennen: */ + if (playerrace(u_race(df->unit))) { + s->casualties += dead; + } + if (df->hits + df->kills) { + struct message *m = + msg_message("killsandhits", "unit hits kills", du, df->hits, + df->kills); + battle_message_faction(b, du->faction, m); + msg_release(m); + } + } + } + + /* POSTCOMBAT */ + do_combatmagic(b, DO_POSTCOMBATSPELL); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + int snumber = 0; + fighter *df; + bool relevant = false; /* Kampf relevant fuer diese Partei? */ + if (!fval(s, SIDE_HASGUARDS)) { + relevant = true; + } + s->flee = 0; + + for (df = s->fighters; df; df = df->next) { + unit *du = df->unit; + int dead = dead_fighters(df); + int sum_hp = 0; + int n; + int flags = 0; + + for (n = 0; n != df->alive; ++n) { + if (df->person[n].hp > 0) { + sum_hp += df->person[n].hp; + } + } + snumber += du->number; + if (dead == df->unit->number) { + flags = UFL_DEAD; + } + else if (relevant) { + flags = UFL_LONGACTION; + if ((du->status != ST_FLEE) && (df->run.hp <= 0)) { + flags |= UFL_NOTMOVING; + } + } + if (flags) { + fset(du, flags); + } + if (df->alive && df->alive == du->number) { + du->hp = sum_hp; + continue; /* nichts passiert */ + } + else if (df->run.hp) { + if (df->alive == 0) { + /* Report the casualties */ + reportcasualties(b, df, dead); + + /* Zuerst duerfen die Feinde pluendern, die mitgenommenen Items + * stehen in fig->run.items. Dann werden die Fliehenden auf + * die leere (tote) alte Einheit gemapt */ + if (!fval(df, FIG_NOLOOT)) { + loot_items(df); + } + scale_number(du, df->run.number); + du->hp = df->run.hp; + setguard(du, false); + /* must leave ships or buildings, or a stealthy hobbit + * can hold castles indefinitely */ + if (!fval(r->terrain, SEA_REGION)) { + leave(du, true); /* even region owners have to flee */ + } + fset(du, UFL_FLEEING); + } + else { + /* nur teilweise geflohene Einheiten mergen sich wieder */ + df->alive += df->run.number; + s->size[0] += df->run.number; + s->size[statusrow(df->status)] += df->run.number; + s->alive += df->run.number; + sum_hp += df->run.hp; + df->run.number = 0; + df->run.hp = 0; + /* df->run.region = NULL; */ + + reportcasualties(b, df, dead); + + scale_number(du, df->alive); + du->hp = sum_hp; + } + } + else { + if (df->alive == 0) { + /* alle sind tot, niemand geflohen. Einheit aufloesen */ + df->run.number = 0; + df->run.hp = 0; + + /* Report the casualties */ + reportcasualties(b, df, dead); + + /* Distribute Loot */ + loot_items(df); + + setguard(du, false); + scale_number(du, 0); + } + else { + df->run.number = 0; + df->run.hp = 0; + + reportcasualties(b, df, dead); + + scale_number(du, df->alive); + du->hp = sum_hp; + } + } + s->flee += df->run.number; + + if (playerrace(u_race(du))) { + /* tote im kampf werden zu regionsuntoten: + * for each of them, a peasant will die as well */ + dead_players += dead; + } + if (du->hp < du->number) { + log_error("%s has less hitpoints (%u) than people (%u)\n", itoa36(du->no), du->hp, du->number); + du->hp = du->number; + } + } + s->alive += s->healed; + assert(snumber == s->flee + s->alive + s->dead); + } + + battle_effects(b, dead_players); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + message *seen = msg_message("army_report", + "index abbrev dead fled survived", + army_index(s), sideabkz(s, false), s->dead, s->flee, s->alive); + message *unseen = msg_message("army_report", + "index abbrev dead fled survived", + army_index(s), "-?-", s->dead, s->flee, s->alive); + + for (bf = b->factions; bf; bf = bf->next) { + faction *f = bf->faction; + message *m = seematrix(f, s) ? seen : unseen; + + battle_message_faction(b, f, m); + } + + msg_release(seen); + msg_release(unseen); + } + + /* Wir benutzen drifted, um uns zu merken, ob ein Schiff + * schonmal Schaden genommen hat. (moved und drifted + * sollten in flags ueberfuehrt werden */ + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *df; + + for (df = s->fighters; df; df = df->next) { + unit *du = df->unit; + item *l; + + /* Beute verteilen */ + for (l = df->loot; l; l = l->next) { + const item_type *itype = l->type; + message *m = + msg_message("battle_loot", "unit amount item", du, l->number, + itype->rtype); + battle_message_faction(b, du->faction, m); + msg_release(m); + i_change(&du->items, itype, l->number); + } + + /* Wenn sich die Einheit auf einem Schiff befindet, wird + * dieses Schiff beschaedigt. Andernfalls ein Schiff, welches + * evt. zuvor verlassen wurde. */ + if (ships_damaged) { + ship *sh; + if (du->ship) + sh = du->ship; + else + sh = leftship(du); + + if (sh && fval(sh, SF_DAMAGED)) { + int n = b->turn - 2; + if (n > 0) { + double dmg = + config_get_flt("rules.ship.damage.battleround", + 0.05F); + damage_ship(sh, dmg * n); + freset(sh, SF_DAMAGED); + } } } } } - static int attacks_per_round(troop t) - { - return t.fighter->person[t.index].speed; + if (ships_damaged) { + ship **sp = &r->ships; + + while (*sp) { + ship *sh = *sp; + freset(sh, SF_DAMAGED); + if (sh->damage >= sh->size * DAMAGE_SCALE) { + sink_ship(sh); + remove_ship(sp, sh); + } + else { + sp = &sh->next; + } + } } - static void make_heroes(battle * b) - { + reorder_fleeing(r); +} + +static void battle_punit(unit * u, battle * b) +{ + bfaction *bf; + + for (bf = b->factions; bf; bf = bf->next) { + faction *f = bf->faction; + strlist *S = 0, *x; + + spunit(&S, f, u, 4, seen_battle); + for (x = S; x; x = x->next) { + fbattlerecord(b, f, x->s); + } + if (S) + freestrlist(S); + } +} + +static void print_fighters(battle * b, const side * s) +{ + fighter *df; + int row; + + for (row = 1; row != NUMROWS; ++row) { + message *m = NULL; + + for (df = s->fighters; df; df = df->next) { + unit *du = df->unit; + int thisrow = statusrow(df->unit->status); + + if (row == thisrow) { + if (m == NULL) { + m = msg_message("battle_row", "row", row); + message_all(b, m); + } + battle_punit(du, b); + } + } + if (m != NULL) + msg_release(m); + } +} + +bool is_attacker(const fighter * fig) +{ + return fval(fig, FIG_ATTACKER) != 0; +} + +static void set_attacker(fighter * fig) +{ + fset(fig, FIG_ATTACKER); +} + +static void print_stats(battle * b) +{ + side *s2; + side *s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + bfaction *bf; + + for (bf = b->factions; bf; bf = bf->next) { + faction *f = bf->faction; + const char *loc_army = LOC(f->locale, "battle_army"); + char *bufp; + const char *header; + size_t rsize, size; + int komma; + const char *sname = + seematrix(f, s) ? sidename(s) : LOC(f->locale, "unknown_faction"); + message *msg; + char buf[1024]; + + msg = msg_message("para_army_index", "index name", army_index(s), sname); + battle_message_faction(b, f, msg); + msg_release(msg); + + bufp = buf; + size = sizeof(buf); + komma = 0; + header = LOC(f->locale, "battle_opponents"); + + for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { + if (enemy(s2, s)) { + const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; + rsize = slprintf(bufp, size, "%s %s %d(%s)", + komma++ ? "," : (const char *)header, loc_army, army_index(s2), + abbrev); + if (rsize > size) + rsize = size - 1; + size -= rsize; + bufp += rsize; + } + } + if (komma) + fbattlerecord(b, f, buf); + + bufp = buf; + size = sizeof(buf); + komma = 0; + header = LOC(f->locale, "battle_helpers"); + + for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { + if (friendly(s2, s)) { + const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; + rsize = slprintf(bufp, size, "%s %s %d(%s)", + komma++ ? "," : (const char *)header, loc_army, army_index(s2), + abbrev); + if (rsize > size) + rsize = size - 1; + size -= rsize; + bufp += rsize; + } + } + if (komma) + fbattlerecord(b, f, buf); + + bufp = buf; + size = sizeof(buf); + komma = 0; + header = LOC(f->locale, "battle_attack"); + + for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { + if (s->relations[s2->index] & E_ATTACKING) { + const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; + rsize = + slprintf(bufp, size, "%s %s %d(%s)", + komma++ ? "," : (const char *)header, loc_army, army_index(s2), + abbrev); + if (rsize > size) + rsize = size - 1; + size -= rsize; + bufp += rsize; + } + } + if (komma) + fbattlerecord(b, f, buf); + } + + print_fighters(b, s); + } + + /* Besten Taktiker ermitteln */ + + b->max_tactics = 0; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (!selist_empty(s->leader.fighters)) { + if (s->leader.value > b->max_tactics) { + b->max_tactics = s->leader.value; + } + } + } + + if (b->max_tactics > 0) { + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->leader.value == b->max_tactics) { + selist *ql; + int qi; + + for (qi = 0, ql = s->leader.fighters; ql; selist_advance(&ql, &qi, 1)) { + fighter *tf = (fighter *)selist_get(ql, qi); + unit *u = tf->unit; + message *m = NULL; + if (!is_attacker(tf)) { + m = msg_message("para_tactics_lost", "unit", u); + } + else { + m = msg_message("para_tactics_won", "unit", u); + } + message_all(b, m); + msg_release(m); + } + } + } + } +} + +static int weapon_weight(const weapon * w, bool missile) +{ + if (missile == !!(fval(w->type, WTF_MISSILE))) { + return w->attackskill + w->defenseskill; + } + return 0; +} + +side * get_side(battle * b, const struct unit * u) +{ + side * s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->faction == u->faction) { + fighter * fig; + for (fig = s->fighters; fig; fig = fig->next) { + if (fig->unit == u) { + return s; + } + } + } + } + return 0; +} + +side * find_side(battle * b, const faction * f, const group * g, unsigned int flags, const faction * stealthfaction) +{ + side * s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->faction == f && s->group == g) { + unsigned int s1flags = flags | SIDE_HASGUARDS; + unsigned int s2flags = s->flags | SIDE_HASGUARDS; + if (rule_anon_battle && s->stealthfaction != stealthfaction) { + continue; + } + if (s1flags == s2flags) { + return s; + } + } + } + return 0; +} + +fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) +{ +#define WMAX 20 + weapon weapons[WMAX]; + region *r = b->region; + item *itm; + fighter *fig = NULL; + int h, i, tactics = effskill(u, SK_TACTICS, NULL); + int berserk; + int strongmen; + int speeded = 0, speed = 1; + int rest; + const group *g = NULL; + const faction *stealthfaction = get_otherfaction(u); + unsigned int flags = 0; + + assert(u->number); + if (fval(u, UFL_ANON_FACTION) != 0) + flags |= SIDE_STEALTH; + if (!(AllianceAuto() & HELP_FIGHT) && fval(u, UFL_GROUP)) { + g = get_group(u); + } + + /* Illusionen und Zauber kaempfen nicht */ + if (fval(u_race(u), RCF_ILLUSIONARY) || u->number == 0) { + return NULL; + } + if (s1 == NULL) { + s1 = find_side(b, u->faction, g, flags, stealthfaction); + /* aliances are moved out of make_fighter and will be handled later */ + if (!s1) { + s1 = make_side(b, u->faction, g, flags, stealthfaction); + } + else if (!stealthfaction) { + s1->stealthfaction = NULL; + } + /* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit fuer noch + * keinen Kampf ausgewaehlt wurde (sonst wuerde ein fighter existieren) */ + } + fig = (struct fighter*)calloc(1, sizeof(struct fighter)); + + fig->next = s1->fighters; + s1->fighters = fig; + + fig->unit = u; + /* In einer Burg muss man a) nicht Angreifer sein, und b) drin sein, und + * c) noch Platz finden. d) menschanaehnlich sein */ + if (attack) { + set_attacker(fig); + } + else { + building *bld = u->building; + if (bld && bld->sizeleft >= u->number && playerrace(u_race(u))) { + fig->building = bld; + fig->building->sizeleft -= u->number; + } + } + fig->status = u->status; + fig->side = s1; + fig->alive = u->number; + fig->side->alive += u->number; + fig->side->battle->alive += u->number; + fig->catmsg = -1; + + /* Freigeben nicht vergessen! */ + assert(fig->alive > 0); + fig->person = (struct person*)calloc((size_t)fig->alive, sizeof(struct person)); + + h = u->hp / u->number; + assert(h); + rest = u->hp % u->number; + + /* Effekte von Spruechen */ + + if (u->attribs) { + curse *c = get_curse(u->attribs, &ct_speed); + if (c) { + speeded = get_cursedmen(u, c); + speed = curse_geteffect_int(c); + } + } + + /* Effekte von Alchemie */ + berserk = get_effect(u, oldpotiontype[P_BERSERK]); + /* change_effect wird in ageing gemacht */ + + /* Effekte von Artefakten */ + strongmen = trollbelts(u); + if (strongmen > fig->unit->number) strongmen = fig->unit->number; + + /* Hitpoints, Attack- und Defense-Boni fuer alle Personen */ + for (i = 0; i < fig->alive; i++) { + assert(i < fig->unit->number); + fig->person[i].hp = h; + if (i < rest) + fig->person[i].hp++; + + if (i < speeded) + fig->person[i].speed = speed; + else + fig->person[i].speed = 1; + + if (i < berserk) { + fig->person[i].attack++; + } + /* Leute mit Kraftzauber machen +2 Schaden im Nahkampf. */ + if (i < strongmen) { + fig->person[i].damage += 2; + } + } + + /* Fuer alle Waffengattungen wird bestimmt, wie viele der Personen mit + * ihr kaempfen koennten, und was ihr Wert darin ist. */ + if (u_race(u)->battle_flags & BF_EQUIPMENT) { + int owp[WMAX]; + int dwp[WMAX]; + int wcount[WMAX]; + int wused[WMAX]; + int oi = 0, di = 0, w = 0; + for (itm = u->items; itm && w != WMAX; itm = itm->next) { + const weapon_type *wtype = resource2weapon(itm->type->rtype); + if (wtype == NULL || itm->number == 0) + continue; + weapons[w].attackskill = weapon_skill(wtype, u, true); + weapons[w].defenseskill = weapon_skill(wtype, u, false); + if (weapons[w].attackskill >= 0 || weapons[w].defenseskill >= 0) { + weapons[w].type = wtype; + wused[w] = 0; + wcount[w] = itm->number; + ++w; + } + assert(w != WMAX); + } + assert(w >= 0); + fig->weapons = (weapon *)calloc((size_t)(w + 1), sizeof(weapon)); + memcpy(fig->weapons, weapons, (size_t)w * sizeof(weapon)); + + for (i = 0; i != w; ++i) { + int j, o = 0, d = 0; + for (j = 0; j != i; ++j) { + if (weapon_weight(fig->weapons + j, + true) >= weapon_weight(fig->weapons + i, true)) + ++d; + if (weapon_weight(fig->weapons + j, + false) >= weapon_weight(fig->weapons + i, false)) + ++o; + } + for (j = i + 1; j != w; ++j) { + if (weapon_weight(fig->weapons + j, + true) > weapon_weight(fig->weapons + i, true)) + ++d; + if (weapon_weight(fig->weapons + j, + false) > weapon_weight(fig->weapons + i, false)) + ++o; + } + owp[o] = i; + dwp[d] = i; + } + /* jetzt enthalten owp und dwp eine absteigend schlechter werdende Liste der Waffen + * oi and di are the current index to the sorted owp/dwp arrays + * owp, dwp contain indices to the figther::weapons array */ + + /* hand out melee weapons: */ + for (i = 0; i != fig->alive; ++i) { + int wpless = weapon_skill(NULL, u, true); + while (oi != w + && (wused[owp[oi]] == wcount[owp[oi]] + || fval(fig->weapons[owp[oi]].type, WTF_MISSILE))) { + ++oi; + } + if (oi == w) + break; /* no more weapons available */ + if (weapon_weight(fig->weapons + owp[oi], false) <= wpless) { + continue; /* we fight better with bare hands */ + } + fig->person[i].melee = &fig->weapons[owp[oi]]; + ++wused[owp[oi]]; + } + /* hand out missile weapons (from back to front, in case of mixed troops). */ + for (di = 0, i = fig->alive; i-- != 0;) { + while (di != w && (wused[dwp[di]] == wcount[dwp[di]] + || !fval(fig->weapons[dwp[di]].type, WTF_MISSILE))) { + ++di; + } + if (di == w) + break; /* no more weapons available */ + if (weapon_weight(fig->weapons + dwp[di], true) > 0) { + fig->person[i].missile = &fig->weapons[dwp[di]]; + ++wused[dwp[di]]; + } + } + } + + s1->size[statusrow(fig->status)] += u->number; + s1->size[SUM_ROW] += u->number; + if (u_race(u)->battle_flags & BF_NOBLOCK) { + s1->nonblockers[statusrow(fig->status)] += u->number; + } + + if (u_race(fig->unit)->flags & RCF_HORSE) { + fig->horses = fig->unit->number; + fig->elvenhorses = 0; + } + else { + const resource_type *rt_horse = 0; + const resource_type *rt_elvenhorse = 0; + rt_elvenhorse = get_resourcetype(R_UNICORN); + rt_horse = get_resourcetype(R_CHARGER); + if (!rt_horse) { + rt_horse = get_resourcetype(R_HORSE); + } + fig->horses = rt_horse ? i_get(u->items, rt_horse->itype) : 0; + fig->elvenhorses = rt_elvenhorse ? i_get(u->items, rt_elvenhorse->itype) : 0; + } + + if (u_race(u)->battle_flags & BF_EQUIPMENT) { + for (itm = u->items; itm; itm = itm->next) { + if (itm->type->rtype->atype) { + if (i_canuse(u, itm->type)) { + struct armor *adata = (struct armor *)malloc(sizeof(armor)), **aptr; + adata->atype = itm->type->rtype->atype; + adata->count = itm->number; + for (aptr = &fig->armors; *aptr; aptr = &(*aptr)->next) { + if (adata->atype->prot > (*aptr)->atype->prot) { + break; + } + } + adata->next = *aptr; + *aptr = adata; + } + } + } + } + + /* Jetzt muss noch geschaut werden, wo die Einheit die jeweils besten + * Werte hat, das kommt aber erst irgendwo spaeter. Ich entscheide + * waehrend des Kampfes, welche ich nehme, je nach Gegner. Deswegen auch + * keine addierten boni. */ + + /* Zuerst mal die Spezialbehandlung gewisser Sonderfaelle. */ + fig->magic = effskill(u, SK_MAGIC, NULL); + + if (fig->horses) { + if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r) + || effskill(u, SK_RIDING, NULL) < CavalrySkill() + || u_race(u) == get_race(RC_TROLL) || fval(u, UFL_WERE)) + fig->horses = 0; + } + + if (fig->elvenhorses) { + if (effskill(u, SK_RIDING, NULL) < 5 || u_race(u) == get_race(RC_TROLL) + || fval(u, UFL_WERE)) + fig->elvenhorses = 0; + } + + /* Schauen, wie gut wir in Taktik sind. */ + if (tactics > 0 && u_race(u) == get_race(RC_INSECT)) + tactics -= 1 - (int)log10(fig->side->size[SUM_ROW]); +#ifdef TACTICS_MODIFIER + if (tactics > 0 && statusrow(fig->status) == FIGHT_ROW) + tactics += TACTICS_MODIFIER; + if (tactics > 0 && statusrow(fig->status) > BEHIND_ROW) { + tactics -= TACTICS_MODIFIER; + } +#endif + + if (tactics > 0) { + int bonus = 0; + + for (i = 0; i < fig->alive; i++) { + int p_bonus = 0; + int rnd; + + do { + rnd = (int)(rng_int() % 100); + if (rnd >= 40 && rnd <= 69) + p_bonus += 1; + else if (rnd <= 89) + p_bonus += 2; + else + p_bonus += 3; + } while (rnd >= 97); + if (p_bonus > bonus) p_bonus = bonus; + } + tactics += bonus; + } + + add_tactics(&fig->side->leader, fig, tactics); + ++b->nfighters; + return fig; +} + +int join_battle(battle * b, unit * u, bool attack, fighter ** cp) +{ + side *s; + fighter *fc = NULL; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + if (s->faction == u->faction) { + for (fig = s->fighters; fig; fig = fig->next) { + if (fig->unit == u) { + fc = fig; + if (attack) { + set_attacker(fig); + } + break; + } + } + } + } + if (!fc) { + *cp = make_fighter(b, u, NULL, attack); + return *cp != NULL; + } + *cp = fc; + return false; +} + +battle *make_battle(region * r) +{ + unit *u; + bfaction *bf; + building * bld; + battle *b = (battle *)calloc(1, sizeof(battle)); + + assert(b); + /* Alle Mann raus aus der Burg! */ + for (bld = r->buildings; bld != NULL; bld = bld->next) + bld->sizeleft = bld->size; + + b->region = r; + b->plane = getplane(r); + /* Finde alle Parteien, die den Kampf beobachten koennen: */ + for (u = r->units; u; u = u->next) { + if (u->number > 0) { + if (!fval(u->faction, FFL_MARK)) { + fset(u->faction, FFL_MARK); + for (bf = b->factions; bf; bf = bf->next) { + if (bf->faction == u->faction) + break; + } + if (!bf) { + bf = (bfaction *)calloc(1, sizeof(bfaction)); + assert(bf); + ++b->nfactions; + bf->faction = u->faction; + bf->next = b->factions; + b->factions = bf; + } + } + } + } + + for (bf = b->factions; bf; bf = bf->next) { + faction *f = bf->faction; + freset(f, FFL_MARK); + } + return b; +} + +static void free_side(side * si) +{ + selist_free(si->leader.fighters); +} + +static void free_fighter(fighter * fig) +{ + armor **ap = &fig->armors; + while (*ap) { + armor *a = *ap; + *ap = a->next; + free(a); + } + while (fig->loot) { + i_free(i_remove(&fig->loot, fig->loot)); + } + free(fig->person); + free(fig->weapons); + +} + +static void battle_free(battle * b) { + side *s; + + assert(b); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter **fp = &s->fighters; + while (*fp) { + fighter *fig = *fp; + *fp = fig->next; + free_fighter(fig); + free(fig); + } + s->fighters = NULL; + free_side(s); + } + free(b); +} + +void free_battle(battle * b) +{ + while (b->factions) { + bfaction *bf = b->factions; + b->factions = bf->next; + free(bf); + } + + selist_free(b->leaders); + selist_foreach(b->meffects, free); + selist_free(b->meffects); + + battle_free(b); +} + +static int *get_alive(side * s) +{ + return s->size; +} + +static int battle_report(battle * b) +{ + side *s, *s2; + bool cont = false; + bfaction *bf; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->alive - s->removed > 0) { + for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { + if (s2->alive - s2->removed > 0 && enemy(s, s2)) { + cont = true; + break; + } + } + if (cont) + break; + } + } + + fflush(stdout); + + for (bf = b->factions; bf; bf = bf->next) { + faction *fac = bf->faction; + char buf[32 * MAXSIDES]; + message *m; + sbstring sbs; + bool komma = false; + + sbs_init(&sbs, buf, sizeof(buf)); + + if (cont) + m = msg_message("para_lineup_battle", "turn", b->turn); + else + m = msg_message("para_after_battle", ""); + battle_message_faction(b, fac, m); + msg_release(m); + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + if (s->alive) { + int r, k = 0, *alive = get_alive(s); + int l = FIGHT_ROW; + const char *abbrev = seematrix(fac, s) ? sideabkz(s, false) : "-?-"; + const char *loc_army = LOC(fac->locale, "battle_army"); + char buffer[32]; + + if (komma) { + sbs_strcat(&sbs, ", "); + } + snprintf(buffer, sizeof(buffer), "%s %2d(%s): ", + loc_army, army_index(s), abbrev); + sbs_strcat(&sbs, buffer); + + for (r = FIGHT_ROW; r != NUMROWS; ++r) { + if (alive[r]) { + if (l != FIGHT_ROW) { + sbs_strcat(&sbs, "+"); + } + while (k--) { + sbs_strcat(&sbs, "0+"); + } + sprintf(buffer, "%d", alive[r]); + sbs_strcat(&sbs, buffer); + + k = 0; + l = r + 1; + } + else + ++k; + } + + komma = true; + } + } + fbattlerecord(b, fac, buf); + } + return cont; +} + +static void join_allies(battle * b) +{ + region *r = b->region; + unit *u; + side *s, *s_end = b->sides + b->nsides; + /* make_side might be adding a new faction, but it adds them to the end + * of the list, so we're safe in our iteration here if we remember the end + * up front. */ + for (u = r->units; u; u = u->next) { + /* Was ist mit Schiffen? */ + if (u->status != ST_FLEE && u->status != ST_AVOID + && !fval(u, UFL_LONGACTION | UFL_ISNEW) && u->number > 0) { + faction *f = u->faction; + fighter *c = NULL; + + for (s = b->sides; s != s_end; ++s) { + side *se; + /* Wenn alle attackierten noch FFL_NOAID haben, dann kaempfe nicht mit. */ + if (fval(s->faction, FFL_NOAID)) + continue; + if (s->faction != f) { + /* Wenn wir attackiert haben, kommt niemand mehr hinzu: */ + if (s->bf->attacker) + continue; + /* alliiert muessen wir schon sein, sonst ist's eh egal : */ + if (!alliedunit(u, s->faction, HELP_FIGHT)) + continue; + /* wenn die partei verborgen ist, oder gar eine andere + * vorgespiegelt wird, und er sich uns gegenueber nicht zu + * erkennen gibt, helfen wir ihm nicht */ + if (s->stealthfaction) { + if (!alliedside(s, u->faction, HELP_FSTEALTH)) { + continue; + } + } + } + /* einen alliierten angreifen duerfen sie nicht, es sei denn, der + * ist mit einem alliierten verfeindet, der nicht attackiert + * hat: */ + for (se = b->sides; se != s_end; ++se) { + if (u->faction == se->faction) + continue; + if (alliedunit(u, se->faction, HELP_FIGHT) && !se->bf->attacker) { + continue; + } + if (enemy(s, se)) + break; + } + if (se == s_end) + continue; + /* keine Einwaende, also soll er mitmachen: */ + if (c == NULL) { + if (!join_battle(b, u, false, &c)) { + continue; + } + } + + /* the enemy of my friend is my enemy: */ + for (se = b->sides; se != s_end; ++se) { + if (se->faction != u->faction && enemy(s, se)) { + set_enemy(se, c->side, false); + } + } + } + } + } + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + int si; + side *sa; + faction *f = s->faction; + + /* Den Feinden meiner Feinde gebe ich Deckung (gegen gemeinsame Feinde): */ + for (si = 0; s->enemies[si]; ++si) { + side *se = s->enemies[si]; + int ai; + for (ai = 0; se->enemies[ai]; ++ai) { + side *as = se->enemies[ai]; + if (as == s || !enemy(as, s)) { + set_friendly(as, s); + } + } + } + + for (sa = s + 1; sa != b->sides + b->nsides; ++sa) { + if (!enemy(s, sa) && !friendly(s, sa)) { + if (alliedfaction(f, sa->faction, HELP_FIGHT)) { + if (alliedfaction(sa->faction, f, HELP_FIGHT)) { + set_friendly(s, sa); + } + } + } + } + } +} + +static void flee(const troop dt) +{ + fighter *fig = dt.fighter; + unit *u = fig->unit; + int fchance = fleechance(u); + + if (fig->person[dt.index].flags & FL_PANICED) { + fchance += EFFECT_PANIC_SPELL; + } + if (fchance > flee_chance_max_percent) { + fchance = flee_chance_max_percent; + } + if (rng_int() % 100 < fchance) { + fig->run.hp += fig->person[dt.index].hp; + ++fig->run.number; + + setguard(u, false); + kill_troop(dt); + } +} + +static bool is_calmed(const unit *u, const faction *f) { + attrib *a = a_find(u->attribs, &at_curse); + + while (a && a->type == &at_curse) { + curse *c = (curse *)a->data.v; + if (c->type == &ct_calmmonster && curse_geteffect_int(c) == f->uid) { + if (curse_active(c)) { + return true; + } + } + a = a->next; + } + return false; +} + +static bool start_battle(region * r, battle ** bp) +{ + battle *b = NULL; + unit *u; + bool fighting = false; + + for (u = r->units; u != NULL; u = u->next) { + if (fval(u, UFL_LONGACTION)) + continue; + if (u->number > 0) { + order *ord; + + for (ord = u->orders; ord; ord = ord->next) { + if (getkeyword(ord) == K_ATTACK) { + unit *u2; + fighter *c1, *c2; + ship *lsh = NULL; + plane *pl = rplane(r); + + if (pl && fval(pl, PFL_NOATTACK)) { + cmistake(u, ord, 271, MSG_BATTLE); + continue; + } + + if (u_race(u)->battle_flags & BF_NO_ATTACK) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_no_attack", + "race", u_race(u))); + continue; + } + /** + ** Fehlerbehandlung Angreifer + **/ + if (LongHunger(u)) { + cmistake(u, ord, 225, MSG_BATTLE); + continue; + } + + if (u->status == ST_AVOID || u->status == ST_FLEE) { + cmistake(u, ord, 226, MSG_BATTLE); + continue; + } + + /* ist ein Fluechtling aus einem andern Kampf */ + if (fval(u, UFL_LONGACTION)) + continue; + + if (curse_active(get_curse(r->attribs, &ct_peacezone))) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "peace_active", "")); + continue; + } + + if (curse_active(get_curse(u->attribs, &ct_slavery))) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "slave_active", "")); + continue; + } + + if ((u->ship != NULL && !fval(r->terrain, SEA_REGION)) + || (lsh = leftship(u)) != NULL) { + if (is_guarded(r, u)) { + if (lsh) { + cmistake(u, ord, 234, MSG_BATTLE); + } + else { + /* Fehler: "Das Schiff muss erst verlassen werden" */ + cmistake(u, ord, 19, MSG_BATTLE); + } + continue; + } + } + + /* Ende Fehlerbehandlung Angreifer */ + + init_order_depr(ord); + /* attackierte Einheit ermitteln */ + getunit(r, u->faction, &u2); + + /* Beginn Fehlerbehandlung */ + /* Fehler: "Die Einheit wurde nicht gefunden" */ + if (!u2 || u2->number == 0 || !cansee(u->faction, u->region, u2, 0)) { + ADDMSG(&u->faction->msgs, msg_feedback(u, ord, + "feedback_unit_not_found", "")); + continue; + } + /* Fehler: "Die Einheit ist eine der unsrigen" */ + if (u2->faction == u->faction) { + cmistake(u, ord, 45, MSG_BATTLE); + continue; + } + /* Fehler: "Die Einheit ist mit uns alliert" */ + if (alliedunit(u, u2->faction, HELP_FIGHT)) { + cmistake(u, ord, 47, MSG_BATTLE); + continue; + } + if (IsImmune(u2->faction)) { + add_message(&u->faction->msgs, + msg_feedback(u, u->thisorder, "newbie_immunity_error", "turns", + NewbieImmunity())); + continue; + } + + /* Fehler: "Die Einheit ist mit uns alliert" */ + if (is_calmed(u, u2->faction)) { + cmistake(u, ord, 47, MSG_BATTLE); + continue; + } + /* Ende Fehlerbehandlung */ + if (b == NULL) { + unit *utmp; + for (utmp = r->units; utmp != NULL; utmp = utmp->next) { + fset(utmp->faction, FFL_NOAID); + } + b = make_battle(r); + } + join_battle(b, u, true, &c1); + join_battle(b, u2, false, &c2); + + if (u2->attribs) { + if (it_mistletoe) { + int effect = get_effect(u2, it_mistletoe); + if (effect >= u->number) { + change_effect(u2, it_mistletoe, -u2->number); + c2->run.hp = u2->hp; + c2->run.number = u2->number; + c2->side->flee += u2->number; + setguard(u2, false); + rmfighter(c2, u2->number); + } + } + } + + /* Hat die attackierte Einheit keinen Noaid-Status, + * wird das Flag von der Faction genommen, andere + * Einheiten greifen ein. */ + if (!fval(u2, UFL_NOAID)) + freset(u2->faction, FFL_NOAID); + + if (c1 && c2 && c2->run.number < c2->unit->number) { + /* Merken, wer Angreifer ist, fuer die Rueckzahlung der + * Praecombataura bei kurzem Kampf. */ + c1->side->bf->attacker = true; + + set_enemy(c1->side, c2->side, true); + fighting = true; + } + } + } + } + } + *bp = b; + return fighting; +} + +/** execute one round of attacks + * fig->fighting is used to determine who attacks, not fig->alive, since + * the latter may be influenced by attacks that already took place. + */ +static void battle_attacks(battle * b) +{ + side *s; + + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + + if (b->turn != 0 || (b->max_tactics > 0 + && get_tactics(s, NULL) == b->max_tactics)) { + for (fig = s->fighters; fig; fig = fig->next) { + + /* ist in dieser Einheit noch jemand handlungsfaehig? */ + if (fig->fighting <= 0) + continue; + + /* Handle the unit's attack on someone */ + do_attack(fig); + } + } + } +} + +/** updates the number of attacking troops in each fighter struct. + * this has to be calculated _before_ the actual attacks take + * place because otherwise dead troops would not strike in the + * round they die. */ +static void battle_update(battle * b) +{ + side *s; + for (s = b->sides; s != b->sides + b->nsides; ++s) { + fighter *fig; + for (fig = s->fighters; fig; fig = fig->next) { + fig->fighting = fig->alive - fig->removed; + } + } +} + +/** attempt to flee from battle before the next round begins + * there's a double attempt before the first round, but only + * one attempt before round zero, the potential tactics round. */ +static void battle_flee(battle * b) +{ + int attempt, flee_ops = 1; + + if (b->turn == 1) + flee_ops = 2; + + for (attempt = 1; attempt <= flee_ops; ++attempt) { side *s; for (s = b->sides; s != b->sides + b->nsides; ++s) { fighter *fig; for (fig = s->fighters; fig; fig = fig->next) { unit *u = fig->unit; - if (fval(u, UFL_HERO)) { - int i; - if (!playerrace(u_race(u))) { - log_error("Hero %s is a %s.\n", unitname(u), u_race(u)->_name); - } - for (i = 0; i != u->number; ++i) { - fig->person[i].speed += (rule_hero_speed - 1); - } - } - } - } - } + troop dt; + /* Flucht nicht bei mehr als 600 HP. Damit Wyrme toetbar bleiben. */ + int runhp = (int)(0.9 + unit_max_hp(u) * hpflee(u->status)); + if (runhp > 600) runhp = 600; - static void attack(battle * b, troop ta, const att * a, int numattack) - { - fighter *af = ta.fighter; - troop td; - unit *au = af->unit; - - switch (a->type) { - case AT_COMBATSPELL: - /* Magier versuchen immer erstmal zu zaubern, erst wenn das - * fehlschlaegt, wird af->magic == 0 und der Magier kaempft - * konventionell weiter */ - if (numattack == 0 && af->magic > 0) { - /* wenn der magier in die potenzielle Reichweite von Attacken des - * Feindes kommt, beginnt er auch bei einem Status von KAEMPFE NICHT, - * Kampfzauber zu schleudern: */ - if (count_enemies(b, af, melee_range[0], missile_range[1], - SELECT_ADVANCE | SELECT_DISTANCE | SELECT_FIND)) { - do_combatspell(ta); - } - } - break; - case AT_STANDARD: /* Waffen, mag. Gegenstaende, Kampfzauber */ - if (numattack > 0 || af->magic <= 0) { - weapon *wp = ta.fighter->person[ta.index].missile; - int melee = - count_enemies(b, af, melee_range[0], melee_range[1], - SELECT_ADVANCE | SELECT_DISTANCE | SELECT_FIND); - if (melee) - wp = preferred_weapon(ta, true); - /* Sonderbehandlungen */ - - if (getreload(ta)) { - ta.fighter->person[ta.index].reload--; - } - else { - bool standard_attack = true; - bool reload = false; - /* spezialattacken der waffe nur, wenn erste attacke in der runde. - * sonst helden mit feuerschwertern zu maechtig */ - if (numattack == 0 && wp && wp->type->attack) { - int dead = 0; - standard_attack = wp->type->attack(&ta, wp->type, &dead); - if (!standard_attack) - reload = true; - af->catmsg += dead; - if (!standard_attack && af->person[ta.index].last_action < b->turn) { - af->person[ta.index].last_action = b->turn; - } - } - if (standard_attack) { - bool missile = false; - if (wp && fval(wp->type, WTF_MISSILE)) - missile = true; - if (missile) { - td = select_opponent(b, ta, missile_range[0], missile_range[1]); - } - else { - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - } - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - reload = true; - if (hits(ta, td, wp)) { - const char *d; - if (wp == NULL) - d = u_race(au)->def_damage; - else if (is_riding(ta)) - d = wp->type->damage[1]; - else - d = wp->type->damage[0]; - terminate(td, ta, a->type, d, missile); - } - } - if (reload && wp && wp->type->reload && !getreload(ta)) { - setreload(ta); - } - } - } - break; - case AT_SPELL: /* Extra-Sprueche. Kampfzauber in AT_COMBATSPELL! */ - do_extra_spell(ta, a); - break; - case AT_NATURAL: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (hits(ta, td, NULL)) { - terminate(td, ta, a->type, a->data.dice, false); - } - break; - case AT_DRAIN_ST: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (hits(ta, td, NULL)) { - int c = dice_rand(a->data.dice); - while (c > 0) { - if (rng_int() % 2) { - td.fighter->person[td.index].attack -= 1; - } - else { - td.fighter->person[td.index].defense -= 1; - } - c--; - } - } - break; - case AT_DRAIN_EXP: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (hits(ta, td, NULL)) { - drain_exp(td.fighter->unit, dice_rand(a->data.dice)); - } - break; - case AT_DAZZLE: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (hits(ta, td, NULL)) { - dazzle(b, &td); - } - break; - case AT_STRUCTURAL: - td = select_opponent(b, ta, melee_range[0], melee_range[1]); - if (!td.fighter) - return; - if (ta.fighter->person[ta.index].last_action < b->turn) { - ta.fighter->person[ta.index].last_action = b->turn; - } - if (td.fighter->unit->ship) { - int dice = dice_rand(a->data.dice); - ship * sh = td.fighter->unit->ship; - damage_ship(sh, dice / sh->type->damage / sh->size); - } - else if (td.fighter->unit->building) { - damage_building(b, td.fighter->unit->building, dice_rand(a->data.dice)); - } - } - } - - void do_attack(fighter * af) - { - troop ta; - unit *au = af->unit; - side *side = af->side; - battle *b = side->battle; - - ta.fighter = af; - - assert(au && au->number); - /* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen - * Kaempfern beruht, darf die Reihenfolge und Groesse der Einheit keine - * Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der - * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zufaellig - * mit einer grossen Einheit zuerst drankommt, extrem bevorteilt. */ - ta.index = af->fighting; - - while (ta.index--) { - /* Wir suchen eine beliebige Feind-Einheit aus. An der koennen - * wir feststellen, ob noch jemand da ist. */ - int apr, attacks = attacks_per_round(ta); - if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND)) - break; - - for (apr = 0; apr != attacks; ++apr) { - int a; - for (a = 0; a < RACE_ATTACKS && u_race(au)->attack[a].type != AT_NONE; ++a) { - if (apr > 0) { - /* Wenn die Waffe nachladen muss, oder es sich nicht um einen - * Waffen-Angriff handelt, dann gilt der Speed nicht. */ - /* TODO: allow multiple AT_NATURAL attacks? */ - if (u_race(au)->attack[a].type != AT_STANDARD) - continue; - else { - weapon *wp = preferred_weapon(ta, true); - if (wp != NULL && wp->type->reload) - continue; - } - } - attack(b, ta, &(u_race(au)->attack[a]), apr); - } - } - } - /* Der letzte Katapultschuetze setzt die - * Ladezeit neu und generiert die Meldung. */ - if (af->catmsg >= 0) { - struct message *m = - msg_message("killed_battle", "unit dead", au, af->catmsg); - message_all(b, m); - msg_release(m); - af->catmsg = -1; - } - } - - static void add_tactics(tactics * ta, fighter * fig, int value) - { - if (value == 0 || value < ta->value) - return; - if (value > ta->value) { - selist_free(ta->fighters); - ta->fighters = 0; - } - selist_push(&ta->fighters, fig); - selist_push(&fig->side->battle->leaders, fig); - ta->value = value; - } - - static int horse_fleeing_bonus(const unit * u) - { - const item_type *it_horse, *it_elvenhorse, *it_charger; - int n1 = 0, n2 = 0, n3 = 0; - item *itm; - int skl = effskill(u, SK_RIDING, NULL); - const resource_type *rtype; - - it_horse = ((rtype = get_resourcetype(R_HORSE)) != NULL) ? rtype->itype : 0; - it_elvenhorse = ((rtype = get_resourcetype(R_UNICORN)) != NULL) ? rtype->itype : 0; - it_charger = ((rtype = get_resourcetype(R_CHARGER)) != NULL) ? rtype->itype : 0; - - for (itm = u->items; itm; itm = itm->next) { - if (itm->type->flags & ITF_ANIMAL) { - if (itm->type == it_elvenhorse) - n3 += itm->number; - else if (itm->type == it_charger) - n2 += itm->number; - else if (itm->type == it_horse) - n1 += itm->number; - } - } - if (skl >= 5 && n3 >= u->number) - return 30; - if (skl >= 2 && n2 + n3 >= u->number) - return 20; - if (n1 + n2 + n3 >= u->number) - return 10; - return 0; - } - - static int fleechance(unit * u) - { - int p = flee_chance_base; /* Fluchtwahrscheinlichkeit in % */ - /* Einheit u versucht, dem Getuemmel zu entkommen */ - - p += (effskill(u, SK_STEALTH, NULL) * flee_chance_skill_bonus); - p += horse_fleeing_bonus(u); - - if (u_race(u) == get_race(RC_HALFLING)) { - p += flee_chance_base; - if (p > flee_chance_max_percent) { - p = flee_chance_max_percent; - } - } - return p; - } - - /** add a new army to the conflict. - * beware: armies need to be added _at the beginning_ of the list because - * otherwise join_allies() will get into trouble */ - side *make_side(battle * b, const faction * f, const group * g, - unsigned int flags, const faction * stealthfaction) - { - side *s1 = b->sides + b->nsides; - bfaction *bf; - - if (fval(b->region->terrain, SEA_REGION)) { - /* every fight in an ocean is short */ - flags |= SIDE_HASGUARDS; - } - else { - unit *u; - for (u = b->region->units; u; u = u->next) { - if (is_guard(u)) { - if (alliedunit(u, f, HELP_GUARD)) { - flags |= SIDE_HASGUARDS; - break; - } - } - } - } - - s1->battle = b; - s1->group = g; - s1->flags = flags; - s1->stealthfaction = stealthfaction; - for (bf = b->factions; bf; bf = bf->next) { - faction *f2 = bf->faction; - - if (f2 == f) { - s1->bf = bf; - s1->faction = f2; - s1->index = b->nsides++; - s1->nextF = bf->sides; - bf->sides = s1; - assert(b->nsides <= MAXSIDES); - break; - } - } - assert(bf); - return s1; - } - - troop select_ally(fighter * af, int minrow, int maxrow, int allytype) - { - side *as = af->side; - battle *b = as->battle; - side *ds; - int allies = count_allies(as, minrow, maxrow, SELECT_ADVANCE, allytype); - - if (!allies) { - return no_troop; - } - allies = (int)(rng_int() % allies); - - for (ds = b->sides; ds != b->sides + b->nsides; ++ds) { - if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF - && as->faction == ds->faction)) { - fighter *df; - for (df = ds->fighters; df; df = df->next) { - int dr = get_unitrow(df, NULL); - if (dr >= minrow && dr <= maxrow) { - if (df->alive - df->removed > allies) { - troop dt; - assert(allies >= 0); - dt.index = allies; - dt.fighter = df; - return dt; - } - allies -= df->alive; - } - } - } - } - assert(!"we should never have gotten here"); - return no_troop; - } - - static int loot_quota(const unit * src, const unit * dst, - const item_type * type, int n) - { - UNUSED_ARG(type); - if (dst && src && src->faction != dst->faction) { - double divisor = config_get_flt("rules.items.loot_divisor", 1); - assert(divisor <= 0 || divisor >= 1); - if (divisor >= 1) { - double r = n / divisor; - int x = (int)r; - - r = r - x; - if (chance(r)) - ++x; - - return x; - } - } - return n; - } - - static void loot_items(fighter * corpse) - { - unit *u = corpse->unit; - item *itm = u->items; - battle *b = corpse->side->battle; - int dead = dead_fighters(corpse); - - if (dead <= 0) - return; - - while (itm) { - float lootfactor = (float)dead / (float)u->number; /* only loot the dead! */ - int maxloot = (int)((float)itm->number * lootfactor); - if (maxloot > 0) { - int i = (maxloot > 10) ? 10 : maxloot; - for (; i != 0; --i) { - int loot = maxloot / i; - - if (loot > 0) { - fighter *fig = NULL; - int looting = 0; - int maxrow = 0; - /* mustloot: we absolutely, positively must have somebody loot this thing */ - int mustloot = itm->type->flags & (ITF_CURSED | ITF_NOTLOST); - - itm->number -= loot; - maxloot -= loot; - - if (is_monsters(u->faction) && (rule_loot & LOOT_MONSTERS)) { - looting = 1; - } - else if (rule_loot & LOOT_OTHERS) { - looting = 1; - } - else if (rule_loot & LOOT_SELF) { - looting = 2; - } - if (looting) { - if (mustloot) { - maxrow = LAST_ROW; - } - else if (rule_loot & LOOT_KEEPLOOT) { - int lootchance = 50 + b->keeploot; - if (rng_int() % 100 < lootchance) { - maxrow = BEHIND_ROW; - } - } - else { - maxrow = LAST_ROW; - } - } - if (maxrow > 0) { - if (looting == 1) { - /* enemies get dibs */ - fig = select_enemy(corpse, FIGHT_ROW, maxrow, 0).fighter; - } - if (!fig) { - /* self and allies get second pick */ - fig = select_ally(corpse, FIGHT_ROW, LAST_ROW, ALLY_SELF).fighter; - } - } - - if (fig) { - int trueloot = - mustloot ? loot : loot_quota(corpse->unit, fig->unit, itm->type, - loot); - if (trueloot > 0) { - i_change(&fig->loot, itm->type, trueloot); - } - } - } - } - } - itm = itm->next; - } - } - - bool seematrix(const faction * f, const side * s) - { - if (f == s->faction) - return true; - if (s->flags & SIDE_STEALTH) - return false; - return true; - } - - static double PopulationDamage(void) - { - return rule_population_damage / 100.0; - } - - static void battle_effects(battle * b, int dead_players) - { - region *r = b->region; - int rp = rpeasants(r); - - if (rp > 0) { - int dead_peasants = (int)(dead_players * PopulationDamage()); - if (dead_peasants > rp) { - dead_peasants = rp; - } - if (dead_peasants) { - deathcounts(r, dead_peasants + dead_players); - rsetpeasants(r, rp - dead_peasants); - } - } - } - - static void reorder_fleeing(region * r) - { - unit **usrc = &r->units; - unit **udst = &r->units; - unit *ufirst = NULL; - unit *u; - - for (; *udst; udst = &u->next) { - u = *udst; - } - - for (u = *usrc; u != ufirst; u = *usrc) { - if (u->next && fval(u, UFL_FLEEING)) { - *usrc = u->next; - *udst = u; - udst = &u->next; - if (!ufirst) - ufirst = u; - } - else { - usrc = &u->next; - } - } - *udst = NULL; - } - - static void aftermath(battle * b) - { - region *r = b->region; - side *s; - int dead_players = 0; - bfaction *bf; - bool ships_damaged = (b->turn + (b->has_tactics_turn ? 1 : 0) > 2); /* only used for ship damage! */ - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *df; - s->dead = 0; - - for (df = s->fighters; df; df = df->next) { - unit *du = df->unit; - int dead = dead_fighters(df); - - /* tote insgesamt: */ - s->dead += dead; - /* Tote, die wiederbelebt werde koennen: */ - if (playerrace(u_race(df->unit))) { - s->casualties += dead; - } - if (df->hits + df->kills) { - struct message *m = - msg_message("killsandhits", "unit hits kills", du, df->hits, - df->kills); - battle_message_faction(b, du->faction, m); - msg_release(m); - } - } - } - - /* POSTCOMBAT */ - do_combatmagic(b, DO_POSTCOMBATSPELL); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - int snumber = 0; - fighter *df; - bool relevant = false; /* Kampf relevant fuer diese Partei? */ - if (!fval(s, SIDE_HASGUARDS)) { - relevant = true; - } - s->flee = 0; - - for (df = s->fighters; df; df = df->next) { - unit *du = df->unit; - int dead = dead_fighters(df); - int sum_hp = 0; - int n; - int flags = 0; - - for (n = 0; n != df->alive; ++n) { - if (df->person[n].hp > 0) { - sum_hp += df->person[n].hp; - } - } - snumber += du->number; - if (dead == df->unit->number) { - flags = UFL_DEAD; - } - else if (relevant) { - flags = UFL_LONGACTION; - if ((du->status != ST_FLEE) && (df->run.hp <= 0)) { - flags |= UFL_NOTMOVING; - } - } - if (flags) { - fset(du, flags); - } - if (df->alive && df->alive == du->number) { - du->hp = sum_hp; - continue; /* nichts passiert */ - } - else if (df->run.hp) { - if (df->alive == 0) { - /* Report the casualties */ - reportcasualties(b, df, dead); - - /* Zuerst duerfen die Feinde pluendern, die mitgenommenen Items - * stehen in fig->run.items. Dann werden die Fliehenden auf - * die leere (tote) alte Einheit gemapt */ - if (!fval(df, FIG_NOLOOT)) { - loot_items(df); - } - scale_number(du, df->run.number); - du->hp = df->run.hp; - setguard(du, false); - /* must leave ships or buildings, or a stealthy hobbit - * can hold castles indefinitely */ - if (!fval(r->terrain, SEA_REGION)) { - leave(du, true); /* even region owners have to flee */ - } - fset(du, UFL_FLEEING); - } - else { - /* nur teilweise geflohene Einheiten mergen sich wieder */ - df->alive += df->run.number; - s->size[0] += df->run.number; - s->size[statusrow(df->status)] += df->run.number; - s->alive += df->run.number; - sum_hp += df->run.hp; - df->run.number = 0; - df->run.hp = 0; - /* df->run.region = NULL; */ - - reportcasualties(b, df, dead); - - scale_number(du, df->alive); - du->hp = sum_hp; - } - } - else { - if (df->alive == 0) { - /* alle sind tot, niemand geflohen. Einheit aufloesen */ - df->run.number = 0; - df->run.hp = 0; - - /* Report the casualties */ - reportcasualties(b, df, dead); - - /* Distribute Loot */ - loot_items(df); - - setguard(du, false); - scale_number(du, 0); - } - else { - df->run.number = 0; - df->run.hp = 0; - - reportcasualties(b, df, dead); - - scale_number(du, df->alive); - du->hp = sum_hp; - } - } - s->flee += df->run.number; - - if (playerrace(u_race(du))) { - /* tote im kampf werden zu regionsuntoten: - * for each of them, a peasant will die as well */ - dead_players += dead; - } - if (du->hp < du->number) { - log_error("%s has less hitpoints (%u) than people (%u)\n", itoa36(du->no), du->hp, du->number); - du->hp = du->number; - } - } - s->alive += s->healed; - assert(snumber == s->flee + s->alive + s->dead); - } - - battle_effects(b, dead_players); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - message *seen = msg_message("army_report", - "index abbrev dead fled survived", - army_index(s), sideabkz(s, false), s->dead, s->flee, s->alive); - message *unseen = msg_message("army_report", - "index abbrev dead fled survived", - army_index(s), "-?-", s->dead, s->flee, s->alive); - - for (bf = b->factions; bf; bf = bf->next) { - faction *f = bf->faction; - message *m = seematrix(f, s) ? seen : unseen; - - battle_message_faction(b, f, m); - } - - msg_release(seen); - msg_release(unseen); - } - - /* Wir benutzen drifted, um uns zu merken, ob ein Schiff - * schonmal Schaden genommen hat. (moved und drifted - * sollten in flags ueberfuehrt werden */ - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *df; - - for (df = s->fighters; df; df = df->next) { - unit *du = df->unit; - item *l; - - /* Beute verteilen */ - for (l = df->loot; l; l = l->next) { - const item_type *itype = l->type; - message *m = - msg_message("battle_loot", "unit amount item", du, l->number, - itype->rtype); - battle_message_faction(b, du->faction, m); - msg_release(m); - i_change(&du->items, itype, l->number); - } - - /* Wenn sich die Einheit auf einem Schiff befindet, wird - * dieses Schiff beschaedigt. Andernfalls ein Schiff, welches - * evt. zuvor verlassen wurde. */ - if (ships_damaged) { - ship *sh; - if (du->ship) - sh = du->ship; - else - sh = leftship(du); - - if (sh && fval(sh, SF_DAMAGED)) { - int n = b->turn - 2; - if (n > 0) { - double dmg = - config_get_flt("rules.ship.damage.battleround", - 0.05F); - damage_ship(sh, dmg * n); - freset(sh, SF_DAMAGED); - } - } - } - } - } - - if (ships_damaged) { - ship **sp = &r->ships; - - while (*sp) { - ship *sh = *sp; - freset(sh, SF_DAMAGED); - if (sh->damage >= sh->size * DAMAGE_SCALE) { - sink_ship(sh); - remove_ship(sp, sh); - } - else { - sp = &sh->next; - } - } - } - - reorder_fleeing(r); - } - - static void battle_punit(unit * u, battle * b) - { - bfaction *bf; - - for (bf = b->factions; bf; bf = bf->next) { - faction *f = bf->faction; - strlist *S = 0, *x; - - spunit(&S, f, u, 4, seen_battle); - for (x = S; x; x = x->next) { - fbattlerecord(b, f, x->s); - } - if (S) - freestrlist(S); - } - } - - static void print_fighters(battle * b, const side * s) - { - fighter *df; - int row; - - for (row = 1; row != NUMROWS; ++row) { - message *m = NULL; - - for (df = s->fighters; df; df = df->next) { - unit *du = df->unit; - int thisrow = statusrow(df->unit->status); - - if (row == thisrow) { - if (m == NULL) { - m = msg_message("battle_row", "row", row); - message_all(b, m); - } - battle_punit(du, b); - } - } - if (m != NULL) - msg_release(m); - } - } - - bool is_attacker(const fighter * fig) - { - return fval(fig, FIG_ATTACKER) != 0; - } - - static void set_attacker(fighter * fig) - { - fset(fig, FIG_ATTACKER); - } - - static void print_stats(battle * b) - { - side *s2; - side *s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - bfaction *bf; - - for (bf = b->factions; bf; bf = bf->next) { - faction *f = bf->faction; - const char *loc_army = LOC(f->locale, "battle_army"); - char *bufp; - const char *header; - size_t rsize, size; - int komma; - const char *sname = - seematrix(f, s) ? sidename(s) : LOC(f->locale, "unknown_faction"); - message *msg; - char buf[1024]; - - msg = msg_message("para_army_index", "index name", army_index(s), sname); - battle_message_faction(b, f, msg); - msg_release(msg); - - bufp = buf; - size = sizeof(buf); - komma = 0; - header = LOC(f->locale, "battle_opponents"); - - for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (enemy(s2, s)) { - const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; - rsize = slprintf(bufp, size, "%s %s %d(%s)", - komma++ ? "," : (const char *)header, loc_army, army_index(s2), - abbrev); - if (rsize > size) - rsize = size - 1; - size -= rsize; - bufp += rsize; - } - } - if (komma) - fbattlerecord(b, f, buf); - - bufp = buf; - size = sizeof(buf); - komma = 0; - header = LOC(f->locale, "battle_helpers"); - - for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (friendly(s2, s)) { - const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; - rsize = slprintf(bufp, size, "%s %s %d(%s)", - komma++ ? "," : (const char *)header, loc_army, army_index(s2), - abbrev); - if (rsize > size) - rsize = size - 1; - size -= rsize; - bufp += rsize; - } - } - if (komma) - fbattlerecord(b, f, buf); - - bufp = buf; - size = sizeof(buf); - komma = 0; - header = LOC(f->locale, "battle_attack"); - - for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (s->relations[s2->index] & E_ATTACKING) { - const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; - rsize = - slprintf(bufp, size, "%s %s %d(%s)", - komma++ ? "," : (const char *)header, loc_army, army_index(s2), - abbrev); - if (rsize > size) - rsize = size - 1; - size -= rsize; - bufp += rsize; - } - } - if (komma) - fbattlerecord(b, f, buf); - } - - print_fighters(b, s); - } - - /* Besten Taktiker ermitteln */ - - b->max_tactics = 0; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (!selist_empty(s->leader.fighters)) { - if (s->leader.value > b->max_tactics) { - b->max_tactics = s->leader.value; - } - } - } - - if (b->max_tactics > 0) { - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->leader.value == b->max_tactics) { - selist *ql; - int qi; - - for (qi = 0, ql = s->leader.fighters; ql; selist_advance(&ql, &qi, 1)) { - fighter *tf = (fighter *)selist_get(ql, qi); - unit *u = tf->unit; - message *m = NULL; - if (!is_attacker(tf)) { - m = msg_message("para_tactics_lost", "unit", u); - } - else { - m = msg_message("para_tactics_won", "unit", u); - } - message_all(b, m); - msg_release(m); - } - } - } - } - } - - static int weapon_weight(const weapon * w, bool missile) - { - if (missile == !!(fval(w->type, WTF_MISSILE))) { - return w->attackskill + w->defenseskill; - } - return 0; - } - - side * get_side(battle * b, const struct unit * u) - { - side * s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->faction == u->faction) { - fighter * fig; - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->unit == u) { - return s; - } - } - } - } - return 0; - } - - side * find_side(battle * b, const faction * f, const group * g, unsigned int flags, const faction * stealthfaction) - { - side * s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->faction == f && s->group == g) { - unsigned int s1flags = flags | SIDE_HASGUARDS; - unsigned int s2flags = s->flags | SIDE_HASGUARDS; - if (rule_anon_battle && s->stealthfaction != stealthfaction) { + if (u->ship && fval(u->region->terrain, SEA_REGION)) { + /* keine Flucht von Schiffen auf hoher See */ continue; } - if (s1flags == s2flags) { - return s; - } - } - } - return 0; - } - - fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) - { -#define WMAX 20 - weapon weapons[WMAX]; - region *r = b->region; - item *itm; - fighter *fig = NULL; - int h, i, tactics = effskill(u, SK_TACTICS, NULL); - int berserk; - int strongmen; - int speeded = 0, speed = 1; - int rest; - const group *g = NULL; - const faction *stealthfaction = get_otherfaction(u); - unsigned int flags = 0; - - assert(u->number); - if (fval(u, UFL_ANON_FACTION) != 0) - flags |= SIDE_STEALTH; - if (!(AllianceAuto() & HELP_FIGHT) && fval(u, UFL_GROUP)) { - g = get_group(u); - } - - /* Illusionen und Zauber kaempfen nicht */ - if (fval(u_race(u), RCF_ILLUSIONARY) || u->number == 0) { - return NULL; - } - if (s1 == NULL) { - s1 = find_side(b, u->faction, g, flags, stealthfaction); - /* aliances are moved out of make_fighter and will be handled later */ - if (!s1) { - s1 = make_side(b, u->faction, g, flags, stealthfaction); - } - else if (!stealthfaction) { - s1->stealthfaction = NULL; - } - /* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit fuer noch - * keinen Kampf ausgewaehlt wurde (sonst wuerde ein fighter existieren) */ - } - fig = (struct fighter*)calloc(1, sizeof(struct fighter)); - - fig->next = s1->fighters; - s1->fighters = fig; - - fig->unit = u; - /* In einer Burg muss man a) nicht Angreifer sein, und b) drin sein, und - * c) noch Platz finden. d) menschanaehnlich sein */ - if (attack) { - set_attacker(fig); - } - else { - building *bld = u->building; - if (bld && bld->sizeleft >= u->number && playerrace(u_race(u))) { - fig->building = bld; - fig->building->sizeleft -= u->number; - } - } - fig->status = u->status; - fig->side = s1; - fig->alive = u->number; - fig->side->alive += u->number; - fig->side->battle->alive += u->number; - fig->catmsg = -1; - - /* Freigeben nicht vergessen! */ - assert(fig->alive > 0); - fig->person = (struct person*)calloc((size_t)fig->alive, sizeof(struct person)); - - h = u->hp / u->number; - assert(h); - rest = u->hp % u->number; - - /* Effekte von Spruechen */ - - if (u->attribs) { - curse *c = get_curse(u->attribs, &ct_speed); - if (c) { - speeded = get_cursedmen(u, c); - speed = curse_geteffect_int(c); - } - } - - /* Effekte von Alchemie */ - berserk = get_effect(u, oldpotiontype[P_BERSERK]); - /* change_effect wird in ageing gemacht */ - - /* Effekte von Artefakten */ - strongmen = trollbelts(u); - if (strongmen > fig->unit->number) strongmen = fig->unit->number; - - /* Hitpoints, Attack- und Defense-Boni fuer alle Personen */ - for (i = 0; i < fig->alive; i++) { - assert(i < fig->unit->number); - fig->person[i].hp = h; - if (i < rest) - fig->person[i].hp++; - - if (i < speeded) - fig->person[i].speed = speed; - else - fig->person[i].speed = 1; - - if (i < berserk) { - fig->person[i].attack++; - } - /* Leute mit Kraftzauber machen +2 Schaden im Nahkampf. */ - if (i < strongmen) { - fig->person[i].damage += 2; - } - } - - /* Fuer alle Waffengattungen wird bestimmt, wie viele der Personen mit - * ihr kaempfen koennten, und was ihr Wert darin ist. */ - if (u_race(u)->battle_flags & BF_EQUIPMENT) { - int owp[WMAX]; - int dwp[WMAX]; - int wcount[WMAX]; - int wused[WMAX]; - int oi = 0, di = 0, w = 0; - for (itm = u->items; itm && w != WMAX; itm = itm->next) { - const weapon_type *wtype = resource2weapon(itm->type->rtype); - if (wtype == NULL || itm->number == 0) + if (fval(u_race(u), RCF_UNDEAD) || u_race(u) == get_race(RC_SHADOWKNIGHT)) { + /* Untote fliehen nicht. Warum eigentlich? */ continue; - weapons[w].attackskill = weapon_skill(wtype, u, true); - weapons[w].defenseskill = weapon_skill(wtype, u, false); - if (weapons[w].attackskill >= 0 || weapons[w].defenseskill >= 0) { - weapons[w].type = wtype; - wused[w] = 0; - wcount[w] = itm->number; - ++w; } - assert(w != WMAX); - } - assert(w >= 0); - fig->weapons = (weapon *)calloc((size_t)(w + 1), sizeof(weapon)); - memcpy(fig->weapons, weapons, (size_t)w * sizeof(weapon)); - for (i = 0; i != w; ++i) { - int j, o = 0, d = 0; - for (j = 0; j != i; ++j) { - if (weapon_weight(fig->weapons + j, - true) >= weapon_weight(fig->weapons + i, true)) - ++d; - if (weapon_weight(fig->weapons + j, - false) >= weapon_weight(fig->weapons + i, false)) - ++o; - } - for (j = i + 1; j != w; ++j) { - if (weapon_weight(fig->weapons + j, - true) > weapon_weight(fig->weapons + i, true)) - ++d; - if (weapon_weight(fig->weapons + j, - false) > weapon_weight(fig->weapons + i, false)) - ++o; - } - owp[o] = i; - dwp[d] = i; - } - /* jetzt enthalten owp und dwp eine absteigend schlechter werdende Liste der Waffen - * oi and di are the current index to the sorted owp/dwp arrays - * owp, dwp contain indices to the figther::weapons array */ + dt.fighter = fig; + dt.index = fig->alive - fig->removed; + while (s->size[SUM_ROW] && dt.index != 0) { + --dt.index; + assert(dt.index >= 0 && dt.index < fig->unit->number); + assert(fig->person[dt.index].hp > 0); - /* hand out melee weapons: */ - for (i = 0; i != fig->alive; ++i) { - int wpless = weapon_skill(NULL, u, true); - while (oi != w - && (wused[owp[oi]] == wcount[owp[oi]] - || fval(fig->weapons[owp[oi]].type, WTF_MISSILE))) { - ++oi; - } - if (oi == w) - break; /* no more weapons available */ - if (weapon_weight(fig->weapons + owp[oi], false) <= wpless) { - continue; /* we fight better with bare hands */ - } - fig->person[i].melee = &fig->weapons[owp[oi]]; - ++wused[owp[oi]]; - } - /* hand out missile weapons (from back to front, in case of mixed troops). */ - for (di = 0, i = fig->alive; i-- != 0;) { - while (di != w && (wused[dwp[di]] == wcount[dwp[di]] - || !fval(fig->weapons[dwp[di]].type, WTF_MISSILE))) { - ++di; - } - if (di == w) - break; /* no more weapons available */ - if (weapon_weight(fig->weapons + dwp[di], true) > 0) { - fig->person[i].missile = &fig->weapons[dwp[di]]; - ++wused[dwp[di]]; + /* Versuche zu fliehen, wenn + * - Kampfstatus fliehe + * - schwer verwundet und nicht erste kampfrunde + * - in panik (Zauber) + * aber nicht, wenn der Zaubereffekt Held auf dir liegt! + */ + switch (u->status) { + case ST_FLEE: + break; + default: + if ((fig->person[dt.index].flags & FL_HIT) == 0) + continue; + if (fig->person[dt.index].hp <= runhp) + break; + if (fig->person[dt.index].flags & FL_PANICED) { + if ((fig->person[dt.index].flags & FL_COURAGE) == 0) + break; + } + continue; + } + flee(dt); } } } + } +} - s1->size[statusrow(fig->status)] += u->number; - s1->size[SUM_ROW] += u->number; - if (u_race(u)->battle_flags & BF_NOBLOCK) { - s1->nonblockers[statusrow(fig->status)] += u->number; - } - - if (u_race(fig->unit)->flags & RCF_HORSE) { - fig->horses = fig->unit->number; - fig->elvenhorses = 0; +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) { + return enemy(s1, s2); + } + } } else { - const resource_type *rt_horse = 0; - const resource_type *rt_elvenhorse = 0; - rt_elvenhorse = get_resourcetype(R_UNICORN); - rt_horse = get_resourcetype(R_CHARGER); - if (!rt_horse) { - rt_horse = get_resourcetype(R_HORSE); - } - fig->horses = rt_horse ? i_get(u->items, rt_horse->itype) : 0; - fig->elvenhorses = rt_elvenhorse ? i_get(u->items, rt_elvenhorse->itype) : 0; - } - - if (u_race(u)->battle_flags & BF_EQUIPMENT) { - for (itm = u->items; itm; itm = itm->next) { - if (itm->type->rtype->atype) { - if (i_canuse(u, itm->type)) { - struct armor *adata = (struct armor *)malloc(sizeof(armor)), **aptr; - adata->atype = itm->type->rtype->atype; - adata->count = itm->number; - for (aptr = &fig->armors; *aptr; aptr = &(*aptr)->next) { - if (adata->atype->prot > (*aptr)->atype->prot) { - break; - } - } - adata->next = *aptr; - *aptr = adata; - } - } - } - } - - /* Jetzt muss noch geschaut werden, wo die Einheit die jeweils besten - * Werte hat, das kommt aber erst irgendwo spaeter. Ich entscheide - * waehrend des Kampfes, welche ich nehme, je nach Gegner. Deswegen auch - * keine addierten boni. */ - - /* Zuerst mal die Spezialbehandlung gewisser Sonderfaelle. */ - fig->magic = effskill(u, SK_MAGIC, NULL); - - if (fig->horses) { - if (!fval(r->terrain, CAVALRY_REGION) || r_isforest(r) - || effskill(u, SK_RIDING, NULL) < CavalrySkill() - || u_race(u) == get_race(RC_TROLL) || fval(u, UFL_WERE)) - fig->horses = 0; - } - - if (fig->elvenhorses) { - if (effskill(u, SK_RIDING, NULL) < 5 || u_race(u) == get_race(RC_TROLL) - || fval(u, UFL_WERE)) - fig->elvenhorses = 0; - } - - /* Schauen, wie gut wir in Taktik sind. */ - if (tactics > 0 && u_race(u) == get_race(RC_INSECT)) - tactics -= 1 - (int)log10(fig->side->size[SUM_ROW]); -#ifdef TACTICS_MODIFIER - if (tactics > 0 && statusrow(fig->status) == FIGHT_ROW) - tactics += TACTICS_MODIFIER; - if (tactics > 0 && statusrow(fig->status) > BEHIND_ROW) { - tactics -= TACTICS_MODIFIER; - } -#endif - - if (tactics > 0) { - int bonus = 0; - - for (i = 0; i < fig->alive; i++) { - int p_bonus = 0; - int rnd; - - do { - rnd = (int)(rng_int() % 100); - if (rnd >= 40 && rnd <= 69) - p_bonus += 1; - else if (rnd <= 89) - p_bonus += 2; - else - p_bonus += 3; - } while (rnd >= 97); - if (p_bonus > bonus) p_bonus = bonus; - } - tactics += bonus; - } - - add_tactics(&fig->side->leader, fig, tactics); - ++b->nfighters; - return fig; - } - - int join_battle(battle * b, unit * u, bool attack, fighter ** cp) - { - side *s; - fighter *fc = NULL; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - if (s->faction == u->faction) { - for (fig = s->fighters; fig; fig = fig->next) { - if (fig->unit == u) { - fc = fig; - if (attack) { - set_attacker(fig); - } - break; - } - } - } - } - if (!fc) { - *cp = make_fighter(b, u, NULL, attack); - return *cp != NULL; - } - *cp = fc; - return false; - } - - battle *make_battle(region * r) - { - unit *u; - bfaction *bf; - building * bld; - battle *b = (battle *)calloc(1, sizeof(battle)); - - assert(b); - /* Alle Mann raus aus der Burg! */ - for (bld = r->buildings; bld != NULL; bld = bld->next) - bld->sizeleft = bld->size; - - b->region = r; - b->plane = getplane(r); - /* Finde alle Parteien, die den Kampf beobachten koennen: */ - for (u = r->units; u; u = u->next) { - if (u->number > 0) { - if (!fval(u->faction, FFL_MARK)) { - fset(u->faction, FFL_MARK); - for (bf = b->factions; bf; bf = bf->next) { - if (bf->faction == u->faction) - break; - } - if (!bf) { - bf = (bfaction *)calloc(1, sizeof(bfaction)); - assert(bf); - ++b->nfactions; - bf->faction = u->faction; - bf->next = b->factions; - b->factions = bf; - } - } - } - } - - for (bf = b->factions; bf; bf = bf->next) { - faction *f = bf->faction; - freset(f, FFL_MARK); - } - return b; - } - - static void free_side(side * si) - { - selist_free(si->leader.fighters); - } - - static void free_fighter(fighter * fig) - { - armor **ap = &fig->armors; - while (*ap) { - armor *a = *ap; - *ap = a->next; - free(a); - } - while (fig->loot) { - i_free(i_remove(&fig->loot, fig->loot)); - } - free(fig->person); - free(fig->weapons); - - } - - static void battle_free(battle * b) { - side *s; - - assert(b); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter **fp = &s->fighters; - while (*fp) { - fighter *fig = *fp; - *fp = fig->next; - free_fighter(fig); - free(fig); - } - s->fighters = NULL; - free_side(s); - } - free(b); - } - - void free_battle(battle * b) - { - while (b->factions) { - bfaction *bf = b->factions; - b->factions = bf->next; - free(bf); - } - - selist_free(b->leaders); - selist_foreach(b->meffects, free); - selist_free(b->meffects); - - battle_free(b); - } - - static int *get_alive(side * s) - { - return s->size; - } - - static int battle_report(battle * b) - { - side *s, *s2; - bool cont = false; - bfaction *bf; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->alive - s->removed > 0) { - for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (s2->alive - s2->removed > 0 && enemy(s, s2)) { - cont = true; - break; - } - } - if (cont) - break; - } - } - - fflush(stdout); - - for (bf = b->factions; bf; bf = bf->next) { - faction *fac = bf->faction; - char buf[32 * MAXSIDES]; - message *m; - sbstring sbs; - bool komma = false; - - sbs_init(&sbs, buf, sizeof(buf)); - - if (cont) - m = msg_message("para_lineup_battle", "turn", b->turn); - else - m = msg_message("para_after_battle", ""); - battle_message_faction(b, fac, m); - msg_release(m); - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - if (s->alive) { - int r, k = 0, *alive = get_alive(s); - int l = FIGHT_ROW; - const char *abbrev = seematrix(fac, s) ? sideabkz(s, false) : "-?-"; - const char *loc_army = LOC(fac->locale, "battle_army"); - char buffer[32]; - - if (komma) { - sbs_strcat(&sbs, ", "); - } - snprintf(buffer, sizeof(buffer), "%s %2d(%s): ", - loc_army, army_index(s), abbrev); - sbs_strcat(&sbs, buffer); - - for (r = FIGHT_ROW; r != NUMROWS; ++r) { - if (alive[r]) { - if (l != FIGHT_ROW) { - sbs_strcat(&sbs, "+"); - } - while (k--) { - sbs_strcat(&sbs, "0+"); - } - sprintf(buffer, "%d", alive[r]); - sbs_strcat(&sbs, buffer); - - k = 0; - l = r + 1; - } - else - ++k; - } - - komma = true; - } - } - fbattlerecord(b, fac, buf); - } - return cont; - } - - static void join_allies(battle * b) - { - region *r = b->region; - unit *u; - side *s, *s_end = b->sides + b->nsides; - /* make_side might be adding a new faction, but it adds them to the end - * of the list, so we're safe in our iteration here if we remember the end - * up front. */ - for (u = r->units; u; u = u->next) { - /* Was ist mit Schiffen? */ - if (u->status != ST_FLEE && u->status != ST_AVOID - && !fval(u, UFL_LONGACTION | UFL_ISNEW) && u->number > 0) { - faction *f = u->faction; - fighter *c = NULL; - - for (s = b->sides; s != s_end; ++s) { - side *se; - /* Wenn alle attackierten noch FFL_NOAID haben, dann kaempfe nicht mit. */ - if (fval(s->faction, FFL_NOAID)) - continue; - if (s->faction != f) { - /* Wenn wir attackiert haben, kommt niemand mehr hinzu: */ - if (s->bf->attacker) - continue; - /* alliiert muessen wir schon sein, sonst ist's eh egal : */ - if (!alliedunit(u, s->faction, HELP_FIGHT)) - continue; - /* wenn die partei verborgen ist, oder gar eine andere - * vorgespiegelt wird, und er sich uns gegenueber nicht zu - * erkennen gibt, helfen wir ihm nicht */ - if (s->stealthfaction) { - if (!alliedside(s, u->faction, HELP_FSTEALTH)) { - continue; - } - } - } - /* einen alliierten angreifen duerfen sie nicht, es sei denn, der - * ist mit einem alliierten verfeindet, der nicht attackiert - * hat: */ - for (se = b->sides; se != s_end; ++se) { - if (u->faction == se->faction) - continue; - if (alliedunit(u, se->faction, HELP_FIGHT) && !se->bf->attacker) { - continue; - } - if (enemy(s, se)) - break; - } - if (se == s_end) - continue; - /* keine Einwaende, also soll er mitmachen: */ - if (c == NULL) { - if (!join_battle(b, u, false, &c)) { - continue; - } - } - - /* the enemy of my friend is my enemy: */ - for (se = b->sides; se != s_end; ++se) { - if (se->faction != u->faction && enemy(s, se)) { - set_enemy(se, c->side, false); - } - } - } - } - } - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - int si; - side *sa; - faction *f = s->faction; - - /* Den Feinden meiner Feinde gebe ich Deckung (gegen gemeinsame Feinde): */ - for (si = 0; s->enemies[si]; ++si) { - side *se = s->enemies[si]; - int ai; - for (ai = 0; se->enemies[ai]; ++ai) { - side *as = se->enemies[ai]; - if (as == s || !enemy(as, s)) { - set_friendly(as, s); - } - } - } - - for (sa = s + 1; sa != b->sides + b->nsides; ++sa) { - if (!enemy(s, sa) && !friendly(s, sa)) { - if (alliedfaction(f, sa->faction, HELP_FIGHT)) { - if (alliedfaction(sa->faction, f, HELP_FIGHT)) { - set_friendly(s, sa); - } - } - } - } + return !help_enter(u1, u2); } } + return false; +} - static void flee(const troop dt) - { - fighter *fig = dt.fighter; - unit *u = fig->unit; - int fchance = fleechance(u); +void force_leave(region *r, battle *b) { + unit *u; - if (fig->person[dt.index].flags & FL_PANICED) { - fchance += EFFECT_PANIC_SPELL; + for (u = r->units; u; u = u->next) { + unit *uo = NULL; + if (u->building) { + uo = building_owner(u->building); } - if (fchance > flee_chance_max_percent) { - fchance = flee_chance_max_percent; + if (u->ship && r->land) { + uo = ship_owner(u->ship); } - if (rng_int() % 100 < fchance) { - fig->run.hp += fig->person[dt.index].hp; - ++fig->run.number; - - setguard(u, false); - kill_troop(dt); - } - } - - static bool is_calmed(const unit *u, const faction *f) { - attrib *a = a_find(u->attribs, &at_curse); - - while (a && a->type == &at_curse) { - curse *c = (curse *)a->data.v; - if (c->type == &ct_calmmonster && curse_geteffect_int(c) == f->uid) { - if (curse_active(c)) { - return true; - } - } - a = a->next; - } - return false; - } - - static bool start_battle(region * r, battle ** bp) - { - battle *b = NULL; - unit *u; - bool fighting = false; - - for (u = r->units; u != NULL; u = u->next) { - if (fval(u, UFL_LONGACTION)) - continue; - if (u->number > 0) { - order *ord; - - for (ord = u->orders; ord; ord = ord->next) { - if (getkeyword(ord) == K_ATTACK) { - unit *u2; - fighter *c1, *c2; - ship *lsh = NULL; - plane *pl = rplane(r); - - if (pl && fval(pl, PFL_NOATTACK)) { - cmistake(u, ord, 271, MSG_BATTLE); - continue; - } - - if (u_race(u)->battle_flags & BF_NO_ATTACK) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_no_attack", - "race", u_race(u))); - continue; - } - /** - ** Fehlerbehandlung Angreifer - **/ - if (LongHunger(u)) { - cmistake(u, ord, 225, MSG_BATTLE); - continue; - } - - if (u->status == ST_AVOID || u->status == ST_FLEE) { - cmistake(u, ord, 226, MSG_BATTLE); - continue; - } - - /* ist ein Fluechtling aus einem andern Kampf */ - if (fval(u, UFL_LONGACTION)) - continue; - - if (curse_active(get_curse(r->attribs, &ct_peacezone))) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "peace_active", "")); - continue; - } - - if (curse_active(get_curse(u->attribs, &ct_slavery))) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "slave_active", "")); - continue; - } - - if ((u->ship != NULL && !fval(r->terrain, SEA_REGION)) - || (lsh = leftship(u)) != NULL) { - if (is_guarded(r, u)) { - if (lsh) { - cmistake(u, ord, 234, MSG_BATTLE); - } - else { - /* Fehler: "Das Schiff muss erst verlassen werden" */ - cmistake(u, ord, 19, MSG_BATTLE); - } - continue; - } - } - - /* Ende Fehlerbehandlung Angreifer */ - - init_order_depr(ord); - /* attackierte Einheit ermitteln */ - getunit(r, u->faction, &u2); - - /* Beginn Fehlerbehandlung */ - /* Fehler: "Die Einheit wurde nicht gefunden" */ - if (!u2 || u2->number == 0 || !cansee(u->faction, u->region, u2, 0)) { - ADDMSG(&u->faction->msgs, msg_feedback(u, ord, - "feedback_unit_not_found", "")); - continue; - } - /* Fehler: "Die Einheit ist eine der unsrigen" */ - if (u2->faction == u->faction) { - cmistake(u, ord, 45, MSG_BATTLE); - continue; - } - /* Fehler: "Die Einheit ist mit uns alliert" */ - if (alliedunit(u, u2->faction, HELP_FIGHT)) { - cmistake(u, ord, 47, MSG_BATTLE); - continue; - } - if (IsImmune(u2->faction)) { - add_message(&u->faction->msgs, - msg_feedback(u, u->thisorder, "newbie_immunity_error", "turns", - NewbieImmunity())); - continue; - } - - /* Fehler: "Die Einheit ist mit uns alliert" */ - if (is_calmed(u, u2->faction)) { - cmistake(u, ord, 47, MSG_BATTLE); - continue; - } - /* Ende Fehlerbehandlung */ - if (b == NULL) { - unit *utmp; - for (utmp = r->units; utmp != NULL; utmp = utmp->next) { - fset(utmp->faction, FFL_NOAID); - } - b = make_battle(r); - } - join_battle(b, u, true, &c1); - join_battle(b, u2, false, &c2); - - if (u2->attribs) { - if (it_mistletoe) { - int effect = get_effect(u2, it_mistletoe); - if (effect >= u->number) { - change_effect(u2, it_mistletoe, -u2->number); - c2->run.hp = u2->hp; - c2->run.number = u2->number; - c2->side->flee += u2->number; - setguard(u2, false); - rmfighter(c2, u2->number); - } - } - } - - /* Hat die attackierte Einheit keinen Noaid-Status, - * wird das Flag von der Faction genommen, andere - * Einheiten greifen ein. */ - if (!fval(u2, UFL_NOAID)) - freset(u2->faction, FFL_NOAID); - - if (c1 && c2 && c2->run.number < c2->unit->number) { - /* Merken, wer Angreifer ist, fuer die Rueckzahlung der - * Praecombataura bei kurzem Kampf. */ - c1->side->bf->attacker = true; - - set_enemy(c1->side, c2->side, true); - fighting = true; - } - } - } - } - } - *bp = b; - return fighting; - } - - /** execute one round of attacks - * fig->fighting is used to determine who attacks, not fig->alive, since - * the latter may be influenced by attacks that already took place. - */ - static void battle_attacks(battle * b) - { - side *s; - - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - - if (b->turn != 0 || (b->max_tactics > 0 - && get_tactics(s, NULL) == b->max_tactics)) { - for (fig = s->fighters; fig; fig = fig->next) { - - /* ist in dieser Einheit noch jemand handlungsfaehig? */ - if (fig->fighting <= 0) - continue; - - /* Handle the unit's attack on someone */ - do_attack(fig); - } - } - } - } - - /** updates the number of attacking troops in each fighter struct. - * this has to be calculated _before_ the actual attacks take - * place because otherwise dead troops would not strike in the - * round they die. */ - static void battle_update(battle * b) - { - side *s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - for (fig = s->fighters; fig; fig = fig->next) { - fig->fighting = fig->alive - fig->removed; - } - } - } - - /** attempt to flee from battle before the next round begins - * there's a double attempt before the first round, but only - * one attempt before round zero, the potential tactics round. */ - static void battle_flee(battle * b) - { - int attempt, flee_ops = 1; - - if (b->turn == 1) - flee_ops = 2; - - for (attempt = 1; attempt <= flee_ops; ++attempt) { - side *s; - for (s = b->sides; s != b->sides + b->nsides; ++s) { - fighter *fig; - for (fig = s->fighters; fig; fig = fig->next) { - unit *u = fig->unit; - troop dt; - /* Flucht nicht bei mehr als 600 HP. Damit Wyrme toetbar bleiben. */ - int runhp = (int)(0.9 + unit_max_hp(u) * hpflee(u->status)); - if (runhp > 600) runhp = 600; - - if (u->ship && fval(u->region->terrain, SEA_REGION)) { - /* keine Flucht von Schiffen auf hoher See */ - continue; - } - if (fval(u_race(u), RCF_UNDEAD) || u_race(u) == get_race(RC_SHADOWKNIGHT)) { - /* Untote fliehen nicht. Warum eigentlich? */ - continue; - } - - dt.fighter = fig; - dt.index = fig->alive - fig->removed; - while (s->size[SUM_ROW] && dt.index != 0) { - --dt.index; - assert(dt.index >= 0 && dt.index < fig->unit->number); - assert(fig->person[dt.index].hp > 0); - - /* Versuche zu fliehen, wenn - * - Kampfstatus fliehe - * - schwer verwundet und nicht erste kampfrunde - * - in panik (Zauber) - * aber nicht, wenn der Zaubereffekt Held auf dir liegt! - */ - switch (u->status) { - case ST_FLEE: - break; - default: - if ((fig->person[dt.index].flags & FL_HIT) == 0) - continue; - if (fig->person[dt.index].hp <= runhp) - break; - if (fig->person[dt.index].flags & FL_PANICED) { - if ((fig->person[dt.index].flags & FL_COURAGE) == 0) - break; - } - continue; - } - flee(dt); - } - } - } - } - } - - 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) { - return enemy(s1, s2); - } - } - } - else { - return !help_enter(u1, u2); - } - } - return false; - } - - void force_leave(region *r, battle *b) { - unit *u; - - for (u = r->units; u; u = u->next) { - unit *uo = NULL; + if (uo && is_enemy(b, uo, u)) { + message *msg = NULL; if (u->building) { - uo = building_owner(u->building); + msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building); } - if (u->ship && r->land) { - uo = ship_owner(u->ship); + else { + msg = msg_message("force_leave_ship", "unit owner ship", u, uo, 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); + if (msg) { + ADDMSG(&u->faction->msgs, msg); } + leave(u, false); } } +} - static void do_battle(region * r) { - battle *b = NULL; - bool fighting; - ship *sh; +static void do_battle(region * r) { + battle *b = NULL; + bool fighting; + ship *sh; - fighting = start_battle(r, &b); + fighting = start_battle(r, &b); - if (b == NULL) - return; - - /* Bevor wir die alliierten hineinziehen, sollten wir schauen, * - * Ob jemand fliehen kann. Dann eruebrigt sich das ganze ja - * vielleicht schon. */ - report_battle_start(b); - if (!fighting) { - /* Niemand mehr da, Kampf kann nicht stattfinden. */ - message *m = msg_message("aborted_battle", ""); - message_all(b, m); - msg_release(m); - free_battle(b); - return; - } - join_allies(b); - make_heroes(b); - - /* make sure no ships are damaged initially */ - for (sh = r->ships; sh; sh = sh->next) - freset(sh, SF_DAMAGED); - - /* Gibt es eine Taktikrunde ? */ - if (!selist_empty(b->leaders)) { - b->turn = 0; - b->has_tactics_turn = true; - } - else { - b->turn = 1; - b->has_tactics_turn = false; - } - - /* PRECOMBATSPELLS */ - do_combatmagic(b, DO_PRECOMBATSPELL); - - print_stats(b); /* gibt die Kampfaufstellung aus */ - log_debug("battle in %s (%d, %d) : ", regionname(r, 0), r->x, r->y); - - for (; battle_report(b) && b->turn <= max_turns; ++b->turn) { - battle_flee(b); - battle_update(b); - battle_attacks(b); - - } - - /* Auswirkungen berechnen: */ - aftermath(b); - if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) { - force_leave(b->region, b); - } - /* Hier ist das Gefecht beendet, und wir koennen die - * Hilfsstrukturen * wieder loeschen: */ + if (b == NULL) + return; + /* Bevor wir die alliierten hineinziehen, sollten wir schauen, * + * Ob jemand fliehen kann. Dann eruebrigt sich das ganze ja + * vielleicht schon. */ + report_battle_start(b); + if (!fighting) { + /* Niemand mehr da, Kampf kann nicht stattfinden. */ + message *m = msg_message("aborted_battle", ""); + message_all(b, m); + msg_release(m); free_battle(b); + return; + } + join_allies(b); + make_heroes(b); + + /* make sure no ships are damaged initially */ + for (sh = r->ships; sh; sh = sh->next) + freset(sh, SF_DAMAGED); + + /* Gibt es eine Taktikrunde ? */ + if (!selist_empty(b->leaders)) { + b->turn = 0; + b->has_tactics_turn = true; + } + else { + b->turn = 1; + b->has_tactics_turn = false; } - void do_battles(void) { - region *r; - init_rules(); - for (r = regions; r; r = r->next) { - do_battle(r); - } + /* PRECOMBATSPELLS */ + do_combatmagic(b, DO_PRECOMBATSPELL); + + print_stats(b); /* gibt die Kampfaufstellung aus */ + log_debug("battle in %s (%d, %d) : ", regionname(r, 0), r->x, r->y); + + for (; battle_report(b) && b->turn <= max_turns; ++b->turn) { + battle_flee(b); + battle_update(b); + battle_attacks(b); + } + + /* Auswirkungen berechnen: */ + aftermath(b); + if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) { + force_leave(b->region, b); + } + /* Hier ist das Gefecht beendet, und wir koennen die + * Hilfsstrukturen * wieder loeschen: */ + + free_battle(b); +} + +void do_battles(void) { + region *r; + init_rules(); + for (r = regions; r; r = r->next) { + do_battle(r); + } +} diff --git a/src/bind_faction.c b/src/bind_faction.c index cfadbc6ab..b9d9ecda1 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -272,7 +272,7 @@ static int tolua_faction_debug_messages(lua_State * L) } lua_newtable(L); for (ml = self->msgs->begin; ml; ml = ml->next, ++i) { - char buf[80]; + char buf[120]; nr_render(ml->msg, default_locale, buf, sizeof(buf), NULL); puts(buf); } diff --git a/src/move.c b/src/move.c index 984904608..3bc4bc3df 100644 --- a/src/move.c +++ b/src/move.c @@ -258,6 +258,14 @@ get_transporters(const item * itm, int *p_animals, int *p_acap, int *p_vehicles, *p_acap = acap; } +static int walking_horse_limit(const unit *u, int skill) { + return (1 + skill * 4) * u->number; +} + +static int riding_horse_limit(const unit *u, int skill) { + return skill * 2 * u->number; +} + static int ridingcapacity(const unit * u) { int vehicles = 0, vcap = 0; @@ -270,7 +278,7 @@ static int ridingcapacity(const unit * u) ** tragen nichts (siehe walkingcapacity). Ein Wagen zaehlt nur, wenn er ** von zwei Pferden gezogen wird */ - horses = effskill(u, SK_RIDING, NULL) * u->number * 2; + horses = riding_horse_limit(u, effskill(u, SK_RIDING, NULL)); if (animals > horses) animals = horses; if (fval(u_race(u), RCF_HORSE)) @@ -297,7 +305,7 @@ int walkingcapacity(const struct unit *u) /* Das Gewicht, welches die Pferde tragen, plus das Gewicht, welches * die Leute tragen */ - horses = effskill(u, SK_RIDING, NULL) * u->number * 4; + horses = walking_horse_limit(u, effskill(u, SK_RIDING, NULL)); pferde_fuer_wagen = (animals < horses) ? animals : horses; if (fval(u_race(u), RCF_HORSE)) { animals += u->number; @@ -366,7 +374,6 @@ static int canwalk(unit * u) int maxwagen, maxpferde; int vehicles = 0, vcap = 0; int animals = 0, acap = 0; - int effsk; /* workaround: monsters are too stupid to drop items, therefore they have * infinite carrying capacity */ @@ -375,13 +382,12 @@ static int canwalk(unit * u) get_transporters(u->items, &animals, &acap, &vehicles, &vcap); - effsk = effskill(u, SK_RIDING, NULL); - maxwagen = effsk * u->number * 2; + maxpferde = walking_horse_limit(u, effskill(u, SK_RIDING, NULL)); + maxwagen = maxpferde / 2; if (u_race(u) == get_race(RC_TROLL)) { int trolls = u->number / 4; - if (maxwagen > trolls) maxwagen = trolls; + if (maxwagen < trolls) maxwagen = trolls; } - maxpferde = effsk * u->number * 4 + u->number; if (animals > maxpferde) return E_CANWALK_TOOMANYHORSES; @@ -440,7 +446,7 @@ bool canswim(unit * u) static int walk_mode(const unit * u) { int horses = 0, maxhorses, unicorns = 0, maxunicorns; - int skill = effskill(u, SK_RIDING, NULL); + int skill; item *itm; const item_type *it_horse, *it_elvenhorse, *it_charger; const resource_type *rtype; @@ -458,8 +464,9 @@ static int walk_mode(const unit * u) } } + skill = effskill(u, SK_RIDING, NULL); maxunicorns = (skill / 5) * u->number; - maxhorses = skill * u->number * 2; + maxhorses = riding_horse_limit(u, skill); if (!(u_race(u)->flags & RCF_HORSE) && ((horses == 0 && unicorns == 0) From b9ae927aa3f4b2918b79703c477f12221aa9a340 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 13 Sep 2019 21:35:44 +0200 Subject: [PATCH 06/72] remove copyright notices. --- src/academy.c | 18 ------------------ src/alchemy.c | 18 ------------------ src/alchemy.h | 18 ------------------ src/attributes/attributes.c | 18 ------------------ src/attributes/attributes.h | 18 ------------------ src/attributes/dict.c | 18 ------------------ src/attributes/dict.h | 12 ------------ src/attributes/follow.c | 18 ------------------ src/attributes/follow.h | 18 ------------------ src/attributes/hate.c | 18 ------------------ src/attributes/hate.h | 18 ------------------ src/attributes/iceberg.c | 18 ------------------ src/attributes/iceberg.h | 18 ------------------ src/attributes/key.c | 18 ------------------ src/attributes/key.h | 18 ------------------ src/attributes/movement.c | 18 ------------------ src/attributes/movement.h | 18 ------------------ src/attributes/otherfaction.c | 18 ------------------ src/attributes/otherfaction.h | 18 +----------------- src/attributes/overrideroads.c | 18 ------------------ src/attributes/overrideroads.h | 18 ------------------ src/attributes/racename.c | 18 ------------------ src/attributes/racename.h | 18 ------------------ src/attributes/raceprefix.c | 18 ------------------ src/attributes/raceprefix.h | 18 ------------------ src/attributes/reduceproduction.c | 18 ------------------ src/attributes/reduceproduction.h | 18 ------------------ src/attributes/seenspell.c | 18 ------------------ src/attributes/targetregion.c | 18 ------------------ src/attributes/targetregion.h | 18 ------------------ src/automate.h | 18 ------------------ src/battle.c | 18 ------------------ src/battle.h | 18 ------------------ src/bind_building.h | 12 ------------ src/bind_faction.c | 12 ------------ src/bind_faction.h | 12 ------------ src/bind_message.h | 12 ------------ src/bind_region.h | 12 ------------ src/bind_ship.h | 12 ------------ src/bind_storage.h | 12 ------------ src/bind_unit.h | 12 ------------ src/bindings.h | 12 ------------ src/chaos.c | 18 ------------------ src/chaos.h | 18 ------------------ src/console.h | 18 ------------------ src/creport.c | 9 --------- src/creport.h | 11 ----------- src/economy.c | 19 ------------------- src/economy.h | 18 ------------------ src/give.c | 12 ------------ src/give.h | 12 ------------ src/gmtool.c | 10 ---------- src/gmtool.h | 10 ---------- src/gmtool_structs.h | 10 ---------- src/guard.c | 18 ------------------ src/helpers.c | 12 ------------ src/helpers.h | 13 +------------ src/items.h | 12 ------------ src/items/speedsail.c | 18 ------------------ src/items/speedsail.h | 18 ------------------ src/items/weapons.c | 18 ------------------ src/items/weapons.h | 12 ------------ src/items/xerewards.c | 18 ------------------ src/items/xerewards.h | 18 ------------------ src/jsonconf.c | 12 ------------ src/jsonconf.h | 12 ------------ src/kernel/alliance.c | 12 ------------ src/kernel/alliance.h | 18 ------------------ src/kernel/ally.h | 18 ------------------ src/kernel/attrib.c | 18 ------------------ src/kernel/attrib.h | 18 ------------------ src/kernel/build.c | 18 ------------------ src/kernel/build.h | 18 ------------------ src/kernel/building.c | 18 ------------------ src/kernel/building.h | 18 ------------------ src/kernel/callbacks.h | 18 ------------------ src/kernel/command.c | 12 ------------ src/kernel/command.h | 12 ------------ src/kernel/command.test.c | 12 ------------ src/kernel/config.c | 18 ------------------ src/kernel/config.h | 18 ------------------ src/kernel/connection.c | 18 ------------------ src/kernel/connection.h | 18 ------------------ src/kernel/curse.c | 18 ------------------ src/kernel/curse.h | 18 ------------------ src/kernel/equipment.c | 18 ------------------ src/kernel/equipment.h | 18 ------------------ src/kernel/event.c | 18 ------------------ src/kernel/event.h | 18 ------------------ src/kernel/faction.c | 18 ------------------ src/kernel/faction.h | 18 ------------------ src/kernel/group.c | 18 ------------------ src/kernel/group.h | 18 ------------------ src/kernel/item.c | 18 ------------------ src/kernel/item.h | 18 ------------------ src/kernel/messages.c | 18 ------------------ src/kernel/messages.h | 18 ------------------ src/kernel/objtypes.h | 18 ------------------ src/kernel/order.c | 12 ------------ src/kernel/order.h | 12 ------------ src/kernel/pathfinder.c | 18 ------------------ src/kernel/pathfinder.h | 18 ------------------ src/kernel/plane.c | 18 ------------------ src/kernel/plane.h | 18 ------------------ src/kernel/pool.c | 18 ------------------ src/kernel/pool.h | 18 ------------------ src/kernel/race.c | 18 ------------------ src/kernel/race.h | 18 ------------------ src/kernel/region.c | 18 ------------------ src/kernel/region.h | 18 ------------------ src/kernel/render.h | 18 ------------------ src/kernel/resources.c | 12 ------------ src/kernel/resources.h | 11 ----------- src/kernel/save.c | 19 ------------------- src/kernel/save.h | 18 ------------------ src/kernel/ship.c | 18 ------------------ src/kernel/ship.h | 18 ------------------ src/kernel/skills.c | 18 ------------------ src/kernel/skills.h | 12 ------------ src/kernel/spell.c | 18 ------------------ src/kernel/spell.h | 18 ------------------ src/kernel/spellbook.h | 18 ------------------ src/kernel/terrain.c | 18 ------------------ src/kernel/terrain.h | 18 ------------------ src/kernel/terrainid.h | 9 --------- src/kernel/types.h | 18 ------------------ src/kernel/unit.c | 18 ------------------ src/kernel/unit.h | 18 ------------------ src/kernel/version.h | 10 ---------- src/laws.c | 18 ------------------ src/laws.h | 18 ------------------ src/lighthouse.h | 18 ------------------ src/listbox.c | 10 ---------- src/magic.c | 18 ------------------ src/magic.h | 18 ------------------ src/main.c | 18 ------------------ src/market.c | 12 ------------ src/market.h | 12 ------------ src/modules/autoseed.c | 12 ------------ src/modules/autoseed.h | 12 ------------ src/modules/gmcmd.c | 12 ------------ src/modules/gmcmd.h | 18 ------------------ src/modules/museum.c | 18 ------------------ src/modules/museum.h | 18 ------------------ src/modules/score.c | 18 ------------------ src/modules/score.h | 18 ------------------ src/modules/xmas.c | 12 ------------ src/modules/xmas.h | 12 ------------ src/monsters.c | 19 ------------------- src/monsters.h | 18 ------------------ src/morale.c | 18 ------------------ src/morale.h | 18 ------------------ src/move.c | 18 ------------------ src/move.h | 18 ------------------ src/names.c | 18 ------------------ src/names.h | 18 ------------------ src/races/dragons.c | 12 ------------ src/races/races.c | 10 ---------- src/races/races.h | 10 ---------- src/races/zombies.c | 12 ------------ src/randenc.c | 18 ------------------ src/randenc.h | 18 ------------------ src/recruit.c | 19 ------------------- src/recruit.h | 18 ------------------ src/report.c | 18 ------------------ src/report.h | 12 ------------ src/reports.c | 18 ------------------ src/reports.h | 19 ------------------- src/settings.h | 12 ------------ src/spells.c | 13 ------------- src/spells.h | 14 -------------- src/spells/buildingcurse.c | 13 ------------- src/spells/buildingcurse.h | 13 ------------- src/spells/combatspells.c | 11 ----------- src/spells/combatspells.h | 12 ------------ src/spells/regioncurse.c | 13 ------------- src/spells/regioncurse.h | 13 ------------- src/spells/shipcurse.c | 13 ------------- src/spells/shipcurse.h | 12 ------------ src/spells/unitcurse.c | 13 ------------- src/spells/unitcurse.h | 13 ------------- src/spy.c | 18 ------------------ src/spy.h | 18 ------------------ src/steal.c | 18 ------------------ src/study.c | 18 ------------------ src/study.h | 18 ------------------ src/summary.c | 10 ---------- src/summary.h | 10 ---------- src/teleport.c | 18 ------------------ src/teleport.h | 18 ------------------ src/tools/atoi36.c | 12 ------------ src/tools/namegen.c | 13 ------------- src/travelthru.c | 18 ------------------ src/triggers/changefaction.c | 18 ------------------ src/triggers/changefaction.h | 18 ------------------ src/triggers/changerace.c | 18 ------------------ src/triggers/changerace.h | 18 ------------------ src/triggers/clonedied.c | 18 ------------------ src/triggers/clonedied.h | 18 ------------------ src/triggers/createcurse.c | 18 ------------------ src/triggers/createcurse.h | 18 ------------------ src/triggers/createunit.c | 18 ------------------ src/triggers/createunit.h | 18 ------------------ src/triggers/gate.c | 11 ----------- src/triggers/gate.h | 12 ------------ src/triggers/giveitem.c | 18 ------------------ src/triggers/giveitem.h | 18 ------------------ src/triggers/killunit.c | 18 ------------------ src/triggers/killunit.h | 18 ------------------ src/triggers/shock.c | 18 ------------------ src/triggers/shock.h | 18 ------------------ src/triggers/timeout.c | 18 ------------------ src/triggers/timeout.h | 18 ------------------ src/triggers/triggers.c | 18 ------------------ src/triggers/triggers.h | 18 ------------------ src/util/base36.c | 18 ------------------ src/util/base36.h | 18 ------------------ src/util/crmessage.c | 13 ------------- src/util/crmessage.h | 12 ------------ src/util/dice.c | 19 ------------------- src/util/filereader.h | 9 --------- src/util/functions.c | 18 ------------------ src/util/functions.h | 18 ------------------ src/util/goodies.c | 18 ------------------ src/util/goodies.h | 18 ------------------ src/util/language.c | 18 ------------------ src/util/language.h | 18 ------------------ src/util/lists.c | 18 ------------------ src/util/lists.h | 18 ------------------ src/util/log.c | 11 ----------- src/util/log.h | 11 ----------- src/util/message.c | 13 ------------- src/util/message.h | 11 ----------- src/util/nrmessage.c | 13 ------------- src/util/nrmessage.h | 12 ------------ src/util/order_parser.h | 11 ----------- src/util/parser.h | 10 ---------- src/util/rand.c | 18 ------------------ src/util/rand.h | 18 ------------------ src/util/resolve.c | 18 ------------------ src/util/resolve.h | 18 ------------------ src/util/rng.h | 9 --------- src/util/strings.c | 18 ------------------ src/util/strings.h | 18 ------------------ src/util/translation.c | 11 ----------- src/util/translation.h | 12 ------------ src/util/umlaut.c | 18 ------------------ src/util/umlaut.h | 18 ------------------ src/util/unicode.c | 10 ---------- src/util/unicode.h | 18 ------------------ src/volcano.c | 18 ------------------ src/volcano.h | 19 ------------------- src/wormhole.c | 12 ------------ src/wormhole.h | 18 ------------------ 254 files changed, 2 insertions(+), 4057 deletions(-) diff --git a/src/academy.c b/src/academy.c index c8a7e5a14..a3df1a5f9 100644 --- a/src/academy.c +++ b/src/academy.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include "platform.h" #include "kernel/config.h" #include diff --git a/src/alchemy.c b/src/alchemy.c index 3d3fe9836..bc66cb931 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "alchemy.h" diff --git a/src/alchemy.h b/src/alchemy.h index b1dde1c44..df6d8280a 100644 --- a/src/alchemy.h +++ b/src/alchemy.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_ALCHEMY_H #define H_KRNL_ALCHEMY_H diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index f580a4f29..4b1af76b0 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "attributes.h" diff --git a/src/attributes/attributes.h b/src/attributes/attributes.h index 3cd303f15..ea10542ab 100644 --- a/src/attributes/attributes.h +++ b/src/attributes/attributes.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_ATTRIBUTES #define H_ATTRIBUTE_ATTRIBUTES #ifdef __cplusplus diff --git a/src/attributes/dict.c b/src/attributes/dict.c index caa7d7e6a..2f8aff5d2 100644 --- a/src/attributes/dict.c +++ b/src/attributes/dict.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "dict.h" diff --git a/src/attributes/dict.h b/src/attributes/dict.h index aa6b4566a..d41b7c08c 100644 --- a/src/attributes/dict.h +++ b/src/attributes/dict.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef H_ATTRIBUTE_OBJECT #define H_ATTRIBUTE_OBJECT diff --git a/src/attributes/follow.c b/src/attributes/follow.c index c81e5630d..4b5a17dab 100644 --- a/src/attributes/follow.c +++ b/src/attributes/follow.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "follow.h" diff --git a/src/attributes/follow.h b/src/attributes/follow.h index 516812a4d..d315b224d 100644 --- a/src/attributes/follow.h +++ b/src/attributes/follow.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_FOLLOW #define H_ATTRIBUTE_FOLLOW #ifdef __cplusplus diff --git a/src/attributes/hate.c b/src/attributes/hate.c index 678ee9922..bd124db40 100644 --- a/src/attributes/hate.c +++ b/src/attributes/hate.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "hate.h" diff --git a/src/attributes/hate.h b/src/attributes/hate.h index 2652b6664..8aec0aefd 100644 --- a/src/attributes/hate.h +++ b/src/attributes/hate.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_HATE #define H_ATTRIBUTE_HATE #ifdef __cplusplus diff --git a/src/attributes/iceberg.c b/src/attributes/iceberg.c index 0c6e4e288..f930ea1b4 100644 --- a/src/attributes/iceberg.c +++ b/src/attributes/iceberg.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "iceberg.h" diff --git a/src/attributes/iceberg.h b/src/attributes/iceberg.h index 1fe3ed2ab..50ed7d63b 100644 --- a/src/attributes/iceberg.h +++ b/src/attributes/iceberg.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_ICEBERG #define H_ATTRIBUTE_ICEBERG diff --git a/src/attributes/key.c b/src/attributes/key.c index 10f7c49a9..22164e1fb 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "key.h" diff --git a/src/attributes/key.h b/src/attributes/key.h index 0b3ab748f..3d7ef6615 100644 --- a/src/attributes/key.h +++ b/src/attributes/key.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_KEY #define H_ATTRIBUTE_KEY diff --git a/src/attributes/movement.c b/src/attributes/movement.c index 19c5fb774..73fd1fa87 100644 --- a/src/attributes/movement.c +++ b/src/attributes/movement.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "movement.h" diff --git a/src/attributes/movement.h b/src/attributes/movement.h index a75e970ea..35a5c8fd6 100644 --- a/src/attributes/movement.h +++ b/src/attributes/movement.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_MOVEMENT #define H_ATTRIBUTE_MOVEMENT #ifdef __cplusplus diff --git a/src/attributes/otherfaction.c b/src/attributes/otherfaction.c index 5f4c83086..880502ebc 100644 --- a/src/attributes/otherfaction.c +++ b/src/attributes/otherfaction.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "otherfaction.h" diff --git a/src/attributes/otherfaction.h b/src/attributes/otherfaction.h index a274bcd49..46f2fb88f 100644 --- a/src/attributes/otherfaction.h +++ b/src/attributes/otherfaction.h @@ -1,20 +1,4 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ +#pragma once #ifdef __cplusplus extern "C" { diff --git a/src/attributes/overrideroads.c b/src/attributes/overrideroads.c index 8fbd18972..e89849081 100644 --- a/src/attributes/overrideroads.c +++ b/src/attributes/overrideroads.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "overrideroads.h" diff --git a/src/attributes/overrideroads.h b/src/attributes/overrideroads.h index 6959da21f..24b4b3002 100644 --- a/src/attributes/overrideroads.h +++ b/src/attributes/overrideroads.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_OVERRRIDEROADS #define H_ATTRIBUTE_OVERRRIDEROADS #ifdef __cplusplus diff --git a/src/attributes/racename.c b/src/attributes/racename.c index 880f32d57..138355e3c 100644 --- a/src/attributes/racename.c +++ b/src/attributes/racename.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "racename.h" diff --git a/src/attributes/racename.h b/src/attributes/racename.h index f775c9a6e..0efe48a47 100644 --- a/src/attributes/racename.h +++ b/src/attributes/racename.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_RACENAME_H #define H_ATTRIBUTE_RACENAME_H #ifdef __cplusplus diff --git a/src/attributes/raceprefix.c b/src/attributes/raceprefix.c index 68a8923d4..8b0406ada 100644 --- a/src/attributes/raceprefix.c +++ b/src/attributes/raceprefix.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "raceprefix.h" diff --git a/src/attributes/raceprefix.h b/src/attributes/raceprefix.h index e1e9f0be0..fccc91c44 100644 --- a/src/attributes/raceprefix.h +++ b/src/attributes/raceprefix.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_RACEPREFIX #define H_ATTRIBUTE_RACEPREFIX #ifdef __cplusplus diff --git a/src/attributes/reduceproduction.c b/src/attributes/reduceproduction.c index 57bfa4b93..b02101084 100644 --- a/src/attributes/reduceproduction.c +++ b/src/attributes/reduceproduction.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "reduceproduction.h" diff --git a/src/attributes/reduceproduction.h b/src/attributes/reduceproduction.h index 42ed635e7..1a7350a75 100644 --- a/src/attributes/reduceproduction.h +++ b/src/attributes/reduceproduction.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_REDUCEPRODUCTION #define H_ATTRIBUTE_REDUCEPRODUCTION #ifdef __cplusplus diff --git a/src/attributes/seenspell.c b/src/attributes/seenspell.c index 442660860..b2560d1d7 100644 --- a/src/attributes/seenspell.c +++ b/src/attributes/seenspell.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/attributes/targetregion.c b/src/attributes/targetregion.c index 2c29f8216..fca21cdb5 100644 --- a/src/attributes/targetregion.c +++ b/src/attributes/targetregion.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "targetregion.h" diff --git a/src/attributes/targetregion.h b/src/attributes/targetregion.h index f108dcadf..a160e9ff4 100644 --- a/src/attributes/targetregion.h +++ b/src/attributes/targetregion.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ATTRIBUTE_TARGETREGION #define H_ATTRIBUTE_TARGETREGION #ifdef __cplusplus diff --git a/src/automate.h b/src/automate.h index 7c71259b2..a59e7516e 100644 --- a/src/automate.h +++ b/src/automate.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2018, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #pragma once #ifndef H_GC_AUTOMATE diff --git a/src/battle.c b/src/battle.c index a0e043eb9..493e6c1c9 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/battle.h b/src/battle.h index 738fe928c..0ce76bfea 100644 --- a/src/battle.h +++ b/src/battle.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_BATTLE #define H_KRNL_BATTLE diff --git a/src/bind_building.h b/src/bind_building.h index ec971546e..a1c43f4f7 100644 --- a/src/bind_building.h +++ b/src/bind_building.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef __cplusplus extern "C" { #endif diff --git a/src/bind_faction.c b/src/bind_faction.c index b9d9ecda1..f71e334d1 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef _MSC_VER #include #endif diff --git a/src/bind_faction.h b/src/bind_faction.h index 2de048803..aed077f10 100644 --- a/src/bind_faction.h +++ b/src/bind_faction.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef __cplusplus extern "C" { #endif diff --git a/src/bind_message.h b/src/bind_message.h index 9087f63d3..5debe757c 100644 --- a/src/bind_message.h +++ b/src/bind_message.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef __cplusplus extern "C" { #endif diff --git a/src/bind_region.h b/src/bind_region.h index c8dcc840b..427a9b152 100644 --- a/src/bind_region.h +++ b/src/bind_region.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef __cplusplus extern "C" { #endif diff --git a/src/bind_ship.h b/src/bind_ship.h index 2bad027c9..fc1d5f63d 100644 --- a/src/bind_ship.h +++ b/src/bind_ship.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef __cplusplus extern "C" { #endif diff --git a/src/bind_storage.h b/src/bind_storage.h index a3944f19f..fba4480ee 100644 --- a/src/bind_storage.h +++ b/src/bind_storage.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef __cplusplus extern "C" { #endif diff --git a/src/bind_unit.h b/src/bind_unit.h index cc29bfa61..d1f97e617 100644 --- a/src/bind_unit.h +++ b/src/bind_unit.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef __cplusplus extern "C" { #endif diff --git a/src/bindings.h b/src/bindings.h index 038afd31e..144f65ca6 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef __cplusplus extern "C" { #endif diff --git a/src/chaos.c b/src/chaos.c index 26a11b8a2..ef1dffca6 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "chaos.h" diff --git a/src/chaos.h b/src/chaos.h index cb913d1a0..d3c187ff2 100644 --- a/src/chaos.h +++ b/src/chaos.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_GC_CHAOS #define H_GC_CHAOS #ifdef __cplusplus diff --git a/src/console.h b/src/console.h index de0e64348..05bc70477 100644 --- a/src/console.h +++ b/src/console.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_LUA_CONSOLE #define H_LUA_CONSOLE diff --git a/src/creport.c b/src/creport.c index 1d3a32d48..4088db49c 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1,12 +1,3 @@ -/* -+-------------------+ Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -+-------------------+ -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #include #include #include diff --git a/src/creport.h b/src/creport.h index f4e0cd4bd..5cca41274 100644 --- a/src/creport.h +++ b/src/creport.h @@ -1,14 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ #ifndef H_GC_CREPORT #define H_GC_CREPORT diff --git a/src/economy.c b/src/economy.c index c5cbe80c8..1fd202369 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1,22 +1,3 @@ -/* -Copyright (c) 1998-2019, -Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/economy.h b/src/economy.h index 2eace8a2d..57ef3581a 100644 --- a/src/economy.h +++ b/src/economy.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_GC_ECONOMY #define H_GC_ECONOMY diff --git a/src/give.c b/src/give.c index 64fa39504..ba04e69a6 100644 --- a/src/give.c +++ b/src/give.c @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2014 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ #ifdef _MSC_VER #include #endif diff --git a/src/give.h b/src/give.h index 4d44790a7..b0edc58a9 100644 --- a/src/give.h +++ b/src/give.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ #ifndef H_GC_GIVE #define H_GC_GIVE diff --git a/src/gmtool.c b/src/gmtool.c index 08c15930b..3c75fab7d 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2006 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #ifdef _MSC_VER #include #endif diff --git a/src/gmtool.h b/src/gmtool.h index 6566db7cb..aeef21d1e 100644 --- a/src/gmtool.h +++ b/src/gmtool.h @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2006 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #ifndef H_GMTOOL #define H_GMTOOL diff --git a/src/gmtool_structs.h b/src/gmtool_structs.h index aedee2aa9..df4c7f6cc 100644 --- a/src/gmtool_structs.h +++ b/src/gmtool_structs.h @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2006 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #ifndef H_GMTOOL_STRUCTS #define H_GMTOOL_STRUCTS diff --git a/src/guard.c b/src/guard.c index b27423b2e..17ab8581e 100644 --- a/src/guard.c +++ b/src/guard.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "guard.h" diff --git a/src/helpers.c b/src/helpers.c index 7f19a6dcc..b6f76abf5 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifdef _MSC_VER #include #endif diff --git a/src/helpers.h b/src/helpers.h index a5eccd0f5..f6167d1fc 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -1,15 +1,4 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2008 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - +#pragma once #ifdef __cplusplus extern "C" { #endif diff --git a/src/items.h b/src/items.h index f37444b74..4b756d236 100644 --- a/src/items.h +++ b/src/items.h @@ -1,15 +1,3 @@ -/* -+-------------------+ Christian Schlittchen -| | Enno Rehling -| Eressea PBEM host | Katja Zedel -| (c) 1998 - 2003 | Henning Peters -| | Ingo Wilken -+-------------------+ Stefan Reich - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifndef H_KRNL_ITEMS #define H_KRNL_ITEMS diff --git a/src/items/speedsail.c b/src/items/speedsail.c index 69c7deed0..8a8f35d84 100644 --- a/src/items/speedsail.c +++ b/src/items/speedsail.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "speedsail.h" diff --git a/src/items/speedsail.h b/src/items/speedsail.h index 2a342633c..ddc1e747e 100644 --- a/src/items/speedsail.h +++ b/src/items/speedsail.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ITM_SPEEDVIAL #define H_ITM_SPEEDVIAL #ifdef __cplusplus diff --git a/src/items/weapons.c b/src/items/weapons.c index bb8191f52..0b2e26b9a 100644 --- a/src/items/weapons.c +++ b/src/items/weapons.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER # include #endif diff --git a/src/items/weapons.h b/src/items/weapons.h index a14662e6c..2a94d5e15 100644 --- a/src/items/weapons.h +++ b/src/items/weapons.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - #ifndef H_ITM_WEAPONS #define H_ITM_WEAPONS #ifdef __cplusplus diff --git a/src/items/xerewards.c b/src/items/xerewards.c index 78430693c..acea74fc3 100644 --- a/src/items/xerewards.c +++ b/src/items/xerewards.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "xerewards.h" diff --git a/src/items/xerewards.h b/src/items/xerewards.h index 189032891..7207cd5d2 100644 --- a/src/items/xerewards.h +++ b/src/items/xerewards.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_ITM_XEREWARDS #define H_ITM_XEREWARDS #ifdef __cplusplus diff --git a/src/jsonconf.c b/src/jsonconf.c index fdcae9f25..8761f36be 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2004 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #include #include "jsonconf.h" diff --git a/src/jsonconf.h b/src/jsonconf.h index d7c66ecb1..d5d0935d0 100644 --- a/src/jsonconf.h +++ b/src/jsonconf.h @@ -1,15 +1,3 @@ -/* -+-------------------+ -| | Enno Rehling -| Eressea PBEM host | Christian Schlittchen -| (c) 1998 - 2007 | Katja Zedel -| | Henning Peters -+-------------------+ - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #ifndef H_JSONCONF_H #define H_JSONCONF_H #ifdef __cplusplus diff --git a/src/kernel/alliance.c b/src/kernel/alliance.c index 34775b4bc..17683a0f3 100644 --- a/src/kernel/alliance.c +++ b/src/kernel/alliance.c @@ -1,15 +1,3 @@ -/* -+-------------------+ Christian Schlittchen -| | Enno Rehling -| Eressea PBEM host | Katja Zedel -| (c) 1998 - 2003 | Henning Peters -| | Ingo Wilken -+-------------------+ Stefan Reich - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ - #include #include "alliance.h" diff --git a/src/kernel/alliance.h b/src/kernel/alliance.h index 00b4b29e4..a87413f7e 100644 --- a/src/kernel/alliance.h +++ b/src/kernel/alliance.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_ALLIANCE #define H_KRNL_ALLIANCE diff --git a/src/kernel/ally.h b/src/kernel/ally.h index 3d9058bc4..c6cb8fe51 100644 --- a/src/kernel/ally.h +++ b/src/kernel/ally.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef ALLY_H #define ALLY_H diff --git a/src/kernel/attrib.c b/src/kernel/attrib.c index 7f65e4b73..3b99053b2 100644 --- a/src/kernel/attrib.c +++ b/src/kernel/attrib.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "attrib.h" diff --git a/src/kernel/attrib.h b/src/kernel/attrib.h index 65c41aa71..c14ffed65 100644 --- a/src/kernel/attrib.h +++ b/src/kernel/attrib.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef ATTRIB_H #define ATTRIB_H diff --git a/src/kernel/build.c b/src/kernel/build.c index 271960907..3a73f8fd5 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/kernel/build.h b/src/kernel/build.h index c52cc5da1..d37d7fa12 100644 --- a/src/kernel/build.h +++ b/src/kernel/build.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_BUILD #define H_KRNL_BUILD diff --git a/src/kernel/building.c b/src/kernel/building.c index fd81651be..aba7953a0 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/kernel/building.h b/src/kernel/building.h index d1eb4d9fd..2471bbfdc 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_BUILDING #define H_KRNL_BUILDING diff --git a/src/kernel/callbacks.h b/src/kernel/callbacks.h index 1977cd284..f42707f45 100644 --- a/src/kernel/callbacks.h +++ b/src/kernel/callbacks.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_CALLBACKS_H #define H_KRNL_CALLBACKS_H diff --git a/src/kernel/command.c b/src/kernel/command.c index 71abc4e4e..51dab1f10 100644 --- a/src/kernel/command.c +++ b/src/kernel/command.c @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ #include #include #include "command.h" diff --git a/src/kernel/command.h b/src/kernel/command.h index 8fba94b7b..d17b65d82 100644 --- a/src/kernel/command.h +++ b/src/kernel/command.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ #ifndef H_UTIL_COMMAND_H #define H_UTIL_COMMAND_H #ifdef __cplusplus diff --git a/src/kernel/command.test.c b/src/kernel/command.test.c index 4c7bbb362..f83f3f33b 100644 --- a/src/kernel/command.test.c +++ b/src/kernel/command.test.c @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ #include #include "command.h" diff --git a/src/kernel/config.c b/src/kernel/config.c index f620cb882..4075621f3 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/kernel/config.h b/src/kernel/config.h index 1090967dd..9b10f1520 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef ERESSEA_H #define ERESSEA_H diff --git a/src/kernel/connection.c b/src/kernel/connection.c index e80294909..a41b2e1ca 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/kernel/connection.h b/src/kernel/connection.h index af412b036..06e238243 100644 --- a/src/kernel/connection.h +++ b/src/kernel/connection.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_BORDER #define H_KRNL_BORDER diff --git a/src/kernel/curse.c b/src/kernel/curse.c index be7ca4559..f96e2d212 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/kernel/curse.h b/src/kernel/curse.h index a3cf6176d..8a54fbb68 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef CURSE_H #define CURSE_H diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 4042662c2..611492c8a 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "equipment.h" diff --git a/src/kernel/equipment.h b/src/kernel/equipment.h index 7c95b8f67..f96f7e053 100644 --- a/src/kernel/equipment.h +++ b/src/kernel/equipment.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_EQUIPMENT_H #define H_KRNL_EQUIPMENT_H diff --git a/src/kernel/event.c b/src/kernel/event.c index a20296c57..1fcf70ebe 100644 --- a/src/kernel/event.c +++ b/src/kernel/event.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "event.h" #include "attrib.h" diff --git a/src/kernel/event.h b/src/kernel/event.h index c6c880c4c..7234b335d 100644 --- a/src/kernel/event.h +++ b/src/kernel/event.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef EVENT_H #define EVENT_H #ifdef __cplusplus diff --git a/src/kernel/faction.c b/src/kernel/faction.c index b5067b7cf..b6bd02659 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "faction.h" diff --git a/src/kernel/faction.h b/src/kernel/faction.h index d22e9ee22..0fcb2ff4a 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_FACTION #define H_KRNL_FACTION diff --git a/src/kernel/group.c b/src/kernel/group.c index 1515f8ea1..7c5ae1c73 100755 --- a/src/kernel/group.c +++ b/src/kernel/group.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "group.h" diff --git a/src/kernel/group.h b/src/kernel/group.h index 8bb764603..4f3d6c6cb 100755 --- a/src/kernel/group.h +++ b/src/kernel/group.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KERNEL_GROUP #define H_KERNEL_GROUP #ifdef __cplusplus diff --git a/src/kernel/item.c b/src/kernel/item.c index 4f33ce9bb..1533d65bc 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "item.h" diff --git a/src/kernel/item.h b/src/kernel/item.h index 568338b4c..0b90b7b1e 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_ITEM #define H_KRNL_ITEM diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 6e31810bf..656e08b3a 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "messages.h" diff --git a/src/kernel/messages.h b/src/kernel/messages.h index 7fa6996e2..643e1ccbb 100644 --- a/src/kernel/messages.h +++ b/src/kernel/messages.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_MESSAGE #define H_KRNL_MESSAGE #ifdef __cplusplus diff --git a/src/kernel/objtypes.h b/src/kernel/objtypes.h index d0e9a706d..1c1e166b1 100644 --- a/src/kernel/objtypes.h +++ b/src/kernel/objtypes.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_OBJTYPES #define H_KRNL_OBJTYPES #ifdef __cplusplus diff --git a/src/kernel/order.c b/src/kernel/order.c index b352a1650..056722294 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -1,15 +1,3 @@ -/* - +-------------------+ - | | Christian Schlittchen - | Eressea PBEM host | Enno Rehling - | (c) 1998 - 2014 | Katja Zedel - | | - +-------------------+ - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifdef _MSC_VER #include #endif diff --git a/src/kernel/order.h b/src/kernel/order.h index ca57d0179..cd5f59ba7 100644 --- a/src/kernel/order.h +++ b/src/kernel/order.h @@ -1,15 +1,3 @@ -/* - +-------------------+ - | | Christian Schlittchen - | Eressea PBEM host | Enno Rehling - | (c) 1998 - 2004 | Katja Zedel - | | - +-------------------+ - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef KRNL_ORDER_H #define KRNL_ORDER_H diff --git a/src/kernel/pathfinder.c b/src/kernel/pathfinder.c index 59f977f61..f2103f63f 100644 --- a/src/kernel/pathfinder.c +++ b/src/kernel/pathfinder.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include diff --git a/src/kernel/pathfinder.h b/src/kernel/pathfinder.h index a6c583139..9557fe735 100644 --- a/src/kernel/pathfinder.h +++ b/src/kernel/pathfinder.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_PATHFINDER #define H_KRNL_PATHFINDER #ifdef __cplusplus diff --git a/src/kernel/plane.c b/src/kernel/plane.c index 6d957ef57..8394edf34 100644 --- a/src/kernel/plane.c +++ b/src/kernel/plane.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "plane.h" diff --git a/src/kernel/plane.h b/src/kernel/plane.h index 4f63db398..a8855a8f2 100644 --- a/src/kernel/plane.h +++ b/src/kernel/plane.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_PLANES #define H_KRNL_PLANES #ifdef __cplusplus diff --git a/src/kernel/pool.c b/src/kernel/pool.c index 7236aeeed..f09781478 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/kernel/pool.h b/src/kernel/pool.h index df7638689..22f2f1a7f 100644 --- a/src/kernel/pool.h +++ b/src/kernel/pool.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_POOL_H #define H_KRNL_POOL_H #ifdef __cplusplus diff --git a/src/kernel/race.c b/src/kernel/race.c index af023341c..95239bd3f 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "race.h" diff --git a/src/kernel/race.h b/src/kernel/race.h index dd169272a..bce12912d 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_RACE_H #define H_KRNL_RACE_H #include diff --git a/src/kernel/region.c b/src/kernel/region.c index 85cb2a944..b3bc9a0e9 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER # include #endif diff --git a/src/kernel/region.h b/src/kernel/region.h index 7bd6cb2c4..04a4c3ebc 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_REGION #define H_KRNL_REGION diff --git a/src/kernel/render.h b/src/kernel/render.h index f12d55b9b..6f42243c4 100644 --- a/src/kernel/render.h +++ b/src/kernel/render.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include diff --git a/src/kernel/resources.c b/src/kernel/resources.c index ad2b67d90..17cec5ea2 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #include #include "resources.h" diff --git a/src/kernel/resources.h b/src/kernel/resources.h index 65431bb2c..45a1fdc37 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -1,14 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ #ifndef H_KRNL_RESOURCES #define H_KRNL_RESOURCES #ifdef __cplusplus diff --git a/src/kernel/save.c b/src/kernel/save.c index a39bde161..2eb36b134 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1,22 +1,3 @@ -#include "save.h" -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include diff --git a/src/kernel/save.h b/src/kernel/save.h index e8b631aab..8c000e911 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_SAVE #define H_KRNL_SAVE diff --git a/src/kernel/ship.c b/src/kernel/ship.c index d25e0c911..d1657b926 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER # include #endif diff --git a/src/kernel/ship.h b/src/kernel/ship.h index e944c0d65..cd6966040 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_SHIP #define H_KRNL_SHIP diff --git a/src/kernel/skills.c b/src/kernel/skills.c index 7987bb75c..8f1c421b6 100644 --- a/src/kernel/skills.c +++ b/src/kernel/skills.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "skill.h" diff --git a/src/kernel/skills.h b/src/kernel/skills.h index aa3c62339..21b926159 100644 --- a/src/kernel/skills.h +++ b/src/kernel/skills.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef H_KRNL_SKILL #define H_KRNL_SKILL diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 96190717f..ff0077377 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/kernel/spell.h b/src/kernel/spell.h index b38f77dee..6003f9cb7 100644 --- a/src/kernel/spell.h +++ b/src/kernel/spell.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_SPELL #define H_KRNL_SPELL #ifdef __cplusplus diff --git a/src/kernel/spellbook.h b/src/kernel/spellbook.h index 3894f9b44..ff12317cd 100644 --- a/src/kernel/spellbook.h +++ b/src/kernel/spellbook.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_SPELLBOOK_H #define H_KRNL_SPELLBOOK_H diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c index 57598c43c..10fa7ad33 100644 --- a/src/kernel/terrain.c +++ b/src/kernel/terrain.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "terrain.h" diff --git a/src/kernel/terrain.h b/src/kernel/terrain.h index 951ff7724..e47c2fbb5 100644 --- a/src/kernel/terrain.h +++ b/src/kernel/terrain.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef TERRAIN_H #define TERRAIN_H diff --git a/src/kernel/terrainid.h b/src/kernel/terrainid.h index b6235c399..28de47c1e 100644 --- a/src/kernel/terrainid.h +++ b/src/kernel/terrainid.h @@ -1,12 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2005 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - */ - #ifndef H_KRNL_TERRAINID_H #define H_KRNL_TERRAINID_H diff --git a/src/kernel/types.h b/src/kernel/types.h index 82af31cdc..13bca4d34 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef ERESSEA_TYPES_H #define ERESSEA_TYPES_H diff --git a/src/kernel/unit.c b/src/kernel/unit.c index e92ea4ca0..9933899ed 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER # include #endif diff --git a/src/kernel/unit.h b/src/kernel/unit.h index fc5602694..3290c4f78 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_UNIT_H #define H_KRNL_UNIT_H diff --git a/src/kernel/version.h b/src/kernel/version.h index c268e7bac..e9c058866 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -1,13 +1,3 @@ -#pragma once -/* - +-------------------+ - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2016 | Christian Schlittchen - | | https://github.com/eressea/server - +-------------------+ - */ - #ifndef H_KERNEL_VERSION #define H_KERNEL_VERSION diff --git a/src/laws.c b/src/laws.c index eb483aae7..7f78ac04b 100644 --- a/src/laws.c +++ b/src/laws.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/laws.h b/src/laws.h index fe423302e..4924a5f6e 100755 --- a/src/laws.h +++ b/src/laws.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_GC_LAWS #define H_GC_LAWS diff --git a/src/lighthouse.h b/src/lighthouse.h index cd0e055fd..4b76d1325 100644 --- a/src/lighthouse.h +++ b/src/lighthouse.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef LIGHTHOUSE_H #define LIGHTHOUSE_H diff --git a/src/listbox.c b/src/listbox.c index 542ab13e8..fc9bce15d 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -1,13 +1,3 @@ -/* -* +-------------------+ Christian Schlittchen -* | | Enno Rehling -* | Eressea PBEM host | Katja Zedel -* | (c) 1998 - 2006 | -* | | This program may not be used, modified or distributed -* +-------------------+ without prior permission by the authors of Eressea. -* -*/ - #ifdef _MSC_VER #include #endif diff --git a/src/magic.c b/src/magic.c index 80cc0e73e..eed6cda90 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/magic.h b/src/magic.h index 15870e90c..c373d2ecf 100644 --- a/src/magic.h +++ b/src/magic.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_MAGIC #define H_KRNL_MAGIC diff --git a/src/main.c b/src/main.c index 452b92353..cfc2f9c22 100644 --- a/src/main.c +++ b/src/main.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/market.c b/src/market.c index b954e2d35..61c7f9c6a 100644 --- a/src/market.c +++ b/src/market.c @@ -1,15 +1,3 @@ -/* -+-------------------+ Christian Schlittchen -| | Enno Rehling -| Eressea PBEM host | Katja Zedel -| (c) 1998 - 2003 | Henning Peters -| | Ingo Wilken -+-------------------+ Stefan Reich - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. - -*/ #include #include #include "market.h" diff --git a/src/market.h b/src/market.h index 8f1d39eb4..92d1d549e 100644 --- a/src/market.h +++ b/src/market.h @@ -1,15 +1,3 @@ -/* -+-------------------+ Christian Schlittchen -| | Enno Rehling -| Eressea PBEM host | Katja Zedel -| (c) 1998 - 2003 | Henning Peters -| | Ingo Wilken -+-------------------+ Stefan Reich - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. - -*/ #ifndef H_GC_MARKET #define H_GC_MARKET diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 7a6420e1c..2cf931498 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #include #include #include "autoseed.h" diff --git a/src/modules/autoseed.h b/src/modules/autoseed.h index cec42ba4a..b19565020 100644 --- a/src/modules/autoseed.h +++ b/src/modules/autoseed.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef _REGIONLIST_H #define _REGIONLIST_H #ifdef __cplusplus diff --git a/src/modules/gmcmd.c b/src/modules/gmcmd.c index 4cc573f16..2f93b92e5 100644 --- a/src/modules/gmcmd.c +++ b/src/modules/gmcmd.c @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #include #include #include "gmcmd.h" diff --git a/src/modules/gmcmd.h b/src/modules/gmcmd.h index 2b2b21adc..bc79c3a83 100644 --- a/src/modules/gmcmd.h +++ b/src/modules/gmcmd.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_MOD_GMCMD #define H_MOD_GMCMD #ifdef __cplusplus diff --git a/src/modules/museum.c b/src/modules/museum.c index 72e0b31b5..2ac4b9b95 100644 --- a/src/modules/museum.c +++ b/src/modules/museum.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include diff --git a/src/modules/museum.h b/src/modules/museum.h index 696b512d1..425fa3ec9 100644 --- a/src/modules/museum.h +++ b/src/modules/museum.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef HEADER_MUSEUM_H #define HEADER_MUSEUM_H diff --git a/src/modules/score.c b/src/modules/score.c index 31a06d1cd..85759fe02 100644 --- a/src/modules/score.c +++ b/src/modules/score.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "score.h" diff --git a/src/modules/score.h b/src/modules/score.h index 4fc1f52bb..00120605b 100644 --- a/src/modules/score.h +++ b/src/modules/score.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef SCORE_H #define SCORE_H diff --git a/src/modules/xmas.c b/src/modules/xmas.c index 15af966d6..9e6037cd8 100644 --- a/src/modules/xmas.c +++ b/src/modules/xmas.c @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #include #include #include "xmas.h" diff --git a/src/modules/xmas.h b/src/modules/xmas.h index f1f417622..34581e8a5 100644 --- a/src/modules/xmas.h +++ b/src/modules/xmas.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - #ifndef H_MOD_XMAS #define H_MOD_XMAS #ifdef __cplusplus diff --git a/src/monsters.c b/src/monsters.c index 24b3ec397..7cdebfd6c 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -1,22 +1,3 @@ -/* - * Eressea PB(E)M host Copyright (C) 1998-2019 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * based on: - * - * Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace - * Atlantis v1.7 Copyright 1996 by Alex Schroeder - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - * This program may not be sold or used commercially without prior written - * permission from the authors. - */ - #ifdef _MSC_VER #include #endif diff --git a/src/monsters.h b/src/monsters.h index 56f527d0a..81f7e39a3 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_GC_MONSTER #define H_GC_MONSTER diff --git a/src/morale.c b/src/morale.c index 5fd2c8205..1bb7a546f 100644 --- a/src/morale.c +++ b/src/morale.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "morale.h" diff --git a/src/morale.h b/src/morale.h index 09eab5c8b..dd5e1a9a7 100644 --- a/src/morale.h +++ b/src/morale.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_GC_MORALE #define H_GC_MORALE diff --git a/src/move.c b/src/move.c index 3bc4bc3df..a5438eb3d 100644 --- a/src/move.c +++ b/src/move.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/move.h b/src/move.h index d08a8211d..cbf154694 100644 --- a/src/move.h +++ b/src/move.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include "direction.h" #include diff --git a/src/names.c b/src/names.c index c1193d5f5..450fa9478 100644 --- a/src/names.c +++ b/src/names.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "names.h" diff --git a/src/names.h b/src/names.h index d7ab417c1..4beba2269 100644 --- a/src/names.h +++ b/src/names.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_NAMES #define H_KRNL_NAMES diff --git a/src/races/dragons.c b/src/races/dragons.c index c5fabd09f..de7b04086 100644 --- a/src/races/dragons.c +++ b/src/races/dragons.c @@ -1,15 +1,3 @@ -/* - * Eressea PB(E)M host Copyright (C) 1998-2019 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #include /* kernel includes */ diff --git a/src/races/races.c b/src/races/races.c index b5cc3772a..7c3e65fc4 100644 --- a/src/races/races.c +++ b/src/races/races.c @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2007 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #include #include "races.h" diff --git a/src/races/races.h b/src/races/races.h index 78c8b062f..395f2c3f8 100644 --- a/src/races/races.h +++ b/src/races/races.h @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2007 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #ifndef H_RACES #define H_RACES diff --git a/src/races/zombies.c b/src/races/zombies.c index 3227f621a..389f5e250 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -1,15 +1,3 @@ -/* - * Eressea PB(E)M host Copyright (C) 1998-2019 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #include /* kernel includes */ diff --git a/src/randenc.c b/src/randenc.c index 0011e5b0e..368a839e9 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/randenc.h b/src/randenc.h index 3814a520d..14f957f6c 100644 --- a/src/randenc.h +++ b/src/randenc.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_GC_RANDENC #define H_GC_RANDENC #ifdef __cplusplus diff --git a/src/recruit.c b/src/recruit.c index 2dc3eb526..4f4be25b7 100644 --- a/src/recruit.c +++ b/src/recruit.c @@ -1,22 +1,3 @@ -/* -Copyright (c) 1998-2019, -Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/recruit.h b/src/recruit.h index 347ea99f9..f5a9c9695 100644 --- a/src/recruit.h +++ b/src/recruit.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #pragma once #ifndef H_GC_RECRUIT #define H_GC_RECRUIT diff --git a/src/report.c b/src/report.c index a6e55409d..38f27e327 100644 --- a/src/report.c +++ b/src/report.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/report.h b/src/report.h index ed31d179e..1e26e5ac1 100644 --- a/src/report.h +++ b/src/report.h @@ -1,15 +1,3 @@ -#pragma once -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ #ifndef H_GC_REPORT #define H_GC_REPORT diff --git a/src/reports.c b/src/reports.c index 7a3271b71..c690aa345 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/reports.h b/src/reports.h index 00b94c8a7..13ae89b87 100644 --- a/src/reports.h +++ b/src/reports.h @@ -1,22 +1,3 @@ -#pragma once -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_REPORTS #define H_KRNL_REPORTS diff --git a/src/settings.h b/src/settings.h index 498786be9..72c9bcc18 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #define RESOURCE_QUANTITY 0.5 #define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ diff --git a/src/spells.c b/src/spells.c index a16ec8573..3c6a9304a 100644 --- a/src/spells.c +++ b/src/spells.c @@ -1,16 +1,3 @@ -/* - * - * - * Eressea PB(E)M host Copyright (C) 1998-2019 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ #ifdef _MSC_VER #include #endif diff --git a/src/spells.h b/src/spells.h index 7d80e49c6..5a82d5b6f 100644 --- a/src/spells.h +++ b/src/spells.h @@ -1,17 +1,3 @@ -/* - * - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #ifndef H_SPL_SPELLS #define H_SPL_SPELLS diff --git a/src/spells/buildingcurse.c b/src/spells/buildingcurse.c index b25abef34..496692616 100644 --- a/src/spells/buildingcurse.c +++ b/src/spells/buildingcurse.c @@ -1,16 +1,3 @@ -/* - * - * Eressea PB(E)M host Copyright (C) 1998-2019 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #include #include "buildingcurse.h" diff --git a/src/spells/buildingcurse.h b/src/spells/buildingcurse.h index 03fc46a63..3db013a01 100644 --- a/src/spells/buildingcurse.h +++ b/src/spells/buildingcurse.h @@ -1,16 +1,3 @@ -/* - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #ifndef _BCURSE_H #define _BCURSE_H #include diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index e8a1be274..51059b546 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -1,14 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ #ifdef _MSC_VER #include #endif diff --git a/src/spells/combatspells.h b/src/spells/combatspells.h index 91da5cdeb..c8bbc3c9c 100644 --- a/src/spells/combatspells.h +++ b/src/spells/combatspells.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef H_GC_COMBATSPELLS #define H_GC_COMBATSPELLS diff --git a/src/spells/regioncurse.c b/src/spells/regioncurse.c index 35a09a515..48565789e 100644 --- a/src/spells/regioncurse.c +++ b/src/spells/regioncurse.c @@ -1,16 +1,3 @@ -/* - * - * Eressea PB(E)M host Copyright (C) 1998-2019 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #include #include "regioncurse.h" #include "magic.h" diff --git a/src/spells/regioncurse.h b/src/spells/regioncurse.h index 467c1fb57..b1425daf0 100644 --- a/src/spells/regioncurse.h +++ b/src/spells/regioncurse.h @@ -1,16 +1,3 @@ -/* - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #ifndef _RCURSE_H #define _RCURSE_H #ifdef __cplusplus diff --git a/src/spells/shipcurse.c b/src/spells/shipcurse.c index 278e1ec93..834455635 100644 --- a/src/spells/shipcurse.c +++ b/src/spells/shipcurse.c @@ -1,16 +1,3 @@ -/* - * - * Eressea PB(E)M host Copyright (C) 1998-2019 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #include #include "shipcurse.h" diff --git a/src/spells/shipcurse.h b/src/spells/shipcurse.h index 8bb98bcbe..0a4d8c821 100644 --- a/src/spells/shipcurse.h +++ b/src/spells/shipcurse.h @@ -1,15 +1,3 @@ -/* - * Eressea PB(E)M host Copyright (C) 1998-2015 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #ifndef _SCURSE_H #define _SCURSE_H diff --git a/src/spells/unitcurse.c b/src/spells/unitcurse.c index c3f0e05c2..095649562 100644 --- a/src/spells/unitcurse.c +++ b/src/spells/unitcurse.c @@ -1,16 +1,3 @@ -/* - * - * Eressea PB(E)M host Copyright (C) 1998-2019 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #include #include "unitcurse.h" diff --git a/src/spells/unitcurse.h b/src/spells/unitcurse.h index 681fa32de..5a842e8ca 100644 --- a/src/spells/unitcurse.h +++ b/src/spells/unitcurse.h @@ -1,16 +1,3 @@ -/* - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - #ifndef _UCURSE_H #define _UCURSE_H diff --git a/src/spy.c b/src/spy.c index e1e65ef95..c4752ff72 100644 --- a/src/spy.c +++ b/src/spy.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/spy.h b/src/spy.h index b0bd7ae0e..51a655cd3 100644 --- a/src/spy.h +++ b/src/spy.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_SPY #define H_KRNL_SPY #ifdef __cplusplus diff --git a/src/steal.c b/src/steal.c index 08fd352db..b93a283f0 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/study.c b/src/study.c index 9b647e2ec..802fc5fe1 100644 --- a/src/study.c +++ b/src/study.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/study.h b/src/study.h index c1d44ed7b..6fed0c50d 100644 --- a/src/study.h +++ b/src/study.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_KRNL_STUDY #define H_KRNL_STUDY diff --git a/src/summary.c b/src/summary.c index 1e3ddbedf..de20f2dae 100644 --- a/src/summary.c +++ b/src/summary.c @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2007 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #ifdef _MSC_VER #include #endif diff --git a/src/summary.h b/src/summary.h index 22832e4cb..8118a7612 100644 --- a/src/summary.h +++ b/src/summary.h @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2007 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #ifndef H_GC_SUMMARY #define H_GC_SUMMARY diff --git a/src/teleport.c b/src/teleport.c index 66315d52b..84e4afe90 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "teleport.h" diff --git a/src/teleport.h b/src/teleport.h index 153c0114b..416b6b406 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef TELEPORT_H #define TELEPORT_H diff --git a/src/tools/atoi36.c b/src/tools/atoi36.c index a0ddaad04..e71cbbe13 100644 --- a/src/tools/atoi36.c +++ b/src/tools/atoi36.c @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2001 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - #include #include #include diff --git a/src/tools/namegen.c b/src/tools/namegen.c index 1ef9b7bb7..9bf69be08 100644 --- a/src/tools/namegen.c +++ b/src/tools/namegen.c @@ -1,16 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2001 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ - #include #include #include diff --git a/src/travelthru.c b/src/travelthru.c index 419c71046..9d984a16e 100644 --- a/src/travelthru.c +++ b/src/travelthru.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 91703c552..36e40ed46 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "changefaction.h" diff --git a/src/triggers/changefaction.h b/src/triggers/changefaction.h index 6ef2cc735..4a847a009 100644 --- a/src/triggers/changefaction.h +++ b/src/triggers/changefaction.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef CHANGEFACTION_H #define CHANGEFACTION_H #ifdef __cplusplus diff --git a/src/triggers/changerace.c b/src/triggers/changerace.c index 0e5498663..173b20d77 100644 --- a/src/triggers/changerace.c +++ b/src/triggers/changerace.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "changerace.h" diff --git a/src/triggers/changerace.h b/src/triggers/changerace.h index e6b19dcb0..950f04784 100644 --- a/src/triggers/changerace.h +++ b/src/triggers/changerace.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef CHANGERACE_H #define CHANGERACE_H #ifdef __cplusplus diff --git a/src/triggers/clonedied.c b/src/triggers/clonedied.c index 861972c1f..500104ba1 100644 --- a/src/triggers/clonedied.c +++ b/src/triggers/clonedied.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "clonedied.h" diff --git a/src/triggers/clonedied.h b/src/triggers/clonedied.h index ae93324c3..68f810399 100644 --- a/src/triggers/clonedied.h +++ b/src/triggers/clonedied.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef CLONEDIED_H #define CLONEDIED_H #ifdef __cplusplus diff --git a/src/triggers/createcurse.c b/src/triggers/createcurse.c index 4db37a738..760834a3d 100644 --- a/src/triggers/createcurse.c +++ b/src/triggers/createcurse.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "createcurse.h" diff --git a/src/triggers/createcurse.h b/src/triggers/createcurse.h index c3602ec6a..606a8802c 100644 --- a/src/triggers/createcurse.h +++ b/src/triggers/createcurse.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef CREATECURSE_H #define CREATECURSE_H #ifdef __cplusplus diff --git a/src/triggers/createunit.c b/src/triggers/createunit.c index bdb8662e0..d9437c87b 100644 --- a/src/triggers/createunit.c +++ b/src/triggers/createunit.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "createunit.h" diff --git a/src/triggers/createunit.h b/src/triggers/createunit.h index d2337d306..c4c24e7e6 100644 --- a/src/triggers/createunit.h +++ b/src/triggers/createunit.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef CREATEUNIT_H #define CREATEUNIT_H #ifdef __cplusplus diff --git a/src/triggers/gate.c b/src/triggers/gate.c index 0218f6a3c..5b541b80b 100644 --- a/src/triggers/gate.c +++ b/src/triggers/gate.c @@ -1,14 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ #include #include "gate.h" diff --git a/src/triggers/gate.h b/src/triggers/gate.h index 297393d70..52e4c8449 100644 --- a/src/triggers/gate.h +++ b/src/triggers/gate.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef GATE_H #define GATE_H #ifdef __cplusplus diff --git a/src/triggers/giveitem.c b/src/triggers/giveitem.c index 6e7a7a77b..1664c1d3a 100644 --- a/src/triggers/giveitem.c +++ b/src/triggers/giveitem.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "giveitem.h" diff --git a/src/triggers/giveitem.h b/src/triggers/giveitem.h index eab4473b4..9b1abe74d 100644 --- a/src/triggers/giveitem.h +++ b/src/triggers/giveitem.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef GIVEITEM_H #define GIVEITEM_H #ifdef __cplusplus diff --git a/src/triggers/killunit.c b/src/triggers/killunit.c index 0e49d90e2..5f221350e 100644 --- a/src/triggers/killunit.c +++ b/src/triggers/killunit.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "killunit.h" diff --git a/src/triggers/killunit.h b/src/triggers/killunit.h index a32b749f4..bdfebeada 100644 --- a/src/triggers/killunit.h +++ b/src/triggers/killunit.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef KILLUNIT_H #define KILLUNIT_H #ifdef __cplusplus diff --git a/src/triggers/shock.c b/src/triggers/shock.c index a8b4774fa..b45eeb90b 100644 --- a/src/triggers/shock.c +++ b/src/triggers/shock.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER # include #endif diff --git a/src/triggers/shock.h b/src/triggers/shock.h index 612e2d1bd..0af36b352 100644 --- a/src/triggers/shock.h +++ b/src/triggers/shock.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_TRG_SHOCK_H #define H_TRG_SHOCK_H #ifdef __cplusplus diff --git a/src/triggers/timeout.c b/src/triggers/timeout.c index d9adda4dc..fa4cbc46b 100644 --- a/src/triggers/timeout.c +++ b/src/triggers/timeout.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "timeout.h" diff --git a/src/triggers/timeout.h b/src/triggers/timeout.h index 831bc737d..dc8c22d92 100644 --- a/src/triggers/timeout.h +++ b/src/triggers/timeout.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_TRG_TIMEOUT_H #define H_TRG_TIMEOUT_H #ifdef __cplusplus diff --git a/src/triggers/triggers.c b/src/triggers/triggers.c index 67e36381a..ea592b9af 100644 --- a/src/triggers/triggers.c +++ b/src/triggers/triggers.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include /* triggers includes */ diff --git a/src/triggers/triggers.h b/src/triggers/triggers.h index a5b478687..993b1e18a 100644 --- a/src/triggers/triggers.h +++ b/src/triggers/triggers.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_TRG_TRIGGERS #define H_TRG_TRIGGERS #ifdef __cplusplus diff --git a/src/util/base36.c b/src/util/base36.c index ec41991d8..85f2cc80d 100644 --- a/src/util/base36.c +++ b/src/util/base36.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "base36.h" #include "log.h" diff --git a/src/util/base36.h b/src/util/base36.h index ef08094b2..f07f64247 100644 --- a/src/util/base36.h +++ b/src/util/base36.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_UTIL_BASE36 #define H_UTIL_BASE36 diff --git a/src/util/crmessage.c b/src/util/crmessage.c index e59ea474a..ec5016743 100644 --- a/src/util/crmessage.c +++ b/src/util/crmessage.c @@ -1,16 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ - #include #include "crmessage.h" diff --git a/src/util/crmessage.h b/src/util/crmessage.h index 3cd71d71c..0d88baad3 100644 --- a/src/util/crmessage.h +++ b/src/util/crmessage.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef H_UTIL_CRMESSAGE #define H_UTIL_CRMESSAGE diff --git a/src/util/dice.c b/src/util/dice.c index 6fa50261d..2e4cc7e11 100644 --- a/src/util/dice.c +++ b/src/util/dice.c @@ -1,22 +1,3 @@ -/* -Copyright (c) 2010-2015, Enno Rehling , -Christian Schlittchen , -Katja Zedel , -Henning Peters - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "rng.h" diff --git a/src/util/filereader.h b/src/util/filereader.h index a80afa65f..53c24f697 100644 --- a/src/util/filereader.h +++ b/src/util/filereader.h @@ -1,12 +1,3 @@ -/* -* +-------------------+ Christian Schlittchen -* | | Enno Rehling -* | Eressea PBEM host | Katja Zedel -* | (c) 1998 - 2005 | -* | | This program may not be used, modified or distributed -* +-------------------+ without prior permission by the authors of Eressea. -* -*/ #ifndef UTIL_FILEREADER_H #define UTIL_FILEREADER_H diff --git a/src/util/functions.c b/src/util/functions.c index f7f7544d9..b554e844b 100644 --- a/src/util/functions.c +++ b/src/util/functions.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "functions.h" diff --git a/src/util/functions.h b/src/util/functions.h index 944ce0466..41166ffe7 100644 --- a/src/util/functions.h +++ b/src/util/functions.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef FUNCTIONS_H #define FUNCTIONS_H #ifdef __cplusplus diff --git a/src/util/goodies.c b/src/util/goodies.c index 1c115a207..927250b8a 100644 --- a/src/util/goodies.c +++ b/src/util/goodies.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "goodies.h" diff --git a/src/util/goodies.h b/src/util/goodies.h index bb3a372f6..1ba1f92ac 100644 --- a/src/util/goodies.h +++ b/src/util/goodies.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef GOODIES_H #define GOODIES_H diff --git a/src/util/language.c b/src/util/language.c index 18548162f..f7894ac4e 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/util/language.h b/src/util/language.h index 735fd4a95..fce6bbebd 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef MY_LOCALE_H #define MY_LOCALE_H diff --git a/src/util/lists.c b/src/util/lists.c index 21caa7d86..52eabbc8b 100644 --- a/src/util/lists.c +++ b/src/util/lists.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTH19ER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #endif diff --git a/src/util/lists.h b/src/util/lists.h index ac6c4a7eb..5ae753b3e 100644 --- a/src/util/lists.h +++ b/src/util/lists.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef LISTS_H #define LISTS_H #ifdef __cplusplus diff --git a/src/util/log.c b/src/util/log.c index 8f0d81b6d..47bf09320 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -1,14 +1,3 @@ -/* -+-------------------+ Christian Schlittchen -| | Enno Rehling -| Eressea PBEM host | Katja Zedel -| (c) 1998 - 2003 | Henning Peters -| | Ingo Wilken -+-------------------+ Stefan Reich - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ #include #include "log.h" diff --git a/src/util/log.h b/src/util/log.h index 98a0d3af6..ce254c406 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -1,14 +1,3 @@ -/* -+-------------------+ Christian Schlittchen -| | Enno Rehling -| Eressea PBEM host | Katja Zedel -| (c) 1998 - 2003 | Henning Peters -| | Ingo Wilken -+-------------------+ Stefan Reich - -This program may not be used, modified or distributed -without prior permission by the authors of Eressea. -*/ #ifndef H_UTIL_LOG #define H_UTIL_LOG #ifdef __cplusplus diff --git a/src/util/message.c b/src/util/message.c index 6eb1b9a16..38254958b 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -1,16 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ - #ifdef _MSC_VER #include #endif diff --git a/src/util/message.h b/src/util/message.h index 52b087203..73d808a2d 100644 --- a/src/util/message.h +++ b/src/util/message.h @@ -1,14 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ #ifndef H_MESSAGE_H #define H_MESSAGE_H diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index 564abecb7..b84da36e4 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -1,16 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - - */ - #include #include "nrmessage.h" diff --git a/src/util/nrmessage.h b/src/util/nrmessage.h index 15914841b..316a43007 100644 --- a/src/util/nrmessage.h +++ b/src/util/nrmessage.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef H_UTIL_NRMESSAGE #define H_UTIL_NRMESSAGE diff --git a/src/util/order_parser.h b/src/util/order_parser.h index 159fd6594..d8643063d 100644 --- a/src/util/order_parser.h +++ b/src/util/order_parser.h @@ -1,14 +1,3 @@ -#pragma once -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2007 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #ifndef UTIL_ORDER_PARSER_H #define UTIL_ORDER_PARSER_H diff --git a/src/util/parser.h b/src/util/parser.h index 329d6f654..a08133775 100644 --- a/src/util/parser.h +++ b/src/util/parser.h @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2007 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #ifndef UTIL_PARSER_H #define UTIL_PARSER_H diff --git a/src/util/rand.c b/src/util/rand.c index e76f30925..a14f1def4 100644 --- a/src/util/rand.c +++ b/src/util/rand.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "rand.h" #include "mtrand.h" diff --git a/src/util/rand.h b/src/util/rand.h index e9d9062b7..b659a68d3 100644 --- a/src/util/rand.h +++ b/src/util/rand.h @@ -1,22 +1,4 @@ #pragma once -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef RAND_H #define RAND_H diff --git a/src/util/resolve.c b/src/util/resolve.c index 589707f46..4c61a22d3 100644 --- a/src/util/resolve.c +++ b/src/util/resolve.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include diff --git a/src/util/resolve.h b/src/util/resolve.h index ef33fd67d..ed9d037a9 100644 --- a/src/util/resolve.h +++ b/src/util/resolve.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef RESOLVE_H #define RESOLVE_H diff --git a/src/util/rng.h b/src/util/rng.h index c16433200..9c619b42e 100644 --- a/src/util/rng.h +++ b/src/util/rng.h @@ -1,12 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2005 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ #ifndef UTIL_RNG_H #define UTIL_RNG_H diff --git a/src/util/strings.c b/src/util/strings.c index 7a2739650..775b8cda3 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifdef _MSC_VER #include #undef HAVE__ITOA diff --git a/src/util/strings.h b/src/util/strings.h index a381b56b9..b30a3f840 100644 --- a/src/util/strings.h +++ b/src/util/strings.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef STRINGS_H #define STRINGS_H diff --git a/src/util/translation.c b/src/util/translation.c index 44f252790..3d794d920 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -1,14 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ #ifdef _MSC_VER #include #endif diff --git a/src/util/translation.h b/src/util/translation.h index 76206021b..c7de9a2b0 100644 --- a/src/util/translation.h +++ b/src/util/translation.h @@ -1,15 +1,3 @@ -/* - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #ifndef H_UTIL_TRANSLATION #define H_UTIL_TRANSLATION diff --git a/src/util/umlaut.c b/src/util/umlaut.c index 33facc0aa..46e901994 100644 --- a/src/util/umlaut.c +++ b/src/util/umlaut.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include "umlaut.h" diff --git a/src/util/umlaut.h b/src/util/umlaut.h index d64df7609..a6178a87f 100644 --- a/src/util/umlaut.h +++ b/src/util/umlaut.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef _UMLAUT_H #define _UMLAUT_H diff --git a/src/util/unicode.c b/src/util/unicode.c index d09476318..e87c27fc3 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -1,13 +1,3 @@ -/* - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2007 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - #include #include "unicode.h" diff --git a/src/util/unicode.h b/src/util/unicode.h index c03e83686..a277b0db3 100644 --- a/src/util/unicode.h +++ b/src/util/unicode.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef _UNICODE_H #define _UNICODE_H diff --git a/src/volcano.c b/src/volcano.c index 1e117b567..1c9d9a320 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2019, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #include #include #include "volcano.h" diff --git a/src/volcano.h b/src/volcano.h index c72801cce..0ec72523e 100644 --- a/src/volcano.h +++ b/src/volcano.h @@ -1,22 +1,3 @@ -#pragma once -/* -Copyright (c) 1998-2015, Enno Rehling -Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_GC_VOLCANO #define H_GC_VOLCANO diff --git a/src/wormhole.c b/src/wormhole.c index 2f94b008e..22f2e3d8b 100644 --- a/src/wormhole.c +++ b/src/wormhole.c @@ -1,15 +1,3 @@ -/* - +-------------------+ - | | Christian Schlittchen - | Eressea PBEM host | Enno Rehling - | (c) 1998 - 2004 | Katja Zedel - | | - +-------------------+ - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. - */ - #include #include diff --git a/src/wormhole.h b/src/wormhole.h index 783b59983..2c799ee9d 100644 --- a/src/wormhole.h +++ b/src/wormhole.h @@ -1,21 +1,3 @@ -/* -Copyright (c) 1998-2015, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -**/ - #ifndef H_MOD_WORMHOLE #define H_MOD_WORMHOLE #ifdef __cplusplus From 0a1fc3c53091c9ad808f785f01a9f6347d08236b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 13 Sep 2019 21:42:46 +0200 Subject: [PATCH 07/72] New license is CC BY-NC-SA --- LICENSE | 15 --------------- LICENSE.md | 5 +++++ 2 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 LICENSE create mode 100644 LICENSE.md diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 00ab17b3d..000000000 --- a/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 000000000..debd2a9a1 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,5 @@ +Copyright (c) 1998-2019, Enno Rehling + +Eressea is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + +* [![License Text](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-nc-sa/4.0/) From 8fc0aaf98d92cc5e2bb119f64e88b339d207439e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 13 Sep 2019 21:45:23 +0200 Subject: [PATCH 08/72] Add license to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7d9c4424d..46679d755 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,4 @@ If you got this far and all went well, you have built a server (it is linked fro * [![Static Analysis](https://scan.coverity.com/projects/6742/badge.svg?flat=1)](https://scan.coverity.com/projects/6742/) * [![Build Status](https://api.travis-ci.org/eressea/server.svg?branch=develop)](https://travis-ci.org/eressea/server) +* [![License: CC BY-NC-SA 4.0](https://licensebuttons.net/l/by-nc-sa/4.0/80x15.png)](http://creativecommons.org/licenses/by-nc-sa/4.0/) From f30a7848a551843cdc7f94afb88c6826023c29fd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 24 Aug 2019 12:14:43 +0200 Subject: [PATCH 09/72] rule_give is crufty, do not involve it in destroyfaction --- src/kernel/config.c | 1 + src/kernel/unit.c | 10 ---------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 4075621f3..9858e2f8b 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -516,6 +516,7 @@ int rule_give(void) static int config; static int rule; if (config_changed(&config)) { + /* TODO: No game uses this. Eliminate? */ rule = config_get_int("rules.give.flags", GIVE_DEFAULT); } return rule; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 9933899ed..f8e737587 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -221,19 +221,9 @@ int gift_items(unit * u, int flags) region *r = u->region; item **itm_p = &u->items; int retval = 0; - int rule = rule_give(); assert(u->region); - if ((rule & GIVE_ONDEATH) == 0 || !u->faction || (u->faction->flags & FFL_QUIT) == 0) { - if ((rule & GIVE_ALLITEMS) == 0 && (flags & GIFT_FRIENDS)) - flags -= GIFT_FRIENDS; - if ((rule & GIVE_PEASANTS) == 0 && (flags & GIFT_PEASANTS)) - flags -= GIFT_PEASANTS; - if ((rule & GIVE_SELF) == 0 && (flags & GIFT_SELF)) - flags -= GIFT_SELF; - } - if (u->items == NULL || fval(u_race(u), RCF_ILLUSIONARY)) return 0; From bfd29a4d172d7c3f2bf072bc852dd411412cb0b9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 13 Sep 2019 22:03:40 +0200 Subject: [PATCH 10/72] clibs update --- clibs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clibs b/clibs index 1854780fe..f8969f44d 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit 1854780fe3073e491775836c22f709668b1fff62 +Subproject commit f8969f44de1ec413cfee82b23c9f4b3c32d49b56 From 434aa15b9afd4df474ba7e0b1d0428215faa608c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 14 Sep 2019 21:51:13 +0200 Subject: [PATCH 11/72] factions that idle out gift their stuff to friends --- src/kernel/faction.c | 5 ++--- src/spells/combatspells.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index b6bd02659..882c1333a 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -408,9 +408,6 @@ void destroyfaction(faction ** fp) f->next = dead_factions; dead_factions = f; - fset(f, FFL_QUIT); - f->_alive = false; - if (f->spellbook) { spellbook_clear(f->spellbook); free(f->spellbook); @@ -463,6 +460,8 @@ void destroyfaction(faction ** fp) setalliance(f, NULL); } + fset(f, FFL_QUIT); + f->_alive = false; funhash(f); /* units of other factions that were disguised as this faction diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index 51059b546..f4b8b6954 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -952,8 +952,7 @@ int sp_hero(struct castorder * co) } } - m = - msg_message("cast_hero_effect", "mage spell amount", fi->unit, sp, targets); + m = msg_message("cast_hero_effect", "mage spell amount", fi->unit, sp, targets); message_all(b, m); msg_release(m); From fef57d3fcfc0aa30472fbbb27febf6089da1ff6a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 14 Sep 2019 21:51:13 +0200 Subject: [PATCH 12/72] factions that idle out gift their stuff to friends --- scripts/tests/e2/allies.lua | 15 +++ scripts/tests/e2/init.lua | 1 + src/bind_faction.c | 217 +++++++++++++++++++++--------------- src/kernel/ally.c | 23 ++++ src/kernel/ally.h | 1 + src/kernel/faction.c | 5 +- src/spells/combatspells.c | 3 +- 7 files changed, 171 insertions(+), 94 deletions(-) create mode 100644 scripts/tests/e2/allies.lua diff --git a/scripts/tests/e2/allies.lua b/scripts/tests/e2/allies.lua new file mode 100644 index 000000000..d7164c74b --- /dev/null +++ b/scripts/tests/e2/allies.lua @@ -0,0 +1,15 @@ +require "lunit" + +module("tests.e2.allies", package.seeall, lunit.testcase) + +function test_get_set_ally() + local f1 = faction.create("human") + local f2 = faction.create("human") + + assert_equal(false, f1:get_ally(f2, "guard")) + f1:set_ally(f2, "guard", true) + assert_equal(true, f1:get_ally(f2, "guard")) + assert_equal(false, f1:get_ally(f2, "give")) + f1:set_ally(f2, "give", true) + assert_equal(true, f1:get_ally(f2, "give")) +end diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 28d7ebc9b..39178467b 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,4 +1,5 @@ require 'tests.e2.carts' +require 'tests.e2.allies' require 'tests.e2.quit' require 'tests.e2.movement' require 'tests.e2.astral' diff --git a/src/bind_faction.c b/src/bind_faction.c index f71e334d1..bb3de9d04 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -7,6 +7,7 @@ #include "bindings.h" #include "magic.h" +#include #include #include #include @@ -48,13 +49,13 @@ int tolua_factionlist_next(lua_State * L) static int tolua_faction_get_units(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); unit **unit_ptr = (unit **)lua_newuserdata(L, sizeof(unit *)); luaL_getmetatable(L, TOLUA_CAST "unit"); lua_setmetatable(L, -2); - *unit_ptr = self->units; + *unit_ptr = f->units; lua_pushcclosure(L, tolua_unitlist_nextf, 1); return 1; @@ -62,7 +63,7 @@ static int tolua_faction_get_units(lua_State * L) int tolua_faction_add_item(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char *iname = tolua_tostring(L, 2, NULL); int number = (int)tolua_tonumber(L, 3, 0); int result = -1; @@ -70,7 +71,7 @@ int tolua_faction_add_item(lua_State * L) if (iname != NULL) { const resource_type *rtype = rt_find(iname); if (rtype && rtype->itype) { - item *i = i_change(&self->items, rtype->itype, number); + item *i = i_change(&f->items, rtype->itype, number); result = i ? i->number : 0; } /* if (itype!=NULL) */ } @@ -80,38 +81,38 @@ int tolua_faction_add_item(lua_State * L) static int tolua_faction_get_maxheroes(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, maxheroes(self)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, maxheroes(f)); return 1; } static int tolua_faction_get_heroes(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, countheroes(self)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, countheroes(f)); return 1; } static int tolua_faction_get_score(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushnumber(L, (lua_Number)self->score); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushnumber(L, (lua_Number)f->score); return 1; } static int tolua_faction_get_id(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->no); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, f->no); return 1; } static int tolua_faction_set_id(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); int id = (int)tolua_tonumber(L, 2, 0); if (findfaction(id) == NULL) { - renumber_faction(self, id); + renumber_faction(f, id); lua_pushboolean(L, 1); } else { @@ -122,20 +123,20 @@ static int tolua_faction_set_id(lua_State * L) static int tolua_faction_get_magic(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushstring(L, magic_school[self->magiegebiet]); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushstring(L, magic_school[f->magiegebiet]); return 1; } static int tolua_faction_set_magic(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char *type = tolua_tostring(L, 2, NULL); int mtype; for (mtype = 0; mtype != MAXMAGIETYP; ++mtype) { if (strcmp(magic_school[mtype], type) == 0) { - self->magiegebiet = (magic_t)mtype; + f->magiegebiet = (magic_t)mtype; break; } } @@ -144,89 +145,89 @@ static int tolua_faction_set_magic(lua_State * L) static int tolua_faction_get_age(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->age); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, f->age); return 1; } static int tolua_faction_set_age(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); int age = (int)tolua_tonumber(L, 2, 0); - self->age = age; + f->age = age; return 0; } static int tolua_faction_get_flags(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->flags); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, f->flags); return 1; } static int tolua_faction_set_flags(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - int flags = (int)tolua_tonumber(L, 2, self->flags); - self->flags = flags; + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + int flags = (int)tolua_tonumber(L, 2, f->flags); + f->flags = flags; return 1; } static int tolua_faction_get_options(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->options); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, f->options); return 1; } static int tolua_faction_set_options(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - int options = (int)tolua_tonumber(L, 2, self->options); - self->options = options; + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + int options = (int)tolua_tonumber(L, 2, f->options); + f->options = options; return 1; } static int tolua_faction_get_lastturn(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->lastorders); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, f->lastorders); return 1; } static int tolua_faction_set_lastturn(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - if (self) { - self->lastorders = (int)tolua_tonumber(L, 2, self->lastorders); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + if (f) { + f->lastorders = (int)tolua_tonumber(L, 2, f->lastorders); } return 0; } static int tolua_faction_renumber(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); int no = (int)tolua_tonumber(L, 2, 0); - renumber_faction(self, no); + renumber_faction(f, no); return 0; } static int tolua_faction_addnotice(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char *str = tolua_tostring(L, 2, NULL); - addmessage(NULL, self, str, MSG_MESSAGE, ML_IMPORTANT); + addmessage(NULL, f, str, MSG_MESSAGE, ML_IMPORTANT); return 0; } static int tolua_faction_getkey(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char *name = tolua_tostring(L, 2, NULL); int flag = atoi36(name); - int value = key_get(self->attribs, flag); + int value = key_get(f->attribs, flag); if (value != 0) { lua_pushinteger(L, value); return 1; @@ -236,16 +237,16 @@ static int tolua_faction_getkey(lua_State * L) static int tolua_faction_setkey(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char *name = tolua_tostring(L, 2, NULL); int value = (int)tolua_tonumber(L, 3, 1); int flag = atoi36(name); if (value) { - key_set(&self->attribs, flag, value); + key_set(&f->attribs, flag, value); } else { - key_unset(&self->attribs, flag); + key_unset(&f->attribs, flag); } return 0; } @@ -269,14 +270,14 @@ static int tolua_faction_debug_messages(lua_State * L) static int tolua_faction_get_messages(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); int i = 1; mlist *ml; - if (!self->msgs) { + if (!f->msgs) { return 0; } lua_newtable(L); - for (ml = self->msgs->begin; ml; ml = ml->next, ++i) { + for (ml = f->msgs->begin; ml; ml = ml->next, ++i) { lua_pushnumber(L, i); lua_pushstring(L, ml->msg->type->name); lua_rawset(L, -3); @@ -285,11 +286,11 @@ static int tolua_faction_get_messages(lua_State * L) } static int tolua_faction_count_msg_type(lua_State *L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char *str = tolua_tostring(L, 2, NULL); int n = 0; - if (self->msgs) { - mlist * ml = self->msgs->begin; + if (f->msgs) { + mlist * ml = f->msgs->begin; while (ml) { if (strcmp(str, ml->msg->type->name) == 0) { ++n; @@ -330,9 +331,9 @@ static int tolua_faction_set_origin(lua_State * L) static int tolua_faction_get_origin(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); int x = 0, y = 0; - faction_getorigin(self, 0, &x, &y); + faction_getorigin(f, 0, &x, &y); lua_pushinteger(L, x); lua_pushinteger(L, y); @@ -380,48 +381,48 @@ static int tolua_faction_create(lua_State * L) static int tolua_faction_get_password(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, faction_getpassword(self)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, faction_getpassword(f)); return 1; } static int tolua_faction_set_password(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char * passw = tolua_tostring(L, 2, NULL); - faction_setpassword(self, + faction_setpassword(f, passw ? password_hash(passw, PASSWORD_DEFAULT) : NULL); return 0; } static int tolua_faction_get_email(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, faction_getemail(self)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, faction_getemail(f)); return 1; } static int tolua_faction_set_email(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - faction_setemail(self, tolua_tostring(L, 2, NULL)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + faction_setemail(f, tolua_tostring(L, 2, NULL)); return 0; } static int tolua_faction_get_locale(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, locale_name(self->locale)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, locale_name(f->locale)); return 1; } static int tolua_faction_set_locale(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char *name = tolua_tostring(L, 2, NULL); const struct locale *loc = get_locale(name); if (loc) { - self->locale = loc; + f->locale = loc; } else { tolua_pushstring(L, "invalid locale"); @@ -432,18 +433,18 @@ static int tolua_faction_set_locale(lua_State * L) static int tolua_faction_get_race(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, self->race->_name); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, f->race->_name); return 1; } static int tolua_faction_set_race(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); const char *name = tolua_tostring(L, 2, NULL); const race *rc = rc_find(name); if (rc != NULL) { - self->race = rc; + f->race = rc; } return 0; @@ -451,15 +452,15 @@ static int tolua_faction_set_race(lua_State * L) static int tolua_faction_get_name(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, faction_getname(self)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, faction_getname(f)); return 1; } static int tolua_faction_set_name(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - faction_setname(self, tolua_tostring(L, 2, NULL)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + faction_setname(f, tolua_tostring(L, 2, NULL)); return 0; } @@ -479,44 +480,78 @@ static int tolua_faction_set_uid(lua_State * L) static int tolua_faction_get_info(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, faction_getbanner(self)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, faction_getbanner(f)); return 1; } static int tolua_faction_set_info(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - faction_setbanner(self, tolua_tostring(L, 2, NULL)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + faction_setbanner(f, tolua_tostring(L, 2, NULL)); return 0; } -static int tolua_faction_get_alliance(lua_State * L) +static int tolua_faction_set_ally(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - tolua_pushusertype(L, f_get_alliance(self), TOLUA_CAST "alliance"); + faction *f1 = (faction *)tolua_tousertype(L, 1, NULL); + faction *f2 = (faction *)tolua_tousertype(L, 2, NULL); + const char *status = tolua_tostring(L, 3, NULL); + bool value = tolua_toboolean(L, 4, 1); + if (status) { + int flag = ally_status(status); + int flags = ally_get(f1->allies, f2); + if (value) { + flags |= flag; + } + else { + flags &= ~flag; + } + ally_set(&f1->allies, f2, flags); + } + return 0; +} + +static int tolua_faction_get_ally(lua_State * L) +{ + faction *f1 = (faction *)tolua_tousertype(L, 1, NULL); + faction *f2 = (faction *)tolua_tousertype(L, 2, NULL); + const char *status = tolua_tostring(L, 3, NULL); + if (f1 && f2 && status) { + int test = ally_status(status); + int flags = ally_get(f1->allies, f2); + lua_pushboolean(L, (test & flags) == test); + return 1; + } + return 0; +} + +static int tolua_faction_get_alliances(lua_State * L) +{ + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + tolua_pushusertype(L, f_get_alliance(f), TOLUA_CAST "alliance"); return 1; } static int tolua_faction_set_alliance(lua_State * L) { - struct faction *self = (struct faction *)tolua_tousertype(L, 1, NULL); + struct faction *f = (struct faction *)tolua_tousertype(L, 1, NULL); struct alliance *alli = (struct alliance *) tolua_tousertype(L, 2, NULL); - setalliance(self, alli); + setalliance(f, alli); return 0; } static int tolua_faction_get_items(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); item **item_ptr = (item **)lua_newuserdata(L, sizeof(item *)); luaL_getmetatable(L, TOLUA_CAST "item"); lua_setmetatable(L, -2); - *item_ptr = self->items; + *item_ptr = f->items; lua_pushcclosure(L, tolua_itemlist_next, 1); @@ -525,8 +560,8 @@ static int tolua_faction_get_items(lua_State * L) static int tolua_faction_tostring(lua_State * L) { - faction *self = (faction *)tolua_tousertype(L, 1, NULL); - lua_pushstring(L, factionname(self)); + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_pushstring(L, factionname(f)); return 1; } @@ -569,8 +604,6 @@ void tolua_faction_open(lua_State * L) tolua_faction_set_locale); tolua_variable(L, TOLUA_CAST "race", tolua_faction_get_race, tolua_faction_set_race); - tolua_variable(L, TOLUA_CAST "alliance", tolua_faction_get_alliance, - tolua_faction_set_alliance); tolua_variable(L, TOLUA_CAST "score", tolua_faction_get_score, NULL); tolua_variable(L, TOLUA_CAST "magic", tolua_faction_get_magic, tolua_faction_set_magic); @@ -582,6 +615,12 @@ void tolua_faction_open(lua_State * L) tolua_variable(L, TOLUA_CAST "lastturn", tolua_faction_get_lastturn, tolua_faction_set_lastturn); + tolua_variable(L, TOLUA_CAST "alliance", tolua_faction_get_alliances, + tolua_faction_set_alliance); + + tolua_function(L, TOLUA_CAST "set_ally", tolua_faction_set_ally); + tolua_function(L, TOLUA_CAST "get_ally", tolua_faction_get_ally); + tolua_function(L, TOLUA_CAST "get_origin", tolua_faction_get_origin); tolua_function(L, TOLUA_CAST "set_origin", tolua_faction_set_origin); tolua_function(L, TOLUA_CAST "normalize", tolua_faction_normalize); diff --git a/src/kernel/ally.c b/src/kernel/ally.c index 4ee6b0f57..300d64e15 100644 --- a/src/kernel/ally.c +++ b/src/kernel/ally.c @@ -185,6 +185,29 @@ static int ally_flag(const char *s, int help_mask) return 0; } +int ally_status(const char *s) +{ + if (strcmp(s, "give") == 0) { + return HELP_GIVE; + } + else if (strcmp(s, "fight") == 0) { + return HELP_FIGHT; + } + else if (strcmp(s, "money") == 0) { + return HELP_MONEY; + } + else if (strcmp(s, "travel") == 0) { + return HELP_TRAVEL; + } + else if (strcmp(s, "guard") == 0) { + return HELP_GUARD; + } + else if (strcmp(s, "all") == 0) { + return HELP_ALL; + } + return 0; +} + /** Specifies automatic alliance modes. * If this returns a value then the bits set are immutable between alliance * partners (faction::alliance) and cannot be changed with the HELP command. diff --git a/src/kernel/ally.h b/src/kernel/ally.h index c6cb8fe51..ac7ff6238 100644 --- a/src/kernel/ally.h +++ b/src/kernel/ally.h @@ -14,6 +14,7 @@ struct allies; extern struct attrib_type at_npcfaction; +int ally_status(const char *s); int ally_get(struct allies *al, const struct faction *f); void ally_set(struct allies **p_al, struct faction *f, int status); void write_allies(struct gamedata * data, const struct allies *alist); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index b6bd02659..882c1333a 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -408,9 +408,6 @@ void destroyfaction(faction ** fp) f->next = dead_factions; dead_factions = f; - fset(f, FFL_QUIT); - f->_alive = false; - if (f->spellbook) { spellbook_clear(f->spellbook); free(f->spellbook); @@ -463,6 +460,8 @@ void destroyfaction(faction ** fp) setalliance(f, NULL); } + fset(f, FFL_QUIT); + f->_alive = false; funhash(f); /* units of other factions that were disguised as this faction diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index 51059b546..f4b8b6954 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -952,8 +952,7 @@ int sp_hero(struct castorder * co) } } - m = - msg_message("cast_hero_effect", "mage spell amount", fi->unit, sp, targets); + m = msg_message("cast_hero_effect", "mage spell amount", fi->unit, sp, targets); message_all(b, m); msg_release(m); From fa3abe8c322405bd664f85f65370dadce76d6374 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Sep 2019 13:08:50 +0200 Subject: [PATCH 13/72] new bindings for allies. script to fix damage from bug 2608. --- scripts/fix-death.lua | 76 +++++++++++++++++++++++++++++++++++++ scripts/tests/e2/allies.lua | 17 ++++++++- src/bind_faction.c | 35 ++++++++++++++++- 3 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 scripts/fix-death.lua diff --git a/scripts/fix-death.lua b/scripts/fix-death.lua new file mode 100644 index 000000000..992af95d3 --- /dev/null +++ b/scripts/fix-death.lua @@ -0,0 +1,76 @@ +require 'config' + +eressea.read_game('1137.dat') + +local dead = {"cwz", "rama"} + + +local function list_items(f) + local items = {} + for u in f.units do + local r = u.region + for name in u.items do + local count = u:get_item(name) + if not items[r.id] then + items[r.id] = {} + end + if not items[r.id][name] then + items[r.id][name] = count + else + items[r.id][name] = items[r.id][name] + count + end + end + end + return items +end + +gifts = {} +info = {} + +for _, no in ipairs(dead) do + f = get_faction(no) + gifts[f.id] = list_items(f) + local allies = {} + for fno, as in pairs(f.allies) do + local f2 = get_faction(fno) + if f2:get_ally(f, 'give') then + allies[fno] = as + end + end + info[f.id] = { + ['name'] = f.name, + ['race'] = f.race, + ['allies'] = allies + } +end + +eressea.free_game() +eressea.read_game('1138.dat') + +newf = {} + +for fid, rlist in pairs(gifts) do + local name = "Erben von " . info[fid].name + local race = info[fid].race + local f = faction.create(race, "noreply@eressea.de") + f.name = name + f.age = 10 + f.lastturn = 1130 + table.insert(newf, f) + for rid, items in pairs(rlist) do + local r = get_region_by_id(rid) + local u = unit.create(f, r, 1) + for name, count in pairs(items) do + u:add_item(name, count) + end + end + for fno, as in pairs(info[fid].allies) do + local f2 = get_faction(fno) + for _, s in ipairs(as) do + f:set_ally(f2, s) + end + f2:set_ally(f, "give") + end +end + +eressea.write_game('1138.new.dat') diff --git a/scripts/tests/e2/allies.lua b/scripts/tests/e2/allies.lua index d7164c74b..9f86e5f7c 100644 --- a/scripts/tests/e2/allies.lua +++ b/scripts/tests/e2/allies.lua @@ -2,7 +2,7 @@ require "lunit" module("tests.e2.allies", package.seeall, lunit.testcase) -function test_get_set_ally() +function skip_test_get_set_ally() local f1 = faction.create("human") local f2 = faction.create("human") @@ -13,3 +13,18 @@ function test_get_set_ally() f1:set_ally(f2, "give", true) assert_equal(true, f1:get_ally(f2, "give")) end + +function test_get_allies() + local f1 = faction.create("human") + local f2 = faction.create("human") + + local allies = f1.allies + assert_equal('table', type(allies)) + assert_equal(0, #allies) + f1:set_ally(f2, "give", true) + allies = f1.allies + assert_not_nil(1, table.getn(allies)) + assert_equal('table', type(allies[f2.id])) + assert_equal(1, #allies[f2.id]) + assert_equal("give", allies[f2.id][1]) +end diff --git a/src/bind_faction.c b/src/bind_faction.c index bb3de9d04..fd6983f0d 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -492,8 +492,38 @@ static int tolua_faction_set_info(lua_State * L) return 0; } -static int tolua_faction_set_ally(lua_State * L) -{ +/* TODO: this is probably useful elsewhere */ +static const char *status_names[] = { + "money", "fight", "observe", "give", "guard", "stealth", "travel", NULL +}; + +static int cb_ally_push(struct allies *af, struct faction *f, int status, void *udata) { + struct lua_State *L = (struct lua_State *)udata; + int len = 1; + int i; + + lua_pushnumber(L, f->no); + lua_newtable(L); + for (i = 0; status_names[i]; ++i) { + int flag = 1 << i; + if (status & flag) { + lua_pushstring(L, status_names[i]); + lua_rawseti(L, -2, len++); + } + } + + lua_rawset(L, -3); + return 0; +} + +static int tolua_faction_get_allies(lua_State * L) { + faction *f = (faction *)tolua_tousertype(L, 1, NULL); + lua_newtable(L); + allies_walk(f->allies, cb_ally_push, L); + return 1; +} + +static int tolua_faction_set_ally(lua_State * L) { faction *f1 = (faction *)tolua_tousertype(L, 1, NULL); faction *f2 = (faction *)tolua_tousertype(L, 2, NULL); const char *status = tolua_tostring(L, 3, NULL); @@ -618,6 +648,7 @@ void tolua_faction_open(lua_State * L) tolua_variable(L, TOLUA_CAST "alliance", tolua_faction_get_alliances, tolua_faction_set_alliance); + tolua_variable(L, TOLUA_CAST "allies", tolua_faction_get_allies, NULL); tolua_function(L, TOLUA_CAST "set_ally", tolua_faction_set_ally); tolua_function(L, TOLUA_CAST "get_ally", tolua_faction_get_ally); From 52f08917d51a331ce7cdc613728e27246a6690dd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Sep 2019 13:37:04 +0200 Subject: [PATCH 14/72] getn is deprecated --- scripts/tests/e2/allies.lua | 2 +- src/bind_faction.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/tests/e2/allies.lua b/scripts/tests/e2/allies.lua index 9f86e5f7c..ef38a97bf 100644 --- a/scripts/tests/e2/allies.lua +++ b/scripts/tests/e2/allies.lua @@ -23,7 +23,7 @@ function test_get_allies() assert_equal(0, #allies) f1:set_ally(f2, "give", true) allies = f1.allies - assert_not_nil(1, table.getn(allies)) + assert_not_nil(allies[f2.id]) assert_equal('table', type(allies[f2.id])) assert_equal(1, #allies[f2.id]) assert_equal("give", allies[f2.id][1]) diff --git a/src/bind_faction.c b/src/bind_faction.c index fd6983f0d..56164785d 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -32,7 +32,10 @@ #include #include #include -#include +#include // for bool +#include // for puts + +struct allies; int tolua_factionlist_next(lua_State * L) { From 65689df308a463587f434961fab86a40432e802d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Sep 2019 14:12:18 +0200 Subject: [PATCH 15/72] quit faction is still disabled --- scripts/tests/e2/init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 39178467b..afe0ac5ad 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,6 +1,5 @@ require 'tests.e2.carts' require 'tests.e2.allies' -require 'tests.e2.quit' require 'tests.e2.movement' require 'tests.e2.astral' require 'tests.e2.spells' From 93e82fc6ae1820885af58b4cb68a6a99686b0c0b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Sep 2019 14:30:50 +0200 Subject: [PATCH 16/72] concat in Lua is not PHP --- scripts/fix-death.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fix-death.lua b/scripts/fix-death.lua index 992af95d3..8f0b52e08 100644 --- a/scripts/fix-death.lua +++ b/scripts/fix-death.lua @@ -50,7 +50,7 @@ eressea.read_game('1138.dat') newf = {} for fid, rlist in pairs(gifts) do - local name = "Erben von " . info[fid].name + local name = "Erben von " .. info[fid].name local race = info[fid].race local f = faction.create(race, "noreply@eressea.de") f.name = name From ea9e31d1b2eea6463108886019bf1f4da906194c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 15 Sep 2019 20:32:07 +0200 Subject: [PATCH 17/72] tests for trolls riding on carts. --- scripts/tests/e2/carts.lua | 47 ++++++ src/bind_unit.c | 293 +++++++++++++++++++------------------ 2 files changed, 194 insertions(+), 146 deletions(-) diff --git a/scripts/tests/e2/carts.lua b/scripts/tests/e2/carts.lua index c2acbc25e..025b473df 100644 --- a/scripts/tests/e2/carts.lua +++ b/scripts/tests/e2/carts.lua @@ -185,3 +185,50 @@ function test_trolls_pull_carts() process_orders() assert_equal(r1, u1.region) end + +function test_trolls_with_horses() + local r0 = region.create(0, 0, "plain") + local r1 = region.create(1, 0, "plain") + local r2 = region.create(2, 0, "plain") + local r3 = region.create(3, 0, "plain") + local f = faction.create("troll") + -- 1. 20 trolls can pull 5 loaded carts: + local u1 = unit.create(f, r0, 20) + u1:add_item("cart", 5) + -- trolls carry 10.8 GE, carts carry 100 GE: + u1:add_item("money", 100 * (5 * 100 + 2 * 108)) + u1:add_order("NACH O O O") + + process_orders() + assert_equal(r1, u1.region) + + u1:add_item("horse", 20) + u1:add_item("money", 100 * 20 * 20) + process_orders() + assert_equal(r2, u1.region) +end + +function test_trolls_ride_carts() + local r0 = region.create(0, 0, "plain") + local r1 = region.create(1, 0, "plain") + local r2 = region.create(2, 0, "plain") + local r3 = region.create(3, 0, "plain") + local r4 = region.create(4, 0, "plain") + local f = faction.create("troll") + -- 1. 20 trolls can pull 5 loaded carts: + local u1 = unit.create(f, r0, 20) + u1:add_item("cart", 5) + -- but with 10 or more horses, they should ride in the cart: + u1:set_skill("riding", 1, true) + u1:add_item("horse", 10) + -- trolls weigh 20 GE, horses carry 20, carts carry 100 GE: + u1:add_item("money", 100 * (10 * 20 + 5 * 100 - u1.number * 20)) + u1:add_order("NACH O O O") + + process_orders() + assert_equal(r2, u1.region) + + u1:add_item("money", 1) -- just one wafer thin mint + process_orders() + assert_equal(r3, u1.region) -- can still walk +end diff --git a/src/bind_unit.c b/src/bind_unit.c index c5954082b..f12b60b55 100644 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -147,129 +147,129 @@ static int tolua_unit_get_group(lua_State * L) static int tolua_unit_set_group(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - group *g = join_group(self, tolua_tostring(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + group *g = join_group(u, tolua_tostring(L, 2, 0)); lua_pushboolean(L, g!=NULL); return 1; } static int tolua_unit_get_name(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushstring(L, unit_getname(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushstring(L, unit_getname(u)); return 1; } static int tolua_unit_set_name(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - unit_setname(self, tolua_tostring(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + unit_setname(u, tolua_tostring(L, 2, 0)); return 0; } static int tolua_unit_get_info(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushstring(L, unit_getinfo(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushstring(L, unit_getinfo(u)); return 1; } static int tolua_unit_set_info(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - unit_setinfo(self, tolua_tostring(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + unit_setinfo(u, tolua_tostring(L, 2, 0)); return 0; } static int tolua_unit_get_id(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, unit_getid(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, unit_getid(u)); return 1; } static int tolua_unit_set_id(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - unit_setid(self, (int)tolua_tonumber(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + unit_setid(u, (int)tolua_tonumber(L, 2, 0)); return 0; } static int tolua_unit_get_auramax(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, max_spellpoints_depr(self->region, self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, max_spellpoints_depr(u->region, u)); return 1; } static int tolua_unit_get_hpmax(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, unit_max_hp(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, unit_max_hp(u)); return 1; } static int tolua_unit_get_hp(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, unit_gethp(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, unit_gethp(u)); return 1; } static int tolua_unit_set_hp(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - unit_sethp(self, (int)tolua_tonumber(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + unit_sethp(u, (int)tolua_tonumber(L, 2, 0)); return 0; } static int tolua_unit_get_number(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, self->number); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, u->number); return 1; } static int tolua_unit_set_number(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); int number = (int)tolua_tonumber(L, 2, 0); - if (self->number == 0) { - set_number(self, number); - self->hp = unit_max_hp(self) * number; + if (u->number == 0) { + set_number(u, number); + u->hp = unit_max_hp(u) * number; } else { - scale_number(self, number); + scale_number(u, number); } return 0; } static int tolua_unit_get_flags(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, self->flags); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, u->flags); return 1; } static int tolua_unit_set_flags(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - self->flags = (int)tolua_tonumber(L, 2, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + u->flags = (int)tolua_tonumber(L, 2, 0); return 0; } static int tolua_unit_get_guard(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushboolean(L, is_guard(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushboolean(L, is_guard(u)); return 1; } static int tolua_unit_set_guard(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); unsigned int flags = (unsigned int)tolua_tonumber(L, 2, 0); - setguard(self, flags!=0); + setguard(u, flags!=0); return 0; } @@ -285,8 +285,8 @@ static const char *unit_getmagic(const unit * u) static int tolua_unit_get_magic(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushstring(L, unit_getmagic(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, unit_getmagic(u)); return 1; } @@ -306,64 +306,64 @@ static void unit_setmagic(unit * u, const char *type) static int tolua_unit_set_magic(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *type = tolua_tostring(L, 2, 0); - unit_setmagic(self, type); + unit_setmagic(u, type); return 0; } static int tolua_unit_get_aura(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, get_spellpoints(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, get_spellpoints(u)); return 1; } static int tolua_unit_set_aura(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - set_spellpoints(self, (int)tolua_tonumber(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + set_spellpoints(u, (int)tolua_tonumber(L, 2, 0)); return 0; } static int tolua_unit_get_age(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, self->age); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, u->age); return 1; } static int tolua_unit_set_age(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - self->age = (int)tolua_tonumber(L, 2, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + u->age = (int)tolua_tonumber(L, 2, 0); return 0; } static int tolua_unit_get_status(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, unit_getstatus(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, unit_getstatus(u)); return 1; } static int tolua_unit_set_status(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - unit_setstatus(self, (status_t)tolua_tonumber(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + unit_setstatus(u, (status_t)tolua_tonumber(L, 2, 0)); return 0; } static int tolua_unit_get_item(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *iname = tolua_tostring(L, 2, 0); int result = -1; if (iname != NULL) { const item_type *itype = it_find(iname); if (itype != NULL) { - result = i_get(self->items, itype); + result = i_get(u->items, itype); } } lua_pushinteger(L, result); @@ -372,13 +372,13 @@ static int tolua_unit_get_item(lua_State * L) static int tolua_unit_get_effect(lua_State * L) { - const unit *self = (unit *)tolua_tousertype(L, 1, 0); + const unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *potion_name = tolua_tostring(L, 2, 0); int result = -1; const item_type *it_potion = it_find(potion_name); if (it_potion != NULL) { - result = get_effect(self, it_potion); + result = get_effect(u, it_potion); } lua_pushinteger(L, result); @@ -387,7 +387,7 @@ static int tolua_unit_get_effect(lua_State * L) static int tolua_unit_add_item(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *iname = tolua_tostring(L, 2, 0); int number = (int)tolua_tonumber(L, 3, 0); int result = -1; @@ -395,7 +395,7 @@ static int tolua_unit_add_item(lua_State * L) if (iname != NULL) { const item_type *itype = it_find(iname); if (itype != NULL) { - item *i = i_change(&self->items, itype, number); + item *i = i_change(&u->items, itype, number); result = i ? i->number : 0; } } @@ -405,12 +405,12 @@ static int tolua_unit_add_item(lua_State * L) static int tolua_unit_getskill(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *skname = tolua_tostring(L, 2, 0); skill_t sk = findskill(skname); int value = -1; if (sk != NOSKILL) { - skill *sv = unit_skill(self, sk); + skill *sv = unit_skill(u, sk); if (sv) { value = sv->level; } @@ -423,10 +423,10 @@ static int tolua_unit_getskill(lua_State * L) static int tolua_unit_effskill(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *skname = tolua_tostring(L, 2, 0); skill_t sk = findskill(skname); - int value = (sk == NOSKILL) ? -1 : effskill(self, sk, NULL); + int value = (sk == NOSKILL) ? -1 : effskill(u, sk, NULL); lua_pushinteger(L, value); return 1; } @@ -438,10 +438,10 @@ typedef struct event { static int tolua_unit_addnotice(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *str = tolua_tostring(L, 2, 0); - addmessage(self->region, self->faction, str, MSG_MESSAGE, ML_IMPORTANT); + addmessage(u->region, u->faction, str, MSG_MESSAGE, ML_IMPORTANT); return 0; } @@ -475,11 +475,11 @@ static void unit_castspell(unit * u, const char *name, int level) static int tolua_unit_castspell(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *str = tolua_tostring(L, 2, 0); int level = (int)tolua_tonumber(L, 3, 1); - unit_castspell(self, str, level); + unit_castspell(u, str, level); return 0; } @@ -505,17 +505,17 @@ static int tolua_unit_addspell(lua_State * L) static int tolua_unit_set_racename(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *str = tolua_tostring(L, 2, 0); - set_racename(&self->attribs, str); + set_racename(&u->attribs, str); return 0; } static int tolua_unit_get_racename(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - attrib *a = a_find(self->attribs, &at_racename); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + attrib *a = a_find(u->attribs, &at_racename); if (a) { tolua_pushstring(L, get_racename(a)); return 1; @@ -525,29 +525,30 @@ static int tolua_unit_get_racename(lua_State * L) static int tolua_unit_setskill(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *skname = tolua_tostring(L, 2, 0); int level = (int)tolua_tonumber(L, 3, 0); + bool rcmod = tolua_toboolean(L, 4, 0); skill_t sk = findskill(skname); + + if (rcmod) level -= u_race(u)->bonus[sk]; if (sk != NOSKILL) { - set_level(self, sk, level); + set_level(u, sk, level); + lua_pushinteger(L, level); + return 1; } - else { - level = -1; - } - lua_pushinteger(L, level); - return 1; + return 0; } static int tolua_unit_use_pooled(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *iname = tolua_tostring(L, 2, 0); int number = (int)tolua_tonumber(L, 3, 0); const resource_type *rtype = rt_find(iname); int result = -1; if (rtype != NULL) { - result = use_pooled(self, rtype, GET_DEFAULT, number); + result = use_pooled(u, rtype, GET_DEFAULT, number); } lua_pushinteger(L, result); return 1; @@ -555,12 +556,12 @@ static int tolua_unit_use_pooled(lua_State * L) static int tolua_unit_get_pooled(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *iname = tolua_tostring(L, 2, 0); const resource_type *rtype = rt_find(iname); int result = -1; if (rtype != NULL) { - result = get_pooled(self, rtype, GET_DEFAULT, INT_MAX); + result = get_pooled(u, rtype, GET_DEFAULT, INT_MAX); } lua_pushinteger(L, result); return 1; @@ -577,8 +578,8 @@ static unit *unit_getfamiliar(const unit * u) static int tolua_unit_get_familiar(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, unit_getfamiliar(self), TOLUA_CAST "unit"); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, unit_getfamiliar(u), TOLUA_CAST "unit"); return 1; } @@ -597,8 +598,8 @@ static int tolua_unit_set_familiar(lua_State * L) static int tolua_unit_get_building(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, self->building, TOLUA_CAST "building"); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, u->building, TOLUA_CAST "building"); return 1; } @@ -622,8 +623,8 @@ static int tolua_unit_set_building(lua_State * L) static int tolua_unit_get_ship(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, self->ship, TOLUA_CAST "ship"); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, u->ship, TOLUA_CAST "ship"); return 1; } @@ -638,17 +639,17 @@ static void unit_setship(unit * u, ship * s) static int tolua_unit_set_ship(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - if (self->faction) { - unit_setship(self, (ship *)tolua_tousertype(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + if (u->faction) { + unit_setship(u, (ship *)tolua_tousertype(L, 2, 0)); } return 0; } static int tolua_unit_get_region(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, self->region, TOLUA_CAST "region"); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, u->region, TOLUA_CAST "region"); return 1; } @@ -659,29 +660,29 @@ static void unit_setregion(unit * u, region * r) static int tolua_unit_set_region(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - unit_setregion(self, (region *)tolua_tousertype(L, 2, 0)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + unit_setregion(u, (region *)tolua_tousertype(L, 2, 0)); return 0; } static int tolua_unit_get_order(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); int index = (int)tolua_tonumber(L, 2, -1); order *ord = NULL; if (index < 0) { - ord = self->thisorder; + ord = u->thisorder; } else { int i; - ord = self->orders; + ord = u->orders; for (i = 0; ord && i != index; ++i) { ord = ord->next; } } if (ord) { char buffer[1024]; - get_command(ord, self->faction->locale, buffer, sizeof(buffer)); + get_command(ord, u->faction->locale, buffer, sizeof(buffer)); lua_pushstring(L, buffer); return 1; } @@ -690,30 +691,30 @@ static int tolua_unit_get_order(lua_State * L) static int tolua_unit_add_order(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *str = tolua_tostring(L, 2, 0); - order *ord = parse_order(str, self->faction->locale); - unit_addorder(self, ord); + order *ord = parse_order(str, u->faction->locale); + unit_addorder(u, ord); return 0; } static int tolua_unit_clear_orders(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - free_orders(&self->orders); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + free_orders(&u->orders); return 0; } static int tolua_unit_get_items(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); item **item_ptr = (item **)lua_newuserdata(L, sizeof(item *)); luaL_getmetatable(L, TOLUA_CAST "item"); lua_setmetatable(L, -2); - *item_ptr = self->items; + *item_ptr = u->items; lua_pushcclosure(L, tolua_itemlist_next, 1); @@ -722,8 +723,8 @@ static int tolua_unit_get_items(lua_State * L) static int tolua_unit_get_spells(lua_State * L) { - unit *self = (unit *) tolua_tousertype(L, 1, 0); - struct sc_mage *mage = self ? get_mage(self) : NULL; + unit *u = (unit *) tolua_tousertype(L, 1, 0); + struct sc_mage *mage = u ? get_mage(u) : NULL; spellbook *sb = mage_get_spellbook(mage); selist *slist = 0; if (sb) { @@ -734,10 +735,10 @@ static int tolua_unit_get_spells(lua_State * L) } static int tolua_unit_get_curse(lua_State *L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); - if (self->attribs) { - curse * c = get_curse(self->attribs, ct_find(name)); + if (u->attribs) { + curse * c = get_curse(u->attribs, ct_find(name)); if (c) { lua_pushnumber(L, curse_geteffect(c)); return 1; @@ -747,9 +748,9 @@ static int tolua_unit_get_curse(lua_State *L) { } static int tolua_unit_has_attrib(lua_State *L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); - attrib * a = self->attribs; + attrib * a = u->attribs; while (a) { if (strcmp(a->type->name, name) == 0) { break; @@ -762,105 +763,105 @@ static int tolua_unit_has_attrib(lua_State *L) { static int tolua_unit_get_key(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); int flag = atoi36(name); - lua_pushboolean(L, key_get(self->attribs, flag)); + lua_pushboolean(L, key_get(u->attribs, flag)); return 1; } static int tolua_unit_set_key(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); int value = (int)tolua_tonumber(L, 3, 0); int flag = atoi36(name); if (value) { - key_set(&self->attribs, flag, value); + key_set(&u->attribs, flag, value); } else { - key_unset(&self->attribs, flag); + key_unset(&u->attribs, flag); } return 0; } static int tolua_unit_get_flag(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, NULL); + unit *u = (unit *)tolua_tousertype(L, 1, NULL); int bit = (int)tolua_tonumber(L, 2, 0); - lua_pushboolean(L, (self->flags & (1 << bit))); + lua_pushboolean(L, (u->flags & (1 << bit))); return 1; } static int tolua_unit_set_flag(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, NULL); + unit *u = (unit *)tolua_tousertype(L, 1, NULL); int bit = (int)tolua_tonumber(L, 2, 0); int set = tolua_toboolean(L, 3, 1); if (set) - self->flags |= (1 << bit); + u->flags |= (1 << bit); else - self->flags &= ~(1 << bit); + u->flags &= ~(1 << bit); return 0; } static int tolua_unit_get_weight(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, unit_getweight(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, unit_getweight(u)); return 1; } static int tolua_unit_get_capacity(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushinteger(L, unit_getcapacity(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushinteger(L, unit_getcapacity(u)); return 1; } static int tolua_unit_get_faction(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushusertype(L, (void *)self->faction, TOLUA_CAST "faction"); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushusertype(L, (void *)u->faction, TOLUA_CAST "faction"); return 1; } static int tolua_unit_set_faction(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); faction *f = (faction *)tolua_tousertype(L, 2, 0); - u_setfaction(self, f); + u_setfaction(u, f); return 0; } static int tolua_unit_get_race(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - tolua_pushstring(L, u_race(self)->_name); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + tolua_pushstring(L, u_race(u)->_name); return 1; } static int tolua_unit_set_race(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); + unit *u = (unit *)tolua_tousertype(L, 1, 0); const char *rcname = tolua_tostring(L, 2, 0); const race *rc = rc_find(rcname); if (rc != NULL) { - if (self->irace == u_race(self)) { - self->irace = NULL; + if (u->irace == u_race(u)) { + u->irace = NULL; } - u_setrace(self, rc); + u_setrace(u, rc); } return 0; } static int tolua_unit_destroy(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - if (self) { - remove_unit(&self->region->units, self); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + if (u) { + remove_unit(&u->region->units, u); } return 0; } @@ -884,25 +885,25 @@ static int tolua_unit_create(lua_State * L) static int tolua_unit_tostring(lua_State * L) { - unit *self = (unit *)tolua_tousertype(L, 1, 0); - lua_pushstring(L, unitname(self)); + unit *u = (unit *)tolua_tousertype(L, 1, 0); + lua_pushstring(L, unitname(u)); return 1; } static int tolua_event_gettype(lua_State * L) { - event *self = (event *)tolua_tousertype(L, 1, 0); + event *u = (event *)tolua_tousertype(L, 1, 0); int index = (int)tolua_tonumber(L, 2, 0); - lua_pushstring(L, self->args[index].type); + lua_pushstring(L, u->args[index].type); return 1; } static int tolua_event_get(lua_State * L) { - struct event *self = (struct event *)tolua_tousertype(L, 1, 0); + struct event *u = (struct event *)tolua_tousertype(L, 1, 0); int index = (int)tolua_tonumber(L, 2, 0); - event_arg *arg = self->args + index; + event_arg *arg = u->args + index; if (arg->type) { if (strcmp(arg->type, "string") == 0) { From d5104fa55a02186fc0abd2192a112da39b9150d8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 18 Sep 2019 20:55:44 +0200 Subject: [PATCH 18/72] Bug 2609 VERGESSE Magie --- src/economy.c | 18 +++++++++++++++--- src/kernel/faction.c | 2 +- src/kernel/unit.c | 11 +++++++++++ src/kernel/unit.h | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/economy.c b/src/economy.c index 1fd202369..b73845c06 100644 --- a/src/economy.c +++ b/src/economy.c @@ -282,9 +282,21 @@ static int forget_cmd(unit * u, order * ord) sk = get_skill(s, u->faction->locale); if (sk != NOSKILL) { - if (sk == SK_MAGIC && is_familiar(u)) { - /* some units cannot forget their innate magical abilities */ - return 0; + if (sk == SK_MAGIC) { + if (is_familiar(u)) { + /* some units cannot forget their innate magical abilities */ + return 0; + } + else { + unit *ufam = get_familiar(u); + if (ufam) { + a_removeall(&ufam->attribs, NULL); + u_setfaction(ufam, get_monsters()); + unit_convert_race(ufam, NULL, "ghost"); + } + a_removeall(&u->attribs, &at_mage); + a_removeall(&u->attribs, &at_familiar); + } } ADDMSG(&u->faction->msgs, msg_message("forget", "unit skill", u, sk)); set_level(u, sk, 0); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 882c1333a..81f2d42b1 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -395,7 +395,7 @@ void save_special_items(unit *usrc) /* some units have plural names, it would be neat if they aren't single: */ scale_number(u, 2); } - set_racename(&u->attribs, "ghost"); + unit_convert_race(u, rc_ghost, "ghost"); give_special_items(u, &usrc->items); } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index f8e737587..06463820c 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1833,3 +1833,14 @@ double u_heal_factor(const unit * u) } return 1.0; } + +void unit_convert_race(unit *u, const race *rc, const char *rcname) +{ + if (rc && u->_race != rc) { + u_setrace(u, rc); + } + if (rcname && strcmp(rcname, u->_race->_name) != 0) { + set_racename(&u->attribs, rcname); + } +} + diff --git a/src/kernel/unit.h b/src/kernel/unit.h index 3290c4f78..863dccd13 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -221,6 +221,7 @@ extern "C" { char *write_unitname(const struct unit *u, char *buffer, size_t size); bool unit_name_equals_race(const struct unit *u); + void unit_convert_race(struct unit *u, const struct race *rc, const char *rcname); /* getunit results: */ #define GET_UNIT 0 #define GET_NOTFOUND 1 From 17ba4e7746f25a2ac93a847a206685bd53bd5ab4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 19 Sep 2019 05:03:01 +0200 Subject: [PATCH 19/72] allow clearing attributes from lua --- src/bind_unit.c | 10 ++++++++++ src/gmtool.c | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/bind_unit.c b/src/bind_unit.c index c5954082b..afbd81afe 100644 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -746,6 +746,15 @@ static int tolua_unit_get_curse(lua_State *L) { return 0; } +static int tolua_unit_clear_attribs(lua_State *L) { + unit *u = (unit *)tolua_tousertype(L, 1, NULL); + const char *name = tolua_tostring(L, 2, NULL); + const attrib_type *at = name ? at_find(name) : NULL; + + a_removeall(&u->attribs, at); + return 0; +} + static int tolua_unit_has_attrib(lua_State *L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); @@ -978,6 +987,7 @@ void tolua_unit_open(lua_State * L) tolua_function(L, TOLUA_CAST "add_order", tolua_unit_add_order); tolua_function(L, TOLUA_CAST "clear_orders", tolua_unit_clear_orders); tolua_function(L, TOLUA_CAST "get_curse", tolua_unit_get_curse); + tolua_function(L, TOLUA_CAST "clear_attribs", tolua_unit_clear_attribs); tolua_function(L, TOLUA_CAST "has_attrib", tolua_unit_has_attrib); /* key-attributes for named flags: */ diff --git a/src/gmtool.c b/src/gmtool.c index 3c75fab7d..d876b22bd 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -441,16 +441,6 @@ static void paint_info_region(window * wnd, const state * st) r->land->trees[1] + r->land->trees[2]); } line++; - if (r->ships && (st->info_flags & IFL_SHIPS)) { - ship *sh; - wattron(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW)); - mvwaddnstr(win, line++, 1, "* ships:", size - 5); - wattroff(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW)); - for (sh = r->ships; sh && line < maxline; sh = sh->next) { - mvwprintw(win, line, 1, "%.4s ", itoa36(sh->no)); - umvwaddnstr(win, line++, 6, (char *)sh->type->_name, size - 5); - } - } if (r->units && (st->info_flags & IFL_FACTIONS)) { unit *u; wattron(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW)); @@ -477,6 +467,16 @@ static void paint_info_region(window * wnd, const state * st) umvwaddnstr(win, line++, 6, unit_getname(u), size - 5); } } + if (r->ships && (st->info_flags & IFL_SHIPS)) { + ship *sh; + wattron(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW)); + mvwaddnstr(win, line++, 1, "* ships:", size - 5); + wattroff(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW)); + for (sh = r->ships; sh && line < maxline; sh = sh->next) { + mvwprintw(win, line, 1, "%.4s ", itoa36(sh->no)); + umvwaddnstr(win, line++, 6, (char *)sh->type->_name, size - 5); + } + } } } From 8433052c649e3a79756edabbe35ea4a69e9babff Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 19 Sep 2019 05:05:13 +0200 Subject: [PATCH 20/72] CID 204092: Memory - illegal accesses (NEGATIVE_RETURNS) --- src/bind_unit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bind_unit.c b/src/bind_unit.c index 921dcc659..45b4d7d0a 100644 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -531,8 +531,8 @@ static int tolua_unit_setskill(lua_State * L) bool rcmod = tolua_toboolean(L, 4, 0); skill_t sk = findskill(skname); - if (rcmod) level -= u_race(u)->bonus[sk]; if (sk != NOSKILL) { + if (rcmod) level -= u_race(u)->bonus[sk]; set_level(u, sk, level); lua_pushinteger(L, level); return 1; From 6c73a58608316eb74925cb3f5f4fa91623654002 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Sep 2019 22:16:46 +0200 Subject: [PATCH 21/72] =?UTF-8?q?Bug=202607:=20BEnutze=20format=5Flist=20f?= =?UTF-8?q?=C3=BCr=20Schemen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clibs | 2 +- res/translations/strings.de.po | 19 ++++++++---- res/translations/strings.en.po | 19 ++++++++---- src/report.c | 53 ++++++++++++++++++++++------------ src/teleport.c | 28 +++++++++++++++++- src/teleport.h | 3 ++ 6 files changed, 93 insertions(+), 31 deletions(-) diff --git a/clibs b/clibs index f8969f44d..abe774f70 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f8969f44de1ec413cfee82b23c9f4b3c32d49b56 +Subproject commit abe774f70265de14ea7f5e530518ca130562a9c9 diff --git a/res/translations/strings.de.po b/res/translations/strings.de.po index 8c90d6657..68f126335 100644 --- a/res/translations/strings.de.po +++ b/res/translations/strings.de.po @@ -570,8 +570,20 @@ msgstr "Dieses Ritual, ausgeführt vor einem Kampf, verwirbelt die astralen Ener msgid "balloon" msgstr "Ballon" -msgid "nr_schemes_postfix" -msgstr "sind erkennbar." +msgid "nr_schemes_template" +msgstr "Schemen der Regionen {0} sind erkennbar." + +msgid "list_two" +msgstr "{0} und {1}" + +msgid "list_start" +msgstr "{0}, {1}" + +msgid "list_middle" +msgstr "{0}, {1}" + +msgid "list_end" +msgstr "{0} und {1}" msgid "SILBER" msgstr "SILBER" @@ -4408,9 +4420,6 @@ msgstr "Magie" msgid "see_lighthouse" msgstr "vom Turm erblickt" -msgid "nr_schemes_prefix" -msgstr "Schemen der Regionen" - msgid "aoc_p" msgstr "Katzenamulette" diff --git a/res/translations/strings.en.po b/res/translations/strings.en.po index 13badb9cb..36020a3f6 100644 --- a/res/translations/strings.en.po +++ b/res/translations/strings.en.po @@ -444,9 +444,6 @@ msgctxt "spellinfo" msgid "draigfumbleshield" msgstr "This ritual, performed before a battle, causes the astral energies on the battlefield to whirl and churn and thereby makes spellcasting more difficult for the enemy mages." -msgid "nr_schemes_postfix" -msgstr "can be discerned." - msgid "SILBER" msgstr "SILVER" @@ -3937,8 +3934,20 @@ msgstr "magic" msgid "see_lighthouse" msgstr "from lighthouse" -msgid "nr_schemes_prefix" -msgstr "Schemes of " +msgid "list_two" +msgstr "{0} and {1}" + +msgid "list_start" +msgstr "{0}, {1}" + +msgid "list_middle" +msgstr "{0}, {1}" + +msgid "list_end" +msgstr "{0}, and {1}" + +msgid "nr_schemes_template" +msgstr "Schemes of {0} can be discerned." msgid "aoc_p" msgstr "amulets of the kitten" diff --git a/src/report.c b/src/report.c index 38f27e327..904fd6f14 100644 --- a/src/report.c +++ b/src/report.c @@ -71,6 +71,7 @@ #include #include +#include #include #include #include @@ -1053,33 +1054,47 @@ static void report_region_edges(struct stream *out, const region * r, faction * } } +char *report_list(const struct locale *lang, char *buffer, size_t len, int argc, const char **argv) { + const char *two = LOC(lang, "list_two"); + const char *start = LOC(lang, "list_start"); + const char *middle = LOC(lang, "list_middle"); + const char *end = LOC(lang, "list_end"); + return format_list(argc, argv, buffer, len, two, start, middle, end); +} + +#define MAX_SCHEMES ((TP_RADIUS * 2 + 1) * (TP_RADIUS * 2 + 1) - 4) + static void report_region_schemes(struct stream *out, const region * r, faction * f) { - char buf[4096]; - sbstring sbs; - sbs_init(&sbs, buf, sizeof(buf)); if (r->seen.mode >= seen_unit && is_astral(r) && !is_cursed(r->attribs, &ct_astralblock)) { /* Sonderbehandlung Teleport-Ebene */ - region_list *rl = astralregions(r, inhabitable); - region_list *rl2; + region *rl[MAX_SCHEMES]; + int num = get_astralregions(r, inhabitable, rl); + char buf[4096]; - if (rl) { - /* this localization might not work for every language but is fine for de and en */ - sbs_strcat(&sbs, LOC(f->locale, "nr_schemes_prefix")); - rl2 = rl; - while (rl2) { + if (num == 1) { + /* single region is easy */ + region *rn = rl[0]; + f_regionid(rn, f, buf, sizeof(buf)); + } + else if (num > 1) { + int i; + char *rnames[MAX_SCHEMES]; + + for (i = 0; i != num; ++i) { char rbuf[REPORTWIDTH]; - f_regionid(rl2->data, f, rbuf, sizeof(rbuf)); - sbs_strcat(&sbs, rbuf); - rl2 = rl2->next; - if (rl2) { - sbs_strcat(&sbs, ", "); - } + region *rn = rl[i]; + f_regionid(rn, f, rbuf, sizeof(rbuf)); + rnames[i] = str_strdup(rbuf); } - sbs_strcat(&sbs,LOC(f->locale, "nr_schemes_postfix")); - free_regionlist(rl); - /* Schreibe Paragraphen */ + report_list(f->locale, buf, sizeof(buf), num, rnames); + for (i = 0; i != num; ++i) { + free(rnames[i]); + } + } + if (num > 0) { + format_replace(LOC(f->locale, "nr_schemes_template"), "{0}", buf, buf, sizeof(buf)); newline(out); paragraph(out, buf, 0, 0, 0); } diff --git a/src/teleport.c b/src/teleport.c index 84e4afe90..c59c92c40 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -22,7 +22,6 @@ #include #define TE_CENTER 1000 -#define TP_RADIUS 2 #define TP_DISTANCE 4 int real2tp(int rk) @@ -75,6 +74,33 @@ region_list *astralregions(const region * r, bool(*valid) (const region *)) return rlist; } + +int get_astralregions(const region * r, bool(*valid) (const region *), region *result[]) +{ + assert(is_astral(r)); + r = r_astral_to_standard(r); + if (r) { + int x, y, num = 0; + for (x = -TP_RADIUS; x <= +TP_RADIUS; ++x) { + for (y = -TP_RADIUS; y <= +TP_RADIUS; ++y) { + region *rn; + int dist = koor_distance(0, 0, x, y); + + if (dist <= TP_RADIUS) { + int nx = r->x + x, ny = r->y + y; + pnormalize(&nx, &ny, rplane(r)); + rn = findregion(nx, ny); + if (rn != NULL && (valid == NULL || valid(rn))) { + result[num++] = rn; + } + } + } + } + return num; + } + return 0; +} + region *r_standard_to_astral(const region * r) { assert(!is_astral(r)); diff --git a/src/teleport.h b/src/teleport.h index 416b6b406..cb225e978 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -7,6 +7,8 @@ extern "C" { #endif +#define TP_RADIUS 2 /* Radius von Schemen */ + struct region; struct region_list; struct plane; @@ -20,6 +22,7 @@ extern "C" { bool inhabitable(const struct region *r); bool is_astral(const struct region *r); struct plane *get_astralplane(void); + int get_astralregions(const struct region * r, bool(*valid) (const struct region *), struct region *result[]); void create_teleport_plane(void); void spawn_braineaters(float chance); From 08e45dc7229d2bdf8400aca142ef661511bb72ad Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Sep 2019 22:18:41 +0200 Subject: [PATCH 22/72] appease gcc const-check --- src/report.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/report.c b/src/report.c index 904fd6f14..7f0ad8dc0 100644 --- a/src/report.c +++ b/src/report.c @@ -1080,7 +1080,7 @@ static void report_region_schemes(struct stream *out, const region * r, faction } else if (num > 1) { int i; - char *rnames[MAX_SCHEMES]; + const char *rnames[MAX_SCHEMES]; for (i = 0; i != num; ++i) { char rbuf[REPORTWIDTH]; @@ -1090,7 +1090,7 @@ static void report_region_schemes(struct stream *out, const region * r, faction } report_list(f->locale, buf, sizeof(buf), num, rnames); for (i = 0; i != num; ++i) { - free(rnames[i]); + free((char *)rnames[i]); } } if (num > 0) { From 0db9389df665c8266547d63ca60beebddf30c9ee Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 21 Sep 2019 22:28:13 +0200 Subject: [PATCH 23/72] coverity thinks I should check return values --- src/report.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/report.c b/src/report.c index 7f0ad8dc0..392ede0da 100644 --- a/src/report.c +++ b/src/report.c @@ -1094,9 +1094,10 @@ static void report_region_schemes(struct stream *out, const region * r, faction } } if (num > 0) { - format_replace(LOC(f->locale, "nr_schemes_template"), "{0}", buf, buf, sizeof(buf)); - newline(out); - paragraph(out, buf, 0, 0, 0); + if (format_replace(LOC(f->locale, "nr_schemes_template"), "{0}", buf, buf, sizeof(buf))) { + newline(out); + paragraph(out, buf, 0, 0, 0); + } } } } From 3ac343a99749cb098ad3bef06ce5607c686f3437 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Sep 2019 13:18:30 +0200 Subject: [PATCH 24/72] Pestmeldung, Regionen Singular/Plural. --- res/core/messages.xml | 1 + res/translations/messages.de.po | 2 +- res/translations/messages.en.po | 2 +- res/translations/strings.de.po | 2 +- src/randenc.c | 3 ++- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 766cd481c..d40efb9ac 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -5291,6 +5291,7 @@ + diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po index a1d30c85c..776a1e207 100644 --- a/res/translations/messages.de.po +++ b/res/translations/messages.de.po @@ -2370,7 +2370,7 @@ msgid "sp_confusion_effect_0" msgstr "\"$unit($mage) stimmt einen seltsamen Gesang an. Ein plötzlicher Tumult entsteht, der sich jedoch schnell wieder legt.\"" msgid "pest" -msgstr "\"Hier wütete die Pest, und $int($dead) Bauern starben.\"" +msgstr "\"Hier wütete die Pest, und $int($dead) $resource($peasants,$dead) $if($eq($dead,1), \"starb\", \"starben\").\"" msgid "wormhole_exit" msgstr "\"$unit($unit) reist durch ein Wurmloch nach $region($region).\"" diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index 037b50d4d..9621b3d73 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -2370,7 +2370,7 @@ msgid "sp_confusion_effect_0" msgstr "\"$unit($mage) intones a mysterious chant. There is a sudden hubbub, but order is restored quickly.\"" msgid "pest" -msgstr "\"The region is visited by the plague and $int($dead) peasants died.\"" +msgstr "\"The region is visited by the plague and $int($dead) $resource($$peasants,$dead) died.\"" msgid "wormhole_exit" msgstr "\"$unit($unit) travels through a wormhole to $region($region).\"" diff --git a/res/translations/strings.de.po b/res/translations/strings.de.po index 68f126335..e6931c344 100644 --- a/res/translations/strings.de.po +++ b/res/translations/strings.de.po @@ -571,7 +571,7 @@ msgid "balloon" msgstr "Ballon" msgid "nr_schemes_template" -msgstr "Schemen der Regionen {0} sind erkennbar." +msgstr "Schemen von {0} sind erkennbar." msgid "list_two" msgstr "{0} und {1}" diff --git a/src/randenc.c b/src/randenc.c index 368a839e9..356c9c695 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -587,7 +587,8 @@ void plagues(region * r) } if (dead > 0) { - ADDMSG(&r->msgs, msg_message("pest", "dead", dead)); + ADDMSG(&r->msgs, msg_message("pest", "peasants dead", + get_resourcetype(R_PEASANT), dead)); deathcounts(r, dead); rsetpeasants(r, peasants - dead); } From ef9567897fc4d7075f0e2c69398e0f5b278739b9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Sep 2019 14:06:04 +0200 Subject: [PATCH 25/72] test for insect behavior when riding out of of through mountains. --- scripts/tests/e2/insects.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/tests/e2/insects.lua b/scripts/tests/e2/insects.lua index 1898e215c..f5b8a3213 100644 --- a/scripts/tests/e2/insects.lua +++ b/scripts/tests/e2/insects.lua @@ -85,3 +85,30 @@ function test_recruit_in_desert() assert_equal('winter', get_season(get_turn())) assert_equal(2, u.number) end + +function test_ride_through_mountain() + local r1 = region.create(1, 0, "plain") + local r2 = region.create(2, 0, "mountain") + local r3 = region.create(3, 0, "plain") + local f = faction.create("insect") + local u = unit.create(f, r1, 1) + u.name="Hercules" + u:add_order('NACH O O') + u:add_item('horse', 1) + u:set_skill('riding', 1, true) + process_orders() + assert_equal(r3, u.region) +end + +function test_ride_from_mountain() + local r1 = region.create(1, 0, "mountain") + local r2 = region.create(2, 0, "plain") + local r3 = region.create(3, 0, "plain") + local f = faction.create("insect") + local u = unit.create(f, r1, 1) + u:add_order('NACH O O') + u:add_item('horse', 1) + u:set_skill('riding', 1, true) + process_orders() + assert_equal(r2, u.region) +end From b6edc0b9400cbaa50828f8b85bb0f6bf02faebfd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Sep 2019 16:31:02 +0200 Subject: [PATCH 26/72] =?UTF-8?q?Bug=202611:=20password=5Fcmd=20erzeugt=20?= =?UTF-8?q?ung=C3=BCltige=20Passworte.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/laws.c | 29 ++++++++++------- src/laws.h | 1 + src/laws.test.c | 85 +++++++++++++++++++++++++++++++------------------ 3 files changed, 73 insertions(+), 42 deletions(-) diff --git a/src/laws.c b/src/laws.c index 7f78ac04b..50d364660 100644 --- a/src/laws.c +++ b/src/laws.c @@ -2181,6 +2181,21 @@ int email_cmd(unit * u, struct order *ord) return 0; } +bool password_wellformed(const char *password) +{ + unsigned char *c = (unsigned char *)password; + int i; + if (!password || password[0]=='\0') { + return false; + } + for (i = 0; c[i] && i != PASSWORD_MAXSIZE; ++i) { + if (!isalnum(c[i])) { + return false; + } + } + return true; +} + int password_cmd(unit * u, struct order *ord) { char pwbuf[PASSWORD_MAXSIZE + 1]; @@ -2194,19 +2209,11 @@ int password_cmd(unit * u, struct order *ord) pwbuf[PASSWORD_MAXSIZE - 1] = '\0'; } - if (s && *s) { - unsigned char *c = (unsigned char *)pwbuf; - int i, r = 0; - - for (i = 0; c[i] && i != PASSWORD_MAXSIZE; ++i) { - if (!isalnum(c[i])) { - c[i] = 'X'; - ++r; - } - } - if (r != 0) { + if (!s || !password_wellformed(s)) { + if (s) { cmistake(u, ord, 283, MSG_EVENT); } + password_generate(pwbuf, PASSWORD_MAXSIZE); } faction_setpassword(u->faction, password_hash(pwbuf, PASSWORD_DEFAULT)); ADDMSG(&u->faction->msgs, msg_message("changepasswd", "value", pwbuf)); diff --git a/src/laws.h b/src/laws.h index 4924a5f6e..a49848ac9 100755 --- a/src/laws.h +++ b/src/laws.h @@ -48,6 +48,7 @@ extern "C" { void sinkships(struct region * r); void do_enter(struct region *r, bool is_final_attempt); bool long_order_allowed(const struct unit *u); + bool password_wellformed(const char *password); int password_cmd(struct unit *u, struct order *ord); int banner_cmd(struct unit *u, struct order *ord); diff --git a/src/laws.test.c b/src/laws.test.c index 5dff45a92..8b92629b2 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -49,37 +49,6 @@ static void test_new_building_can_be_renamed(CuTest * tc) test_teardown(); } -static void test_password_cmd(CuTest * tc) -{ - unit *u; - faction * f; - test_setup(); - u = test_create_unit(f = test_create_faction(NULL), test_create_plain(0, 0)); - - u->thisorder = create_order(K_PASSWORD, f->locale, "abcdefgh"); - password_cmd(u, u->thisorder); - CuAssertPtrNotNull(tc, faction_getpassword(f)); - CuAssertTrue(tc, checkpasswd(f, "abcdefgh")); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd")); - free_order(u->thisorder); - - u->thisorder = create_order(K_PASSWORD, f->locale, "abc*de*"); - password_cmd(u, u->thisorder); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error283")); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd")); - CuAssertTrue(tc, !checkpasswd(f, "abc*de*")); - CuAssertTrue(tc, checkpasswd(f, "abcXdeX")); - free_order(u->thisorder); - - u->thisorder = create_order(K_PASSWORD, f->locale, "1234567890123456789012345678901234567890"); - password_cmd(u, u->thisorder); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error321")); - CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd")); - CuAssertTrue(tc, checkpasswd(f, "1234567890123456789012345678901")); - - test_teardown(); -} - static void test_rename_building(CuTest * tc) { region *r; @@ -1949,6 +1918,60 @@ static void test_long_order_on_ocean(CuTest *tc) { test_teardown(); } +static void test_password_cmd(CuTest *tc) { + unit *u; + message *msg; + faction * f; + + CuAssertTrue(tc, password_wellformed("PASSword")); + CuAssertTrue(tc, password_wellformed("1234567")); + CuAssertTrue(tc, !password_wellformed("$password")); + CuAssertTrue(tc, !password_wellformed("no space")); + + test_setup(); + mt_create_error(283); + mt_create_error(321); + mt_create_va(mt_new("changepasswd", NULL), "value:string", MT_NEW_END); + u = test_create_unit(f = test_create_faction(NULL), test_create_plain(0, 0)); + u->thisorder = create_order(K_PASSWORD, f->locale, "password1234", NULL); + password_cmd(u, u->thisorder); + CuAssertTrue(tc, checkpasswd(f, "password1234")); + CuAssertPtrNotNull(tc, msg = test_find_messagetype(f->msgs, "changepasswd")); + free_order(u->thisorder); + test_clear_messages(f); + + u->thisorder = create_order(K_PASSWORD, f->locale, "bad-password", NULL); + password_cmd(u, u->thisorder); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error283")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd")); + CuAssertTrue(tc, !checkpasswd(f, "password1234")); + free_order(u->thisorder); + test_clear_messages(f); + + u->thisorder = create_order(K_PASSWORD, f->locale, "''", NULL); + password_cmd(u, u->thisorder); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error283")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd")); + free_order(u->thisorder); + test_clear_messages(f); + + u->thisorder = create_order(K_PASSWORD, f->locale, NULL); + password_cmd(u, u->thisorder); + CuAssertTrue(tc, !checkpasswd(f, "password1234")); + CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "error283")); + CuAssertPtrNotNull(tc, msg = test_find_messagetype(f->msgs, "changepasswd")); + free_order(u->thisorder); + test_clear_messages(f); + + u->thisorder = create_order(K_PASSWORD, f->locale, "1234567890123456789012345678901234567890"); + password_cmd(u, u->thisorder); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error321")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "changepasswd")); + CuAssertTrue(tc, checkpasswd(f, "1234567890123456789012345678901")); + + test_teardown(); +} + static void test_peasant_migration(CuTest *tc) { region *r1, *r2; int rmax; From e72914eca3c4b30814d6c479345e13f4db8bb6a5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Sep 2019 17:33:49 +0200 Subject: [PATCH 27/72] new version of clibs --- clibs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clibs b/clibs index f8969f44d..abe774f70 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f8969f44de1ec413cfee82b23c9f4b3c32d49b56 +Subproject commit abe774f70265de14ea7f5e530518ca130562a9c9 From a2963a8621033366ea292a3b52e7aaf8e257371f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 23 Sep 2019 20:44:19 +0200 Subject: [PATCH 28/72] stop using astralregions, avoid dynamic allocations. --- src/creport.c | 16 +++++----- src/report.c | 2 -- src/spells.c | 81 ++++++++++---------------------------------------- src/teleport.c | 5 +++- src/teleport.h | 1 + 5 files changed, 29 insertions(+), 76 deletions(-) diff --git a/src/creport.c b/src/creport.c index 4088db49c..72bca8c70 100644 --- a/src/creport.c +++ b/src/creport.c @@ -1464,14 +1464,16 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r) cr_output_curses_compat(F, f, r, TYP_REGION); cr_borders(r, f, r->seen.mode, F); if (r->seen.mode >= seen_unit && is_astral(r) - && !is_cursed(r->attribs, &ct_astralblock)) { + && !is_cursed(r->attribs, &ct_astralblock)) + { /* Sonderbehandlung Teleport-Ebene */ - region_list *rl = astralregions(r, inhabitable); + region *rl[MAX_SCHEMES]; + int num = get_astralregions(r, inhabitable, rl); - if (rl) { - region_list *rl2 = rl; - while (rl2) { - region *r2 = rl2->data; + if (num > 0) { + int i; + for (i = 0; i != num; ++i) { + region *r2 = rl[i]; plane *plx = rplane(r2); nx = r2->x; @@ -1480,9 +1482,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r) adjust_coordinates(f, &nx, &ny, plx); fprintf(F, "SCHEMEN %d %d\n", nx, ny); fprintf(F, "\"%s\";Name\n", rname(r2, f->locale)); - rl2 = rl2->next; } - free_regionlist(rl); } } diff --git a/src/report.c b/src/report.c index 392ede0da..c69ddcdab 100644 --- a/src/report.c +++ b/src/report.c @@ -1062,8 +1062,6 @@ char *report_list(const struct locale *lang, char *buffer, size_t len, int argc, return format_list(argc, argv, buffer, len, two, start, middle, end); } -#define MAX_SCHEMES ((TP_RADIUS * 2 + 1) * (TP_RADIUS * 2 + 1) - 4) - static void report_region_schemes(struct stream *out, const region * r, faction * f) { if (r->seen.mode >= seen_unit && is_astral(r) && diff --git a/src/spells.c b/src/spells.c index 3c6a9304a..284f1ba10 100644 --- a/src/spells.c +++ b/src/spells.c @@ -1852,8 +1852,6 @@ static int sp_treewalkenter(castorder * co) static int sp_treewalkexit(castorder * co) { region *rt; - region_list *rl, *rl2; - int tax, tay; unit *u, *u2; int remaining_cap; int n; @@ -1885,23 +1883,7 @@ static int sp_treewalkexit(castorder * co) /* Koordinaten setzen und Region loeschen fuer Ueberpruefung auf * Gueltigkeit */ rt = pa->param[0]->data.r; - tax = rt->x; - tay = rt->y; - - rl = astralregions(r, inhabitable); - rt = NULL; - - rl2 = rl; - while (rl2) { - if (rl2->data->x == tax && rl2->data->y == tay) { - rt = rl2->data; - break; - } - rl2 = rl2->next; - } - free_regionlist(rl); - - if (!rt) { + if (!rt || !inhabitable(rt) || r_standard_to_astral(rt) != r) { cmistake(caster, co->order, 195, MSG_MAGIC); return 0; } @@ -5051,7 +5033,6 @@ int sp_pullastral(castorder * co) { region *rt, *ro; unit *u, *u2; - region_list *rl, *rl2; int remaining_cap; int n, w; region *r = co_get_region(co); @@ -5064,23 +5045,12 @@ int sp_pullastral(castorder * co) case 1: rt = r; ro = pa->param[0]->data.r; - rl = astralregions(r, NULL); - rl2 = rl; - while (rl2 != NULL) { - region *r2 = rl2->data; - if (r2->x == ro->x && r2->y == ro->y) { - ro = r2; - break; - } - rl2 = rl2->next; - } - if (!rl2) { + + if (r_astral_to_standard(r) != ro) { ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "spellfail::nocontact", "target", rt)); - free_regionlist(rl); return 0; } - free_regionlist(rl); break; default: ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, @@ -5192,7 +5162,6 @@ int sp_pullastral(castorder * co) int sp_leaveastral(castorder * co) { region *rt, *ro; - region_list *rl, *rl2; unit *u, *u2; int remaining_cap; int n, w; @@ -5204,27 +5173,13 @@ int sp_leaveastral(castorder * co) switch (getplaneid(r)) { case 1: - ro = r; rt = pa->param[0]->data.r; - if (!rt) { + if (!rt || r_standard_to_astral(rt) != r || !inhabitable(rt)) { ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "spellfail::noway", "")); return 0; } - rl = astralregions(r, inhabitable); - rl2 = rl; - while (rl2 != NULL) { - if (rl2->data == rt) - break; - rl2 = rl2->next; - } - if (rl2 == NULL) { - ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, - "spellfail::noway", "")); - free_regionlist(rl); - return 0; - } - free_regionlist(rl); + ro = r; break; default: ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, @@ -5545,11 +5500,12 @@ int sp_showastral(castorder * co) /* ------------------------------------------------------------- */ int sp_viewreality(castorder * co) { - region_list *rl, *rl2; region *r = co_get_region(co); unit *mage = co_get_caster(co); int cast_level = co->level; message *m; + region *rl[MAX_SCHEMES]; + int num; if (getplaneid(r) != 1) { /* sprintf(buf, "Dieser Zauber kann nur im Astralraum gezaubert werden."); */ @@ -5558,18 +5514,17 @@ int sp_viewreality(castorder * co) return 0; } - rl = astralregions(r, NULL); - - /* Irgendwann mal auf Curses u/o Attribut umstellen. */ - for (rl2 = rl; rl2; rl2 = rl2->next) { - region *rt = rl2->data; - if (!is_cursed(rt->attribs, &ct_astralblock)) { - set_observer(rt, mage->faction, co->level / 2, 2); + num = get_astralregions(r, NULL, rl); + if (num > 0) { + int i; + for (i = 0; i != num; ++i) { + region *rt = rl[i]; + if (!is_cursed(rt->attribs, &ct_astralblock)) { + set_observer(rt, mage->faction, co->level / 2, 2); + } } } - free_regionlist(rl); - m = msg_message("viewreality_effect", "unit", mage); r_addmessage(r, mage->faction, m); msg_release(m); @@ -5620,11 +5575,7 @@ int sp_disruptastral(castorder * co) continue; if (r2->units != NULL) { - region_list *trl2; - - trl = astralregions(rl2->data, inhabitable); - for (trl2 = trl; trl2; trl2 = trl2->next) - ++inhab_regions; + inhab_regions = get_astralregions(r, inhabitable, NULL); } /* Nicht-Permanente Tore zerstoeren */ diff --git a/src/teleport.c b/src/teleport.c index c59c92c40..6a897e057 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -91,7 +91,10 @@ int get_astralregions(const region * r, bool(*valid) (const region *), region *r pnormalize(&nx, &ny, rplane(r)); rn = findregion(nx, ny); if (rn != NULL && (valid == NULL || valid(rn))) { - result[num++] = rn; + if (result) { + result[num] = rn; + } + ++num; } } } diff --git a/src/teleport.h b/src/teleport.h index cb225e978..ce46a5778 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -8,6 +8,7 @@ extern "C" { #endif #define TP_RADIUS 2 /* Radius von Schemen */ +#define MAX_SCHEMES ((TP_RADIUS * 2 + 1) * (TP_RADIUS * 2 + 1) - 4) struct region; struct region_list; From 7335d8c5c91b50d2aa4cb0e187d402dd5f7d079f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 24 Sep 2019 09:35:38 +0200 Subject: [PATCH 29/72] fix build (bad merge, self is now f) --- src/bind_faction.c | 2 +- src/bind_faction.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bind_faction.c b/src/bind_faction.c index 07121d530..ada69f12b 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -260,7 +260,7 @@ static int tolua_faction_debug_messages(lua_State * L) int i = 1; if (f->msgs) { mlist *ml; - for (ml = self->msgs->begin; ml; ml = ml->next, ++i) { + for (ml = f->msgs->begin; ml; ml = ml->next, ++i) { char buf[120]; nr_render(ml->msg, default_locale, buf, sizeof(buf), NULL); puts(buf); diff --git a/src/bind_faction.h b/src/bind_faction.h index aed077f10..8f1255e65 100644 --- a/src/bind_faction.h +++ b/src/bind_faction.h @@ -1,8 +1,11 @@ +#pragma once + +struct lua_State; + #ifdef __cplusplus extern "C" { #endif - struct lua_State; int tolua_factionlist_next(struct lua_State *L); void tolua_faction_open(struct lua_State *L); From 24552613c8b727a5c9f422b7fb0229eea05239d9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 24 Sep 2019 21:26:34 +0200 Subject: [PATCH 30/72] fetch_astral braucht astralregions eigentlich nicht. --- scripts/tests/e2/astral.lua | 11 ++++++++--- src/bind_region.c | 11 ++++++++++- src/spells.c | 13 +------------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/scripts/tests/e2/astral.lua b/scripts/tests/e2/astral.lua index 1573c9af2..5c4461921 100644 --- a/scripts/tests/e2/astral.lua +++ b/scripts/tests/e2/astral.lua @@ -15,16 +15,20 @@ end function test_fetch_astral() local r = region.create(0, 0, "plain") + local ra = r:get_astral('fog') + local rb = region.create(ra.x + 1, ra.y, 'fog') local f = faction.create("human") local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) + local u3 = unit.create(f, rb, 1) + rb.plane = ra.plane u1.magic = "gray" u1:set_skill("magic", 6) u1.aura = 0 u1:add_spell("fetch_astral") u1:clear_orders() - u1:add_order("ZAUBERE Ruf~der~Realitaet " .. itoa36(u2.id)) + u1:add_order("ZAUBERE Ruf~der~Realitaet " .. itoa36(u2.id) .. " " .. itoa36(u3.id)) process_orders() assert_equal(1, f:count_msg_type('missing_components_list'), 'no components') @@ -33,10 +37,11 @@ function test_fetch_astral() assert_equal(12, u1.aura) assert_equal(1, f:count_msg_type('spellfail_astralonly'), 'astral space') - u2.region = u2.region:get_astral('fog') + u2.region = ra process_orders() assert_equal(0, u1.aura) - assert_equal(u1.region, u2.region) + assert_equal(r, u2.region) + assert_equal(rb, u3.region) end function test_pull_astral() diff --git a/src/bind_region.c b/src/bind_region.c index 29c7e6893..d0c184e0d 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -114,6 +114,14 @@ static int tolua_region_get_plane(lua_State * L) return 1; } +static int tolua_region_set_plane(lua_State * L) +{ + region *r = (region *)tolua_tousertype(L, 1, NULL); + plane *pl = (plane *)tolua_tousertype(L, 2, NULL); + r->_plane = pl; + return 0; +} + static int tolua_region_get_terrain(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, NULL); @@ -768,7 +776,8 @@ void tolua_region_open(lua_State * L) tolua_variable(L, TOLUA_CAST "id", tolua_region_get_id, NULL); tolua_variable(L, TOLUA_CAST "x", tolua_region_get_x, NULL); tolua_variable(L, TOLUA_CAST "y", tolua_region_get_y, NULL); - tolua_variable(L, TOLUA_CAST "plane", tolua_region_get_plane, NULL); + tolua_variable(L, TOLUA_CAST "plane", tolua_region_get_plane, + tolua_region_set_plane); tolua_variable(L, TOLUA_CAST "name", tolua_region_get_name, tolua_region_set_name); tolua_variable(L, TOLUA_CAST "morale", tolua_region_get_morale, diff --git a/src/spells.c b/src/spells.c index 284f1ba10..e5d0191af 100644 --- a/src/spells.c +++ b/src/spells.c @@ -5283,7 +5283,6 @@ int sp_fetchastral(castorder * co) spellparameter *pa = co->par; double power = co->force; int remaining_cap = (int)((power - 3) * 1500); - region_list *rtl = NULL; region *rt = co_get_region(co); /* region to which we are fetching */ region *ro = NULL; /* region in which the target is */ @@ -5305,21 +5304,13 @@ int sp_fetchastral(castorder * co) if (u->region != ro) { /* this can happen several times if the units are from different astral * regions. Only possible on the intersections of schemes */ - region_list *rfind; if (!is_astral(u->region)) { ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "spellfail_astralonly", "")); continue; } - if (rtl != NULL) - free_regionlist(rtl); - rtl = astralregions(u->region, NULL); - for (rfind = rtl; rfind != NULL; rfind = rfind->next) { - if (rfind->data == mage->region) - break; - } - if (rfind == NULL) { + if (r_standard_to_astral(mage->region) != u->region) { /* the region r is not in the schemes of rt */ ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "spellfail_distance", "target", u)); @@ -5401,8 +5392,6 @@ int sp_fetchastral(castorder * co) if (m) msg_release(m); } - if (rtl != NULL) - free_regionlist(rtl); return cast_level; } From 2ef753bd161ab9b080e7b278c104e133594d40a2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 24 Sep 2019 21:42:53 +0200 Subject: [PATCH 31/72] Tod den region_list Listen. Weg mit astralregions(). --- src/teleport.c | 31 ------------------------------- src/teleport.h | 2 -- 2 files changed, 33 deletions(-) diff --git a/src/teleport.c b/src/teleport.c index 6a897e057..590c458be 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -43,37 +43,6 @@ static region *tpregion(const region * r) return rt; } -region_list *astralregions(const region * r, bool(*valid) (const region *)) -{ - region_list *rlist = NULL; - int x, y; - - assert(is_astral(r)); - if (!is_astral(r)) { - log_error("astralregions was called with a non-astral region.\n"); - return NULL; - } - r = r_astral_to_standard(r); - if (r == NULL) - return NULL; - - for (x = -TP_RADIUS; x <= +TP_RADIUS; ++x) { - for (y = -TP_RADIUS; y <= +TP_RADIUS; ++y) { - region *rn; - int dist = koor_distance(0, 0, x, y); - int nx = r->x + x, ny = r->y + y; - - if (dist > TP_RADIUS) - continue; - pnormalize(&nx, &ny, rplane(r)); - rn = findregion(nx, ny); - if (rn != NULL && (valid == NULL || valid(rn))) - add_regionlist(&rlist, rn); - } - } - return rlist; -} - int get_astralregions(const region * r, bool(*valid) (const region *), region *result[]) { diff --git a/src/teleport.h b/src/teleport.h index ce46a5778..72815f497 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -16,8 +16,6 @@ extern "C" { struct region *r_standard_to_astral(const struct region *r); struct region *r_astral_to_standard(const struct region *); - struct region_list *astralregions(const struct region *rastral, - bool(*valid) (const struct region *)); struct region_list *all_in_range(const struct region *r, int n, bool(*valid) (const struct region *)); bool inhabitable(const struct region *r); From bb408d617ff9b95527bd30243a231b0969abb2ff Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 28 Sep 2019 20:54:30 +0200 Subject: [PATCH 32/72] typo in message definition --- res/translations/messages.en.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index 9621b3d73..7724fdc07 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -2370,7 +2370,7 @@ msgid "sp_confusion_effect_0" msgstr "\"$unit($mage) intones a mysterious chant. There is a sudden hubbub, but order is restored quickly.\"" msgid "pest" -msgstr "\"The region is visited by the plague and $int($dead) $resource($$peasants,$dead) died.\"" +msgstr "\"The region is visited by the plague and $int($dead) $resource($peasants,$dead) died.\"" msgid "wormhole_exit" msgstr "\"$unit($unit) travels through a wormhole to $region($region).\"" From a6ea80f5f85546dde37ec4638149f4d12e44d623 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Sep 2019 16:57:26 +0200 Subject: [PATCH 33/72] create a for_all_in_range function to avoid use of region_list. functional programming is good. --- src/spells.c | 77 +++++++++++++++++++++++++++++++++++--------------- src/teleport.c | 26 ----------------- src/teleport.h | 2 -- 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/src/spells.c b/src/spells.c index e5d0191af..0184fadd5 100644 --- a/src/spells.c +++ b/src/spells.c @@ -121,6 +121,41 @@ static double curse_chance(const struct curse *c, double force) return 1.0 + (force - c->vigour) * 0.1; } +#define RANGE_MAX 32 +static void for_all_in_range(const region * r, int range, void (*callback)(region *, void *), void *cbdata) { + if (r) { + int x, y; + plane *pl = rplane(r); + for (x = r->x - range; x <= r->x + range; ++x) { + for (y = r->y - range; y <= r->y + range; ++y) { + if (koor_distance(r->x, r->y, x, y) <= range) { + region *r2; + int nx = x, ny = y; + pnormalize(&nx, &ny, pl); + r2 = findregion(nx, ny); + if (r2) { + callback(r2, cbdata); + } + } + } + } + } +} + +static void cb_collect(region *r, void *cbdata) { + region_list **rlistp = (region_list **)cbdata; + add_regionlist(rlistp, r); +} + +static region_list *list_all_in_range(const region * r, int n) +{ + region_list *rlist = NULL; + for_all_in_range(r, n, cb_collect, &rlist); + return rlist; +} + + + static void magicanalyse_region(region * r, unit * mage, double force) { attrib *a; @@ -2516,6 +2551,23 @@ static void patzer_fumblecurse(const castorder * co) return; } +static void cb_set_dragon_target(region *r2, void *cbdata) { + region *r = (region *)cbdata; + unit *u; + for (u = r2->units; u; u = u->next) { + if (u_race(u) == get_race(RC_WYRM) || u_race(u) == get_race(RC_DRAGON)) { + attrib *a = a_find(u->attribs, &at_targetregion); + if (!a) { + a = a_add(&u->attribs, make_targetregion(r)); + } + else { + a->data.v = r; + } + } + } + +} + /* ------------------------------------------------------------- */ /* Name: Drachenruf * Stufe: 11 @@ -2538,13 +2590,10 @@ static int sp_summondragon(castorder * co) { region *r = co_get_region(co); unit *caster = co_get_caster(co); - unit *u; int cast_level = co->level; double power = co->force; - region_list *rl, *rl2; faction *f; - int time; - int number; + int time, number; const race *race; f = get_monsters(); @@ -2581,27 +2630,11 @@ static int sp_summondragon(castorder * co) } } - rl = all_in_range(r, (short)power, NULL); - - for (rl2 = rl; rl2; rl2 = rl2->next) { - region *r2 = rl2->data; - for (u = r2->units; u; u = u->next) { - if (u_race(u) == get_race(RC_WYRM) || u_race(u) == get_race(RC_DRAGON)) { - attrib *a = a_find(u->attribs, &at_targetregion); - if (!a) { - a = a_add(&u->attribs, make_targetregion(r)); - } - else { - a->data.v = r; - } - } - } - } + for_all_in_range(r, (int)power, cb_set_dragon_target, r); ADDMSG(&caster->faction->msgs, msg_message("summondragon", "unit region command target", caster, caster->region, co->order, r)); - free_regionlist(rl); return cast_level; } @@ -5551,7 +5584,7 @@ int sp_disruptastral(castorder * co) return 0; } - rl = all_in_range(rt, (short)(power / 5), NULL); + rl = list_all_in_range(rt, (short)(power / 5)); for (rl2 = rl; rl2 != NULL; rl2 = rl2->next) { attrib *a; diff --git a/src/teleport.c b/src/teleport.c index 590c458be..ecd3834bf 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -95,32 +95,6 @@ region *r_astral_to_standard(const region * r) return r2; } -region_list *all_in_range(const region * r, int n, - bool(*valid) (const region *)) -{ - int x, y; - region_list *rlist = NULL; - plane *pl = rplane(r); - - if (r == NULL) - return NULL; - - for (x = r->x - n; x <= r->x + n; x++) { - for (y = r->y - n; y <= r->y + n; y++) { - if (koor_distance(r->x, r->y, x, y) <= n) { - region *r2; - int nx = x, ny = y; - pnormalize(&nx, &ny, pl); - r2 = findregion(nx, ny); - if (r2 != NULL && (valid == NULL || valid(r2))) - add_regionlist(&rlist, r2); - } - } - } - - return rlist; -} - #define MAX_BRAIN_SIZE 100 void spawn_braineaters(float chance) diff --git a/src/teleport.h b/src/teleport.h index 72815f497..d91bed3df 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -16,8 +16,6 @@ extern "C" { struct region *r_standard_to_astral(const struct region *r); struct region *r_astral_to_standard(const struct region *); - struct region_list *all_in_range(const struct region *r, int n, - bool(*valid) (const struct region *)); bool inhabitable(const struct region *r); bool is_astral(const struct region *r); struct plane *get_astralplane(void); From 17fbd0d67d4d6475c01829d286372a925c1d7567 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Sep 2019 17:56:56 +0200 Subject: [PATCH 34/72] Bug 2612 Zauberreparatur. --- scripts/tests/e2/spells.lua | 17 +++++++++++++++-- src/bind_region.c | 4 ++-- src/spells.c | 27 +++++++++++++-------------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua index 02699c0b8..442e83d00 100644 --- a/scripts/tests/e2/spells.lua +++ b/scripts/tests/e2/spells.lua @@ -234,8 +234,6 @@ function test_familiar_school() local u = unit.create(f, r) u.magic = "draig" u:set_skill("magic", 10) - u.aura = 200 - u:add_spell("fireball") local uf = unit.create(f, r) uf.race = "lynx" u.familiar = uf @@ -247,3 +245,18 @@ function test_familiar_school() assert_equal(0, uf.aura) assert_nil(uf.magic) end + +function test_astral_disruption() + local r = region.create(0, 0, "plain") + local r2 = r:get_astral('fog') + local f = faction.create("human") + local u = unit.create(f, r) + local uh = unit.create(get_monsters(), r2, 1, "braineater") + u.magic = "draig" + u:set_skill("magic", 100) -- level 100 should beat magic resistance + u.aura = 200 + u:add_spell("astral_disruption") + u:add_order('ZAUBERE STUFE 1 "Stoere Astrale Integritaet"') + process_orders() + assert_equal(r, uh.region) +end diff --git a/src/bind_region.c b/src/bind_region.c index d0c184e0d..4ba16192f 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -587,10 +587,10 @@ static int tolua_region_getastral(lua_State * L) if (!rt) { const char *tname = tolua_tostring(L, 2, NULL); + const terrain_type *terrain = get_terrain(tname ? tname : "fog"); plane *pl = get_astralplane(); rt = new_region(real2tp(r->x), real2tp(r->y), pl, 0); - if (tname) { - const terrain_type *terrain = get_terrain(tname); + if (terrain) { terraform_region(rt, terrain); } } diff --git a/src/spells.c b/src/spells.c index 0184fadd5..2669664c7 100644 --- a/src/spells.c +++ b/src/spells.c @@ -5554,7 +5554,14 @@ int sp_viewreality(castorder * co) return cast_level; } -/* ------------------------------------------------------------- */ +/** + * Zauber: Störe astrale Integrität + * + * Dieser Zauber bewirkt eine schwere Störung des Astralraums. Innerhalb eines + * astralen Radius von Stufe/5 Regionen werden alle Astralwesen, die dem Zauber + * nicht wiederstehen können, aus der astralen Ebene geschleudert. Der astrale + * Kontakt mit allen betroffenen Regionen ist für Stufe/3 Wochen gestört. + */ int sp_disruptastral(castorder * co) { region_list *rl, *rl2; @@ -5584,20 +5591,20 @@ int sp_disruptastral(castorder * co) return 0; } - rl = list_all_in_range(rt, (short)(power / 5)); + rl = list_all_in_range(rt, (int)(power / 5)); for (rl2 = rl; rl2 != NULL; rl2 = rl2->next) { attrib *a; double effect; region *r2 = rl2->data; int inhab_regions = 0; - region_list *trl = NULL; + region *rtargets[MAX_SCHEMES]; if (is_cursed(r2->attribs, &ct_astralblock)) continue; if (r2->units != NULL) { - inhab_regions = get_astralregions(r, inhabitable, NULL); + inhab_regions = get_astralregions(r2, inhabitable, rtargets); } /* Nicht-Permanente Tore zerstoeren */ @@ -5613,17 +5620,10 @@ int sp_disruptastral(castorder * co) /* Einheiten auswerfen */ - if (trl != NULL) { + if (inhab_regions) { for (u = r2->units; u; u = u->next) { - region_list *trl2 = trl; - region *tr; int c = rng_int() % inhab_regions; - - /* Zufaellige Zielregion suchen */ - while (c-- != 0) { - trl2 = trl2->next; - } - tr = trl2->data; + region *tr = rtargets[c]; if (!is_magic_resistant(mage, u, 0) && can_survive(u, tr)) { message *msg = msg_message("disrupt_astral", "unit region", u, tr); @@ -5634,7 +5634,6 @@ int sp_disruptastral(castorder * co) move_unit(u, tr, NULL); } } - free_regionlist(trl); } /* Kontakt unterbinden */ From 7b9ea75d1676c1298fc280048bf049266fee89b7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Sep 2019 18:25:08 +0200 Subject: [PATCH 35/72] make disrupt_astral use callback, not region_list. --- src/spells.c | 132 +++++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 73 deletions(-) diff --git a/src/spells.c b/src/spells.c index 2669664c7..cea715ae1 100644 --- a/src/spells.c +++ b/src/spells.c @@ -15,7 +15,7 @@ #include "monsters.h" #include "teleport.h" - /* triggers includes */ +/* triggers includes */ #include #include #include @@ -122,7 +122,7 @@ static double curse_chance(const struct curse *c, double force) } #define RANGE_MAX 32 -static void for_all_in_range(const region * r, int range, void (*callback)(region *, void *), void *cbdata) { +static void for_all_in_range(const region * r, int range, void(*callback)(region *, void *), void *cbdata) { if (r) { int x, y; plane *pl = rplane(r); @@ -147,15 +147,6 @@ static void cb_collect(region *r, void *cbdata) { add_regionlist(rlistp, r); } -static region_list *list_all_in_range(const region * r, int n) -{ - region_list *rlist = NULL; - for_all_in_range(r, n, cb_collect, &rlist); - return rlist; -} - - - static void magicanalyse_region(region * r, unit * mage, double force) { attrib *a; @@ -1106,7 +1097,7 @@ static int sp_blessedharvest(castorder * co) if (create_curse(caster, &r->attribs, &ct_blessedharvest, co->force, duration, 1.0, 0)) { - const char * effect = co->sp->sname[0]=='b' ? "harvest_effect" : "raindance_effect"; + const char * effect = co->sp->sname[0] == 'b' ? "harvest_effect" : "raindance_effect"; message *seen = msg_message(effect, "mage", caster); message *unseen = msg_message(effect, "mage", (unit *)NULL); report_effect(r, caster, seen, unseen); @@ -2840,7 +2831,7 @@ static int dc_age(struct curse *c) } /* Reduziert durch Magieresistenz */ - dmg = frac_mul(dmg, frac_sub(frac_make(1,1), magic_resistance(u))); + dmg = frac_mul(dmg, frac_sub(frac_make(1, 1), magic_resistance(u))); damage *= dmg.sa[0]; damage /= dmg.sa[1]; hp = change_hitpoints(u, -(int)damage); @@ -5554,24 +5545,70 @@ int sp_viewreality(castorder * co) return cast_level; } -/** +static void cb_disrupt_astral(region *r2, void *cbdata) { + castorder *co = (castorder *)cbdata; + attrib *a; + region *rtargets[MAX_SCHEMES]; + region *r = co_get_region(co); + unit *caster = co_get_caster(co); + int duration = (int)(co->force / 3) + 1; + + if (is_cursed(r2->attribs, &ct_astralblock)) { + return; + } + + /* Nicht-Permanente Tore zerstoeren */ + a = a_find(r->attribs, &at_direction); + + while (a != NULL && a->type == &at_direction) { + attrib *a2 = a->next; + spec_direction *sd = (spec_direction *)(a->data.v); + if (sd->duration != -1) + a_remove(&r->attribs, a); + a = a2; + } + + /* Einheiten auswerfen */ + + if (r2->units != NULL) { + int inhab_regions = get_astralregions(r2, inhabitable, rtargets); + + if (inhab_regions) { + unit *u; + for (u = r2->units; u; u = u->next) { + int c = rng_int() % inhab_regions; + region *tr = rtargets[c]; + + if (!is_magic_resistant(caster, u, 0) && can_survive(u, tr)) { + message *msg = msg_message("disrupt_astral", "unit region", u, tr); + add_message(&u->faction->msgs, msg); + add_message(&tr->msgs, msg); + msg_release(msg); + + move_unit(u, tr, NULL); + } + } + } + } + + /* Kontakt unterbinden */ + create_curse(caster, &r2->attribs, &ct_astralblock, co->force, duration, 100, 0); +} + +/** * Zauber: Störe astrale Integrität * * Dieser Zauber bewirkt eine schwere Störung des Astralraums. Innerhalb eines * astralen Radius von Stufe/5 Regionen werden alle Astralwesen, die dem Zauber - * nicht wiederstehen können, aus der astralen Ebene geschleudert. Der astrale + * nicht wiederstehen können, aus der astralen Ebene geschleudert. Der astrale * Kontakt mit allen betroffenen Regionen ist für Stufe/3 Wochen gestört. */ int sp_disruptastral(castorder * co) { - region_list *rl, *rl2; region *rt; - unit *u; region *r = co_get_region(co); unit *mage = co_get_caster(co); - int cast_level = co->level; double power = co->force; - int duration = (int)(power / 3) + 1; switch (getplaneid(r)) { case 0: @@ -5591,59 +5628,8 @@ int sp_disruptastral(castorder * co) return 0; } - rl = list_all_in_range(rt, (int)(power / 5)); - - for (rl2 = rl; rl2 != NULL; rl2 = rl2->next) { - attrib *a; - double effect; - region *r2 = rl2->data; - int inhab_regions = 0; - region *rtargets[MAX_SCHEMES]; - - if (is_cursed(r2->attribs, &ct_astralblock)) - continue; - - if (r2->units != NULL) { - inhab_regions = get_astralregions(r2, inhabitable, rtargets); - } - - /* Nicht-Permanente Tore zerstoeren */ - a = a_find(r->attribs, &at_direction); - - while (a != NULL && a->type == &at_direction) { - attrib *a2 = a->next; - spec_direction *sd = (spec_direction *)(a->data.v); - if (sd->duration != -1) - a_remove(&r->attribs, a); - a = a2; - } - - /* Einheiten auswerfen */ - - if (inhab_regions) { - for (u = r2->units; u; u = u->next) { - int c = rng_int() % inhab_regions; - region *tr = rtargets[c]; - - if (!is_magic_resistant(mage, u, 0) && can_survive(u, tr)) { - message *msg = msg_message("disrupt_astral", "unit region", u, tr); - add_message(&u->faction->msgs, msg); - add_message(&tr->msgs, msg); - msg_release(msg); - - move_unit(u, tr, NULL); - } - } - } - - /* Kontakt unterbinden */ - effect = 100; - create_curse(mage, &rl2->data->attribs, &ct_astralblock, - power, duration, effect, 0); - } - - free_regionlist(rl); - return cast_level; + for_all_in_range(rt, (int)(power / 5), cb_disrupt_astral, co); + return co->level; } /* ------------------------------------------------------------- */ @@ -6538,7 +6524,7 @@ void register_spells(void) register_borders(); at_deprecate("zauber_todeswolke", dc_read_compat); - + /* init_firewall(); */ ct_register(&ct_firewall); ct_register(&ct_deathcloud); From b4f312065822a7dca962b711fe3fbcbb351f5623 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Sep 2019 18:31:11 +0200 Subject: [PATCH 36/72] delete unused function --- src/spells.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/spells.c b/src/spells.c index cea715ae1..81588ca4a 100644 --- a/src/spells.c +++ b/src/spells.c @@ -142,11 +142,6 @@ static void for_all_in_range(const region * r, int range, void(*callback)(region } } -static void cb_collect(region *r, void *cbdata) { - region_list **rlistp = (region_list **)cbdata; - add_regionlist(rlistp, r); -} - static void magicanalyse_region(region * r, unit * mage, double force) { attrib *a; From f02c4cbaeb3dfc11acab3292fa797af5a9d108ae Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 5 Oct 2019 20:59:55 +0200 Subject: [PATCH 37/72] disable magic resistant to prevent 2% intermittent test. --- scripts/tests/e2/spells.lua | 2 ++ src/magic.c | 8 ++++++++ src/spells.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua index 442e83d00..de2386113 100644 --- a/scripts/tests/e2/spells.lua +++ b/scripts/tests/e2/spells.lua @@ -9,6 +9,7 @@ function setup() eressea.settings.set("NewbieImmunity", "0") eressea.settings.set("rules.food.flags", "4") eressea.settings.set("rules.peasants.growth.factor", "0") + eressea.settings.set("magic.resist.enable", "0") eressea.settings.set("magic.fumble.enable", "0") eressea.settings.set("magic.regeneration.enable", "0") end @@ -258,5 +259,6 @@ function test_astral_disruption() u:add_spell("astral_disruption") u:add_order('ZAUBERE STUFE 1 "Stoere Astrale Integritaet"') process_orders() + assert_not_nil(r2:get_curse("astralblock")) assert_equal(r, uh.region) end diff --git a/src/magic.c b/src/magic.c index eed6cda90..5300101d3 100644 --- a/src/magic.c +++ b/src/magic.c @@ -1152,6 +1152,14 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus) { variant v02p, v98p, prob = frac_make(t_bonus, 100); attrib *a = NULL; + static bool never_resist; + static int config; + if (config_changed(&config)) { + never_resist = config_get_int("magic.resist.enable", 1) == 0; + } + if (never_resist) { + return false; + } if (magician == NULL || obj == NULL) { return true; diff --git a/src/spells.c b/src/spells.c index 81588ca4a..486a62b71 100644 --- a/src/spells.c +++ b/src/spells.c @@ -5546,7 +5546,7 @@ static void cb_disrupt_astral(region *r2, void *cbdata) { region *rtargets[MAX_SCHEMES]; region *r = co_get_region(co); unit *caster = co_get_caster(co); - int duration = (int)(co->force / 3) + 1; + int duration = (int)(co->force / 3) + 2; if (is_cursed(r2->attribs, &ct_astralblock)) { return; From 84633b50e101225d3b02cc741b21ab9450f58fc3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 5 Oct 2019 20:31:00 +0200 Subject: [PATCH 38/72] gamedata version SHIP_NUMBER_VERSION --- src/kernel/gamedata.h | 3 ++- src/kernel/save.c | 7 +++++++ src/kernel/ship.c | 16 ++++++++-------- src/kernel/ship.h | 1 + 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/kernel/gamedata.h b/src/kernel/gamedata.h index bc1701173..b0fd7762c 100644 --- a/src/kernel/gamedata.h +++ b/src/kernel/gamedata.h @@ -45,8 +45,9 @@ #define FIX_RES_BASE_VERSION 367 /* fixing resource base */ #define FIX_CLONES_VERSION 368 /* dissolve clones */ #define FIX_MIGRANT_AURA_VERSION 369 /* bug 2585, migrants with aura */ +#define SHIP_NUMBER_VERISON 370 /* ships have a number */ -#define RELEASE_VERSION FIX_MIGRANT_AURA_VERSION /* current datafile */ +#define RELEASE_VERSION SHIP_NUMBER_VERISON /* current datafile */ #define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */ #define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */ diff --git a/src/kernel/save.c b/src/kernel/save.c index 2eb36b134..2774f3401 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1283,6 +1283,7 @@ void write_ship(gamedata *data, const ship *sh) WRITE_STR(store, (const char *)sh->name); WRITE_STR(store, sh->display ? (const char *)sh->display : ""); WRITE_TOK(store, sh->type->_name); + WRITE_INT(store, sh->number); WRITE_INT(store, sh->size); WRITE_INT(store, sh->damage); WRITE_INT(store, sh->flags & SFL_SAVEMASK); @@ -1320,6 +1321,12 @@ ship *read_ship(gamedata *data) } assert(sh->type || !"ship_type not registered!"); + if (data->version < SHIP_NUMBER_VERISON) { + sh->number = 1; + } + else { + READ_INT(store, &sh->number); + } READ_INT(store, &sh->size); READ_INT(store, &sh->damage); if (data->version >= FOSS_VERSION) { diff --git a/src/kernel/ship.c b/src/kernel/ship.c index d1657b926..6d458843e 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -389,7 +389,7 @@ int shipcapacity(const ship * sh) { int i = sh->type->cargo; - if (sh->type->construction && sh->size != sh->type->construction->maxsize) + if (sh->type->construction && sh->size < sh->number * sh->type->construction->maxsize) return 0; if (sh->damage) { @@ -465,17 +465,17 @@ void write_ship_reference(const struct ship *sh, struct storage *store) WRITE_INT(store, (sh && sh->region) ? sh->no : 0); } -void ship_setname(ship * self, const char *name) +void ship_setname(ship * sh, const char *name) { - free(self->name); - self->name = name ? str_strdup(name) : 0; + free(sh->name); + sh->name = name ? str_strdup(name) : 0; } -const char *ship_getname(const ship * self) +const char *ship_getname(const ship * sh) { - return self->name; + return sh->name; } -int ship_damage_percent(const ship *ship) { - return (ship->damage * 100 + DAMAGE_SCALE - 1) / (ship->size * DAMAGE_SCALE); +int ship_damage_percent(const ship *sh) { + return (sh->damage * 100 + DAMAGE_SCALE - 1) / (sh->size * DAMAGE_SCALE); } diff --git a/src/kernel/ship.h b/src/kernel/ship.h index cd6966040..6c4e0bf95 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -73,6 +73,7 @@ extern "C" { struct ship *nexthash; struct unit * _owner; /* never use directly, always use ship_owner() */ int no; + int number; struct region *region; char *name; char *display; From 178f7c2e19f9b8ac642645656f59bdbd37e4c1d7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 6 Oct 2019 18:11:10 +0200 Subject: [PATCH 39/72] add number of ships for convoys. check required crew skills. require number of captains >= ship.number. --- scripts/tests/e2/ships.lua | 89 +++++++++++++++++++++++++++++ src/bind_ship.c | 111 +++++++++++++++++++++---------------- src/bind_unit.c | 14 ++++- src/creport.c | 7 ++- src/kernel/save.c | 1 + src/kernel/ship.c | 96 ++++++++++++++++++++++---------- src/kernel/ship.h | 11 +++- src/kernel/ship.test.c | 14 ++--- src/laws.c | 6 +- src/move.c | 39 +++++-------- src/move.h | 1 - src/report.c | 2 +- 12 files changed, 271 insertions(+), 120 deletions(-) diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 3208f0a0d..27e4d9b26 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -75,3 +75,92 @@ function test_speedy_ship_fast() process_orders() assert_equal(8, u1.region.x) end + +function test_ship_convoy_capacity() + local r1 = region.create(1, 0, 'ocean') + local r2 = region.create(2, 0, 'ocean') + local f = faction.create("human") + local u = unit.create(f, r1, 1) + + u:add_order('NACH O') + u:set_skill('sailing', 2, true) + u:add_item('jewel', 40) + u.ship = ship.create(r1, 'boat') + assert_equal(1, u.ship.number) + process_orders() + u:clear_orders() + assert_equal(r2, u.region) + + u:add_order('NACH W') + u:add_item('jewel', 1) + u:set_skill('sailing', 2, true) + process_orders() + u:clear_orders() + assert_equal(r2, u.region) -- too heavy + + u:add_order('NACH W') + u:add_item('jewel', 39) + u.name = 'Xolgrim' + u.ship.number = 2 + u.number = 2 + u:set_skill('sailing', 2, true) + process_orders() + u:clear_orders() + assert_equal(r1, u.region) -- double capacity + + u:add_order('NACH O') + u.ship.number = 2 + u.name = 'Bolgrim' + u:add_item('jewel', 1) -- too heavy again + u:set_skill('sailing', 2, true) + process_orders() + u:clear_orders() + assert_equal(r1, u.region) +end + +function test_ship_convoy_crew() + local r1 = region.create(1, 0, 'ocean') + local r2 = region.create(2, 0, 'ocean') + local f = faction.create("human") + local u = unit.create(f, r1, 1) + u.ship = ship.create(r1, 'boat') + u.ship.number = 2 + + u:set_skill('sailing', 4, true) + u:add_order('NACH O') + process_orders() + u:clear_orders() + assert_equal(r1, u.region) -- not enough captains + + u.number = 2 + u:set_skill('sailing', 2, true) + u:add_order('NACH O') + process_orders() + u:clear_orders() + assert_equal(r2, u.region) +end + +function test_ship_convoy_skill() + local r1 = region.create(1, 0, 'ocean') + local r2 = region.create(2, 0, 'ocean') + local r3 = region.create(3, 0, 'ocean') + local f = faction.create("human") + local u = unit.create(f, r1, 1) + + u:set_skill('sailing', 2, true) + u.ship = ship.create(r1, 'boat') + assert_equal(1, u.ship.number) + u:add_order('NACH O') + process_orders() + assert_equal(r2, u.region) + + u.ship.number = 2 + u:set_skill('sailing', 2, true) + process_orders() + assert_equal(r2, u.region) + + u.number = 2 + u:set_skill('sailing', 2, true) + process_orders() + assert_equal(r3, u.region) +end diff --git a/src/bind_ship.c b/src/bind_ship.c index d335d996d..6711b0370 100644 --- a/src/bind_ship.c +++ b/src/bind_ship.c @@ -38,39 +38,55 @@ int tolua_shiplist_next(lua_State * L) return 0; /* no more values to return */ } +static int tolua_ship_get_number(lua_State * L) +{ + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, sh->number); + return 1; +} + +static int tolua_ship_set_number(lua_State * L) +{ + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + int n = (int)tolua_tonumber(L, 2, 0); + sh->number = n; + sh->size += sh->type->construction->maxsize; + return 0; +} + static int tolua_ship_get_id(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->no); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, sh->no); return 1; } static int tolua_ship_get_name(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, ship_getname(self)); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, ship_getname(sh)); return 1; } static int tolua_ship_get_size(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->size); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, sh->size); return 1; } static int tolua_ship_get_display(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, self->display); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, sh->display); return 1; } static int tolua_ship_get_region(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - if (self) { - tolua_pushusertype(L, self->region, TOLUA_CAST "region"); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + if (sh) { + tolua_pushusertype(L, sh->region, TOLUA_CAST "region"); return 1; } return 0; @@ -78,43 +94,43 @@ static int tolua_ship_get_region(lua_State * L) static int tolua_ship_set_region(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); region *r = (region *)tolua_tousertype(L, 2, NULL); - if (self) { - move_ship(self, self->region, r, NULL); + if (sh) { + move_ship(sh, sh->region, r, NULL); } return 0; } static int tolua_ship_set_name(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - ship_setname(self, tolua_tostring(L, 2, NULL)); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + ship_setname(sh, tolua_tostring(L, 2, NULL)); return 0; } static int tolua_ship_set_size(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - self->size = lua_tointeger(L, 2); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + sh->size = lua_tointeger(L, 2); return 0; } static int tolua_ship_set_display(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - free(self->display); - self->display = str_strdup(tolua_tostring(L, 2, NULL)); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + free(sh->display); + sh->display = str_strdup(tolua_tostring(L, 2, NULL)); return 0; } static int tolua_ship_get_units(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); unit **unit_ptr = (unit **)lua_newuserdata(L, sizeof(unit *)); - unit *u = self->region->units; + unit *u = sh->region->units; - while (u && u->ship != self) + while (u && u->ship != sh) u = u->next; luaL_getmetatable(L, TOLUA_CAST "unit"); lua_setmetatable(L, -2); @@ -147,42 +163,42 @@ static int tolua_ship_create(lua_State * L) static int tolua_ship_tostring(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - lua_pushstring(L, shipname(self)); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + lua_pushstring(L, shipname(sh)); return 1; } static int tolua_ship_get_flags(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->flags); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, sh->flags); return 1; } static int tolua_ship_set_flags(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - self->flags = (int)lua_tointeger(L, 2); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + sh->flags = (int)lua_tointeger(L, 2); return 0; } static int tolua_ship_set_coast(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); if (lua_isnil(L, 2)) { - self->coast = NODIRECTION; + sh->coast = NODIRECTION; } else if (lua_isnumber(L, 2)) { - self->coast = (direction_t)lua_tointeger(L, 2); + sh->coast = (direction_t)lua_tointeger(L, 2); } return 0; } static int tolua_ship_get_coast(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - if (self->coast) { - lua_pushinteger(L, self->coast); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + if (sh->coast) { + lua_pushinteger(L, sh->coast); return 1; } return 0; @@ -190,30 +206,30 @@ static int tolua_ship_get_coast(lua_State * L) static int tolua_ship_get_type(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - tolua_pushstring(L, self->type->_name); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + tolua_pushstring(L, sh->type->_name); return 1; } static int tolua_ship_get_damage(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - lua_pushinteger(L, self->damage); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + lua_pushinteger(L, sh->damage); return 1; } static int tolua_ship_set_damage(lua_State * L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); - self->damage = (int)lua_tointeger(L, 2); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); + sh->damage = (int)lua_tointeger(L, 2); return 0; } static int tolua_ship_get_curse(lua_State *L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); const char *name = tolua_tostring(L, 2, NULL); - if (self->attribs) { - curse * c = get_curse(self->attribs, ct_find(name)); + if (sh->attribs) { + curse * c = get_curse(sh->attribs, ct_find(name)); if (c) { lua_pushnumber(L, curse_geteffect(c)); return 1; @@ -223,9 +239,9 @@ static int tolua_ship_get_curse(lua_State *L) { } static int tolua_ship_has_attrib(lua_State *L) { - ship *self = (ship *)tolua_tousertype(L, 1, NULL); + ship *sh = (ship *)tolua_tousertype(L, 1, NULL); const char *name = tolua_tostring(L, 2, NULL); - attrib * a = a_find(self->attribs, at_find(name)); + attrib * a = a_find(sh->attribs, at_find(name)); lua_pushboolean(L, a != NULL); return 1; } @@ -243,6 +259,7 @@ void tolua_ship_open(lua_State * L) { tolua_function(L, TOLUA_CAST "__tostring", tolua_ship_tostring); tolua_variable(L, TOLUA_CAST "id", tolua_ship_get_id, NULL); + tolua_variable(L, TOLUA_CAST "number", tolua_ship_get_number, tolua_ship_set_number); tolua_variable(L, TOLUA_CAST "name", tolua_ship_get_name, tolua_ship_set_name); tolua_variable(L, TOLUA_CAST "size", tolua_ship_get_size, diff --git a/src/bind_unit.c b/src/bind_unit.c index 45b4d7d0a..28e24e85b 100644 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -884,9 +884,19 @@ static int tolua_unit_create(lua_State * L) const char *rcname = tolua_tostring(L, 4, NULL); const race *rc; - assert(f && r); + if (!r) { + log_warning("unit.create: arg(2) is not a region"); + return 0; + } + if (!f) { + log_warning("unit.create: arg(1) is not a faction"); + return 0; + } rc = rcname ? rc_find(rcname) : f->race; - assert(rc); + if (!rc) { + log_warning("unit.create: unknown race %s", rcname); + return 0; + } u = create_unit(r, f, num, rc, 0, NULL, NULL); tolua_pushusertype(L, u, TOLUA_CAST "unit"); return 1; diff --git a/src/creport.c b/src/creport.c index 72bca8c70..4a5188108 100644 --- a/src/creport.c +++ b/src/creport.c @@ -515,7 +515,9 @@ static void report_crtypes(FILE * F, const struct locale *lang) fputc('\"', F); fputs(crescape(nrt_string(kmt->mtype, lang), buffer, sizeof(buffer)), F); fputs("\";text\n", F); - fprintf(F, "\"%s\";section\n", kmt->mtype->section); + if (kmt->mtype->section) { + fprintf(F, "\"%s\";section\n", kmt->mtype->section); + } } while (mtypehash[i]) { kmt = mtypehash[i]; @@ -695,6 +697,7 @@ static void cr_output_ship(struct stream *out, const ship *sh, const unit *u, stream_printf(out, "\"%s\";Beschr\n", sh->display); stream_printf(out, "\"%s\";Typ\n", translate(sh->type->_name, LOC(f->locale, sh->type->_name))); + stream_printf(out, "%d;Anzahl\n", sh->number); stream_printf(out, "%d;Groesse\n", sh->size); if (sh->damage) { int percent = @@ -710,7 +713,7 @@ static void cr_output_ship(struct stream *out, const ship *sh, const unit *u, /* calculate cargo */ if (u && (u->faction == f || omniscient(f))) { int n = 0, p = 0; - int mweight = shipcapacity(sh); + int mweight = ship_capacity(sh); getshipweight(sh, &n, &p); stream_printf(out, "%d;capacity\n", mweight); diff --git a/src/kernel/save.c b/src/kernel/save.c index 2774f3401..a65dda7e1 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1283,6 +1283,7 @@ void write_ship(gamedata *data, const ship *sh) WRITE_STR(store, (const char *)sh->name); WRITE_STR(store, sh->display ? (const char *)sh->display : ""); WRITE_TOK(store, sh->type->_name); + assert(sh->number > 0); WRITE_INT(store, sh->number); WRITE_INT(store, sh->size); WRITE_INT(store, sh->damage); diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 6d458843e..67b98d37c 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -181,6 +181,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang) sh->coast = NODIRECTION; sh->type = stype; sh->region = r; + sh->number = 1; if (lang) { sname = LOC(lang, stype->_name); @@ -275,13 +276,13 @@ static int ShipSpeedBonus(const unit * u) } if (bonus > 0) { int skl = effskill(u, SK_SAILING, NULL); - int minsk = (sh->type->cptskill + 1) / 2; + int minsk = (ship_captain_minskill(sh) + 1) / 2; return (skl - minsk) / bonus; } else if (sh->type->flags & SFL_SPEEDY) { int base = 3; int speed = 0; - int minsk = sh->type->cptskill * base; + int minsk = ship_captain_minskill(sh) * base; int skl = effskill(u, SK_SAILING, NULL); while (skl >= minsk) { ++speed; @@ -292,21 +293,8 @@ static int ShipSpeedBonus(const unit * u) return 0; } -int crew_skill(const ship *sh) { - int n = 0; - unit *u; - - n = 0; - - for (u = sh->region->units; u; u = u->next) { - if (u->ship == sh) { - int es = effskill(u, SK_SAILING, NULL); - if (es >= sh->type->minskill) { - n += es * u->number; - } - } - } - return n; +int ship_captain_minskill(const ship *sh) { + return sh->type->cptskill; } int shipspeed(const ship * sh, const unit * u) @@ -323,8 +311,9 @@ int shipspeed(const ship * sh, const unit * u) assert(sh->type->construction); k = sh->type->range; - if (sh->size != sh->type->construction->maxsize) + if (!ship_finished(sh)) { return 0; + } if (sh->attribs) { if (curse_active(get_curse(sh->attribs, &ct_stormwind))) { @@ -343,7 +332,7 @@ int shipspeed(const ship * sh, const unit * u) bonus = ShipSpeedBonus(u); if (bonus > 0 && sh->type->range_max > sh->type->range) { - int crew = crew_skill(sh); + int crew = crew_skill(sh, NULL); int crew_bonus = (crew / sh->type->sumskill / 2) - 1; if (crew_bonus > 0) { int sbonus = sh->type->range_max - sh->type->range; @@ -385,17 +374,68 @@ const char *shipname(const ship * sh) return write_shipname(sh, ibuf, sizeof(idbuf[0])); } -int shipcapacity(const ship * sh) +bool ship_finished(const ship *sh) { - int i = sh->type->cargo; - - if (sh->type->construction && sh->size < sh->number * sh->type->construction->maxsize) - return 0; - - if (sh->damage) { - i = (int)ceil(i * (1.0 - sh->damage / sh->size / (double)DAMAGE_SCALE)); + if (sh->type->construction) { + return (sh->size >= sh->number * sh->type->construction->maxsize); } - return i; + return true; +} + +int enoughsailors(const ship * sh, int crew_skill) +{ + return crew_skill >= sh->type->sumskill * sh->number; +} + +int crew_skill(const ship *sh, int *o_captains) { + int n = 0, captains = 0; + unit *u; + + for (u = sh->region->units; u; u = u->next) { + if (u->ship == sh) { + int es = effskill(u, SK_SAILING, NULL); + if (es >= sh->type->cptskill) { + captains += u->number; + } + if (es >= sh->type->minskill) { + n += es * u->number; + } + } + } + if (o_captains) { + *o_captains = captains; + } + return n; +} + +bool ship_crewed(const ship *sh) +{ + int num_caps, crew = crew_skill(sh, &num_caps); + return num_caps >= sh->number && enoughsailors(sh, crew); +} + +int ship_capacity(const ship * sh) +{ + if (ship_finished(sh)) { + int i = sh->type->cargo * sh->number; + if (sh->damage) { + i = (int)ceil(i * (1.0 - sh->damage / sh->size / (double)DAMAGE_SCALE)); + } + return i; + } + return 0; +} + +int ship_cabins(const ship * sh) +{ + if (ship_finished(sh)) { + int i = sh->type->cabins * sh->number; + if (sh->damage) { + i = (int)ceil(i * (1.0 - sh->damage / sh->size / (double)DAMAGE_SCALE)); + } + return i; + } + return 0; } void getshipweight(const ship * sh, int *sweight, int *scabins) diff --git a/src/kernel/ship.h b/src/kernel/ship.h index 6c4e0bf95..b82a69140 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -90,8 +90,10 @@ extern "C" { struct unit *ship_owner(const struct ship *sh); void ship_update_owner(struct ship * sh); - extern const char *shipname(const struct ship *self); - extern int shipcapacity(const struct ship *sh); + const char *shipname(const struct ship *self); + int ship_capacity(const struct ship *sh); + int ship_cabins(const struct ship *sh); + bool ship_finished(const struct ship *sh); extern void getshipweight(const struct ship *sh, int *weight, int *cabins); extern ship *new_ship(const struct ship_type *stype, struct region *r, @@ -114,7 +116,10 @@ extern "C" { const char *ship_getname(const struct ship *sh); void ship_setname(struct ship *self, const char *name); int shipspeed(const struct ship *sh, const struct unit *u); - int crew_skill(const struct ship *sh); + + bool ship_crewed(const struct ship *sh); + int crew_skill(const struct ship *sh, int *num_captains); + int ship_captain_minskill(const struct ship *sh); int ship_damage_percent(const struct ship *sh); #ifdef __cplusplus diff --git a/src/kernel/ship.test.c b/src/kernel/ship.test.c index 062e7cd20..18d8a1754 100644 --- a/src/kernel/ship.test.c +++ b/src/kernel/ship.test.c @@ -641,21 +641,21 @@ static void test_crew_skill(CuTest *tc) { CuAssertIntEquals(tc, 1, stype->minskill); r = test_create_ocean(0, 0); sh = test_create_ship(r, stype); - CuAssertIntEquals(tc, 0, crew_skill(sh)); + CuAssertIntEquals(tc, 0, crew_skill(sh, NULL)); u = test_create_unit(test_create_faction(NULL), r); set_level(u, SK_SAILING, 1); - CuAssertIntEquals(tc, 0, crew_skill(sh)); + CuAssertIntEquals(tc, 0, crew_skill(sh, NULL)); u_set_ship(u, sh); set_level(u, SK_SAILING, 1); - CuAssertIntEquals(tc, 1, crew_skill(sh)); + CuAssertIntEquals(tc, 1, crew_skill(sh, NULL)); set_number(u, 10); - CuAssertIntEquals(tc, 10, crew_skill(sh)); + CuAssertIntEquals(tc, 10, crew_skill(sh, NULL)); stype->minskill = 2; - CuAssertIntEquals(tc, 0, crew_skill(sh)); + CuAssertIntEquals(tc, 0, crew_skill(sh, NULL)); set_level(u, SK_SAILING, 2); - CuAssertIntEquals(tc, 20, crew_skill(sh)); + CuAssertIntEquals(tc, 20, crew_skill(sh, NULL)); set_level(u, SK_SAILING, 3); - CuAssertIntEquals(tc, 30, crew_skill(sh)); + CuAssertIntEquals(tc, 30, crew_skill(sh, NULL)); test_teardown(); } diff --git a/src/laws.c b/src/laws.c index 50d364660..61262b75d 100644 --- a/src/laws.c +++ b/src/laws.c @@ -1094,8 +1094,8 @@ int enter_ship(unit * u, struct order *ord, int id, bool report) } if (CheckOverload()) { int sweight, scabins; - int mweight = shipcapacity(sh); - int mcabins = sh->type->cabins; + int mweight = ship_capacity(sh); + int mcabins = ship_cabins(sh); if (mweight > 0) { getshipweight(sh, &sweight, &scabins); @@ -2598,7 +2598,7 @@ void sinkships(struct region * r) if (!sh->type->construction || sh->size >= sh->type->construction->maxsize) { if (fval(r->terrain, SEA_REGION)) { - if (!enoughsailors(sh, crew_skill(sh))) { + if (!ship_crewed(sh)) { /* ship is at sea, but not enough people to control it */ double dmg = config_get_flt("rules.ship.damage.nocrewocean", 0.3); damage_ship(sh, dmg); diff --git a/src/move.c b/src/move.c index a5438eb3d..484ee993f 100644 --- a/src/move.c +++ b/src/move.c @@ -470,13 +470,13 @@ static bool cansail(const region * r, ship * sh) { UNUSED_ARG(r); - if (sh->type->construction && sh->size != sh->type->construction->maxsize) { + if (!ship_finished(sh)) { return false; } else { int n = 0, p = 0; - int mweight = shipcapacity(sh); - int mcabins = sh->type->cabins; + int mweight = ship_capacity(sh); + int mcabins = ship_cabins(sh); getshipweight(sh, &n, &p); @@ -492,12 +492,12 @@ static double overload(const region * r, ship * sh) { UNUSED_ARG(r); - if (sh->type->construction && sh->size != sh->type->construction->maxsize) { + if (!ship_finished(sh)) { return DBL_MAX; } else { int n = 0, p = 0; - int mcabins = sh->type->cabins; + int mcabins = sh->type->cabins * sh->number; double ovl; getshipweight(sh, &n, &p); @@ -509,11 +509,6 @@ static double overload(const region * r, ship * sh) } } -int enoughsailors(const ship * sh, int crew_skill) -{ - return crew_skill >= sh->type->sumskill; -} - /* ------------------------------------------------------------- */ static ship *do_maelstrom(region * r, unit * u) @@ -808,7 +803,7 @@ static void drifting_ships(region * r) ship *sh = *shp; region *rnext = NULL; region_list *route = NULL; - unit *firstu = r->units, *lastu = NULL, *captain; + unit *firstu = r->units, *lastu = NULL; direction_t dir = NODIRECTION; double ovl; @@ -822,16 +817,10 @@ static void drifting_ships(region * r) continue; } - /* Kapitaen bestimmen */ - captain = ship_owner(sh); - if (captain && effskill(captain, SK_SAILING, r) < sh->type->cptskill) - captain = NULL; - /* Kapitaen da? Beschaedigt? Genuegend Matrosen? * Genuegend leicht? Dann ist alles OK. */ - if (captain && sh->size == sh->type->construction->maxsize - && enoughsailors(sh, crew_skill(sh)) && cansail(r, sh)) { + if (ship_finished(sh) && ship_crewed(sh) && cansail(r, sh)) { shp = &sh->next; continue; } @@ -1639,19 +1628,17 @@ static bool ship_ready(const region * r, unit * u, order * ord) cmistake(u, ord, 146, MSG_MOVE); return false; } - if (effskill(u, SK_SAILING, r) < u->ship->type->cptskill) { + if (effskill(u, SK_SAILING, r) < ship_captain_minskill(u->ship)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, - "error_captain_skill_low", "value ship", u->ship->type->cptskill, + "error_captain_skill_low", "value ship", ship_captain_minskill(u->ship), u->ship)); return false; } - if (u->ship->type->construction) { - if (u->ship->size != u->ship->type->construction->maxsize) { - cmistake(u, ord, 15, MSG_MOVE); - return false; - } + if (!ship_finished(u->ship)) { + cmistake(u, ord, 15, MSG_MOVE); + return false; } - if (!enoughsailors(u->ship, crew_skill(u->ship))) { + if (!ship_crewed(u->ship)) { cmistake(u, ord, 1, MSG_MOVE); return false; } diff --git a/src/move.h b/src/move.h index cbf154694..4362091b2 100644 --- a/src/move.h +++ b/src/move.h @@ -53,7 +53,6 @@ extern "C" { int personcapacity(const struct unit *u); void movement(void); - void run_to(struct unit *u, struct region *to); int enoughsailors(const struct ship *sh, int sumskill); bool canswim(struct unit *u); bool canfly(struct unit *u); diff --git a/src/report.c b/src/report.c index c69ddcdab..63886096e 100644 --- a/src/report.c +++ b/src/report.c @@ -1728,7 +1728,7 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, n = (n + 99) / 100; /* 1 Silber = 1 GE */ sbs_printf(&sbs, "%s, %s, (%d/%d)", shipname(sh), - LOC(f->locale, sh->type->_name), n, shipcapacity(sh) / 100); + LOC(f->locale, sh->type->_name), n, ship_capacity(sh) / 100); } else { sbs_printf(&sbs, "%s, %s", shipname(sh), LOC(f->locale, sh->type->_name)); From 5cf417d16d96e3c15f9f813dcea2ec9293ac59f2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 6 Oct 2019 20:22:19 +0200 Subject: [PATCH 40/72] must have one captain per ship. --- scripts/tests/e2/ships.lua | 7 +++---- src/kernel/ship.c | 36 +++++++++++++++++++++++------------- src/kernel/ship.h | 2 +- src/kernel/ship.test.c | 14 +++++++------- 4 files changed, 34 insertions(+), 25 deletions(-) diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 27e4d9b26..ad4e3656c 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -100,7 +100,6 @@ function test_ship_convoy_capacity() u:add_order('NACH W') u:add_item('jewel', 39) - u.name = 'Xolgrim' u.ship.number = 2 u.number = 2 u:set_skill('sailing', 2, true) @@ -146,7 +145,7 @@ function test_ship_convoy_skill() local r3 = region.create(3, 0, 'ocean') local f = faction.create("human") local u = unit.create(f, r1, 1) - + u:set_skill('sailing', 2, true) u.ship = ship.create(r1, 'boat') assert_equal(1, u.ship.number) @@ -155,9 +154,9 @@ function test_ship_convoy_skill() assert_equal(r2, u.region) u.ship.number = 2 - u:set_skill('sailing', 2, true) + u:set_skill('sailing', 4, true) process_orders() - assert_equal(r2, u.region) + assert_equal(r2, u.region) -- not enough captains u.number = 2 u:set_skill('sailing', 2, true) diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 67b98d37c..ca2da27b9 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -332,7 +332,7 @@ int shipspeed(const ship * sh, const unit * u) bonus = ShipSpeedBonus(u); if (bonus > 0 && sh->type->range_max > sh->type->range) { - int crew = crew_skill(sh, NULL); + int crew = crew_skill(sh); int crew_bonus = (crew / sh->type->sumskill / 2) - 1; if (crew_bonus > 0) { int sbonus = sh->type->range_max - sh->type->range; @@ -387,31 +387,41 @@ int enoughsailors(const ship * sh, int crew_skill) return crew_skill >= sh->type->sumskill * sh->number; } -int crew_skill(const ship *sh, int *o_captains) { - int n = 0, captains = 0; +int crew_skill(const ship *sh) { + int n = 0; unit *u; for (u = sh->region->units; u; u = u->next) { if (u->ship == sh) { int es = effskill(u, SK_SAILING, NULL); - if (es >= sh->type->cptskill) { - captains += u->number; - } if (es >= sh->type->minskill) { n += es * u->number; } } } - if (o_captains) { - *o_captains = captains; - } return n; } -bool ship_crewed(const ship *sh) -{ - int num_caps, crew = crew_skill(sh, &num_caps); - return num_caps >= sh->number && enoughsailors(sh, crew); +bool ship_crewed(const ship *sh) { + unit *u; + int capskill = -1, sumskill = 0; + for (u = sh->region->units; u; u = u->next) { + if (u->ship == sh) { + int es = effskill(u, SK_SAILING, NULL); + if (capskill < 0) { + if (u->number >= sh->number) { + capskill = es; + } + else { + capskill = 0; + } + } + if (es >= sh->type->minskill) { + sumskill += es * u->number; + } + } + } + return (capskill >= ship_captain_minskill(sh)) && (sumskill >= sh->type->sumskill * sh->number); } int ship_capacity(const ship * sh) diff --git a/src/kernel/ship.h b/src/kernel/ship.h index b82a69140..34230f55b 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -118,7 +118,7 @@ extern "C" { int shipspeed(const struct ship *sh, const struct unit *u); bool ship_crewed(const struct ship *sh); - int crew_skill(const struct ship *sh, int *num_captains); + int crew_skill(const struct ship *sh); int ship_captain_minskill(const struct ship *sh); int ship_damage_percent(const struct ship *sh); diff --git a/src/kernel/ship.test.c b/src/kernel/ship.test.c index 18d8a1754..062e7cd20 100644 --- a/src/kernel/ship.test.c +++ b/src/kernel/ship.test.c @@ -641,21 +641,21 @@ static void test_crew_skill(CuTest *tc) { CuAssertIntEquals(tc, 1, stype->minskill); r = test_create_ocean(0, 0); sh = test_create_ship(r, stype); - CuAssertIntEquals(tc, 0, crew_skill(sh, NULL)); + CuAssertIntEquals(tc, 0, crew_skill(sh)); u = test_create_unit(test_create_faction(NULL), r); set_level(u, SK_SAILING, 1); - CuAssertIntEquals(tc, 0, crew_skill(sh, NULL)); + CuAssertIntEquals(tc, 0, crew_skill(sh)); u_set_ship(u, sh); set_level(u, SK_SAILING, 1); - CuAssertIntEquals(tc, 1, crew_skill(sh, NULL)); + CuAssertIntEquals(tc, 1, crew_skill(sh)); set_number(u, 10); - CuAssertIntEquals(tc, 10, crew_skill(sh, NULL)); + CuAssertIntEquals(tc, 10, crew_skill(sh)); stype->minskill = 2; - CuAssertIntEquals(tc, 0, crew_skill(sh, NULL)); + CuAssertIntEquals(tc, 0, crew_skill(sh)); set_level(u, SK_SAILING, 2); - CuAssertIntEquals(tc, 20, crew_skill(sh, NULL)); + CuAssertIntEquals(tc, 20, crew_skill(sh)); set_level(u, SK_SAILING, 3); - CuAssertIntEquals(tc, 30, crew_skill(sh, NULL)); + CuAssertIntEquals(tc, 30, crew_skill(sh)); test_teardown(); } From 39e3001a5062ad9670e04fdbad28982f5d584300 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 6 Oct 2019 20:42:47 +0200 Subject: [PATCH 41/72] start implementing give_ship --- scripts/tests/e2/ships.lua | 27 +++++++++++++++++++++++++++ src/give.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index ad4e3656c..a50182c0d 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -163,3 +163,30 @@ function test_ship_convoy_skill() process_orders() assert_equal(r3, u.region) end + +function test_give_ship() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'boat') + u1.ship.number = 2 + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(1, u1.ship.number) + assert_equal(1, u2.ship.number) +end + +function test_give_ship_merge() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + u2.ship = ship.create(r, 'boat') + u1.ship = ship.create(r, 'boat') + u1.ship.number = 2 + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(1, u1.ship.number) + assert_equal(2, u2.ship.number) +end diff --git a/src/give.c b/src/give.c index ba04e69a6..036a7ae04 100644 --- a/src/give.c +++ b/src/give.c @@ -293,6 +293,14 @@ bool rule_transfermen(void) return rule != 0; } +message * give_ship(unit *u, unit *u2, int n, order *ord) { + assert(u->ship); + if (u->ship->number < n) { + n = u->ship->number; + } + return NULL; +} + message * give_men(int n, unit * u, unit * u2, struct order *ord) { int error = 0; @@ -652,7 +660,19 @@ static void give_all_items(unit *u, unit *u2, order *ord) { } } else { - if (isparam(s, u->faction->locale, P_PERSON)) { + param_t p = findparam(s, u->faction->locale); + if (p == P_SHIP) { + if (u->ship) { + message * msg = give_ship(u, u2, u->ship->number, ord); + if (msg) { + ADDMSG(&u->faction->msgs, msg); + } + } + else { + cmistake(u, ord, 144, MSG_COMMERCE); + } + } + else if (p == P_PERSON) { if (!(u_race(u)->ec_flags & ECF_GIVEPERSON)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_noregroup", "race", u_race(u))); @@ -815,7 +835,19 @@ void give_cmd(unit * u, order * ord) return; } - if (isparam(s, u->faction->locale, P_PERSON)) { + p = findparam(s, u->faction->locale); + if (p == P_SHIP) { + if (u->ship) { + message * msg = give_ship(u, u2, n, ord); + if (msg) { + ADDMSG(&u->faction->msgs, msg); + } + } + else { + cmistake(u, ord, 144, MSG_COMMERCE); + } + } + else if (p == P_PERSON) { if (!(u_race(u)->ec_flags & ECF_GIVEPERSON)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_noregroup", "race", u_race(u))); From f4011af7843aa823df7b1d7b67e74e92c346c715 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 7 Oct 2019 21:45:49 +0200 Subject: [PATCH 42/72] GIB unit n SCHIFF implementiert. --- res/translations/messages.de.po | 6 ++++ scripts/tests/e2/ships.lua | 35 ++++++++++++++++++++++ src/bind_ship.c | 3 +- src/give.c | 53 ++++++++++++++++++++++++--------- src/kernel/build.c | 3 +- src/kernel/ship.c | 7 +++++ src/kernel/ship.h | 1 + 7 files changed, 90 insertions(+), 18 deletions(-) diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po index 776a1e207..759f41ed1 100644 --- a/res/translations/messages.de.po +++ b/res/translations/messages.de.po @@ -2768,6 +2768,12 @@ msgstr "\"$unit($unit) verspeiste $int($amount) Bauern.\"" msgid "error320" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit kann nicht bewachen, da sie versucht zu fliehen.\"" +msgid "error321" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit gehört nicht zu unserer Partei.\"" + +msgid "error322" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist bereits auf einem Schiff.\"" + msgid "dissolve_units_2" msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) $if($eq($number,1),\"wurde zum Baum\", \"wurden zu Bäumen\").\"" diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index a50182c0d..1e101b5b2 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -190,3 +190,38 @@ function test_give_ship_merge() assert_equal(1, u1.ship.number) assert_equal(2, u2.ship.number) end + +function test_give_ship_max() + local r = region.create(1, 0, 'plain') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + local sh = ship.create(r, 'boat') + sh.number = 3 + sh.damage = 9 + sh.size = 12 + u1.ship = sh + u1:add_order("GIB " .. itoa36(u2.id) .. " 4 SCHIFF") + process_orders() + assert_equal(1, u1.ship.number) + assert_equal(3, u1.ship.damage) + assert_equal(4, u1.ship.size) + assert_equal(2, u2.ship.number) + assert_equal(6, u2.ship.damage) + assert_equal(8, u2.ship.size) +end + +function test_give_ship_self_only() + local r = region.create(1, 0, 'plain') + local f1 = faction.create("human") + local f2 = faction.create("human") + local u1 = unit.create(f1, r, 1) + local u2 = unit.create(f2, r, 1) + local sh = ship.create(r, 'boat') + sh.number = 2 + u1.ship = sh + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(2, u1.ship.number) + assert_equal(nil, u2.ship) +end diff --git a/src/bind_ship.c b/src/bind_ship.c index 6711b0370..71b6ae4f4 100644 --- a/src/bind_ship.c +++ b/src/bind_ship.c @@ -49,8 +49,7 @@ static int tolua_ship_set_number(lua_State * L) { ship *sh = (ship *)tolua_tousertype(L, 1, NULL); int n = (int)tolua_tonumber(L, 2, 0); - sh->number = n; - sh->size += sh->type->construction->maxsize; + scale_ship(sh, n); return 0; } diff --git a/src/give.c b/src/give.c index 036a7ae04..52b017448 100644 --- a/src/give.c +++ b/src/give.c @@ -293,8 +293,40 @@ bool rule_transfermen(void) return rule != 0; } -message * give_ship(unit *u, unit *u2, int n, order *ord) { +static void transfer_ships(ship *s1, ship *s2, int n) +{ + assert(n < s1->number); + s2->damage += s1->damage * n / s1->number; + s2->size += s1->size * n / s1->number; + s2->number += n; + scale_ship(s1, s1->number - n); +} + +message * give_ship(unit *u, unit *u2, int n, order *ord) +{ assert(u->ship); + assert(n > 0 && n < u->ship->number); + if (u->faction != u2->faction) { + return msg_error(u, ord, 321); + } + if (u2->ship) { + if (u2->ship->type != u->ship->type) { + return msg_error(u, ord, 322); + } + transfer_ships(u->ship, u2->ship, n); + } + else{ + if (fval(u_race(u2), RCF_CANSAIL)) { + ship * sh = new_ship(u->ship->type, u->region, u->faction->locale); + scale_ship(sh, 0); + u_set_ship(u2, sh); + transfer_ships(u->ship, sh, n); + } + else { + return msg_error(u, ord, 233); + } + + } if (u->ship->number < n) { n = u->ship->number; } @@ -661,18 +693,7 @@ static void give_all_items(unit *u, unit *u2, order *ord) { } else { param_t p = findparam(s, u->faction->locale); - if (p == P_SHIP) { - if (u->ship) { - message * msg = give_ship(u, u2, u->ship->number, ord); - if (msg) { - ADDMSG(&u->faction->msgs, msg); - } - } - else { - cmistake(u, ord, 144, MSG_COMMERCE); - } - } - else if (p == P_PERSON) { + if (p == P_PERSON) { if (!(u_race(u)->ec_flags & ECF_GIVEPERSON)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "race_noregroup", "race", u_race(u))); @@ -838,7 +859,11 @@ void give_cmd(unit * u, order * ord) p = findparam(s, u->faction->locale); if (p == P_SHIP) { if (u->ship) { - message * msg = give_ship(u, u2, n, ord); + message * msg; + if (n >= u->ship->number) { + n = u->ship->number - 1; + } + msg = give_ship(u, u2, n, ord); if (msg) { ADDMSG(&u->faction->msgs, msg); } diff --git a/src/kernel/build.c b/src/kernel/build.c index 3a73f8fd5..447db8662 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -932,8 +932,7 @@ static void build_ship(unit * u, ship * sh, int want) msg_message("buildship", "ship unit size", sh, u, n)); } -void -create_ship(unit * u, const struct ship_type *newtype, int want, +void create_ship(unit * u, const struct ship_type *newtype, int want, order * ord) { ship *sh; diff --git a/src/kernel/ship.c b/src/kernel/ship.c index ca2da27b9..1e38257d9 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -424,6 +424,13 @@ bool ship_crewed(const ship *sh) { return (capskill >= ship_captain_minskill(sh)) && (sumskill >= sh->type->sumskill * sh->number); } +void scale_ship(ship *sh, int n) +{ + sh->size = sh->size * n / sh->number; + sh->damage = sh->damage * n / sh->number; + sh->number = n; +} + int ship_capacity(const ship * sh) { if (ship_finished(sh)) { diff --git a/src/kernel/ship.h b/src/kernel/ship.h index 34230f55b..a9a678848 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -122,6 +122,7 @@ extern "C" { int ship_captain_minskill(const struct ship *sh); int ship_damage_percent(const struct ship *sh); + void scale_ship(struct ship *sh, int n); #ifdef __cplusplus } #endif From 4052cb71ffd804fde7fefd8fea1bdd037ea36e0e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 7 Oct 2019 22:01:02 +0200 Subject: [PATCH 43/72] Show convoy in reports. --- src/creport.c | 2 +- src/report.c | 7 +++++-- src/util/language.c | 13 +++++++++++++ src/util/language.h | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/creport.c b/src/creport.c index 4a5188108..46b998066 100644 --- a/src/creport.c +++ b/src/creport.c @@ -84,7 +84,7 @@ static char g_bigbuf[BUFFERSIZE]; bool opt_cr_absolute_coords = false; /* globals */ -#define C_REPORT_VERSION 66 +#define C_REPORT_VERSION 67 struct locale *crtag_locale(void) { static struct locale * lang; diff --git a/src/report.c b/src/report.c index 63886096e..407db00ff 100644 --- a/src/report.c +++ b/src/report.c @@ -1724,11 +1724,14 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, if (captain && captain->faction == f) { int n = 0, p = 0; + const char *stname; + getshipweight(sh, &n, &p); n = (n + 99) / 100; /* 1 Silber = 1 GE */ - sbs_printf(&sbs, "%s, %s, (%d/%d)", shipname(sh), - LOC(f->locale, sh->type->_name), n, ship_capacity(sh) / 100); + stname = locale_plural(f->locale, sh->type->_name, sh->number, true); + sbs_printf(&sbs, "%s, %d %s, (%d/%d)", shipname(sh), sh->number, + stname, n, ship_capacity(sh) / 100); } else { sbs_printf(&sbs, "%s, %s", shipname(sh), LOC(f->locale, sh->type->_name)); diff --git a/src/util/language.c b/src/util/language.c index f7894ac4e..f8dac8b39 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -129,6 +129,19 @@ const char *locale_getstring(const locale * lang, const char *key) return NULL; } +const char *locale_plural(const struct locale *lang, const char *key, int n, bool warn) { + assert(lang); + assert(key); + + if (n != 1) { + char plural[32]; + snprintf(plural, 32, "%s_p", key); + plural[31] = '\0'; + return locale_string(lang, plural, warn); + } + return locale_string(lang, key, warn); +} + const char *locale_string(const locale * lang, const char *key, bool warn) { assert(lang); diff --git a/src/util/language.h b/src/util/language.h index fce6bbebd..da1f17817 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -32,6 +32,7 @@ extern "C" { const char *locale_getstring(const struct locale *lang, const char *key); const char *locale_string(const struct locale *lang, const char *key, bool warn); /* does fallback */ + const char *locale_plural(const struct locale *lang, const char *key, int n, bool warn); unsigned int locale_index(const struct locale *lang); const char *locale_name(const struct locale *lang); From b0e6ed430ba4aace08d147dc43df5453fb55ff9b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 8 Oct 2019 04:52:41 +0200 Subject: [PATCH 44/72] GIB alle Schiffe an andere Einheit. --- scripts/tests/e2/ships.lua | 33 +++++++++++++++++-- src/give.c | 67 +++++++++++++++++++++++++------------- 2 files changed, 75 insertions(+), 25 deletions(-) diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 1e101b5b2..c71cf9eb3 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -191,7 +191,21 @@ function test_give_ship_merge() assert_equal(2, u2.ship.number) end -function test_give_ship_max() +function test_give_ship_only_same() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + u2.ship = ship.create(r, 'boat') + u1.ship = ship.create(r, 'longboat') + u1.ship.number = 2 + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(2, u1.ship.number) + assert_equal(1, u2.ship.number) +end + +function test_give_ship_scale() local r = region.create(1, 0, 'plain') local f = faction.create("human") local u1 = unit.create(f, r, 1) @@ -201,7 +215,7 @@ function test_give_ship_max() sh.damage = 9 sh.size = 12 u1.ship = sh - u1:add_order("GIB " .. itoa36(u2.id) .. " 4 SCHIFF") + u1:add_order("GIB " .. itoa36(u2.id) .. " 2 SCHIFF") process_orders() assert_equal(1, u1.ship.number) assert_equal(3, u1.ship.damage) @@ -211,6 +225,21 @@ function test_give_ship_max() assert_equal(8, u2.ship.size) end +function test_give_ship_all_ships() + local r = region.create(1, 0, 'plain') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'boat') + u1.ship.number = 2 + u2.ship = ship.create(r, 'boat') + u2.ship.number = 1 + u1:add_order("GIB " .. itoa36(u2.id) .. " 2 SCHIFF") + process_orders() + assert_equal(3, u2.ship.number) + assert_equal(u2.ship, u1.ship) +end + function test_give_ship_self_only() local r = region.create(1, 0, 'plain') local f1 = faction.create("human") diff --git a/src/give.c b/src/give.c index 52b017448..582532fe1 100644 --- a/src/give.c +++ b/src/give.c @@ -295,40 +295,61 @@ bool rule_transfermen(void) static void transfer_ships(ship *s1, ship *s2, int n) { - assert(n < s1->number); + assert(n <= s1->number); s2->damage += s1->damage * n / s1->number; s2->size += s1->size * n / s1->number; s2->number += n; scale_ship(s1, s1->number - n); } -message * give_ship(unit *u, unit *u2, int n, order *ord) +static void transfer_units(ship *s1, ship *s2) { - assert(u->ship); - assert(n > 0 && n < u->ship->number); - if (u->faction != u2->faction) { - return msg_error(u, ord, 321); - } - if (u2->ship) { - if (u2->ship->type != u->ship->type) { - return msg_error(u, ord, 322); + region * r = s1->region; + unit *u; + for (u = r->units; u; u = u->next) { + if (u->ship == s1) { + leave_ship(u); + u_set_ship(u, s2); } - transfer_ships(u->ship, u2->ship, n); } - else{ - if (fval(u_race(u2), RCF_CANSAIL)) { - ship * sh = new_ship(u->ship->type, u->region, u->faction->locale); - scale_ship(sh, 0); - u_set_ship(u2, sh); - transfer_ships(u->ship, sh, n); +} + +message * give_ship(unit *u1, unit *u2, int n, order *ord) +{ + assert(u1->ship); + assert(n > 0 && n <= u1->ship->number); + if (u1->faction != u2->faction) { + return msg_error(u1, ord, 321); + } + /* TODO: when transferring all ships, unit must hop on the target ship */ + if (u2->ship) { + if (n < u1->ship->number) { + if (u2->ship->type != u1->ship->type) { + return msg_error(u1, ord, 322); + } + transfer_ships(u1->ship, u2->ship, n); } else { - return msg_error(u, ord, 233); + transfer_ships(u1->ship, u2->ship, n); + transfer_units(u1->ship, u2->ship); } - } - if (u->ship->number < n) { - n = u->ship->number; + else { + if (fval(u_race(u2), RCF_CANSAIL)) { + if (n < u1->ship->number) { + ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); + scale_ship(sh, 0); + u_set_ship(u2, sh); + transfer_ships(u1->ship, sh, n); + } + else { + u_set_ship(u2, u1->ship); + ship_set_owner(u2); + } + } + else { + return msg_error(u1, ord, 233); + } } return NULL; } @@ -860,8 +881,8 @@ void give_cmd(unit * u, order * ord) if (p == P_SHIP) { if (u->ship) { message * msg; - if (n >= u->ship->number) { - n = u->ship->number - 1; + if (n > u->ship->number) { + n = u->ship->number; } msg = give_ship(u, u2, n, ord); if (msg) { From 43094e8bf95fa37d1adde898e6837e83635e641f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 8 Oct 2019 05:15:23 +0200 Subject: [PATCH 45/72] plural strings for ships. --- res/translations/strings.de.po | 24 ++++++++++++++++++++++++ res/translations/strings.en.po | 21 +++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/res/translations/strings.de.po b/res/translations/strings.de.po index e6931c344..1351c3d05 100644 --- a/res/translations/strings.de.po +++ b/res/translations/strings.de.po @@ -389,6 +389,9 @@ msgstr "Schaffenstrunk" msgid "balloon_a" msgstr "ein Ballon" +msgid "balloon_p" +msgstr "Ballons" + msgid "undead_name_8" msgstr "Monster" @@ -1115,6 +1118,9 @@ msgstr "Orks" msgid "boat_a" msgstr "ein Boot" +msgid "boat_p" +msgstr "Boote" + msgctxt "race" msgid "nymph" msgstr "Nymphe" @@ -1719,9 +1725,15 @@ msgstr "Ring der Unsichtbarkeit" msgid "caravel_a" msgstr "eine Karavelle" +msgid "caravel_p" +msgstr "Karavellen" + msgid "galleon_a" msgstr "eine Galeone" +msgid "galleon_p" +msgstr "Galeonen" + msgctxt "keyword" msgid "describe" msgstr "BESCHREIBE" @@ -1895,6 +1907,9 @@ msgstr "Untoten" msgid "flyingcarpet_a" msgstr "ein fliegender Teppich" +msgid "flyingcarpet_p" +msgstr "fliegende Teppiche" + msgid "mallorntree_p" msgstr "Mallorn" @@ -2806,6 +2821,9 @@ msgstr "Fjordwuchs" msgid "trireme_a" msgstr "eine Trireme" +msgid "trireme_p" +msgstr "Triremen" + msgctxt "prefix" msgid "Dunkel" msgstr "Dunkel" @@ -4112,6 +4130,9 @@ msgstr "Luchs" msgid "longboat_a" msgstr "ein Langboot" +msgid "longboat_p" +msgstr "Langboote" + msgctxt "race" msgid "human_d" msgstr "Menschen" @@ -5858,6 +5879,9 @@ msgstr "Tiger" msgid "dragonship_a" msgstr "ein Drachenschiff" +msgid "dragonship_p" +msgstr "Drachenschiffe" + msgctxt "race" msgid "mountainguard_x" msgstr "Bergwächter" diff --git a/res/translations/strings.en.po b/res/translations/strings.en.po index 36020a3f6..0eb8d3a37 100644 --- a/res/translations/strings.en.po +++ b/res/translations/strings.en.po @@ -303,6 +303,9 @@ msgstr "busybeer" msgid "balloon_a" msgstr "a balloon" +msgid "balloon_p" +msgstr "balloons" + msgid "jadee_ring" msgstr "Jadee's wedding ring" @@ -879,6 +882,9 @@ msgstr "gems" msgid "boat_a" msgstr "a boat" +msgid "boat_p" +msgstr "boats" + msgctxt "race" msgid "orc_p" msgstr "orcs" @@ -1458,12 +1464,18 @@ msgstr "ring of invisibility" msgid "galleon_a" msgstr "a galleon" +msgid "galleon_p" +msgstr "galleons" + msgid "galleon" msgstr "galleon" msgid "caravel_a" msgstr "a caravel" +msgid "caravel_p" +msgstr "caravels" + msgid "mallornspear_p" msgstr "mallorn spear" @@ -2439,6 +2451,9 @@ msgstr "fjord fungus" msgid "trireme_a" msgstr "a trireme" +msgid "trireme_p" +msgstr "triremes" + msgctxt "spell" msgid "healing" msgstr "Heal" @@ -3639,6 +3654,9 @@ msgstr "goblin head" msgid "longboat_a" msgstr "a longboat" +msgid "longboat_p" +msgstr "longboats" + msgctxt "race" msgid "lynx" msgstr "lynx" @@ -5171,6 +5189,9 @@ msgstr "tiger" msgid "dragonship_a" msgstr "a dragonship" +msgid "dragonship_p" +msgstr "dragonships" + msgctxt "race" msgid "mountainguard_x" msgstr "mountainguard" From 1e0afdc96125f60a91fc7a09323756e5a28ca9bb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 8 Oct 2019 20:56:14 +0200 Subject: [PATCH 46/72] spells can only be cast on single ships. --- res/translations/messages.de.po | 8 ++++- res/translations/messages.en.po | 12 +++++++ scripts/tests/e2/ships.lua | 63 ++++++++++++++++++++++++++++++++- src/give.c | 14 ++++++-- src/items.c | 4 +++ src/kernel/ship.c | 1 - src/spells.c | 8 +++++ 7 files changed, 105 insertions(+), 5 deletions(-) diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po index 759f41ed1..1ea230c8c 100644 --- a/res/translations/messages.de.po +++ b/res/translations/messages.de.po @@ -2768,12 +2768,18 @@ msgstr "\"$unit($unit) verspeiste $int($amount) Bauern.\"" msgid "error320" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit kann nicht bewachen, da sie versucht zu fliehen.\"" -msgid "error321" +msgid "error325" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Der Zauber kann nur auf ein einzelnes Schiff gewirkt werden.\"" + +msgid "error324" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit gehört nicht zu unserer Partei.\"" msgid "error322" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist bereits auf einem Schiff.\"" +msgid "error323" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff ist verzaubert.\"" + msgid "dissolve_units_2" msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) $if($eq($number,1),\"wurde zum Baum\", \"wurden zu Bäumen\").\"" diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index 7724fdc07..e6bc922f2 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -2768,6 +2768,18 @@ msgstr "\"$unit($unit) ate $int($amount) peasants.\"" msgid "error320" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit cannot guard the region because it is trying to flee.\"" +msgid "error325" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Spells can only be cast on a single ship.\"" + +msgid "error324" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is not one of ours.\"" + +msgid "error322" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is already on a ship.\"" + +msgid "error323" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - The ship is under a spell.\"" + msgid "dissolve_units_2" msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) turned into $if($eq($number,1),\"a tree\", \"trees\").\"" diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index c71cf9eb3..5cd723f8e 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -177,6 +177,22 @@ function test_give_ship() assert_equal(1, u2.ship.number) end +function test_give_ship_only_to_captain() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + local u3 = unit.create(f, r, 1) + u2.ship = ship.create(r, 'boat') + u3.ship = u2.ship + u1.ship = ship.create(r, 'boat') + u1.ship.number = 2 + u1:add_order("GIB " .. itoa36(u3.id) .. " 1 SCHIFF") + process_orders() + assert_equal(2, u1.ship.number) + assert_equal(1, u2.ship.number) +end + function test_give_ship_merge() local r = region.create(1, 0, 'ocean') local f = faction.create("human") @@ -227,15 +243,17 @@ end function test_give_ship_all_ships() local r = region.create(1, 0, 'plain') - local f = faction.create("human") + local f = faction.create("human", 'noreply@vg.no') local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) u1.ship = ship.create(r, 'boat') + u1.ship.damage = 2 u1.ship.number = 2 u2.ship = ship.create(r, 'boat') u2.ship.number = 1 u1:add_order("GIB " .. itoa36(u2.id) .. " 2 SCHIFF") process_orders() + write_reports() assert_equal(3, u2.ship.number) assert_equal(u2.ship, u1.ship) end @@ -254,3 +272,46 @@ function test_give_ship_self_only() assert_equal(2, u1.ship.number) assert_equal(nil, u2.ship) end + +function test_give_ship_not_cursed() + local r = region.create(1, 0, 'plain') + local f = faction.create("human") + local u = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + local sh = ship.create(r, 'boat') + u.ship = sh + u:add_item("speedsail", 1) + u:add_order("BENUTZE 1 Sonnensegel") + process_orders() + u:clear_orders() + assert_equal(1, sh:get_curse('shipspeedup')) + + u:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(nil, u2.ship) +end + +function test_speedsail_on_ship() + local r = region.create(1, 0, 'plain') + local f = faction.create("human") + local u = unit.create(f, r, 1) + local sh = ship.create(r, 'boat') + u.ship = sh + u:add_item("speedsail", 1) + u:add_order("BENUTZE 1 Sonnensegel") + process_orders() + assert_equal(1, sh:get_curse('shipspeedup')) +end + +function test_no_speedsail_on_convoy() + local r = region.create(1, 0, 'plain') + local f = faction.create("human") + local u = unit.create(f, r, 1) + local sh = ship.create(r, 'boat') + u.ship = sh + sh.number = 2 + u:add_item("speedsail", 2) + u:add_order("BENUTZE 2 Sonnensegel") + process_orders() + assert_equal(nil, sh:get_curse('shipspeedup')) +end diff --git a/src/give.c b/src/give.c index 582532fe1..71c9bab7d 100644 --- a/src/give.c +++ b/src/give.c @@ -314,15 +314,24 @@ static void transfer_units(ship *s1, ship *s2) } } +static bool ship_cursed(const ship *sh) { + return a_find(sh->attribs, &at_curse) != NULL; +} + message * give_ship(unit *u1, unit *u2, int n, order *ord) { assert(u1->ship); assert(n > 0 && n <= u1->ship->number); if (u1->faction != u2->faction) { - return msg_error(u1, ord, 321); + return msg_error(u1, ord, 324); + } + if (ship_cursed(u1->ship)) { + return msg_error(u1, ord, 323); } - /* TODO: when transferring all ships, unit must hop on the target ship */ if (u2->ship) { + if (ship_cursed(u2->ship)) { + return msg_error(u1, ord, 323); + } if (n < u1->ship->number) { if (u2->ship->type != u1->ship->type) { return msg_error(u1, ord, 322); @@ -892,6 +901,7 @@ void give_cmd(unit * u, order * ord) else { cmistake(u, ord, 144, MSG_COMMERCE); } + return; } else if (p == P_PERSON) { if (!(u_race(u)->ec_flags & ECF_GIVEPERSON)) { diff --git a/src/items.c b/src/items.c index c99fc2cdf..7912ff350 100644 --- a/src/items.c +++ b/src/items.c @@ -101,6 +101,10 @@ struct order *ord) cmistake(u, ord, 20, MSG_MOVE); return -1; } + if (sh->number > 1) { + cmistake(u, ord, 325, MSG_MAGIC); + return -1; + } effect = SPEEDSAIL_EFFECT; create_curse(u, &sh->attribs, &ct_shipspeedup, 20, INT_MAX, effect, 0); diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 1e38257d9..601c36d82 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -314,7 +314,6 @@ int shipspeed(const ship * sh, const unit * u) if (!ship_finished(sh)) { return 0; } - if (sh->attribs) { if (curse_active(get_curse(sh->attribs, &ct_stormwind))) { k *= 2; diff --git a/src/spells.c b/src/spells.c index 486a62b71..200e87f62 100644 --- a/src/spells.c +++ b/src/spells.c @@ -808,6 +808,10 @@ static int sp_goodwinds(castorder * co) return 0; sh = pa->param[0]->data.sh; + if (sh->number > 1) { + cmistake(caster, co->order, 325, MSG_MAGIC); + return 0; + } /* keine Probleme mit C_SHIP_SPEEDUP und C_SHIP_FLYING */ /* NODRIFT bewirkt auch +1 Geschwindigkeit */ @@ -2231,6 +2235,10 @@ static int sp_stormwinds(castorder * co) sh = pa->param[n]->data.sh; + if (sh->number > 1) { + cmistake(caster, co->order, 325, MSG_MAGIC); + continue; + } if (is_cursed(sh->attribs, &ct_flyingship)) { ADDMSG(&caster->faction->msgs, msg_feedback(caster, co->order, "error_spell_on_flying_ship", "ship", sh)) From 24978a5b80b2949d34eaf20ad1056990050e1ba9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 8 Oct 2019 21:14:01 +0200 Subject: [PATCH 47/72] =?UTF-8?q?Schiffstransfer=20nur=20zwischen=20Kapit?= =?UTF-8?q?=C3=A4nen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tests/e2/ships.lua | 20 ++++++++++++++++++-- src/give.c | 6 ++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 5cd723f8e..b038553b8 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -183,16 +183,32 @@ function test_give_ship_only_to_captain() local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) local u3 = unit.create(f, r, 1) - u2.ship = ship.create(r, 'boat') - u3.ship = u2.ship u1.ship = ship.create(r, 'boat') u1.ship.number = 2 + u2.ship = ship.create(r, 'boat') + u3.ship = u2.ship u1:add_order("GIB " .. itoa36(u3.id) .. " 1 SCHIFF") process_orders() assert_equal(2, u1.ship.number) assert_equal(1, u2.ship.number) end +function test_give_ship_only_from_captain() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + local u3 = unit.create(f, r, 1) + u2.ship = ship.create(r, 'boat') + u1.ship = ship.create(r, 'boat') + u1.ship.number = 2 + u3.ship = u1.ship + u3:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(2, u1.ship.number) + assert_equal(1, u2.ship.number) +end + function test_give_ship_merge() local r = region.create(1, 0, 'ocean') local f = faction.create("human") diff --git a/src/give.c b/src/give.c index 71c9bab7d..cc9f54987 100644 --- a/src/give.c +++ b/src/give.c @@ -328,7 +328,13 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) if (ship_cursed(u1->ship)) { return msg_error(u1, ord, 323); } + if (u1 != ship_owner(u1->ship)) { + return msg_error(u1, ord, 146); + } if (u2->ship) { + if (u2 != ship_owner(u2->ship)) { + return msg_error(u1, ord, 146); + } if (ship_cursed(u2->ship)) { return msg_error(u1, ord, 323); } From 78e44e0fe396d8c75a0b61929763c8d70cc53ecb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Oct 2019 16:12:25 +0200 Subject: [PATCH 48/72] check compatible costs --- scripts/tests/e2/ships.lua | 43 +++++++++++++++++++++++++++++++++++ src/give.c | 46 +++++++++++++++++++++++--------------- 2 files changed, 71 insertions(+), 18 deletions(-) diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index b038553b8..f8020f3d7 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -193,6 +193,49 @@ function test_give_ship_only_to_captain() assert_equal(1, u2.ship.number) end +function test_give_ship_compatible_coasts() + local r = region.create(1, 0, 'plain') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'boat') + u1.ship.number = 4 + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + u2.ship = ship.create(r, 'boat') + + -- cannot give a ship with different coast: + u1.ship.coast = 1 + u2.ship.coast = 2 + process_orders() + assert_equal(4, u1.ship.number) + assert_equal(1, u2.ship.number) + + -- can give a ship with no coast: + u1.ship.coast = -1 + u2.ship.coast = 2 + process_orders() + assert_equal(3, u1.ship.number) + assert_equal(2, u2.ship.number) + assert_equal(2, u2.ship.coast) + + -- can give a ship with same coast: + u1.ship.coast = 2 + u2.ship.coast = 2 + process_orders() + assert_equal(2, u1.ship.number) + assert_equal(3, u2.ship.number) + assert_equal(2, u2.ship.coast) + + -- giving to a ship with no coast: + u1.ship.coast = 2 + u2.ship.coast = -1 + process_orders() + assert_equal(1, u1.ship.number) + assert_equal(4, u2.ship.number) + assert_equal(2, u2.ship.coast) + +end + function test_give_ship_only_from_captain() local r = region.create(1, 0, 'ocean') local f = faction.create("human") diff --git a/src/give.c b/src/give.c index cc9f54987..716bab933 100644 --- a/src/give.c +++ b/src/give.c @@ -331,26 +331,36 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) if (u1 != ship_owner(u1->ship)) { return msg_error(u1, ord, 146); } - if (u2->ship) { - if (u2 != ship_owner(u2->ship)) { - return msg_error(u1, ord, 146); - } - if (ship_cursed(u2->ship)) { - return msg_error(u1, ord, 323); - } - if (n < u1->ship->number) { + if (fval(u_race(u2), RCF_CANSAIL)) { + if (u2->ship) { + if (u2 != ship_owner(u2->ship)) { + return msg_error(u1, ord, 146); + } if (u2->ship->type != u1->ship->type) { return msg_error(u1, ord, 322); } - transfer_ships(u1->ship, u2->ship, n); + if (ship_cursed(u2->ship)) { + return msg_error(u1, ord, 323); + } + if (u1->ship->coast != u2->ship->coast) { + if (u1->ship->coast != NODIRECTION) { + if (u2->ship->coast == NODIRECTION) { + u2->ship->coast = u1->ship->coast; + } + else { + return msg_error(u1, ord, 182); + } + } + } + if (n < u1->ship->number) { + transfer_ships(u1->ship, u2->ship, n); + } + else { + transfer_ships(u1->ship, u2->ship, n); + transfer_units(u1->ship, u2->ship); + } } else { - transfer_ships(u1->ship, u2->ship, n); - transfer_units(u1->ship, u2->ship); - } - } - else { - if (fval(u_race(u2), RCF_CANSAIL)) { if (n < u1->ship->number) { ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); scale_ship(sh, 0); @@ -362,9 +372,9 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) ship_set_owner(u2); } } - else { - return msg_error(u1, ord, 233); - } + } + else { + return msg_error(u1, ord, 233); } return NULL; } From 1d405e2ef8f6aa80a6771654274d6857284db859 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Oct 2019 20:17:25 +0200 Subject: [PATCH 49/72] =?UTF-8?q?GIB=200=20n=20SCHIFFE=20Keine=20Boote=20e?= =?UTF-8?q?rlauben=20=C3=9Cbergabe=20an=20eigene=20Besatzung.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/translations/messages.de.po | 6 ++ res/translations/messages.en.po | 3 + scripts/tests/e2/ships.lua | 133 ++++++++++++++++++++++++-------- src/give.c | 99 +++++++++++++++--------- 4 files changed, 171 insertions(+), 70 deletions(-) diff --git a/res/translations/messages.de.po b/res/translations/messages.de.po index 1ea230c8c..5d2717e51 100644 --- a/res/translations/messages.de.po +++ b/res/translations/messages.de.po @@ -2780,6 +2780,12 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist msgid "error323" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff ist verzaubert.\"" +msgid "error327" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - So viele Schiffe kann die Einheit nicht übergeben.\"" + +msgid "error326" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - Diese Schiffe können keinen Konvoi bilden.\"" + msgid "dissolve_units_2" msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) $if($eq($number,1),\"wurde zum Baum\", \"wurden zu Bäumen\").\"" diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index e6bc922f2..135053782 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -2771,6 +2771,9 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit cannot msgid "error325" msgstr "\"$unit($unit) in $region($region): '$order($command)' - Spells can only be cast on a single ship.\"" +msgid "error326" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - These ships cannot form a convoy.\"" + msgid "error324" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is not one of ours.\"" diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index f8020f3d7..9286cc8f1 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -83,9 +83,9 @@ function test_ship_convoy_capacity() local u = unit.create(f, r1, 1) u:add_order('NACH O') - u:set_skill('sailing', 2, true) - u:add_item('jewel', 40) - u.ship = ship.create(r1, 'boat') + u:set_skill('sailing', 10, true) + u:add_item('jewel', 490) + u.ship = ship.create(r1, 'longboat') assert_equal(1, u.ship.number) process_orders() u:clear_orders() @@ -99,19 +99,17 @@ function test_ship_convoy_capacity() assert_equal(r2, u.region) -- too heavy u:add_order('NACH W') - u:add_item('jewel', 39) + u:add_item('jewel', 489) u.ship.number = 2 u.number = 2 - u:set_skill('sailing', 2, true) + u:set_skill('sailing', 10, true) process_orders() u:clear_orders() assert_equal(r1, u.region) -- double capacity u:add_order('NACH O') u.ship.number = 2 - u.name = 'Bolgrim' u:add_item('jewel', 1) -- too heavy again - u:set_skill('sailing', 2, true) process_orders() u:clear_orders() assert_equal(r1, u.region) @@ -122,17 +120,17 @@ function test_ship_convoy_crew() local r2 = region.create(2, 0, 'ocean') local f = faction.create("human") local u = unit.create(f, r1, 1) - u.ship = ship.create(r1, 'boat') + u.ship = ship.create(r1, 'longboat') u.ship.number = 2 - u:set_skill('sailing', 4, true) + u.number = 2 + u:set_skill('sailing', 5, true) u:add_order('NACH O') process_orders() u:clear_orders() assert_equal(r1, u.region) -- not enough captains - u.number = 2 - u:set_skill('sailing', 2, true) + u:set_skill('sailing', 10, true) u:add_order('NACH O') process_orders() u:clear_orders() @@ -146,20 +144,20 @@ function test_ship_convoy_skill() local f = faction.create("human") local u = unit.create(f, r1, 1) - u:set_skill('sailing', 2, true) - u.ship = ship.create(r1, 'boat') + u:set_skill('sailing', 10, true) + u.ship = ship.create(r1, 'longboat') assert_equal(1, u.ship.number) u:add_order('NACH O') process_orders() assert_equal(r2, u.region) u.ship.number = 2 - u:set_skill('sailing', 4, true) + u:set_skill('sailing', 20, true) process_orders() assert_equal(r2, u.region) -- not enough captains u.number = 2 - u:set_skill('sailing', 2, true) + u:set_skill('sailing', 10, true) process_orders() assert_equal(r3, u.region) end @@ -169,7 +167,7 @@ function test_give_ship() local f = faction.create("human") local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) - u1.ship = ship.create(r, 'boat') + u1.ship = ship.create(r, 'longboat') u1.ship.number = 2 u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") process_orders() @@ -177,15 +175,84 @@ function test_give_ship() assert_equal(1, u2.ship.number) end +function test_give_ship_new_unit() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'longboat') + u1.ship.number = 2 + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(1, u1.ship.number) + assert_equal(1, u2.ship.number) +end + +function test_give_ship_same_ship() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'longboat') + u2.ship = u1.ship + u1.ship.number = 2 + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(1, u1.ship.number) + assert_equal(1, u2.ship.number) + assert_not_equal(u1.ship, u2.ship) +end + +function test_give_ship_dont_give_all() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'longboat') + u1.ship.number = 2 + u1:add_order("GIB 0 2 SCHIFF") + process_orders() + assert_equal(2, u1.ship.number) +end + +function test_give_ship_no_boat() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'boat') + u1.ship.number = 1 + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") + process_orders() + assert_equal(1, u1.ship.number) + assert_equal(nil, u2.ship) +end + +function test_give_ship_away() + local r = region.create(1, 0, 'ocean') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'longboat') + u1.ship.number = 2 + u1:add_order("GIB 0 1 SCHIFF") + process_orders() + assert_equal(1, u1.ship.number) + local count = 0 + for sh in r.ships do + assert_equal(1, sh.number) + count = count + 1 + end + assert_equal(2, count) +end + function test_give_ship_only_to_captain() local r = region.create(1, 0, 'ocean') local f = faction.create("human") local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) local u3 = unit.create(f, r, 1) - u1.ship = ship.create(r, 'boat') + u1.ship = ship.create(r, 'longboat') u1.ship.number = 2 - u2.ship = ship.create(r, 'boat') + u2.ship = ship.create(r, 'longboat') u3.ship = u2.ship u1:add_order("GIB " .. itoa36(u3.id) .. " 1 SCHIFF") process_orders() @@ -198,10 +265,10 @@ function test_give_ship_compatible_coasts() local f = faction.create("human") local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) - u1.ship = ship.create(r, 'boat') + u1.ship = ship.create(r, 'longboat') u1.ship.number = 4 u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") - u2.ship = ship.create(r, 'boat') + u2.ship = ship.create(r, 'longboat') -- cannot give a ship with different coast: u1.ship.coast = 1 @@ -242,8 +309,8 @@ function test_give_ship_only_from_captain() local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) local u3 = unit.create(f, r, 1) - u2.ship = ship.create(r, 'boat') - u1.ship = ship.create(r, 'boat') + u2.ship = ship.create(r, 'longboat') + u1.ship = ship.create(r, 'longboat') u1.ship.number = 2 u3.ship = u1.ship u3:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") @@ -257,8 +324,8 @@ function test_give_ship_merge() local f = faction.create("human") local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) - u2.ship = ship.create(r, 'boat') - u1.ship = ship.create(r, 'boat') + u2.ship = ship.create(r, 'longboat') + u1.ship = ship.create(r, 'longboat') u1.ship.number = 2 u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") process_orders() @@ -271,8 +338,8 @@ function test_give_ship_only_same() local f = faction.create("human") local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) - u2.ship = ship.create(r, 'boat') - u1.ship = ship.create(r, 'longboat') + u2.ship = ship.create(r, 'longboat') + u1.ship = ship.create(r, 'caravel') u1.ship.number = 2 u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") process_orders() @@ -285,7 +352,7 @@ function test_give_ship_scale() local f = faction.create("human") local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) - local sh = ship.create(r, 'boat') + local sh = ship.create(r, 'longboat') sh.number = 3 sh.damage = 9 sh.size = 12 @@ -305,10 +372,10 @@ function test_give_ship_all_ships() local f = faction.create("human", 'noreply@vg.no') local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) - u1.ship = ship.create(r, 'boat') + u1.ship = ship.create(r, 'longboat') u1.ship.damage = 2 u1.ship.number = 2 - u2.ship = ship.create(r, 'boat') + u2.ship = ship.create(r, 'longboat') u2.ship.number = 1 u1:add_order("GIB " .. itoa36(u2.id) .. " 2 SCHIFF") process_orders() @@ -323,7 +390,7 @@ function test_give_ship_self_only() local f2 = faction.create("human") local u1 = unit.create(f1, r, 1) local u2 = unit.create(f2, r, 1) - local sh = ship.create(r, 'boat') + local sh = ship.create(r, 'longboat') sh.number = 2 u1.ship = sh u1:add_order("GIB " .. itoa36(u2.id) .. " 1 SCHIFF") @@ -337,7 +404,7 @@ function test_give_ship_not_cursed() local f = faction.create("human") local u = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) - local sh = ship.create(r, 'boat') + local sh = ship.create(r, 'longboat') u.ship = sh u:add_item("speedsail", 1) u:add_order("BENUTZE 1 Sonnensegel") @@ -354,7 +421,7 @@ function test_speedsail_on_ship() local r = region.create(1, 0, 'plain') local f = faction.create("human") local u = unit.create(f, r, 1) - local sh = ship.create(r, 'boat') + local sh = ship.create(r, 'longboat') u.ship = sh u:add_item("speedsail", 1) u:add_order("BENUTZE 1 Sonnensegel") @@ -366,7 +433,7 @@ function test_no_speedsail_on_convoy() local r = region.create(1, 0, 'plain') local f = faction.create("human") local u = unit.create(f, r, 1) - local sh = ship.create(r, 'boat') + local sh = ship.create(r, 'longboat') u.ship = sh sh.number = 2 u:add_item("speedsail", 2) diff --git a/src/give.c b/src/give.c index 716bab933..ad157225a 100644 --- a/src/give.c +++ b/src/give.c @@ -299,6 +299,9 @@ static void transfer_ships(ship *s1, ship *s2, int n) s2->damage += s1->damage * n / s1->number; s2->size += s1->size * n / s1->number; s2->number += n; + if (s1->coast != NODIRECTION) { + s2->coast = s1->coast; + } scale_ship(s1, s1->number - n); } @@ -322,8 +325,9 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) { assert(u1->ship); assert(n > 0 && n <= u1->ship->number); - if (u1->faction != u2->faction) { - return msg_error(u1, ord, 324); + if (u1->ship->type->range < 3) { + /* Keine Boote und anderes Kleinzeug erlaubt */ + return msg_error(u1, ord, 326); } if (ship_cursed(u1->ship)) { return msg_error(u1, ord, 323); @@ -331,51 +335,72 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) if (u1 != ship_owner(u1->ship)) { return msg_error(u1, ord, 146); } - if (fval(u_race(u2), RCF_CANSAIL)) { - if (u2->ship) { - if (u2 != ship_owner(u2->ship)) { - return msg_error(u1, ord, 146); - } - if (u2->ship->type != u1->ship->type) { - return msg_error(u1, ord, 322); - } - if (ship_cursed(u2->ship)) { - return msg_error(u1, ord, 323); - } - if (u1->ship->coast != u2->ship->coast) { - if (u1->ship->coast != NODIRECTION) { - if (u2->ship->coast == NODIRECTION) { - u2->ship->coast = u1->ship->coast; + if (u2 == NULL) { + if (n < u1->ship->number) { + ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); + scale_ship(sh, 0); + transfer_ships(u1->ship, sh, n); + } + else { + return msg_error(u1, ord, 327); + } + } else { + if (u1->faction != u2->faction) { + return msg_error(u1, ord, 324); + } + if (fval(u_race(u2), RCF_CANSAIL)) { + if (u2->ship) { + if (u2->ship == u1->ship) { + ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); + scale_ship(sh, 0); + leave_ship(u2); + u_set_ship(u2, sh); + } else { + if (u2 != ship_owner(u2->ship)) { + return msg_error(u1, ord, 146); } - else { - return msg_error(u1, ord, 182); + if (u2->ship->type != u1->ship->type) { + return msg_error(u1, ord, 322); + } + if (ship_cursed(u2->ship)) { + return msg_error(u1, ord, 323); + } + if (u1->ship->coast != u2->ship->coast) { + if (u1->ship->coast != NODIRECTION) { + if (u2->ship->coast == NODIRECTION) { + u2->ship->coast = u1->ship->coast; + } + else { + return msg_error(u1, ord, 182); + } + } } } - } - if (n < u1->ship->number) { - transfer_ships(u1->ship, u2->ship, n); + if (n < u1->ship->number) { + transfer_ships(u1->ship, u2->ship, n); + } + else { + transfer_ships(u1->ship, u2->ship, n); + transfer_units(u1->ship, u2->ship); + } } else { - transfer_ships(u1->ship, u2->ship, n); - transfer_units(u1->ship, u2->ship); + if (n < u1->ship->number) { + ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); + scale_ship(sh, 0); + u_set_ship(u2, sh); + transfer_ships(u1->ship, sh, n); + } + else { + u_set_ship(u2, u1->ship); + ship_set_owner(u2); + } } } else { - if (n < u1->ship->number) { - ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); - scale_ship(sh, 0); - u_set_ship(u2, sh); - transfer_ships(u1->ship, sh, n); - } - else { - u_set_ship(u2, u1->ship); - ship_set_owner(u2); - } + return msg_error(u1, ord, 233); } } - else { - return msg_error(u1, ord, 233); - } return NULL; } From 12491ffc168b86e4ffa5dc99d6b562e27569b3f7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Oct 2019 20:24:18 +0200 Subject: [PATCH 50/72] GIB 0 an Land kann alle Schiffe geben, auf Ozean nicht. --- res/translations/messages.en.po | 3 +++ scripts/tests/e2/ships.lua | 16 ++++++++++++++-- src/give.c | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/res/translations/messages.en.po b/res/translations/messages.en.po index 135053782..659adee9f 100644 --- a/res/translations/messages.en.po +++ b/res/translations/messages.en.po @@ -2774,6 +2774,9 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Spells can only msgid "error326" msgstr "\"$unit($unit) in $region($region): '$order($command)' - These ships cannot form a convoy.\"" +msgid "error327" +msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit must keep at least one ship.\"" + msgid "error324" msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is not one of ours.\"" diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 9286cc8f1..416677d26 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -203,8 +203,8 @@ function test_give_ship_same_ship() assert_not_equal(u1.ship, u2.ship) end -function test_give_ship_dont_give_all() - local r = region.create(1, 0, 'ocean') +function test_give_ship_all_on_ocean() + local r = region.create(0, 0, 'ocean') local f = faction.create("human") local u1 = unit.create(f, r, 1) u1.ship = ship.create(r, 'longboat') @@ -214,6 +214,18 @@ function test_give_ship_dont_give_all() assert_equal(2, u1.ship.number) end +function test_give_ship_all_on_land() + local r = region.create(0, 0, 'plain') + local f = faction.create("human") + local u1 = unit.create(f, r, 1) + u1.ship = ship.create(r, 'longboat') + u1.ship.number = 2 + u1:add_order("GIB 0 2 SCHIFF") + process_orders() + assert_equal(nil, u1.ship) + assert_not_equal(nil, r.ships()) +end + function test_give_ship_no_boat() local r = region.create(1, 0, 'ocean') local f = faction.create("human") diff --git a/src/give.c b/src/give.c index ad157225a..47f472ec1 100644 --- a/src/give.c +++ b/src/give.c @@ -336,7 +336,7 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) return msg_error(u1, ord, 146); } if (u2 == NULL) { - if (n < u1->ship->number) { + if (fval(u1->region->terrain, LAND_REGION) || n < u1->ship->number) { ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); scale_ship(sh, 0); transfer_ships(u1->ship, sh, n); From d9cbbd9052ea3a756de3a8272646f5bae7c7746e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 Oct 2019 17:11:58 +0200 Subject: [PATCH 51/72] Bug 2614: Einheiten bewachen Region vor sich selbst. --- src/economy.c | 5 ++--- src/modules/autoseed.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/economy.c b/src/economy.c index b73845c06..377a71a6c 100644 --- a/src/economy.c +++ b/src/economy.c @@ -607,9 +607,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) if (itype->rtype && (itype->rtype == get_resourcetype(R_IRON) || itype->rtype == rt_find("laen"))) { unit *u2; for (u2 = r->units; u2; u2 = u2->next) { - if (is_guard(u) - && !fval(u2, UFL_ISNEW) - && u2->number && !alliedunit(u2, u->faction, HELP_GUARD)) { + if (!fval(u2, UFL_ISNEW) && u2->number + && is_guard(u2) && !alliedunit(u2, u->faction, HELP_GUARD)) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "region_guarded", "guard", u2)); return; diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 2cf931498..fca838c2a 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -874,10 +874,10 @@ int build_island(int x, int y, int minsize, newfaction ** players, int numfactio fset(r, RF_MARK); if (r->land) { if (nsize < minsize) { - nsize += random_neighbours(r, &rlist, &random_terrain, minsize - nsize); + nsize += random_neighbours(r, &rlist, random_terrain, minsize - nsize); } else { - nsize += random_neighbours(r, &rlist, &get_ocean, minsize - nsize); + nsize += random_neighbours(r, &rlist, get_ocean, minsize - nsize); } } regionqueue_push(&island, r); From d04fe741a9584fa2cd72949cd1d9b1328d233035 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 Oct 2019 18:04:49 +0200 Subject: [PATCH 52/72] https://bugs.eressea.de/view.php?id=2615 in the report, calculate max size of ships correctly. --- src/kernel/ship.c | 7 ++++++- src/kernel/ship.h | 14 +++++++------- src/report.c | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 601c36d82..80acbec12 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -373,10 +373,15 @@ const char *shipname(const ship * sh) return write_shipname(sh, ibuf, sizeof(idbuf[0])); } +int ship_maxsize(const ship *sh) +{ + return sh->number * sh->type->construction->maxsize; +} + bool ship_finished(const ship *sh) { if (sh->type->construction) { - return (sh->size >= sh->number * sh->type->construction->maxsize); + return (sh->size >= ship_maxsize(sh)); } return true; } diff --git a/src/kernel/ship.h b/src/kernel/ship.h index a9a678848..d21f9f3c3 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -93,20 +93,20 @@ extern "C" { const char *shipname(const struct ship *self); int ship_capacity(const struct ship *sh); int ship_cabins(const struct ship *sh); + int ship_maxsize(const struct ship *sh); bool ship_finished(const struct ship *sh); - extern void getshipweight(const struct ship *sh, int *weight, int *cabins); + void getshipweight(const struct ship *sh, int *weight, int *cabins); - extern ship *new_ship(const struct ship_type *stype, struct region *r, + ship *new_ship(const struct ship_type *stype, struct region *r, const struct locale *lang); - extern const char *write_shipname(const struct ship *sh, char *buffer, + const char *write_shipname(const struct ship *sh, char *buffer, size_t size); - extern struct ship *findship(int n); - extern struct ship *findshipr(const struct region *r, int n); + struct ship *findship(int n); - extern const struct ship_type *findshiptype(const char *s, + const struct ship_type *findshiptype(const char *s, const struct locale *lang); - extern void write_ship_reference(const struct ship *sh, + void write_ship_reference(const struct ship *sh, struct storage *store); void remove_ship(struct ship **slist, struct ship *s); diff --git a/src/report.c b/src/report.c index 407db00ff..7fdf8e690 100644 --- a/src/report.c +++ b/src/report.c @@ -1737,10 +1737,10 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f, sbs_printf(&sbs, "%s, %s", shipname(sh), LOC(f->locale, sh->type->_name)); } - if (sh->size != sh->type->construction->maxsize) { + if (!ship_finished(sh)) { sbs_printf(&sbs, ", %s (%d/%d)", LOC(f->locale, "nr_undercons"), sh->size, - sh->type->construction->maxsize); + ship_maxsize(sh)); } if (sh->damage) { int percent = ship_damage_percent(sh); From 70b148296f8d9bfa60d51c9933fd9dec53d550a0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 21 Oct 2019 20:04:32 +0200 Subject: [PATCH 53/72] =?UTF-8?q?MACHE=20besch=C3=A4digte=20Konvois?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tests/e2/ships.lua | 64 +++++++++++++++++++++++++++++++++++++- src/creport.c | 3 +- src/economy.c | 4 +-- src/kernel/build.c | 32 ++++++++++--------- src/kernel/build.h | 2 +- src/kernel/build.test.c | 24 +++++++------- src/kernel/ship.c | 5 ++- 7 files changed, 100 insertions(+), 34 deletions(-) diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 416677d26..bab27d0a9 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -312,7 +312,6 @@ function test_give_ship_compatible_coasts() assert_equal(1, u1.ship.number) assert_equal(4, u2.ship.number) assert_equal(2, u2.ship.coast) - end function test_give_ship_only_from_captain() @@ -453,3 +452,66 @@ function test_no_speedsail_on_convoy() process_orders() assert_equal(nil, sh:get_curse('shipspeedup')) end + +function test_build_ship() + local r = region.create(1, 0, 'plain') + local f = faction.create("insect") + local u = unit.create(f, r, 25) + local sh = ship.create(r, 'longboat') + u.ship = sh + sh.size = 25 + u:set_skill('shipcraft', 1) + u:add_item("log", 50) + u:add_order("MACHE SCHIFF " .. itoa36(sh.id)) + process_orders() + assert_equal(50, sh.size) + assert_equal(25, u:get_item('log')) +end + +function test_build_convoi() + local r = region.create(1, 0, 'plain') + local f = faction.create("insect") + local u = unit.create(f, r, 50) + local sh = ship.create(r, 'longboat') + u.ship = sh + sh.number = 2 + sh.size = 25 + u:set_skill('shipcraft', 1) + u:add_item("log", 100) + u:add_order("MACHE SCHIFF " .. itoa36(sh.id)) + process_orders() + assert_equal(75, sh.size) + assert_equal(50, u:get_item('log')) +end + +function test_repair_convoi() + local r = region.create(1, 0, 'plain') + local f = faction.create("insect") + local u = unit.create(f, r, 50) + local sh = ship.create(r, 'longboat') + u.ship = sh + sh.number = 2 + sh.damage = 7500 -- 75 Holz + u:set_skill('shipcraft', 1) + u:add_item("log", 100) + u:add_order("MACHE SCHIFF " .. itoa36(sh.id)) + process_orders() + assert_equal(2500, sh.damage) + assert_equal(50, u:get_item('log')) +end + +function test_build_convoi_max() + local r = region.create(1, 0, 'plain') + local f = faction.create("insect") + local u = unit.create(f, r, 100) + local sh = ship.create(r, 'longboat') + u.ship = sh + sh.number = 2 + sh.size = 25 + u:set_skill('shipcraft', 1) + u:add_item("log", 100) + u:add_order("MACHE SCHIFF " .. itoa36(sh.id)) + process_orders() + assert_equal(100, sh.size) + assert_equal(25, u:get_item('log')) +end diff --git a/src/creport.c b/src/creport.c index 46b998066..f9bffd177 100644 --- a/src/creport.c +++ b/src/creport.c @@ -700,8 +700,7 @@ static void cr_output_ship(struct stream *out, const ship *sh, const unit *u, stream_printf(out, "%d;Anzahl\n", sh->number); stream_printf(out, "%d;Groesse\n", sh->size); if (sh->damage) { - int percent = - (sh->damage * 100 + DAMAGE_SCALE - 1) / (sh->size * DAMAGE_SCALE); + int percent = ship_damage_percent(sh); stream_printf(out, "%d;Schaden\n", percent); } if (u) { diff --git a/src/economy.c b/src/economy.c index 377a71a6c..7cd28f6b9 100644 --- a/src/economy.c +++ b/src/economy.c @@ -509,7 +509,7 @@ static void manufacture(unit * u, const item_type * itype, int want) if (want == 0) { want = maxbuild(u, itype->construction); } - n = build(u, itype->construction, 0, want, skill_mod); + n = build(u, 1, itype->construction, 0, want, skill_mod); switch (n) { case ENEEDSKILL: ADDMSG(&u->faction->msgs, @@ -850,7 +850,7 @@ static void create_potion(unit * u, const item_type * itype, int want) if (want == 0) { want = maxbuild(u, itype->construction); } - built = build(u, itype->construction, 0, want, 0); + built = build(u, 1, itype->construction, 0, want, 0); switch (built) { case ELOWSKILL: case ENEEDSKILL: diff --git a/src/kernel/build.c b/src/kernel/build.c index 447db8662..29dfc81f0 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -224,7 +224,7 @@ int destroy_cmd(unit * u, struct order *ord) return 14; } - if (n >= (sh->size * 100) / sh->type->construction->maxsize) { + if (n >= (sh->size * 100) / ship_maxsize(sh)) { /* destroy completly */ /* all units leave the ship */ for (u2 = r->units; u2; u2 = u2->next) { @@ -509,9 +509,9 @@ int build_skill(unit *u, int basesk, int skill_mod) { * of the first object have already been finished. return the * actual size that could be built. */ -static int build_limited(unit * u, const construction * con, int completed, int want, int basesk, int *skill_total) { +static int build_limited(unit * u, const construction * con, int completed, int number, int want, int basesk, int *skill_total) { int skills = *skill_total; - int made = 0; + int made = 0, maxsize = con->maxsize * number; if (want <= 0) { return 0; @@ -519,7 +519,7 @@ static int build_limited(unit * u, const construction * con, int completed, int if (con == NULL) { return ENOMATERIALS; } - if (completed == con->maxsize) { + if (completed == maxsize) { return ECOMPLETE; } for (; want > 0 && skills > 0;) { @@ -530,8 +530,8 @@ static int build_limited(unit * u, const construction * con, int completed, int * (enno): Nein, das ist fuer Dinge, bei denen die naechste Ausbaustufe * die gleiche wie die vorherige ist. z.b. Gegenstaende. */ - if (con->maxsize > 0) { - completed = completed % con->maxsize; + if (maxsize > 0) { + completed = completed % (maxsize); } else { completed = 0; @@ -566,8 +566,8 @@ static int build_limited(unit * u, const construction * con, int completed, int if (want < n) n = want; - if (con->maxsize > 0) { - int req = con->maxsize - completed; + if (maxsize > 0) { + int req = maxsize - completed; if (req < n) n = req; want = n; } @@ -592,11 +592,12 @@ static int build_limited(unit * u, const construction * con, int completed, int return made; } -int build(unit * u, const construction * con, int completed, int want, int skill_mod) +int build(unit * u, int number, const construction * con, int completed, int want, int skill_mod) { int skills = INT_MAX; /* number of skill points remainig */ int made, basesk = 0; + assert(number >= 1); assert(con->skill != NOSKILL); basesk = effskill(u, con->skill, NULL); if (basesk == 0) { @@ -604,7 +605,7 @@ int build(unit * u, const construction * con, int completed, int want, int skill } skills = build_skill(u, basesk, skill_mod); - made = build_limited(u, con, completed, want, basesk, &skills); + made = build_limited(u, con, completed, number, want, basesk, &skills); /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ if (made > 0) { produceexp(u, con->skill, (made < u->number) ? made : u->number); @@ -698,7 +699,7 @@ static int build_stages(unit *u, const building_type *btype, int built, int n, i want = todo; } } - err = build_limited(u, con, built, want, basesk, skill_total); + err = build_limited(u, con, 1, built, want, basesk, skill_total); if (err < 0) { if (made == 0) { /* could not make any part at all */ @@ -904,9 +905,9 @@ static void build_ship(unit * u, ship * sh, int want) const construction *construction = sh->type->construction; int size = (sh->size * DAMAGE_SCALE - sh->damage) / DAMAGE_SCALE; int n; - int can = build(u, construction, size, want, 0); + int can = build(u, sh->number, construction, size, want, 0); - if ((n = construction->maxsize - sh->size) > 0 && can > 0) { + if ((n = ship_maxsize(sh) - sh->size) > 0 && can > 0) { if (can >= n) { sh->size += n; can -= n; @@ -1000,11 +1001,12 @@ void continue_ship(unit * u, int want) cmistake(u, u->thisorder, 20, MSG_PRODUCE); return; } - cons = sh->type->construction; - if (sh->size == cons->maxsize && !sh->damage) { + msize = ship_maxsize(sh); + if (sh->size >= msize && !sh->damage) { cmistake(u, u->thisorder, 16, MSG_PRODUCE); return; } + cons = sh->type->construction; if (effskill(u, cons->skill, NULL) < cons->minskill) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_build_skill_low", "value", cons->minskill)); diff --git a/src/kernel/build.h b/src/kernel/build.h index d37d7fa12..523ec0e63 100644 --- a/src/kernel/build.h +++ b/src/kernel/build.h @@ -44,7 +44,7 @@ extern "C" { void sunhash(struct ship *sh); int roqf_factor(void); - int build(struct unit *u, const construction * ctype, int completed, int want, int skill_mod); + int build(struct unit *u, int number, const construction * ctype, int completed, int want, int skill_mod); int maxbuild(const struct unit *u, const construction * cons); struct message *msg_materials_required(struct unit *u, struct order *ord, const struct construction *ctype, int multi); diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c index 4eba0baaf..5534ebc32 100644 --- a/src/kernel/build.test.c +++ b/src/kernel/build.test.c @@ -145,10 +145,10 @@ static void test_build_requires_materials(CuTest *tc) { u = setup_build(&bf); set_level(u, SK_ARMORER, 2); - CuAssertIntEquals(tc, ENOMATERIALS, build(u, &bf.cons, 0, 1, 0)); + CuAssertIntEquals(tc, ENOMATERIALS, build(u, 1, &bf.cons, 0, 1, 0)); itype = bf.cons.materials[0].rtype->itype; i_change(&u->items, itype, 2); - CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 1, 0)); + CuAssertIntEquals(tc, 1, build(u, 1, &bf.cons, 0, 1, 0)); CuAssertIntEquals(tc, 1, i_get(u->items, itype)); teardown_build(&bf); } @@ -161,7 +161,7 @@ static void test_build_failure_missing_skill(CuTest *tc) { u = setup_build(&bf); rtype = bf.cons.materials[0].rtype; i_change(&u->items, rtype->itype, 1); - CuAssertIntEquals(tc, ENEEDSKILL, build(u, &bf.cons, 1, 1, 0)); + CuAssertIntEquals(tc, ENEEDSKILL, build(u, 1, &bf.cons, 1, 1, 0)); teardown_build(&bf); } @@ -174,7 +174,7 @@ static void test_build_failure_low_skill(CuTest *tc) { rtype = bf.cons.materials[0].rtype; i_change(&u->items, rtype->itype, 1); set_level(u, SK_ARMORER, bf.cons.minskill - 1); - CuAssertIntEquals(tc, ELOWSKILL, build(u, &bf.cons, 0, 10, 0)); + CuAssertIntEquals(tc, ELOWSKILL, build(u, 1, &bf.cons, 0, 10, 0)); teardown_build(&bf); } @@ -188,7 +188,7 @@ static void test_build_failure_completed(CuTest *tc) { i_change(&u->items, rtype->itype, 1); set_level(u, SK_ARMORER, bf.cons.minskill); bf.cons.maxsize = 1; - CuAssertIntEquals(tc, ECOMPLETE, build(u, &bf.cons, bf.cons.maxsize, 10, 0)); + CuAssertIntEquals(tc, ECOMPLETE, build(u, 1, &bf.cons, bf.cons.maxsize, 10, 0)); CuAssertIntEquals(tc, 1, i_get(u->items, rtype->itype)); teardown_build(&bf); } @@ -203,19 +203,19 @@ static void test_build_limits(CuTest *tc) { assert(rtype); i_change(&u->items, rtype->itype, 1); set_level(u, SK_ARMORER, bf.cons.minskill); - CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 10, 0)); + CuAssertIntEquals(tc, 1, build(u, 1, &bf.cons, 0, 10, 0)); CuAssertIntEquals(tc, 0, i_get(u->items, rtype->itype)); scale_number(u, 2); set_level(u, SK_ARMORER, bf.cons.minskill); i_change(&u->items, rtype->itype, 2); - CuAssertIntEquals(tc, 2, build(u, &bf.cons, 0, 10, 0)); + CuAssertIntEquals(tc, 2, build(u, 1, &bf.cons, 0, 10, 0)); CuAssertIntEquals(tc, 0, i_get(u->items, rtype->itype)); scale_number(u, 2); set_level(u, SK_ARMORER, bf.cons.minskill * 2); i_change(&u->items, rtype->itype, 4); - CuAssertIntEquals(tc, 4, build(u, &bf.cons, 0, 10, 0)); + CuAssertIntEquals(tc, 4, build(u, 1, &bf.cons, 0, 10, 0)); CuAssertIntEquals(tc, 0, i_get(u->items, rtype->itype)); teardown_build(&bf); } @@ -234,7 +234,7 @@ static void test_build_with_ring(CuTest *tc) { set_level(u, SK_ARMORER, bf.cons.minskill); i_change(&u->items, rtype->itype, 20); i_change(&u->items, ring, 1); - CuAssertIntEquals(tc, 10, build(u, &bf.cons, 0, 20, 0)); + CuAssertIntEquals(tc, 10, build(u, 1, &bf.cons, 0, 20, 0)); CuAssertIntEquals(tc, 10, i_get(u->items, rtype->itype)); teardown_build(&bf); } @@ -253,16 +253,16 @@ static void test_build_with_potion(CuTest *tc) { i_change(&u->items, rtype->itype, 20); change_effect(u, ptype, 4); set_level(u, SK_ARMORER, bf.cons.minskill); - CuAssertIntEquals(tc, 2, build(u, &bf.cons, 0, 20, 0)); + CuAssertIntEquals(tc, 2, build(u, 1, &bf.cons, 0, 20, 0)); CuAssertIntEquals(tc, 18, i_get(u->items, rtype->itype)); CuAssertIntEquals(tc, 3, get_effect(u, ptype)); set_level(u, SK_ARMORER, bf.cons.minskill * 2); - CuAssertIntEquals(tc, 4, build(u, &bf.cons, 0, 20, 0)); + CuAssertIntEquals(tc, 4, build(u, 1, &bf.cons, 0, 20, 0)); CuAssertIntEquals(tc, 2, get_effect(u, ptype)); set_level(u, SK_ARMORER, bf.cons.minskill); scale_number(u, 2); /* OBS: this scales the effects, too: */ CuAssertIntEquals(tc, 4, get_effect(u, ptype)); - CuAssertIntEquals(tc, 4, build(u, &bf.cons, 0, 20, 0)); + CuAssertIntEquals(tc, 4, build(u, 1, &bf.cons, 0, 20, 0)); CuAssertIntEquals(tc, 2, get_effect(u, ptype)); teardown_build(&bf); } diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 80acbec12..56551e0f2 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -538,5 +538,8 @@ const char *ship_getname(const ship * sh) } int ship_damage_percent(const ship *sh) { - return (sh->damage * 100 + DAMAGE_SCALE - 1) / (sh->size * DAMAGE_SCALE); + /* Schaden muss granularer sein als Größe, deshalb ist er skaliert + * DAMAGE_SCALE ist der Faktor zwischen 1 Schadenspunkt und 1 Größenpunkt. + */ + return ((DAMAGE_SCALE - 1) + sh->damage * 100) / (sh->size * DAMAGE_SCALE); } From f64020157cfc15f5836f83ba247534f75d281849 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 21 Oct 2019 20:07:55 +0200 Subject: [PATCH 54/72] test name spelling fix --- scripts/tests/e2/ships.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index bab27d0a9..5b77220ec 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -468,7 +468,7 @@ function test_build_ship() assert_equal(25, u:get_item('log')) end -function test_build_convoi() +function test_build_convoy() local r = region.create(1, 0, 'plain') local f = faction.create("insect") local u = unit.create(f, r, 50) @@ -484,7 +484,7 @@ function test_build_convoi() assert_equal(50, u:get_item('log')) end -function test_repair_convoi() +function test_repair_convoy() local r = region.create(1, 0, 'plain') local f = faction.create("insect") local u = unit.create(f, r, 50) @@ -500,7 +500,7 @@ function test_repair_convoi() assert_equal(50, u:get_item('log')) end -function test_build_convoi_max() +function test_build_convoy_max() local r = region.create(1, 0, 'plain') local f = faction.create("insect") local u = unit.create(f, r, 100) From 75a71c36aae902a8bcdfc5cb62dba5081cc482d2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 22 Oct 2019 18:46:00 +0200 Subject: [PATCH 55/72] ZERSTOERE Schiffe evtl. auch richtig? Best effort. --- src/kernel/build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/build.c b/src/kernel/build.c index 29dfc81f0..d9e1cc8bc 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -239,7 +239,7 @@ int destroy_cmd(unit * u, struct order *ord) } else { /* partial destroy */ - sh->size -= (sh->type->construction->maxsize * n) / 100; + sh->size -= (ship_maxsize(sh) * n) / 100; ADDMSG(&u->faction->msgs, msg_message("shipdestroy_partial", "unit region ship", u, r, sh)); } From 1c358b99823806923c0d3f5fdb8d5ae01d9dde9b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 22 Oct 2019 18:56:04 +0200 Subject: [PATCH 56/72] bug 2263: skeletons and undead can guard and desert. --- res/e3a/races.xml | 8 ++++---- res/eressea/races.xml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index e2fea2acb..117759ca8 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -703,8 +703,8 @@ + walk="yes" learn="no" teach="no" noheal="yes" desert="yes" + undead="yes" equipment="yes" giveperson="yes" unarmedguard="yes"> @@ -801,7 +801,7 @@ - + @@ -816,7 +816,7 @@ - + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index c858aceb1..82b642ba2 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -732,7 +732,7 @@ - + @@ -1044,7 +1044,7 @@ - + @@ -1058,7 +1058,7 @@ - + From c82b3b27dda63b54e02f2e7187f6d63402bf15c6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 22 Oct 2019 21:30:14 +0200 Subject: [PATCH 57/72] =?UTF-8?q?Bug=202616:=20FOLGE=20schiesst=20=C3=BCbe?= =?UTF-8?q?r=20das=20Ziel=20hinaus.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/move.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/move.c b/src/move.c index 484ee993f..7a636d2f0 100644 --- a/src/move.c +++ b/src/move.c @@ -2227,6 +2227,7 @@ int follow_ship(unit * u, order * ord) int moves, id, speed; char command[256]; direction_t dir; + ship *sh; if (fval(u, UFL_NOTMOVING)) { return 0; @@ -2251,10 +2252,10 @@ int follow_ship(unit * u, order * ord) return 0; } + sh = findship(id); dir = hunted_dir(rc->attribs, id); if (dir == NODIRECTION) { - ship *sh = findship(id); if (sh == NULL || sh->region != rc) { cmistake(u, ord, 20, MSG_MOVE); } @@ -2278,7 +2279,7 @@ int follow_ship(unit * u, order * ord) speed = maxspeed; } rc = rconnect(rc, dir); - while (rc && moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION) { + while (rc && rc != sh->region && moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION) { const char *loc = LOC(u->faction->locale, directions[dir]); sbs_strcat(&sbcmd, " "); sbs_strcat(&sbcmd, loc); From 533a0aceec949ea2ee2caed8370b728e34b61505 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 23 Oct 2019 23:17:31 +0200 Subject: [PATCH 58/72] fix crash when following a lost ship --- src/move.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/move.c b/src/move.c index 7a636d2f0..18cb5098d 100644 --- a/src/move.c +++ b/src/move.c @@ -2279,7 +2279,7 @@ int follow_ship(unit * u, order * ord) speed = maxspeed; } rc = rconnect(rc, dir); - while (rc && rc != sh->region && moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION) { + while (rc && (!sh || rc != sh->region) && moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION) { const char *loc = LOC(u->faction->locale, directions[dir]); sbs_strcat(&sbcmd, " "); sbs_strcat(&sbcmd, loc); From c8769a4412782d45e2de8550f598386acc313f0b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 27 Oct 2019 10:56:16 +0100 Subject: [PATCH 59/72] Fehler in ship_crewed Berechnung --- src/kernel/ship.c | 13 ++++------- src/kernel/ship.test.c | 53 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 56551e0f2..87194834b 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -407,22 +407,19 @@ int crew_skill(const ship *sh) { } bool ship_crewed(const ship *sh) { - unit *u; + unit *u, *cap = ship_owner(sh); int capskill = -1, sumskill = 0; for (u = sh->region->units; u; u = u->next) { if (u->ship == sh) { int es = effskill(u, SK_SAILING, NULL); - if (capskill < 0) { - if (u->number >= sh->number) { + if (es > 0) { + if (u == cap && u->number >= sh->number) { capskill = es; } - else { - capskill = 0; + if (es >= sh->type->minskill) { + sumskill += es * u->number; } } - if (es >= sh->type->minskill) { - sumskill += es * u->number; - } } } return (capskill >= ship_captain_minskill(sh)) && (sumskill >= sh->type->sumskill * sh->number); diff --git a/src/kernel/ship.test.c b/src/kernel/ship.test.c index 062e7cd20..ddc0d7795 100644 --- a/src/kernel/ship.test.c +++ b/src/kernel/ship.test.c @@ -30,6 +30,58 @@ static void test_register_ship(CuTest * tc) test_teardown(); } +static void test_ship_crewed(CuTest * tc) +{ + struct region *r; + struct faction *f; + struct ship *sh; + struct unit *u1, *u2; + struct ship_type *stype; + + test_setup(); + f = test_create_faction(NULL); + r = test_create_ocean(0, 0); + stype = test_create_shiptype("longboat"); + stype->cptskill = 2; + stype->sumskill = 4; + sh = test_create_ship(r, stype); + CuAssertTrue(tc, !ship_crewed(sh)); + u1 = test_create_unit(f, r); + set_level(u1, SK_SAILING, 4); + u_set_ship(u1, sh); + CuAssertTrue(tc, ship_crewed(sh)); + u2 = test_create_unit(f, r); + set_level(u1, SK_SAILING, 2); + set_level(u1, SK_SAILING, 2); + u_set_ship(u2, sh); + CuAssertTrue(tc, ship_crewed(sh)); + set_level(u1, SK_SAILING, 1); + set_level(u2, SK_SAILING, 2); + CuAssertTrue(tc, !ship_crewed(sh)); + set_level(u1, SK_SAILING, 2); + set_level(u2, SK_SAILING, 1); + CuAssertTrue(tc, !ship_crewed(sh)); + set_level(u1, SK_SAILING, 3); + set_level(u2, SK_SAILING, 1); + CuAssertTrue(tc, ship_crewed(sh)); + stype->minskill = 2; + CuAssertTrue(tc, !ship_crewed(sh)); + set_level(u1, SK_SAILING, 2); + set_level(u2, SK_SAILING, 2); + CuAssertTrue(tc, ship_crewed(sh)); + sh->number = 2; + CuAssertTrue(tc, !ship_crewed(sh)); + set_level(u1, SK_SAILING, 4); + set_level(u2, SK_SAILING, 4); + CuAssertTrue(tc, !ship_crewed(sh)); + u1->number = 2; + set_level(u1, SK_SAILING, 2); + set_level(u2, SK_SAILING, 4); + CuAssertTrue(tc, ship_crewed(sh)); + + test_teardown(); +} + static void test_ship_set_owner(CuTest * tc) { struct region *r; @@ -665,6 +717,7 @@ CuSuite *get_ship_suite(void) SUITE_ADD_TEST(suite, test_register_ship); SUITE_ADD_TEST(suite, test_stype_defaults); SUITE_ADD_TEST(suite, test_ship_set_owner); + SUITE_ADD_TEST(suite, test_ship_crewed); SUITE_ADD_TEST(suite, test_shipowner_resets_when_empty); SUITE_ADD_TEST(suite, test_shipowner_goes_to_next_when_empty); SUITE_ADD_TEST(suite, test_shipowner_goes_to_other_when_empty); From 7f57aa2a18faeaeff0a249d101977695c665e245 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 27 Oct 2019 10:57:32 +0100 Subject: [PATCH 60/72] small copy/paste error --- src/kernel/ship.test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/ship.test.c b/src/kernel/ship.test.c index ddc0d7795..174762182 100644 --- a/src/kernel/ship.test.c +++ b/src/kernel/ship.test.c @@ -52,7 +52,7 @@ static void test_ship_crewed(CuTest * tc) CuAssertTrue(tc, ship_crewed(sh)); u2 = test_create_unit(f, r); set_level(u1, SK_SAILING, 2); - set_level(u1, SK_SAILING, 2); + set_level(u2, SK_SAILING, 2); u_set_ship(u2, sh); CuAssertTrue(tc, ship_crewed(sh)); set_level(u1, SK_SAILING, 1); From 0db8f2167bef44f628e2c1b195e1e92e57e09812 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 28 Oct 2019 20:09:35 +0100 Subject: [PATCH 61/72] =?UTF-8?q?Bug=202618:=20Zus=C3=A4tzlicher=20Test=20?= =?UTF-8?q?Piraterie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tests/e2/init.lua | 2 +- scripts/tests/e2/movement.lua | 35 +++++++++++++++++++++++++++++++---- src/move.c | 14 ++++++-------- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 28d7ebc9b..0f377a991 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,6 +1,6 @@ +require 'tests.e2.movement' require 'tests.e2.carts' require 'tests.e2.quit' -require 'tests.e2.movement' require 'tests.e2.astral' require 'tests.e2.spells' require 'tests.e2.e2features' diff --git a/scripts/tests/e2/movement.lua b/scripts/tests/e2/movement.lua index 2d8d6b7a7..aa42857f3 100644 --- a/scripts/tests/e2/movement.lua +++ b/scripts/tests/e2/movement.lua @@ -5,11 +5,40 @@ module("tests.e2.movement", package.seeall, lunit.testcase) function setup() eressea.free_game() eressea.settings.set("rules.food.flags", "4") + eressea.settings.set("rules.ship.damage.nocrewocean", "0") + eressea.settings.set("rules.ship.damage.nocrew", "0") + eressea.settings.set("rules.ship.drifting", "0") + eressea.settings.set("rules.ship.storms", "0") eressea.settings.set("nmr.timeout", "0") eressea.settings.set("NewbieImmunity", "0") end function test_piracy() + local r = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "ocean") + local r3 = region.create(-1, 0, "ocean") + local f = faction.create("human", "pirate@eressea.de", "de") + local f2 = faction.create("human", "elf@eressea.de", "de") + local u1 = unit.create(f, r2, 1) + local u2 = unit.create(f2, r3, 1) + + u1.ship = ship.create(r2, "longboat") + u2.ship = ship.create(r3, "longboat") + u1:set_skill("sailing", 10) + u2:set_skill("sailing", 10) + + u1:clear_orders() + u1:add_order("PIRATERIE") + u2:clear_orders() + u2:add_order("NACH o") + + process_orders() + + assert_equal(r, u2.region) -- Nach Osten + assert_equal(r, u1.region) -- Entern! +end + +function test_piracy_to_land() local r = region.create(0, 0, "plain") local r2 = region.create(1, 0, "plain") local r3 = region.create(-1, 0, "ocean") @@ -30,10 +59,8 @@ function test_piracy() process_orders() - if r2~=u1.region then - write_reports() - end - assert_equal(r2, u1.region) -- should pass, but fails!!! + assert_equal(r, u2.region) -- Nach Osten + assert_equal(r2, u1.region) -- bewegt sich nicht end function test_dolphin_on_land() diff --git a/src/move.c b/src/move.c index 18cb5098d..0fc6f6411 100644 --- a/src/move.c +++ b/src/move.c @@ -696,18 +696,17 @@ int check_ship_allowed(struct ship *sh, const region * r) return SA_NO_COAST; } -static void set_coast(ship * sh, region * r, region * rnext) +static enum direction_t set_coast(ship * sh, region * r, region * rnext) { if (sh->type->flags & SFL_NOCOAST) { - sh->coast = NODIRECTION; + return sh->coast = NODIRECTION; } else if (!fval(rnext->terrain, SEA_REGION) && !flying_ship(sh)) { - sh->coast = reldirection(rnext, r); - assert(fval(r->terrain, SEA_REGION)); - } - else { - sh->coast = NODIRECTION; + if (fval(r->terrain, SEA_REGION)) { + return sh->coast = reldirection(rnext, r); + } } + return sh->coast = NODIRECTION; } static double overload_start(void) { @@ -1923,7 +1922,6 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) replace_order(&u->orders, ord, norder); free_order(norder); } - set_order(&u->thisorder, NULL); set_coast(sh, last_point, current_point); if (is_cursed(sh->attribs, &ct_flyingship)) { From 68fa43130f1b6fd34f003f750e87269f853a8f3a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 28 Oct 2019 20:22:40 +0100 Subject: [PATCH 62/72] test travis arm builds --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index d7a014d89..174c21efa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ sudo: false language: c +arch: + - amd64 + - arm64 compiler: - gcc - clang From 6c37b122b421fcf9302ee6c3ec210a8fe1d5b3ce Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 28 Oct 2019 20:35:15 +0100 Subject: [PATCH 63/72] no arm builds, valgrind --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 174c21efa..d7a014d89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ sudo: false language: c -arch: - - amd64 - - arm64 compiler: - gcc - clang From 52ee682a4891660fdfceb2c4ed6ec2afab1685b6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 2 Nov 2019 19:09:15 +0100 Subject: [PATCH 64/72] =?UTF-8?q?Bug=202617:=20Berechnung=20von=20=C3=9Cbe?= =?UTF-8?q?rladung=20berechnet=20Flotten=20korrekt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/move.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/move.c b/src/move.c index 0fc6f6411..e444ead56 100644 --- a/src/move.c +++ b/src/move.c @@ -501,7 +501,7 @@ static double overload(const region * r, ship * sh) double ovl; getshipweight(sh, &n, &p); - ovl = n / (double)sh->type->cargo; + ovl = n / (double)(sh->type->cargo * sh->number); if (mcabins) { ovl = fmax(ovl, p / (double)mcabins); } @@ -746,7 +746,7 @@ double damage_overload(double overload) } /* message to all factions in ship, start from firstu, end before lastu (may be NULL) */ -static void msg_to_ship_inmates(ship *sh, unit **firstu, unit **lastu, message *msg) { +static void msg_to_passengers(ship *sh, unit **firstu, unit **lastu, message *msg) { unit *u, *shipfirst = NULL; for (u = *firstu; u != *lastu; u = u->next) { if (u->ship == sh) { @@ -836,19 +836,19 @@ static void drifting_ships(region * r) if (rnext && firstu) { message *msg = msg_message("ship_drift", "ship dir", sh, dir); - msg_to_ship_inmates(sh, &firstu, &lastu, msg); + msg_to_passengers(sh, &firstu, &lastu, msg); } fset(sh, SF_DRIFTED); if (ovl >= overload_start()) { damage_ship(sh, damage_overload(ovl)); - msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh)); + msg_to_passengers(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh)); } else { damage_ship(sh, damage_drift); } if (sh->damage >= sh->size * DAMAGE_SCALE) { - msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("shipsink", "ship", sh)); + msg_to_passengers(sh, &firstu, &lastu, msg_message("shipsink", "ship", sh)); sink_ship(sh); remove_ship(shp, sh); } From fd1b981983f58b86838921fb2dcdfba655e69d33 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 2 Nov 2019 21:32:11 +0100 Subject: [PATCH 65/72] simplify sail/travel, remove route from arguments. --- src/move.c | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/src/move.c b/src/move.c index e444ead56..d33987d54 100644 --- a/src/move.c +++ b/src/move.c @@ -1683,12 +1683,13 @@ bool can_takeoff(const ship * sh, const region * from, const region * to) return true; } -static void sail(unit * u, order * ord, region_list ** routep, bool drifting) +static void sail(unit * u, order * ord, bool drifting) { + region_list *route = NULL; region *starting_point = u->region; region *current_point, *last_point; int k, step = 0; - region_list **iroute = routep; + region_list **iroute = &route; ship *sh = u->ship; faction *f = u->faction; region *next_point = NULL; @@ -1698,10 +1699,6 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) int lighthouse_div = config_get_int("rules.storm.lighthouse.divisor", 0); const char *token = getstrtoken(); - if (routep) { - *routep = NULL; - } - error = movewhere(u, token, starting_point, &next_point); if (error) { message *msg = movement_error(u, token, ord, error); @@ -1940,7 +1937,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) if (fval(u, UFL_FOLLOWING)) caught_target(current_point, u); - move_ship(sh, starting_point, current_point, routep ? *routep : NULL); + move_ship(sh, starting_point, current_point, route); /* Hafengebuehren ? */ @@ -1982,6 +1979,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) } } } + free_regionlist(route); } /* Segeln, Wandern, Reiten @@ -2088,14 +2086,12 @@ static const region_list *travel_i(unit * u, const region_list * route_begin, /** traveling without ships * walking, flying or riding units use this function */ -static void travel(unit * u, order *ord, region_list ** routep) +static void travel(unit * u, order *ord) { - region *r = u->region; - region_list *route_begin; - follower *followers = NULL; + region_list *route = NULL; - assert(routep); - *routep = NULL; + region *r = u->region; + follower *followers = NULL; /* a few pre-checks that need not be done for each step: */ if (!fval(r->terrain, SEA_REGION)) { @@ -2131,12 +2127,10 @@ static void travel(unit * u, order *ord, region_list ** routep) return; } - make_route(u, ord, routep); - route_begin = *routep; - - if (route_begin) { + make_route(u, ord, &route); + if (route) { /* und ab die post: */ - travel_i(u, route_begin, NULL, ord, TRAVEL_NORMAL, &followers); + travel_i(u, route, NULL, ord, TRAVEL_NORMAL, &followers); /* followers */ while (followers != NULL) { @@ -2157,34 +2151,30 @@ static void travel(unit * u, order *ord, region_list ** routep) follow_order = create_order(K_FOLLOW, lang, "%s %i", s, ut->no); - route_end = reroute(uf, route_begin, route_end); - travel_i(uf, route_begin, route_end, follow_order, TRAVEL_FOLLOWING, + route_end = reroute(uf, route, route_end); + travel_i(uf, route, route_end, follow_order, TRAVEL_FOLLOWING, &followers); caught_target(uf->region, uf); free_order(follow_order); } } + free_regionlist(route); } } void move_cmd(unit * u, order * ord) { - region_list *route = NULL; - assert(u->number); if (u->ship && u == ship_owner(u->ship)) { bool drifting = (getkeyword(ord) == K_MOVE); - sail(u, ord, &route, drifting); + sail(u, ord, drifting); } else { - travel(u, ord, &route); + travel(u, ord); } fset(u, UFL_LONGACTION | UFL_NOTMOVING); set_order(&u->thisorder, NULL); - - if (route != NULL) - free_regionlist(route); } static void age_traveldir(region * r) From 7850e84cea5f48983a3e5ef3cf1fed8186a4e077 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 2 Nov 2019 21:37:33 +0100 Subject: [PATCH 66/72] let's try increasing MAX_UNITSIZE to 128K --- src/kernel/unit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/unit.h b/src/kernel/unit.h index 863dccd13..c77cfdb7a 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -54,7 +54,7 @@ extern "C" { /* Flags, die gespeichert werden sollen: */ #define UFL_SAVEMASK (UFL_DEFENDER|UFL_MOVED|UFL_NOAID|UFL_ANON_FACTION|UFL_LOCKED|UFL_HUNGER|UFL_TAKEALL|UFL_GUARD|UFL_STEALTH|UFL_GROUP|UFL_HERO) -#define UNIT_MAXSIZE 50000 +#define UNIT_MAXSIZE 128 * 1024 extern int maxheroes(const struct faction *f); extern int countheroes(const struct faction *f); From 75000f266306d7f940c94f9f3381f12d316c290d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 17 Nov 2019 19:55:41 +0100 Subject: [PATCH 67/72] reduce struct person by 12 bytes on a 32-bit arch. --- src/battle.c | 18 ++++-------------- src/battle.h | 16 ++++++++-------- src/exparse.c | 2 +- src/kernel/item.c | 2 +- src/kernel/item.h | 4 ++-- src/spells/combatspells.c | 2 +- 6 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/battle.c b/src/battle.c index 835917e62..a0e03f1f9 100644 --- a/src/battle.c +++ b/src/battle.c @@ -104,8 +104,6 @@ const troop no_troop = { 0, 0 }; #define LOOT_KEEPLOOT (1<<4) #define DAMAGE_CRITICAL (1<<0) -#define DAMAGE_MELEE_BONUS (1<<1) -#define DAMAGE_MISSILE_BONUS (1<<2) /* deprecated */ #define DAMAGE_SKILL_BONUS (1<<4) static int max_turns; @@ -117,7 +115,7 @@ static int flee_chance_skill_bonus; static int skill_formula; static int rule_cavalry_skill; static int rule_population_damage; -static int rule_hero_speed; +static unsigned char rule_hero_speed; static bool rule_anon_battle; static bool rule_igjarjuk_curse; static int rule_goblin_bonus; @@ -139,7 +137,7 @@ static void init_rules(void) rule_nat_armor = config_get_int("rules.combat.nat_armor", 0); rule_tactics_formula = config_get_int("rules.tactics.formula", 0); rule_goblin_bonus = config_get_int("rules.combat.goblinbonus", 10); - rule_hero_speed = config_get_int("rules.combat.herospeed", 10); + rule_hero_speed = (unsigned char)config_get_int("rules.combat.herospeed", 10); rule_population_damage = config_get_int("rules.combat.populationdamage", 20); rule_anon_battle = config_get_int("rules.stealth.anon_battle", 1) != 0; rule_igjarjuk_curse = config_get_int("rules.combat.igjarjuk_curse", 0) != 0; @@ -157,12 +155,6 @@ static void init_rules(void) if (config_get_int("rules.combat.critical", 1)) { rule_damage |= DAMAGE_CRITICAL; } - if (config_get_int("rules.combat.melee_bonus", 1)) { - rule_damage |= DAMAGE_MELEE_BONUS; - } - if (config_get_int("rules.combat.missile_bonus", 1)) { /* deprecated */ - rule_damage |= DAMAGE_MISSILE_BONUS; - } if (config_get_int("rules.combat.skill_bonus", 1)) { rule_damage |= DAMAGE_SKILL_BONUS; } @@ -1304,9 +1296,7 @@ terminate(troop dt, troop at, int type, const char *damage_formula, bool missile if (awtype == NULL || !fval(awtype, WTF_MISSILE)) { /* melee bonus */ - if (rule_damage & DAMAGE_MELEE_BONUS) { - damage += af->person[at.index].damage; - } + damage += af->person[at.index].damage; } /* Skilldifferenzbonus */ @@ -3158,7 +3148,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack) fig->person[i].hp++; if (i < speeded) - fig->person[i].speed = speed; + fig->person[i].speed = (unsigned char) speed; else fig->person[i].speed = 1; diff --git a/src/battle.h b/src/battle.h index 0ce76bfea..83bcaf09a 100644 --- a/src/battle.h +++ b/src/battle.h @@ -81,9 +81,9 @@ extern "C" { int nsides; struct selist *meffects; int max_tactics; - int turn; + unsigned char turn; + signed char keeploot; /* keep (50 + keeploot) percent of items as loot */ bool has_tactics_turn; - int keeploot; bool reelarrow; int alive; struct { @@ -153,13 +153,13 @@ extern "C" { int catmsg; /* Merkt sich, ob Katapultmessage schon generiert. */ struct person { int hp; /* Trefferpunkte der Personen */ - int attack; - int defense; - int damage; int flags; - int speed; - int reload; - int last_action; + int attack; /* weapon skill bonus for attacker */ + int defense; /* weapon skill bonus for defender */ + char damage; /* bonus damage for melee attacks (e.g. troll belt) */ + unsigned char speed; + unsigned char reload; + unsigned char last_action; struct weapon *missile; /* missile weapon */ struct weapon *melee; /* melee weapon */ } *person; diff --git a/src/exparse.c b/src/exparse.c index 4160b32ba..a9c21b025 100644 --- a/src/exparse.c +++ b/src/exparse.c @@ -280,7 +280,7 @@ static void handle_weapon(parseinfo *pi, const XML_Char *el, const XML_Char **at wtype->defmod = xml_int(attr[i + 1]); } else if (xml_strequal(attr[i], "reload")) { - wtype->reload = xml_int(attr[i + 1]); + wtype->reload = (unsigned char) xml_int(attr[i + 1]); } else if (xml_strequal(attr[i], "skill")) { wtype->skill = findskill(attr[i + 1]); diff --git a/src/kernel/item.c b/src/kernel/item.c index 1533d65bc..0d2764412 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -260,7 +260,7 @@ luxury_type *new_luxurytype(item_type * itype, int price) weapon_type *new_weapontype(item_type * itype, int wflags, variant magres, const char *damage[], int offmod, int defmod, - int reload, skill_t sk) + unsigned char reload, skill_t sk) { weapon_type *wtype; diff --git a/src/kernel/item.h b/src/kernel/item.h index 0b90b7b1e..46b27505f 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -169,7 +169,7 @@ extern "C" { int offmod; int defmod; variant magres; - int reload; /* time to reload this weapon */ + unsigned char reload; /* time to reload this weapon */ weapon_mod *modifiers; /* --- functions --- */ bool(*attack) (const struct troop *, const struct weapon_type *, @@ -208,7 +208,7 @@ extern "C" { item_type *it_get_or_create(resource_type *rtype); luxury_type *new_luxurytype(item_type * itype, int price); weapon_type *new_weapontype(item_type * itype, int wflags, - variant magres, const char *damage[], int offmod, int defmod, int reload, + variant magres, const char *damage[], int offmod, int defmod, unsigned char reload, skill_t sk); void free_wtype(struct weapon_type *wtype); armor_type *new_armortype(item_type * itype, double penalty, diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index f4b8b6954..dea37345b 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -1378,7 +1378,7 @@ int sp_keeploot(struct castorder * co) message_all(b, m); msg_release(m); - b->keeploot = (int)fmax(25, b->keeploot + 5 * power); + b->keeploot = (signed char) fmax(25, b->keeploot + 5 * power); return level; } From beffa1d5362002838b97c82c23db1aa5b5720445 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 18 Nov 2019 18:48:28 +0100 Subject: [PATCH 68/72] CID 205842: con is never NULL. --- src/kernel/build.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/kernel/build.c b/src/kernel/build.c index d9e1cc8bc..7e97819dc 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -511,14 +511,13 @@ int build_skill(unit *u, int basesk, int skill_mod) { */ static int build_limited(unit * u, const construction * con, int completed, int number, int want, int basesk, int *skill_total) { int skills = *skill_total; - int made = 0, maxsize = con->maxsize * number; + int made = 0, maxsize; + assert(con); if (want <= 0) { return 0; } - if (con == NULL) { - return ENOMATERIALS; - } + maxsize = con->maxsize * number; if (completed == maxsize) { return ECOMPLETE; } From 1bff7801ff579d1daa55e1241fd59c8f166b244e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 18 Nov 2019 19:33:37 +0100 Subject: [PATCH 69/72] transfer_faction respects magic schools. --- clibs | 2 +- src/laws.c | 8 ++++++++ src/laws.test.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/clibs b/clibs index f8969f44d..abe774f70 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f8969f44de1ec413cfee82b23c9f4b3c32d49b56 +Subproject commit abe774f70265de14ea7f5e530518ca130562a9c9 diff --git a/src/laws.c b/src/laws.c index eb483aae7..42230e338 100644 --- a/src/laws.c +++ b/src/laws.c @@ -976,9 +976,17 @@ void transfer_faction(faction *fsrc, faction *fdst) { for (i = 0; i != u->skill_size; ++i) { const skill *sv = u->skills + i; skill_t sk = (skill_t)sv->id; + struct sc_mage *mage; + if (skill_count[sk] + u->number > skill_limit[sk]) { break; } + mage = get_mage(u); + if (mage) { + if (fdst->magiegebiet != mage_get_type(mage)) { + break; + } + } } if (i != u->skill_size) { u = u->nextF; diff --git a/src/laws.test.c b/src/laws.test.c index 5dff45a92..ea273d017 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -2083,6 +2083,56 @@ static void test_quit_transfer_limited(CuTest *tc) { test_teardown(); } +/** + * Gifting units with same magic schools. + */ +static void test_quit_transfer_mages(CuTest *tc) { + faction *f1, *f2; + unit *u1, *u2; + region *r; + + test_setup(); + config_set_int("rules.maxskills.magic", 2); + r = test_create_plain(0, 0); + f1 = test_create_faction(NULL); + faction_setpassword(f1, "password"); + u1 = test_create_unit(f1, r); + f2 = test_create_faction(NULL); + u2 = test_create_unit(f2, r); + contact_unit(u2, u1); + u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s", + LOC(f1->locale, parameters[P_FACTION]), itoa36(f2->no)); + + f1->magiegebiet = M_GWYRRD; + set_level(u1, SK_MAGIC, 1); + create_mage(u1, M_GWYRRD); + + f2->magiegebiet = M_CERDDOR; + set_level(u2, SK_MAGIC, 1); + create_mage(u2, M_CERDDOR); + + quit_cmd(u1, u1->thisorder); + CuAssertPtrEquals(tc, f1, u1->faction); + CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT); + f1->flags -= FFL_QUIT; + + unit_set_magic(u1, M_CERDDOR); + scale_number(u1, 2); + f1->magiegebiet = M_CERDDOR; + quit_cmd(u1, u1->thisorder); + CuAssertPtrEquals(tc, f1, u1->faction); + CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT); + f1->flags -= FFL_QUIT; + + unit_set_magic(u1, M_CERDDOR); + scale_number(u1, 1); + f1->magiegebiet = M_CERDDOR; + quit_cmd(u1, u1->thisorder); + CuAssertPtrEquals(tc, f2, u1->faction); + + test_teardown(); +} + /** * Only units of the same race can be gifted to another faction. */ @@ -2248,6 +2298,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_quit_transfer); SUITE_ADD_TEST(suite, test_quit_transfer_limited); SUITE_ADD_TEST(suite, test_quit_transfer_migrants); + SUITE_ADD_TEST(suite, test_quit_transfer_mages); SUITE_ADD_TEST(suite, test_quit_transfer_hero); SUITE_ADD_TEST(suite, test_transfer_faction); #endif From cd165d94ec083a2a7f31a2f34545e2242a8e264c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 18 Nov 2019 19:44:24 +0100 Subject: [PATCH 70/72] =?UTF-8?q?Magier=20d=C3=BCrfen=20bei=20STIRB=20nich?= =?UTF-8?q?t=20=C3=BCbergeben=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/laws.c | 10 +--------- src/laws.test.c | 21 +++------------------ 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/laws.c b/src/laws.c index 42230e338..ddda26f27 100644 --- a/src/laws.c +++ b/src/laws.c @@ -969,24 +969,16 @@ void transfer_faction(faction *fsrc, faction *fdst) { if (u_race(u) == fdst->race) { u->flags &= ~UFL_HERO; - if (give_unit_allowed(u) == 0) { + if (give_unit_allowed(u) == 0 && !get_mage(u)) { if (u->skills) { int i; - for (i = 0; i != u->skill_size; ++i) { const skill *sv = u->skills + i; skill_t sk = (skill_t)sv->id; - struct sc_mage *mage; if (skill_count[sk] + u->number > skill_limit[sk]) { break; } - mage = get_mage(u); - if (mage) { - if (fdst->magiegebiet != mage_get_type(mage)) { - break; - } - } } if (i != u->skill_size) { u = u->nextF; diff --git a/src/laws.test.c b/src/laws.test.c index ea273d017..f6e1ef585 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -2084,7 +2084,7 @@ static void test_quit_transfer_limited(CuTest *tc) { } /** - * Gifting units with same magic schools. + * Mages cannot be transfered. At all. */ static void test_quit_transfer_mages(CuTest *tc) { faction *f1, *f2; @@ -2107,28 +2107,13 @@ static void test_quit_transfer_mages(CuTest *tc) { set_level(u1, SK_MAGIC, 1); create_mage(u1, M_GWYRRD); - f2->magiegebiet = M_CERDDOR; + f2->magiegebiet = M_GWYRRD; set_level(u2, SK_MAGIC, 1); - create_mage(u2, M_CERDDOR); + create_mage(u2, M_GWYRRD); quit_cmd(u1, u1->thisorder); CuAssertPtrEquals(tc, f1, u1->faction); CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT); - f1->flags -= FFL_QUIT; - - unit_set_magic(u1, M_CERDDOR); - scale_number(u1, 2); - f1->magiegebiet = M_CERDDOR; - quit_cmd(u1, u1->thisorder); - CuAssertPtrEquals(tc, f1, u1->faction); - CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT); - f1->flags -= FFL_QUIT; - - unit_set_magic(u1, M_CERDDOR); - scale_number(u1, 1); - f1->magiegebiet = M_CERDDOR; - quit_cmd(u1, u1->thisorder); - CuAssertPtrEquals(tc, f2, u1->faction); test_teardown(); } From 1a8b94da59bf28deef71f876414bd6a05df48108 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 24 Nov 2019 16:39:21 +0100 Subject: [PATCH 71/72] =?UTF-8?q?STIRB=20PARTEI=20l=C3=B6scht=20die=20Befe?= =?UTF-8?q?hle=20nicht.=20Reparatur=20des=20Tests=20f=C3=BCr=20VERGESSE=20?= =?UTF-8?q?MAGIE=20(Vertraute)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tests/economy.lua | 22 +++++++++++++++++++--- src/chaos.c | 1 + src/economy.c | 1 + src/give.c | 1 + src/kernel/unit.c | 9 ++++++--- src/kernel/unit.h | 1 + src/laws.c | 4 ++++ src/monsters.c | 2 ++ src/spells.c | 4 ++-- src/triggers/changefaction.c | 4 +++- 10 files changed, 40 insertions(+), 9 deletions(-) diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index 9c72e7e70..0c140e418 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -28,8 +28,6 @@ function test_work() end function test_bug_2361_forget_magic() - -- https://bugs.eressea.de/view.php?id=2361 - -- familiars cannot forget magic local r = region.create(0, 0, "plain") local f = faction.create("human") local u = unit.create(f, r, 1) @@ -38,12 +36,30 @@ function test_bug_2361_forget_magic() u:add_order("VERGESSE Magie") u:set_skill('magic', 5) uf.race = 'unicorn' + u.familiar = uf + process_orders() + assert_equal(0, u:get_skill('magic')) + assert_nil(u.familiar) + -- without a mage, familiars become ghosts: + assert_equal('ghost', uf.race_name) + assert_equal(0, uf:get_skill('magic')) +end + +function test_bug_2361_familiar_cannot_forget_magic_() + -- https://bugs.eressea.de/view.php?id=2361 + local r = region.create(0, 0, "plain") + local f = faction.create("human") + local u = unit.create(f, r, 1) + local uf = unit.create(f, r, 1) + u:clear_orders() + u:set_skill('magic', 5) + uf.race = 'unicorn' uf:clear_orders() uf:add_order("VERGESSE Magie") uf:set_skill('magic', 5) u.familiar = uf process_orders() - assert_equal(0, u:get_skill('magic')) + -- familiars cannot forget magic: assert_equal(5, uf:get_skill('magic')) end diff --git a/src/chaos.c b/src/chaos.c index ef1dffca6..2639592f0 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -86,6 +86,7 @@ static void chaos(region * r) if (u && playerrace(u_race(u))) { ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u)); u_setfaction(u, get_monsters()); + u_freeorders(u); u_setrace(u, get_race(RC_GHOUL)); } } diff --git a/src/economy.c b/src/economy.c index 7cd28f6b9..35e08ade6 100644 --- a/src/economy.c +++ b/src/economy.c @@ -292,6 +292,7 @@ static int forget_cmd(unit * u, order * ord) if (ufam) { a_removeall(&ufam->attribs, NULL); u_setfaction(ufam, get_monsters()); + u_freeorders(ufam); unit_convert_race(ufam, NULL, "ghost"); } a_removeall(&u->attribs, &at_mage); diff --git a/src/give.c b/src/give.c index 47f472ec1..ac792da9a 100644 --- a/src/give.c +++ b/src/give.c @@ -709,6 +709,7 @@ void give_unit(unit * u, unit * u2, order * ord) } add_give_person(u, u2, u->number, ord, 0); u_setfaction(u, u2->faction); + u_freeorders(u); u2->faction->newbies += u->number; } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 06463820c..e9ec8e657 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -886,6 +886,12 @@ struct building *inside_building(const struct unit *u) return NULL; } +void u_freeorders(unit *u) +{ + free_orders(&u->orders); + set_order(&u->thisorder, NULL); +} + void u_setfaction(unit * u, faction * f) { if (u->faction == f) @@ -896,9 +902,6 @@ void u_setfaction(unit * u, faction * f) u->faction->num_people -= u->number; } set_group(u, NULL); - free_orders(&u->orders); - set_order(&u->thisorder, NULL); - if (u->nextF) { u->nextF->prevF = u->prevF; } diff --git a/src/kernel/unit.h b/src/kernel/unit.h index c77cfdb7a..7fc6fa730 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -179,6 +179,7 @@ extern "C" { /* cleanup code for this module */ void free_units(void); void u_setfaction(struct unit *u, struct faction *f); + void u_freeorders(struct unit *u); void set_number(struct unit *u, int count); int invisible(const struct unit *target, const struct unit *viewer); diff --git a/src/laws.c b/src/laws.c index b1ca5e300..285ee3f1c 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3764,6 +3764,10 @@ void process(void) } if (ord) { porder->data.per_order.process(u, ord); + if (!u->orders) { + /* GIVE UNIT or QUIT delete all orders of the unit, stop */ + break; + } } } if (!ord || *ordp == ord) diff --git a/src/monsters.c b/src/monsters.c index 7cdebfd6c..6f20a8c8b 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -174,6 +174,7 @@ void monsters_desert(struct faction *monsters) ADDMSG(&u->faction->msgs, msg_message("desertion", "unit region", u, r)); u_setfaction(u, monsters); + u_freeorders(u); } } } @@ -1157,6 +1158,7 @@ void monster_kills_peasants(unit * u) void make_zombie(unit * u) { u_setfaction(u, get_monsters()); + u_freeorders(u); scale_number(u, 1); u->hp = unit_max_hp(u) * u->number; u_setrace(u, get_race(RC_ZOMBIE)); diff --git a/src/spells.c b/src/spells.c index 200e87f62..6cff4bb9b 100644 --- a/src/spells.c +++ b/src/spells.c @@ -3553,7 +3553,7 @@ static int sp_charmingsong(castorder * co) /* setze Partei um und loesche langen Befehl aus Sicherheitsgruenden */ u_setfaction(target, mage->faction); - set_order(&target->thisorder, NULL); + u_freeorders(target); /* setze Parteitarnung, damit nicht sofort klar ist, wer dahinter * steckt */ @@ -3796,7 +3796,7 @@ static int sp_migranten(castorder * co) return 0; } u_setfaction(target, mage->faction); - set_order(&target->thisorder, NULL); + u_freeorders(target); /* Erfolg melden */ ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "sp_migranten", diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 36e40ed46..85403083b 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -48,7 +48,9 @@ static int changefaction_handle(trigger * t, void *data) */ changefaction_data *td = (changefaction_data *)t->data.v; if (td->unit && td->faction) { - u_setfaction(td->unit, td->faction); + unit * u = td->unit; + u_setfaction(u, td->faction); + u_freeorders(u); } else { log_error("could not perform changefaction::handle()\n"); From 633866c814f5a437cd34c76487967f284ac9f975 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 30 Nov 2019 16:29:23 +0100 Subject: [PATCH 72/72] =?UTF-8?q?STIRB=20PARTEI:=20Versuche,=20Helden=20zu?= =?UTF-8?q?=20=C3=BCbernehmen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/laws.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/laws.c b/src/laws.c index 285ee3f1c..10975c6a7 100644 --- a/src/laws.c +++ b/src/laws.c @@ -924,6 +924,7 @@ int leave_cmd(unit * u, struct order *ord) void transfer_faction(faction *fsrc, faction *fdst) { unit *u; skill_t sk; + int hmax, hnow; int skill_count[MAXSKILLS]; int skill_limit[MAXSKILLS]; @@ -945,12 +946,21 @@ void transfer_faction(faction *fsrc, faction *fdst) { } } + hnow = countheroes(fdst); + hmax = maxheroes(fdst); u = fsrc->units; while (u) { unit *unext = u->nextF; if (u_race(u) == fdst->race) { - u->flags &= ~UFL_HERO; + if (u->flags & UFL_HERO) { + if (u->number + hnow > hmax) { + u->flags &= ~UFL_HERO; + } + else { + hnow += u->number; + } + } if (give_unit_allowed(u) == 0 && !get_mage(u)) { if (u->skills) { int i;