forked from github/server
indentation + whitespace changes
This commit is contained in:
parent
bf4bda36a2
commit
1918f56990
189
src/economy.c
189
src/economy.c
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
Copyright (c) 1998-2014,
|
||||||
|
Enno Rehling <enno@eressea.de>
|
||||||
Katja Zedel <katze@felidae.kn-bremen.de
|
Katja Zedel <katze@felidae.kn-bremen.de
|
||||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
|
|
||||||
|
@ -170,7 +171,8 @@ static void expandorders(region * r, request * requests)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scramble(oa, norders, sizeof(request));
|
scramble(oa, norders, sizeof(request));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
oa = NULL;
|
oa = NULL;
|
||||||
}
|
}
|
||||||
while (requests) {
|
while (requests) {
|
||||||
|
@ -216,7 +218,8 @@ static recruitment *select_recruitment(request ** rop,
|
||||||
|
|
||||||
if (qty < 0) {
|
if (qty < 0) {
|
||||||
rop = &ro->next; /* skip this one */
|
rop = &ro->next; /* skip this one */
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
*rop = ro->next; /* remove this one */
|
*rop = ro->next; /* remove this one */
|
||||||
while (rec && rec->f != u->faction)
|
while (rec && rec->f != u->faction)
|
||||||
rec = rec->next;
|
rec = rec->next;
|
||||||
|
@ -250,7 +253,8 @@ static void add_recruits(unit * u, int number, int wanted)
|
||||||
set_number(u, number);
|
set_number(u, number);
|
||||||
u->hp = number * unit_max_hp(u);
|
u->hp = number * unit_max_hp(u);
|
||||||
unew = u;
|
unew = u;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
unew = create_unit(r, u->faction, number, u_race(u), 0, NULL, u);
|
unew = create_unit(r, u->faction, number, u_race(u), 0, NULL, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +412,8 @@ static bool can_give(const unit * u, const unit * u2, const item_type * itype, i
|
||||||
}
|
}
|
||||||
return (rule & mask) != 0;
|
return (rule & mask) != 0;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int rule = rule_give();
|
int rule = rule_give();
|
||||||
return (rule & GIVE_PEASANTS) != 0;
|
return (rule & GIVE_PEASANTS) != 0;
|
||||||
}
|
}
|
||||||
|
@ -478,7 +483,8 @@ static int recruit_cost(const faction * f, const race * rc)
|
||||||
{
|
{
|
||||||
if (is_monsters(f) || f->race == rc) {
|
if (is_monsters(f) || f->race == rc) {
|
||||||
return rc->recruitcost;
|
return rc->recruitcost;
|
||||||
} else if (valid_race(f, rc)) {
|
}
|
||||||
|
else if (valid_race(f, rc)) {
|
||||||
return rc->recruitcost;
|
return rc->recruitcost;
|
||||||
/* return get_param_int(f->race->parameters, "other_cost", -1); */
|
/* return get_param_int(f->race->parameters, "other_cost", -1); */
|
||||||
}
|
}
|
||||||
|
@ -673,18 +679,23 @@ int give_control_cmd(unit * u, order * ord)
|
||||||
if (!u2 || u2->number == 0) {
|
if (!u2 || u2->number == 0) {
|
||||||
msg = msg_feedback(u, ord, "feedback_unit_not_found", "");
|
msg = msg_feedback(u, ord, "feedback_unit_not_found", "");
|
||||||
ADDMSG(&u->faction->msgs, msg);
|
ADDMSG(&u->faction->msgs, msg);
|
||||||
} else if (!u->building && !u->ship) {
|
}
|
||||||
|
else if (!u->building && !u->ship) {
|
||||||
msg = cmistake(u, ord, 140, MSG_EVENT);
|
msg = cmistake(u, ord, 140, MSG_EVENT);
|
||||||
} else if (u->building) {
|
}
|
||||||
|
else if (u->building) {
|
||||||
if (u != building_owner(u->building)) {
|
if (u != building_owner(u->building)) {
|
||||||
msg = cmistake(u, ord, 49, MSG_EVENT);
|
msg = cmistake(u, ord, 49, MSG_EVENT);
|
||||||
} else if (u2->building != u->building) {
|
}
|
||||||
|
else if (u2->building != u->building) {
|
||||||
msg = cmistake(u, ord, 33, MSG_EVENT);
|
msg = cmistake(u, ord, 33, MSG_EVENT);
|
||||||
}
|
}
|
||||||
} else if (u->ship) {
|
}
|
||||||
|
else if (u->ship) {
|
||||||
if (u != ship_owner(u->ship)) {
|
if (u != ship_owner(u->ship)) {
|
||||||
msg = cmistake(u, ord, 49, MSG_EVENT);
|
msg = cmistake(u, ord, 49, MSG_EVENT);
|
||||||
} else if (u2->ship != u->ship) {
|
}
|
||||||
|
else if (u2->ship != u->ship) {
|
||||||
msg = cmistake(u, ord, 32, MSG_EVENT);
|
msg = cmistake(u, ord, 32, MSG_EVENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -878,22 +889,27 @@ static void give_cmd(unit * u, order * ord)
|
||||||
itmp = &itm->next;
|
itmp = &itm->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (isparam(s, u->faction->locale, P_PERSON)) {
|
if (isparam(s, u->faction->locale, P_PERSON)) {
|
||||||
if (!(u_race(u)->ec_flags & GIVEPERSON)) {
|
if (!(u_race(u)->ec_flags & GIVEPERSON)) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_noregroup", "race", u_race(u)));
|
msg_feedback(u, ord, "race_noregroup", "race", u_race(u)));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
n = u->number;
|
n = u->number;
|
||||||
give_men(n, u, u2, ord);
|
give_men(n, u, u2, ord);
|
||||||
}
|
}
|
||||||
} else if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
}
|
||||||
|
else if (!(u_race(u)->ec_flags & GIVEITEM) && u2 != NULL) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||||
} else if (u2 && !(u_race(u2)->ec_flags & GETITEM)) {
|
}
|
||||||
|
else if (u2 && !(u_race(u2)->ec_flags & GETITEM)) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_notake", "race", u_race(u2)));
|
msg_feedback(u, ord, "race_notake", "race", u_race(u2)));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
itype = finditemtype(s, u->faction->locale);
|
itype = finditemtype(s, u->faction->locale);
|
||||||
if (itype != NULL) {
|
if (itype != NULL) {
|
||||||
item *i = *i_find(&u->items, itype);
|
item *i = *i_find(&u->items, itype);
|
||||||
|
@ -901,7 +917,8 @@ static void give_cmd(unit * u, order * ord)
|
||||||
if (can_give(u, u2, itype, 0)) {
|
if (can_give(u, u2, itype, 0)) {
|
||||||
n = i->number - get_reservation(u, itype->rtype);
|
n = i->number - get_reservation(u, itype->rtype);
|
||||||
give_item(n, itype, u, u2, ord);
|
give_item(n, itype, u, u2, ord);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
feedback_give_not_allowed(u, ord);
|
feedback_give_not_allowed(u, ord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -909,7 +926,8 @@ static void give_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (p == P_EACH) {
|
}
|
||||||
|
else if (p == P_EACH) {
|
||||||
if (u2 == NULL) {
|
if (u2 == NULL) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "peasants_give_invalid", ""));
|
msg_feedback(u, ord, "peasants_give_invalid", ""));
|
||||||
|
@ -953,7 +971,8 @@ static void give_cmd(unit * u, order * ord)
|
||||||
if (itype != NULL) {
|
if (itype != NULL) {
|
||||||
if (can_give(u, u2, itype, 0)) {
|
if (can_give(u, u2, itype, 0)) {
|
||||||
give_item(n, itype, u, u2, ord);
|
give_item(n, itype, u, u2, ord);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
feedback_give_not_allowed(u, ord);
|
feedback_give_not_allowed(u, ord);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1118,7 +1137,8 @@ static bool maintain(building * b, bool first)
|
||||||
}
|
}
|
||||||
assert(cost == 0);
|
assert(cost == 0);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b));
|
ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1143,7 +1163,8 @@ void maintain_buildings(region * r, bool crash)
|
||||||
if (u) {
|
if (u) {
|
||||||
add_message(&u->faction->msgs, msg);
|
add_message(&u->faction->msgs, msg);
|
||||||
r_addmessage(r, u->faction, msg);
|
r_addmessage(r, u->faction, msg);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
add_message(&r->msgs, msg);
|
add_message(&r->msgs, msg);
|
||||||
}
|
}
|
||||||
msg_release(msg);
|
msg_release(msg);
|
||||||
|
@ -1169,7 +1190,8 @@ void economics(region * r)
|
||||||
keyword_t kwd = getkeyword(ord);
|
keyword_t kwd = getkeyword(ord);
|
||||||
if (kwd == K_GIVE) {
|
if (kwd == K_GIVE) {
|
||||||
give_cmd(u, ord);
|
give_cmd(u, ord);
|
||||||
} else if (kwd == K_FORGET) {
|
}
|
||||||
|
else if (kwd == K_FORGET) {
|
||||||
forget_cmd(u, ord);
|
forget_cmd(u, ord);
|
||||||
}
|
}
|
||||||
if (u->orders == NULL) {
|
if (u->orders == NULL) {
|
||||||
|
@ -1272,7 +1294,8 @@ static void manufacture(unit * u, const item_type * itype, int want)
|
||||||
ADDMSG(&u->faction->msgs, msg_message("manufacture",
|
ADDMSG(&u->faction->msgs, msg_message("manufacture",
|
||||||
"unit region amount wanted resource", u, u->region, n, want,
|
"unit region amount wanted resource", u, u->region, n, want,
|
||||||
itype->rtype));
|
itype->rtype));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_cannotmake",
|
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_cannotmake",
|
||||||
""));
|
""));
|
||||||
}
|
}
|
||||||
|
@ -1403,7 +1426,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
|
||||||
"skill minskill product", sk, itype->construction->minskill,
|
"skill minskill product", sk, itype->construction->minskill,
|
||||||
itype->rtype));
|
itype->rtype));
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
struct building *b = inside_building(u);
|
struct building *b = inside_building(u);
|
||||||
const struct building_type *btype = b ? b->type : NULL;
|
const struct building_type *btype = b ? b->type : NULL;
|
||||||
|
|
||||||
|
@ -1515,10 +1539,12 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
|
||||||
>= rm->level + itype->construction->minskill - 1) {
|
>= rm->level + itype->construction->minskill - 1) {
|
||||||
if (req) {
|
if (req) {
|
||||||
norders += req;
|
norders += req;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
fset(al, AFL_DONE);
|
fset(al, AFL_DONE);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
fset(al, AFL_DONE);
|
fset(al, AFL_DONE);
|
||||||
if (first)
|
if (first)
|
||||||
fset(al, AFL_LOWSKILL);
|
fset(al, AFL_LOWSKILL);
|
||||||
|
@ -1697,7 +1723,8 @@ static void create_item(unit * u, const item_type * itype, int want)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
allocate_resource(u, itype->rtype, want);
|
allocate_resource(u, itype->rtype, want);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const potion_type *ptype = resource2potion(itype->rtype);
|
const potion_type *ptype = resource2potion(itype->rtype);
|
||||||
if (ptype != NULL)
|
if (ptype != NULL)
|
||||||
create_potion(u, ptype, want);
|
create_potion(u, ptype, want);
|
||||||
|
@ -1731,7 +1758,8 @@ int make_cmd(unit * u, struct order *ord)
|
||||||
if (!strcmp(ibuf, (const char *)s)) {
|
if (!strcmp(ibuf, (const char *)s)) {
|
||||||
/* first came a want-paramter */
|
/* first came a want-paramter */
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
m = INT_MAX;
|
m = INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1745,25 +1773,30 @@ int make_cmd(unit * u, struct order *ord)
|
||||||
plane *pl = rplane(r);
|
plane *pl = rplane(r);
|
||||||
if (pl && fval(pl, PFL_NOBUILD)) {
|
if (pl && fval(pl, PFL_NOBUILD)) {
|
||||||
cmistake(u, ord, 275, MSG_PRODUCE);
|
cmistake(u, ord, 275, MSG_PRODUCE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
direction_t d = get_direction(getstrtoken(), u->faction->locale);
|
direction_t d = get_direction(getstrtoken(), u->faction->locale);
|
||||||
if (d != NODIRECTION) {
|
if (d != NODIRECTION) {
|
||||||
build_road(r, u, m, d);
|
build_road(r, u, m, d);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Die Richtung wurde nicht erkannt */
|
/* Die Richtung wurde nicht erkannt */
|
||||||
cmistake(u, ord, 71, MSG_PRODUCE);
|
cmistake(u, ord, 71, MSG_PRODUCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else if (p == P_SHIP) {
|
}
|
||||||
|
else if (p == P_SHIP) {
|
||||||
plane *pl = rplane(r);
|
plane *pl = rplane(r);
|
||||||
if (pl && fval(pl, PFL_NOBUILD)) {
|
if (pl && fval(pl, PFL_NOBUILD)) {
|
||||||
cmistake(u, ord, 276, MSG_PRODUCE);
|
cmistake(u, ord, 276, MSG_PRODUCE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
continue_ship(r, u, m);
|
continue_ship(r, u, m);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else if (p == P_HERBS) {
|
}
|
||||||
|
else if (p == P_HERBS) {
|
||||||
herbsearch(r, u, m);
|
herbsearch(r, u, m);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1780,14 +1813,16 @@ int make_cmd(unit * u, struct order *ord)
|
||||||
if (itype->construction == NULL) {
|
if (itype->construction == NULL) {
|
||||||
/* if the item cannot be made, we probably didn't mean to make it */
|
/* if the item cannot be made, we probably didn't mean to make it */
|
||||||
itype = NULL;
|
itype = NULL;
|
||||||
} else if (stype != NULL) {
|
}
|
||||||
|
else if (stype != NULL) {
|
||||||
const char *sname = LOC(lang, stype->_name);
|
const char *sname = LOC(lang, stype->_name);
|
||||||
const char *iname = LOC(lang, resourcename(itype->rtype, 0));
|
const char *iname = LOC(lang, resourcename(itype->rtype, 0));
|
||||||
if (strlen(iname) < strlen(sname))
|
if (strlen(iname) < strlen(sname))
|
||||||
stype = NULL;
|
stype = NULL;
|
||||||
else
|
else
|
||||||
itype = NULL;
|
itype = NULL;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const char *bname = LOC(lang, btype->_name);
|
const char *bname = LOC(lang, btype->_name);
|
||||||
const char *iname = LOC(lang, resourcename(itype->rtype, 0));
|
const char *iname = LOC(lang, resourcename(itype->rtype, 0));
|
||||||
if (strlen(iname) < strlen(bname))
|
if (strlen(iname) < strlen(bname))
|
||||||
|
@ -1810,20 +1845,25 @@ int make_cmd(unit * u, struct order *ord)
|
||||||
plane *pl = rplane(r);
|
plane *pl = rplane(r);
|
||||||
if (pl && fval(pl, PFL_NOBUILD)) {
|
if (pl && fval(pl, PFL_NOBUILD)) {
|
||||||
cmistake(u, ord, 276, MSG_PRODUCE);
|
cmistake(u, ord, 276, MSG_PRODUCE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
create_ship(r, u, stype, m, ord);
|
create_ship(r, u, stype, m, ord);
|
||||||
}
|
}
|
||||||
} else if (btype != NOBUILDING) {
|
}
|
||||||
|
else if (btype != NOBUILDING) {
|
||||||
plane *pl = rplane(r);
|
plane *pl = rplane(r);
|
||||||
if (pl && fval(pl, PFL_NOBUILD)) {
|
if (pl && fval(pl, PFL_NOBUILD)) {
|
||||||
cmistake(u, ord, 94, MSG_PRODUCE);
|
cmistake(u, ord, 94, MSG_PRODUCE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int id = getid();
|
int id = getid();
|
||||||
build_building(u, btype, id, m, ord);
|
build_building(u, btype, id, m, ord);
|
||||||
}
|
}
|
||||||
} else if (itype != NULL) {
|
}
|
||||||
|
else if (itype != NULL) {
|
||||||
create_item(u, itype, m);
|
create_item(u, itype, m);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", ""));
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2000,7 +2040,8 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
|
||||||
cmistake(u, ord, 119, MSG_COMMERCE);
|
cmistake(u, ord, 119, MSG_COMMERCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* ...oder in der Region muß es eine Burg geben. */
|
/* ...oder in der Region muß es eine Burg geben. */
|
||||||
building *b = 0;
|
building *b = 0;
|
||||||
if (r->buildings) {
|
if (r->buildings) {
|
||||||
|
@ -2026,7 +2067,8 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
|
||||||
a = a_find(u->attribs, &at_trades);
|
a = a_find(u->attribs, &at_trades);
|
||||||
if (!a) {
|
if (!a) {
|
||||||
a = a_add(&u->attribs, a_new(&at_trades));
|
a = a_add(&u->attribs, a_new(&at_trades));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
k -= a->data.i;
|
k -= a->data.i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2086,7 +2128,8 @@ static void expandselling(region * r, request * sellorders, int limit)
|
||||||
for (ltype = luxurytypes; ltype; ltype = ltype->next)
|
for (ltype = luxurytypes; ltype; ltype = ltype->next)
|
||||||
++ncounter;
|
++ncounter;
|
||||||
counter = (int *)gc_add(calloc(sizeof(int), ncounter));
|
counter = (int *)gc_add(calloc(sizeof(int), ncounter));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
memset(counter, 0, sizeof(int) * ncounter);
|
memset(counter, 0, sizeof(int) * ncounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2102,7 +2145,8 @@ static void expandselling(region * r, request * sellorders, int limit)
|
||||||
maxb = b;
|
maxb = b;
|
||||||
maxsize = b->size;
|
maxsize = b->size;
|
||||||
maxowner = building_owner(b);
|
maxowner = building_owner(b);
|
||||||
} else if (b->size == maxsize && b->type == bt_find("castle")) {
|
}
|
||||||
|
else if (b->size == maxsize && b->type == bt_find("castle")) {
|
||||||
maxb = (building *)NULL;
|
maxb = (building *)NULL;
|
||||||
maxowner = (unit *)NULL;
|
maxowner = (unit *)NULL;
|
||||||
}
|
}
|
||||||
|
@ -2282,7 +2326,8 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
|
||||||
cmistake(u, ord, 303, MSG_COMMERCE);
|
cmistake(u, ord, 303, MSG_COMMERCE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
n = atoi((const char *)s);
|
n = atoi((const char *)s);
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
cmistake(u, ord, 27, MSG_COMMERCE);
|
cmistake(u, ord, 27, MSG_COMMERCE);
|
||||||
|
@ -2303,7 +2348,8 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
|
||||||
cmistake(u, ord, 119, MSG_COMMERCE);
|
cmistake(u, ord, 119, MSG_COMMERCE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* ...oder in der Region muß es eine Burg geben. */
|
/* ...oder in der Region muß es eine Burg geben. */
|
||||||
building *b = 0;
|
building *b = 0;
|
||||||
if (r->buildings) {
|
if (r->buildings) {
|
||||||
|
@ -2333,7 +2379,8 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
|
||||||
if (ltype == NULL) {
|
if (ltype == NULL) {
|
||||||
cmistake(u, ord, 126, MSG_COMMERCE);
|
cmistake(u, ord, 126, MSG_COMMERCE);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
attrib *a;
|
attrib *a;
|
||||||
request *o;
|
request *o;
|
||||||
int k, available;
|
int k, available;
|
||||||
|
@ -2374,7 +2421,8 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
|
||||||
a = a_find(u->attribs, &at_trades);
|
a = a_find(u->attribs, &at_trades);
|
||||||
if (!a) {
|
if (!a) {
|
||||||
a = a_add(&u->attribs, a_new(&at_trades));
|
a = a_add(&u->attribs, a_new(&at_trades));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
k -= a->data.i;
|
k -= a->data.i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2673,13 +2721,15 @@ static void breed_cmd(unit * u, struct order *ord)
|
||||||
if (m != 0) {
|
if (m != 0) {
|
||||||
/* first came a want-paramter */
|
/* first came a want-paramter */
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
m = INT_MAX;
|
m = INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s[0]) {
|
if (!s[0]) {
|
||||||
p = P_ANY;
|
p = P_ANY;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
p = findparam(s, u->faction->locale);
|
p = findparam(s, u->faction->locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2696,7 +2746,8 @@ static void breed_cmd(unit * u, struct order *ord)
|
||||||
if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORNSEED)) {
|
if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORNSEED)) {
|
||||||
breedtrees(r, u, m);
|
breedtrees(r, u, m);
|
||||||
break;
|
break;
|
||||||
} else if (rtype != get_resourcetype(R_HORSE)) {
|
}
|
||||||
|
else if (rtype != get_resourcetype(R_HORSE)) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", ""));
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", ""));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2712,11 +2763,14 @@ static const char *rough_amount(int a, int m)
|
||||||
|
|
||||||
if (p < 10) {
|
if (p < 10) {
|
||||||
return "sehr wenige";
|
return "sehr wenige";
|
||||||
} else if (p < 30) {
|
}
|
||||||
|
else if (p < 30) {
|
||||||
return "wenige";
|
return "wenige";
|
||||||
} else if (p < 60) {
|
}
|
||||||
|
else if (p < 60) {
|
||||||
return "relativ viele";
|
return "relativ viele";
|
||||||
} else if (p < 90) {
|
}
|
||||||
|
else if (p < 90) {
|
||||||
return "viele";
|
return "viele";
|
||||||
}
|
}
|
||||||
return "sehr viele";
|
return "sehr viele";
|
||||||
|
@ -2747,11 +2801,13 @@ static void research_cmd(unit * u, struct order *ord)
|
||||||
ADDMSG(&u->faction->msgs, msg_message("researchherb",
|
ADDMSG(&u->faction->msgs, msg_message("researchherb",
|
||||||
"unit region amount herb",
|
"unit region amount herb",
|
||||||
u, r, rough_amount(rherbs(r), 100), itype->rtype));
|
u, r, rough_amount(rherbs(r), 100), itype->rtype));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
|
ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
|
||||||
"unit region", u, r));
|
"unit region", u, r));
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
|
ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
|
||||||
"unit region", u, r));
|
"unit region", u, r));
|
||||||
}
|
}
|
||||||
|
@ -2816,7 +2872,8 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
|
||||||
|
|
||||||
if (u2 && u2->region == u->region) {
|
if (u2 && u2->region == u->region) {
|
||||||
f = u2->faction;
|
f = u2->faction;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
f = dfindhash(id);
|
f = dfindhash(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2856,12 +2913,14 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
|
||||||
ADDMSG(&u->faction->msgs, msg_message("stealfail", "unit target", u, u2));
|
ADDMSG(&u->faction->msgs, msg_message("stealfail", "unit target", u, u2));
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
ADDMSG(&u2->faction->msgs, msg_message("stealdetect", "unit", u2));
|
ADDMSG(&u2->faction->msgs, msg_message("stealdetect", "unit", u2));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target",
|
ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target",
|
||||||
u, u2));
|
u, u2));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("stealfatal", "unit target", u,
|
ADDMSG(&u->faction->msgs, msg_message("stealfatal", "unit target", u,
|
||||||
u2));
|
u2));
|
||||||
ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target", u,
|
ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target", u,
|
||||||
|
@ -2874,7 +2933,8 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
|
||||||
i = _min(u->number, i_get(u->items, rring->itype));
|
i = _min(u->number, i_get(u->items, rring->itype));
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
n *= STEALINCOME * (u->number + i * (roqf_factor() - 1));
|
n *= STEALINCOME * (u->number + i * (roqf_factor() - 1));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
n *= u->number * STEALINCOME;
|
n *= u->number * STEALINCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3063,7 +3123,8 @@ static int do_work(unit * u, order * ord, request * o)
|
||||||
o->qty = u->number * w;
|
o->qty = u->number * w;
|
||||||
working += u->number;
|
working += u->number;
|
||||||
return 0;
|
return 0;
|
||||||
} else if (ord && !is_monsters(u->faction)) {
|
}
|
||||||
|
else if (ord && !is_monsters(u->faction)) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_cantwork", "race", u_race(u)));
|
msg_feedback(u, ord, "race_cantwork", "race", u_race(u)));
|
||||||
}
|
}
|
||||||
|
@ -3132,7 +3193,8 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
|
||||||
max = INT_MAX;
|
max = INT_MAX;
|
||||||
if (!playerrace(u_race(u))) {
|
if (!playerrace(u_race(u))) {
|
||||||
u->wants = _min(income(u), max);
|
u->wants = _min(income(u), max);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
u->wants = _min(n * eff_skill(u, SK_TAXING, r) * 20, max);
|
u->wants = _min(n * eff_skill(u, SK_TAXING, r) * 20, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3278,7 +3340,8 @@ void produce(struct region *r)
|
||||||
if (kwd == K_BUY) {
|
if (kwd == K_BUY) {
|
||||||
buy(u, &buyorders, ord);
|
buy(u, &buyorders, ord);
|
||||||
trader = true;
|
trader = true;
|
||||||
} else if (kwd == K_SELL) {
|
}
|
||||||
|
else if (kwd == K_SELL) {
|
||||||
/* sell returns true if the sale is not limited
|
/* sell returns true if the sale is not limited
|
||||||
* by the region limit */
|
* by the region limit */
|
||||||
limited &= !sell(u, &sellorders, ord);
|
limited &= !sell(u, &sellorders, ord);
|
||||||
|
|
89
src/give.c
89
src/give.c
|
@ -2,7 +2,7 @@
|
||||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
| | Enno Rehling <enno@eressea.de>
|
| | Enno Rehling <enno@eressea.de>
|
||||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
| (c) 1998 - 2014 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||||
|
|
||||||
|
@ -67,10 +67,12 @@ add_give(unit * u, unit * u2, int given, int received,
|
||||||
{
|
{
|
||||||
if (error) {
|
if (error) {
|
||||||
cmistake(u, ord, error, MSG_COMMERCE);
|
cmistake(u, ord, error, MSG_COMMERCE);
|
||||||
} else if (u2 == NULL) {
|
}
|
||||||
|
else if (u2 == NULL) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_message("give_peasants", "unit resource amount", u, rtype, given));
|
msg_message("give_peasants", "unit resource amount", u, rtype, given));
|
||||||
} else if (u2->faction != u->faction) {
|
}
|
||||||
|
else if (u2->faction != u->faction) {
|
||||||
message *msg;
|
message *msg;
|
||||||
|
|
||||||
msg =
|
msg =
|
||||||
|
@ -130,7 +132,8 @@ give_item(int want, const item_type * itype, unit * src, unit * dest,
|
||||||
"turns", GiveRestriction()));
|
"turns", GiveRestriction()));
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
} else if (n == 0) {
|
}
|
||||||
|
else if (n == 0) {
|
||||||
int reserve = get_reservation(src, itype->rtype);
|
int reserve = get_reservation(src, itype->rtype);
|
||||||
if (reserve) {
|
if (reserve) {
|
||||||
msg_feedback(src, ord, "nogive_reserved", "resource reservation",
|
msg_feedback(src, ord, "nogive_reserved", "resource reservation",
|
||||||
|
@ -138,9 +141,11 @@ give_item(int want, const item_type * itype, unit * src, unit * dest,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
error = 36;
|
error = 36;
|
||||||
} else if (itype->flags & ITF_CURSED) {
|
}
|
||||||
|
else if (itype->flags & ITF_CURSED) {
|
||||||
error = 25;
|
error = 25;
|
||||||
} else if (itype->give == NULL || itype->give(src, dest, itype, n, ord) != 0) {
|
}
|
||||||
|
else if (itype->give == NULL || itype->give(src, dest, itype, n, ord) != 0) {
|
||||||
int use = use_pooled(src, item2resource(itype), GET_SLACK, n);
|
int use = use_pooled(src, item2resource(itype), GET_SLACK, n);
|
||||||
if (use < n)
|
if (use < n)
|
||||||
use +=
|
use +=
|
||||||
|
@ -184,43 +189,56 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "giverestriction",
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "giverestriction",
|
||||||
"turns", GiveRestriction()));
|
"turns", GiveRestriction()));
|
||||||
return;
|
return;
|
||||||
} else if (u == u2) {
|
}
|
||||||
|
else if (u == u2) {
|
||||||
error = 10;
|
error = 10;
|
||||||
}
|
}
|
||||||
else if (!u2 && u_race(u) == get_race(RC_SNOTLING)) {
|
else if (!u2 && u_race(u) == get_race(RC_SNOTLING)) {
|
||||||
/* snotlings may not be given to the peasants. */
|
/* snotlings may not be given to the peasants. */
|
||||||
error = 307;
|
error = 307;
|
||||||
} else if (u2 && u2->number && (fval(u, UFL_HERO) != fval(u2, UFL_HERO))) {
|
}
|
||||||
|
else if (u2 && u2->number && (fval(u, UFL_HERO) != fval(u2, UFL_HERO))) {
|
||||||
/* heroes may not be given to non-heroes and vice versa */
|
/* heroes may not be given to non-heroes and vice versa */
|
||||||
error = 75;
|
error = 75;
|
||||||
} else if (unit_has_cursed_item(u) || (u2 && unit_has_cursed_item(u2))) {
|
}
|
||||||
|
else if (unit_has_cursed_item(u) || (u2 && unit_has_cursed_item(u2))) {
|
||||||
error = 78;
|
error = 78;
|
||||||
} else if (fval(u, UFL_LOCKED) || is_cursed(u->attribs, C_SLAVE, 0)) {
|
}
|
||||||
|
else if (fval(u, UFL_LOCKED) || is_cursed(u->attribs, C_SLAVE, 0)) {
|
||||||
error = 74;
|
error = 74;
|
||||||
} else if (u2 && fval(u, UFL_HUNGER)) {
|
}
|
||||||
|
else if (u2 && fval(u, UFL_HUNGER)) {
|
||||||
/* hungry people cannot be given away */
|
/* hungry people cannot be given away */
|
||||||
error = 73;
|
error = 73;
|
||||||
} else if (u2 && (fval(u2, UFL_LOCKED) || is_cursed(u2->attribs, C_SLAVE, 0))) {
|
}
|
||||||
|
else if (u2 && (fval(u2, UFL_LOCKED) || is_cursed(u2->attribs, C_SLAVE, 0))) {
|
||||||
error = 75;
|
error = 75;
|
||||||
} else if (u2 && !ucontact(u2, u)) {
|
}
|
||||||
|
else if (u2 && !ucontact(u2, u)) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_no_contact",
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_no_contact",
|
||||||
"target", u2));
|
"target", u2));
|
||||||
error = -1;
|
error = -1;
|
||||||
} else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) {
|
}
|
||||||
|
else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) {
|
||||||
/* cannot give units to and from magicians */
|
/* cannot give units to and from magicians */
|
||||||
error = 158;
|
error = 158;
|
||||||
} else if (u2 && (fval(u, UFL_WERE) != fval(u2, UFL_WERE))) {
|
}
|
||||||
|
else if (u2 && (fval(u, UFL_WERE) != fval(u2, UFL_WERE))) {
|
||||||
/* werewolves can't be given to non-werewolves and vice-versa */
|
/* werewolves can't be given to non-werewolves and vice-versa */
|
||||||
error = 312;
|
error = 312;
|
||||||
} else if (u2 && u2->number != 0 && u_race(u2) != u_race(u)) {
|
}
|
||||||
|
else if (u2 && u2->number != 0 && u_race(u2) != u_race(u)) {
|
||||||
log_warning("faction %s attempts to give %s to %s.\n", itoa36(u->faction->no), u_race(u)->_name[0], u_race(u2)->_name[1]);
|
log_warning("faction %s attempts to give %s to %s.\n", itoa36(u->faction->no), u_race(u)->_name[0], u_race(u2)->_name[1]);
|
||||||
error = 139;
|
error = 139;
|
||||||
} else if (u2 != NULL && (get_racename(u2->attribs)
|
}
|
||||||
|
else if (u2 != NULL && (get_racename(u2->attribs)
|
||||||
|| get_racename(u->attribs))) {
|
|| get_racename(u->attribs))) {
|
||||||
error = 139;
|
error = 139;
|
||||||
} else if (u2 && u2->faction != u->faction && !rule_transfermen()) {
|
}
|
||||||
|
else if (u2 && u2->faction != u->faction && !rule_transfermen()) {
|
||||||
error = 74;
|
error = 74;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (n > u->number)
|
if (n > u->number)
|
||||||
n = u->number;
|
n = u->number;
|
||||||
if (u2 && n + u2->number > UNIT_MAXSIZE) {
|
if (u2 && n + u2->number > UNIT_MAXSIZE) {
|
||||||
|
@ -231,18 +249,23 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
error = 96;
|
error = 96;
|
||||||
} else if (u2 && u->faction != u2->faction) {
|
}
|
||||||
|
else if (u2 && u->faction != u2->faction) {
|
||||||
if (u2->faction->newbies + n > MAXNEWBIES) {
|
if (u2->faction->newbies + n > MAXNEWBIES) {
|
||||||
error = 129;
|
error = 129;
|
||||||
} else if (u_race(u) != u2->faction->race) {
|
}
|
||||||
|
else if (u_race(u) != u2->faction->race) {
|
||||||
if (u2->faction->race != get_race(RC_HUMAN)) {
|
if (u2->faction->race != get_race(RC_HUMAN)) {
|
||||||
error = 120;
|
error = 120;
|
||||||
} else if (count_migrants(u2->faction) + n >
|
}
|
||||||
|
else if (count_migrants(u2->faction) + n >
|
||||||
count_maxmigrants(u2->faction)) {
|
count_maxmigrants(u2->faction)) {
|
||||||
error = 128;
|
error = 128;
|
||||||
} else if (has_limited_skills(u) || has_limited_skills(u2)) {
|
}
|
||||||
|
else if (has_limited_skills(u) || has_limited_skills(u2)) {
|
||||||
error = 154;
|
error = 154;
|
||||||
} else if (u2->number != 0) {
|
}
|
||||||
|
else if (u2->number != 0) {
|
||||||
error = 139;
|
error = 139;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +317,8 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
if (u->faction != u2->faction) {
|
if (u->faction != u2->faction) {
|
||||||
u2->faction->newbies += n;
|
u2->faction->newbies += n;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (getunitpeasants) {
|
if (getunitpeasants) {
|
||||||
#ifdef ORCIFICATION
|
#ifdef ORCIFICATION
|
||||||
if (u_race(u) == get_race(RC_SNOTLING) && !fval(u->region, RF_ORCIFIED)) {
|
if (u_race(u) == get_race(RC_SNOTLING) && !fval(u->region, RF_ORCIFIED)) {
|
||||||
|
@ -305,17 +329,20 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
transfermen(u, NULL, n);
|
transfermen(u, NULL, n);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
error = 159;
|
error = 159;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error > 0) {
|
if (error > 0) {
|
||||||
cmistake(u, ord, error, MSG_COMMERCE);
|
cmistake(u, ord, error, MSG_COMMERCE);
|
||||||
} else if (!u2) {
|
}
|
||||||
|
else if (!u2) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_message("give_person_peasants", "unit amount", u, n));
|
msg_message("give_person_peasants", "unit amount", u, n));
|
||||||
} else if (u2->faction != u->faction) {
|
}
|
||||||
|
else if (u2->faction != u->faction) {
|
||||||
message *msg = msg_message("give_person", "unit target amount", u, u2, n);
|
message *msg = msg_message("give_person", "unit target amount", u, u2, n);
|
||||||
add_message(&u->faction->msgs, msg);
|
add_message(&u->faction->msgs, msg);
|
||||||
add_message(&u2->faction->msgs, msg);
|
add_message(&u2->faction->msgs, msg);
|
||||||
|
@ -350,7 +377,8 @@ void give_unit(unit * u, unit * u2, order * ord)
|
||||||
if (u2 == NULL) {
|
if (u2 == NULL) {
|
||||||
if (fval(r->terrain, SEA_REGION)) {
|
if (fval(r->terrain, SEA_REGION)) {
|
||||||
cmistake(u, ord, 152, MSG_COMMERCE);
|
cmistake(u, ord, 152, MSG_COMMERCE);
|
||||||
} else if (getunitpeasants) {
|
}
|
||||||
|
else if (getunitpeasants) {
|
||||||
unit *u3;
|
unit *u3;
|
||||||
|
|
||||||
for (u3 = r->units; u3; u3 = u3->next)
|
for (u3 = r->units; u3; u3 = u3->next)
|
||||||
|
@ -371,7 +399,8 @@ void give_unit(unit * u, unit * u2, order * ord)
|
||||||
}
|
}
|
||||||
give_men(u->number, u, NULL, ord);
|
give_men(u->number, u, NULL, ord);
|
||||||
cmistake(u, ord, 153, MSG_COMMERCE);
|
cmistake(u, ord, 153, MSG_COMMERCE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
|
||||||
""));
|
""));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
Copyright (c) 1998-2014,
|
||||||
|
Enno Rehling <enno@eressea.de>
|
||||||
Katja Zedel <katze@felidae.kn-bremen.de
|
Katja Zedel <katze@felidae.kn-bremen.de
|
||||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
|
|
||||||
|
@ -161,7 +162,8 @@ static int a_ageicastle(struct attrib *a)
|
||||||
/* remove_building lets units leave the building */
|
/* remove_building lets units leave the building */
|
||||||
remove_building(&r->buildings, b);
|
remove_building(&r->buildings, b);
|
||||||
return AT_AGE_REMOVE;
|
return AT_AGE_REMOVE;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
data->time--;
|
data->time--;
|
||||||
return AT_AGE_KEEP;
|
return AT_AGE_KEEP;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +234,8 @@ void read_spells(struct quicklist **slistp, magic_t mtype,
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
break;
|
break;
|
||||||
sp = find_spellbyid((unsigned int)i);
|
sp = find_spellbyid((unsigned int)i);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
READ_TOK(store, spname, sizeof(spname));
|
READ_TOK(store, spname, sizeof(spname));
|
||||||
if (strcmp(spname, "end") == 0)
|
if (strcmp(spname, "end") == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -275,7 +278,8 @@ static int read_mage(attrib * a, void *owner, struct storage *store)
|
||||||
if (spid >= 0) {
|
if (spid >= 0) {
|
||||||
sp = find_spellbyid((unsigned int)spid);
|
sp = find_spellbyid((unsigned int)spid);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
READ_TOK(store, spname, sizeof(spname));
|
READ_TOK(store, spname, sizeof(spname));
|
||||||
READ_INT(store, &level);
|
READ_INT(store, &level);
|
||||||
|
|
||||||
|
@ -302,7 +306,8 @@ static int read_mage(attrib * a, void *owner, struct storage *store)
|
||||||
}
|
}
|
||||||
if (mage->magietyp == M_GRAY) {
|
if (mage->magietyp == M_GRAY) {
|
||||||
read_spellbook(&mage->spellbook, store, get_spell_level_mage, mage);
|
read_spellbook(&mage->spellbook, store, get_spell_level_mage, mage);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
read_spellbook(0, store, 0, mage);
|
read_spellbook(0, store, 0, mage);
|
||||||
}
|
}
|
||||||
return AT_READ_OK;
|
return AT_READ_OK;
|
||||||
|
@ -380,7 +385,8 @@ static int read_seenspell(attrib * a, void *owner, struct storage *store)
|
||||||
i = atoi(token);
|
i = atoi(token);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
sp = find_spellbyid((unsigned int)i);
|
sp = find_spellbyid((unsigned int)i);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (global.data_version < UNIQUE_SPELLS_VERSION) {
|
if (global.data_version < UNIQUE_SPELLS_VERSION) {
|
||||||
READ_INT(store, 0); /* ignore mtype */
|
READ_INT(store, 0); /* ignore mtype */
|
||||||
}
|
}
|
||||||
|
@ -479,7 +485,8 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells
|
||||||
commonspells[spellno] = commonspells[--maxspell];
|
commonspells[spellno] = commonspells[--maxspell];
|
||||||
commonspells[maxspell] = sbe;
|
commonspells[maxspell] = sbe;
|
||||||
sbe = 0;
|
sbe = 0;
|
||||||
} else if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) {
|
}
|
||||||
|
else if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) {
|
||||||
commonspells[spellno] = commonspells[--numspells];
|
commonspells[spellno] = commonspells[--numspells];
|
||||||
if (maxspell > numspells) {
|
if (maxspell > numspells) {
|
||||||
maxspell = numspells;
|
maxspell = numspells;
|
||||||
|
@ -556,7 +563,8 @@ const spell *get_combatspell(const unit * u, int nr)
|
||||||
m = get_mage(u);
|
m = get_mage(u);
|
||||||
if (m) {
|
if (m) {
|
||||||
return m->combatspells[nr].sp;
|
return m->combatspells[nr].sp;
|
||||||
} else if (u_race(u)->precombatspell != NULL) {
|
}
|
||||||
|
else if (u_race(u)->precombatspell != NULL) {
|
||||||
return u_race(u)->precombatspell;
|
return u_race(u)->precombatspell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,15 +621,18 @@ void unset_combatspell(unit * u, spell * sp)
|
||||||
for (i = 0; i < MAXCOMBATSPELLS; i++) {
|
for (i = 0; i < MAXCOMBATSPELLS; i++) {
|
||||||
m->combatspells[i].sp = NULL;
|
m->combatspells[i].sp = NULL;
|
||||||
}
|
}
|
||||||
} else if (sp->sptyp & PRECOMBATSPELL) {
|
}
|
||||||
|
else if (sp->sptyp & PRECOMBATSPELL) {
|
||||||
if (sp != get_combatspell(u, 0))
|
if (sp != get_combatspell(u, 0))
|
||||||
return;
|
return;
|
||||||
} else if (sp->sptyp & COMBATSPELL) {
|
}
|
||||||
|
else if (sp->sptyp & COMBATSPELL) {
|
||||||
if (sp != get_combatspell(u, 1)) {
|
if (sp != get_combatspell(u, 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nr = 1;
|
nr = 1;
|
||||||
} else if (sp->sptyp & POSTCOMBATSPELL) {
|
}
|
||||||
|
else if (sp->sptyp & POSTCOMBATSPELL) {
|
||||||
if (sp != get_combatspell(u, 2)) {
|
if (sp != get_combatspell(u, 2)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -842,7 +853,8 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range)
|
||||||
* gezauberten Sprüche abhängig */
|
* gezauberten Sprüche abhängig */
|
||||||
if (sp->components[k].type == r_aura) {
|
if (sp->components[k].type == r_aura) {
|
||||||
needplevel = spellcost(u, sp) * range;
|
needplevel = spellcost(u, sp) * range;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
needplevel = sp->components[k].amount * range;
|
needplevel = sp->components[k].amount * range;
|
||||||
}
|
}
|
||||||
maxlevel =
|
maxlevel =
|
||||||
|
@ -856,12 +868,14 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range)
|
||||||
cast_level = 0;
|
cast_level = 0;
|
||||||
/* ansonsten wird das Minimum aus maximal möglicher Stufe und der
|
/* ansonsten wird das Minimum aus maximal möglicher Stufe und der
|
||||||
* gewünschten gebildet */
|
* gewünschten gebildet */
|
||||||
} else if (sp->components[k].cost == SPC_LEVEL) {
|
}
|
||||||
|
else if (sp->components[k].cost == SPC_LEVEL) {
|
||||||
costtyp = SPC_LEVEL;
|
costtyp = SPC_LEVEL;
|
||||||
cast_level = _min(cast_level, maxlevel);
|
cast_level = _min(cast_level, maxlevel);
|
||||||
/* bei Typ Linear müssen die Kosten in Höhe der Stufe vorhanden
|
/* bei Typ Linear müssen die Kosten in Höhe der Stufe vorhanden
|
||||||
* sein, ansonsten schlägt der Spruch fehl */
|
* sein, ansonsten schlägt der Spruch fehl */
|
||||||
} else if (sp->components[k].cost == SPC_LINEAR) {
|
}
|
||||||
|
else if (sp->components[k].cost == SPC_LINEAR) {
|
||||||
costtyp = SPC_LINEAR;
|
costtyp = SPC_LINEAR;
|
||||||
if (maxlevel < cast_level)
|
if (maxlevel < cast_level)
|
||||||
cast_level = 0;
|
cast_level = 0;
|
||||||
|
@ -900,7 +914,8 @@ void pay_spell(unit * u, const spell * sp, int cast_level, int range)
|
||||||
for (k = 0; sp->components[k].type; k++) {
|
for (k = 0; sp->components[k].type; k++) {
|
||||||
if (sp->components[k].type == r_aura) {
|
if (sp->components[k].type == r_aura) {
|
||||||
resuse = spellcost(u, sp) * range;
|
resuse = spellcost(u, sp) * range;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
resuse = sp->components[k].amount * range;
|
resuse = sp->components[k].amount * range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,7 +980,8 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
|
||||||
* gezauberten Sprüche abhängig */
|
* gezauberten Sprüche abhängig */
|
||||||
if (rtype == r_aura) {
|
if (rtype == r_aura) {
|
||||||
itemanz = spellcost(u, sp) * range;
|
itemanz = spellcost(u, sp) * range;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
itemanz = sp->components[k].amount * range;
|
itemanz = sp->components[k].amount * range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,7 +1036,8 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order
|
||||||
|
|
||||||
if (sp == NULL) {
|
if (sp == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Bonus durch Magieturm und gesegneten Steinkreis */
|
/* Bonus durch Magieturm und gesegneten Steinkreis */
|
||||||
struct building *b = inside_building(u);
|
struct building *b = inside_building(u);
|
||||||
const struct building_type *btype = b ? b->type : NULL;
|
const struct building_type *btype = b ? b->type : NULL;
|
||||||
|
@ -1048,7 +1065,8 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order
|
||||||
if (force > 0) {
|
if (force > 0) {
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("reduce_spell",
|
ADDMSG(&mage->faction->msgs, msg_message("reduce_spell",
|
||||||
"self mage region", mage, u, r));
|
"self mage region", mage, u, r));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("block_spell",
|
ADDMSG(&mage->faction->msgs, msg_message("block_spell",
|
||||||
"self mage region", mage, u, r));
|
"self mage region", mage, u, r));
|
||||||
}
|
}
|
||||||
|
@ -1066,7 +1084,8 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order
|
||||||
if (force > 0) {
|
if (force > 0) {
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("reduce_spell",
|
ADDMSG(&mage->faction->msgs, msg_message("reduce_spell",
|
||||||
"self mage region", mage, u, r));
|
"self mage region", mage, u, r));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("block_spell",
|
ADDMSG(&mage->faction->msgs, msg_message("block_spell",
|
||||||
"self mage region", mage, u, r));
|
"self mage region", mage, u, r));
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1171,8 @@ double magic_resistance(unit * target)
|
||||||
probability += curse_geteffect(c) * 0.01;
|
probability += curse_geteffect(c) * 0.01;
|
||||||
ct_goodresist = 0; /* only one effect per region */
|
ct_goodresist = 0; /* only one effect per region */
|
||||||
}
|
}
|
||||||
} else if (ct_badresist && c->type == ct_badresist) {
|
}
|
||||||
|
else if (ct_badresist && c->type == ct_badresist) {
|
||||||
if (!alliedunit(mage, target->faction, HELP_GUARD)) {
|
if (!alliedunit(mage, target->faction, HELP_GUARD)) {
|
||||||
probability -= curse_geteffect(c) * 0.01;
|
probability -= curse_geteffect(c) * 0.01;
|
||||||
ct_badresist = 0; /* only one effect per region */
|
ct_badresist = 0; /* only one effect per region */
|
||||||
|
@ -1555,7 +1575,8 @@ message *msg_unitnotfound(const struct unit * mage, struct order * ord,
|
||||||
|
|
||||||
if (spobj->typ == SPP_UNIT) {
|
if (spobj->typ == SPP_UNIT) {
|
||||||
uid = itoa36(spobj->data.i);
|
uid = itoa36(spobj->data.i);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sprintf(tbuf, "%s %s", LOC(mage->faction->locale,
|
sprintf(tbuf, "%s %s", LOC(mage->faction->locale,
|
||||||
parameters[P_TEMP]), itoa36(spobj->data.i));
|
parameters[P_TEMP]), itoa36(spobj->data.i));
|
||||||
uid = tbuf;
|
uid = tbuf;
|
||||||
|
@ -1737,7 +1758,8 @@ verify_targets(castorder * co, int *invalid, int *resist, int *success)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* der Zauber hat keine expliziten Parameter/Ziele, es kann sich
|
/* der Zauber hat keine expliziten Parameter/Ziele, es kann sich
|
||||||
* aber um einen Regionszauber handeln. Wenn notwendig hier die
|
* aber um einen Regionszauber handeln. Wenn notwendig hier die
|
||||||
* Magieresistenz der Region prüfen. */
|
* Magieresistenz der Region prüfen. */
|
||||||
|
@ -1761,13 +1783,16 @@ verify_targets(castorder * co, int *invalid, int *resist, int *success)
|
||||||
"unit region command", mage, mage->region, co->order));
|
"unit region command", mage, mage->region, co->order));
|
||||||
spobj->flag = TARGET_RESISTS;
|
spobj->flag = TARGET_RESISTS;
|
||||||
++*resist;
|
++*resist;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
++*success;
|
++*success;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
++*success;
|
++*success;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
++*success;
|
++*success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1853,7 +1878,8 @@ addparam_region(const char *const param[], spllprm ** spobjp, const unit * u,
|
||||||
/* Fehler: Zielregion vergessen */
|
/* Fehler: Zielregion vergessen */
|
||||||
cmistake(u, ord, 194, MSG_MAGIC);
|
cmistake(u, ord, 194, MSG_MAGIC);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int tx = atoi((const char *)param[0]), ty = atoi((const char *)param[1]);
|
int tx = atoi((const char *)param[0]), ty = atoi((const char *)param[1]);
|
||||||
int x = rel_to_abs(pl, u->faction, tx, 0);
|
int x = rel_to_abs(pl, u->faction, tx, 0);
|
||||||
int y = rel_to_abs(pl, u->faction, ty, 1);
|
int y = rel_to_abs(pl, u->faction, ty, 1);
|
||||||
|
@ -1868,7 +1894,8 @@ addparam_region(const char *const param[], spllprm ** spobjp, const unit * u,
|
||||||
spobj->flag = 0;
|
spobj->flag = 0;
|
||||||
spobj->typ = SPP_REGION;
|
spobj->typ = SPP_REGION;
|
||||||
spobj->data.r = rt;
|
spobj->data.r = rt;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Fehler: Zielregion vergessen */
|
/* Fehler: Zielregion vergessen */
|
||||||
cmistake(u, ord, 194, MSG_MAGIC);
|
cmistake(u, ord, 194, MSG_MAGIC);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2169,7 +2196,8 @@ static void set_familiar(unit * mage, unit * familiar)
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
a = a_add(&mage->attribs, a_new(&at_familiar));
|
a = a_add(&mage->attribs, a_new(&at_familiar));
|
||||||
a->data.v = familiar;
|
a->data.v = familiar;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
assert(!a->data.v || a->data.v == familiar);
|
assert(!a->data.v || a->data.v == familiar);
|
||||||
/* TODO: Diese Attribute beim Tod des Familiars entfernen: */
|
/* TODO: Diese Attribute beim Tod des Familiars entfernen: */
|
||||||
|
|
||||||
|
@ -2177,7 +2205,8 @@ static void set_familiar(unit * mage, unit * familiar)
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
a = a_add(&familiar->attribs, a_new(&at_familiarmage));
|
a = a_add(&familiar->attribs, a_new(&at_familiarmage));
|
||||||
a->data.v = mage;
|
a->data.v = mage;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
assert(!a->data.v || a->data.v == mage);
|
assert(!a->data.v || a->data.v == mage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2273,7 +2302,8 @@ void create_newclone(unit * mage, unit * clone)
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
a = a_add(&mage->attribs, a_new(&at_clone));
|
a = a_add(&mage->attribs, a_new(&at_clone));
|
||||||
a->data.v = clone;
|
a->data.v = clone;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
assert(!a->data.v || a->data.v == clone);
|
assert(!a->data.v || a->data.v == clone);
|
||||||
/* TODO: Diese Attribute beim Tod des Klons entfernen: */
|
/* TODO: Diese Attribute beim Tod des Klons entfernen: */
|
||||||
|
|
||||||
|
@ -2281,7 +2311,8 @@ void create_newclone(unit * mage, unit * clone)
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
a = a_add(&clone->attribs, a_new(&at_clonemage));
|
a = a_add(&clone->attribs, a_new(&at_clonemage));
|
||||||
a->data.v = mage;
|
a->data.v = mage;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
assert(!a->data.v || a->data.v == mage);
|
assert(!a->data.v || a->data.v == mage);
|
||||||
|
|
||||||
/* Wenn der Magier stirbt, wird das in destroy_unit abgefangen.
|
/* Wenn der Magier stirbt, wird das in destroy_unit abgefangen.
|
||||||
|
@ -2299,14 +2330,16 @@ static void set_clone(unit * mage, unit * clone)
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
a = a_add(&mage->attribs, a_new(&at_clone));
|
a = a_add(&mage->attribs, a_new(&at_clone));
|
||||||
a->data.v = clone;
|
a->data.v = clone;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
assert(!a->data.v || a->data.v == clone);
|
assert(!a->data.v || a->data.v == clone);
|
||||||
|
|
||||||
a = a_find(clone->attribs, &at_clonemage);
|
a = a_find(clone->attribs, &at_clonemage);
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
a = a_add(&clone->attribs, a_new(&at_clonemage));
|
a = a_add(&clone->attribs, a_new(&at_clonemage));
|
||||||
a->data.v = mage;
|
a->data.v = mage;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
assert(!a->data.v || a->data.v == mage);
|
assert(!a->data.v || a->data.v == mage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2562,7 +2595,8 @@ static castorder *cast_cmd(unit * u, order * ord)
|
||||||
if (caster) {
|
if (caster) {
|
||||||
familiar = u;
|
familiar = u;
|
||||||
sp = unit_getspell(caster, s, caster->faction->locale);
|
sp = unit_getspell(caster, s, caster->faction->locale);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* somehow, this familiar has no mage! */
|
/* somehow, this familiar has no mage! */
|
||||||
log_error("cast_cmd: familiar %s is without a mage?\n", unitname(u));
|
log_error("cast_cmd: familiar %s is without a mage?\n", unitname(u));
|
||||||
caster = u;
|
caster = u;
|
||||||
|
@ -2604,7 +2638,8 @@ static castorder *cast_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
/* Auf bewegenden Schiffen kann man nur explizit als
|
/* Auf bewegenden Schiffen kann man nur explizit als
|
||||||
* ONSHIPCAST deklarierte Zauber sprechen */
|
* ONSHIPCAST deklarierte Zauber sprechen */
|
||||||
} else if (u->ship) {
|
}
|
||||||
|
else if (u->ship) {
|
||||||
if (is_moving_ship(r, u->ship)) {
|
if (is_moving_ship(r, u->ship)) {
|
||||||
if (!(sp->sptyp & ONSHIPCAST)) {
|
if (!(sp->sptyp & ONSHIPCAST)) {
|
||||||
/* Fehler: "Diesen Spruch kann man nicht auf einem sich
|
/* Fehler: "Diesen Spruch kann man nicht auf einem sich
|
||||||
|
@ -2817,7 +2852,8 @@ void magic(void)
|
||||||
/* kein Ziel gefunden, Fehlermeldungen sind in verify_targets */
|
/* kein Ziel gefunden, Fehlermeldungen sind in verify_targets */
|
||||||
/* keine kosten für den zauber */
|
/* keine kosten für den zauber */
|
||||||
continue; /* äußere Schleife, nächster Zauberer */
|
continue; /* äußere Schleife, nächster Zauberer */
|
||||||
} else if (co->force > 0 && resist > 0) {
|
}
|
||||||
|
else if (co->force > 0 && resist > 0) {
|
||||||
/* einige oder alle Ziele waren magieresistent */
|
/* einige oder alle Ziele waren magieresistent */
|
||||||
if (success == 0) {
|
if (success == 0) {
|
||||||
co->force = 0;
|
co->force = 0;
|
||||||
|
@ -2834,7 +2870,8 @@ void magic(void)
|
||||||
if (fumble(target_r, u, sp, co->level)) {
|
if (fumble(target_r, u, sp, co->level)) {
|
||||||
/* zuerst bezahlen, dann evt in do_fumble alle Aura verlieren */
|
/* zuerst bezahlen, dann evt in do_fumble alle Aura verlieren */
|
||||||
fumbled = true;
|
fumbled = true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
co->level = sp->cast(co);
|
co->level = sp->cast(co);
|
||||||
if (co->level <= 0) {
|
if (co->level <= 0) {
|
||||||
/* Kosten nur für real benötige Stufe berechnen */
|
/* Kosten nur für real benötige Stufe berechnen */
|
||||||
|
@ -2902,7 +2939,8 @@ spell *unit_getspell(struct unit *u, const char *name, const struct locale * lan
|
||||||
const char *n = spell_name(sp, lang);
|
const char *n = spell_name(sp, lang);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
log_error("no translation in locale %s for spell %s\n", locale_name(lang), sp->sname);
|
log_error("no translation in locale %s for spell %s\n", locale_name(lang), sp->sname);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
token.v = sp;
|
token.v = sp;
|
||||||
addtoken(&tokens, n, token);
|
addtoken(&tokens, n, token);
|
||||||
}
|
}
|
||||||
|
@ -2930,7 +2968,8 @@ spellbook * get_spellbook(const char * name)
|
||||||
|
|
||||||
if (cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0)) {
|
if (cb_find_prefix(&cb_spellbooks, name, strlen(name), &match, 1, 0)) {
|
||||||
cb_get_kv(match, &result, sizeof(result));
|
cb_get_kv(match, &result, sizeof(result));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
size_t len = strlen(name);
|
size_t len = strlen(name);
|
||||||
result = create_spellbook(name);
|
result = create_spellbook(name);
|
||||||
assert(strlen(name) + sizeof(result) < sizeof(buffer));
|
assert(strlen(name) + sizeof(result) < sizeof(buffer));
|
||||||
|
|
|
@ -286,7 +286,8 @@ int walkingcapacity(const struct unit *u)
|
||||||
if (fval(u_race(u), RCF_HORSE)) {
|
if (fval(u_race(u), RCF_HORSE)) {
|
||||||
animals += u->number;
|
animals += u->number;
|
||||||
people = 0;
|
people = 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
people = u->number;
|
people = u->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +426,8 @@ static int canride(unit * u)
|
||||||
for (itm = u->items; itm; itm = itm->next) {
|
for (itm = u->items; itm; itm = itm->next) {
|
||||||
if (itm->type == it_horse || itm->type == it_charger) {
|
if (itm->type == it_horse || itm->type == it_charger) {
|
||||||
horses += itm->number;
|
horses += itm->number;
|
||||||
} else if (itm->type == it_elvenhorse) {
|
}
|
||||||
|
else if (itm->type == it_elvenhorse) {
|
||||||
unicorns += itm->number;
|
unicorns += itm->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,7 +459,8 @@ static bool cansail(const region * r, ship * sh)
|
||||||
|
|
||||||
if (sh->type->construction && sh->size != sh->type->construction->maxsize) {
|
if (sh->type->construction && sh->size != sh->type->construction->maxsize) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int n = 0, p = 0;
|
int n = 0, p = 0;
|
||||||
int mweight = shipcapacity(sh);
|
int mweight = shipcapacity(sh);
|
||||||
int mcabins = sh->type->cabins;
|
int mcabins = sh->type->cabins;
|
||||||
|
@ -685,10 +688,12 @@ static void set_coast(ship * sh, region * r, region * rnext)
|
||||||
{
|
{
|
||||||
if (sh->type->flags & SFL_NOCOAST) {
|
if (sh->type->flags & SFL_NOCOAST) {
|
||||||
sh->coast = NODIRECTION;
|
sh->coast = NODIRECTION;
|
||||||
} else if (!fval(rnext->terrain, SEA_REGION) && !flying_ship(sh)) {
|
}
|
||||||
|
else if (!fval(rnext->terrain, SEA_REGION) && !flying_ship(sh)) {
|
||||||
sh->coast = reldirection(rnext, r);
|
sh->coast = reldirection(rnext, r);
|
||||||
assert(fval(r->terrain, SEA_REGION));
|
assert(fval(r->terrain, SEA_REGION));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sh->coast = NODIRECTION;
|
sh->coast = NODIRECTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -824,7 +829,8 @@ static void caught_target(region * r, unit * u)
|
||||||
if (!present(r, target)) {
|
if (!present(r, target)) {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("followfail", "unit follower",
|
ADDMSG(&u->faction->msgs, msg_message("followfail", "unit follower",
|
||||||
target, u));
|
target, u));
|
||||||
} else if (!alliedunit(target, u->faction, HELP_ALL)
|
}
|
||||||
|
else if (!alliedunit(target, u->faction, HELP_ALL)
|
||||||
&& cansee(target->faction, r, u, 0)) {
|
&& cansee(target->faction, r, u, 0)) {
|
||||||
ADDMSG(&target->faction->msgs, msg_message("followdetect",
|
ADDMSG(&target->faction->msgs, msg_message("followdetect",
|
||||||
"unit follower", target, u));
|
"unit follower", target, u));
|
||||||
|
@ -979,7 +985,8 @@ unit *is_guarded(region * r, unit * u, unsigned int mask)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
u2 = guard;
|
u2 = guard;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* exhausted all the guards in the cache, but maybe we'll find one later? */
|
/* exhausted all the guards in the cache, but maybe we'll find one later? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1052,10 +1059,12 @@ static void cycle_route(order * ord, unit * u, int gereist)
|
||||||
d = get_direction(token, lang);
|
d = get_direction(token, lang);
|
||||||
if (d == D_PAUSE) {
|
if (d == D_PAUSE) {
|
||||||
pause = true;
|
pause = true;
|
||||||
} else if (d == NODIRECTION) {
|
}
|
||||||
|
else if (d == NODIRECTION) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cm < gereist) {
|
if (cm < gereist) {
|
||||||
|
@ -1072,7 +1081,8 @@ static void cycle_route(order * ord, unit * u, int gereist)
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
} else if (strlen(neworder) > sizeof(neworder) / 2)
|
}
|
||||||
|
else if (strlen(neworder) > sizeof(neworder) / 2)
|
||||||
break;
|
break;
|
||||||
else if (cm == gereist && !paused && pause) {
|
else if (cm == gereist && !paused && pause) {
|
||||||
const char *loc = LOC(lang, parameters[P_PAUSE]);
|
const char *loc = LOC(lang, parameters[P_PAUSE]);
|
||||||
|
@ -1083,14 +1093,16 @@ static void cycle_route(order * ord, unit * u, int gereist)
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
paused = true;
|
paused = true;
|
||||||
} else if (pause) {
|
}
|
||||||
|
else if (pause) {
|
||||||
/* da PAUSE nicht in ein shortdirections[d] umgesetzt wird (ist
|
/* da PAUSE nicht in ein shortdirections[d] umgesetzt wird (ist
|
||||||
* hier keine normale direction), muss jede PAUSE einzeln
|
* hier keine normale direction), muss jede PAUSE einzeln
|
||||||
* herausgefiltert und explizit gesetzt werden */
|
* herausgefiltert und explizit gesetzt werden */
|
||||||
if (neworder[0])
|
if (neworder[0])
|
||||||
strcat(neworder, " ");
|
strcat(neworder, " ");
|
||||||
strcat(neworder, LOC(lang, parameters[P_PAUSE]));
|
strcat(neworder, LOC(lang, parameters[P_PAUSE]));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (neworder[0])
|
if (neworder[0])
|
||||||
strcat(neworder, " ");
|
strcat(neworder, " ");
|
||||||
strcat(neworder, LOC(lang, shortdirections[d]));
|
strcat(neworder, LOC(lang, shortdirections[d]));
|
||||||
|
@ -1099,7 +1111,8 @@ static void cycle_route(order * ord, unit * u, int gereist)
|
||||||
|
|
||||||
if (neworder[0]) {
|
if (neworder[0]) {
|
||||||
norder = create_order(K_ROUTE, u->faction->locale, "%s %s", neworder, tail);
|
norder = create_order(K_ROUTE, u->faction->locale, "%s %s", neworder, tail);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
norder = create_order(K_ROUTE, u->faction->locale, "%s", tail);
|
norder = create_order(K_ROUTE, u->faction->locale, "%s", tail);
|
||||||
}
|
}
|
||||||
replace_order(&u->orders, ord, norder);
|
replace_order(&u->orders, ord, norder);
|
||||||
|
@ -1161,7 +1174,8 @@ static void init_transportation(void)
|
||||||
if (!transport(ut, u)) {
|
if (!transport(ut, u)) {
|
||||||
if (cansee(u->faction, r, ut, 0)) {
|
if (cansee(u->faction, r, ut, 0)) {
|
||||||
cmistake(u, u->thisorder, 286, MSG_MOVE);
|
cmistake(u, u->thisorder, 286, MSG_MOVE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder,
|
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder,
|
||||||
"feedback_unit_not_found", ""));
|
"feedback_unit_not_found", ""));
|
||||||
}
|
}
|
||||||
|
@ -1481,18 +1495,21 @@ static const region_list *travel_route(unit * u,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
landing = true;
|
landing = true;
|
||||||
} else if ((u_race(u)->flags & RCF_WALK) == 0) {
|
}
|
||||||
|
else if ((u_race(u)->flags & RCF_WALK) == 0) {
|
||||||
/* Spezialeinheiten, die nicht laufen können. */
|
/* Spezialeinheiten, die nicht laufen können. */
|
||||||
ADDMSG(&u->faction->msgs, msg_message("detectocean",
|
ADDMSG(&u->faction->msgs, msg_message("detectocean",
|
||||||
"unit region", u, next));
|
"unit region", u, next));
|
||||||
break;
|
break;
|
||||||
} else if (landing) {
|
}
|
||||||
|
else if (landing) {
|
||||||
/* wir sind diese woche angelandet */
|
/* wir sind diese woche angelandet */
|
||||||
ADDMSG(&u->faction->msgs, msg_message("detectocean",
|
ADDMSG(&u->faction->msgs, msg_message("detectocean",
|
||||||
"unit region", u, next));
|
"unit region", u, next));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Ozeanfelder können nur von Einheiten mit Schwimmen und ohne
|
/* Ozeanfelder können nur von Einheiten mit Schwimmen und ohne
|
||||||
* Pferde betreten werden. */
|
* Pferde betreten werden. */
|
||||||
if (!(canswim(u) || canfly(u))) {
|
if (!(canswim(u) || canfly(u))) {
|
||||||
|
@ -1583,7 +1600,8 @@ static const region_list *travel_route(unit * u,
|
||||||
if (canride(u)) {
|
if (canride(u)) {
|
||||||
walkmode = 1;
|
walkmode = 1;
|
||||||
produceexp(u, SK_RIDING, u->number);
|
produceexp(u, SK_RIDING, u->number);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
walkmode = 2;
|
walkmode = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1819,14 +1837,16 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
"ship region", sh, next_point));
|
"ship region", sh, next_point));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (!check_takeoff(sh, current_point, next_point)) {
|
if (!check_takeoff(sh, current_point, next_point)) {
|
||||||
/* Schiff kann nicht ablegen */
|
/* Schiff kann nicht ablegen */
|
||||||
cmistake(u, ord, 182, MSG_MOVE);
|
cmistake(u, ord, 182, MSG_MOVE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fval(tnext, SEA_REGION)) {
|
}
|
||||||
|
else if (fval(tnext, SEA_REGION)) {
|
||||||
/* target region is an ocean, and we're not leaving a shore */
|
/* target region is an ocean, and we're not leaving a shore */
|
||||||
if (!(sh->type->flags & SFL_OPENSEA)) {
|
if (!(sh->type->flags & SFL_OPENSEA)) {
|
||||||
/* ship can only stay close to shore */
|
/* ship can only stay close to shore */
|
||||||
|
@ -1850,7 +1870,8 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
/* for some reason or another, we aren't allowed in there.. */
|
/* for some reason or another, we aren't allowed in there.. */
|
||||||
if (check_leuchtturm(current_point, NULL) || reason == SA_NO_INSECT) {
|
if (check_leuchtturm(current_point, NULL) || reason == SA_NO_INSECT) {
|
||||||
ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship region", sh, next_point));
|
ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship region", sh, next_point));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
float dmg =
|
float dmg =
|
||||||
get_param_flt(global.parameters, "rules.ship.damage.nolanding",
|
get_param_flt(global.parameters, "rules.ship.damage.nolanding",
|
||||||
0.10F);
|
0.10F);
|
||||||
|
@ -1931,7 +1952,8 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
if (is_cursed(sh->attribs, C_SHIP_FLYING, 0)) {
|
if (is_cursed(sh->attribs, C_SHIP_FLYING, 0)) {
|
||||||
ADDMSG(&f->msgs, msg_message("shipfly", "ship from to", sh,
|
ADDMSG(&f->msgs, msg_message("shipfly", "ship from to", sh,
|
||||||
starting_point, current_point));
|
starting_point, current_point));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&f->msgs, msg_message("shipsail", "ship from to", sh,
|
ADDMSG(&f->msgs, msg_message("shipsail", "ship from to", sh,
|
||||||
starting_point, current_point));
|
starting_point, current_point));
|
||||||
}
|
}
|
||||||
|
@ -2061,9 +2083,11 @@ static const region_list *travel_i(unit * u, const region_list * route_begin,
|
||||||
if (ut->building && !can_leave(ut)) {
|
if (ut->building && !can_leave(ut)) {
|
||||||
cmistake(ut, ut->thisorder, 150, MSG_MOVE);
|
cmistake(ut, ut->thisorder, 150, MSG_MOVE);
|
||||||
cmistake(u, ord, 99, MSG_MOVE);
|
cmistake(u, ord, 99, MSG_MOVE);
|
||||||
} else if (!can_move(ut)) {
|
}
|
||||||
|
else if (!can_move(ut)) {
|
||||||
cmistake(u, ord, 99, MSG_MOVE);
|
cmistake(u, ord, 99, MSG_MOVE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (!fval(ut, UFL_NOTMOVING) && !LongHunger(ut)) {
|
if (!fval(ut, UFL_NOTMOVING) && !LongHunger(ut)) {
|
||||||
|
@ -2085,14 +2109,16 @@ static const region_list *travel_i(unit * u, const region_list * route_begin,
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (cansee(u->faction, u->region, ut, 0)) {
|
if (cansee(u->faction, u->region, ut, 0)) {
|
||||||
cmistake(u, ord, 90, MSG_MOVE);
|
cmistake(u, ord, 90, MSG_MOVE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
||||||
"feedback_unit_not_found", ""));
|
"feedback_unit_not_found", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
|
||||||
""));
|
""));
|
||||||
}
|
}
|
||||||
|
@ -2139,7 +2165,8 @@ static void travel(unit * u, region_list ** routep)
|
||||||
cmistake(u, u->thisorder, 143, MSG_MOVE);
|
cmistake(u, u->thisorder, 143, MSG_MOVE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (u->ship && fval(u->ship, SF_MOVED)) {
|
}
|
||||||
|
else if (u->ship && fval(u->ship, SF_MOVED)) {
|
||||||
/* die Einheit ist auf einem Schiff, das sich bereits bewegt hat */
|
/* die Einheit ist auf einem Schiff, das sich bereits bewegt hat */
|
||||||
cmistake(u, u->thisorder, 13, MSG_MOVE);
|
cmistake(u, u->thisorder, 13, MSG_MOVE);
|
||||||
return;
|
return;
|
||||||
|
@ -2186,7 +2213,8 @@ static void move(unit * u, bool move_on_land)
|
||||||
assert(u->number);
|
assert(u->number);
|
||||||
if (u->ship && u == ship_owner(u->ship)) {
|
if (u->ship && u == ship_owner(u->ship)) {
|
||||||
sail(u, u->thisorder, move_on_land, &route);
|
sail(u, u->thisorder, move_on_land, &route);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
travel(u, &route);
|
travel(u, &route);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2394,13 +2422,16 @@ static int hunt(unit * u, order * ord)
|
||||||
|
|
||||||
if (fval(u, UFL_NOTMOVING)) {
|
if (fval(u, UFL_NOTMOVING)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!u->ship) {
|
}
|
||||||
|
else if (!u->ship) {
|
||||||
cmistake(u, ord, 144, MSG_MOVE);
|
cmistake(u, ord, 144, MSG_MOVE);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (u!=ship_owner(u->ship)) {
|
}
|
||||||
|
else if (u != ship_owner(u->ship)) {
|
||||||
cmistake(u, ord, 146, MSG_MOVE);
|
cmistake(u, ord, 146, MSG_MOVE);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!can_move(u)) {
|
}
|
||||||
|
else if (!can_move(u)) {
|
||||||
cmistake(u, ord, 55, MSG_MOVE);
|
cmistake(u, ord, 55, MSG_MOVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2432,7 +2463,8 @@ static int hunt(unit * u, order * ord)
|
||||||
speed = getuint();
|
speed = getuint();
|
||||||
if (speed == 0) {
|
if (speed == 0) {
|
||||||
speed = shipspeed(u->ship, u);
|
speed = shipspeed(u->ship, u);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int maxspeed = shipspeed(u->ship, u);
|
int maxspeed = shipspeed(u->ship, u);
|
||||||
if (maxspeed < speed)
|
if (maxspeed < speed)
|
||||||
speed = maxspeed;
|
speed = maxspeed;
|
||||||
|
@ -2513,7 +2545,8 @@ static void move_hunters(void)
|
||||||
if (fval(u, UFL_NOTMOVING)) {
|
if (fval(u, UFL_NOTMOVING)) {
|
||||||
cmistake(u, ord, 52, MSG_MOVE);
|
cmistake(u, ord, 52, MSG_MOVE);
|
||||||
break;
|
break;
|
||||||
} else if (!can_move(u)) {
|
}
|
||||||
|
else if (!can_move(u)) {
|
||||||
cmistake(u, ord, 55, MSG_MOVE);
|
cmistake(u, ord, 55, MSG_MOVE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2552,7 +2585,8 @@ static void move_pirates(void)
|
||||||
if (*up == u) {
|
if (*up == u) {
|
||||||
/* not moved, use next unit */
|
/* not moved, use next unit */
|
||||||
up = &u->next;
|
up = &u->next;
|
||||||
} else if (*up && (*up)->region != r) {
|
}
|
||||||
|
else if (*up && (*up)->region != r) {
|
||||||
/* moved the previous unit along with u (units on same ship)
|
/* moved the previous unit along with u (units on same ship)
|
||||||
* must start from the beginning again */
|
* must start from the beginning again */
|
||||||
up = &r->units;
|
up = &r->units;
|
||||||
|
@ -2602,24 +2636,29 @@ void movement(void)
|
||||||
if (fval(u, UFL_LONGACTION)) {
|
if (fval(u, UFL_LONGACTION)) {
|
||||||
cmistake(u, u->thisorder, 52, MSG_MOVE);
|
cmistake(u, u->thisorder, 52, MSG_MOVE);
|
||||||
set_order(&u->thisorder, NULL);
|
set_order(&u->thisorder, NULL);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cmistake(u, u->thisorder, 319, MSG_MOVE);
|
cmistake(u, u->thisorder, 319, MSG_MOVE);
|
||||||
set_order(&u->thisorder, NULL);
|
set_order(&u->thisorder, NULL);
|
||||||
}
|
}
|
||||||
} else if (fval(u, UFL_MOVED)) {
|
}
|
||||||
|
else if (fval(u, UFL_MOVED)) {
|
||||||
cmistake(u, u->thisorder, 187, MSG_MOVE);
|
cmistake(u, u->thisorder, 187, MSG_MOVE);
|
||||||
set_order(&u->thisorder, NULL);
|
set_order(&u->thisorder, NULL);
|
||||||
} else if (!can_move(u)) {
|
}
|
||||||
|
else if (!can_move(u)) {
|
||||||
cmistake(u, u->thisorder, 55, MSG_MOVE);
|
cmistake(u, u->thisorder, 55, MSG_MOVE);
|
||||||
set_order(&u->thisorder, NULL);
|
set_order(&u->thisorder, NULL);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (ships) {
|
if (ships) {
|
||||||
if (u->ship && ship_owner(u->ship) == u) {
|
if (u->ship && ship_owner(u->ship) == u) {
|
||||||
init_tokens(u->thisorder);
|
init_tokens(u->thisorder);
|
||||||
skip_token();
|
skip_token();
|
||||||
move(u, false);
|
move(u, false);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (!u->ship || ship_owner(u->ship) != u) {
|
if (!u->ship || ship_owner(u->ship) != u) {
|
||||||
init_tokens(u->thisorder);
|
init_tokens(u->thisorder);
|
||||||
skip_token();
|
skip_token();
|
||||||
|
@ -2631,13 +2670,15 @@ void movement(void)
|
||||||
if (u->region == r) {
|
if (u->region == r) {
|
||||||
/* not moved, use next unit */
|
/* not moved, use next unit */
|
||||||
up = &u->next;
|
up = &u->next;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (*up && (*up)->region != r) {
|
if (*up && (*up)->region != r) {
|
||||||
/* moved the upcoming unit along with u (units on ships or followers,
|
/* moved the upcoming unit along with u (units on ships or followers,
|
||||||
* for example). must start from the beginning again immediately */
|
* for example). must start from the beginning again immediately */
|
||||||
up = &r->units;
|
up = &r->units;
|
||||||
repeat = false;
|
repeat = false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
repeat = true;
|
repeat = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2690,10 +2731,12 @@ void follow_unit(unit * u)
|
||||||
unit *uf = findunit(id);
|
unit *uf = findunit(id);
|
||||||
if (!a) {
|
if (!a) {
|
||||||
a = a_add(&u->attribs, make_follow(uf));
|
a = a_add(&u->attribs, make_follow(uf));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
a->data.v = uf;
|
a->data.v = uf;
|
||||||
}
|
}
|
||||||
} else if (a) {
|
}
|
||||||
|
else if (a) {
|
||||||
a_remove(&u->attribs, a);
|
a_remove(&u->attribs, a);
|
||||||
a = NULL;
|
a = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,8 @@ static char* get_command(const order *ord, char *sbuffer, size_t size) {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
*bufp++ = '@';
|
*bufp++ = '@';
|
||||||
--size;
|
--size;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +117,8 @@ static char* get_command(const order *ord, char *sbuffer, size_t size) {
|
||||||
bytes = (int)strlcpy(bufp, str, size);
|
bytes = (int)strlcpy(bufp, str, size);
|
||||||
if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER();
|
||||||
if (text) *bufp++ = ' ';
|
if (text) *bufp++ = ' ';
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +222,8 @@ static order_data *create_data(keyword_t kwd, const char *sptr, int lindex)
|
||||||
memcpy(data->_str + 1, skname, len);
|
memcpy(data->_str + 1, skname, len);
|
||||||
data->_str[len + 1] = '\"';
|
data->_str[len + 1] = '\"';
|
||||||
data->_str[len + 2] = '\0';
|
data->_str[len + 2] = '\0';
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
data->_str = _strdup(skname);
|
data->_str = _strdup(skname);
|
||||||
}
|
}
|
||||||
data->_refcount = 1;
|
data->_refcount = 1;
|
||||||
|
@ -328,7 +331,8 @@ order *create_order(keyword_t kwd, const struct locale * lang,
|
||||||
default:
|
default:
|
||||||
assert(!"unknown format-character in create_order");
|
assert(!"unknown format-character in create_order");
|
||||||
}
|
}
|
||||||
} else if (size > 0) {
|
}
|
||||||
|
else if (size > 0) {
|
||||||
*bufp++ = *params;
|
*bufp++ = *params;
|
||||||
--size;
|
--size;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +340,8 @@ order *create_order(keyword_t kwd, const struct locale * lang,
|
||||||
}
|
}
|
||||||
va_end(marker);
|
va_end(marker);
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
zBuffer[0] = 0;
|
zBuffer[0] = 0;
|
||||||
}
|
}
|
||||||
return create_order_i(kwd, zBuffer, 0, lang);
|
return create_order_i(kwd, zBuffer, 0, lang);
|
||||||
|
@ -563,12 +568,14 @@ char *write_order(const order * ord, char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
if (ord == 0) {
|
if (ord == 0) {
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
keyword_t kwd = ORD_KEYWORD(ord);
|
keyword_t kwd = ORD_KEYWORD(ord);
|
||||||
if (kwd == NOKEYWORD) {
|
if (kwd == NOKEYWORD) {
|
||||||
const char *text = ORD_STRING(ord);
|
const char *text = ORD_STRING(ord);
|
||||||
strlcpy(buffer, (const char *)text, size);
|
strlcpy(buffer, (const char *)text, size);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
get_command(ord, buffer, size);
|
get_command(ord, buffer, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
Copyright (c) 1998-2014,
|
||||||
|
Enno Rehling <enno@eressea.de>
|
||||||
Katja Zedel <katze@felidae.kn-bremen.de
|
Katja Zedel <katze@felidae.kn-bremen.de
|
||||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue