Bladeren bron

Genericize config paths

Use CMake definitions to specify config paths and filenames.
master
TheoryOfNekomata 1 jaar geleden
bovenliggende
commit
4415eb0e9e
7 gewijzigde bestanden met toevoegingen van 21 en 20 verwijderingen
  1. +2
    -0
      CMakeLists.txt
  2. +1
    -2
      src/packages/game/IZ_app.c
  3. +1
    -1
      src/packages/game/IZ_app_config.c
  4. +14
    -14
      src/packages/game/input/input.test.c
  5. +1
    -1
      src/packages/game/output/output.test.c
  6. +1
    -1
      src/packages/server/IZ_app.c
  7. +1
    -1
      src/packages/server/IZ_app_config.c

+ 2
- 0
CMakeLists.txt Bestand weergeven

@@ -41,6 +41,8 @@ add_definitions(
-DIZ_PLAYERS=1
#-DIZ_LOG_DATE_FUNCTION=IZ_TimerElapsed
-DIZ_LOG_DATE_FUNCTION=IZ_TimerNow
-DIZ_CONFIG_GAME_PATH="config-game.ini"
-DIZ_CONFIG_SERVER_PATH="config-server.ini"
)

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")


+ 1
- 2
src/packages/game/IZ_app.c Bestand weergeven

@@ -84,12 +84,11 @@ void IZ_AppPrintHelpOptions() {
"\n"
"Options:\n"
"\n"
" -c <path> Specifies the path to the config file. (default: \"./config-game.ini\")\n"
" -c <path> Specifies the path to the config file. (default: \"./" IZ_CONFIG_GAME_PATH "\")\n"
" -f <value> Specifies the frames per second. (default: 30)\n"
" -h Displays this help screen.\n"
" -i <value> Specifies the interval of sending packets (default: 200)\n"
" in milliseconds.\n"

);
}



+ 1
- 1
src/packages/game/IZ_app_config.c Bestand weergeven

@@ -8,5 +8,5 @@ void IZ_ConfigGetDefaultPath(char* config_path, size_t string_size) {
#endif

IZ_memcpy(config_path, string_size, config_path_dir, 128);
IZ_strcat(config_path, string_size, "config-game.ini");
IZ_strcat(config_path, string_size, IZ_CONFIG_GAME_PATH);
}

+ 14
- 14
src/packages/game/input/input.test.c Bestand weergeven

@@ -42,7 +42,7 @@ spec("input") {
}

it("sets initial state") {
IZ_JoystickInitialize(&state, "config-game.ini", 0, NULL);
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

// check(mock_is_called(IZ_memcpy), "Initial state not loaded.");
check(mock_is_called(SDL_NumJoysticks), "Connected joysticks not checked.");
@@ -51,7 +51,7 @@ spec("input") {
it("calls load method") {
mock_set_expected_calls(ini_getl, ((IZ_CONTROLS - 4) + 2) * IZ_PLAYERS);

IZ_JoystickInitialize(&state, "config-game.ini", 0, NULL);
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

check(
mock_get_expected_calls(ini_getl) == mock_get_actual_calls(ini_getl),
@@ -64,7 +64,7 @@ spec("input") {
it("calls save method") {
mock_set_expected_calls(ini_putl, ((IZ_CONTROLS - 4) + 2) * IZ_PLAYERS);

IZ_JoystickInitialize(&state, "config-game.ini", 0, NULL);
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

check(
mock_get_expected_calls(ini_putl) == mock_get_actual_calls(ini_putl),
@@ -77,7 +77,7 @@ spec("input") {
it("opens device handles") {
mock_set_expected_calls(SDL_JoystickOpen, MOCK_OPEN_JOYSTICKS);

IZ_JoystickInitialize(&state, "config-game.ini", 0, NULL);
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

check(
mock_get_expected_calls(SDL_JoystickOpen) == mock_get_actual_calls(SDL_JoystickOpen),
@@ -352,7 +352,7 @@ spec("input") {
it("calls save method") {
mock_set_expected_calls(ini_putl, ((IZ_CONTROLS - 4) + 2) * IZ_PLAYERS);

IZ_JoystickSaveConfig(&state, "config-game.ini");
IZ_JoystickSaveConfig(&state, IZ_CONFIG_GAME_PATH);

check(
mock_get_expected_calls(ini_putl) == mock_get_actual_calls(ini_putl),
@@ -417,7 +417,7 @@ spec("input") {
}

it("sets initial state") {
IZ_KeyboardInitialize(&state, "config-game.ini", 0, NULL);
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

// check(mock_is_called(IZ_memcpy), "Initial state not loaded.");
}
@@ -425,7 +425,7 @@ spec("input") {
it("calls load method") {
mock_set_expected_calls(ini_gets, IZ_CONTROLS * IZ_PLAYERS);

IZ_KeyboardInitialize(&state, "config-game.ini", 0, NULL);
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

check(
mock_get_expected_calls(ini_gets) == mock_get_actual_calls(ini_gets),
@@ -438,7 +438,7 @@ spec("input") {
it("calls save method") {
mock_set_expected_calls(ini_puts, IZ_CONTROLS * IZ_PLAYERS);

IZ_KeyboardInitialize(&state, "config-game.ini", 0, NULL);
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

check(
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts),
@@ -505,7 +505,7 @@ spec("input") {
it("calls save method") {
mock_set_expected_calls(ini_puts, IZ_CONTROLS * IZ_PLAYERS);

IZ_KeyboardSaveConfig("config-game.ini", &state);
IZ_KeyboardSaveConfig(IZ_CONFIG_GAME_PATH, &state);

check(
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts),
@@ -550,7 +550,7 @@ spec("input") {
}

it("sets initial state") {
IZ_MIDIInputInitialize(&state, "config-game.ini", 0, NULL);
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

// check(mock_is_called(IZ_memcpy), "Initial state not loaded.");
check(mock_is_called(Pm_CountDevices), "Connected MIDI devices not checked.");
@@ -560,7 +560,7 @@ spec("input") {
mock_set_expected_calls(ini_gets, IZ_CONTROLS * IZ_PLAYERS);
mock_set_expected_calls(ini_getl, 2 * IZ_PLAYERS);

IZ_MIDIInputInitialize(&state, "config-game.ini", 0, NULL);
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

check(
mock_get_expected_calls(ini_gets) == mock_get_actual_calls(ini_gets),
@@ -581,7 +581,7 @@ spec("input") {
mock_set_expected_calls(ini_puts, IZ_CONTROLS * IZ_PLAYERS);
mock_set_expected_calls(ini_putl, 2 * IZ_PLAYERS);

IZ_MIDIInputInitialize(&state, "config-game.ini", 0, NULL);
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

check(
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts),
@@ -601,7 +601,7 @@ spec("input") {
it("opens device handles") {
mock_set_expected_calls(Pm_OpenInput, MOCK_OPEN_JOYSTICKS);

IZ_MIDIInputInitialize(&state, "config-game.ini", 0, NULL);
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL);

check(
mock_get_expected_calls(Pm_OpenInput) == mock_get_actual_calls(Pm_OpenInput),
@@ -627,7 +627,7 @@ spec("input") {
mock_set_expected_calls(ini_puts, IZ_CONTROLS * IZ_PLAYERS);
mock_set_expected_calls(ini_putl, 2 * IZ_PLAYERS);

IZ_MIDIInputSaveConfig("config-game.ini", &state);
IZ_MIDIInputSaveConfig(IZ_CONFIG_GAME_PATH, &state);

check(
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts),


+ 1
- 1
src/packages/game/output/output.test.c Bestand weergeven

@@ -44,7 +44,7 @@ spec("output") {
it("calls save method") {
mock_set_expected_calls(ini_putl, 3);

IZ_VideoSaveConfig(&state, "config-game.ini");
IZ_VideoSaveConfig(&state, IZ_CONFIG_GAME_PATH);

check(
mock_get_expected_calls(ini_putl) == mock_get_actual_calls(ini_putl),


+ 1
- 1
src/packages/server/IZ_app.c Bestand weergeven

@@ -49,7 +49,7 @@ void IZ_AppPrintHelpOptions() {
"\n"
"Options:\n"
"\n"
" -c <path> Specifies the path to the config file. (default: \"./config-server.ini\")\n"
" -c <path> Specifies the path to the config file. (default: \"./" IZ_CONFIG_SERVER_PATH "\")\n"
" -d <path> Specifies the path to the database. (default: \"./db.sqlite\")\n"
" -h Displays this help screen.\n"
" -m <value> Specifies the message of the day. (default: \"\")\n"


+ 1
- 1
src/packages/server/IZ_app_config.c Bestand weergeven

@@ -8,5 +8,5 @@ void IZ_ConfigGetDefaultPath(char* config_path, size_t string_size) {
#endif

IZ_memcpy(config_path, string_size, config_path_dir, 128);
IZ_strcat(config_path, string_size, "config-server.ini");
IZ_strcat(config_path, string_size, IZ_CONFIG_SERVER_PATH);
}

Laden…
Annuleren
Opslaan