mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #2729 from janisozaur/fixes
Minor fixes, mostly posix.c
This commit is contained in:
commit
1d2d9ce828
|
@ -84,12 +84,12 @@ void audio_populate_devices()
|
|||
if (utf8Name == NULL)
|
||||
utf8Name = language_get_string(5511);
|
||||
|
||||
safe_strncpy(systemAudioDevices[i].name, utf8Name, AUDIO_DEVICE_NAME_SIZE);
|
||||
safe_strcpy(systemAudioDevices[i].name, utf8Name, AUDIO_DEVICE_NAME_SIZE);
|
||||
}
|
||||
#ifndef __LINUX__
|
||||
gAudioDeviceCount++;
|
||||
gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device));
|
||||
safe_strncpy(gAudioDevices[0].name, language_get_string(5510), AUDIO_DEVICE_NAME_SIZE);
|
||||
safe_strcpy(gAudioDevices[0].name, language_get_string(5510), AUDIO_DEVICE_NAME_SIZE);
|
||||
memcpy(&gAudioDevices[1], systemAudioDevices, (gAudioDeviceCount - 1) * sizeof(audio_device));
|
||||
#else
|
||||
gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device));
|
||||
|
|
|
@ -132,7 +132,7 @@ exitcode_t CommandLine::HandleCommandDefault()
|
|||
|
||||
if (_openrctDataPath != NULL) {
|
||||
String::Set(gCustomOpenrctDataPath, sizeof(gCustomOpenrctDataPath), _openrctDataPath);
|
||||
Memory::Free(gCustomOpenrctDataPath);
|
||||
Memory::Free(_openrctDataPath);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -490,7 +490,7 @@ int cmdline_for_sprite(const char **argv, int argc)
|
|||
int maxIndex = (int)spriteFileHeader.num_entries;
|
||||
int numbers = (int)floor(log(maxIndex));
|
||||
|
||||
safe_strncpy(outputPath, argv[2], MAX_PATH);
|
||||
safe_strcpy(outputPath, argv[2], MAX_PATH);
|
||||
int pathLen = strlen(outputPath);
|
||||
|
||||
if (pathLen >= MAX_PATH - numbers - 5){
|
||||
|
@ -501,7 +501,7 @@ int cmdline_for_sprite(const char **argv, int argc)
|
|||
for (int x = 0; x < numbers; x++){
|
||||
outputPath[pathLen + x] = '0';
|
||||
}
|
||||
safe_strncpy(outputPath + pathLen + numbers, ".png", MAX_PATH);
|
||||
safe_strcpy(outputPath + pathLen + numbers, ".png", MAX_PATH);
|
||||
|
||||
for (int spriteIndex = 0; spriteIndex < maxIndex; spriteIndex++){
|
||||
|
||||
|
@ -603,7 +603,7 @@ int cmdline_for_sprite(const char **argv, int argc)
|
|||
int i = 0;
|
||||
do {
|
||||
// Create image path
|
||||
safe_strncpy(imagePath, resourcePath, MAX_PATH);
|
||||
safe_strcpy(imagePath, resourcePath, MAX_PATH);
|
||||
if (resourcePath[resourceLength - 1] == '/' || resourcePath[resourceLength - 1] == '\\')
|
||||
imagePath[resourceLength - 1] = 0;
|
||||
sprintf(imagePath, "%s%c%d.png", imagePath, platform_get_path_separator(), i);
|
||||
|
|
28
src/config.c
28
src/config.c
|
@ -832,7 +832,7 @@ static bool config_find_rct2_path(utf8 *resultPath)
|
|||
|
||||
for (i = 0; i < countof(searchLocations); i++) {
|
||||
if (platform_original_game_data_exists(searchLocations[i])) {
|
||||
safe_strncpy(resultPath, searchLocations[i], MAX_PATH);
|
||||
safe_strcpy(resultPath, searchLocations[i], MAX_PATH);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ bool config_find_or_browse_install_directory()
|
|||
if (config_find_rct2_path(path)) {
|
||||
SafeFree(gConfigGeneral.game_path);
|
||||
gConfigGeneral.game_path = malloc(strlen(path) + 1);
|
||||
safe_strncpy(gConfigGeneral.game_path, path, MAX_PATH);
|
||||
safe_strcpy(gConfigGeneral.game_path, path, MAX_PATH);
|
||||
} else {
|
||||
platform_show_messagebox("Unable to find RCT2 installation directory. Please select the directory where you installed RCT2!");
|
||||
installPath = platform_open_directory_browser("Please select your RCT2 directory");
|
||||
|
@ -1095,7 +1095,7 @@ void themes_set_default()
|
|||
gConfigThemes.presets = malloc(sizeof(theme_preset) * gConfigThemes.num_presets);
|
||||
|
||||
// Set RCT2 theme
|
||||
safe_strncpy(gConfigThemes.presets[0].name, language_get_string(2741), THEME_PRESET_NAME_SIZE);
|
||||
safe_strcpy(gConfigThemes.presets[0].name, language_get_string(2741), THEME_PRESET_NAME_SIZE);
|
||||
gConfigThemes.presets[0].windows = malloc(sizeof(theme_window) * gNumThemeWindows);
|
||||
|
||||
// Define the defaults for RCT2 here
|
||||
|
@ -1109,7 +1109,7 @@ void themes_set_default()
|
|||
}
|
||||
|
||||
// Set RCT1 theme
|
||||
safe_strncpy(gConfigThemes.presets[1].name, language_get_string(2740), THEME_PRESET_NAME_SIZE);
|
||||
safe_strcpy(gConfigThemes.presets[1].name, language_get_string(2740), THEME_PRESET_NAME_SIZE);
|
||||
gConfigThemes.presets[1].windows = malloc(sizeof(theme_window) * gNumThemeWindows);
|
||||
|
||||
// Define the defaults for RCT1 here
|
||||
|
@ -1203,7 +1203,7 @@ bool themes_open(const_utf8string path)
|
|||
if (preset == gConfigThemes.num_presets) {
|
||||
gConfigThemes.num_presets++;
|
||||
gConfigThemes.presets = realloc(gConfigThemes.presets, sizeof(theme_preset) * gConfigThemes.num_presets);
|
||||
safe_strncpy(gConfigThemes.presets[preset].name, path_get_filename(path), THEME_PRESET_NAME_SIZE);
|
||||
safe_strcpy(gConfigThemes.presets[preset].name, path_get_filename(path), THEME_PRESET_NAME_SIZE);
|
||||
path_remove_extension(gConfigThemes.presets[preset].name);
|
||||
gConfigThemes.presets[preset].windows = malloc(sizeof(theme_window) * gNumThemeWindows);
|
||||
gConfigThemes.presets[preset].features.rct1_ride_lights = false;
|
||||
|
@ -1520,7 +1520,7 @@ static void title_sequence_open(const char *path, const char *customName)
|
|||
char separator = platform_get_path_separator();
|
||||
|
||||
// Check for the script file
|
||||
safe_strncpy(scriptPath, path, MAX_PATH);
|
||||
safe_strcpy(scriptPath, path, MAX_PATH);
|
||||
strcat(scriptPath, "script.txt");
|
||||
if (!platform_file_exists(scriptPath)) {
|
||||
// No script file, title sequence is invalid
|
||||
|
@ -1541,18 +1541,18 @@ static void title_sequence_open(const char *path, const char *customName)
|
|||
|
||||
if (customName == NULL) {
|
||||
char nameBuffer[MAX_PATH];
|
||||
safe_strncpy(nameBuffer, path, MAX_PATH);
|
||||
safe_strcpy(nameBuffer, path, MAX_PATH);
|
||||
// Get folder name
|
||||
// First strip off the last folder separator
|
||||
*strrchr(nameBuffer, platform_get_path_separator()) = '\0';
|
||||
// Then find the name of the folder
|
||||
char *name = strrchr(nameBuffer, platform_get_path_separator()) + 1;
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
|
||||
gConfigTitleSequences.presets[preset].path[0] = 0;
|
||||
}
|
||||
else {
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].name, customName, TITLE_SEQUENCE_NAME_SIZE);
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].path, path, MAX_PATH);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].name, customName, TITLE_SEQUENCE_NAME_SIZE);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].path, path, MAX_PATH);
|
||||
}
|
||||
|
||||
gConfigTitleSequences.presets[preset].saves = malloc(0);
|
||||
|
@ -1562,23 +1562,23 @@ static void title_sequence_open(const char *path, const char *customName)
|
|||
}
|
||||
|
||||
// Get the save file list
|
||||
safe_strncpy(titlePath, path, MAX_PATH);
|
||||
safe_strcpy(titlePath, path, MAX_PATH);
|
||||
strcat(titlePath, "*.sv6");
|
||||
fileEnumHandle = platform_enumerate_files_begin(titlePath);
|
||||
while (platform_enumerate_files_next(fileEnumHandle, &fileInfo)) {
|
||||
gConfigTitleSequences.presets[preset].num_saves++;
|
||||
gConfigTitleSequences.presets[preset].saves = realloc(gConfigTitleSequences.presets[preset].saves, sizeof(char[TITLE_SEQUENCE_MAX_SAVE_LENGTH]) * (size_t)gConfigTitleSequences.presets[preset].num_saves);
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], fileInfo.path, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], fileInfo.path, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1][TITLE_SEQUENCE_MAX_SAVE_LENGTH - 1] = '\0';
|
||||
}
|
||||
platform_enumerate_files_end(fileEnumHandle);
|
||||
safe_strncpy(titlePath, path, MAX_PATH);
|
||||
safe_strcpy(titlePath, path, MAX_PATH);
|
||||
strcat(titlePath, "*.sc6");
|
||||
fileEnumHandle = platform_enumerate_files_begin(titlePath);
|
||||
while (platform_enumerate_files_next(fileEnumHandle, &fileInfo)) {
|
||||
gConfigTitleSequences.presets[preset].num_saves++;
|
||||
gConfigTitleSequences.presets[preset].saves = realloc(gConfigTitleSequences.presets[preset].saves, sizeof(char[TITLE_SEQUENCE_MAX_SAVE_LENGTH]) * (size_t)gConfigTitleSequences.presets[preset].num_saves);
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], fileInfo.path, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], fileInfo.path, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1][TITLE_SEQUENCE_MAX_SAVE_LENGTH - 1] = '\0';
|
||||
}
|
||||
platform_enumerate_files_end(fileEnumHandle);
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace String
|
|||
|
||||
utf8 * Set(utf8 * buffer, size_t bufferSize, const utf8 * src)
|
||||
{
|
||||
return safe_strncpy(buffer, src, bufferSize);
|
||||
return safe_strcpy(buffer, src, bufferSize);
|
||||
}
|
||||
|
||||
utf8 * Set(utf8 * buffer, size_t bufferSize, const utf8 * src, size_t srcSize)
|
||||
|
|
|
@ -1386,7 +1386,7 @@ void shorten_path(utf8 *buffer, size_t bufferSize, const utf8 *path, int availab
|
|||
|
||||
// Return full string if it fits
|
||||
if (gfx_get_string_width((char*)path) <= availableWidth) {
|
||||
safe_strncpy(buffer, path, bufferSize);
|
||||
safe_strcpy(buffer, path, bufferSize);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1399,7 +1399,7 @@ void shorten_path(utf8 *buffer, size_t bufferSize, const utf8 *path, int availab
|
|||
}
|
||||
|
||||
// TODO: Replace with unicode ellipsis when supported
|
||||
safe_strncpy(buffer, "...", bufferSize);
|
||||
safe_strcpy(buffer, "...", bufferSize);
|
||||
|
||||
// Abreviate beginning with xth separator
|
||||
int begin = -1;
|
||||
|
@ -1408,11 +1408,11 @@ void shorten_path(utf8 *buffer, size_t bufferSize, const utf8 *path, int availab
|
|||
begin++;
|
||||
} while (path[begin] != platform_get_path_separator());
|
||||
|
||||
safe_strncpy(buffer + 3, path + begin, bufferSize - 3);
|
||||
safe_strcpy(buffer + 3, path + begin, bufferSize - 3);
|
||||
if (gfx_get_string_width(buffer) <= availableWidth) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
safe_strncpy(buffer, path, bufferSize);
|
||||
safe_strcpy(buffer, path, bufferSize);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ void editor_load()
|
|||
gfx_invalidate_screen();
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, sint16) = 0;
|
||||
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, language_get_string(2749), 0x40);
|
||||
safe_strcpy((char*)RCT2_ADDRESS_SCENARIO_NAME, language_get_string(2749), 0x40);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,8 +119,8 @@ void editor_convert_save_to_scenario_callback(int result)
|
|||
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_NO_MONEY_SCENARIO;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) |= PARK_FLAGS_NO_MONEY;
|
||||
|
||||
safe_strncpy(s6Info->name, (const char*)RCT2_ADDRESS_SCENARIO_NAME, 64);
|
||||
safe_strncpy(s6Info->details, (const char*)RCT2_ADDRESS_SCENARIO_DETAILS, 256);
|
||||
safe_strcpy(s6Info->name, (const char*)RCT2_ADDRESS_SCENARIO_NAME, 64);
|
||||
safe_strcpy(s6Info->details, (const char*)RCT2_ADDRESS_SCENARIO_DETAILS, 256);
|
||||
s6Info->objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8);
|
||||
s6Info->objective_arg_1 = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8);
|
||||
s6Info->objective_arg_2 = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_CURRENCY, sint32);
|
||||
|
|
18
src/game.c
18
src/game.c
|
@ -604,7 +604,7 @@ static int open_landscape_file_dialog()
|
|||
{
|
||||
int result;
|
||||
format_string((char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, STR_LOAD_LANDSCAPE_DIALOG_TITLE, 0);
|
||||
safe_strncpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_LANDSCAPES_PATH, MAX_PATH);
|
||||
safe_strcpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_LANDSCAPES_PATH, MAX_PATH);
|
||||
format_string((char*)0x0141EE68, STR_RCT2_LANDSCAPE_FILE, 0);
|
||||
audio_pause_sounds();
|
||||
result = platform_open_common_file_dialog(1, (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, (char*)0x0141EF68, "*.SV6;*.SV4;*.SC6", (char*)0x0141EE68);
|
||||
|
@ -621,7 +621,7 @@ static int open_load_game_dialog()
|
|||
{
|
||||
int result;
|
||||
format_string((char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, STR_LOAD_GAME_DIALOG_TITLE, 0);
|
||||
safe_strncpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_SAVED_GAMES_PATH, MAX_PATH);
|
||||
safe_strcpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_SAVED_GAMES_PATH, MAX_PATH);
|
||||
format_string((char*)0x0141EE68, STR_RCT2_SAVED_GAME, 0);
|
||||
audio_pause_sounds();
|
||||
result = platform_open_common_file_dialog(1, (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, (char*)0x0141EF68, "*.SV6", (char*)0x0141EE68);
|
||||
|
@ -864,10 +864,10 @@ bool game_load_save(const utf8 *path)
|
|||
{
|
||||
log_verbose("loading saved game, %s", path);
|
||||
|
||||
safe_strncpy((char*)0x0141EF68, path, MAX_PATH);
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, path, MAX_PATH);
|
||||
safe_strcpy((char*)0x0141EF68, path, MAX_PATH);
|
||||
safe_strcpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, path, MAX_PATH);
|
||||
|
||||
safe_strncpy(gScenarioSavePath, path, MAX_PATH);
|
||||
safe_strcpy(gScenarioSavePath, path, MAX_PATH);
|
||||
|
||||
SDL_RWops* rw = SDL_RWFromFile(path, "rb");
|
||||
if (rw == NULL) {
|
||||
|
@ -965,7 +965,7 @@ static int show_save_game_dialog(char *resultPath)
|
|||
char filterName[256];
|
||||
|
||||
format_string(title, STR_SAVE_GAME_1040, NULL);
|
||||
safe_strncpy(filename, RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH_2, char), MAX_PATH);
|
||||
safe_strcpy(filename, RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH_2, char), MAX_PATH);
|
||||
format_string(filterName, STR_RCT2_SAVED_GAME, NULL);
|
||||
|
||||
audio_pause_sounds();
|
||||
|
@ -973,7 +973,7 @@ static int show_save_game_dialog(char *resultPath)
|
|||
audio_unpause_sounds();
|
||||
|
||||
if (result)
|
||||
safe_strncpy(resultPath, filename, MAX_PATH);
|
||||
safe_strcpy(resultPath, filename, MAX_PATH);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -999,7 +999,7 @@ void save_game()
|
|||
void save_game_as()
|
||||
{
|
||||
char name[MAX_PATH];
|
||||
safe_strncpy(name, path_get_filename(gScenarioSavePath), MAX_PATH);
|
||||
safe_strcpy(name, path_get_filename(gScenarioSavePath), MAX_PATH);
|
||||
path_remove_extension(name);
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME, name);
|
||||
}
|
||||
|
@ -1091,7 +1091,7 @@ void game_autosave()
|
|||
|
||||
|
||||
platform_get_user_directory(path, "save");
|
||||
safe_strncpy(backupPath, path, MAX_PATH);
|
||||
safe_strcpy(backupPath, path, MAX_PATH);
|
||||
|
||||
strcat(path, "autosave_");
|
||||
strcat(path, timeString);
|
||||
|
|
|
@ -79,14 +79,14 @@ void chat_draw()
|
|||
if (!gChatOpen && SDL_TICKS_PASSED(SDL_GetTicks(), chat_history_get_time(i) + 10000)) {
|
||||
break;
|
||||
}
|
||||
safe_strncpy(lineBuffer, chat_history_get(i), CHAT_INPUT_SIZE + 10);
|
||||
safe_strcpy(lineBuffer, chat_history_get(i), CHAT_INPUT_SIZE + 10);
|
||||
gfx_set_dirty_blocks(x, y, x + gfx_get_string_width(lineBuffer), y + 12);
|
||||
gfx_draw_string(dpi, lineBuffer, 255, x, y);
|
||||
}
|
||||
if (gChatOpen) {
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE);
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_CELADON);
|
||||
safe_strncpy(lineCh, _chatCurrentLine, CHAT_INPUT_SIZE);
|
||||
safe_strcpy(lineCh, _chatCurrentLine, CHAT_INPUT_SIZE);
|
||||
y = _chatBottom - 10;
|
||||
gfx_set_dirty_blocks(x, y, x + gfx_get_string_width(lineBuffer) + 7, y + 12);
|
||||
gfx_draw_string(dpi, lineBuffer, 255, x, y);
|
||||
|
|
|
@ -201,7 +201,7 @@ void theme_create_preset(int duplicate, const char *name)
|
|||
int preset = gConfigThemes.num_presets;
|
||||
gConfigThemes.num_presets++;
|
||||
gConfigThemes.presets = realloc(gConfigThemes.presets, sizeof(theme_preset) * gConfigThemes.num_presets);
|
||||
safe_strncpy(gConfigThemes.presets[preset].name, name, THEME_PRESET_NAME_SIZE);
|
||||
safe_strcpy(gConfigThemes.presets[preset].name, name, THEME_PRESET_NAME_SIZE);
|
||||
gConfigThemes.presets[preset].windows = malloc(sizeof(theme_window) * gNumThemeWindows);
|
||||
for (int i = 0; i < (int)gNumThemeWindows; i++) {
|
||||
gConfigThemes.presets[preset].windows[i] = gConfigThemes.presets[duplicate].windows[i];
|
||||
|
@ -242,7 +242,7 @@ void theme_rename_preset(int preset, const char *newName)
|
|||
strcat(dest, ".ini");
|
||||
platform_file_move(src, dest);
|
||||
|
||||
safe_strncpy(gConfigThemes.presets[preset].name, newName, THEME_PRESET_NAME_SIZE);
|
||||
safe_strcpy(gConfigThemes.presets[preset].name, newName, THEME_PRESET_NAME_SIZE);
|
||||
|
||||
if (preset == gCurrentTheme) {
|
||||
gConfigInterface.current_theme_preset = gConfigThemes.presets[preset].name;
|
||||
|
|
|
@ -47,7 +47,7 @@ bool title_sequence_save_exists(int preset, const char *name)
|
|||
{
|
||||
utf8 newName[MAX_PATH];
|
||||
char *extension = (char*)path_get_extension(name);
|
||||
safe_strncpy(newName, name, MAX_PATH);
|
||||
safe_strcpy(newName, name, MAX_PATH);
|
||||
if (_stricmp(extension, ".sv6") != 0 && _stricmp(extension, ".sc6") != 0)
|
||||
strcat(newName, ".sv6");
|
||||
for (int i = 0; i < gConfigTitleSequences.presets[preset].num_saves; i++) {
|
||||
|
@ -95,7 +95,7 @@ void title_sequence_create_preset(const char *name)
|
|||
int preset = gConfigTitleSequences.num_presets;
|
||||
gConfigTitleSequences.num_presets++;
|
||||
gConfigTitleSequences.presets = realloc(gConfigTitleSequences.presets, sizeof(title_sequence) * (size_t)gConfigTitleSequences.num_presets);
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
|
||||
gConfigTitleSequences.presets[preset].path[0] = 0;
|
||||
|
||||
gConfigTitleSequences.presets[preset].saves = malloc(0);
|
||||
|
@ -121,7 +121,7 @@ void title_sequence_duplicate_preset(int duplicate, const char *name)
|
|||
int preset = gConfigTitleSequences.num_presets;
|
||||
gConfigTitleSequences.num_presets++;
|
||||
gConfigTitleSequences.presets = realloc(gConfigTitleSequences.presets, sizeof(title_sequence) * (size_t)gConfigTitleSequences.num_presets);
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
|
||||
gConfigTitleSequences.presets[preset].path[0] = 0;
|
||||
|
||||
size_t savesSize = sizeof(char[TITLE_SEQUENCE_MAX_SAVE_LENGTH]) * gConfigTitleSequences.presets[duplicate].num_saves;
|
||||
|
@ -153,7 +153,7 @@ void title_sequence_duplicate_preset(int duplicate, const char *name)
|
|||
char separator = platform_get_path_separator();
|
||||
for (int i = 0; i < gConfigTitleSequences.presets[preset].num_saves; i++) {
|
||||
if (gConfigTitleSequences.presets[duplicate].path[0]) {
|
||||
safe_strncpy(srcPath, gConfigTitleSequences.presets[duplicate].path, MAX_PATH);
|
||||
safe_strcpy(srcPath, gConfigTitleSequences.presets[duplicate].path, MAX_PATH);
|
||||
strcat(srcPath, gConfigTitleSequences.presets[duplicate].saves[i]);
|
||||
}
|
||||
else {
|
||||
|
@ -219,7 +219,7 @@ void title_sequence_rename_preset(int preset, const char *newName)
|
|||
strcat(dest, newName);
|
||||
platform_file_move(src, dest);
|
||||
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].name, newName, TITLE_SEQUENCE_NAME_SIZE);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].name, newName, TITLE_SEQUENCE_NAME_SIZE);
|
||||
|
||||
// Rename the config preset name if needed
|
||||
if (preset == gCurrentPreviewTitleSequence) {
|
||||
|
@ -233,7 +233,7 @@ void title_sequence_add_save(int preset, const char *path, const char *newName)
|
|||
{
|
||||
utf8 newPath[MAX_PATH];
|
||||
char *extension = (char*)path_get_extension(newName);
|
||||
safe_strncpy(newPath, newName, MAX_PATH);
|
||||
safe_strcpy(newPath, newName, MAX_PATH);
|
||||
if (_stricmp(extension, ".sv6") != 0 && _stricmp(extension, ".sc6") != 0)
|
||||
strcat(newPath, ".sv6");
|
||||
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && filename_valid_characters(newPath) && !title_sequence_save_exists(preset, newPath) && platform_file_exists(path)) {
|
||||
|
@ -251,7 +251,7 @@ void title_sequence_add_save(int preset, const char *path, const char *newName)
|
|||
gConfigTitleSequences.presets[preset].num_saves++;
|
||||
gConfigTitleSequences.presets[preset].saves = realloc(gConfigTitleSequences.presets[preset].saves, sizeof(char[TITLE_SEQUENCE_MAX_SAVE_LENGTH]) * (size_t)gConfigTitleSequences.presets[preset].num_saves);
|
||||
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], newName, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], newName, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
// Add the appropriate extension if needed
|
||||
if (_stricmp(extension, ".sv6") != 0 && _stricmp(extension, ".sc6") != 0)
|
||||
strcat(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], ".sv6");
|
||||
|
@ -281,7 +281,7 @@ void title_sequence_remove_save(int preset, int index)
|
|||
}
|
||||
|
||||
for (int i = index; i < gConfigTitleSequences.presets[preset].num_saves - 1; i++) {
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].saves[i], gConfigTitleSequences.presets[preset].saves[i + 1], TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].saves[i], gConfigTitleSequences.presets[preset].saves[i + 1], TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
}
|
||||
gConfigTitleSequences.presets[preset].num_saves--;
|
||||
gConfigTitleSequences.presets[preset].saves = realloc(gConfigTitleSequences.presets[preset].saves, sizeof(char[TITLE_SEQUENCE_MAX_SAVE_LENGTH]) * (size_t)gConfigTitleSequences.presets[preset].num_saves);
|
||||
|
@ -311,7 +311,7 @@ void title_sequence_rename_save(int preset, int index, const char *newName)
|
|||
strcat(dest, ".sv6");
|
||||
platform_file_move(src, dest);
|
||||
|
||||
safe_strncpy(gConfigTitleSequences.presets[preset].saves[index], newName, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
safe_strcpy(gConfigTitleSequences.presets[preset].saves[index], newName, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
|
||||
// Add the appropriate extension if needed
|
||||
if (_stricmp(extension, ".sv6") != 0 && _stricmp(extension, ".sc6") != 0)
|
||||
strcat(gConfigTitleSequences.presets[preset].saves[index], ".sv6");
|
||||
|
|
|
@ -1169,7 +1169,7 @@ static void widget_text_box_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg
|
|||
if (!active) {
|
||||
|
||||
if (w->widgets[widgetIndex].image != 0) {
|
||||
safe_strncpy(wrapped_string, (char*)w->widgets[widgetIndex].image, 512);
|
||||
safe_strcpy(wrapped_string, (char*)w->widgets[widgetIndex].image, 512);
|
||||
gfx_wrap_string(wrapped_string, r - l - 5, &no_lines, &font_height);
|
||||
gfx_draw_string(dpi, wrapped_string, w->colours[1], l + 2, t);
|
||||
}
|
||||
|
@ -1177,7 +1177,7 @@ static void widget_text_box_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg
|
|||
}
|
||||
|
||||
|
||||
safe_strncpy(wrapped_string, gTextBoxInput, 512);
|
||||
safe_strcpy(wrapped_string, gTextBoxInput, 512);
|
||||
|
||||
// String length needs to add 12 either side of box
|
||||
// +13 for cursor when max length.
|
||||
|
|
|
@ -442,7 +442,7 @@ void format_currency(char **dest, long long value)
|
|||
|
||||
// Prefix
|
||||
if (affix == CURRENCY_PREFIX) {
|
||||
safe_strncpy(*dest, symbol, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
safe_strcpy(*dest, symbol, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
*dest += strlen(*dest);
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ void format_currency(char **dest, long long value)
|
|||
|
||||
// Currency symbol suffix
|
||||
if (affix == CURRENCY_SUFFIX) {
|
||||
safe_strncpy(*dest, symbol, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
safe_strcpy(*dest, symbol, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
*dest += strlen(*dest);
|
||||
}
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ void format_currency_2dp(char **dest, long long value)
|
|||
|
||||
// Prefix
|
||||
if (affix == CURRENCY_PREFIX) {
|
||||
safe_strncpy(*dest, symbol, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
safe_strcpy(*dest, symbol, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
*dest += strlen(*dest);
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ void format_currency_2dp(char **dest, long long value)
|
|||
|
||||
// Currency symbol suffix
|
||||
if (affix == CURRENCY_SUFFIX) {
|
||||
safe_strncpy(*dest, symbol, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
safe_strcpy(*dest, symbol, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
*dest += strlen(*dest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ rct_string_id user_string_allocate(int base, const utf8 *text)
|
|||
if (userString[0] != 0)
|
||||
continue;
|
||||
|
||||
safe_strncpy(userString, text, USER_STRING_MAX_LENGTH - 1);
|
||||
safe_strcpy(userString, text, USER_STRING_MAX_LENGTH - 1);
|
||||
return 0x8000 + (i | highBits);
|
||||
}
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_TOO_MANY_NAMES_DEFINED;
|
||||
|
|
|
@ -327,7 +327,7 @@ void news_item_add_to_queue_raw(uint8 type, const utf8 *text, uint32 assoc)
|
|||
newsItem->ticks = 0;
|
||||
newsItem->month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
|
||||
newsItem->day = ((days_in_month[(newsItem->month_year & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16) + 1;
|
||||
safe_strncpy(newsItem->text, text, 255);
|
||||
safe_strcpy(newsItem->text, text, 255);
|
||||
newsItem->text[254] = 0;
|
||||
|
||||
// blatant disregard for what happens on the last element.
|
||||
|
|
|
@ -192,7 +192,7 @@ bool NetworkPacket::CommandRequiresAuth()
|
|||
|
||||
NetworkPlayer::NetworkPlayer(const char* name)
|
||||
{
|
||||
safe_strncpy((char*)NetworkPlayer::name, name, sizeof(NetworkPlayer::name));
|
||||
safe_strcpy((char*)NetworkPlayer::name, name, sizeof(NetworkPlayer::name));
|
||||
NetworkPlayer::name[sizeof(NetworkPlayer::name) - 1] = 0;
|
||||
ping = 0;
|
||||
flags = 0;
|
||||
|
@ -776,13 +776,13 @@ const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text)
|
|||
if (fromplayer) {
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE);
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_BABYBLUE);
|
||||
safe_strncpy(lineCh, (const char*)fromplayer->name, sizeof(fromplayer->name));
|
||||
safe_strcpy(lineCh, (const char*)fromplayer->name, sizeof(fromplayer->name));
|
||||
strcat(lineCh, ": ");
|
||||
lineCh = strchr(lineCh, '\0');
|
||||
}
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE);
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_WHITE);
|
||||
safe_strncpy(lineCh, text, 800);
|
||||
safe_strcpy(lineCh, text, 800);
|
||||
return formatted;
|
||||
}
|
||||
|
||||
|
|
|
@ -422,14 +422,14 @@ static void twitch_parse_chat_message(const char *message)
|
|||
|
||||
message++;
|
||||
ch = strchrm(message, " \t");
|
||||
safe_strncpy(buffer, message, ch - message);
|
||||
safe_strcpy(buffer, message, ch - message);
|
||||
buffer[ch - message] = 0;
|
||||
if (_strcmpi(buffer, "news") == 0) {
|
||||
if (gConfigTwitch.enable_news) {
|
||||
ch = strskipwhitespace(ch);
|
||||
|
||||
buffer[0] = (char)FORMAT_TOPAZ;
|
||||
safe_strncpy(buffer + 1, ch, sizeof(buffer) - 2);
|
||||
safe_strcpy(buffer + 1, ch, sizeof(buffer) - 2);
|
||||
buffer[sizeof(buffer) - 2] = 0;
|
||||
|
||||
// Remove unsupport characters
|
||||
|
|
|
@ -107,7 +107,7 @@ static void openrct2_copy_files_over(const utf8 *originalDirectory, const utf8 *
|
|||
}
|
||||
|
||||
// Create filter path
|
||||
safe_strncpy(filter, originalDirectory, MAX_PATH);
|
||||
safe_strcpy(filter, originalDirectory, MAX_PATH);
|
||||
ch = strchr(filter, '*');
|
||||
if (ch != NULL)
|
||||
*ch = 0;
|
||||
|
@ -116,10 +116,10 @@ static void openrct2_copy_files_over(const utf8 *originalDirectory, const utf8 *
|
|||
|
||||
fileEnumHandle = platform_enumerate_files_begin(filter);
|
||||
while (platform_enumerate_files_next(fileEnumHandle, &fileInfo)) {
|
||||
safe_strncpy(newPath, newDirectory, MAX_PATH);
|
||||
safe_strcpy(newPath, newDirectory, MAX_PATH);
|
||||
strcat(newPath, fileInfo.path);
|
||||
|
||||
safe_strncpy(oldPath, originalDirectory, MAX_PATH);
|
||||
safe_strcpy(oldPath, originalDirectory, MAX_PATH);
|
||||
ch = strchr(oldPath, '*');
|
||||
if (ch != NULL)
|
||||
*ch = 0;
|
||||
|
@ -132,10 +132,10 @@ static void openrct2_copy_files_over(const utf8 *originalDirectory, const utf8 *
|
|||
|
||||
fileEnumHandle = platform_enumerate_directories_begin(originalDirectory);
|
||||
while (platform_enumerate_directories_next(fileEnumHandle, filter)) {
|
||||
safe_strncpy(newPath, newDirectory, MAX_PATH);
|
||||
safe_strcpy(newPath, newDirectory, MAX_PATH);
|
||||
strcat(newPath, filter);
|
||||
|
||||
safe_strncpy(oldPath, originalDirectory, MAX_PATH);
|
||||
safe_strcpy(oldPath, originalDirectory, MAX_PATH);
|
||||
ch = strchr(oldPath, '*');
|
||||
if (ch != NULL)
|
||||
*ch = 0;
|
||||
|
|
|
@ -60,7 +60,7 @@ void platform_get_exe_path(utf8 *outPath)
|
|||
int exeDelimiterIndex = (int)(exeDelimiter - exePath);
|
||||
|
||||
exePath[exeDelimiterIndex] = '\0';
|
||||
safe_strncpy(outPath, exePath, exeDelimiterIndex + 1);
|
||||
safe_strcpy(outPath, exePath, exeDelimiterIndex + 1);
|
||||
}
|
||||
|
||||
bool platform_check_steam_overlay_attached() {
|
||||
|
@ -140,7 +140,7 @@ void platform_posix_sub_resolve_openrct_data_path(utf8 *out) {
|
|||
if (platform_directory_exists(searchLocations[i]))
|
||||
{
|
||||
out[0] = '\0';
|
||||
safe_strncpy(out, searchLocations[i], MAX_PATH);
|
||||
safe_strcpy(out, searchLocations[i], MAX_PATH);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer)
|
|||
if (FcPatternGetString(match, FC_FILE, 0, &filename) == FcResultMatch)
|
||||
{
|
||||
found = true;
|
||||
safe_strncpy(buffer, (utf8*) filename, MAX_PATH);
|
||||
safe_strcpy(buffer, (utf8*) filename, MAX_PATH);
|
||||
log_verbose("FontConfig provided font %s", filename);
|
||||
}
|
||||
FcPatternDestroy(match);
|
||||
|
|
|
@ -49,7 +49,7 @@ void platform_get_exe_path(utf8 *outPath)
|
|||
}
|
||||
int exeDelimiterIndex = (int)(exeDelimiter - exePath);
|
||||
|
||||
safe_strncpy(outPath, exePath, exeDelimiterIndex + 1);
|
||||
safe_strcpy(outPath, exePath, exeDelimiterIndex + 1);
|
||||
outPath[exeDelimiterIndex] = '\0';
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ void platform_posix_sub_resolve_openrct_data_path(utf8 *out) {
|
|||
if (platform_directory_exists(resources))
|
||||
{
|
||||
out[0] = '\0';
|
||||
safe_strncpy(out, resources, MAX_PATH);
|
||||
safe_strcpy(out, resources, MAX_PATH);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,10 @@ bool platform_directory_delete(const utf8 *path)
|
|||
chp = fts_children(ftsp, 0);
|
||||
if (chp == NULL) {
|
||||
log_verbose("No files to traverse, deleting directory %s", path);
|
||||
remove(path);
|
||||
if (remove(path) != 0)
|
||||
{
|
||||
log_error("Failed to remove %s, errno = %d", path, errno);
|
||||
}
|
||||
free(ourPath);
|
||||
return true; // No files to traverse
|
||||
}
|
||||
|
@ -227,12 +230,9 @@ bool platform_directory_delete(const utf8 *path)
|
|||
bool platform_lock_single_instance()
|
||||
{
|
||||
char pidFilePath[MAX_PATH];
|
||||
char separator = platform_get_path_separator();
|
||||
|
||||
strncpy(pidFilePath, _userDataDirectoryPath, MAX_PATH);
|
||||
strncat(pidFilePath, &separator, 1);
|
||||
strncat(pidFilePath, SINGLE_INSTANCE_MUTEX_NAME,
|
||||
MAX_PATH - strnlen(pidFilePath, MAX_PATH) - 1);
|
||||
safe_strcpy(pidFilePath, _userDataDirectoryPath, sizeof(pidFilePath));
|
||||
safe_strcat_path(pidFilePath, SINGLE_INSTANCE_MUTEX_NAME, sizeof(pidFilePath));
|
||||
|
||||
// We will never close this file manually. The operating system will
|
||||
// take care of that, because flock keeps the lock as long as the
|
||||
|
@ -325,7 +325,7 @@ int platform_enumerate_files_begin(const utf8 *pattern)
|
|||
for (int i = 0; i < countof(_enumerateFileInfoList); i++) {
|
||||
enumFileInfo = &_enumerateFileInfoList[i];
|
||||
if (!enumFileInfo->active) {
|
||||
safe_strncpy(enumFileInfo->pattern, npattern, sizeof(enumFileInfo->pattern));
|
||||
safe_strcpy(enumFileInfo->pattern, npattern, sizeof(enumFileInfo->pattern));
|
||||
cnt = scandir(dir_name, &enumFileInfo->fileListTemp, winfilter, alphasort);
|
||||
if (cnt < 0)
|
||||
{
|
||||
|
@ -465,7 +465,7 @@ int platform_enumerate_directories_begin(const utf8 *directory)
|
|||
for (int i = 0; i < countof(_enumerateFileInfoList); i++) {
|
||||
enumFileInfo = &_enumerateFileInfoList[i];
|
||||
if (!enumFileInfo->active) {
|
||||
safe_strncpy(enumFileInfo->pattern, npattern, length);
|
||||
safe_strcpy(enumFileInfo->pattern, npattern, length);
|
||||
cnt = scandir(npattern, &enumFileInfo->fileListTemp, dirfilter, alphasort);
|
||||
if (cnt < 0)
|
||||
{
|
||||
|
@ -534,7 +534,7 @@ bool platform_enumerate_directories_next(int handle, utf8 *path)
|
|||
return false;
|
||||
}
|
||||
// so very, very wrong
|
||||
safe_strncpy(path, basename(fileName), MAX_PATH);
|
||||
safe_strcpy(path, basename(fileName), MAX_PATH);
|
||||
strncat(path, "/", MAX_PATH - strlen(path) - 1);
|
||||
return true;
|
||||
} else {
|
||||
|
@ -576,10 +576,11 @@ bool platform_file_copy(const utf8 *srcPath, const utf8 *dstPath, bool overwrite
|
|||
if (overwrite) {
|
||||
dstFile = fopen(dstPath, "wb");
|
||||
} else {
|
||||
// Portability note: check your libc's support for "wbx"
|
||||
dstFile = fopen(dstPath, "wbx");
|
||||
}
|
||||
|
||||
if (dstFile != NULL) {
|
||||
if (dstFile == NULL) {
|
||||
if (errno == EEXIST) {
|
||||
log_warning("platform_file_copy: Not overwriting %s, because overwrite flag == false", dstPath);
|
||||
return 0;
|
||||
|
@ -591,7 +592,7 @@ bool platform_file_copy(const utf8 *srcPath, const utf8 *dstPath, bool overwrite
|
|||
|
||||
// Open both files and check whether they are opened correctly
|
||||
FILE *srcFile = fopen(srcPath, "rb");
|
||||
if (!srcFile) {
|
||||
if (srcFile == NULL) {
|
||||
fclose(dstFile);
|
||||
log_error("Could not open source file %s for copying", srcPath);
|
||||
return 0;
|
||||
|
@ -680,13 +681,13 @@ void platform_resolve_user_data_path()
|
|||
w_buffer[len] = '\0';
|
||||
utf8 *path = widechar_to_utf8(w_buffer);
|
||||
free(w_buffer);
|
||||
safe_strncpy(_userDataDirectoryPath, path, MAX_PATH);
|
||||
safe_strcpy(_userDataDirectoryPath, path, MAX_PATH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
void platform_get_openrct_data_path(utf8 *outPath)
|
||||
{
|
||||
safe_strncpy(outPath, _openrctDataDirectoryPath, sizeof(_openrctDataDirectoryPath));
|
||||
safe_strcpy(outPath, _openrctDataDirectoryPath, sizeof(_openrctDataDirectoryPath));
|
||||
}
|
||||
|
||||
void platform_posix_sub_resolve_openrct_data_path(utf8 *out);
|
||||
|
@ -721,7 +722,7 @@ void platform_resolve_openrct_data_path()
|
|||
if (platform_directory_exists(buffer))
|
||||
{
|
||||
_openrctDataDirectoryPath[0] = '\0';
|
||||
safe_strncpy(_openrctDataDirectoryPath, buffer, MAX_PATH);
|
||||
safe_strcpy(_openrctDataDirectoryPath, buffer, MAX_PATH);
|
||||
log_verbose("Found OpenRCT2 data in %s", _openrctDataDirectoryPath);
|
||||
return;
|
||||
}
|
||||
|
@ -734,7 +735,7 @@ void platform_get_user_directory(utf8 *outPath, const utf8 *subDirectory)
|
|||
{
|
||||
const char separator[2] = { platform_get_path_separator(), 0 };
|
||||
char buffer[MAX_PATH];
|
||||
safe_strncpy(buffer, _userDataDirectoryPath, sizeof(buffer));
|
||||
safe_strcpy(buffer, _userDataDirectoryPath, sizeof(buffer));
|
||||
if (subDirectory != NULL && subDirectory[0] != 0) {
|
||||
log_verbose("adding subDirectory '%s'", subDirectory);
|
||||
strncat(buffer, subDirectory, MAX_PATH - strnlen(buffer, MAX_PATH) - 1);
|
||||
|
@ -745,7 +746,7 @@ void platform_get_user_directory(utf8 *outPath, const utf8 *subDirectory)
|
|||
w_buffer[len] = '\0';
|
||||
utf8 *path = widechar_to_utf8(w_buffer);
|
||||
free(w_buffer);
|
||||
safe_strncpy(outPath, path, MAX_PATH);
|
||||
safe_strcpy(outPath, path, MAX_PATH);
|
||||
free(path);
|
||||
log_verbose("outPath + subDirectory = '%s'", buffer);
|
||||
}
|
||||
|
|
|
@ -687,7 +687,7 @@ void platform_process_messages()
|
|||
}
|
||||
break;
|
||||
case SDL_TEXTEDITING:
|
||||
safe_strncpy(gTextInputComposition, e.edit.text, min(e.edit.length, 32));
|
||||
safe_strcpy(gTextInputComposition, e.edit.text, min(e.edit.length, 32));
|
||||
gTextInputCompositionStart = e.edit.start;
|
||||
gTextInputCompositionLength = e.edit.length;
|
||||
gTextInputCompositionActive = gTextInputComposition[0] != 0;
|
||||
|
|
|
@ -483,7 +483,7 @@ void platform_resolve_openrct_data_path()
|
|||
exit(-1);
|
||||
}
|
||||
utf8 *outPathTemp = widechar_to_utf8(wOutPath);
|
||||
safe_strncpy(_userDataDirectoryPath, outPathTemp, sizeof(_userDataDirectoryPath));
|
||||
safe_strcpy(_userDataDirectoryPath, outPathTemp, sizeof(_userDataDirectoryPath));
|
||||
free(outPathTemp);
|
||||
free(customUserDataPathW);
|
||||
|
||||
|
@ -503,7 +503,7 @@ void platform_resolve_openrct_data_path()
|
|||
if (platform_directory_exists(buffer))
|
||||
{
|
||||
_openrctDataDirectoryPath[0] = '\0';
|
||||
safe_strncpy(_openrctDataDirectoryPath, buffer, sizeof(_openrctDataDirectoryPath));
|
||||
safe_strcpy(_openrctDataDirectoryPath, buffer, sizeof(_openrctDataDirectoryPath));
|
||||
return;
|
||||
} else {
|
||||
log_fatal("Unable to resolve openrct data path.");
|
||||
|
@ -513,7 +513,7 @@ void platform_resolve_openrct_data_path()
|
|||
|
||||
void platform_get_openrct_data_path(utf8 *outPath)
|
||||
{
|
||||
safe_strncpy(outPath, _openrctDataDirectoryPath, sizeof(_openrctDataDirectoryPath));
|
||||
safe_strcpy(outPath, _openrctDataDirectoryPath, sizeof(_openrctDataDirectoryPath));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -533,7 +533,7 @@ void platform_resolve_user_data_path()
|
|||
exit(-1);
|
||||
}
|
||||
utf8 *outPathTemp = widechar_to_utf8(wOutPath);
|
||||
safe_strncpy(_userDataDirectoryPath, outPathTemp, sizeof(_userDataDirectoryPath));
|
||||
safe_strcpy(_userDataDirectoryPath, outPathTemp, sizeof(_userDataDirectoryPath));
|
||||
free(outPathTemp);
|
||||
free(customUserDataPathW);
|
||||
|
||||
|
@ -547,7 +547,7 @@ void platform_resolve_user_data_path()
|
|||
|
||||
if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, wOutPath))) {
|
||||
utf8 *outPathTemp = widechar_to_utf8(wOutPath);
|
||||
safe_strncpy(_userDataDirectoryPath, outPathTemp, sizeof(_userDataDirectoryPath));
|
||||
safe_strcpy(_userDataDirectoryPath, outPathTemp, sizeof(_userDataDirectoryPath));
|
||||
free(outPathTemp);
|
||||
|
||||
strcat(_userDataDirectoryPath, separator);
|
||||
|
|
|
@ -203,7 +203,7 @@ int scenario_load_and_play_from_path(const char *path)
|
|||
return 0;
|
||||
|
||||
int len = strnlen(path, MAX_PATH) + 1;
|
||||
safe_strncpy(_scenarioPath, path, len);
|
||||
safe_strcpy(_scenarioPath, path, len);
|
||||
if (len - 1 == MAX_PATH)
|
||||
{
|
||||
_scenarioPath[MAX_PATH - 1] = '\0';
|
||||
|
@ -275,24 +275,24 @@ void scenario_begin()
|
|||
|
||||
finance_update_loan_hash();
|
||||
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, s6Info->details, 256);
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, s6Info->name, 64);
|
||||
safe_strcpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, s6Info->details, 256);
|
||||
safe_strcpy((char*)RCT2_ADDRESS_SCENARIO_NAME, s6Info->name, 64);
|
||||
|
||||
{
|
||||
utf8 normalisedName[64];
|
||||
safe_strncpy(normalisedName, s6Info->name, sizeof(normalisedName));
|
||||
safe_strcpy(normalisedName, s6Info->name, sizeof(normalisedName));
|
||||
scenario_normalise_name(normalisedName);
|
||||
|
||||
rct_string_id localisedStringIds[3];
|
||||
if (language_get_localised_scenario_strings(normalisedName, localisedStringIds)) {
|
||||
if (localisedStringIds[0] != STR_NONE) {
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, language_get_string(localisedStringIds[0]), 32);
|
||||
safe_strcpy((char*)RCT2_ADDRESS_SCENARIO_NAME, language_get_string(localisedStringIds[0]), 32);
|
||||
}
|
||||
if (localisedStringIds[1] != STR_NONE) {
|
||||
park_set_name(language_get_string(localisedStringIds[1]));
|
||||
}
|
||||
if (localisedStringIds[2] != STR_NONE) {
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, language_get_string(localisedStringIds[2]), 256);
|
||||
safe_strcpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, language_get_string(localisedStringIds[2]), 256);
|
||||
}
|
||||
} else {
|
||||
rct_stex_entry* stex = g_stexEntries[0];
|
||||
|
@ -305,12 +305,12 @@ void scenario_begin()
|
|||
|
||||
// Set localised scenario name
|
||||
format_string(buffer, stex->scenario_name, 0);
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, buffer, 31);
|
||||
safe_strcpy((char*)RCT2_ADDRESS_SCENARIO_NAME, buffer, 31);
|
||||
((char*)RCT2_ADDRESS_SCENARIO_NAME)[31] = '\0';
|
||||
|
||||
// Set localised scenario details
|
||||
format_string(buffer, stex->details, 0);
|
||||
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, buffer, 255);
|
||||
safe_strcpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, buffer, 255);
|
||||
((char*)RCT2_ADDRESS_SCENARIO_DETAILS)[255] = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ void scenario_success_submit_name(const char *name)
|
|||
money32 scenarioWinCompanyValue = RCT2_GLOBAL(0x013587C0, money32);
|
||||
if (scenario->highscore->company_value == scenarioWinCompanyValue) {
|
||||
scenario->highscore->name = _strdup(name);
|
||||
safe_strncpy((char*)0x013587D8, name, 32);
|
||||
safe_strcpy((char*)0x013587D8, name, 32);
|
||||
scenario_scores_save();
|
||||
}
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ int scenario_prepare_for_save()
|
|||
rct_stex_entry* stex = g_stexEntries[0];
|
||||
if ((int)stex != 0xFFFFFFFF) {
|
||||
format_string(buffer, stex->scenario_name, NULL);
|
||||
safe_strncpy(s6Info->name, buffer, sizeof(s6Info->name));
|
||||
safe_strcpy(s6Info->name, buffer, sizeof(s6Info->name));
|
||||
|
||||
memcpy(&s6Info->entry, &object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].entries[0], sizeof(rct_object_entry));
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ static void sub_674BCF()
|
|||
char *dst = &savedExpansionPackNames[i * 128];
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_EXPANSION_FLAGS, uint16) & (1 << i)) {
|
||||
char *src = &(RCT2_ADDRESS(RCT2_ADDRESS_EXPANSION_NAMES, char)[i * 128]);
|
||||
safe_strncpy(dst, src, 128);
|
||||
safe_strcpy(dst, src, 128);
|
||||
} else {
|
||||
*dst = 0;
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ int scenario_save(SDL_RWops* rw, int flags)
|
|||
memcpy(s6->map_elements, (void*)0x00F663B8, 0x180000);
|
||||
memcpy(&s6->dword_010E63B8, (void*)0x010E63B8, 0x2E8570);
|
||||
|
||||
safe_strncpy(s6->scenario_filename, _scenarioFileName, sizeof(s6->scenario_filename));
|
||||
safe_strcpy(s6->scenario_filename, _scenarioFileName, sizeof(s6->scenario_filename));
|
||||
|
||||
scenario_fix_ghosts(s6);
|
||||
game_convert_strings_to_rct2(s6);
|
||||
|
|
|
@ -60,7 +60,7 @@ void scenario_load_list()
|
|||
gScenarioListCount = 0;
|
||||
|
||||
// Get scenario directory from RCT2
|
||||
safe_strncpy(directory, gConfigGeneral.game_path, sizeof(directory));
|
||||
safe_strcpy(directory, gConfigGeneral.game_path, sizeof(directory));
|
||||
safe_strcat_path(directory, "Scenarios", sizeof(directory));
|
||||
scenario_list_include(directory);
|
||||
|
||||
|
@ -84,13 +84,13 @@ static void scenario_list_include(const utf8 *directory)
|
|||
|
||||
// Scenarios in this directory
|
||||
utf8 pattern[MAX_PATH];
|
||||
safe_strncpy(pattern, directory, sizeof(pattern));
|
||||
safe_strcpy(pattern, directory, sizeof(pattern));
|
||||
safe_strcat_path(pattern, "*.sc6", sizeof(pattern));
|
||||
|
||||
handle = platform_enumerate_files_begin(pattern);
|
||||
while (platform_enumerate_files_next(handle, &fileInfo)) {
|
||||
utf8 path[MAX_PATH];
|
||||
safe_strncpy(path, directory, sizeof(pattern));
|
||||
safe_strcpy(path, directory, sizeof(pattern));
|
||||
safe_strcat_path(path, fileInfo.path, sizeof(pattern));
|
||||
scenario_list_add(path, fileInfo.last_modified);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ static void scenario_list_include(const utf8 *directory)
|
|||
handle = platform_enumerate_directories_begin(directory);
|
||||
while (platform_enumerate_directories_next(handle, subDirectory)) {
|
||||
utf8 path[MAX_PATH];
|
||||
safe_strncpy(path, directory, sizeof(pattern));
|
||||
safe_strcpy(path, directory, sizeof(pattern));
|
||||
safe_strcat_path(path, subDirectory, sizeof(pattern));
|
||||
scenario_list_include(path);
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ static void scenario_list_add(const utf8 *path, uint64 timestamp)
|
|||
}
|
||||
|
||||
// Set new entry
|
||||
safe_strncpy(newEntry->path, path, sizeof(newEntry->path));
|
||||
safe_strcpy(newEntry->path, path, sizeof(newEntry->path));
|
||||
newEntry->timestamp = timestamp;
|
||||
newEntry->category = s6Info.category;
|
||||
newEntry->objective_type = s6Info.objective_type;
|
||||
|
@ -160,8 +160,8 @@ static void scenario_list_add(const utf8 *path, uint64 timestamp)
|
|||
newEntry->objective_arg_2 = s6Info.objective_arg_2;
|
||||
newEntry->objective_arg_3 = s6Info.objective_arg_3;
|
||||
newEntry->highscore = NULL;
|
||||
safe_strncpy(newEntry->name, s6Info.name, sizeof(newEntry->name));
|
||||
safe_strncpy(newEntry->details, s6Info.details, sizeof(newEntry->details));
|
||||
safe_strcpy(newEntry->name, s6Info.name, sizeof(newEntry->name));
|
||||
safe_strcpy(newEntry->details, s6Info.details, sizeof(newEntry->details));
|
||||
|
||||
// Normalise the name to make the scenario as recognisable as possible.
|
||||
scenario_normalise_name(newEntry->name);
|
||||
|
@ -191,10 +191,10 @@ static void scenario_translate(scenario_index_entry *scenarioEntry, const rct_ob
|
|||
rct_string_id localisedStringIds[3];
|
||||
if (language_get_localised_scenario_strings(scenarioEntry->name, localisedStringIds)) {
|
||||
if (localisedStringIds[0] != STR_NONE) {
|
||||
safe_strncpy(scenarioEntry->name, language_get_string(localisedStringIds[0]), 64);
|
||||
safe_strcpy(scenarioEntry->name, language_get_string(localisedStringIds[0]), 64);
|
||||
}
|
||||
if (localisedStringIds[2] != STR_NONE) {
|
||||
safe_strncpy(scenarioEntry->details, language_get_string(localisedStringIds[2]), 256);
|
||||
safe_strcpy(scenarioEntry->details, language_get_string(localisedStringIds[2]), 256);
|
||||
}
|
||||
} else {
|
||||
// Checks for a scenario string object (possibly for localisation)
|
||||
|
|
|
@ -287,9 +287,9 @@ void scenario_normalise_name(utf8 *name)
|
|||
if (nameLength >= 3 && (name[0] == 'R' && name[1] == 'C' && name[2] == 'T')) {
|
||||
if (nameLength >= 4 && (name[3] == '1' || name[3] == '2')) {
|
||||
log_verbose("Stripping RCT/1/2 from name: %s", name);
|
||||
safe_strncpy(name, name + 4, 64);
|
||||
safe_strcpy(name, name + 4, 64);
|
||||
} else {
|
||||
safe_strncpy(name, name + 3, 64);
|
||||
safe_strcpy(name, name + 3, 64);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ void scenario_normalise_name(utf8 *name)
|
|||
for (int i = 0; i < countof(ScenarioAliases); i++) {
|
||||
if (strcmp(ScenarioAliases[i].alternative, name) == 0) {
|
||||
log_verbose("Found alias: %s; will treat as: %s", name, ScenarioAliases[i].original);
|
||||
safe_strncpy(name, ScenarioAliases[i].original, 64);
|
||||
safe_strcpy(name, ScenarioAliases[i].original, 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ static void title_do_next_script_opcode()
|
|||
|
||||
// Construct full relative path
|
||||
if (gConfigTitleSequences.presets[_scriptCurrentPreset].path[0]) {
|
||||
safe_strncpy(path, gConfigTitleSequences.presets[_scriptCurrentPreset].path, MAX_PATH);
|
||||
safe_strcpy(path, gConfigTitleSequences.presets[_scriptCurrentPreset].path, MAX_PATH);
|
||||
}
|
||||
else {
|
||||
platform_get_user_directory(path, "title sequences");
|
||||
|
|
|
@ -111,7 +111,7 @@ void path_append_extension(utf8 *path, const utf8 *newExtension)
|
|||
*endOfString++ = '.';
|
||||
|
||||
// Append the extension to the path
|
||||
safe_strncpy(endOfString, newExtension, MAX_PATH - (endOfString - path) - 1);
|
||||
safe_strcpy(endOfString, newExtension, MAX_PATH - (endOfString - path) - 1);
|
||||
}
|
||||
|
||||
void path_remove_extension(utf8 *path)
|
||||
|
@ -192,7 +192,7 @@ int strcicmp(char const *a, char const *b)
|
|||
}
|
||||
}
|
||||
|
||||
char *safe_strncpy(char * destination, const char * source, size_t size)
|
||||
char *safe_strcpy(char * destination, const char * source, size_t size)
|
||||
{
|
||||
assert(destination != NULL);
|
||||
assert(source != NULL);
|
||||
|
@ -265,7 +265,7 @@ char *safe_strcat_path(char *destination, const char *source, size_t size)
|
|||
{
|
||||
const char pathSeparator = platform_get_path_separator();
|
||||
|
||||
size_t length = strlen(destination);
|
||||
size_t length = strnlen(destination, size);
|
||||
if (length >= size - 1) {
|
||||
return destination;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ char *safe_strtrimleft(char *destination, const char *source, size_t size)
|
|||
while (*source == ' ' && *source != '\0') {
|
||||
source++;
|
||||
}
|
||||
return safe_strncpy(destination, source, size);
|
||||
return safe_strcpy(destination, source, size);
|
||||
}
|
||||
|
||||
bool utf8_is_bom(const char *str)
|
||||
|
|
|
@ -41,7 +41,7 @@ int bitscanforward(int source);
|
|||
int bitcount(int source);
|
||||
bool strequals(const char *a, const char *b, int length, bool caseInsensitive);
|
||||
int strcicmp(char const *a, char const *b);
|
||||
char *safe_strncpy(char * destination, const char * source, size_t num);
|
||||
char *safe_strcpy(char * destination, const char * source, size_t num);
|
||||
char *safe_strcat(char *destination, const char *source, size_t size);
|
||||
char *safe_strcat_path(char *destination, const char *source, size_t size);
|
||||
char *safe_strtrimleft(char *destination, const char *source, size_t size);
|
||||
|
|
|
@ -342,7 +342,7 @@ static int show_save_scenario_dialog(char *resultPath)
|
|||
audio_unpause_sounds();
|
||||
|
||||
if (result)
|
||||
safe_strncpy(resultPath, filename, MAX_PATH);
|
||||
safe_strcpy(resultPath, filename, MAX_PATH);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -2028,7 +2028,7 @@ static void window_editor_object_selection_textinput(rct_window *w, int widgetIn
|
|||
}
|
||||
else {
|
||||
memset(_filter_string, 0, sizeof(_filter_string));
|
||||
safe_strncpy(_filter_string, text, sizeof(_filter_string));
|
||||
safe_strcpy(_filter_string, text, sizeof(_filter_string));
|
||||
}
|
||||
|
||||
filter_update_counts();
|
||||
|
@ -2057,9 +2057,9 @@ static bool filter_string(rct_object_entry *entry, rct_object_filters *filter)
|
|||
char name_lower[MAX_PATH];
|
||||
char type_lower[MAX_PATH];
|
||||
char filter_lower[sizeof(_filter_string)];
|
||||
safe_strncpy(name_lower, name, MAX_PATH);
|
||||
safe_strncpy(type_lower, ride_type, MAX_PATH);
|
||||
safe_strncpy(filter_lower, _filter_string, sizeof(_filter_string));
|
||||
safe_strcpy(name_lower, name, MAX_PATH);
|
||||
safe_strcpy(type_lower, ride_type, MAX_PATH);
|
||||
safe_strcpy(filter_lower, _filter_string, sizeof(_filter_string));
|
||||
|
||||
// Make use of lowercase characters only
|
||||
for (int i = 0; name_lower[i] != '\0'; i++)
|
||||
|
|
|
@ -406,11 +406,11 @@ static void window_editor_objective_options_main_mouseup(rct_window *w, int widg
|
|||
window_text_input_open(w, WIDX_PARK_NAME, STR_PARK_NAME, STR_ENTER_PARK_NAME, RCT2_GLOBAL(RCT2_ADDRESS_PARK_NAME, rct_string_id), 0, 32);
|
||||
break;
|
||||
case WIDX_SCENARIO_NAME:
|
||||
safe_strncpy((char*)0x009BC677, s6Info->name, 64);
|
||||
safe_strcpy((char*)0x009BC677, s6Info->name, 64);
|
||||
window_text_input_open(w, WIDX_SCENARIO_NAME, STR_SCENARIO_NAME, STR_ENTER_SCENARIO_NAME, 3165, 0, 64);
|
||||
break;
|
||||
case WIDX_DETAILS:
|
||||
safe_strncpy((char*)0x009BC677, s6Info->details, 256);
|
||||
safe_strcpy((char*)0x009BC677, s6Info->details, 256);
|
||||
window_text_input_open(w, WIDX_DETAILS, 3315, 3316, 3165, 0, 256);
|
||||
break;
|
||||
}
|
||||
|
@ -1003,7 +1003,7 @@ static void window_editor_objective_options_main_paint(rct_window *w, rct_drawpi
|
|||
if (stex != NULL) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = stex->scenario_name;
|
||||
} else {
|
||||
safe_strncpy((char*)0x009BC677, s6Info->name, 64);
|
||||
safe_strcpy((char*)0x009BC677, s6Info->name, 64);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = 3165;
|
||||
}
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = RCT2_GLOBAL(RCT2_ADDRESS_PARK_NAME_ARGS, uint32);
|
||||
|
@ -1022,7 +1022,7 @@ static void window_editor_objective_options_main_paint(rct_window *w, rct_drawpi
|
|||
if (stex != NULL) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = stex->details;
|
||||
} else {
|
||||
safe_strncpy((char*)0x009BC677, s6Info->details, 256);
|
||||
safe_strcpy((char*)0x009BC677, s6Info->details, 256);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = 3165;
|
||||
}
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = RCT2_GLOBAL(RCT2_ADDRESS_PARK_NAME_ARGS, uint32);
|
||||
|
|
|
@ -157,7 +157,7 @@ rct_window *window_loadsave_open(int type, char *defaultName)
|
|||
_defaultName[0] = '\0';
|
||||
|
||||
if (!str_is_null_or_empty(defaultName)) {
|
||||
safe_strncpy(_defaultName, defaultName, sizeof(_defaultName));
|
||||
safe_strcpy(_defaultName, defaultName, sizeof(_defaultName));
|
||||
}
|
||||
|
||||
w = window_bring_to_front_by_class(WC_LOADSAVE);
|
||||
|
@ -239,7 +239,7 @@ rct_window *window_loadsave_open(int type, char *defaultName)
|
|||
}
|
||||
*/
|
||||
|
||||
safe_strncpy(path, RCT2_ADDRESS(RCT2_ADDRESS_TRACKS_PATH, char), MAX_PATH);
|
||||
safe_strcpy(path, RCT2_ADDRESS(RCT2_ADDRESS_TRACKS_PATH, char), MAX_PATH);
|
||||
ch = strchr(path, '*');
|
||||
if (ch != NULL)
|
||||
*ch = 0;
|
||||
|
@ -276,7 +276,7 @@ static void window_loadsave_mouseup(rct_window *w, int widgetIndex)
|
|||
char directory[MAX_PATH];
|
||||
int includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
|
||||
|
||||
safe_strncpy(directory, _parentDirectory, sizeof(directory));
|
||||
safe_strcpy(directory, _parentDirectory, sizeof(directory));
|
||||
window_loadsave_populate_list(w, includeNewItem, directory, _extension);
|
||||
window_init_scroll_widgets(w);
|
||||
w->no_list_items = _listItemsCount;
|
||||
|
@ -293,13 +293,13 @@ static void window_loadsave_mouseup(rct_window *w, int widgetIndex)
|
|||
break;
|
||||
}
|
||||
case WIDX_BROWSE:
|
||||
safe_strncpy(path, _directory, MAX_PATH);
|
||||
safe_strcpy(path, _directory, MAX_PATH);
|
||||
if (_type & LOADSAVETYPE_SAVE) {
|
||||
strcat(path, _defaultName);
|
||||
}
|
||||
|
||||
memset(filter, '\0', MAX_PATH);
|
||||
safe_strncpy(filter, "*", MAX_PATH);
|
||||
safe_strcpy(filter, "*", MAX_PATH);
|
||||
strncat(filter, _extension, MAX_PATH - strnlen(filter, MAX_PATH) - 1);
|
||||
|
||||
switch (_type) {
|
||||
|
@ -385,7 +385,7 @@ static void window_loadsave_scrollmousedown(rct_window *w, int scrollIndex, int
|
|||
includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
|
||||
|
||||
char directory[MAX_PATH];
|
||||
safe_strncpy(directory, _listItems[selectedItem].path, sizeof(directory));
|
||||
safe_strcpy(directory, _listItems[selectedItem].path, sizeof(directory));
|
||||
|
||||
window_loadsave_populate_list(w, includeNewItem, directory, _extension);
|
||||
window_init_scroll_widgets(w);
|
||||
|
@ -437,7 +437,7 @@ static void window_loadsave_textinput(rct_window *w, int widgetIndex, char *text
|
|||
return;
|
||||
}
|
||||
|
||||
safe_strncpy(path, _directory, sizeof(path));
|
||||
safe_strcpy(path, _directory, sizeof(path));
|
||||
strncat(path, text, sizeof(path) - strnlen(path, MAX_PATH) - 1);
|
||||
strncat(path, _extension, sizeof(path) - strnlen(path, MAX_PATH) - 1);
|
||||
|
||||
|
@ -479,7 +479,7 @@ static void window_loadsave_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
utf8 *ch = buffer;
|
||||
ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT);
|
||||
ch = utf8_write_codepoint(ch, FORMAT_BLACK);
|
||||
safe_strncpy(ch, _shortenedDirectory, sizeof(buffer) - (ch - buffer));
|
||||
safe_strcpy(ch, _shortenedDirectory, sizeof(buffer) - (ch - buffer));
|
||||
|
||||
// Draw shadow
|
||||
gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 20);
|
||||
|
@ -567,14 +567,14 @@ static void window_loadsave_populate_list(rct_window *w, int includeNewItem, con
|
|||
loadsave_list_item *listItem;
|
||||
char filter[MAX_PATH];
|
||||
|
||||
safe_strncpy(_directory, directory, sizeof(_directory));
|
||||
safe_strcpy(_directory, directory, sizeof(_directory));
|
||||
if (_extension != extension) {
|
||||
safe_strncpy(_extension, extension, sizeof(_extension));
|
||||
safe_strcpy(_extension, extension, sizeof(_extension));
|
||||
_extension[sizeof(_extension) - 1] = '\0';
|
||||
}
|
||||
_shortenedDirectory[0] = '\0';
|
||||
|
||||
safe_strncpy(filter, directory, sizeof(filter));
|
||||
safe_strcpy(filter, directory, sizeof(filter));
|
||||
strncat(filter, "*", sizeof(filter) - strnlen(filter, MAX_PATH) - 1);
|
||||
strncat(filter, extension, sizeof(filter) - strnlen(filter, MAX_PATH) - 1);
|
||||
|
||||
|
@ -615,7 +615,7 @@ static void window_loadsave_populate_list(rct_window *w, int includeNewItem, con
|
|||
if(directory[i]==separator)
|
||||
break;
|
||||
}
|
||||
safe_strncpy(_parentDirectory, directory, sizeof(_parentDirectory));
|
||||
safe_strcpy(_parentDirectory, directory, sizeof(_parentDirectory));
|
||||
_parentDirectory[i+1] = '\0';
|
||||
if(_parentDirectory[0]=='\0' && platform_get_drives()==0)
|
||||
w->disabled_widgets |= (1<<WIDX_UP);
|
||||
|
@ -638,9 +638,9 @@ static void window_loadsave_populate_list(rct_window *w, int includeNewItem, con
|
|||
|
||||
listItem = &_listItems[_listItemsCount];
|
||||
memset(listItem->path, '\0', MAX_PATH);
|
||||
safe_strncpy(listItem->path, directory, MAX_PATH);
|
||||
safe_strcpy(listItem->path, directory, MAX_PATH);
|
||||
strncat(listItem->path, subDir, MAX_PATH - strnlen(listItem->path, MAX_PATH) - 1);
|
||||
safe_strncpy(listItem->name, subDir, sizeof(listItem->name));
|
||||
safe_strcpy(listItem->name, subDir, sizeof(listItem->name));
|
||||
listItem->type = TYPE_DIRECTORY;
|
||||
_listItemsCount++;
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ static void window_loadsave_populate_list(rct_window *w, int includeNewItem, con
|
|||
}
|
||||
|
||||
listItem = &_listItems[_listItemsCount];
|
||||
safe_strncpy(listItem->path, directory, sizeof(listItem->path));
|
||||
safe_strcpy(listItem->path, directory, sizeof(listItem->path));
|
||||
strncat(listItem->path, fileInfo.path, sizeof(listItem->path) - strnlen(listItem->path, MAX_PATH) - 1);
|
||||
listItem->type = TYPE_FILE;
|
||||
listItem->date_modified = platform_file_get_modified_time(listItem->path);
|
||||
|
@ -692,7 +692,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
|||
if (gLoadSaveTitleSequenceSave) {
|
||||
utf8 newName[MAX_PATH];
|
||||
char *extension = (char*)path_get_extension(path);
|
||||
safe_strncpy(newName, path_get_filename(path), MAX_PATH);
|
||||
safe_strcpy(newName, path_get_filename(path), MAX_PATH);
|
||||
if (_stricmp(extension, ".sv6") != 0 && _stricmp(extension, ".sc6") != 0)
|
||||
strcat(newName, ".sv6");
|
||||
if (title_sequence_save_exists(gCurrentTitleSequence, newName)) {
|
||||
|
@ -709,7 +709,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
|||
network_begin_server(gConfigNetwork.default_port);
|
||||
}
|
||||
|
||||
safe_strncpy(gScenarioSavePath, path, MAX_PATH);
|
||||
safe_strcpy(gScenarioSavePath, path, MAX_PATH);
|
||||
gFirstTimeSave = 0;
|
||||
|
||||
window_close(w);
|
||||
|
@ -727,7 +727,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
|||
int success = scenario_save(rw, gConfigGeneral.save_plugin_data ? 1 : 0);
|
||||
SDL_RWclose(rw);
|
||||
if (success) {
|
||||
safe_strncpy(gScenarioSavePath, path, MAX_PATH);
|
||||
safe_strcpy(gScenarioSavePath, path, MAX_PATH);
|
||||
gFirstTimeSave = 0;
|
||||
|
||||
window_close_by_class(WC_LOADSAVE);
|
||||
|
@ -880,8 +880,8 @@ static rct_window *window_overwrite_prompt_open(const char *name, const char *pa
|
|||
w->flags |= WF_TRANSPARENT;
|
||||
w->colours[0] = 154;
|
||||
|
||||
safe_strncpy(_window_overwrite_prompt_name, name, sizeof(_window_overwrite_prompt_name));
|
||||
safe_strncpy(_window_overwrite_prompt_path, path, sizeof(_window_overwrite_prompt_path));
|
||||
safe_strcpy(_window_overwrite_prompt_name, name, sizeof(_window_overwrite_prompt_name));
|
||||
safe_strcpy(_window_overwrite_prompt_path, path, sizeof(_window_overwrite_prompt_path));
|
||||
|
||||
return w;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ void window_network_status_open(const char* text)
|
|||
{
|
||||
rct_window* window;
|
||||
|
||||
safe_strncpy(window_network_status_text, text, sizeof(window_network_status_text));
|
||||
safe_strcpy(window_network_status_text, text, sizeof(window_network_status_text));
|
||||
|
||||
// Check if window is already open
|
||||
window = window_bring_to_front_by_class(WC_NETWORK_STATUS);
|
||||
|
@ -146,7 +146,7 @@ static void window_network_status_textinput(rct_window *w, int widgetIndex, char
|
|||
switch (widgetIndex) {
|
||||
case WIDX_PASSWORD:
|
||||
if (text != NULL)
|
||||
safe_strncpy(_password, text, sizeof(_password));
|
||||
safe_strcpy(_password, text, sizeof(_password));
|
||||
break;
|
||||
}
|
||||
if (text == NULL) {
|
||||
|
|
|
@ -1746,7 +1746,7 @@ static void window_park_objective_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
// Scenario description
|
||||
x = w->x + window_park_objective_widgets[WIDX_PAGE_BACKGROUND].left + 4;
|
||||
y = w->y + window_park_objective_widgets[WIDX_PAGE_BACKGROUND].top + 7;
|
||||
safe_strncpy((char*)0x009BC677, RCT2_ADDRESS(RCT2_ADDRESS_SCENARIO_DETAILS, char), 256);
|
||||
safe_strcpy((char*)0x009BC677, RCT2_ADDRESS(RCT2_ADDRESS_SCENARIO_DETAILS, char), 256);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, short) = 3165;
|
||||
y += gfx_draw_string_left_wrapped(dpi, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, x, y, 222, 1191, 0);
|
||||
y += 5;
|
||||
|
|
|
@ -298,7 +298,7 @@ static void window_player_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi
|
|||
int colour = 0;
|
||||
if (i == w->selected_list_item) {
|
||||
gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x02000031);
|
||||
safe_strncpy(&buffer[0], network_get_player_name(i), sizeof(buffer));
|
||||
safe_strcpy(&buffer[0], network_get_player_name(i), sizeof(buffer));
|
||||
colour = w->colours[2];
|
||||
} else {
|
||||
if (network_get_player_flags(i) & NETWORK_PLAYER_FLAG_ISSERVER) {
|
||||
|
@ -306,7 +306,7 @@ static void window_player_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi
|
|||
} else {
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK);
|
||||
}
|
||||
safe_strncpy(lineCh, network_get_player_name(i), sizeof(buffer) - (lineCh - buffer));
|
||||
safe_strcpy(lineCh, network_get_player_name(i), sizeof(buffer) - (lineCh - buffer));
|
||||
}
|
||||
gfx_clip_string(buffer, 230);
|
||||
gfx_draw_string(dpi, buffer, colour, 0, y - 1);
|
||||
|
|
|
@ -184,7 +184,7 @@ void window_server_list_open()
|
|||
|
||||
window_set_resize(window, WWIDTH_MIN, WHEIGHT_MIN, WWIDTH_MAX, WHEIGHT_MAX);
|
||||
|
||||
safe_strncpy(_playerName, gConfigNetwork.player_name, sizeof(_playerName));
|
||||
safe_strcpy(_playerName, gConfigNetwork.player_name, sizeof(_playerName));
|
||||
|
||||
server_list_load_saved_servers();
|
||||
window->no_list_items = _numSavedServers;
|
||||
|
@ -325,7 +325,7 @@ static void window_server_list_textinput(rct_window *w, int widgetIndex, char *t
|
|||
memset(_playerName, 0, sizeof(_playerName));
|
||||
} else {
|
||||
memset(_playerName, 0, sizeof(_playerName));
|
||||
safe_strncpy(_playerName, text, sizeof(_playerName));
|
||||
safe_strcpy(_playerName, text, sizeof(_playerName));
|
||||
}
|
||||
|
||||
if (strlen(_playerName) > 0) {
|
||||
|
|
|
@ -141,7 +141,7 @@ void window_server_start_open()
|
|||
window->colours[2] = 26;
|
||||
|
||||
sprintf(_port, "%u", gConfigNetwork.default_port);
|
||||
safe_strncpy(_name, gConfigNetwork.server_name, sizeof(_name));
|
||||
safe_strcpy(_name, gConfigNetwork.server_name, sizeof(_name));
|
||||
}
|
||||
|
||||
static void window_server_start_close(rct_window *w)
|
||||
|
@ -210,7 +210,7 @@ static void window_server_start_textinput(rct_window *w, int widgetIndex, char *
|
|||
|
||||
memset(_port, 0, sizeof(_port));
|
||||
if (strlen(text) > 0) {
|
||||
safe_strncpy(_port, text, sizeof(_port));
|
||||
safe_strcpy(_port, text, sizeof(_port));
|
||||
}
|
||||
|
||||
gConfigNetwork.default_port = atoi(_port);
|
||||
|
@ -224,7 +224,7 @@ static void window_server_start_textinput(rct_window *w, int widgetIndex, char *
|
|||
|
||||
memset(_name, 0, sizeof(_name));
|
||||
if (strlen(text) > 0) {
|
||||
safe_strncpy(_name, text, sizeof(_name));
|
||||
safe_strcpy(_name, text, sizeof(_name));
|
||||
}
|
||||
|
||||
if (strlen(_name) > 0) {
|
||||
|
@ -241,7 +241,7 @@ static void window_server_start_textinput(rct_window *w, int widgetIndex, char *
|
|||
|
||||
memset(_password, 0, sizeof(_password));
|
||||
if (strlen(text) > 0) {
|
||||
safe_strncpy(_password, text, sizeof(_password));
|
||||
safe_strcpy(_password, text, sizeof(_password));
|
||||
}
|
||||
|
||||
widget_invalidate(w, WIDX_PASSWORD_INPUT);
|
||||
|
|
|
@ -125,7 +125,7 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t
|
|||
|
||||
// Work out the existing size of the window
|
||||
char wrapped_string[512];
|
||||
safe_strncpy(wrapped_string, text_input, 512);
|
||||
safe_strcpy(wrapped_string, text_input, 512);
|
||||
|
||||
int no_lines = 0, font_height = 0;
|
||||
|
||||
|
@ -175,7 +175,7 @@ void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_
|
|||
// Enter in the the text input buffer any existing
|
||||
// text.
|
||||
if (existing_text != NULL)
|
||||
safe_strncpy(text_input, existing_text, maxLength);
|
||||
safe_strcpy(text_input, existing_text, maxLength);
|
||||
|
||||
// In order to prevent strings that exceed the maxLength
|
||||
// from crashing the game.
|
||||
|
@ -186,7 +186,7 @@ void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_
|
|||
|
||||
// Work out the existing size of the window
|
||||
char wrapped_string[512];
|
||||
safe_strncpy(wrapped_string, text_input, 512);
|
||||
safe_strcpy(wrapped_string, text_input, 512);
|
||||
|
||||
int no_lines = 0, font_height = 0;
|
||||
|
||||
|
@ -273,7 +273,7 @@ static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = 0;
|
||||
|
||||
char wrapped_string[512];
|
||||
safe_strncpy(wrapped_string, text_input, 512);
|
||||
safe_strcpy(wrapped_string, text_input, 512);
|
||||
|
||||
// String length needs to add 12 either side of box
|
||||
// +13 for cursor when max length.
|
||||
|
@ -389,7 +389,7 @@ static void window_text_input_invalidate(rct_window *w)
|
|||
{
|
||||
// Work out the existing size of the window
|
||||
char wrapped_string[512];
|
||||
safe_strncpy(wrapped_string, text_input, 512);
|
||||
safe_strcpy(wrapped_string, text_input, 512);
|
||||
|
||||
int no_lines = 0, font_height = 0;
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ static void window_title_editor_mouseup(rct_window *w, int widgetIndex)
|
|||
case WIDX_TITLE_EDITOR_LOAD:
|
||||
if (w->selected_list_item != -1) {
|
||||
if (gConfigTitleSequences.presets[gCurrentTitleSequence].path[0]) {
|
||||
safe_strncpy(path, gConfigTitleSequences.presets[gCurrentTitleSequence].path, MAX_PATH);
|
||||
safe_strcpy(path, gConfigTitleSequences.presets[gCurrentTitleSequence].path, MAX_PATH);
|
||||
}
|
||||
else {
|
||||
platform_get_user_directory(path, "title sequences");
|
||||
|
|
|
@ -388,13 +388,13 @@ static void window_scenarioselect_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
// Scenario name
|
||||
x = w->x + window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4;
|
||||
y = w->y + window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5;
|
||||
safe_strncpy((char*)0x009BC677, scenario->name, 64);
|
||||
safe_strcpy((char*)0x009BC677, scenario->name, 64);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, short) = 3165; // empty string
|
||||
gfx_draw_string_centred_clipped(dpi, 1193, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x + 85, y, 170);
|
||||
y += 15;
|
||||
|
||||
// Scenario details
|
||||
safe_strncpy((char*)0x009BC677, scenario->details, 256);
|
||||
safe_strcpy((char*)0x009BC677, scenario->details, 256);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, short) = 3165; // empty string
|
||||
y += gfx_draw_string_left_wrapped(dpi, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, x, y, 170, 1191, 0) + 5;
|
||||
|
||||
|
@ -411,7 +411,7 @@ static void window_scenarioselect_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
if (!str_is_null_or_empty(scenario->highscore->name)) {
|
||||
completedByName = scenario->highscore->name;
|
||||
}
|
||||
safe_strncpy((char*)0x009BC677, completedByName, 64);
|
||||
safe_strcpy((char*)0x009BC677, completedByName, 64);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, short) = 3165; // empty string
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, int) = scenario->highscore->company_value;
|
||||
y += gfx_draw_string_left_wrapped(dpi, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, x, y, 170, STR_COMPLETED_BY_WITH_COMPANY_VALUE, 0);
|
||||
|
@ -457,7 +457,7 @@ static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *
|
|||
|
||||
// Draw scenario name
|
||||
rct_string_id placeholderStringId = 3165;
|
||||
safe_strncpy((char*)language_get_string(placeholderStringId), scenario->name, 64);
|
||||
safe_strcpy((char*)language_get_string(placeholderStringId), scenario->name, 64);
|
||||
int format = isDisabled ? 865 : (isHighlighted ? highlighted_format : unhighlighted_format);
|
||||
colour = isDisabled ? w->colours[1] | 0x40 : COLOUR_BLACK;
|
||||
gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + 1, colour, &placeholderStringId);
|
||||
|
@ -472,7 +472,7 @@ static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *
|
|||
if (!str_is_null_or_empty(scenario->highscore->name)) {
|
||||
completedByName = scenario->highscore->name;
|
||||
}
|
||||
safe_strncpy((char*)language_get_string(placeholderStringId), completedByName, 64);
|
||||
safe_strcpy((char*)language_get_string(placeholderStringId), completedByName, 64);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, rct_string_id) = 2793;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, rct_string_id) = placeholderStringId;
|
||||
gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + 11, 0, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS);
|
||||
|
|
Loading…
Reference in New Issue