2012-06-07 04:29:36 +02:00
|
|
|
#include "bind_process.h"
|
|
|
|
|
|
|
|
#include <platform.h>
|
|
|
|
#include <kernel/types.h>
|
2012-07-24 09:16:25 +02:00
|
|
|
#include <kernel/alliance.h>
|
|
|
|
#include <kernel/config.h>
|
2012-06-18 02:24:23 +02:00
|
|
|
#include <kernel/magic.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"
|
|
|
|
#include "move.h"
|
2014-02-18 05:45:00 +01:00
|
|
|
#include "economy.h"
|
|
|
|
#include "laws.h"
|
|
|
|
#include "market.h"
|
|
|
|
#include "study.h"
|
2014-06-16 03:34:39 +02:00
|
|
|
#include "keyword.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
|
|
|
|
|
|
|
|
static void process_cmd(keyword_t kwd, int (*callback)(unit *, order *), int flags)
|
2012-06-13 07:36:29 +02:00
|
|
|
{
|
|
|
|
region * r;
|
|
|
|
for (r=regions; r; r=r->next) {
|
|
|
|
unit * u;
|
2012-06-17 04:14:23 +02:00
|
|
|
|
|
|
|
/* 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;
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
2012-06-17 04:14:23 +02:00
|
|
|
if (!r) break;
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (u=r->units; u; u=u->next) {
|
2012-06-17 04:14:23 +02:00
|
|
|
if (flags & PROC_LONG_ORDER) {
|
2014-06-16 16:19:22 +02:00
|
|
|
if (kwd == getkeyword(u->thisorder)) {
|
2012-06-17 04:14:23 +02:00
|
|
|
callback(u, u->thisorder);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
order * ord;
|
|
|
|
for (ord=u->orders; ord; ord=ord->next) {
|
2014-06-16 16:19:22 +02:00
|
|
|
if (kwd == getkeyword(ord)) {
|
2012-06-17 04:14:23 +02:00
|
|
|
callback(u, ord);
|
|
|
|
}
|
|
|
|
}
|
2012-06-13 07:36:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-07 04:29:36 +02:00
|
|
|
|
|
|
|
void process_produce(void) {
|
|
|
|
struct region *r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
2012-06-13 07:36:29 +02:00
|
|
|
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
|
|
|
if (K_MAKE == getkeyword(ord)) {
|
2012-06-13 07:36:29 +02:00
|
|
|
make_cmd(u, ord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-07 04:29:36 +02:00
|
|
|
produce(r);
|
2012-06-13 07:36:29 +02:00
|
|
|
split_allocations(r);
|
2012-06-07 04:29:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-17 04:14:23 +02:00
|
|
|
void process_battle(void) {
|
|
|
|
struct region *r;
|
|
|
|
for (r = regions; r; r = r->next) {
|
|
|
|
do_battle(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void process_siege(void) {
|
|
|
|
process_cmd(K_BESIEGE, siege_cmd, PROC_LAND_REGION);
|
|
|
|
}
|
|
|
|
|
2012-06-10 14:28:19 +02:00
|
|
|
void process_update_long_order(void) {
|
|
|
|
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-07 04:29:36 +02:00
|
|
|
void process_markets(void) {
|
|
|
|
do_markets();
|
|
|
|
}
|
2012-06-07 18:47:02 +02:00
|
|
|
|
|
|
|
void process_make_temp(void) {
|
|
|
|
new_units();
|
|
|
|
}
|
|
|
|
|
|
|
|
void process_settings(void) {
|
|
|
|
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);
|
2012-06-07 18:47:02 +02:00
|
|
|
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-10 14:28:19 +02:00
|
|
|
void process_ally(void) {
|
2012-06-17 04:14:23 +02:00
|
|
|
process_cmd(K_ALLY, ally_cmd, 0);
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_prefix(void) {
|
2012-06-17 04:14:23 +02:00
|
|
|
process_cmd(K_PREFIX, prefix_cmd, 0);
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_setstealth(void) {
|
2012-06-17 04:14:23 +02:00
|
|
|
process_cmd(K_SETSTEALTH, setstealth_cmd, 0);
|
2012-06-10 14:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void process_status(void) {
|
2012-06-17 04:14:23 +02: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) {
|
|
|
|
process_cmd(K_NAME, name_cmd, 0);
|
2012-06-17 04:14:23 +02:00
|
|
|
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);
|
|
|
|
process_cmd(K_STUDY, learn_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) {
|
2014-07-20 09:42:45 +02:00
|
|
|
int rule = get_param_int(global.parameters, "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
|
|
|
}
|
2014-06-16 03:34:39 +02:00
|
|
|
maintain_buildings(r, 0);
|
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
|
|
|
|