forked from github/server
move skill.h to kernel, use enum in struct skill
This commit is contained in:
parent
e3f2ca9aaf
commit
adc03b75bc
21 changed files with 93 additions and 87 deletions
|
@ -113,7 +113,6 @@ set (ERESSEA_SRC
|
|||
renumber.c
|
||||
report.c
|
||||
reports.c
|
||||
skill.c
|
||||
spells.c
|
||||
spy.c
|
||||
steal.c
|
||||
|
@ -238,7 +237,6 @@ set(TESTS_SRC
|
|||
renumber.test.c
|
||||
report.test.c
|
||||
reports.test.c
|
||||
skill.test.c
|
||||
spells.test.c
|
||||
spy.test.c
|
||||
study.test.c
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
#include <kernel/config.h>
|
||||
#include "alchemy.h"
|
||||
#include "guard.h"
|
||||
#include "skill.h"
|
||||
#include "study.h"
|
||||
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/messages.h>
|
||||
#include <kernel/attrib.h>
|
||||
#include <kernel/build.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/gamedata.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/messages.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/pool.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/unit.h>
|
||||
#include "kernel/skill.h"
|
||||
#include "kernel/unit.h"
|
||||
|
||||
/* util includes */
|
||||
#include <kernel/attrib.h>
|
||||
#include <kernel/gamedata.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/log.h>
|
||||
#include <util/macros.h>
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
#ifndef H_GC_AUTOMATE
|
||||
#define H_GC_AUTOMATE
|
||||
|
||||
#include "skill.h"
|
||||
|
||||
struct region;
|
||||
struct unit;
|
||||
enum skill_t;
|
||||
|
||||
typedef struct scholar {
|
||||
struct unit *u;
|
||||
|
@ -19,7 +18,8 @@ typedef struct scholar {
|
|||
|
||||
void do_autostudy(struct region *r);
|
||||
|
||||
int autostudy_init(scholar scholars[], int max_scholars, struct unit **units, skill_t *o_skill);
|
||||
int autostudy_init(scholar scholars[], int max_scholars,
|
||||
struct unit **units, enum skill_t *o_skill);
|
||||
void autostudy_run(scholar scholars[], int nscholars);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "laws.h"
|
||||
#include "monsters.h"
|
||||
#include "move.h"
|
||||
#include "skill.h"
|
||||
#include "study.h"
|
||||
#include "spy.h"
|
||||
|
||||
|
@ -33,6 +32,7 @@
|
|||
#include "kernel/race.h"
|
||||
#include "kernel/region.h"
|
||||
#include "kernel/ship.h"
|
||||
#include "kernel/skill.h"
|
||||
#include "kernel/terrain.h"
|
||||
#include "kernel/unit.h"
|
||||
#include "kernel/spell.h"
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "guard.h"
|
||||
#include "reports.h"
|
||||
#include "skill.h"
|
||||
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/building.h>
|
||||
|
@ -19,7 +18,8 @@
|
|||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/unit.h>
|
||||
#include "kernel/skill.h"
|
||||
#include "kernel/unit.h"
|
||||
|
||||
#include <spells/buildingcurse.h>
|
||||
|
||||
|
|
|
@ -8,18 +8,15 @@
|
|||
#include "reports.h"
|
||||
#include "guard.h"
|
||||
#include "magic.h"
|
||||
#include "skill.h"
|
||||
|
||||
/* util includes */
|
||||
#include <kernel/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <kernel/event.h>
|
||||
#include <util/log.h>
|
||||
#include <util/macros.h>
|
||||
#include "util/strings.h"
|
||||
#include "util/variant.h"
|
||||
/* attributes includes */
|
||||
#include <attributes/racename.h>
|
||||
#include <attributes/key.h>
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/attrib.h>
|
||||
#include "kernel/skill.h"
|
||||
#include <kernel/event.h>
|
||||
#include "kernel/skills.h"
|
||||
#include "kernel/types.h"
|
||||
#include <kernel/building.h>
|
||||
|
@ -38,9 +35,12 @@
|
|||
#include <kernel/spell.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
/* attributes includes */
|
||||
#include <attributes/racename.h>
|
||||
#include <attributes/key.h>
|
||||
/* util includes */
|
||||
#include <util/base36.h>
|
||||
#include <util/log.h>
|
||||
#include <util/macros.h>
|
||||
#include "util/strings.h"
|
||||
#include "util/variant.h"
|
||||
|
||||
#include <selist.h>
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "laws.h"
|
||||
#include "magic.h"
|
||||
#include "reports.h"
|
||||
#include "skill.h"
|
||||
#include "study.h"
|
||||
#include "summary.h"
|
||||
#include "teleport.h"
|
||||
|
@ -30,6 +29,7 @@
|
|||
#include "kernel/region.h"
|
||||
#include "kernel/save.h"
|
||||
#include "kernel/ship.h"
|
||||
#include "kernel/skill.h"
|
||||
#include "kernel/spell.h"
|
||||
#include "kernel/types.h"
|
||||
#include "kernel/item.h"
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "items.h"
|
||||
|
||||
#include "alchemy.h"
|
||||
#include "skill.h"
|
||||
#include "direction.h"
|
||||
#include "study.h"
|
||||
#include "economy.h"
|
||||
|
@ -25,6 +24,7 @@
|
|||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/skills.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "jsonconf.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include "kernel/attrib.h"
|
||||
#include "kernel/building.h"
|
||||
#include "kernel/calendar.h"
|
||||
#include "kernel/config.h"
|
||||
|
@ -15,11 +16,11 @@
|
|||
#include "kernel/resources.h"
|
||||
#include "kernel/ship.h"
|
||||
#include "kernel/terrain.h"
|
||||
#include "kernel/skill.h"
|
||||
#include "kernel/spell.h"
|
||||
#include "kernel/spellbook.h"
|
||||
|
||||
/* util includes */
|
||||
#include "kernel/attrib.h"
|
||||
#include "util/aliases.h"
|
||||
#include "util/crmessage.h"
|
||||
#include "util/functions.h"
|
||||
|
@ -36,7 +37,6 @@
|
|||
#include "direction.h"
|
||||
#include "move.h"
|
||||
#include "prefix.h"
|
||||
#include "skill.h"
|
||||
#include "exparse.h"
|
||||
|
||||
/* external libraries */
|
||||
|
|
|
@ -37,6 +37,7 @@ region.test.c
|
|||
# resources.test.c
|
||||
save.test.c
|
||||
ship.test.c
|
||||
skill.test.c
|
||||
skills.test.c
|
||||
spellbook.test.c
|
||||
spell.test.c
|
||||
|
@ -74,6 +75,7 @@ region.c
|
|||
resources.c
|
||||
save.c
|
||||
ship.c
|
||||
skill.c
|
||||
skills.c
|
||||
spellbook.c
|
||||
spell.c
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef H_KRNL_SKILL
|
||||
#define H_KRNL_SKILL
|
||||
|
||||
#include <skill.h>
|
||||
#include "skill.h"
|
||||
|
||||
struct race;
|
||||
struct unit;
|
||||
|
@ -14,16 +14,16 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct skill {
|
||||
int id : 8;
|
||||
enum skill_t id : 8;
|
||||
int level : 8;
|
||||
int weeks : 8;
|
||||
int old : 8;
|
||||
} skill;
|
||||
|
||||
typedef int(*skillmod_fun) (const struct unit *, const struct region *,
|
||||
skill_t, int);
|
||||
enum skill_t, int);
|
||||
typedef struct skillmod_data {
|
||||
skill_t skill;
|
||||
enum skill_t skill;
|
||||
skillmod_fun special;
|
||||
double multiplier;
|
||||
int number;
|
||||
|
@ -32,14 +32,16 @@ extern "C" {
|
|||
|
||||
extern struct attrib_type at_skillmod;
|
||||
|
||||
int skillmod(const struct unit *u, const struct region *r, skill_t sk, int value);
|
||||
struct attrib *make_skillmod(skill_t sk, skillmod_fun special, double multiplier, int bonus);
|
||||
int skillmod(const struct unit *u, const struct region *r,
|
||||
enum skill_t sk, int value);
|
||||
struct attrib *make_skillmod(enum skill_t sk, skillmod_fun special,
|
||||
double multiplier, int bonus);
|
||||
|
||||
int level_days(int level);
|
||||
int level(int days);
|
||||
|
||||
#define skill_level(level) (level)
|
||||
void increase_skill(struct unit * u, skill_t sk, int weeks);
|
||||
void increase_skill(struct unit * u, enum skill_t sk, int weeks);
|
||||
void reduce_skill(struct unit *u, skill * sv, int weeks);
|
||||
int skill_weeks(int level);
|
||||
int skill_compare(const skill * sk, const skill * sc);
|
||||
|
|
|
@ -16,6 +16,7 @@ extern "C" {
|
|||
struct sc_mage;
|
||||
struct gamedata;
|
||||
struct item_type;
|
||||
enum skill_t;
|
||||
|
||||
#define MAXUNITS 1048573 /* should be prime for hashing. 524287 was >90% full */
|
||||
|
||||
|
@ -125,21 +126,21 @@ extern "C" {
|
|||
int alias);
|
||||
|
||||
const char *u_description(const unit * u, const struct locale *lang);
|
||||
struct skill *add_skill(struct unit *u, skill_t id);
|
||||
void remove_skill(struct unit *u, skill_t sk);
|
||||
struct skill *unit_skill(const struct unit *u, skill_t id);
|
||||
bool has_skill(const unit * u, skill_t sk);
|
||||
int effskill(const struct unit *u, skill_t sk, const struct region *r);
|
||||
struct skill *add_skill(struct unit *u, enum skill_t id);
|
||||
void remove_skill(struct unit *u, enum skill_t sk);
|
||||
struct skill *unit_skill(const struct unit *u, enum skill_t id);
|
||||
bool has_skill(const unit * u, enum skill_t sk);
|
||||
int effskill(const struct unit *u, enum skill_t sk, const struct region *r);
|
||||
|
||||
void set_level(struct unit *u, skill_t id, int level);
|
||||
int get_level(const struct unit *u, skill_t id);
|
||||
void set_level(struct unit *u, enum skill_t id, int level);
|
||||
int get_level(const struct unit *u, enum skill_t id);
|
||||
void transfermen(struct unit *src, struct unit *dst, int n);
|
||||
void clone_men(const struct unit *src, struct unit *dst, int n); /* like transfer, but do not subtract from src */
|
||||
|
||||
int eff_skill(const struct unit *u, const struct skill *sv, const struct region *r);
|
||||
int effskill_study(const struct unit *u, skill_t sk);
|
||||
int effskill_study(const struct unit *u, enum skill_t sk);
|
||||
|
||||
int get_modifier(const struct unit *u, skill_t sk, int level,
|
||||
int get_modifier(const struct unit *u, enum skill_t sk, int level,
|
||||
const struct region *r, bool noitem);
|
||||
int remove_unit(struct unit **ulist, struct unit *u);
|
||||
void leave_region(struct unit* u);
|
||||
|
@ -237,7 +238,7 @@ extern "C" {
|
|||
bool has_horses(const struct unit *u);
|
||||
int maintenance_cost(const struct unit *u);
|
||||
bool has_limited_skills(const struct unit *u);
|
||||
bool is_limited_skill(skill_t sk);
|
||||
bool is_limited_skill(enum skill_t sk);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "contact.h"
|
||||
#include "helpers.h"
|
||||
#include "laws.h"
|
||||
#include "skill.h"
|
||||
#include "spells.h"
|
||||
#include "study.h"
|
||||
|
||||
|
@ -41,6 +40,7 @@
|
|||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include "kernel/skill.h"
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/spellbook.h>
|
||||
#include <kernel/terrain.h>
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#include <platform.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "monsters.h"
|
||||
#include "guard.h"
|
||||
#include "reports.h"
|
||||
#include "study.h"
|
||||
|
||||
#include <kernel/attrib.h>
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
|
@ -9,16 +15,10 @@
|
|||
#include <kernel/region.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/terrain.h>
|
||||
#include <kernel/unit.h>
|
||||
#include "kernel/skill.h"
|
||||
#include "kernel/terrain.h"
|
||||
#include "kernel/unit.h"
|
||||
|
||||
#include "monsters.h"
|
||||
#include "guard.h"
|
||||
#include "reports.h"
|
||||
#include "skill.h"
|
||||
#include "study.h"
|
||||
|
||||
#include <kernel/attrib.h>
|
||||
#include <util/language.h>
|
||||
#include <util/message.h>
|
||||
#include <util/nrmessage.h>
|
||||
|
|
35
src/move.c
35
src/move.c
|
@ -2,6 +2,22 @@
|
|||
#include <platform.h>
|
||||
#endif
|
||||
|
||||
#include "alchemy.h"
|
||||
#include "contact.h"
|
||||
#include "direction.h"
|
||||
#include "guard.h"
|
||||
#include "laws.h"
|
||||
#include "lighthouse.h"
|
||||
#include "monsters.h"
|
||||
#include "move.h"
|
||||
#include "piracy.h"
|
||||
#include "reports.h"
|
||||
#include "study.h"
|
||||
#include "spy.h"
|
||||
#include "teleport.h"
|
||||
#include "travelthru.h"
|
||||
#include "vortex.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include "kernel/ally.h"
|
||||
#include "kernel/attrib.h"
|
||||
|
@ -21,24 +37,11 @@
|
|||
#include "kernel/region.h"
|
||||
#include "kernel/render.h"
|
||||
#include "kernel/ship.h"
|
||||
#include "kernel/skill.h"
|
||||
#include "kernel/terrain.h"
|
||||
#include "kernel/terrainid.h"
|
||||
#include "kernel/unit.h"
|
||||
|
||||
#include "alchemy.h"
|
||||
#include "contact.h"
|
||||
#include "guard.h"
|
||||
#include "laws.h"
|
||||
#include "lighthouse.h"
|
||||
#include "monsters.h"
|
||||
#include "move.h"
|
||||
#include "piracy.h"
|
||||
#include "reports.h"
|
||||
#include "study.h"
|
||||
#include "spy.h"
|
||||
#include "travelthru.h"
|
||||
#include "vortex.h"
|
||||
|
||||
#include <spells/flyingship.h>
|
||||
#include <spells/unitcurse.h>
|
||||
#include <spells/regioncurse.h>
|
||||
|
@ -50,10 +53,6 @@
|
|||
#include <attributes/stealth.h>
|
||||
#include <attributes/targetregion.h>
|
||||
|
||||
#include "teleport.h"
|
||||
#include "direction.h"
|
||||
#include "skill.h"
|
||||
|
||||
/* util includes */
|
||||
#include <util/base36.h>
|
||||
#include <util/language.h>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "economy.h"
|
||||
|
||||
#include "laws.h"
|
||||
#include "skill.h"
|
||||
#include "study.h"
|
||||
|
||||
#include <util/message.h>
|
||||
|
@ -19,6 +18,7 @@
|
|||
#include <kernel/pool.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include "kernel/skill.h"
|
||||
#include <kernel/terrain.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
|
|
22
src/study.h
22
src/study.h
|
@ -1,8 +1,8 @@
|
|||
#ifndef H_KRNL_STUDY
|
||||
#define H_KRNL_STUDY
|
||||
|
||||
#include "skill.h"
|
||||
#include <kernel/types.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -10,6 +10,7 @@ extern "C" {
|
|||
|
||||
struct unit;
|
||||
struct selist;
|
||||
enum skill_t;
|
||||
|
||||
#define STUDYDAYS 30
|
||||
#define TEACHNUMBER 10
|
||||
|
@ -27,18 +28,21 @@ extern "C" {
|
|||
int study_cmd(struct unit *u, struct order *ord);
|
||||
|
||||
magic_t getmagicskill(const struct locale *lang);
|
||||
skill_t getskill(const struct locale *lang);
|
||||
enum skill_t getskill(const struct locale *lang);
|
||||
bool is_migrant(struct unit *u);
|
||||
int study_cost(struct unit *u, skill_t sk);
|
||||
bool check_student(const struct unit *u, struct order *ord, skill_t sk);
|
||||
int study_cost(struct unit *u, enum skill_t sk);
|
||||
bool check_student(const struct unit *u, struct order *ord,
|
||||
enum skill_t sk);
|
||||
|
||||
typedef void(*learn_fun)(struct unit *u, skill_t sk, int days);
|
||||
typedef void(*learn_fun)(struct unit *u, enum skill_t sk, int days);
|
||||
|
||||
int learn_skill(struct unit *u, skill_t sk, int days, int studycost);
|
||||
void change_skill_days(struct unit *u, skill_t sk, int days);
|
||||
int learn_skill(struct unit *u, enum skill_t sk, int days,
|
||||
int studycost);
|
||||
void change_skill_days(struct unit *u, enum skill_t sk, int days);
|
||||
|
||||
void produceexp(struct unit *u, skill_t sk, int n);
|
||||
void produceexp_ex(struct unit *u, skill_t sk, int n, learn_fun learn);
|
||||
void produceexp(struct unit *u, enum skill_t sk, int n);
|
||||
void produceexp_ex(struct unit *u, enum skill_t sk, int n,
|
||||
learn_fun learn);
|
||||
|
||||
void demon_skillchange(struct unit *u);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "kernel/unit.h"
|
||||
#include "kernel/region.h"
|
||||
#include "kernel/race.h"
|
||||
#include "kernel/skill.h"
|
||||
#include "kernel/terrain.h"
|
||||
#include "kernel/faction.h"
|
||||
#include "kernel/plane.h"
|
||||
|
@ -15,7 +16,6 @@
|
|||
#include "util/stats.h"
|
||||
#include "util/rng.h"
|
||||
|
||||
#include "skill.h"
|
||||
#include "monsters.h"
|
||||
|
||||
/* libc includes */
|
||||
|
|
Loading…
Add table
Reference in a new issue