mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-20 22:33:43 -04:00
implement list of destroyed items and a way to return them into game
This commit is contained in:
parent
61044d9a60
commit
14d2aef34e
5 changed files with 80 additions and 31 deletions
49
game/inv.c
49
game/inv.c
|
@ -432,7 +432,7 @@ void draw_placed_items_normal(int celx,int cely,int sect,int side)
|
|||
}
|
||||
}
|
||||
|
||||
int count_items_total(short *place)
|
||||
int count_items_total(const short *place)
|
||||
{
|
||||
int c=0;
|
||||
|
||||
|
@ -441,7 +441,7 @@ int count_items_total(short *place)
|
|||
return c;
|
||||
}
|
||||
|
||||
int count_items_visible(short *place)
|
||||
int count_items_visible(const short *place)
|
||||
{
|
||||
int c=0;
|
||||
|
||||
|
@ -455,7 +455,7 @@ int count_items_visible(short *place)
|
|||
}
|
||||
|
||||
|
||||
int count_items_inside(short *place)
|
||||
int count_items_inside(const short *place)
|
||||
{
|
||||
int c=1;
|
||||
|
||||
|
@ -492,30 +492,37 @@ static char ValidateSector(word sector, void *_)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void push_item(int sect,int pos,short *picked_item)
|
||||
void push_to_destroyed_items(const short *picked_items) {
|
||||
int new_count = count_items_total(picked_items);
|
||||
if (new_count == 0) return;
|
||||
int cur_destroyed = count_items_total(destroyed_items);
|
||||
short *nw = NewArr(short, new_count+cur_destroyed+1);
|
||||
for (int i = 0; i < new_count; ++i) {
|
||||
nw[i] = abs(picked_items[i]);
|
||||
}
|
||||
for (int i = 0; i < cur_destroyed; ++i) {
|
||||
nw[new_count+i] = destroyed_items[i];
|
||||
}
|
||||
nw[new_count+cur_destroyed] = 0;
|
||||
free(destroyed_items);
|
||||
destroyed_items = nw;
|
||||
}
|
||||
|
||||
void push_item(int sect,int pos,const short *picked_item)
|
||||
{
|
||||
int bc;
|
||||
int pc;
|
||||
int tc;
|
||||
short *p;
|
||||
char s = map_sectors[sect].sector_type;
|
||||
|
||||
|
||||
if (map_sectors[sect].sector_type==S_DIRA || ISTELEPORTSECT(sect))
|
||||
if (s==S_DIRA || ISTELEPORTSECT(sect) || s == S_SCHODY)
|
||||
sect=map_sectors[sect].sector_tag;
|
||||
if (sect==0 || map_sectors[sect].sector_type==S_VODA)
|
||||
{
|
||||
if (game_extras & EX_RECOVER_DESTROYED_ITEMS)
|
||||
{
|
||||
labyrinth_find_path(viewsector,65535,SD_PLAY_IMPS,ValidateSector,NULL, NULL);
|
||||
push_item(lastsector,viewdir,picked_item);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(picked_item);
|
||||
picked_item=NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (sect==0 || s==S_VODA || s == S_LAVA || s == S_SSMRT) {
|
||||
push_to_destroyed_items(picked_item);
|
||||
return;
|
||||
}
|
||||
sect=(sect<<2)+pos;
|
||||
bc=count_items_total(map_items[sect]);
|
||||
pc=count_items_total(picked_item);
|
||||
|
@ -682,7 +689,7 @@ char pick_item_(int id,int xa,int ya,int xr,int yr)
|
|||
idd=(id+viewdir)&0x3;
|
||||
if (picked_item!=NULL)
|
||||
{
|
||||
if (map_sectors[sect].sector_type==S_DIRA)
|
||||
if (map_sectors[sect].sector_type==S_DIRA)
|
||||
{
|
||||
throw_fly(xa,ya,0);
|
||||
letici_veci->speed=0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue