New level compiler: code changes

This commit is contained in:
Pasi Kallinen
2015-02-18 20:14:40 +02:00
parent 7912a566e5
commit 47bb9abace
14 changed files with 7189 additions and 3776 deletions

View File

@@ -1683,13 +1683,15 @@ buried_ball_to_freedom()
/* move objects from fobj/nexthere lists to buriedobjlist, keeping position */
/* information */
struct obj *
bury_an_obj(otmp)
bury_an_obj(otmp, dealloced)
struct obj *otmp;
boolean *dealloced;
{
struct obj *otmp2;
boolean under_ice;
debugpline1("bury_an_obj: %s", xname(otmp));
if (dealloced) *dealloced = FALSE;
if (otmp == uball) {
unpunish();
u.utrap = rn1(50,20);
@@ -1720,6 +1722,7 @@ bury_an_obj(otmp)
under_ice = is_ice(otmp->ox, otmp->oy);
if (otmp->otyp == ROCK && !under_ice) {
/* merges into burying material */
if (dealloced) *dealloced = TRUE;
obfree(otmp, (struct obj *)0);
return(otmp2);
}
@@ -1754,7 +1757,7 @@ int x, y;
if(level.objects[x][y] != (struct obj *)0)
debugpline2("bury_objs: at <%d,%d>", x, y);
for (otmp = level.objects[x][y]; otmp; otmp = otmp2)
otmp2 = bury_an_obj(otmp);
otmp2 = bury_an_obj(otmp, NULL);
/* don't expect any engravings here, but just in case */
del_engr_at(x, y);
@@ -1814,7 +1817,7 @@ long timeout UNUSED;
/* Everything which can be held in a container can also be
buried, so bury_an_obj's use of obj_extract_self insures
that Has_contents(obj) will eventually become false. */
(void)bury_an_obj(obj->cobj);
(void)bury_an_obj(obj->cobj, NULL);
}
obj_extract_self(obj);
obfree(obj, (struct obj *) 0);

View File

@@ -398,6 +398,20 @@ dist2(x0, y0, x1, y1) /* square of euclidean distance between pair of pts */
return dx * dx + dy * dy;
}
int
isqrt(val)
int val;
{
int rt = 0;
int odd = 1;
while(val >= odd) {
val = val-odd;
odd = odd+2;
rt = rt + 1;
}
return rt;
}
boolean
online2(x0, y0, x1, y1) /* are two points lined up (on a straight line)? */
int x0, y0, x1, y1;

View File

@@ -17,7 +17,6 @@ STATIC_DCL void FDECL(mkgrave,(struct mkroom *));
STATIC_DCL void NDECL(makevtele);
STATIC_DCL void NDECL(clear_level_structures);
STATIC_DCL void NDECL(makelevel);
STATIC_DCL void NDECL(mineralize);
STATIC_DCL boolean FDECL(bydoor,(XCHAR_P,XCHAR_P));
STATIC_DCL struct mkroom *FDECL(find_branch_room, (coord *));
STATIC_DCL struct mkroom *FDECL(pos_to_room, (XCHAR_P, XCHAR_P));
@@ -814,43 +813,50 @@ skip0:
* Place deposits of minerals (gold and misc gems) in the stone
* surrounding the rooms on the map.
* Also place kelp in water.
* mineralize(-1, -1, -1, -1, FALSE); => "default" behaviour
*/
STATIC_OVL void
mineralize()
void
mineralize(kelp_pool, kelp_moat, goldprob, gemprob, skip_lvl_checks)
int kelp_pool, kelp_moat, goldprob, gemprob;
boolean skip_lvl_checks;
{
s_level *sp;
struct obj *otmp;
int goldprob, gemprob, x, y, cnt;
int x, y, cnt;
if (kelp_pool < 0) kelp_pool = 10;
if (kelp_moat < 0) kelp_moat = 30;
/* Place kelp, except on the plane of water */
if (In_endgame(&u.uz)) return;
if (!skip_lvl_checks && In_endgame(&u.uz)) return;
for (x = 2; x < (COLNO - 2); x++)
for (y = 1; y < (ROWNO - 1); y++)
if ((levl[x][y].typ == POOL && !rn2(10)) ||
(levl[x][y].typ == MOAT && !rn2(30)))
if ((kelp_pool && levl[x][y].typ == POOL && !rn2(kelp_pool)) ||
(kelp_moat && levl[x][y].typ == MOAT && !rn2(kelp_moat)))
(void) mksobj_at(KELP_FROND, x, y, TRUE, FALSE);
/* determine if it is even allowed;
almost all special levels are excluded */
if (In_hell(&u.uz) || In_V_tower(&u.uz) ||
if (!skip_lvl_checks && (In_hell(&u.uz) || In_V_tower(&u.uz) ||
Is_rogue_level(&u.uz) ||
level.flags.arboreal ||
((sp = Is_special(&u.uz)) != 0 && !Is_oracle_level(&u.uz)
&& (!In_mines(&u.uz) || sp->flags.town)
)) return;
))) return;
/* basic level-related probabilities */
goldprob = 20 + depth(&u.uz) / 3;
gemprob = goldprob / 4;
if (goldprob < 0) goldprob = 20 + depth(&u.uz) / 3;
if (gemprob < 0) gemprob = goldprob / 4;
/* mines have ***MORE*** goodies - otherwise why mine? */
if (In_mines(&u.uz)) {
goldprob *= 2;
gemprob *= 3;
} else if (In_quest(&u.uz)) {
goldprob /= 4;
gemprob /= 6;
if (!skip_lvl_checks) {
if (In_mines(&u.uz)) {
goldprob *= 2;
gemprob *= 3;
} else if (In_quest(&u.uz)) {
goldprob /= 4;
gemprob /= 6;
}
}
/*
@@ -905,7 +911,7 @@ mklev()
in_mklev = TRUE;
makelevel();
bound_digging();
mineralize();
mineralize(-1, -1, -1, -1, FALSE);
in_mklev = FALSE;
/* has_morgue gets cleared once morgue is entered; graveyard stays
set (graveyard might already be set even when has_morgue is clear

View File

@@ -556,7 +556,7 @@ register const char *s;
#endif
maze0xy(&mm);
walkfrom((int) mm.x, (int) mm.y);
walkfrom((int) mm.x, (int) mm.y, 0);
/* put a boulder at the maze center */
(void) mksobj_at(BOULDER, (int) mm.x, (int) mm.y, TRUE, FALSE);
@@ -644,14 +644,21 @@ register const char *s;
* that is totally safe.
*/
void
walkfrom(x,y)
walkfrom(x,y,typ)
int x,y;
schar typ;
{
#define CELLS (ROWNO * COLNO) / 4 /* a maze cell is 4 squares */
char mazex[CELLS + 1], mazey[CELLS + 1]; /* char's are OK */
int q, a, dir, pos;
int dirs[4];
#ifndef WALLIFIED_MAZE
if (!typ) typ = CORR;
#else
if (!typ) typ = ROOM;
#endif
pos = 1;
mazex[pos] = (char) x;
mazey[pos] = (char) y;
@@ -660,11 +667,7 @@ int x,y;
y = (int) mazey[pos];
if(!IS_DOOR(levl[x][y].typ)) {
/* might still be on edge of MAP, so don't overwrite */
#ifndef WALLIFIED_MAZE
levl[x][y].typ = CORR;
#else
levl[x][y].typ = ROOM;
#endif
levl[x][y].typ = typ;
levl[x][y].flags = 0;
}
q = 0;
@@ -675,11 +678,7 @@ int x,y;
else {
dir = dirs[rn2(q)];
move(&x, &y, dir);
#ifndef WALLIFIED_MAZE
levl[x][y].typ = CORR;
#else
levl[x][y].typ = ROOM;
#endif
levl[x][y].typ = typ;
move(&x, &y, dir);
pos++;
if (pos > CELLS)
@@ -692,19 +691,22 @@ int x,y;
#else
void
walkfrom(x,y)
walkfrom(x,y,typ)
int x,y;
schar typ;
{
register int q,a,dir;
int dirs[4];
#ifndef WALLIFIED_MAZE
if (!typ) typ = CORR;
#else
if (!typ) typ = ROOM;
#endif
if(!IS_DOOR(levl[x][y].typ)) {
/* might still be on edge of MAP, so don't overwrite */
#ifndef WALLIFIED_MAZE
levl[x][y].typ = CORR;
#else
levl[x][y].typ = ROOM;
#endif
levl[x][y].typ = typ;
levl[x][y].flags = 0;
}
@@ -715,13 +717,9 @@ int x,y;
if(!q) return;
dir = dirs[rn2(q)];
move(&x,&y,dir);
#ifndef WALLIFIED_MAZE
levl[x][y].typ = CORR;
#else
levl[x][y].typ = ROOM;
#endif
levl[x][y].typ = typ;
move(&x,&y,dir);
walkfrom(x,y);
walkfrom(x,y,typ);
}
}
#endif /* MICRO */

View File

@@ -278,9 +278,10 @@ unsigned corpseflags;
obj = mkcorpstat(CORPSE, KEEPTRAITS(mtmp) ? mtmp : 0,
mdat, x, y, corpstatflags);
if (burythem) {
(void) bury_an_obj(obj);
boolean dealloc;
(void) bury_an_obj(obj, &dealloc);
newsym(x, y);
return obj;
return (dealloc ? NULL : obj);
}
}
break;

File diff suppressed because it is too large Load Diff

View File

@@ -3535,7 +3535,7 @@ boolean bury_it;
place_object(otmp, ttmp->tx, ttmp->ty);
if (bury_it) {
/* magical digging first disarms this trap, then will unearth it */
(void) bury_an_obj(otmp);
(void) bury_an_obj(otmp, NULL);
} else {
/* Sell your own traps only... */
if (ttmp->madeby_u) sellobj(otmp, ttmp->tx, ttmp->ty);