mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-08-18 12:17:13 -04:00
Make DDL directory allocated and copied (to support update DDLs in MapEdit)
This commit is contained in:
parent
b33fb43d78
commit
96e6435998
2 changed files with 10 additions and 4 deletions
|
@ -178,8 +178,12 @@ static TNAMETABLE_REF load_file_table(const void *bmf_m)
|
|||
const uint32_t *src_table = (const uint32_t *)bmf_m;
|
||||
uint32_t grptabsiz = src_table[1];
|
||||
TNAMETABLE_REF out;
|
||||
out.data = (const TNAMETABLE *)((const char *)bmf_m + grptabsiz);
|
||||
out.count = (out.data[0].seek - grptabsiz)/sizeof(TNAMETABLE);
|
||||
const TNAMETABLE *ptr = (const TNAMETABLE *)((const char *)bmf_m + grptabsiz);
|
||||
size_t count = (ptr[0].seek - grptabsiz)/sizeof(TNAMETABLE);
|
||||
TNAMETABLE *tbl = NewArr(TNAMETABLE, count);
|
||||
memcpy(tbl,ptr, count * sizeof(TNAMETABLE) );
|
||||
out.data = tbl;
|
||||
out.count = count;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -345,6 +349,7 @@ void reload_ddls(void) {
|
|||
}
|
||||
dinfo->ptr = bmf;
|
||||
dinfo->size = bmf_s;
|
||||
ablock_free(dinfo->nametable.data);
|
||||
dinfo->nametable = load_file_table(bmf);
|
||||
}
|
||||
}
|
||||
|
@ -641,8 +646,9 @@ void close_manager()
|
|||
for(j=0;j<BK_MINOR_HANDLES;j ++) undef_handle(i*BK_MINOR_HANDLES+j);
|
||||
free(_handles[i]);
|
||||
}
|
||||
for (int i = 0; i < MAX_PATCHES; ++i) {
|
||||
for (int i = 0; i < MAX_PATCHES; ++i) if (ddlmap[i].ptr) {
|
||||
unmap_file((void *)ddlmap[i].ptr, ddlmap[i].size);
|
||||
ablock_free(ddlmap[i].nametable.data);
|
||||
free(ddlmap[i].path);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ const void* map_file_to_memory_cpp(const char *name, size_t *sz) {
|
|||
|
||||
std::filesystem::path p(reinterpret_cast<const char8_t *>(name));
|
||||
|
||||
HANDLE h = CreateFileW(p.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
HANDLE h = CreateFileW(p.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if (h == INVALID_HANDLE_VALUE) throw std::runtime_error(std::string("Failed to open file for mapping: ")+p.string());
|
||||
|
||||
LARGE_INTEGER fsize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue