diff --git a/src/pc/mods/mod.c b/src/pc/mods/mod.c index 7cf485bd..a1753924 100644 --- a/src/pc/mods/mod.c +++ b/src/pc/mods/mod.c @@ -231,6 +231,26 @@ static bool mod_load_files(struct Mod* mod, char* modName, char* fullPath) { return true; } +static void mod_set_loading_order(struct Mod* mod) { + if (mod->fileCount <= 1) { + return; + } + + // TODO: add a way to specify the loading order of a mod's files? + + // By default, this is the alphabetical order on relative path + for (s32 i = 1; i < mod->fileCount; ++i) { + struct ModFile file = mod->files[i]; + for (s32 j = 0; j < i; ++j) { + if (strcmp(file.relativePath, mod->files[j].relativePath) < 0) { + memmove(mod->files + j + 1, mod->files + j, sizeof(struct ModFile) * (i - j)); + memcpy(mod->files + j, &file, sizeof(struct ModFile)); + break; + } + } + } +} + static void mod_extract_fields(struct Mod* mod) { // get full path char path[SYS_MAX_PATH] = { 0 }; @@ -372,6 +392,9 @@ bool mod_load(struct Mods* mods, char* basePath, char* modName) { return false; } + // set loading order + mod_set_loading_order(mod); + // extract fields mod_extract_fields(mod); diff --git a/src/pc/network/packets/packet_mod_list.c b/src/pc/network/packets/packet_mod_list.c index ce529279..cd62bccd 100644 --- a/src/pc/network/packets/packet_mod_list.c +++ b/src/pc/network/packets/packet_mod_list.c @@ -170,6 +170,11 @@ void network_receive_mod_list(struct Packet* p) { packet_read(p, &relativePathLength, sizeof(u16)); packet_read(p, file->relativePath, relativePathLength * sizeof(u8)); packet_read(p, &file->size, sizeof(u64)); + if (mod->isDirectory && !strstr(file->relativePath, "actors")) { + char tmp[SYS_MAX_PATH]; + snprintf(tmp, SYS_MAX_PATH, "%s-%s", mod->relativePath, file->relativePath); + memcpy(file->relativePath, tmp, strlen(tmp) + 1); + } normalize_path(file->relativePath); LOG_INFO(" '%s': %llu", file->relativePath, (u64)file->size); }