forked from github/server
allow reading the configuration from a different directory (-c dir).
This commit is contained in:
parent
af73c6dcdf
commit
51207167c8
304
src/laws.c
304
src/laws.c
|
@ -198,7 +198,8 @@ void get_food(region * r)
|
||||||
int get = 0;
|
int get = 0;
|
||||||
if (v->number <= c) {
|
if (v->number <= c) {
|
||||||
get = lifestyle(v);
|
get = lifestyle(v);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
get = lifestyle(v) * c / v->number;
|
get = lifestyle(v) * c / v->number;
|
||||||
}
|
}
|
||||||
if (get) {
|
if (get) {
|
||||||
|
@ -326,7 +327,8 @@ void get_food(region * r)
|
||||||
if (peasantfood >= hungry) {
|
if (peasantfood >= hungry) {
|
||||||
peasantfood -= hungry;
|
peasantfood -= hungry;
|
||||||
hungry = 0;
|
hungry = 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
hungry -= peasantfood;
|
hungry -= peasantfood;
|
||||||
peasantfood = 0;
|
peasantfood = 0;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +341,8 @@ void get_food(region * r)
|
||||||
/* demons who don't feed are hungry */
|
/* demons who don't feed are hungry */
|
||||||
if (hunger(hungry, u))
|
if (hunger(hungry, u))
|
||||||
fset(u, UFL_HUNGER);
|
fset(u, UFL_HUNGER);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* no damage, but set the hungry-flag */
|
/* no damage, but set the hungry-flag */
|
||||||
fset(u, UFL_HUNGER);
|
fset(u, UFL_HUNGER);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +365,8 @@ static void age_unit(region * r, unit * u)
|
||||||
if (--u->age <= 0) {
|
if (--u->age <= 0) {
|
||||||
remove_unit(&r->units, u);
|
remove_unit(&r->units, u);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
++u->age;
|
++u->age;
|
||||||
if (u->number > 0 && u_race(u)->age) {
|
if (u->number > 0 && u_race(u)->age) {
|
||||||
u_race(u)->age(u);
|
u_race(u)->age(u);
|
||||||
|
@ -623,7 +627,8 @@ static void horses(region * r)
|
||||||
if (horses > 0) {
|
if (horses > 0) {
|
||||||
if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) {
|
if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) {
|
||||||
rsethorses(r, (int)(horses * 0.9F));
|
rsethorses(r, (int)(horses * 0.9F));
|
||||||
} else if (maxhorses) {
|
}
|
||||||
|
else if (maxhorses) {
|
||||||
int i;
|
int i;
|
||||||
double growth =
|
double growth =
|
||||||
(RESOURCE_QUANTITY * HORSEGROWTH * 200 * (maxhorses -
|
(RESOURCE_QUANTITY * HORSEGROWTH * 200 * (maxhorses -
|
||||||
|
@ -817,7 +822,8 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (current_season == SEASON_SPRING) {
|
}
|
||||||
|
else if (current_season == SEASON_SPRING) {
|
||||||
|
|
||||||
if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0))
|
if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0))
|
||||||
return;
|
return;
|
||||||
|
@ -941,7 +947,8 @@ void demographics(void)
|
||||||
if (plant_rules == 0) { /* E1 */
|
if (plant_rules == 0) { /* E1 */
|
||||||
growing_trees(r, current_season, last_weeks_season);
|
growing_trees(r, current_season, last_weeks_season);
|
||||||
growing_herbs(r, current_season, last_weeks_season);
|
growing_herbs(r, current_season, last_weeks_season);
|
||||||
} else { /* E3 */
|
}
|
||||||
|
else { /* E3 */
|
||||||
growing_trees_e3(r, current_season, last_weeks_season);
|
growing_trees_e3(r, current_season, last_weeks_season);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -982,7 +989,8 @@ static int modify(int i)
|
||||||
|
|
||||||
if (c >= 1) {
|
if (c >= 1) {
|
||||||
return (c + rng_int() % c);
|
return (c + rng_int() % c);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1118,7 +1126,8 @@ int leave_cmd(unit * u, struct order *ord)
|
||||||
if (!slipthru(r, u, u->building)) {
|
if (!slipthru(r, u, u->building)) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "entrance_besieged",
|
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "entrance_besieged",
|
||||||
"building", u->building));
|
"building", u->building));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
leave(u, true);
|
leave(u, true);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1152,14 +1161,17 @@ int quit_cmd(unit * u, struct order *ord)
|
||||||
if (f2 == NULL) {
|
if (f2 == NULL) {
|
||||||
cmistake(u, ord, 66, MSG_EVENT);
|
cmistake(u, ord, 66, MSG_EVENT);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!u->faction->alliance
|
}
|
||||||
|
else if (!u->faction->alliance
|
||||||
|| u->faction->alliance != f2->alliance) {
|
|| u->faction->alliance != f2->alliance) {
|
||||||
cmistake(u, ord, 315, MSG_EVENT);
|
cmistake(u, ord, 315, MSG_EVENT);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!alliedfaction(NULL, f, f2, HELP_MONEY)) {
|
}
|
||||||
|
else if (!alliedfaction(NULL, f, f2, HELP_MONEY)) {
|
||||||
cmistake(u, ord, 316, MSG_EVENT);
|
cmistake(u, ord, 316, MSG_EVENT);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
variant var;
|
variant var;
|
||||||
var.i = f2_id;
|
var.i = f2_id;
|
||||||
a_add(&f->attribs, object_create("quit", TINTEGER, var));
|
a_add(&f->attribs, object_create("quit", TINTEGER, var));
|
||||||
|
@ -1167,7 +1179,8 @@ int quit_cmd(unit * u, struct order *ord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fset(f, FFL_QUIT);
|
fset(f, FFL_QUIT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
write_order(ord, buffer, sizeof(buffer));
|
write_order(ord, buffer, sizeof(buffer));
|
||||||
cmistake(u, ord, 86, MSG_EVENT);
|
cmistake(u, ord, 86, MSG_EVENT);
|
||||||
|
@ -1260,7 +1273,8 @@ int enter_ship(unit * u, struct order *ord, int id, int report)
|
||||||
u_set_ship(u, sh);
|
u_set_ship(u, sh);
|
||||||
fset(u, UFL_ENTER);
|
fset(u, UFL_ENTER);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (report) {
|
}
|
||||||
|
else if (report) {
|
||||||
cmistake(u, ord, 150, MSG_MOVE);
|
cmistake(u, ord, 150, MSG_MOVE);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1308,7 +1322,8 @@ int enter_building(unit * u, order * ord, int id, int report)
|
||||||
fset(u, UFL_ENTER);
|
fset(u, UFL_ENTER);
|
||||||
u_set_building(u, b);
|
u_set_building(u, b);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (report) {
|
}
|
||||||
|
else if (report) {
|
||||||
cmistake(u, ord, 150, MSG_MOVE);
|
cmistake(u, ord, 150, MSG_MOVE);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1498,7 +1513,8 @@ void quit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
destroyfaction(f);
|
destroyfaction(f);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
++f->age;
|
++f->age;
|
||||||
if (f->age + 1 < NewbieImmunity()) {
|
if (f->age + 1 < NewbieImmunity()) {
|
||||||
ADDMSG(&f->msgs, msg_message("newbieimmunity", "turns",
|
ADDMSG(&f->msgs, msg_message("newbieimmunity", "turns",
|
||||||
|
@ -1558,7 +1574,8 @@ int ally_cmd(unit * u, struct order *ord)
|
||||||
if (keyword == P_NOT || not_kw == P_NOT) {
|
if (keyword == P_NOT || not_kw == P_NOT) {
|
||||||
/* Wir helfen der Partei gar nicht... */
|
/* Wir helfen der Partei gar nicht... */
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sf = calloc(1, sizeof(ally));
|
sf = calloc(1, sizeof(ally));
|
||||||
sf->faction = f;
|
sf->faction = f;
|
||||||
sf->status = 0;
|
sf->status = 0;
|
||||||
|
@ -1702,7 +1719,8 @@ int prefix_cmd(unit * u, struct order *ord)
|
||||||
if (a) {
|
if (a) {
|
||||||
group *g = (group *)a->data.v;
|
group *g = (group *)a->data.v;
|
||||||
a_removeall(&g->attribs, &at_raceprefix);
|
a_removeall(&g->attribs, &at_raceprefix);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
a_removeall(&u->faction->attribs, &at_raceprefix);
|
a_removeall(&u->faction->attribs, &at_raceprefix);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1710,9 +1728,11 @@ int prefix_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
if (findtoken(in->names, s, &var) == E_TOK_NOMATCH) {
|
if (findtoken(in->names, s, &var) == E_TOK_NOMATCH) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (race_prefixes[var.i] == NULL) {
|
}
|
||||||
|
else if (race_prefixes[var.i] == NULL) {
|
||||||
cmistake(u, ord, 299, MSG_EVENT);
|
cmistake(u, ord, 299, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ap = &u->faction->attribs;
|
ap = &u->faction->attribs;
|
||||||
if (fval(u, UFL_GROUP)) {
|
if (fval(u, UFL_GROUP)) {
|
||||||
attrib *a = a_find(u->attribs, &at_group);
|
attrib *a = a_find(u->attribs, &at_group);
|
||||||
|
@ -1729,7 +1749,8 @@ static cmp_building_cb get_cmp_region_owner(void)
|
||||||
{
|
{
|
||||||
if (rule_region_owners()) {
|
if (rule_region_owners()) {
|
||||||
return &cmp_current_owner;
|
return &cmp_current_owner;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return &cmp_wage;
|
return &cmp_wage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1783,7 +1804,8 @@ int display_cmd(unit * u, struct order *ord)
|
||||||
const char *d = getstrtoken();
|
const char *d = getstrtoken();
|
||||||
if (d == NULL || *d == 0) {
|
if (d == NULL || *d == 0) {
|
||||||
usetprivate(u, NULL);
|
usetprivate(u, NULL);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
usetprivate(u, d);
|
usetprivate(u, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1884,13 +1906,15 @@ rename_building(unit * u, order * ord, building * b, const char *name)
|
||||||
ADDMSG(&owner->faction->msgs,
|
ADDMSG(&owner->faction->msgs,
|
||||||
msg_message("renamed_building_seen",
|
msg_message("renamed_building_seen",
|
||||||
"building renamer region", b, u, u->region));
|
"building renamer region", b, u, u->region));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&owner->faction->msgs,
|
ADDMSG(&owner->faction->msgs,
|
||||||
msg_message("renamed_building_notseen",
|
msg_message("renamed_building_notseen",
|
||||||
"building region", b, u->region));
|
"building region", b, u->region));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (owner != u) {
|
if (owner != u) {
|
||||||
cmistake(u, ord, 148, MSG_PRODUCE);
|
cmistake(u, ord, 148, MSG_PRODUCE);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1950,7 +1974,8 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
if (f->age < 10) {
|
if (f->age < 10) {
|
||||||
cmistake(u, ord, 248, MSG_EVENT);
|
cmistake(u, ord, 248, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const struct locale *lang = locales;
|
const struct locale *lang = locales;
|
||||||
for (; lang; lang = nextlocale(lang)) {
|
for (; lang; lang = nextlocale(lang)) {
|
||||||
const char *fdname = LOC(lang, "factiondefault");
|
const char *fdname = LOC(lang, "factiondefault");
|
||||||
|
@ -1967,11 +1992,13 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
if (cansee(f, r, u, 0)) {
|
if (cansee(f, r, u, 0)) {
|
||||||
ADDMSG(&f->msgs,
|
ADDMSG(&f->msgs,
|
||||||
msg_message("renamed_faction_seen", "unit region", u, r));
|
msg_message("renamed_faction_seen", "unit region", u, r));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&f->msgs, msg_message("renamed_faction_notseen", "", r));
|
ADDMSG(&f->msgs, msg_message("renamed_faction_notseen", "", r));
|
||||||
}
|
}
|
||||||
s = &f->name;
|
s = &f->name;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
s = &u->faction->name;
|
s = &u->faction->name;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1984,7 +2011,8 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
if (!sh) {
|
if (!sh) {
|
||||||
cmistake(u, ord, 20, MSG_EVENT);
|
cmistake(u, ord, 20, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const struct locale *lang = locales;
|
const struct locale *lang = locales;
|
||||||
for (; lang; lang = nextlocale(lang)) {
|
for (; lang; lang = nextlocale(lang)) {
|
||||||
const char *sdname = LOC(lang, sh->type->_name);
|
const char *sdname = LOC(lang, sh->type->_name);
|
||||||
|
@ -2012,13 +2040,15 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
if (cansee(uo->faction, r, u, 0)) {
|
if (cansee(uo->faction, r, u, 0)) {
|
||||||
ADDMSG(&uo->faction->msgs,
|
ADDMSG(&uo->faction->msgs,
|
||||||
msg_message("renamed_ship_seen", "ship renamer region", sh, u, r));
|
msg_message("renamed_ship_seen", "ship renamer region", sh, u, r));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&uo->faction->msgs,
|
ADDMSG(&uo->faction->msgs,
|
||||||
msg_message("renamed_ship_notseen", "ship region", sh, r));
|
msg_message("renamed_ship_notseen", "ship region", sh, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s = &sh->name;
|
s = &sh->name;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (!u->ship) {
|
if (!u->ship) {
|
||||||
cmistake(u, ord, 144, MSG_PRODUCE);
|
cmistake(u, ord, 144, MSG_PRODUCE);
|
||||||
break;
|
break;
|
||||||
|
@ -2039,7 +2069,8 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
||||||
"feedback_unit_not_found", ""));
|
"feedback_unit_not_found", ""));
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const char *udefault = LOC(u2->faction->locale, "unitdefault");
|
const char *udefault = LOC(u2->faction->locale, "unitdefault");
|
||||||
size_t udlen = strlen(udefault);
|
size_t udlen = strlen(udefault);
|
||||||
size_t unlen = strlen(u2->name);
|
size_t unlen = strlen(u2->name);
|
||||||
|
@ -2051,12 +2082,14 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
if (cansee(u2->faction, r, u, 0)) {
|
if (cansee(u2->faction, r, u, 0)) {
|
||||||
ADDMSG(&u2->faction->msgs, msg_message("renamed_seen",
|
ADDMSG(&u2->faction->msgs, msg_message("renamed_seen",
|
||||||
"renamer renamed region", u, u2, r));
|
"renamer renamed region", u, u2, r));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u2->faction->msgs, msg_message("renamed_notseen",
|
ADDMSG(&u2->faction->msgs, msg_message("renamed_notseen",
|
||||||
"renamed region", u2, r));
|
"renamed region", u2, r));
|
||||||
}
|
}
|
||||||
s = &u2->name;
|
s = &u2->name;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
s = &u->name;
|
s = &u->name;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2087,7 +2120,8 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
group *g = (group *)a->data.v;
|
group *g = (group *)a->data.v;
|
||||||
s = &g->name;
|
s = &g->name;
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cmistake(u, ord, 109, MSG_EVENT);
|
cmistake(u, ord, 109, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2116,7 +2150,8 @@ deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
|
||||||
if (!receiver) { /* BOTSCHAFT an PARTEI */
|
if (!receiver) { /* BOTSCHAFT an PARTEI */
|
||||||
ADDMSG(&f->msgs,
|
ADDMSG(&f->msgs,
|
||||||
msg_message("regionmessage", "region sender string", r, u, s));
|
msg_message("regionmessage", "region sender string", r, u, s));
|
||||||
} else { /* BOTSCHAFT an EINHEIT */
|
}
|
||||||
|
else { /* BOTSCHAFT an EINHEIT */
|
||||||
ADDMSG(&f->msgs,
|
ADDMSG(&f->msgs,
|
||||||
msg_message("unitmessage", "region unit sender string", r,
|
msg_message("unitmessage", "region unit sender string", r,
|
||||||
receiver, u, s));
|
receiver, u, s));
|
||||||
|
@ -2131,7 +2166,8 @@ mailunit(region * r, unit * u, int n, struct order *ord, const char *s)
|
||||||
if (u2 && cansee(u->faction, r, u2, 0)) {
|
if (u2 && cansee(u->faction, r, u2, 0)) {
|
||||||
deliverMail(u2->faction, r, u, s, u2);
|
deliverMail(u2->faction, r, u, s, u2);
|
||||||
/* now done in prepare_mail_cmd */
|
/* now done in prepare_mail_cmd */
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Immer eine Meldung - sonst koennte man so getarnte EHs enttarnen:
|
/* Immer eine Meldung - sonst koennte man so getarnte EHs enttarnen:
|
||||||
* keine Meldung -> EH hier. */
|
* keine Meldung -> EH hier. */
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
|
@ -2173,7 +2209,8 @@ int mail_cmd(unit * u, struct order *ord)
|
||||||
if (!s[0]) {
|
if (!s[0]) {
|
||||||
cmistake(u, ord, 30, MSG_MESSAGE);
|
cmistake(u, ord, 30, MSG_MESSAGE);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&r->msgs, msg_message("mail_result", "unit message", u, s));
|
ADDMSG(&r->msgs, msg_message("mail_result", "unit message", u, s));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2227,7 +2264,8 @@ int mail_cmd(unit * u, struct order *ord)
|
||||||
if (!s[0]) {
|
if (!s[0]) {
|
||||||
cmistake(u, ord, 30, MSG_MESSAGE);
|
cmistake(u, ord, 30, MSG_MESSAGE);
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
attrib *a = a_find(u2->attribs, &at_eventhandler);
|
attrib *a = a_find(u2->attribs, &at_eventhandler);
|
||||||
if (a != NULL) {
|
if (a != NULL) {
|
||||||
event_arg args[3];
|
event_arg args[3];
|
||||||
|
@ -2310,8 +2348,7 @@ int mail_cmd(unit * u, struct order *ord)
|
||||||
cont = 1;
|
cont = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} while (cont);
|
||||||
while (cont);
|
|
||||||
cmistake(u, ord, 149, MSG_MESSAGE);
|
cmistake(u, ord, 149, MSG_MESSAGE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2341,12 +2378,14 @@ int email_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
if (!s[0]) {
|
if (!s[0]) {
|
||||||
cmistake(u, ord, 85, MSG_EVENT);
|
cmistake(u, ord, 85, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
faction *f = u->faction;
|
faction *f = u->faction;
|
||||||
if (set_email(&f->email, (const char *)s) != 0) {
|
if (set_email(&f->email, (const char *)s) != 0) {
|
||||||
log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), s);
|
log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), s);
|
||||||
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s));
|
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&f->msgs, msg_message("changemail", "value", f->email));
|
ADDMSG(&f->msgs, msg_message("changemail", "value", f->email));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2368,7 +2407,8 @@ int password_cmd(unit * u, struct order *ord)
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
pwbuf[i] = (char)(97 + rng_int() % 26);
|
pwbuf[i] = (char)(97 + rng_int() % 26);
|
||||||
pwbuf[6] = 0;
|
pwbuf[6] = 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
char *c;
|
char *c;
|
||||||
|
|
||||||
strlcpy(pwbuf, (const char *)s, 31);
|
strlcpy(pwbuf, (const char *)s, 31);
|
||||||
|
@ -2384,7 +2424,8 @@ int password_cmd(unit * u, struct order *ord)
|
||||||
if (!pwok) {
|
if (!pwok) {
|
||||||
cmistake(u, ord, 283, MSG_EVENT);
|
cmistake(u, ord, 283, MSG_EVENT);
|
||||||
u->faction->passw = _strdup(itoa36(rng_int()));
|
u->faction->passw = _strdup(itoa36(rng_int()));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
u->faction->passw = _strdup(pwbuf);
|
u->faction->passw = _strdup(pwbuf);
|
||||||
}
|
}
|
||||||
ADDMSG(&u->faction->msgs, msg_message("changepasswd",
|
ADDMSG(&u->faction->msgs, msg_message("changepasswd",
|
||||||
|
@ -2405,14 +2446,17 @@ int send_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
if (option == -1) {
|
if (option == -1) {
|
||||||
cmistake(u, ord, 135, MSG_EVENT);
|
cmistake(u, ord, 135, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (getparam(u->faction->locale) == P_NOT) {
|
if (getparam(u->faction->locale) == P_NOT) {
|
||||||
if (option == O_COMPRESS || option == O_BZIP2) {
|
if (option == O_COMPRESS || option == O_BZIP2) {
|
||||||
cmistake(u, ord, 305, MSG_EVENT);
|
cmistake(u, ord, 305, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
u->faction->options = u->faction->options & ~(1 << option);
|
u->faction->options = u->faction->options & ~(1 << option);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
u->faction->options = u->faction->options | (1 << option);
|
u->faction->options = u->faction->options | (1 << option);
|
||||||
if (option == O_COMPRESS)
|
if (option == O_COMPRESS)
|
||||||
u->faction->options &= ~(1 << O_BZIP2);
|
u->faction->options &= ~(1 << O_BZIP2);
|
||||||
|
@ -2539,7 +2583,8 @@ static bool display_race(faction * f, unit * u, const race * rc)
|
||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
*bufp++ = '.';
|
*bufp++ = '.';
|
||||||
--size;
|
--size;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
/* b_damage : Schaden */
|
/* b_damage : Schaden */
|
||||||
|
@ -2620,7 +2665,8 @@ static bool display_race(faction * f, unit * u, const race * rc)
|
||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
*bufp++ = '.';
|
*bufp++ = '.';
|
||||||
--size;
|
--size;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
|
@ -2661,7 +2707,8 @@ static void reshow(unit * u, struct order *ord, const char *s, param_t p)
|
||||||
if (ptype != NULL) {
|
if (ptype != NULL) {
|
||||||
if (display_potion(u->faction, u, ptype))
|
if (display_potion(u->faction, u, ptype))
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (display_item(u->faction, u, itype))
|
if (display_item(u->faction, u, itype))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2814,7 +2861,8 @@ int status_cmd(unit * u, struct order *ord)
|
||||||
case P_HELP:
|
case P_HELP:
|
||||||
if (getparam(u->faction->locale) == P_NOT) {
|
if (getparam(u->faction->locale) == P_NOT) {
|
||||||
fset(u, UFL_NOAID);
|
fset(u, UFL_NOAID);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
freset(u, UFL_NOAID);
|
freset(u, UFL_NOAID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2822,7 +2870,8 @@ int status_cmd(unit * u, struct order *ord)
|
||||||
if (param[0]) {
|
if (param[0]) {
|
||||||
add_message(&u->faction->msgs,
|
add_message(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "unknown_status", ""));
|
msg_feedback(u, ord, "unknown_status", ""));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setstatus(u, ST_FIGHT);
|
setstatus(u, ST_FIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2866,7 +2915,8 @@ int combatspell_cmd(unit * u, struct order *ord)
|
||||||
* Kampfzauber */
|
* Kampfzauber */
|
||||||
unset_combatspell(u, sp);
|
unset_combatspell(u, sp);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* KAMPFZAUBER "<Spruchname>" setzt diesen Kampfzauber */
|
/* KAMPFZAUBER "<Spruchname>" setzt diesen Kampfzauber */
|
||||||
set_combatspell(u, sp, ord, level);
|
set_combatspell(u, sp, ord, level);
|
||||||
}
|
}
|
||||||
|
@ -2903,7 +2953,8 @@ void update_guards(void)
|
||||||
if (fval(u, UFL_GUARD)) {
|
if (fval(u, UFL_GUARD)) {
|
||||||
if (can_start_guarding(u) != E_GUARD_OK) {
|
if (can_start_guarding(u) != E_GUARD_OK) {
|
||||||
setguard(u, GUARD_NONE);
|
setguard(u, GUARD_NONE);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
attrib *a = a_find(u->attribs, &at_guard);
|
attrib *a = a_find(u->attribs, &at_guard);
|
||||||
if (a && a->data.i == (int)guard_flags(u)) {
|
if (a && a->data.i == (int)guard_flags(u)) {
|
||||||
/* this is really rather not necessary */
|
/* this is really rather not necessary */
|
||||||
|
@ -2928,25 +2979,32 @@ int guard_on_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
if (fval(u->region->terrain, SEA_REGION)) {
|
if (fval(u->region->terrain, SEA_REGION)) {
|
||||||
cmistake(u, ord, 2, MSG_EVENT);
|
cmistake(u, ord, 2, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (fval(u, UFL_MOVED)) {
|
if (fval(u, UFL_MOVED)) {
|
||||||
cmistake(u, ord, 187, MSG_EVENT);
|
cmistake(u, ord, 187, MSG_EVENT);
|
||||||
} else if (fval(u_race(u), RCF_ILLUSIONARY)
|
}
|
||||||
|
else if (fval(u_race(u), RCF_ILLUSIONARY)
|
||||||
|| u_race(u) == get_race(RC_SPELL)) {
|
|| u_race(u) == get_race(RC_SPELL)) {
|
||||||
cmistake(u, ord, 95, MSG_EVENT);
|
cmistake(u, ord, 95, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* Monster der Monsterpartei dürfen immer bewachen */
|
/* Monster der Monsterpartei dürfen immer bewachen */
|
||||||
if (is_monsters(u->faction)) {
|
if (is_monsters(u->faction)) {
|
||||||
guard(u, GUARD_ALL);
|
guard(u, GUARD_ALL);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int err = can_start_guarding(u);
|
int err = can_start_guarding(u);
|
||||||
if (err == E_GUARD_OK) {
|
if (err == E_GUARD_OK) {
|
||||||
guard(u, GUARD_ALL);
|
guard(u, GUARD_ALL);
|
||||||
} else if (err == E_GUARD_UNARMED) {
|
}
|
||||||
|
else if (err == E_GUARD_UNARMED) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", ""));
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", ""));
|
||||||
} else if (err == E_GUARD_FLEEING) {
|
}
|
||||||
|
else if (err == E_GUARD_FLEEING) {
|
||||||
cmistake(u, ord, 320, MSG_EVENT);
|
cmistake(u, ord, 320, MSG_EVENT);
|
||||||
} else if (err == E_GUARD_NEWBIE) {
|
}
|
||||||
|
else if (err == E_GUARD_NEWBIE) {
|
||||||
cmistake(u, ord, 304, MSG_EVENT);
|
cmistake(u, ord, 304, MSG_EVENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3035,7 +3093,8 @@ void renumber_factions(void)
|
||||||
}
|
}
|
||||||
if (*rn && (*rn)->want == want) {
|
if (*rn && (*rn)->want == want) {
|
||||||
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
|
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
struct renum *r = calloc(sizeof(struct renum), 1);
|
struct renum *r = calloc(sizeof(struct renum), 1);
|
||||||
r->next = *rn;
|
r->next = *rn;
|
||||||
r->attrib = a;
|
r->attrib = a;
|
||||||
|
@ -3082,15 +3141,20 @@ void restack_units(void)
|
||||||
|
|
||||||
if (!v || v->faction != u->faction || v->region != r) {
|
if (!v || v->faction != u->faction || v->region != r) {
|
||||||
cmistake(u, ord, 258, MSG_EVENT);
|
cmistake(u, ord, 258, MSG_EVENT);
|
||||||
} else if (v->building != u->building || v->ship != u->ship) {
|
}
|
||||||
|
else if (v->building != u->building || v->ship != u->ship) {
|
||||||
cmistake(u, ord, 259, MSG_EVENT);
|
cmistake(u, ord, 259, MSG_EVENT);
|
||||||
} else if (u->building && building_owner(u->building)==u) {
|
}
|
||||||
|
else if (u->building && building_owner(u->building) == u) {
|
||||||
cmistake(u, ord, 260, MSG_EVENT);
|
cmistake(u, ord, 260, MSG_EVENT);
|
||||||
} else if (u->ship && ship_owner(u->ship)==u) {
|
}
|
||||||
|
else if (u->ship && ship_owner(u->ship) == u) {
|
||||||
cmistake(u, ord, 260, MSG_EVENT);
|
cmistake(u, ord, 260, MSG_EVENT);
|
||||||
} else if (v == u) {
|
}
|
||||||
|
else if (v == u) {
|
||||||
cmistake(u, ord, 10, MSG_EVENT);
|
cmistake(u, ord, 10, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
switch (p) {
|
switch (p) {
|
||||||
case P_AFTER:
|
case P_AFTER:
|
||||||
*up = u->next;
|
*up = u->next;
|
||||||
|
@ -3102,9 +3166,11 @@ void restack_units(void)
|
||||||
case P_BEFORE:
|
case P_BEFORE:
|
||||||
if (v->ship && ship_owner(v->ship) == v) {
|
if (v->ship && ship_owner(v->ship) == v) {
|
||||||
cmistake(v, ord, 261, MSG_EVENT);
|
cmistake(v, ord, 261, MSG_EVENT);
|
||||||
} else if (v->building && building_owner(v->building)==v) {
|
}
|
||||||
|
else if (v->building && building_owner(v->building) == v) {
|
||||||
cmistake(v, ord, 261, MSG_EVENT);
|
cmistake(v, ord, 261, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
unit **vp = &r->units;
|
unit **vp = &r->units;
|
||||||
while (*vp != v)
|
while (*vp != v)
|
||||||
vp = &(*vp)->next;
|
vp = &(*vp)->next;
|
||||||
|
@ -3162,7 +3228,8 @@ int renumber_cmd(unit * u, order * ord)
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
if (s == NULL || *s == 0) {
|
if (s == NULL || *s == 0) {
|
||||||
i = newunitid();
|
i = newunitid();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
i = atoi36((const char *)s);
|
i = atoi36((const char *)s);
|
||||||
if (i <= 0 || i > MAX_UNIT_NR) {
|
if (i <= 0 || i > MAX_UNIT_NR) {
|
||||||
cmistake(u, ord, 114, MSG_EVENT);
|
cmistake(u, ord, 114, MSG_EVENT);
|
||||||
|
@ -3204,7 +3271,8 @@ int renumber_cmd(unit * u, order * ord)
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
if (s == NULL || *s == 0) {
|
if (s == NULL || *s == 0) {
|
||||||
i = newcontainerid();
|
i = newcontainerid();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
i = atoi36((const char *)s);
|
i = atoi36((const char *)s);
|
||||||
if (i <= 0 || i > MAX_CONTAINER_NR) {
|
if (i <= 0 || i > MAX_CONTAINER_NR) {
|
||||||
cmistake(u, ord, 114, MSG_EVENT);
|
cmistake(u, ord, 114, MSG_EVENT);
|
||||||
|
@ -3232,7 +3300,8 @@ int renumber_cmd(unit * u, order * ord)
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
if (*s == 0) {
|
if (*s == 0) {
|
||||||
i = newcontainerid();
|
i = newcontainerid();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
i = atoi36((const char *)s);
|
i = atoi36((const char *)s);
|
||||||
if (i <= 0 || i > MAX_CONTAINER_NR) {
|
if (i <= 0 || i > MAX_CONTAINER_NR) {
|
||||||
cmistake(u, ord, 114, MSG_EVENT);
|
cmistake(u, ord, 114, MSG_EVENT);
|
||||||
|
@ -3313,7 +3382,8 @@ static building *age_building(building * b)
|
||||||
ADDMSG(&r->msgs,
|
ADDMSG(&r->msgs,
|
||||||
msg_message("astralshield_activate", "region unit", r, mage));
|
msg_message("astralshield_activate", "region unit", r, mage));
|
||||||
}
|
}
|
||||||
} else if (mage != NULL) {
|
}
|
||||||
|
else if (mage != NULL) {
|
||||||
int sk = effskill(mage, SK_MAGIC);
|
int sk = effskill(mage, SK_MAGIC);
|
||||||
c->duration = _max(c->duration, sk / 2);
|
c->duration = _max(c->duration, sk / 2);
|
||||||
c->vigour = _max(c->vigour, sk);
|
c->vigour = _max(c->vigour, sk);
|
||||||
|
@ -3364,10 +3434,12 @@ static void age_region(region * r)
|
||||||
region_set_morale(r, r->land->morale + 1, turn);
|
region_set_morale(r, r->land->morale + 1, turn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (r->land->morale > maxmorale) {
|
}
|
||||||
|
else if (r->land->morale > maxmorale) {
|
||||||
region_set_morale(r, r->land->morale - 1, turn);
|
region_set_morale(r, r->land->morale - 1, turn);
|
||||||
}
|
}
|
||||||
} else if (r->land->morale > MORALE_DEFAULT) {
|
}
|
||||||
|
else if (r->land->morale > MORALE_DEFAULT) {
|
||||||
region_set_morale(r, r->land->morale - 1, turn);
|
region_set_morale(r, r->land->morale - 1, turn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3539,7 +3611,8 @@ void new_units(void)
|
||||||
msg_feedback(u, makeord,
|
msg_feedback(u, makeord,
|
||||||
"too_many_units_in_alliance",
|
"too_many_units_in_alliance",
|
||||||
"allowed", maxunits(u->faction)));
|
"allowed", maxunits(u->faction)));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, makeord,
|
msg_feedback(u, makeord,
|
||||||
"too_many_units_in_faction",
|
"too_many_units_in_faction",
|
||||||
|
@ -3605,7 +3678,8 @@ void check_long_orders(unit * u)
|
||||||
for (ord = u->orders; ord; ord = ord->next) {
|
for (ord = u->orders; ord; ord = ord->next) {
|
||||||
if (getkeyword(ord) == NOKEYWORD) {
|
if (getkeyword(ord) == NOKEYWORD) {
|
||||||
cmistake(u, ord, 22, MSG_EVENT);
|
cmistake(u, ord, 22, MSG_EVENT);
|
||||||
} else if (is_long(ord)) {
|
}
|
||||||
|
else if (is_long(ord)) {
|
||||||
keyword_t longorder = getkeyword(ord);
|
keyword_t longorder = getkeyword(ord);
|
||||||
if (otherorder != MAXKEYWORDS) {
|
if (otherorder != MAXKEYWORDS) {
|
||||||
switch (longorder) {
|
switch (longorder) {
|
||||||
|
@ -3617,7 +3691,8 @@ void check_long_orders(unit * u)
|
||||||
case K_BUY:
|
case K_BUY:
|
||||||
if (otherorder == K_SELL) {
|
if (otherorder == K_SELL) {
|
||||||
otherorder = K_BUY;
|
otherorder = K_BUY;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cmistake(u, ord, 52, MSG_EVENT);
|
cmistake(u, ord, 52, MSG_EVENT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3629,7 +3704,8 @@ void check_long_orders(unit * u)
|
||||||
default:
|
default:
|
||||||
cmistake(u, ord, 52, MSG_EVENT);
|
cmistake(u, ord, 52, MSG_EVENT);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
otherorder = longorder;
|
otherorder = longorder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3647,7 +3723,8 @@ void update_long_order(unit * u)
|
||||||
if (hunger) {
|
if (hunger) {
|
||||||
/* Hungernde Einheiten führen NUR den default-Befehl aus */
|
/* Hungernde Einheiten führen NUR den default-Befehl aus */
|
||||||
set_order(&u->thisorder, default_order(u->faction->locale));
|
set_order(&u->thisorder, default_order(u->faction->locale));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
check_long_orders(u);
|
check_long_orders(u);
|
||||||
}
|
}
|
||||||
/* check all orders for a potential new long order this round: */
|
/* check all orders for a potential new long order this round: */
|
||||||
|
@ -3668,11 +3745,13 @@ void update_long_order(unit * u)
|
||||||
/* Über dieser Zeile nur Befehle, die auch eine idle Faction machen darf */
|
/* Über dieser Zeile nur Befehle, die auch eine idle Faction machen darf */
|
||||||
if (idle(u->faction)) {
|
if (idle(u->faction)) {
|
||||||
set_order(&u->thisorder, default_order(u->faction->locale));
|
set_order(&u->thisorder, default_order(u->faction->locale));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
set_order(&u->thisorder, copy_order(ord));
|
set_order(&u->thisorder, copy_order(ord));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
keyword_t keyword = getkeyword(ord);
|
keyword_t keyword = getkeyword(ord);
|
||||||
switch (keyword) {
|
switch (keyword) {
|
||||||
/* Wenn gehandelt wird, darf kein langer Befehl ausgeführt
|
/* Wenn gehandelt wird, darf kein langer Befehl ausgeführt
|
||||||
|
@ -3733,7 +3812,8 @@ use_item(unit * u, const item_type * itype, int amount, struct order *ord)
|
||||||
return EUNUSABLE;
|
return EUNUSABLE;
|
||||||
}
|
}
|
||||||
return itype->use(u, itype, amount, ord);
|
return itype->use(u, itype, amount, ord);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (itype->useonother == NULL) {
|
if (itype->useonother == NULL) {
|
||||||
return EUNUSABLE;
|
return EUNUSABLE;
|
||||||
}
|
}
|
||||||
|
@ -3843,7 +3923,8 @@ static void remove_exclusive(order ** ordp)
|
||||||
*ordp = ord->next;
|
*ordp = ord->next;
|
||||||
ord->next = NULL;
|
ord->next = NULL;
|
||||||
free_order(ord);
|
free_order(ord);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ordp = &ord->next;
|
ordp = &ord->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3880,7 +3961,8 @@ void defaultorders(void)
|
||||||
}
|
}
|
||||||
if (new_order)
|
if (new_order)
|
||||||
addlist(&u->old_orders, new_order);
|
addlist(&u->old_orders, new_order);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
ordp = &ord->next;
|
ordp = &ord->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3986,11 +4068,13 @@ int use_cmd(unit * u, struct order *ord)
|
||||||
/* BENUTZE ALLES Yanxspirit */
|
/* BENUTZE ALLES Yanxspirit */
|
||||||
n = INT_MAX;
|
n = INT_MAX;
|
||||||
t = getstrtoken();
|
t = getstrtoken();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* BENUTZE Yanxspirit */
|
/* BENUTZE Yanxspirit */
|
||||||
n = 1;
|
n = 1;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* BENUTZE 42 Yanxspirit */
|
/* BENUTZE 42 Yanxspirit */
|
||||||
t = getstrtoken();
|
t = getstrtoken();
|
||||||
}
|
}
|
||||||
|
@ -4021,7 +4105,8 @@ int pay_cmd(unit * u, struct order *ord)
|
||||||
{
|
{
|
||||||
if (!u->building) {
|
if (!u->building) {
|
||||||
cmistake(u, ord, 6, MSG_EVENT);
|
cmistake(u, ord, 6, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
param_t p;
|
param_t p;
|
||||||
init_tokens(ord);
|
init_tokens(ord);
|
||||||
skip_token();
|
skip_token();
|
||||||
|
@ -4030,7 +4115,8 @@ int pay_cmd(unit * u, struct order *ord)
|
||||||
unit *owner = building_owner(u->building);
|
unit *owner = building_owner(u->building);
|
||||||
if (owner->no != u->no) {
|
if (owner->no != u->no) {
|
||||||
cmistake(u, ord, 1222, MSG_EVENT);
|
cmistake(u, ord, 1222, MSG_EVENT);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
u->building->flags |= BLD_DONTPAY;
|
u->building->flags |= BLD_DONTPAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4090,7 +4176,8 @@ int claim_cmd(unit * u, struct order *ord)
|
||||||
n = atoi((const char *)t);
|
n = atoi((const char *)t);
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
n = 1;
|
n = 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
t = getstrtoken();
|
t = getstrtoken();
|
||||||
}
|
}
|
||||||
itype = finditemtype(t, u->faction->locale);
|
itype = finditemtype(t, u->faction->locale);
|
||||||
|
@ -4102,7 +4189,8 @@ int claim_cmd(unit * u, struct order *ord)
|
||||||
i_change(iclaim, itype, -n);
|
i_change(iclaim, itype, -n);
|
||||||
i_change(&u->items, itype, n);
|
i_change(&u->items, itype, n);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cmistake(u, ord, 43, MSG_PRODUCE);
|
cmistake(u, ord, 43, MSG_PRODUCE);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4275,15 +4363,18 @@ void process(void)
|
||||||
&& r_insectstalled(r)
|
&& r_insectstalled(r)
|
||||||
&& !is_cursed(u->attribs, C_KAELTESCHUTZ, 0)) {
|
&& !is_cursed(u->attribs, C_KAELTESCHUTZ, 0)) {
|
||||||
ord = NULL;
|
ord = NULL;
|
||||||
} else if (LongHunger(u)) {
|
}
|
||||||
|
else if (LongHunger(u)) {
|
||||||
cmistake(u, ord, 224, MSG_MAGIC);
|
cmistake(u, ord, 224, MSG_MAGIC);
|
||||||
ord = NULL;
|
ord = NULL;
|
||||||
} else if (fval(u, UFL_LONGACTION)) {
|
}
|
||||||
|
else if (fval(u, UFL_LONGACTION)) {
|
||||||
/* this message was already given in laws.update_long_order
|
/* this message was already given in laws.update_long_order
|
||||||
cmistake(u, ord, 52, MSG_PRODUCE);
|
cmistake(u, ord, 52, MSG_PRODUCE);
|
||||||
*/
|
*/
|
||||||
ord = NULL;
|
ord = NULL;
|
||||||
} else if (fval(r->terrain, SEA_REGION)
|
}
|
||||||
|
else if (fval(r->terrain, SEA_REGION)
|
||||||
&& u_race(u) != get_race(RC_AQUARIAN)
|
&& u_race(u) != get_race(RC_AQUARIAN)
|
||||||
&& !(u_race(u)->flags & RCF_SWIM)) {
|
&& !(u_race(u)->flags & RCF_SWIM)) {
|
||||||
/* error message disabled by popular demand */
|
/* error message disabled by popular demand */
|
||||||
|
@ -4327,7 +4418,8 @@ void process(void)
|
||||||
if (g->members == 0) {
|
if (g->members == 0) {
|
||||||
*gp = g->next;
|
*gp = g->next;
|
||||||
free_group(g);
|
free_group(g);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
gp = &g->next;
|
gp = &g->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4371,7 +4463,8 @@ int siege_cmd(unit * u, order * ord)
|
||||||
if (eff_skill(u, SK_CATAPULT, r) >= 1) {
|
if (eff_skill(u, SK_CATAPULT, r) >= 1) {
|
||||||
katapultiere = d;
|
katapultiere = d;
|
||||||
d *= eff_skill(u, SK_CATAPULT, r);
|
d *= eff_skill(u, SK_CATAPULT, r);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
d = 0;
|
d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4407,7 +4500,8 @@ int siege_cmd(unit * u, order * ord)
|
||||||
/* send message to the entire region */
|
/* send message to the entire region */
|
||||||
ADDMSG(&r->msgs, msg_message("siege_catapults",
|
ADDMSG(&r->msgs, msg_message("siege_catapults",
|
||||||
"unit building destruction", u, b, d));
|
"unit building destruction", u, b, d));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* send message to the entire region */
|
/* send message to the entire region */
|
||||||
ADDMSG(&r->msgs, msg_message("siege", "unit building", u, b));
|
ADDMSG(&r->msgs, msg_message("siege", "unit building", u, b));
|
||||||
}
|
}
|
||||||
|
@ -4650,7 +4744,8 @@ int writepasswd(void)
|
||||||
F = fopen(zText, "w");
|
F = fopen(zText, "w");
|
||||||
if (!F) {
|
if (!F) {
|
||||||
perror(zText);
|
perror(zText);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
faction *f;
|
faction *f;
|
||||||
log_info("writing passwords...");
|
log_info("writing passwords...");
|
||||||
|
|
||||||
|
@ -4697,10 +4792,23 @@ void update_subscriptions(void)
|
||||||
fclose(F);
|
fclose(F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *confpath = 0;
|
||||||
|
|
||||||
int init_data(const char *filename, const char *catalog)
|
int init_data(const char *filename, const char *catalog)
|
||||||
{
|
{
|
||||||
|
char filepath[MAX_PATH], catpath[MAX_PATH];
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
|
if (confpath) {
|
||||||
|
if (filename) {
|
||||||
|
_snprintf(filepath, sizeof(filepath), "%s/%s", confpath, filename);
|
||||||
|
filename = filepath;
|
||||||
|
}
|
||||||
|
if (catalog) {
|
||||||
|
_snprintf(catpath, sizeof(catpath), "%s/%s", confpath, catalog);
|
||||||
|
catalog = catpath;
|
||||||
|
}
|
||||||
|
}
|
||||||
l = read_xml(filename, catalog);
|
l = read_xml(filename, catalog);
|
||||||
init_locales();
|
init_locales();
|
||||||
if (l)
|
if (l)
|
||||||
|
|
46
src/main.c
46
src/main.c
|
@ -41,6 +41,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <iniparser.h>
|
#include <iniparser.h>
|
||||||
|
|
||||||
|
extern const char *confpath;
|
||||||
static const char *logfile = "eressea.log";
|
static const char *logfile = "eressea.log";
|
||||||
static const char *luafile = 0;
|
static const char *luafile = 0;
|
||||||
static const char *inifile = "eressea.ini";
|
static const char *inifile = "eressea.ini";
|
||||||
|
@ -60,8 +61,9 @@ static void parse_config(const char *filename)
|
||||||
#endif
|
#endif
|
||||||
/* excerpt from [config] (the rest is used in bindings.c) */
|
/* excerpt from [config] (the rest is used in bindings.c) */
|
||||||
game_name = iniparser_getstring(d, "config:game", game_name);
|
game_name = iniparser_getstring(d, "config:game", game_name);
|
||||||
} else {
|
}
|
||||||
log_warning("could not open configuration file %s\n", filename);
|
else {
|
||||||
|
log_error("could not open configuration file %s\n", filename);
|
||||||
}
|
}
|
||||||
global.inifile = d;
|
global.inifile = d;
|
||||||
}
|
}
|
||||||
|
@ -101,25 +103,33 @@ static int parse_args(int argc, char **argv, int *exitcode)
|
||||||
for (i = 1; i != argc; ++i) {
|
for (i = 1; i != argc; ++i) {
|
||||||
if (argv[i][0] != '-') {
|
if (argv[i][0] != '-') {
|
||||||
luafile = argv[i];
|
luafile = argv[i];
|
||||||
} else if (argv[i][1] == '-') { /* long format */
|
}
|
||||||
|
else if (argv[i][1] == '-') { /* long format */
|
||||||
if (strcmp(argv[i] + 2, "version") == 0) {
|
if (strcmp(argv[i] + 2, "version") == 0) {
|
||||||
printf("\n%s PBEM host\n"
|
printf("\n%s PBEM host\n"
|
||||||
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
|
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
|
||||||
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %d.%d.%d\n\n",
|
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %d.%d.%d\n\n",
|
||||||
global.gamename, VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
|
global.gamename, VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
|
||||||
#ifdef USE_CURSES
|
#ifdef USE_CURSES
|
||||||
} else if (strcmp(argv[i] + 2, "color") == 0) {
|
}
|
||||||
|
else if (strcmp(argv[i] + 2, "color") == 0) {
|
||||||
/* force the editor to have colors */
|
/* force the editor to have colors */
|
||||||
force_color = 1;
|
force_color = 1;
|
||||||
#endif
|
#endif
|
||||||
} else if (strcmp(argv[i] + 2, "help") == 0) {
|
}
|
||||||
|
else if (strcmp(argv[i] + 2, "help") == 0) {
|
||||||
return usage(argv[0], NULL);
|
return usage(argv[0], NULL);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return usage(argv[0], argv[i]);
|
return usage(argv[0], argv[i]);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
const char *arg;
|
const char *arg;
|
||||||
switch (argv[i][1]) {
|
switch (argv[i][1]) {
|
||||||
|
case 'c':
|
||||||
|
i = get_arg(argc, argv, 2, i, &confpath, 0);
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
i = get_arg(argc, argv, 2, i, &luafile, 0);
|
i = get_arg(argc, argv, 2, i, &luafile, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -241,17 +251,27 @@ extern void bind_monsters(struct lua_State *L);
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int err, result = 0;
|
char inipath[MAX_PATH];
|
||||||
|
int err = 0;
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
setup_signal_handler();
|
setup_signal_handler();
|
||||||
parse_config(inifile);
|
|
||||||
log_open(logfile);
|
|
||||||
|
|
||||||
err = parse_args(argc, argv, &result);
|
/* parse args once to read config file location */
|
||||||
if (err) {
|
if (parse_args(argc, argv, &err) != 0) {
|
||||||
return result;
|
return err;
|
||||||
}
|
}
|
||||||
|
/* ini file sets defaults for arguments*/
|
||||||
|
if (confpath) {
|
||||||
|
_snprintf(inipath, sizeof(inipath), "%s/%s", confpath, inifile);
|
||||||
|
parse_config(inipath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parse_config(inifile);
|
||||||
|
}
|
||||||
|
/* parse arguments again, to override ini file */
|
||||||
|
parse_args(argc, argv, &err);
|
||||||
|
|
||||||
|
log_open(logfile);
|
||||||
locale_init();
|
locale_init();
|
||||||
|
|
||||||
#ifdef CRTDBG
|
#ifdef CRTDBG
|
||||||
|
|
Loading…
Reference in New Issue