Skip to content

Commit

Permalink
Some bug and code warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crudelios committed May 16, 2024
1 parent d52c210 commit 7995399
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/figure/phrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "city/resource.h"
#include "city/sentiment.h"
#include "core/calc.h"
#include "core/file.h"
#include "figure/trader.h"
#include "figuretype/trader.h"
#include "sound/speech.h"
Expand Down Expand Up @@ -268,8 +269,8 @@ enum {
static void play_sound_file(int sound_id, int phrase_id)
{
if (sound_id >= 0 && phrase_id >= 0) {
char path[SOUND_FILENAME_MAX];
snprintf(path, SOUND_FILENAME_MAX, "wavs/%s", FIGURE_SOUNDS[sound_id][phrase_id]);
char path[FILE_NAME_MAX];
snprintf(path, FILE_NAME_MAX, "wavs/%s", FIGURE_SOUNDS[sound_id][phrase_id]);
sound_speech_play_file(path);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/platform/file_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ const char *platform_file_manager_get_directory_for_location(int location, const
int platform_file_manager_is_directory_writeable(const char *directory)
{
char file_name[FILE_NAME_MAX];
if (!directory || !*directory) {
directory = ".";
}
int attempt = 0;
do {
snprintf(file_name, FILE_NAME_MAX, "%s/test_%d.txt", directory, random_from_stdlib());
Expand Down
5 changes: 3 additions & 2 deletions src/translation/english.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,8 +1481,9 @@ static translation_string all_strings[] = {
{TR_USER_DIRECTORIES_CANCELLED_TITLE, "Directory selection canceled"},
{TR_USER_DIRECTORIES_CANCELLED_TEXT, "You have decided not to set a user directory. The C3 install directory will be used.\n"
"You can change your settings later in the configuration window."},
{TR_USER_DIRECTORIES_NOT_WRITEABLE_TITLE, "Directory not writeable"},
{TR_USER_DIRECTORIES_NOT_WRITEABLE_TEXT, "The selected directory is not writeable.\n\nPlease select a different directory."},
{TR_USER_DIRECTORIES_NOT_WRITEABLE_TITLE, "User directory not writeable"},
{TR_USER_DIRECTORIES_NOT_WRITEABLE_TEXT, "The selected user directory is not writeable.\n\nPlease select a different user directory."},
{TR_USER_DIRECTORIES_NOT_WRITEABLE_TEXT_DETAILED, "The selected user directory is not writeable.\n\nYou will not be able to save your games.\nPlease select a different user directory from the options window on the main menu."},
{TR_USER_DIRECTORIES_WINDOW_TITLE, "Set user directory"},
{TR_USER_DIRETORIES_WINDOW_USER_PATH, "User directory:" },
{TR_USER_DIRECTORIES_USER_PATH_CHANGED_TITLE, "User path changed"},
Expand Down
1 change: 1 addition & 0 deletions src/translation/translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,7 @@ typedef enum {
TR_USER_DIRECTORIES_CANCELLED_TEXT,
TR_USER_DIRECTORIES_NOT_WRITEABLE_TITLE,
TR_USER_DIRECTORIES_NOT_WRITEABLE_TEXT,
TR_USER_DIRECTORIES_NOT_WRITEABLE_TEXT_DETAILED,
TR_USER_DIRECTORIES_WINDOW_TITLE,
TR_USER_DIRETORIES_WINDOW_USER_PATH,
TR_USER_DIRECTORIES_USER_PATH_CHANGED_TITLE,
Expand Down
4 changes: 2 additions & 2 deletions src/window/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,8 @@ static void cancel_values(void)
data.config_values[i].new_value = data.config_values[i].original_value;
}
for (int i = 0; i < CONFIG_STRING_MAX_ALL; i++) {
snprintf(data.config_string_values[i].new_value, CONFIG_STRING_VALUE_MAX, "%s",
data.config_string_values[i].original_value);
memcpy(data.config_string_values[i].new_value, data.config_string_values[i].original_value,
CONFIG_STRING_VALUE_MAX);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/window/logo.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static int process_pending_actions(void)
}
if (pending_actions & ACTION_SHOW_MESSAGE_USER_DIR_NOT_WRITABLE) {
window_plain_message_dialog_show(TR_USER_DIRECTORIES_NOT_WRITEABLE_TITLE,
TR_USER_DIRECTORIES_NOT_WRITEABLE_TEXT, 0);
TR_USER_DIRECTORIES_NOT_WRITEABLE_TEXT_DETAILED, 0);
pending_actions ^= ACTION_SHOW_MESSAGE_USER_DIR_NOT_WRITABLE;
return 1;
}
Expand Down

0 comments on commit 7995399

Please sign in to comment.