Merge /home/marc/Projets/modmanager
This commit is contained in:
@@ -3,3 +3,4 @@
|
|||||||
build
|
build
|
||||||
build/*
|
build/*
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
.buildconfig
|
||||||
+5
-3
@@ -13,14 +13,16 @@ add_compile_options(-Wall -Wextra -pedantic -Werror)
|
|||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_search_module(GLIB REQUIRED glib-2.0)
|
pkg_search_module(GLIB REQUIRED glib-2.0)
|
||||||
pkg_search_module(audit REQUIRED libaudit)
|
pkg_search_module(AUDIT REQUIRED audit)
|
||||||
pkg_search_module(LIBXML REQUIRED libxml-2.0)
|
pkg_search_module(LIBXML REQUIRED libxml-2.0)
|
||||||
|
|
||||||
target_include_directories(ModManager PRIVATE ${GLIB_INCLUDE_DIRS} ${LIBXML_INCLUDE_DIRS})
|
target_include_directories(ModManager PRIVATE ${GLIB_INCLUDE_DIRS} ${LIBXML_INCLUDE_DIRS} ${AUDIT_INCLUDE_DIRS})
|
||||||
|
|
||||||
add_compile_options(-fsanitize=address)
|
add_compile_options(-fsanitize=address)
|
||||||
add_link_options(-fsanitize=address)
|
add_link_options(-fsanitize=address)
|
||||||
|
|
||||||
target_link_libraries(ModManager ${GLIB_LDFLAGS})
|
target_link_libraries(ModManager ${GLIB_LDFLAGS})
|
||||||
target_link_libraries(ModManager ${AUDIT_LIBRARIES})
|
|
||||||
target_link_libraries(ModManager ${LIBXML_LIBRARIES})
|
target_link_libraries(ModManager ${LIBXML_LIBRARIES})
|
||||||
|
target_link_libraries(ModManager ${AUDIT_LIBRARIES})
|
||||||
|
|
||||||
|
install(TARGETS ModManager DESTINATION bin)
|
||||||
+61
-2
@@ -514,6 +514,7 @@ int parseFOMod(const char * fomodFile, FOMod_t* fomod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getInputCount(const char * input) {
|
int getInputCount(const char * input) {
|
||||||
@@ -656,10 +657,64 @@ void freeFOMod(FOMod_t * fomod) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int stepCmpAsc(const void * stepA, const void * stepB) {
|
||||||
|
const FOModStep_t * step1 = (const FOModStep_t *)stepA;
|
||||||
|
const FOModStep_t * step2 = (const FOModStep_t *)stepB;
|
||||||
|
return strcmp(step1->name, step2->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int stepCmpDesc(const void * stepA, const void * stepB) {
|
||||||
|
const FOModStep_t * step1 = (const FOModStep_t *)stepA;
|
||||||
|
const FOModStep_t * step2 = (const FOModStep_t *)stepB;
|
||||||
|
return 1 - strcmp(step1->name, step2->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sortSteps(FOMod_t * fomod) {
|
||||||
|
switch(fomod->stepOrder) {
|
||||||
|
case ASC:
|
||||||
|
qsort(fomod->steps, fomod->stepCount, sizeof(*fomod->steps), stepCmpAsc);
|
||||||
|
break;
|
||||||
|
case DESC:
|
||||||
|
qsort(fomod->steps, fomod->stepCount, sizeof(*fomod->steps), stepCmpDesc);
|
||||||
|
break;
|
||||||
|
case ORD:
|
||||||
|
//ord mean that we keep the curent order, so no need to sort anything.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int groupCmpAsc(const void * stepA, const void * stepB) {
|
||||||
|
const FOModGroup_t * step1 = (const FOModGroup_t *)stepA;
|
||||||
|
const FOModGroup_t * step2 = (const FOModGroup_t *)stepB;
|
||||||
|
return strcmp(step1->name, step2->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int groupCmpDesc(const void * stepA, const void * stepB) {
|
||||||
|
const FOModGroup_t * step1 = (const FOModGroup_t *)stepA;
|
||||||
|
const FOModGroup_t * step2 = (const FOModGroup_t *)stepB;
|
||||||
|
return 1 - strcmp(step1->name, step2->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sortGroup(FOModGroup_t * group) {
|
||||||
|
switch(group->order) {
|
||||||
|
case ASC:
|
||||||
|
qsort(group->plugins, group->pluginCount, sizeof(*group->plugins), groupCmpAsc);
|
||||||
|
break;
|
||||||
|
case DESC:
|
||||||
|
qsort(group->plugins, group->pluginCount, sizeof(*group->plugins), groupCmpDesc);
|
||||||
|
break;
|
||||||
|
case ORD:
|
||||||
|
//ord mean that we keep the curent order, so no need to sort anything.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: support priority
|
||||||
int installFOMod(const char * modFolder, const char * destination) {
|
int installFOMod(const char * modFolder, const char * destination) {
|
||||||
char * fomodFolder = findFOModFolder(modFolder);
|
char * fomodFolder = findFOModFolder(modFolder);
|
||||||
if(fomodFolder == NULL) {
|
if(fomodFolder == NULL) {
|
||||||
fprintf(stderr, "FOMod folder not found, are you sure this is a fomod mod ?\n");
|
fprintf(stderr, "Fomod folder not found, are you sure this is a fomod mod ?\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,6 +733,8 @@ int installFOMod(const char * modFolder, const char * destination) {
|
|||||||
|
|
||||||
GList * flagList = NULL;
|
GList * flagList = NULL;
|
||||||
|
|
||||||
|
sortSteps(&fomod);
|
||||||
|
|
||||||
for(int i = 0; i < fomod.stepCount; i++) {
|
for(int i = 0; i < fomod.stepCount; i++) {
|
||||||
FOModStep_t * step = &fomod.steps[i];
|
FOModStep_t * step = &fomod.steps[i];
|
||||||
|
|
||||||
@@ -695,13 +752,14 @@ int installFOMod(const char * modFolder, const char * destination) {
|
|||||||
for(int groupId = 0; groupId < step->groupCount; groupId++ ) {
|
for(int groupId = 0; groupId < step->groupCount; groupId++ ) {
|
||||||
FOModGroup_t group = step->groups[groupId];
|
FOModGroup_t group = step->groups[groupId];
|
||||||
|
|
||||||
|
sortGroup(&group);
|
||||||
|
|
||||||
u_int8_t min;
|
u_int8_t min;
|
||||||
u_int8_t max;
|
u_int8_t max;
|
||||||
int inputCount = 0;
|
int inputCount = 0;
|
||||||
char *inputBuffer = NULL;
|
char *inputBuffer = NULL;
|
||||||
size_t bufferSize = 0;
|
size_t bufferSize = 0;
|
||||||
|
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
printfOptionsInOrder(group);
|
printfOptionsInOrder(group);
|
||||||
switch(group.type) {
|
switch(group.type) {
|
||||||
@@ -829,4 +887,5 @@ int installFOMod(const char * modFolder, const char * destination) {
|
|||||||
printf("FOMod successfully installed!\n");
|
printf("FOMod successfully installed!\n");
|
||||||
g_list_free(flagList);
|
g_list_free(flagList);
|
||||||
freeFOMod(&fomod);
|
freeFOMod(&fomod);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user