diff --git a/game/console.c b/game/console.c index bc36de6..eabb7b3 100644 --- a/game/console.c +++ b/game/console.c @@ -419,7 +419,7 @@ static void console_add_line(const char *line) { free(console_output_lines[console_max_lines-1]); memmove(console_output_lines+1,console_output_lines, (console_max_lines-1)*sizeof(char *)); console_output_lines[0] = strdup(line); - + } typedef struct { @@ -789,14 +789,14 @@ static void console_keyboard(EVENT_MSG *msg, void **_) { console_input_line[len+1] = 0; msg->msg = -1; } - } else { + } else { switch (code >> 8) { case 'I': console_top_line = MIN(console_max_lines-10, console_top_line+10);break; case 'Q': console_top_line = MAX(0, console_top_line-10);break; case 'H': console_top_line = MIN(console_max_lines-10, console_top_line+1);break; case 'P': console_top_line = MAX(0, console_top_line-1);break; - case 'G': console_top_line = console_max_characters-10; - case 'O': console_top_line = 0; + case 'G': console_top_line = console_max_characters-10;break; + case 'O': console_top_line = 0;break; default: return; } msg->msg = -1; diff --git a/game/enemy.c b/game/enemy.c index ebc6a2e..059e280 100644 --- a/game/enemy.c +++ b/game/enemy.c @@ -1450,10 +1450,11 @@ void mob_strelba(TMOB *p) spell_throw(-((p-mobs)+1),i); letici_veci->flags &=~FLY_DESTROY; int att = p->vlastnosti[VLS_OBRAT]/5; - letici_veci->hit_bonus=p->vlastnosti[VLS_UTOK_L]+rnd(p->vlastnosti[VLS_UTOK_H]-p->vlastnosti[VLS_UTOK_L]+1) + att; + int attack_roll = p->vlastnosti[VLS_UTOK_L]+rnd(p->vlastnosti[VLS_UTOK_H]-p->vlastnosti[VLS_UTOK_L]+1); + letici_veci->hit_bonus= attack_roll + att; if (log_combat) { wzprintf("%s shoots: %d (roll %d-%d) + %d (%s/5) = %d\n", - p->vlastnosti[VLS_UTOK_L],p->vlastnosti[VLS_UTOK_H],att,texty[13],letici_veci->hit_bonus); + p->name, attack_roll, p->vlastnosti[VLS_UTOK_L],p->vlastnosti[VLS_UTOK_H],att,texty[13],letici_veci->hit_bonus); } letici_veci->damage=p->vlastnosti[VLS_DAMAGE]; p->dostal=0; @@ -2183,11 +2184,11 @@ static void knock_mob_back(TMOB *mm,int dir) const TITEM *it = glob_items + itnum-1; if (it->druh != TYP_UTOC) return; int vls[] = {VLS_MGSIL_H,VLS_MGSIL_L,VLS_UTOK_H,VLS_UTOK_L,VLS_DAMAGE}; - for (int i = 0; i < countof(vls); ++i) { + for (size_t i = 0; i < countof(vls); ++i) { vlastnosti[vls[i]] -= it->zmeny[vls[i]]; } } - + int utok_na_sektor(THUMAN *p,TMOB *mm,int ch,int bonus, int ruka) { diff --git a/game/gamesave.c b/game/gamesave.c index 348ee3c..5d3ea90 100644 --- a/game/gamesave.c +++ b/game/gamesave.c @@ -874,7 +874,7 @@ static int last_select=-1; static TSTR_LIST story_text=NULL; static void *back_texture=NULL; static int cur_story_pos=0; -static char load_mode; +//static char load_mode; #define SLOT_SPACE 33 #define SLOT_FONT H_FBOLD @@ -994,6 +994,7 @@ static int dedup_strings_prefix(TSTR_LIST lst, int count) { } +/* static void load_specific_file(int slot_num,char *filename,void **out,int32_t *size) //call it in task! { FILE *slot; @@ -1022,6 +1023,31 @@ static void load_specific_file(int slot_num,char *filename,void **out,int32_t *s } fclose(slot); } +*/ +static void load_specific_file(const char *filename,const char *name, void **out,int32_t *size) //call it in task! + { + FILE *slot; + + + slot=fopen_icase(build_pathname(2, gpathtable[SR_SAVES], filename),"rb"); + if (slot==NULL) + { + *out=NULL; + return; + } + fseek(slot,SAVE_NAME_SIZE,SEEK_CUR); + + LOAD_SPECIFIC_FILE_CALLBACK_DATA ctx; + ctx.name = name; + + *out = NULL; + *size = 0; + if (enum_all_status(slot, &load_specific_file_callback, &ctx) == 0){ + *out = ctx.data; + *size = ctx.size; + } + fclose(slot); + } static TSAVEGAME_LIST get_all_savegames(unsigned long kampan) { @@ -1147,7 +1173,7 @@ static void redraw_story_bar(int pos) ukaz_mysku(); showview(x,STORY_Y+SCREEN_OFFLINE,STORY_XS,STORY_YS); } - +/* static void read_story_task(va_list args) { int slot=va_arg(args,int); @@ -1202,7 +1228,51 @@ static void read_story(int slot) if (slot!=-1) task_num=add_task(8196,read_story_task,slot); } +*/ +static void read_story(const char *filename) { + void *text_data; + int32_t size; + TSTR_LIST ls; + char *c,*d; + + load_specific_file(filename,STORY_BOOK,&text_data,&size); + if (text_data!=NULL) + { + ls=create_list(2); + c=text_data; + set_font(H_FONT6,0); + while (size>0) + { + int xs,ys; + d=c; + while (size>0 && *d!='\r' && *d!='\n') {d++;size--;}; + if (!size) break; + *d=0; + { + char *e,*or; + or=e=getmem(strlen(c)+2); + zalamovani(c,e,STORY_XS,&xs,&ys); + while (*e) + { + str_add(&ls,e); + if (text_width(e)>STORY_XS) abort(); + e=strchr(e,0)+1; + } + c=d+1;size--; + if (size > 0 &&(*c=='\n' || *c=='\r')) {c++;size--;}; + free(or); + } + } + free(text_data); + } + else ls=NULL; + if (story_text!=NULL) release_list(story_text); + story_text=ls; + cur_story_pos=get_list_count();if (cur_story_pos<0) cur_story_pos=0; + redraw_story_bar(cur_story_pos); + +} static int get_list_count() { @@ -1506,7 +1576,6 @@ T_CLK_MAP clk_save[]= static void select_slot(int i) { int rel = i-current_slot_list_top_line; - char unbright = 1; while (rel < 0) { --current_slot_list_top_line; schovej_mysku(); @@ -1514,20 +1583,23 @@ static void select_slot(int i) { showview(0,0,0,0); ukaz_mysku(); rel++; - unbright = 0; - } + } while (rel > SLOTS_MAX-1) { ++current_slot_list_top_line; schovej_mysku(); redraw_load(); showview(0,0,0,0); ukaz_mysku(); - unbright = 0; rel--; } - if (last_select != -1) place_name(0,last_select-current_slot_list_top_line,1,0); - place_name(0,i-current_slot_list_top_line,1,1); - last_select = i; + if (last_select != i) { + if (last_select != -1) place_name(0,last_select-current_slot_list_top_line,1,0); + place_name(0,i-current_slot_list_top_line,1,1); + last_select = i; + if (last_select != -1 && last_select < (int)current_game_slot_list.count) { + read_story(current_game_slot_list.files[last_select]); + } + } } static void saveload_keyboard(EVENT_MSG *msg,void **_) @@ -1539,7 +1611,7 @@ static void saveload_keyboard(EVENT_MSG *msg,void **_) { case 1:unwire_proc();wire_proc();break; case 'H':if (last_select>0) select_slot(last_select-1);break; - case 'P':if (last_select=0) load_save_pos_ingame(last_select);break; } } @@ -1554,12 +1626,12 @@ static void saveload_keyboard_menu(EVENT_MSG *msg,void **_) { case 1:send_message(E_CLOSE_MAP,NULL);break; case 'H':if (last_select>0) select_slot(last_select-1);break; - case 'P':if (last_select= 0 && last_select < current_game_slot_list.count) { + case 'P':if (last_select<(int)current_game_slot_list.count-1) select_slot(last_select+1);break; + case 28:if (last_select>= 0 && last_select < (int)current_game_slot_list.count) { send_message(E_CLOSE_MAP, current_game_slot_list.files[last_select]); break; } - + } } } diff --git a/game/realgame.c b/game/realgame.c index f4e0aa0..6281845 100644 --- a/game/realgame.c +++ b/game/realgame.c @@ -541,6 +541,7 @@ LETICI_VEC *create_fly() p->items=NULL; p->item=0; p->lives=0; + p->anim_pos = 0; return p; } @@ -1295,7 +1296,12 @@ void group_all(void) void destroy_player_map() //je nutne volat pred presunem postav { int i; - for(i=0;i 0 && s < mapsize) { + map_coord[s].flags&=~(MC_DPLAYER | MC_SAFEPLACE); + } + } } void build_player_map() //je nutne volat po presunu postav diff --git a/game/skeldal.c b/game/skeldal.c index 1ace968..581d02a 100644 --- a/game/skeldal.c +++ b/game/skeldal.c @@ -378,17 +378,17 @@ const void *load_mob_legacy_format(const void *p, int32_t *s) { char *d = (char *)m; size_t ofs = 0; size_t nx = offsetof(TMOB,experience); - memcpy(d, c, nx); + memmove(d, c, nx); c+=nx-2; //first padding 2 d+=nx; ofs=nx; nx = offsetof(TMOB, dialog_flags); - memcpy(d, c, nx - ofs); + memmove(d, c, nx - ofs); c+=nx - ofs -1; //second padding 1 d+=nx; ofs=nx; nx = sizeof(TMOB); - memcpy(d, c, nx - ofs-1); //last padding 1 + memmove(d, c, nx - ofs - 1); //last padding 1 c+=nx - ofs - 1; } *s = count * sizeof(TMOB); diff --git a/game/souboje.c b/game/souboje.c index 822e74e..dd882dc 100644 --- a/game/souboje.c +++ b/game/souboje.c @@ -425,23 +425,23 @@ int vypocet_zasahu(const short *utocnik,const short *obrance, int chaos,int zbr wzprintf(">"); if (utocnik[VLS_UTOK_H]) { wzprintf("Attack (physical): %d (roll %d-%d) + %d (%s/5) + %d (ext.force) = %d\n", - attack_roll, (int)utocnik[VLS_UTOK_L],(int)utocnik[VLS_UTOK_H], + attack_roll, (int)utocnik[VLS_UTOK_L],(int)utocnik[VLS_UTOK_H], attbonus, finesse?texty[13]:texty[10], external_force,utok); } else if (external_force) { wzprintf("Attack (physical): %d (ext.force)\n", external_force); - } + } if (obrance[VLS_OBRAN_H] && utok > 0) { char chaos[50]; if (disadv > 1) snprintf(chaos, 50, ", disadvantage %d", disadv); else strcpy(chaos,""); wzprintf(" Defense (physical): %d (roll %d-%d%s) + %d (%s/5) = %d\n", - defense_roll, ospod, obrance[VLS_OBRAN_H], chaos, obrbonus, texty[13], obrana); + defense_roll, ospod, obrance[VLS_OBRAN_H], chaos, obrbonus, texty[13], obrana); } if (zasah>0) { if (damage) { wzprintf(" Psychical hit: %d - %d + %d (damage) + %d (weapon) = %d\n", - utok, obrana, utocnik[VLS_DAMAGE], zbran, zasah); + utok, obrana, utocnik[VLS_DAMAGE], zbran, zasah); } else { wzprintf(" Psychical hit: %d - %d = %d\n", utok, obrana, zasah); @@ -467,7 +467,7 @@ int vypocet_zasahu(const short *utocnik,const short *obrance, int chaos,int zbr if (flg & SPL_HSANC) { int tmp = total_hit; total_hit/=2; - if (log_combat) wzprintf("Total resistance applied: %d - %d (half) = %d\n", tmp, total_hit - tmp); + if (log_combat) wzprintf("Total resistance applied: %d - %d (half) = %d\n", tmp, total_hit - tmp, total_hit); } if (flg & SPL_TVAR) { if (log_combat) wzprintf("Set Face spell applied: %d = -%d (heal)\n", total_hit, -total_hit); @@ -1221,7 +1221,7 @@ void pouzij_zbran(THUMAN *p,int ruka) } } - + } } else diff --git a/libs/gui.c b/libs/gui.c index a390500..3c17e6e 100644 --- a/libs/gui.c +++ b/libs/gui.c @@ -362,7 +362,10 @@ void define(int id,int x,int y,int xs,int ys,char align,void (*initproc)(OBJREC va_start(vlst, initproc); o->call_init(o,vlst); va_end(vlst); - if (o->datasize && o->data==NULL) o->data=(void *)getmem(o->datasize); + if (o->datasize && o->data==NULL) { + o->data=(void *)getmem(o->datasize); + memset(o->data,0,o->datasize); + } o->next=NULL; if (o_start==NULL) { diff --git a/platform/file_access.cpp b/platform/file_access.cpp index bf9b55f..99bb903 100644 --- a/platform/file_access.cpp +++ b/platform/file_access.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "../libs/logfile.h"