From 41ec941b50202988396107d80770bec307686a04 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Sat, 29 Jun 2024 11:34:16 +0300 Subject: [PATCH] Convert bm_SaveFileBitmap() and SaveVClip() to std::fs::path --- Descent3/vclip.cpp | 18 +++++++++--------- Descent3/vclip.h | 5 +++-- bitmap/bitmain.cpp | 16 ++++++++-------- lib/bitmap.h | 5 +++-- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Descent3/vclip.cpp b/Descent3/vclip.cpp index b92fc3e6..ca5933dd 100644 --- a/Descent3/vclip.cpp +++ b/Descent3/vclip.cpp @@ -154,8 +154,11 @@ * $NoKeywords: $ */ -#include -#include +#include +#include +#include +#include + #include "pstypes.h" #include "pserror.h" #include "bitmap.h" @@ -164,9 +167,6 @@ #include "mono.h" #include "ddio.h" #include "gametexture.h" -#include "texture.h" -#include -#include "ctype.h" #include "mem.h" #include "game.h" @@ -239,18 +239,18 @@ void FreeVClip(int num) { // Saves a given video clip to a file // Returns 1 if everything ok, 0 otherwise // "num" is index into GameVClip array -int SaveVClip(const char *filename, int num) { +int SaveVClip(const std::filesystem::path& filename, int num) { CFILE *outfile; vclip *vc = &GameVClips[num]; ASSERT(vc->used); - ASSERT(filename != NULL); + ASSERT(!filename.empty()); PageInVClip(num); outfile = (CFILE *)cfopen(filename, "wb"); if (!outfile) { - mprintf(0, "Couldn't save vclip %s!\n", filename); + mprintf(0, "Couldn't save vclip %s!\n", filename.u8string().c_str()); return 0; } @@ -267,7 +267,7 @@ int SaveVClip(const char *filename, int num) { // Now save each frame of this vclip for (int i = 0; i < vc->num_frames; i++) { if (bm_SaveBitmap(outfile, vc->frames[i]) != 1) { - mprintf(0, "Couldn't save frame %d of vclip %s!\n", i, filename); + mprintf(0, "Couldn't save frame %d of vclip %s!\n", i, filename.u8string().c_str()); Int3(); cfclose(outfile); return 0; diff --git a/Descent3/vclip.h b/Descent3/vclip.h index fc28eba0..e210edfd 100644 --- a/Descent3/vclip.h +++ b/Descent3/vclip.h @@ -20,7 +20,8 @@ #define VCLIP_H -#include "pstypes.h" +#include + #include "fix.h" #include "manage.h" @@ -56,7 +57,7 @@ void FreeVClip(int num); // Saves a given video clip to a file // Returns 1 if everything ok, 0 otherwise // "num" is index into GameVClip array -int SaveVClip(const char *filename, int num); +int SaveVClip(const std::filesystem::path& filename, int num); // Allocs and loads a vclip from the file named "filename" // Returns -1 on error, index into GameVClip array on success diff --git a/bitmap/bitmain.cpp b/bitmap/bitmain.cpp index ca4c9292..a0f2a6d5 100644 --- a/bitmap/bitmain.cpp +++ b/bitmap/bitmain.cpp @@ -297,9 +297,13 @@ * * $NoKeywords: $ */ -#include -#include -#include + +#include +#include +#include +#include +#include + #include "cfile.h" #include "texture.h" #include "bitmap.h" @@ -313,10 +317,6 @@ #include "mem.h" #include "psrand.h" -#include "Macros.h" - -#include - #define BM_FILETYPE_TGA 1 #define BM_FILETYPE_PCX 2 #define BM_FILETYPE_IFF 3 @@ -1080,7 +1080,7 @@ int bm_MakeBitmapResident(int handle) { } // Saves a bitmap to a file. Saves the bitmap as an OUTRAGE_COMPRESSED_OGF. // Returns -1 if something is wrong. -int bm_SaveFileBitmap(const char *filename, int handle) { +int bm_SaveFileBitmap(const std::filesystem::path& filename, int handle) { int ret; CFILE *fp; if (!GameBitmaps[handle].used) { diff --git a/lib/bitmap.h b/lib/bitmap.h index 1f5108c4..5a148f74 100644 --- a/lib/bitmap.h +++ b/lib/bitmap.h @@ -19,7 +19,8 @@ #ifndef PSBITMAP_H #define PSBITMAP_H -#include "pstypes.h" +#include + #include "cfile.h" #ifdef __LINUX__ @@ -107,7 +108,7 @@ int bm_FindBitmapName(const char *name); int bm_SaveBitmap(CFILE *fp, int handle); // Saves a bitmap to a file. Saves the bitmap as an OUTRAGE_TGA_TYPE. // Returns -1 if something is wrong. -int bm_SaveFileBitmap(const char *filename, int handle); +int bm_SaveFileBitmap(const std::filesystem::path& filename, int handle); // given a handle to a bitmap, returns its width, or -1 if handle is invalid int bm_w(int handle, int miplevel); // given a handle to a bitmap, returns its height, or -1 if handle is invalid