mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-20 05:04:53 -04:00
allow all MAP files to be read from DDL archive
This commit is contained in:
parent
96eaeb4851
commit
73a4187f79
18 changed files with 185 additions and 165 deletions
|
@ -160,7 +160,7 @@ static void mob_reload(EVENT_MSG *msg,void **_){
|
||||||
TMOB *m;
|
TMOB *m;
|
||||||
int32_t vl;
|
int32_t vl;
|
||||||
|
|
||||||
static int last;
|
static int last = 0;
|
||||||
counter=0;
|
counter=0;
|
||||||
while (last<MAX_MOBS)
|
while (last<MAX_MOBS)
|
||||||
{
|
{
|
||||||
|
@ -1318,7 +1318,7 @@ void vymaz_zasahy(THE_TIMER *q)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int select_drop_inventory_place(TMOB *p) {
|
static int select_drop_inventory_place(TMOB *p) {
|
||||||
int x,y,pl;
|
int x,y,pl;
|
||||||
if (p->locx>128) x=1;else if (p->locx<128) x=-1;else x=rnd(2)*2-1;
|
if (p->locx>128) x=1;else if (p->locx<128) x=-1;else x=rnd(2)*2-1;
|
||||||
if (p->locy>128) y=1;else if (p->locy<128) y=-1;else y=rnd(2)*2-1;
|
if (p->locy>128) y=1;else if (p->locy<128) y=-1;else y=rnd(2)*2-1;
|
||||||
pl=0;if (x>0) pl++;
|
pl=0;if (x>0) pl++;
|
||||||
|
|
|
@ -113,19 +113,19 @@ static void unable_write_temp(char *c)
|
||||||
|
|
||||||
int load_org_map(const char *filename,TSTENA **sides,TSECTOR **sectors,TMAP_EDIT_INFO **coords,int *mapsize)
|
int load_org_map(const char *filename,TSTENA **sides,TSECTOR **sectors,TMAP_EDIT_INFO **coords,int *mapsize)
|
||||||
{
|
{
|
||||||
FILE *f;
|
TMPFILE_RD *f;
|
||||||
void *temp;
|
void *temp;
|
||||||
int sect;
|
int sect;
|
||||||
int32_t size,r;
|
int32_t size,r;
|
||||||
char nmapend=1;
|
char nmapend=1;
|
||||||
|
|
||||||
|
|
||||||
const char *c=build_pathname(2, gpathtable[SR_MAP],filename);
|
|
||||||
f=fopen_icase(c,"rb");
|
f = open_ddl_file(filename, SR_MAP);
|
||||||
if (f==NULL) return -1;
|
if (f==NULL) return -1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
r=load_section(f,&temp,§,&size);
|
r=load_section_mem(f,&temp,§,&size);
|
||||||
if (r==size)
|
if (r==size)
|
||||||
switch (sect)
|
switch (sect)
|
||||||
{
|
{
|
||||||
|
@ -152,12 +152,12 @@ int load_org_map(const char *filename,TSTENA **sides,TSECTOR **sectors,TMAP_EDIT
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (temp!=NULL)free(temp);
|
if (temp!=NULL)free(temp);
|
||||||
fclose(f);
|
temp_storage_close_rd(f);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (nmapend);
|
while (nmapend);
|
||||||
fclose(f);
|
temp_storage_close_rd(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ int save_game(long game_time,char *gamename, char is_autosave)
|
||||||
if (svf==NULL){
|
if (svf==NULL){
|
||||||
if (!is_autosave) {
|
if (!is_autosave) {
|
||||||
char buff[256];
|
char buff[256];
|
||||||
sprintf(buff,"Failed to create savegame at path %s", sn);
|
sprintf(buff,"Failed to create savegame at path %s", sn);
|
||||||
message(1,0,0,"",buff,texty[80]);
|
message(1,0,0,"",buff,texty[80]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ static int convert_map_strings_1(const char *source_name, LIST_FILE_TYPE type, s
|
||||||
const char *target_name = set_file_extension(concat2("map_", source_name),".csv");
|
const char *target_name = set_file_extension(concat2("map_", source_name),".csv");
|
||||||
const char *target_path = *(const char **)context;
|
const char *target_path = *(const char **)context;
|
||||||
TSTR_LIST lst = create_list(100);
|
TSTR_LIST lst = create_list(100);
|
||||||
int err = load_string_list_ex(&lst, build_pathname(2, gpathtable[SR_MAP], source_name));
|
int err = load_string_list_ex(&lst, source_name, SR_MAP);
|
||||||
if (err) {
|
if (err) {
|
||||||
release_list(lst);
|
release_list(lst);
|
||||||
fprintf(stderr,"Failed to read: %s, error code: %d\n",source_name, err);
|
fprintf(stderr,"Failed to read: %s, error code: %d\n",source_name, err);
|
||||||
|
@ -95,7 +95,7 @@ static int make_map_name_stringtable_cb(const char *source_name, LIST_FILE_TYPE
|
||||||
uint32_t id = fnv1a_hash(source_name);
|
uint32_t id = fnv1a_hash(source_name);
|
||||||
fprintf(ctx->out, "%u,%s\n", id, source_name);
|
fprintf(ctx->out, "%u,%s\n", id, source_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char make_map_name_stringtable(const char *target_path) {
|
static char make_map_name_stringtable(const char *target_path) {
|
||||||
const char *target_file = build_pathname(2,target_path,"mapnames.csv");
|
const char *target_file = build_pathname(2,target_path,"mapnames.csv");
|
||||||
|
@ -115,9 +115,9 @@ static char make_map_name_stringtable(const char *target_path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char convert_file_to(const char *src_file, const char *target_file) {
|
static char convert_file_to(const char *src_file, int group, const char *target_file) {
|
||||||
TMPFILE_RD *rd = enc_open(src_file);
|
TMPFILE_RD *rd = enc_open(src_file,group);
|
||||||
size_t sz = temp_storage_find("__enc_temp");
|
size_t sz = temp_storage_remain_size(rd);
|
||||||
char *buff = malloc(sz);
|
char *buff = malloc(sz);
|
||||||
temp_storage_retrieve("__enc_temp", buff, sz);
|
temp_storage_retrieve("__enc_temp", buff, sz);
|
||||||
FILE *out = fopen_icase(target_file, "w");
|
FILE *out = fopen_icase(target_file, "w");
|
||||||
|
@ -128,31 +128,31 @@ static char convert_file_to(const char *src_file, const char *target_file) {
|
||||||
printf("Writing %s\n", target_file);
|
printf("Writing %s\n", target_file);
|
||||||
fwrite(buff,1,sz,out);
|
fwrite(buff,1,sz,out);
|
||||||
fclose(out);
|
fclose(out);
|
||||||
enc_close(rd);
|
temp_storage_close_rd(rd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char convert_book(const char *target_path) {
|
static char convert_book(const char *target_path) {
|
||||||
const char *path = build_pathname(2, target_path, "book.txt");
|
const char *path = build_pathname(2, target_path, "book.txt");
|
||||||
path = local_strdup(path);
|
path = local_strdup(path);
|
||||||
return convert_file_to(build_pathname(2, gpathtable[SR_MAP], "kniha.txt"), path);
|
return convert_file_to("kniha.txt", SR_MAP, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char convert_end_titles(const char *target_path) {
|
static char convert_end_titles(const char *target_path) {
|
||||||
const char *path = build_pathname(2, target_path, "end_titles.txt");
|
const char *path = build_pathname(2, target_path, "end_titles.txt");
|
||||||
path = local_strdup(path);
|
path = local_strdup(path);
|
||||||
|
|
||||||
return convert_file_to(build_pathname(2, gpathtable[SR_DATA], "titulky.txt"), path);
|
return convert_file_to("titulky.txt",SR_DATA, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char convert_epilog(const char *target_path) {
|
static char convert_epilog(const char *target_path) {
|
||||||
const char *path = build_pathname(2, target_path, "epilog.txt");
|
const char *path = build_pathname(2, target_path, "epilog.txt");
|
||||||
path = local_strdup(path);
|
path = local_strdup(path);
|
||||||
return convert_file_to(build_pathname(2, gpathtable[SR_DATA], "endtext.txt"), path);
|
return convert_file_to("endtext.txt",SR_DATA, path);
|
||||||
}
|
}
|
||||||
static char convert_intro_titles(const char *target_path) {
|
static char convert_intro_titles(const char *target_path) {
|
||||||
TSTR_LIST lst = create_list(100);
|
TSTR_LIST lst = create_list(100);
|
||||||
int err = load_string_list_ex(&lst, build_pathname(2, gpathtable[SR_VIDEO], "intro.txt"));
|
int err = load_string_list_ex(&lst, "intro.txt", SR_VIDEO);
|
||||||
if (err) {
|
if (err) {
|
||||||
release_list(lst);
|
release_list(lst);
|
||||||
fprintf(stderr,"Failed to read: %s, error code: %d\n","intro.txt", err);
|
fprintf(stderr,"Failed to read: %s, error code: %d\n","intro.txt", err);
|
||||||
|
|
|
@ -608,7 +608,6 @@ extern char set_halucination;
|
||||||
extern int hal_sector; //cislo sektoru a smeru pri halucinaci
|
extern int hal_sector; //cislo sektoru a smeru pri halucinaci
|
||||||
extern int hal_dir;
|
extern int hal_dir;
|
||||||
extern char side_touched; //promena se nastavuje na 1 pri kazdem uspesnem dotyku steny
|
extern char side_touched; //promena se nastavuje na 1 pri kazdem uspesnem dotyku steny
|
||||||
extern const char *texty_knihy; //jmeno souboru s textamy knihy
|
|
||||||
extern int cur_page; //cislo stranky v knize;
|
extern int cur_page; //cislo stranky v knize;
|
||||||
extern int32_t game_time; //hraci cas
|
extern int32_t game_time; //hraci cas
|
||||||
extern char autoattack;
|
extern char autoattack;
|
||||||
|
@ -755,7 +754,9 @@ void turn_zoom(int smer);
|
||||||
void a_touch(int sector,int dir);
|
void a_touch(int sector,int dir);
|
||||||
int do_action(int action_numb,int sector,int direct,int flags,int nosend);
|
int do_action(int action_numb,int sector,int direct,int flags,int nosend);
|
||||||
void delay_action(int action_numb,int sector,int direct,int flags,int nosend,int delay);
|
void delay_action(int action_numb,int sector,int direct,int flags,int nosend,int delay);
|
||||||
int32_t load_section(FILE *f,void **section, int *sct_type,int32_t *sect_size);
|
//int32_t load_section(FILE *f,void **section, int *sct_type,int32_t *sect_size);
|
||||||
|
int32_t load_section_mem(TMPFILE_RD *f,void **section, int *sct_type,int32_t *sect_size);
|
||||||
|
TMPFILE_RD *open_ddl_file(const char *name, int group);
|
||||||
int prepare_graphics(int *ofs,char *names,int32_t size,ABLOCK_DECODEPROC decomp,int class);
|
int prepare_graphics(int *ofs,char *names,int32_t size,ABLOCK_DECODEPROC decomp,int class);
|
||||||
void show_automap(char full);
|
void show_automap(char full);
|
||||||
void draw_medium_map(void);
|
void draw_medium_map(void);
|
||||||
|
@ -1721,9 +1722,9 @@ void check_global_fletna(THE_TIMER *t);
|
||||||
void fletna_glob_add_note(uint8_t note);
|
void fletna_glob_add_note(uint8_t note);
|
||||||
|
|
||||||
|
|
||||||
TMPFILE_RD *enc_open(const char *filename); //dekoduje a otevira TXT soubor (ENC)
|
TMPFILE_RD *enc_open(const char *filename, int group); //dekoduje a otevira TXT soubor (ENC)
|
||||||
void enc_close(TMPFILE_RD *fil);
|
int load_string_list_ex(char ***list,const char *filename, int group);
|
||||||
int load_string_list_ex(char ***list,const char *filename);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int hprice;
|
int hprice;
|
||||||
|
@ -1756,8 +1757,8 @@ extern char trace_dialogs;
|
||||||
char enter_generator(void);
|
char enter_generator(void);
|
||||||
|
|
||||||
//kniha
|
//kniha
|
||||||
#define add_to_book(odst) add_text_to_book(texty_knihy,odst)
|
void add_to_book(int odst);
|
||||||
void add_text_to_book(const char *filename,int odst);
|
void add_text_to_book(const char *filename,int group, int odst);
|
||||||
void write_book(int page);
|
void write_book(int page);
|
||||||
int count_pages(void);
|
int count_pages(void);
|
||||||
void save_book(void);
|
void save_book(void);
|
||||||
|
|
|
@ -1350,64 +1350,39 @@ void check_global_fletna(THE_TIMER *t)
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
|
|
||||||
|
|
||||||
static char *load_file_to_string(FILE *f, int *size) {
|
|
||||||
fseek(f,0, SEEK_END);
|
|
||||||
int sz = ftell(f);
|
|
||||||
fseek(f, 0 , SEEK_SET);
|
|
||||||
char *c = getmem(sz+1);
|
|
||||||
fread(c,1,sz,f);
|
|
||||||
*size = sz;
|
|
||||||
c[sz] = 0;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
TMPFILE_RD *enc_open(const char *filename)
|
TMPFILE_RD *enc_open(const char *filename, int group)
|
||||||
{
|
{
|
||||||
FILE *f;
|
TMPFILE_RD *f;
|
||||||
char *c,*enc;
|
|
||||||
int last=0;
|
int last=0;
|
||||||
int size;
|
|
||||||
char *encdata;
|
|
||||||
|
|
||||||
f=fopen_icase(filename,"r");
|
f=open_ddl_file(filename, group);
|
||||||
if (f!=NULL) {
|
if (f!=NULL) {
|
||||||
encdata = load_file_to_string(f, &size);
|
return f;
|
||||||
fclose(f);
|
|
||||||
} else {
|
} else {
|
||||||
|
const char *enc_name = set_file_extension(filename, ".ENC");
|
||||||
enc=alloca(strlen(filename)+5);
|
int32_t sz;
|
||||||
strcpy(enc,filename);
|
void *data = afile_copy(enc_name,group,&sz);
|
||||||
c=strrchr(enc,'.');
|
if (data == NULL) return NULL;
|
||||||
if (c==NULL) c=strchr(enc,0);
|
char *encdata = (char *)data;
|
||||||
strcpy(c,".ENC");
|
for (int i = 0; i < sz; ++i) {
|
||||||
f=fopen_icase(enc,"rb");
|
|
||||||
if (f==NULL) return NULL;
|
|
||||||
encdata = load_file_to_string(f, &size);
|
|
||||||
fclose(f);
|
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
last = (last + encdata[i]) & 0xFF;
|
last = (last + encdata[i]) & 0xFF;
|
||||||
encdata[i] = last;
|
encdata[i] = last;
|
||||||
}
|
}
|
||||||
|
f = temp_storage_from_binary(encdata, sz, &free, data);
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
temp_storage_store("__enc_temp", encdata, size);
|
|
||||||
free(encdata);
|
|
||||||
return temp_storage_open("__enc_temp");
|
|
||||||
}
|
|
||||||
|
|
||||||
void enc_close(TMPFILE_RD *fil)
|
|
||||||
{
|
|
||||||
temp_storage_close_rd(fil);
|
|
||||||
temp_storage_delete("__enc_temp");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int load_string_list_ex(TSTR_LIST *list,const char *filename)
|
|
||||||
|
int load_string_list_ex(TSTR_LIST *list,const char *filename, int group)
|
||||||
{
|
{
|
||||||
char c[1024],*p;
|
char c[1024],*p;
|
||||||
int i=0,j,lin=0;
|
int i=0,j,lin=0;
|
||||||
TMPFILE_RD *f;
|
TMPFILE_RD *f;
|
||||||
|
|
||||||
f=enc_open(filename);
|
f=enc_open(filename, group);
|
||||||
if (*list==NULL) *list=create_list(256);
|
if (*list==NULL) *list=create_list(256);
|
||||||
if (f==NULL) return -1;
|
if (f==NULL) return -1;
|
||||||
do
|
do
|
||||||
|
@ -1424,12 +1399,12 @@ int load_string_list_ex(TSTR_LIST *list,const char *filename)
|
||||||
j=temp_storage_scanf(f,"%d",&i);
|
j=temp_storage_scanf(f,"%d",&i);
|
||||||
if (j==EOF)
|
if (j==EOF)
|
||||||
{
|
{
|
||||||
enc_close(f);
|
temp_storage_close_rd(f);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
if (j!=1)
|
if (j!=1)
|
||||||
{
|
{
|
||||||
enc_close(f);
|
temp_storage_close_rd(f);
|
||||||
return lin;
|
return lin;
|
||||||
}
|
}
|
||||||
if (i==-1) break;
|
if (i==-1) break;
|
||||||
|
@ -1437,7 +1412,7 @@ int load_string_list_ex(TSTR_LIST *list,const char *filename)
|
||||||
if (j!=EOF) temp_storage_ungetc(f);
|
if (j!=EOF) temp_storage_ungetc(f);
|
||||||
if (temp_storage_gets(c,1022,f)==NULL)
|
if (temp_storage_gets(c,1022,f)==NULL)
|
||||||
{
|
{
|
||||||
enc_close(f);
|
temp_storage_close_rd(f);
|
||||||
return lin;
|
return lin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1449,12 +1424,12 @@ int load_string_list_ex(TSTR_LIST *list,const char *filename)
|
||||||
for(p=c;*p;p++) *p=*p=='|'?'\n':*p;
|
for(p=c;*p;p++) *p=*p=='|'?'\n':*p;
|
||||||
if (str_replace(list,i,c)==NULL)
|
if (str_replace(list,i,c)==NULL)
|
||||||
{
|
{
|
||||||
enc_close(f);
|
temp_storage_close_rd(f);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (1);
|
while (1);
|
||||||
enc_close(f);
|
temp_storage_close_rd(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
game/inv.c
40
game/inv.c
|
@ -149,8 +149,7 @@ void item_sound_event(int item,int sector)
|
||||||
|
|
||||||
void load_items()
|
void load_items()
|
||||||
{
|
{
|
||||||
const char *name;
|
TMPFILE_RD *f;
|
||||||
FILE *f;
|
|
||||||
int sect,i,hs;
|
int sect,i,hs;
|
||||||
int32_t size;
|
int32_t size;
|
||||||
void *p;
|
void *p;
|
||||||
|
@ -167,8 +166,7 @@ void load_items()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
name=build_pathname(2, gpathtable[SR_MAP],ITEM_FILE);
|
f=open_ddl_file(ITEM_FILE,SR_MAP);
|
||||||
f=fopen_icase(name,"rb");
|
|
||||||
if (f==NULL)
|
if (f==NULL)
|
||||||
{
|
{
|
||||||
closemode();
|
closemode();
|
||||||
|
@ -177,7 +175,7 @@ void load_items()
|
||||||
}
|
}
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
load_section(f,&p,§,&size);
|
load_section_mem(f,&p,§,&size);
|
||||||
switch (sect)
|
switch (sect)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -218,7 +216,7 @@ void load_items()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (sect!=SV_END);
|
while (sect!=SV_END);
|
||||||
fclose(f);
|
temp_storage_close_rd(f);
|
||||||
{
|
{
|
||||||
TITEM *t;
|
TITEM *t;
|
||||||
for(i=0,t=glob_items;i<it_count_orgn;i++,t++) if (t->druh==TYP_SPECIALNI)
|
for(i=0,t=glob_items;i<it_count_orgn;i++,t++) if (t->druh==TYP_SPECIALNI)
|
||||||
|
@ -606,11 +604,7 @@ void do_items_specs(void)
|
||||||
cur_page&=~0x1;
|
cur_page&=~0x1;
|
||||||
cur_page++;
|
cur_page++;
|
||||||
if (p->popis[0]==0) add_to_book(p->user_value);
|
if (p->popis[0]==0) add_to_book(p->user_value);
|
||||||
else
|
else add_text_to_book(p->popis,SR_MAP,p->user_value);
|
||||||
{
|
|
||||||
const char *s = build_pathname(2, gpathtable[SR_MAP], p->popis);
|
|
||||||
add_text_to_book(s,p->user_value);
|
|
||||||
}
|
|
||||||
play_fx_at(FX_BOOK);
|
play_fx_at(FX_BOOK);
|
||||||
if (game_extras & EX_AUTOOPENBOOK) autoopenaction=1;
|
if (game_extras & EX_AUTOOPENBOOK) autoopenaction=1;
|
||||||
break;
|
break;
|
||||||
|
@ -1867,7 +1861,7 @@ static char uloz_sip_action(char fast_key) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char MakeItemCombinations(short *itm1, short *itm2)
|
/*static char MakeItemCombinations(short *itm1, short *itm2)
|
||||||
{
|
{
|
||||||
short i1=*itm1-1,i2=*itm2-1;
|
short i1=*itm1-1,i2=*itm2-1;
|
||||||
int src1;
|
int src1;
|
||||||
|
@ -1877,12 +1871,11 @@ static char MakeItemCombinations(short *itm1, short *itm2)
|
||||||
int cnt;
|
int cnt;
|
||||||
char succ=0;
|
char succ=0;
|
||||||
|
|
||||||
FILE *table;
|
TMPFILE_RD *table;
|
||||||
|
|
||||||
const char *fname = build_pathname(2,gpathtable[SR_MAP],"COMBITEM.DAT");
|
table=open_ddl_file("COMBITEM.DAT",SR_MAP);
|
||||||
table=fopen_icase(fname,"r");
|
|
||||||
if (table==NULL) return 0;
|
if (table==NULL) return 0;
|
||||||
cnt=fscanf(table,"%d %d -> %d %d",&src1,&src2,&trg1,&trg2);
|
cnt=temp_storage_scanf(table,"%d %d -> %d %d",&src1,&src2,&trg1,&trg2);
|
||||||
while(cnt>=3)
|
while(cnt>=3)
|
||||||
{
|
{
|
||||||
if (src1==i1 && src2==i2)
|
if (src1==i1 && src2==i2)
|
||||||
|
@ -1915,13 +1908,18 @@ static char MakeItemCombinations(short *itm1, short *itm2)
|
||||||
succ=1;
|
succ=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fscanf(table," ;")==-1) break;
|
int x = temp_storage_getc(table);
|
||||||
cnt=fscanf(table,"%d %d -> %d %d",&src1,&src2,&trg1,&trg2);
|
while (x >= 0 && isspace(x)) x = temp_storage_getc(table);
|
||||||
|
if (x )
|
||||||
|
|
||||||
|
|
||||||
|
if (temp_storage_scanf(table," ;")==-1) break;
|
||||||
|
cnt=temp_storage_scanf(table,"%d %d -> %d %d",&src1,&src2,&trg1,&trg2);
|
||||||
}
|
}
|
||||||
fclose(table);
|
temp_storage_close_rd(table);
|
||||||
return succ;
|
return succ;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
static char bag_action(int xr, int yr);
|
static char bag_action(int xr, int yr);
|
||||||
char bag_click(int id,int xa,int ya,int xr,int yr)
|
char bag_click(int id,int xa,int ya,int xr,int yr)
|
||||||
{
|
{
|
||||||
|
@ -1940,7 +1938,7 @@ static char bag_action(int xr, int yr) {
|
||||||
if (pk!=NULL)
|
if (pk!=NULL)
|
||||||
{
|
{
|
||||||
if (picked_item[1]!=0 && vejdou_se(count_items_total(picked_item))) return 0;
|
if (picked_item[1]!=0 && vejdou_se(count_items_total(picked_item))) return 0;
|
||||||
if (picked_item[1]!=0 || human_selected->inv[id]==0 || !MakeItemCombinations(picked_item,human_selected->inv+id))
|
if (picked_item[1]!=0 || human_selected->inv[id]==0 /* || !MakeItemCombinations(picked_item,human_selected->inv+id)*/)
|
||||||
while (*pk)
|
while (*pk)
|
||||||
{
|
{
|
||||||
p=human_selected->inv[id];
|
p=human_selected->inv[id];
|
||||||
|
|
30
game/kniha.c
30
game/kniha.c
|
@ -50,6 +50,7 @@
|
||||||
#include <libs/event.h>
|
#include <libs/event.h>
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
|
#include "lang.h"
|
||||||
#define XMAX 254
|
#define XMAX 254
|
||||||
#define YMAX 390
|
#define YMAX 390
|
||||||
#define XLEFT 34
|
#define XLEFT 34
|
||||||
|
@ -535,18 +536,37 @@ static void seek_section(TMPFILE_RD *txt,int sect_number)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_text_to_book(const char *filename,int odst)
|
void add_to_book(int odst) {
|
||||||
|
add_text_to_book("kniha.txt", SR_MAP, odst);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void add_text_to_book(const char *filename,int group, int odst)
|
||||||
{
|
{
|
||||||
TMPFILE_RD *fl;
|
TMPFILE_RD *fl = NULL;
|
||||||
|
|
||||||
set_font(H_FKNIHA,NOSHADOW(0));
|
set_font(H_FKNIHA,NOSHADOW(0));
|
||||||
if (all_text==NULL) all_text=create_list(256);
|
if (all_text==NULL) all_text=create_list(256);
|
||||||
fl=enc_open(filename);
|
|
||||||
if (fl==NULL) return;
|
if (istrcmp(filename, "kniha.txt") == 0) {
|
||||||
|
|
||||||
|
if (lang_get_folder()) {
|
||||||
|
char *text = lang_load_string("book.txt");
|
||||||
|
if (text) {
|
||||||
|
fl = temp_storage_from_binary(text,strlen(text),free, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fl) {
|
||||||
|
fl=enc_open(filename, group);
|
||||||
|
if (fl==NULL) return;
|
||||||
|
}
|
||||||
seek_section(fl,odst);
|
seek_section(fl,odst);
|
||||||
read_text(fl);
|
read_text(fl);
|
||||||
next_line(1000);
|
next_line(1000);
|
||||||
enc_close(fl);
|
temp_storage_close_rd(fl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *displ_picture(char *c)
|
static char *displ_picture(char *c)
|
||||||
|
|
|
@ -144,7 +144,7 @@ typedef struct tkouzlo
|
||||||
char povaha;
|
char povaha;
|
||||||
char traceon; //jinak noanim - neprehravaji se animace a zvuky
|
char traceon; //jinak noanim - neprehravaji se animace a zvuky
|
||||||
union {
|
union {
|
||||||
word backfire; //backfire
|
word backfire; //backfire
|
||||||
word demon; // 1 = demon , 0 = bez demona
|
word demon; // 1 = demon , 0 = bez demona
|
||||||
} bkdm;
|
} bkdm;
|
||||||
word wait; //wait - cekani pocet animaci
|
word wait; //wait - cekani pocet animaci
|
||||||
|
@ -565,9 +565,7 @@ void zmen_vlastnost(int num,int cil,int what,int how)
|
||||||
postavy[cil].stare_vls[what]+=how;
|
postavy[cil].stare_vls[what]+=how;
|
||||||
prepocitat_postavu(&postavy[cil]);
|
prepocitat_postavu(&postavy[cil]);
|
||||||
if (p->lives>p->vlastnosti[VLS_MAXHIT]) p->lives=p->vlastnosti[VLS_MAXHIT];
|
if (p->lives>p->vlastnosti[VLS_MAXHIT]) p->lives=p->vlastnosti[VLS_MAXHIT];
|
||||||
//if (p->mana>p->vlastnosti[VLS_MAXMANA]) p->lives=p->vlastnosti[VLS_MAXMANA];
|
if (p->kondice>p->vlastnosti[VLS_KONDIC]) p->kondice=p->vlastnosti[VLS_KONDIC];
|
||||||
if (p->kondice>p->vlastnosti[VLS_KONDIC]) p->lives=p->vlastnosti[VLS_KONDIC];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1481,7 +1479,7 @@ void call_spell(int i)
|
||||||
cil--;
|
cil--;
|
||||||
if (postavy[cil].vlastnosti[VLS_KOUZLA] & SPL_DEMON && !p->bkdm.demon && !p->delay)
|
if (postavy[cil].vlastnosti[VLS_KOUZLA] & SPL_DEMON && !p->bkdm.demon && !p->delay)
|
||||||
{
|
{
|
||||||
p->delay=1;
|
p->delay=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p->delay) return;
|
if (p->delay) return;
|
||||||
|
|
17
game/lang.c
17
game/lang.c
|
@ -3,6 +3,7 @@
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
#include <libs/strlite.h>
|
#include <libs/strlite.h>
|
||||||
|
#include <libs/memman.h>
|
||||||
|
|
||||||
|
|
||||||
static char *lang_folder = NULL;
|
static char *lang_folder = NULL;
|
||||||
|
@ -47,3 +48,19 @@ const char *lang_replace_path_if_exists(const char *file) {
|
||||||
if (check_file_exists(path)) return path;
|
if (check_file_exists(path)) return path;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *lang_load_string(const char *filename) {
|
||||||
|
if (lang_folder == NULL) return NULL;
|
||||||
|
const char *path = build_pathname(2, lang_folder, filename);
|
||||||
|
FILE *f = fopen(path, "r");
|
||||||
|
if (f == NULL) return NULL;
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
long sz = ftell(f);
|
||||||
|
char *trg = getmem(sz+1);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
fread(trg, 1 , sz, f);
|
||||||
|
fclose(f);
|
||||||
|
trg[sz] = 0;
|
||||||
|
return trg;
|
||||||
|
}
|
||||||
|
|
|
@ -9,4 +9,5 @@ const char *lang_get_folder(void);
|
||||||
void lang_patch_stringtable(TSTR_LIST *lst, const char *object_name, const char *prefix);
|
void lang_patch_stringtable(TSTR_LIST *lst, const char *object_name, const char *prefix);
|
||||||
const char *lang_replace_path_if_exists(const char *file);
|
const char *lang_replace_path_if_exists(const char *file);
|
||||||
TSTRINGTABLE *lang_load(const char *object_name);
|
TSTRINGTABLE *lang_load(const char *object_name);
|
||||||
|
char *lang_load_string(const char *filename);
|
||||||
|
|
||||||
|
|
|
@ -572,8 +572,7 @@ static int ma_picki(const TMA_TWOP *i,int abs_pos)
|
||||||
|
|
||||||
static void ma_wbook(const TMA_LOADLEV *l)
|
static void ma_wbook(const TMA_LOADLEV *l)
|
||||||
{
|
{
|
||||||
const char *s = build_pathname(2, gpathtable[SR_MAP], l->name);
|
add_text_to_book(l->name, SR_MAP,l->start_pos);
|
||||||
add_text_to_book(s,l->start_pos);
|
|
||||||
play_fx_at(FX_BOOK);
|
play_fx_at(FX_BOOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
game/menu.c
40
game/menu.c
|
@ -376,44 +376,30 @@ int enter_menu(char open)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *end_titles_path(const char *fname) {
|
|
||||||
if (istrcmp(fname,"TITULKY.TXT") == 0) fname = "end_titles.txt";
|
|
||||||
else if (istrcmp(fname,"ENDTEXT.TXT") == 0) fname = "epilog.txt";
|
|
||||||
return lang_replace_path_if_exists(fname);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static TMPFILE_RD *end_titles_lang(const char *filename) {
|
||||||
|
if (istrcmp(filename,"TITULKY.TXT") == 0) filename = "end_titles.txt";
|
||||||
|
else if (istrcmp(filename,"ENDTEXT.TXT") == 0) filename = "epilog.txt";
|
||||||
|
char *c = lang_load_string(filename);
|
||||||
|
if (!c) return NULL;
|
||||||
|
return temp_storage_from_binary(c, strlen(c), free, c);
|
||||||
|
}
|
||||||
char *get_next_title(signed char control,const char *filename)
|
char *get_next_title(signed char control,const char *filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
static TMPFILE_RD *titles=NULL;
|
static TMPFILE_RD *titles=NULL;
|
||||||
static char buffer[81];
|
static char buffer[81];
|
||||||
char *c;
|
char *c;
|
||||||
const char *path;
|
|
||||||
|
|
||||||
switch(control)
|
switch(control)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
path = end_titles_path(filename);
|
titles = end_titles_lang(filename);
|
||||||
if (path == NULL) {
|
if (titles != NULL) {
|
||||||
path = build_pathname(2, gpathtable[SR_MAP],filename);
|
return (char *)titles;
|
||||||
}
|
}
|
||||||
path = local_strdup(path);
|
titles = enc_open(filename, SR_DATA);
|
||||||
titles=enc_open(path);
|
return (char *)titles;
|
||||||
if (titles==NULL)
|
|
||||||
{
|
|
||||||
const char *path2 = build_pathname(2, gpathtable[SR_DATA],filename);
|
|
||||||
path2 = local_strdup(path2);
|
|
||||||
titles=enc_open(path2);
|
|
||||||
if (titles==NULL)
|
|
||||||
{
|
|
||||||
char popis[300];
|
|
||||||
closemode();
|
|
||||||
sprintf(popis,"Soubor nenalezen: %s nebo %s\n",path,path2);
|
|
||||||
display_error(popis);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (char *)titles;
|
|
||||||
case 0:if (titles!=NULL && temp_storage_gets(buffer,80,titles)) {
|
case 0:if (titles!=NULL && temp_storage_gets(buffer,80,titles)) {
|
||||||
c=strchr(buffer,'\n');if (c!=NULL) *c=0;
|
c=strchr(buffer,'\n');if (c!=NULL) *c=0;
|
||||||
c=strchr(buffer,'\r');if (c!=NULL) *c=0;
|
c=strchr(buffer,'\r');if (c!=NULL) *c=0;
|
||||||
|
@ -421,7 +407,7 @@ char *get_next_title(signed char control,const char *filename)
|
||||||
strcpy(buffer, "*KONEC");
|
strcpy(buffer, "*KONEC");
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
case -1:if (titles!=NULL)enc_close(titles);
|
case -1:if (titles!=NULL)temp_storage_close_rd(titles);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -99,6 +99,7 @@ char runes[5]={0,0,0,0,0};
|
||||||
|
|
||||||
char group_sort[POCET_POSTAV]={0,1,2,3,4,5};
|
char group_sort[POCET_POSTAV]={0,1,2,3,4,5};
|
||||||
|
|
||||||
|
/*
|
||||||
int32_t load_section(FILE *f,void **section, int *sct_type,int32_t *sect_size)
|
int32_t load_section(FILE *f,void **section, int *sct_type,int32_t *sect_size)
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
|
@ -115,6 +116,33 @@ int32_t load_section(FILE *f,void **section, int *sct_type,int32_t *sect_size)
|
||||||
s=fread(*section,1,*sect_size,f);
|
s=fread(*section,1,*sect_size,f);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
static void ddl_file_deleter(void *ctx) {
|
||||||
|
ablock_free(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPFILE_RD *open_ddl_file(const char *name, int group) {
|
||||||
|
int32_t size;
|
||||||
|
if (!test_file_exist(group, name)) return NULL;
|
||||||
|
const void *data = afile(name, group, &size);
|
||||||
|
if (!data) return NULL;
|
||||||
|
return temp_storage_from_binary(data, size, &ddl_file_deleter, (void *)data);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t load_section_mem(TMPFILE_RD *f,void **section, int *sct_type,int32_t *sect_size) {
|
||||||
|
int32_t s;
|
||||||
|
char c[20];
|
||||||
|
|
||||||
|
*section=NULL;
|
||||||
|
temp_storage_read(c,sizeof(sekceid),f);
|
||||||
|
if (strcmp(c,sekceid)) return -1;
|
||||||
|
temp_storage_read(sct_type,sizeof(*sct_type),f);
|
||||||
|
temp_storage_read(sect_size,sizeof(*sect_size),f);
|
||||||
|
temp_storage_read(&s,sizeof(s),f);
|
||||||
|
*section=getmem(*sect_size);
|
||||||
|
s=temp_storage_read(*section,*sect_size,f);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int prepare_graphics(int *ofs,char *names,int32_t size,ABLOCK_DECODEPROC decomp,int class)
|
int prepare_graphics(int *ofs,char *names,int32_t size,ABLOCK_DECODEPROC decomp,int class)
|
||||||
|
@ -142,7 +170,7 @@ int load_level_texts(const char *filename)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
level_texts=create_list(10);
|
level_texts=create_list(10);
|
||||||
err=load_string_list_ex(&level_texts,filename);
|
err=load_string_list_ex(&level_texts,filename, SR_MAP);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +271,7 @@ void translate_map_name(const char *mapfile, MAPGLOBAL *mglob) {
|
||||||
|
|
||||||
int load_map(const char *filename)
|
int load_map(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
TMPFILE_RD *f;
|
||||||
void *temp;
|
void *temp;
|
||||||
int sect;
|
int sect;
|
||||||
int32_t size,r;
|
int32_t size,r;
|
||||||
|
@ -255,11 +283,9 @@ int load_map(const char *filename)
|
||||||
int failed = 0;
|
int failed = 0;
|
||||||
|
|
||||||
map_with_password=0;
|
map_with_password=0;
|
||||||
const char *mpath = build_pathname(2, gpathtable[SR_MAP], filename);
|
|
||||||
mpath = local_strdup(mpath);
|
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
zobraz_mysku();
|
zobraz_mysku();
|
||||||
f=fopen_icase(mpath,"rb");
|
f=open_ddl_file(filename, SR_MAP);
|
||||||
if (level_fname!=NULL) free(level_fname);
|
if (level_fname!=NULL) free(level_fname);
|
||||||
level_fname=(char *)getmem(strlen(filename)+1);
|
level_fname=(char *)getmem(strlen(filename)+1);
|
||||||
strcpy(level_fname,filename);
|
strcpy(level_fname,filename);
|
||||||
|
@ -270,7 +296,7 @@ int load_map(const char *filename)
|
||||||
if (f==NULL) return -1;
|
if (f==NULL) return -1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
r=load_section(f,&temp,§,&size);
|
r=load_section_mem(f,&temp,§,&size);
|
||||||
if (r==size)
|
if (r==size)
|
||||||
switch (sect)
|
switch (sect)
|
||||||
{
|
{
|
||||||
|
@ -396,17 +422,17 @@ int load_map(const char *filename)
|
||||||
{
|
{
|
||||||
if (temp!=NULL)free(temp);
|
if (temp!=NULL)free(temp);
|
||||||
ablock_free(mob_template);
|
ablock_free(mob_template);
|
||||||
fclose(f);
|
temp_storage_close_rd(f);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (nmapend);
|
while (nmapend);
|
||||||
ablock_free(mob_template);
|
ablock_free(mob_template);
|
||||||
fclose(f);
|
temp_storage_close_rd(f);
|
||||||
flag_map=(char *)getmem(mapsize*4);
|
flag_map=(char *)getmem(mapsize*4);
|
||||||
memset(minimap,0,sizeof(minimap));
|
memset(minimap,0,sizeof(minimap));
|
||||||
end_ptr=ofsts;
|
end_ptr=ofsts;
|
||||||
const char *tpath=set_file_extension(mpath,".txt");
|
const char *tpath=set_file_extension(filename,".txt");
|
||||||
failed=load_level_texts(tpath);
|
failed=load_level_texts(tpath);
|
||||||
if (!failed && level_texts!=NULL) {
|
if (!failed && level_texts!=NULL) {
|
||||||
lang_patch_stringtable(&level_texts, filename, "map_");
|
lang_patch_stringtable(&level_texts, filename, "map_");
|
||||||
|
|
|
@ -103,7 +103,6 @@ const void *pcx_8bit_decomp(const void *p, int32_t *s, int h);
|
||||||
const void *pcx_fade_decomp(const void *p, int32_t *s, int h);
|
const void *pcx_fade_decomp(const void *p, int32_t *s, int h);
|
||||||
const void *load_text_decomp(const void *p, int32_t *s, int h);
|
const void *load_text_decomp(const void *p, int32_t *s, int h);
|
||||||
|
|
||||||
const char *texty_knihy;
|
|
||||||
static const char *patch_file=NULL;
|
static const char *patch_file=NULL;
|
||||||
int cur_page=0;
|
int cur_page=0;
|
||||||
|
|
||||||
|
@ -805,14 +804,13 @@ void cti_texty(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
texty=(TSTR_LIST)create_list(4);
|
texty=(TSTR_LIST)create_list(4);
|
||||||
const char *path = build_pathname(2,gpathtable[SR_DATA], TEXTY);
|
if ((err=load_string_list_ex(&texty,TEXTY, SR_DATA))!=0)
|
||||||
if ((err=load_string_list_ex(&texty,path))!=0)
|
|
||||||
{
|
{
|
||||||
char buff[256];
|
char buff[256];
|
||||||
closemode();
|
closemode();
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case -1:sprintf(buff,"Can't load string table. File %s has not been found\n",path);break;
|
case -1:sprintf(buff,"Can't load string table. File %s has not been found\n",TEXTY);break;
|
||||||
case -2:sprintf(buff,"Missing end mark (-1) at the end of string table\n");break;
|
case -2:sprintf(buff,"Missing end mark (-1) at the end of string table\n");break;
|
||||||
case -3:sprintf(buff,"Memory very low (need min 4MB)\n");break;
|
case -3:sprintf(buff,"Memory very low (need min 4MB)\n");break;
|
||||||
default:sprintf(buff,"Error in string table at line %d\n",err);break;
|
default:sprintf(buff,"Error in string table at line %d\n",err);break;
|
||||||
|
@ -1012,16 +1010,6 @@ void init_skeldal(const INI_CONFIG *cfg)
|
||||||
init_DDL_manager();
|
init_DDL_manager();
|
||||||
show_loading_picture("LOADING.HI");
|
show_loading_picture("LOADING.HI");
|
||||||
|
|
||||||
if (lang_get_folder()) {
|
|
||||||
texty_knihy = build_pathname(2, lang_get_folder(), "book.txt");
|
|
||||||
if (!check_file_exists(texty_knihy)) {
|
|
||||||
texty_knihy=strdup(build_pathname(2,gpathtable[SR_MAP],"kniha.txt"));
|
|
||||||
} else {
|
|
||||||
texty_knihy=strdup(texty_knihy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
texty_knihy=strdup(build_pathname(2,gpathtable[SR_MAP],"kniha.txt"));
|
|
||||||
}
|
|
||||||
|
|
||||||
install_gui();
|
install_gui();
|
||||||
if (is_joystick_enabled()) {
|
if (is_joystick_enabled()) {
|
||||||
|
@ -1335,8 +1323,8 @@ void play_anim(int anim_num)
|
||||||
TSTR_LIST titl=NULL;
|
TSTR_LIST titl=NULL;
|
||||||
const char *s = build_pathname(2,gpathtable[SR_VIDEO], texty[anim_num]);
|
const char *s = build_pathname(2,gpathtable[SR_VIDEO], texty[anim_num]);
|
||||||
s = local_strdup(s);
|
s = local_strdup(s);
|
||||||
char *n = set_file_extension(s, ".TXT");
|
char *n = set_file_extension(texty[anim_num], ".TXT");
|
||||||
if (load_string_list_ex(&titl,n)) titl=NULL;
|
if (load_string_list_ex(&titl,n, SR_VIDEO)) titl=NULL;
|
||||||
else {
|
else {
|
||||||
lang_patch_stringtable(&titl, "intro", "");
|
lang_patch_stringtable(&titl, "intro", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ typedef struct _temp_storage_file_wr {
|
||||||
typedef struct _temp_storage_file_rd {
|
typedef struct _temp_storage_file_rd {
|
||||||
std::string_view _data;
|
std::string_view _data;
|
||||||
int skp = 0;
|
int skp = 0;
|
||||||
|
void (*deleter)(void *ctx) = nullptr;
|
||||||
|
void *deleter_ctx = nullptr;
|
||||||
} TMPFILE_RD;
|
} TMPFILE_RD;
|
||||||
|
|
||||||
struct icompare {
|
struct icompare {
|
||||||
|
@ -87,6 +89,7 @@ TMPFILE_WR* temp_storage_append(const char *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_storage_close_rd(TMPFILE_RD *f) {
|
void temp_storage_close_rd(TMPFILE_RD *f) {
|
||||||
|
if (f->deleter) f->deleter(f->deleter_ctx);
|
||||||
delete f;
|
delete f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,3 +170,9 @@ void temp_storage_ungetc(TMPFILE_RD *f) {
|
||||||
TMPFILE_RD *temp_storage_from_string(const char *content) {
|
TMPFILE_RD *temp_storage_from_string(const char *content) {
|
||||||
return new TMPFILE_RD{{content, std::strlen(content)}};
|
return new TMPFILE_RD{{content, std::strlen(content)}};
|
||||||
}
|
}
|
||||||
|
TMPFILE_RD *temp_storage_from_binary(const void *content, size_t sz, void (*deleter)(void *ctx), void *ctx) {
|
||||||
|
return new TMPFILE_RD{{static_cast<const char *>(content), sz}, 0, deleter, ctx};
|
||||||
|
}
|
||||||
|
uint32_t temp_storage_remain_size(TMPFILE_RD *f) {
|
||||||
|
return f->_data.size();
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ typedef struct _temp_storage_file_wr TMPFILE_WR;
|
||||||
|
|
||||||
TMPFILE_RD *temp_storage_open(const char *name);
|
TMPFILE_RD *temp_storage_open(const char *name);
|
||||||
TMPFILE_RD *temp_storage_from_string(const char *content);
|
TMPFILE_RD *temp_storage_from_string(const char *content);
|
||||||
|
TMPFILE_RD *temp_storage_from_binary(const void *content, size_t sz, void (*deleter)(void *ctx), void *ctx);
|
||||||
TMPFILE_WR *temp_storage_create(const char *name);
|
TMPFILE_WR *temp_storage_create(const char *name);
|
||||||
TMPFILE_WR *temp_storage_append(const char *name);
|
TMPFILE_WR *temp_storage_append(const char *name);
|
||||||
void temp_storage_delete(const char *name);
|
void temp_storage_delete(const char *name);
|
||||||
|
@ -26,6 +27,7 @@ char *temp_storage_gets(char *buff, size_t sz, TMPFILE_RD *f);
|
||||||
void temp_storage_ungetc(TMPFILE_RD *f);
|
void temp_storage_ungetc(TMPFILE_RD *f);
|
||||||
void temp_storage_write(const void *data, uint32_t size, TMPFILE_WR *f);
|
void temp_storage_write(const void *data, uint32_t size, TMPFILE_WR *f);
|
||||||
uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f);
|
uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f);
|
||||||
|
uint32_t temp_storage_remain_size(TMPFILE_RD *f);
|
||||||
void temp_storage_skip(TMPFILE_RD *f, int bytes);
|
void temp_storage_skip(TMPFILE_RD *f, int bytes);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
|
@ -140,7 +140,7 @@ uint32_t bk_global_counter=0;
|
||||||
char *swap_path;
|
char *swap_path;
|
||||||
|
|
||||||
|
|
||||||
static int test_file_exist_DOS(int group,char *filename)
|
static int test_file_exist_DOS(int group,const char *filename)
|
||||||
{
|
{
|
||||||
const char *f = build_pathname(2, mman_pathlist[group], filename);
|
const char *f = build_pathname(2, mman_pathlist[group], filename);
|
||||||
if (!check_file_exists(f)) return 0;
|
if (!check_file_exists(f)) return 0;
|
||||||
|
@ -180,7 +180,7 @@ static TNAMETABLE_REF load_file_table(const void *bmf_m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int get_file_entry_in_table(const TNAMETABLE_REF *where, char *name) {
|
int get_file_entry_in_table(const TNAMETABLE_REF *where, const char *name) {
|
||||||
for(uint32_t i = 0; i< where->count; ++i) {
|
for(uint32_t i = 0; i< where->count; ++i) {
|
||||||
if (strncmp(where->data[i].name, name, 12) == 0) {
|
if (strncmp(where->data[i].name, name, 12) == 0) {
|
||||||
return where->data[i].seek;
|
return where->data[i].seek;
|
||||||
|
@ -192,7 +192,7 @@ int get_file_entry_in_table(const TNAMETABLE_REF *where, char *name) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char get_file_entry(int group,char *name, THANDLE_DATA *h) {
|
char get_file_entry(int group,const char *name, THANDLE_DATA *h) {
|
||||||
char ex;
|
char ex;
|
||||||
|
|
||||||
ex=mman_patch && test_file_exist_DOS(group,name);
|
ex=mman_patch && test_file_exist_DOS(group,name);
|
||||||
|
@ -327,7 +327,7 @@ int find_handle(const char *name,ABLOCK_DECODEPROC decomp)
|
||||||
return find_same(name,decomp);
|
return find_same(name,decomp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_file_exist(int group,char *filename)
|
int test_file_exist(int group,const char *filename)
|
||||||
{
|
{
|
||||||
THANDLE_DATA h;
|
THANDLE_DATA h;
|
||||||
if (get_file_entry(group, filename, &h) == 0) return test_file_exist_DOS(group,filename);
|
if (get_file_entry(group, filename, &h) == 0) return test_file_exist_DOS(group,filename);
|
||||||
|
@ -369,7 +369,7 @@ THANDLE_DATA *def_handle(int handle,const char *filename,ABLOCK_DECODEPROC decom
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *afile(char *filename,int group,int32_t *blocksize)
|
const void *afile(const char *filename,int group,int32_t *blocksize)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
char entr;
|
char entr;
|
||||||
|
@ -401,7 +401,7 @@ const void *afile(char *filename,int group,int32_t *blocksize)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *afile_copy(char *filename,int group,int32_t *blocksize) {
|
void *afile_copy(const char *filename,int group,int32_t *blocksize) {
|
||||||
const void *ptr = afile(filename, group, blocksize);
|
const void *ptr = afile(filename, group, blocksize);
|
||||||
if (need_to_be_free(ptr)) return (void *)ptr;
|
if (need_to_be_free(ptr)) return (void *)ptr;
|
||||||
void *cpy = getmem(*blocksize);
|
void *cpy = getmem(*blocksize);
|
||||||
|
|
|
@ -95,9 +95,9 @@ void undef_handle(int handle); //uvolni hadle k dalsimu pouziti
|
||||||
THANDLE_DATA *zneplatnit_block(int handle); //zneplatni data bloku
|
THANDLE_DATA *zneplatnit_block(int handle); //zneplatni data bloku
|
||||||
THANDLE_DATA *get_handle(int handle); //vraci informace o rukojeti
|
THANDLE_DATA *get_handle(int handle); //vraci informace o rukojeti
|
||||||
int find_handle(const char *name,ABLOCK_DECODEPROC decomp); //hleda mezi rukojeti stejnou definici
|
int find_handle(const char *name,ABLOCK_DECODEPROC decomp); //hleda mezi rukojeti stejnou definici
|
||||||
int test_file_exist(int group,char *filename); //testuje zda soubor existuje v ramci mmanageru
|
int test_file_exist(int group,const char *filename); //testuje zda soubor existuje v ramci mmanageru
|
||||||
const void *afile(char *filename,int group,int32_t *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru
|
const void *afile(const char *filename,int group,int32_t *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru
|
||||||
void *afile_copy(char *filename,int group,int32_t *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru
|
void *afile_copy(const char *filename,int group,int32_t *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru
|
||||||
int32_t get_handle_size(int handle);
|
int32_t get_handle_size(int handle);
|
||||||
//void get_mem_info(MEMORYSTATUS *mem);
|
//void get_mem_info(MEMORYSTATUS *mem);
|
||||||
void ablock_free(const void *ptr);
|
void ablock_free(const void *ptr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue