Frantic fixing

This commit is contained in:
MysterD 2022-04-16 13:45:45 -07:00
parent 202315f260
commit ad9e8995d7
2 changed files with 15 additions and 3 deletions

View file

@ -1,4 +1,5 @@
#include <stdio.h>
#include <unistd.h>
#include "mod_cache.h"
#include "mods.h"
#include "mod.h"
@ -7,7 +8,7 @@
#include "pc/utils/md5.h"
#define MOD_CACHE_FILENAME "mod.cache"
#define MOD_CACHE_VERSION 3
#define MOD_CACHE_VERSION 4
#define MD5_BUFFER_SIZE 1024
struct ModCacheEntry* sModCacheHead = NULL;
@ -136,10 +137,20 @@ void mod_cache_add(struct Mod* mod, struct ModFile* file) {
if (!concat_path(modFilePath, mod->basePath, file->relativePath)) {
return;
}
normalize_path(modFilePath);
if (modFilePath[0] == '.' && (modFilePath[1] == '/' || modFilePath[1] == '\\')) {
char modAbsFilePath[SYS_MAX_PATH] = { 0 };
getcwd(modAbsFilePath, SYS_MAX_PATH-1);
strncat(modAbsFilePath, "/", SYS_MAX_PATH-1);
strncat(modAbsFilePath, modFilePath, SYS_MAX_PATH-1);
normalize_path(modAbsFilePath);
file->cachedPath = strdup(modAbsFilePath);
} else {
normalize_path(modFilePath);
file->cachedPath = strdup(modFilePath);
}
// hash and cache
file->cachedPath = strdup(modFilePath);
mod_cache_md5(file->cachedPath, file->dataHash);
mod_cache_add_internal(file->dataHash, 0, file->cachedPath);
}

View file

@ -269,6 +269,7 @@ void network_receive_mod_list_file(struct Packet* p) {
free((char*)file->cachedPath);
}
file->cachedPath = strdup(cache->path);
normalize_path(file->cachedPath);
}
}