From c287a2df48ce7362b0952dac2caf65f317e6dbb3 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Sat, 29 Jun 2024 11:42:52 +0300 Subject: [PATCH] Fix compilation of Descent3Editor Convert some of the paths to use std::fs::path. --- editor/MainFrm.cpp | 10 ++-- editor/MegacellDialog.cpp | 21 +++++--- editor/Read3ds.cpp | 2 +- editor/TableManage.cpp | 2 +- editor/WorldObjectsDoorDialog.cpp | 23 ++++---- editor/WorldObjectsGenericDialog.cpp | 24 ++++----- editor/WorldObjectsPlayerDialog.cpp | 39 ++++++-------- editor/WorldSoundsDialog.cpp | 17 +++--- editor/WorldTexturesDialog.cpp | 49 ++++++++++------- editor/WorldWeaponsDialog.cpp | 81 ++++++++++++++-------------- 10 files changed, 136 insertions(+), 132 deletions(-) diff --git a/editor/MainFrm.cpp b/editor/MainFrm.cpp index 320b80ad..40393ab1 100644 --- a/editor/MainFrm.cpp +++ b/editor/MainFrm.cpp @@ -763,6 +763,7 @@ #include #include +#include #include "stdafx.h" #include "editor.h" @@ -2019,11 +2020,11 @@ void CMainFrame::OnImportBitmap() { mprintf(0, "Making a copy of this bitmap/anim locally...\n"); if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), GameBitmaps[bm_handle].name); bm_SaveFileBitmap(filename, bm_handle); bm_FreeBitmap(bm_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), GameVClips[bm_handle].name); SaveVClip(filename, bm_handle); FreeVClip(bm_handle); } @@ -2963,7 +2964,8 @@ void CMainFrame::OnTerrainView() { SetViewMode(VM_TERRAIN); } void CMainFrame::OnMineView() { // Make sure there's a room to switch to - for (int roomnum = 0; roomnum <= Highest_room_index; roomnum++) + int roomnum; + for (roomnum = 0; roomnum <= Highest_room_index; roomnum++) if (Rooms[roomnum].used && !(Rooms[roomnum].flags & RF_EXTERNAL)) break; @@ -3187,7 +3189,7 @@ void CMainFrame::OnHotspotTga() { } if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), GameBitmaps[bm_handle].name); bm_SaveFileBitmap(filename, bm_handle); bm_FreeBitmap(bm_handle); } diff --git a/editor/MegacellDialog.cpp b/editor/MegacellDialog.cpp index aa8b80bb..d37750c4 100644 --- a/editor/MegacellDialog.cpp +++ b/editor/MegacellDialog.cpp @@ -19,6 +19,8 @@ // MegacellDialog.cpp : implementation file // +#include + #include "stdafx.h" #include "editor.h" #include "MegacellDialog.h" @@ -1071,19 +1073,19 @@ void CMegacellDialog::CheckinTexture(int n, int tracklock_num) { else { // Save this textures bitmap to the network for all - char fname[255]; + std::filesystem::path fname; if (GameTextures[n].flags & TF_ANIMATED) { - sprintf(fname, "%s\\%s", ManageGraphicsDir, GameVClips[GameTextures[n].bm_handle].name); + fname = ManageGraphicsDir / GameVClips[GameTextures[n].bm_handle].name; SaveVClip(fname, GameTextures[n].bm_handle); - sprintf(fname, "%s\\%s", LocalManageGraphicsDir, GameVClips[GameTextures[n].bm_handle].name); + fname = LocalManageGraphicsDir / GameVClips[GameTextures[n].bm_handle].name; SaveVClip(fname, GameTextures[n].bm_handle); } else { - sprintf(fname, "%s\\%s", ManageGraphicsDir, GameBitmaps[GameTextures[n].bm_handle].name); + fname = ManageGraphicsDir / GameBitmaps[GameTextures[n].bm_handle].name; bm_SaveFileBitmap(fname, GameTextures[n].bm_handle); - sprintf(fname, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[n].bm_handle].name); + fname = LocalManageGraphicsDir / GameBitmaps[GameTextures[n].bm_handle].name; bm_SaveFileBitmap(fname, GameTextures[n].bm_handle); } @@ -1198,7 +1200,8 @@ void CMegacellDialog::OnImportTiny() { strcpy(GameBitmaps[bm_handle].name, filename); // Save this textures image locally - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[tex_handle].bm_handle].name); mprintf(0, "Saving bitmap %s from megacell!\n", GameBitmaps[bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle); @@ -1323,7 +1326,8 @@ void CMegacellDialog::OnImportSky() { strcpy(GameBitmaps[bm_handle].name, filename); // Save this textures image locally - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[tex_handle].bm_handle].name); mprintf(0, "Saving bitmap %s from megacell!\n", GameBitmaps[bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle); @@ -1444,7 +1448,8 @@ void CMegacellDialog::OnImportSkyBand() { strcpy(GameBitmaps[bm_handle].name, filename); // Save this textures image locally - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[tex_handle].bm_handle].name); mprintf(0, "Saving bitmap %s from megacell!\n", GameBitmaps[bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle); diff --git a/editor/Read3ds.cpp b/editor/Read3ds.cpp index b1f2ea69..138acf6f 100644 --- a/editor/Read3ds.cpp +++ b/editor/Read3ds.cpp @@ -374,7 +374,7 @@ skip_combine:; strcpy(rp->name, roomname); // Save it out to disk (locally) - ddio_MakePath(name, LocalRoomsDir, roomname, NULL); + ddio_MakePath(name, LocalRoomsDir.u8string().c_str(), roomname, NULL); SaveRoom(ROOMNUM(rp), name); } diff --git a/editor/TableManage.cpp b/editor/TableManage.cpp index 88a3be83..f39e3c28 100644 --- a/editor/TableManage.cpp +++ b/editor/TableManage.cpp @@ -223,7 +223,7 @@ bool GenericPageList::SaveTable(char *table_filename) { return FALSE; // First make sure we can open the table file and the temp table file - infile = cfopen(m_TableFilename, "rb"); + infile = cfopen(m_TableFilename.GetBuffer(0), "rb"); if (!infile) { mprintf(0, "Couldn't open table file to replace generic!\n"); return FALSE; diff --git a/editor/WorldObjectsDoorDialog.cpp b/editor/WorldObjectsDoorDialog.cpp index b3528ab0..3c8b5d25 100644 --- a/editor/WorldObjectsDoorDialog.cpp +++ b/editor/WorldObjectsDoorDialog.cpp @@ -112,6 +112,8 @@ * $NoKeywords: $ */ +#include + #include "mfc_compatibility.h" #include "editor.h" #include "WorldObjectsDoorDialog.h" @@ -308,10 +310,8 @@ void CWorldObjectsDoorDialog::OnAddDoor() { // Finally, save a local copy of the model/anim and alloc a tracklock mprintf(0, "Making a copy of this model locally...\n"); - char destname[100]; - sprintf(destname, "%s\\%s", LocalModelsDir, Poly_models[Doors[door_handle].model_handle].name); - if (stricmp(destname, pathname)) // only copy if they are different - cf_CopyFile(destname, pathname); + std::filesystem::path destname = LocalModelsDir / Poly_models[Doors[door_handle].model_handle].name; + cf_CopyFile(destname, pathname); mng_AllocTrackLock(cur_name, PAGETYPE_DOOR); @@ -407,7 +407,7 @@ void CWorldObjectsDoorDialog::UpdateDialog() { // Update sounds lists SendDlgItemMessage(IDC_DOOR_OPEN_SOUND, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(IDC_DOOR_OPEN_SOUND, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); - for (i = 0; i < MAX_SOUNDS; i++) { + for (int i = 0; i < MAX_SOUNDS; i++) { if (Sounds[i].used) SendDlgItemMessage(IDC_DOOR_OPEN_SOUND, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name); } @@ -418,7 +418,7 @@ void CWorldObjectsDoorDialog::UpdateDialog() { SendDlgItemMessage(IDC_DOOR_CLOSE_SOUND, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(IDC_DOOR_CLOSE_SOUND, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); - for (i = 0; i < MAX_SOUNDS; i++) { + for (int i = 0; i < MAX_SOUNDS; i++) { if (Sounds[i].used) SendDlgItemMessage(IDC_DOOR_CLOSE_SOUND, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name); } @@ -541,11 +541,8 @@ void CWorldObjectsDoorDialog::OnCheckinDoor() { OutrageMessageBox(ErrorString); else { // Save this door anim/model to the network for all - - char destname[100], srcname[100]; - - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Doors[n].model_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Doors[n].model_handle].name); + std::filesystem::path srcname = LocalModelsDir / Poly_models[Doors[n].model_handle].name; + std::filesystem::path destname = NetModelsDir / Poly_models[Doors[n].model_handle].name; cf_CopyFile(destname, srcname); @@ -769,7 +766,6 @@ void CWorldObjectsDoorDialog::OnDoorsOut() { void CWorldObjectsDoorDialog::OnLoadDoorModel() { char filename[255]; - char curname[255]; int img_handle; int door_handle; int c = 1, finding_name = 1; @@ -795,8 +791,7 @@ void CWorldObjectsDoorDialog::OnLoadDoorModel() { Doors[door_handle].model_handle = img_handle; // Finally, save a local copy of the model - - sprintf(curname, "%s\\%s", LocalModelsDir, Poly_models[Doors[door_handle].model_handle].name); + std::filesystem::path curname = LocalModelsDir / Poly_models[Doors[door_handle].model_handle].name; cf_CopyFile(curname, filename); UpdateDialog(); diff --git a/editor/WorldObjectsGenericDialog.cpp b/editor/WorldObjectsGenericDialog.cpp index f3f13eae..08da46e0 100644 --- a/editor/WorldObjectsGenericDialog.cpp +++ b/editor/WorldObjectsGenericDialog.cpp @@ -19,6 +19,8 @@ // WorldObjectsGenericDialog.cpp : implementation file // +#include + #include "mfc_compatibility.h" #include "editor.h" #include "WorldObjectsGenericDialog.h" @@ -722,10 +724,8 @@ retry_name: // Finally, save a local copy of the model/anim and alloc a tracklock mprintf(0, "Making a copy of this model locally...\n"); - char destname[100]; - sprintf(destname, "%s\\%s", LocalModelsDir, Poly_models[Object_info[object_handle].render_handle].name); - if (stricmp(destname, filename)) // only copy if they are different - cf_CopyFile(destname, filename); + std::filesystem::path destname = LocalModelsDir / Poly_models[Object_info[object_handle].render_handle].name; + cf_CopyFile(destname, filename); mng_AllocTrackLock(cur_name, PAGETYPE_GENERIC); @@ -798,21 +798,19 @@ void CWorldObjectsGenericDialog::OnGenericCheckIn() { else { // Save this object anim/model to the network for all - char destname[100], srcname[100]; - - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Object_info[m_current].render_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Object_info[m_current].render_handle].name); + std::filesystem::path srcname = LocalModelsDir / Poly_models[Object_info[m_current].render_handle].name; + std::filesystem::path destname = NetModelsDir / Poly_models[Object_info[m_current].render_handle].name; cf_CopyFile(destname, srcname); if (Object_info[m_current].med_render_handle != -1) { - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Object_info[m_current].med_render_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Object_info[m_current].med_render_handle].name); + srcname = LocalModelsDir / Poly_models[Object_info[m_current].med_render_handle].name; + destname = NetModelsDir / Poly_models[Object_info[m_current].med_render_handle].name; cf_CopyFile(destname, srcname); } if (Object_info[m_current].lo_render_handle != -1) { - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Object_info[m_current].lo_render_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Object_info[m_current].lo_render_handle].name); + srcname = LocalModelsDir / Poly_models[Object_info[m_current].lo_render_handle].name; + destname = NetModelsDir / Poly_models[Object_info[m_current].lo_render_handle].name; cf_CopyFile(destname, srcname); } @@ -1048,7 +1046,7 @@ void CWorldObjectsGenericDialog::OnGenericChangeModel() { } // Finally, save a local copy of the model - sprintf(curname, "%s\\%s", LocalModelsDir, Poly_models[img_handle].name); + sprintf(curname, "%s\\%s", LocalModelsDir.u8string().c_str(), Poly_models[img_handle].name); cf_CopyFile(curname, filename); UpdateDialog(); diff --git a/editor/WorldObjectsPlayerDialog.cpp b/editor/WorldObjectsPlayerDialog.cpp index 6c608120..0b377ac4 100644 --- a/editor/WorldObjectsPlayerDialog.cpp +++ b/editor/WorldObjectsPlayerDialog.cpp @@ -121,6 +121,8 @@ * $NoKeywords: $ */ +#include + #include "mfc_compatibility.h" #include "editor.h" #include "WorldObjectsPlayerDialog.h" @@ -243,10 +245,8 @@ void CWorldObjectsPlayerDialog::OnAddPship() { // Finally, save a local copy of the model/anim and alloc a tracklock mprintf(0, "Making a copy of this model locally...\n"); - char destname[100]; - sprintf(destname, "%s\\%s", LocalModelsDir, Poly_models[Ships[ship_handle].model_handle].name); - if (stricmp(destname, filename)) // only copy if they are different - cf_CopyFile(destname, filename); + std::filesystem::path destname = LocalModelsDir / Poly_models[Ships[ship_handle].model_handle].name; + cf_CopyFile(destname, filename); mng_AllocTrackLock(cur_name, PAGETYPE_SHIP); @@ -291,38 +291,35 @@ void CWorldObjectsPlayerDialog::OnPshipCheckin() { OutrageMessageBox(ErrorString); else { // Save this ship anim/model to the network for all - - char destname[100], srcname[100]; - - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Ships[n].model_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Ships[n].model_handle].name); + std::filesystem::path srcname = LocalModelsDir / Poly_models[Ships[n].model_handle].name; + std::filesystem::path destname = NetModelsDir / Poly_models[Ships[n].model_handle].name; cf_CopyFile(destname, srcname); if (Ships[n].dying_model_handle != -1) { - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Ships[n].dying_model_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Ships[n].dying_model_handle].name); + srcname = LocalModelsDir / Poly_models[Ships[n].dying_model_handle].name; + destname = NetModelsDir / Poly_models[Ships[n].dying_model_handle].name; cf_CopyFile(destname, srcname); } if (Ships[n].med_render_handle != -1) { - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Ships[n].med_render_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Ships[n].med_render_handle].name); + srcname = LocalModelsDir / Poly_models[Ships[n].med_render_handle].name; + destname = NetModelsDir / Poly_models[Ships[n].med_render_handle].name; cf_CopyFile(destname, srcname); } if (Ships[n].lo_render_handle != -1) { - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Ships[n].lo_render_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Ships[n].lo_render_handle].name); + srcname = LocalModelsDir / Poly_models[Ships[n].lo_render_handle].name; + destname = NetModelsDir / Poly_models[Ships[n].lo_render_handle].name; cf_CopyFile(destname, srcname); } if (Ships[n].cockpit_name[0]) { - sprintf(srcname, "%s\\%s", LocalMiscDir, Ships[n].cockpit_name); - sprintf(destname, "%s\\%s", NetMiscDir, Ships[n].cockpit_name); + srcname = LocalMiscDir / Ships[n].cockpit_name; + destname = NetMiscDir / Ships[n].cockpit_name; cf_CopyFile(destname, srcname); } @@ -409,7 +406,6 @@ void CWorldObjectsPlayerDialog::OnPshipDelete() { void CWorldObjectsPlayerDialog::OnPshipLoadModel() { char filename[255]; - char curname[255]; int img_handle; int ship_handle; int c = 1, finding_name = 1; @@ -455,7 +451,7 @@ void CWorldObjectsPlayerDialog::OnPshipLoadModel() { } // Finally, save a local copy of the model - sprintf(curname, "%s\\%s", LocalModelsDir, Poly_models[img_handle].name); + std::filesystem::path curname = LocalModelsDir / Poly_models[img_handle].name; cf_CopyFile(curname, filename); UpdateDialog(); @@ -916,7 +912,6 @@ void CWorldObjectsPlayerDialog::OnPshipEditPhysics() { void CWorldObjectsPlayerDialog::OnPshipDyingModel() { char filename[_MAX_PATH]; - char curname[_MAX_PATH]; int img_handle; int ship_handle; int c = 1, finding_name = 1; @@ -943,7 +938,7 @@ void CWorldObjectsPlayerDialog::OnPshipDyingModel() { // Finally, save a local copy of the model - sprintf(curname, "%s\\%s", LocalModelsDir, Poly_models[Ships[ship_handle].dying_model_handle].name); + std::filesystem::path curname = LocalModelsDir / Poly_models[Ships[ship_handle].dying_model_handle].name; cf_CopyFile(curname, filename); UpdateDialog(); @@ -980,7 +975,7 @@ void CWorldObjectsPlayerDialog::OnPshipCockpit() { sprintf(Ships[D3EditState.current_ship].cockpit_name, "%s%s", curname, ext); // Finally, save a local copy of the inf file. - sprintf(curname, "%s\\%s", LocalMiscDir, Ships[D3EditState.current_ship].cockpit_name); + sprintf(curname, "%s\\%s", LocalMiscDir.u8string().c_str(), Ships[D3EditState.current_ship].cockpit_name); cf_CopyFile(curname, filename); UpdateDialog(); diff --git a/editor/WorldSoundsDialog.cpp b/editor/WorldSoundsDialog.cpp index d962a14c..9300a9cb 100644 --- a/editor/WorldSoundsDialog.cpp +++ b/editor/WorldSoundsDialog.cpp @@ -117,6 +117,8 @@ // WorldSoundsDialog.cpp : implementation file // +#include + #include "stdafx.h" #include "pserror.h" @@ -248,10 +250,8 @@ void CWorldSoundsDialog::OnAddSound() { // Finally, save a local copy of the .wav and alloc a tracklock mprintf(0, "Making a copy of this sound locally...\n"); - char destname[100]; - sprintf(destname, "%s\\%s", LocalSoundsDir, SoundFiles[Sounds[sound_handle].sample_index].name); - if (stricmp(destname, filename)) // only copy if they are different - cf_CopyFile(destname, filename); + std::filesystem::path destname = LocalSoundsDir / SoundFiles[Sounds[sound_handle].sample_index].name; + cf_CopyFile(destname, filename); mng_AllocTrackLock(cur_name, PAGETYPE_SOUND); @@ -300,10 +300,8 @@ void CWorldSoundsDialog::OnCheckinSound() { else { // Save this sound raw to the network for all - char destname[100], srcname[100]; - - sprintf(srcname, "%s\\%s", LocalSoundsDir, SoundFiles[Sounds[n].sample_index].name); - sprintf(destname, "%s\\%s", NetSoundsDir, SoundFiles[Sounds[n].sample_index].name); + std::filesystem::path srcname = LocalSoundsDir / SoundFiles[Sounds[n].sample_index].name; + std::filesystem::path destname = NetSoundsDir / SoundFiles[Sounds[n].sample_index].name; cf_CopyFile(destname, srcname); @@ -451,7 +449,6 @@ void CWorldSoundsDialog::OnLockSound() { void CWorldSoundsDialog::OnLoadSound() { char filename[255]; - char curname[255]; int raw_handle; int sound_handle; int c = 1, finding_name = 1; @@ -477,7 +474,7 @@ void CWorldSoundsDialog::OnLoadSound() { // Finally, save a local copy of the raw - sprintf(curname, "%s\\%s", LocalSoundsDir, SoundFiles[Sounds[sound_handle].sample_index].name); + std::filesystem::path curname = LocalSoundsDir / SoundFiles[Sounds[sound_handle].sample_index].name; cf_CopyFile(curname, filename); UpdateDialog(); diff --git a/editor/WorldTexturesDialog.cpp b/editor/WorldTexturesDialog.cpp index de6de1ee..1fd13819 100644 --- a/editor/WorldTexturesDialog.cpp +++ b/editor/WorldTexturesDialog.cpp @@ -459,10 +459,12 @@ void CWorldTexturesDialog::OnWtexdlgAddnew() { mprintf(0, "Making a copy of this bitmap/anim locally...\n"); if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[tex_handle].bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameVClips[GameTextures[tex_handle].bm_handle].name); SaveVClip(filename, GameTextures[tex_handle].bm_handle); } @@ -1091,19 +1093,19 @@ void CWorldTexturesDialog::OnCheckin() { else { // Save this textures bitmap to the network for all - char fname[255]; + std::filesystem::path fname; if (GameTextures[n].flags & TF_ANIMATED) { - sprintf(fname, "%s\\%s", ManageGraphicsDir, GameVClips[GameTextures[n].bm_handle].name); + fname = ManageGraphicsDir / GameVClips[GameTextures[n].bm_handle].name; SaveVClip(fname, GameTextures[n].bm_handle); - sprintf(fname, "%s\\%s", LocalManageGraphicsDir, GameVClips[GameTextures[n].bm_handle].name); + fname = LocalManageGraphicsDir / GameVClips[GameTextures[n].bm_handle].name; SaveVClip(fname, GameTextures[n].bm_handle); } else { - sprintf(fname, "%s\\%s", ManageGraphicsDir, GameBitmaps[GameTextures[n].bm_handle].name); + fname = ManageGraphicsDir / GameBitmaps[GameTextures[n].bm_handle].name; bm_SaveFileBitmap(fname, GameTextures[n].bm_handle); - sprintf(fname, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[n].bm_handle].name); + fname = LocalManageGraphicsDir / GameBitmaps[GameTextures[n].bm_handle].name; bm_SaveFileBitmap(fname, GameTextures[n].bm_handle); } @@ -1162,13 +1164,13 @@ void CWorldTexturesDialog::SaveTexturesOnClose() { mng_ReplacePage(GameTextures[t].name, GameTextures[t].name, t, PAGETYPE_TEXTURE, 1); - char fname[255]; + std::filesystem::path fname; if (GameTextures[t].flags & TF_ANIMATED) { - sprintf(fname, "%s\\%s", LocalManageGraphicsDir, GameVClips[GameTextures[t].bm_handle].name); + fname = LocalManageGraphicsDir / GameVClips[GameTextures[t].bm_handle].name; SaveVClip(fname, GameTextures[t].bm_handle); } else { - sprintf(fname, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[t].bm_handle].name); + fname = LocalManageGraphicsDir / GameBitmaps[GameTextures[t].bm_handle].name; bm_SaveFileBitmap(fname, GameTextures[t].bm_handle); } } @@ -1331,10 +1333,12 @@ void CWorldTexturesDialog::OnLoadBitmap() { mprintf(0, "Making a copy of this bitmap locally...\n"); if (anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[GameTextures[n].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameVClips[GameTextures[n].bm_handle].name); SaveVClip(filename, GameTextures[n].bm_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[n].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[n].bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[n].bm_handle); } @@ -1688,7 +1692,8 @@ Here: for (i = 0; i < total; i++) { tex_handle = tex_list[i]; - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[tex_handle].bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle); } @@ -1842,10 +1847,12 @@ void CWorldTexturesDialog::OnAddNewSmall() { mprintf(0, "Making a copy of this bitmap/anim locally...\n"); if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[tex_handle].bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameVClips[GameTextures[tex_handle].bm_handle].name); SaveVClip(filename, GameTextures[tex_handle].bm_handle); } @@ -1931,10 +1938,12 @@ void CWorldTexturesDialog::OnAddNewTiny() { mprintf(0, "Making a copy of this bitmap/anim locally...\n"); if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[tex_handle].bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameVClips[GameTextures[tex_handle].bm_handle].name); SaveVClip(filename, GameTextures[tex_handle].bm_handle); } @@ -2543,10 +2552,12 @@ void CWorldTexturesDialog::OnAddNewHuge() { mprintf(0, "Making a copy of this bitmap/anim locally...\n"); if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[GameTextures[tex_handle].bm_handle].name); bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[GameTextures[tex_handle].bm_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameVClips[GameTextures[tex_handle].bm_handle].name); SaveVClip(filename, GameTextures[tex_handle].bm_handle); } diff --git a/editor/WorldWeaponsDialog.cpp b/editor/WorldWeaponsDialog.cpp index e1f38590..46719936 100644 --- a/editor/WorldWeaponsDialog.cpp +++ b/editor/WorldWeaponsDialog.cpp @@ -485,10 +485,12 @@ void CWorldWeaponsDialog::OnAddWeapon() { mprintf(0, "Making a copy of this bitmap/anim locally...\n"); if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[Weapons[weapon_handle].hud_image_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[Weapons[weapon_handle].hud_image_handle].name); bm_SaveFileBitmap(filename, Weapons[weapon_handle].hud_image_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[Weapons[weapon_handle].hud_image_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameVClips[Weapons[weapon_handle].hud_image_handle].name); SaveVClip(filename, Weapons[weapon_handle].hud_image_handle); } @@ -536,17 +538,17 @@ void CWorldWeaponsDialog::OnAddWeapon() { if (!model) { if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[Weapons[weapon_handle].fire_image_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[Weapons[weapon_handle].fire_image_handle].name); bm_SaveFileBitmap(filename, Weapons[weapon_handle].fire_image_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[Weapons[weapon_handle].fire_image_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameVClips[Weapons[weapon_handle].fire_image_handle].name); SaveVClip(filename, Weapons[weapon_handle].fire_image_handle); } } else { - char destname[100]; - sprintf(destname, "%s\\%s", LocalModelsDir, Poly_models[Weapons[weapon_handle].fire_image_handle].name); - if (stricmp(destname, filename)) // only copy if they are different - cf_CopyFile(destname, filename); + std::filesystem::path destname = LocalModelsDir / Poly_models[Weapons[weapon_handle].fire_image_handle].name; + cf_CopyFile(destname, filename); } mng_AllocTrackLock(cur_name, PAGETYPE_WEAPON); @@ -659,29 +661,27 @@ void CWorldWeaponsDialog::OnCheckinWeapon() { OutrageMessageBox(ErrorString); else { // Save this weapon anim/image to the network for all - - char destname[100], srcname[100]; - + std::filesystem::path srcname, destname; if (Weapons[n].flags & WF_HUD_ANIMATED) { - sprintf(srcname, "%s\\%s", LocalManageGraphicsDir, GameVClips[Weapons[n].hud_image_handle].name); - sprintf(destname, "%s\\%s", ManageGraphicsDir, GameVClips[Weapons[n].hud_image_handle].name); + srcname = LocalManageGraphicsDir / GameVClips[Weapons[n].hud_image_handle].name; + destname = ManageGraphicsDir / GameVClips[Weapons[n].hud_image_handle].name; } else { - sprintf(srcname, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[Weapons[n].hud_image_handle].name); - sprintf(destname, "%s\\%s", ManageGraphicsDir, GameBitmaps[Weapons[n].hud_image_handle].name); + srcname = LocalManageGraphicsDir / GameBitmaps[Weapons[n].hud_image_handle].name; + destname = ManageGraphicsDir / GameBitmaps[Weapons[n].hud_image_handle].name; } cf_CopyFile(destname, srcname); if (Weapons[n].flags & WF_IMAGE_BITMAP) { - sprintf(srcname, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[Weapons[n].fire_image_handle].name); - sprintf(destname, "%s\\%s", ManageGraphicsDir, GameBitmaps[Weapons[n].fire_image_handle].name); + srcname = LocalManageGraphicsDir / GameBitmaps[Weapons[n].fire_image_handle].name; + destname = ManageGraphicsDir, GameBitmaps[Weapons[n].fire_image_handle].name; } else if (Weapons[n].flags & WF_IMAGE_VCLIP) { - sprintf(srcname, "%s\\%s", LocalManageGraphicsDir, GameVClips[Weapons[n].fire_image_handle].name); - sprintf(destname, "%s\\%s", ManageGraphicsDir, GameVClips[Weapons[n].fire_image_handle].name); + srcname = LocalManageGraphicsDir / GameVClips[Weapons[n].fire_image_handle].name; + destname = ManageGraphicsDir / GameVClips[Weapons[n].fire_image_handle].name; } else { - sprintf(srcname, "%s\\%s", LocalModelsDir, Poly_models[Weapons[n].fire_image_handle].name); - sprintf(destname, "%s\\%s", NetModelsDir, Poly_models[Weapons[n].fire_image_handle].name); + srcname = LocalModelsDir / Poly_models[Weapons[n].fire_image_handle].name; + destname = NetModelsDir / Poly_models[Weapons[n].fire_image_handle].name; } cf_CopyFile(destname, srcname); @@ -781,7 +781,7 @@ void CWorldWeaponsDialog::OnPrevWeapon() { } void CWorldWeaponsDialog::OnLoadWeaponAnim() { - char filename[255], curname[255]; + char filename[255]; int bm_handle; int anim = 0; @@ -809,12 +809,13 @@ void CWorldWeaponsDialog::OnLoadWeaponAnim() { mprintf(0, "Making a copy of this bitmap/anim locally...\n"); + std::filesystem::path curname; if (anim) { - sprintf(curname, "%s\\%s", LocalManageGraphicsDir, GameVClips[Weapons[n].hud_image_handle].name); + curname = LocalManageGraphicsDir / GameVClips[Weapons[n].hud_image_handle].name; SaveVClip(curname, Weapons[n].hud_image_handle); } else { - sprintf(curname, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[Weapons[n].hud_image_handle].name); + curname = LocalManageGraphicsDir / GameBitmaps[Weapons[n].hud_image_handle].name; bm_SaveFileBitmap(curname, Weapons[n].hud_image_handle); } @@ -941,7 +942,7 @@ void CWorldWeaponsDialog::UpdateDialog() { SendDlgItemMessage(IDC_WEAPON_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)Weapons[n].name); SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_RESETCONTENT, 0, 0); - for (i = 0; i < MAX_SOUNDS; i++) { + for (int i = 0; i < MAX_SOUNDS; i++) { if (Sounds[i].used) SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name); } @@ -953,7 +954,7 @@ void CWorldWeaponsDialog::UpdateDialog() { SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0"); SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_RESETCONTENT, 0, 0); - for (i = 0; i < MAX_SOUNDS; i++) { + for (int i = 0; i < MAX_SOUNDS; i++) { if (Sounds[i].used) SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name); } @@ -965,7 +966,7 @@ void CWorldWeaponsDialog::UpdateDialog() { SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0"); SendDlgItemMessage(IDC_WEAPON_WALL_SOUND_PULLDOWN, CB_RESETCONTENT, 0, 0); - for (i = 0; i < MAX_SOUNDS; i++) { + for (int i = 0; i < MAX_SOUNDS; i++) { if (Sounds[i].used) SendDlgItemMessage(IDC_WEAPON_WALL_SOUND_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name); } @@ -979,7 +980,7 @@ void CWorldWeaponsDialog::UpdateDialog() { SendDlgItemMessage(IDC_SMOKE_PULLDOWN, CB_RESETCONTENT, 0, 0); if (Weapons[n].flags & WF_SMOKE) { - for (i = 0; i < MAX_TEXTURES; i++) { + for (int i = 0; i < MAX_TEXTURES; i++) { if (GameTextures[i].used) SendDlgItemMessage(IDC_SMOKE_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name); } @@ -994,7 +995,7 @@ void CWorldWeaponsDialog::UpdateDialog() { // Do scorch pulldown SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); - for (i = 0; i < MAX_TEXTURES; i++) { + for (int i = 0; i < MAX_TEXTURES; i++) { if (GameTextures[i].used) SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name); } @@ -1008,7 +1009,7 @@ void CWorldWeaponsDialog::UpdateDialog() { // Do icon pulldown SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); - for (i = 0; i < MAX_TEXTURES; i++) { + for (int i = 0; i < MAX_TEXTURES; i++) { if (GameTextures[i].used) SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name); } @@ -1020,7 +1021,7 @@ void CWorldWeaponsDialog::UpdateDialog() { SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); SendDlgItemMessage(IDC_EXPLODE_PULLDOWN, CB_RESETCONTENT, 0, 0); - for (i = 0; i < MAX_TEXTURES; i++) { + for (int i = 0; i < MAX_TEXTURES; i++) { if (GameTextures[i].used) SendDlgItemMessage(IDC_EXPLODE_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name); } @@ -1035,7 +1036,7 @@ void CWorldWeaponsDialog::UpdateDialog() { // Do particle handle SendDlgItemMessage(IDC_PARTICLE_PULLDOWN, CB_RESETCONTENT, 0, 0); - for (i = 0; i < MAX_TEXTURES; i++) { + for (int i = 0; i < MAX_TEXTURES; i++) { if (GameTextures[i].used) SendDlgItemMessage(IDC_PARTICLE_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name); } @@ -1051,7 +1052,7 @@ void CWorldWeaponsDialog::UpdateDialog() { // Do spawn handles SendDlgItemMessage(IDC_WEAPON_SPAWN_PULLDOWN, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(IDC_SPAWN2_PULLDOWN, CB_RESETCONTENT, 0, 0); - for (i = 0; i < MAX_WEAPONS; i++) { + for (int i = 0; i < MAX_WEAPONS; i++) { if (Weapons[i].used) { SendDlgItemMessage(IDC_WEAPON_SPAWN_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Weapons[i].name); SendDlgItemMessage(IDC_SPAWN2_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Weapons[i].name); @@ -1076,7 +1077,7 @@ void CWorldWeaponsDialog::UpdateDialog() { // Do spawn robot stuff SendDlgItemMessage(IDC_SPAWN_ROBOT_PULLDOWN, CB_RESETCONTENT, 0, 0); - for (i = 0; i < MAX_OBJECT_IDS; i++) { + for (int i = 0; i < MAX_OBJECT_IDS; i++) { if (Object_info[i].type == OBJ_ROBOT) SendDlgItemMessage(IDC_SPAWN_ROBOT_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Object_info[i].name); } @@ -1412,17 +1413,17 @@ void CWorldWeaponsDialog::OnLoadWeaponDischarge() { if (!model) { if (!anim) { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameBitmaps[Weapons[n].fire_image_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameBitmaps[Weapons[n].fire_image_handle].name); bm_SaveFileBitmap(filename, Weapons[n].fire_image_handle); } else { - sprintf(filename, "%s\\%s", LocalManageGraphicsDir, GameVClips[Weapons[n].fire_image_handle].name); + sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), + GameVClips[Weapons[n].fire_image_handle].name); SaveVClip(filename, Weapons[n].fire_image_handle); } } else { - char destname[100]; - sprintf(destname, "%s\\%s", LocalModelsDir, Poly_models[Weapons[n].fire_image_handle].name); - if (stricmp(destname, filename)) // only copy if they are different - cf_CopyFile(destname, filename); + std::filesystem::path destname = LocalModelsDir / Poly_models[Weapons[n].fire_image_handle].name; + cf_CopyFile(destname, filename); } UpdateDialog();