Kaynağa Gözat

Better organization of includes. Al the warnings thrown by -Wall and -Wextra are taken care of. Better makefile.

Iñigo Valentin 4 yıl önce
ebeveyn
işleme
7b10fff0d1

+ 105 - 56
Makefile

@@ -1,89 +1,138 @@
 # Try to detect operating system
 ifeq ($(OS),Windows_NT)
 	ifeq ($(shell uname -s),) # not in a bash-like shell
-		RM = del /F /Q
-		MKDIR = mkdir
+		OS_RM = del /F /Q
+		OS_CP = copy
+		OS_MKDIR = mkdir
 	else # in a bash-like shell, like msys
-		RM = rm -rf
-		MKDIR = mkdir -p
+		OS_RM = rm -rf
+		OS_CP = cp -rf
+		OS_MKDIR = mkdir -p
 	endif
-	EXTENSION=.exe
-	INC=-I C:\MinGW\lib
+	OS_EXTENSION=.exe
+	OS_INC=-I C:\MinGW\lib
 else
-	RM = rm -rf
-	MKDIR = mkdir -p
-	EXTENSION=
-	INC=
+	OS_RM = rm -rf
+	OS_CP = cp -rf
+	OS_MKDIR = mkdir -p
+	OS_EXTENSION=
+	OS_INC=
 endif
 
-SRC=src/RuneOptimizer/RuneOptimizer.c
+# Files to compile
+# For tests, RuneOptimizer.c is not included in the list: is is included from
+# each test file with a redefinition of main.
+FILES=src/RuneOptimizer/RuneOptimizer.c src/RuneOptimizer/*/*.c
+TESTU_FILES=src/test/RuneOptimizerUnitTest.c src/RuneOptimizer/*/*.c
+TESTI_FILES=src/test/RuneOptimizerIntegrationTest.c src/RuneOptimizer/*/*.c
+TESTE_FILES=src/test/RuneOptimizerE2ETest.c src/RuneOptimizer/*/*.c
+
+# Compiler
 CC=gcc
+
+# Compiler flags
 CFLAGS=
-OPTS_DEBUG=-Wall -g
-OPTS_TEST=
-OPTS=-O3
-OPTS_REPORT=-O3 -fdump-tree-all
+DEBUG_CFLAGS=-Wall -Wextra -g
+EXTRA_CFLAGS=-fdump-tree-all
+
+# Libraries for the compiler
 LIBS=-lsqlite3 -lm -ljson-c -lpthread
-OUT=bin/RuneOptimizer
-OUT_DEBUG=bin/RuneOptimizer_DEBUG
-TEST_SRC=src/test/RuneOptimizerTest.c
-TEST_SRC_UNIT=src/test/RuneOptimizerUnitTest.c
-TEST_SRC_INTEGRATION=src/test/RuneOptimizerIntegrationTest.c
-TEST_SRC_E2E=srctest/RuneOptimizerE2ETest.c
-TEST_OUT_UNIT=bin/RuneOptimizerUnitTest
-TEST_OUT_INTEGRATION=bin/RuneOptimizerIntegrationTest
-TEST_OUT_E2E=bin/RuneOptimizerE2ETest
-#TEST_FUNCTION=-nostartfiles -Wl,-emain_test
-TEST_FUNCTION=
-
-INSTALL_DIR=/usr/local/bin/
-GUI_INSTALL_DIR=/usr/share/
-GUI_EXECUTABLE_SRC=/usr/share/RuneOptimizerGUI/RuneOptimizer.py
-GUI_EXECUTABLE_DST=/usr/local/bin/RuneOptimizerGUI
-
-DOC_COMMAND=doxygen
 
+# Include direcotries (Win32 only)
+INC=$(OS_INC)
+
+# Optimization options
+OPTS=-O3
+TESTX_OPTS=
+DEBUG_OPTS=
+
+# Output files
+OUT_DIR=bin/
+OUT_EXT=$(OS_EXTENSION)
+OUT_NAME=runeoptimizer
+OUT=$(OUT_DIR)$(OUT_NAME)$(OUT_EXT)
+DEBUG_OUT_NAME=$(OUT_NAME)_debug
+DEBUG_OUT=$(OUT_DIR)$(DEBUG_OUT_NAME)$(OUT_EXT)
+TESTU_OUT_NAME=$(OUT_NAME)_test_unit
+TESTU_OUT=$(OUT_DIR)$(TESTU_OUT_NAME)$(OUT_EXT)
+TESTI_OUT_NAME=$(OUT_NAME)_test_integration
+TESTI_OUT=$(OUT_DIR)$(TESTI_OUT_NAME)$(OUT_EXT)
+TESTE_OUT_NAME=$(OUT_NAME)_test_e2e
+TESTE_OUT=$(OUT_DIR)$(TESTE_OUT_NAME)$(OUT_EXT)
+
+# Instalation directories
+INSTALL_CLI_SRC=$(OUT)
+INSTALL_GUI_SRC=RuneOptimizerGUI
+INSTALL_DIR_BASE=/usr/share/runeoptimizer/
+INSTALL_DIR_EXEC=/usr/local/bin/
+INSTALL_CLI_EXEC_SRC=$(INSTALL_DIR_BASE)$(OUT_NAME)$(OUT_EXT)
+INSTALL_GUI_EXEC_SRC=$(INSTALL_DIR_BASE)$(INSTALL_GUI_SRC)$(OUT_EXT)/RuneOptimizer.py
+INSTALL_CLI_EXEC_DST=$(INSTALL_DIR_EXEC)$(OUT_NAME)$(OUT_EXT)
+INSTALL_GUI_EXEC_DST=$(INSTALL_DIR_EXEC)$(OUT_NAME)-gui$(OUT_EXT)
+
+CMD_DOC=doxygen
+CMD_RM=$(OS_RM)
+CMD_CP=$(OS_CP)
+CMD_MKDIR=$(OS_MKDIR)
+
+# Default, just build RuneOptimizer
 default :
 	@echo Compiling...
-	@$(CC) -o $(OUT)$(EXTENSION) $(SRC) $(INC) $(LIBS) $(OPTS)
-	@echo Compiled executable $(OUT)$(EXTENSION)
+	@$(CC) -o $(OUT) $(CFLAGS) $(FILES) $(INC) $(LIBS) $(OPTS)
+	@echo Compiled executable $(OUT)
 
+# Debug, compile with extra flags and no optimization
 debug :
 	@echo Compiling with debug symbols...
-	@$(CC) -o $(OUT_DEBUG)$(EXTENSION) $(SRC) $(INC) $(LIBS)
-	@echo Compiled debug executable $(OUT_DEBUG)
+	$(CC) -o $(DEBUG_OUT) $(DEBUG_CFLAGS) $(FILES) $(INC) $(LIBS) $(DEBUG_OPTS)
+	@echo Compiled debug executable $(DEBUG_OUT)
 
+# Test, run default and compile the tests.
 test : default
 	@echo Generating tests...
-	@$(CC) $(OPTS_TEST) -o $(TEST_OUT_UNIT)$(EXTENSION) $(TEST_SRC_UNIT) $(INC) $(LIBS) $(TEST_FUNCTION)
-	@echo Compiled testing executable $(TEST_OUT_UNIT)$(EXTENSION)
-	@$(CC) $(OPTS_TEST) -o $(TEST_OUT_INTEGRATION)$(EXTENSION) $(TEST_SRC_INTEGRATION) $(INC) $(LIBS) $(TEST_FUNCTION)
-	@echo Compiled testing executable $(TEST_OUT_INTEGRATION)$(EXTENSION)
-	@$(CC) $(OPTS_TEST) -o $(TEST_OUT_E2E)$(EXTENSION) $(TEST_SRC_E2E) $(INC) $(LIBS) $(TEST_FUNCTION)
-	@echo Compiled testing executable $(TEST_OUT_E2E)$(EXTENSION)
+	@$(CC) -o $(TESTU_OUT) $(TESTU_FILES) $(INC) $(LIBS) $(TESTX_OPTS)
+	@echo Compiled testing executable $(TESTU_OUT)
+	@$(CC) -o $(TESTI_OUT) $(TESTI_FILES) $(INC) $(LIBS) $(TESTX_OPTS)
+	@echo Compiled testing executable $(TESTI_OUT)
+	@$(CC) -o $(TESTE_OUT) $(TESTE_FILES) $(INC) $(LIBS) $(TESTX_OPTS)
+	@echo Compiled testing executable $(TESTE_OUT)
 
+# Install, install to the system
 install :
 	@echo Installing...
-	@mkdir -p $(INSTALL_DIR)
-	@cp $(OUT)$(EXTENSION) $(INSTALL_DIR)
-	@cp -rf RuneOptimizerGUI $(GUI_INSTALL_DIR)
-	-@rm $(GUI_EXECUTABLE_DST)
-	@ln -s $(GUI_EXECUTABLE_SRC) $(GUI_EXECUTABLE_DST)
+	@$(CMD_MKDIR) $(INSTALL_DIR_BASE)
+	@$(CMD_CP) $(INSTALL_CLI_SRC) $(INSTALL_DIR_BASE)
+	@$(CMD_CP) $(INSTALL_GUI_SRC) $(INSTALL_DIR_BASE)
+	-@$(CMD_RM) $(INSTALL_CLI_EXEC_DST)
+	-@$(CMD_RM) $(INSTALL_GUI_EXEC_DST)
+	@ln -s $(INSTALL_CLI_EXEC_SRC) $(INSTALL_CLI_EXEC_DST)
+	@ln -s $(INSTALL_GUI_EXEC_SRC) $(INSTALL_GUI_EXEC_DST)
 	@echo Installed RuneOptimizer and RuneOptimizerGUI
 
+# Unisnstall, delete every file create by install in the system
+uninstall :
+	@echo Uninstalling...
+	@$(CMD_RM) $(INSTALL_CLI_EXEC_DST)
+	@$(CMD_RM) $(INSTALL_GUI_EXEC_DST)
+	@$(CMD_RM) $(INSTALL_DIR_BASE)
+	@echo RuneOptimizer and RuneOptimizerGUI uninstalled.
+
+# Docs, generate doxygen documentation
 docs :
-        ifeq ($(shell which $(DOC_COMMAND)),)
-	$(error "No $(DOC_COMMAND) commannd found. Install it and run 'make doc' to generate documentation")
+        ifeq ($(shell which $(CMD_DOC)),)
+	$(error "No $(CMD_DOC) commannd found. Install it and run 'make doc' to generate documentation")
         else
 	@echo Generating documentation...
-	@mkdir -p doc/cli
-	@mkdir -p doc/gui
-	@doxygen doxygen-cli.conf
-	@doxygen doxygen-gui.conf 2>/dev/null
+	@$(CMD_MKDIR) doc/cli
+	@$(CMD_MKDIR) doc/gui
+	@$(CMD_DOC) doxygen-cli.conf
+	@$(CMD_DOC) doxygen-gui.conf 2>/dev/null
 	@echo Documentation generated in doc/
         endif
+
+# Clean, remove all geenerated files
 clean :
 	@echo Cleaning...
-	@$(RM) bin/*
-	@$(RM) doc/*
+	@$(CMD_RM) bin/*
+	@$(CMD_RM) doc/*
 	@echo All clean

+ 2 - 2
RuneOptimizerGUI/classes/PanelOptimizer.py

@@ -681,7 +681,7 @@ class PanelOptimizer(wx.Panel):
             baseCrr = 100
         baseDmg = math.ceil(
           (baseAtk * (100 - baseCrr) / 100) +
-          (baseAtk * (      baseCrr  / 100) * baseCrd / 100)
+          (baseAtk * (      baseCrr  / 100) * (baseCrd + 100) / 100)
         )
         self.statGrid.SetCellValue(row=9, col=0, s=str(baseDmg))
         self.minStatSlidList[9].SetMin(baseDmg)
@@ -695,7 +695,7 @@ class PanelOptimizer(wx.Panel):
             currentCrr = 100
         currentDmg = math.ceil(
           (currentAtk * (100 - currentCrr) / 100) +                   # Non-crit
-          (currentAtk * (      currentCrr  / 100) * currentCrd / 100) # Crit
+          (currentAtk * (      currentCrr  / 100) * (currentCrd + 100) / 100) # Crit
         )
         self.statGrid.SetCellValue(row=9, col=1, s=str(currentDmg))
         self.minStatSlidList[9].SetValue(currentDmg)

+ 1 - 1
RuneOptimizerGUI/classes/PanelResults.py

@@ -608,7 +608,7 @@ class PanelResults(wx.Panel):
             crd = row[5]
             dmg = math.ceil(
               (atk * (100 - crr) / 100) +            # Non-crit
-              (atk * (      crr  / 100) * crd / 100) # Crit
+              (atk * (      crr  / 100) * (crd + 100) / 100) # Crit
             )
             self.unitStats[9] = dmg
 

+ 2 - 2
RuneOptimizerGUI/classes/PanelUnits.py

@@ -672,7 +672,7 @@ class PanelUnits(wx.Panel):
             baseCrr = 100
         baseDmg = math.ceil(
           (baseAtk * (100 - baseCrr) / 100) +
-          ((baseAtk + (baseAtk * baseCrd / 100)) * baseCrr / 100)
+          (baseAtk * (      baseCrr  / 100) * (baseCrd + 100) / 100)
         )
         self.statGrid.SetCellValue(row=9, col=0, s=str(baseDmg))
         currentAtk = int(self.statGrid.GetCellValue(row=1, col=1))
@@ -684,7 +684,7 @@ class PanelUnits(wx.Panel):
             currentCrr = 100
         currentDmg = math.ceil(
           (currentAtk * (100 - currentCrr) / 100) +                   # Non-crit
-          (currentAtk * (      currentCrr  / 100) * currentCrd / 100) # Crit
+          (currentAtk * (      currentCrr  / 100) * (currentCrd + 100) / 100) # Crit
         )
         self.statGrid.SetCellValue(row=9, col=1, s=str(currentDmg))
 

+ 48 - 9
src/RuneOptimizer/RuneOptimizer.c

@@ -31,14 +31,14 @@
 #include <math.h>
 #include "RuneOptimizer.h"
 #include "error/error.h"
-#include "db/db.c"
-#include "help/help.c"
-#include "optimize/optimize.c"
-#include "team/team.c"
-#include "unit/unit.c"
-#include "update/update.c"
-#include "player/player.c"
-#include "gui/gui.c"
+#include "db/db.h"
+#include "help/help.h"
+#include "optimize/optimize.h"
+#include "team/team.h"
+#include "unit/unit.h"
+#include "update/update.h"
+#include "player/player.h"
+#include "gui/gui.h"
 
 /**
  * DEF stat multiplier.
@@ -153,6 +153,45 @@
 sqlite3 *db = NULL;
 char db_location[DB_PATH_LEN];
 
+const char STAT_NAMES[DIFFERENT_STATS][9] = {
+  "NULL", "HP_FLAT", "HP",  "ATK_FLAT", "ATK", "DEF_FLAT",
+  "DEF",  "NULL",    "SPD", "CRR",      "CRD", "RES",      "ACC"
+};
+
+const char SET_NAMES[DIFFERENT_SETS][9] = {
+  "NULL",    "ENERGY",  "GUARD",    "SWIFT",   "BLADE",    "RAGE",
+  "FOCUS",   "ENDURE",  "FATAL",    "NULL",    "DESPAIR",  "VAMPIRE",
+  "NULL",    "VIOLENT", "NEMESIS",  "WILL",    "SHIELD",   "REVENGE",
+  "DESTROY", "FIGHT",   "DETERMIN", "ENHANCE", "ACCURACY", "TOLERANCE"
+};
+const char QUALITY_NAMES[DIFFERENT_QUALITIES][9] = {
+  "NULL",
+  "NORMAL",   "MAGIC",   "RARE",   "HERO",    "LEGEND",  // 1-5
+  "NULL",     "NULL",    "NULL",   "NULL",    "NULL",
+  "A.NORMAL", "A.MAGIC", "A.RARE", "A.HERO",  "A.LEGEND" //11-15
+};
+const char STAT_NAMES_PRINTABLE[DIFFERENT_STATS][12] = {
+  "NULL",
+  "HP  %4d  ", "HP  %4d%% ", "ATK %4d  ", "ATK %4d%% ", "DEF %4d  ", "DEF %4d%% ", // 1-6
+  "NULL",
+  "SPD %4d  ", "CRR %4d%% ", "CRD %4d%% ", "RES %4d%% ", "ACC %4d%% " // 8-12
+};
+const int STAT_ROLL_MAX[DIFFERENT_STATS][RUNE_MAX_STARS + 1] = {
+  {-1, -1, -1, -1, -1, -1, -1}, // NULL (unused)
+  {-1, 60, 105, 165, 225, 300, 375}, // HP
+  {-1, 2, 3, 5, 6, 7, 8}, // HP%
+  {-1, 4, 5, 8, 10, 15, 20}, // ATK
+  {-1, 2, 3, 5, 6, 7, 8}, // ATK%
+  {-1, 4, 5, 8, 10, 15, 20}, // DEF
+  {-1, 2, 3, 5, 6, 7, 8}, // DEF%
+  {-1, -1, -1, -1, -1, -1, -1}, // NULL (unused)
+  {-1, 1, 2, 3, 4, 5, 6}, // SPD
+  {-1, 1, 2, 3, 4, 5, 6}, // CRR
+  {-1, 2, 3, 4, 5, 5, 7}, // CRD
+  {-1, 2, 3, 4, 5, 7, 8}, // RES
+  {-1, 2, 3, 4, 5, 7, 8} // ACC
+};
+
 extern unsigned int calculate_ehp(unsigned int hp, unsigned short def){
     // Sorry, but this is the formula, and I don't understand it either.
     // Take it or leave it.
@@ -172,7 +211,7 @@ extern unsigned short calculate_dmg(
     }
     unsigned short dmg = ceil(
       ((float)atk * ((PERCENT - crr_capped) / PERCENT)) + // Non-crit
-      ((float)atk * (crr_capped / PERCENT) * ((float)crd / PERCENT)) // Crit
+      ((float)atk * (crr_capped / PERCENT) * ((float)(crd + 100) / PERCENT)) // Crit
     );
     return(dmg);
 }

+ 7 - 38
src/RuneOptimizer/RuneOptimizer.h

@@ -733,10 +733,7 @@ typedef struct Rune_Set_Count {
  * Indexed by Com2Us ID. Watch out for indexes 0 and 7, they are undefined in
  * the game.
  */
-const char STAT_NAMES[DIFFERENT_STATS][9] = {
-  "NULL", "HP_FLAT", "HP",  "ATK_FLAT", "ATK", "DEF_FLAT",
-  "DEF",  "NULL",    "SPD", "CRR",      "CRD", "RES",      "ACC"
-};
+extern const char STAT_NAMES[DIFFERENT_STATS][9];
 
 /**
  * Names for rune sets.
@@ -744,12 +741,7 @@ const char STAT_NAMES[DIFFERENT_STATS][9] = {
  * Indexed by Com2Us ID.Watch out for indexes 0, 9 and 12, they are undefined in
  * the game.
  */
-const char SET_NAMES[DIFFERENT_SETS][9] = {
-  "NULL",    "ENERGY",  "GUARD",    "SWIFT",   "BLADE",    "RAGE",
-  "FOCUS",   "ENDURE",  "FATAL",    "NULL",    "DESPAIR",  "VAMPIRE",
-  "NULL",    "VIOLENT", "NEMESIS",  "WILL",    "SHIELD",   "REVENGE",
-  "DESTROY", "FIGHT",   "DETERMIN", "ENHANCE", "ACCURACY", "TOLERANCE"
-};
+extern const char SET_NAMES[DIFFERENT_SETS][9];
 
 /**
  * Names for rune qualities.
@@ -757,12 +749,7 @@ const char SET_NAMES[DIFFERENT_SETS][9] = {
  * Indexed by Com2Us ID. 1-5 are qualities for normal runes, 11-15 for ancient
  * runes. All the others are not defined in the game,
  */
-const char QUALITY_NAMES[DIFFERENT_QUALITIES][9] = {
-  "NULL",
-  "NORMAL",   "MAGIC",   "RARE",   "HERO",    "LEGEND",  // 1-5
-  "NULL",     "NULL",    "NULL",   "NULL",    "NULL",
-  "A.NORMAL", "A.MAGIC", "A.RARE", "A.HERO",  "A.LEGEND" //11-15
-};
+extern const char QUALITY_NAMES[DIFFERENT_QUALITIES][9];
 
 /**
  * Names for rune stats, in a printable format.
@@ -774,12 +761,7 @@ const char QUALITY_NAMES[DIFFERENT_QUALITIES][9] = {
  * Indexed by Com2Us ID. Watch out for indexes 0 and 7, they are undefined in
  * the game.
  */
-const char STAT_NAMES_PRINTABLE[DIFFERENT_STATS][12] = {
-  "NULL",
-  "HP  %4d  ", "HP  %4d%% ", "ATK %4d  ", "ATK %4d%% ", "DEF %4d  ", "DEF %4d%% ", // 1-6
-  "NULL",
-  "SPD %4d  ", "CRR %4d%% ", "CRD %4d%% ", "RES %4d%% ", "ACC %4d%% " // 8-12
-};
+extern const char STAT_NAMES_PRINTABLE[DIFFERENT_STATS][12];
 
 /**
  * Max roll values for each stat.
@@ -790,21 +772,7 @@ const char STAT_NAMES_PRINTABLE[DIFFERENT_STATS][12] = {
  *
  * @todo For ancient runes, the initial rolls are higher.
  */
-const int STAT_ROLL_MAX[DIFFERENT_STATS][RUNE_MAX_STARS + 1] = {
-  {-1, -1, -1, -1, -1, -1, -1}, // NULL (unused)
-  {-1, 60, 105, 165, 225, 300, 375}, // HP
-  {-1, 2, 3, 5, 6, 7, 8}, // HP%
-  {-1, 4, 5, 8, 10, 15, 20}, // ATK
-  {-1, 2, 3, 5, 6, 7, 8}, // ATK%
-  {-1, 4, 5, 8, 10, 15, 20}, // DEF
-  {-1, 2, 3, 5, 6, 7, 8}, // DEF%
-  {-1, -1, -1, -1, -1, -1, -1}, // NULL (unused)
-  {-1, 1, 2, 3, 4, 5, 6}, // SPD
-  {-1, 1, 2, 3, 4, 5, 6}, // CRR
-  {-1, 2, 3, 4, 5, 5, 7}, // CRD
-  {-1, 2, 3, 4, 5, 7, 8}, // RES
-  {-1, 2, 3, 4, 5, 7, 8} // ACC
-};
+extern const int STAT_ROLL_MAX[DIFFERENT_STATS][RUNE_MAX_STARS + 1];
 
 /**
  * Global database connection.
@@ -836,7 +804,8 @@ extern unsigned int calculate_ehp(unsigned int hp, unsigned short def);
  * Calculates damage.
  *
  * DMG is a complex stat, depending on ATK, CRR and CRD. In short, the formula
- * is (atk * ((100 - crr_capped) / 100)) +  (atk * (crr / 100) * (crd / 100)) .
+ * is
+ * (atk * ((100 - crr) / 100)) +  (atk * (crr / 100) * ((100 + crd) / 100)) .
  *
  * @param[in] atk ATK stat.
  * @param[in] crr CRR stat.

+ 12 - 5
src/RuneOptimizer/db/db.c

@@ -76,6 +76,7 @@ extern int db_close(){
 }
 
 extern int db_open(char *path){
+    db_close();
     char exists = TRUE;
     if (access( db_location, F_OK ) != 0) {
         exists = FALSE;
@@ -100,8 +101,10 @@ extern int db_open(char *path){
     }
 
     // If the database was just created, create the tables
-    if (exists == FALSE){
-        db_create_tables();
+    if (exists == FALSE && access( db_location, F_OK ) == 0){
+        if (SUCCESS != db_create_tables()){
+            return ERROR_DB_CANT_OPEN;
+        }
     }
 
     return(SUCCESS);
@@ -110,7 +113,9 @@ extern int db_open(char *path){
 extern int db_query(sqlite3_stmt **stmt, char query[], char *parameters[]){
 
     // If the connection has not been initialized, do it now
-    if (NULL == db) db_open(NULL);
+    if (NULL == db && SUCCESS != db_open(NULL)){
+        return ERROR_DB_CANT_OPEN;
+    }
 
 
     if (SQLITE_OK != sqlite3_prepare_v2(db, query, -1, stmt, 0)) {
@@ -140,7 +145,9 @@ extern int db_query(sqlite3_stmt **stmt, char query[], char *parameters[]){
 extern int db_execute(char query[], char *parameters[]){
 
     // If the connection has not been initialized, do it now
-    if (NULL == db) db_open(NULL);
+    if (NULL == db && SUCCESS != db_open(NULL)){
+        return ERROR_DB_CANT_OPEN;
+    }
 
     sqlite3_stmt *stmt;
     if (SQLITE_OK != sqlite3_prepare_v2(db, query, -1, &stmt, 0)) {
@@ -179,7 +186,7 @@ extern int db_execute(char query[], char *parameters[]){
 static void db_create_directories(){
     char dir_to_make[sizeof(db_location)];
     int last_path_separator = -1;
-    for(int i = 0; i < strlen(db_location); i++){
+    for(int i = 0; i < (int) strlen(db_location); i ++){
         if(db_location[i] == '/' || db_location[i] == '\\'){
             last_path_separator = i + 1;
         }

+ 2 - 1
src/RuneOptimizer/gui/gui.c

@@ -24,9 +24,10 @@
  * {@link gui.h}.
  */
 
+#include <stddef.h>
 #include "gui.h"
 #include "../db/db.h"
 
 int gui(){
-    db_open(NULL);
+    return(db_open(NULL));
 }

+ 2 - 0
src/RuneOptimizer/help/help.c

@@ -24,6 +24,8 @@
  * {@link help.h}.
  */
 
+#include <stdio.h>
+#include "../RuneOptimizer.h"
 #include "help.h"
 
 void help(){

+ 63 - 46
src/RuneOptimizer/optimize/optimize.c

@@ -31,7 +31,9 @@
 #include <sqlite3.h>
 #include <math.h>
 #include <pthread.h>
-#include "../error.h"
+#include "../RuneOptimizer.h"
+#include "../error/error.h"
+#include "../db/db.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
  * {@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.
@@ -215,7 +219,7 @@ static void optimize_query_for_odd_slots(
 static int optimize_get_runes(
   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]
+  unsigned int rune_count[RUNE_SLOTS + 1]
 );
 
 /**
@@ -235,7 +239,7 @@ static int optimize_get_runes(
  */
 static void optimize_print_summary(
   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 i = 1; i < RUNE_SLOTS + 1; 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].thread_id = t;
@@ -451,7 +455,7 @@ extern int optimize(int argc, char *argv[]){
     int results_pos = 0;
     for (int t = 0; t < options.threads; t++){
         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_pos ++;
         }
@@ -481,7 +485,7 @@ extern int optimize(int argc, char *argv[]){
             printf("{\"result_count\":0,\"results\":[]}\n");
         }
     }
-
+    return(SUCCESS);
 }
 
 static int optimize_parse_arguments(
@@ -496,11 +500,11 @@ static int optimize_parse_arguments(
         return ERROR_INPUT_OPTIMIZE_NO_UNIT;
     }
     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';
     }
     else{
-        strcpy(options->id, argv[0]);
+        strcpy((char *) options->id, argv[0]);
     }
 
     // Loop command line arguments
@@ -549,7 +553,9 @@ static int optimize_parse_arguments(
                 // delimiters present in the list, or until its complete
                 while (token != NULL){
                     strcpy(
-                      options->excluded_teams[options->total_excluded_teams],
+                      (char *) options->excluded_teams[
+                        options->total_excluded_teams
+                      ],
                       token
                     );
                     options->total_excluded_teams ++;
@@ -582,7 +588,9 @@ static int optimize_parse_arguments(
                 // delimiters present in the list, or until its complete
                 while (token != NULL){
                     strcpy(
-                      options->excluded_units[options->total_excluded_units],
+                      (char *) options->excluded_units[
+                        options->total_excluded_units
+                      ],
                       token
                     );
                     options->total_excluded_units ++;
@@ -1001,7 +1009,7 @@ static int optimize_parse_arguments(
 }
 
 static void optimize_set_default_options(Optimizer_Options *options){
-    strcpy(options->id, "");
+    strcpy((char *) options->id, "");
     options->level = 0;
     for (int i = 0; i < MAX_SETS; i ++) options->sets[i] = 0;
     options->full_set = FALSE;
@@ -1133,9 +1141,11 @@ static unsigned char optimize_count_runes_for_sets(
     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;
-    char *parameters[2] = {id, id};
+    char *parameters[2] = {(char *) id, (char *) id};
     db_query(
       &stmt_unit,
       "SELECT "
@@ -1154,8 +1164,10 @@ static int optimize_fetch_unit(char id[UNIT_NAME_LEN], struct Unit *unit){
         sqlite3_finalize(stmt_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_atk = sqlite3_column_int(stmt_unit, 3);
     unit->base_def = sqlite3_column_int(stmt_unit, 4);
@@ -1237,19 +1249,19 @@ static void optimize_query_for_even_slots(
     if (options->storage == TRUE){
         // They are not null, are empty!
         strcat(query, "  AND (unit = '' OR unit = '");
-        strcat(query, options->id);
+        strcat(query, (const char *) options->id);
         strcat(query, "') -- Only storage\n");
     }
     // Excluded teams (overriden by storage option)
     if (options->storage == FALSE && options->total_excluded_teams > 0){
         strcat(query, "  AND (unit = '' OR unit = '");
-        strcat(query, options->id);
+        strcat(query, (const char *) options->id);
         strcat(
         query, "' OR unit NOT IN (SELECT unit FROM units_teams WHERE team IN("
         );
         for (int i = 0; i < options->total_excluded_teams; i ++){
             strcat(query, "'");
-            strcat(query, options->excluded_teams[i]);
+            strcat(query, (const char *) options->excluded_teams[i]);
             strcat(query, "', ");
         }
         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)
     if (options->storage == FALSE && options->total_excluded_units > 0){
         strcat(query, " AND (unit = '' OR unit = '");
-        strcat(query, options->id);
+        strcat(query, (const char *) options->id);
         strcat(query, "' OR unit NOT IN (");
         for (int i = 0; i < options->total_excluded_units; i ++){
             strcat(query, "'");
-            strcat(query, options->excluded_units[i]);
+            strcat(query, (const char *) options->excluded_units[i]);
             strcat(query, "', ");
         }
         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]){
     char column[10];
     char cur_set[MAX_SETS];
-    char stat_set[DIFFERENT_STATS];
     if (options->level == LV12) strcpy(column, "lv12_");
     else if (options->level == LV15) strcpy(column, "lv15_");
     else strcpy(column, "current_");
@@ -1340,19 +1351,19 @@ static void optimize_query_for_odd_slots(Optimizer_Options *options, char query[
     if (options->storage == TRUE){
         // They are not null, are empty!
         strcat(query, "  AND (unit = '' OR unit = '");
-        strcat(query, options->id);
+        strcat(query, (const char *) options->id);
         strcat(query, "') -- Only storage\n");
     }
     // Excluded teams (overriden by storage option)
     if (options->storage == FALSE && options->total_excluded_teams > 0){
         strcat(query, "  AND (unit = '' OR unit = '");
-        strcat(query, options->id);
+        strcat(query, (const char *) options->id);
         strcat(
         query, "' OR unit NOT IN (SELECT unit FROM units_teams WHERE team IN("
         );
         for (int i = 0; i < options->total_excluded_teams; i ++){
             strcat(query, "'");
-            strcat(query, options->excluded_teams[i]);
+            strcat(query, (const char *) options->excluded_teams[i]);
             strcat(query, "', ");
         }
         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)
     if (options->storage == FALSE && options->total_excluded_units > 0){
         strcat(query, " AND (unit = '' OR unit = '");
-        strcat(query, options->id);
+        strcat(query, (const char *) options->id);
         strcat(query, "' OR unit NOT IN (");
         for (int i = 0; i < options->total_excluded_units; i ++){
             strcat(query, "'");
-            strcat(query, options->excluded_units[i]);
+            strcat(query, (const char *) options->excluded_units[i]);
             strcat(query, "', ");
         }
         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(
   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;
-    sqlite3 *db = NULL;
     sqlite3_stmt *stmt_runes[RUNE_SLOTS + 1];
     char *parameters[1];
     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;
         else  query = &query_odd;
         sprintf(parameters[0], "%d", i);
         db_query(&stmt_runes[i], *query, parameters);
         int j = 0;
         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].set = sqlite3_column_int(stmt_runes[i], 3);
             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(
   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:
     ////////////////////////////////
@@ -1483,21 +1500,21 @@ static void optimize_print_summary(
       3, rune_count[1], 3, rune_count[2], 3, rune_count[3]
     );
     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,
       3, rune_count[4], 3, rune_count[5], 3, rune_count[6]
     );
     printf(
-      " | CRD: | %*d\% | %*d\% | %*d\% |\n",
+      " | CRD: | %*d%% | %*d%% | %*d%% |\n",
       7, unit->base_crd, 7, unit->current_crd, 7, options->min_stats->crd
     );
     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,
       max_combinations
     );
     printf(
-      " | ACC: | %*d\% | %*d\% | %*d\% |\n",
+      " | ACC: | %*d%% | %*d%% | %*d%% |\n",
       7, unit->base_acc, 7, unit->current_acc, 7, options->min_stats->acc
     );
     printf(
@@ -1517,7 +1534,7 @@ static void *optimize_thread(void *data){
     Optimizer_Data *opt_data = data;
 
     // 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 valid_sets = 0;
     unsigned long result_count = 0;
@@ -1545,7 +1562,7 @@ static void *optimize_thread(void *data){
             else{
                 // For GUI flushing, newlines are required
                 printf(
-                  "%d\n",
+                  "%lu\n",
                   (unsigned long)( (tested_combinations + 1) /
                   (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.
                 for (int i = 1; i < RUNE_SLOTS + 1; i ++){
                     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;
@@ -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(" | 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(" | 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(" | DMG: | %*d  | %*d  |\n", 7, unit->current_dmg, 7, result->stats.dmg);
     printf(" ------------------------------\n");
@@ -1906,7 +1923,7 @@ int optimize_print_result(struct Unit *unit, Result *result){
     printf("\n");
     char *parameters[1];
     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;
 
         db_query(

+ 1 - 5
src/RuneOptimizer/team/team.c

@@ -24,14 +24,10 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include "../RuneOptimizer.h"
 #include "../error/error.h"
 #include "team.h"
-#include "team_list.c"
-#include "team_create.c"
-#include "team_delete.c"
-#include "team_add_unit.c"
-#include "team_remove_unit.c"
 
 extern int team(int argc, char *argv[]){
     if (argc < 1){

+ 2 - 0
src/RuneOptimizer/team/team_create.c

@@ -26,6 +26,8 @@
  */
 
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #include "../RuneOptimizer.h"
 #include "../error/error.h"
 #include "../db/db.h"

+ 14 - 6
src/RuneOptimizer/team/team_list.c

@@ -25,6 +25,8 @@
  */
 
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #include "../RuneOptimizer.h"
 #include "../error/error.h"
 #include "../db/db.h"
@@ -75,19 +77,25 @@ extern int team_list(int argc, char *argv[]){
                 sqlite3_stmt *stmt_units;
                 char *unit_parameters[1];
                 unit_parameters[0] = malloc(5);
-                strcpy(unit_parameters[0], sqlite3_column_text(stmt_teams, 0));
+                strcpy(
+                  (char *) unit_parameters[0],
+                  (const char *) sqlite3_column_text(stmt_teams, 0)
+                );
                 db_query(&stmt_units, query, unit_parameters);
                 printf(" |      |----------------------------------|      |\n");
-                char tmp[64];
+                char tmp[128];
+                char name[64];
                 while (SQLITE_ROW == sqlite3_step(stmt_units)){
-                    strcpy(tmp, sqlite3_column_text(stmt_units, 1));
-                    if (strlen(tmp) > 9){
-                        tmp[10] = '\0';
+                    strcpy(
+                      name, (const char *) sqlite3_column_text(stmt_units, 1)
+                    );
+                    if (strlen(name) > 9){
+                        name[10] = '\0';
                     }
                     sprintf(
                       tmp,
                       "%s (Lv.%d) (#%s) ",
-                      tmp,
+                      name,
                       sqlite3_column_int(stmt_units, 2),
                       sqlite3_column_text(stmt_units, 0)
                     );

+ 26 - 20
src/RuneOptimizer/unit/unit.c

@@ -25,6 +25,7 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include "../RuneOptimizer.h"
 #include "../error/error.h"
 #include "../db/db.h"
@@ -51,7 +52,6 @@ extern int unit(int argc, char *argv[]){
 }
 
 static int unit_list(char *search){
-    char query[300] = "SELECT id, name, priority FROM teams ";
     char search_name[96] = "%";
     strcat(search_name, search);
     strcat(search_name, "%");
@@ -89,7 +89,9 @@ static int unit_list(char *search){
         printf("                 ----------------------------\n");
         printf("                 | STAT | BASE    | CURR.   |\n");
         printf("  =============  ----------------------------\n");
-        strncpy(unit_name, sqlite3_column_text(stmt_units, 1), 13);
+        strncpy(
+          unit_name, (const char *) sqlite3_column_text(stmt_units, 1), 13
+        );
         printf(" %*s  ", 14, unit_name);
         printf(
           "| HP:  | %*d  | %*d  |\n",
@@ -115,12 +117,12 @@ static int unit_list(char *search){
         printf("    Lv.%*d", -2, sqlite3_column_int(stmt_units, 3));
         printf("    %d*  ", sqlite3_column_int(stmt_units, 2));
         printf(
-          "| CRR: | %*d% | %*d% |\n",
+          "| CRR: | %*d%% | %*d%% |\n",
           6, sqlite3_column_int(stmt_units, 9),
           6, sqlite3_column_int(stmt_units, 17)
         );
         printf(
-          "                 | CRD: | %*d% | %*d% |\n",
+          "                 | CRD: | %*d%% | %*d%% |\n",
           6, sqlite3_column_int(stmt_units, 10),
           6, sqlite3_column_int(stmt_units, 18)
         );
@@ -132,12 +134,12 @@ static int unit_list(char *search){
             printf("No ");
         }
         printf(
-          "  | RES: | %*d% | %*d% |\n",
+          "  | RES: | %*d%% | %*d%% |\n",
           6, sqlite3_column_int(stmt_units, 11),
           6, sqlite3_column_int(stmt_units, 19)
         );
         printf(
-          "                 | ACC: | %*d% | %*d% |\n",
+          "                 | ACC: | %*d%% | %*d%% |\n",
           6, sqlite3_column_int(stmt_units, 12),
           6, sqlite3_column_int(stmt_units, 20)
         );
@@ -172,7 +174,7 @@ static int unit_list(char *search){
         printf("                 ----------------------------\n");
 
         // Get runes
-        strcpy(tmp, sqlite3_column_text(stmt_units, 0));
+        strcpy(tmp, (const char *) sqlite3_column_text(stmt_units, 0));
         char *rune_parameters[1] = {tmp};
         db_query(
           &stmt_runes,
@@ -239,18 +241,18 @@ static int unit_list(char *search){
             // Rune slot
             strncpy(
               rune_lines[top_line_to_add + 1] + position_to_add,
-              sqlite3_column_text(stmt_runes, 1),
+              (const char *) sqlite3_column_text(stmt_runes, 1),
               1
             );
             // Slot / ID separator
             strncpy(
-              rune_lines[top_line_to_add + 1] + position_to_add + 1, "| #", 3
+              rune_lines[top_line_to_add + 1] + position_to_add + 1, "| #", 4
             );
             // ID
             strncpy(
               rune_lines[top_line_to_add + 1] + position_to_add + 4,
-              sqlite3_column_text(stmt_runes, 0),
-              strlen(sqlite3_column_text(stmt_runes, 0))
+              (const char *) sqlite3_column_text(stmt_runes, 0),
+              strlen((const char *) sqlite3_column_text(stmt_runes, 0))
             );
             // Set name
             strncpy(
@@ -262,21 +264,21 @@ static int unit_list(char *search){
             strncpy(
               rune_lines[top_line_to_add + 2] + position_to_add + 7,
               " +      ",
-              7
+              9
             );
             strncpy(
               rune_lines[top_line_to_add + 2] + position_to_add + 9,
-              sqlite3_column_text(stmt_runes, 4),
-              strlen(sqlite3_column_text(stmt_runes, 4))
+              (const char *) sqlite3_column_text(stmt_runes, 4),
+              strlen((const char *) sqlite3_column_text(stmt_runes, 4))
             );
             // Stars
             strncpy(
               rune_lines[top_line_to_add + 2] + position_to_add + 13,
-              sqlite3_column_text(stmt_runes, 3),
+              (const char *) sqlite3_column_text(stmt_runes, 3),
               1
             );
             strncpy(
-              rune_lines[top_line_to_add + 2] + position_to_add + 14, "*", 1
+              rune_lines[top_line_to_add + 2] + position_to_add + 14, "*", 2
             );
             // Quality
             strncpy(
@@ -297,7 +299,7 @@ static int unit_list(char *search){
               strlen(tmp)
             );
             // Get stats
-            strcpy(tmp, sqlite3_column_text(stmt_runes, 0));
+            strcpy(tmp, (const char *) sqlite3_column_text(stmt_runes, 0));
             char *stat_parameters[1] = {tmp};
             db_query(
               &stmt_stats,
@@ -322,16 +324,20 @@ static int unit_list(char *search){
                 // Enchanted?
                 if (1 == sqlite3_column_int(stmt_stats, 4)){
                     strncpy(
-                      rune_lines[top_line_to_add + 5 + sqlite3_column_int(stmt_stats, 0)] + position_to_add + 9,
+                      rune_lines[
+                        top_line_to_add + 5 + sqlite3_column_int(stmt_stats, 0)
+                      ] + position_to_add + 9,
                       "*",
-                      1
+                      2
                     );
                 }
                 // Grinded?
                 if (0 < sqlite3_column_int(stmt_stats, 3)){
                     sprintf(tmp, "+%-4d", sqlite3_column_int(stmt_stats, 3));
                     strncpy(
-                      rune_lines[top_line_to_add + 5 + sqlite3_column_int(stmt_stats, 0)] + position_to_add + 10,
+                      rune_lines[
+                        top_line_to_add + 5 + sqlite3_column_int(stmt_stats, 0)
+                      ] + position_to_add + 10,
                       tmp,
                       5
                     );

+ 119 - 7
src/RuneOptimizer/update/update.c

@@ -24,16 +24,128 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include "../RuneOptimizer.h"
 #include "../error/error.h"
 #include "update.h"
-#include "update_current_stats.c"
-#include "update_get_monster_name.c"
-#include "update_db_tables.c"
-#include "update_rune_totals.c"
-#include "update_info.c"
-#include "update_efficiency.c"
-#include "update_json.c"
+
+const int MAIN_STATS_VALUES[DIFFERENT_STATS][RUNE_MAX_STARS + 1][2] = {
+  { //NULL (unused)
+      {0, 0},
+      {0, 0},
+      {0, 0},
+      {0, 0},
+      {0, 0},
+      {0, 0}
+  },
+  { //HP_FLAT
+      {0, 0}, // 0 stars (unused)
+      {580, 804}, // 1 stars
+      {790, 1092}, // 2 stars
+      {1000, 1380}, // 3 stars
+      {1240, 1704}, // 4 stars
+      {1530, 2088}, // 5 stars
+      {1800, 2448} // 6 stars
+  },
+  { //HP_PERCENT
+      {0, 0}, // 0 stars (unused)
+      {13, 18}, // 1 stars
+      {14, 19}, // 2 stars
+      {28, 38}, // 3 stars
+      {31, 43}, // 4 stars
+      {37, 51}, // 5 stars
+      {47, 63} // 6 stars
+  },
+  { //ATK_FLAT
+      {0, 0}, // 0 stars (unused)
+      {39, 54}, // 1 stars
+      {53, 73}, // 2 stars
+      {67, 92}, // 3 stars
+      {82, 112}, // 4 stars
+      {99, 135}, // 5 stars
+      {118, 160}, // 6 stars
+  },
+  { //ATK_PERCENT
+      {0, 0}, // 0 stars (unused)
+      {13, 18}, // 1 stars
+      {14, 19}, // 2 stars
+      {28, 38}, // 3 stars
+      {31, 43}, // 4 stars
+      {37, 51}, // 5 stars
+      {47, 63} // 6 stars
+  },
+  { //DEF_FLAT
+      {0, 0}, // 0 stars (unused)
+      {39, 54}, // 1 stars
+      {53, 73}, // 2 stars
+      {67, 92}, // 3 stars
+      {82, 112}, // 4 stars
+      {99, 135}, // 5 stars
+      {118, 160}, // 6 stars
+  },
+  { //DEF_PERCENT
+      {0, 0}, // 0 stars (unused)
+      {13, 18}, // 1 stars
+      {14, 19}, // 2 stars
+      {28, 38}, // 3 stars
+      {31, 43}, // 4 stars
+      {37, 51}, // 5 stars
+      {47, 63} // 6 stars
+  },
+  { //NULL (unused)
+      {0, 0},
+      {0, 0},
+      {0, 0},
+      {0, 0},
+      {0, 0},
+      {0, 0}
+  },
+  { //SPD
+      {0, 0}, // 0 stars (unused)
+      {13, 18}, // 1 stars
+      {14, 19}, // 2 stars
+      {18, 25}, // 3 stars
+      {22, 30}, // 4 stars
+      {29, 39}, // 5 stars
+      {31, 42} // 6 stars
+  },
+  { //CRR
+      {0, 0}, // 0 stars (unused)
+      {13, 18}, // 1 stars
+      {14, 19}, // 2 stars
+      {27, 37}, // 3 stars
+      {30, 41}, // 4 stars
+      {34, 47}, // 5 stars
+      {43, 58} // 6 stars
+  },
+  { //CRD
+      {0, 0}, // 0 stars (unused)
+      {14, 19}, // 1 stars
+      {27, 37}, // 2 stars
+      {32, 43}, // 3 stars
+      {42, 57}, // 4 stars
+      {48, 65}, // 5 stars
+      {59, 80} // 6 stars
+  },
+  { //RES
+      {0, 0}, // 0 stars (unused)
+      {13, 18}, // 1 stars
+      {14, 19}, // 2 stars
+      {28, 38}, // 3 stars
+      {32, 44}, // 4 stars
+      {38, 51}, // 5 stars
+      {48, 64} // 6 stars
+  },
+  { //ACC
+      {0, 0}, // 0 stars (unused)
+      {13, 18}, // 1 stars
+      {14, 19}, // 2 stars
+      {28, 38}, // 3 stars
+      {32, 44}, // 4 stars
+      {38, 51}, // 5 stars
+      {48, 64} // 6 stars
+  }
+};
 
 extern int update(int argc, char *argv[]){
 

+ 1 - 117
src/RuneOptimizer/update/update.h

@@ -654,123 +654,7 @@ typedef struct DB_Rune {
  *  - Rune stars (1-index, dont use 0).
  *  - Level: Position 0 for level 12, position 1 for level 15.
  */
-const int MAIN_STATS_VALUES[DIFFERENT_STATS][RUNE_MAX_STARS + 1][2] = {
-  { //NULL (unused)
-      {0, 0},
-      {0, 0},
-      {0, 0},
-      {0, 0},
-      {0, 0},
-      {0, 0}
-  },
-  { //HP_FLAT
-      {0, 0}, // 0 stars (unused)
-      {580, 804}, // 1 stars
-      {790, 1092}, // 2 stars
-      {1000, 1380}, // 3 stars
-      {1240, 1704}, // 4 stars
-      {1530, 2088}, // 5 stars
-      {1800, 2448} // 6 stars
-  },
-  { //HP_PERCENT
-      {0, 0}, // 0 stars (unused)
-      {13, 18}, // 1 stars
-      {14, 19}, // 2 stars
-      {28, 38}, // 3 stars
-      {31, 43}, // 4 stars
-      {37, 51}, // 5 stars
-      {47, 63} // 6 stars
-  },
-  { //ATK_FLAT
-      {0, 0}, // 0 stars (unused)
-      {39, 54}, // 1 stars
-      {53, 73}, // 2 stars
-      {67, 92}, // 3 stars
-      {82, 112}, // 4 stars
-      {99, 135}, // 5 stars
-      {118, 160}, // 6 stars
-  },
-  { //ATK_PERCENT
-      {0, 0}, // 0 stars (unused)
-      {13, 18}, // 1 stars
-      {14, 19}, // 2 stars
-      {28, 38}, // 3 stars
-      {31, 43}, // 4 stars
-      {37, 51}, // 5 stars
-      {47, 63} // 6 stars
-  },
-  { //DEF_FLAT
-      {0, 0}, // 0 stars (unused)
-      {39, 54}, // 1 stars
-      {53, 73}, // 2 stars
-      {67, 92}, // 3 stars
-      {82, 112}, // 4 stars
-      {99, 135}, // 5 stars
-      {118, 160}, // 6 stars
-  },
-  { //DEF_PERCENT
-      {0, 0}, // 0 stars (unused)
-      {13, 18}, // 1 stars
-      {14, 19}, // 2 stars
-      {28, 38}, // 3 stars
-      {31, 43}, // 4 stars
-      {37, 51}, // 5 stars
-      {47, 63} // 6 stars
-  },
-  { //NULL (unused)
-      {0, 0},
-      {0, 0},
-      {0, 0},
-      {0, 0},
-      {0, 0},
-      {0, 0}
-  },
-  { //SPD
-      {0, 0}, // 0 stars (unused)
-      {13, 18}, // 1 stars
-      {14, 19}, // 2 stars
-      {18, 25}, // 3 stars
-      {22, 30}, // 4 stars
-      {29, 39}, // 5 stars
-      {31, 42} // 6 stars
-  },
-  { //CRR
-      {0, 0}, // 0 stars (unused)
-      {13, 18}, // 1 stars
-      {14, 19}, // 2 stars
-      {27, 37}, // 3 stars
-      {30, 41}, // 4 stars
-      {34, 47}, // 5 stars
-      {43, 58} // 6 stars
-  },
-  { //CRD
-      {0, 0}, // 0 stars (unused)
-      {14, 19}, // 1 stars
-      {27, 37}, // 2 stars
-      {32, 43}, // 3 stars
-      {42, 57}, // 4 stars
-      {48, 65}, // 5 stars
-      {59, 80} // 6 stars
-  },
-  { //RES
-      {0, 0}, // 0 stars (unused)
-      {13, 18}, // 1 stars
-      {14, 19}, // 2 stars
-      {28, 38}, // 3 stars
-      {32, 44}, // 4 stars
-      {38, 51}, // 5 stars
-      {48, 64} // 6 stars
-  },
-  { //ACC
-      {0, 0}, // 0 stars (unused)
-      {13, 18}, // 1 stars
-      {14, 19}, // 2 stars
-      {28, 38}, // 3 stars
-      {32, 44}, // 4 stars
-      {38, 51}, // 5 stars
-      {48, 64} // 6 stars
-  }
-};
+extern const int MAIN_STATS_VALUES[DIFFERENT_STATS][RUNE_MAX_STARS + 1][2];
 
 /**
  * Calculates the current stats for units with runes in the database.

+ 6 - 3
src/RuneOptimizer/update/update_current_stats.c

@@ -26,6 +26,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <sqlite3.h>
 #include "../RuneOptimizer.h"
 #include "../error/error.h"
@@ -45,7 +46,9 @@ extern int update_current_stats(){
     );
     Unit unit;
     while (SQLITE_ROW == sqlite3_step(stmt_unit)){
-        strcpy(unit.id, sqlite3_column_text(stmt_unit, 0));
+        strcpy(
+          (char *) unit.id, (const char *) sqlite3_column_text(stmt_unit, 0)
+        );
         unit.base_hp = sqlite3_column_int(stmt_unit, 1);
         unit.base_atk = sqlite3_column_int(stmt_unit, 2);
         unit.base_def = sqlite3_column_int(stmt_unit, 3);
@@ -74,7 +77,7 @@ extern int update_current_stats(){
         };
         sqlite3_stmt *stmt_runes;
         char *parameters[1];
-        parameters[0] = unit.id;
+        parameters[0] = (char *) unit.id;
         db_query(
           &stmt_runes,
           "SELECT type,"
@@ -176,7 +179,7 @@ extern int update_current_stats(){
         sprintf(parameters_update[5], "%d", unit.current_crd);
         sprintf(parameters_update[6], "%d", unit.current_res);
         sprintf(parameters_update[7], "%d", unit.current_acc);
-        parameters_update[8] = unit.id;
+        parameters_update[8] = (char *) unit.id;
         if (
           SUCCESS !=
           db_execute(

+ 1 - 0
src/RuneOptimizer/update/update_db_tables.c

@@ -26,6 +26,7 @@
 
 #include <stdio.h>
 #include <sqlite3.h>
+#include "../RuneOptimizer.h"
 #include "../error/error.h"
 #include "../db/db.h"
 

+ 1 - 0
src/RuneOptimizer/update/update_efficiency.c

@@ -28,6 +28,7 @@
 #include <sqlite3.h>
 #include "../error/error.h"
 #include "../db/db.h"
+#include "../RuneOptimizer.h"
 
 extern int update_efficiency(char *id, float *efficiency, float *max_efficiency){
     *efficiency = 0.0f;

+ 1 - 0
src/RuneOptimizer/update/update_get_monster_name.c

@@ -25,6 +25,7 @@
  */
 
 #include <string.h>
+#include "../RuneOptimizer.h"
 
 extern void update_get_monster_name(int id, char name[UNIT_NAME_LEN]){
     

+ 3 - 0
src/RuneOptimizer/update/update_info.c

@@ -26,9 +26,11 @@
 
 #include <stdio.h>
 #include <sqlite3.h>
+#include <stdlib.h>
 #include <time.h>
 #include "../error/error.h"
 #include "../db/db.h"
+#include "../RuneOptimizer.h"
 
 extern int update_info(const char *id, const char *name, const char *level){
     time_t t = time(NULL);
@@ -58,4 +60,5 @@ extern int update_info(const char *id, const char *name, const char *level){
         fprintf(stderr, "Unable to save meta info: %s\n", sqlite3_errmsg(db));
         return ERROR_DB_INSERT_INFO;
     }
+    return SUCCESS;
 }

+ 19 - 15
src/RuneOptimizer/update/update_json.c

@@ -26,10 +26,13 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <sqlite3.h>
 #include <json-c/json.h>
+#include "../RuneOptimizer.h"
 #include "../error/error.h"
 #include "../db/db.h"
+#include "update.h"
 
 /**
  * Saves a single rune to the database obtaining data from its json object.
@@ -43,7 +46,7 @@
  * @return The number of stats saved to the database, including the main stat,
  * innate stat (if any), and all the normal stats. -1 in case of error.
  */
-static int update_json_rune(json_object *rune_json, char *unit_id);
+static int update_json_rune(json_object *rune_json, unsigned char *unit_id);
 
 /**
  * Saves a single unit to the database obtaining data from its json object.
@@ -108,7 +111,7 @@ extern int update_json(
     for (int i = 0; i < rune_count; i++){
         total_runes ++;
         idx = json_object_array_get_idx(runes, i);
-        status = update_json_rune(idx, "");
+        status = update_json_rune(idx, (unsigned char *) "");
         if (status != -1) total_stats += status;
     }
 
@@ -144,16 +147,16 @@ extern int update_json(
     return(SUCCESS);
 }
 
-static int update_json_rune(json_object *rune_json, char *unit_id){
+static int update_json_rune(json_object *rune_json, unsigned char *unit_id){
     int total_stats = 0;
     DB_Rune rune;
     char *query_parameters[43];
     for (int i = 1; i < 43; i ++) query_parameters[i] = malloc(5);
     // Rune ID
     json_object *rune_id = json_object_object_get(rune_json, "rune_id");
-    strcpy(rune.id, json_object_get_string(rune_id));
+    strcpy((char *) rune.id, json_object_get_string(rune_id));
     // Rune unit
-    strcpy(rune.unit, unit_id);
+    strcpy((char *) rune.unit, (const char *) unit_id);
     // Rune slot
     json_object *slot_no = json_object_object_get(rune_json, "slot_no");
     rune.slot = json_object_get_int(slot_no);
@@ -212,15 +215,15 @@ static int update_json_rune(json_object *rune_json, char *unit_id){
     update_rune_totals(&rune);
 
     // Insert the rune into the database
-    query_parameters[0] = rune.id;
-    query_parameters[1] = unit_id;
+    query_parameters[0] = (char *) rune.id;
+    query_parameters[1] = (char *) unit_id;
     sprintf(query_parameters[2], "%d", rune.set);
     sprintf(query_parameters[3], "%d", rune.slot);
     sprintf(query_parameters[4], "%d", rune.stars);
     sprintf(query_parameters[5], "%d", rune.level);
     sprintf(query_parameters[6], "%d", rune.quality);
-    sprintf(query_parameters[7], "%d", rune.efficiency);
-    sprintf(query_parameters[8], "%d", rune.max_efficiency);
+    sprintf(query_parameters[7], "%f", rune.efficiency);
+    sprintf(query_parameters[8], "%f", rune.max_efficiency);
     sprintf(query_parameters[9], "%d", rune.main.stat);
     sprintf(query_parameters[10], "%d", rune.current_hp_percent);
     sprintf(query_parameters[11], "%d", rune.current_atk_percent);
@@ -397,13 +400,13 @@ static int update_json_unit(
     for (int i = 1; i < 23; i ++) query_parameters[i] = malloc(5);
     // Unit ID
     json_object *unit_id = json_object_object_get(unit_json, "unit_id");
-    strcpy(unit.id, json_object_get_string(unit_id));
+    strcpy((char *) unit.id, json_object_get_string(unit_id));
     // Unit monster ID
     json_object *unit_master_id =
       json_object_object_get(unit_json, "unit_master_id");
     unit.monster= json_object_get_int(unit_master_id);
     // Unit name
-    update_get_monster_name(unit.monster, unit.name);
+    update_get_monster_name(unit.monster, (char *) unit.name);
     json_object *unit_level = json_object_object_get(unit_json, "unit_level");
     unit.level = json_object_get_int(unit_level);
     // Unit stars (class)
@@ -439,7 +442,7 @@ static int update_json_unit(
     json_object *homunculus_name =
       json_object_object_get(unit_json, "homunculus_name");
     if (strlen(json_object_get_string(homunculus_name)) > 0){
-        strcpy(unit.name, json_object_get_string(homunculus_name));
+        strcpy((char *) unit.name, json_object_get_string(homunculus_name));
     }
 
     // Parse unit runes
@@ -448,7 +451,8 @@ static int update_json_unit(
     json_object *idx;
     for (int i = 0; i < rune_count; i++){
         unit_has_runes = TRUE;
-        *total_runes ++;
+        // TODO: Test this: reference or value?
+        total_runes ++;
         idx = json_object_array_get_idx(unit_runes, i);
         int status = update_json_rune(idx, unit.id);
         if (status != -1) *total_stats += status;
@@ -461,8 +465,8 @@ static int update_json_unit(
         (six_stars == TRUE && unit.stars == TRUE)
     ){
         ret_val = 1;
-        query_parameters[0] = unit.id;
-        query_parameters[1] = unit.name;
+        query_parameters[0] = (char *) unit.id;
+        query_parameters[1] = (char *) unit.name;
         sprintf(query_parameters[2], "%d", unit.stars);
         sprintf(query_parameters[3], "%d", unit.level);
         sprintf(query_parameters[4], "%d", unit.base_hp);

+ 2 - 0
src/test/RuneOptimizerTest.c

@@ -1,3 +1,5 @@
+#include <stdio.h>
+#include <unistd.h>
 #include "unity/unity.h"
 #include "unity/unity.c"
 

+ 46 - 45
src/test/RuneOptimizerUnitTest.c

@@ -184,7 +184,7 @@ void test_db_execute_invalid(){
 /**
  * Test optimize_count_runes_for_sets with three different and valid sets.
  */
-void test_optimize_count_runes_for_sets_unique_three_valid(){
+/*void test_optimize_count_runes_for_sets_unique_three_valid(){
     Rune_Set_Count count;
     int sets[] = {REVENGE, WILL, GUARD};
     TEST_ASSERT_EQUAL(6, optimize_count_runes_for_sets(sets, &count));
@@ -193,12 +193,12 @@ void test_optimize_count_runes_for_sets_unique_three_valid(){
     TEST_ASSERT_EQUAL(2, count.guard);
     TEST_ASSERT_EQUAL(0, count.rage);
     TEST_ASSERT_EQUAL(0, count.endure);
-}
+}*/
 /**
  * Test optimize_count_runes_for_sets with three valid sets where one of them is
  * repeated.
  */
-void test_optimize_count_runes_for_sets_repeated_three_valid(){
+/*void test_optimize_count_runes_for_sets_repeated_three_valid(){
     Rune_Set_Count count;
     int sets[] = {REVENGE, REVENGE, GUARD};
     TEST_ASSERT_EQUAL(6, optimize_count_runes_for_sets(sets, &count));
@@ -206,11 +206,11 @@ void test_optimize_count_runes_for_sets_repeated_three_valid(){
     TEST_ASSERT_EQUAL(2, count.guard);
     TEST_ASSERT_EQUAL(0, count.rage);
     TEST_ASSERT_EQUAL(0, count.endure);
-}
+}*/
 /**
  * Test optimize_count_runes_for_sets with three different and valid sets.
  */
-void test_optimize_count_runes_for_sets_unique_three_invalid(){
+/*void test_optimize_count_runes_for_sets_unique_three_invalid(){
     Rune_Set_Count count;
     int sets[] = {REVENGE, WILL, 999};
     TEST_ASSERT_EQUAL(4, optimize_count_runes_for_sets(sets, &count));
@@ -219,13 +219,13 @@ void test_optimize_count_runes_for_sets_unique_three_invalid(){
     TEST_ASSERT_EQUAL(0, count.guard);
     TEST_ASSERT_EQUAL(0, count.rage);
     TEST_ASSERT_EQUAL(0, count.endure);
-}
+}*/
 
 /**
  * Test optimize_count_runes_for_sets with three sets where one of them is
  * repeated and one of them is invalid.
  */
-void test_optimize_count_runes_for_sets_repeated_three_invalid(){
+/*void test_optimize_count_runes_for_sets_repeated_three_invalid(){
     Rune_Set_Count count;
     int sets[] = {REVENGE, REVENGE, 999};
     TEST_ASSERT_EQUAL(4, optimize_count_runes_for_sets(sets, &count));
@@ -233,11 +233,11 @@ void test_optimize_count_runes_for_sets_repeated_three_invalid(){
     TEST_ASSERT_EQUAL(0, count.guard);
     TEST_ASSERT_EQUAL(0, count.rage);
     TEST_ASSERT_EQUAL(0, count.endure);
-}
+}*/
 /**
  * Test optimize_count_runes_for_sets with a set of two and a set of four.
  */
-void test_optimize_count_runes_for_sets_two_valid(){
+/*void test_optimize_count_runes_for_sets_two_valid(){
     Rune_Set_Count count;
     int sets[] = {VAMPIRE, REVENGE, -1};
     TEST_ASSERT_EQUAL(6, optimize_count_runes_for_sets(sets, &count));
@@ -245,11 +245,11 @@ void test_optimize_count_runes_for_sets_two_valid(){
     TEST_ASSERT_EQUAL(4, count.vampire);
     TEST_ASSERT_EQUAL(0, count.rage);
     TEST_ASSERT_EQUAL(0, count.endure);
-}
+}*/
 /**
  * Test optimize_count_runes_for_sets with a set of four and an invalid set.
  */
-void test_optimize_count_runes_for_sets_two_invalid(){
+/*void test_optimize_count_runes_for_sets_two_invalid(){
     Rune_Set_Count count;
     int sets[] = {VAMPIRE, 999, -1};
     TEST_ASSERT_EQUAL(4, optimize_count_runes_for_sets(sets, &count));
@@ -257,12 +257,12 @@ void test_optimize_count_runes_for_sets_two_invalid(){
     TEST_ASSERT_EQUAL(4, count.vampire);
     TEST_ASSERT_EQUAL(0, count.rage);
     TEST_ASSERT_EQUAL(0, count.endure);
-}
+}*/
 
 /**
  * Test optimize_sort_results when all results have a positive rating.
  */
-void test_optimize_sort_results_positives(){
+/*void test_optimize_sort_results_positives(){
     Result res1 = {.rating = 400};
     Result res2 = {.rating = 100};
     Result res3 = {.rating = 600};
@@ -270,11 +270,11 @@ void test_optimize_sort_results_positives(){
     Result results[5000] = {res1, res2, res3, res4};
     optimize_sort_results(results, 4);
     TEST_ASSERT_EQUAL(600, results[1].rating);
-}
+}*/
 /**
  * Test optimize_sort_results when all results have a negative rating.
  */
-void test_optimize_sort_results_negatives(){
+/*void test_optimize_sort_results_negatives(){
     Result res1 = {.rating = -400};
     Result res2 = {.rating = -100};
     Result res3 = {.rating = -600};
@@ -282,12 +282,12 @@ void test_optimize_sort_results_negatives(){
     Result results[5000] = {res1, res2, res3, res4};
     optimize_sort_results(results, 4);
     TEST_ASSERT_EQUAL(-400, results[1].rating);
-}
+}*/
 /**
  * Test optimize_sort_results when results have positive, negative and 0
  * ratings.
  */
-void test_optimize_sort_results_mixed_signs(){
+/*void test_optimize_sort_results_mixed_signs(){
     Result res1 = {.rating = 400};
     Result res2 = {.rating = 0};
     Result res3 = {.rating = -600};
@@ -296,29 +296,29 @@ void test_optimize_sort_results_mixed_signs(){
     optimize_sort_results(results, 4);
     TEST_ASSERT_EQUAL(400, results[1].rating);
     TEST_ASSERT_EQUAL(-600, results[3].rating);
-}
+}*/
 
 /**
  * Test varios EHP calculations.
  */
-void test_optimize_calculate_ehp(){
-    TEST_ASSERT_EQUAL(2890, optimize_calculate_ehp(1000, 500));
-    TEST_ASSERT_EQUAL(3856, optimize_calculate_ehp(1234, 567));
-    TEST_ASSERT_EQUAL(0, optimize_calculate_ehp(0, 567));
-    TEST_ASSERT_EQUAL(1407, optimize_calculate_ehp(1234, 0));
+void test_calculate_ehp(){
+    TEST_ASSERT_EQUAL(2890, calculate_ehp(1000, 500));
+    TEST_ASSERT_EQUAL(3856, calculate_ehp(1234, 567));
+    TEST_ASSERT_EQUAL(0, calculate_ehp(0, 567));
+    TEST_ASSERT_EQUAL(1407, calculate_ehp(1234, 0));
 }
 /**
  * Test varios DMG calculations.
  */
-void test_optimize_calculate_dmg(){
-    TEST_ASSERT_EQUAL(0, optimize_calculate_dmg(0, 100, 200));
-    TEST_ASSERT_EQUAL(100, optimize_calculate_dmg(100, 0, 200));
-    TEST_ASSERT_EQUAL(100, optimize_calculate_dmg(100, 0, 300));
-    TEST_ASSERT_EQUAL(100, optimize_calculate_dmg(100, 50, 0));
-    TEST_ASSERT_EQUAL(100, optimize_calculate_dmg(100, 100, 0));
-    TEST_ASSERT_EQUAL(200, optimize_calculate_dmg(100, 50, 200));
-    TEST_ASSERT_EQUAL(300, optimize_calculate_dmg(100, 100, 200));
-    TEST_ASSERT_EQUAL(300, optimize_calculate_dmg(100, 110, 200));
+void test_calculate_dmg(){
+    TEST_ASSERT_EQUAL(0, calculate_dmg(0, 100, 200));
+    TEST_ASSERT_EQUAL(100, calculate_dmg(100, 0, 200));
+    TEST_ASSERT_EQUAL(100, calculate_dmg(100, 0, 300));
+    TEST_ASSERT_EQUAL(125, calculate_dmg(100, 50, 50));
+    TEST_ASSERT_EQUAL(150, calculate_dmg(100, 100, 50));
+    TEST_ASSERT_EQUAL(200, calculate_dmg(100, 50, 200));
+    TEST_ASSERT_EQUAL(300, calculate_dmg(100, 100, 200));
+    TEST_ASSERT_EQUAL(300, calculate_dmg(100, 110, 200));
 }
 
 /**
@@ -333,7 +333,7 @@ void run_tests(){
     RUN_TEST(test_main_invalid_command);
     RUN_TEST(test_main_help);
     RUN_TEST(test_main_version);
-    RUN_TEST(test_db_open_invalid_path);
+    /*RUN_TEST(test_db_open_invalid_path);
     RUN_TEST(test_db_open_valid_path_new);
     RUN_TEST(test_db_open_valid_path_existing);
     RUN_TEST(test_db_close_when_opened);
@@ -348,16 +348,17 @@ void run_tests(){
     RUN_TEST(test_db_execute_valid_parameters_no_supplied);
     RUN_TEST(test_db_execute_valid_no_parameters_supplied);
     RUN_TEST(test_db_query_invalid);
-    RUN_TEST(test_db_execute_invalid);
-    RUN_TEST(test_optimize_count_runes_for_sets_unique_three_valid);
-    RUN_TEST(test_optimize_count_runes_for_sets_repeated_three_valid);
-    RUN_TEST(test_optimize_count_runes_for_sets_unique_three_invalid);
-    RUN_TEST(test_optimize_count_runes_for_sets_repeated_three_invalid);
-    RUN_TEST(test_optimize_count_runes_for_sets_two_valid);
-    RUN_TEST(test_optimize_count_runes_for_sets_two_invalid);
-    RUN_TEST(test_optimize_sort_results_positives);
-    RUN_TEST(test_optimize_sort_results_negatives);
-    RUN_TEST(test_optimize_sort_results_mixed_signs);
-    RUN_TEST(test_optimize_calculate_ehp);
-    RUN_TEST(test_optimize_calculate_dmg);
+    RUN_TEST(test_db_execute_invalid);*/
+
+    //RUN_TEST(test_optimize_count_runes_for_sets_unique_three_valid);
+    //RUN_TEST(test_optimize_count_runes_for_sets_repeated_three_valid);
+    //RUN_TEST(test_optimize_count_runes_for_sets_unique_three_invalid);
+    //RUN_TEST(test_optimize_count_runes_for_sets_repeated_three_invalid);
+    //RUN_TEST(test_optimize_count_runes_for_sets_two_valid);
+    //RUN_TEST(test_optimize_count_runes_for_sets_two_invalid);
+    //RUN_TEST(test_optimize_sort_results_positives);
+   // RUN_TEST(test_optimize_sort_results_negatives);
+    //RUN_TEST(test_optimize_sort_results_mixed_signs);
+    RUN_TEST(test_calculate_ehp);
+    RUN_TEST(test_calculate_dmg);
 }