From 865eaca27d5ea0eb7f9ad93ad3d169d192080386 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 7 Feb 2022 00:36:48 +0100 Subject: Changed all file opening modes to be binary to have consistent newlines --- Stars45/AudioConfig.cpp | 2 +- Stars45/CampaignMissionFighter.cpp | 2 +- Stars45/CampaignMissionStarship.cpp | 2 +- Stars45/CampaignSaveGame.cpp | 4 ++-- Stars45/KeyMap.cpp | 4 ++-- Stars45/Main.cpp | 4 ++-- Stars45/Mission.cpp | 2 +- Stars45/ModConfig.cpp | 2 +- Stars45/NetClientConfig.cpp | 2 +- Stars45/NetLobbyClient.cpp | 2 +- Stars45/NetLobbyServer.cpp | 6 +++--- Stars45/NetServerConfig.cpp | 4 ++-- Stars45/Player.cpp | 2 +- Stars45/Starshatter.cpp | 2 +- Stars45/VidDlg.cpp | 4 ++-- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Stars45/AudioConfig.cpp b/Stars45/AudioConfig.cpp index 63e1413..9411daa 100644 --- a/Stars45/AudioConfig.cpp +++ b/Stars45/AudioConfig.cpp @@ -389,7 +389,7 @@ void AudioConfig::Save() { FILE* f; - fopen_s(&f, "audio.cfg", "w"); + fopen_s(&f, "audio.cfg", "wb"); if (f) { fprintf(f, "AUDIO\n\n"); fprintf(f, "menu_music: %3d\n", menu_music); diff --git a/Stars45/CampaignMissionFighter.cpp b/Stars45/CampaignMissionFighter.cpp index f59d24e..3ba745a 100644 --- a/Stars45/CampaignMissionFighter.cpp +++ b/Stars45/CampaignMissionFighter.cpp @@ -178,7 +178,7 @@ CampaignMissionFighter::CreateMission(CampaignMissionRequest* req) sprintf_s(fname, "msn%03d.def", info->id); FILE* f; - fopen_s(&f, fname, "w"); + fopen_s(&f, fname, "wb"); if (f) { fprintf(f, "%s\n", script.data()); fclose(f); diff --git a/Stars45/CampaignMissionStarship.cpp b/Stars45/CampaignMissionStarship.cpp index df50b3f..fedd965 100644 --- a/Stars45/CampaignMissionStarship.cpp +++ b/Stars45/CampaignMissionStarship.cpp @@ -140,7 +140,7 @@ CampaignMissionStarship::CreateMission(CampaignMissionRequest* req) sprintf_s(fname, "msn%03d.def", info->id); FILE* f; - fopen_s(&f, fname, "w"); + fopen_s(&f, fname, "wb"); if (f) { fprintf(f, "%s\n", script.data()); fclose(f); diff --git a/Stars45/CampaignSaveGame.cpp b/Stars45/CampaignSaveGame.cpp index 4caf0d6..380f82e 100644 --- a/Stars45/CampaignSaveGame.cpp +++ b/Stars45/CampaignSaveGame.cpp @@ -590,7 +590,7 @@ CampaignSaveGame::Save(const char* name) Text s = GetSaveDirectory() + Text("/") + Text(name); FILE* f; - fopen_s(&f, s, "w"); + fopen_s(&f, s, "wb"); if (f) { char timestr[32]; @@ -733,7 +733,7 @@ CampaignSaveGame::GetResumeFile() { // check for auto save game: FILE* f; - ::fopen_s(&f, GetSaveDirectory() + "/AutoSave", "r"); + ::fopen_s(&f, GetSaveDirectory() + "/AutoSave", "rb"); if (f) { ::fclose(f); diff --git a/Stars45/KeyMap.cpp b/Stars45/KeyMap.cpp index c2e7cc1..1c21c15 100644 --- a/Stars45/KeyMap.cpp +++ b/Stars45/KeyMap.cpp @@ -600,7 +600,7 @@ int KeyMap::LoadKeyMap(const char* filename, int max_keys) { FILE* f; - fopen_s(&f, filename, "r"); + fopen_s(&f, filename, "rb"); if (!f) return nkeys; @@ -661,7 +661,7 @@ int KeyMap::SaveKeyMap(const char* filename, int max_keys) { FILE* f; - fopen_s(&f, filename, "w"); + fopen_s(&f, filename, "wb"); if (!f) return 0; for (int i = 0; i < nkeys; i++) { diff --git a/Stars45/Main.cpp b/Stars45/Main.cpp index 075ddcd..58b60d1 100644 --- a/Stars45/Main.cpp +++ b/Stars45/Main.cpp @@ -83,9 +83,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, int do_server = 0; if (strstr(lpCmdLine, "-server")) - ErrLog = fopen("serverlog.txt", "w"); + ErrLog = fopen("serverlog.txt", "wb"); else - ErrLog = fopen("errlog.txt", "w"); + ErrLog = fopen("errlog.txt", "wb"); PrintLogHeader(); diff --git a/Stars45/Mission.cpp b/Stars45/Mission.cpp index 6438cc4..f3fb247 100644 --- a/Stars45/Mission.cpp +++ b/Stars45/Mission.cpp @@ -477,7 +477,7 @@ Mission::Save() char fname[256]; sprintf_s(fname, "%s%s", path, filename); FILE* f; - fopen_s(&f, fname, "w"); + fopen_s(&f, fname, "wb"); if (f) { fwrite(content.data(), content.length(), 1, f); fclose(f); diff --git a/Stars45/ModConfig.cpp b/Stars45/ModConfig.cpp index 6f36261..2e36ed4 100644 --- a/Stars45/ModConfig.cpp +++ b/Stars45/ModConfig.cpp @@ -167,7 +167,7 @@ void ModConfig::Save() { FILE* f; - fopen_s(&f, "mod.cfg", "w"); + fopen_s(&f, "mod.cfg", "wb"); if (f) { fprintf(f, "MOD_CONFIG\n\n"); diff --git a/Stars45/NetClientConfig.cpp b/Stars45/NetClientConfig.cpp index 9b00e1e..351dd5c 100644 --- a/Stars45/NetClientConfig.cpp +++ b/Stars45/NetClientConfig.cpp @@ -262,7 +262,7 @@ void NetClientConfig::Save() { FILE* f; - fopen_s(&f, "client.cfg", "w"); + fopen_s(&f, "client.cfg", "wb"); if (f) { fprintf(f, "CLIENT_CONFIG\n\n"); diff --git a/Stars45/NetLobbyClient.cpp b/Stars45/NetLobbyClient.cpp index 9340409..14bf749 100644 --- a/Stars45/NetLobbyClient.cpp +++ b/Stars45/NetLobbyClient.cpp @@ -745,7 +745,7 @@ NetLobbyClient::DoMissionData(NetPeer* peer, Text msg) if (msg.length()) { FILE* f; - ::fopen_s(&f, "multi_mission_recv.def", "w"); + ::fopen_s(&f, "multi_mission_recv.def", "wb"); if (f) { ::fwrite(msg.data(), msg.length(), 1, f); ::fclose(f); diff --git a/Stars45/NetLobbyServer.cpp b/Stars45/NetLobbyServer.cpp index c3817c8..a0014e4 100644 --- a/Stars45/NetLobbyServer.cpp +++ b/Stars45/NetLobbyServer.cpp @@ -202,7 +202,7 @@ NetLobbyServer::LoadMOTD() motd.destroy(); FILE* f; - fopen_s(&f, "motd.txt", "r"); + fopen_s(&f, "motd.txt", "rb"); if (f) { char line[256]; @@ -595,7 +595,7 @@ void NetLobbyServer::SaveChat() { FILE* f; - fopen_s(&f, "chat.txt", "w"); + fopen_s(&f, "chat.txt", "wb"); if (f) { for (int i = 0; i < chat_log.size(); i++) { NetChatEntry* c = chat_log[i]; @@ -1311,7 +1311,7 @@ NetLobbyServer::DoMissionData(NetPeer* peer, Text msg) Text reply = Serialize(mission, user); SendData(user, NET_LOBBY_MISSION_DATA, reply); - FILE* f = ::fopen("multi_mission_send.def", "w"); + FILE* f = ::fopen("multi_mission_send.def", "wb"); if (f) { ::fwrite(reply.data(), reply.length(), 1, f); ::fclose(f); diff --git a/Stars45/NetServerConfig.cpp b/Stars45/NetServerConfig.cpp index cab2f79..6c4ea9f 100644 --- a/Stars45/NetServerConfig.cpp +++ b/Stars45/NetServerConfig.cpp @@ -273,7 +273,7 @@ void NetServerConfig::Save() { FILE* f; - fopen_s(&f, "server.cfg", "w"); + fopen_s(&f, "server.cfg", "wb"); if (f) { fprintf(f, "SERVER_CONFIG\n\n"); fprintf(f, "hostname: \"%s\"\n", instance->hostname.data()); @@ -452,7 +452,7 @@ NetServerConfig::BanUser(NetUser* user) banned_names.append(user_name); FILE* f; - fopen_s(&f, "banned.cfg", "w"); + fopen_s(&f, "banned.cfg", "wb"); if (f) { fprintf(f, "BANNED_CONFIG\n\n"); diff --git a/Stars45/Player.cpp b/Stars45/Player.cpp index 9546991..990fd71 100644 --- a/Stars45/Player.cpp +++ b/Stars45/Player.cpp @@ -1165,7 +1165,7 @@ Player::Save() } FILE* f; - fopen_s(&f, "player.cfg", "w"); + fopen_s(&f, "player.cfg", "wb"); if (f) { fprintf(f, "PLAYER_CONFIG\n\n"); diff --git a/Stars45/Starshatter.cpp b/Stars45/Starshatter.cpp index f9fefbf..3077aca 100644 --- a/Stars45/Starshatter.cpp +++ b/Stars45/Starshatter.cpp @@ -2643,7 +2643,7 @@ Starshatter::SaveVideoConfig(const char* filename) if (!video_settings) return; - FILE* f = fopen(filename, "w"); + FILE* f = fopen(filename, "wb"); if (f) { fprintf(f, "VIDEO\n\n"); fprintf(f, "width: %4d\n", video_settings->fullscreen_mode.width); diff --git a/Stars45/VidDlg.cpp b/Stars45/VidDlg.cpp index 918d1df..e7bdc09 100644 --- a/Stars45/VidDlg.cpp +++ b/Stars45/VidDlg.cpp @@ -403,9 +403,9 @@ VidDlg::Apply() FILE* f = 0; if (video_change) - fopen_s(&f, "video2.cfg", "w"); + fopen_s(&f, "video2.cfg", "wb"); else - fopen_s(&f, "video.cfg", "w"); + fopen_s(&f, "video.cfg", "wb"); if (gamma) { g = gamma->GetValue(); -- cgit v1.1