2012-06-07 04:29:36 +02:00
|
|
|
#include "bind_process.h"
|
|
|
|
|
|
|
|
#include <platform.h>
|
2012-07-24 09:16:25 +02:00
|
|
|
#include <kernel/alliance.h>
|
|
|
|
#include <kernel/config.h>
|
2012-06-07 18:47:02 +02:00
|
|
|
#include <kernel/order.h>
|
2012-06-07 04:29:36 +02:00
|
|
|
#include <kernel/region.h>
|
2012-06-17 04:14:23 +02:00
|
|
|
#include <kernel/terrain.h>
|
2012-06-07 18:47:02 +02:00
|
|
|
#include <kernel/unit.h>
|
2014-08-27 06:40:18 +02:00
|
|
|
#include "battle.h"
|
2014-02-18 05:45:00 +01:00
|
|
|
#include "economy.h"
|
2014-11-01 12:57:01 +01:00
|
|
|
#include "keyword.h"
|
2014-02-18 05:45:00 +01:00
|
|
|
#include "laws.h"
|
2014-11-01 12:57:01 +01:00
|
|
|
#include "magic.h"
|
2014-02-18 05:45:00 +01:00
|
|
|
#include "market.h"
|
2014-11-01 12:57:01 +01:00
|
|
|
#include "move.h"
|
2014-02-18 05:45:00 +01:00
|
|
|
#include "study.h"
|
2012-06-13 07:36:29 +02:00
|
|
|
|
2012-06-17 04:14:23 +02:00
|
|
|
#define PROC_LAND_REGION 0x0001
|
|
|
|
#define PROC_LONG_ORDER 0x0002
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
static void process_cmd(keyword_t kwd, int(*callback)(unit *, order *), int flags)
|
2012-06-13 07:36:29 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
region * r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
unit * u;
|
|
|
|
|
|
|
|
/* look for shortcuts */
|
|
|
|
if (flags&PROC_LAND_REGION) {
|
|
|
|
/* only execute when we are on solid terrain */
|
|
|
|
while (r && (r->terrain->flags&LAND_REGION) == 0) {
|
|
|
|
r = r->next;
|
|
|
|
}
|
|
|
|
if (!r) break;
|
2012-06-17 04:14:23 +02:00
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
if (flags & PROC_LONG_ORDER) {
|
|
|
|
if (kwd == getkeyword(u->thisorder)) {
|
|
|
|
callback(u, u->thisorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
order * ord;
|
|
|
|
for (ord = u->orders; ord; ord = ord->next) {
|
|
|
|
if (kwd == getkeyword(ord)) {
|
|
|
|
callback(u, ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-17 04:14:23 +02:00
|
|
|
}
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
|
|
|
}
|
2012-06-07 04:29:36 +02:00
|
|
|
|
|
|
|
void process_produce(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
struct region *r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
unit * u;
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
order * ord;
|
|
|
|
for (ord = u->orders; ord; ord = ord->next) {
|
|
|
|
if (K_MAKE == getkeyword(ord)) {
|
|
|
|
make_cmd(u, ord);
|
|
|
|
}
|
|
|
|
}
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
2015-01-30 20:37:14 +01:00
|
|
|
produce(r);
|
|
|
|
split_allocations(r);
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
2012-06-07 04:29:36 +02:00
|
|
|
}
|
|
|
|
|
2012-06-17 04:14:23 +02:00
|
|
|
void process_battle(void) {
|
2015-11-22 15:29:43 +01:00
|
|
|
do_battles();
|
2012-06-17 04:14:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_siege(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
process_cmd(K_BESIEGE, siege_cmd, PROC_LAND_REGION);
|
2012-06-17 04:14:23 +02:00
|
|
|
}
|
|
|
|
|
2012-06-10 14:28:19 +02:00
|
|
|
void process_update_long_order(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
region * r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
unit * u;
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
update_long_order(u);
|
|
|
|
}
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-07 04:29:36 +02:00
|
|
|
void process_markets(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
do_markets();
|
2012-06-07 04:29:36 +02:00
|
|
|
}
|
2012-06-07 18:47:02 +02:00
|
|
|
|
|
|
|
void process_make_temp(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
new_units();
|
2012-06-07 18:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_settings(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
region * r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
unit * u;
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
order * ord;
|
|
|
|
for (ord = u->orders; ord; ord = ord->next) {
|
|
|
|
keyword_t kwd = getkeyword(ord);
|
|
|
|
if (kwd == K_BANNER) {
|
|
|
|
banner_cmd(u, ord);
|
|
|
|
}
|
|
|
|
else if (kwd == K_EMAIL) {
|
|
|
|
email_cmd(u, ord);
|
|
|
|
}
|
|
|
|
else if (kwd == K_SEND) {
|
|
|
|
send_cmd(u, ord);
|
|
|
|
}
|
|
|
|
else if (kwd == K_PASSWORD) {
|
|
|
|
password_cmd(u, ord);
|
|
|
|
}
|
|
|
|
}
|
2012-06-07 18:47:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 14:28:19 +02:00
|
|
|
void process_ally(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
process_cmd(K_ALLY, ally_cmd, 0);
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_prefix(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
process_cmd(K_PREFIX, prefix_cmd, 0);
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_setstealth(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
process_cmd(K_SETSTEALTH, setstealth_cmd, 0);
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_status(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
process_cmd(K_STATUS, status_cmd, 0);
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
|
2012-06-17 07:38:44 +02:00
|
|
|
void process_name(void) {
|
2015-01-30 20:37:14 +01:00
|
|
|
process_cmd(K_NAME, name_cmd, 0);
|
|
|
|
process_cmd(K_DISPLAY, display_cmd, 0);
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
|
2012-06-07 18:47:02 +02:00
|
|
|
void process_group(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_GROUP, group_cmd, 0);
|
2012-06-07 18:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_origin(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_URSPRUNG, origin_cmd, 0);
|
2012-06-07 18:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_quit(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_QUIT, quit_cmd, 0);
|
|
|
|
quit();
|
2012-06-07 18:47:02 +02:00
|
|
|
}
|
2012-06-13 07:36:29 +02:00
|
|
|
|
|
|
|
void process_study(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_TEACH, teach_cmd, PROC_LONG_ORDER);
|
2015-07-09 13:24:21 +02:00
|
|
|
process_cmd(K_STUDY, study_cmd, PROC_LONG_ORDER);
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_movement(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
region *r;
|
2012-06-17 07:38:44 +02:00
|
|
|
|
2014-06-16 03:34:39 +02:00
|
|
|
movement();
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
if (r->ships) {
|
|
|
|
sinkships(r);
|
|
|
|
}
|
2012-06-17 07:38:44 +02:00
|
|
|
}
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_use(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_USE, use_cmd, 0);
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
2012-06-14 08:28:56 +02:00
|
|
|
|
|
|
|
void process_leave(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_LEAVE, leave_cmd, 0);
|
2012-06-14 08:28:56 +02:00
|
|
|
}
|
2012-06-17 07:38:44 +02:00
|
|
|
|
2012-06-17 08:31:25 +02:00
|
|
|
void process_promote(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_PROMOTION, promotion_cmd, 0);
|
2012-06-17 08:31:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_renumber(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_NUMBER, renumber_cmd, 0);
|
|
|
|
renumber_factions();
|
2012-06-17 08:31:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_restack(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
restack_units();
|
2012-06-17 08:31:25 +02:00
|
|
|
}
|
|
|
|
|
2012-06-17 21:51:48 +02:00
|
|
|
void process_setspells(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_COMBATSPELL, combatspell_cmd, 0);
|
2012-06-17 21:51:48 +02:00
|
|
|
}
|
|
|
|
|
2012-06-18 00:55:23 +02:00
|
|
|
void process_sethelp(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_ALLY, ally_cmd, 0);
|
2012-06-18 00:55:23 +02:00
|
|
|
}
|
|
|
|
|
2012-06-18 02:24:23 +02:00
|
|
|
void process_contact(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_CONTACT, contact_cmd, 0);
|
2012-06-18 02:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_magic(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
magic();
|
2012-06-18 02:24:23 +02:00
|
|
|
}
|
|
|
|
|
2012-06-18 02:55:46 +02:00
|
|
|
void process_give_control(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_CONTACT, give_control_cmd, 0);
|
2012-06-18 02:55:46 +02:00
|
|
|
}
|
|
|
|
|
2012-06-18 08:13:58 +02:00
|
|
|
void process_guard_on(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_GUARD, guard_on_cmd, PROC_LAND_REGION);
|
2012-06-18 08:13:58 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 09:16:25 +02:00
|
|
|
void process_explain(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_RESHOW, reshow_cmd, 0);
|
2012-07-24 09:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_reserve(void) {
|
2015-11-22 10:33:31 +01:00
|
|
|
int rule = config_get_int("rules.reserve.twophase", 0);
|
2014-07-20 06:19:21 +02:00
|
|
|
if (rule) {
|
|
|
|
process_cmd(K_RESERVE, reserve_self, 0);
|
|
|
|
}
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_RESERVE, reserve_cmd, 0);
|
2012-07-24 09:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_claim(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_CLAIM, claim_cmd, 0);
|
2012-07-24 09:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_follow(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
struct region *r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
unit *u;
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
follow_unit(u);
|
|
|
|
}
|
2012-07-24 09:16:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void process_messages(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_MAIL, mail_cmd, 0);
|
2012-07-24 09:16:25 +02:00
|
|
|
}
|
|
|
|
|
2012-06-18 08:13:58 +02:00
|
|
|
void process_guard_off(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
process_cmd(K_GUARD, guard_off_cmd, PROC_LAND_REGION);
|
2012-06-18 08:13:58 +02:00
|
|
|
}
|
|
|
|
|
2012-06-18 07:31:30 +02:00
|
|
|
void process_regeneration(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
monthly_healing();
|
|
|
|
regenerate_aura();
|
2012-06-18 07:31:30 +02:00
|
|
|
}
|
|
|
|
|
2012-06-18 02:24:23 +02:00
|
|
|
void process_enter(int final) {
|
2014-06-16 03:34:39 +02:00
|
|
|
region *r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
do_enter(r, final);
|
|
|
|
}
|
2012-06-18 02:24:23 +02:00
|
|
|
}
|
2012-06-18 00:55:23 +02:00
|
|
|
|
2012-06-17 07:38:44 +02:00
|
|
|
void process_maintenance(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
region *r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
unit *u;
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
order *ord;
|
|
|
|
for (ord = u->orders; ord; ord = ord->next) {
|
2014-06-16 16:19:22 +02:00
|
|
|
keyword_t kwd = getkeyword(ord);
|
2014-06-16 03:34:39 +02:00
|
|
|
if (kwd == K_PAY) {
|
|
|
|
pay_cmd(u, ord);
|
|
|
|
}
|
|
|
|
}
|
2012-06-17 07:38:44 +02:00
|
|
|
}
|
2016-08-21 18:06:38 +02:00
|
|
|
maintain_buildings(r);
|
2012-06-17 07:38:44 +02:00
|
|
|
}
|
|
|
|
}
|
2012-07-24 09:16:25 +02:00
|
|
|
|
|
|
|
void process_alliance(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
alliance_cmd();
|
2012-07-24 09:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_idle(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
region *r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
auto_work(r);
|
|
|
|
}
|
2012-07-24 09:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_set_default(void) {
|
2014-06-16 03:34:39 +02:00
|
|
|
if (!keyword_disabled(K_DEFAULT)) {
|
|
|
|
defaultorders();
|
|
|
|
}
|
2012-07-24 09:16:25 +02:00
|
|
|
}
|
2014-06-16 03:34:39 +02:00
|
|
|
|