revision of events

This commit is contained in:
Ondřej Novák 2025-01-27 17:33:59 +01:00
parent 858c4384e8
commit 669f72908e
33 changed files with 661 additions and 382 deletions

View file

@ -216,7 +216,7 @@ static void error(char *text)
sprintf(buff,"%s v odstavci %d\r\nLocal_pgf=%d / DIALOG : %d / SENTENCE : %d\r\n",text,last_pgf+local_pgf,local_pgf,local_pgf/128,last_pgf);
// MessageBox(NULL,buff,NULL,MB_OK|MB_ICONSTOP|MB_SYSTEMMODAL);
SEND_LOG("(DIALOGS) Dialog error detected at %d:%d",local_pgf/128,last_pgf);
SEND_LOG("(DIALOGS) Error description: %s",text,0);
SEND_LOG("(DIALOGS) Error description: %s",text);
}
static void show_dialog_picture()
@ -906,7 +906,7 @@ static void exit_dialog()
norefresh=0;
}
starting_shop=-1;
SEND_LOG("(DIALOGS) Exiting dialog...",0,0);
SEND_LOG("(DIALOGS) Exiting dialog...");
}
@ -955,7 +955,7 @@ char join_character(int i)
THUMAN *s=postavy_2+i;
int j;
SEND_LOG("(DIALOGS) Joining character '%s'",s->jmeno,0);
SEND_LOG("(DIALOGS) Joining character '%s'",s->jmeno);
for(j=0,h=postavy;j<POCET_POSTAV;j++,h++) if (!h->used)
{
memcpy(h,s,sizeof(THUMAN));
@ -966,7 +966,7 @@ char join_character(int i)
bott_draw(1);
return 0;
}
SEND_LOG("(DIALOGS) Join failed - no room for new character",0,0);
SEND_LOG("(DIALOGS) Join failed - no room for new character");
return 1;
}
@ -1335,7 +1335,7 @@ void call_dialog(int entr,int mob)
curcolor=0;
create_back_pic();
bar32(0,SCREEN_OFFLINE,639,SCREEN_OFFLINE+359);
SEND_LOG("(DIALOGS) Starting dialog...",0,0);
SEND_LOG("(DIALOGS) Starting dialog...");
for(i=0;i<POCET_POSTAV;i++) if (isdemon(postavy+i)) unaffect_demon(i);
mute_all_tracks(0);
dialog_mob=mob;
@ -1367,7 +1367,7 @@ char save_dialog_info(TMPFILE_WR *f)
char *c,res=0;
T_PARAGRAPH *q;
SEND_LOG("(DIALOGS)(SAVELOAD) Saving dialogs info...",0,0);
SEND_LOG("(DIALOGS)(SAVELOAD) Saving dialogs info...");
p=ablock(H_DIALOGY_DAT);
pgf_pocet=*p;
temp_storage_write(&pgf_pocet,1*4,f);
@ -1387,7 +1387,7 @@ char save_dialog_info(TMPFILE_WR *f)
free(c);
}
temp_storage_write(_flag_map,1*sizeof(_flag_map),f);
SEND_LOG("(DIALOGS)(SAVELOAD) Done...",0,0);
SEND_LOG("(DIALOGS)(SAVELOAD) Done...");
return res;
}
@ -1399,7 +1399,7 @@ char load_dialog_info(TMPFILE_RD *f)
char *c,res=0;
T_PARAGRAPH *q;
SEND_LOG("(DIALOGS)(SAVELOAD) Loading dialogs info...",0,0);
SEND_LOG("(DIALOGS)(SAVELOAD) Loading dialogs info...");
p=ablock(H_DIALOGY_DAT);
aswap(H_DIALOGY_DAT);
temp_storage_read(&pgf_pocet,1*4,f);
@ -1425,6 +1425,6 @@ char load_dialog_info(TMPFILE_RD *f)
free(c);
}
res|=(temp_storage_read(_flag_map,1*sizeof(_flag_map),f)!=sizeof(_flag_map));
SEND_LOG("(DIALOGS)(SAVELOAD) Done...",0,0);
SEND_LOG("(DIALOGS)(SAVELOAD) Done...");
return res;
}

View file

@ -46,10 +46,10 @@ void save_dump(const uint16_t *screen_addr,
if (dump_counter == -1) {
dump_counter = findMaxDumpNumber(".");
SEND_LOG("(DUMP) Dump counter sets to %d", dump_counter, 0);
SEND_LOG("(DUMP) Dump counter sets to %d", dump_counter);
}
sprintf(c, "dump%04d.bmp", ++dump_counter);
SEND_LOG("(DUMP) Saving screen shot named '%s'", c, 0);
SEND_LOG("(DUMP) Saving screen shot named '%s'", c);
f = fopen(c, "wb");
fputc('B', f);
fputc('M', f);

View file

@ -1249,7 +1249,7 @@ void mob_check_death(int num,TMOB *p)
mob_dostal=0;
bott_draw(0);
if (p->lives>0) return;
SEND_LOG("(GAME) Monster killed ... '%s'",p->name,0);
SEND_LOG("(GAME) Monster killed ... '%s'",p->name);
sect=p->sector;
p->vlajky&=~MOB_IN_BATTLE & ~MOB_LIVE;
free_path(num);

View file

@ -84,7 +84,7 @@ static int unable_open_temp(char *c)
concat(e,d,c);
closemode();
display_error(e);
SEND_LOG("(SAVELOAD) Open temp error detected (%s)",c,0);
SEND_LOG("(SAVELOAD) Open temp error detected (%s)",c);
exit(1);
}
@ -95,7 +95,7 @@ static void unable_write_temp(char *c)
concat(e,d,c);
closemode();
display_error(e);
SEND_LOG("(SAVELOAD) Open temp error detected (%s)",c,0);
SEND_LOG("(SAVELOAD) Open temp error detected (%s)",c);
exit(1);
}
@ -348,7 +348,7 @@ int save_map_state() //uklada stav mapy pro savegame (neuklada aktualni pozici);
restore_sound_names();
strcpy(sta,level_fname);
fsta=temp_storage_create(sta);if (fsta==NULL) unable_open_temp(sta);
SEND_LOG("(SAVELOAD) Saving map state for current map",0,0);
SEND_LOG("(SAVELOAD) Saving map state for current map");
if (load_org_map(level_fname,&org_sides,&org_sectors,NULL,NULL)) goto err;
siz=(mapsize+7)/8;
bf=(char *)getmem(siz);
@ -400,7 +400,7 @@ int save_map_state() //uklada stav mapy pro savegame (neuklada aktualni pozici);
save_enemy_paths(fsta);
res=0;
err:
SEND_LOG("(SAVELOAD) State of current map saved (err:%d)",res,0);
SEND_LOG("(SAVELOAD) State of current map saved (err:%d)",res);
temp_storage_close_wr(fsta);
free(org_sectors);
free(org_sides);
@ -430,7 +430,7 @@ int load_map_state() //obnovuje stav mapy; nutno volat po zavolani load_map;
if (ver>STATE_CUR_VER) goto err;
if (!temp_storage_read(&i,sizeof(mapsize)*1,fsta)) goto err;
if (mapsize!=i) goto err;
SEND_LOG("(SAVELOAD) Loading map state for current map",0,0);
SEND_LOG("(SAVELOAD) Loading map state for current map");
temp_storage_read(&siz,1*sizeof(siz),fsta);
bf=(char *)getmem(siz);
if (!temp_storage_read(bf,siz*1,fsta)) goto err;
@ -483,7 +483,7 @@ int load_map_state() //obnovuje stav mapy; nutno volat po zavolani load_map;
res|=load_all_fly(fsta);
res|=load_enemy_paths(fsta);
err:
SEND_LOG("(SAVELOAD) State of current map loaded (err:%d)",res,0);
SEND_LOG("(SAVELOAD) State of current map loaded (err:%d)",res);
temp_storage_close_rd(fsta);
free(bf);
return res;
@ -493,7 +493,7 @@ void restore_current_map() //pouze obnovuje ulozeny stav aktualni mapy
{
int i;
SEND_LOG("(SAVELOAD) Restore map...",0,0);
SEND_LOG("(SAVELOAD) Restore map...");
kill_all_sounds();
for(i=0;i<mapsize;i++) map_coord[i].flags&=~0x7f; //vynuluj flags_info
free(map_sides); //uvolni informace o stenach
@ -530,7 +530,7 @@ int pack_status_file(FILE *f,const char *status_name)
char *buffer,*c;
unsigned char name_len;
SEND_LOG("(SAVELOAD) Packing status file '%s'",status_name,0);
SEND_LOG("(SAVELOAD) Packing status file '%s'",status_name);
fsz = temp_storage_find(status_name);
if (fsz < 0) return 2;
name_len = (unsigned char)strlen(status_name);
@ -561,7 +561,7 @@ int unpack_status_file(FILE *f)
fread(&namelen, 1,1, f);
if (namelen == 0) return -1;
fread(name, 1, namelen, f);
SEND_LOG("(SAVELOAD) Unpacking status file '%s'",name,0);
SEND_LOG("(SAVELOAD) Unpacking status file '%s'",name);
fread(&fsz,1,4,f);
buffer=(char *)getmem(fsz);
if (fread(buffer,1,fsz,f)!=(unsigned)fsz) return 1;
@ -602,7 +602,7 @@ int save_basic_info()
char res=0;
THUMAN *h;
SEND_LOG("(SAVELOAD) Saving basic info for game (file:%s)",_GAME_ST ,0);
SEND_LOG("(SAVELOAD) Saving basic info for game (file:%s)",_GAME_ST );
f=temp_storage_create(_GAME_ST);
if (f==NULL) return 1;
s.viewsector=viewsector;
@ -646,7 +646,7 @@ int save_basic_info()
temp_storage_write(h->demon_save,sizeof(THUMAN)*1,f); //ulozeni polozek s demony
res|=save_dialog_info(f);
temp_storage_close_wr(f);
SEND_LOG("(SAVELOAD) Done... Result: %d",res,0);
SEND_LOG("(SAVELOAD) Done... Result: %d",res);
return res;
}
@ -659,7 +659,7 @@ int load_basic_info()
TITEM *itg;
THUMAN *h;
SEND_LOG("(SAVELOAD) Loading basic info for game (file:%s)",_GAME_ST,0);
SEND_LOG("(SAVELOAD) Loading basic info for game (file:%s)",_GAME_ST);
f=temp_storage_open(_GAME_ST);
if (f==NULL) return 1;
res|=(temp_storage_read(&s,1*sizeof(s),f)!=sizeof(s));
@ -726,7 +726,7 @@ int load_basic_info()
}
else load_another=0;
for(i=0;i<POCET_POSTAV;i++) postavy[i].dostal=0;
SEND_LOG("(SAVELOAD) Done... Result: %d",res,0);
SEND_LOG("(SAVELOAD) Done... Result: %d",res);
return res;
}
@ -766,7 +766,7 @@ int save_game(int slotnum,char *gamename)
FILE *svf;
int r;
SEND_LOG("(SAVELOAD) Saving game slot %d",slotnum,0);
SEND_LOG("(SAVELOAD) Saving game slot %d",slotnum);
save_map_state();
concat(sn,pathtable[SR_SAVES],_SLOT_SAV);
MakeSaveGameDir(pathtable[SR_SAVES]);
@ -793,7 +793,7 @@ int save_game(int slotnum,char *gamename)
open_story_file();
fclose(svf);
}
SEND_LOG("(SAVELOAD) Game saved.... Result %d",r,0);
SEND_LOG("(SAVELOAD) Game saved.... Result %d",r);
disable_intro();
return r;
}
@ -806,7 +806,7 @@ int load_game(int slotnum)
FILE *svf;
int r,t;
SEND_LOG("(SAVELOAD) Loading game slot %d",slotnum,0);
SEND_LOG("(SAVELOAD) Loading game slot %d",slotnum);
if (battle) konec_kola();
battle=0;
close_story_file();
@ -822,7 +822,7 @@ int load_game(int slotnum)
open_story_file();
if (r>0)
{
SEND_LOG("(ERROR) Error detected during unpacking game... Loading stopped (result:%d)",r,0);
SEND_LOG("(ERROR) Error detected during unpacking game... Loading stopped (result:%d)",r);
return r;
}
load_book();
@ -838,7 +838,7 @@ int load_game(int slotnum)
norefresh=1;
}
for(t=0;t<POCET_POSTAV;t++) postavy[t].zvolene_akce=NULL;
SEND_LOG("(SAVELOAD) Game loaded.... Result %d",r,0);
SEND_LOG("(SAVELOAD) Game loaded.... Result %d",r);
// if (GetKeyState(VK_CONTROL) & 0x80) correct_level();
return r;
}
@ -1422,7 +1422,7 @@ void open_story_file()
{
story=temp_storage_append(STORY_BOOK);
SEND_LOG("(STORY) Story temp file is opened....",0,0);
SEND_LOG("(STORY) Story temp file is opened....");
}
@ -1437,7 +1437,7 @@ void close_story_file()
{
if (story!=NULL) temp_storage_close_wr(story);
story=NULL;
SEND_LOG("(STORY) Story temp file is closed...",0,0);
SEND_LOG("(STORY) Story temp file is closed...");
}
static int load_map_state_partial(char *level_fname,int mapsize) //obnovuje stav mapy; castecne

View file

@ -248,7 +248,7 @@ void message_keyboard(EVENT_MSG *msg,void **user_ptr)
case E_DONE:c = *user_ptr;
free(c);
user_ptr = NULL;
*user_ptr = NULL;
break;
case E_KEYBOARD:
{
@ -274,7 +274,6 @@ void message_keyboard(EVENT_MSG *msg,void **user_ptr)
int message(int butts,char def,char canc,char *keys,...)
{
char **texty;
int id;
void *clksav;int clksav2;
@ -284,8 +283,13 @@ int message(int butts,char def,char canc,char *keys,...)
unwire_proc();
save_click_map(&clksav,&clksav2);
change_click_map(NULL,0);
texty=(char **)(&keys+1);
open_message_win(butts+1,texty);
va_list args;
va_start(args, keys);
char **texts = (char **)alloca((butts+1)*sizeof(char *));
for (int i = 0; i < butts+1; ++i) {
texts[i] = va_arg(args,char *);
}
open_message_win(butts+1,texts);
send_message(E_ADD,E_KEYBOARD,message_keyboard,keys);
escape();
id=o_aktual->id;
@ -1393,7 +1397,7 @@ int load_string_list_ex(TSTR_LIST *list,char *filename)
if (j==';') while ((j=temp_storage_getc(f))!='\n' && j!=EOF);
if (j=='\n') lin++;
}
while (j=='\n');
while (j=='\n' || j == '\r');
temp_storage_ungetc(f);
j=temp_storage_scanf(f,"%d",&i);
if (j==EOF)
@ -1414,7 +1418,12 @@ int load_string_list_ex(TSTR_LIST *list,char *filename)
enc_close(f);
return lin;
}
p=strchr(c,'\n');if (p!=NULL) *p=0;
p=strchr(c,0);
while (p > c && isspace(p[-1])) {
--p;
*p = 0;
}
for(p=c;*p;p++) *p=*p=='|'?'\n':*p;
if (str_replace(list,i,c)==NULL)
{

View file

@ -1103,7 +1103,7 @@ void real_regeneration()
if (sleep_ticks>MAX_SLEEP) sleep_ticks=MAX_SLEEP;
tick_tack(1);
TimerEvents(viewsector,viewdir,game_time);
SEND_LOG("(GAME) Tick Tack, Game time: %d",game_time,0);
SEND_LOG("(GAME) Tick Tack, Game time: %d",game_time);
GlobEvent(MAGLOB_ONROUND,viewsector,viewdir);
bott_draw(0);
}
@ -2263,7 +2263,7 @@ void build_fly_map()
if (!counter)
SEND_LOG("(FLY) Fly_map was reduced - capacity: %d flies in game / was: %d",fly_count,fly_map_size);
else
SEND_LOG("(FLY) Fly_map was expanded - capacity: %d flies in game ",fly_count,fly_map_size);
SEND_LOG("(FLY) Fly_map was expanded - capacity: %d flies in game / was: %d",fly_count,fly_map_size);
counter=1000;
fly_map_size=fly_count;
}
@ -2416,26 +2416,70 @@ static void shop_mouse_event(EVENT_MSG *msg,void **unused)
}
}
}
static __inline void copy_data(char **src, void *target, int size) {
memcpy(target, *src, size);
(*src)+=size;
}
static char * load_TSHOP(char *binary, TSHOP *target) {
copy_data(&binary, target->keeper, 16);
copy_data(&binary, target->picture, 13);
copy_data(&binary, &target->koef, 4);
copy_data(&binary, &target->products, 4);
copy_data(&binary, &target->shop_id, 4);
copy_data(&binary, &target->list_size, 4);
copy_data(&binary, &target->spec_max, 2);
copy_data(&binary, &target->list, 4);
return binary;
}
static char * load_TPRODUCT(char *binary, TPRODUCT *target) {
copy_data(&binary, &target->item, 2);
copy_data(&binary, &target->cena, 4);
copy_data(&binary, &target->trade_flags, 2);
copy_data(&binary, &target->pocet, 4);
copy_data(&binary, &target->max_pocet, 4);
return binary;
}
static void rebuild_shops(void)
{
char *c=(char *)shop_hacek;
int i;
SEND_LOG("(SHOP) Rebuilding shops....",0,0);
SEND_LOG("(SHOP) Rebuilding shops....");
if (shop_list!=NULL) free(shop_list);
shop_list=NewArr(TSHOP *,max_shops);
c+=4;
for(i=0;i<max_shops;i++)
{
TSHOP *p;
char *d = c;
size_t reqsize = 0;
for(i=0;i<max_shops;i++) {
TSHOP s;
d = load_TSHOP(d, &s);
reqsize += sizeof(TSHOP);
for (int j = 0; j < s.products; ++j) {
TPRODUCT p;
d = load_TPRODUCT(d, &p);
reqsize += sizeof(TPRODUCT);
}
}
char *newhacek = getmem(reqsize);
TPRODUCT *products = (TPRODUCT *)(newhacek+max_shops*sizeof(TSHOP));
TSHOP *shops = (TSHOP *)newhacek;
for(i=0;i<max_shops;i++) {
c = load_TSHOP(c, shops+i);
shops[i].list = products;
for (int j = 0; j < shops[i].products; ++j) {
c = load_TPRODUCT(c, products);
products++;
}
shop_list[i] = shops+i;
SEND_LOG("(SHOP) Shop found: '%s', products %d",shops[i].keeper,shops[i].products);
}
free(shop_hacek);
shop_hacek = newhacek;
shop_list[i]=(TSHOP *)c;
p=shop_list[i];
c+=sizeof(TSHOP);
p->list=(TPRODUCT *)c;
c+=p->products*sizeof(TPRODUCT);
SEND_LOG("(SHOP) Shop found: '%s'",p->keeper,0);
}
}
void load_shops(void)
@ -2844,7 +2888,7 @@ void enter_shop(int shopid)
{
int i;
SEND_LOG("(SHOP) Entering shop...",0,0);
SEND_LOG("(SHOP) Entering shop...");
for(i=0;i<POCET_POSTAV;i++) if (isdemon(postavy+i)) unaffect_demon(i);
for(i=0;i<POCET_POSTAV && postavy[i].sektor!=viewsector;i++);
if (i==POCET_POSTAV) return; //nesmysl, nemelo by nikdy nastat.
@ -2922,7 +2966,7 @@ char shop_change_player(int id, int xa, int ya,int xr,int yr)
char _exit_shop(int id, int xa, int ya,int xr,int yr)
{
xr,yr,xa,ya,id;
SEND_LOG("(SHOP) Exiting shop...",0,0);
SEND_LOG("(SHOP) Exiting shop...");
if (cur_owner==-1)
{
free(picked_item);
@ -2941,7 +2985,7 @@ static void reroll_shop(TSHOP *p)
int poc_spec=0;
TPRODUCT *pr;
SEND_LOG("(SHOP) Shops reroll: '%s' ",p->keeper,0);
SEND_LOG("(SHOP) Shops reroll: '%s' ",p->keeper);
pr=p->list;
for(i=0;i<p->list_size;i++,pr++)
{
@ -2973,7 +3017,7 @@ char save_shops()
TMPFILE_WR *f;
int res=0;
SEND_LOG("(SHOP) Saving shops...",0,0);
SEND_LOG("(SHOP) Saving shops...");
if (max_shops==0 || shop_hacek==NULL) return 0;
f = temp_storage_create(_SHOP_ST);
if (f==NULL) return 1;
@ -2991,7 +3035,7 @@ char load_saved_shops()
int res=0;
int i=0,j=0;
SEND_LOG("(SHOP) Loading saved shops...",0,0);
SEND_LOG("(SHOP) Loading saved shops...");
f=temp_storage_open(_SHOP_ST);
if (f==NULL) return 0;
temp_storage_read(&i,1*sizeof(max_shops),f);

View file

@ -190,10 +190,10 @@ static void play_anim(va_list args) //tasked animation
if (running_anm)
{
SEND_LOG("(ERROR)(ANIM) Animation's mutex is already in use!",0,0);
SEND_LOG("(ERROR)(ANIM) Animation's mutex is already in use!");
return;
}
SEND_LOG("(ANIM) Running animation number %xh",block,0);
anim_render_buffer=getmem(ANIM_SIZE);
mgif_install_proc(animace_kouzla);
running_anm=1;
@ -202,7 +202,7 @@ static void play_anim(va_list args) //tasked animation
alock(block);
anm=open_mgif(ablock(block));
c=0;
SEND_LOG("(ANIM) Buffer is now ready...",0,0);
SEND_LOG("(ANIM) Buffer is now ready...");
while (anm!=NULL)
{
task_wait_event(E_KOUZLO_ANM);
@ -215,7 +215,7 @@ static void play_anim(va_list args) //tasked animation
close_mgif();
running_anm=0;
free(anim_render_buffer);
SEND_LOG("(ANIM) Closing animation %xh",block,0);
aunlock(block);
}
@ -617,7 +617,7 @@ static void unaffect_after_demon(int cil)
char a;
TKOUZLO *spl;
SEND_LOG("(SPELLS) Unaffecting after demon...",0,0);
SEND_LOG("(SPELLS) Unaffecting after demon...");
do
{
a=0;
@ -657,7 +657,7 @@ void spell_end(int num,int ccil,int owner)
unaffect_after_demon(ccil);
zmena_demona(cil,owner,0);
_flag_map[num]&=~SPL_DEMON;
SEND_LOG("(SPELLS) Spell 'Demon' has ended...",0,0);
SEND_LOG("(SPELLS) Spell 'Demon' has ended...");
}
postavy[cil].stare_vls[VLS_KOUZLA]&=~_flag_map[num];
if (cil>=0 && cil<POCET_POSTAV)
@ -682,7 +682,7 @@ void spell_end(int num,int ccil,int owner)
l=_flag_map[num];
_flag_map[num]=0;
if (l>0xffff) spell_end_global();
SEND_LOG("(SPELLS) Spell ID %d ends.",num,0);
}
static void spell_demon(int num,TKOUZLO *spl,int cil,int demon)
@ -1394,7 +1394,7 @@ void call_spell(int i)
unsigned char ext=0;
int cil;
SEND_LOG("(SPELLS) Calculating spell ID: %d",i,0);
p=spell_table[i];
if (p==NULL) return;
cil=p->cil;
@ -1485,7 +1485,7 @@ int add_spell(int num,int cil,int owner,char noanim)
int accnum;
char time_acc=1;
SEND_LOG("(SPELLS) Casting spell number %d",num,0);
alock(H_KOUZLA);
q=(TKOUZLO *)ablock(H_KOUZLA)+num;
accnum=q->accnum;
@ -1500,7 +1500,7 @@ int add_spell(int num,int cil,int owner,char noanim)
if (i==MAX_SPELLS) i=nl;
if (i==-1)
{
SEND_LOG("(ERROR) Too many spells in game!",0,0);
SEND_LOG("(ERROR) Too many spells in game!");
return -1;
}
if (spell_table[i]!=NULL)
@ -1636,7 +1636,7 @@ void cast(int num,THUMAN *p,int owner, char backfire)
SEND_LOG("(SPELLS) Cast num %d cil %d",num2,cil);
k=((TKOUZLO *)ablock(H_KOUZLA))+num2;
SEND_LOG("(SPELLS) Cast spell name %s",k->spellname,0);
if (cil>0 && k->cil!=C_postava_jinde)
{
@ -1711,7 +1711,7 @@ void cast(int num,THUMAN *p,int owner, char backfire)
if (p->mana>p->mana_battery)
{
if (p->mana_battery>=0)p->mana=p->mana_battery;
else SEND_LOG("(ERROR) Mana battery error on character %d",p-postavy,0);
else
p->mana_battery=32767;
}
end:
@ -1821,7 +1821,7 @@ void area_cast(int num,int sector,int owner,char noanim)
void kouzla_init()
{
SEND_LOG("(SPELLS) Init...",0,0);
SEND_LOG("(SPELLS) Init...");
send_message(E_ADD,E_KOUZLO_ANM,kouzla_anm);
send_message(E_ADD,E_KOUZLO_KOLO,kouzla_kola);
memset(spell_table,0,sizeof(spell_table));
@ -1837,7 +1837,7 @@ void reinit_kouzla_full()
{
int i;
SEND_LOG("(SPELLS) Reinit...",0,0);
SEND_LOG("(SPELLS) Reinit...");
for(i=0;i<MAX_SPELLS;i++) if (spell_table[i]!=NULL) free(spell_table[i]);
for(i=0;i<MAX_SPELLS;i++) if (vls_table[i]!=NULL) free(vls_table[i]);
memset(spell_table,0,sizeof(spell_table));
@ -1854,7 +1854,7 @@ void remove_all_mob_spells()
int i;
char a;
SEND_LOG("(SPELLS) Removing spells from enemies...",0,0);
SEND_LOG("(SPELLS) Removing spells from enemies...");
do
{
a=0;
@ -1882,7 +1882,7 @@ int save_spells(TMPFILE_WR *f)
{
int i,s;
SEND_LOG("(SPELLS) Saving spell table...",0,0);
SEND_LOG("(SPELLS) Saving spell table...");
for(i=0,s=0;i<MAX_SPELLS;i++)
if (spell_table[i]!=NULL) s++;
temp_storage_write(&s,1*sizeof(s),f);
@ -1902,7 +1902,7 @@ int load_spells(TMPFILE_RD *f)
int i,s;
SEND_LOG("(SPELLS) Loading saved spell table...",0,0);
SEND_LOG("(SPELLS) Loading saved spell table...");
reinit_kouzla_full();
res|=(temp_storage_read(&s,1*sizeof(s),f)!=sizeof(s));
for(i=0;i<s && !res;i++)
@ -1926,7 +1926,7 @@ void unaffect()
int i;
char a;
SEND_LOG("(WIZARD) Unaffect / dispel_magic",0,0);
SEND_LOG("(WIZARD) Unaffect / dispel_magic");
do
{
a=0;
@ -1948,7 +1948,7 @@ void unaffect()
}
while(a);
SEND_LOG("(WIZARD) Unaffect... done",0,0);
SEND_LOG("(WIZARD) Unaffect... done");
}
void unaffect_demon(int cil)
@ -1959,7 +1959,7 @@ void unaffect_demon(int cil)
cil++;
SEND_LOG("(SPELLS) Demon returns to astral spaces...",0,0);
SEND_LOG("(SPELLS) Demon returns to astral spaces...");
for(i=0;spl=spell_table[i],i<MAX_SPELLS;i++) if (spl!=NULL && _flag_map[i] & SPL_DEMON && spl->cil==cil)
{
while (spell_table[i]!=NULL)

View file

@ -365,9 +365,8 @@ int enter_menu(char open)
char *get_next_title(signed char control,char *filename)
{
/*
static TMPFILE_RD *titles=NULL;
static ENCFILE fl;
static TMPFILE_RD *titles=NULL;
static char buffer[81];
char *path,*c;
@ -389,13 +388,12 @@ char *get_next_title(signed char control,char *filename)
}
}
return (char *)titles;
case 0:if (titles!=NULL)fgets(buffer,80,titles);
case 0:if (titles!=NULL)temp_storage_gets(buffer,80,titles);
c=strchr(buffer,'\n');if (c!=NULL) *c=0;
return buffer;
case -1:if (titles!=NULL)enc_close(&fl);
case -1:if (titles!=NULL)enc_close(titles);
break;
}
*/
return NULL;
}

View file

@ -230,7 +230,7 @@ int load_map(char *filename)
if (level_fname!=NULL) free(level_fname);
level_fname=(char *)getmem(strlen(filename)+1);
strcpy(level_fname,filename);
SEND_LOG("(GAME) Loading map: '%s'",level_fname,0);
SEND_LOG("(GAME) Loading map: '%s'",level_fname);
strupr(level_fname);
mob_template=NULL;
mob_size=0;
@ -303,13 +303,13 @@ int load_map(char *filename)
back_color=RGB888(mglob.fade_r,mglob.fade_g,mglob.fade_b);
break;
case A_MAPITEM:
SEND_LOG("(GAME) Loading items...",0,0);
SEND_LOG("(GAME) Loading items...");
load_item_map(temp,size);
free(temp);
break;
case A_MAPMOBS:
if (snd_load==0) create_sound_table_old();
SEND_LOG("(GAME) Loading enemies...",0,0);
SEND_LOG("(GAME) Loading enemies...");
if (mob_template==NULL)
{
int32_t h;char *p;
@ -324,12 +324,12 @@ int load_map(char *filename)
{
load_enemies(temp,size,&ofsts,mob_template,mob_size);
free(mob_template);
SEND_LOG("(GAME) Loading enemies from map template...",0,0);
SEND_LOG("(GAME) Loading enemies from map template...");
}
free(temp);
break;
case A_MAPMACR:
SEND_LOG("(GAME) Loading multiactions...",0,0);
SEND_LOG("(GAME) Loading multiactions...");
load_macros(size,temp);
break;
case A_MAPVYK:
@ -413,7 +413,7 @@ void leave_current_map()
{
int i;
TFLY *p;
SEND_LOG("(GAME) Leaving current map ... start",0,0);
SEND_LOG("(GAME) Leaving current map ... start");
add_leaving_place(viewsector);
kill_all_sounds();
restore_sound_names();
@ -1411,7 +1411,7 @@ void real_krok(EVENT_MSG *msg,void **data)
if (msg->msg==E_INIT || msg->msg==E_DONE) return;
check_all_mobs();
calc_game();msg;data;
SEND_LOG("(GAME) STEP",0,0);
SEND_LOG("(GAME) STEP");
}
void do_halucinace()

View file

@ -97,7 +97,7 @@ static void wire_setup()
mute_all_tracks(0);
cur_mode=MD_SETUP;
send_message(E_ADD,E_KEYBOARD,setup_keyboard);
SEND_LOG("(GAME) Starting setup",0,0);
SEND_LOG("(GAME) Starting setup");
}
static void unwire_setup()
@ -113,7 +113,7 @@ static void unwire_setup()
send_message(E_DONE,E_KEYBOARD,setup_keyboard);
wire_proc();
cancel_render=1;
SEND_LOG("(GAME) Setup closed",0,0);
SEND_LOG("(GAME) Setup closed");
}
char exit_setup(int id,int xa,int ya,int xr,int yr)

View file

@ -92,7 +92,7 @@ TMA_LOADLEV loadlevel;
typedef struct inis
{
char heslo[25];
char heslo[50];
char parmtype;
}INIS;
@ -321,29 +321,29 @@ int set_video(int mode)
{
case 1:er=initmode256(cur_xlat);
if (banking) report_mode(5); else report_mode(2);
SEND_LOG("(GAME) Video changed to 256 colors %s",banking?"Bank":"LFB",0);
break;
case 2:er=initmode32();
if (banking) report_mode(4); else report_mode(1);
SEND_LOG("(GAME) Video changed to HIcolor %s",banking?"Bank":"LFB",0);
break;
case 0:er=initmode_lo(cur_xlat);
report_mode(3);
SEND_LOG("(GAME) Video changed to 256 VGA comp. ",0,0);
break;
case 3: free(cur_xlat);cur_xlat=create_blw_palette16();
er=initmode16(cur_xlat);
SEND_LOG("(GAME) Video changed to 16 grayscale",0,0);
report_mode(3);
break;
case 4:er=init_empty_mode();
report_mode(3);
SEND_LOG("(GAME) Video changed to <empty>",0,0);
break;
case 5:free(cur_xlat);cur_xlat=create_hixlat();
er=initmode64(cur_xlat);
if (banking) report_mode(7); else report_mode(6);
SEND_LOG("(GAME) Video changed to HIcolor64 %s",banking?"Bank":"LFB",0);
break;
default:er=-1;
@ -542,18 +542,18 @@ void music_init(void)
// char *path;
/* if (sound_detection)
{
SEND_LOG("(SOUND) SOUND_DETECT Detecting sound card",0,0);
if (sound_detect(&snd_devnum,&snd_parm1,&snd_parm2,&snd_parm3)) snd_devnum=DEV_NOSOUND;
}*/
SEND_LOG("(SOUND) SOUND_SET Setting Sound: Device '%s' Port: %3X",device_name(snd_devnum),snd_parm1);
SEND_LOG("(SOUND) SOUND_SET Setting Sound: IRQ: %X DMA: %X",snd_parm2,snd_parm3);
set_mixing_device(snd_devnum,snd_mixing,snd_parm1,snd_parm2,snd_parm3);
SEND_LOG("(SOUND) SOUND_INIT Starting mixing",0,0);
start_mixing();
set_snd_effect(SND_GFX,init_gfx_vol);
set_snd_effect(SND_MUSIC,init_music_vol);
// path=plugins_path;
SEND_LOG("(SOUND) SOUND_DONE Sound Engine should work now",0,0);
}
@ -608,16 +608,17 @@ void *timming(EVENT_MSG *msg,void **data)
p=q->next;
q->zavora=1;
q->counter=q->count_max;
if (q->calls!=-1)
if (q->calls!=-1) {
if (--q->calls<1)
{
for(p=&timer_tree;p->next!=q;p=p->next);
p->next=q->next;
#ifdef LOGFILE
if (q->next==NULL)
SEND_LOG("(TIMER) Self remove for timer id: %d, next-><NULL>",q->id,0);
else
if (q->next==NULL) {
} else {
SEND_LOG("(TIMER) Self remove for timer id: %d, next->%d",q->id,q->next->id);
}
#endif
free(q);
q=p;
@ -625,6 +626,7 @@ void *timming(EVENT_MSG *msg,void **data)
//else
// q->counter=1;
}
}
else {
q->counter=1;
}
@ -632,7 +634,7 @@ void *timming(EVENT_MSG *msg,void **data)
if (q->next!=p && q!=p)
{
THE_TIMER *z;
SEND_LOG("(TIMER) Timer integrity corrupted",0,0);
z=&timer_tree;while(z->next!=p && z->next!=NULL) z=z->next;
if (z->next==NULL) return NULL;
}
@ -655,10 +657,11 @@ void delete_from_timer(int id)
if (q->zavora)
{
#ifdef LOGFILE
if (q->next==NULL)
SEND_LOG("(TIMER) Removing timer id: %d, next-><NULL>",id,0);
else
if (q->next==NULL) {
}else {
SEND_LOG("(TIMER) Removing timer id: %d, next->%d",id,q->next->id);
}
#endif
p->next=q->next;
free(q);
@ -666,7 +669,7 @@ void delete_from_timer(int id)
}
else
{
SEND_LOG("(TIMER) Can't remove timer! id: %d. Currently in use.",id,0);
q->calls=-2;
q->counter=1;
}
@ -757,7 +760,7 @@ void do_timer(void)
void done_skeldal(void)
{
SEND_LOG("(GAME) Video returned to textmode",0,0);
close_manager();
close_story_file();
purge_temps(1);
@ -766,7 +769,7 @@ void done_skeldal(void)
if (texty!=NULL) release_list(texty);texty=NULL;
if (cur_config!=NULL) release_list(cur_config);cur_config=NULL;
kill_timer();
SEND_LOG("NORMAL TERMINATING--------------------------",0,0);
}
@ -878,11 +881,11 @@ void error_exception(EVENT_MSG *msg,void **unused)
if (msg->msg==E_PRGERROR)
{
unused;
SEND_LOG("(ERROR) Runtime error detected ... Game terminator lunched.",0,0);
SEND_LOG("(ERROR) Log: Now dump of useful informations:",0,0);
SEND_LOG("(ERROR) Log: Map name '%s'",level_fname==NULL?"<NULL>":level_fname,0);
SEND_LOG("(ERROR) Log: Sector %d Direction %d",viewsector,viewdir);
SEND_LOG("(ERROR) Log: Last 'memman' handle: %x",memman_handle,0);
SEND_LOG("(ERROR) Log: Battle: %d Select_player %d",battle,select_player);
closemode();
printf("Program zp<7A>sobil b<>hovou chybu a bude ukon<6F>en\n"
@ -899,7 +902,7 @@ void error_exception(EVENT_MSG *msg,void **unused)
void swap_error_exception(void)
{
closemode();
SEND_LOG("(ERROR) Disk is full ...",0,0);
puts("Program jiz nema kam odkladat, protoze disk s odkladacim souborem byl \n"
"zaplnen. Uvolnete prosim nejake misto na odkladacim disku, nebo zmente \n"
"adresar odkladani na jednotku, kde je vice mista");
@ -970,78 +973,78 @@ void init_skeldal(void)
int verr;
boldcz=LoadDefaultFont();
SEND_LOG("(INIT) Reading texts.",0,0);
cti_texty();
timer_tree.next=NULL;
SEND_LOG("(INIT) Setting random seed.",0,0);
srand(clock());
SEND_LOG("(INIT) Creating 256 color palette.",0,0);
cur_xlat=create_special_palette();
SEND_LOG("(INIT) Init message system - event handler",0,0);
init_events();
SEND_LOG("(INIT) Setting videomode.",0,0);
verr=set_video(vmode);
if (verr)
{
exit(ERR_GENERAL);
}
SEND_LOG("(INIT) Initializing engine.",0,0);
general_engine_init();
atexit(done_skeldal);
/*SEND_LOG("(INIT) Loading DOS error handler.",0,0);
/*
install_dos_error(device_error,(char *)getmem(4096)+4096);*/
swap_error=swap_error_exception;
snprintf(d,sizeof(d),"%s%s",pathtable[SR_DATA],"skeldal.ddl");
SEND_LOG("(INIT) Initializing memory manager",0,0);
snprintf(d,sizeof(d),"%s%s",pathtable[SR_DATA],"SKELDAL.DDL");
init_manager(d,c);
SEND_LOG("(GAME) Memory manager initialized. Using DDL: '%s' Temp dir: '%s'",d,c);
texty_knihy=find_map_path("kniha.txt");
SEND_LOG("(INIT) Installing GUI",0,0);
install_gui();
SEND_LOG("(INIT) Attaching patch.",0,0);
if (patch_file!=NULL) patch_error(add_patch_file(patch_file));
SEND_LOG("(INIT) Registring basic data.",0,0);
register_basic_data();
SEND_LOG("(INIT) Timer event handler.",0,0);
send_message(E_DONE,E_WATCH,timer);
send_message(E_DONE,E_IDLE,redraw_desktop_call);
send_message(E_ADD,E_TIMER,timming);
SEND_LOG("(INIT) User timer.",0,0);
send_message(E_ADD,E_WATCH,user_timer);
SEND_LOG("(INIT) Mouse clicking maps.",0,0);
send_message(E_ADD,E_MOUSE,ms_clicker);
SEND_LOG("(INIT) Global keyboard event handler.",0,0);
send_message(E_ADD,E_KEYBOARD,global_kbd);
SEND_LOG("(INIT) Error exception event handler.",0,0);
send_message(E_ADD,E_PRGERROR,error_exception);
SEND_LOG("(INIT) Wizard handler.",0,0);
if (debug_enabled) install_wizard();
SEND_LOG("(INIT) Background music timer.",0,0);
add_to_timer(TM_BACK_MUSIC,5,-1,back_music);
SEND_LOG("(INIT) Creating game window.",0,0);
add_game_window();
SEND_LOG("(INIT) Music.",0,0);
music_init();
SEND_LOG("(INIT) Mouse interrupt handler.",0,0);
if ((verr=init_mysky())!=0)
{
closemode();
puts(texty[174-verr]);
SEND_LOG("(ERROR) %s (%d)",texty[174-verr],verr);
SEND_LOG("(ERROR) Mouse not found, shutting down.",0,0);
exit(0);
}
SEND_LOG("(INIT) Mouse initialized.",0,0);
// hranice_mysky(0,0,639,479);
SEND_LOG("(INIT) Loading mouse cursor.",0,0);
mouse_set_default(H_MS_DEFAULT);
ukaz_mysku();
set_end_of_song_callback(end_of_song_callback, NULL);
SEND_LOG("(INIT) Loading spells.",0,0);
kouzla_init();
SEND_LOG("(INIT) Loading items.",0,0);
load_items();
SEND_LOG("(INIT) Loading shops.",0,0);
load_shops();
SetWheelMapping('H','P');
}
@ -1049,7 +1052,7 @@ SEND_LOG("(INIT) Loading shops.",0,0);
void wire_main_functs();
void unwire_main_functs(void)
{
SEND_LOG("(SYS) Wire main functions",0,0);
delete_from_timer(TM_FLY);
delete_from_timer(TM_SCENE);
delete_from_timer(TM_REGEN);
@ -1063,7 +1066,7 @@ void unwire_main_functs(void)
void wire_main_functs(void)
{
SEND_LOG("(SYS) unWire main functions",0,0);
add_to_timer(TM_SCENE,gamespeed,-1,refresh_scene);
add_to_timer(TM_FLY,gamespeed,-1,calc_fly);
add_to_timer(TM_REGEN,500,-1,real_regeneration);
@ -1080,9 +1083,9 @@ void wire_main_functs(void)
void init_game(void)
{
SEND_LOG("(INIT) Inventory.",0,0);
init_inventory();
SEND_LOG("(INIT) Characters.",0,0);
reg_grafiku_postav();
build_all_players();
}
@ -1135,14 +1138,14 @@ void enter_game(void)
cancel_pass=0;
autosave();
set_game_click_map();
SEND_LOG("(GAME) --------- Waiting for E_CLOSE_MAP ------------\n",0,0);
send_message(E_ADD,E_RELOADMAP,reload_map_handler);
{
EVENT_MSG *msg = task_wait_event(E_CLOSE_MAP);
end = va_arg(msg->data, int);
}
send_message(E_DONE,E_RELOADMAP,reload_map_handler);
SEND_LOG("(GAME) --------- E_CLOSE_MAP triggered, leaving map------------\n",0,0);
unwire_main_functs();
delete_from_timer(TM_FAST_TIMER);
cancel_pass=1;
@ -1174,7 +1177,7 @@ static int do_config_skeldal(int num,int numdata,char *txt)
sound_detection=0;
break;
case 6:snd_mixing=numdata;break;
case 7:strncpy(default_map,txt,20);default_map[19]='\0';SEND_LOG("(GAME) Start map sets as '%s'",default_map,0);break;
case 7:strncpy(default_map,txt,20);default_map[19]='\0';break;
case 8:gamespeed=numdata;break;
case 9:level_preload=numdata;break;
// case 10:system(txt);break;
@ -1262,9 +1265,9 @@ static void configure(char *filename)
puts(s);
exit(1);
}
SEND_LOG("(GAME) Configuring game...",0,0);
process_ini(cur_config,config_skeldal);
SEND_LOG("(GAME) Done config.",0,0);
}
static int update_config(void)
@ -1277,7 +1280,7 @@ static int update_config(void)
add_field_num(&cur_config,sinit[9].heslo,level_preload);
add_field_num(&cur_config,sinit[13].heslo,autosave_enabled);
save_config(cur_config,CONFIG_NAME);
SEND_LOG("(GAME) Config. file was saved",0,0);
return 0;
}
@ -1423,7 +1426,7 @@ static void game_big_circle(char enforced)
int err;
int r;
char s[13];
SEND_LOG("\n(GAME) --------- Entering big loop ------------",0,0);
purge_playlist();
s[12]=0;strncpy(s,loadlevel.name,12);
err=load_map(s);
@ -1469,16 +1472,16 @@ static void game_big_circle(char enforced)
for(r=0;r<mapsize*4;r++) call_macro(r,MC_STARTLEV);
recalc_volumes(viewsector,viewdir);
loadlevel.name[0]=0;
SEND_LOG("\n(GAME) --------- Entering game ------------",0,0);
enter_game();
SEND_LOG("(GAME) --------- Leaving game ------------\n",0,0);
leave_current_map();
s[12]=0;strncpy(s,loadlevel.name,12);
if (s[0]!=0)err=load_map(s);
memset(GlobEventList,0,sizeof(GlobEventList));
}
SEND_LOG("(GAME) --------- Leaving big loop ------------\n",0,0);
}
extern THUMAN postavy_2[];
@ -1646,16 +1649,14 @@ int main(int argc,char *argv[])
if (argc>=3) rm=!strcmp(argv[1],"12345678");else rm=0;
//OPEN_LOG("syslog");
OPEN_LOG("con");
SEND_LOG("START --------------------------",0,0);
argv;
c=getcwd(NULL,0);
pathtable[SR_SAVES]=getmem(strlen(c)+2);
strcpy(pathtable[SR_SAVES],c);
strcat(pathtable[SR_SAVES],PATH_SEPARATOR);
free(c);
SEND_LOG("(GAME) Save directory sets to '%s'",pathtable[SR_SAVES],0);
// set_verify(0);
mman_pathlist=pathtable;
zoom_speed(1);
@ -1672,7 +1673,7 @@ int main(int argc,char *argv[])
adventure=argv[1];
cur_config=NULL;
SEND_LOG("(GAME) Starting new adventure: %s",adventure,0);
configure(adventure);
release_list(cur_config);
cur_config=config;
@ -1680,25 +1681,25 @@ int main(int argc,char *argv[])
#ifdef LOGFILE
{
int i;
for(i=0;i<(sizeof(pathtable)/4);i++) SEND_LOG("(GAME) LOG: Using directory '%s' as '%s'",pathtable[i],sinit[i+CESTY_POS].heslo);
for(i=0;i<(int)(sizeof(pathtable)/sizeof(*pathtable));i++) SEND_LOG("(GAME) LOG: Using directory '%s' as '%s'",pathtable[i],sinit[i+CESTY_POS].heslo);
}
#endif
start_check();
purge_temps(1);
// textmode_effekt();
clrscr();
SEND_LOG("\n(GAME) Init----------------",0,0);
init_skeldal();
//add_task(32768,check_number_1phase,argv[0]);
SEND_LOG("(INIT) Starting game thread.",0,0);
if (argc>=3 && rm)
{
add_task(65536,start_from_mapedit,argc,argv);
}
else
add_task(65536,start);
SEND_LOG("(INIT) Main thread goes to sleep.",0,0);
/* position(200,200);
set_font(H_FBIG,RGB(200,200,200));
outtext("Ahoj lidi");

View file

@ -340,7 +340,7 @@ void recalc_volumes(int sector,int side)
if (sector>=mapsize) return;
side;
SEND_LOG("(SOUND) %s","Recalculating volumes",0);
SEND_LOG("(SOUND) %s","Recalculating volumes");
newx=map_coord[sector].x;
newy=map_coord[sector].y;
// layer=map_coord[sector].layer;
@ -580,7 +580,7 @@ void mute_all_tracks(char all)
void kill_all_sounds()
{
int i;
SEND_LOG("(SOUND) Killing sound tracks...",0,0);
SEND_LOG("(SOUND) Killing sound tracks...");
for (i=0;i<CHANNELS;i++) release_channel(i);
for (i=0;i<32;i++) if (locks[i]!=0) aunlock(locks[i]);
}

View file

@ -520,7 +520,7 @@ void zacatek_kola()
int i;
THUMAN *p;
SEND_LOG("(BATTLE) Start round",0,0);
SEND_LOG("(BATTLE) Start round");
build_player_map();
cislo_kola++;
autostart_round=0;
@ -581,7 +581,7 @@ void konec_kola()
int i;THUMAN *h;TMOB *m;
int j;
SEND_LOG("(BATTLE) End round",0,0);
SEND_LOG("(BATTLE) End round");
prekvapeni=0;
for(i=0,h=postavy;i<POCET_POSTAV;i++,h++)
if (h->used)
@ -1162,7 +1162,7 @@ void jadro_souboje(EVENT_MSG *msg,void **unused) //!!!! Jadro souboje
if(nxt==-255)
{
int i;
SEND_LOG("(BATTLE) Ending round...",nxt,mobs[nxt].name);
SEND_LOG("(BATTLE) Ending round...(nxt=%d,mob=%s)",nxt,mobs[nxt].name);
delete_from_timer(TM_SCENE);
add_to_timer(TM_SCENE,gamespeed,-1,refresh_scene);
for(i=0;i<MAX_MOBS;i++)
@ -1272,7 +1272,7 @@ void jadro_souboje(EVENT_MSG *msg,void **unused) //!!!! Jadro souboje
int i;
THUMAN *p;
SEND_LOG("(BATTLE) Leaving battle",0,0);
SEND_LOG("(BATTLE) Leaving battle");
prekvapeni=0;
unwire_proc();
wire_main_functs();
@ -2023,7 +2023,7 @@ void start_battle()
disable_click_map();
if (!running_battle)
{
SEND_LOG("(BATTLE) Battle started (monster: %s)",attack_mob!=NULL?attack_mob->name:"(NULL)",0);
SEND_LOG("(BATTLE) Battle started (monster: %s)",attack_mob!=NULL?attack_mob->name:"(NULL)");
poloz_vsechny_predmety();
zacatek_kola();
running_battle=1;
@ -2368,7 +2368,7 @@ char player_check_death(THUMAN *p, char afterround)
if (p->level>1) p->exp=level_map[p->level-2];
p->kondice=0;
p->mana=0;
SEND_LOG("(GAME) Character '%s' died. R.I.P.",p->jmeno,0);
SEND_LOG("(GAME) Character '%s' died. R.I.P.",p->jmeno);
if (numplayers(p->sektor,0)==0) map_coord[p->sektor].flags &=~MC_PLAYER;
mp=map_sectors[p->sektor].sector_type;
if (mp==S_VODA || mp==S_LAVA || mp==S_VIR) p->sektor=0;

View file

@ -4,6 +4,7 @@
#include <string>
#include <string_view>
#include <vector>
#include <iostream>
extern "C" {
#include "temp_storage.h"
@ -16,7 +17,6 @@ typedef struct _temp_storage_file_wr {
typedef struct _temp_storage_file_rd {
std::basic_string_view<uint8_t> _data;
int skp = 0;
int scan_ret = 0;
} TMPFILE_RD;
using FileSystem = std::map<std::string, std::vector<uint8_t>, std::less<> >;
@ -26,7 +26,11 @@ static FileSystem temp_fsystem;
void temp_storage_store(const char *name, const void *data, int32_t size) {
auto b = reinterpret_cast<const uint8_t *>(data);
auto e = b+size;
temp_fsystem[std::string(name)] = {b,e};
auto &v =temp_fsystem[std::string(name)];
v.clear();
v.resize(size+1);
std::copy(b,e, v.begin());
v[size] = 0;
}
int32_t temp_storage_find(const char *name) {
@ -89,7 +93,7 @@ uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f) {
auto p = d.substr(0,size);
d = d.substr(p.size());
auto b = reinterpret_cast<uint8_t *>(data);
std::copy(d.begin(), d.end(), b);
std::copy(p.begin(), p.end(), b);
return p.size();
}
@ -106,7 +110,7 @@ void temp_storage_delete(const char *name) {
int temp_storage_getc(TMPFILE_RD *f) {
if (f->_data.empty()) return -1;
int r = f->_data[0];
int r = static_cast<uint8_t>(f->_data[0]);
f->_data = f->_data.substr(1);
return r;
}
@ -114,7 +118,7 @@ int temp_storage_getc(TMPFILE_RD *f) {
char *temp_storage_gets(char *buff, size_t sz, TMPFILE_RD *f) {
auto &d =f->_data;
auto pos = d.find('\n');
if (pos > d.size()) pos = d.size();
if (pos > d.size()) pos = d.size(); else ++pos;
if (pos == 0) return NULL;
if (pos > sz - 1) pos = sz - 1;
temp_storage_read(buff, pos, f);
@ -123,23 +127,25 @@ char *temp_storage_gets(char *buff, size_t sz, TMPFILE_RD *f) {
}
void temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ...) {
int temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ...) {
if (f->_data.empty()) {
f->scan_ret = -1;
return -1;
}
va_list lst;
va_start(lst, format);
f->scan_ret = vsscanf(reinterpret_cast<const char *>(f->_data.data()), format, lst);
int scan_ret = vsscanf(reinterpret_cast<const char *>(f->_data.data()), format, lst);
va_end(lst);
return scan_ret;
}
int *temp_storage_internal_skip_ptr(TMPFILE_RD *f) {
f->skp = 0;
return &f->skp;
}
int temp_storage_internal_end_scanf(TMPFILE_RD *f) {
int temp_storage_internal_end_scanf(TMPFILE_RD *f, int r) {
temp_storage_skip(f, f->skp);
return f->scan_ret;
return r;
}
void temp_storage_ungetc(TMPFILE_RD *f) {

View file

@ -28,11 +28,14 @@ uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f);
void temp_storage_skip(TMPFILE_RD *f, int bytes);
int *temp_storage_internal_skip_ptr(TMPFILE_RD *f);
void temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ... ) __attribute__((format(scanf, 2, 3)));
int temp_storage_internal_end_scanf(TMPFILE_RD *f);
int temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ... ) __attribute__((format(scanf, 2, 3)));
int temp_storage_internal_end_scanf(TMPFILE_RD *f, int r);
#define temp_storage_scanf(f, format, ...) (temp_storage_internal_begin_scanf(f, format "%n", __VA_ARGS__, temp_storage_internal_skip_ptr(f)),temp_storage_internal_end_scanf(f))
#define temp_storage_scanf(f, format, ...) \
temp_storage_internal_end_scanf(f,\
temp_storage_internal_begin_scanf(f, format "%n", \
__VA_ARGS__, temp_storage_internal_skip_ptr(f)))