This commit is contained in:
Ondrej Novak 2025-02-14 20:46:25 +01:00
commit 075100d2ce
8 changed files with 115 additions and 32 deletions

View file

@ -419,7 +419,7 @@ static void console_add_line(const char *line) {
free(console_output_lines[console_max_lines-1]); free(console_output_lines[console_max_lines-1]);
memmove(console_output_lines+1,console_output_lines, (console_max_lines-1)*sizeof(char *)); memmove(console_output_lines+1,console_output_lines, (console_max_lines-1)*sizeof(char *));
console_output_lines[0] = strdup(line); console_output_lines[0] = strdup(line);
} }
typedef struct { typedef struct {
@ -789,14 +789,14 @@ static void console_keyboard(EVENT_MSG *msg, void **_) {
console_input_line[len+1] = 0; console_input_line[len+1] = 0;
msg->msg = -1; msg->msg = -1;
} }
} else { } else {
switch (code >> 8) { switch (code >> 8) {
case 'I': console_top_line = MIN(console_max_lines-10, console_top_line+10);break; 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 '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 '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 'P': console_top_line = MAX(0, console_top_line-1);break;
case 'G': console_top_line = console_max_characters-10; case 'G': console_top_line = console_max_characters-10;break;
case 'O': console_top_line = 0; case 'O': console_top_line = 0;break;
default: return; default: return;
} }
msg->msg = -1; msg->msg = -1;

View file

@ -1450,10 +1450,11 @@ void mob_strelba(TMOB *p)
spell_throw(-((p-mobs)+1),i); spell_throw(-((p-mobs)+1),i);
letici_veci->flags &=~FLY_DESTROY; letici_veci->flags &=~FLY_DESTROY;
int att = p->vlastnosti[VLS_OBRAT]/5; 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) { if (log_combat) {
wzprintf("%s shoots: %d (roll %d-%d) + %d (%s/5) = %d\n", 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]; letici_veci->damage=p->vlastnosti[VLS_DAMAGE];
p->dostal=0; p->dostal=0;
@ -2183,11 +2184,11 @@ static void knock_mob_back(TMOB *mm,int dir)
const TITEM *it = glob_items + itnum-1; const TITEM *it = glob_items + itnum-1;
if (it->druh != TYP_UTOC) return; if (it->druh != TYP_UTOC) return;
int vls[] = {VLS_MGSIL_H,VLS_MGSIL_L,VLS_UTOK_H,VLS_UTOK_L,VLS_DAMAGE}; 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]]; vlastnosti[vls[i]] -= it->zmeny[vls[i]];
} }
} }
int utok_na_sektor(THUMAN *p,TMOB *mm,int ch,int bonus, int ruka) int utok_na_sektor(THUMAN *p,TMOB *mm,int ch,int bonus, int ruka)
{ {

View file

@ -874,7 +874,7 @@ static int last_select=-1;
static TSTR_LIST story_text=NULL; static TSTR_LIST story_text=NULL;
static void *back_texture=NULL; static void *back_texture=NULL;
static int cur_story_pos=0; static int cur_story_pos=0;
static char load_mode; //static char load_mode;
#define SLOT_SPACE 33 #define SLOT_SPACE 33
#define SLOT_FONT H_FBOLD #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! static void load_specific_file(int slot_num,char *filename,void **out,int32_t *size) //call it in task!
{ {
FILE *slot; FILE *slot;
@ -1022,6 +1023,31 @@ static void load_specific_file(int slot_num,char *filename,void **out,int32_t *s
} }
fclose(slot); 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) { static TSAVEGAME_LIST get_all_savegames(unsigned long kampan) {
@ -1147,7 +1173,7 @@ static void redraw_story_bar(int pos)
ukaz_mysku(); ukaz_mysku();
showview(x,STORY_Y+SCREEN_OFFLINE,STORY_XS,STORY_YS); showview(x,STORY_Y+SCREEN_OFFLINE,STORY_XS,STORY_YS);
} }
/*
static void read_story_task(va_list args) static void read_story_task(va_list args)
{ {
int slot=va_arg(args,int); int slot=va_arg(args,int);
@ -1202,7 +1228,51 @@ static void read_story(int slot)
if (slot!=-1) if (slot!=-1)
task_num=add_task(8196,read_story_task,slot); 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() static int get_list_count()
{ {
@ -1506,7 +1576,6 @@ T_CLK_MAP clk_save[]=
static void select_slot(int i) { static void select_slot(int i) {
int rel = i-current_slot_list_top_line; int rel = i-current_slot_list_top_line;
char unbright = 1;
while (rel < 0) { while (rel < 0) {
--current_slot_list_top_line; --current_slot_list_top_line;
schovej_mysku(); schovej_mysku();
@ -1514,20 +1583,23 @@ static void select_slot(int i) {
showview(0,0,0,0); showview(0,0,0,0);
ukaz_mysku(); ukaz_mysku();
rel++; rel++;
unbright = 0; }
}
while (rel > SLOTS_MAX-1) { while (rel > SLOTS_MAX-1) {
++current_slot_list_top_line; ++current_slot_list_top_line;
schovej_mysku(); schovej_mysku();
redraw_load(); redraw_load();
showview(0,0,0,0); showview(0,0,0,0);
ukaz_mysku(); ukaz_mysku();
unbright = 0;
rel--; rel--;
} }
if (last_select != -1) place_name(0,last_select-current_slot_list_top_line,1,0); if (last_select != i) {
place_name(0,i-current_slot_list_top_line,1,1); if (last_select != -1) place_name(0,last_select-current_slot_list_top_line,1,0);
last_select = i; 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 **_) 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 1:unwire_proc();wire_proc();break;
case 'H':if (last_select>0) select_slot(last_select-1);break; case 'H':if (last_select>0) select_slot(last_select-1);break;
case 'P':if (last_select<current_game_slot_list.count-1) select_slot(last_select+1);break; case 'P':if (last_select<(int)current_game_slot_list.count-1) select_slot(last_select+1);break;
case 28:if (last_select>=0) load_save_pos_ingame(last_select);break; case 28: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 1:send_message(E_CLOSE_MAP,NULL);break;
case 'H':if (last_select>0) select_slot(last_select-1);break; case 'H':if (last_select>0) select_slot(last_select-1);break;
case 'P':if (last_select<current_game_slot_list.count-1) select_slot(last_select+1);break; 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 < current_game_slot_list.count) { 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]); send_message(E_CLOSE_MAP, current_game_slot_list.files[last_select]);
break; break;
} }
} }
} }
} }

View file

@ -541,6 +541,7 @@ LETICI_VEC *create_fly()
p->items=NULL; p->items=NULL;
p->item=0; p->item=0;
p->lives=0; p->lives=0;
p->anim_pos = 0;
return p; return p;
} }
@ -1295,7 +1296,12 @@ void group_all(void)
void destroy_player_map() //je nutne volat pred presunem postav void destroy_player_map() //je nutne volat pred presunem postav
{ {
int i; int i;
for(i=0;i<POCET_POSTAV;i++) map_coord[postavy[i].sektor].flags&=~(MC_DPLAYER | MC_SAFEPLACE); for(i=0;i<POCET_POSTAV;i++) {
int s = postavy[i].sektor;
if (s > 0 && s < mapsize) {
map_coord[s].flags&=~(MC_DPLAYER | MC_SAFEPLACE);
}
}
} }
void build_player_map() //je nutne volat po presunu postav void build_player_map() //je nutne volat po presunu postav

View file

@ -378,17 +378,17 @@ const void *load_mob_legacy_format(const void *p, int32_t *s) {
char *d = (char *)m; char *d = (char *)m;
size_t ofs = 0; size_t ofs = 0;
size_t nx = offsetof(TMOB,experience); size_t nx = offsetof(TMOB,experience);
memcpy(d, c, nx); memmove(d, c, nx);
c+=nx-2; //first padding 2 c+=nx-2; //first padding 2
d+=nx; d+=nx;
ofs=nx; ofs=nx;
nx = offsetof(TMOB, dialog_flags); nx = offsetof(TMOB, dialog_flags);
memcpy(d, c, nx - ofs); memmove(d, c, nx - ofs);
c+=nx - ofs -1; //second padding 1 c+=nx - ofs -1; //second padding 1
d+=nx; d+=nx;
ofs=nx; ofs=nx;
nx = sizeof(TMOB); 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; c+=nx - ofs - 1;
} }
*s = count * sizeof(TMOB); *s = count * sizeof(TMOB);

View file

@ -425,23 +425,23 @@ int vypocet_zasahu(const short *utocnik,const short *obrance, int chaos,int zbr
wzprintf(">"); wzprintf(">");
if (utocnik[VLS_UTOK_H]) { if (utocnik[VLS_UTOK_H]) {
wzprintf("Attack (physical): %d (roll %d-%d) + %d (%s/5) + %d (ext.force) = %d\n", 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], attbonus, finesse?texty[13]:texty[10],
external_force,utok); external_force,utok);
} else if (external_force) { } else if (external_force) {
wzprintf("Attack (physical): %d (ext.force)\n", external_force); wzprintf("Attack (physical): %d (ext.force)\n", external_force);
} }
if (obrance[VLS_OBRAN_H] && utok > 0) { if (obrance[VLS_OBRAN_H] && utok > 0) {
char chaos[50]; char chaos[50];
if (disadv > 1) snprintf(chaos, 50, ", disadvantage %d", disadv); if (disadv > 1) snprintf(chaos, 50, ", disadvantage %d", disadv);
else strcpy(chaos,""); else strcpy(chaos,"");
wzprintf(" Defense (physical): %d (roll %d-%d%s) + %d (%s/5) = %d\n", 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 (zasah>0) {
if (damage) { if (damage) {
wzprintf(" Psychical hit: %d - %d + %d (damage) + %d (weapon) = %d\n", 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 { } else {
wzprintf(" Psychical hit: %d - %d = %d\n", wzprintf(" Psychical hit: %d - %d = %d\n",
utok, obrana, zasah); utok, obrana, zasah);
@ -467,7 +467,7 @@ int vypocet_zasahu(const short *utocnik,const short *obrance, int chaos,int zbr
if (flg & SPL_HSANC) { if (flg & SPL_HSANC) {
int tmp = total_hit; int tmp = total_hit;
total_hit/=2; 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 (flg & SPL_TVAR) {
if (log_combat) wzprintf("Set Face spell applied: %d = -%d (heal)\n", total_hit, -total_hit); 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 else

View file

@ -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); va_start(vlst, initproc);
o->call_init(o,vlst); o->call_init(o,vlst);
va_end(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; o->next=NULL;
if (o_start==NULL) if (o_start==NULL)
{ {

View file

@ -2,6 +2,7 @@
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
#include <cstdarg> #include <cstdarg>
#include <chrono>
#include <filesystem> #include <filesystem>
#include "../libs/logfile.h" #include "../libs/logfile.h"