forked from github/server
move findrace into race.c
This commit is contained in:
parent
925d65c206
commit
09f22ba0bc
|
@ -183,18 +183,6 @@ parse(keyword_t kword, int(*dofun) (unit *, struct order *), bool thisorder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct race *findrace(const char *s, const struct locale *lang)
|
|
||||||
{
|
|
||||||
void **tokens = get_translations(lang, UT_RACES);
|
|
||||||
variant token;
|
|
||||||
|
|
||||||
assert(lang);
|
|
||||||
if (tokens && findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
|
|
||||||
return (const struct race *)token.v;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int findoption(const char *s, const struct locale *lang)
|
int findoption(const char *s, const struct locale *lang)
|
||||||
{
|
{
|
||||||
void **tokens = get_translations(lang, UT_OPTIONS);
|
void **tokens = get_translations(lang, UT_OPTIONS);
|
||||||
|
|
|
@ -83,8 +83,6 @@ struct param;
|
||||||
#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS)
|
#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS)
|
||||||
int rule_give(void);
|
int rule_give(void);
|
||||||
|
|
||||||
const struct race *findrace(const char *, const struct locale *);
|
|
||||||
|
|
||||||
/* grammatik-flags: */
|
/* grammatik-flags: */
|
||||||
#define GF_NONE 0
|
#define GF_NONE 0
|
||||||
/* singular, ohne was dran */
|
/* singular, ohne was dran */
|
||||||
|
|
|
@ -39,6 +39,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/bsdstring.h>
|
#include <util/bsdstring.h>
|
||||||
#include <util/functions.h>
|
#include <util/functions.h>
|
||||||
|
#include <util/umlaut.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/rng.h>
|
#include <util/rng.h>
|
||||||
|
@ -75,6 +76,18 @@ static const char *racenames[MAXRACES] = {
|
||||||
"clone"
|
"clone"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct race *findrace(const char *s, const struct locale *lang)
|
||||||
|
{
|
||||||
|
void **tokens = get_translations(lang, UT_RACES);
|
||||||
|
variant token;
|
||||||
|
|
||||||
|
assert(lang);
|
||||||
|
if (tokens && findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
|
||||||
|
return (const struct race *)token.v;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const struct race *get_race(race_t rt) {
|
const struct race *get_race(race_t rt) {
|
||||||
const char * name;
|
const char * name;
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ extern "C" {
|
||||||
|
|
||||||
struct param;
|
struct param;
|
||||||
struct spell;
|
struct spell;
|
||||||
|
struct locale;
|
||||||
|
|
||||||
extern int num_races;
|
extern int num_races;
|
||||||
|
|
||||||
|
@ -163,6 +164,7 @@ extern "C" {
|
||||||
void racelist_clear(struct race_list **rl);
|
void racelist_clear(struct race_list **rl);
|
||||||
void racelist_insert(struct race_list **rl, const struct race *r);
|
void racelist_insert(struct race_list **rl, const struct race *r);
|
||||||
|
|
||||||
|
const struct race *findrace(const char *, const struct locale *);
|
||||||
|
|
||||||
struct race_list *get_familiarraces(void);
|
struct race_list *get_familiarraces(void);
|
||||||
struct race *races;
|
struct race *races;
|
||||||
|
|
12
src/spy.c
12
src/spy.c
|
@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <kernel/config.h>
|
|
||||||
#include "spy.h"
|
#include "spy.h"
|
||||||
#include "guard.h"
|
#include "guard.h"
|
||||||
#include "laws.h"
|
#include "laws.h"
|
||||||
|
@ -26,6 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "study.h"
|
#include "study.h"
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
|
#include <kernel/config.h>
|
||||||
#include <kernel/item.h>
|
#include <kernel/item.h>
|
||||||
#include <kernel/faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <kernel/messages.h>
|
#include <kernel/messages.h>
|
||||||
|
@ -297,7 +297,7 @@ int setstealth_cmd(unit * u, struct order *ord)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (findparam(s, u->faction->locale) == P_NOT) {
|
else if (findparam(s, u->faction->locale) == P_NOT) {
|
||||||
freset(u, UFL_ANON_FACTION);
|
u->flags |= ~UFL_ANON_FACTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,18 +414,18 @@ static void sink_ship(region * r, ship * sh, unit * saboteur)
|
||||||
/* slight optimization to avoid dereferencing u->faction each time */
|
/* slight optimization to avoid dereferencing u->faction each time */
|
||||||
if (f != u->faction) {
|
if (f != u->faction) {
|
||||||
f = u->faction;
|
f = u->faction;
|
||||||
freset(f, FFL_SELECT);
|
f->flags |= ~FFL_SELECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* figure out what a unit's chances of survival are: */
|
/* figure out what a unit's chances of survival are: */
|
||||||
if (!fval(r->terrain, SEA_REGION)) {
|
if (!(r->terrain->flags & SEA_REGION)) {
|
||||||
probability = CANAL_SWIMMER_CHANCE;
|
probability = CANAL_SWIMMER_CHANCE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
||||||
region *rn = rconnect(r, d);
|
region *rn = rconnect(r, d);
|
||||||
if (rn && !fval(rn->terrain, SEA_REGION) && !move_blocked(NULL, r, rn)) {
|
if (rn && !(rn->terrain->flags & SEA_REGION) && !move_blocked(NULL, r, rn)) {
|
||||||
safety = rn;
|
safety = rn;
|
||||||
probability = OCEAN_SWIMMER_CHANCE;
|
probability = OCEAN_SWIMMER_CHANCE;
|
||||||
break;
|
break;
|
||||||
|
@ -436,7 +436,7 @@ static void sink_ship(region * r, ship * sh, unit * saboteur)
|
||||||
unit *u = *ui;
|
unit *u = *ui;
|
||||||
|
|
||||||
/* inform this faction about the sinking ship: */
|
/* inform this faction about the sinking ship: */
|
||||||
if (!fval(u->faction, FFL_SELECT)) {
|
if (!(u->faction->flags & FFL_SELECT)) {
|
||||||
fset(u->faction, FFL_SELECT);
|
fset(u->faction, FFL_SELECT);
|
||||||
if (sink_msg == NULL) {
|
if (sink_msg == NULL) {
|
||||||
sink_msg = msg_message("sink_msg", "ship region", sh, r);
|
sink_msg = msg_message("sink_msg", "ship region", sh, r);
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
struct unit;
|
struct unit;
|
||||||
struct region;
|
struct region;
|
||||||
struct strlist;
|
struct strlist;
|
||||||
|
struct order;
|
||||||
|
|
||||||
extern int setstealth_cmd(struct unit *u, struct order *ord);
|
extern int setstealth_cmd(struct unit *u, struct order *ord);
|
||||||
extern int spy_cmd(struct unit *u, struct order *ord);
|
extern int spy_cmd(struct unit *u, struct order *ord);
|
||||||
|
|
Loading…
Reference in New Issue