niches don't need special SD flag

This commit is contained in:
Ondřej Novák 2025-07-12 08:42:30 +02:00
parent 7b6ad6fdcd
commit 6872f8529f
6 changed files with 42 additions and 32 deletions

View file

@ -855,11 +855,9 @@ static int calc_item_shiftup(TITEM *it)
void draw_vyklenek(int celx,int cely,int sector,int dir)
{
int i,j;
TVYKLENEK *v;
TVYKLENEK *v = map_vyk[sector * 4 + dir];
for(i=0;i<vyk_max;i++) if (map_vyk[i].sector==sector && map_vyk[i].dir==dir) break;
if (i==vyk_max) return;
v=map_vyk+i;
if (!v) return ;
for(i=0;(j=v->items[i])!=0;i++)
{
TITEM *it=&glob_items[j-1];
@ -906,8 +904,7 @@ static int draw_basic_sector(int celx, int cely, int sector) {
q->ysec << 1, 0, ghost_walls | (q->flags & tmask));
}
}
if (q->oblouk & 0x10)
draw_vyklenek(celx, cely, sector, dirs[1]);
draw_vyklenek(celx, cely, sector, dirs[1]);
}
if (celx <= 0) {
q = &w[dirs[0]];

View file

@ -34,13 +34,12 @@ char clk_step(int id,int xa,int ya,int xr,int yr)
char clk_touch_vyk(int sector,int side,int xr,int yr)
{
int i;
TVYKLENEK *v;
int i = sector * 4 + side;
TVYKLENEK *v= map_vyk[i];
int x1,y1,x2,y2;
if (picked_item!=NULL && picked_item[1]!=0) return 0;
for(i=0;v=map_vyk+i,i<vyk_max;i++) if (v->sector==sector && v->dir==side) break;
if (i==vyk_max) return 0;
if (!v || (picked_item!=NULL && picked_item[1]!=0)) return 0;
x1=v->xpos-v->xs/2;
x2=v->xpos+v->xs/2;
y1=320-(v->ypos+v->ys);
@ -102,7 +101,7 @@ char clk_touch(int id,int xa,int ya,int xr,int yr)
spell_cast=0;
pick_set_cursor();
id=viewsector*4+viewdir;
if (map_sides[id].oblouk & 0x10) if (clk_touch_vyk(viewsector,viewdir,xr,yr))return 1;
if (clk_touch_vyk(viewsector,viewdir,xr,yr))return 1;
if (map_sides[id].flags & SD_SEC_VIS && map_sides[id].sec!=0)
{
xa=map_sides[id].xsec<<1;

View file

@ -245,20 +245,24 @@ void restore_items(TMPFILE_RD *f)
void save_vyklenky(TMPFILE_WR *fsta)
{
temp_storage_write(&vyk_max,1*sizeof(vyk_max),fsta);
if (vyk_max)
temp_storage_write(map_vyk,vyk_max*sizeof(TVYKLENEK),fsta);
uint16_t cnt =0;
for (int i = 0; i < 4*mapsize; ++i) if (map_vyk[i]) cnt++;
temp_storage_write(&cnt,sizeof(cnt),fsta);
for (int i = 0; i < 4*mapsize; ++i) if (map_vyk[i]) {
temp_storage_write(map_vyk[i],sizeof(TVYKLENEK),fsta);
}
}
int load_vyklenky(TMPFILE_RD *fsta)
{
int i=0;
temp_storage_read(&i,1*sizeof(vyk_max),fsta);
if (vyk_max)
{
if (i>vyk_max) return -2;
temp_storage_read(map_vyk,vyk_max*sizeof(TVYKLENEK),fsta);
}
uint16_t cnt=0;
temp_storage_read(&cnt,sizeof(cnt),fsta);
for (uint32_t i = 0; i < cnt; ++i) {
TVYKLENEK v;
temp_storage_read(&v,sizeof(TVYKLENEK), fsta);
uint32_t pos = v.sector * 4 + v.dir;
if (map_vyk[pos]) *map_vyk[pos] = v;
}
return 0;
}

View file

@ -78,7 +78,7 @@
//extended side flags (oblouky)
#define SD_POSITION 0x60
#define SD_RECESS 0x10 //vyklenek
#define SD_OLD_RECESS 0x10 //vyklenek (not used)
#define SD_ITPUSH 0x80 //vec lze zkrs tuto stenu polozit na dalsi sektor
@ -561,8 +561,7 @@ extern word color_topbar[7];
extern MAPGLOBAL mglob; //globalni informace o levelu
extern TSTENA *map_sides; //popisy jednotlivych sten (map_sides[(sector<<2)+dir])
extern TSECTOR *map_sectors; //popisy sektoru map_sectors[sector]
extern TVYKLENEK *map_vyk; //mapa vyklenku
extern word vyk_max; //pocet vyklenku v mape
extern TVYKLENEK **map_vyk; //mapa vyklenku
extern char *flag_map; //mapa prenasenych flagu
extern TMAP_EDIT_INFO *map_coord; //mapa souradnic a flagu
extern int viewsector; //aktualni sektor vyhledu

View file

@ -754,7 +754,7 @@ char put_item_to_inv(THUMAN *p,short *picked_items)
if (p->inv_size>MAX_INV) p->inv_size=MAX_INV;
if (picked_items==NULL) return 0;
if ((p)) return 0;
if (!can_see_inventory(p)) return 0;
it=*picked_items;
if (it && glob_items[it-1].umisteni==PL_SIP && !neprezbrojit()) {
int u=glob_items[it-1].user_value;if (!u) u=1;

View file

@ -60,8 +60,7 @@ MAPGLOBAL mglob={
};
TSTENA *map_sides;
TSECTOR *map_sectors;
TVYKLENEK *map_vyk; //mapa vyklenku
word vyk_max; //pocet vyklenku v mape
TVYKLENEK **map_vyk; //mapa vyklenku
short **map_items = 0;
short *destroyed_items = 0;;
char *flag_map;
@ -282,6 +281,7 @@ int load_map(const char *filename)
mob_template=NULL;
mob_size=0;
if (f==NULL) return -1;
mapsize = 0;
do
{
uint32_t r=load_section_mem(f,&temp,&sect,&size);
@ -375,9 +375,16 @@ int load_map(const char *filename)
load_macros(size,temp);
break;
case A_MAPVYK:
map_vyk = getmem(size);
memcpy(map_vyk, temp, size);
vyk_max=size/sizeof(TVYKLENEK);
map_vyk = NewArr(TVYKLENEK *, mapsize*4);
memset(map_vyk, 0, sizeof(TVYKLENEK *)*mapsize*4);
for (size_t i = 0, cnt = size/sizeof(TVYKLENEK); i < cnt; ++i) {
TVYKLENEK *x = (TVYKLENEK *)temp + i;
uint32_t pos = x->sector *4 +x->dir;
if (map_vyk[pos]) continue;
TVYKLENEK *y = NewArr(TVYKLENEK, 1);
*y = *x;
map_vyk[pos] = y;
}
break;
case A_MOBS: {
int32_t s = size;
@ -479,7 +486,11 @@ void leave_current_map()
free(map_sectors);
free(flag_map);
free(map_coord);
free(map_vyk);map_vyk=NULL;vyk_max=0;
if (map_vyk) {
for (int i = 0; i < 4*mapsize; ++i) free(map_vyk[i]);
free(map_vyk);
map_vyk=NULL;
}
free_map_description();
while (d_action!=NULL)
{