- use of short for coordinates is a pain (if memory becomes an issue again, we fix it another way).

- starting on work to have a wraparound world.
This commit is contained in:
Enno Rehling 2009-06-27 01:27:48 +00:00
parent a21dbbbadf
commit 5b6b638a37
29 changed files with 194 additions and 123 deletions

View File

@ -683,7 +683,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
if(current_season == SEASON_SUMMER || current_season == SEASON_AUTUMN) {
double seedchance = 0.01F * RESOURCE_QUANTITY;
int elves = count_race(r,new_race[RC_ELF]);
int elves = count_race(r, new_race[RC_ELF]);
a = a_find(r->attribs, &at_germs);
if(a && last_weeks_season == SEASON_SPRING) {

View File

@ -799,7 +799,7 @@ move_iceberg(region *r)
if (fval(rc->terrain, SEA_REGION)) { /* Eisberg treibt */
ship *sh, *shn;
unit *u;
short x, y;
int x, y;
for (u=r->units; u; u=u->next) freset(u->faction, FFL_SELECT);

View File

@ -734,16 +734,21 @@ CavalryBonus(const unit * u, troop enemy, int type)
/* old rule, Eressea 1.0 compat */
return (type==BONUS_SKILL)?2:0;
} else {
if (type==BONUS_DAMAGE) {
/* new rule, chargers in Eressea 1.1 */
int skl = effskill(u, SK_RIDING);
/* only half against trolls */
if (skl>0) {
int dmg = 1+rng_int() % skl;
if (type==BONUS_DAMAGE) {
int dmg = MIN(skl, 8);
if (enemy.fighter->unit->race==new_race[RC_TROLL]) {
dmg = dmg/4;
} else {
dmg = dmg/2;
}
return dmg;
} else {
skl = skl/2;
return MIN(skl, 4);
}
}
}

View File

@ -91,6 +91,9 @@
#include <util/patricia.h>
#endif
int world_width = -1;
int world_height = -1;
/* exported variables */
region *regions;
faction *factions;
@ -1149,15 +1152,15 @@ update_lighthouse(building * lh)
if (lh->type==bt_lighthouse) {
region * r = lh->region;
short d = (short)log10(lh->size) + 1;
short x;
int d = (int)log10(lh->size) + 1;
int x;
if (lh->size>0) {
r->flags |= RF_LIGHTHOUSE;
}
for (x=-d;x<=d;++x) {
short y;
int y;
for (y=-d;y<=d;++y) {
attrib * a;
region * r2 = findregion(x+r->x, y+r->y);
@ -2928,9 +2931,12 @@ has_limited_skills (const struct unit * u)
return false;
}
}
void
attrib_init(void)
{
world_width = get_param_int(global.parameters, "world.width", 0);
world_height = get_param_int(global.parameters, "world.height", 0);
/* Alle speicherbaren Attribute müssen hier registriert werden */
at_register(&at_shiptrail);
at_register(&at_familiar);

View File

@ -115,6 +115,9 @@ extern const char *parameters[MAXPARAMS];
#define want(option) (1<<option)
extern const char *options[MAXOPTIONS];
extern int world_width;
extern int world_height;
/* ------------------------------------------------------------- */
extern int shipspeed(const struct ship * sh, const struct unit * u);

View File

@ -1913,8 +1913,8 @@ addparam_region(const char * const param[], spllprm ** spobjp, const unit * u, o
return -1;
} else {
int tx = atoi((const char*)param[0]), ty = atoi((const char*)param[1]);
short x = rel_to_abs(0, u->faction, (short)tx, 0);
short y = rel_to_abs(0, u->faction, (short)ty, 1);
int x = rel_to_abs(0, u->faction, tx, 0);
int y = rel_to_abs(0, u->faction, ty, 1);
region *rt = findregion(x,y);
if (rt!=NULL) {

View File

@ -72,7 +72,7 @@ getplanebyname(const char * name)
}
plane *
findplane(short x, short y)
findplane(int x, int y)
{
plane *pl;
@ -103,7 +103,7 @@ getplaneid(const region *r)
return 0;
}
static short
static int
ursprung_x(const faction *f, const plane *pl, const region * rdefault)
{
ursprung *ur;
@ -124,7 +124,7 @@ ursprung_x(const faction *f, const plane *pl, const region * rdefault)
return rdefault->x - plane_center_x(pl);
}
static short
static int
ursprung_y(const faction *f, const plane *pl, const region * rdefault)
{
ursprung *ur;
@ -145,7 +145,7 @@ ursprung_y(const faction *f, const plane *pl, const region * rdefault)
return rdefault->y - plane_center_y(pl);
}
short
int
plane_center_x(const plane *pl)
{
if(pl == NULL)
@ -154,7 +154,7 @@ plane_center_x(const plane *pl)
return(pl->minx + pl->maxx)/2;
}
short
int
plane_center_y(const plane *pl)
{
if(pl == NULL)
@ -163,14 +163,14 @@ plane_center_y(const plane *pl)
return(pl->miny + pl->maxy)/2;
}
short
int
region_x(const region *r, const faction *f)
{
plane *pl = r->planep;
return r->x - ursprung_x(f, pl, r) - plane_center_x(pl);
}
short
int
region_y(const region *r, const faction *f)
{
plane *pl = r->planep;
@ -178,7 +178,7 @@ region_y(const region *r, const faction *f)
}
void
set_ursprung(faction *f, int id, short x, short y)
set_ursprung(faction *f, int id, int x, int y)
{
ursprung *ur;
assert(f!=NULL);
@ -199,7 +199,7 @@ set_ursprung(faction *f, int id, short x, short y)
}
plane *
create_new_plane(int id, const char *name, short minx, short maxx, short miny, short maxy, int flags)
create_new_plane(int id, const char *name, int minx, int maxx, int miny, int maxy, int flags)
{
plane *pl = getplanebyid(id);
@ -220,8 +220,8 @@ create_new_plane(int id, const char *name, short minx, short maxx, short miny, s
}
/* Umrechnung Relative-Absolute-Koordinaten */
short
rel_to_abs(const struct plane *pl, const struct faction * f, short rel, unsigned char index)
int
rel_to_abs(const struct plane *pl, const struct faction * f, int rel, unsigned char index)
{
assert(index == 0 || index == 1);

View File

@ -52,7 +52,7 @@ typedef struct plane {
struct watcher * watchers;
int id;
char *name;
short minx, maxx, miny, maxy;
int minx, maxx, miny, maxy;
unsigned int flags;
struct attrib *attribs;
} plane;
@ -60,18 +60,18 @@ typedef struct plane {
extern struct plane *planes;
struct plane *getplane(const struct region *r);
struct plane *findplane(short x, short y);
struct plane *findplane(int x, int y);
void init_planes(void);
int getplaneid(const struct region *r);
struct plane * getplanebyid(int id);
short region_x(const struct region *r, const struct faction *f);
short region_y(const struct region *r, const struct faction *f);
short plane_center_x(const struct plane *pl);
short plane_center_y(const struct plane *pl);
void set_ursprung(struct faction *f, int id, short x, short y);
plane * create_new_plane(int id, const char *name, short minx, short maxx, short miny, short maxy, int flags);
int region_x(const struct region *r, const struct faction *f);
int region_y(const struct region *r, const struct faction *f);
int plane_center_x(const struct plane *pl);
int plane_center_y(const struct plane *pl);
void set_ursprung(struct faction *f, int id, int x, int y);
plane * create_new_plane(int id, const char *name, int minx, int maxx, int miny, int maxy, int flags);
plane * getplanebyname(const char *);
extern short rel_to_abs(const struct plane *pl, const struct faction * f, short rel, unsigned char index);
extern int rel_to_abs(const struct plane *pl, const struct faction * f, int rel, unsigned char index);
extern boolean is_watcher(const struct plane * p, const struct faction * f);
extern int resolve_plane(variant data, void * addr);
extern void write_plane_reference(const plane * p, struct storage * store);

View File

@ -73,12 +73,12 @@ get_maxluxuries()
}
return maxluxuries;
}
const short delta_x[MAXDIRECTIONS] =
const int delta_x[MAXDIRECTIONS] =
{
-1, 0, 1, 1, 0, -1
};
const short delta_y[MAXDIRECTIONS] =
const int delta_y[MAXDIRECTIONS] =
{
1, 1, 0, -1, -1, 0
};
@ -433,8 +433,24 @@ static int hash_requests;
static int hash_misses;
#endif
void cnormalize(int * x, int * y)
{
if (world_width && x) {
if (*x<0) {
*x = world_width - abs(*x) % world_width;
}
*x = *x % world_width;
}
if (world_height && y) {
if (*y<0) {
*y = world_height - abs(*y) % world_height;
}
*y = *y % world_height;
}
}
static region *
rfindhash(short x, short y)
rfindhash(int x, int y)
{
unsigned int rid = coor_hashkey(x, y);
#if HASH_STATISTICS
@ -510,7 +526,7 @@ r_connect(const region * r, direction_t dir)
}
region *
findregion(short x, short y)
findregion(int x, int y)
{
return rfindhash(x, y);
}
@ -840,7 +856,7 @@ static region *last;
static unsigned int max_index = 0;
region *
new_region(short x, short y, unsigned int uid)
new_region(int x, int y, unsigned int uid)
{
region *r = rfindhash(x, y);

View File

@ -112,7 +112,7 @@ typedef struct region {
which a faction has its units. See the implementations of firstregion
and lastregion */
unsigned int uid; /* a unique id */
short x, y;
int x, y;
struct plane *planep;
char *display;
unsigned int flags;
@ -141,7 +141,7 @@ struct message_list * r_getmessages(const struct region * r, const struct factio
struct message * r_addmessage(struct region * r, const struct faction * viewer, struct message * msg);
typedef struct spec_direction {
short x, y;
int x, y;
int duration;
boolean active;
char *desc;
@ -157,7 +157,7 @@ typedef struct {
int distance(const struct region*, const struct region*);
int koor_distance(int ax, int ay, int bx, int by) ;
direction_t reldirection(const struct region * from, const struct region * to);
struct region * findregion(short x, short y);
struct region * findregion(int x, int y);
struct region * findregionbyid(unsigned int uid);
extern struct attrib_type at_direction;
@ -229,12 +229,12 @@ int r_demand(const struct region * r, const struct luxury_type * ltype);
const char * write_regionname(const struct region * r, const struct faction * f, char * buffer, size_t size);
struct region * new_region(short x, short y, unsigned int uid);
struct region * new_region(int x, int y, unsigned int uid);
void remove_region(region ** rlist, region * r);
void terraform_region(struct region * r, const struct terrain_type * terrain);
extern const short delta_x[MAXDIRECTIONS];
extern const short delta_y[MAXDIRECTIONS];
extern const int delta_x[MAXDIRECTIONS];
extern const int delta_y[MAXDIRECTIONS];
direction_t dir_invert(direction_t dir);
int production(const struct region *r);

View File

@ -883,7 +883,7 @@ write_unit(struct storage * store, const unit * u)
}
static region *
readregion(struct storage * store, short x, short y)
readregion(struct storage * store, int x, int y)
{
region * r = findregion(x, y);
const terrain_type * terrain;
@ -1210,8 +1210,8 @@ readfaction(struct storage * store)
planes = store->r_int(store);
while(--planes >= 0) {
int id = store->r_int(store);
short ux = (short)store->r_int(store);
short uy = (short)store->r_int(store);
int ux = store->r_int(store);
int uy = store->r_int(store);
set_ursprung(f, id, ux, uy);
}
f->newbies = 0;
@ -1386,10 +1386,10 @@ readgame(const char * filename, int mode, int backup)
}
pl->id = id;
pl->name = store->r_str(store);
pl->minx = (short)store->r_int(store);
pl->maxx = (short)store->r_int(store);
pl->miny = (short)store->r_int(store);
pl->maxy = (short)store->r_int(store);
pl->minx = store->r_int(store);
pl->maxx = store->r_int(store);
pl->miny = store->r_int(store);
pl->maxy = store->r_int(store);
pl->flags = store->r_int(store);
/* read watchers */
@ -1443,8 +1443,8 @@ readgame(const char * filename, int mode, int backup)
log_info((1, " - Einzulesende Regionen: %d/%d\r", rmax, n));
while (--n >= 0) {
unit **up;
short x = (short)store->r_int(store);
short y = (short)store->r_int(store);
int x = store->r_int(store);
int y = store->r_int(store);
if ((n & 0x3FF) == 0) { /* das spart extrem Zeit */
log_info((2, " - Einzulesende Regionen: %d/%d * %d,%d \r", rmax, n, x, y));

View File

@ -45,8 +45,8 @@
#define TP_RADIUS 2
#define TP_DISTANCE 4
static short
real2tp(short rk) {
static int
real2tp(int rk) {
/* in C:
* -4 / 5 = 0;
* +4 / 5 = 0;
@ -66,7 +66,7 @@ region_list *
astralregions(const region * r, boolean (*valid)(const region *))
{
region_list * rlist = NULL;
short x, y;
int x, y;
assert(is_astral(r));
if (!is_astral(r)) {
@ -99,7 +99,7 @@ r_standard_to_astral(const region *r)
region *
r_astral_to_standard(const region *r)
{
short x, y;
int x, y;
region *r2;
assert(is_astral(r));
@ -113,9 +113,9 @@ r_astral_to_standard(const region *r)
}
region_list *
all_in_range(const region *r, short n, boolean (*valid)(const region *))
all_in_range(const region *r, int n, boolean (*valid)(const region *))
{
short x, y;
int x, y;
region_list *rlist = NULL;
if (r == NULL) return NULL;
@ -205,8 +205,8 @@ create_teleport_plane(void)
region *ra = tpregion(r);
if (ra==NULL) {
short x = TE_CENTER_X+real2tp(r->x);
short y = TE_CENTER_Y+real2tp(r->y);
int x = TE_CENTER_X+real2tp(r->x);
int y = TE_CENTER_Y+real2tp(r->y);
plane * pl = findplane(x, y);
if (aplane && pl==aplane) {

View File

@ -21,7 +21,7 @@ extern "C" {
struct region *r_standard_to_astral(const struct region *r);
struct region *r_astral_to_standard(const struct region *);
extern struct region_list *astralregions(const struct region * rastral, boolean (*valid)(const struct region *));
extern struct region_list *all_in_range(const struct region *r, short n, boolean (*valid)(const struct region *));
extern struct region_list *all_in_range(const struct region *r, int n, boolean (*valid)(const struct region *));
extern boolean inhabitable(const struct region * r);
extern boolean is_astral(const struct region * r);
extern struct plane * get_astralplane(void);

View File

@ -74,7 +74,7 @@ struct weapon_type;
typedef struct ursprung {
struct ursprung *next;
int id;
short x, y;
int x, y;
} ursprung;
/* ----------------- Befehle ----------------------------------- */

View File

@ -355,9 +355,9 @@ guardian_faction(plane * pl, int id)
#ifdef ARENA_CREATION
static void
block_create(short x1, short y1, char terrain)
block_create(int x1, int y1, char terrain)
{
short x, y;
int x, y;
for (x=0;x!=BLOCKSIZE;++x) {
for (y=0;y!=BLOCKSIZE;++y) {
region * r = new_region(x1 + x, y1 + y, 0);
@ -464,7 +464,7 @@ init_volcano(void)
void
create_arena(void)
{
short x;
int x;
arena_id = hashstring("arena");
arena = getplanebyid(arena_id);
if (arena!=NULL) return;
@ -477,7 +477,7 @@ create_arena(void)
block_create(arena->minx, arena->miny, T_OCEAN);
arena_center = findregion(plane_center_x(arena), plane_center_y(arena));
for (x=0;x!=BLOCKSIZE;++x) {
short y;
int y;
for (y=0;y!=BLOCKSIZE;++y) {
region * r = findregion(arena->minx+x, arena->miny+y);
freset(r, RF_ENCOUNTER);

View File

@ -479,7 +479,7 @@ prepare_starting_region(region * r)
int
autoseed(newfaction ** players, int nsize, int max_agediff)
{
short x = 0, y = 0;
int x = 0, y = 0;
region * r = NULL;
region_list * rlist = NULL;
int rsize = 0, tsize = 0;
@ -712,7 +712,7 @@ autoseed(newfaction ** players, int nsize, int max_agediff)
direction_t d;
rbegin=&(*rbegin)->next;
for (d=0;d!=MAXDIRECTIONS;++d) if (rconnect(r, d)==NULL) {
short i;
int i;
for (i=1;i!=MAXFILLDIST;++i) {
if (findregion(r->x + i*delta_x[d], r->y + i*delta_y[d]))
break;
@ -881,8 +881,8 @@ smooth_island(region_list * island)
r = rlist->data;
runhash(r);
runhash(rn[n]);
SWAP(short, r->x, rn[n]->x);
SWAP(short, r->y, rn[n]->y);
SWAP(int, r->x, rn[n]->x);
SWAP(int, r->y, rn[n]->y);
rhash(r);
rhash(rn[n]);
rlist->data = r;
@ -901,6 +901,7 @@ starting_region(region * r, region * rn[])
unit * u;
int n;
oceans_around(r, rn);
freset(r, RF_MARK);
for (n=0;n!=MAXDIRECTIONS;++n) {
freset(rn[n], RF_MARK);
@ -913,7 +914,7 @@ starting_region(region * r, region * rn[])
}
/* E3A island generation */
int
build_island_e3(short x, short y, int numfactions, int minsize)
build_island_e3(int x, int y, int numfactions, int minsize)
{
#define MIN_QUALITY 1000
int nfactions = 0;
@ -923,7 +924,9 @@ build_island_e3(short x, short y, int numfactions, int minsize)
int nsize = 1;
int q, maxq = INT_MIN, minq = INT_MAX;
do {
terraform_region(r, random_terrain_e3(NODIRECTION));
} while (!r->land);
while (r) {
fset(r, RF_MARK);
@ -963,7 +966,6 @@ build_island_e3(short x, short y, int numfactions, int minsize)
get_neighbours(r, rn);
q = region_quality(r, rn);
if (q>=MIN_QUALITY*4/3 && nfactions<numfactions) {
oceans_around(r, rn);
starting_region(r, rn);
minq = MIN(minq, q);
maxq = MAX(maxq, q);

View File

@ -42,7 +42,7 @@ extern int fix_demand(struct region *r);
extern const struct terrain_type * random_terrain(const struct terrain_type * terrains[], int distribution[], int size);
extern int seed_adamantium(struct region * r, int base);
extern int build_island_e3(short x, short y, int numfactions, int minsize);
extern int build_island_e3(int x, int y, int numfactions, int minsize);
#ifdef __cplusplus
}

View File

@ -176,8 +176,8 @@ gm_gate(const tnode * tnext, void * data, struct order * ord)
unit * u = (unit*)data;
const struct plane * p = rplane(u->region);
int id = getid();
short x = rel_to_abs(p, u->faction, (short)getint(), 0);
short y = rel_to_abs(p, u->faction, (short)getint(), 1);
int x = rel_to_abs(p, u->faction, getint(), 0);
int y = rel_to_abs(p, u->faction, getint(), 1);
region * r = findregion(x, y);
building * b = findbuilding(id);
if (b==NULL || r==NULL || p!=rplane(b->region) || p!=rplane(r)) {
@ -208,8 +208,8 @@ gm_terraform(const tnode * tnext, void * data, struct order * ord)
{
unit * u = (unit*)data;
const struct plane * p = rplane(u->region);
short x = rel_to_abs(p, u->faction, (short)getint(), 0);
short y = rel_to_abs(p, u->faction, (short)getint(), 1);
int x = rel_to_abs(p, u->faction, getint(), 0);
int y = rel_to_abs(p, u->faction, getint(), 1);
const char * c = getstrtoken();
region * r = findregion(x, y);
variant token;
@ -240,8 +240,8 @@ gm_teleport(const tnode * tnext, void * data, struct order * ord)
unit * u = (unit*)data;
const struct plane * p = rplane(u->region);
unit * to = findunit(getid());
short x = rel_to_abs(p, u->faction, (short)getint(), 0);
short y = rel_to_abs(p, u->faction, (short)getint(), 1);
int x = rel_to_abs(p, u->faction, getint(), 0);
int y = rel_to_abs(p, u->faction, getint(), 1);
region * r = findregion(x, y);
if (r==NULL || p!=rplane(r)) {
@ -334,8 +334,8 @@ gm_messageregion(const tnode * tnext, void * data, struct order * ord)
{
unit * u = (unit*)data;
const struct plane * p = rplane(u->region);
short x = rel_to_abs(p, u->faction, (short)getint(), 0);
short y = rel_to_abs(p, u->faction, (short)getint(), 1);
int x = rel_to_abs(p, u->faction, getint(), 0);
int y = rel_to_abs(p, u->faction, getint(), 1);
const char * msg = getstrtoken();
region * r = findregion(x, y);
@ -611,22 +611,22 @@ gmcommands(void)
#define EXTENSION 10000
faction *
gm_addquest(const char * email, const char * name, short radius, unsigned int flags)
gm_addquest(const char * email, const char * name, int radius, unsigned int flags)
{
plane * p;
watcher * w = calloc(sizeof(watcher), 1);
region * center;
boolean invalid = false;
short minx, miny, maxx, maxy, cx, cy;
short x;
int minx, miny, maxx, maxy, cx, cy;
int x;
faction * f;
/* GM playfield */
do {
minx = (short)((rng_int() % (2*EXTENSION)) - EXTENSION);
miny = (short)((rng_int() % (2*EXTENSION)) - EXTENSION);
minx = ((rng_int() % (2*EXTENSION)) - EXTENSION);
miny = ((rng_int() % (2*EXTENSION)) - EXTENSION);
for (x=0;!invalid && x<=radius*2;++x) {
short y;
int y;
for (y=0;!invalid && y<=radius*2;++y) {
region * r = findregion(minx+x, miny+y);
if (r) invalid = true;
@ -638,7 +638,7 @@ gm_addquest(const char * email, const char * name, short radius, unsigned int fl
p = create_new_plane(rng_int(), name, minx, maxx, miny, maxy, flags);
center = new_region(cx, cy, 0);
for (x=0;x<=2*radius;++x) {
short y;
int y;
for (y=0;y<=2*radius;++y) {
region * r = findregion(minx+x, miny+y);
if (!r) r = new_region(minx+x, miny+y, 0);
@ -723,20 +723,20 @@ gm_addfaction(const char * email, plane * p, region * r)
}
plane *
gm_addplane(short radius, unsigned int flags, const char * name)
gm_addplane(int radius, unsigned int flags, const char * name)
{
region * center;
plane * p;
boolean invalid = false;
short minx, miny, maxx, maxy, cx, cy;
short x;
int minx, miny, maxx, maxy, cx, cy;
int x;
/* GM playfield */
do {
minx = (short)(rng_int() % (2*EXTENSION)) - EXTENSION;
miny = (short)(rng_int() % (2*EXTENSION)) - EXTENSION;
minx = (rng_int() % (2*EXTENSION)) - EXTENSION;
miny = (rng_int() % (2*EXTENSION)) - EXTENSION;
for (x=0;!invalid && x<=radius*2;++x) {
short y;
int y;
for (y=0;!invalid && y<=radius*2;++y) {
region * r = findregion(minx+x, miny+y);
if (r) invalid = true;
@ -748,7 +748,7 @@ gm_addplane(short radius, unsigned int flags, const char * name)
p = create_new_plane(rng_int(), name, minx, maxx, miny, maxy, flags);
center = new_region(cx, cy, 0);
for (x=0;x<=2*radius;++x) {
short y;
int y;
for (y=0;y<=2*radius;++y) {
region * r = findregion(minx+x, miny+y);
if (!r) r = new_region(minx+x, miny+y, 0);

View File

@ -31,7 +31,7 @@ extern void gmcommands(void);
/* execute commands */
extern struct faction * gm_addfaction(const char * email, struct plane * p, struct region * r);
extern struct plane * gm_addplane(short radius, unsigned int flags, const char * name);
extern struct plane * gm_addplane(int radius, unsigned int flags, const char * name);
/*
* doesn't belong in here:

View File

@ -35,9 +35,9 @@ seed_players(const char * filename, boolean new_island)
}
void
make_block(short x, short y, short radius, const struct terrain_type * terrain)
make_block(int x, int y, int radius, const struct terrain_type * terrain)
{
short cx, cy;
int cx, cy;
region *r;
if (terrain==NULL) return;
@ -55,7 +55,7 @@ make_block(short x, short y, short radius, const struct terrain_type * terrain)
}
void
make_island(short x, short y, int size)
make_island(int x, int y, int size)
{
/* region_list * island; */
}

View File

@ -11,8 +11,8 @@
#ifndef GM_EDITING
#define GM_EDITING
extern void make_block(short x, short y, short radius, const struct terrain_type * terrain);
extern void make_island(short x, short y, int size);
extern void make_block(int x, int y, int radius, const struct terrain_type * terrain);
extern void make_island(int x, int y, int size);
extern void seed_players(const char * filename, boolean new_island);
#endif /* GM_EDITING */

View File

@ -449,7 +449,7 @@ static void
terraform_at(coordinate * c, const terrain_type *terrain)
{
if (terrain!=NULL) {
short x = (short)c->x, y = (short)c->y;
int x = c->x, y = c->y;
region * r = findregion(x, y);
if (r==NULL) r = new_region(x, y, 0);
terraform_region(r, terrain);
@ -466,7 +466,7 @@ terraform_selection(selection * selected, const terrain_type *terrain)
tag ** tp = &selected->tags[i];
while (*tp) {
tag * t = *tp;
short x = (short)t->coord.x, y = (short)t->coord.y;
int x = t->coord.x, y = t->coord.y;
region * r = findregion(x, y);
if (r==NULL) r = new_region(x, y, 0);
terraform_region(r, terrain);
@ -789,17 +789,17 @@ handlekey(state * st, int c)
break;
case 'B':
/*
make_block((short)st->cursor.x, (short)st->cursor.y, 6, select_terrain(st, NULL));
make_block(st->cursor.x, st->cursor.y, 6, select_terrain(st, NULL));
*/
n = rng_int() % 8 + 8;
build_island_e3((short)st->cursor.x, (short)st->cursor.y, n, n*3);
build_island_e3(st->cursor.x, st->cursor.y, n, n*3);
st->modified = 1;
st->wnd_info->update |= 1;
st->wnd_status->update |= 1;
st->wnd_map->update |= 1;
break;
case 0x02: /* CTRL+b */
make_block((short)st->cursor.x, (short)st->cursor.y, 6, newterrain(T_OCEAN));
make_block(st->cursor.x, st->cursor.y, 6, newterrain(T_OCEAN));
st->modified = 1;
st->wnd_info->update |= 1;
st->wnd_status->update |= 1;
@ -1072,7 +1072,7 @@ update_view(view * vi)
mr->coord.x = vi->topleft.x + i - j/2;
mr->coord.y = vi->topleft.y + j;
mr->coord.p = vi->plane;
mr->r = findregion((short)mr->coord.x, (short)mr->coord.y);
mr->r = findregion(mr->coord.x, mr->coord.y);
}
}
}

View File

@ -570,7 +570,7 @@ fix_road_borders(void)
border * b;
for (b=blist;b && fixes!=MAXDEL;b=b->next) {
if (b->type == &bt_road) {
short x1, x2, y1, y2;
int x1, x2, y1, y2;
region *r1, *r2;
x1 = b->from->x;

View File

@ -229,22 +229,22 @@ faction_getorigin(const faction * f, int &x, int &y)
y = 0;
}
}
short
int
faction_getorigin_x(const faction * f) {
return f->ursprung->x;
}
void
faction_setorigin_x(faction * f, short x) {
faction_setorigin_x(faction * f, int x) {
f->ursprung->x = x;
}
static short
static int
faction_getorigin_y(const faction * f) {
return f->ursprung->y;
}
static void
faction_setorigin_y(faction * f, short y) {
faction_setorigin_y(faction * f, int y) {
f->ursprung->y = y;
}

View File

@ -182,7 +182,7 @@ region_getroad(region * r, int dir)
}
static region *
region_terraform(short x, short y, const char * tname)
region_terraform(int x, int y, const char * tname)
{
const terrain_type * terrain = get_terrain(tname);
region * r = findregion(x, y);
@ -238,7 +238,7 @@ plane_remove(int plane_id)
}
void
region_move(region * r, short x, short y)
region_move(region * r, int x, int y)
{
if (findregion(x,y)) {
log_error(("Bei %d, %d gibt es schon eine Region.\n", x, y));

View File

@ -3,8 +3,11 @@
#include "bind_gmtool.h"
#include "../gmtool.h"
#include "../gmtool_structs.h"
#include "../editing.h"
#include <kernel/region.h>
#include <kernel/terrain.h>
#include <modules/autoseed.h>
#include <lua.h>
#include <tolua.h>
@ -77,7 +80,7 @@ tag_advance(tag_iterator * iter)
}
}
if (iter->node) {
iter->r = findregion((short)iter->node->coord.x, (short)iter->node->coord.y);
iter->r = findregion(iter->node->coord.x, iter->node->coord.y);
if (iter->r) {
break;
}
@ -93,7 +96,7 @@ tag_rewind(tag_iterator * iter)
iter->node = iter->list->tags[0];
iter->hash = 0;
if (iter->node) {
iter->r = findregion((short)iter->node->coord.x, (short)iter->node->coord.y);
iter->r = findregion(iter->node->coord.x, iter->node->coord.y);
}
if (!iter->r) {
tag_advance(iter);
@ -149,6 +152,29 @@ tolua_state_close(lua_State* L)
return 0;
}
static int
tolua_make_island(lua_State * L)
{
int x = (int)tolua_tonumber(L, 1, 0);
int y = (int)tolua_tonumber(L, 2, 0);
int n = (int)tolua_tonumber(L, 3, 0);
n = build_island_e3(x, y, n, n*3);
tolua_pushnumber(L, n);
return 1;
}
static int
tolua_make_block(lua_State * L)
{
int x = (int)tolua_tonumber(L, 1, 0);
int y = (int)tolua_tonumber(L, 2, 0);
int r = (int)tolua_tonumber(L, 3, 6);
const char * str = tolua_tostring(L, 4, "ocean");
const struct terrain_type * ter = get_terrain(str);
make_block(x, y, r, ter);
return 0;
}
void
tolua_gmtool_open(lua_State* L)
{
@ -170,6 +196,9 @@ tolua_gmtool_open(lua_State* L)
tolua_function(L, "highlight", tolua_highlight_region);
tolua_function(L, "select", tolua_select_region);
tolua_function(L, "select_at", tolua_select_coordinate);
tolua_function(L, "make_block", &tolua_make_block);
tolua_function(L, "make_island", &tolua_make_island);
}
tolua_endmodule(L);
}

View File

@ -217,8 +217,8 @@ tolua_region_get_objects(lua_State* L)
static int
tolua_region_create(lua_State* L)
{
short x = (short)tolua_tonumber(L, 1, 0);
short y = (short)tolua_tonumber(L, 2, 0);
int x = (int)tolua_tonumber(L, 1, 0);
int y = (int)tolua_tonumber(L, 2, 0);
const char * tname = tolua_tostring(L, 3, 0);
const terrain_type * terrain = get_terrain(tname);

View File

@ -37,6 +37,7 @@ without prior permission by the authors of Eressea.
#include <kernel/faction.h>
#include <kernel/save.h>
#include <gamecode/creport.h>
#include <gamecode/summary.h>
#include <gamecode/laws.h>
#include <gamecode/monster.h>
@ -549,6 +550,14 @@ tolua_free_game(lua_State* L)
return 0;
}
static int
tolua_write_map(lua_State* L)
{
const char * filename = tolua_tostring(L, 1, 0);
crwritemap(filename);
return 0;
}
static int
tolua_write_game(lua_State* L)
{
@ -591,8 +600,8 @@ tolua_get_faction(lua_State* L)
static int
tolua_get_region(lua_State* L)
{
short x = (short)tolua_tonumber(L, 1, 0);
short y = (short)tolua_tonumber(L, 2, 0);
int x = (int)tolua_tonumber(L, 1, 0);
int y = (int)tolua_tonumber(L, 2, 0);
region * r = findregion(x, y);
tolua_pushusertype(L, r, "region");
@ -891,6 +900,7 @@ tolua_eressea_open(lua_State* L)
tolua_function(L, "read_game", tolua_read_game);
tolua_function(L, "write_game", tolua_write_game);
tolua_function(L, "free_game", tolua_free_game);
tolua_function(L, "write_map", &tolua_write_map);
tolua_function(L, "read_orders", tolua_read_orders);
tolua_function(L, "process_orders", tolua_process_orders);

View File

@ -55,7 +55,7 @@
<xi:include href="names-ghouls.xml"/>
<xi:include href="names-dragons.xml"/>
<game name="Aragon" units="500">
<game name="E3" units="500">
<!-- Game specific settings -->
<param name="database.gameid" value="7"></param>