forked from github/server
E4 combat prototype (WIP)
This commit is contained in:
parent
1861268109
commit
f893ea03b6
|
@ -28,6 +28,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <kernel/magic.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/move.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
|
|
|
@ -206,7 +206,7 @@ static void message_faction(battle * b, faction * f, struct message *m)
|
|||
region *r = b->region;
|
||||
|
||||
if (f->battles == NULL || f->battles->r != r) {
|
||||
struct bmsg *bm = calloc(1, sizeof(struct bmsg));
|
||||
struct bmsg *bm = (struct bmsg *)calloc(1, sizeof(struct bmsg));
|
||||
bm->next = f->battles;
|
||||
f->battles = bm;
|
||||
bm->r = r;
|
||||
|
@ -3203,7 +3203,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
|
|||
/* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit für noch
|
||||
* keinen Kampf ausgewählt wurde (sonst würde ein fighter existieren) */
|
||||
}
|
||||
fig = calloc(1, sizeof(struct fighter));
|
||||
fig = (struct fighter*)calloc(1, sizeof(struct fighter));
|
||||
|
||||
fig->next = s1->fighters;
|
||||
s1->fighters = fig;
|
||||
|
@ -3228,7 +3228,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
|
|||
fig->catmsg = -1;
|
||||
|
||||
/* Freigeben nicht vergessen! */
|
||||
fig->person = calloc(fig->alive, sizeof(struct person));
|
||||
fig->person = (struct person*)calloc(fig->alive, sizeof(struct person));
|
||||
|
||||
h = u->hp / u->number;
|
||||
assert(h);
|
||||
|
@ -3542,7 +3542,7 @@ battle *make_battle(region * r)
|
|||
else {
|
||||
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
||||
fwrite(utf8_bom, 1, 3, bdebug);
|
||||
fprintf(bdebug, "In %s findet ein Kampf stattactics:\n", rname(r,
|
||||
fprintf(bdebug, "In %s findet ein Kampf statt:\n", rname(r,
|
||||
default_locale));
|
||||
}
|
||||
obs_count++;
|
||||
|
@ -3600,7 +3600,6 @@ static void free_fighter(fighter * fig)
|
|||
|
||||
static void free_battle(battle * b)
|
||||
{
|
||||
side *s;
|
||||
int max_fac_no = 0;
|
||||
|
||||
if (bdebug) {
|
||||
|
@ -3615,19 +3614,11 @@ static void free_battle(battle * b)
|
|||
free(bf);
|
||||
}
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fnext = s->fighters;
|
||||
while (fnext) {
|
||||
fighter *fig = fnext;
|
||||
fnext = fig->next;
|
||||
free_fighter(fig);
|
||||
free(fig);
|
||||
}
|
||||
free_side(s);
|
||||
}
|
||||
ql_free(b->leaders);
|
||||
ql_foreach(b->meffects, free);
|
||||
ql_free(b->meffects);
|
||||
|
||||
battle_free(b);
|
||||
}
|
||||
|
||||
static int *get_alive(side * s)
|
||||
|
@ -3876,7 +3867,7 @@ static void flee(const troop dt)
|
|||
kill_troop(dt);
|
||||
}
|
||||
|
||||
static bool init_battle(region * r, battle ** bp)
|
||||
static bool start_battle(region * r, battle ** bp)
|
||||
{
|
||||
battle *b = NULL;
|
||||
unit *u;
|
||||
|
@ -4091,7 +4082,7 @@ static void battle_stats(FILE * F, battle * b)
|
|||
}
|
||||
stat = *slist;
|
||||
if (stat == NULL || stat->wtype != wtype || stat->level != level) {
|
||||
stat = calloc(1, sizeof(stat_info));
|
||||
stat = (stat_info*)calloc(1, sizeof(stat_info));
|
||||
stat->wtype = wtype;
|
||||
stat->level = level;
|
||||
stat->next = *slist;
|
||||
|
@ -4251,7 +4242,7 @@ void do_battle(region * r)
|
|||
msg_separator = msg_message("battle::section", "");
|
||||
}
|
||||
|
||||
fighting = init_battle(r, &b);
|
||||
fighting = start_battle(r, &b);
|
||||
|
||||
if (b == NULL)
|
||||
return;
|
||||
|
@ -4318,3 +4309,26 @@ void do_battle(region * r)
|
|||
free(b);
|
||||
}
|
||||
}
|
||||
|
||||
void battle_init(battle * b) {
|
||||
assert(b);
|
||||
memset(b, 0, sizeof(battle));
|
||||
}
|
||||
|
||||
void battle_free(battle * b) {
|
||||
side *s;
|
||||
|
||||
assert(b);
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fnext = s->fighters;
|
||||
while (fnext) {
|
||||
fighter *fig = fnext;
|
||||
fnext = fig->next;
|
||||
free_fighter(fig);
|
||||
free(fig);
|
||||
}
|
||||
free_side(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,9 @@ extern "C" {
|
|||
} fast;
|
||||
} battle;
|
||||
|
||||
void battle_init(battle * b);
|
||||
void battle_free(battle * b);
|
||||
|
||||
typedef struct weapon {
|
||||
int count, used;
|
||||
const struct weapon_type *type;
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
#include "region.h"
|
||||
#include "skill.h"
|
||||
#include "unit.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include <CuTest.h>
|
||||
#include "tests.h"
|
||||
|
||||
static void test_make_fighter(CuTest * tc)
|
||||
{
|
||||
|
|
|
@ -1249,12 +1249,6 @@ int count_maxmigrants(const faction * f)
|
|||
return migrants;
|
||||
}
|
||||
|
||||
void init_tokens(const struct order *ord)
|
||||
{
|
||||
char *cmd = getcommand(ord);
|
||||
init_tokens_str(cmd, cmd);
|
||||
}
|
||||
|
||||
void
|
||||
parse(keyword_t kword, int (*dofun) (unit *, struct order *), bool thisorder)
|
||||
{
|
||||
|
@ -1953,6 +1947,11 @@ direction_t finddirection(const char *s, const struct locale *lang)
|
|||
return NODIRECTION;
|
||||
}
|
||||
|
||||
direction_t getdirection(const struct locale * lang)
|
||||
{
|
||||
return finddirection(getstrtoken(), lang);
|
||||
}
|
||||
|
||||
static void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings)
|
||||
{
|
||||
char buffer[256];
|
||||
|
|
|
@ -165,9 +165,10 @@ extern "C" {
|
|||
unsigned int getuint(void);
|
||||
int getint(void);
|
||||
|
||||
direction_t getdirection(const struct locale *);
|
||||
|
||||
extern const char *igetstrtoken(const char *s);
|
||||
|
||||
extern void init_tokens(const struct order *ord); /* initialize token parsing */
|
||||
extern skill_t findskill(const char *s, const struct locale *lang);
|
||||
|
||||
extern keyword_t findkeyword(const char *s, const struct locale *lang);
|
||||
|
|
|
@ -176,13 +176,6 @@ attrib_type at_speedup = {
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
direction_t getdirection(const struct locale * lang)
|
||||
{
|
||||
return finddirection(getstrtoken(), lang);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static attrib_type at_driveweight = {
|
||||
"driveweight", NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
|
|
@ -47,7 +47,6 @@ extern "C" {
|
|||
** pferde, macht nur noch 100, aber samt eigenem gewicht (40) macht also 140. */
|
||||
|
||||
int personcapacity(const struct unit *u);
|
||||
direction_t getdirection(const struct locale *);
|
||||
void movement(void);
|
||||
void run_to(struct unit *u, struct region *to);
|
||||
struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask);
|
||||
|
|
|
@ -606,3 +606,9 @@ void push_order(order ** ordp, order * ord)
|
|||
ordp = &(*ordp)->next;
|
||||
*ordp = ord;
|
||||
}
|
||||
|
||||
void init_tokens(const struct order *ord)
|
||||
{
|
||||
char *cmd = getcommand(ord);
|
||||
init_tokens_str(cmd, cmd);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ extern "C" {
|
|||
extern int is_long(const order * ord);
|
||||
|
||||
extern char *write_order(const order * ord, char *buffer, size_t size);
|
||||
extern void init_tokens(const struct order *ord); /* initialize token parsing */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -628,13 +628,13 @@ int distance(const region * r1, const region * r2)
|
|||
static direction_t
|
||||
koor_reldirection(int ax, int ay, int bx, int by, const struct plane *pl)
|
||||
{
|
||||
direction_t dir;
|
||||
int dir;
|
||||
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
|
||||
int x = ax + delta_x[dir];
|
||||
int y = ay + delta_y[dir];
|
||||
pnormalize(&x, &y, pl);
|
||||
if (bx == x && by == y)
|
||||
return dir;
|
||||
return (direction_t)dir;
|
||||
}
|
||||
return NODIRECTION;
|
||||
}
|
||||
|
@ -1593,9 +1593,9 @@ void region_set_morale(region * r, int morale, int turn)
|
|||
|
||||
void get_neighbours(const region * r, region ** list)
|
||||
{
|
||||
direction_t dir;
|
||||
int dir;
|
||||
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
|
||||
list[dir] = rconnect(r, dir);
|
||||
list[dir] = rconnect(r, (direction_t)dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue