|
@@ -31,7 +31,9 @@
|
|
|
#include <sqlite3.h>
|
|
#include <sqlite3.h>
|
|
|
#include <math.h>
|
|
#include <math.h>
|
|
|
#include <pthread.h>
|
|
#include <pthread.h>
|
|
|
-#include "../error.h"
|
|
|
|
|
|
|
+#include "../RuneOptimizer.h"
|
|
|
|
|
+#include "../error/error.h"
|
|
|
|
|
+#include "../db/db.h"
|
|
|
#include "optimize.h"
|
|
#include "optimize.h"
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -151,7 +153,9 @@ static unsigned char optimize_count_runes_for_sets(
|
|
|
* @return {@link SUCCESS} if the unit info is loaded, or
|
|
* @return {@link SUCCESS} if the unit info is loaded, or
|
|
|
* {@link ERROR_DB_SELECT_UNIT} if the unit doesn't exist in the database.
|
|
* {@link ERROR_DB_SELECT_UNIT} if the unit doesn't exist in the database.
|
|
|
*/
|
|
*/
|
|
|
-static int optimize_fetch_unit(char id[UNIT_NAME_LEN], struct Unit *unit);
|
|
|
|
|
|
|
+static int optimize_fetch_unit(
|
|
|
|
|
+ unsigned char id[UNIT_NAME_LEN], struct Unit *unit
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Generates the query to get the runes from the database for even slots.
|
|
* Generates the query to get the runes from the database for even slots.
|
|
@@ -215,7 +219,7 @@ static void optimize_query_for_odd_slots(
|
|
|
static int optimize_get_runes(
|
|
static int optimize_get_runes(
|
|
|
char query_even[RUNE_QUERY_LEN], char query_odd[RUNE_QUERY_LEN],
|
|
char query_even[RUNE_QUERY_LEN], char query_odd[RUNE_QUERY_LEN],
|
|
|
struct Rune runes[RUNE_SLOTS + 1][LIMIT_RUNES_PER_SLOT],
|
|
struct Rune runes[RUNE_SLOTS + 1][LIMIT_RUNES_PER_SLOT],
|
|
|
- int rune_count[RUNE_SLOTS + 1]
|
|
|
|
|
|
|
+ unsigned int rune_count[RUNE_SLOTS + 1]
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -235,7 +239,7 @@ static int optimize_get_runes(
|
|
|
*/
|
|
*/
|
|
|
static void optimize_print_summary(
|
|
static void optimize_print_summary(
|
|
|
struct Unit *unit, Optimizer_Options *options,
|
|
struct Unit *unit, Optimizer_Options *options,
|
|
|
- unsigned int rune_count[RUNE_SLOTS + 1], unsigned long max_combinations
|
|
|
|
|
|
|
+ unsigned int rune_count[RUNE_SLOTS + 1], unsigned long long max_combinations
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -419,7 +423,7 @@ extern int optimize(int argc, char *argv[]){
|
|
|
for (int t = 0; t < options.threads; t++){
|
|
for (int t = 0; t < options.threads; t++){
|
|
|
for (int i = 1; i < RUNE_SLOTS + 1; i ++){
|
|
for (int i = 1; i < RUNE_SLOTS + 1; i ++){
|
|
|
opt_data[t].count[i] = rune_count[i];
|
|
opt_data[t].count[i] = rune_count[i];
|
|
|
- for (int j = 0; j < rune_count[i]; j ++){
|
|
|
|
|
|
|
+ for (unsigned int j = 0; j < rune_count[i]; j ++){
|
|
|
opt_data[t].runes[i][j] = runes[i][j];
|
|
opt_data[t].runes[i][j] = runes[i][j];
|
|
|
}
|
|
}
|
|
|
opt_data[t].thread_id = t;
|
|
opt_data[t].thread_id = t;
|
|
@@ -451,7 +455,7 @@ extern int optimize(int argc, char *argv[]){
|
|
|
int results_pos = 0;
|
|
int results_pos = 0;
|
|
|
for (int t = 0; t < options.threads; t++){
|
|
for (int t = 0; t < options.threads; t++){
|
|
|
result_count += opt_data[t].total_results;
|
|
result_count += opt_data[t].total_results;
|
|
|
- for (int i = 0; i < opt_data[t].total_results; i ++){
|
|
|
|
|
|
|
+ for (unsigned int i = 0; i < opt_data[t].total_results; i ++){
|
|
|
results[results_pos] = opt_data[t].results[i];
|
|
results[results_pos] = opt_data[t].results[i];
|
|
|
results_pos ++;
|
|
results_pos ++;
|
|
|
}
|
|
}
|
|
@@ -481,7 +485,7 @@ extern int optimize(int argc, char *argv[]){
|
|
|
printf("{\"result_count\":0,\"results\":[]}\n");
|
|
printf("{\"result_count\":0,\"results\":[]}\n");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ return(SUCCESS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int optimize_parse_arguments(
|
|
static int optimize_parse_arguments(
|
|
@@ -496,11 +500,11 @@ static int optimize_parse_arguments(
|
|
|
return ERROR_INPUT_OPTIMIZE_NO_UNIT;
|
|
return ERROR_INPUT_OPTIMIZE_NO_UNIT;
|
|
|
}
|
|
}
|
|
|
if (strlen(argv[0]) > UNIT_NAME_LEN - 1){
|
|
if (strlen(argv[0]) > UNIT_NAME_LEN - 1){
|
|
|
- strncpy(options->id, argv[0], UNIT_NAME_LEN - 1);
|
|
|
|
|
|
|
+ strncpy((char *) options->id, argv[0], UNIT_NAME_LEN - 1);
|
|
|
options->id[UNIT_NAME_LEN - 1] = '\0';
|
|
options->id[UNIT_NAME_LEN - 1] = '\0';
|
|
|
}
|
|
}
|
|
|
else{
|
|
else{
|
|
|
- strcpy(options->id, argv[0]);
|
|
|
|
|
|
|
+ strcpy((char *) options->id, argv[0]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Loop command line arguments
|
|
// Loop command line arguments
|
|
@@ -549,7 +553,9 @@ static int optimize_parse_arguments(
|
|
|
// delimiters present in the list, or until its complete
|
|
// delimiters present in the list, or until its complete
|
|
|
while (token != NULL){
|
|
while (token != NULL){
|
|
|
strcpy(
|
|
strcpy(
|
|
|
- options->excluded_teams[options->total_excluded_teams],
|
|
|
|
|
|
|
+ (char *) options->excluded_teams[
|
|
|
|
|
+ options->total_excluded_teams
|
|
|
|
|
+ ],
|
|
|
token
|
|
token
|
|
|
);
|
|
);
|
|
|
options->total_excluded_teams ++;
|
|
options->total_excluded_teams ++;
|
|
@@ -582,7 +588,9 @@ static int optimize_parse_arguments(
|
|
|
// delimiters present in the list, or until its complete
|
|
// delimiters present in the list, or until its complete
|
|
|
while (token != NULL){
|
|
while (token != NULL){
|
|
|
strcpy(
|
|
strcpy(
|
|
|
- options->excluded_units[options->total_excluded_units],
|
|
|
|
|
|
|
+ (char *) options->excluded_units[
|
|
|
|
|
+ options->total_excluded_units
|
|
|
|
|
+ ],
|
|
|
token
|
|
token
|
|
|
);
|
|
);
|
|
|
options->total_excluded_units ++;
|
|
options->total_excluded_units ++;
|
|
@@ -1001,7 +1009,7 @@ static int optimize_parse_arguments(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void optimize_set_default_options(Optimizer_Options *options){
|
|
static void optimize_set_default_options(Optimizer_Options *options){
|
|
|
- strcpy(options->id, "");
|
|
|
|
|
|
|
+ strcpy((char *) options->id, "");
|
|
|
options->level = 0;
|
|
options->level = 0;
|
|
|
for (int i = 0; i < MAX_SETS; i ++) options->sets[i] = 0;
|
|
for (int i = 0; i < MAX_SETS; i ++) options->sets[i] = 0;
|
|
|
options->full_set = FALSE;
|
|
options->full_set = FALSE;
|
|
@@ -1133,9 +1141,11 @@ static unsigned char optimize_count_runes_for_sets(
|
|
|
return total_requested_runes;
|
|
return total_requested_runes;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static int optimize_fetch_unit(char id[UNIT_NAME_LEN], struct Unit *unit){
|
|
|
|
|
|
|
+static int optimize_fetch_unit(
|
|
|
|
|
+ unsigned char id[UNIT_NAME_LEN], struct Unit *unit
|
|
|
|
|
+){
|
|
|
sqlite3_stmt *stmt_unit;
|
|
sqlite3_stmt *stmt_unit;
|
|
|
- char *parameters[2] = {id, id};
|
|
|
|
|
|
|
+ char *parameters[2] = {(char *) id, (char *) id};
|
|
|
db_query(
|
|
db_query(
|
|
|
&stmt_unit,
|
|
&stmt_unit,
|
|
|
"SELECT "
|
|
"SELECT "
|
|
@@ -1154,8 +1164,10 @@ static int optimize_fetch_unit(char id[UNIT_NAME_LEN], struct Unit *unit){
|
|
|
sqlite3_finalize(stmt_unit);
|
|
sqlite3_finalize(stmt_unit);
|
|
|
return(ERROR_DB_SELECT_UNIT);
|
|
return(ERROR_DB_SELECT_UNIT);
|
|
|
}
|
|
}
|
|
|
- strcpy(unit->id, sqlite3_column_text(stmt_unit, 0));
|
|
|
|
|
- strcpy(unit->name, sqlite3_column_text(stmt_unit, 1));
|
|
|
|
|
|
|
+ strcpy((char *) unit->id, (const char *) sqlite3_column_text(stmt_unit, 0));
|
|
|
|
|
+ strcpy(
|
|
|
|
|
+ (char *) unit->name, (const char *)sqlite3_column_text(stmt_unit, 1)
|
|
|
|
|
+ );
|
|
|
unit->base_hp = sqlite3_column_int(stmt_unit, 2);
|
|
unit->base_hp = sqlite3_column_int(stmt_unit, 2);
|
|
|
unit->base_atk = sqlite3_column_int(stmt_unit, 3);
|
|
unit->base_atk = sqlite3_column_int(stmt_unit, 3);
|
|
|
unit->base_def = sqlite3_column_int(stmt_unit, 4);
|
|
unit->base_def = sqlite3_column_int(stmt_unit, 4);
|
|
@@ -1237,19 +1249,19 @@ static void optimize_query_for_even_slots(
|
|
|
if (options->storage == TRUE){
|
|
if (options->storage == TRUE){
|
|
|
// They are not null, are empty!
|
|
// They are not null, are empty!
|
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
|
- strcat(query, options->id);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->id);
|
|
|
strcat(query, "') -- Only storage\n");
|
|
strcat(query, "') -- Only storage\n");
|
|
|
}
|
|
}
|
|
|
// Excluded teams (overriden by storage option)
|
|
// Excluded teams (overriden by storage option)
|
|
|
if (options->storage == FALSE && options->total_excluded_teams > 0){
|
|
if (options->storage == FALSE && options->total_excluded_teams > 0){
|
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
|
- strcat(query, options->id);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->id);
|
|
|
strcat(
|
|
strcat(
|
|
|
query, "' OR unit NOT IN (SELECT unit FROM units_teams WHERE team IN("
|
|
query, "' OR unit NOT IN (SELECT unit FROM units_teams WHERE team IN("
|
|
|
);
|
|
);
|
|
|
for (int i = 0; i < options->total_excluded_teams; i ++){
|
|
for (int i = 0; i < options->total_excluded_teams; i ++){
|
|
|
strcat(query, "'");
|
|
strcat(query, "'");
|
|
|
- strcat(query, options->excluded_teams[i]);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->excluded_teams[i]);
|
|
|
strcat(query, "', ");
|
|
strcat(query, "', ");
|
|
|
}
|
|
}
|
|
|
query[strlen(query) - 2] = '\0'; // Remove last coma
|
|
query[strlen(query) - 2] = '\0'; // Remove last coma
|
|
@@ -1258,11 +1270,11 @@ static void optimize_query_for_even_slots(
|
|
|
// Excluded units (overriden by storage option)
|
|
// Excluded units (overriden by storage option)
|
|
|
if (options->storage == FALSE && options->total_excluded_units > 0){
|
|
if (options->storage == FALSE && options->total_excluded_units > 0){
|
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
|
- strcat(query, options->id);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->id);
|
|
|
strcat(query, "' OR unit NOT IN (");
|
|
strcat(query, "' OR unit NOT IN (");
|
|
|
for (int i = 0; i < options->total_excluded_units; i ++){
|
|
for (int i = 0; i < options->total_excluded_units; i ++){
|
|
|
strcat(query, "'");
|
|
strcat(query, "'");
|
|
|
- strcat(query, options->excluded_units[i]);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->excluded_units[i]);
|
|
|
strcat(query, "', ");
|
|
strcat(query, "', ");
|
|
|
}
|
|
}
|
|
|
query[strlen(query) - 2] = '\0'; // Remove last coma
|
|
query[strlen(query) - 2] = '\0'; // Remove last coma
|
|
@@ -1291,7 +1303,6 @@ static void optimize_query_for_even_slots(
|
|
|
static void optimize_query_for_odd_slots(Optimizer_Options *options, char query[RUNE_QUERY_LEN]){
|
|
static void optimize_query_for_odd_slots(Optimizer_Options *options, char query[RUNE_QUERY_LEN]){
|
|
|
char column[10];
|
|
char column[10];
|
|
|
char cur_set[MAX_SETS];
|
|
char cur_set[MAX_SETS];
|
|
|
- char stat_set[DIFFERENT_STATS];
|
|
|
|
|
if (options->level == LV12) strcpy(column, "lv12_");
|
|
if (options->level == LV12) strcpy(column, "lv12_");
|
|
|
else if (options->level == LV15) strcpy(column, "lv15_");
|
|
else if (options->level == LV15) strcpy(column, "lv15_");
|
|
|
else strcpy(column, "current_");
|
|
else strcpy(column, "current_");
|
|
@@ -1340,19 +1351,19 @@ static void optimize_query_for_odd_slots(Optimizer_Options *options, char query[
|
|
|
if (options->storage == TRUE){
|
|
if (options->storage == TRUE){
|
|
|
// They are not null, are empty!
|
|
// They are not null, are empty!
|
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
|
- strcat(query, options->id);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->id);
|
|
|
strcat(query, "') -- Only storage\n");
|
|
strcat(query, "') -- Only storage\n");
|
|
|
}
|
|
}
|
|
|
// Excluded teams (overriden by storage option)
|
|
// Excluded teams (overriden by storage option)
|
|
|
if (options->storage == FALSE && options->total_excluded_teams > 0){
|
|
if (options->storage == FALSE && options->total_excluded_teams > 0){
|
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
|
- strcat(query, options->id);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->id);
|
|
|
strcat(
|
|
strcat(
|
|
|
query, "' OR unit NOT IN (SELECT unit FROM units_teams WHERE team IN("
|
|
query, "' OR unit NOT IN (SELECT unit FROM units_teams WHERE team IN("
|
|
|
);
|
|
);
|
|
|
for (int i = 0; i < options->total_excluded_teams; i ++){
|
|
for (int i = 0; i < options->total_excluded_teams; i ++){
|
|
|
strcat(query, "'");
|
|
strcat(query, "'");
|
|
|
- strcat(query, options->excluded_teams[i]);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->excluded_teams[i]);
|
|
|
strcat(query, "', ");
|
|
strcat(query, "', ");
|
|
|
}
|
|
}
|
|
|
query[strlen(query) - 2] = '\0'; // Remove last coma
|
|
query[strlen(query) - 2] = '\0'; // Remove last coma
|
|
@@ -1361,11 +1372,11 @@ static void optimize_query_for_odd_slots(Optimizer_Options *options, char query[
|
|
|
// Excluded units (overriden by storage option)
|
|
// Excluded units (overriden by storage option)
|
|
|
if (options->storage == FALSE && options->total_excluded_units > 0){
|
|
if (options->storage == FALSE && options->total_excluded_units > 0){
|
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
strcat(query, " AND (unit = '' OR unit = '");
|
|
|
- strcat(query, options->id);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->id);
|
|
|
strcat(query, "' OR unit NOT IN (");
|
|
strcat(query, "' OR unit NOT IN (");
|
|
|
for (int i = 0; i < options->total_excluded_units; i ++){
|
|
for (int i = 0; i < options->total_excluded_units; i ++){
|
|
|
strcat(query, "'");
|
|
strcat(query, "'");
|
|
|
- strcat(query, options->excluded_units[i]);
|
|
|
|
|
|
|
+ strcat(query, (const char *) options->excluded_units[i]);
|
|
|
strcat(query, "', ");
|
|
strcat(query, "', ");
|
|
|
}
|
|
}
|
|
|
query[strlen(query) - 2] = '\0'; // Remove last coma
|
|
query[strlen(query) - 2] = '\0'; // Remove last coma
|
|
@@ -1383,22 +1394,28 @@ static void optimize_query_for_odd_slots(Optimizer_Options *options, char query[
|
|
|
|
|
|
|
|
static int optimize_get_runes(
|
|
static int optimize_get_runes(
|
|
|
char query_even[RUNE_QUERY_LEN], char query_odd[RUNE_QUERY_LEN],
|
|
char query_even[RUNE_QUERY_LEN], char query_odd[RUNE_QUERY_LEN],
|
|
|
- struct Rune runes[RUNE_SLOTS + 1][LIMIT_RUNES_PER_SLOT], int rune_count[RUNE_SLOTS + 1]
|
|
|
|
|
|
|
+ struct Rune runes[RUNE_SLOTS + 1][LIMIT_RUNES_PER_SLOT],
|
|
|
|
|
+ unsigned int rune_count[RUNE_SLOTS + 1]
|
|
|
){
|
|
){
|
|
|
char **query;
|
|
char **query;
|
|
|
- sqlite3 *db = NULL;
|
|
|
|
|
sqlite3_stmt *stmt_runes[RUNE_SLOTS + 1];
|
|
sqlite3_stmt *stmt_runes[RUNE_SLOTS + 1];
|
|
|
char *parameters[1];
|
|
char *parameters[1];
|
|
|
parameters[0] = malloc(sizeof(int));
|
|
parameters[0] = malloc(sizeof(int));
|
|
|
- for (char i = 1; i < RUNE_SLOTS + 1; i ++){
|
|
|
|
|
|
|
+ for (int i = 1; i < RUNE_SLOTS + 1; i ++){
|
|
|
if (i % 2 == 0) query = &query_even;
|
|
if (i % 2 == 0) query = &query_even;
|
|
|
else query = &query_odd;
|
|
else query = &query_odd;
|
|
|
sprintf(parameters[0], "%d", i);
|
|
sprintf(parameters[0], "%d", i);
|
|
|
db_query(&stmt_runes[i], *query, parameters);
|
|
db_query(&stmt_runes[i], *query, parameters);
|
|
|
int j = 0;
|
|
int j = 0;
|
|
|
while (SQLITE_ROW == sqlite3_step(stmt_runes[i])){
|
|
while (SQLITE_ROW == sqlite3_step(stmt_runes[i])){
|
|
|
- strcpy(runes[i][j].id, sqlite3_column_text(stmt_runes[i], 0));
|
|
|
|
|
- strcpy(runes[i][j].unit, sqlite3_column_text(stmt_runes[i], 1));
|
|
|
|
|
|
|
+ strcpy(
|
|
|
|
|
+ (char *) runes[i][j].id,
|
|
|
|
|
+ (const char *) sqlite3_column_text(stmt_runes[i], 0)
|
|
|
|
|
+ );
|
|
|
|
|
+ strcpy(
|
|
|
|
|
+ (char *) runes[i][j].unit,
|
|
|
|
|
+ (const char *) sqlite3_column_text(stmt_runes[i], 1)
|
|
|
|
|
+ );
|
|
|
runes[i][j].slot = sqlite3_column_int(stmt_runes[i], 2);
|
|
runes[i][j].slot = sqlite3_column_int(stmt_runes[i], 2);
|
|
|
runes[i][j].set = sqlite3_column_int(stmt_runes[i], 3);
|
|
runes[i][j].set = sqlite3_column_int(stmt_runes[i], 3);
|
|
|
runes[i][j].hp_flat = sqlite3_column_int(stmt_runes[i], 4);
|
|
runes[i][j].hp_flat = sqlite3_column_int(stmt_runes[i], 4);
|
|
@@ -1423,7 +1440,7 @@ static int optimize_get_runes(
|
|
|
|
|
|
|
|
static void optimize_print_summary(
|
|
static void optimize_print_summary(
|
|
|
struct Unit *unit, Optimizer_Options *options,
|
|
struct Unit *unit, Optimizer_Options *options,
|
|
|
- unsigned int rune_count[RUNE_SLOTS + 1], unsigned long max_combinations
|
|
|
|
|
|
|
+ unsigned int rune_count[RUNE_SLOTS + 1], unsigned long long max_combinations
|
|
|
){
|
|
){
|
|
|
// This is an output example:
|
|
// This is an output example:
|
|
|
////////////////////////////////
|
|
////////////////////////////////
|
|
@@ -1483,21 +1500,21 @@ static void optimize_print_summary(
|
|
|
3, rune_count[1], 3, rune_count[2], 3, rune_count[3]
|
|
3, rune_count[1], 3, rune_count[2], 3, rune_count[3]
|
|
|
);
|
|
);
|
|
|
printf(
|
|
printf(
|
|
|
- " | CRR: | %*d\% | %*d\% | %*d\% | 4:%*d 5:%*d 6:%*d\n",
|
|
|
|
|
|
|
+ " | CRR: | %*d%% | %*d%% | %*d%% | 4:%*d 5:%*d 6:%*d\n",
|
|
|
7, unit->base_crr, 7, unit->current_crr, 7, options->min_stats->crr,
|
|
7, unit->base_crr, 7, unit->current_crr, 7, options->min_stats->crr,
|
|
|
3, rune_count[4], 3, rune_count[5], 3, rune_count[6]
|
|
3, rune_count[4], 3, rune_count[5], 3, rune_count[6]
|
|
|
);
|
|
);
|
|
|
printf(
|
|
printf(
|
|
|
- " | CRD: | %*d\% | %*d\% | %*d\% |\n",
|
|
|
|
|
|
|
+ " | CRD: | %*d%% | %*d%% | %*d%% |\n",
|
|
|
7, unit->base_crd, 7, unit->current_crd, 7, options->min_stats->crd
|
|
7, unit->base_crd, 7, unit->current_crd, 7, options->min_stats->crd
|
|
|
);
|
|
);
|
|
|
printf(
|
|
printf(
|
|
|
- " | RES: | %*d\% | %*d\% | %*d\% | Total combinations: %llu\n",
|
|
|
|
|
|
|
+ " | RES: | %*d%% | %*d%% | %*d%% | Total combinations: %llu\n",
|
|
|
7, unit->base_res, 7, unit->current_res, 7, options->min_stats->res,
|
|
7, unit->base_res, 7, unit->current_res, 7, options->min_stats->res,
|
|
|
max_combinations
|
|
max_combinations
|
|
|
);
|
|
);
|
|
|
printf(
|
|
printf(
|
|
|
- " | ACC: | %*d\% | %*d\% | %*d\% |\n",
|
|
|
|
|
|
|
+ " | ACC: | %*d%% | %*d%% | %*d%% |\n",
|
|
|
7, unit->base_acc, 7, unit->current_acc, 7, options->min_stats->acc
|
|
7, unit->base_acc, 7, unit->current_acc, 7, options->min_stats->acc
|
|
|
);
|
|
);
|
|
|
printf(
|
|
printf(
|
|
@@ -1517,7 +1534,7 @@ static void *optimize_thread(void *data){
|
|
|
Optimizer_Data *opt_data = data;
|
|
Optimizer_Data *opt_data = data;
|
|
|
|
|
|
|
|
// Initialize arrys and some counters
|
|
// Initialize arrys and some counters
|
|
|
- int index[RUNE_SLOTS + 1] = {0, opt_data->start_at, 0, 0, 0, 0};
|
|
|
|
|
|
|
+ unsigned int index[RUNE_SLOTS + 1] = {0, opt_data->start_at, 0, 0, 0, 0};
|
|
|
unsigned long tested_combinations = 0;
|
|
unsigned long tested_combinations = 0;
|
|
|
unsigned long valid_sets = 0;
|
|
unsigned long valid_sets = 0;
|
|
|
unsigned long result_count = 0;
|
|
unsigned long result_count = 0;
|
|
@@ -1545,7 +1562,7 @@ static void *optimize_thread(void *data){
|
|
|
else{
|
|
else{
|
|
|
// For GUI flushing, newlines are required
|
|
// For GUI flushing, newlines are required
|
|
|
printf(
|
|
printf(
|
|
|
- "%d\n",
|
|
|
|
|
|
|
+ "%lu\n",
|
|
|
(unsigned long)( (tested_combinations + 1) /
|
|
(unsigned long)( (tested_combinations + 1) /
|
|
|
(unsigned long)(opt_data->max_combinations / 20)));
|
|
(unsigned long)(opt_data->max_combinations / 20)));
|
|
|
}
|
|
}
|
|
@@ -1713,8 +1730,8 @@ static void *optimize_thread(void *data){
|
|
|
// Create a result with rune indexes, stats, and rating.
|
|
// Create a result with rune indexes, stats, and rating.
|
|
|
for (int i = 1; i < RUNE_SLOTS + 1; i ++){
|
|
for (int i = 1; i < RUNE_SLOTS + 1; i ++){
|
|
|
strcpy(
|
|
strcpy(
|
|
|
- opt_data->results[result_count].rune_ids[i - 1],
|
|
|
|
|
- opt_data->runes[i][index[i]].id
|
|
|
|
|
|
|
+ (char *) opt_data->results[result_count].rune_ids[i - 1],
|
|
|
|
|
+ (const char *) opt_data->runes[i][index[i]].id
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
opt_data->results[result_count].stats.hp = stats.hp;
|
|
opt_data->results[result_count].stats.hp = stats.hp;
|
|
@@ -1850,10 +1867,10 @@ int optimize_print_result(struct Unit *unit, Result *result){
|
|
|
printf(" | ATK: | %*d | %*d |\n", 7, unit->current_atk, 7, result->stats.atk);
|
|
printf(" | ATK: | %*d | %*d |\n", 7, unit->current_atk, 7, result->stats.atk);
|
|
|
printf(" | DEF: | %*d | %*d |\n", 7, unit->current_def, 7, result->stats.def);
|
|
printf(" | DEF: | %*d | %*d |\n", 7, unit->current_def, 7, result->stats.def);
|
|
|
printf(" | SPD: | %*d | %*d |\n", 7, unit->current_spd, 7, result->stats.spd);
|
|
printf(" | SPD: | %*d | %*d |\n", 7, unit->current_spd, 7, result->stats.spd);
|
|
|
- printf(" | CRR: | %*d\% | %*d\% |\n", 7, unit->current_crr, 7, result->stats.crr);
|
|
|
|
|
- printf(" | CRD: | %*d\% | %*d\% |\n", 7, unit->current_crd, 7, result->stats.crd);
|
|
|
|
|
- printf(" | RES: | %*d\% | %*d\% |\n", 7, unit->current_res, 7, result->stats.res);
|
|
|
|
|
- printf(" | ACC: | %*d\% | %*d\% |\n", 7, unit->current_acc, 7, result->stats.acc);
|
|
|
|
|
|
|
+ printf(" | CRR: | %*d%% | %*d%% |\n", 7, unit->current_crr, 7, result->stats.crr);
|
|
|
|
|
+ printf(" | CRD: | %*d%% | %*d%% |\n", 7, unit->current_crd, 7, result->stats.crd);
|
|
|
|
|
+ printf(" | RES: | %*d%% | %*d%% |\n", 7, unit->current_res, 7, result->stats.res);
|
|
|
|
|
+ printf(" | ACC: | %*d%% | %*d%% |\n", 7, unit->current_acc, 7, result->stats.acc);
|
|
|
printf(" | EHP: | %*d | %*d |\n", 7, unit->current_ehp, 7, result->stats.ehp);
|
|
printf(" | EHP: | %*d | %*d |\n", 7, unit->current_ehp, 7, result->stats.ehp);
|
|
|
printf(" | DMG: | %*d | %*d |\n", 7, unit->current_dmg, 7, result->stats.dmg);
|
|
printf(" | DMG: | %*d | %*d |\n", 7, unit->current_dmg, 7, result->stats.dmg);
|
|
|
printf(" ------------------------------\n");
|
|
printf(" ------------------------------\n");
|
|
@@ -1906,7 +1923,7 @@ int optimize_print_result(struct Unit *unit, Result *result){
|
|
|
printf("\n");
|
|
printf("\n");
|
|
|
char *parameters[1];
|
|
char *parameters[1];
|
|
|
for (int i = 6; i != 0;){
|
|
for (int i = 6; i != 0;){
|
|
|
- parameters[0] = result->rune_ids[i - 1];
|
|
|
|
|
|
|
+ parameters[0] = (char *) result->rune_ids[i - 1];
|
|
|
sqlite3_stmt *rune_res;
|
|
sqlite3_stmt *rune_res;
|
|
|
|
|
|
|
|
db_query(
|
|
db_query(
|