Der Editiermodus für den Mapper (mit 'E').

This commit is contained in:
Enno Rehling 2002-09-26 20:37:49 +00:00
parent 4859d603c4
commit 0336eb2ff3
3 changed files with 32 additions and 12 deletions

View File

@ -94,7 +94,7 @@ blockcoord(int x)
static char newblock[BLOCKSIZE][BLOCKSIZE]; static char newblock[BLOCKSIZE][BLOCKSIZE];
static int g_maxluxuries; static int g_maxluxuries;
static void void
block_create(int x1, int y1, int size, char chaotisch, int special, char terrain) block_create(int x1, int y1, int size, char chaotisch, int special, char terrain)
{ {
int local_climate; int local_climate;
@ -103,9 +103,9 @@ block_create(int x1, int y1, int size, char chaotisch, int special, char terrain
vset_init(&fringe); vset_init(&fringe);
x1 = blockcoord(x1); /* x1 = blockcoord(x1);
y1 = blockcoord(y1); y1 = blockcoord(y1);
local_climate = climate(y1); */ local_climate = climate(y1);
memset(newblock, T_OCEAN, sizeof newblock); memset(newblock, T_OCEAN, sizeof newblock);
x = BLOCKSIZE / 2; x = BLOCKSIZE / 2;
@ -198,9 +198,9 @@ block_create(int x1, int y1, int size, char chaotisch, int special, char terrain
for (x = 0; x != BLOCKSIZE; x++) { for (x = 0; x != BLOCKSIZE; x++) {
for (y = 0; y != BLOCKSIZE; y++) { for (y = 0; y != BLOCKSIZE; y++) {
const luxury_type * sale = (rand()%2)?p1:p2; const luxury_type * sale = (rand()%2)?p1:p2;
r = findregion(x1 + x, y1 + y); r = findregion(x1 + x - BLOCKSIZE/2, y1 + y - BLOCKSIZE/2);
if (r) continue; if (r && r->terrain!=T_OCEAN) continue;
r = new_region(x1 + x, y1 + y); if (r==NULL) r = new_region(x1 + x - BLOCKSIZE/2, y1 + y - BLOCKSIZE/2);
if (chaotisch) fset(r, RF_CHAOTIC); if (chaotisch) fset(r, RF_CHAOTIC);
if (special == 1) { if (special == 1) {
terraform(r, terrain); terraform(r, terrain);
@ -1302,7 +1302,8 @@ Create_Island(region *r, int * n, terrain_t t, int x, int y) {
} }
void void
create_island(region *r, int n, terrain_t t) { create_island(region *r, int n, terrain_t t)
{
int sx=r->x, sy=r->y, i, x = 0, y = 0; int sx=r->x, sy=r->y, i, x = 0, y = 0;
direction_t d; direction_t d;
boolean abbruch=false; boolean abbruch=false;

View File

@ -747,6 +747,7 @@ movearound(int rx, int ry) {
int hx = -1, hy = -1, ch, x, y, Rand, d, a, b, p, q, oldx=0, oldy=0; int hx = -1, hy = -1, ch, x, y, Rand, d, a, b, p, q, oldx=0, oldy=0;
int oldrx=0, oldry=0, Hx=0, Hy=0; int oldrx=0, oldry=0, Hx=0, Hy=0;
int sel; int sel;
static int editmode=0;
char *selc; char *selc;
region *c, *r = NULL, *r2; region *c, *r = NULL, *r2;
tagregion *tag; tagregion *tag;
@ -788,11 +789,28 @@ movearound(int rx, int ry) {
} else } else
#endif #endif
{ {
int edit=0;
ch = getch(); ch = getch();
unmark(x, y, rx, ry); unmark(x, y, rx, ry);
oldx=x; oldy=y; oldrx=rx; oldry=ry; oldx=x; oldy=y; oldrx=rx; oldry=ry;
switch (ch) { if (editmode) {
if (ch=='E') {
editmode=0;
edit=1;
} else {
region * r = findregion(rx, ry);
if (r) {
int terrai = 0;
while (terrai!=MAXTERRAINS && tolower(terrain[terrai].symbol)!=tolower(ch)) ++terrai;
if (terrai!=MAXTERRAINS) {
edit=1;
terraform(r, (terrain_t)terrai);
}
}
}
}
if (!edit) switch (ch) {
case KEY_HELP: case KEY_HELP:
case '?': case '?':
if (reglist) { if (reglist) {
@ -1048,6 +1066,7 @@ movearound(int rx, int ry) {
case 'I': case 'I':
a=map_input(0,0,0,"Wieviele Regionen?",0,500,0); a=map_input(0,0,0,"Wieviele Regionen?",0,500,0);
if (a) { if (a) {
/* block_create(rx, ry, a, 0, 0, T_GLACIER); */
create_island(r, a, (terrain_t)(rand()%(T_GLACIER)+1)); create_island(r, a, (terrain_t)(rand()%(T_GLACIER)+1));
modified=1; modified=1;
} }
@ -1138,10 +1157,9 @@ movearound(int rx, int ry) {
} }
} }
break; break;
case 'E': case 'E':
clipunit = 0; editmode = !editmode;
clipregion = 0; break;
break;
case 'i': case 'i':
case 'r': case 'r':
showregion(r, 1); showregion(r, 1);

View File

@ -121,6 +121,7 @@ typedef struct selection {
struct selection * do_selection(struct selection * sel, const char * title, void (*perform)(struct selection *, void *), void * data); struct selection * do_selection(struct selection * sel, const char * title, void (*perform)(struct selection *, void *), void * data);
struct selection ** push_selection(struct selection ** p_sel, char * str, void * payload); struct selection ** push_selection(struct selection ** p_sel, char * str, void * payload);
void insert_selection(struct selection ** p_sel, struct selection * prev, char * str, void * payload); void insert_selection(struct selection ** p_sel, struct selection * prev, char * str, void * payload);
void block_create(int x1, int y1, int size, char chaotisch, int special, char terrain);
extern void read_newfactions(const char * filename); extern void read_newfactions(const char * filename);
extern void read_orders(const char * filename); extern void read_orders(const char * filename);