| @@ -43,7 +43,12 @@ void execute_sql_command(sqlite3* database, std::string command) { |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | | 45 | |
| 46 | -void addGame(sqlite3* database, int id, std::string name, std::string path) { | 46 | +void addGame(sqlite3* database, std::string name, std::string path) { |
| | 47 | + int id = games.size() + 1; // calculateId(); |
| | 48 | + addGameToDatabase(database, id, name, path); |
| | 49 | +} |
| | 50 | + |
| | 51 | +void addGameToDatabase(sqlite3* database, int id, std::string name, std::string path) { |
| 47 | std::string command = "INSERT INTO GAME (GAME_ID, GAME_NAME, GAME_PATH) VALUES ("; | 52 | std::string command = "INSERT INTO GAME (GAME_ID, GAME_NAME, GAME_PATH) VALUES ("; |
| 48 | command += std::to_string(id) + ", '" + name + "', \"" + path + "\");"; | 53 | command += std::to_string(id) + ", '" + name + "', \"" + path + "\");"; |
| 49 | execute_sql_command(database, command); | 54 | execute_sql_command(database, command); |
| @@ -57,9 +62,7 @@ void removeGame(sqlite3* database, std::string name) { |
| 57 | | 62 | |
| 58 | void initialize_database(sqlite3* database) { | 63 | void initialize_database(sqlite3* database) { |
| 59 | execute_sql_command(database, database_initialization_command); | 64 | execute_sql_command(database, database_initialization_command); |
| 60 | - addGame(database, 1, "Devastating Fog", ""); | 65 | + printMessage("Database Initialized"); |
| 61 | - addGame(database, 2, "No Pirates Here!", ""); | | |
| 62 | - printMessage("Database Initialized"); | | |
| 63 | } | 66 | } |
| 64 | | 67 | |
| 65 | void runGame(sqlite3* database, std::string gameName) { | 68 | void runGame(sqlite3* database, std::string gameName) { |
| @@ -110,7 +113,7 @@ void handleCommand(int argc, char const *argv[], sqlite3* database) { |
| 110 | } | 113 | } |
| 111 | } | 114 | } |
| 112 | | 115 | |
| 113 | - addGame(database, games.size() + 1, gameName, temp); | 116 | + addGame(database, gameName, temp); |
| 114 | } | 117 | } |
| 115 | break; | 118 | break; |
| 116 | } | 119 | } |