From 6d34c8cfa0e3849da2312b8bc1091138feb36e41 Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 12 Nov 2024 23:26:19 -0500 Subject: [PATCH 1/9] Enhance utils with string utility functions and platform compatibility. Refactored N3Utils.h to introduce various platform-agnostic string utilities, improving code consistency and cross-platform compatibility. Changes include: - Added concepts for CharType, StringType, StringViewType, and PathType. - Introduced case-insensitive comparison functions (iequals, istarts_with, iends_with) for strings and filesystem paths, using a custom ToLower functor to handle case transformations across char types. - Defined platform-specific mappings for string functions, improving portability across Windows, macOS, and Linux. - Updated comments and instructions for verifying compatibility with C++20 compilers (GCC, Clang, MSVC) on godbolt.org. These improvements enhance code reuse and ensure compatibility across multiple platforms, supporting the goal of a more robust, standardized codebase. --- src/common/N3Utils.h | 150 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 142 insertions(+), 8 deletions(-) diff --git a/src/common/N3Utils.h b/src/common/N3Utils.h index a6197436..31aa194f 100644 --- a/src/common/N3Utils.h +++ b/src/common/N3Utils.h @@ -1,25 +1,164 @@ - +// This header only files is used across all projects. +// Add here only functions that are minimal and platform agnostic. +// You should also test your code with gcc, clang and msvc via: +// godbolt.org +// Make sure to enable there C++20 and all warnings: +// msvc: /std:c++20 /Wall +// gcc and clang: --std=c++20 -Wall #pragma once #include +#include #include #include #include #include - -namespace fs = std::filesystem; +#include +#include +#include #if defined(_WIN32) || defined(_WIN64) #define VC_EXTRALEAN +#define NOMINMAX #include + +// Functions mapping matching with POSIX systems +#define strcasecmp _stricmp +#define wcscasecmp _wcsicmp + #elif defined(__APPLE__) #include + #elif defined(__linux__) #include + #endif // #if defined(_WIN32) || defined(_WIN64) +namespace fs = std::filesystem; + namespace n3std { +// Concepts +template +concept CharType = std::disjunction_v, std::is_same, std::is_same, + std::is_same, std::is_same>; + +template +concept StringType = std::is_base_of_v, T>; + +template +concept StringViewType = std::is_base_of_v, T>; + +template +concept StringLike = StringType || StringViewType; + +template +concept PathType = std::is_base_of_v; + +template +concept PathConstructible = std::constructible_from; + +// Forward declaration +struct ToLower; + +inline void to_lower(StringType auto & str); +[[nodiscard]] inline auto to_lower(StringType auto && str); +inline void to_lower(PathType auto & path); +[[nodiscard]] inline auto to_lower(PathType auto && path); + +inline bool istarts_with(const StringLike auto & lhs, const StringLike auto & rhs); +inline bool iends_with(const StringLike auto & lhs, const StringLike auto & rhs); + +inline bool iequals(const char * lhs, const char * rhs); +inline bool iequals(const wchar_t * lhs, const wchar_t * rhs); +inline bool iequals(const StringLike auto & lhs, const StringLike auto & rhs); +inline bool iequals(const std::filesystem::path & lhs, const std::filesystem::path & rhs); + +} // namespace n3std + +namespace n3std { + +// Functor for character transformation +struct ToLower { + template T operator()(T ch) const { + if constexpr (std::is_same_v) { + return static_cast(std::tolower(static_cast(ch))); + } else if constexpr (std::is_same_v) { + return static_cast(std::towlower(ch)); + } else if constexpr (std::is_integral()) { + // Handle char8_t, char16_t, char32_t, and other integral types + return static_cast(std::towlower(static_cast(ch))); + } else { + return ch; + } + } +}; + +inline void to_lower(StringType auto & str) { + std::transform(str.begin(), str.end(), str.begin(), ToLower{}); +} + +[[nodiscard]] inline auto to_lower(StringType auto && str) { + std::transform(str.begin(), str.end(), str.begin(), ToLower{}); + return str; +} + +inline void to_lower(PathType auto & path) { + auto & _Text = const_cast(path.native()); + to_lower(_Text); +} + +[[nodiscard]] inline auto to_lower(PathType auto && path) { + auto & _Text = const_cast(path.native()); + to_lower(_Text); + return path; +} + +inline bool istarts_with(const StringLike auto & lhs, const StringLike auto & rhs) { + if (rhs.size() > lhs.size()) { + return false; + } + + auto transform_lower = std::ranges::views::transform(ToLower{}); + return std::ranges::equal(lhs | std::views::take(static_cast(rhs.size())) | transform_lower, + rhs | transform_lower); +} + +inline bool iends_with(const StringLike auto & lhs, const StringLike auto & rhs) { + if (rhs.size() > lhs.size()) { + return false; + } + + auto transform_lower = std::ranges::views::transform(ToLower{}); + return std::ranges::equal(lhs | std::views::drop(static_cast(lhs.size() - rhs.size())) | transform_lower, + rhs | transform_lower); +} + +inline bool iequals(const char * lhs, const char * rhs) { + return strcasecmp(lhs, rhs) == 0; +} + +inline bool iequals(const wchar_t * lhs, const wchar_t * rhs) { + return wcscasecmp(lhs, rhs) == 0; +} + +inline bool iequals(const StringLike auto & lhs, const StringLike auto & rhs) { + if (rhs.size() != lhs.size()) { + return false; + } + + auto transform_lower = std::ranges::views::transform(ToLower{}); + return std::ranges::equal(lhs | transform_lower, rhs | transform_lower); +} + +// Note that fs::path constructors supports implicit conversions from wide-character +// strings to narrow and vice versa. Therefore this overload will be invoked for most scenarios +// where both lhs and rhs types are not the same. This also means that a copy of the object will +// be created to unify both types before comparison. +inline bool iequals(const std::filesystem::path & lhs, const std::filesystem::path & rhs) { + return iequals(lhs.c_str(), rhs.c_str()); +} + inline fs::path get_app_path() { static fs::path app_path = [] { fs::path::value_type buff[512]{}; @@ -55,11 +194,6 @@ inline void log_file_write(const char * log_msg) { log_file_write(std::string_view(log_msg)); } -static bool iequals(const std::string_view & lhs, const std::string_view & rhs) { - auto to_lower{std::ranges::views::transform(::tolower)}; - return std::ranges::equal(lhs | to_lower, rhs | to_lower); -} - static std::string bytes_to_hex(const uint8_t * const data, const size_t size) { if (!data || size == 0) { return ""; From a23482a4bd58e2ccd16178ef18b0443dd07f0b8f Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 12 Nov 2024 23:29:21 -0500 Subject: [PATCH 2/9] Implement extended filesystem wrapper class for enhanced path handling. This commit introduces `fs::pathx`, a custom wrapper around `std::filesystem::path`, to address limitations in the standard implementation. This extended class provides additional functionality and optimizations while maintaining compatibility with existing code. Key features include: - **Automatic Path Normalization**: FS_AUTO_NORMALIZE automatically standardizes path separators during concatenation with `operator/` or `operator/=`, simplifying path handling, especially on Windows. - **Extended Path Manipulation**: Added functions for case-insensitive path comparisons (`icontains`), relative path construction, and converting paths to lowercase, improving flexibility in handling paths. - **Operator Overloading**: Implemented `operator/` and `operator+=` to streamline path concatenation, along with other convenient overloads. - **Temporary File Creation**: Added `mktemp_file`, a function for creating temporary files with customizable prefixes, suffixes, and directory locations. - **Namespace Redirection**: The new class uses namespace redirection and aliasing to remain unobtrusive in the codebase, making it behave like a native `std::filesystem::path` object. These enhancements offer a more versatile and efficient approach to path management, particularly on Windows, and allow for a cleaner, more maintainable codebase. This approach should remain effective until future standard updates to `std::filesystem` address current limitations. --- src/common/N3Utils.h | 347 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 345 insertions(+), 2 deletions(-) diff --git a/src/common/N3Utils.h b/src/common/N3Utils.h index 31aa194f..09e0d17d 100644 --- a/src/common/N3Utils.h +++ b/src/common/N3Utils.h @@ -17,6 +17,13 @@ #include #include +// Enables automatic path normalization during concatenation with `operator/` or `operator/=`. +// This removes the need to manually call the normalize function to standardize path separators. +// On Windows, both `\` and `/` separators are valid and mixable, but this can lead to inconsistent paths. +// Caution: This adds overhead by copying paths via `generic_string()`, reconstructing paths anew. +// Note: Most KO editors save paths with Windows `\`, so this aids in standardizing paths when reading and concatenating. +#define FS_AUTO_NORMALIZE + #if defined(_WIN32) || defined(_WIN64) #define VC_EXTRALEAN #define NOMINMAX @@ -34,8 +41,6 @@ #endif // #if defined(_WIN32) || defined(_WIN64) -namespace fs = std::filesystem; - namespace n3std { // Concepts @@ -76,6 +81,344 @@ inline bool iequals(const std::filesystem::path & lhs, const std::filesystem::pa } // namespace n3std +namespace fs { + +using namespace std::filesystem; + +// The `+` operator is not available for fs::path: +// https://www.reddit.com/r/cpp/comments/9bwou7/why_doesnt_stdfilesystempath_have_an_operator/ +// so I implemented it to redirect std::filesystem::path to use pathx, incorporating additional +// useful functionality and optimizations. +class pathx : public std::filesystem::path { + private: + string_type & _Text_get() { return const_cast(native()); } + + public: + using std::filesystem::path::path; + + pathx() = default; + pathx(const pathx &) = default; + pathx(pathx &&) = default; + ~pathx() = default; + + // Conversion constructors for implicit conversion from path to pathx. + pathx(const path & p) noexcept + : path(p) {} + pathx(path && p) noexcept + : path(std::move(p)) {} + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // BEGIN: Operators + + // Assignment operators + pathx & operator=(const pathx &) = default; + pathx & operator=(pathx &&) noexcept = default; + pathx & operator=(string_type && _Source) noexcept { + path::operator=(std::move(_Source)); + return *this; + } + template pathx & operator=(const _Src & _Source) { + path::operator=(_Source); + return *this; + } + + // Append operators + pathx & operator/=(const pathx & _Other) { +#if defined(FS_AUTO_NORMALIZE) + *this = path::operator/=(_Other).generic_string(); +#else + path::operator/=(_Other); +#endif + return *this; + } + template pathx & operator/=(const _Src & _Source) { +#if defined(FS_AUTO_NORMALIZE) + *this = path::operator/=(path{_Source}).generic_string(); +#else + path::operator/=(path{_Source}); +#endif + return *this; + } + + // Concat operators + pathx & operator+=(const path & _Added) { return operator+=(_Added.native()); } + pathx & operator+=(const string_type & _Added) { + path::operator+=(_Added); + return *this; + } + pathx & operator+=(const std::wstring_view _Added) { + path::operator+=(_Added); + return *this; + } + pathx & operator+=(const value_type * const _Added) { + path::operator+=(_Added); + return *this; + } + pathx & operator+=(const value_type _Added) { + path::operator+=(_Added); + return *this; + } + template pathx & operator+=(const _Src & _Added) { + path::operator+=(path{_Added}.native()); + return *this; + } + template pathx & operator+=(const CharT _Added) { + path::operator+=(path{&_Added, &_Added + 1}.native()); + return *this; + } + + // END: Operators + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + template [[nodiscard]] friend pathx operator+(pathx lhs, T && rhs) noexcept { + if constexpr (n3std::PathType>) { + lhs._Text_get() += rhs.native(); + } else { + lhs._Text_get() += path{std::forward(rhs)}.native(); + } + return lhs; + } + + inline pathx & normalize(value_type from = '\\', value_type to = '/') & { + std::ranges::replace(_Text_get(), from, to); + return *this; + } + + // Reference collapsing for temporaries + inline pathx && normalize(value_type from = '\\', value_type to = '/') && { + std::ranges::replace(_Text_get(), from, to); + return std::move(*this); + } + + // Const overload to return a modified copy + inline pathx normalize(value_type from = '\\', value_type to = '/') const & { + pathx copy = *this; + copy.normalize(from, to); + return copy; + } + + inline pathx & make_lower() { + n3std::to_lower(_Text_get()); + return *this; + } + + [[nodiscard]] inline pathx lower() const { + pathx copy(*this); + copy.make_lower(); + return copy; + } + + inline pathx & make_relative(const path & base, bool ignore_case = false) { + if (base.empty()) { + return *this; + } + + std::string lhs = this->generic_string(); + std::string rhs = base.generic_string(); + if (ignore_case ? n3std::istarts_with(lhs, rhs) : lhs.starts_with(rhs)) { + _Text_get().erase(0, rhs.size() + 1); + } + + return *this; + } + + [[nodiscard]] inline pathx relative(const path & base, bool ignore_case = false) const { + fs::pathx copy(*this); + copy.make_relative(base, ignore_case); + return copy; + } + + inline bool contains(const path & segment) const { + for (const auto & seg : *this) { + if (seg == segment) { + return true; + } + } + + return false; + } + + inline bool icontains(const path & segment) const { + for (const auto & seg : *this) { + if (n3std::iequals(seg, segment)) { + return true; + } + } + + return false; + } + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // BEGIN: Overloads - Declare some of the most common overloads to return pathx + + pathx & make_preferred() noexcept { + path::make_preferred(); + return *this; + } + pathx & remove_filename() noexcept { + path::remove_filename(); + return *this; + } + pathx & replace_filename(const path & _Replacement) { // remove any filename from *this and append _Replacement + path::replace_filename(_Replacement); + return *this; + } + pathx & replace_extension() noexcept { + path::replace_extension(); + return *this; + } + pathx & replace_extension(const path & _Replacement) { + path::replace_extension(_Replacement); + return *this; + } + + [[nodiscard]] pathx root_name() const { return path::root_name(); } + [[nodiscard]] pathx root_directory() const { return path::root_directory(); } + [[nodiscard]] pathx root_path() const { return path::root_path(); } + [[nodiscard]] pathx relative_path() const { return path::relative_path(); } + [[nodiscard]] pathx parent_path() const { return path::parent_path(); } + [[nodiscard]] pathx filename() const { return path::filename(); } + [[nodiscard]] pathx stem() const { return path::stem(); } + [[nodiscard]] pathx extension() const { return path::extension(); } + + [[nodiscard]] pathx lexically_normal() const { return path::lexically_normal(); } + [[nodiscard]] inline pathx lexically_relative(const path & _Base) const { return path::lexically_relative(_Base); } + [[nodiscard]] pathx lexically_proximate(const path & _Base) const { return path::lexically_proximate(_Base); } +}; + +[[nodiscard]] inline pathx absolute(const path & _Input, std::error_code & _Ec) { + return std::filesystem::absolute(_Input, _Ec); +} + +[[nodiscard]] inline pathx absolute(const path & _Input) { + return std::filesystem::absolute(_Input); +} + +[[nodiscard]] inline pathx canonical(const path & _Input) { + return std::filesystem::canonical(_Input); +} + +[[nodiscard]] inline pathx canonical(const path & _Input, std::error_code & _Ec) { + return std::filesystem::canonical(_Input, _Ec); +} + +[[nodiscard]] inline pathx read_symlink(const path & _Symlink_path, std::error_code & _Ec) { + return std::filesystem::read_symlink(_Symlink_path, _Ec); +} + +[[nodiscard]] inline pathx read_symlink(const path & _Symlink_path) { + return std::filesystem::read_symlink(_Symlink_path); +} + +[[nodiscard]] inline pathx temp_directory_path(std::error_code & _Ec) { + return std::filesystem::temp_directory_path(_Ec); +} + +[[nodiscard]] inline pathx temp_directory_path() { + return std::filesystem::temp_directory_path(); +} + +[[nodiscard]] inline pathx current_path(std::error_code & _Ec) { + return std::filesystem::current_path(_Ec); +} + +[[nodiscard]] inline pathx current_path() { + return std::filesystem::current_path(); +} + +inline void current_path(const path & _To, std::error_code & _Ec) noexcept { + std::filesystem::current_path(_To, _Ec); +} + +inline void current_path(const path & _To) { + std::filesystem::current_path(_To); +} + +[[nodiscard]] inline pathx weakly_canonical(const path & _Input, std::error_code & _Ec) { + return std::filesystem::weakly_canonical(_Input, _Ec); +} + +[[nodiscard]] inline pathx weakly_canonical(const path & _Input) { + return std::filesystem::weakly_canonical(_Input); +} + +[[nodiscard]] inline pathx proximate(const path & _Path, const path & _Base = std::filesystem::current_path()) { + return std::filesystem::proximate(_Path, _Base); +} + +[[nodiscard]] inline pathx proximate(const path & _Path, const path & _Base, std::error_code & _Ec) { + return std::filesystem::proximate(_Path, _Base, _Ec); +} + +[[nodiscard]] inline pathx proximate(const path & _Path, std::error_code & _Ec) { + return std::filesystem::proximate(_Path, _Ec); +} + +[[nodiscard]] inline pathx relative(const path & _Path, const path & _Base = std::filesystem::current_path()) { + return std::filesystem::relative(_Path, _Base); +} + +[[nodiscard]] inline pathx relative(const path & _Path, const path & _Base, std::error_code & _Ec) { + return std::filesystem::relative(_Path, _Base, _Ec); +} + +[[nodiscard]] inline pathx relative(const path & _Path, std::error_code & _Ec) { + return std::filesystem::relative(_Path, _Ec); +} + +// END: Overloads +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +inline pathx mktemp_file(std::string_view prefix = "temp", std::string_view suffix = ".tmp", size_t length = 4, + const pathx & dir = temp_directory_path()) { + constexpr std::string_view chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + + static thread_local std::mt19937 generator{std::random_device{}()}; + static thread_local std::uniform_int_distribution dist(0, chars.size() - 1); + + if (!dir.empty() && (!exists(dir) || !is_directory(dir))) { + create_directories(dir); + } + + pathx result; + do { + std::string filename; + filename.reserve(prefix.size() + length + suffix.size()); + filename.append(prefix); + for (size_t i = 0; i < length; ++i) { + filename += chars[dist(generator)]; + } + filename.append(suffix); + + result = dir / filename; + } while (exists(result)); + +#if defined(FS_AUTO_NORMALIZE) + return result.generic_string(); +#else + return result; +#endif +} + +// Redirect path usages to pathx +using path = pathx; + +} // namespace fs + +// Trick ADL to prioritize our custom overloads so that we return pathx instead of path +namespace std::filesystem { + +[[nodiscard]] fs::pathx operator/(const n3std::PathConstructible auto & lhs, + const n3std::PathConstructible auto & rhs) { +#if defined(FS_AUTO_NORMALIZE) + return (static_cast(lhs) / static_cast(rhs)).generic_string(); +#else + return static_cast(lhs) / static_cast(rhs); +#endif +} + +} // namespace std::filesystem + namespace n3std { // Functor for character transformation From 1689d21753af7faa289e55ea1a4293c94cf72b4e Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 12 Nov 2024 23:29:56 -0500 Subject: [PATCH 3/9] Log CLogWriter output to console for improved debugging visibility. Added a console log output in CLogWriter::Write to display log messages directly in the console in addition to file output. This enhancement helps improve real-time debugging by making logs immediately visible. --- src/engine/N3Base/LogWriter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/N3Base/LogWriter.cpp b/src/engine/N3Base/LogWriter.cpp index d493192f..fcfd4b18 100644 --- a/src/engine/N3Base/LogWriter.cpp +++ b/src/engine/N3Base/LogWriter.cpp @@ -115,6 +115,7 @@ void CLogWriter::Write(const char * lpszFormat, ...) { va_start(argList, lpszFormat); vsprintf(szBuff, lpszFormat, argList); va_end(argList); + N3_DEBUG("CLogWriter::Write: {}", szBuff); lstrcat(szFinal, szBuff); lstrcat(szFinal, "\r\n"); From 9cc65913c93354eacc98b7d23ad825e08817cac8 Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 12 Nov 2024 23:42:26 -0500 Subject: [PATCH 4/9] Refactor project to standardize file handling with std::filesystem. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit replaces numerous platform-specific WinAPI functions and custom implementations with C++17’s std::filesystem, streamlining and modernizing path and file management across the codebase. The refactor enhances code readability, reduces platform-specific dependencies, and improves cross-platform compatibility. Summary of changes: - **Path Handling**: Replaced custom and WinAPI-based path handling across files, standardizing operations like path concatenation, normalization, and extraction using std::filesystem methods. - **File I/O Operations**: Migrated file reading, writing, and existence checks to use std::filesystem, ensuring cleaner and more uniform file operations across platforms. - **Legacy Code Removal**: Removed obsolete components such as `CAVIPlayer` and other WinAPI-based implementations no longer required with std::filesystem support. - **Bug Fixes**: Addressed existing path-related bugs and inconsistencies that stemmed from the manual path handling methods previously used. - **Code Cleanup**: Deleted unnecessary code comments and unused functions, including those related to deprecated path handling, for a cleaner, more maintainable codebase. This update provides a solid foundation for improved cross-platform support and prepares the codebase for future C++ standard upgrades. --- src/engine/N3Base/AVIPlayer.cpp | 198 ----- src/engine/N3Base/AVIPlayer.h | 29 - src/engine/N3Base/BitMapFile.cpp | 18 +- src/engine/N3Base/BitMapFile.h | 6 +- src/engine/N3Base/Jpeg.cpp | 9 +- src/engine/N3Base/Jpeg.h | 44 +- src/engine/N3Base/JpegFile.cpp | 117 ++- src/engine/N3Base/JpegFile.h | 52 +- src/engine/N3Base/LogWriter.cpp | 28 +- src/engine/N3Base/LogWriter.h | 4 +- src/engine/N3Base/N3AnimControl.h | 8 +- src/engine/N3Base/N3AnimatedTexures.cpp | 25 +- src/engine/N3Base/N3Base.cpp | 17 +- src/engine/N3Base/N3Base.h | 10 +- src/engine/N3Base/N3BaseFileAccess.cpp | 110 ++- src/engine/N3Base/N3BaseFileAccess.h | 33 +- src/engine/N3Base/N3Board.cpp | 16 +- src/engine/N3Base/N3Board.h | 4 +- src/engine/N3Base/N3Chr.cpp | 301 ++++---- src/engine/N3Base/N3Chr.h | 38 +- src/engine/N3Base/N3Cloud.cpp | 9 +- src/engine/N3Base/N3Cloud.h | 4 +- src/engine/N3Base/N3Eng.cpp | 8 +- src/engine/N3Base/N3EngTool.h | 2 +- src/engine/N3Base/N3FXBundle.cpp | 125 +--- src/engine/N3Base/N3FXBundle.h | 4 +- src/engine/N3Base/N3FXDef.h | 8 +- src/engine/N3Base/N3FXGroup.cpp | 35 +- src/engine/N3Base/N3FXGroup.h | 2 +- src/engine/N3Base/N3FXPMesh.cpp | 2 +- src/engine/N3Base/N3FXPMeshInstance.cpp | 10 +- src/engine/N3Base/N3FXPMeshInstance.h | 4 +- src/engine/N3Base/N3FXPartBase.cpp | 177 ++--- src/engine/N3Base/N3FXPartBase.h | 5 +- src/engine/N3Base/N3FXPartBillBoard.cpp | 24 +- src/engine/N3Base/N3FXPartBottomBoard.cpp | 14 +- src/engine/N3Base/N3FXPartMesh.cpp | 50 +- src/engine/N3Base/N3FXPartParticles.cpp | 77 +- src/engine/N3Base/N3FXPlug.cpp | 33 +- src/engine/N3Base/N3FXPlug.h | 2 +- src/engine/N3Base/N3FXShape.cpp | 69 +- src/engine/N3Base/N3FXShape.h | 4 +- src/engine/N3Base/N3GESnow.cpp | 2 +- src/engine/N3Base/N3IMesh.cpp | 9 +- src/engine/N3Base/N3Joint.cpp | 2 +- src/engine/N3Base/N3Mesh.cpp | 6 +- src/engine/N3Base/N3Mng.h | 41 +- src/engine/N3Base/N3Moon.cpp | 4 +- src/engine/N3Base/N3Moon.h | 2 +- src/engine/N3Base/N3PMeshCreate.cpp | 2 +- src/engine/N3Base/N3PMeshInstance.cpp | 10 +- src/engine/N3Base/N3PMeshInstance.h | 4 +- src/engine/N3Base/N3Pond.cpp | 4 +- src/engine/N3Base/N3River.cpp | 4 +- src/engine/N3Base/N3River2.cpp | 2 +- src/engine/N3Base/N3Scene.cpp | 101 +-- src/engine/N3Base/N3Scene.h | 8 +- src/engine/N3Base/N3Shape.cpp | 238 +++--- src/engine/N3Base/N3Shape.h | 10 +- src/engine/N3Base/N3ShapeMgr.cpp | 2 +- src/engine/N3Base/N3ShapeMod.cpp | 20 +- src/engine/N3Base/N3ShapeMod.h | 2 +- src/engine/N3Base/N3SkyMng.cpp | 115 +-- src/engine/N3Base/N3SkyMng.h | 17 +- src/engine/N3Base/N3SndDef.h | 5 +- src/engine/N3Base/N3SndEng.cpp | 8 +- src/engine/N3Base/N3SndMgr.cpp | 34 +- src/engine/N3Base/N3SndMgr.h | 22 +- src/engine/N3Base/N3SndObj.cpp | 18 +- src/engine/N3Base/N3SndObj.h | 4 +- src/engine/N3Base/N3SndObj2D.cpp | 3 +- src/engine/N3Base/N3SndObj2D.h | 6 +- src/engine/N3Base/N3SndObjStream.cpp | 12 +- src/engine/N3Base/N3SndObjStream.h | 4 +- src/engine/N3Base/N3Sun.cpp | 4 +- src/engine/N3Base/N3Sun.h | 2 +- src/engine/N3Base/N3TableBase.h | 28 +- src/engine/N3Base/N3Texture.cpp | 74 +- src/engine/N3Base/N3Texture.h | 8 +- src/engine/N3Base/N3TransformCollision.cpp | 84 ++- src/engine/N3Base/N3TransformCollision.h | 8 +- src/engine/N3Base/N3UIBase.cpp | 123 ++-- src/engine/N3Base/N3UIBase.h | 20 +- src/engine/N3Base/N3UIButton.cpp | 84 +-- src/engine/N3Base/N3UIButton.h | 8 +- src/engine/N3Base/N3UIDef.h | 2 - src/engine/N3Base/N3UIEdit.cpp | 41 +- src/engine/N3Base/N3UIEdit.h | 4 +- src/engine/N3Base/N3UIImage.cpp | 182 ++--- src/engine/N3Base/N3UIImage.h | 10 +- src/engine/N3Base/N3UIList.cpp | 12 +- src/engine/N3Base/N3UIStatic.cpp | 43 +- src/engine/N3Base/N3UIStatic.h | 4 +- src/engine/N3Base/N3UIString.cpp | 4 +- src/engine/N3Base/N3VMesh.cpp | 2 +- src/engine/N3Base/StreamSoundObj.cpp | 6 +- src/engine/N3Base/StreamSoundObj.h | 2 +- src/engine/N3Base/WaveFile.cpp | 13 +- src/engine/N3Base/WaveFile.h | 2 +- src/game/APISocket.cpp | 66 +- src/game/Bird.cpp | 10 +- src/game/Bird.h | 2 +- src/game/BirdMng.cpp | 12 +- src/game/BirdMng.h | 9 +- src/game/DungeonManager.cpp | 2 +- src/game/EventManager.cpp | 4 +- src/game/EventManager.h | 2 +- src/game/GameBase.cpp | 110 +-- src/game/GameBase.h | 4 +- src/game/GameDef.h | 43 +- src/game/GameEng.cpp | 7 - src/game/GameProcCharacterCreate.cpp | 6 +- src/game/GameProcCharacterSelect.cpp | 180 +++-- src/game/GameProcLogIn.cpp | 30 +- src/game/GameProcMain.cpp | 203 ++---- src/game/GameProcNationSelect.cpp | 9 +- src/game/GameProcedure.cpp | 62 +- src/game/GameProcedure.h | 2 +- src/game/LightMgr.cpp | 8 +- src/game/LightMgr.h | 2 +- src/game/MachineBase.cpp | 2 +- src/game/MachineMng.cpp | 126 ++-- src/game/MagicSkillMng.cpp | 36 +- src/game/Main.cpp | 46 +- src/game/N3EffectWave2.cpp | 9 +- src/game/N3EffectWave2.h | 2 +- src/game/N3FXBundleGame.cpp | 34 +- src/game/N3FXMgr.cpp | 24 +- src/game/N3FXMgr.h | 6 +- src/game/N3MP3.cpp | 16 +- src/game/N3Terrain.cpp | 69 +- src/game/N3Terrain.h | 2 +- src/game/N3TerrainManager.cpp | 19 +- src/game/N3UIWndBase.h | 2 +- src/game/PlayerBase.cpp | 161 ++--- src/game/PlayerBase.h | 4 +- src/game/PlayerMySelf.cpp | 72 +- src/game/PlayerMySelf.h | 4 +- src/game/PlayerOther.cpp | 57 +- src/game/PortalVolume.cpp | 16 +- src/game/PortalVolume.h | 8 +- src/game/PvsMgr.cpp | 39 +- src/game/PvsMgr.h | 6 +- src/game/SubProcPerTrade.cpp | 36 +- src/game/UIDroppedItemDlg.cpp | 22 +- src/game/UIHotKeyDlg.cpp | 13 +- src/game/UIImageTooltipDlg.cpp | 2 +- src/game/UIInventory.cpp | 42 +- src/game/UILogin.cpp | 4 +- src/game/UIPerTradeDlg.cpp | 20 +- src/game/UIPerTradeDlg.h | 2 +- src/game/UISkillTreeDlg.cpp | 39 +- src/game/UISkillTreeDlg.h | 8 +- src/game/UIStateBar.cpp | 23 +- src/game/UIStateBar.h | 3 +- src/game/UITransactionDlg.cpp | 24 +- src/game/UITransactionDlg.h | 2 +- src/game/UIVarious.cpp | 27 +- src/game/UIWareHouseDlg.cpp | 16 +- src/server/AIServer/AIServerDlg.cpp | 26 +- src/server/AIServer/MAP.cpp | 42 +- src/server/AIServer/MAP.h | 2 +- src/server/AIServer/N3BASE/N3ShapeMgr.cpp | 9 +- src/server/AIServer/Npc.cpp | 4 +- src/server/AIServer/Server/MAP.cpp | 18 +- src/server/Aujard/AujardDlg.cpp | 28 +- src/server/Ebenezer/EVENT.cpp | 23 +- src/server/Ebenezer/EbenezerDlg.cpp | 27 +- src/server/Ebenezer/Map.cpp | 1 - src/server/Ebenezer/Map.h | 16 +- src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp | 9 +- src/server/ItemManager/ItemManagerDlg.cpp | 14 +- src/server/LoginServer/DBProcess.cpp | 327 ++++----- src/server/LoginServer/DBProcess.h | 15 +- src/server/LoginServer/Define.h | 8 +- src/server/LoginServer/LoginServerDlg.cpp | 95 +-- src/server/LoginServer/LoginServerDlg.h | 14 +- src/server/LoginServer/SettingDlg.cpp | 363 ++++------ src/server/LoginServer/SettingDlg.h | 39 +- src/server/LoginServer/User.cpp | 48 +- src/server/LoginServer/User.h | 2 +- src/server/LoginServer/VersionSet.cpp | 10 +- src/server/LoginServer/VersionSet.h | 5 +- src/server/LoginServer/res/LoginServer.rc | 54 +- src/server/LoginServer/res/Resource.h | 44 +- src/tool/KscViewer/KscViewerDoc.cpp | 68 +- src/tool/KscViewer/KscViewerDoc.h | 2 +- src/tool/KscViewer/KscViewerView.cpp | 17 +- src/tool/KscViewer/N3JpegFile.cpp | 4 +- src/tool/KscViewer/N3JpegFile.h | 2 +- src/tool/Launcher/LauncherDlg.cpp | 77 +- src/tool/Launcher/LauncherDlg.h | 8 +- src/tool/N3CE/DlgChrProperty.cpp | 89 +-- src/tool/N3CE/FormViewAnimation.cpp | 29 +- src/tool/N3CE/FormViewProperty.cpp | 62 +- src/tool/N3CE/FormViewTool.cpp | 24 +- src/tool/N3CE/MainFrm.cpp | 2 +- src/tool/N3CE/N3CEDoc.cpp | 144 ++-- src/tool/N3CE/N3CEView.cpp | 9 +- src/tool/N3FXE/DlgEditFxg.cpp | 60 +- src/tool/N3FXE/DlgEditFxg.h | 2 +- src/tool/N3FXE/DlgEditPartBillBoard.cpp | 82 +-- src/tool/N3FXE/DlgEditPartBillBoard.h | 2 +- src/tool/N3FXE/DlgEditPartGround.cpp | 82 +-- src/tool/N3FXE/DlgEditPartGround.h | 2 +- src/tool/N3FXE/DlgEditPartMesh.cpp | 47 +- src/tool/N3FXE/DlgEditPartMesh.h | 2 +- src/tool/N3FXE/DlgEditPartParticle.cpp | 98 +-- src/tool/N3FXE/DlgEditPartParticle.h | 2 +- src/tool/N3FXE/DlgEditScript.cpp | 137 ++-- src/tool/N3FXE/DlgEditScript.h | 2 +- src/tool/N3FXE/Ground.cpp | 6 +- src/tool/N3FXE/Ground.h | 2 +- src/tool/N3FXE/MainFrm.cpp | 32 +- src/tool/N3Indoor/DlgBase.cpp | 94 +-- src/tool/N3Indoor/DlgShapeList.cpp | 39 +- src/tool/N3Indoor/DlgUnusedFiles.cpp | 36 +- src/tool/N3Indoor/DlgUnusedFiles.h | 4 +- src/tool/N3Indoor/MainFrm.cpp | 301 +++----- src/tool/N3Indoor/MainFrm.h | 10 +- src/tool/N3Indoor/N3Indoor.cpp | 61 +- src/tool/N3Indoor/N3Indoor.h | 7 +- src/tool/N3Indoor/OrganizeView.cpp | 142 ++-- src/tool/N3Indoor/OrganizeView.h | 8 +- src/tool/N3Indoor/PVSManager.cpp | 67 +- src/tool/N3Indoor/PVSManager.h | 4 +- src/tool/N3Indoor/PortalFactory.cpp | 4 +- src/tool/N3Indoor/PortalVolume.cpp | 24 +- src/tool/N3Indoor/PortalVolume.h | 9 +- src/tool/N3Indoor/PvsObjFactory.cpp | 10 +- src/tool/N3ME/DTexGroupMng.cpp | 26 +- src/tool/N3ME/DTexGroupMng.h | 4 +- src/tool/N3ME/DTexMng.cpp | 208 ++---- src/tool/N3ME/DTexMng.h | 10 +- src/tool/N3ME/DlgAddDTex.cpp | 19 +- src/tool/N3ME/DlgBase.cpp | 157 ++-- src/tool/N3ME/DlgEditEvent.cpp | 4 +- src/tool/N3ME/DlgEditWarp.cpp | 11 +- src/tool/N3ME/DlgFolderSelect.cpp | 4 +- src/tool/N3ME/DlgLight.cpp | 7 +- src/tool/N3ME/DlgLoadEvt.cpp | 28 +- src/tool/N3ME/DlgLoadNPCPath.cpp | 29 +- src/tool/N3ME/DlgLoadTileSet.cpp | 33 +- src/tool/N3ME/DlgMakeNPCPath.cpp | 16 +- src/tool/N3ME/DlgPondProperty.cpp | 15 +- src/tool/N3ME/DlgRegenUser.cpp | 10 +- src/tool/N3ME/DlgRiverProperty.cpp | 45 +- src/tool/N3ME/DlgSaveDivision.cpp | 8 +- src/tool/N3ME/DlgSaveEvt.cpp | 28 +- src/tool/N3ME/DlgSaveNPCPath.cpp | 28 +- src/tool/N3ME/DlgSaveNewTileSet.cpp | 27 +- src/tool/N3ME/DlgSetDTex.cpp | 18 +- src/tool/N3ME/DlgShapeList.cpp | 16 +- src/tool/N3ME/DlgUnusedFiles.cpp | 34 +- src/tool/N3ME/DlgUnusedFiles.h | 4 +- src/tool/N3ME/EventMgr.cpp | 38 +- src/tool/N3ME/EventMgr.h | 8 +- src/tool/N3ME/LightObjMgr.cpp | 6 +- src/tool/N3ME/LightObjMgr.h | 2 +- src/tool/N3ME/LyTerrain.cpp | 465 ++++++------ src/tool/N3ME/LyTerrain.h | 24 +- src/tool/N3ME/MainFrm.cpp | 34 +- src/tool/N3ME/MainFrm.h | 2 +- src/tool/N3ME/MapMng.cpp | 794 ++++++++------------- src/tool/N3ME/MapMng.h | 28 +- src/tool/N3ME/N3MEDoc.cpp | 8 +- src/tool/N3ME/NPCPathMgr.cpp | 35 +- src/tool/N3ME/NPCPathMgr.h | 6 +- src/tool/N3ME/PondMesh.cpp | 61 +- src/tool/N3ME/PondMesh.h | 2 +- src/tool/N3ME/PondMng.cpp | 2 +- src/tool/N3ME/RegenUser.cpp | 50 +- src/tool/N3ME/RegenUser.h | 4 +- src/tool/N3ME/RiverMesh.cpp | 59 +- src/tool/N3ME/RiverMesh.h | 4 +- src/tool/N3ME/RiverMng.cpp | 218 +++--- src/tool/N3ME/RiverMng2.cpp | 33 +- src/tool/N3ME/WallMgr.cpp | 3 +- src/tool/N3TexViewer/MainFrm.cpp | 228 +++--- src/tool/N3TexViewer/MainFrm.h | 2 +- src/tool/N3TexViewer/N3TexViewerDoc.cpp | 131 ++-- src/tool/N3TexViewer/N3TexViewerDoc.h | 7 +- src/tool/N3Viewer/MainFrm.cpp | 11 +- src/tool/N3Viewer/N3ViewerDoc.cpp | 86 +-- src/tool/N3Viewer/ViewProperty.cpp | 113 ++- src/tool/N3Viewer/ViewSceneTree.cpp | 4 +- src/tool/Option/OptionDlg.cpp | 117 +-- src/tool/Option/OptionDlg.h | 10 +- src/tool/PlugIn_Max/DllEntry.cpp | 2 + src/tool/PlugIn_Max/N3DExp.cpp | 258 +++---- src/tool/PlugIn_Max/N3DExp.h | 10 +- src/tool/PlugIn_Maya/N3E2Translator.cpp | 35 +- src/tool/PlugIn_Maya/N3E2Wrapper.cpp | 282 +++----- src/tool/PlugIn_Maya/N3E2Wrapper.h | 8 +- src/tool/PlugIn_Maya/iffreader.cpp | 2 + src/tool/RscTables/RscTablesDlg.cpp | 187 ++--- src/tool/RscTables/RscTablesDlg.h | 2 +- src/tool/RscTables/TableGenerator.cpp | 126 ++-- src/tool/RscTables/TableGenerator.h | 22 +- src/tool/ServerInfoViewer/MainFrm.cpp | 2 +- src/tool/SkyViewer/FormViewProperty.cpp | 29 +- src/tool/SkyViewer/MainFrm.cpp | 14 +- src/tool/UIE/DlgBar.cpp | 8 +- src/tool/UIE/DlgChangeImage.cpp | 35 +- src/tool/UIE/DlgChangeImage.h | 4 +- src/tool/UIE/DlgTexture.cpp | 6 +- src/tool/UIE/DlgTexture.h | 4 +- src/tool/UIE/DlgUnusedFileList.cpp | 26 +- src/tool/UIE/DlgUnusedFileList.h | 2 +- src/tool/UIE/MainFrm.cpp | 16 +- src/tool/UIE/MainFrm.h | 2 +- src/tool/UIE/PropertyView.cpp | 50 +- src/tool/UIE/TexViewer.cpp | 4 +- src/tool/UIE/TexViewer.h | 8 +- src/tool/UIE/UIE.cpp | 18 +- src/tool/UIE/UIE.h | 2 +- src/tool/UIE/UIEDoc.cpp | 180 +++-- src/tool/UIE/UIEView.cpp | 18 +- src/tool/Widget/PropertyList.cpp | 45 +- 319 files changed, 5460 insertions(+), 7531 deletions(-) delete mode 100644 src/engine/N3Base/AVIPlayer.cpp delete mode 100644 src/engine/N3Base/AVIPlayer.h diff --git a/src/engine/N3Base/AVIPlayer.cpp b/src/engine/N3Base/AVIPlayer.cpp deleted file mode 100644 index 3c425d0c..00000000 --- a/src/engine/N3Base/AVIPlayer.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// AVIPlayer.cpp: implementation of the CAVIPlayer class. -// -////////////////////////////////////////////////////////////////////// - -#include "StdAfx.h" -#include "AVIPlayer.h" -#include -#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -bool CAVIPlayer::m_bInterrupted = false; - -CAVIPlayer::CAVIPlayer() { - m_pGraphBuilder = NULL; - m_pMediaControl = NULL; - m_pVideoWindow = NULL; - m_pMediaEvent = NULL; - m_hWndMain = NULL; -} - -CAVIPlayer::~CAVIPlayer() {} - -void CAVIPlayer::Release() { - if (m_pGraphBuilder) { - m_pGraphBuilder->Release(), m_pGraphBuilder = NULL; - } - if (m_pMediaControl) { - m_pMediaControl->Release(), m_pMediaControl = NULL; - } - if (m_pVideoWindow) { - m_pVideoWindow->Release(), m_pVideoWindow = NULL; - } - if (m_pMediaEvent) { - m_pMediaEvent->Release(), m_pMediaEvent = NULL; - } - - DestroyWindow(m_hWndMain); - m_hWndMain = NULL; -} - -bool CAVIPlayer::InitInterfaces() { - if (FAILED( - CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&m_pGraphBuilder))) { - return false; - } - - // Get interfaces to control playback & screensize - if (FAILED(m_pGraphBuilder->QueryInterface(IID_IMediaControl, (void **)&m_pMediaControl))) { - return false; - } - if (FAILED(m_pGraphBuilder->QueryInterface(IID_IVideoWindow, (void **)&m_pVideoWindow))) { - return false; - } - // Get interface to allow the app to wait for completion of playback - if (FAILED(m_pGraphBuilder->QueryInterface(IID_IMediaEventEx, (void **)&m_pMediaEvent))) { - return false; - } - - return true; -} - -bool CAVIPlayer::PlayCutScene(LPTSTR pszMovie, HINSTANCE hInstance) { - if (!CreateHiddenWindow(hInstance, pszMovie)) { - return false; - } - - HRESULT hr; - if (FAILED(hr = CoInitialize(NULL))) { - return false; - } - - if (!InitInterfaces()) { - CoUninitialize(); - return false; - } - - // Play the movie / cutscene - USES_CONVERSION; - WCHAR wFileName[MAX_PATH]; - wcscpy(wFileName, T2W(pszMovie)); - if (S_OK != m_pGraphBuilder->RenderFile(wFileName, NULL)) { - return false; - } - m_pVideoWindow->put_MessageDrain((OAHWND)m_hWndMain); - - // Set Full screen mode - LONG lMode; - m_pVideoWindow->get_FullScreenMode(&lMode); - static HWND hDrain = 0; - if (lMode == 0) { - m_pVideoWindow->get_MessageDrain((OAHWND *)&hDrain); - m_pVideoWindow->put_MessageDrain((OAHWND)m_hWndMain); - lMode = -1; // OATRUE - m_pVideoWindow->put_FullScreenMode(lMode); - } - - // - m_pMediaControl->Pause(); - m_pMediaControl->Run(); - - // - BOOL bSleep = TRUE; - while (1) { - MSG msg; - long lEventCode, lParam1, lParam2; - - // Reset sleep flag - bSleep = TRUE; - - if (m_bInterrupted) { - m_pMediaControl->Stop(); - bSleep = FALSE; - break; - } - - // Has there been a media event? Look for end of stream condition. - if (E_ABORT != m_pMediaEvent->GetEvent(&lEventCode, (LONG_PTR *)&lParam1, (LONG_PTR *)&lParam2, 0)) { - // Free the media event resources. - m_pMediaEvent->FreeEventParams(lEventCode, lParam1, lParam2); - - // Is this the end of the movie? - if (lEventCode == EC_COMPLETE) { - bSleep = FALSE; - break; - } - } - - // Give system threads time to run (and don't sample user input madly) - if (bSleep) { - Sleep(100); - } - - // Check and process window messages (like our keystrokes) - while (PeekMessage(&msg, m_hWndMain, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - // Release DirectShow interfaces - Release(); - CoUninitialize(); - - return true; -} - -LONG WINAPI CAVIPlayer::WindowProc_Player(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) { - // Monitor keystrokes for manipulating video window - // and program options - case WM_KEYDOWN: - switch (wParam) { - case VK_ESCAPE: - case VK_SPACE: - case VK_RETURN: - CAVIPlayer::m_bInterrupted = true; - break; - } - break; - case WM_LBUTTONDOWN: - CAVIPlayer::m_bInterrupted = true; - break; - } - - return (LONG)DefWindowProc(hWnd, message, wParam, lParam); -} - -BOOL CAVIPlayer::CreateHiddenWindow(HINSTANCE hInstance, LPTSTR szFile) { - TCHAR szTitle[MAX_PATH]; - - // Set up and register window class - WNDCLASS wc = {0}; - wc.lpfnWndProc = (WNDPROC)WindowProc_Player; - wc.hInstance = hInstance; - wc.lpszClassName = "AVI"; - if (!RegisterClass(&wc)) { - return FALSE; - } - - wsprintf(szTitle, TEXT("%s: %s"), "CutScene", szFile); - - // Create a window of zero size that will serve as the sink for - // keyboard input. If this media file has a video component, then - // a second ActiveMovie window will be displayed in which the video - // will be rendered. Setting keyboard focus on this application window - // will allow the user to move the video window around the screen, make - // it full screen, resize, center, etc. independent of the application - // window. If the media file has only an audio component, then this will - // be the only window created. - m_hWndMain = CreateWindowEx(0, "AVI", szTitle, - 0, // not visible - 0, 0, 0, 0, NULL, NULL, hInstance, NULL); - - return (m_hWndMain != NULL); -} diff --git a/src/engine/N3Base/AVIPlayer.h b/src/engine/N3Base/AVIPlayer.h deleted file mode 100644 index 1c51570e..00000000 --- a/src/engine/N3Base/AVIPlayer.h +++ /dev/null @@ -1,29 +0,0 @@ -// AVIPlayer.h: interface for the CAVIPlayer class. -// -////////////////////////////////////////////////////////////////////// - -#pragma once - -#include - -class CAVIPlayer { - public: - CAVIPlayer(); - virtual ~CAVIPlayer(); - - public: - bool PlayCutScene(LPTSTR pszMovie, HINSTANCE hInstance); - static LONG WINAPI WindowProc_Player(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - static bool m_bInterrupted; - - protected: - HWND m_hWndMain; - IGraphBuilder * m_pGraphBuilder; - IMediaControl * m_pMediaControl; - IVideoWindow * m_pVideoWindow; - IMediaEvent * m_pMediaEvent; - - BOOL CreateHiddenWindow(HINSTANCE hInstance, LPTSTR szFile); - bool InitInterfaces(); - void Release(); -}; diff --git a/src/engine/N3Base/BitMapFile.cpp b/src/engine/N3Base/BitMapFile.cpp index 335b5ec0..225bd99f 100644 --- a/src/engine/N3Base/BitMapFile.cpp +++ b/src/engine/N3Base/BitMapFile.cpp @@ -103,8 +103,8 @@ bool CBitMapFile::Save(HANDLE hFile) { return true; } -bool CBitMapFile::SaveRectToFile(const std::string & szFN, RECT rc) { - if (szFN.empty()) { +bool CBitMapFile::SaveRectToFile(const fs::path & fsFile, RECT rc) { + if (fsFile.empty()) { return false; } @@ -136,7 +136,7 @@ bool CBitMapFile::SaveRectToFile(const std::string & szFN, RECT rc) { } DWORD dwRWC = 0; - HANDLE hFile = ::CreateFile(szFN.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = ::CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); // 쓰기 모드로 파일 열기 if (INVALID_HANDLE_VALUE == hFile) { @@ -179,13 +179,13 @@ bool CBitMapFile::SaveRectToFile(const std::string & szFN, RECT rc) { return true; } -bool CBitMapFile::LoadFromFile(const char * pszFN) { - if (NULL == pszFN || lstrlen(pszFN) <= 0) { +bool CBitMapFile::LoadFromFile(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } DWORD dwRWC = 0; - HANDLE hFile = ::CreateFile(pszFN, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = ::CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { return false; @@ -198,13 +198,13 @@ bool CBitMapFile::LoadFromFile(const char * pszFN) { return bSuccess; } -bool CBitMapFile::SaveToFile(const char * pszFN) { - if (NULL == pszFN || lstrlen(pszFN) <= 0) { +bool CBitMapFile::SaveToFile(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } DWORD dwRWC = 0; - HANDLE hFile = ::CreateFile(pszFN, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = ::CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return false; diff --git a/src/engine/N3Base/BitMapFile.h b/src/engine/N3Base/BitMapFile.h index c862ed1a..e11ddcc9 100644 --- a/src/engine/N3Base/BitMapFile.h +++ b/src/engine/N3Base/BitMapFile.h @@ -13,14 +13,14 @@ class CBitMapFile { void * m_pPixels; // 실제 픽셀 데이터 int Pitch() { return ((int)((m_bmInfoHeader.biWidth * 3 + 3) / 4)) * 4; } // 비트맵의 실제 너비(byte 단위).. bool Create(int nWidth, int nHeight, int nBPP = 24); - bool SaveRectToFile(const std::string & szFN, RECT rc); + bool SaveRectToFile(const fs::path & fsFile, RECT rc); void * Pixels(int x = 0, int y = 0); BITMAPINFOHEADER * GetBitmapInfoHeader() { return &m_bmInfoHeader; } BITMAPFILEHEADER * GetBitmapFileHeader() { return &m_bmfHeader; } bool Load(HANDLE hFile); bool Save(HANDLE hFile); - bool LoadFromFile(const char * pszFN); - bool SaveToFile(const char * pszFN); + bool LoadFromFile(const fs::path & fsFile); + bool SaveToFile(const fs::path & fsFile); int Width() { return m_bmInfoHeader.biWidth; } int Height() { return m_bmInfoHeader.biHeight; } diff --git a/src/engine/N3Base/Jpeg.cpp b/src/engine/N3Base/Jpeg.cpp index 9cb4126d..2f0d3db3 100644 --- a/src/engine/N3Base/Jpeg.cpp +++ b/src/engine/N3Base/Jpeg.cpp @@ -38,9 +38,9 @@ CJpeg::~CJpeg() { } } -void CJpeg::LoadJPG(LPCSTR FileName) { +void CJpeg::LoadJPG(const fs::path & fsFile) { // File Open & Load Entire Contents // - HFILE hFile = _lopen(FileName, OF_READWRITE); + HFILE hFile = _wopen(fsFile.c_str(), OF_READWRITE); int FileSize = GetFileSize((HANDLE)hFile, NULL); m_pBuf = new BYTE[FileSize]; _lread(hFile, m_pBuf, FileSize); @@ -647,7 +647,7 @@ void CJpeg::ConvertYUV2RGB() { delete[] pLine; } -void CJpeg::SaveJPG(LPCSTR FileName, int Width, int Height, BYTE * pp) { +void CJpeg::SaveJPG(const fs::path & fsFile, int Width, int Height, BYTE * pp) { m_rWidth = Width; m_rHeight = Height; @@ -672,7 +672,8 @@ void CJpeg::SaveJPG(LPCSTR FileName, int Width, int Height, BYTE * pp) { } DWORD dwWritten; - HANDLE fh = CreateFile(FileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE fh = + CreateFileW(fsFile.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fh == INVALID_HANDLE_VALUE) { return; } diff --git a/src/engine/N3Base/Jpeg.h b/src/engine/N3Base/Jpeg.h index 1101ee0d..cbe398bf 100644 --- a/src/engine/N3Base/Jpeg.h +++ b/src/engine/N3Base/Jpeg.h @@ -55,30 +55,30 @@ struct SCANHEADER { class CJpeg { public: // JPEG File을 Load하기 위한 함수들 // - void LoadJPG(LPCSTR FileName); // JPEG File을 Load하는 함수 - void FindSOI(); // Start of Image 마커를 찾는 함수 - void FindDQT(); // Quantization Table을 찾아 구조체에 설정하는 함수 - void FindDHT(); // Huffman Table을 찾아 구조체에 설정하는 함수 - void FindSOF(); // Frame Header를 찾아 구조체에 설정하는 함수 - void FindSOS(); // Scan Header를 찾아 구조체에 설정하는 함수 - void FindETC(); // DRI(Define Restart Interval) 로드 - void Decode(); // 디코드를 위한 정보를 설정하고 디코드를 시작 - void DecodeMCU(int mx, int my); // MCU블럭을 디코드하는 함수 - void DecodeDU(int N); // 8x8 Data Unit를 디코드하는 함수 - void IDCT(); // Inverse DCT를 하는 함수 - void Zigzag(); // Zigzag순으로 되어있는 DU를 원상복귀시키는 함수 - void DecodeAC(int Th); // DU중, AC성분을 디코드하는 함수 - void DecodeDC(int Th); // DU중, DC성분을 디코드하는 함수 - short Extend(WORD V, BYTE T); // V를 카테고리 T에 맞도록 확장 - WORD Receive(BYTE SSSS); // 버퍼에서 SSSS비트만큼 읽어오는 함수 - BYTE hDecode(int Th); // 허프만 부호를 디코드하는 부분 - BYTE NextByte(); // 버퍼에서 다음 1 바이트를 읽어오는 함수 - WORD NextBit(); // 버퍼에서 다음 1 비트를 읽어오는 함수 - void ConvertYUV2RGB(); // 디코드된 데이터를 컬러모델을 바꿈과 동시에 - // 비트맵에 호환되도록 변환하는 함수 + void LoadJPG(const fs::path & fsFile); // JPEG File을 Load하는 함수 + void FindSOI(); // Start of Image 마커를 찾는 함수 + void FindDQT(); // Quantization Table을 찾아 구조체에 설정하는 함수 + void FindDHT(); // Huffman Table을 찾아 구조체에 설정하는 함수 + void FindSOF(); // Frame Header를 찾아 구조체에 설정하는 함수 + void FindSOS(); // Scan Header를 찾아 구조체에 설정하는 함수 + void FindETC(); // DRI(Define Restart Interval) 로드 + void Decode(); // 디코드를 위한 정보를 설정하고 디코드를 시작 + void DecodeMCU(int mx, int my); // MCU블럭을 디코드하는 함수 + void DecodeDU(int N); // 8x8 Data Unit를 디코드하는 함수 + void IDCT(); // Inverse DCT를 하는 함수 + void Zigzag(); // Zigzag순으로 되어있는 DU를 원상복귀시키는 함수 + void DecodeAC(int Th); // DU중, AC성분을 디코드하는 함수 + void DecodeDC(int Th); // DU중, DC성분을 디코드하는 함수 + short Extend(WORD V, BYTE T); // V를 카테고리 T에 맞도록 확장 + WORD Receive(BYTE SSSS); // 버퍼에서 SSSS비트만큼 읽어오는 함수 + BYTE hDecode(int Th); // 허프만 부호를 디코드하는 부분 + BYTE NextByte(); // 버퍼에서 다음 1 바이트를 읽어오는 함수 + WORD NextBit(); // 버퍼에서 다음 1 비트를 읽어오는 함수 + void ConvertYUV2RGB(); // 디코드된 데이터를 컬러모델을 바꿈과 동시에 + // 비트맵에 호환되도록 변환하는 함수 // JPEG File을 Save하기 위한 함수들 // - void SaveJPG(LPCSTR FileName, int Width, int Height, BYTE * pp); // JPEG 파일을 저장하는 함수 + void SaveJPG(const fs::path & fsFile, int Width, int Height, BYTE * pp); // JPEG 파일을 저장하는 함수 void PutSOI(HANDLE hFile); // Start of Image 마커를 삽입 void PutDQT(HANDLE hFile); // Quantizatino Table을 삽입 diff --git a/src/engine/N3Base/JpegFile.cpp b/src/engine/N3Base/JpegFile.cpp index 324b003e..8b78a924 100644 --- a/src/engine/N3Base/JpegFile.cpp +++ b/src/engine/N3Base/JpegFile.cpp @@ -88,7 +88,7 @@ CJpegFile::~CJpegFile() {} // read a JPEG file // -BYTE * CJpegFile::JpegFileToRGB(std::string fileName, UINT * width, UINT * height) +BYTE * CJpegFile::JpegFileToRGB(const fs::path & fsFile, UINT * width, UINT * height) { // get our buffer set to hold data @@ -113,7 +113,6 @@ BYTE * CJpegFile::JpegFileToRGB(std::string fileName, UINT * width, UINT * heigh JSAMPARRAY buffer; /* Output row buffer */ int row_stride; /* physical row width in output buffer */ - char buf[250]; /* In this example we want to open the input file before doing anything else, * so that the setjmp() error recovery below can assume the file is open. @@ -121,9 +120,8 @@ BYTE * CJpegFile::JpegFileToRGB(std::string fileName, UINT * width, UINT * heigh * requires it in order to read binary files. */ - if ((infile = fopen(fileName.c_str(), "rb")) == NULL) { - sprintf(buf, "JPEG :\nCan't open %s\n", fileName.c_str()); - // AfxMessageBox(buf); + if ((infile = _wfopen(fsFile.c_str(), L"rb")) == NULL) { + //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile.string()).c_str()); return NULL; } @@ -261,7 +259,7 @@ BYTE * CJpegFile::JpegFileToRGB(std::string fileName, UINT * width, UINT * heigh return dataBuf; } -BOOL CJpegFile::GetJPGDimensions(std::string fileName, UINT * width, UINT * height) +BOOL CJpegFile::GetJPGDimensions(const fs::path & fsFile, UINT * width, UINT * height) { // basic code from IJG Jpeg Code v6 example.c @@ -277,7 +275,6 @@ BOOL CJpegFile::GetJPGDimensions(std::string fileName, UINT * width, UINT * heig struct my_error_mgr jerr; /* More stuff */ FILE * infile = NULL; /* source file */ - char buf[250]; /* In this example we want to open the input file before doing anything else, * so that the setjmp() error recovery below can assume the file is open. @@ -285,9 +282,8 @@ BOOL CJpegFile::GetJPGDimensions(std::string fileName, UINT * width, UINT * heig * requires it in order to read binary files. */ - if ((infile = fopen(fileName.c_str(), "rb")) == NULL) { - sprintf(buf, "JPEG :\nCan't open %s\n", fileName.c_str()); - // AfxMessageBox(buf); + if ((infile = _wfopen(fsFile.c_str(), L"rb")) == NULL) { + //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile.string()).c_str()); return FALSE; } @@ -378,7 +374,7 @@ BYTE * CJpegFile::RGBFromDWORDAligned(BYTE * inBuf, UINT widthPix, UINT widthByt // // -BOOL CJpegFile::RGBToJpegFile(std::string fileName, BYTE * dataBuf, UINT widthPix, UINT height, BOOL color, +BOOL CJpegFile::RGBToJpegFile(const fs::path & fsFile, BYTE * dataBuf, UINT widthPix, UINT height, BOOL color, int quality) { if (dataBuf == NULL) { return FALSE; @@ -450,10 +446,8 @@ BOOL CJpegFile::RGBToJpegFile(std::string fileName, BYTE * dataBuf, UINT widthPi /* Step 2: specify data destination (eg, a file) */ /* Note: steps 2 and 3 can be done in either order. */ - if ((outfile = fopen(fileName.c_str(), "wb")) == NULL) { - char buf[250]; - sprintf(buf, "JpegFile :\nCan't open %s\n", fileName.c_str()); - // AfxMessageBox(buf); + if ((outfile = _wfopen(fsFile.c_str(), L"wb")) == NULL) { + //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile.string()).c_str()); return FALSE; } @@ -1275,7 +1269,7 @@ DWORD PASCAL CJpegFile::MyWrite(int iFileHandle, VOID FAR * lpBuffer, DWORD dwBy return dwBytesTmp; } -WORD FAR CJpegFile::SaveDIB(HDIB hDib, LPSTR lpFileName) { +WORD FAR CJpegFile::SaveDIB(HDIB hDib, const fs::path & fsFile) { BITMAPFILEHEADER bmfHdr; // Header for Bitmap file LPBITMAPINFOHEADER lpBI; // Pointer to DIB info structure HANDLE fh; // file handle for opened file @@ -1286,7 +1280,7 @@ WORD FAR CJpegFile::SaveDIB(HDIB hDib, LPSTR lpFileName) { if (!hDib) { return ERR_INVALIDHANDLE; } - fh = CreateFile(lpFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fh = CreateFileW(fsFile.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fh == INVALID_HANDLE_VALUE) { return ERR_OPEN; } @@ -1609,13 +1603,13 @@ BOOL CJpegFile::DibToSamps(HANDLE hDib, int nSampsPerRow, struct jpeg_compress_s return TRUE; } -BOOL CJpegFile::JpegFromDib(HANDLE hDib, //Handle to DIB - int nQuality, //JPEG quality (0-100) - std::string csJpeg, //Pathname to jpeg file - std::string & szErrMsg) //Error msg to return +BOOL CJpegFile::JpegFromDib(HANDLE hDib, // Handle to DIB + int nQuality, // JPEG quality (0-100) + const fs::path & fsJpegFile, // Path to jpeg file + std::string & szErrMsg) // Error msg to return { //Basic sanity checks... - if (nQuality < 0 || nQuality > 100 || hDib == NULL || csJpeg == "") { + if (nQuality < 0 || nQuality > 100 || hDib == NULL || fsJpegFile.empty()) { szErrMsg = "Invalid input data"; return FALSE; } @@ -1637,7 +1631,7 @@ BOOL CJpegFile::JpegFromDib(HANDLE hDib, //Handle to DIB jpeg_create_compress(&cinfo); - if ((pOutFile = fopen(csJpeg.c_str(), "wb")) == NULL) { + if ((pOutFile = _wfopen(fsJpegFile.c_str(), L"wb")) == NULL) { szErrMsg = "Cannot open Fail"; jpeg_destroy_compress(&cinfo); GlobalUnlock(hDib); @@ -1686,12 +1680,12 @@ BOOL CJpegFile::JpegFromDib(HANDLE hDib, //Handle to DIB } } -BOOL CJpegFile::EncryptJPEG(HANDLE hDib, //Handle to DIB - int nQuality, //JPEG quality (0-100) - std::string csJpeg, //Pathname to jpeg file - std::string & szErrMsg) //Error msg to return +BOOL CJpegFile::EncryptJPEG(HANDLE hDib, // Handle to DIB + int nQuality, // JPEG quality (0-100) + const fs::path & fsJpegFile, // Path to jpeg file + std::string & szErrMsg) // Error msg to return { - if (JpegFromDib(hDib, nQuality, csJpeg, szErrMsg) == FALSE) { + if (JpegFromDib(hDib, nQuality, fsJpegFile, szErrMsg) == FALSE) { return FALSE; } @@ -1701,7 +1695,7 @@ BOOL CJpegFile::EncryptJPEG(HANDLE hDib, //Handle to DIB DWORD encrypt_len; // JPEG 파일 읽어오기 - fh = CreateFile(csJpeg.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + fh = CreateFileW(fsJpegFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (fh == INVALID_HANDLE_VALUE) { return false; } @@ -1735,7 +1729,7 @@ BOOL CJpegFile::EncryptJPEG(HANDLE hDib, //Handle to DIB } // Encoding 파일 Writing - fh = CreateFile(csJpeg.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fh = CreateFileW(fsJpegFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fh == INVALID_HANDLE_VALUE) { delete[] data_byte; return FALSE; @@ -1750,48 +1744,33 @@ BOOL CJpegFile::EncryptJPEG(HANDLE hDib, //Handle to DIB return TRUE; } -BOOL CJpegFile::DecryptJPEG(std::string csJpeg) { - char szTempName[MAX_PATH]{}; - std::string szDstpath; - HANDLE hSrc, hDst; - BYTE * dst_data, *src_data; - DWORD dst_len, src_len, src_hlen; - DWORD result_len; - - int rfv = csJpeg.rfind('\\'); - szDstpath = csJpeg; - szDstpath.resize(rfv); - if (szDstpath.size() == 2) { - szDstpath += _T('\\'); - } - - if (GetTempFileName((LPCTSTR)szDstpath.c_str(), "ksc", 0, szTempName) == 0) { - // AfxMessageBox("임시 파일을 생성할 수가 없습니다.", MB_ICONSTOP|MB_OK); - return FALSE; - } - - hSrc = CreateFile((LPCTSTR)csJpeg.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +BOOL CJpegFile::DecryptJPEG(const fs::path & fsJpegFile) { + HANDLE hSrc = CreateFileW(fsJpegFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hSrc == INVALID_HANDLE_VALUE) { // AfxMessageBox("소스 파일이 존재하지 않습니다. 다른 파일을 선택해주세요.", MB_ICONSTOP|MB_OK); return FALSE; } - hDst = CreateFile((LPCTSTR)szTempName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fs::path fsTmpFile = fs::mktemp_file("ksc"); + HANDLE hDst = CreateFileW(fsTmpFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hDst == INVALID_HANDLE_VALUE) { CloseHandle(hSrc); return FALSE; } - src_len = GetFileSize(hSrc, &src_hlen); + DWORD src_hlen; + DWORD src_len = GetFileSize(hSrc, &src_hlen); if (src_hlen > 0) { CloseHandle(hSrc); CloseHandle(hDst); + return FALSE; } - dst_len = src_len - 8; + DWORD dst_len = src_len - 8; - src_data = new BYTE[src_len]; - dst_data = new BYTE[dst_len]; + BYTE * src_data = new BYTE[src_len]; + BYTE * dst_data = new BYTE[dst_len]; + DWORD result_len; ReadFile(hSrc, (LPVOID)src_data, src_len, &result_len, NULL); m_r = 1124; @@ -1826,39 +1805,37 @@ BOOL CJpegFile::DecryptJPEG(std::string csJpeg) { delete[] dst_data; delete[] src_data; - LoadJpegFile(szTempName); - DeleteFile((LPCTSTR)szTempName); + LoadJpegFile(fsTmpFile); + fs::remove(fsTmpFile); return TRUE; } -BOOL CJpegFile::SaveFromDecryptToJpeg(std::string csKsc, std::string csJpeg) { - HANDLE hSrc, hDst; - BYTE * dst_data, *src_data; - DWORD dst_len, src_len, src_hlen; - DWORD result_len; - - hSrc = CreateFile((LPCTSTR)csKsc.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +BOOL CJpegFile::SaveFromDecryptToJpeg(const fs::path & fsKscFile, const fs::path & fsJpegFile) { + HANDLE hSrc = CreateFileW(fsKscFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hSrc == INVALID_HANDLE_VALUE) { return FALSE; } - hDst = CreateFile((LPCTSTR)csJpeg.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hDst = CreateFileW(fsJpegFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hDst == INVALID_HANDLE_VALUE) { CloseHandle(hSrc); return FALSE; } - src_len = GetFileSize(hSrc, &src_hlen); + DWORD src_hlen; + DWORD src_len = GetFileSize(hSrc, &src_hlen); if (src_hlen > 0) { CloseHandle(hSrc); CloseHandle(hDst); + return FALSE; } - dst_len = src_len - 8; + DWORD dst_len = src_len - 8; - src_data = new BYTE[src_len]; - dst_data = new BYTE[dst_len]; + BYTE * src_data = new BYTE[src_len]; + BYTE * dst_data = new BYTE[dst_len]; + DWORD result_len; ReadFile(hSrc, (LPVOID)src_data, src_len, &result_len, NULL); m_r = 1124; diff --git a/src/engine/N3Base/JpegFile.h b/src/engine/N3Base/JpegFile.h index 7500bd91..aa7dcb87 100644 --- a/src/engine/N3Base/JpegFile.h +++ b/src/engine/N3Base/JpegFile.h @@ -204,27 +204,27 @@ class CJpegFile { // BYTE *buf = JpegFile::JpegFileToRGB(....); // delete [] buf; - BYTE * JpegFileToRGB(std::string fileName, // path to image - UINT * width, // image width in pixels - UINT * height); // image height + BYTE * JpegFileToRGB(const fs::path & fsFile, // path to image + UINT * width, // image width in pixels + UINT * height); // image height //////////////////////////////////////////////////////////////// // write a JPEG file from a 3-component, 1-byte per component buffer - BOOL RGBToJpegFile(std::string fileName, // path - BYTE * dataBuf, // RGB buffer - UINT width, // pixels - UINT height, // rows - BOOL color, // TRUE = RGB - // FALSE = Grayscale - int quality); // 0 - 100 + BOOL RGBToJpegFile(const fs::path & fsFile, // path + BYTE * dataBuf, // RGB buffer + UINT width, // pixels + UINT height, // rows + BOOL color, // TRUE = RGB + // FALSE = Grayscale + int quality); // 0 - 100 //////////////////////////////////////////////////////////////// // fetch width / height of an image - BOOL GetJPGDimensions(std::string fileName, // path - UINT * width, // pixels - UINT * height); + BOOL GetJPGDimensions(const fs::path & fsFile, // path + UINT * width, // pixels + UINT * height); //////////////////////////////////////////////////////////////// // utility functions @@ -290,22 +290,22 @@ class CJpegFile { HDIB FAR ChangeBitmapFormat(HBITMAP hBitmap, WORD wBitCount, DWORD wCompression, HPALETTE hPal); DWORD PASCAL MyWrite(int iFileHandle, VOID FAR * lpBuffer, DWORD dwBytes); HPALETTE FAR GetSystemPalette(void); - WORD FAR SaveDIB(HDIB hDib, LPSTR lpFileName); + WORD FAR SaveDIB(HDIB hDib, const fs::path & fsFile); RGBQUAD QuadFromWord(WORD b16); BOOL DibToSamps(HANDLE hDib, int nSampsPerRow, struct jpeg_compress_struct cinfo, JSAMPARRAY jsmpPixels, std::string & szErrMsg); - BOOL JpegFromDib(HANDLE hDib, //Handle to DIB - int nQuality, //JPEG quality (0-100) - std::string csJpeg, //Pathname to jpeg file - std::string & szErrMsg); //Error msg to return - virtual BOOL EncryptJPEG(HANDLE hDib, //Handle to DIB - int nQuality, //JPEG quality (0-100) - std::string csJpeg, //Pathname to jpeg file - std::string & szErrMsg); //Error msg to return - - BOOL SaveFromDecryptToJpeg(std::string csKsc, std::string csJpeg); - virtual BOOL DecryptJPEG(std::string csJpeg); - virtual BOOL LoadJpegFile(std::string csJpeg) { return TRUE; } + BOOL JpegFromDib(HANDLE hDib, // Handle to DIB + int nQuality, // JPEG quality (0-100) + const fs::path & fsJpegFile, // Path to jpeg file + std::string & szErrMsg); // Error msg to return + virtual BOOL EncryptJPEG(HANDLE hDib, // Handle to DIB + int nQuality, // JPEG quality (0-100) + const fs::path & fsJpegFile, // Path to jpeg file + std::string & szErrMsg); // Error msg to return + + BOOL SaveFromDecryptToJpeg(const fs::path & fsKscFile, const fs::path & fsJpegFile); + virtual BOOL DecryptJPEG(const fs::path & fsJpegFile); + virtual BOOL LoadJpegFile(const fs::path & fsJpegFile) { return TRUE; } virtual void DrawImage(HDC hDC) {} diff --git a/src/engine/N3Base/LogWriter.cpp b/src/engine/N3Base/LogWriter.cpp index fcfd4b18..7b8f20e1 100644 --- a/src/engine/N3Base/LogWriter.cpp +++ b/src/engine/N3Base/LogWriter.cpp @@ -10,25 +10,25 @@ // Construction/Destruction ////////////////////////////////////////////////////////////////////// //HANDLE CLogWriter::s_hFile = NULL; -std::string CLogWriter::s_szFileName = ""; +fs::path CLogWriter::s_fsLogFile; CLogWriter::CLogWriter() {} CLogWriter::~CLogWriter() {} -void CLogWriter::Open(const std::string & szFN) { - // if (s_hFile || szFN.empty()) { +void CLogWriter::Open(const fs::path & fsFile) { + // if (s_hFile || fsFile.empty()) { // return; // } - if (szFN.empty()) { + if (fsFile.empty()) { return; } - s_szFileName = szFN; + s_fsLogFile = fsFile; - HANDLE hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { return; } @@ -39,8 +39,8 @@ void CLogWriter::Open(const std::string & szFN) { if (dwSizeLow > 256000) // 파일 사이즈가 너무 크면 지운다.. { CloseHandle(hFile); - ::DeleteFile(s_szFileName.c_str()); - hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fs::remove(s_fsLogFile); + hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { return; } @@ -66,9 +66,9 @@ void CLogWriter::Open(const std::string & szFN) { } void CLogWriter::Close() { - HANDLE hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { hFile = NULL; } @@ -97,7 +97,7 @@ void CLogWriter::Close() { } void CLogWriter::Write(const char * lpszFormat, ...) { - if (s_szFileName.empty() || NULL == lpszFormat) { + if (s_fsLogFile.empty() || NULL == lpszFormat) { return; } @@ -121,9 +121,9 @@ void CLogWriter::Write(const char * lpszFormat, ...) { lstrcat(szFinal, "\r\n"); int iLength = lstrlen(szFinal); - HANDLE hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { hFile = NULL; } diff --git a/src/engine/N3Base/LogWriter.h b/src/engine/N3Base/LogWriter.h index 71b13b63..67fb49dd 100644 --- a/src/engine/N3Base/LogWriter.h +++ b/src/engine/N3Base/LogWriter.h @@ -9,10 +9,10 @@ class CLogWriter { protected: // static HANDLE s_hFile; - static std::string s_szFileName; + static fs::path s_fsLogFile; public: - static void Open(const std::string & szFN); + static void Open(const fs::path & fsFile); static void Close(); static void Write(const char * lpszFormat, ...); diff --git a/src/engine/N3Base/N3AnimControl.h b/src/engine/N3Base/N3AnimControl.h index 5d4c15fa..46a90ebc 100644 --- a/src/engine/N3Base/N3AnimControl.h +++ b/src/engine/N3Base/N3AnimControl.h @@ -92,11 +92,11 @@ typedef struct __AnimData { // 이름 읽기.. szName = ""; + nL = 0; ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - std::vector buffer(nL, 0); - ReadFile(hFile, &buffer[0], nL, &dwRWC, NULL); - szName = std::string(buffer.begin(), buffer.end()); + szName.assign(nL, '\0'); + ReadFile(hFile, szName.data(), nL, &dwRWC, NULL); } } void Save(HANDLE hFile) { @@ -127,7 +127,7 @@ typedef struct __AnimData { WriteFile(hFile, &fFrmStrike1, 4, &dwRWC, NULL); // 이름 읽기.. - nL = szName.size(); + nL = szName.length(); WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { WriteFile(hFile, szName.c_str(), nL, &dwRWC, NULL); diff --git a/src/engine/N3Base/N3AnimatedTexures.cpp b/src/engine/N3Base/N3AnimatedTexures.cpp index 77710df7..1671c532 100644 --- a/src/engine/N3Base/N3AnimatedTexures.cpp +++ b/src/engine/N3Base/N3AnimatedTexures.cpp @@ -49,16 +49,15 @@ bool CN3AnimatedTexures::Load(HANDLE hFile) { m_TexRefs.clear(); } - int nL = 0; - char szFN[256] = ""; - m_TexRefs.assign(iTC, NULL); // Texture Pointer Pointer 할당.. - for (int i = 0; i < iTC; i++) // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. - { + int nL = 0; + std::string szFile; + m_TexRefs.assign(iTC, NULL); // Texture Pointer Pointer 할당.. + for (int i = 0; i < iTC; i++) { // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; // 텍스처 파일 이름.. - m_TexRefs[i] = s_MngTex.Get(szFN); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + m_TexRefs[i] = s_MngTex.Get(szFile); } } @@ -75,15 +74,17 @@ bool CN3AnimatedTexures::Save(HANDLE hFile) { int iTC = m_TexRefs.size(); WriteFile(hFile, &iTC, 4, &dwRWC, NULL); - for (int i = 0; i < iTC; i++) // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. - { + int nL = 0; + std::string szFile; + for (int i = 0; i < iTC; i++) { // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. nL = 0; if (m_TexRefs[i]) { - nL = m_TexRefs[i].size(); + szFile = m_TexRefs[i]->FilePathWin().string(); + nL = szFile.length(); } WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - WriteFile(hFile, m_TexRefs[i]->FileName().c_str(), nL, &dwRWC, NULL); // 텍스처 파일 이름.. + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); // 텍스처 파일 이름.. } } diff --git a/src/engine/N3Base/N3Base.cpp b/src/engine/N3Base/N3Base.cpp index 6ee46a42..afbe1d5b 100644 --- a/src/engine/N3Base/N3Base.cpp +++ b/src/engine/N3Base/N3Base.cpp @@ -25,7 +25,7 @@ HWND CN3Base::s_hWndPresent = NULL; // 최근에 Present 한 D3DPRESENT_PARAMETERS CN3Base::s_DevParam; // Device 생성 Present Parameter D3DCAPS9 CN3Base::s_DevCaps; // Device 호환성... -std::string CN3Base::s_szPath; +fs::path CN3Base::s_fsBaseDir; __CameraData CN3Base::s_CameraData; // Camera Data __ResrcInfo CN3Base::s_ResrcInfo; // Rendering Information @@ -60,7 +60,6 @@ CLogWriter g_Log; // 로그 남기기... CN3Base::CN3Base() { m_dwType = OBJ_BASE; // "MESH", "CAMERA", "SCENE", "???" .... 등등등... - m_szName = ""; } CN3Base::~CN3Base() {} @@ -255,18 +254,8 @@ float CN3Base::TimerProcess(TIMER_COMMAND command) { } } -void CN3Base::PathSet(const std::string & szPath) { - s_szPath = szPath; - if (s_szPath.size() <= 0) { - return; - } - - CharLower(&(s_szPath[0])); // 반드시 소문자로 만들어 준다.. - if (s_szPath.size() > 1) { - if (s_szPath[s_szPath.size() - 1] != '\\') { - s_szPath += '\\'; - } - } +void CN3Base::PathSet(const fs::path & fsBaseDir) { + s_fsBaseDir = fsBaseDir.lower().generic_string(); } void CN3Base::RenderLines(const __Vector3 * pvLines, int nCount, D3DCOLOR color) { diff --git a/src/engine/N3Base/N3Base.h b/src/engine/N3Base/N3Base.h index d853145c..7d069cdb 100644 --- a/src/engine/N3Base/N3Base.h +++ b/src/engine/N3Base/N3Base.h @@ -193,8 +193,8 @@ class CN3Base { static CN3Mng s_MngFXPMesh; // FX에서 쓰는 PMesh - 파일은 일반 PMesh를 쓰지만 속은 다르다. static CN3Mng s_MngFXShape; // FX에서 쓰는 Shape - 파일은 일반 shape를 쓰지만 속은 다르다. - protected: - static std::string s_szPath; // 프로그램이 실행된 경로.. + private: + static fs::path s_fsBaseDir; // Application root path (aka working directory) protected: DWORD m_dwType; // "MESH", "CAMERA", "SCENE", "???" .... 등등등... @@ -203,9 +203,9 @@ class CN3Base { std::string m_szName; public: - static float TimeGet(); - static const std::string & PathGet() { return s_szPath; } - static void PathSet(const std::string & szPath); + static float TimeGet(); + static const fs::path & PathGet() { return s_fsBaseDir; } + static void PathSet(const fs::path & fsBaseDir); static void RenderLines(const __Vector3 * pvLines, int nCount, D3DCOLOR color); static void RenderLines(const RECT & rc, D3DCOLOR color); diff --git a/src/engine/N3Base/N3BaseFileAccess.cpp b/src/engine/N3Base/N3BaseFileAccess.cpp index 8d82aef6..ec82eaa8 100644 --- a/src/engine/N3Base/N3BaseFileAccess.cpp +++ b/src/engine/N3Base/N3BaseFileAccess.cpp @@ -11,72 +11,64 @@ CN3BaseFileAccess::CN3BaseFileAccess() { m_dwType |= OBJ_BASE_FILEACCESS; - m_szFileName = ""; - m_iLOD = 0; // 로딩할때 쓸 LOD + m_iLOD = 0; } CN3BaseFileAccess::~CN3BaseFileAccess() {} void CN3BaseFileAccess::Release() { - m_szFileName = ""; - m_iLOD = 0; // 로딩할때 쓸 LOD + m_fsFile = fs::path(); + m_fsFileAbs = fs::path(); + m_iLOD = 0; CN3Base::Release(); } -void CN3BaseFileAccess::FileNameSet(const std::string & szFileName) { - std::string szTmpFN = szFileName; +void CN3BaseFileAccess::ToRelative(fs::path & fsFile) { + fsFile.make_lower().make_relative(CN3Base::PathGet()); +} - if (!szTmpFN.empty()) { - CharLower(&(szTmpFN[0])); // 모두 소문자로 만든다.. - } - int iPos = szTmpFN.find(CN3Base::PathGet()); // 문자열에 Base Path 와 일치하는 이름이 있는지 본다. - if (iPos >= 0) { - m_szFileName = szTmpFN.substr(CN3Base::PathGet().size()); // 경로가 일치하면.. 긴경로는 짤라준다.. +fs::path CN3BaseFileAccess::ToRelative(const fs::path & fsFile) { + fs::path fsFileCopy(fsFile); + ToRelative(fsFileCopy); + return fsFileCopy; +} + +void CN3BaseFileAccess::FilePathSet(const fs::path & fsFile) { + m_fsFile = fsFile.lower().generic_string(); + if (m_fsFile.is_absolute()) { + m_fsFileAbs = m_fsFile; + m_fsFile.make_relative(CN3Base::PathGet()); } else { - m_szFileName = szTmpFN; + m_fsFileAbs = CN3Base::PathGet() / m_fsFile; } } bool CN3BaseFileAccess::Load(HANDLE hFile) { - m_szName = ""; + m_szName.clear(); DWORD dwRWC = 0; - int nL = 0; - ReadFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL > 0) { - std::vector buffer(nL, 0); - ReadFile(hFile, &buffer[0], nL, &dwRWC, NULL); - m_szName = std::string(buffer.begin(), buffer.end()); + int iLen = 0; + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + m_szName.assign(iLen, '\0'); + ReadFile(hFile, m_szName.data(), iLen, &dwRWC, NULL); } return true; } bool CN3BaseFileAccess::LoadFromFile() { - if (m_szFileName.size() <= 0) { + if (FilePathAbs().empty()) { #ifdef _N3GAME CLogWriter::Write("Can't open file (read)"); #endif return false; } - std::string szFullPath; - if (-1 != m_szFileName.find(':') || -1 != m_szFileName.find("\\\\") || - -1 != m_szFileName.find("//")) // 문자열에 ':', '\\', '//' 이 들어 있으면 전체 경로이다.. - { - szFullPath = m_szFileName; - } else { - if (NULL != CN3Base::PathGet().size() > 0) { - szFullPath = CN3Base::PathGet(); - } - szFullPath += m_szFileName; - } - - DWORD dwRWC = 0; - HANDLE hFile = ::CreateFile(szFullPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - + HANDLE hFile = + ::CreateFileW(FilePathAbs().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - std::string szErr = szFullPath + " - Can't open file (read)"; + std::string szErr = FilePathAbs().string() + " - Can't open file (read)"; #ifdef _N3TOOL MessageBox(::GetActiveWindow(), szErr.c_str(), "File Handle error", MB_OK); #endif @@ -86,61 +78,45 @@ bool CN3BaseFileAccess::LoadFromFile() { return false; } - bool bSuccess = this->Load(hFile); - + bool bSuccess = Load(hFile); CloseHandle(hFile); - return bSuccess; } -bool CN3BaseFileAccess::LoadFromFile(const std::string & szFileName) { - this->FileNameSet(szFileName); - return this->LoadFromFile(); +bool CN3BaseFileAccess::LoadFromFile(const fs::path & fsFile) { + FilePathSet(fsFile); + return LoadFromFile(); } bool CN3BaseFileAccess::SaveToFile() { - if (m_szFileName.size() <= 0) { + if (FilePathAbs().empty()) { std::string szErr = m_szName + " Can't open file (write) - NULL String"; MessageBox(::GetActiveWindow(), szErr.c_str(), "File Open Error", MB_OK); return false; } - std::string szFullPath; - if (-1 != m_szFileName.find(':') || -1 != m_szFileName.find("\\\\") || - -1 != m_szFileName.find("//")) // 문자열에 ':', '\\', '//' 이 들어 있으면 전체 경로이다.. - { - szFullPath = m_szFileName; - } else { - if (CN3Base::PathGet().size() > 0) { - szFullPath = CN3Base::PathGet(); - } - szFullPath += m_szFileName; - } - - DWORD dwRWC = 0; - HANDLE hFile = ::CreateFile(szFullPath.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - + HANDLE hFile = + ::CreateFileW(FilePathAbs().c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - std::string szErr = szFullPath + " - Can't open file(write)"; + std::string szErr = FilePathAbs().string() + " - Can't open file(write)"; MessageBox(::GetActiveWindow(), szErr.c_str(), "File Handle error", MB_OK); return false; } - this->Save(hFile); - + bool bSuccess = Save(hFile); CloseHandle(hFile); - return true; + return bSuccess; } -bool CN3BaseFileAccess::SaveToFile(const std::string & szFileName) { - this->FileNameSet(szFileName); - return this->SaveToFile(); +bool CN3BaseFileAccess::SaveToFile(const fs::path & fsFile) { + FilePathSet(fsFile); + return SaveToFile(); } bool CN3BaseFileAccess::Save(HANDLE hFile) { DWORD dwRWC = 0; - int nL = m_szName.size(); + int nL = m_szName.length(); WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { WriteFile(hFile, m_szName.c_str(), nL, &dwRWC, NULL); diff --git a/src/engine/N3Base/N3BaseFileAccess.h b/src/engine/N3Base/N3BaseFileAccess.h index a44333f6..fdb03267 100644 --- a/src/engine/N3Base/N3BaseFileAccess.h +++ b/src/engine/N3Base/N3BaseFileAccess.h @@ -10,23 +10,34 @@ #include class CN3BaseFileAccess : public CN3Base { - protected: - std::string m_szFileName; // Base Path 를 제외한 로컬 경로 + 파일 이름 + private: + fs::path m_fsFile; + fs::path m_fsFileAbs; public: - int m_iLOD; // 로딩할때 쓸 LOD + int m_iLOD; // level of details public: - const std::string & FileName() const { return m_szFileName; } // Full Path - void FileNameSet(const std::string & szFileName); + static void ToRelative(fs::path & fsFile); + [[nodiscard]] static fs::path ToRelative(const fs::path & fsFile); - bool LoadFromFile(); // 파일에서 읽어오기. - virtual bool LoadFromFile(const std::string & szFileName); // 파일에서 읽어오기. - virtual bool Load(HANDLE hFile); // 핸들에서 읽어오기.. + const fs::path & FilePath() const { return m_fsFile; } + void FilePathSet(const fs::path & fsFile); - virtual bool SaveToFile(); // 현재 파일 이름대로 저장. - virtual bool SaveToFile(const std::string & szFileName); // 새이름으로 저장. - virtual bool Save(HANDLE hFile); // 핸들을 통해 저장.. + const fs::path & FilePathAbs() const { return m_fsFileAbs; }; + + // Explictly converts the stored file path to Windows format by replacing '/' with '\'. + // Although Windows accepts both path separators, using '\' ensures compatibility with + // the official client's path format when writing paths to files. + [[nodiscard]] fs::path FilePathWin() const { return fs::path(m_fsFile).normalize('/', '\\'); } + + bool LoadFromFile(); + virtual bool LoadFromFile(const fs::path & fsFile); + virtual bool Load(HANDLE hFile); + + virtual bool SaveToFile(); + virtual bool SaveToFile(const fs::path & fsFile); + virtual bool Save(HANDLE hFile); public: void Release(); diff --git a/src/engine/N3Base/N3Board.cpp b/src/engine/N3Base/N3Board.cpp index 71252e7a..4facda91 100644 --- a/src/engine/N3Base/N3Board.cpp +++ b/src/engine/N3Base/N3Board.cpp @@ -161,19 +161,19 @@ void CN3Board::TexAlloc(int nCount) { m_TexRefs.assign(nCount, NULL); } -void CN3Board::TexSet(int index, const std::string & szFN) { +void CN3Board::TexSet(int index, const fs::path & fsFile) { if (index < 0 || index >= m_TexRefs.size()) { return; } s_MngTex.Delete(&m_TexRefs[index]); - m_TexRefs[index] = s_MngTex.Get(szFN); + m_TexRefs[index] = s_MngTex.Get(fsFile); } -void CN3Board::LoadFromText(const std::string & szFName) { +void CN3Board::LoadFromText(const fs::path & fsFile) { Release(); - FILE * stream = fopen(szFName.c_str(), "r"); + FILE * stream = _wfopen(fsFile.c_str(), L"r"); __ASSERT(stream, "지정한 파일을 찾을 수 없습니다."); int result, iCount; @@ -201,12 +201,12 @@ void CN3Board::LoadFromText(const std::string & szFName) { __ASSERT(result != EOF, "잘못된 Machine 세팅 파일"); if (iCount > 0) { - char szTexFName[_MAX_PATH]; + char szTexFile[260]{}; TexAlloc(iCount); for (int i = 0; i < iCount; ++i) { - result = fscanf(stream, "Texture Name = %s\n", &szTexFName); + result = fscanf(stream, "Texture Name = %s\n", &szTexFile); __ASSERT(result != EOF, "잘못된 Machine 세팅 파일"); - TexSet(i, szTexFName); + TexSet(i, szTexFile); } } @@ -222,4 +222,4 @@ void CN3Board::LoadFromText(const std::string & szFName) { m_dwBoardType = BOARD_XYZ; } Init(vPos, m_dwBoardType, fWidth, fHeight); -} \ No newline at end of file +} diff --git a/src/engine/N3Base/N3Board.h b/src/engine/N3Base/N3Board.h index 13dffd2a..c7f3f3e4 100644 --- a/src/engine/N3Base/N3Board.h +++ b/src/engine/N3Base/N3Board.h @@ -25,7 +25,7 @@ class CN3Board : public CN3Transform { __Material m_Mtl; // 재질.. public: - void TexSet(int index, const std::string & szFN); + void TexSet(int index, const fs::path & fsFile); void TexAlloc(int nCount); int TexCount() { return m_TexRefs.size(); } CN3Texture * Tex(int index) { @@ -40,7 +40,7 @@ class CN3Board : public CN3Transform { void Render(); bool Load(HANDLE hFile); - void LoadFromText(const std::string & szFName); + void LoadFromText(const fs::path & fsFile); #ifdef _N3TOOL bool Save(HANDLE hFile); diff --git a/src/engine/N3Base/N3Chr.cpp b/src/engine/N3Base/N3Chr.cpp index fd892ceb..aa7e7cd3 100644 --- a/src/engine/N3Base/N3Chr.cpp +++ b/src/engine/N3Base/N3Chr.cpp @@ -90,9 +90,9 @@ void CN3CPart::Release() { CN3BaseFileAccess::Release(); } -CN3CPartSkins * CN3CPart::SkinsSet(const std::string & szFN) { +CN3CPartSkins * CN3CPart::SkinsSet(const fs::path & fsFile) { s_MngSkins.Delete(&m_pSkinsRef); - m_pSkinsRef = s_MngSkins.Get(szFN, TRUE); + m_pSkinsRef = s_MngSkins.Get(fsFile, TRUE); return m_pSkinsRef; } @@ -101,26 +101,27 @@ bool CN3CPart::Load(HANDLE hFile) { CN3BaseFileAccess::Load(hFile); DWORD dwRWC = 0; - int nL = 0; - char szFN[256] = ""; ReadFile(hFile, &m_dwReserved, 4, &dwRWC, NULL); ReadFile(hFile, &m_MtlOrg, sizeof(__Material), &dwRWC, NULL); m_Mtl = m_MtlOrg; + int nL = 0; + std::string szFile; ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; - this->TexSet(szFN); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + TexSet(szFile); } + nL = 0; ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); s_MngSkins.Delete(&m_pSkinsRef); - m_pSkinsRef = s_MngSkins.Get(szFN); + m_pSkinsRef = s_MngSkins.Get(szFile); } return true; @@ -130,30 +131,34 @@ bool CN3CPart::Load(HANDLE hFile) { bool CN3CPart::Save(HANDLE hFile) { CN3BaseFileAccess::Save(hFile); - DWORD dwRWC = 0; - int nL = 0; + DWORD dwRWC = 0; + std::string szFile; + int nL = 0; WriteFile(hFile, &m_dwReserved, 4, &dwRWC, NULL); WriteFile(hFile, &m_Mtl, sizeof(__Material), &dwRWC, NULL); if (m_pTexRef) { - nL = m_pTexRef->FileName().size(); + szFile = m_pTexRef->FilePathWin().string(); + nL = szFile.length(); } else { nL = 0; } + WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - WriteFile(hFile, m_pTexRef->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); } if (m_pSkinsRef) { - nL = m_pSkinsRef->FileName().size(); + szFile = m_pSkinsRef->FilePathWin().string(); + nL = szFile.length(); } else { nL = 0; } WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - WriteFile(hFile, m_pSkinsRef->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); } return true; @@ -243,13 +248,13 @@ void CN3CPart::Render(int nLOD) { } } -CN3Texture * CN3CPart::TexOverlapSet(const std::string & szFN) { - if (m_pTexOverlapRef && 0 == lstrcmpi(m_pTexOverlapRef->FileName().c_str(), szFN.c_str())) { +CN3Texture * CN3CPart::TexOverlapSet(const fs::path & fsFile) { + if (m_pTexOverlapRef && n3std::iequals(m_pTexOverlapRef->FilePath(), fsFile)) { return m_pTexOverlapRef; } s_MngTex.Delete(&m_pTexOverlapRef); - m_pTexOverlapRef = s_MngTex.Get(szFN, true, s_Options.iTexLOD_Chr); + m_pTexOverlapRef = s_MngTex.Get(fsFile, true, s_Options.iTexLOD_Chr); return m_pTexOverlapRef; } @@ -327,8 +332,8 @@ void CN3CPlugBase::ReCalcMatrix() { // m_Matrix *= mtxScale; } -void CN3CPlugBase::PMeshSet(const std::string & szFN) { - m_PMeshInst.Create(szFN); +void CN3CPlugBase::PMeshSet(const fs::path & fsFile) { + m_PMeshInst.Create(fsFile); } void CN3CPlugBase::Render(const __Matrix44 & mtxParent, const __Matrix44 & mtxJoint) { @@ -421,14 +426,14 @@ void CN3CPlugBase::Render(const __Matrix44 & mtxParent, const __Matrix44 & mtxJo } } -CN3Texture * CN3CPlugBase::TexOverlapSet(const std::string & szFN) { - // if(m_pTexOverlapRef && m_pTexOverlapRef->FileName() == szFN) return m_pTexOverlapRef; - if (m_pTexOverlapRef && 0 == lstrcmpi(m_pTexOverlapRef->FileName().c_str(), szFN.c_str())) { +CN3Texture * CN3CPlugBase::TexOverlapSet(const fs::path & fsFile) { + // if(m_pTexOverlapRef && m_pTexOverlapRef->FilePath() == fsFile) return m_pTexOverlapRef; + if (m_pTexOverlapRef && n3std::iequals(m_pTexOverlapRef->FilePath(), fsFile)) { return m_pTexOverlapRef; } s_MngTex.Delete(&m_pTexOverlapRef); - m_pTexOverlapRef = s_MngTex.Get(szFN, true, s_Options.iTexLOD_Chr); + m_pTexOverlapRef = s_MngTex.Get(fsFile, true, s_Options.iTexLOD_Chr); return m_pTexOverlapRef; } @@ -445,8 +450,6 @@ bool CN3CPlugBase::Load(HANDLE hFile) { CN3BaseFileAccess::Load(hFile); DWORD dwRWC = 0; - int nL = 0; - char szFN[512] = ""; ReadFile(hFile, &m_ePlugType, 4, &dwRWC, NULL); // Plug Type //#ifdef _N3TOOL @@ -462,21 +465,23 @@ bool CN3CPlugBase::Load(HANDLE hFile) { ReadFile(hFile, &m_Mtl, sizeof(__Material), &dwRWC, NULL); // 재질 - ReadFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; - this->PMeshSet(szFN); + int iLen = 0; + std::string szFile; + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + szFile.assign(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); + PMeshSet(szFile); } - ReadFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; - this->TexSet(szFN); + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + szFile.assign(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); + TexSet(szFile); } - this->ReCalcMatrix(); // 행렬 계산... + ReCalcMatrix(); // 행렬 계산... return 0; } @@ -486,7 +491,6 @@ bool CN3CPlugBase::Save(HANDLE hFile) { CN3BaseFileAccess::Save(hFile); DWORD dwRWC = 0; - int nL = 0; WriteFile(hFile, &m_ePlugType, 4, &dwRWC, NULL); // Plug Type WriteFile(hFile, &m_nJointIndex, 4, &dwRWC, NULL); // Plug Joint Index @@ -497,39 +501,46 @@ bool CN3CPlugBase::Save(HANDLE hFile) { WriteFile(hFile, &m_Mtl, sizeof(__Material), &dwRWC, NULL); // 재질 - nL = 0; + std::string szFile; + int nL = 0; + CN3PMesh * pPMesh = m_PMeshInst.GetMesh(); if (pPMesh) { - nL = pPMesh->FileName().size(); + szFile = pPMesh->FilePathWin().string(); + nL = szFile.length(); + } else { + nL = 0; } WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - WriteFile(hFile, pPMesh->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); } - nL = 0; if (m_pTexRef) { - nL = m_pTexRef->FileName().size(); + szFile = m_pTexRef->FilePathWin().string(); + nL = szFile.length(); + } else { + nL = 0; } WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - WriteFile(hFile, m_pTexRef->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); } return 0; } #endif // end of _N3TOOL -e_PlugType CN3CPlugBase::GetPlugTypeByFileName(const std::string & szFN) { - if (szFN.empty()) { +e_PlugType CN3CPlugBase::GetPlugTypeByFileName(const fs::path & fsFile) { + if (fsFile.empty()) { return PLUGTYPE_UNDEFINED; } // berserk // 일단 확장자로 구분한다. 별로 좋은 방법 같지는 않지만.. N3CPlug, N3CPlug_Cloak - int nL = szFN.size(); - if (szFN[nL - 2] == 'u' && szFN[nL - 1] == 'g') { // PLUGTYPE_NORMAL + std::string szFile = fsFile.string(); + if (szFile.ends_with("ug")) { // PLUGTYPE_NORMAL return PLUGTYPE_NORMAL; - } else if (szFN[nL - 2] == 'a' && szFN[nL - 1] == 'k') { + } else if (szFile.ends_with("ak")) { return PLUGTYPE_CLOAK; } else { return PLUGTYPE_UNDEFINED; @@ -551,11 +562,6 @@ CN3CPlug::CN3CPlug() { for (int i = 0; i < MAX_FXTAIL; i++) { m_pFXTailBundle[i] = NULL; } - - // m_strFXName[PLUGATTR_FIRE] = "fx//fire_sword0_1.fxb"; - // m_strFXName[PLUGATTR_ICE] = "fx//ice_sword0_1.fxb"; - // m_strFXName[PLUGATTR_LIGHTENNING] = "fx//poison_sword0_1.fxb"; - // m_strFXName[PLUGATTR_POISON] = "fx//fire_sword0_1.fxb"; } CN3CPlug::~CN3CPlug() { @@ -614,38 +620,40 @@ bool CN3CPlug::Load(HANDLE hFile) { if (iUseVMesh) { CN3PMesh * pPMesh = new CN3PMesh(); pPMesh->Load(hFile); + + // TODO: FIXME: this can overflow the longer the game runs + // Note that they added this because s_MngPMesh doesn't allow adding files without + // names, since it uses them in std::map container as keys. static int iSN = 0; - char szFNTmp[256]; - sprintf(szFNTmp, "Temp_Plug_%d.N3PMesh", iSN++); - pPMesh->FileNameSet(szFNTmp); + pPMesh->FilePathSet(std::format("Temp_Plug_{:d}.n3pmesh", iSN++)); s_MngPMesh.Add(pPMesh); m_PMeshInstFX.Create(pPMesh); // FX 에 쓸 PMesh Instance } - m_strFXMainName = ""; - m_strFXTailName = ""; - InitFX(m_strFXMainName, m_strFXTailName, 0xffffffff); + m_fsFXMainFile.clear(); + m_fsFXTailFile.clear(); + InitFX(m_fsFXMainFile, m_fsFXTailFile, 0xffffffff); return true; } -void CN3CPlug::InitFX(std::string & szFXMain, std::string & szFXTail, D3DCOLOR TraceCR) { - if (szFXMain.empty()) { +void CN3CPlug::InitFX(const fs::path & fsMainFile, const fs::path & fsTailFile, D3DCOLOR TraceCR) { + if (fsMainFile.empty()) { if (m_pFXMainBundle) { delete m_pFXMainBundle; } m_pFXMainBundle = NULL; - m_strFXMainName = szFXMain; - } else if (!m_pFXMainBundle || szFXMain != m_pFXMainBundle->FileName()) { - m_strFXMainName = szFXMain; + m_fsFXMainFile = fsMainFile; + } else if (!m_pFXMainBundle || fsMainFile != m_pFXMainBundle->FilePath()) { + m_fsFXMainFile = fsMainFile; if (m_pFXMainBundle) { delete m_pFXMainBundle; } m_pFXMainBundle = new CN3FXBundle; - if (!m_pFXMainBundle->LoadFromFile(m_strFXMainName.c_str())) { + if (!m_pFXMainBundle->LoadFromFile(m_fsFXMainFile)) { delete m_pFXMainBundle; m_pFXMainBundle = NULL; - m_strFXMainName = ""; + m_fsFXMainFile.clear(); m_crTrace = 0xffffffff; } else { @@ -657,24 +665,24 @@ void CN3CPlug::InitFX(std::string & szFXMain, std::string & szFXTail, D3DCOLOR T } } - if (szFXTail.empty()) { - m_strFXTailName = szFXTail; + if (fsTailFile.empty()) { + m_fsFXTailFile = fsTailFile; for (int i = 0; i < MAX_FXTAIL; i++) { if (m_pFXTailBundle[i]) { delete m_pFXTailBundle[i]; } m_pFXTailBundle[i] = NULL; } - } else if (!m_pFXTailBundle[0] || szFXTail != m_pFXTailBundle[0]->FileName()) { - m_strFXTailName = szFXTail; + } else if (!m_pFXTailBundle[0] || fsTailFile != m_pFXTailBundle[0]->FilePath()) { + m_fsFXTailFile = fsTailFile; if (m_pFXTailBundle[0]) { delete m_pFXTailBundle[0]; } m_pFXTailBundle[0] = new CN3FXBundle; - if (!m_pFXTailBundle[0]->LoadFromFile(m_strFXTailName.c_str())) { + if (!m_pFXTailBundle[0]->LoadFromFile(m_fsFXTailFile)) { delete m_pFXTailBundle[0]; m_pFXTailBundle[0] = NULL; - m_strFXTailName = ""; + m_fsFXTailFile.clear(); return; } else { CN3PMesh * pMesh = m_PMeshInstFX.GetMesh(); @@ -721,12 +729,12 @@ bool CN3CPlug::Save(HANDLE hFile) { #endif #ifdef _N3TOOL -void CN3CPlug::ImportPMesh(const std::string & szFileName) { - if (szFileName.empty()) { +void CN3CPlug::ImportPMesh(const fs::path & fsFile) { + if (fsFile.empty()) { return; } m_PMeshInstFX.Release(); - m_PMeshInstFX.Create(szFileName); + m_PMeshInstFX.Create(fsFile); } #endif @@ -767,7 +775,7 @@ void CN3CPlug::RenderFX(const __Matrix44 & mtxParent, const __Matrix44 & mtxJoin return; } __VertexT1 * pvAxis = m_PMeshInstFX.GetVertices(); - //if(m_pFXMainBundle->FileName() != m_strFXMainName) InitFX(m_strFXMainName, m_strFXTailName); + //if(m_pFXMainBundle->FilePath() != m_fsFXMainFile) InitFX(m_fsFXMainFile, m_fsFXTailFile); m_pFXMainBundle->Tick(); @@ -1148,13 +1156,14 @@ bool CN3Chr::Load(HANDLE hFile) { DWORD dwRWC = 0; - int nL = 0; - char szFN[512] = ""; - + int nL = 0; + std::string szFile; ReadFile(hFile, &nL, 4, &dwRWC, NULL); - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; - this->JointSet(szFN); // 뼈대 세팅.. + if (nL > 0) { + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + JointSet(szFile); + } // Part Allocation, Loading .. int iPC = 0; @@ -1164,9 +1173,9 @@ bool CN3Chr::Load(HANDLE hFile) { nL = 0; ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; - m_Parts[i]->LoadFromFile(szFN); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + m_Parts[i]->LoadFromFile(szFile); } } @@ -1178,21 +1187,21 @@ bool CN3Chr::Load(HANDLE hFile) { nL = 0; ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; - m_Plugs[i]->LoadFromFile(szFN); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + m_Plugs[i]->LoadFromFile(szFile); // CN3CPlugBase * pPlug = NULL; - // e_PlugType eType = CN3CPlugBase::GetPlugTypeByFileName(szFN); + // e_PlugType eType = CN3CPlugBase::GetPlugTypeByFileName(szFile); // if (eType == PLUGTYPE_NORMAL) { // PLUGTYPE_NORMAL // pPlug = (CN3CPlugBase *)new CN3CPlug(); - // if (false == pPlug->LoadFromFile(szFN)) { + // if (false == pPlug->LoadFromFile(szFile)) { // delete pPlug; // continue; // } // } else if (eType == PLUGTYPE_CLOAK) { // PLUGTYPE_CLOAK // pPlug = (CN3CPlugBase *)new CN3CPlug_Cloak(); - // if (false == pPlug->LoadFromFile(szFN)) { + // if (false == pPlug->LoadFromFile(szFile)) { // delete pPlug; // continue; // } @@ -1207,9 +1216,9 @@ bool CN3Chr::Load(HANDLE hFile) { nL = 0; ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; - this->AniCtrlSet(szFN); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + AniCtrlSet(szFile); } ReadFile(hFile, m_nJointPartStarts, sizeof(m_nJointPartStarts), &dwRWC, @@ -1223,9 +1232,9 @@ bool CN3Chr::Load(HANDLE hFile) { nL = 0; ReadFile(hFile, &nL, sizeof(nL), &dwRWC, NULL); if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; - FXPlugSet(szFN); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + FXPlugSet(szFile); } // End Of Code (By Dino On 2002-10-10 오후 2:33:07 ) ////////////////////////////////////////////////// @@ -1253,16 +1262,18 @@ __AnimData * CN3Chr::AniDataUpper() { bool CN3Chr::Save(HANDLE hFile) { CN3TransformCollision::Save(hFile); - DWORD dwRWC = 0; - int nL = 0; + DWORD dwRWC = 0; + std::string szFile; + int nL = 0; // 관절 파일 이름 써주기.. if (m_pRootJointRef) { - nL = m_pRootJointRef->FileName().size(); + szFile = m_pRootJointRef->FilePathWin().string(); + nL = szFile.length(); } WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - WriteFile(hFile, m_pRootJointRef->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); } // 내용이 없는 Part Data는 걸러낸다.. @@ -1298,32 +1309,35 @@ bool CN3Chr::Save(HANDLE hFile) { int iPC = m_Parts.size(); WriteFile(hFile, &iPC, 4, &dwRWC, NULL); for (int i = 0; i < iPC; i++) { - nL = m_Parts[i]->FileName().size(); - if (nL <= 0) { - char szFNTmp[256]; - wsprintf(szFNTmp, "%s_Default%d.N3CPart", m_szName.c_str(), i); - m_Parts[i]->FileNameSet(szFNTmp); + szFile = m_Parts[i]->FilePathWin().string(); + if (szFile.empty()) { + m_Parts[i]->FilePathSet(std::format("{:s}_Default{:d}.n3cpart", m_szName, i)); + szFile = m_Parts[i]->FilePathWin().string(); } - nL = m_Parts[i]->FileName().size(); + + nL = szFile.length(); WriteFile(hFile, &nL, 4, &dwRWC, NULL); - WriteFile(hFile, m_Parts[i]->FileName().c_str(), nL, &dwRWC, NULL); + if (nL > 0) { + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); + } m_Parts[i]->SaveToFile(); } iPC = m_Plugs.size(); WriteFile(hFile, &iPC, 4, &dwRWC, NULL); for (int i = 0; i < iPC; i++) { - nL = m_Plugs[i]->FileName().size(); - if (nL <= 0) { - char szFNTmp[256]; - wsprintf(szFNTmp, "%s_Default%d.N3CPlug", m_szName.c_str(), i); - m_Plugs[i]->FileNameSet(szFNTmp); + szFile = m_Plugs[i]->FilePathWin().string(); + if (szFile.empty()) { + m_Plugs[i]->FilePathSet(std::format("{:s}_Default{:d}.n3cplug", m_szName, i)); + szFile = m_Plugs[i]->FilePathWin().string(); i++; } - nL = m_Plugs[i]->FileName().size(); + nL = szFile.length(); WriteFile(hFile, &nL, 4, &dwRWC, NULL); - WriteFile(hFile, m_Plugs[i]->FileName().c_str(), nL, &dwRWC, NULL); + if (nL > 0) { + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); + } m_Plugs[i]->SaveToFile(); } @@ -1339,11 +1353,12 @@ bool CN3Chr::Save(HANDLE hFile) { // Animation Control.. nL = 0; if (m_pAniCtrlRef) { - nL = m_pAniCtrlRef->FileName().size(); + szFile = m_pAniCtrlRef->FilePathWin().string(); + nL = szFile.length(); } WriteFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - WriteFile(hFile, m_pAniCtrlRef->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); } WriteFile(hFile, m_nJointPartStarts, sizeof(m_nJointPartStarts), &dwRWC, @@ -1356,11 +1371,12 @@ bool CN3Chr::Save(HANDLE hFile) { // FXPlug nL = 0; if (m_pFXPlug) { - nL = m_pFXPlug->FileName().size(); + szFile = m_pFXPlug->FilePathWin().string(); + nL = szFile.length(); } WriteFile(hFile, &nL, sizeof(nL), &dwRWC, NULL); if (nL > 0) { - WriteFile(hFile, m_pFXPlug->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), nL, &dwRWC, NULL); m_pFXPlug->SaveToFile(); } // End Of Code (By Dino On 2002-10-11 오후 2:19:11 ) @@ -1977,17 +1993,17 @@ void CN3Chr::Init() { m_pMeshCollision->CreateCube(m_vMin, m_vMax); } -void CN3Chr::JointSet(const std::string & szFN) { +void CN3Chr::JointSet(const fs::path & fsFile) { bool bNeedInit = false; if (NULL == m_pRootJointRef) { bNeedInit = true; - } else if (m_pRootJointRef && m_pRootJointRef->FileName() != szFN) { + } else if (m_pRootJointRef && m_pRootJointRef->FilePath() != fsFile) { bNeedInit = true; // 파일 이름이 달라야 지우고 새로 한다.. } if (bNeedInit) { s_MngJoint.Delete(&m_pRootJointRef); - m_pRootJointRef = s_MngJoint.Get(szFN); + m_pRootJointRef = s_MngJoint.Get(fsFile); this->Init(); // 초기화... } } @@ -2020,18 +2036,18 @@ void CN3Chr::PartDelete(int iIndex) { m_Parts.erase(it); } -CN3CPart * CN3Chr::PartSet(int iIndex, const std::string & szFN) { +CN3CPart * CN3Chr::PartSet(int iIndex, const fs::path & fsFile) { if (iIndex < 0 || iIndex >= m_Parts.size()) { return NULL; } - if (m_Parts[iIndex]->FileName() == szFN) { + if (m_Parts[iIndex]->FilePath() == fsFile) { return m_Parts[iIndex]; } - if (szFN.size() <= 0) { + if (fsFile.empty()) { m_Parts[iIndex]->Release(); } else { - m_Parts[iIndex]->LoadFromFile(szFN); + m_Parts[iIndex]->LoadFromFile(fsFile); } return m_Parts[iIndex]; @@ -2051,19 +2067,19 @@ void CN3Chr::PlugDelete(int iIndex) { m_Plugs.erase(it); } -CN3CPlug * CN3Chr::PlugSet(int iIndex, const std::string & szFN) { +CN3CPlug * CN3Chr::PlugSet(int iIndex, const fs::path & fsFile) { if (iIndex < 0 || iIndex >= m_Plugs.size()) { return NULL; } - if (m_Plugs[iIndex]->FileName() == szFN) { + if (m_Plugs[iIndex]->FilePath() == fsFile) { return m_Plugs[iIndex]; } - if (szFN.size() <= 0) { + if (fsFile.empty()) { m_Plugs[iIndex]->Release(); } else { - m_Plugs[iIndex]->LoadFromFile(szFN); + m_Plugs[iIndex]->LoadFromFile(fsFile); } this->RemakePlugTracePolygons(); @@ -2087,16 +2103,16 @@ void CN3Chr::PlugAlloc(int iCount) { } /* -void CN3Chr::CollisionSkinSet(const std::string& szFN) +void CN3Chr::CollisionSkinSet(const fs::path & fsFile) { s_MngSkin.Delete(m_pSkinCollision); - m_pSkinCollision = s_MngSkin.Get(szFN); + m_pSkinCollision = s_MngSkin.Get(fsFile); } */ -void CN3Chr::AniCtrlSet(const std::string & szFN) { +void CN3Chr::AniCtrlSet(const fs::path & fsFile) { s_MngAniCtrl.Delete(&m_pAniCtrlRef); - m_pAniCtrlRef = s_MngAniCtrl.Get(szFN); + m_pAniCtrlRef = s_MngAniCtrl.Get(fsFile); for (int i = 0; i < MAX_CHR_ANI_PART; i++) { m_FrmCtrl.iAni = -1; @@ -2222,7 +2238,7 @@ void CN3Chr::AniDefaultSet() { // 기본적인 Animation Control 만들기.. CN3AnimControl * pAniCtrlDefault = new CN3AnimControl(); pAniCtrlDefault->m_szName = "Default"; - pAniCtrlDefault->FileNameSet("Chr\\Default.N3Anim"); + pAniCtrlDefault->FilePathSet(fs::path("Chr") / "Default.n3anim"); s_MngAniCtrl.Add(pAniCtrlDefault); m_pAniCtrlRef = pAniCtrlDefault; @@ -2368,13 +2384,13 @@ int CN3Chr::CheckCollisionPrecisely(const __Vector3 & vPos, const __Vector3 & vD // FXPlug // FXPlugSet : FXPlug 파일을 지정해주는 함수 -CN3FXPlug * CN3Chr::FXPlugSet(const std::string & strFN) { +CN3FXPlug * CN3Chr::FXPlugSet(const fs::path & fsFile) { if (m_pFXPlug) { m_pFXPlug->Release(); } else { m_pFXPlug = new CN3FXPlug(); } - if (false == m_pFXPlug->LoadFromFile(strFN)) { + if (!m_pFXPlug->LoadFromFile(fsFile)) { return NULL; } return m_pFXPlug; @@ -2386,12 +2402,11 @@ CN3FXPlug * CN3Chr::FXPlugCreate() { } else { m_pFXPlug = new CN3FXPlug(); + fs::path fsChrDir("Chr"); if (m_szName.size() > 0) { - char szFN[_MAX_PATH]; - wsprintf(szFN, "Chr\\%s.N3FXPlug", m_szName.c_str()); // 캐릭터의 이름을 붙인다. - m_pFXPlug->FileNameSet(szFN); + m_pFXPlug->FilePathSet(fsChrDir / (m_szName + ".n3fxplug")); } else { - m_pFXPlug->FileNameSet("Chr\\Default.N3FXPlug"); // 그냥 default이름을 붙인다. + m_pFXPlug->FilePathSet(fsChrDir / "Default.n3fxplug"); // 그냥 default이름을 붙인다. } } return m_pFXPlug; diff --git a/src/engine/N3Base/N3Chr.h b/src/engine/N3Base/N3Chr.h index 13569440..80162be6 100644 --- a/src/engine/N3Base/N3Chr.h +++ b/src/engine/N3Base/N3Chr.h @@ -59,9 +59,9 @@ class CN3CPart : public CN3BaseFileAccess { void Render(int nLOD); CN3Texture * Tex() { return m_pTexRef; } - CN3Texture * TexSet(const std::string & szFN) { + CN3Texture * TexSet(const fs::path & fsFile) { s_MngTex.Delete(&m_pTexRef); - m_pTexRef = s_MngTex.Get(szFN, true, s_Options.iTexLOD_Chr); + m_pTexRef = s_MngTex.Get(fsFile, true, s_Options.iTexLOD_Chr); return m_pTexRef; } void TexSet(CN3Texture * pTex) { @@ -70,7 +70,7 @@ class CN3CPart : public CN3BaseFileAccess { } CN3Texture * TexOverlap() { return m_pTexOverlapRef; } // 위에 덧칠할 텍스처 - CN3Texture * TexOverlapSet(const std::string & szFN); + CN3Texture * TexOverlapSet(const fs::path & fsFile); void TexOverlapSet(CN3Texture * pTex); CN3Skin * Skin(int nLOD) { @@ -81,7 +81,7 @@ class CN3CPart : public CN3BaseFileAccess { } } CN3CPartSkins * Skins() { return m_pSkinsRef; } - CN3CPartSkins * SkinsSet(const std::string & szFN); + CN3CPartSkins * SkinsSet(const fs::path & fsFile); #ifdef _N3TOOL void RenderSelected(int nLOD); @@ -122,7 +122,7 @@ class CN3CPlugBase : public CN3BaseFileAccess { public: CN3CPlugBase(); virtual ~CN3CPlugBase(); - static e_PlugType GetPlugTypeByFileName(const std::string & szFN); + static e_PlugType GetPlugTypeByFileName(const fs::path & fsFile); virtual bool Load(HANDLE hFile); #ifdef _N3TOOL @@ -152,9 +152,9 @@ class CN3CPlugBase : public CN3BaseFileAccess { } CN3Texture * Tex() { return m_pTexRef; } - CN3Texture * TexSet(const std::string & szFN) { + CN3Texture * TexSet(const fs::path & fsFile) { s_MngTex.Delete(&m_pTexRef); - m_pTexRef = s_MngTex.Get(szFN, true, s_Options.iTexLOD_Chr); + m_pTexRef = s_MngTex.Get(fsFile, true, s_Options.iTexLOD_Chr); return m_pTexRef; } void TexSet(CN3Texture * pTex) { @@ -163,12 +163,12 @@ class CN3CPlugBase : public CN3BaseFileAccess { } CN3Texture * TexOverlap() { return m_pTexOverlapRef; } // 위에 덧칠할 텍스처 - CN3Texture * TexOverlapSet(const std::string & szFN); + CN3Texture * TexOverlapSet(const fs::path & fsFile); void TexOverlapSet(CN3Texture * pTex); CN3PMesh * PMesh() { return m_PMeshInst.GetMesh(); } CN3PMeshInstance * PMeshInst() { return &m_PMeshInst; } - void PMeshSet(const std::string & szFN); + void PMeshSet(const fs::path & fsFile); }; const int MAX_PLUG_FX_POSITION = 5; @@ -193,21 +193,21 @@ class CN3CPlug : public CN3CPlugBase { class CN3FXBundle * m_pFXMainBundle; class CN3FXBundle * m_pFXTailBundle[MAX_FXTAIL]; class CN3FXPartBillBoard * m_pFXPart; - std::string m_strFXMainName; - std::string m_strFXTailName; + fs::path m_fsFXMainFile; + fs::path m_fsFXTailFile; public: virtual bool Load(HANDLE hFile); #ifdef _N3TOOL virtual bool Save(HANDLE hFile); - void ImportPMesh(const std::string & szFileName); + void ImportPMesh(const fs::path & fsFile); void RenderFXLines(const __Matrix44 & mtxParent, const __Matrix44 & mtxJoint); // FX 들어갈 곳에 선을 그려준다. #endif // end of _N3TOOL virtual void Render(const __Matrix44 & mtxParent, const __Matrix44 & mtxJoint); virtual void Release(); void RenderFX(const __Matrix44 & mtxParent, const __Matrix44 & mtxJoint); - void InitFX(std::string & szFXMain, std::string & szFXTail, D3DCOLOR TraceCR = 0xffffffff); + void InitFX(const fs::path & fsMainFile, const fs::path & fsTailFile, D3DCOLOR TraceCR = 0xffffffff); public: CN3CPlug(); @@ -339,13 +339,13 @@ class CN3Chr : public CN3TransformCollision { return NULL; } - // void CollisionSkinSet(const std::string & szFN); + // void CollisionSkinSet(const fs::path & fsFile); // CN3Skin * CollisionSkin() { return m_pSkinCollision; } void PartDelete(int iIndex); void PartAlloc(int nCount); int PartCount() { return m_Parts.size(); } - CN3CPart * PartSet(int iIndex, const std::string & szFN); + CN3CPart * PartSet(int iIndex, const fs::path & fsFile); CN3CPart * PartAdd() { CN3CPart * pPart = new CN3CPart(); m_Parts.push_back(pPart); @@ -361,7 +361,7 @@ class CN3Chr : public CN3TransformCollision { void PlugDelete(int iIndex); void PlugAlloc(int nCount); int PlugCount() { return m_Plugs.size(); } - CN3CPlug * PlugSet(int iIndex, const std::string & szFN); + CN3CPlug * PlugSet(int iIndex, const fs::path & fsFile); CN3CPlug * PlugAdd(e_PlugType eType = PLUGTYPE_NORMAL) { CN3CPlug * pPlug = new CN3CPlug(); m_Plugs.push_back(pPlug); @@ -384,14 +384,14 @@ class CN3Chr : public CN3TransformCollision { float Radius() { return m_fRadius * m_vScale.y; } // 스케일을 적용한 너비... CN3Joint * Joint() { return m_pRootJointRef; } - void JointSet(const std::string & szFN); + void JointSet(const fs::path & fsFile); // Animation 관련 함수 #ifdef _N3TOOL void AniDefaultSet(); #endif // #ifdef _N3TOOL CN3AnimControl * AniCtrl() { return m_pAniCtrlRef; } - void AniCtrlSet(const std::string & szFN); + void AniCtrlSet(const fs::path & fsFile); int AniIndexCur() { return m_FrmCtrl.iAni; } int AniCurSet(int iAni, // Animation 번호, bool bOnceAndFreeze = false, // 한번만 돌고 멈추어야 하는가?? @@ -428,7 +428,7 @@ class CN3Chr : public CN3TransformCollision { ////////////////////////////////////////////////// // Coded (By Dino On 2002-10-10 오후 2:35:32 ) // FXPlug - class CN3FXPlug * FXPlugSet(const std::string & strFN); + class CN3FXPlug * FXPlugSet(const fs::path & fsFile); class CN3FXPlug * FXPlugCreate(); class CN3FXPlug * FXPlugGet() { return m_pFXPlug; } void FXPlugDelete(); diff --git a/src/engine/N3Base/N3Cloud.cpp b/src/engine/N3Base/N3Cloud.cpp index dba26665..6a51c917 100644 --- a/src/engine/N3Base/N3Cloud.cpp +++ b/src/engine/N3Base/N3Cloud.cpp @@ -13,7 +13,6 @@ CN3Cloud::CN3Cloud() { for (int i = 0; i < NUM_CLOUD; i++) { m_pTextures[i] = NULL; - m_szTextures[i] = ""; } m_Color1.ChangeColor(0xffffffff); @@ -39,7 +38,7 @@ void CN3Cloud::Release() { for (int i = 0; i < NUM_CLOUD; ++i) { if (m_pTextures[i]) { s_MngTex.Delete(&m_pTextures[i]); - m_szTextures[i] = ""; + m_fsTexFiles[i] = fs::path(); } } m_Color1.ChangeColor(0xffffffff); @@ -231,7 +230,7 @@ void CN3Cloud::Render() { LPDIRECT3DTEXTURE9 CN3Cloud::GetTex(e_CLOUDTEX tex) { if (NULL == m_pTextures[tex]) { - m_pTextures[tex] = s_MngTex.Get(m_szTextures[tex]); + m_pTextures[tex] = s_MngTex.Get(m_fsTexFiles[tex]); if (NULL == m_pTextures[tex]) { return NULL; } @@ -240,11 +239,11 @@ LPDIRECT3DTEXTURE9 CN3Cloud::GetTex(e_CLOUDTEX tex) { return m_pTextures[tex]->Get(); } -void CN3Cloud::Init(const std::string * pszFNs) { +void CN3Cloud::Init(const fs::path * pfsTexFiles) { Release(); for (int i = 0; i < NUM_CLOUD; i++) { - m_szTextures[i] = pszFNs[i]; + m_fsTexFiles[i] = pfsTexFiles[i]; } /* diff --git a/src/engine/N3Base/N3Cloud.h b/src/engine/N3Base/N3Cloud.h index b8113b15..57a232e7 100644 --- a/src/engine/N3Base/N3Cloud.h +++ b/src/engine/N3Base/N3Cloud.h @@ -32,7 +32,7 @@ class CN3Cloud : public CN3Base { protected: __VertexXyzColorT2 m_pVertices[NUM_CLOUD_VERTEX]; // 구름층의 버텍스 CN3Texture * m_pTextures[NUM_CLOUD]; // 텍스쳐들.. - std::string m_szTextures[NUM_CLOUD]; // 텍스처 파일 이름들... + fs::path m_fsTexFiles[NUM_CLOUD]; // 텍스처 파일 이름들... CN3ColorChange m_Color1; // 구름 색1 CN3ColorChange m_Color2; // 구름 색2 @@ -50,7 +50,7 @@ class CN3Cloud : public CN3Base { void ChangeColor1(D3DCOLOR color, float fSec) { m_Color1.ChangeColor(color, fSec); } void ChangeColor2(D3DCOLOR color, float fSec) { m_Color2.ChangeColor(color, fSec); } void SetCloud(e_CLOUDTEX eCloud1, e_CLOUDTEX eCloud2, float fSec); - void Init(const std::string * pszFNs); + void Init(const fs::path * pfsTexFiles); virtual void Release(); virtual void Render(); virtual void Tick(); diff --git a/src/engine/N3Base/N3Eng.cpp b/src/engine/N3Base/N3Eng.cpp index dec87c95..5b338aaa 100644 --- a/src/engine/N3Base/N3Eng.cpp +++ b/src/engine/N3Base/N3Eng.cpp @@ -40,7 +40,7 @@ CN3Eng::CN3Eng() { } if (CN3Base::PathGet().empty()) { - CN3Base::PathSet(n3std::get_app_dir().string()); + CN3Base::PathSet(n3std::get_app_dir()); } #ifdef _N3GAME @@ -644,9 +644,9 @@ bool CN3Eng::RegistryValueGet(HKEY hKey, const std::string & szName, std::string DWORD dwType = REG_SZ; DWORD dwBytes = 0; - char buffer[MAX_PATH]{}; - long lStatus = RegQueryValueEx(hKey, szName.c_str(), NULL, &dwType, (BYTE *)buffer, &dwBytes); - szValue = buffer; + char szBuff[260]{}; + long lStatus = RegQueryValueEx(hKey, szName.c_str(), NULL, &dwType, (BYTE *)szBuff, &dwBytes); + szValue = szBuff; if (ERROR_SUCCESS == lStatus) { return true; diff --git a/src/engine/N3Base/N3EngTool.h b/src/engine/N3Base/N3EngTool.h index e52de4de..b39b4e76 100644 --- a/src/engine/N3Base/N3EngTool.h +++ b/src/engine/N3Base/N3EngTool.h @@ -42,7 +42,7 @@ struct __EXPORT_OPTION { bGenerateHalfSizeTexture; // 텍스처 파일을 자동으로 최적화 시켜서 생성 Direct3D 의 포맷에 맞게 2의 제곱수 단위로 맞추어서 "OBM" 비트맵 파일로 저장. BOOL bGenerateCompressedTexture; // Texture 압축 사용 - char szSubDir[_MAX_DIR]; // export 할때 저장하는 sub폴더를 지정해준다. + fs::path fsSubDir; // export 할때 저장하는 sub폴더를 지정해준다. }; class CN3EngTool : public CN3Eng { diff --git a/src/engine/N3Base/N3FXBundle.cpp b/src/engine/N3Base/N3FXBundle.cpp index c835b5a5..308a46f8 100644 --- a/src/engine/N3Base/N3FXBundle.cpp +++ b/src/engine/N3Base/N3FXBundle.cpp @@ -77,55 +77,46 @@ CN3FXBundle::~CN3FXBundle() { // 스크립트 파일 읽고 해석시킴... // #ifdef _N3TOOL -bool CN3FXBundle::DecodeScriptFile(const char * lpPathName) { - FILE * stream = fopen(lpPathName, "r"); +bool CN3FXBundle::DecodeScriptFile(const fs::path & fsFile) { + FILE * stream = _wfopen(fsFile.c_str(), L"r"); if (!stream) { return false; } - char szGamePathName[_MAX_PATH]; - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpPathName, szDrive, szDir, szFName, szExt); - _makepath(szGamePathName, szDrive, szDir, szFName, "fxb"); + fs::path fsFxbFile = fs::path(fsFile).replace_extension(".fxb"); + CN3BaseFileAccess::FilePathSet(fsFxbFile); - CN3BaseFileAccess::FileNameSet(szGamePathName); - - char szLine[512] = "", szCommand[80] = "", szBuf[4][80] = {"", "", "", ""}; - char * pResult = fgets(szLine, 512, stream); + char szLine[512]{}, szCommand[80]{}, szBuf[4][80]{}; + char * pResult = fgets(szLine, sizeof(szLine), stream); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "")) { + if (!n3std::iequals(szCommand, "")) { fclose(stream); return false; } while (!feof(stream)) { - char * pResult = fgets(szLine, 512, stream); + char * pResult = fgets(szLine, sizeof(szLine), stream); if (pResult == NULL) { continue; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_strName = szBuf[0]; continue; } - if (lstrcmpi(szCommand, "") == 0) { - char szFullPath[_MAX_PATH]; //full path 만들기.. - sprintf(szFullPath, "%s%s", CN3Base::PathGet().c_str(), szBuf[0]); + if (n3std::iequals(szCommand, "")) { + fs::path fsFile = CN3Base::PathGet() / szBuf[0]; FXPARTWITHSTARTTIME * pPart = new FXPARTWITHSTARTTIME; pPart->fStartTime = atof(szBuf[1]); - - pPart->pPart = SetPart(szFullPath); + pPart->pPart = SetPart(fsFile); if (!(pPart->pPart)) { delete pPart; @@ -140,20 +131,20 @@ bool CN3FXBundle::DecodeScriptFile(const char * lpPathName) { } continue; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fVelocity = atof(szBuf[0]); continue; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuf[0], "true") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuf[0], "true")) { m_bDependScale = true; } else { m_bDependScale = false; } continue; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuf[0], "true") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuf[0], "true")) { m_bStatic = true; } else { m_bStatic = false; @@ -174,44 +165,42 @@ bool CN3FXBundle::DecodeScriptFile(const char * lpPathName) { // 파트의 파일이름으로 타입을 알아내자.. // #ifdef _N3TOOL -CN3FXPartBase * CN3FXBundle::SetPart(const char * pFileName) { +CN3FXPartBase * CN3FXBundle::SetPart(const fs::path & fsFile) { int PartType = FX_PART_TYPE_NONE; - FILE * stream = fopen(pFileName, "r"); + FILE * stream = _wfopen(fsFile.c_str(), L"r"); if (!stream) { return NULL; } - char szLine[512] = "", szCommand[80] = "", szBuf[4][80] = {"", "", "", ""}; - char * pResult = fgets(szLine, 512, stream); + char szLine[512]{}, szCommand[80]{}, szBuf[4][80]{}; + char * pResult = fgets(szLine, sizeof(szLine), stream); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "")) { + if (!n3std::iequals(szCommand, "")) { fclose(stream); return NULL; } while (!feof(stream)) { - char * pResult = fgets(szLine, 512, stream); + char * pResult = fgets(szLine, sizeof(szLine), stream); if (pResult == NULL) { continue; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); + sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuf[0], "particle") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuf[0], "particle")) { PartType = FX_PART_TYPE_PARTICLE; - } else if (lstrcmpi(szBuf[0], "board") == 0) { + } else if (n3std::iequals(szBuf[0], "board")) { PartType = FX_PART_TYPE_BOARD; - } else if (lstrcmpi(szBuf[0], "mesh") == 0) { + } else if (n3std::iequals(szBuf[0], "mesh")) { PartType = FX_PART_TYPE_MESH; - } else if (lstrcmpi(szBuf[0], "ground") == 0) { + } else if (n3std::iequals(szBuf[0], "ground")) { PartType = FX_PART_TYPE_BOTTOMBOARD; } //^^v 더 넣을꺼 있으면 넣어라.. @@ -224,25 +213,25 @@ CN3FXPartBase * CN3FXBundle::SetPart(const char * pFileName) { pPart = new CN3FXPartParticles; pPart->m_pRefBundle = this; pPart->m_pRefPrevPart = NULL; - pPart->DecodeScriptFile(pFileName); + pPart->DecodeScriptFile(fsFile); return pPart; } else if (PartType == FX_PART_TYPE_BOARD) { pPart = new CN3FXPartBillBoard; pPart->m_pRefBundle = this; pPart->m_pRefPrevPart = NULL; - pPart->DecodeScriptFile(pFileName); + pPart->DecodeScriptFile(fsFile); return pPart; } else if (PartType == FX_PART_TYPE_MESH) { pPart = new CN3FXPartMesh; pPart->m_pRefBundle = this; pPart->m_pRefPrevPart = NULL; - pPart->DecodeScriptFile(pFileName); + pPart->DecodeScriptFile(fsFile); return pPart; } else if (PartType == FX_PART_TYPE_BOTTOMBOARD) { pPart = new CN3FXPartBottomBoard; pPart->m_pRefBundle = this; pPart->m_pRefPrevPart = NULL; - pPart->DecodeScriptFile(pFileName); + pPart->DecodeScriptFile(fsFile); return pPart; } return NULL; @@ -295,10 +284,7 @@ bool CN3FXBundle::Load(HANDLE hFile) { else if (iType == FX_PART_TYPE_PARTICLE) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -307,17 +293,13 @@ bool CN3FXBundle::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_PARTICLE; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_BOARD) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -326,17 +308,13 @@ bool CN3FXBundle::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_BOARD; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_MESH) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -345,15 +323,11 @@ bool CN3FXBundle::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_MESH; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_BOTTOMBOARD) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -362,7 +336,6 @@ bool CN3FXBundle::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_BOTTOMBOARD; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } } @@ -380,10 +353,7 @@ bool CN3FXBundle::Load(HANDLE hFile) { else if (iType == FX_PART_TYPE_PARTICLE) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -392,17 +362,13 @@ bool CN3FXBundle::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_PARTICLE; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_BOARD) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -411,17 +377,13 @@ bool CN3FXBundle::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_BOARD; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_MESH) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -430,15 +392,11 @@ bool CN3FXBundle::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_MESH; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_BOTTOMBOARD) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -447,7 +405,6 @@ bool CN3FXBundle::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_BOTTOMBOARD; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } } @@ -474,10 +431,6 @@ bool CN3FXBundle::Save(HANDLE hFile) { for (int i = 0; i < MAX_FX_PART; i++) { if (m_pPart[i] && m_pPart[i]->pPart) { WriteFile(hFile, &(m_pPart[i]->pPart->m_iType), sizeof(int), &dwRWC, NULL); - - //char FName[80]; - //sprintf(FName, m_pPart[i]->pPart->FileName().c_str()); - //WriteFile(hFile, FName, 80, &dwRWC, NULL); WriteFile(hFile, &(m_pPart[i]->fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->pPart->Save(hFile); } else { @@ -642,7 +595,7 @@ void CN3FXBundle::SetPartSTime(int i, float time) { } void CN3FXBundle::Duplicate(CN3FXBundle * pDestBundle) { - pDestBundle->FileNameSet(this->FileName()); + pDestBundle->FilePathSet(FilePath()); pDestBundle->m_iVersion = m_iVersion; pDestBundle->m_fLife0 = m_fLife0; @@ -709,4 +662,4 @@ void CN3FXBundle::Duplicate(CN3FXBundle * pDestBundle) { } } } -} \ No newline at end of file +} diff --git a/src/engine/N3Base/N3FXBundle.h b/src/engine/N3Base/N3FXBundle.h index 7f0dd843..7c15c68b 100644 --- a/src/engine/N3Base/N3FXBundle.h +++ b/src/engine/N3Base/N3FXBundle.h @@ -77,7 +77,7 @@ class CN3FXBundle : public CN3BaseFileAccess { #ifdef _N3TOOL //툴에서만 쓰는 함수들... public: - CN3FXPartBase * SetPart(const char * pFileName); - bool DecodeScriptFile(const char * lpPathName); + CN3FXPartBase * SetPart(const fs::path & fsFile); + bool DecodeScriptFile(const fs::path & fsFile); #endif // end of _N3TOOL }; diff --git a/src/engine/N3Base/N3FXDef.h b/src/engine/N3Base/N3FXDef.h index f740e9a8..e183cb4c 100644 --- a/src/engine/N3Base/N3FXDef.h +++ b/src/engine/N3Base/N3FXDef.h @@ -65,8 +65,8 @@ enum e_FXPartParticleEmitType // 이펙트 파트가 어떤 모양으로 전개 /* typedef struct __TABLE_FX // FX 리소스 레코드... { - DWORD dwID; // 고유 ID - std::string szFN; // file name + DWORD dwID; // 고유 ID + std::string szFile; // file path DWORD dwSoundID; // 효과에 쓰는 사운드 아디. } TABLE_FX; */ @@ -95,12 +95,12 @@ typedef struct __FXPartWithStartTime // 번들에서 파트들 관리할때.. } FXPARTWITHSTARTTIME, *LPFXPARTWITHSTARTTIME; typedef struct __FXBInfo { - char FXBName[MAX_PATH]; + char szFxbFile[260]; int joint; BOOL IsLooping; __FXBInfo() { - ZeroMemory(FXBName, MAX_PATH); + memset(szFxbFile, 0, sizeof(szFxbFile)); joint = -1; IsLooping = FALSE; } diff --git a/src/engine/N3Base/N3FXGroup.cpp b/src/engine/N3Base/N3FXGroup.cpp index e6250f95..6b907ff8 100644 --- a/src/engine/N3Base/N3FXGroup.cpp +++ b/src/engine/N3Base/N3FXGroup.cpp @@ -71,47 +71,40 @@ bool CN3FXGroup::Save(HANDLE hFile) { // 스크립트 파일 읽고 해석시킴... // #ifdef _N3TOOL -bool CN3FXGroup::DecodeScriptFile(const char * lpPathName) { - FILE * stream = fopen(lpPathName, "r"); +bool CN3FXGroup::DecodeScriptFile(const fs::path & fsFile) { + FILE * stream = _wfopen(fsFile.c_str(), L"r"); if (!stream) { return false; } - char szGamePathName[_MAX_PATH]; - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpPathName, szDrive, szDir, szFName, szExt); - _makepath(szGamePathName, szDrive, szDir, szFName, "fxg"); + fs::path fsFxgPath = fs::path(fsFile).replace_extension(".fxg"); + CN3BaseFileAccess::FilePathSet(fsFxgPath); - CN3BaseFileAccess::FileNameSet(szGamePathName); - - char szLine[512] = "", szCommand[80] = "", szBuf[4][80] = {"", "", "", ""}; - char * pResult = fgets(szLine, 512, stream); + char szLine[512]{}, szCommand[80]{}, szBuf[4][80]{}; + char * pResult = fgets(szLine, sizeof(szLine), stream); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "")) { + if (!n3std::iequals(szCommand, "")) { fclose(stream); return false; } while (!feof(stream)) { - char * pResult = fgets(szLine, 512, stream); + char * pResult = fgets(szLine, sizeof(szLine), stream); if (pResult == NULL) { continue; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { __FXBInfo * pFXB = new __FXBInfo; - sprintf(pFXB->FXBName, szBuf[0]); + memcpy(pFXB->szFxbFile, szBuf[0], sizeof(szBuf[0])); pFXB->joint = atoi(szBuf[1]); - if (lstrcmpi(szBuf[2], "TRUE") == 0) { + if (n3std::iequals(szBuf[2], "TRUE")) { pFXB->IsLooping = TRUE; } @@ -137,4 +130,4 @@ __FXBInfo * CN3FXGroup::GetFXBInfo(int idx) { it++; } return (*it); -} \ No newline at end of file +} diff --git a/src/engine/N3Base/N3FXGroup.h b/src/engine/N3Base/N3FXGroup.h index 04bc19d9..816d277c 100644 --- a/src/engine/N3Base/N3FXGroup.h +++ b/src/engine/N3Base/N3FXGroup.h @@ -26,6 +26,6 @@ class CN3FXGroup : public CN3BaseFileAccess { #ifdef _N3TOOL //툴에서만 쓰는 함수들... public: - bool DecodeScriptFile(const char * lpPathName); + bool DecodeScriptFile(const fs::path & fsFile); #endif // end of _N3TOOL }; diff --git a/src/engine/N3Base/N3FXPMesh.cpp b/src/engine/N3Base/N3FXPMesh.cpp index 471c47cb..b380fd2d 100644 --- a/src/engine/N3Base/N3FXPMesh.cpp +++ b/src/engine/N3Base/N3FXPMesh.cpp @@ -59,7 +59,7 @@ void CN3FXPMesh::operator=(const CN3FXPMesh & fxPMesh) { Release(); - FileNameSet(fxPMesh.FileName()); + FilePathSet(fxPMesh.FilePath()); m_iMaxNumVertices = fxPMesh.m_iMaxNumVertices; m_iMaxNumIndices = fxPMesh.m_iMaxNumIndices; diff --git a/src/engine/N3Base/N3FXPMeshInstance.cpp b/src/engine/N3Base/N3FXPMeshInstance.cpp index 8f0f3dba..605354ea 100644 --- a/src/engine/N3Base/N3FXPMeshInstance.cpp +++ b/src/engine/N3Base/N3FXPMeshInstance.cpp @@ -29,7 +29,7 @@ CN3FXPMeshInstance::CN3FXPMeshInstance(CN3FXPMesh * pN3FXPMesh) { CN3FXPMeshInstance::Create(pN3FXPMesh); } -CN3FXPMeshInstance::CN3FXPMeshInstance(const std::string & szFN) { +CN3FXPMeshInstance::CN3FXPMeshInstance(const fs::path & fsFile) { m_pFXPMesh = NULL; m_pIndices = NULL; m_pColorVertices = NULL; @@ -37,7 +37,7 @@ CN3FXPMeshInstance::CN3FXPMeshInstance(const std::string & szFN) { m_iNumIndices = 0; m_pCollapseUpTo = NULL; - this->Create(szFN); + this->Create(fsFile); } CN3FXPMeshInstance::~CN3FXPMeshInstance() { @@ -118,13 +118,13 @@ bool CN3FXPMeshInstance::Create(CN3FXPMesh * pN3FXPMesh) { return true; } -bool CN3FXPMeshInstance::Create(const std::string & szFN) { - if (m_pFXPMesh && m_pFXPMesh->FileName() == szFN) { +bool CN3FXPMeshInstance::Create(const fs::path & fsFile) { + if (m_pFXPMesh && m_pFXPMesh->FilePath() == fsFile) { return true; // 파일 이름이 같으면 새로 만들지 않고 리턴하자 } this->Release(); - CN3FXPMesh * pN3FXPMesh = s_MngFXPMesh.Get(szFN); + CN3FXPMesh * pN3FXPMesh = s_MngFXPMesh.Get(fsFile); return this->Create(pN3FXPMesh); } diff --git a/src/engine/N3Base/N3FXPMeshInstance.h b/src/engine/N3Base/N3FXPMeshInstance.h index 6955dea2..c77b39f9 100644 --- a/src/engine/N3Base/N3FXPMeshInstance.h +++ b/src/engine/N3Base/N3FXPMeshInstance.h @@ -14,7 +14,7 @@ class CN3FXPMeshInstance : public CN3Base { public: CN3FXPMeshInstance(); CN3FXPMeshInstance(CN3FXPMesh * pN3FXPMesh); - CN3FXPMeshInstance(const std::string & szFN); + CN3FXPMeshInstance(const fs::path & fsFile); virtual ~CN3FXPMeshInstance(); protected: @@ -40,7 +40,7 @@ class CN3FXPMeshInstance : public CN3Base { return TRUE; } bool Create(CN3FXPMesh * pN3FXPMesh); - bool Create(const std::string & szFN); + bool Create(const fs::path & fsFile); void Release(); void Render(); void RenderTwoUV(); diff --git a/src/engine/N3Base/N3FXPartBase.cpp b/src/engine/N3Base/N3FXPartBase.cpp index 2515387f..bfc1b17c 100644 --- a/src/engine/N3Base/N3FXPartBase.cpp +++ b/src/engine/N3Base/N3FXPartBase.cpp @@ -43,8 +43,6 @@ CN3FXPartBase::CN3FXPartBase() { m_fFadeOut = 0.0f; m_fFadeIn = 0.0f; - ZeroMemory(m_pTexName, MAX_PATH); - m_bOnGround = false; m_dwRenderFlag = RF_ALPHABLENDING | RF_NOTUSEFOG | RF_DIFFUSEALPHA | RF_NOTUSELIGHT | RF_DOUBLESIDED; @@ -86,23 +84,23 @@ CN3FXPartBase::~CN3FXPartBase() { #ifdef _N3TOOL bool CN3FXPartBase::ParseScript(char * szCommand, char * szBuff0, char * szBuff1, char * szBuff2, char * szBuff3) { // 이름. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_strName = szBuff0; return true; } // 타입.. - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "particle") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "particle")) { m_iType = FX_PART_TYPE_PARTICLE; } - if (lstrcmpi(szBuff0, "board") == 0) { + if (n3std::iequals(szBuff0, "board")) { m_iType = FX_PART_TYPE_BOARD; } - if (lstrcmpi(szBuff0, "mesh") == 0) { + if (n3std::iequals(szBuff0, "mesh")) { m_iType = FX_PART_TYPE_MESH; } - if (lstrcmpi(szBuff0, "ground") == 0) { + if (n3std::iequals(szBuff0, "ground")) { m_iType = FX_PART_TYPE_BOTTOMBOARD; } //^^v 더 넣을꺼 있으면 넣어라.. @@ -110,45 +108,34 @@ bool CN3FXPartBase::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 } // 지속시간.(0이면 무한대...) - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fLife = atof(szBuff0); return true; } // texture 이름과 개수 읽기. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_iNumTex = atoi(szBuff1); m_ppRefTex = new CN3Texture *[m_iNumTex]; - char szPathName[_MAX_PATH]; - char szDir[_MAX_DIR]; - char szFileName[_MAX_PATH]; - char szExt[_MAX_EXT]; - - sprintf(szPathName, szBuff0); - _splitpath(szPathName, NULL, szDir, szFileName, szExt); - sprintf(m_pTexName, "%s%s", szDir, szFileName); + fs::path fsFile = szBuff0; + m_fsTexFileBase = fsFile.parent_path() / fsFile.stem(); - std::string FileName = m_pTexName; - char Buff[5]; + std::string szExt = fsFile.extension().string(); for (int i = 0; i < m_iNumTex; i++) { - sprintf(Buff, "%04d", i); - FileName = m_pTexName; - FileName += Buff; - FileName += szExt; - m_ppRefTex[i] = CN3Base::s_MngTex.Get(FileName); + m_ppRefTex[i] = CN3Base::s_MngTex.Get(m_fsTexFileBase + std::format("{:04d}{:s}", i, szExt)); } return true; } // texture animation speed 설정.. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fTexFPS = atof(szBuff0); return true; } // 상대위치... - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_vPos.x = atof(szBuff0); m_vPos.y = atof(szBuff1); m_vPos.z = atof(szBuff2); @@ -156,7 +143,7 @@ bool CN3FXPartBase::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 } // 속도.. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { __Vector3 v; m_vVelocity.x = atof(szBuff0); m_vVelocity.y = atof(szBuff1); @@ -165,7 +152,7 @@ bool CN3FXPartBase::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 } // 가속도.. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { __Vector3 v; m_vAcceleration.x = atof(szBuff0); m_vAcceleration.y = atof(szBuff1); @@ -174,7 +161,7 @@ bool CN3FXPartBase::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 } // 회전 각속도.. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { __Vector3 v; m_vRotVelocity.x = atof(szBuff0); m_vRotVelocity.y = atof(szBuff1); @@ -183,114 +170,114 @@ bool CN3FXPartBase::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 } // SRCBLEND.. - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "ONE") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "ONE")) { m_dwSrcBlend = D3DBLEND_ONE; - } else if (lstrcmpi(szBuff0, "ZERO") == 0) { + } else if (n3std::iequals(szBuff0, "ZERO")) { m_dwSrcBlend = D3DBLEND_ZERO; - } else if (lstrcmpi(szBuff0, "SRCCOLOR") == 0) { + } else if (n3std::iequals(szBuff0, "SRCCOLOR")) { m_dwSrcBlend = D3DBLEND_SRCCOLOR; - } else if (lstrcmpi(szBuff0, "INVSRCCOLOR") == 0) { + } else if (n3std::iequals(szBuff0, "INVSRCCOLOR")) { m_dwSrcBlend = D3DBLEND_INVSRCCOLOR; - } else if (lstrcmpi(szBuff0, "SRCALPHA") == 0) { + } else if (n3std::iequals(szBuff0, "SRCALPHA")) { m_dwSrcBlend = D3DBLEND_SRCALPHA; - } else if (lstrcmpi(szBuff0, "INVSRCALPHA") == 0) { + } else if (n3std::iequals(szBuff0, "INVSRCALPHA")) { m_dwSrcBlend = D3DBLEND_INVSRCALPHA; } return true; } // SRCBLEND.. - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "ONE") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "ONE")) { m_dwDestBlend = D3DBLEND_ONE; - } else if (lstrcmpi(szBuff0, "ZERO") == 0) { + } else if (n3std::iequals(szBuff0, "ZERO")) { m_dwDestBlend = D3DBLEND_ZERO; - } else if (lstrcmpi(szBuff0, "SRCCOLOR") == 0) { + } else if (n3std::iequals(szBuff0, "SRCCOLOR")) { m_dwDestBlend = D3DBLEND_SRCCOLOR; - } else if (lstrcmpi(szBuff0, "INVSRCCOLOR") == 0) { + } else if (n3std::iequals(szBuff0, "INVSRCCOLOR")) { m_dwDestBlend = D3DBLEND_INVSRCCOLOR; - } else if (lstrcmpi(szBuff0, "SRCALPHA") == 0) { + } else if (n3std::iequals(szBuff0, "SRCALPHA")) { m_dwDestBlend = D3DBLEND_SRCALPHA; - } else if (lstrcmpi(szBuff0, "INVSRCALPHA") == 0) { + } else if (n3std::iequals(szBuff0, "INVSRCALPHA")) { m_dwDestBlend = D3DBLEND_INVSRCALPHA; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_dwRenderFlag |= RF_ALPHABLENDING; - if (lstrcmpi(szBuff0, "TRUE") == 0) { + if (n3std::iequals(szBuff0, "TRUE")) { m_bAlpha = TRUE; - } else if (lstrcmpi(szBuff0, "FALSE") == 0) { + } else if (n3std::iequals(szBuff0, "FALSE")) { m_bAlpha = FALSE; m_dwRenderFlag ^= RF_ALPHABLENDING; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fFadeOut = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fFadeIn = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "TRUE") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "TRUE")) { m_bOnGround = true; - } else if (lstrcmpi(szBuff0, "FALSE") == 0) { + } else if (n3std::iequals(szBuff0, "FALSE")) { m_bOnGround = false; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_dwRenderFlag |= RF_DOUBLESIDED; - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szBuff0, "true")) { m_dwDoubleSide = D3DCULL_NONE; } - if (lstrcmpi(szBuff0, "false") == 0) { + if (n3std::iequals(szBuff0, "false")) { m_dwDoubleSide = D3DCULL_CCW; m_dwRenderFlag ^= RF_DOUBLESIDED; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_dwRenderFlag |= RF_NOTUSELIGHT; - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szBuff0, "true")) { m_dwLight = TRUE; m_dwRenderFlag ^= RF_NOTUSELIGHT; } - if (lstrcmpi(szBuff0, "false") == 0) { + if (n3std::iequals(szBuff0, "false")) { m_dwLight = FALSE; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_dwRenderFlag |= RF_NOTZBUFFER; - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szBuff0, "true")) { m_dwZEnable = D3DZB_TRUE; m_dwRenderFlag ^= RF_NOTZBUFFER; } - if (lstrcmpi(szBuff0, "false") == 0) { + if (n3std::iequals(szBuff0, "false")) { m_dwZEnable = D3DZB_FALSE; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_dwRenderFlag |= RF_NOTZWRITE; - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szBuff0, "true")) { m_dwZWrite = TRUE; m_dwRenderFlag ^= RF_NOTZWRITE; } - if (lstrcmpi(szBuff0, "false") == 0) { + if (n3std::iequals(szBuff0, "false")) { m_dwZWrite = FALSE; } return true; @@ -305,39 +292,33 @@ bool CN3FXPartBase::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 // 스크립트 파일 읽고 해석.(call parse script..) // #ifdef _N3TOOL -bool CN3FXPartBase::DecodeScriptFile(const char * lpPathName) { - // char szGamePathName[_MAX_PATH]; - // char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - // _splitpath(lpPathName, szDrive, szDir, szFName, szExt); - // _makepath(szGamePathName, szDrive, szDir, szFName, "fxp"); - // CN3BaseFileAccess::FileNameSet(szGamePathName); - CN3BaseFileAccess::FileNameSet(lpPathName); - - FILE * stream = fopen(lpPathName, "r"); +bool CN3FXPartBase::DecodeScriptFile(const fs::path & fsFile) { + // fs::path fsFxpPath = fs::path(fsFile).replace_extension(".fxp"); + // CN3BaseFileAccess::FilePathSet(fsFxpPath); + CN3BaseFileAccess::FilePathSet(fsFile); + + FILE * stream = _wfopen(fsFile.c_str(), L"r"); if (!stream) { return false; } - char szLine[512] = "", szCommand[80] = "", szBuf[4][80] = {"", "", "", ""}; - char * pResult = fgets(szLine, 512, stream); + char szLine[512]{}, szCommand[80]{}, szBuf[4][80]{}; + char * pResult = fgets(szLine, sizeof(szLine), stream); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "")) { + if (!n3std::iequals(szCommand, "")) { fclose(stream); return false; } while (!feof(stream)) { - char * pResult = fgets(szLine, 512, stream); + char * pResult = fgets(szLine, sizeof(szLine), stream); if (pResult == NULL) { continue; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); ParseScript(szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); } @@ -442,7 +423,10 @@ bool CN3FXPartBase::Load(HANDLE hFile) { ReadFile(hFile, &m_iNumTex, sizeof(int), &dwRWC, NULL); ReadFile(hFile, &m_fTexFPS, sizeof(float), &dwRWC, NULL); - ReadFile(hFile, &m_pTexName, MAX_PATH, &dwRWC, NULL); + + char szTexFileBase[260]{}; + ReadFile(hFile, &szTexFileBase, sizeof(szTexFileBase), &dwRWC, NULL); + m_fsTexFileBase = fs::path(szTexFileBase).generic_string(); if (m_iBaseVersion < 2) { ReadFile(hFile, &m_bAlpha, sizeof(BOOL), &dwRWC, NULL); @@ -489,16 +473,8 @@ bool CN3FXPartBase::Load(HANDLE hFile) { } m_ppRefTex = new CN3Texture *[m_iNumTex]; - - std::string FileName; - char Buff[5]; for (int i = 0; i < m_iNumTex; i++) { - sprintf(Buff, "%04d", i); - FileName = m_pTexName; - FileName += Buff; - FileName += ".dxt"; - - m_ppRefTex[i] = CN3Base::s_MngTex.Get(FileName); + m_ppRefTex[i] = CN3Base::s_MngTex.Get(m_fsTexFileBase + std::format("{:04d}.dxt", i)); } return true; @@ -534,7 +510,9 @@ bool CN3FXPartBase::Save(HANDLE hFile) { WriteFile(hFile, &m_fTexFPS, sizeof(float), &dwRWC, NULL); - WriteFile(hFile, &m_pTexName, MAX_PATH, &dwRWC, NULL); + char szTexFileBase[260]{}; + fs::path(m_fsTexFileBase).normalize('/', '\\').string().copy(szTexFileBase, sizeof(szTexFileBase) - 1); + WriteFile(hFile, szTexFileBase, sizeof(szTexFileBase), &dwRWC, NULL); /* if(m_iBaseVersion<2) @@ -593,7 +571,7 @@ void CN3FXPartBase::Duplicate(CN3FXPartBase * pSrc) { m_vPos = pSrc->m_vPos; m_iNumTex = pSrc->m_iNumTex; m_fTexFPS = pSrc->m_fTexFPS; - sprintf(m_pTexName, pSrc->m_pTexName); + m_fsTexFileBase = pSrc->m_fsTexFileBase; m_dwZEnable = pSrc->m_dwZEnable; m_dwZWrite = pSrc->m_dwZWrite; @@ -609,14 +587,7 @@ void CN3FXPartBase::Duplicate(CN3FXPartBase * pSrc) { m_ppRefTex = new CN3Texture *[m_iNumTex]; - std::string FileName; - char Buff[5]; for (int i = 0; i < m_iNumTex; i++) { - sprintf(Buff, "%04d", i); - FileName = m_pTexName; - FileName += Buff; - FileName += ".dxt"; - - m_ppRefTex[i] = CN3Base::s_MngTex.Get(FileName); + m_ppRefTex[i] = CN3Base::s_MngTex.Get(m_fsTexFileBase + std::format("{:04d}.dxt", i)); } -} \ No newline at end of file +} diff --git a/src/engine/N3Base/N3FXPartBase.h b/src/engine/N3Base/N3FXPartBase.h index 81ca1367..902e1660 100644 --- a/src/engine/N3Base/N3FXPartBase.h +++ b/src/engine/N3Base/N3FXPartBase.h @@ -37,8 +37,7 @@ class CN3FXPartBase : public CN3BaseFileAccess { bool m_bOnGround; //바닥에 붙어서 갈 것인가... - //texture.. - char m_pTexName[MAX_PATH]; + fs::path m_fsTexFileBase; // without texture index and ext (fx/billboard/tex|{0,1,2}.dxt) CN3Texture ** m_ppRefTex; int m_iNumTex; float m_fTexFPS; @@ -78,7 +77,7 @@ class CN3FXPartBase : public CN3BaseFileAccess { char * szBuff3); //실질적인 스크립트 해석 함수.. public: - bool DecodeScriptFile(const char * lpPathName); + bool DecodeScriptFile(const fs::path & fsFile); #endif // end of _N3TOOL public: diff --git a/src/engine/N3Base/N3FXPartBillBoard.cpp b/src/engine/N3Base/N3FXPartBillBoard.cpp index d6fc287b..ee1e3416 100644 --- a/src/engine/N3Base/N3FXPartBillBoard.cpp +++ b/src/engine/N3Base/N3FXPartBillBoard.cpp @@ -57,7 +57,7 @@ bool CN3FXPartBillBoard::ParseScript(char * szCommand, char * szBuff0, char * sz } // 보드 갯수. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_iNum = atoi(szBuff0); if (m_iNum > 0) { CreateVB(); @@ -66,7 +66,7 @@ bool CN3FXPartBillBoard::ParseScript(char * szCommand, char * szBuff0, char * sz } // 보드 크기. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fSizeX = atof(szBuff0); m_fSizeY = atof(szBuff1); @@ -74,30 +74,30 @@ bool CN3FXPartBillBoard::ParseScript(char * szCommand, char * szBuff0, char * sz m_fCurrSizeY = m_fSizeY; return true; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "true")) { m_bTexLoop = true; - } else if (lstrcmpi(szBuff0, "false") == 0) { + } else if (n3std::iequals(szBuff0, "false")) { m_bTexLoop = false; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fRadius = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "true")) { m_bRoateOnlyY = true; - } else if (lstrcmpi(szBuff0, "false") == 0) { + } else if (n3std::iequals(szBuff0, "false")) { m_bRoateOnlyY = false; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fScaleVelX = atof(szBuff0); m_fScaleVelY = atof(szBuff1); @@ -106,13 +106,13 @@ bool CN3FXPartBillBoard::ParseScript(char * szCommand, char * szBuff0, char * sz return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fScaleAccelX = atof(szBuff0); m_fScaleAccelY = atof(szBuff1); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fRotBillBoardX = atof(szBuff0); m_fRotBillBoardY = atof(szBuff1); m_fRotBillBoardZ = atof(szBuff2); diff --git a/src/engine/N3Base/N3FXPartBottomBoard.cpp b/src/engine/N3Base/N3FXPartBottomBoard.cpp index 2c1043bd..d99d05d9 100644 --- a/src/engine/N3Base/N3FXPartBottomBoard.cpp +++ b/src/engine/N3Base/N3FXPartBottomBoard.cpp @@ -58,7 +58,7 @@ bool CN3FXPartBottomBoard::ParseScript(char * szCommand, char * szBuff0, char * } // 보드 크기. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fCurrSizeX = m_fSizeX = atof(szBuff0); m_fCurrSizeZ = m_fSizeZ = atof(szBuff1); /* @@ -70,25 +70,25 @@ bool CN3FXPartBottomBoard::ParseScript(char * szCommand, char * szBuff0, char * */ return true; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "true")) { m_bTexLoop = true; - } else if (lstrcmpi(szBuff0, "false") == 0) { + } else if (n3std::iequals(szBuff0, "false")) { m_bTexLoop = false; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fScaleVelX = atof(szBuff0); m_fScaleVelZ = atof(szBuff1); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fScaleAccelX = atof(szBuff0); m_fScaleAccelZ = atof(szBuff1); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fGap = atof(szBuff0); return true; } diff --git a/src/engine/N3Base/N3FXPartMesh.cpp b/src/engine/N3Base/N3FXPartMesh.cpp index fbbc5a3c..19a7fcf7 100644 --- a/src/engine/N3Base/N3FXPartMesh.cpp +++ b/src/engine/N3Base/N3FXPartMesh.cpp @@ -56,12 +56,11 @@ bool CN3FXPartMesh::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 return true; } - if (lstrcmpi(szCommand, "") == 0) { - char szPath[MAX_PATH]; - sprintf(szPath, szBuff0); + if (n3std::iequals(szCommand, "")) { + fs::path fsShapeFile = szBuff0; m_pShape = new CN3FXShape; - m_pRefShape = s_MngFXShape.Get(szPath); + m_pRefShape = s_MngFXShape.Get(fsShapeFile); m_pShape->Duplicate(m_pRefShape); __Vector3 vScale; @@ -73,14 +72,14 @@ bool CN3FXPartMesh::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 return true; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "up") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "up")) { m_cTextureMoveDir = 1; - } else if (lstrcmpi(szBuff0, "down") == 0) { + } else if (n3std::iequals(szBuff0, "down")) { m_cTextureMoveDir = 2; - } else if (lstrcmpi(szBuff0, "left") == 0) { + } else if (n3std::iequals(szBuff0, "left")) { m_cTextureMoveDir = 3; - } else if (lstrcmpi(szBuff0, "right") == 0) { + } else if (n3std::iequals(szBuff0, "right")) { m_cTextureMoveDir = 4; } @@ -102,20 +101,20 @@ bool CN3FXPartMesh::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_vScaleVel.Set(atof(szBuff0), atof(szBuff1), atof(szBuff2)); m_vCurrScaleVel = m_vScaleVel; return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_vScaleAccel.Set(atof(szBuff0), atof(szBuff1), atof(szBuff2)); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_vUnitScale.Set(atof(szBuff0), atof(szBuff1), atof(szBuff2)); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fTexFPS = atof(szBuff0); if (!m_pShape) { return false; @@ -125,9 +124,9 @@ bool CN3FXPartMesh::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_bTexLoop = true; - if (lstrcmpi(szBuff0, "false") == 0) { + if (n3std::iequals(szBuff0, "false")) { m_bTexLoop = false; } @@ -139,12 +138,12 @@ bool CN3FXPartMesh::ParseScript(char * szCommand, char * szBuff0, char * szBuff1 } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fMeshFPS = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { Init(); return true; } @@ -190,18 +189,18 @@ bool CN3FXPartMesh::Load(HANDLE hFile) { DWORD dwRWC = 0; - char szShapeFileName[_MAX_PATH]; - ReadFile(hFile, szShapeFileName, _MAX_PATH, &dwRWC, NULL); + char szShapeFile[260]{}; + ReadFile(hFile, szShapeFile, sizeof(szShapeFile), &dwRWC, NULL); if (m_pShape) { delete m_pShape; } m_pShape = new CN3FXShape; - m_pRefShape = s_MngFXShape.Get(szShapeFileName); + m_pRefShape = s_MngFXShape.Get(szShapeFile); m_pShape->Duplicate(m_pRefShape); m_pShape->SetPartsMtl(m_bAlpha, m_dwSrcBlend, m_dwDestBlend, m_dwZEnable, m_dwZWrite, m_dwLight, m_dwDoubleSide); - //m_pShape->LoadFromFile(szShapeFileName); + //m_pShape->LoadFromFile(szShapeFile); __Vector3 vScale; if (m_pShape->m_KeyScale.DataGet(0, vScale)) { m_vUnitScale = vScale; @@ -250,10 +249,9 @@ bool CN3FXPartMesh::Save(HANDLE hFile) { DWORD dwRWC = 0; - char szShapeFileName[_MAX_PATH]; - sprintf(szShapeFileName, m_pShape->FileName().c_str()); - - WriteFile(hFile, szShapeFileName, _MAX_PATH, &dwRWC, NULL); + char szShapeFile[260]{}; + m_pShape->FilePathWin().string().copy(szShapeFile, sizeof(szShapeFile) - 1); + WriteFile(hFile, szShapeFile, sizeof(szShapeFile), &dwRWC, NULL); WriteFile(hFile, &m_cTextureMoveDir, sizeof(char), &dwRWC, NULL); WriteFile(hFile, &m_fu, sizeof(float), &dwRWC, NULL); @@ -678,7 +676,7 @@ void CN3FXPartMesh::Duplicate(CN3FXPartMesh * pSrc) { m_pShape = new CN3FXShape; - m_pRefShape = s_MngFXShape.Get(pSrc->m_pRefShape->FileName()); + m_pRefShape = s_MngFXShape.Get(pSrc->m_pRefShape->FilePath()); m_pShape->Duplicate(m_pRefShape); m_pShape->SetPartsMtl(m_bAlpha, m_dwSrcBlend, m_dwDestBlend, m_dwZEnable, m_dwZWrite, m_dwLight, m_dwDoubleSide); diff --git a/src/engine/N3Base/N3FXPartParticles.cpp b/src/engine/N3Base/N3FXPartParticles.cpp index f9b63252..6048a0cb 100644 --- a/src/engine/N3Base/N3FXPartParticles.cpp +++ b/src/engine/N3Base/N3FXPartParticles.cpp @@ -130,7 +130,7 @@ bool CN3FXPartParticles::ParseScript(char * szCommand, char * szBuff0, char * sz } // 파티클 수. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_iNumParticle = atoi(szBuff0); if (m_iNumParticle > 0) { InitVB(); @@ -139,53 +139,53 @@ bool CN3FXPartParticles::ParseScript(char * szCommand, char * szBuff0, char * sz } // 파티클 크기. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_pair_fParticleSize.first = m_pair_fParticleSize.second = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_pair_fParticleSize.first = atof(szBuff0); m_pair_fParticleSize.second = atof(szBuff1); return true; } // 파티클 생명. - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_pair_fParticleLife.first = atof(szBuff0); m_pair_fParticleLife.second = atof(szBuff1); return true; } // 파티클 시작오차..min - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_MinCreateRange.Set(atof(szBuff0), atof(szBuff1), atof(szBuff2)); return true; } // 파티클 시작오차..max - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_MaxCreateRange.Set(atof(szBuff0), atof(szBuff1), atof(szBuff2)); return true; } // 파티클 한번에 생성 갯수 - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_iNumCreate = atoi(szBuff0); return true; } // 파티클 한번에 생성 시간 범위 - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_CurrCreateDelay = m_fCreateDelay = atof(szBuff0); return true; } // 시작하는 방법. - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "spread") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "spread")) { m_dwEmitType = FX_PART_PARTICLE_EMIT_TYPE_SPREAD; m_uEmitCon.fEmitAngle = atof(szBuff1); - } else if (lstrcmpi(szBuff0, "gather") == 0) { + } else if (n3std::iequals(szBuff0, "gather")) { m_dwEmitType = FX_PART_PARTICLE_EMIT_TYPE_GATHER; m_uEmitCon.vGatherPoint.x = atof(szBuff1); m_uEmitCon.vGatherPoint.y = atof(szBuff2); @@ -194,33 +194,33 @@ bool CN3FXPartParticles::ParseScript(char * szCommand, char * szBuff0, char * sz return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_vPtEmitDir.Set(atof(szBuff0), atof(szBuff1), atof(szBuff2)); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fPtVelocity = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fPtAccel = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { float Degree = atof(szBuff0); m_fPtRotVelocity = D3DXToRadian(Degree); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fPtGravity = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { int seq = atoi(szBuff0); DWORD color = atoi(szBuff1); if (seq >= 0 && seq < NUM_KEY_COLOR) { @@ -229,58 +229,57 @@ bool CN3FXPartParticles::ParseScript(char * szCommand, char * szBuff0, char * sz return true; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "true")) { m_bChangeColor = true; } - if (lstrcmpi(szBuff0, "false") == 0) { + if (n3std::iequals(szBuff0, "false")) { m_bChangeColor = false; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { int seq = atoi(szBuff0); if (seq >= 0 && seq < NUM_KEY_COLOR) { m_bChangeColorKey[seq] = true; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { int seq = atoi(szBuff0); if (seq >= 0 && seq < NUM_KEY_COLOR) { m_bChangeAlphaKey[seq] = true; } return true; } - if (lstrcmpi(szCommand, "") == 0 && lstrcmpi(szBuff0, "") != 0) { - char szPath[MAX_PATH]; - sprintf(szPath, szBuff0); + if (n3std::iequals(szCommand, "") && szBuff0[0] != '\0') { + fs::path fsShapeFile = szBuff0; m_pShape = new CN3FXShape; - m_pRefShape = s_MngFXShape.Get(szPath); + m_pRefShape = s_MngFXShape.Get(fsShapeFile); m_pShape->Duplicate(m_pRefShape); m_vCurrPos = m_pShape->CenterPos(); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fMeshFPS = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuff0, "true") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuff0, "true")) { m_bAnimKey = true; } - if (lstrcmpi(szBuff0, "false") == 0) { + if (n3std::iequals(szBuff0, "false")) { m_bAnimKey = false; } return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fTexRotateVelocity = atof(szBuff0); return true; } - if (lstrcmpi(szCommand, "") == 0) { + if (n3std::iequals(szCommand, "")) { m_fScaleVelX = atof(szBuff0); m_fScaleVelY = atof(szBuff1); return true; @@ -395,8 +394,8 @@ bool CN3FXPartParticles::Load(HANDLE hFile) { if (m_bAnimKey) { ReadFile(hFile, &m_fMeshFPS, sizeof(float), &dwRWC, NULL); - char szShapeFileName[_MAX_PATH]; - ReadFile(hFile, szShapeFileName, _MAX_PATH, &dwRWC, NULL); + char szShapeFile[260]{}; + ReadFile(hFile, szShapeFile, sizeof(szShapeFile), &dwRWC, NULL); if (m_pShape) { delete m_pShape; @@ -405,7 +404,7 @@ bool CN3FXPartParticles::Load(HANDLE hFile) { m_pShape = new CN3FXShape; - m_pRefShape = s_MngFXShape.Get(szShapeFileName); + m_pRefShape = s_MngFXShape.Get(szShapeFile); m_pShape->Duplicate(m_pRefShape); } @@ -470,9 +469,9 @@ bool CN3FXPartParticles::Save(HANDLE hFile) { if (m_bAnimKey) { WriteFile(hFile, &m_fMeshFPS, sizeof(float), &dwRWC, NULL); - char szShapeFileName[_MAX_PATH]; - sprintf(szShapeFileName, m_pRefShape->FileName().c_str()); - WriteFile(hFile, szShapeFileName, _MAX_PATH, &dwRWC, NULL); + char szShapeFile[260]{}; + m_pRefShape->FilePathWin().string().copy(szShapeFile, sizeof(szShapeFile) - 1); + WriteFile(hFile, szShapeFile, sizeof(szShapeFile), &dwRWC, NULL); } WriteFile(hFile, &m_fTexRotateVelocity, sizeof(float), &dwRWC, NULL); @@ -1312,7 +1311,7 @@ void CN3FXPartParticles::Duplicate(CN3FXPartParticles * pSrc) { m_pShape = new CN3FXShape; - m_pRefShape = s_MngFXShape.Get(pSrc->m_pRefShape->FileName()); + m_pRefShape = s_MngFXShape.Get(pSrc->m_pRefShape->FilePath()); m_pShape->Duplicate(m_pRefShape); } diff --git a/src/engine/N3Base/N3FXPlug.cpp b/src/engine/N3Base/N3FXPlug.cpp index f388281d..f11c40d7 100644 --- a/src/engine/N3Base/N3FXPlug.cpp +++ b/src/engine/N3Base/N3FXPlug.cpp @@ -32,20 +32,19 @@ void CN3FXPlugPart::Release() { } bool CN3FXPlugPart::Load(HANDLE hFile) { - if (false == CN3BaseFileAccess::Load(hFile)) { + if (!CN3BaseFileAccess::Load(hFile)) { return false; } __ASSERT(NULL == m_pFXB, "must null"); - DWORD dwNum; - int nStrLen; - ReadFile(hFile, &nStrLen, sizeof(nStrLen), &dwNum, NULL); - if (nStrLen > 0) { - char szFN[_MAX_PATH]; - ReadFile(hFile, szFN, nStrLen, &dwNum, NULL); - szFN[nStrLen] = NULL; + DWORD dwNum = 0; + int iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); + if (iLen > 0) { + std::string szFile(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwNum, NULL); m_pFXB = new CN3FXBundle(); - if (false == m_pFXB->LoadFromFile(szFN)) { + if (!m_pFXB->LoadFromFile(szFile)) { delete m_pFXB; m_pFXB = NULL; } else { @@ -68,10 +67,14 @@ bool CN3FXPlugPart::Save(HANDLE hFile) { } __ASSERT(m_pFXB, "no FXB"); - DWORD dwNum; - int nStrLen = m_pFXB->FileName().size(); - WriteFile(hFile, &nStrLen, sizeof(nStrLen), &dwNum, NULL); - WriteFile(hFile, m_pFXB->FileName().c_str(), nStrLen, &dwNum, NULL); + DWORD dwNum; + std::string szFile = m_pFXB->FilePathWin().string(); + int iLen = szFile.length(); + + WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwNum, NULL); + } WriteFile(hFile, &m_nRefIndex, sizeof(m_nRefIndex), &dwNum, NULL); WriteFile(hFile, &m_vOffsetPos, sizeof(m_vOffsetPos), &dwNum, NULL); WriteFile(hFile, &m_vOffsetDir, sizeof(m_vOffsetDir), &dwNum, NULL); @@ -123,13 +126,13 @@ void CN3FXPlugPart::Render() { } } -void CN3FXPlugPart::SetFXB(const std::string & strFN) { +void CN3FXPlugPart::SetFXB(const fs::path & fsFile) { if (NULL == m_pFXB) { m_pFXB = new CN3FXBundle(); } else { m_pFXB->Release(); } - m_pFXB->LoadFromFile(strFN); + m_pFXB->LoadFromFile(fsFile); m_vOffsetPos = m_pFXB->m_vPos; //일단 FXB에 설정되어 있는 vPos와 vDir값을 가져와서 적용. m_vOffsetDir = m_pFXB->m_vDir; diff --git a/src/engine/N3Base/N3FXPlug.h b/src/engine/N3Base/N3FXPlug.h index 81eb1ce5..3db0648a 100644 --- a/src/engine/N3Base/N3FXPlug.h +++ b/src/engine/N3Base/N3FXPlug.h @@ -36,7 +36,7 @@ class CN3FXPlugPart : public CN3BaseFileAccess { virtual bool Load(HANDLE hFile); const CN3FXBundle * GetFXB() const { return m_pFXB; } - void SetFXB(const std::string & strFN); + void SetFXB(const fs::path & fsFile); int GetRefIndex() const { return m_nRefIndex; } void SetRefIdx(int nRefIndex) { m_nRefIndex = nRefIndex; } void StopFXB(bool bImmediately); diff --git a/src/engine/N3Base/N3FXShape.cpp b/src/engine/N3Base/N3FXShape.cpp index a83956b2..f61fb502 100644 --- a/src/engine/N3Base/N3FXShape.cpp +++ b/src/engine/N3Base/N3FXShape.cpp @@ -78,12 +78,12 @@ CN3Texture * CN3FXSPart::Tex(int iIndex) { return m_TexRefs[iIndex]; } -CN3Texture * CN3FXSPart::TexSet(int iIndex, const std::string & szFN) { +CN3Texture * CN3FXSPart::TexSet(int iIndex, const fs::path & fsFile) { if (iIndex < 0 || iIndex >= m_TexRefs.size()) { return NULL; } s_MngTex.Delete(&m_TexRefs[iIndex]); - m_TexRefs[iIndex] = s_MngTex.Get(szFN); + m_TexRefs[iIndex] = s_MngTex.Get(fsFile); return m_TexRefs[iIndex]; } @@ -235,25 +235,24 @@ void CN3FXSPart::Render() { } bool CN3FXSPart::Load(HANDLE hFile) { - DWORD dwRWC; - int nL = 0; - char szFN[256]; + DWORD dwRWC = 0; + int iLen = 0; + std::string szFile; ReadFile(hFile, &m_vPivot, sizeof(__Vector3), &dwRWC, NULL); - ReadFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; // 메시 파일 이름.. + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName + if (iLen <= 0) { + N3_ERROR("CN3FXShape's n3shape file without n3pmesh ({:s})", FilePath().string()); + return false; + } - //m_pRefShape의 경로와 읽어들인 파일명을 합쳐라... - char szPath[_MAX_PATH]; - char szFName[_MAX_FNAME], szExt[_MAX_EXT]; - char szDir[_MAX_DIR]; - _splitpath(m_pRefShape->FileName().c_str(), NULL, szDir, NULL, NULL); - _splitpath(szFN, NULL, NULL, szFName, szExt); - _makepath(szPath, NULL, szDir, szFName, szExt); + szFile.assign(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); - if (!this->MeshSet(szPath)) { + fs::path fsDir = m_pRefShape->FilePath().parent_path(); + fs::path fsMeshFile = fsDir / fs::path(szFile).filename(); + if (!MeshSet(fsMeshFile)) { return false; } @@ -263,17 +262,16 @@ bool CN3FXSPart::Load(HANDLE hFile) { ReadFile(hFile, &iTC, 4, &dwRWC, NULL); ReadFile(hFile, &m_fTexFPS, 4, &dwRWC, NULL); m_TexRefs.clear(); - this->TexAlloc(iTC); // Texture Pointer Pointer 할당.. - for (int j = 0; j < iTC; j++) // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. - { - ReadFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; // 텍스처 파일 이름.. - - _splitpath(szFN, NULL, NULL, szFName, szExt); - _makepath(szPath, NULL, szDir, szFName, szExt); - m_TexRefs[j] = s_MngTex.Get(szPath); + this->TexAlloc(iTC); // Texture Pointer Pointer 할당.. + for (int j = 0; j < iTC; j++) { // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. + iLen = 0; + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + szFile.assign(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); + + fs::path fsTexFile = fsDir / fs::path(szFile).filename(); + m_TexRefs[j] = s_MngTex.Get(fsTexFile); } } @@ -283,7 +281,7 @@ bool CN3FXSPart::Load(HANDLE hFile) { void CN3FXSPart::Duplicate(CN3FXSPart * pSrc) { m_vPivot = pSrc->m_vPivot; if (pSrc->Mesh()) { - MeshSet(pSrc->Mesh()->FileName()); + MeshSet(pSrc->Mesh()->FilePath()); } m_Mtl = pSrc->m_Mtl; @@ -297,7 +295,7 @@ void CN3FXSPart::Duplicate(CN3FXSPart * pSrc) { for (int j = 0; j < iTC; j++) // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. { if (pSrc->Tex(j)) { - m_TexRefs[j] = s_MngTex.Get(pSrc->Tex(j)->FileName()); + m_TexRefs[j] = s_MngTex.Get(pSrc->Tex(j)->FilePath()); } } return; @@ -307,9 +305,8 @@ bool CN3FXSPart::Save(HANDLE hFile) { return true; } -bool CN3FXSPart::MeshSet(const std::string & szFN) { - m_FXPMInst.Create(szFN); - return true; +bool CN3FXSPart::MeshSet(const fs::path & fsFile) { + return m_FXPMInst.Create(fsFile); } // @@ -415,7 +412,7 @@ bool CN3FXShape::Save(HANDLE hFile) { DWORD dwRWC = 0; - int nL = 0; + int iLen = 0; CN3SPart* pPD = NULL; int iPC = m_Parts.size(); @@ -516,10 +513,10 @@ void CN3FXShape::Duplicate(CN3FXShape * pSrc) { SetMax(pSrc->Max()); if (pSrc->CollisionMesh()) { - SetMeshCollision(pSrc->CollisionMesh()->FileName()); + SetMeshCollision(pSrc->CollisionMesh()->FilePath()); } if (pSrc->ClimbMesh()) { - SetMeshClimb(pSrc->ClimbMesh()->FileName()); + SetMeshClimb(pSrc->ClimbMesh()->FilePath()); } //transform.... @@ -528,7 +525,7 @@ void CN3FXShape::Duplicate(CN3FXShape * pSrc) { RotSet(pSrc->Rot()); //basefileaccess - FileNameSet(pSrc->FileName()); + FilePathSet(pSrc->FilePath()); m_Matrix = pSrc->m_Matrix; // diff --git a/src/engine/N3Base/N3FXShape.h b/src/engine/N3Base/N3FXShape.h index 965c1e02..4e219f3d 100644 --- a/src/engine/N3Base/N3FXShape.h +++ b/src/engine/N3Base/N3FXShape.h @@ -42,7 +42,7 @@ class CN3FXSPart : public CN3BaseFileAccess { int TexCount() { return m_TexRefs.size(); } CN3Texture * Tex(int iIndex); void TexAlloc(int m_nCount); - CN3Texture * TexSet(int iIndex, const std::string & szFN); + CN3Texture * TexSet(int iIndex, const fs::path & fsFile); void TexSet(int iIndex, CN3Texture * pTex); __Vector3 Min() { @@ -70,7 +70,7 @@ class CN3FXSPart : public CN3BaseFileAccess { CN3FXPMesh * Mesh() { return m_FXPMInst.GetMesh(); } __VertexXyzColorT1 * GetColorVertices() { return m_FXPMInst.GetVertices(); } void SetColor(DWORD dwColor = 0xffffffff) { m_FXPMInst.SetColor(dwColor); } - bool MeshSet(const std::string & szFN); + bool MeshSet(const fs::path & fsFile); void Tick(const __Matrix44 & mtxParent); void Render(); void Release(); diff --git a/src/engine/N3Base/N3GESnow.cpp b/src/engine/N3Base/N3GESnow.cpp index 8f85814f..51246055 100644 --- a/src/engine/N3Base/N3GESnow.cpp +++ b/src/engine/N3Base/N3GESnow.cpp @@ -304,5 +304,5 @@ void CN3GESnow::Create(float fDensity, float fWidth, float fHeight, float fSnowS } m_pVB->Unlock(); - m_pTex = s_MngTex.Get("Misc\\Snow.DXT", TRUE); + m_pTex = s_MngTex.Get(fs::path("Misc") / "snow.dxt", TRUE); } diff --git a/src/engine/N3Base/N3IMesh.cpp b/src/engine/N3Base/N3IMesh.cpp index debccf08..4caad0ca 100644 --- a/src/engine/N3Base/N3IMesh.cpp +++ b/src/engine/N3Base/N3IMesh.cpp @@ -73,7 +73,7 @@ bool CN3IMesh::Create(int nFC, int nVC, int nUVC) { #ifdef _N3GAME if (nFC > 32768) { - CLogWriter::Write("CN3IMesh::Create - Too many faces. (more than 32768) (%s)", m_szFileName.c_str()); + CLogWriter::Write("CN3IMesh::Create - Too many faces. (more than 32768) (%s)", FilePath().string().c_str()); } #endif @@ -93,11 +93,10 @@ bool CN3IMesh::Create(int nFC, int nVC, int nUVC) { } // s_lpD3DDev->CreateVertexBuffer(nFC * 3 * sizeof(__VertexT1), 0, FVF_VNT1, D3DPOOL_MANAGED, &m_lpVB, NULL); - - // if(NULL == m_lpVB) - // { + // + // if (NULL == m_lpVB) { //#ifdef _N3GAME - // CLogWriter::Write("CN3IMesh::Create - Can't Create VertexBuffer (%s)", m_szFileName.c_str()); + // CLogWriter::Write("CN3IMesh::Create - Can't Create VertexBuffer (%s)", FilePath().string().c_str()); //#endif // this->Release(); // return false; diff --git a/src/engine/N3Base/N3Joint.cpp b/src/engine/N3Base/N3Joint.cpp index 73e74cc2..05afa9d6 100644 --- a/src/engine/N3Base/N3Joint.cpp +++ b/src/engine/N3Base/N3Joint.cpp @@ -534,7 +534,7 @@ void CN3Joint::CopyExceptAnimationKey(CN3Joint * pJSrc) { this->Release(); m_szName = pJSrc->m_szName; - m_szFileName = pJSrc->m_szFileName; + FilePathSet(pJSrc->FilePath()); m_vPos = pJSrc->m_vPos; m_qRot = pJSrc->m_qRot; diff --git a/src/engine/N3Base/N3Mesh.cpp b/src/engine/N3Base/N3Mesh.cpp index 16e9a0be..d8d43746 100644 --- a/src/engine/N3Base/N3Mesh.cpp +++ b/src/engine/N3Base/N3Mesh.cpp @@ -146,7 +146,8 @@ void CN3Mesh::Create(int nVC, int nIC) { { #ifdef _N3GAME if (nVC > 32768) { - CLogWriter::Write("CN3IMesh::Create - Too many vertices. (more than 32768) (%s)", m_szFileName.c_str()); + CLogWriter::Write("CN3IMesh::Create - Too many vertices. (more than 32768) (%s)", + FilePath().string().c_str()); } #endif if (m_pVertices) { @@ -161,7 +162,8 @@ void CN3Mesh::Create(int nVC, int nIC) { { #ifdef _N3GAME if (nIC > 32768) { - CLogWriter::Write("CN3IMesh::Create - Too many indices. (more than 32768) (%s)", m_szFileName.c_str()); + CLogWriter::Write("CN3IMesh::Create - Too many indices. (more than 32768) (%s)", + FilePath().string().c_str()); } #endif if (m_psnIndices) { diff --git a/src/engine/N3Base/N3Mng.h b/src/engine/N3Base/N3Mng.h index 5c1e9085..bb48968d 100644 --- a/src/engine/N3Base/N3Mng.h +++ b/src/engine/N3Base/N3Mng.h @@ -15,14 +15,14 @@ template class CN3Mng { protected: - typedef typename std::map::iterator it_Data; - typedef typename std::map::value_type val_Data; + typedef typename std::map::iterator it_Data; + typedef typename std::map::value_type val_Data; typedef typename std::map::iterator it_Ref; typedef typename std::map::value_type val_Ref; - std::map m_Datas; - std::map m_Refs; + std::map m_Datas; + std::map m_Refs; public: int Count() { return m_Datas.size(); } @@ -34,7 +34,7 @@ template class CN3Mng { #endif return -1; } - if (pData->FileName().empty()) { + if (pData->FilePath().empty()) { #ifdef _N3GAME CLogWriter::Write("CN3Mng::Add - Null object file name"); #endif @@ -49,7 +49,7 @@ template class CN3Mng { return -1; } - std::pair pairData = m_Datas.insert(val_Data(pData->FileName(), pData)); + std::pair pairData = m_Datas.insert(val_Data(pData->FilePath(), pData)); if (false == pairData.second) { #ifdef _N3GAME CLogWriter::Write("CN3Mng::Add - duplicated object's file name."); @@ -82,22 +82,20 @@ template class CN3Mng { return it->second; } - T * Get(const std::string & szFN, bool bIncreaseRefCount = TRUE, int iLOD = 0) { - if (szFN.empty()) { + T * Get(const fs::path & fsFile, bool bIncreaseRefCount = TRUE, int iLOD = 0) { + if (fsFile.empty()) { return NULL; } - std::string szFN2 = szFN; - CharLower(&(szFN2[0])); + + fs::path fsFile2 = fsFile.lower(); T * pData = NULL; - it_Data it = m_Datas.find(szFN2); - if (it == m_Datas.end()) // 못 찾았다.. - { + it_Data it = m_Datas.find(fsFile2); + if (it == m_Datas.end()) { // 못 찾았다.. pData = new T(); pData->m_iLOD = iLOD; // 로딩시 LOD 적용 - if (false == pData->LoadFromFile(szFN2)) // 파일 읽기에 실패했다!! - { + if (false == pData->LoadFromFile(fsFile2)) { // 파일 읽기에 실패했다!! delete pData; pData = NULL; } else { @@ -106,7 +104,7 @@ template class CN3Mng { if (reChk == -1) // 추가시 전에 데이터가 있어 참조 카운트를 하나 더한다 { T * pBakData = pData; // 같은 파일중 전 데이타를 받아 리턴(새로운 그림으로 바뀌지 않을수 있다) - it_Data it = m_Datas.find(pBakData->FileName()); + it_Data it = m_Datas.find(pBakData->FilePath()); pData = (*it).second; if (bIncreaseRefCount) { @@ -122,8 +120,7 @@ template class CN3Mng { } // asm } - } else // 찾았다..!! - { + } else { // 찾았다..!! pData = (*it).second; if (bIncreaseRefCount) { @@ -138,12 +135,12 @@ template class CN3Mng { return pData; } - bool IsExist(const std::string & szFN) { - if (szFN.empty()) { + bool IsExist(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } - if (m_Datas.find(szFN) != m_Datas.end()) { + if (m_Datas.find(fsFile) != m_Datas.end()) { return true; } else { return false; @@ -158,7 +155,7 @@ template class CN3Mng { return; } - it_Data it = m_Datas.find((*ppData)->FileName()); + it_Data it = m_Datas.find((*ppData)->FilePath()); if (it == m_Datas.end()) { return; // 못 찾았다.. } else // 찾았다..!! diff --git a/src/engine/N3Base/N3Moon.cpp b/src/engine/N3Base/N3Moon.cpp index f3b2340d..57fa8150 100644 --- a/src/engine/N3Base/N3Moon.cpp +++ b/src/engine/N3Base/N3Moon.cpp @@ -28,9 +28,9 @@ void CN3Moon::Release() { m_iMoonPhaseIndex = 0; } -void CN3Moon::Init(const std::string & szTexFN) { +void CN3Moon::Init(const fs::path & fsTexFile) { Release(); - m_pTexture = s_MngTex.Get(szTexFN); + m_pTexture = s_MngTex.Get(fsTexFile); __ASSERT(m_pTexture, "Texture load failed."); m_fMoonRatio = 0.2f; diff --git a/src/engine/N3Base/N3Moon.h b/src/engine/N3Base/N3Moon.h index 88c9f452..0a55bd91 100644 --- a/src/engine/N3Base/N3Moon.h +++ b/src/engine/N3Base/N3Moon.h @@ -29,7 +29,7 @@ class CN3Moon : public CN3Base { // Operations public: - void Init(const std::string & szTexFN); + void Init(const fs::path & fsTexFile); void SetMoonPhase(int iIndex); // 달의 모양 설정 void SetCurAngle(float fAngle) { m_fCurRadian = D3DXToRadian(fAngle); } // 현재 각도설정 diff --git a/src/engine/N3Base/N3PMeshCreate.cpp b/src/engine/N3Base/N3PMeshCreate.cpp index 54b59393..b6648349 100644 --- a/src/engine/N3Base/N3PMeshCreate.cpp +++ b/src/engine/N3Base/N3PMeshCreate.cpp @@ -766,7 +766,7 @@ bool CN3PMeshCreate::ConvertFromN3PMesh(CN3PMesh * pN3PMesh) { Release(); CN3PMesh * pPMeshTmp = - CN3Base::s_MngPMesh.Get(pN3PMesh->FileName()); // 이래야 참조 카운트가 하나 늘어서 포인터가 안없어진다. + CN3Base::s_MngPMesh.Get(pN3PMesh->FilePath()); // 이래야 참조 카운트가 하나 늘어서 포인터가 안없어진다. CN3PMeshInstance PMeshInst(pN3PMesh); PMeshInst.SetLODByNumVertices(pN3PMesh->GetMaxNumVertices()); diff --git a/src/engine/N3Base/N3PMeshInstance.cpp b/src/engine/N3Base/N3PMeshInstance.cpp index 49679ef9..eaf5b2ed 100644 --- a/src/engine/N3Base/N3PMeshInstance.cpp +++ b/src/engine/N3Base/N3PMeshInstance.cpp @@ -39,7 +39,7 @@ CN3PMeshInstance::CN3PMeshInstance(CN3PMesh * pN3PMesh) { CN3PMeshInstance::Create(pN3PMesh); } -CN3PMeshInstance::CN3PMeshInstance(const std::string & szFN) { +CN3PMeshInstance::CN3PMeshInstance(const fs::path & fsFile) { m_pPMesh = NULL; #ifdef _USE_VERTEXBUFFER @@ -51,7 +51,7 @@ CN3PMeshInstance::CN3PMeshInstance(const std::string & szFN) { m_iNumIndices = 0; m_pCollapseUpTo = NULL; - this->Create(szFN); + this->Create(fsFile); } CN3PMeshInstance::~CN3PMeshInstance() { @@ -132,13 +132,13 @@ bool CN3PMeshInstance::Create(CN3PMesh * pN3PMesh) { return true; } -bool CN3PMeshInstance::Create(const std::string & szFN) { - if (m_pPMesh && m_pPMesh->FileName() == szFN) { +bool CN3PMeshInstance::Create(const fs::path & fsFile) { + if (m_pPMesh && m_pPMesh->FilePath() == fsFile) { return true; // 파일 이름이 같으면 새로 만들지 않고 리턴하자 } this->Release(); - CN3PMesh * pN3PMesh = s_MngPMesh.Get(szFN); + CN3PMesh * pN3PMesh = s_MngPMesh.Get(fsFile); return this->Create(pN3PMesh); } diff --git a/src/engine/N3Base/N3PMeshInstance.h b/src/engine/N3Base/N3PMeshInstance.h index 0ac5b71c..071a4a05 100644 --- a/src/engine/N3Base/N3PMeshInstance.h +++ b/src/engine/N3Base/N3PMeshInstance.h @@ -15,7 +15,7 @@ class CN3PMeshInstance : public CN3Base { public: CN3PMeshInstance(); CN3PMeshInstance(CN3PMesh * pN3PMesh); - CN3PMeshInstance(const std::string & szFN); + CN3PMeshInstance(const fs::path & fsFile); virtual ~CN3PMeshInstance(); protected: @@ -41,7 +41,7 @@ class CN3PMeshInstance : public CN3Base { return TRUE; } bool Create(CN3PMesh * pN3Mesh); - bool Create(const std::string & szFN); + bool Create(const fs::path & fsFile); void Release(); void Render(); void RenderTwoUV(); diff --git a/src/engine/N3Base/N3Pond.cpp b/src/engine/N3Base/N3Pond.cpp index 7430e3cc..cd9476ee 100644 --- a/src/engine/N3Base/N3Pond.cpp +++ b/src/engine/N3Base/N3Pond.cpp @@ -98,7 +98,7 @@ bool CN3Pond::Load(HANDLE hFile) { } fs::path fsTexFile = fs::path("Misc") / "river" / szFile; - ptmpPondMesh->m_pTexWave = s_MngTex.Get(fsTexFile.string()); + ptmpPondMesh->m_pTexWave = s_MngTex.Get(fsTexFile); __ASSERT(ptmpPondMesh->m_pTexWave, "CN3Pond::texture load failed"); } @@ -212,7 +212,7 @@ bool CN3Pond::Load(HANDLE hFile) { for (int i = 0; i < MAX_POND_TEX; i++) { fs::path fsTexFile = fs::path("Misc") / "river" / std::format("caust{:02d}.dxt", i); - m_pTexPond[i] = CN3Base::s_MngTex.Get(fsTexFile.string()); + m_pTexPond[i] = CN3Base::s_MngTex.Get(fsTexFile); __ASSERT(m_pTexPond[i], "CN3Pond::texture load failed"); } diff --git a/src/engine/N3Base/N3River.cpp b/src/engine/N3Base/N3River.cpp index bb653182..1de63efd 100644 --- a/src/engine/N3Base/N3River.cpp +++ b/src/engine/N3Base/N3River.cpp @@ -64,7 +64,7 @@ bool CN3River::Load(HANDLE hFile) { } fs::path fsTexFile = fs::path("Misc") / "river" / szFile; - pInfo->m_pTexWave = s_MngTex.Get(fsTexFile.string()); + pInfo->m_pTexWave = s_MngTex.Get(fsTexFile); __ASSERT(pInfo->m_pTexWave, "CN3River::texture load failed"); } @@ -129,7 +129,7 @@ bool CN3River::Load(HANDLE hFile) { for (int i = 0; i < MAX_RIVER_TEX; i++) { fs::path fsTexFile = fs::path("Misc") / "river" / std::format("caust{:02d}.dxt", i); - m_pTexRiver[i] = s_MngTex.Get(fsTexFile.string()); + m_pTexRiver[i] = s_MngTex.Get(fsTexFile); __ASSERT(m_pTexRiver[i], "CN3River::texture load failed"); } diff --git a/src/engine/N3Base/N3River2.cpp b/src/engine/N3Base/N3River2.cpp index 34df70ba..20a910bb 100644 --- a/src/engine/N3Base/N3River2.cpp +++ b/src/engine/N3Base/N3River2.cpp @@ -293,7 +293,7 @@ void CN3River2::Init(const std::string & TexPath) { for (int i = 0; i < MAX_RIVER_TEX; i++) { fs::path fsTexFile = fs::path("Misc") / "river" / std::format("caust{:02d}.dxt", i); - m_pTexRiver[i] = s_MngTex.Get(fsTexFile.string()); + m_pTexRiver[i] = s_MngTex.Get(fsTexFile); __ASSERT(m_pTexRiver[i], "CN3River2::texture load failed"); } m_pTexWave = s_MngTex.Get(TexPath); diff --git a/src/engine/N3Base/N3Scene.cpp b/src/engine/N3Base/N3Scene.cpp index bf972641..36010847 100644 --- a/src/engine/N3Base/N3Scene.cpp +++ b/src/engine/N3Base/N3Scene.cpp @@ -82,8 +82,8 @@ bool CN3Scene::Load(HANDLE hFile) { ReadFile(hFile, &m_fFrmStart, 4, &dwRWC, NULL); // 전체 프레임. ReadFile(hFile, &m_fFrmEnd, 4, &dwRWC, NULL); // 전체 프레임. - int nL = 0; - char szName[512] = ""; + int nL = 0; + std::string szName; int nCC = 0; ReadFile(hFile, &nCC, 4, &dwRWC, NULL); // 카메라.. @@ -93,8 +93,8 @@ bool CN3Scene::Load(HANDLE hFile) { continue; } - ReadFile(hFile, szName, nL, &dwRWC, NULL); - szName[nL] = NULL; + szName.assign(nL, '\0'); + ReadFile(hFile, szName.data(), nL, &dwRWC, NULL); CN3Camera * pCamera = new CN3Camera(); if (false == pCamera->LoadFromFile(szName)) { @@ -113,8 +113,8 @@ bool CN3Scene::Load(HANDLE hFile) { continue; } - ReadFile(hFile, szName, nL, &dwRWC, NULL); - szName[nL] = NULL; + szName.assign(nL, '\0'); + ReadFile(hFile, szName.data(), nL, &dwRWC, NULL); CN3Light * pLight = new CN3Light(); if (false == pLight->LoadFromFile(szName)) { @@ -133,8 +133,8 @@ bool CN3Scene::Load(HANDLE hFile) { continue; } - ReadFile(hFile, szName, nL, &dwRWC, NULL); - szName[nL] = NULL; + szName.assign(nL, '\0'); + ReadFile(hFile, szName.data(), nL, &dwRWC, NULL); CN3Shape * pShape = new CN3Shape(); if (false == pShape->LoadFromFile(szName)) { @@ -153,8 +153,8 @@ bool CN3Scene::Load(HANDLE hFile) { continue; } - ReadFile(hFile, szName, nL, &dwRWC, NULL); - szName[nL] = NULL; + szName.assign(nL, '\0'); + ReadFile(hFile, szName.data(), nL, &dwRWC, NULL); CN3Chr * pChr = new CN3Chr(); if (false == pChr->LoadFromFile(szName)) { @@ -176,10 +176,9 @@ bool CN3Scene::Load(HANDLE hFile) { } bool CN3Scene::Save(HANDLE hFile) { - ::CreateDirectory("Data", NULL); - ::CreateDirectory("Chr", NULL); - ::CreateDirectory("Object", NULL); - ::CreateDirectory("Item", NULL); + for (const auto & szDir : {"Data", "Chr", "Object", "Item"}) { + fs::create_directory(szDir); + } DWORD dwRWC = 0; @@ -188,45 +187,55 @@ bool CN3Scene::Save(HANDLE hFile) { WriteFile(hFile, &m_fFrmStart, 4, &dwRWC, NULL); // 전체 프레임. WriteFile(hFile, &m_fFrmEnd, 4, &dwRWC, NULL); // 전체 프레임. + std::string szFile; + int iLen; WriteFile(hFile, &m_nCameraCount, 4, &dwRWC, NULL); // 카메라.. for (int i = 0; i < m_nCameraCount; i++) { - int nL = m_pCameras[i]->FileName().size(); - WriteFile(hFile, &nL, 4, &dwRWC, NULL); - WriteFile(hFile, m_pCameras[i]->FileName().c_str(), nL, &dwRWC, NULL); + szFile = m_pCameras[i]->FilePathWin().string(); + iLen = szFile.length(); + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); + } m_pCameras[i]->SaveToFile(); } WriteFile(hFile, &m_nLightCount, 4, &dwRWC, NULL); // 카메라.. for (int i = 0; i < m_nLightCount; i++) { - int nL = m_pLights[i]->FileName().size(); - WriteFile(hFile, &nL, 4, &dwRWC, NULL); - WriteFile(hFile, m_pLights[i]->FileName().c_str(), nL, &dwRWC, NULL); + szFile = m_pLights[i]->FilePathWin().string(); + iLen = szFile.length(); + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); + } m_pLights[i]->SaveToFile(); } int iSC = m_Shapes.size(); WriteFile(hFile, &iSC, 4, &dwRWC, NULL); // Shapes.. for (int i = 0; i < iSC; i++) { - int nL = m_Shapes[i]->FileName().size(); - WriteFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL <= 0) { + szFile = m_Shapes[i]->FilePathWin().string(); + iLen = szFile.length(); + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen <= 0) { continue; } - WriteFile(hFile, m_Shapes[i]->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); m_Shapes[i]->SaveToFile(); } int iCC = m_Chrs.size(); WriteFile(hFile, &iCC, 4, &dwRWC, NULL); // 캐릭터 for (int i = 0; i < iCC; i++) { - int nL = m_Chrs[i]->FileName().size(); - WriteFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL <= 0) { + szFile = m_Chrs[i]->FilePathWin().string(); + iLen = szFile.length(); + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen <= 0) { continue; } - WriteFile(hFile, m_Chrs[i]->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); m_Chrs[i]->SaveToFile(); } @@ -535,13 +544,13 @@ bool CN3Scene::CheckOverlappedShapesAndReport() { vPos2 = pShapes[j]->Pos(); if( vPos1 == vPos2 || - pShapes[i]->FileName() == pShapes[j]->FileName() ) // 위치나 이름이 같은 오브젝트가 있는지 찾아본다. + pShapes[i]->FilePath() == pShapes[j]->FilePath() ) // 위치나 이름이 같은 오브젝트가 있는지 찾아본다. { char szErr[512]; __Vector3 vPos = pShapes[j]->Pos(); sprintf(szErr, "파일 이름이 같거나 위치가 같은 오브젝트가 있습니다\n첫번째 오브젝트 : \"%s\" - 위치(%f, %f, %f)\n두번째 오브젝트 : \"%s\" - 위치(%f, %f, %f)", - pShapes[i]->FileName().c_str(), vPos1.x, vPos1.y, vPos1.z, - pShapes[j]->FileName().c_str(), vPos2.x, vPos2.y, vPos2.z); + pShapes[i]->FilePath().c_str(), vPos1.x, vPos1.y, vPos1.z, + pShapes[j]->FilePath().c_str(), vPos2.x, vPos2.y, vPos2.z); MessageBox(::GetActiveWindow(), szErr, "Scene 오브젝트 중복 점검", MB_OK); bOverlapped = true; } @@ -581,7 +590,7 @@ void CN3Scene::DeleteOverlappedShapes() { vPos2 = pShapes[j]->Pos(); if( vPos1 == vPos2 || - pShapes[i]->FileName() == pShapes[j]->FileName() ) // 위치나 이름이 같은 오브젝트가 있는지 찾아본다. + pShapes[i]->FilePath() == pShapes[j]->FilePath() ) // 위치나 이름이 같은 오브젝트가 있는지 찾아본다. { bNeedDeletes[j] = true; } @@ -599,44 +608,36 @@ void CN3Scene::DeleteOverlappedShapes() } } */ -bool CN3Scene::LoadDataAndResourcesFromFile(const std::string & szFN) { - if (szFN.empty()) { +bool CN3Scene::LoadDataAndResourcesFromFile(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } - char szPath[512] = "", szDrv[_MAX_DRIVE] = "", szDir[_MAX_DIR] = ""; - ::_splitpath(szFN.c_str(), szDrv, szDir, NULL, NULL); - ::_makepath(szPath, szDrv, szDir, NULL, NULL); - this->Release(); - CN3Base::PathSet(szPath); - return LoadFromFile(szFN); + CN3Base::PathSet(fsFile.parent_path()); + return LoadFromFile(fsFile); } -bool CN3Scene::SaveDataAndResourcesToFile(const std::string & szFN) { - if (szFN.empty()) { +bool CN3Scene::SaveDataAndResourcesToFile(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } - char szPath[512] = "", szDrv[_MAX_DRIVE] = "", szDir[_MAX_DIR] = ""; - ::_splitpath(szFN.c_str(), szDrv, szDir, NULL, NULL); - ::_makepath(szPath, szDrv, szDir, NULL, NULL); - - CN3Base::PathSet(szPath); - return SaveToFile(szFN); + CN3Base::PathSet(fsFile.parent_path()); + return SaveToFile(fsFile); } void CN3Scene::DefaultCameraAdd() { CN3Camera * pCamera = new CN3Camera(); pCamera->m_szName = "DefaultCamera"; - pCamera->FileNameSet("Data\\DefaultCamera.N3Camera"); + pCamera->FilePathSet(fs::path("Data") / "DefaultCamera.n3camera"); this->CameraAdd(pCamera); } void CN3Scene::DefaultLightAdd() { // Light 초기화.. CN3Light * pLight = new CN3Light(); pLight->m_szName = "DefaultLight"; - pLight->FileNameSet("Data\\DefaultLight.N3Light"); + pLight->FilePathSet(fs::path("Data") / "DefaultLight.n3light"); int nLight = this->LightAdd(pLight) - 1; D3DCOLORVALUE ltColor = {0.7f, 0.7f, 0.7f, 1.0f}; diff --git a/src/engine/N3Base/N3Scene.h b/src/engine/N3Base/N3Scene.h index 6d3ecc7f..6fb26833 100644 --- a/src/engine/N3Base/N3Scene.h +++ b/src/engine/N3Base/N3Scene.h @@ -40,8 +40,8 @@ class CN3Scene : public CN3BaseFileAccess { void DefaultCameraAdd(); void DefaultLightAdd(); - bool LoadDataAndResourcesFromFile(const std::string & szFileName); - bool SaveDataAndResourcesToFile(const std::string & szFileName); + bool LoadDataAndResourcesFromFile(const fs::path & fsFile); + bool SaveDataAndResourcesToFile(const fs::path & fsFile); // bool CheckOverlappedShapesAndReport(); // void DeleteOverlappedShapes(); @@ -94,13 +94,13 @@ class CN3Scene : public CN3BaseFileAccess { } return m_Shapes[iIndex]; } - CN3Shape * ShapeGetByFileName(std::string & str) { + CN3Shape * ShapeGetByFile(const fs::path & fsFile) { if (m_Shapes.empty()) { return NULL; } int iSize = m_Shapes.size(); for (int i = 0; i < iSize; i++) { - if (str == m_Shapes[i]->FileName()) { + if (fsFile == m_Shapes[i]->FilePath()) { return m_Shapes[i]; } } diff --git a/src/engine/N3Base/N3Shape.cpp b/src/engine/N3Base/N3Shape.cpp index 1c6eb6ee..2af20e4c 100644 --- a/src/engine/N3Base/N3Shape.cpp +++ b/src/engine/N3Base/N3Shape.cpp @@ -52,8 +52,8 @@ void CN3SPart::Release() { m_PMInst.Release(); } -void CN3SPart::MeshSet(const std::string & szFN) { - m_PMInst.Create(szFN); +void CN3SPart::MeshSet(const fs::path & fsFile) { + m_PMInst.Create(fsFile); } void CN3SPart::TexAlloc(int nCount) { @@ -329,15 +329,17 @@ void CN3SPart::RenderAxis() { bool CN3SPart::Load(HANDLE hFile) { DWORD dwRWC; - int nL = 0; - char szFN[256]; ReadFile(hFile, &m_vPivot, sizeof(__Vector3), &dwRWC, NULL); + int nL = 0; + std::string szFile; ReadFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; // 메시 파일 이름.. - this->MeshSet(szFN); + if (nL > 0) { + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + MeshSet(szFile); + } ReadFile(hFile, &m_Mtl, sizeof(__Material), &dwRWC, NULL); // 재질 @@ -345,14 +347,14 @@ bool CN3SPart::Load(HANDLE hFile) { ReadFile(hFile, &iTC, 4, &dwRWC, NULL); ReadFile(hFile, &m_fTexFPS, 4, &dwRWC, NULL); m_TexRefs.clear(); - this->TexAlloc(iTC); // Texture Pointer Pointer 할당.. - for (int j = 0; j < iTC; j++) // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. - { + this->TexAlloc(iTC); // Texture Pointer Pointer 할당.. + for (int j = 0; j < iTC; j++) { // Texture Count 만큼 파일 이름 읽어서 텍스처 부르기.. + nL = 0; ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; // 텍스처 파일 이름.. - m_TexRefs[j] = s_MngTex.Get(szFN, true, s_Options.iTexLOD_Shape); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + m_TexRefs[j] = s_MngTex.Get(szFile, true, s_Options.iTexLOD_Shape); } } @@ -367,9 +369,11 @@ bool CN3SPart::Save(HANDLE hFile) { CN3PMesh * pPMesh = m_PMInst.GetMesh(); __ASSERT(pPMesh, "Progressive mesh pointer is NULL!"); - int nL = 0; + std::string szFile; + int iLen = 0; if (pPMesh) { - nL = pPMesh->FileName().size(); + szFile = pPMesh->FilePathWin().string(); + iLen = szFile.length(); } else { MessageBox(GetActiveWindow(), "Progressive mesh pointer is NULL! : object가 제대로 보이지 않을 수 있습니다.(리소스 파일이 " @@ -377,20 +381,19 @@ bool CN3SPart::Save(HANDLE hFile) { "warning", MB_OK); } - WriteFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName - if (nL > 0) { - // if(-1 == pPMesh->FileName().find("object\\")) // 임시로 경로를 바꾸려고 넣었다.. 나중에 필요없음 지운다.. - // { - // char szFNTmp[256]; - // wsprintf(szFNTmp, "Object\\%s.N3PMesh", pPMesh->Name()); - // pPMesh->FileNameSet(szFNTmp); - // - // SetFilePointer(hFile, -4, 0, FILE_CURRENT); - // nL = pPMesh->FileName().size(); - // WriteFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName - // } + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName + if (iLen > 0) { + //// 임시로 경로를 바꾸려고 넣었다.. 나중에 필요없음 지운다.. + //if (!n3std::iequals(*pPMesh->FilePath().begin(), "object")) { + // pPMesh->FilePathSet(fs::path("Object") / (pPMesh->m_szName + ".n3pmesh")); + + // SetFilePointer(hFile, -4, 0, FILE_CURRENT); + // szFile = pPMesh->FilePathWin().string(); + // iLen = szFile.length(); + // WriteFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName + //} - WriteFile(hFile, pPMesh->FileName().c_str(), nL, &dwRWC, NULL); // 메시 파일 이름.. + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); // 메시 파일 이름.. } WriteFile(hFile, &m_Mtl, sizeof(__Material), &dwRWC, NULL); // 재질 @@ -401,29 +404,28 @@ bool CN3SPart::Save(HANDLE hFile) { for (int j = 0; j < iTC; j++) // Texture File 이름 쓰기... { if (m_TexRefs[j]) { - nL = m_TexRefs[j]->FileName().size(); + szFile = m_TexRefs[j]->FilePathWin().string(); + iLen = szFile.length(); } else { - nL = 0; + szFile.clear(); + iLen = 0; } - WriteFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL > 0) { - // if(-1 == m_TexRefs[j]->FileName().find("object\\")) // 임시로 경로를 바꾸려고 넣었다.. 나중에 필요없음 지운다.. - // { - // // 폴더 이름을 분리하고.. - // char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - // _splitpath(m_TexRefs[j]->FileName(), szDrive, szDir, szFName, szExt); - // - // char szFNTmp[256]; - // wsprintf(szFNTmp, "Object\\%s.DXT", szFName); - // m_TexRefs[j]->FileNameSet(szFNTmp); - // - // SetFilePointer(hFile, -4, 0, FILE_CURRENT); - // nL = lstrlen(m_TexRefs[j]->FileName()); - // WriteFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName - // } - - WriteFile(hFile, m_TexRefs[j]->FileName().c_str(), nL, &dwRWC, NULL); // 택스처 파일 이름.. + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + //// 임시로 경로를 바꾸려고 넣었다.. 나중에 필요없음 지운다.. + //if (!n3std::iequals(*m_TexRefs[j]->FilePath().begin(), "object")) { + // fs::path fsFile(m_TexRefs[j]->FilePath()); + // fsFile = "Object" / fsFile.stem() + ".dxt"; + // m_TexRefs[j]->FilePathSet(fsFile); + + // SetFilePointer(hFile, -4, 0, FILE_CURRENT); + // szFile = m_TexRefs[j]->FilePathWin().string(); + // iLen = szFile.length(); + // WriteFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName + //} + + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); // 택스처 파일 이름.. } } @@ -1038,14 +1040,11 @@ bool CN3Shape::MakeCollisionMeshByParts() // 충돌 메시를 박스로 만든 return false; } - int iCount = CN3Base::s_MngVMesh.Count(); - char szBuff[256]; - sprintf(szBuff, "%s_collision_%d.n3vmesh", m_szFileName.c_str(), iCount); // 임시로 이름일 짓고.. - - pVMesh->FileNameSet(szBuff); + int iCount = CN3Base::s_MngVMesh.Count(); + pVMesh->FilePathSet(FilePath() + std::format("_collision_{:d}.n3vmesh", iCount)); CN3Base::s_MngVMesh.Delete(&m_pMeshCollision); // 전의 거 지우고.. CN3Base::s_MngVMesh.Add(pVMesh); - m_pMeshCollision = s_MngVMesh.Get(pVMesh->FileName()); + m_pMeshCollision = s_MngVMesh.Get(pVMesh->FilePath()); this->FindMinMax(); @@ -1125,14 +1124,11 @@ bool CN3Shape::MakeCollisionMeshByPartsDetail() // 현재 모습 그대로... return false; } - int iCount = CN3Base::s_MngVMesh.Count(); - char szBuff[256]; - sprintf(szBuff, "%s_collision_%d.n3vmesh", m_szFileName.c_str(), iCount); // 임시로 이름일 짓고.. - - pVMesh->FileNameSet(szBuff); + int iCount = CN3Base::s_MngVMesh.Count(); + pVMesh->FilePathSet(FilePath() + std::format("_collision_{:d}.n3vmesh", iCount)); CN3Base::s_MngVMesh.Delete(&m_pMeshCollision); // 전의 거 지우고.. CN3Base::s_MngVMesh.Add(pVMesh); - m_pMeshCollision = s_MngVMesh.Get(pVMesh->FileName()); + m_pMeshCollision = s_MngVMesh.Get(pVMesh->FilePath()); this->FindMinMax(); @@ -1164,130 +1160,90 @@ void CN3Shape::RemoveRenderFlags(int nFlags) { #endif // end of _N3TOOL #ifdef _N3TOOL -bool CN3Shape::SaveToSameFolder(const std::string & szFullPath) { - if (szFullPath.empty()) { +bool CN3Shape::SaveToSameFolder(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } - std::string szPath = szFullPath; - for (int i = szFullPath.size() - 1; i >= 0; i--) { - if ('\\' == szPath[i] || '/' == szPath[i]) { - szPath = szPath.substr(0, i + 1); - break; - } - } - - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - std::string szNameTmp, szOldFN; + fs::path fsDir = fsFile.parent_path(); + fs::path fsOldFile; - int iPC = m_Parts.size(); - std::vector OldPartFNs; - std::vector OldTexFNs; - for (int i = 0; i < iPC; i++) { - szOldFN = m_Parts[i]->Mesh()->FileName(); - OldPartFNs.push_back(szOldFN); // 파일 이름 보관.. + std::vector vOldPartFiles, vOldTexFiles; + for (const auto & pPart : m_Parts) { + fsOldFile = pPart->Mesh()->FilePath(); + vOldPartFiles.emplace_back(fsOldFile); // 파일 이름 보관.. - _splitpath(szOldFN.c_str(), szDrive, szDir, szFName, szExt); - szNameTmp = szPath + szFName + szExt; - m_Parts[i]->Mesh()->SaveToFile(szNameTmp); + pPart->Mesh()->SaveToFile(fsDir / fsOldFile.filename()); - int iTC = m_Parts[i]->TexCount(); + int iTC = pPart->TexCount(); for (int j = 0; j < iTC; j++) { - CN3Texture * pTex = m_Parts[i]->Tex(j); - - szOldFN = pTex->FileName(); - OldTexFNs.push_back(szOldFN); // 파일 이름 보관.. + CN3Texture * pTex = pPart->Tex(j); - _splitpath(szOldFN.c_str(), szDrive, szDir, szFName, szExt); - szNameTmp = szPath + szFName + szExt; - pTex->SaveToFile(szNameTmp); + fsOldFile = pTex->FilePath(); + vOldTexFiles.emplace_back(fsOldFile); // 파일 이름 보관.. + pTex->SaveToFile(fsDir / fsOldFile.filename()); } } - szOldFN = m_szFileName; - _splitpath(m_szFileName.c_str(), szDrive, szDir, szFName, szExt); - szNameTmp = szPath + szFName + szExt; - this->SaveToFile(szNameTmp); - m_szFileName = szOldFN; + fsOldFile = FilePath(); + this->SaveToFile(fsDir / fsOldFile.filename()); + FilePathSet(fsOldFile); // 원래대로 파일 이름 돌려놓기.. - iPC = m_Parts.size(); int iSeq = 0; - for (int i = 0; i < iPC; i++) { - m_Parts[i]->Mesh()->FileNameSet(OldPartFNs[i]); + for (int i = 0; i < m_Parts.size(); i++) { + m_Parts[i]->Mesh()->FilePathSet(vOldPartFiles[i]); int iTC = m_Parts[i]->TexCount(); for (int j = 0; j < iTC; j++) { - m_Parts[i]->Tex(j)->FileNameSet(OldTexFNs[iSeq]); + m_Parts[i]->Tex(j)->FilePathSet(vOldTexFiles[iSeq]); iSeq++; } } // By : Ecli666 ( On 2002-10-16 오전 11:44:19 ) // - szOldFN = CollisionMesh()->FileName(); - _splitpath(CollisionMesh()->FileName().c_str(), szDrive, szDir, szFName, szExt); - szNameTmp = szPath + szFName + szExt; - CollisionMesh()->SaveToFile(szNameTmp); - CollisionMesh()->FileNameSet(szOldFN); + fsOldFile = CollisionMesh()->FilePath(); + CollisionMesh()->SaveToFile(fsDir / fsOldFile.filename()); + CollisionMesh()->FilePathSet(fsOldFile); // ~(By Ecli666 On 2002-10-16 오전 11:44:19 ) return true; } -bool CN3Shape::SaveToSameFolderAndMore(const std::string & szFullPath, const std::string & szRelativePath) { - if (szFullPath.empty()) { +bool CN3Shape::SaveToSameFolderAndMore(const fs::path & fsFile, const fs::path & fsDirRelative) { + if (fsFile.empty()) { return false; } - std::string szPath = szFullPath; - for (int i = szFullPath.size() - 1; i >= 0; i--) { - if ('\\' == szPath[i] || '/' == szPath[i]) { - szPath = szPath.substr(0, i + 1); - break; - } - } - - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - std::string szNameTmp, szOldFN; - - int iPC = m_Parts.size(); - for (int i = 0; i < iPC; i++) { - szOldFN = m_Parts[i]->Mesh()->FileName(); + fs::path fsDir = fsFile.parent_path(); + fs::path fsOldFile; - _splitpath(szOldFN.c_str(), szDrive, szDir, szFName, szExt); - szNameTmp = szPath + szFName + szExt; - m_Parts[i]->Mesh()->SaveToFile(szNameTmp); - m_Parts[i]->Mesh()->FileNameSet(szRelativePath + szFName + szExt); + for (const auto & pPart : m_Parts) { + fsOldFile = pPart->Mesh()->FilePath(); - int iTC = m_Parts[i]->TexCount(); - for (int j = 0; j < iTC; j++) { - CN3Texture * pTex = m_Parts[i]->Tex(j); + pPart->Mesh()->SaveToFile(fsDir / fsOldFile.filename()); + pPart->Mesh()->FilePathSet(fsDirRelative / fsOldFile.filename()); - szOldFN = pTex->FileName(); + for (int j = 0; j < pPart->TexCount(); j++) { + CN3Texture * pTex = pPart->Tex(j); - _splitpath(szOldFN.c_str(), szDrive, szDir, szFName, szExt); - szNameTmp = szPath + szFName + szExt; - pTex->SaveToFile(szNameTmp); - pTex->FileNameSet(szRelativePath + szFName + szExt); + fsOldFile = pTex->FilePath(); + pTex->SaveToFile(fsDir / fsOldFile.filename()); + pTex->FilePathSet(fsDirRelative / fsOldFile.filename()); } } - _splitpath(m_szFileName.c_str(), szDrive, szDir, szFName, szExt); - szNameTmp = szPath + szFName + szExt; - this->SaveToFile(szNameTmp); - m_szFileName = szRelativePath + szFName + szExt; + this->SaveToFile(fsDir / FilePath().filename()); + FilePathSet(fsDirRelative / FilePath().filename()); // By : Ecli666 ( On 2002-10-16 오전 11:44:19 ) // if (CollisionMesh()) { - _splitpath(CollisionMesh()->FileName().c_str(), szDrive, szDir, szFName, szExt); - szNameTmp = szPath + szFName + szExt; - CollisionMesh()->SaveToFile(szNameTmp); - szOldFN = szFName; - szOldFN += szExt; - CollisionMesh()->FileNameSet(szRelativePath + szFName + szExt); + fsOldFile = CollisionMesh()->FilePath().filename(); + CollisionMesh()->SaveToFile(fsDir / fsOldFile); + CollisionMesh()->FilePathSet(fsDirRelative / fsOldFile); } // ~(By Ecli666 On 2002-10-16 오전 11:44:19 ) diff --git a/src/engine/N3Base/N3Shape.h b/src/engine/N3Base/N3Shape.h index d2bb7d9b..36fd4f88 100644 --- a/src/engine/N3Base/N3Shape.h +++ b/src/engine/N3Base/N3Shape.h @@ -52,12 +52,12 @@ class CN3SPart : public CN3BaseFileAccess { return m_TexRefs[iIndex]; } void TexAlloc(int m_nCount); - CN3Texture * TexSet(int iIndex, const std::string & szFN) { + CN3Texture * TexSet(int iIndex, const fs::path & fsFile) { if (iIndex < 0 || iIndex >= m_TexRefs.size()) { return NULL; } s_MngTex.Delete(&m_TexRefs[iIndex]); - m_TexRefs[iIndex] = s_MngTex.Get(szFN, true, s_Options.iTexLOD_Shape); + m_TexRefs[iIndex] = s_MngTex.Get(fsFile, true, s_Options.iTexLOD_Shape); return m_TexRefs[iIndex]; } void TexSet(int iIndex, CN3Texture * pTex) { @@ -70,7 +70,7 @@ class CN3SPart : public CN3BaseFileAccess { CN3PMeshInstance * MeshInstance() { return &m_PMInst; } CN3PMesh * Mesh() { return m_PMInst.GetMesh(); } - void MeshSet(const std::string & szFN); + void MeshSet(const fs::path & fsFile); void ReCalcMatrix(const __Matrix44 & mtxParent) { m_Matrix.Identity(); @@ -137,8 +137,8 @@ class CN3Shape : public CN3TransformCollision { public: #ifdef _N3TOOL - bool SaveToSameFolderAndMore(const std::string & szFullPath, const std::string & szRelativePath); - bool SaveToSameFolder(const std::string & szFullPath); + bool SaveToSameFolder(const fs::path & fsFile); + bool SaveToSameFolderAndMore(const fs::path & fsFile, const fs::path & fsDirRelative); void RemoveRenderFlags(int nFlags = -1); void MakeDefaultMaterial(); #endif // end of _N3TOOL diff --git a/src/engine/N3Base/N3ShapeMgr.cpp b/src/engine/N3Base/N3ShapeMgr.cpp index 3c46ee5e..b6126864 100644 --- a/src/engine/N3Base/N3ShapeMgr.cpp +++ b/src/engine/N3Base/N3ShapeMgr.cpp @@ -562,7 +562,7 @@ int CN3ShapeMgr::Add(CN3Shape * pShape) { pShape->SaveToFile(); // 파일로 저장하고.. CN3Shape * pShapeAdd = new CN3Shape(); - if (false == pShapeAdd->LoadFromFile(pShape->FileName())) // 이 파일을 열은 다음 + if (false == pShapeAdd->LoadFromFile(pShape->FilePath())) // 이 파일을 열은 다음 { delete pShapeAdd; return -1; diff --git a/src/engine/N3Base/N3ShapeMod.cpp b/src/engine/N3Base/N3ShapeMod.cpp index 46ee6821..0170f2bd 100644 --- a/src/engine/N3Base/N3ShapeMod.cpp +++ b/src/engine/N3Base/N3ShapeMod.cpp @@ -35,14 +35,14 @@ void CN3ShapeMod::Release() { m_fTimeChanging = 0.0f; } -CN3SPart * CN3ShapeMod::GetPartByPMeshFileName(const std::string & szFN) { - if (szFN.empty()) { +CN3SPart * CN3ShapeMod::GetPartByPMeshFilePath(const fs::path & fsFile) { + if (fsFile.empty()) { return NULL; } int iPC = m_Parts.size(); for (int i = 0; i < iPC; i++) { - if (m_Parts[i]->Mesh() && m_Parts[i]->Mesh()->FileName() == szFN) { + if (m_Parts[i]->Mesh() && n3std::iequals(m_Parts[i]->Mesh()->FilePath(), fsFile)) { return m_Parts[i]; } } @@ -52,14 +52,10 @@ CN3SPart * CN3ShapeMod::GetPartByPMeshFileName(const std::string & szFN) { bool CN3ShapeMod::Load(HANDLE hFile) { bool ret = CN3Shape::Load(hFile); - char szPathName[_MAX_PATH]; - char szDir[_MAX_DIR]; - char szFName[_MAX_FNAME]; - _splitpath(m_szFileName.c_str(), NULL, szDir, szFName, NULL); - _makepath(szPathName, NULL, szDir, szFName, "txt"); - FILE * stream = fopen(szPathName, "r"); - LoadStateInfo(stream); - fclose(stream); + fs::path fsTxtFile = fs::path(FilePath()).replace_extension(".txt"); + FILE * pFile = _wfopen(fsTxtFile.c_str(), L"r"); + LoadStateInfo(pFile); + fclose(pFile); return ret; } @@ -110,7 +106,7 @@ BOOL CN3ShapeMod::LoadStateInfo(FILE * stream) // 상태 정보를 읽어온다. for (int i = 0; i < m_iModPartCount; ++i) { result = fscanf(stream, "PMesh_FName=%s\n", szPMeshName); __ASSERT(result != EOF, "잘못된 N3ShapeMod 세팅 파일"); - m_pModParts[i].pPart = GetPartByPMeshFileName(szPMeshName); + m_pModParts[i].pPart = GetPartByPMeshFilePath(szPMeshName); m_pModParts[i].pStateInfos = new __ModPosRotScale[m_iStateCount]; for (int j = 0; j < m_iStateCount; ++j) { result = fscanf(stream, "Pos(%f, %f, %f)\n", &vPos.x, &vPos.y, &vPos.z); diff --git a/src/engine/N3Base/N3ShapeMod.h b/src/engine/N3Base/N3ShapeMod.h index 977b7941..f1dae691 100644 --- a/src/engine/N3Base/N3ShapeMod.h +++ b/src/engine/N3Base/N3ShapeMod.h @@ -107,5 +107,5 @@ class CN3ShapeMod : public CN3Shape { virtual bool Load(HANDLE hFile); protected: - CN3SPart * GetPartByPMeshFileName(const std::string & szFN); // 이름으로 PMesh포인터 구하기 + CN3SPart * GetPartByPMeshFilePath(const fs::path & fsFile); // 이름으로 PMesh포인터 구하기 }; diff --git a/src/engine/N3Base/N3SkyMng.cpp b/src/engine/N3Base/N3SkyMng.cpp index 842e9d63..bcd4c3b4 100644 --- a/src/engine/N3Base/N3SkyMng.cpp +++ b/src/engine/N3Base/N3SkyMng.cpp @@ -431,19 +431,19 @@ bool CN3SkyMng::DayChangeWrite(FILE * fp, __SKY_DAYCHANGE * pDayChange) { #endif // #ifdef _N3TOOL #ifdef _N3TOOL -bool CN3SkyMng::LoadFromTextFile(const char * szIniFN) { - if (NULL == szIniFN || strlen(szIniFN) <= 0) { +bool CN3SkyMng::LoadFromTextFile(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } - FILE * fp = fopen(szIniFN, "r"); + FILE * fp = _wfopen(fsFile.c_str(), L"r"); if (!fp) { return false; } - std::string szMoon; - std::string szSuns[NUM_SUNPART]; - std::string szClouds[NUM_CLOUD]; + fs::path szMoon; + fs::path szSuns[NUM_SUNPART]; + fs::path szClouds[NUM_CLOUD]; char szLine[512] = "", szBuff[256] = ""; char * pResult = fgets(szLine, 512, fp); @@ -533,35 +533,38 @@ bool CN3SkyMng::LoadFromTextFile(const char * szIniFN) { #endif // #ifdef _N3TOOL #ifdef _N3TOOL -bool CN3SkyMng::SaveToTextFile(const char * szIniFN) { - if (NULL == szIniFN || strlen(szIniFN) <= 0) { +bool CN3SkyMng::SaveToTextFile(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } - FILE * fp = fopen(szIniFN, "w"); + FILE * fp = _wfopen(fsFile.c_str(), L"w"); if (!fp) { return false; } char szBuff[256] = ""; - if (this->MoonTextureGet()) { - fprintf(fp, "Moon : %s\r\n", this->MoonTextureGet()->FileName().c_str()); + CN3Texture * pMoonTex = MoonTextureGet(); + if (pMoonTex) { + fprintf(fp, "Moon : %s\r\n", pMoonTex->FilePathWin().string().c_str()); } else { fprintf(fp, "Moon : \r\n"); } for (int i = 0; i < NUM_SUNPART; i++) { - if (this->SunTextureGet(i)) { - fprintf(fp, "Sun : %s\r\n", this->SunTextureGet(i)->FileName().c_str()); + CN3Texture * pSunTex = SunTextureGet(i); + if (pSunTex) { + fprintf(fp, "Sun : %s\r\n", pSunTex->FilePathWin().string().c_str()); } else { fprintf(fp, "Sun : \r\n"); } } for (int i = 0; i < NUM_CLOUD; i++) { - if (this->CloudTextureFileName(i)) { - fprintf(fp, "Cloud : %s\r\n", this->CloudTextureFileName(i)); + fs::path fsCloudTexFile = CloudTextureFile(i).normalize('/', '\\'); + if (!fsCloudTexFile.empty()) { + fprintf(fp, "Cloud : %s\r\n", fsCloudTexFile.string().c_str()); } else { fprintf(fp, "Cloud : \r\n"); } @@ -583,18 +586,20 @@ bool CN3SkyMng::SaveToTextFile(const char * szIniFN) { void CN3SkyMng::InitToDefaultHardCoding() { this->Release(); + fs::path fsSkyDir = fs::path("Misc") / "Sky"; + m_pSky = new CN3Sky(); m_pSky->Init(); m_pMoon = new CN3Moon(); - m_pMoon->Init("misc\\sky\\phases.tga"); + m_pMoon->Init(fsSkyDir / "phases.tga"); - std::string szSuns[NUM_SUNPART] = {"misc\\sky\\sundisk.bmp", "misc\\sky\\sunglow.bmp", "misc\\sky\\sunflare.bmp"}; + fs::path szSuns[NUM_SUNPART] = {fsSkyDir / "sundisk.bmp", fsSkyDir / "sunglow.bmp", fsSkyDir / "sunflare.bmp"}; m_pSun = new CN3Sun(); m_pSun->Init(szSuns); - std::string szClouds[NUM_CLOUD] = {"misc\\sky\\wisps.tga", "misc\\sky\\puffs.tga", "misc\\sky\\tatters.tga", - "misc\\sky\\streaks.tga", "misc\\sky\\dense.tga", "misc\\sky\\overcast.tga"}; + fs::path szClouds[NUM_CLOUD] = {fsSkyDir / "wisps.tga", fsSkyDir / "puffs.tga", fsSkyDir / "tatters.tga", + fsSkyDir / "streaks.tga", fsSkyDir / "dense.tga", fsSkyDir / "overcast.tga"}; m_pCloud = new CN3Cloud(); m_pCloud->Init(szClouds); @@ -1466,34 +1471,40 @@ D3DCOLOR CN3SkyMng::GetLightAmbientColor(int iIndex) { } bool CN3SkyMng::Load(HANDLE hFile) { - DWORD dwRWC = 0; - std::string szSuns[NUM_SUNPART]; - std::string szClouds[NUM_CLOUD]; - std::string szMoon; + DWORD dwRWC = 0; + fs::path fsSuns[NUM_SUNPART]; + fs::path fsClouds[NUM_CLOUD]; + fs::path fsMoon; + + int iL = 0; + std::string szFile; for (int i = 0; i < NUM_SUNPART; i++) { - int iL = 0; + iL = 0; ReadFile(hFile, &iL, 4, &dwRWC, NULL); if (iL > 0) { - szSuns[i].assign(iL, ' '); - ReadFile(hFile, &(szSuns[i][0]), iL, &dwRWC, NULL); + szFile.assign(iL, '\0'); + ReadFile(hFile, szFile.data(), iL, &dwRWC, NULL); + fsSuns[i] = szFile; } } for (int i = 0; i < NUM_CLOUD; i++) { - int iL = 0; + iL = 0; ReadFile(hFile, &iL, 4, &dwRWC, NULL); if (iL > 0) { - szClouds[i].assign(iL, ' '); - ReadFile(hFile, &(szClouds[i][0]), iL, &dwRWC, NULL); + szFile.assign(iL, '\0'); + ReadFile(hFile, szFile.data(), iL, &dwRWC, NULL); + fsClouds[i] = szFile; } } - int iL = 0; + iL = 0; ReadFile(hFile, &iL, 4, &dwRWC, NULL); if (iL > 0) { - szMoon.assign(iL, ' '); - ReadFile(hFile, &(szMoon[0]), iL, &dwRWC, NULL); + szFile.assign(iL, '\0'); + ReadFile(hFile, szFile.data(), iL, &dwRWC, NULL); + fsMoon = szFile; } if (NULL == m_pSky) { @@ -1509,17 +1520,17 @@ bool CN3SkyMng::Load(HANDLE hFile) { if (NULL == m_pSun) { m_pSun = new CN3Sun(); } - m_pSun->Init(szSuns); + m_pSun->Init(fsSuns); if (NULL == m_pCloud) { m_pCloud = new CN3Cloud(); } - m_pCloud->Init(szClouds); + m_pCloud->Init(fsClouds); if (NULL == m_pMoon) { m_pMoon = new CN3Moon(); } - m_pMoon->Init(szMoon); + m_pMoon->Init(fsMoon); for (int i = 0; i < MAX_GAME_LIGHT; i++) { if (NULL == m_pLightColorDiffuses[i]) { @@ -1557,16 +1568,16 @@ bool CN3SkyMng::Save(HANDLE hFile) { for (int i = 0; i < NUM_SUNPART; i++) { if (m_pSun && m_pSun->m_Parts[i].pTex) { - szSuns[i] = m_pSun->m_Parts[i].pTex->FileName(); + szSuns[i] = m_pSun->m_Parts[i].pTex->FilePathWin().string(); } } for (int i = 0; i < NUM_CLOUD; i++) { if (m_pCloud) { - szClouds[i] = m_pCloud->m_szTextures[i]; + szClouds[i] = fs::path(m_pCloud->m_fsTexFiles[i]).normalize('/', '\\').string(); } } if (m_pMoon && m_pMoon->m_pTexture) { - szMoon = m_pMoon->m_pTexture->FileName(); + szMoon = m_pMoon->m_pTexture->FilePathWin().string(); } for (int i = 0; i < NUM_SUNPART; i++) { @@ -1645,38 +1656,38 @@ bool CN3SkyMng::DayChangeDelete(int iIndex) { return true; } -CN3Texture * CN3SkyMng::SunTextureSet(int iIndex, const char * szPath) { - if (NULL == szPath || NULL == m_pSun || iIndex < 0 || iIndex >= NUM_SUNPART) { +CN3Texture * CN3SkyMng::SunTextureSet(int iIndex, const fs::path & fsFile) { + if (fsFile.empty() || NULL == m_pSun || iIndex < 0 || iIndex >= NUM_SUNPART) { return NULL; } s_MngTex.Delete(&(m_pSun->m_Parts[iIndex].pTex)); - m_pSun->m_Parts[iIndex].pTex = s_MngTex.Get(szPath); + m_pSun->m_Parts[iIndex].pTex = s_MngTex.Get(fsFile); return m_pSun->m_Parts[iIndex].pTex; } -CN3Texture * CN3SkyMng::MoonTextureSet(const char * szPath) { - if (NULL == szPath || NULL == m_pMoon) { +CN3Texture * CN3SkyMng::MoonTextureSet(const fs::path & fsFile) { + if (fsFile.empty() || NULL == m_pMoon) { return NULL; } s_MngTex.Delete(&(m_pMoon->m_pTexture)); - m_pMoon->m_pTexture = s_MngTex.Get(szPath); + m_pMoon->m_pTexture = s_MngTex.Get(fsFile); return m_pMoon->m_pTexture; } -CN3Texture * CN3SkyMng::CloudTextureSet(int iIndex, const char * szPath) { - if (NULL == szPath || NULL == m_pCloud || iIndex < 0 || iIndex >= NUM_CLOUD) { +CN3Texture * CN3SkyMng::CloudTextureSet(int iIndex, const fs::path & fsFile) { + if (fsFile.empty() || NULL == m_pCloud || iIndex < 0 || iIndex >= NUM_CLOUD) { return NULL; } s_MngTex.Delete(&(m_pCloud->m_pTextures[iIndex])); - m_pCloud->m_pTextures[iIndex] = s_MngTex.Get(szPath); - m_pCloud->m_szTextures[iIndex] = ""; + m_pCloud->m_pTextures[iIndex] = s_MngTex.Get(fsFile); + m_pCloud->m_fsTexFiles[iIndex] = fs::path(); if (m_pCloud->m_pTextures[iIndex]) { - m_pCloud->m_szTextures[iIndex] = m_pCloud->m_pTextures[iIndex]->FileName(); + m_pCloud->m_fsTexFiles[iIndex] = m_pCloud->m_pTextures[iIndex]->FilePath(); } return m_pCloud->m_pTextures[iIndex]; @@ -1703,11 +1714,11 @@ CN3Texture * CN3SkyMng::CloudTextureGet(int iIndex) { return m_pCloud->m_pTextures[iIndex]; } -const char * CN3SkyMng::CloudTextureFileName(int iIndex) { +fs::path CN3SkyMng::CloudTextureFile(int iIndex) { if (NULL == m_pCloud || iIndex < 0 || iIndex >= NUM_CLOUD) { - return NULL; + return fs::path(); } - return m_pCloud->m_szTextures[iIndex].c_str(); + return m_pCloud->m_fsTexFiles[iIndex]; } #endif diff --git a/src/engine/N3Base/N3SkyMng.h b/src/engine/N3Base/N3SkyMng.h index 1fb1e41b..50486143 100644 --- a/src/engine/N3Base/N3SkyMng.h +++ b/src/engine/N3Base/N3SkyMng.h @@ -65,9 +65,8 @@ struct __SKY_DAYCHANGE { int nL = 0; ReadFile(hFile, &nL, 4, &dwRWC, NULL); if (nL > 0) { - std::vector buffer(nL, 0); - ReadFile(hFile, &buffer[0], nL, &dwRWC, NULL); - szName = std::string(buffer.begin(), buffer.end()); + szName.assign(nL, '\0'); + ReadFile(hFile, szName.data(), nL, &dwRWC, NULL); } ReadFile(hFile, &eSkyDayChange, 4, &dwRWC, NULL); @@ -154,8 +153,8 @@ class CN3SkyMng : public CN3BaseFileAccess { public: #ifdef _N3TOOL void InitToDefaultHardCoding(); - bool LoadFromTextFile(const char * szIniFN); - bool SaveToTextFile(const char * szIniFN); + bool LoadFromTextFile(const fs::path & fsFile); + bool SaveToTextFile(const fs::path & fsFile); bool DayChangeParse(FILE * fp, __SKY_DAYCHANGE * pDayChange); bool DayChangeWrite(FILE * fp, __SKY_DAYCHANGE * pDayChange); @@ -165,14 +164,14 @@ class CN3SkyMng : public CN3BaseFileAccess { __SKY_DAYCHANGE * DayChangeInsert(int iIndex); bool DayChangeDelete(int iIndex); - CN3Texture * SunTextureSet(int iIndex, const char * szPath); - CN3Texture * MoonTextureSet(const char * szPath); - CN3Texture * CloudTextureSet(int iIndex, const char * szPath); + CN3Texture * SunTextureSet(int iIndex, const fs::path & fsFile); + CN3Texture * MoonTextureSet(const fs::path & fsFile); + CN3Texture * CloudTextureSet(int iIndex, const fs::path & fsFile); CN3Texture * SunTextureGet(int iIndex); CN3Texture * MoonTextureGet(); CN3Texture * CloudTextureGet(int iIndex); - const char * CloudTextureFileName(int iIndex); + fs::path CloudTextureFile(int iIndex); #endif bool Load(HANDLE hFile); diff --git a/src/engine/N3Base/N3SndDef.h b/src/engine/N3Base/N3SndDef.h index ae8eaa8e..78641f54 100644 --- a/src/engine/N3Base/N3SndDef.h +++ b/src/engine/N3Base/N3SndDef.h @@ -17,7 +17,7 @@ class CN3SndObj; typedef struct __SoundSource { int iID; - std::string szFN; + fs::path fsFile; LPDIRECTSOUNDBUFFER pDSBuff; int Size; int Type; // 0:2d 1:3d 2: streammin.. @@ -28,7 +28,6 @@ typedef struct __SoundSource { __SoundSource() { iID = 0; ppObjs = NULL; - szFN = ""; pDSBuff = NULL; Size = 0; Type = 0; @@ -40,7 +39,7 @@ typedef struct __SoundSource { typedef struct __TABLE_SOUND // Sound 리소스 레코드... { DWORD dwID; // 고유 ID - std::string szFN; // wave file name + std::string szFile; // wave file path int iType; // 사운드 타입... int iNumInst; // 최대 사용할 수 있는 인스턴스의 갯수.. } TABLE_SOUND; diff --git a/src/engine/N3Base/N3SndEng.cpp b/src/engine/N3Base/N3SndEng.cpp index 01709e82..d9ea4ab8 100644 --- a/src/engine/N3Base/N3SndEng.cpp +++ b/src/engine/N3Base/N3SndEng.cpp @@ -131,10 +131,10 @@ bool CN3SndEng::LoadSource(LPSOUNDSOURCE pSrc) { } CWaveFile WaveFile; - HRESULT hr = WaveFile.Open(pSrc->szFN.c_str(), NULL, 1); //#define WAVEFILE_READ 1 + HRESULT hr = WaveFile.Open(pSrc->fsFile, NULL, 1); //#define WAVEFILE_READ 1 if (FAILED(hr)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndEng::LoadSource - WaveFile Open Failed.. (%)", pSrc->szFN.c_str()); + CLogWriter::Write("CN3SndEng::LoadSource - WaveFile Open Failed.. (%)", pSrc->fsFile.string().c_str()); #endif return false; } @@ -157,14 +157,14 @@ bool CN3SndEng::LoadSource(LPSOUNDSOURCE pSrc) { hr = m_pDS->CreateSoundBuffer(&dsbd, &(pSrc->pDSBuff), NULL); if (FAILED(hr)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndEng::LoadSource - CreateSoundBuffer Failed.. (%)", pSrc->szFN.c_str()); + CLogWriter::Write("CN3SndEng::LoadSource - CreateSoundBuffer Failed.. (%)", pSrc->fsFile.string().c_str()); #endif return false; } if (!FillBufferWithSound(pSrc, &WaveFile)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndEng::LoadSource - FillBufferWithSound Failed.. (%)", pSrc->szFN.c_str()); + CLogWriter::Write("CN3SndEng::LoadSource - FillBufferWithSound Failed.. (%)", pSrc->fsFile.string().c_str()); #endif return false; } diff --git a/src/engine/N3Base/N3SndMgr.cpp b/src/engine/N3Base/N3SndMgr.cpp index 2d8e37da..e7e8e810 100644 --- a/src/engine/N3Base/N3SndMgr.cpp +++ b/src/engine/N3Base/N3SndMgr.cpp @@ -26,7 +26,7 @@ CN3SndMgr::~CN3SndMgr() { void CN3SndMgr::Init(HWND hWnd) { Release(); m_bSndEnable = CN3SndObj::StaticInit(hWnd); - m_Tbl_Source.LoadFromFile("Data\\sound.tbl"); + m_Tbl_Source.LoadFromFile(fs::path("Data") / "sound.tbl"); } CN3SndObj * CN3SndMgr::CreateObj(int iID, e_SndType eType) { @@ -35,26 +35,26 @@ CN3SndObj * CN3SndMgr::CreateObj(int iID, e_SndType eType) { return NULL; } - return this->CreateObj(pTbl->szFN, eType); + return this->CreateObj(pTbl->szFile, eType); } -CN3SndObj * CN3SndMgr::CreateObj(const std::string & szFN, e_SndType eType) { +CN3SndObj * CN3SndMgr::CreateObj(const fs::path & fsFile, e_SndType eType) { if (!m_bSndEnable) { return NULL; } CN3SndObj * pObjSrc = NULL; - itm_Snd it = m_SndObjSrcs.find(szFN); + itm_Snd it = m_SndObjSrcs.find(fsFile); if (it == m_SndObjSrcs.end()) // 못 찾았다... 새로 만들자.. { pObjSrc = new CN3SndObj(); - if (false == pObjSrc->Create(szFN, eType)) // 새로 로딩.. + if (false == pObjSrc->Create(fsFile, eType)) // 새로 로딩.. { delete pObjSrc; pObjSrc = NULL; return NULL; } - m_SndObjSrcs.insert(val_Snd(szFN, pObjSrc)); // 맵에 추가한다.. + m_SndObjSrcs.insert(val_Snd(fsFile, pObjSrc)); // 맵에 추가한다.. } else { pObjSrc = it->second; } @@ -81,9 +81,9 @@ CN3SndObj * CN3SndMgr::CreateObj(const std::string & szFN, e_SndType eType) { return pObjNew; } -CN3SndObjStream * CN3SndMgr::CreateStreamObj(const std::string & szFN) { +CN3SndObjStream * CN3SndMgr::CreateStreamObj(const fs::path & fsFile) { CN3SndObjStream * pObj = new CN3SndObjStream(); - if (false == pObj->Create(szFN)) { + if (false == pObj->Create(fsFile)) { delete pObj; pObj = NULL; return NULL; @@ -100,7 +100,7 @@ CN3SndObjStream * CN3SndMgr::CreateStreamObj(int iID) { return NULL; } - return this->CreateStreamObj(pTbl->szFN); + return this->CreateStreamObj(pTbl->szFile); } void CN3SndMgr::ReleaseStreamObj(CN3SndObjStream ** ppObj) { @@ -201,7 +201,7 @@ void CN3SndMgr::ReleaseObj(CN3SndObj ** ppObj) { if (NULL == ppObj || NULL == *ppObj) { return; } - std::string szFN = (*ppObj)->m_szFileName; // 파일 이름을 기억하고.. + fs::path fsFile = (*ppObj)->m_fsFile; // 파일 이름을 기억하고.. itl_Snd it = m_SndObjs_Duplicated.begin(), itEnd = m_SndObjs_Duplicated.end(); for (; it != itEnd; it++) { @@ -226,7 +226,7 @@ void CN3SndMgr::ReleaseObj(CN3SndObj ** ppObj) { *ppObj = NULL; // 포인터만 널로 만들어 준다.. - /* itm_Snd it = m_SndObjSrcs.find(szFN); + /* itm_Snd it = m_SndObjSrcs.find(fsFile); if(it != m_SndObjSrcs.end()) // 찾았다.. { CN3SndObj* pObj = it->second; @@ -308,22 +308,22 @@ bool CN3SndMgr::PlayOnceAndRelease(int iSndID, const _D3DVECTOR * pPos) { } TABLE_SOUND * pTbl = m_Tbl_Source.Find(iSndID); - if (pTbl == NULL || pTbl->szFN.empty()) { + if (pTbl == NULL || pTbl->szFile.empty()) { return false; } CN3SndObj * pObjSrc = NULL; - itm_Snd it = m_SndObjSrcs.find(pTbl->szFN); + itm_Snd it = m_SndObjSrcs.find(pTbl->szFile); if (it == m_SndObjSrcs.end()) // 못 찾았다... 새로 만들자.. { pObjSrc = new CN3SndObj(); - if (false == pObjSrc->Create(pTbl->szFN, (e_SndType)pTbl->iType)) // 새로 로딩.. + if (false == pObjSrc->Create(pTbl->szFile, (e_SndType)pTbl->iType)) // 새로 로딩.. { delete pObjSrc; pObjSrc = NULL; return NULL; } - m_SndObjSrcs.insert(val_Snd(pTbl->szFN, pObjSrc)); // 맵에 추가한다.. + m_SndObjSrcs.insert(val_Snd(pTbl->szFile, pObjSrc)); // 맵에 추가한다.. if (!m_bSndDuplicated) { pObjSrc->Play(pPos); //this_Snd } @@ -357,7 +357,7 @@ bool CN3SndMgr::PlayOnceAndRelease(int iSndID, const _D3DVECTOR * pPos) { return false; /* CN3SndObj* pObj = new CN3SndObj(); - if(false == pObj->Create(pTbl->szFN, (e_SndType)pTbl->iType)) + if(false == pObj->Create(pTbl->fsFile, (e_SndType)pTbl->iType)) { delete pObj; pObj = NULL; return false; @@ -366,4 +366,4 @@ bool CN3SndMgr::PlayOnceAndRelease(int iSndID, const _D3DVECTOR * pPos) { m_SndObjs_PlayOnceAndRelease.push_back(pObj); return true; */ -} \ No newline at end of file +} diff --git a/src/engine/N3Base/N3SndMgr.h b/src/engine/N3Base/N3SndMgr.h index 7de5fc33..b0dd4e6e 100644 --- a/src/engine/N3Base/N3SndMgr.h +++ b/src/engine/N3Base/N3SndMgr.h @@ -14,20 +14,20 @@ class CN3SndObj; class CN3SndObjStream; -typedef typename std::list::iterator itl_Snd; -typedef typename std::list::iterator itl_SndStream; -typedef typename std::map::iterator itm_Snd; -typedef typename std::map::value_type val_Snd; +typedef typename std::list::iterator itl_Snd; +typedef typename std::list::iterator itl_SndStream; +typedef typename std::map::iterator itm_Snd; +typedef typename std::map::value_type val_Snd; class CN3SndMgr { protected: CN3TableBase<__TABLE_SOUND> m_Tbl_Source; // 사운드 소스 정보 테이블.. - bool m_bSndEnable; - bool m_bSndDuplicated; - std::map m_SndObjSrcs; - std::list m_SndObjStreams; // 스트리밍 사운드.. - std::list m_SndObjs_Duplicated; + bool m_bSndEnable; + bool m_bSndDuplicated; + std::map m_SndObjSrcs; + std::list m_SndObjStreams; // 스트리밍 사운드.. + std::list m_SndObjs_Duplicated; std::list m_SndObjs_PlayOnceAndRelease; // 한번만 플레이 하고 릴리즈 해야 하는 사운드들 public: @@ -44,9 +44,9 @@ class CN3SndMgr { void Release(); void Tick(); - CN3SndObj * CreateObj(const std::string & szFN, e_SndType eType = SNDTYPE_3D); + CN3SndObj * CreateObj(const fs::path & fsFile, e_SndType eType = SNDTYPE_3D); CN3SndObj * CreateObj(int iID, e_SndType eType = SNDTYPE_3D); - CN3SndObjStream * CreateStreamObj(const std::string & szFN); + CN3SndObjStream * CreateStreamObj(const fs::path & fsFile); CN3SndObjStream * CreateStreamObj(int iID); CN3SndMgr(); diff --git a/src/engine/N3Base/N3SndObj.cpp b/src/engine/N3Base/N3SndObj.cpp index c8e756ff..b2e56fd2 100644 --- a/src/engine/N3Base/N3SndObj.cpp +++ b/src/engine/N3Base/N3SndObj.cpp @@ -20,7 +20,6 @@ CN3SndObj::CN3SndObj() { m_lpDS3DBuff = NULL; m_bIsLoop = false; m_iVol = -1; - m_szFileName = ""; m_fFadeInTime = 0; m_fFadeOutTime = 0; @@ -43,7 +42,6 @@ void CN3SndObj::Init() { m_bIsLoop = false; m_iVol = -1; - m_szFileName = ""; m_fStartDelayTime = 0; m_fTmpSecPerFrm = 0; @@ -174,7 +172,7 @@ void CN3SndObj::StaticTick() { s_bNeedDeferredTick = false; } -bool CN3SndObj::Create(const std::string & szFN, e_SndType eType) { +bool CN3SndObj::Create(const fs::path & fsFile, e_SndType eType) { if (NULL == s_lpDS) { return false; } @@ -186,11 +184,11 @@ bool CN3SndObj::Create(const std::string & szFN, e_SndType eType) { } CWaveFile WaveFile; - HRESULT hr = WaveFile.Open(szFN.c_str(), NULL, 1); //#define WAVEFILE_READ 1 + HRESULT hr = WaveFile.Open(fsFile, NULL, 1); //#define WAVEFILE_READ 1 if (FAILED(hr)) { #ifdef _N3GAME - if (!szFN.empty()) { - CLogWriter::Write("CN3SndEng::LoadSource - WaveFile Open Failed.. (%s)", szFN.c_str()); + if (!fsFile.empty()) { + CLogWriter::Write("CN3SndEng::LoadSource - WaveFile Open Failed.. (%s)", fsFile.string().c_str()); } #endif return false; @@ -214,14 +212,14 @@ bool CN3SndObj::Create(const std::string & szFN, e_SndType eType) { hr = s_lpDS->CreateSoundBuffer(&dsbd, &m_lpDSBuff, NULL); if (FAILED(hr)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndObj::Create - CreateSoundBuffer Failed.. (%)", szFN.c_str()); + CLogWriter::Write("CN3SndObj::Create - CreateSoundBuffer Failed.. (%)", fsFile.string().c_str()); #endif return false; } if (!FillBufferWithSound(&WaveFile)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndObj::Create - FillBufferWithSound Failed.. (%)", szFN.c_str()); + CLogWriter::Write("CN3SndObj::Create - FillBufferWithSound Failed.. (%)", fsFile.string().c_str()); #endif return false; } @@ -233,7 +231,7 @@ bool CN3SndObj::Create(const std::string & szFN, e_SndType eType) { } } - m_szFileName = szFN; // 파일 이름을 기록한다.. + m_fsFile = fsFile; // 파일 이름을 기록한다.. s_bNeedDeferredTick = true; // 3D Listener CommitDeferredSetting return true; @@ -281,7 +279,7 @@ bool CN3SndObj::Duplicate(CN3SndObj * pSrc, e_SndType eType, D3DVECTOR * pPos) { } s_bNeedDeferredTick = true; // 3D Listener CommitDeferredSetting - m_szFileName = pSrc->m_szFileName; + m_fsFile = pSrc->m_fsFile; return true; } diff --git a/src/engine/N3Base/N3SndObj.h b/src/engine/N3Base/N3SndObj.h index ae45d64f..b88c39c8 100644 --- a/src/engine/N3Base/N3SndObj.h +++ b/src/engine/N3Base/N3SndObj.h @@ -28,7 +28,7 @@ class CN3SndObj { float m_fTmpSecPerFrm; public: - std::string m_szFileName; //파일이름...(ID 대용). + fs::path m_fsFile; //파일이름...(ID 대용). protected: virtual void RealPlay(); @@ -60,7 +60,7 @@ class CN3SndObj { void Init(); void Release(); // 참조 카운트를 리턴 해준다.. 사운드 매니저에서는 이 참조 카운트를 보고 맵에서 지운다.. - virtual bool Create(const std::string & szFN, e_SndType eType); + virtual bool Create(const fs::path & fsFile, e_SndType eType); bool Duplicate(CN3SndObj * pSrc, e_SndType eType, D3DVECTOR * pPos = NULL); void Play(const D3DVECTOR * pvPos = NULL, float delay = 0.0f, float fFadeInTime = 0.0f, bool bImmediately = true); diff --git a/src/engine/N3Base/N3SndObj2D.cpp b/src/engine/N3Base/N3SndObj2D.cpp index 45196b95..b8eff5a0 100644 --- a/src/engine/N3Base/N3SndObj2D.cpp +++ b/src/engine/N3Base/N3SndObj2D.cpp @@ -17,7 +17,6 @@ CN3SndObj2D::CN3SndObj() { m_bIsLoop = false; m_iVol = -1; m_iType = SNDTYPE_2D; - m_szFileName = ""; m_pRefMgr = NULL; m_fFadeInTime = 0; @@ -45,7 +44,7 @@ void CN3SndObj2D::Init() { m_iVol = -1; m_iType = SNDTYPE_2D; m_pRefMgr = NULL; - m_szFileName = ""; + m_fsFile = fs::path(); m_fStartDelayTime = 0; m_fTmpSecPerFrm = 0; diff --git a/src/engine/N3Base/N3SndObj2D.h b/src/engine/N3Base/N3SndObj2D.h index 31bf19be..de490f4c 100644 --- a/src/engine/N3Base/N3SndObj2D.h +++ b/src/engine/N3Base/N3SndObj2D.h @@ -29,9 +29,9 @@ class CN3SndObj2D { int m_iMaxVolume; public: - int m_iID; - bool m_bUse; - std::string m_szFileName; //파일이름...(ID 대용). + int m_iID; + bool m_bUse; + fs::path m_fsFile; //파일이름...(ID 대용). protected: virtual void RealPlay(); diff --git a/src/engine/N3Base/N3SndObjStream.cpp b/src/engine/N3Base/N3SndObjStream.cpp index 0a54163a..d62525cf 100644 --- a/src/engine/N3Base/N3SndObjStream.cpp +++ b/src/engine/N3Base/N3SndObjStream.cpp @@ -27,7 +27,7 @@ CN3SndObjStream::~CN3SndObjStream() { Release(); } -bool CN3SndObjStream::Create(const std::string & szFN, e_SndType eType) { +bool CN3SndObjStream::Create(const fs::path & fsFile, e_SndType eType) { Release(); if (NULL == s_lpDS) { @@ -36,11 +36,11 @@ bool CN3SndObjStream::Create(const std::string & szFN, e_SndType eType) { if (SNDTYPE_STREAM != eType) { return false; } - if (!LoadWave(szFN.c_str())) { + if (!LoadWave(fsFile)) { return false; } - m_szFileName = szFN; + m_fsFile = fsFile; DWORD nBlockAlign = m_WaveFormat.nBlockAlign; DWORD BlockPerSec = m_WaveFormat.nSamplesPerSec * nBlockAlign; @@ -76,8 +76,8 @@ bool CN3SndObjStream::Create(const std::string & szFN, e_SndType eType) { return true; } -BOOL CN3SndObjStream::LoadWave(LPCSTR pFileName) { - hMMIO = mmioOpen((LPSTR)pFileName, NULL, MMIO_READ | MMIO_ALLOCBUF); +BOOL CN3SndObjStream::LoadWave(const fs::path & fsFile) { + hMMIO = mmioOpenW(const_cast(fsFile.c_str()), NULL, MMIO_READ | MMIO_ALLOCBUF); if (hMMIO == NULL) { return FALSE; } @@ -326,4 +326,4 @@ void CN3SndObjStream::Stop(float fFadeOutTime) return; } */ -// end of N3SndObjStream.cpp \ No newline at end of file +// end of N3SndObjStream.cpp diff --git a/src/engine/N3Base/N3SndObjStream.h b/src/engine/N3Base/N3SndObjStream.h index ba3b1553..653b1b9f 100644 --- a/src/engine/N3Base/N3SndObjStream.h +++ b/src/engine/N3Base/N3SndObjStream.h @@ -37,7 +37,7 @@ class CN3SndObjStream : public CN3SndObj { HMMIO hMMIO; public: - bool Create(const std::string & szFN, e_SndType eType = SNDTYPE_STREAM); + bool Create(const fs::path & fsFile, e_SndType eType = SNDTYPE_STREAM); // void Play(float delay = 0.0f, float fFadeInTime = 0.0f); // void Stop(float fFadeOutTime = 0.0f); @@ -53,7 +53,7 @@ class CN3SndObjStream : public CN3SndObj { //void Stop(); - BOOL LoadWave(LPCSTR pFileName); + BOOL LoadWave(const fs::path & fsFile); BOOL WriteBuffer(); BOOL InitWriteBuffer(); void Reset(); diff --git a/src/engine/N3Base/N3Sun.cpp b/src/engine/N3Base/N3Sun.cpp index f80e7f27..e03e43f7 100644 --- a/src/engine/N3Base/N3Sun.cpp +++ b/src/engine/N3Base/N3Sun.cpp @@ -132,14 +132,14 @@ void CN3Sun::Tick() { } } -void CN3Sun::Init(const std::string * pszFNs) { +void CN3Sun::Init(const fs::path * pfsTexFiles) { Release(); const float fZ = 0.9f; const float rhw = 1.0f; const D3DCOLOR color = 0xffffffff; for (int i = 0; i < NUM_SUNPART; ++i) { - m_Parts[i].pTex = s_MngTex.Get(pszFNs[i]); // load texture + m_Parts[i].pTex = s_MngTex.Get(pfsTexFiles[i]); // load texture m_Parts[i].pVertices[0].Set(0, 0, fZ, rhw, color, 0.0f, 0.0f); m_Parts[i].pVertices[1].Set(0, 0, fZ, rhw, color, 1.0f, 0.0f); diff --git a/src/engine/N3Base/N3Sun.h b/src/engine/N3Base/N3Sun.h index 0d215a70..368c1a27 100644 --- a/src/engine/N3Base/N3Sun.h +++ b/src/engine/N3Base/N3Sun.h @@ -37,7 +37,7 @@ class CN3Sun : public CN3Base { // Operations public: void SetCurAngle(float fAngle) { m_fCurRadian = D3DXToRadian(fAngle); } // 현재 각도설정 - void Init(const std::string * pszFNs); + void Init(const fs::path * pfsTexFiles); // By : Ecli666 ( On 2002-04-04 오전 10:55:52 ) // float GetCurAngle() { return D3DXToDegree(m_fCurRadian); } diff --git a/src/engine/N3Base/N3TableBase.h b/src/engine/N3Base/N3TableBase.h index 8392bf2d..4aa2b061 100644 --- a/src/engine/N3Base/N3TableBase.h +++ b/src/engine/N3Base/N3TableBase.h @@ -84,7 +84,7 @@ template class CN3TableBase { return -1; } - BOOL LoadFromFile(const std::string & szFN); + BOOL LoadFromFile(const fs::path & fsFile); protected: BOOL Load(HANDLE hFile); @@ -268,27 +268,27 @@ template BOOL CN3TableBase::ReadData(HANDLE hFile, DATA_TYPE return TRUE; } -template BOOL CN3TableBase::LoadFromFile(const std::string & szFN) { - if (szFN.empty()) { +template BOOL CN3TableBase::LoadFromFile(const fs::path & fsFile) { + if (fsFile.empty()) { return FALSE; } - HANDLE hFile = ::CreateFile(szFN.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = ::CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { #ifdef _N3GAME - CLogWriter::Write("N3TableBase - Can't open file(read) File Handle error (%s)", szFN.c_str()); + CLogWriter::Write("N3TableBase - Can't open file(read) File Handle error (%s)", fsFile.string().c_str()); #endif return FALSE; } // 파일 암호화 풀기.. .. 임시 파일에다 쓴다음 .. - std::string szFNTmp = szFN + ".tmp"; - DWORD dwSizeHigh = 0; - DWORD dwSizeLow = ::GetFileSize(hFile, &dwSizeHigh); + fs::path fsFileTmp = fsFile + ".tmp"; + DWORD dwSizeHigh = 0; + DWORD dwSizeLow = ::GetFileSize(hFile, &dwSizeHigh); if (dwSizeLow <= 0) { CloseHandle(hFile); - ::remove(szFNTmp.c_str()); // 임시 파일 지우기.. + fs::remove(fsFileTmp); // 임시 파일 지우기.. return FALSE; } @@ -327,14 +327,14 @@ template BOOL CN3TableBase::LoadFromFile(const std::string & } // 임시 파일에 쓴다음.. 다시 연다.. - hFile = ::CreateFile(szFNTmp.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = ::CreateFileW(fsFileTmp.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); ::WriteFile(hFile, pDatas, dwSizeLow, &dwRWC, NULL); // 임시파일에 암호화 풀린 데이터 쓰기 CloseHandle(hFile); // 임시 파일 닫기 delete[] pDatas; pDatas = NULL; - hFile = ::CreateFile(szFNTmp.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - NULL); // 임시 파일 읽기 모드로 열기. + hFile = ::CreateFileW(fsFileTmp.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, + NULL); // 임시 파일 읽기 모드로 열기. BOOL bResult = Load(hFile); @@ -342,12 +342,12 @@ template BOOL CN3TableBase::LoadFromFile(const std::string & if (FALSE == bResult) { #ifdef _N3GAME - CLogWriter::Write("N3TableBase - incorrect table (%s)", szFN.c_str()); + CLogWriter::Write("N3TableBase - incorrect table (%s)", fsFile.string().c_str()); #endif } // 임시 파일 지우기.. - ::remove(szFNTmp.c_str()); + fs::remove(fsFileTmp); return bResult; } diff --git a/src/engine/N3Base/N3Texture.cpp b/src/engine/N3Base/N3Texture.cpp index fcb4db1a..ccf76ef4 100644 --- a/src/engine/N3Base/N3Texture.cpp +++ b/src/engine/N3Base/N3Texture.cpp @@ -115,15 +115,13 @@ bool CN3Texture::Create(int nWidth, int nHeight, D3DFORMAT Format, BOOL bGenerat #ifdef _N3GAME if (rval == D3DERR_INVALIDCALL) { - CLogWriter::Write("N3Texture: createtexture err D3DERR_INVALIDCALL(%s)", m_szFileName.c_str()); + CLogWriter::Write("N3Texture: createtexture err D3DERR_INVALIDCALL(%s)", FilePath().string().c_str()); return false; - } - if (rval == D3DERR_OUTOFVIDEOMEMORY) { - CLogWriter::Write("N3Texture: createtexture err D3DERR_OUTOFVIDEOMEMORY(%s)", m_szFileName.c_str()); + } else if (rval == D3DERR_OUTOFVIDEOMEMORY) { + CLogWriter::Write("N3Texture: createtexture err D3DERR_OUTOFVIDEOMEMORY(%s)", FilePath().string().c_str()); return false; - } - if (rval == E_OUTOFMEMORY) { - CLogWriter::Write("N3Texture: createtexture err E_OUTOFMEMORY(%s)", m_szFileName.c_str()); + } else if (rval == E_OUTOFMEMORY) { + CLogWriter::Write("N3Texture: createtexture err E_OUTOFMEMORY(%s)", FilePath().string().c_str()); return false; } #endif @@ -176,42 +174,32 @@ bool CN3Texture::CreateFromSurface(LPDIRECT3DSURFACE9 lpSurf, D3DFORMAT Format, } #endif // end of _N3TOOL -bool CN3Texture::LoadFromFile(const std::string & szFileName) { +bool CN3Texture::LoadFromFile(const fs::path & fsFile) { if (m_lpTexture != NULL) { this->Release(); } - this->FileNameSet(szFileName); // 파일 이름을 복사하고.. - std::string szFullPath; - if (-1 != m_szFileName.find(':') || -1 != m_szFileName.find("\\\\") || - -1 != m_szFileName.find("//")) // 문자열에 ':', '\\', '//' 이 들어 있으면 전체 경로이다.. - { - szFullPath = m_szFileName; - } else { - if (NULL != CN3Base::PathGet()[0]) { - szFullPath = CN3Base::PathGet(); - } - szFullPath += m_szFileName; - } + bool bSuccess = false; - int nFNL = szFullPath.size(); - if (lstrcmpi(&szFullPath[nFNL - 3], "DXT") == 0) { + this->FilePathSet(fsFile); + if (n3std::iequals(fsFile.extension(), ".dxt")) { HANDLE hFile = - ::CreateFile(szFullPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + ::CreateFileW(FilePathAbs().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { #ifdef _N3GAME - CLogWriter::Write("invalid file handle(%d) - Can't open texture file(%s)", (int)hFile, szFullPath.c_str()); + CLogWriter::Write("invalid file handle(%d) - Can't open texture file(%s)", (int)hFile, + FilePathAbs().string().c_str()); #endif return false; } - this->Load(hFile); + bSuccess = this->Load(hFile); CloseHandle(hFile); } else { D3DXIMAGE_INFO ImgInfo; HRESULT rval = - D3DXCreateTextureFromFileEx(s_lpD3DDev, szFullPath.c_str(), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, - D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE | D3DX_FILTER_MIRROR, - D3DX_FILTER_TRIANGLE | D3DX_FILTER_MIRROR, 0, &ImgInfo, NULL, &m_lpTexture); + D3DXCreateTextureFromFileExW(s_lpD3DDev, FilePathAbs().c_str(), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, + D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE | D3DX_FILTER_MIRROR, + D3DX_FILTER_TRIANGLE | D3DX_FILTER_MIRROR, 0, &ImgInfo, NULL, &m_lpTexture); if (rval == D3D_OK) { D3DSURFACE_DESC sd; m_lpTexture->GetLevelDesc(0, &sd); @@ -219,9 +207,10 @@ bool CN3Texture::LoadFromFile(const std::string & szFileName) { m_Header.nWidth = sd.Width; m_Header.nHeight = sd.Height; m_Header.Format = sd.Format; + bSuccess = true; } else { #ifdef _N3GAME - CLogWriter::Write("N3Texture - Failed to load texture(%s)", szFullPath.c_str()); + CLogWriter::Write("N3Texture - Failed to load texture(%s)", FilePathAbs().string().c_str()); #endif } @@ -242,11 +231,12 @@ bool CN3Texture::LoadFromFile(const std::string & szFileName) { } } - if (NULL == m_lpTexture) { + if (!m_lpTexture) { this->Release(); return false; } - return true; + + return bSuccess; } bool CN3Texture::Load(HANDLE hFile) { @@ -260,7 +250,7 @@ bool CN3Texture::Load(HANDLE hFile) { 3 != HeaderOrg.szID[3]) // "NTF"3 - Noah Texture File Ver. 3.0 { #ifdef _N3GAME - CLogWriter::Write("N3Texture Warning - Old format DXT file (%s)", m_szFileName.c_str()); + CLogWriter::Write("N3Texture Warning - Old format DXT file (%s)", FilePath().string().c_str()); #endif } @@ -320,7 +310,7 @@ bool CN3Texture::Load(HANDLE hFile) { if (m_lpTexture == NULL) { #ifdef _N3GAME - CLogWriter::Write("N3Texture error - Can't create texture (%s)", m_szFileName.c_str()); + CLogWriter::Write("N3Texture error - Can't create texture (%s)", FilePath().string().c_str()); #endif return false; } @@ -511,7 +501,7 @@ bool CN3Texture::SkipFileHandle(HANDLE hFile) { 3 != HeaderOrg.szID[3]) // "NTF"3 - Noah Texture File Ver. 3.0 { #ifdef _N3GAME - CLogWriter::Write("N3Texture Warning - Old format DXT file (%s)", m_szFileName.c_str()); + CLogWriter::Write("N3Texture Warning - Old format DXT file (%s)", FilePath().string().c_str()); #endif } @@ -583,9 +573,7 @@ bool CN3Texture::SkipFileHandle(HANDLE hFile) { #ifdef _N3TOOL bool CN3Texture::SaveToFile() { - char szExt[_MAX_EXT]; - _splitpath(m_szFileName.c_str(), NULL, NULL, NULL, szExt); - if (lstrcmpi(szExt, ".dxt") != 0) { + if (!n3std::iequals(FilePath().extension(), ".dxt")) { return false; } @@ -594,8 +582,8 @@ bool CN3Texture::SaveToFile() { #endif // end of _N3TOOL #ifdef _N3TOOL -bool CN3Texture::SaveToFile(const std::string & szFileName) { - this->FileNameSet(szFileName); +bool CN3Texture::SaveToFile(const fs::path & fsFile) { + this->FilePathSet(fsFile); return this->SaveToFile(); } #endif // end of _N3TOOL @@ -623,7 +611,7 @@ bool CN3Texture::Save(HANDLE hFile) { } if (nMMC < nMMC2) { #ifdef _N3GAME - CLogWriter::Write("N3Texture save warning - Invalid MipMap Count (%s)", m_szFileName.c_str()); + CLogWriter::Write("N3Texture save warning - Invalid MipMap Count (%s)", FilePath().string().c_str()); #endif m_Header.bMipMap = FALSE; nMMC = 1; @@ -888,8 +876,8 @@ bool CN3Texture::GenerateMipMap(LPDIRECT3DSURFACE9 lpSurfSrc) { void CN3Texture::UpdateRenderInfo() {} #ifdef _N3TOOL -bool CN3Texture::SaveToBitmapFile(const std::string & szFN) { - if (szFN.empty()) { +bool CN3Texture::SaveToBitmapFile(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } if (NULL == m_lpTexture) { @@ -943,6 +931,6 @@ bool CN3Texture::SaveToBitmapFile(const std::string & szFN) { lpSurfSrc->Release(); lpSurfSrc = NULL; - return bmpf.SaveToFile(szFN.c_str()); + return bmpf.SaveToFile(fsFile); } #endif // end of _N3TOOL diff --git a/src/engine/N3Base/N3Texture.h b/src/engine/N3Base/N3Texture.h index 58ea44e6..6cbccf35 100644 --- a/src/engine/N3Base/N3Texture.h +++ b/src/engine/N3Base/N3Texture.h @@ -23,7 +23,7 @@ class CN3Texture : public CN3BaseFileAccess { public: void UpdateRenderInfo(); - bool LoadFromFile(const std::string & szFileName); + bool LoadFromFile(const fs::path & fsFile); bool Load(HANDLE hFile); bool SkipFileHandle(HANDLE hFile); @@ -31,10 +31,10 @@ class CN3Texture : public CN3BaseFileAccess { bool GenerateMipMap(LPDIRECT3DSURFACE9 lpSurf = NULL); // NULL 이면 0 레벨의 서피스로부터 생성.. bool Convert(D3DFORMAT Format, int nWidth = 0, int nHeight = 0, BOOL bGenerateMipMap = TRUE); //#ifdef _N3TOOL - bool SaveToFile(); // 현재 파일 이름대로 저장. - bool SaveToFile(const std::string & szFileName); // 새이름으로 저장. + bool SaveToFile(); + bool SaveToFile(const fs::path & fsFile); bool Save(HANDLE hFile); - bool SaveToBitmapFile(const std::string & szFN); // 24비트 비트맵 파일로 저장.. + bool SaveToBitmapFile(const fs::path & fsFile); // Save as 24-bit bitmap file bool CreateFromSurface(LPDIRECT3DSURFACE9 lpSurf, D3DFORMAT Format, BOOL bGenerateMipMap); #endif // end of _N3TOOL diff --git a/src/engine/N3Base/N3TransformCollision.cpp b/src/engine/N3Base/N3TransformCollision.cpp index a824d6cf..e9e3a404 100644 --- a/src/engine/N3Base/N3TransformCollision.cpp +++ b/src/engine/N3Base/N3TransformCollision.cpp @@ -39,22 +39,23 @@ void CN3TransformCollision::Release() { bool CN3TransformCollision::Load(HANDLE hFile) { CN3Transform::Load(hFile); - int nL = 0; - char szFN[512] = ""; + DWORD dwRWC = 0; + int nL = 0; + std::string szFile; - DWORD dwRWC; ReadFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; // 메시 파일 이름.. - m_pMeshCollision = s_MngVMesh.Get(szFN); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + m_pMeshCollision = s_MngVMesh.Get(szFile); } + nL = 0; ReadFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName if (nL > 0) { - ReadFile(hFile, szFN, nL, &dwRWC, NULL); - szFN[nL] = NULL; // 메시 파일 이름.. - m_pMeshClimb = s_MngVMesh.Get(szFN); + szFile.assign(nL, '\0'); + ReadFile(hFile, szFile.data(), nL, &dwRWC, NULL); + m_pMeshClimb = s_MngVMesh.Get(szFile); } return true; } @@ -65,61 +66,68 @@ bool CN3TransformCollision::Save(HANDLE hFile) { DWORD dwRWC; - int nL = 0; + fs::path fsFile; + std::string szFile; + int iLen = 0; if (m_pMeshCollision) { - nL = m_pMeshCollision->FileName().size(); + fsFile = m_pMeshCollision->FilePathWin(); + szFile = fsFile.string(); + iLen = szFile.length(); } - WriteFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName - if (nL > 0) { - if (m_pMeshCollision->FileName().find("object\\") < - 0) // 임시로 경로를 바꾸려고 넣었다.. 나중에 필요없음 지운다.. - { - char szFNTmp[256]; - wsprintf(szFNTmp, "Object\\%s.N3VMesh", m_pMeshCollision->m_szName.c_str()); - m_pMeshCollision->FileNameSet(szFNTmp); + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName + if (iLen > 0) { + // 임시로 경로를 바꾸려고 넣었다.. 나중에 필요없음 지운다.. + if (!fsFile.parent_path().icontains("Object")) { + fsFile = fs::path("Object") / (m_pMeshCollision->m_szName + ".n3vmesh"); + m_pMeshCollision->FilePathSet(fsFile); + fsFile = m_pMeshCollision->FilePathWin(); + szFile = fsFile.string(); + iLen = szFile.length(); SetFilePointer(hFile, -4, 0, FILE_CURRENT); - nL = m_pMeshCollision->FileName().size(); - WriteFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName } - WriteFile(hFile, m_pMeshCollision->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); } - nL = 0; + iLen = 0; if (m_pMeshClimb) { - nL = m_pMeshClimb->FileName().size(); + fsFile = m_pMeshClimb->FilePathWin(); + szFile = fsFile.string(); + iLen = szFile.length(); } - WriteFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName - if (nL > 0) { - if (-1 == m_pMeshClimb->FileName().find("object\\")) // 임시로 경로를 바꾸려고 넣었다.. 나중에 필요없음 지운다.. - { - char szFNTmp[256]; - wsprintf(szFNTmp, "Object\\%s.N3VMesh", m_pMeshClimb->m_szName.c_str()); - m_pMeshClimb->FileNameSet(szFNTmp); + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName + if (iLen > 0) { + // 임시로 경로를 바꾸려고 넣었다.. 나중에 필요없음 지운다.. + if (!fsFile.parent_path().icontains("object")) { + fsFile = fs::path("Object") / (m_pMeshClimb->m_szName + ".n3vmesh"); + m_pMeshClimb->FilePathSet(fsFile); + fsFile = m_pMeshClimb->FilePathWin(); + szFile = fsFile.string(); + iLen = szFile.length(); SetFilePointer(hFile, -4, 0, FILE_CURRENT); - nL = m_pMeshClimb->FileName().size(); - WriteFile(hFile, &nL, 4, &dwRWC, NULL); // Mesh FileName + WriteFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName } - WriteFile(hFile, m_pMeshClimb->FileName().c_str(), nL, &dwRWC, NULL); + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); } return true; } #endif // end of _N3TOOL -void CN3TransformCollision::CollisionMeshSet(const std::string & szFN) { +void CN3TransformCollision::CollisionMeshSet(const fs::path & fsFile) { s_MngVMesh.Delete(&m_pMeshCollision); - m_pMeshCollision = s_MngVMesh.Get(szFN); + m_pMeshCollision = s_MngVMesh.Get(fsFile); if (m_pMeshCollision) { this->FindMinMax(); } } -void CN3TransformCollision::ClimbMeshSet(const std::string & szFN) { +void CN3TransformCollision::ClimbMeshSet(const fs::path & fsFile) { s_MngVMesh.Delete(&m_pMeshClimb); - m_pMeshClimb = s_MngVMesh.Get(szFN); + m_pMeshClimb = s_MngVMesh.Get(fsFile); if (m_pMeshClimb) { m_pMeshClimb->FindMinMax(); } diff --git a/src/engine/N3Base/N3TransformCollision.h b/src/engine/N3Base/N3TransformCollision.h index 4c8c2dc5..2af13bcf 100644 --- a/src/engine/N3Base/N3TransformCollision.h +++ b/src/engine/N3Base/N3TransformCollision.h @@ -27,8 +27,8 @@ class CN3TransformCollision : public CN3Transform { void SetRadius(float fRadius) { m_fRadius = fRadius; } void SetMin(__Vector3 vMin) { m_vMin = vMin; } void SetMax(__Vector3 vMax) { m_vMin = vMax; } - void SetMeshCollision(const std::string & szFN) { m_pMeshCollision = s_MngVMesh.Get(szFN); } - void SetMeshClimb(const std::string & szFN) { m_pMeshClimb = s_MngVMesh.Get(szFN); } + void SetMeshCollision(const fs::path & fsFile) { m_pMeshCollision = s_MngVMesh.Get(fsFile); } + void SetMeshClimb(const fs::path & fsFile) { m_pMeshClimb = s_MngVMesh.Get(fsFile); } // By : Dino ( On 2001-08-27 오후 9:15:24 ) // 주어진 지점이 m_fRadius 범위안에 있는지 체크 @@ -49,8 +49,8 @@ class CN3TransformCollision : public CN3Transform { CN3VMesh * CollisionMesh() { return m_pMeshCollision; } CN3VMesh * ClimbMesh() { return m_pMeshClimb; } - void CollisionMeshSet(const std::string & szFN); - void ClimbMeshSet(const std::string & szFN); + void CollisionMeshSet(const fs::path & fsFile); + void ClimbMeshSet(const fs::path & fsFile); bool Load(HANDLE hFile); #ifdef _N3TOOL diff --git a/src/engine/N3Base/N3UIBase.cpp b/src/engine/N3Base/N3UIBase.cpp index da357d50..f4df7d6b 100644 --- a/src/engine/N3Base/N3UIBase.cpp +++ b/src/engine/N3Base/N3UIBase.cpp @@ -279,9 +279,8 @@ bool CN3UIBase::Load(HANDLE hFile) { int iIDLen = 0; ReadFile(hFile, &iIDLen, sizeof(iIDLen), &dwRWC, NULL); // ui id length if (iIDLen > 0) { - std::vector buffer(iIDLen, 0); - ReadFile(hFile, &buffer[0], iIDLen, &dwRWC, NULL); // ui id - m_szID = std::string(buffer.begin(), buffer.end()); + m_szID.assign(iIDLen, '\0'); + ReadFile(hFile, m_szID.data(), iIDLen, &dwRWC, NULL); // ui id } else { m_szID = ""; } @@ -293,29 +292,27 @@ bool CN3UIBase::Load(HANDLE hFile) { int iTooltipLen; ReadFile(hFile, &iTooltipLen, sizeof(iTooltipLen), &dwRWC, NULL); // tooltip문자열 길이 if (iTooltipLen > 0) { - std::vector buffer(iTooltipLen, 0); - ReadFile(hFile, &buffer[0], iTooltipLen, &dwRWC, NULL); - m_szToolTip = std::string(buffer.begin(), buffer.end()); + m_szToolTip.assign(iTooltipLen, '\0'); + ReadFile(hFile, m_szToolTip.data(), iTooltipLen, &dwRWC, NULL); } // 이전 uif파일을 컨버팅 하려면 사운드 로드 하는 부분 막기 - int iSndFNLen = 0; - ReadFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwRWC, NULL); // 사운드 파일 문자열 길이 - if (iSndFNLen > 0) { - std::vector buffer(iSndFNLen, 0); - ReadFile(hFile, &buffer[0], iSndFNLen, &dwRWC, NULL); - + int iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwRWC, NULL); // 사운드 파일 문자열 길이 + if (iLen > 0) { + std::string szFile(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); __ASSERT(NULL == m_pSnd_OpenUI, "memory leak"); - m_pSnd_OpenUI = s_SndMgr.CreateObj(std::string(buffer.begin(), buffer.end()), SNDTYPE_2D); + m_pSnd_OpenUI = s_SndMgr.CreateObj(szFile, SNDTYPE_2D); } - ReadFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwRWC, NULL); // 사운드 파일 문자열 길이 - if (iSndFNLen > 0) { - std::vector buffer(iSndFNLen, 0); - ReadFile(hFile, &buffer[0], iSndFNLen, &dwRWC, NULL); - + iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwRWC, NULL); // 사운드 파일 문자열 길이 + if (iLen > 0) { + std::string szFile(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); __ASSERT(NULL == m_pSnd_CloseUI, "memory leak"); - m_pSnd_CloseUI = s_SndMgr.CreateObj(std::string(buffer.begin(), buffer.end()), SNDTYPE_2D); + m_pSnd_CloseUI = s_SndMgr.CreateObj(szFile, SNDTYPE_2D); } return true; @@ -407,16 +404,16 @@ DWORD CN3UIBase::MouseProc(DWORD dwFlags, const POINT & ptCur, const POINT & ptO return dwRet; } -bool CN3UIBase::EnableTooltip(const std::string & szFN) { +bool CN3UIBase::EnableTooltip(const fs::path & fsFile) { delete s_pTooltipCtrl; s_pTooltipCtrl = NULL; - if (szFN.empty()) { + if (fsFile.empty()) { return false; } s_pTooltipCtrl = new CN3UITooltip(); s_pTooltipCtrl->Init(NULL); - s_pTooltipCtrl->LoadFromFile(szFN); + s_pTooltipCtrl->LoadFromFile(fsFile); return true; } @@ -434,8 +431,8 @@ CN3UIBase * CN3UIBase::GetChildByID(const std::string & szID) { for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (*itor); - // if(pChild->m_szID == szID) return pChild; - if (lstrcmpi(pChild->m_szID.c_str(), szID.c_str()) == 0) { + //if(pChild->m_szID == szID) return pChild; + if (n3std::iequals(pChild->m_szID, szID)) { return pChild; // 대소문자 안가리고 검색.. } } @@ -587,12 +584,12 @@ void CN3UIBase::operator=(const CN3UIBase & other) { if (other.m_pSnd_OpenUI) { CN3Base::s_SndMgr.ReleaseObj(&m_pSnd_OpenUI); - m_pSnd_OpenUI = s_SndMgr.CreateObj(other.m_pSnd_OpenUI->m_szFileName, SNDTYPE_2D); + m_pSnd_OpenUI = s_SndMgr.CreateObj(other.m_pSnd_OpenUI->m_fsFile, SNDTYPE_2D); } if (other.m_pSnd_CloseUI) { CN3Base::s_SndMgr.ReleaseObj(&m_pSnd_CloseUI); - m_pSnd_CloseUI = s_SndMgr.CreateObj(other.m_pSnd_CloseUI->m_szFileName, SNDTYPE_2D); + m_pSnd_CloseUI = s_SndMgr.CreateObj(other.m_pSnd_CloseUI->m_fsFile, SNDTYPE_2D); } m_rcMovable = other.m_rcMovable; @@ -638,44 +635,48 @@ bool CN3UIBase::Save(HANDLE hFile) { WriteFile(hFile, m_szToolTip.c_str(), iTooltipLen, &dwRWC, NULL); } - int iSndFNLen = 0; + std::string szFile; + int iLen = 0; if (m_pSnd_OpenUI) { - iSndFNLen = m_pSnd_OpenUI->m_szFileName.size(); + szFile = fs::path(m_pSnd_OpenUI->m_fsFile).normalize('/', '\\').string(); + iLen = szFile.length(); } - WriteFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwRWC, NULL); // 사운드 파일 문자열 길이 - if (iSndFNLen > 0) { - WriteFile(hFile, m_pSnd_OpenUI->m_szFileName.c_str(), iSndFNLen, &dwRWC, NULL); + WriteFile(hFile, &iLen, sizeof(iLen), &dwRWC, NULL); // 사운드 파일 문자열 길이 + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); } - iSndFNLen = 0; + szFile.clear(); + iLen = 0; if (m_pSnd_CloseUI) { - iSndFNLen = m_pSnd_CloseUI->m_szFileName.size(); + szFile = fs::path(m_pSnd_CloseUI->m_fsFile).normalize('/', '\\').string(); + iLen = szFile.length(); } - WriteFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwRWC, NULL); // 사운드 파일 문자열 길이 - if (iSndFNLen > 0) { - WriteFile(hFile, m_pSnd_CloseUI->m_szFileName.c_str(), iSndFNLen, &dwRWC, NULL); + WriteFile(hFile, &iLen, sizeof(iLen), &dwRWC, NULL); // 사운드 파일 문자열 길이 + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwRWC, NULL); } return true; } -void CN3UIBase::ChangeImagePath(const std::string & szPathOld, const std::string & szPathNew) { +void CN3UIBase::ChangeImagePath(const fs::path & fsOldFile, const fs::path & fsNewFile) { // child 정보 for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (*itor); - pChild->ChangeImagePath(szPathOld, szPathNew); + pChild->ChangeImagePath(fsOldFile, fsNewFile); } } -void CN3UIBase::ChangeFont(const std::string & szFont) { +void CN3UIBase::ChangeFont(const fs::path & fsFile) { // child 정보 for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (*itor); - pChild->ChangeFont(szFont); + pChild->ChangeFont(fsFile); } } -void CN3UIBase::GatherImageFileName(std::set & setImgFile) { +void CN3UIBase::GatherImageFileName(std::set & setImgFile) { // child 정보 for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (*itor); @@ -957,8 +958,8 @@ void CN3UIBase::operator=(const CN3UIBase & other) { m_eState = other.m_eState; m_eType = other.m_eType; - SetSndOpen(other.GetSndFName_OpenUI()); - SetSndClose(other.GetSndFName_CloseUI()); + SetSndOpen(other.GetSndFileOpenUI()); + SetSndClose(other.GetSndFileCloseUI()); m_rcMovable = other.m_rcMovable; m_rcRegion = other.m_rcRegion; @@ -966,45 +967,41 @@ void CN3UIBase::operator=(const CN3UIBase & other) { m_szToolTip = other.m_szToolTip; } -void CN3UIBase::SetSndOpen(const std::string & strFileName) { +void CN3UIBase::SetSndOpen(const fs::path & fsFile) { CN3Base::s_SndMgr.ReleaseObj(&m_pSnd_OpenUI); - if (0 == strFileName.size()) { + fs::path fsSndFile = CN3BaseFileAccess::ToRelative(fsFile); + if (fsSndFile.empty()) { return; } - CN3BaseFileAccess tmpBase; - tmpBase.FileNameSet(strFileName); // Base경로에 대해서 상대적 경로를 넘겨준다. - - SetCurrentDirectory(CN3Base::PathGet().c_str()); - m_pSnd_OpenUI = s_SndMgr.CreateObj(tmpBase.FileName(), SNDTYPE_2D); + fs::current_path(CN3Base::PathGet()); + m_pSnd_OpenUI = s_SndMgr.CreateObj(fsSndFile, SNDTYPE_2D); } -void CN3UIBase::SetSndClose(const std::string & strFileName) { +void CN3UIBase::SetSndClose(const fs::path & fsFile) { CN3Base::s_SndMgr.ReleaseObj(&m_pSnd_CloseUI); - if (0 == strFileName.size()) { + fs::path fsFileRel = CN3BaseFileAccess::ToRelative(fsFile); + if (fsFileRel.empty()) { return; } - CN3BaseFileAccess tmpBase; - tmpBase.FileNameSet(strFileName); // Base경로에 대해서 상대적 경로를 넘겨준다. - - SetCurrentDirectory(CN3Base::PathGet().c_str()); - m_pSnd_CloseUI = s_SndMgr.CreateObj(tmpBase.FileName(), SNDTYPE_2D); + fs::current_path(CN3Base::PathGet()); + m_pSnd_CloseUI = s_SndMgr.CreateObj(fsFileRel, SNDTYPE_2D); } -std::string CN3UIBase::GetSndFName_OpenUI() const { +fs::path CN3UIBase::GetSndFileOpenUI() const { if (m_pSnd_OpenUI) { - return m_pSnd_OpenUI->m_szFileName; + return m_pSnd_OpenUI->m_fsFile; } else { - return std::string(""); + return fs::path(); } } -std::string CN3UIBase::GetSndFName_CloseUI() const { +fs::path CN3UIBase::GetSndFileCloseUI() const { if (m_pSnd_CloseUI) { - return m_pSnd_CloseUI->m_szFileName; + return m_pSnd_CloseUI->m_fsFile; } else { - return std::string(""); + return fs::path(); } } diff --git a/src/engine/N3Base/N3UIBase.h b/src/engine/N3Base/N3UIBase.h index 31b7afaf..403d8e46 100644 --- a/src/engine/N3Base/N3UIBase.h +++ b/src/engine/N3Base/N3UIBase.h @@ -133,8 +133,8 @@ class CN3UIBase : public CN3BaseFileAccess { virtual bool OnKeyPress(int iKey) { return false; } virtual bool OnKeyPressed(int iKey) { return false; } - static bool EnableTooltip(const std::string & szFN); // tooltip UI를 초기화 해준다. - static void DestroyTooltip(); // tooltip ui에 관련된 것을 해제해준다. + static bool EnableTooltip(const fs::path & fsFile); // tooltip UI를 초기화 해준다. + static void DestroyTooltip(); // tooltip ui에 관련된 것을 해제해준다. int GetChildrenCount() { return m_Children.size(); } CN3UIBase * GetChildByIndex(int iIndex) { @@ -153,9 +153,9 @@ class CN3UIBase : public CN3BaseFileAccess { #ifdef _N3TOOL public: virtual bool Save(HANDLE hFile); - virtual void ChangeImagePath(const std::string & szPathOld, const std::string & szPathNew); - virtual void ChangeFont(const std::string & szFont); - virtual void GatherImageFileName(std::set & setImgFile); + virtual void ChangeImagePath(const fs::path & fsOldFile, const fs::path & fsNewFile); + virtual void ChangeFont(const fs::path & fsFile); + virtual void GatherImageFileName(std::set & setImgFile); void ResizeAutomaticalyByChild(); int IsMyChild(CN3UIBase * pUI); @@ -166,11 +166,11 @@ class CN3UIBase : public CN3BaseFileAccess { bool MoveToLowest(CN3UIBase * pChild); bool MoveToHighest(CN3UIBase * pChild); - void ArrangeZOrder(); - void SetSndOpen(const std::string & strFileName); - void SetSndClose(const std::string & strFileName); - std::string GetSndFName_OpenUI() const; - std::string GetSndFName_CloseUI() const; + void ArrangeZOrder(); + void SetSndOpen(const fs::path & fsFile); + void SetSndClose(const fs::path & fsFile); + fs::path GetSndFileOpenUI() const; + fs::path GetSndFileCloseUI() const; virtual bool ReplaceAllTextures(const std::string & strFind, const std::string & strReplace); #endif diff --git a/src/engine/N3Base/N3UIButton.cpp b/src/engine/N3Base/N3UIButton.cpp index 89fea093..23951a18 100644 --- a/src/engine/N3Base/N3UIButton.cpp +++ b/src/engine/N3Base/N3UIButton.cpp @@ -280,20 +280,19 @@ bool CN3UIButton::Load(HANDLE hFile) { int iSndFNLen = 0; ReadFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwNum, NULL); // 사운드 파일 문자열 길이 if (iSndFNLen > 0) { - std::vector buffer(iSndFNLen, 0); - ReadFile(hFile, &buffer[0], iSndFNLen, &dwNum, NULL); - + std::string szFile(iSndFNLen, '\0'); + ReadFile(hFile, szFile.data(), iSndFNLen, &dwNum, NULL); __ASSERT(NULL == m_pSnd_On, "memory leak"); - m_pSnd_On = s_SndMgr.CreateObj(std::string(buffer.begin(), buffer.end()), SNDTYPE_2D); + m_pSnd_On = s_SndMgr.CreateObj(szFile, SNDTYPE_2D); } + iSndFNLen = 0; ReadFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwNum, NULL); // 사운드 파일 문자열 길이 if (iSndFNLen > 0) { - std::vector buffer(iSndFNLen, 0); - ReadFile(hFile, &buffer[0], iSndFNLen, &dwNum, NULL); - + std::string szFile(iSndFNLen, '\0'); + ReadFile(hFile, szFile.data(), iSndFNLen, &dwNum, NULL); __ASSERT(NULL == m_pSnd_Click, "memory leak"); - m_pSnd_Click = s_SndMgr.CreateObj(std::string(buffer.begin(), buffer.end()), SNDTYPE_2D); + m_pSnd_Click = s_SndMgr.CreateObj(szFile, SNDTYPE_2D); } return true; @@ -303,9 +302,9 @@ bool CN3UIButton::Load(HANDLE hFile) { void CN3UIButton::operator=(const CN3UIButton & other) { CN3UIBase::operator=(other); - m_rcClick = other.m_rcClick; // 클릭 영역 - SetSndOn(other.GetSndFName_On()); // 사운드 - SetSndClick(other.GetSndFName_Click()); // 사운드 + m_rcClick = other.m_rcClick; // 클릭 영역 + SetSndOn(other.GetSndFileOn()); // 사운드 + SetSndClick(other.GetSndFileClick()); // 사운드 // m_ImageRef 설정하기 for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { @@ -327,22 +326,25 @@ bool CN3UIButton::Save(HANDLE hFile) { DWORD dwNum; WriteFile(hFile, &m_rcClick, sizeof(m_rcClick), &dwNum, NULL); // click 영역 - int iSndFNLen = 0; + std::string szFile; + int iLen = 0; if (m_pSnd_On) { - iSndFNLen = m_pSnd_On->m_szFileName.size(); + szFile = fs::path(m_pSnd_On->m_fsFile).normalize('/', '\\').string(); + iLen = szFile.length(); } - WriteFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwNum, NULL); // 사운드 파일 문자열 길이 - if (iSndFNLen > 0) { - WriteFile(hFile, m_pSnd_On->m_szFileName.c_str(), iSndFNLen, &dwNum, NULL); + WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // 사운드 파일 문자열 길이 + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwNum, NULL); } - iSndFNLen = 0; + iLen = 0; if (m_pSnd_Click) { - iSndFNLen = m_pSnd_Click->m_szFileName.size(); + szFile = fs::path(m_pSnd_Click->m_fsFile).normalize('/', '\\').string(); + iLen = szFile.length(); } - WriteFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwNum, NULL); // 사운드 파일 문자열 길이 - if (iSndFNLen > 0) { - WriteFile(hFile, m_pSnd_Click->m_szFileName.c_str(), iSndFNLen, &dwNum, NULL); + WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // 사운드 파일 문자열 길이 + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwNum, NULL); } return true; @@ -360,46 +362,34 @@ void CN3UIButton::CreateImages() { } } -void CN3UIButton::SetSndOn(const std::string & strFileName) { +void CN3UIButton::SetSndOn(const fs::path & fsFile) { CN3Base::s_SndMgr.ReleaseObj(&m_pSnd_On); - if (0 == strFileName.size()) { + fs::path fsFileRel = CN3BaseFileAccess::ToRelative(fsFile); + if (fsFileRel.empty()) { return; } - CN3BaseFileAccess tmpBase; - tmpBase.FileNameSet(strFileName); // Base경로에 대해서 상대적 경로를 넘겨준다. - - SetCurrentDirectory(CN3Base::PathGet().c_str()); - m_pSnd_On = s_SndMgr.CreateObj(tmpBase.FileName(), SNDTYPE_2D); + fs::current_path(CN3Base::PathGet()); + m_pSnd_On = s_SndMgr.CreateObj(fsFileRel, SNDTYPE_2D); } -void CN3UIButton::SetSndClick(const std::string & strFileName) { +void CN3UIButton::SetSndClick(const fs::path & fsFile) { CN3Base::s_SndMgr.ReleaseObj(&m_pSnd_Click); - if (0 == strFileName.size()) { + fs::path fsFileRel = CN3BaseFileAccess::ToRelative(fsFile); + if (fsFileRel.empty()) { return; } - CN3BaseFileAccess tmpBase; - tmpBase.FileNameSet(strFileName); // Base경로에 대해서 상대적 경로를 넘겨준다. - - SetCurrentDirectory(CN3Base::PathGet().c_str()); - m_pSnd_Click = s_SndMgr.CreateObj(tmpBase.FileName(), SNDTYPE_2D); + fs::current_path(CN3Base::PathGet()); + m_pSnd_Click = s_SndMgr.CreateObj(fsFileRel, SNDTYPE_2D); } -std::string CN3UIButton::GetSndFName_On() const { - if (m_pSnd_On) { - return m_pSnd_On->m_szFileName; - } else { - return std::string(""); - } +fs::path CN3UIButton::GetSndFileOn() const { + return m_pSnd_On ? m_pSnd_On->m_fsFile : fs::path(); } -std::string CN3UIButton::GetSndFName_Click() const { - if (m_pSnd_Click) { - return m_pSnd_Click->m_szFileName; - } else { - return std::string(""); - } +fs::path CN3UIButton::GetSndFileClick() const { + return m_pSnd_Click ? m_pSnd_Click->m_fsFile : fs::path(); } #endif diff --git a/src/engine/N3Base/N3UIButton.h b/src/engine/N3Base/N3UIButton.h index 099a5f8f..2a6874e1 100644 --- a/src/engine/N3Base/N3UIButton.h +++ b/src/engine/N3Base/N3UIButton.h @@ -49,10 +49,10 @@ class CN3UIButton : public CN3UIBase { virtual bool Save(HANDLE hFile); void CreateImages(); CN3UIImage * GetImageRef(eBTN_STATE eState) const { return m_ImageRef[eState]; } - void SetSndOn(const std::string & strFileName); - void SetSndClick(const std::string & strFileName); + void SetSndOn(const fs::path & fsFile); + void SetSndClick(const fs::path & fsFile); - std::string GetSndFName_On() const; - std::string GetSndFName_Click() const; + fs::path GetSndFileOn() const; + fs::path GetSndFileClick() const; #endif }; diff --git a/src/engine/N3Base/N3UIDef.h b/src/engine/N3Base/N3UIDef.h index 9729e912..8dc7e4ce 100644 --- a/src/engine/N3Base/N3UIDef.h +++ b/src/engine/N3Base/N3UIDef.h @@ -6,8 +6,6 @@ #include -#define DIR_UITEXTURE ("Texture\\UI\\") - const float UI_DEFAULT_Z = 0.9f; const float UI_DEFAULT_RHW = 1.0f; diff --git a/src/engine/N3Base/N3UIEdit.cpp b/src/engine/N3Base/N3UIEdit.cpp index d0c45368..83e2ef9c 100644 --- a/src/engine/N3Base/N3UIEdit.cpp +++ b/src/engine/N3Base/N3UIEdit.cpp @@ -657,16 +657,15 @@ bool CN3UIEdit::Load(HANDLE hFile) { } // 이전 uif파일을 컨버팅 하려면 사운드 로드 하는 부분 막기 - int iSndFNLen = 0; DWORD dwNum; + int iSndFNLen = 0; ReadFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwNum, NULL); // 사운드 파일 문자열 길이 if (iSndFNLen > 0) { - std::vector buffer(iSndFNLen, 0); - ReadFile(hFile, &buffer[0], iSndFNLen, &dwNum, NULL); - + std::string szFile(iSndFNLen, '\0'); + ReadFile(hFile, szFile.data(), iSndFNLen, &dwNum, NULL); __ASSERT(NULL == m_pSnd_Typing, "memory leak"); - m_pSnd_Typing = s_SndMgr.CreateObj(std::string(buffer.begin(), buffer.end()), SNDTYPE_2D); + m_pSnd_Typing = s_SndMgr.CreateObj(szFile, SNDTYPE_2D); } return true; @@ -675,7 +674,7 @@ bool CN3UIEdit::Load(HANDLE hFile) { #ifdef _N3TOOL void CN3UIEdit::operator=(const CN3UIEdit & other) { CN3UIStatic::operator=(other); - SetSndTyping(other.GetSndFName_Typing()); + SetSndTyping(other.GetSndFileTyping()); } bool CN3UIEdit::Save(HANDLE hFile) { @@ -685,36 +684,36 @@ bool CN3UIEdit::Save(HANDLE hFile) { DWORD dwNum; - int iSndFNLen = 0; + std::string szFile; + int iLen = 0; if (m_pSnd_Typing) { - iSndFNLen = m_pSnd_Typing->m_szFileName.size(); + szFile = fs::path(m_pSnd_Typing->m_fsFile).normalize('/', '\\').string(); + iLen = szFile.length(); } - WriteFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwNum, NULL); // 사운드 파일 문자열 길이 - if (iSndFNLen > 0) { - WriteFile(hFile, m_pSnd_Typing->m_szFileName.c_str(), iSndFNLen, &dwNum, NULL); + WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // 사운드 파일 문자열 길이 + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwNum, NULL); } return true; } -void CN3UIEdit::SetSndTyping(const std::string & strFileName) { +void CN3UIEdit::SetSndTyping(const fs::path & fsFile) { CN3Base::s_SndMgr.ReleaseObj(&m_pSnd_Typing); - if (0 == strFileName.size()) { + fs::path fsFileRel = CN3BaseFileAccess::ToRelative(fsFile); + if (fsFileRel.empty()) { return; } - CN3BaseFileAccess tmpBase; - tmpBase.FileNameSet(strFileName); // Base경로에 대해서 상대적 경로를 넘겨준다. - - SetCurrentDirectory(CN3Base::PathGet().c_str()); - m_pSnd_Typing = s_SndMgr.CreateObj(tmpBase.FileName(), SNDTYPE_2D); + fs::current_path(CN3Base::PathGet()); + m_pSnd_Typing = s_SndMgr.CreateObj(fsFileRel, SNDTYPE_2D); } -std::string CN3UIEdit::GetSndFName_Typing() const { +fs::path CN3UIEdit::GetSndFileTyping() const { if (m_pSnd_Typing) { - return m_pSnd_Typing->m_szFileName; + return m_pSnd_Typing->m_fsFile; } else { - return std::string(""); + return fs::path(); } } #endif diff --git a/src/engine/N3Base/N3UIEdit.h b/src/engine/N3Base/N3UIEdit.h index 94297342..9c00e5ec 100644 --- a/src/engine/N3Base/N3UIEdit.h +++ b/src/engine/N3Base/N3UIEdit.h @@ -87,7 +87,7 @@ class CN3UIEdit : public CN3UIStatic { public: virtual void operator=(const CN3UIEdit & other); virtual bool Save(HANDLE hFile); - void SetSndTyping(const std::string & strFileName); - std::string GetSndFName_Typing() const; + void SetSndTyping(const fs::path & fsFile); + fs::path GetSndFileTyping() const; #endif }; diff --git a/src/engine/N3Base/N3UIImage.cpp b/src/engine/N3Base/N3UIImage.cpp index a6636f5d..763f4b48 100644 --- a/src/engine/N3Base/N3UIImage.cpp +++ b/src/engine/N3Base/N3UIImage.cpp @@ -15,7 +15,6 @@ CN3UIImage::CN3UIImage() { m_pVB = NULL; m_pTexRef = NULL; - m_szTexFN = ""; m_pAnimImagesRef = NULL; ZeroMemory(&m_frcUVRect, sizeof(m_frcUVRect)); @@ -44,7 +43,7 @@ void CN3UIImage::Release() { m_pVB = NULL; } s_MngTex.Delete(&m_pTexRef); - m_szTexFN = ""; + m_fsTexFile.clear(); ZeroMemory(&m_frcUVRect, sizeof(m_frcUVRect)); m_Color = D3DCOLOR_ARGB(0xff, 0xff, 0xff, 0xff); @@ -102,12 +101,12 @@ void CN3UIImage::SetVB() { } } -void CN3UIImage::SetTex(const std::string & szFN) { - m_szTexFN = szFN; +void CN3UIImage::SetTex(const fs::path & fsFile) { + m_fsTexFile = fsFile; s_MngTex.Delete(&m_pTexRef); // animate image일때만 texture 지정하기 if (!(UISTYLE_IMAGE_ANIMATE & m_dwStyle)) { - m_pTexRef = s_MngTex.Get(szFN); + m_pTexRef = s_MngTex.Get(fsFile); } } @@ -206,16 +205,17 @@ bool CN3UIImage::Load(HANDLE hFile) { if (false == CN3UIBase::Load(hFile)) { return false; } - DWORD dwNum; - // texture 정보 - __ASSERT(NULL == m_pTexRef, "load 하기 전에 초기화가 되지 않았습니다."); - int iStrLen = 0; - ReadFile(hFile, &iStrLen, sizeof(iStrLen), &dwNum, NULL); // 파일 이름 길이 - char szFName[MAX_PATH] = ""; - if (iStrLen > 0) { - ReadFile(hFile, szFName, iStrLen, &dwNum, NULL); // 파일 이름 - szFName[iStrLen] = '\0'; - this->SetTex(szFName); + + __ASSERT(NULL == m_pTexRef, "Not initialized before loading."); + + DWORD dwNum = 0; + + int iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // 파일 이름 길이 + if (iLen > 0) { + std::string szFile(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwNum, NULL); // 파일 이름 + SetTex(szFile); } ReadFile(hFile, &m_frcUVRect, sizeof(m_frcUVRect), &dwNum, NULL); // uv좌표 @@ -258,9 +258,9 @@ void CN3UIImage::operator=(const CN3UIImage & other) { m_iAnimCount = other.m_iAnimCount; if (other.m_pTexRef) { - m_pTexRef = s_MngTex.Get(other.m_pTexRef->FileName()); + m_pTexRef = s_MngTex.Get(other.m_pTexRef->FilePath()); } - m_szTexFN = other.m_szTexFN; + m_fsTexFile = other.m_fsTexFile; // Animate 되는 image이면 관련된 변수 세팅 m_iAnimCount = m_Children.size(); // animate image 수 정하기 @@ -289,12 +289,13 @@ bool CN3UIImage::Save(HANDLE hFile) { DWORD dwNum; // texture 정보 if (m_pTexRef) { - m_szTexFN = m_pTexRef->FileName(); + m_fsTexFile = m_pTexRef->FilePathWin(); } - int iStrLen = m_szTexFN.size(); - WriteFile(hFile, &iStrLen, sizeof(iStrLen), &dwNum, NULL); // 파일 길이 - if (iStrLen > 0) { - WriteFile(hFile, m_szTexFN.c_str(), iStrLen, &dwNum, NULL); // 파일 이름 + std::string szTexFile = m_fsTexFile.string(); + int iLen = szTexFile.length(); + WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // 파일 길이 + if (iLen > 0) { + WriteFile(hFile, szTexFile.c_str(), iLen, &dwNum, NULL); // 파일 이름 } WriteFile(hFile, &m_frcUVRect, sizeof(m_frcUVRect), &dwNum, NULL); // uv좌표 @@ -303,41 +304,37 @@ bool CN3UIImage::Save(HANDLE hFile) { return true; } -void CN3UIImage::ChangeImagePath(const std::string & szPathOld, const std::string & szPathNew) { - CN3UIBase::ChangeImagePath(szPathOld, szPathNew); +void CN3UIImage::ChangeImagePath(const fs::path & fsOldFile, const fs::path & fsNewFile) { + CN3UIBase::ChangeImagePath(fsOldFile, fsNewFile); - std::string szOld = szPathOld, szNew = szPathNew; - - if (!szOld.empty()) { - ::CharLower(&(szOld[0])); - } - if (!szNew.empty()) { - ::CharLower(&(szNew[0])); + fs::path fsOld = fsOldFile, fsNew = fsNewFile; + if (!fsOld.empty()) { + CN3BaseFileAccess::ToRelative(fsOld); } - if (!m_szTexFN.empty()) { - ::CharLower(&(m_szTexFN[0])); + if (!fsNew.empty()) { + CN3BaseFileAccess::ToRelative(fsNew); } if (m_pTexRef) { - m_szTexFN = m_pTexRef->FileName(); + m_fsTexFile = m_pTexRef->FilePath(); } - int i = m_szTexFN.find(szOld); - if (i >= 0) { - std::string szF = m_szTexFN.substr(0, i); - std::string szL = m_szTexFN.substr(i + szOld.size()); - m_szTexFN = szF + szNew + szL; + if (!m_fsTexFile.empty()) { + CN3BaseFileAccess::ToRelative(m_fsTexFile); + } + + if (m_fsTexFile == fsOld) { + m_fsTexFile = fsNew; s_MngTex.Delete(&m_pTexRef); - m_pTexRef = s_MngTex.Get(m_szTexFN); + m_pTexRef = s_MngTex.Get(m_fsTexFile); } } -void CN3UIImage::GatherImageFileName(std::set & setImgFile) { +void CN3UIImage::GatherImageFileName(std::set & setImgFile) { CN3UIBase::GatherImageFileName(setImgFile); // child 정보 - std::string szImgFN = m_szTexFN; - if (!szImgFN.empty()) { - ::CharLower(&(szImgFN[0])); - setImgFile.insert(szImgFN); + fs::path fsTexFile = m_fsTexFile; + if (!fsTexFile.empty()) { + setImgFile.insert(fsTexFile.lower()); } } @@ -415,86 +412,91 @@ void CN3UIImage::SetAnimImage(int iAnimCount) { } bool CN3UIImage::ReplaceAllTextures(const std::string & strFind, const std::string & strReplace) { - if (strFind.size() <= 0 || strReplace.size() <= 0) { + if (strFind.empty() || strReplace.empty()) { return false; } - while (m_pTexRef) { - char szFindDir[_MAX_DIR], szFindFName[_MAX_FNAME], szFindExt[_MAX_EXT]; - char szReplaceDir[_MAX_DIR], szReplaceFName[_MAX_FNAME], szReplaceExt[_MAX_EXT]; - char szTexDir[_MAX_DIR], szTexFName[_MAX_FNAME], szTexExt[_MAX_EXT]; - _splitpath(strFind.c_str(), NULL, szFindDir, szFindFName, szFindExt); - _splitpath(strReplace.c_str(), NULL, szReplaceDir, szReplaceFName, szReplaceExt); - _splitpath(m_pTexRef->FileName().c_str(), NULL, szTexDir, szTexFName, szTexExt); - - if (lstrlen(szFindFName) == 0 || lstrlen(szFindExt) == 0 || lstrlen(szReplaceFName) == 0 || - lstrlen(szReplaceExt) == 0) { - return false; - } - std::string strNew(szTexDir); - if (lstrcmpi(szFindFName, "*") == 0) { - if (lstrcmpi(szFindExt, ".*") == 0) { // *.* -> - if (lstrcmpi(szReplaceFName, "*") == 0) { - strNew += szTexFName; + fs::path fsFindPath(strFind); + fs::path fsReplacePath(strReplace); + + std::string szFindStem = fsFindPath.stem().string(); + std::string szFindExt = fsFindPath.extension().string(); + + std::string szReplaceStem = fsReplacePath.stem().string(); + std::string szReplaceExt = fsReplacePath.extension().string(); + + if (szFindStem.empty() || szFindExt.empty() || szReplaceStem.empty() || szReplaceExt.empty()) { + return false; + } + + while (m_pTexRef) { + std::string szTexStem = m_pTexRef->FilePath().stem().string(); + std::string szTexExt = m_pTexRef->FilePath().extension().string(); + + fs::path fsNew = m_pTexRef->FilePath().parent_path(); + if (szFindStem == "*") { + if (szFindExt == ".*") { // *.* -> + if (szReplaceStem == "*") { + fsNew /= szTexStem; } else { - strNew += szReplaceFName; + fsNew /= szReplaceStem; } - if (lstrcmpi(szReplaceExt, ".*") == 0) { - strNew += szTexExt; + if (szReplaceExt == ".*") { + fsNew += szTexExt; } else { - strNew += szReplaceExt; + fsNew += szReplaceExt; } } else { // *.tga -> - if (lstrcmpi(szFindExt, szTexExt) != 0) { + if (!n3std::iequals(szFindExt, szTexExt)) { break; // 확장자가 같지 않으므로 그냥 리턴 } - if (lstrcmpi(szReplaceFName, "*") == 0) { - strNew += szTexFName; + if (szReplaceStem == "*") { + fsNew /= szTexStem; } else { - strNew += szReplaceFName; + fsNew /= szReplaceStem; } - if (lstrcmpi(szReplaceExt, ".*") == 0) { - strNew += szTexExt; + if (szReplaceExt == ".*") { + fsNew += szTexExt; } else { - strNew += szReplaceExt; + fsNew += szReplaceExt; } } } else { - if (lstrcmpi(szFindFName, szTexFName) != 0) { + if (!n3std::iequals(szFindStem, szTexStem)) { break; // 이름이 같지 않으므로 그냥 리턴 } - if (lstrcmpi(szFindExt, ".*") == 0) { // abc.* -> - if (lstrcmpi(szReplaceFName, "*") == 0) { - strNew += szFindFName; + if (szFindExt == ".*") { // abc.* -> + if (szReplaceStem == "*") { + fsNew /= szFindStem; } else { - strNew += szReplaceFName; + fsNew /= szReplaceStem; } - if (lstrcmpi(szReplaceExt, ".*") == 0) { - strNew += szTexExt; + if (szReplaceExt == ".*") { + fsNew += szTexExt; } else { - strNew += szReplaceExt; + fsNew += szReplaceExt; } } else { // 찾는 파일명과 확장자가 지정되어 있을경우 // abc.tga -> - if (lstrcmpi(szFindExt, szTexExt) != 0) { + if (!n3std::iequals(szFindExt, szTexExt)) { break; // 확장자가 같지 않으므로 그냥 리턴 } - if (lstrcmpi(szReplaceFName, "*") == 0) { - strNew += szFindFName; + if (szReplaceStem == "*") { + fsNew /= szFindStem; } else { - strNew += szReplaceFName; + fsNew /= szReplaceStem; } - if (lstrcmpi(szReplaceExt, ".*") == 0) { - strNew += szTexExt; + if (szReplaceExt == ".*") { + fsNew += szTexExt; } else { - strNew += szReplaceExt; + fsNew += szReplaceExt; } } } // 텍스쳐 다시 지정하기 - SetTex(strNew); + SetTex(fsNew.string()); break; } return CN3UIBase::ReplaceAllTextures(strFind, strReplace); diff --git a/src/engine/N3Base/N3UIImage.h b/src/engine/N3Base/N3UIImage.h index eacd8d15..f1e6f832 100644 --- a/src/engine/N3Base/N3UIImage.h +++ b/src/engine/N3Base/N3UIImage.h @@ -23,7 +23,7 @@ class CN3UIImage : public CN3UIBase { protected: LPDIRECT3DVERTEXBUFFER9 m_pVB; // vertex buffer CN3Texture * m_pTexRef; // texture 참조 포인터 (s_TexMng에서 관리하므로 참조포인터이다.) - std::string m_szTexFN; // 텍스처 이름.. 따로 갖고 있는 이유는 툴에서 텍스처 부르기가 실패할 경우를 대비해서이다. + fs::path m_fsTexFile; // 텍스처 이름.. 따로 갖고 있는 이유는 툴에서 텍스처 부르기가 실패할 경우를 대비해서이다. __FLOAT_RECT m_frcUVRect; // uv 좌표를 저장 D3DCOLOR m_Color; // 칼라(배경 이미지가 없을경우 사용된다.) @@ -37,7 +37,7 @@ class CN3UIImage : public CN3UIBase { D3DCOLOR GetColor() { return m_Color; } CN3Texture * GetTex() const { return m_pTexRef; } // Texture 포인터 얻기 - void SetTex(const std::string & szFN); // Texture 지정 + void SetTex(const fs::path & fsFile); // Texture 지정 void SetUVRect(float left, float top, float right, float bottom); // image의 uv좌표 지정 void SetColor(D3DCOLOR color); // 칼라 지정 @@ -59,9 +59,9 @@ class CN3UIImage : public CN3UIBase { #ifdef _N3TOOL public: virtual bool Save(HANDLE hFile); - virtual void ChangeImagePath(const std::string & szPathOld, const std::string & szPathNew); - void GatherImageFileName(std::set & setImgFile); - std::string GetTexFN() { return m_szTexFN; } + virtual void ChangeImagePath(const fs::path & fsOldFile, const fs::path & fsNewFile); + void GatherImageFileName(std::set & setImgFile); + fs::path GetTexFile() { return m_fsTexFile; } void ReorderChildImage(); void SetAnimImage(int iAnimCount); diff --git a/src/engine/N3Base/N3UIList.cpp b/src/engine/N3Base/N3UIList.cpp index bc3f3005..e95fb261 100644 --- a/src/engine/N3Base/N3UIList.cpp +++ b/src/engine/N3Base/N3UIList.cpp @@ -268,12 +268,12 @@ bool CN3UIList::Load(HANDLE hFile) { ReadFile(hFile, &iStrLen, sizeof(iStrLen), &dwNum, NULL); // font 이름 길이 __ASSERT(iStrLen > 0, "No font name"); if (iStrLen > 0) { - m_szFontName.assign(iStrLen, ' '); - ReadFile(hFile, &(m_szFontName[0]), iStrLen, &dwNum, NULL); // string - ReadFile(hFile, &m_dwFontHeight, 4, &dwNum, NULL); // font height - ReadFile(hFile, &m_crFont, 4, &dwNum, NULL); // font color - ReadFile(hFile, &m_bFontBold, 4, &dwNum, NULL); // font flag (bold, italic) - ReadFile(hFile, &m_bFontItalic, 4, &dwNum, NULL); // font flag (bold, italic) + m_szFontName.assign(iStrLen, '\0'); + ReadFile(hFile, m_szFontName.data(), iStrLen, &dwNum, NULL); // string + ReadFile(hFile, &m_dwFontHeight, 4, &dwNum, NULL); // font height + ReadFile(hFile, &m_crFont, 4, &dwNum, NULL); // font color + ReadFile(hFile, &m_bFontBold, 4, &dwNum, NULL); // font flag (bold, italic) + ReadFile(hFile, &m_bFontItalic, 4, &dwNum, NULL); // font flag (bold, italic) } // Child 중에 Scroll Bar 가 있는지 찾아본다. diff --git a/src/engine/N3Base/N3UIStatic.cpp b/src/engine/N3Base/N3UIStatic.cpp index 70862c9b..2251478f 100644 --- a/src/engine/N3Base/N3UIStatic.cpp +++ b/src/engine/N3Base/N3UIStatic.cpp @@ -70,11 +70,10 @@ bool CN3UIStatic::Load(HANDLE hFile) { DWORD dwNum; ReadFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwNum, NULL); // 사운드 파일 문자열 길이 if (iSndFNLen > 0) { - std::vector buffer(iSndFNLen, 0); - ReadFile(hFile, &buffer[0], iSndFNLen, &dwNum, NULL); - + std::string szFile(iSndFNLen, '\0'); + ReadFile(hFile, szFile.data(), iSndFNLen, &dwNum, NULL); __ASSERT(NULL == m_pSnd_Click, "memory leak"); - m_pSnd_Click = s_SndMgr.CreateObj(std::string(buffer.begin(), buffer.end()), SNDTYPE_2D); + m_pSnd_Click = s_SndMgr.CreateObj(szFile, SNDTYPE_2D); } return true; @@ -121,7 +120,7 @@ DWORD CN3UIStatic::MouseProc(DWORD dwFlags, const POINT & ptCur, const POINT & p void CN3UIStatic::operator=(const CN3UIStatic & other) { CN3UIBase::operator=(other); - SetSndClick(other.GetSndFName_Click()); + SetSndClick(other.GetSndFileClick()); // m_pImageBkGnd, m_pBuffOutRef 설정하기 for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { @@ -139,14 +138,16 @@ bool CN3UIStatic::Save(HANDLE hFile) { return false; } - DWORD dwNum; - int iSndFNLen = 0; + DWORD dwNum; + std::string szFile; + int iLen = 0; if (m_pSnd_Click) { - iSndFNLen = m_pSnd_Click->m_szFileName.size(); + szFile = fs::path(m_pSnd_Click->m_fsFile).normalize('/', '\\').string(); + iLen = szFile.length(); } - WriteFile(hFile, &iSndFNLen, sizeof(iSndFNLen), &dwNum, NULL); // 사운드 파일 문자열 길이 - if (iSndFNLen > 0) { - WriteFile(hFile, m_pSnd_Click->m_szFileName.c_str(), iSndFNLen, &dwNum, NULL); + WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // 사운드 파일 문자열 길이 + if (iLen > 0) { + WriteFile(hFile, szFile.c_str(), iLen, &dwNum, NULL); } return true; } @@ -168,24 +169,18 @@ void CN3UIStatic::DeleteImage() { } } -void CN3UIStatic::SetSndClick(const std::string & strFileName) { +void CN3UIStatic::SetSndClick(const fs::path & fsFile) { CN3Base::s_SndMgr.ReleaseObj(&m_pSnd_Click); - if (0 == strFileName.size()) { + fs::path fsFileRel = CN3BaseFileAccess::ToRelative(fsFile); + if (fsFileRel.empty()) { return; } - CN3BaseFileAccess tmpBase; - tmpBase.FileNameSet(strFileName); // Base경로에 대해서 상대적 경로를 넘겨준다. - - SetCurrentDirectory(CN3Base::PathGet().c_str()); - m_pSnd_Click = s_SndMgr.CreateObj(tmpBase.FileName(), SNDTYPE_2D); + fs::current_path(CN3Base::PathGet()); + m_pSnd_Click = s_SndMgr.CreateObj(fsFileRel, SNDTYPE_2D); } -std::string CN3UIStatic::GetSndFName_Click() const { - if (m_pSnd_Click) { - return m_pSnd_Click->m_szFileName; - } else { - return std::string(""); - } +fs::path CN3UIStatic::GetSndFileClick() const { + return m_pSnd_Click ? m_pSnd_Click->m_fsFile : fs::path(); } #endif diff --git a/src/engine/N3Base/N3UIStatic.h b/src/engine/N3Base/N3UIStatic.h index 5692ffae..bbdf1559 100644 --- a/src/engine/N3Base/N3UIStatic.h +++ b/src/engine/N3Base/N3UIStatic.h @@ -36,7 +36,7 @@ class CN3UIStatic : public CN3UIBase { CN3UIImage * GetImageBkGnd() const { return m_pImageBkGnd; } CN3UIString * GetUIString() const { return m_pBuffOutRef; } void DeleteImage(); // 이미지를 사용하지 않는 static일 경우 호출하면 지워진다. - void SetSndClick(const std::string & strFileName); - std::string GetSndFName_Click() const; + void SetSndClick(const fs::path & fsFile); + fs::path GetSndFileClick() const; #endif }; diff --git a/src/engine/N3Base/N3UIString.cpp b/src/engine/N3Base/N3UIString.cpp index fa931350..d440b04d 100644 --- a/src/engine/N3Base/N3UIString.cpp +++ b/src/engine/N3Base/N3UIString.cpp @@ -374,7 +374,7 @@ bool CN3UIString::Load(HANDLE hFile) { ReadFile(hFile, &iStrLen, sizeof(iStrLen), &dwNum, NULL); // font 이름 길이 if (iStrLen > 0) { std::string szFontName(iStrLen, '?'); - ReadFile(hFile, &(szFontName[0]), iStrLen, &dwNum, NULL); // string + ReadFile(hFile, szFontName.data(), iStrLen, &dwNum, NULL); // string DWORD dwFontFlags = 0, dwFontHeight = 0; ReadFile(hFile, &dwFontHeight, sizeof(dwFontHeight), &dwNum, NULL); // font height @@ -397,7 +397,7 @@ bool CN3UIString::Load(HANDLE hFile) { ReadFile(hFile, &iStrLen, sizeof(iStrLen), &dwNum, NULL); // string 길이 if (iStrLen > 0) { std::string szString(iStrLen, '?'); - ReadFile(hFile, &(szString[0]), iStrLen, &dwNum, NULL); // string + ReadFile(hFile, szString.data(), iStrLen, &dwNum, NULL); // string SetString(szString); } diff --git a/src/engine/N3Base/N3VMesh.cpp b/src/engine/N3Base/N3VMesh.cpp index 9773c9e8..8046e018 100644 --- a/src/engine/N3Base/N3VMesh.cpp +++ b/src/engine/N3Base/N3VMesh.cpp @@ -123,7 +123,7 @@ void CN3VMesh::CreateIndex(int nIC) { #ifdef _N3GAME if (nIC > 32768) { - CLogWriter::Write("N3VMesh creation warning (%s) - Too many Indices.", m_szFileName.c_str()); + CLogWriter::Write("N3VMesh creation warning (%s) - Too many Indices.", FilePath().string().c_str()); } #endif diff --git a/src/engine/N3Base/StreamSoundObj.cpp b/src/engine/N3Base/StreamSoundObj.cpp index f3f43052..a4289794 100644 --- a/src/engine/N3Base/StreamSoundObj.cpp +++ b/src/engine/N3Base/StreamSoundObj.cpp @@ -31,7 +31,7 @@ CStreamSoundObj::~CStreamSoundObj() { BOOL CStreamSoundObj::Create(CN3SndEng * pEng) { Release(); - if (!LoadWave(CN3SndObj::m_szFileName.c_str())) { + if (!LoadWave(CN3SndObj::m_fsFile)) { return FALSE; } @@ -69,8 +69,8 @@ BOOL CStreamSoundObj::Create(CN3SndEng * pEng) { return TRUE; } -BOOL CStreamSoundObj::LoadWave(LPCSTR pFileName) { - hMMIO = mmioOpen((LPSTR)pFileName, NULL, MMIO_READ | MMIO_ALLOCBUF); +BOOL CStreamSoundObj::LoadWave(const fs::path & fsFile) { + hMMIO = mmioOpenW(const_cast(fsFile.c_str()), NULL, MMIO_READ | MMIO_ALLOCBUF); if (hMMIO == NULL) { return FALSE; } diff --git a/src/engine/N3Base/StreamSoundObj.h b/src/engine/N3Base/StreamSoundObj.h index 20b4453b..3c7e50f3 100644 --- a/src/engine/N3Base/StreamSoundObj.h +++ b/src/engine/N3Base/StreamSoundObj.h @@ -53,7 +53,7 @@ class CStreamSoundObj : public CN3SndObj { //void Stop(); - BOOL LoadWave(LPCSTR pFileName); + BOOL LoadWave(const fs::path & fsFile); BOOL WriteBuffer(); BOOL InitWriteBuffer(); void Reset(); diff --git a/src/engine/N3Base/WaveFile.cpp b/src/engine/N3Base/WaveFile.cpp index 556661a3..e3984b3c 100644 --- a/src/engine/N3Base/WaveFile.cpp +++ b/src/engine/N3Base/WaveFile.cpp @@ -49,14 +49,14 @@ CWaveFile::~CWaveFile() { // Name: CWaveFile::Open() // Desc: Opens a wave file for reading //----------------------------------------------------------------------------- -HRESULT CWaveFile::Open(LPCSTR strFileName, WAVEFORMATEX * pwfx, DWORD dwFlags) { +HRESULT CWaveFile::Open(const fs::path & fsFile, WAVEFORMATEX * pwfx, DWORD dwFlags) { HRESULT hr; m_dwFlags = dwFlags; m_bIsReadingFromMemory = FALSE; if (m_dwFlags == WAVEFILE_READ) { - if (strFileName == NULL) { + if (fsFile.empty()) { return E_INVALIDARG; } if (m_pwfx) { @@ -64,7 +64,7 @@ HRESULT CWaveFile::Open(LPCSTR strFileName, WAVEFORMATEX * pwfx, DWORD dwFlags) m_pwfx = NULL; } - m_hmmio = mmioOpen((LPSTR)strFileName, NULL, MMIO_ALLOCBUF | MMIO_READ); + m_hmmio = mmioOpenW(const_cast(fsFile.c_str()), NULL, MMIO_ALLOCBUF | MMIO_READ); if (NULL == m_hmmio) { HRSRC hResInfo; @@ -73,8 +73,8 @@ HRESULT CWaveFile::Open(LPCSTR strFileName, WAVEFORMATEX * pwfx, DWORD dwFlags) VOID * pvRes; // Loading it as a file failed, so try it as a resource - if (NULL == (hResInfo = FindResource(NULL, strFileName, TEXT("WAVE")))) { - if (NULL == (hResInfo = FindResource(NULL, strFileName, TEXT("WAV")))) { + if (NULL == (hResInfo = FindResourceW(NULL, fsFile.c_str(), TEXT(L"WAVE")))) { + if (NULL == (hResInfo = FindResourceW(NULL, fsFile.c_str(), TEXT(L"WAV")))) { return E_FAIL; } } @@ -116,7 +116,8 @@ HRESULT CWaveFile::Open(LPCSTR strFileName, WAVEFORMATEX * pwfx, DWORD dwFlags) // After the reset, the size of the wav file is m_ck.cksize so store it now m_dwSize = m_ck.cksize; } else { - m_hmmio = mmioOpen((LPSTR)strFileName, NULL, MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_CREATE); + m_hmmio = mmioOpenW(const_cast(fsFile.c_str()), NULL, + MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_CREATE); if (NULL == m_hmmio) { return E_FAIL; } diff --git a/src/engine/N3Base/WaveFile.h b/src/engine/N3Base/WaveFile.h index 02530f0c..4adf82a6 100644 --- a/src/engine/N3Base/WaveFile.h +++ b/src/engine/N3Base/WaveFile.h @@ -42,7 +42,7 @@ class CWaveFile { CWaveFile(); ~CWaveFile(); - HRESULT Open(LPCSTR strFileName, WAVEFORMATEX * pwfx, DWORD dwFlags); + HRESULT Open(const fs::path & fsFile, WAVEFORMATEX * pwfx, DWORD dwFlags); HRESULT OpenFromMemory(BYTE * pbData, ULONG ulDataSize, WAVEFORMATEX * pwfx, DWORD dwFlags); HRESULT Close(); diff --git a/src/game/APISocket.cpp b/src/game/APISocket.cpp index 0813acfe..780e042e 100644 --- a/src/game/APISocket.cpp +++ b/src/game/APISocket.cpp @@ -126,54 +126,58 @@ void CAPISocket::Release() { // 통계를 써준다.. #ifdef _DEBUG - /* DWORD dwRWC = 0; - char szFN1[256] = "", szFN2[256] = ""; + /* SYSTEMTIME ST; ::GetLocalTime(&ST); - sprintf(szFN1, "Socket_Statistics_Send_%d_%d_%d_%d.txt", ST.wMonth, ST.wDay, ST.wHour, ST.wMinute); - sprintf(szFN2, "Socket_Statistics_Recv_%d_%d_%d_%d.txt", ST.wMonth, ST.wDay, ST.wHour, ST.wMinute); - HANDLE hFile1 = ::CreateFile(szFN1, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - HANDLE hFile2 = ::CreateFile(szFN2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - - char szBuff[64] = ""; - char szCmd[32] = ""; + fs::path fsFileSend = + std::format("Socket_Statistics_Send_{:d}_{:d}_{:d}_{:d}.txt", ST.wMonth, ST.wDay, ST.wHour, ST.wMinute); + fs::path fsFileRecv = + std::format("Socket_Statistics_Recv_{:d}_{:d}_{:d}_{:d}.txt", ST.wMonth, ST.wDay, ST.wHour, ST.wMinute); + HANDLE hFileSend = + ::CreateFileW(fsFileSend.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFileRecv = + ::CreateFileW(fsFileRecv.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + + DWORD dwRWC = 0; + char szBuff[64] = ""; + char szCmd[32] = ""; strcpy(szBuff, "Packet\t양\t횟수\r\n"); - WriteFile(hFile1, szBuff, lstrlen(szBuff), &dwRWC, NULL); - WriteFile(hFile2, szBuff, lstrlen(szBuff), &dwRWC, NULL); - - for(int i = 0; i < UCHAR_MAX + 1; i++) - { - if(i == N3_NPC_MOVE) lstrcpy(szCmd, "NPC Move"); - else if(i == N3_ATTACK) lstrcpy(szCmd, "Attack"); - else if(i == N3_MOVE) lstrcpy(szCmd, "User Move"); - else if(i == N3_MAGIC) lstrcpy(szCmd, "Magic"); - else if(i == N3_CHAT) lstrcpy(szCmd, "Chatting"); - else - { + WriteFile(hFileSend, szBuff, lstrlen(szBuff), &dwRWC, NULL); + WriteFile(hFileRecv, szBuff, lstrlen(szBuff), &dwRWC, NULL); + + for (int i = 0; i < UCHAR_MAX + 1; i++) { + if (i == N3_NPC_MOVE) { + lstrcpy(szCmd, "NPC Move"); + } else if (i == N3_ATTACK) { + lstrcpy(szCmd, "Attack"); + } else if (i == N3_MOVE) { + lstrcpy(szCmd, "User Move"); + } else if (i == N3_MAGIC) { + lstrcpy(szCmd, "Magic"); + } else if (i == N3_CHAT) { + lstrcpy(szCmd, "Chatting"); + } else { sprintf(szCmd, "ETC : %d", i); } - if(m_Statistics_Send_Sum[i].iSize > 0 || m_Statistics_Send_Sum[i].dwTime > 0) - { + if (m_Statistics_Send_Sum[i].iSize > 0 || m_Statistics_Send_Sum[i].dwTime > 0) { sprintf(szBuff, "%s\t%d\t%d\t\r\n", szCmd, m_Statistics_Send_Sum[i].iSize, m_Statistics_Send_Sum[i].dwTime); - WriteFile(hFile1, szBuff, lstrlen(szBuff), &dwRWC, NULL); + WriteFile(hFileSend, szBuff, lstrlen(szBuff), &dwRWC, NULL); } - if(m_Statistics_Recv_Sum[i].iSize > 0 || m_Statistics_Recv_Sum[i].dwTime > 0) - { + if (m_Statistics_Recv_Sum[i].iSize > 0 || m_Statistics_Recv_Sum[i].dwTime > 0) { sprintf(szBuff, "%s\t%d\t%d\t\r\n", szCmd, m_Statistics_Recv_Sum[i].iSize, m_Statistics_Recv_Sum[i].dwTime); - WriteFile(hFile2, szBuff, lstrlen(szBuff), &dwRWC, NULL); + WriteFile(hFileRecv, szBuff, lstrlen(szBuff), &dwRWC, NULL); } } -*/ + */ memset(m_Statistics_Send_Sum, 0, sizeof(m_Statistics_Send_Sum)); memset(m_Statistics_Recv_Sum, 0, sizeof(m_Statistics_Recv_Sum)); -// CloseHandle(hFile1); -// CloseHandle(hFile2); + //CloseHandle(hFileSend); + //CloseHandle(hFileRecv); #endif } diff --git a/src/game/Bird.cpp b/src/game/Bird.cpp index 3ff2879a..824c73f4 100644 --- a/src/game/Bird.cpp +++ b/src/game/Bird.cpp @@ -109,19 +109,17 @@ void CBird::Render() { m_pShape->Render(); } -int CBird::LoadBird(const std::string & szFN) { +int CBird::LoadBird(const fs::path & fsFile) { Release(); - FILE * stream = fopen(szFN.c_str(), "r"); //text파일로 만든다 + FILE * stream = _wfopen(fsFile.c_str(), L"r"); //text파일로 만든다 if (NULL == stream) { #if _DEBUG - char szErr[512]; - wsprintf(szErr, "failed to open file - %s", szFN); - __ASSERT(stream, szErr); + __ASSERT(stream, std::format("failed to open file - {:s}", fsFile.string()).c_str()); #endif return false; } - char szRrcName[_MAX_PATH]; + char szRrcName[260]{}; float fSpeed = 0.0f; int result = fscanf(stream, "ResourceName = %s\n", szRrcName); __ASSERT(result != EOF, "잘못된 Machine 세팅 파일"); diff --git a/src/game/Bird.h b/src/game/Bird.h index bf908291..756cd14f 100644 --- a/src/game/Bird.h +++ b/src/game/Bird.h @@ -41,7 +41,7 @@ class CBird : public CN3Base { void Tick(); void Render(); - int LoadBird(const std::string & szFN); + int LoadBird(const fs::path & fsFile); protected: }; diff --git a/src/game/BirdMng.cpp b/src/game/BirdMng.cpp index 4f95080e..89bc1df9 100644 --- a/src/game/BirdMng.cpp +++ b/src/game/BirdMng.cpp @@ -27,19 +27,17 @@ void CBirdMng::Release() { m_iBirdCount = 0; } -void CBirdMng::LoadFromFile(const std::string & szFN) { +void CBirdMng::LoadFromFile(const fs::path & fsFile) { Release(); - if (szFN.empty()) { + if (fsFile.empty()) { return; } - FILE * stream = fopen(szFN.c_str(), "r"); //text파일로 만든다 + FILE * stream = _wfopen(fsFile.c_str(), L"r"); //text파일로 만든다 if (NULL == stream) { #if _DEBUG - char szErr[512]; - wsprintf(szErr, "failed to open file - %s", szFN.c_str()); - __ASSERT(stream, szErr); + __ASSERT(stream, std::format("failed to open file - {:s}", fsFile.string()).c_str()); #endif return; } @@ -70,4 +68,4 @@ void CBirdMng::Render() { for (int i = 0; i < m_iBirdCount; i++) { m_pBird[i].Render(); } -} \ No newline at end of file +} diff --git a/src/game/BirdMng.h b/src/game/BirdMng.h index 20990625..8fd8fd1f 100644 --- a/src/game/BirdMng.h +++ b/src/game/BirdMng.h @@ -6,13 +6,6 @@ #include "N3Base/N3Base.h" -typedef struct __TABLE_BIRD { - DWORD dwID; // zone ID - char * pszTerrainFN; // Terrain FileName - Terrain, Tile Map, ColorMap.... - char * pszColorMapFN; - char * pszObjectPostDataFN; // Object 위치 정보 - 이안에 충돌 체크 데이터도 들어 있다. -} TABLE_BIRD; - class CBird; class CBirdMng : public CN3Base { @@ -30,7 +23,7 @@ class CBirdMng : public CN3Base { virtual void Release(); void Tick(); void Render(); - void LoadFromFile(const std::string & szFN); + void LoadFromFile(const fs::path & fsFile); protected: }; diff --git a/src/game/DungeonManager.cpp b/src/game/DungeonManager.cpp index da6f5cf0..089c7fad 100644 --- a/src/game/DungeonManager.cpp +++ b/src/game/DungeonManager.cpp @@ -24,7 +24,7 @@ void CDungeonManager::InitWorld(int iZoneID, const __Vector3 & vPosPlayer) { return; } - m_pvsmgr.LoadFromFile(pZone->szTerrainFN); + m_pvsmgr.LoadFromFile(pZone->szGtdFile); } void CDungeonManager::Tick() { diff --git a/src/game/EventManager.cpp b/src/game/EventManager.cpp index 8a881c11..5dd33309 100644 --- a/src/game/EventManager.cpp +++ b/src/game/EventManager.cpp @@ -37,10 +37,10 @@ CEventManager::~CEventManager() { Release(); } -bool CEventManager::LoadFromFile(const char * szFileName) { +bool CEventManager::LoadFromFile(const fs::path & fsFile) { Release(); - HANDLE hGevFile = CreateFile(szFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hGevFile = CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hGevFile) { return false; } diff --git a/src/game/EventManager.h b/src/game/EventManager.h index cb467e21..c6ac2e28 100644 --- a/src/game/EventManager.h +++ b/src/game/EventManager.h @@ -28,7 +28,7 @@ class CEventManager { bool PtInRect(int x, int z, RECT rc); short SetPos(float fX, float fZ); void Release(); - bool LoadFromFile(const char * szFileName); + bool LoadFromFile(const fs::path & fsFile); CEventManager(); virtual ~CEventManager(); }; diff --git a/src/game/GameBase.cpp b/src/game/GameBase.cpp index a209b1fd..4d5fe6b0 100644 --- a/src/game/GameBase.cpp +++ b/src/game/GameBase.cpp @@ -74,65 +74,28 @@ void _FormatCoins(int64_t nCoins, std::string & szCoins) { } void CGameBase::StaticMemberInit() { - ////////////////////////////////////////////////////////////////////////////////////////// - // Resource Table 로딩 및 초기화... - s_pTbl_Zones = new CN3TableBase<__TABLE_ZONE>; // Zone 정보에 관한 Table - s_pTbl_UI = new CN3TableBase<__TABLE_UI_RESRC>; // UI Resource File Table loading - s_pTbl_UPC_Looks = - new CN3TableBase<__TABLE_PLAYER_LOOKS>; // 플레이어들의 기본 모습이 되는 NPC Resource Table loading - s_pTbl_Items_Basic = new CN3TableBase<__TABLE_ITEM_BASIC>; // Item Resource Table loading + const std::string szLangTail = (::GetUserDefaultLangID() == 0x0404) ? "_TW" : ""; + + auto fnLoadTbl = [&](const std::string & szFileStem, auto & pTbl) { + pTbl = new std::decay_t(); + pTbl->LoadFromFile(fs::path("Data") / (szFileStem + ".tbl")); + }; + + fnLoadTbl("Zones", s_pTbl_Zones); + fnLoadTbl("UIs" + szLangTail, s_pTbl_UI); + fnLoadTbl("UPC_DefaultLooks", s_pTbl_UPC_Looks); + fnLoadTbl("Item_Org" + szLangTail, s_pTbl_Items_Basic); + fnLoadTbl("Quest_Menu" + szLangTail, s_pTbl_QuestMenu); + fnLoadTbl("Quest_Talk" + szLangTail, s_pTbl_QuestTalk); + fnLoadTbl("Texts" + szLangTail, s_pTbl_Texts); + fnLoadTbl("help" + szLangTail, s_pTbl_Help); for (int i = 0; i < MAX_ITEM_EXTENSION; i++) { - s_pTbl_Items_Exts[i] = new CN3TableBase<__TABLE_ITEM_EXT>; + fnLoadTbl(std::format("Item_Ext_{:d}", i) + szLangTail, s_pTbl_Items_Exts[i]); } - s_pTbl_NPC_Looks = new CN3TableBase<__TABLE_PLAYER_LOOKS>; // NPC Resource Table loading - s_pTbl_Skill = new CN3TableBase<__TABLE_UPC_SKILL>; // Skill 정보에 관한 Table - s_pTbl_Exchange_Quest = new CN3TableBase<__TABLE_EXCHANGE_QUEST>; // 교환 퀘스트에 관한 테이블.. - s_pTbl_FXSource = new CN3TableBase<__TABLE_FX>; // FX Source에 관한 테이블.. - s_pTbl_QuestMenu = new CN3TableBase<__TABLE_QUEST_MENU>; - s_pTbl_QuestTalk = new CN3TableBase<__TABLE_QUEST_TALK>; - s_pTbl_Texts = new CN3TableBase<__TABLE_TEXTS>; - s_pTbl_Help = new CN3TableBase<__TABLE_HELP>; - - std::string szLangTail = ".tbl"; - int iLangID = ::GetUserDefaultLangID(); - if (0x0404 == iLangID) { - szLangTail = "_TW.tbl"; // Taiwan Language - } - - std::string szFN; - szFN = "Data\\Zones.tbl"; - s_pTbl_Zones->LoadFromFile(szFN.c_str()); // Zone 정보에 관한 Table - szFN = "Data\\UIs" + szLangTail; - s_pTbl_UI->LoadFromFile(szFN.c_str()); // UI Resource File Table loading - szFN = "Data\\UPC_DefaultLooks.tbl"; - s_pTbl_UPC_Looks->LoadFromFile(szFN.c_str()); // 플레이어들의 기본 모습이 되는 NPC Resource Table loading - szFN = "Data\\Item_Org" + szLangTail; - s_pTbl_Items_Basic->LoadFromFile(szFN.c_str()); // Item Resource Table loading - - szFN = "Data\\Quest_Menu" + szLangTail; - s_pTbl_QuestMenu->LoadFromFile(szFN.c_str()); // 퀘스트 관련 선택메뉴 - szFN = "Data\\Quest_Talk" + szLangTail; - s_pTbl_QuestTalk->LoadFromFile(szFN.c_str()); // 퀘스트 관련 지문 - szFN = "Data\\Texts" + szLangTail; - s_pTbl_Texts->LoadFromFile(szFN.c_str()); - szFN = "Data\\help" + szLangTail; - s_pTbl_Help->LoadFromFile(szFN.c_str()); - - for (int i = 0; i < MAX_ITEM_EXTENSION; i++) { - char szFNTmp[256] = ""; - sprintf(szFNTmp, "Data\\Item_Ext_%d", i); - szFN = szFNTmp + szLangTail; - s_pTbl_Items_Exts[i]->LoadFromFile(szFN.c_str()); - } - - szFN = "Data\\NPC_Looks.tbl"; - s_pTbl_NPC_Looks->LoadFromFile(szFN.c_str()); // NPC Resource Table loading - szFN = "Data\\skill_magic_main" + szLangTail; - s_pTbl_Skill->LoadFromFile(szFN.c_str()); // Skill 정보에 관한 Table - szFN = "Data\\Exchange_Quest.tbl"; - s_pTbl_Exchange_Quest->LoadFromFile(szFN.c_str()); // 교환 퀘스트에 관한 테이블.. - szFN = "Data\\fx.tbl"; - s_pTbl_FXSource->LoadFromFile(szFN.c_str()); + fnLoadTbl("NPC_Looks", s_pTbl_NPC_Looks); + fnLoadTbl("Skill_Magic_Main" + szLangTail, s_pTbl_Skill); + fnLoadTbl("Exchange_Quest", s_pTbl_Exchange_Quest); + fnLoadTbl("fx", s_pTbl_FXSource); s_pWorldMgr = new CN3WorldManager(); s_pOPMgr = new CPlayerOtherMgr(); @@ -575,18 +538,18 @@ D3DCOLOR CGameBase::GetIDColorByLevelDifference(int iLevelDiff) { // Item Data 를 가지고 파일이름을 만든다.. e_ItemType CGameBase::MakeResrcFileNameForUPC(__TABLE_ITEM_BASIC * pItem, // 아이템 데이터... - std::string * pszResrcFN, // Resource FileName - std::string * pszIconFN, // Icon FileName + fs::path * pfsResrcFile, // Resource file path + fs::path * pfsIconFile, // Icon file path e_PartPosition & ePartPosition, // Part 일경우 Index e_PlugPosition & ePlugPosition) // Plug 일경우 Index { ePartPosition = PART_POS_UNKNOWN; ePlugPosition = PLUG_POS_UNKNOWN; - if (pszResrcFN) { - *pszResrcFN = ""; + if (pfsResrcFile) { + *pfsResrcFile = fs::path(); } - if (pszIconFN) { - *pszIconFN = ""; + if (pfsIconFile) { + *pfsIconFile = fs::path(); } if (NULL == pItem) { @@ -640,20 +603,19 @@ e_ItemType CGameBase::MakeResrcFileNameForUPC(__TABLE_ITEM_BASIC * pItem, __ASSERT(0, "Invalid Item Position"); } - if (pszResrcFN) { + if (pfsResrcFile) { + // It could be a plug or part that only has an icon... if (pItem->dwIDResrc) { - *pszResrcFN = std::format("Item\\{:d}_{:04d}_{:02d}_{:d}{}", (pItem->dwIDResrc / 10000000), - (pItem->dwIDResrc / 1000) % 10000, (pItem->dwIDResrc / 10) % 100, - pItem->dwIDResrc % 10, szExt); - } else { - // 아이콘만 있는 플러그나 파트 일수도 있다... - *pszResrcFN = ""; + *pfsResrcFile = fs::path("Item") / std::format("{:d}_{:04d}_{:02d}_{:d}{:s}", (pItem->dwIDResrc / 10000000), + (pItem->dwIDResrc / 1000) % 10000, + (pItem->dwIDResrc / 10) % 100, pItem->dwIDResrc % 10, szExt); } } - if (pszIconFN) { - //*pszIconFN = std::format("UI\\ItemIcon_{:d}_{:04d}_{:02d}_{:d}.dxt", eType, iIndex, eRace, iPos); - *pszIconFN = std::format("UI\\ItemIcon_{:d}_{:04d}_{:02d}_{:d}.dxt", (pItem->dwIDIcon / 10000000), - (pItem->dwIDIcon / 1000) % 10000, (pItem->dwIDIcon / 10) % 100, pItem->dwIDIcon % 10); + if (pfsIconFile) { + //*pfsIconFile = fs::path("UI") / std::format("ItemIcon_{:d}_{:04d}_{:02d}_{:d}.dxt", eType, iIndex, eRace, iPos); + *pfsIconFile = fs::path("UI") / std::format("ItemIcon_{:d}_{:04d}_{:02d}_{:d}.dxt", + (pItem->dwIDIcon / 10000000), (pItem->dwIDIcon / 1000) % 10000, + (pItem->dwIDIcon / 10) % 100, pItem->dwIDIcon % 10); } return eType; diff --git a/src/game/GameBase.h b/src/game/GameBase.h index 0f2470f7..3955be67 100644 --- a/src/game/GameBase.h +++ b/src/game/GameBase.h @@ -48,8 +48,8 @@ class CGameBase : public CN3Base { static D3DCOLOR GetIDColorByLevelDifference(int iLevelDiff); // 레벨 차이에 따른 ID 색 돌려준다. static e_Class_Represent GetRepresentClass(e_Class eClass); // 세부직업을 넣어주면 대표되는 직업을 돌려준다. static e_ItemType MakeResrcFileNameForUPC(__TABLE_ITEM_BASIC * pItem, // 아이템 데이터... - std::string * szResrcFN, // Resource FileName - std::string * szIconFN, // Icon FileName + fs::path * pfsResrcFile, // Resource file path + fs::path * pfsIconFile, // Icon file path e_PartPosition & ePartPosition, // Part 일경우 Index e_PlugPosition & ePlugPosition); // Plug 일경우 Index diff --git a/src/game/GameDef.h b/src/game/GameDef.h index 92988c61..f39316c3 100644 --- a/src/game/GameDef.h +++ b/src/game/GameDef.h @@ -721,22 +721,21 @@ enum { }; typedef struct __TABLE_ZONE { - DWORD dwID; // zone ID - std::string szTerrainFN; // Terrain FileName - Terrain, Tile Map, ColorMap.... - std::string szColorMapFN; - std::string szLightMapFN; - std::string szObjectPostDataFN; // Object 위치 정보 - 이안에 충돌 체크 데이터도 들어 있다. - std::string szMiniMapFN; - std::string szSkySetting; // 하늘과 분위기 조정한 세팅 정보 파일.. - BOOL bIndicateEnemyPlayer; // 적국 플레이어를 표시하나?? - int iFixedSundDirection; // 해의 방향을 고정시키는지.. - std::string szLightObjFN; // 지형에 배치되어 있는 라이트정보파일.. - - std::string szGevFN; // TODO: implement - uint32_t iAbyssSomething; // TODO: implement - std::string szEnsFN; // TODO: implement - float fFOV; // TODO: implement - std::string szFlagFN; // TODO: implement + DWORD dwID; // Zone ID + std::string szGtdFile; // Game Terrain Data (terrain, tile map, color map) + std::string szTctFile; // Tile Color Texture + std::string szTltFile; // Tile Light Texture + std::string szOpdFile; // Object Post Data (position and collision) + std::string szMiniMapFile; // Minimap texture + std::string szSkyFile; // Sky and atmosphere settings + BOOL bIndicateEnemyPlayer; // Show enemy players in red on the minimap + int iFixedSundDirection; // Fixed sun direction + std::string szGloFile; // Game Light Object + std::string szGevFile; // TODO: implement Game Event (tile event) + uint32_t iAbyssSomething; // TODO: implement + std::string szEnsFile; // TODO: implement Environment Sound (rectangle coordinates) + float fFOV; // TODO: implement + std::string szFlagFile; // TODO: implement Flag (textures and transformation) } TABLE_ZONE; typedef struct __TABLE_UI_RESRC { @@ -1051,11 +1050,11 @@ enum e_ItemSlot { typedef struct __TABLE_PLAYER_LOOKS // NPC, Mob 모습 관한 리소스 레코드... { - DWORD dwID; // NPC 고유 ID - std::string szName; // 캐릭터 이름 - std::string szJointFN; // 관절 파일 이름 - std::string szAniFN; // 에니메이션 파일 이름 - std::string szPartFNs[7]; // 각 Character Part - 상체, 하체, 머리, 팔, 다리, 머리카락, 망토 + DWORD dwID; // NPC 고유 ID + std::string szName; // 캐릭터 이름 + std::string szJointFile; // 관절 파일 이름 + std::string szAniFile; // 에니메이션 파일 이름 + std::string szPartFiles[7]; // 각 Character Part - 상체, 하체, 머리, 팔, 다리, 머리카락, 망토 int iJointRH; // 오른손 끝 관절번호 int iJointLH; // 왼손 끝 관절번호 @@ -1395,7 +1394,7 @@ typedef struct __TABLE_FX // FX 리소스 레코드... { DWORD dwID; // 고유 ID std::string szName; // TODO: implement - std::string szFN; // file name + std::string szFile; // file path DWORD dwSoundID; // 효과에 쓰는 사운드 아디. } TABLE_FX; diff --git a/src/game/GameEng.cpp b/src/game/GameEng.cpp index 633987bf..455910bf 100644 --- a/src/game/GameEng.cpp +++ b/src/game/GameEng.cpp @@ -18,13 +18,6 @@ const float LIGHTNING_DURATION = 2.0f; CGameEng::CGameEng() { m_pActiveCam = NULL; - // 프로그램이 실행된 경로.. - char szBuf[_MAX_PATH]; - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - ::GetModuleFileName(NULL, szBuf, _MAX_PATH); - _splitpath(szBuf, szDrive, szDir, NULL, NULL); - _makepath(szBuf, szDrive, szDir, NULL, NULL); - /////////////////////////////////////////////////////////////// // 기본 카메라 세팅.. CN3Camera * pCamera = new CN3Camera(); diff --git a/src/game/GameProcCharacterCreate.cpp b/src/game/GameProcCharacterCreate.cpp index f2630da3..10861e4b 100644 --- a/src/game/GameProcCharacterCreate.cpp +++ b/src/game/GameProcCharacterCreate.cpp @@ -52,7 +52,7 @@ void CGameProcCharacterCreate::Init() { SetRect(&m_rcChr, 0, 0, 0, 0); - m_Tbl_InitValue.LoadFromFile("Data\\NewChrValue.tbl"); + m_Tbl_InitValue.LoadFromFile(fs::path("Data") / "NewChrValue.tbl"); s_pPlayer->m_InfoBase.eRace = RACE_UNKNOWN; s_pPlayer->m_InfoBase.eClass = CLASS_UNKNOWN; @@ -118,7 +118,7 @@ void CGameProcCharacterCreate::SetChr() { s_pPlayer->InitHair(); continue; } - s_pPlayer->PartSet((e_PartPosition)i, pLooks->szPartFNs[i], NULL, NULL); + s_pPlayer->PartSet((e_PartPosition)i, pLooks->szPartFiles[i], NULL, NULL); } } @@ -292,4 +292,4 @@ bool CGameProcCharacterCreate::ProcessPacket(DataPack * pDataPack, int & iOffset } return false; -} \ No newline at end of file +} diff --git a/src/game/GameProcCharacterSelect.cpp b/src/game/GameProcCharacterSelect.cpp index fafdcbfb..36246c61 100644 --- a/src/game/GameProcCharacterSelect.cpp +++ b/src/game/GameProcCharacterSelect.cpp @@ -174,15 +174,16 @@ void CGameProcCharacterSelect::Init() { m_lgt[2].Diffuse.b = m_lgt[1].Diffuse.b = m_lgt[0].Diffuse.b = 255 / 255.0f; m_lgt[2].Falloff = m_lgt[1].Falloff = m_lgt[0].Falloff = 20.0f; + fs::path fsChrSelectDir("ChrSelect"); __Vector3 vTemp; switch (s_pPlayer->m_InfoBase.eNation) { case NATION_KARUS: - m_pActiveBg->LoadFromFile("ChrSelect\\ka_chairs.n3shape"); + m_pActiveBg->LoadFromFile(fsChrSelectDir / "ka_chairs.n3shape"); // Light.. - m_pLights[0]->LoadFromFile("ChrSelect\\ka_light_0.n3light"); - m_pLights[1]->LoadFromFile("ChrSelect\\ka_light_1.n3light"); - m_pLights[2]->LoadFromFile("ChrSelect\\ka_light_2.n3light"); + m_pLights[0]->LoadFromFile(fsChrSelectDir / "ka_light_0.n3light"); + m_pLights[1]->LoadFromFile(fsChrSelectDir / "ka_light_1.n3light"); + m_pLights[2]->LoadFromFile(fsChrSelectDir / "ka_light_2.n3light"); m_lgt[0].Position = m_vEye; // 카루스 m_lgt[0].Position.y += 2.0f; // 카루스 @@ -205,12 +206,12 @@ void CGameProcCharacterSelect::Init() { break; case NATION_ELMORAD: - m_pActiveBg->LoadFromFile("ChrSelect\\el_chairs.n3shape"); + m_pActiveBg->LoadFromFile(fsChrSelectDir / "el_chairs.n3shape"); // Light.. - m_pLights[0]->LoadFromFile("ChrSelect\\el_light_0.n3light"); - m_pLights[1]->LoadFromFile("ChrSelect\\el_light_1.n3light"); - m_pLights[2]->LoadFromFile("ChrSelect\\el_light_2.n3light"); + m_pLights[0]->LoadFromFile(fsChrSelectDir / "el_light_0.n3light"); + m_pLights[1]->LoadFromFile(fsChrSelectDir / "el_light_1.n3light"); + m_pLights[2]->LoadFromFile(fsChrSelectDir / "el_light_2.n3light"); m_lgt[0].Position = m_vEye; // 카루스 m_lgt[0].Position.y += 2.0f; // 카루스 @@ -373,15 +374,16 @@ void CGameProcCharacterSelect::AddChr(e_ChrPos eCP, __CharacterSelectInfo * pInf m_pChrs[iPosIndex]->PartAlloc(PART_POS_COUNT); m_pChrs[iPosIndex]->PlugAlloc(PLUG_POS_COUNT); - std::string szJointFN, szAniFN, szPlug0FN, szPlug1FN; + fs::path fsJointFile, fsAniFile, fsPlug0File, fsPlug1File; + fs::path fsChrSelectDir("ChrSelect"); switch (pInfo->eRace) { case RACE_EL_BABARIAN: // 남자 바바리안은 직업이 하나.. - szJointFN = "ChrSelect\\upc_el_ba_wa.n3joint"; // 관절 세팅.. - szAniFN = "ChrSelect\\upc_el_ba_wa.n3anim"; // 에니메이션 파일 이름.. :-D; - szPlug0FN = "ChrSelect\\wea_el_great_sword.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_el_ba_wa.n3joint"; // 관절 세팅.. + fsAniFile = fsChrSelectDir / "upc_el_ba_wa.n3anim"; // 에니메이션 파일 이름.. :-D; + fsPlug0File = fsChrSelectDir / "wea_el_great_sword.n3cplug"; + fsPlug1File = fs::path(); break; case RACE_EL_WOMEN: // 엘모 여자는 직업이 현재 세개(전사, 로그, 성직자).. 성직자는 그래픽이 없다.. @@ -389,34 +391,34 @@ void CGameProcCharacterSelect::AddChr(e_ChrPos eCP, __CharacterSelectInfo * pInf case CLASS_EL_WARRIOR: case CLASS_EL_BLADE: case CLASS_EL_PROTECTOR: - szJointFN = "ChrSelect\\upc_el_rf_wa.n3joint"; - szAniFN = "ChrSelect\\upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; - szPlug0FN = "ChrSelect\\wea_el_long_sword_left.n3cplug"; // 왼손에 검을 찬다.. - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_el_rf_wa.n3joint"; + fsAniFile = fsChrSelectDir / "upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; + fsPlug0File = fsChrSelectDir / "wea_el_long_sword_left.n3cplug"; // 왼손에 검을 찬다.. + fsPlug1File = fs::path(); break; case CLASS_EL_ROGUE: case CLASS_EL_RANGER: case CLASS_EL_ASSASIN: - szJointFN = "ChrSelect\\upc_el_rf_rog.n3joint"; // 관절 세팅.. - szAniFN = "ChrSelect\\upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; - szPlug0FN = "ChrSelect\\wea_el_rf_rog_bow.n3cplug"; - szPlug1FN = "ChrSelect\\wea_el_quiver.n3cplug"; + fsJointFile = fsChrSelectDir / "upc_el_rf_rog.n3joint"; // 관절 세팅.. + fsAniFile = fsChrSelectDir / "upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; + fsPlug0File = fsChrSelectDir / "wea_el_rf_rog_bow.n3cplug"; + fsPlug1File = fsChrSelectDir / "wea_el_quiver.n3cplug"; break; case CLASS_EL_WIZARD: case CLASS_EL_MAGE: case CLASS_EL_ENCHANTER: - szJointFN = "ChrSelect\\upc_el_rf_wiz.n3joint"; // 관절 세팅.. - szAniFN = "ChrSelect\\upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; - szPlug0FN = "ChrSelect\\upc_el_rf_wiz.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_el_rf_wiz.n3joint"; // 관절 세팅.. + fsAniFile = fsChrSelectDir / "upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; + fsPlug0File = fsChrSelectDir / "upc_el_rf_wiz.n3cplug"; + fsPlug1File = fs::path(); break; case CLASS_EL_PRIEST: case CLASS_EL_CLERIC: case CLASS_EL_DRUID: - szJointFN = "ChrSelect\\upc_el_rf_pri.n3joint"; // 관절 세팅.. - szAniFN = "ChrSelect\\upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; - szPlug0FN = "ChrSelect\\wea_el_wand.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_el_rf_pri.n3joint"; // 관절 세팅.. + fsAniFile = fsChrSelectDir / "upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; + fsPlug0File = fsChrSelectDir / "wea_el_wand.n3cplug"; + fsPlug1File = fs::path(); break; } break; @@ -426,90 +428,90 @@ void CGameProcCharacterSelect::AddChr(e_ChrPos eCP, __CharacterSelectInfo * pInf case CLASS_EL_WARRIOR: case CLASS_EL_BLADE: case CLASS_EL_PROTECTOR: - szJointFN = "ChrSelect\\upc_el_rm_wa.n3joint"; - szAniFN = "ChrSelect\\upc_el_rm_wa.n3anim"; - szPlug0FN = "ChrSelect\\wea_el_long_sword.n3cplug"; + fsJointFile = fsChrSelectDir / "upc_el_rm_wa.n3joint"; + fsAniFile = fsChrSelectDir / "upc_el_rm_wa.n3anim"; + fsPlug0File = fsChrSelectDir / "wea_el_long_sword.n3cplug"; break; case CLASS_EL_ROGUE: case CLASS_EL_RANGER: case CLASS_EL_ASSASIN: - szJointFN = "ChrSelect\\upc_el_rm_rog.n3joint"; - szAniFN = "ChrSelect\\upc_el_rm_rog.n3anim"; - szPlug0FN = "ChrSelect\\upc_el_rm_rog_bow.n3cplug"; - szPlug1FN = "ChrSelect\\wea_el_quiver.n3cplug"; + fsJointFile = fsChrSelectDir / "upc_el_rm_rog.n3joint"; + fsAniFile = fsChrSelectDir / "upc_el_rm_rog.n3anim"; + fsPlug0File = fsChrSelectDir / "upc_el_rm_rog_bow.n3cplug"; + fsPlug1File = fsChrSelectDir / "wea_el_quiver.n3cplug"; break; case CLASS_EL_WIZARD: case CLASS_EL_MAGE: case CLASS_EL_ENCHANTER: - szJointFN = "ChrSelect\\upc_el_rm_ma.n3joint"; - szAniFN = "ChrSelect\\upc_el_rm_rog.n3anim"; - szPlug0FN = "ChrSelect\\upc_el_rm_wiz.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_el_rm_ma.n3joint"; + fsAniFile = fsChrSelectDir / "upc_el_rm_rog.n3anim"; + fsPlug0File = fsChrSelectDir / "upc_el_rm_wiz.n3cplug"; + fsPlug1File = fs::path(); break; case CLASS_EL_PRIEST: case CLASS_EL_CLERIC: case CLASS_EL_DRUID: - szJointFN = "ChrSelect\\upc_el_rm_pri.n3joint"; - szAniFN = "ChrSelect\\upc_el_rm_rog.n3anim"; - szPlug0FN = "ChrSelect\\wea_el_wand.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_el_rm_pri.n3joint"; + fsAniFile = fsChrSelectDir / "upc_el_rm_rog.n3anim"; + fsPlug0File = fsChrSelectDir / "wea_el_wand.n3cplug"; + fsPlug1File = fs::path(); break; } break; case RACE_KA_ARKTUAREK: // 카루스 직업 하나.. 온리 전사.. - szJointFN = "ChrSelect\\upc_ka_at_wa.n3joint"; - szAniFN = "ChrSelect\\upc_ka_at_wa.n3anim"; - szPlug0FN = "ChrSelect\\wea_ka_great_axe.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_ka_at_wa.n3joint"; + fsAniFile = fsChrSelectDir / "upc_ka_at_wa.n3anim"; + fsPlug0File = fsChrSelectDir / "wea_ka_great_axe.n3cplug"; + fsPlug1File = fs::path(); break; case RACE_KA_TUAREK: switch (pInfo->eClass) { case CLASS_KA_ROGUE: case CLASS_KA_HUNTER: case CLASS_KA_PENETRATOR: - szJointFN = "ChrSelect\\upc_ka_tu_rog.n3joint"; - szAniFN = "ChrSelect\\upc_ka_at_wa.n3anim"; - szPlug0FN = "ChrSelect\\wea_ka_bow.n3cplug"; - szPlug1FN = "ChrSelect\\wea_ka_quiver.n3cplug"; + fsJointFile = fsChrSelectDir / "upc_ka_tu_rog.n3joint"; + fsAniFile = fsChrSelectDir / "upc_ka_at_wa.n3anim"; + fsPlug0File = fsChrSelectDir / "wea_ka_bow.n3cplug"; + fsPlug1File = fsChrSelectDir / "wea_ka_quiver.n3cplug"; break; case CLASS_KA_PRIEST: case CLASS_KA_SHAMAN: case CLASS_KA_DARKPRIEST: - szJointFN = "ChrSelect\\upc_ka_tu_pri.n3joint"; - szAniFN = "ChrSelect\\upc_ka_at_wa.n3anim"; - szPlug0FN = "ChrSelect\\wea_ka_mace.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_ka_tu_pri.n3joint"; + fsAniFile = fsChrSelectDir / "upc_ka_at_wa.n3anim"; + fsPlug0File = fsChrSelectDir / "wea_ka_mace.n3cplug"; + fsPlug1File = fs::path(); break; } break; case RACE_KA_WRINKLETUAREK: - szJointFN = "ChrSelect\\upc_ka_wt_ma.n3joint"; - szAniFN = "ChrSelect\\upc_ka_at_wa.n3anim"; - szPlug0FN = "ChrSelect\\wea_ka_staff.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_ka_wt_ma.n3joint"; + fsAniFile = fsChrSelectDir / "upc_ka_at_wa.n3anim"; + fsPlug0File = fsChrSelectDir / "wea_ka_staff.n3cplug"; + fsPlug1File = fs::path(); break; case RACE_KA_PURITUAREK: - szJointFN = "ChrSelect\\upc_el_rf_pri.n3joint"; // 관절 세팅.. - szAniFN = "ChrSelect\\upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; - szPlug0FN = "ChrSelect\\wea_ka_mace.n3cplug"; - szPlug1FN = ""; + fsJointFile = fsChrSelectDir / "upc_el_rf_pri.n3joint"; // 관절 세팅.. + fsAniFile = fsChrSelectDir / "upc_el_rf_wa.n3anim"; // 에니메이션 파일 이름.. :-D; + fsPlug0File = fsChrSelectDir / "wea_ka_mace.n3cplug"; + fsPlug1File = fs::path(); break; default: return; } - m_pChrs[iPosIndex]->JointSet(szJointFN); // 관절 세팅.. - m_pChrs[iPosIndex]->AniCtrlSet(szAniFN); // 에니메이션 파일 이름.. :-D; - m_pChrs[iPosIndex]->PlugSet(0, szPlug0FN); - m_pChrs[iPosIndex]->PlugSet(1, szPlug1FN); + m_pChrs[iPosIndex]->JointSet(fsJointFile); // 관절 세팅.. + m_pChrs[iPosIndex]->AniCtrlSet(fsAniFile); // 에니메이션 파일 이름.. :-D; + m_pChrs[iPosIndex]->PlugSet(0, fsPlug0File); + m_pChrs[iPosIndex]->PlugSet(1, fsPlug1File); // 상체.. this->AddChrPart(m_pChrs[iPosIndex], pLooks, PART_POS_UPPER, pInfo->dwItemUpper, pInfo->iItemUpperDurability); // 하체 __TABLE_ITEM_BASIC * pItemUpper = this->s_pTbl_Items_Basic->Find(pInfo->dwItemUpper); if (pItemUpper && pItemUpper->byIsRobeType) { - m_pChrs[iPosIndex]->PartSet(PART_POS_LOWER, ""); // 하체일 경우 상체에 로브를 입었으면 .. + m_pChrs[iPosIndex]->PartSet(PART_POS_LOWER, fs::path()); // 하체일 경우 상체에 로브를 입었으면 .. } else { this->AddChrPart(m_pChrs[iPosIndex], pLooks, PART_POS_LOWER, pInfo->dwItemLower, pInfo->iItemLowerDurability); //아님 입히고... @@ -519,15 +521,11 @@ void CGameProcCharacterSelect::AddChr(e_ChrPos eCP, __CharacterSelectInfo * pInf // 다리 this->AddChrPart(m_pChrs[iPosIndex], pLooks, PART_POS_FEET, pInfo->dwItemShoes, pInfo->iItemShoesDurability); - char szBuff[256] = ""; - std::string szResrcFN; - // 얼굴 - - if (!pLooks->szPartFNs[PART_POS_FACE].empty()) { - char szBuff[256] = "", szDir[128] = "", szFName[128] = "", szExt[16] = ""; - ::_splitpath(pLooks->szPartFNs[PART_POS_FACE].c_str(), NULL, szDir, szFName, szExt); - sprintf(szBuff, "%s%s%.2d%s", szDir, szFName, pInfo->iFace, szExt); - m_pChrs[iPosIndex]->PartSet(PART_POS_FACE, szBuff); + if (!pLooks->szPartFiles[PART_POS_FACE].empty()) { + fs::path fsFile = pLooks->szPartFiles[PART_POS_FACE]; + fsFile = fsFile.parent_path() / (fsFile.stem() + std::format("{:02d}", pInfo->iFace) + fsFile.extension()); + m_pChrs[iPosIndex]->PartSet(PART_POS_FACE, fsFile); } // 머리카락 혹은 헬멧 - @@ -536,14 +534,12 @@ void CGameProcCharacterSelect::AddChr(e_ChrPos eCP, __CharacterSelectInfo * pInf { this->AddChrPart(m_pChrs[iPosIndex], pLooks, PART_POS_HAIR_HELMET, pInfo->dwItemHelmet, pInfo->iItemHelmetDurability); - } else if (!pLooks->szPartFNs[PART_POS_HAIR_HELMET].empty()) // 아이템이 없으면 기본 머리.. - { - char szBuff[256] = "", szDir[128] = "", szFName[128] = "", szExt[16] = ""; - ::_splitpath(pLooks->szPartFNs[PART_POS_HAIR_HELMET].c_str(), NULL, szDir, szFName, szExt); - sprintf(szBuff, "%s%s%.2d%s", szDir, szFName, pInfo->iHair, szExt); - m_pChrs[iPosIndex]->PartSet(PART_POS_HAIR_HELMET, szBuff); + } else if (!pLooks->szPartFiles[PART_POS_HAIR_HELMET].empty()) { // 아이템이 없으면 기본 머리.. + fs::path fsFile = pLooks->szPartFiles[PART_POS_HAIR_HELMET]; + fsFile = fsFile.parent_path() / (fsFile.stem() + std::format("{:02d}", pInfo->iHair) + fsFile.extension()); + m_pChrs[iPosIndex]->PartSet(PART_POS_HAIR_HELMET, fsFile); } else { - m_pChrs[iPosIndex]->PartSet(PART_POS_HAIR_HELMET, ""); // 헬멧도 아니고 머리카락도 없으면.. 대머리다! + m_pChrs[iPosIndex]->PartSet(PART_POS_HAIR_HELMET, fs::path()); // 헬멧도 아니고 머리카락도 없으면.. 대머리다! } __Quaternion qt; @@ -615,25 +611,25 @@ void CGameProcCharacterSelect::AddChrPart(CN3Chr * pChr, const __TABLE_PLAYER_LO return; } - std::string szResrcFN; + fs::path fsResrcFile; CN3CPart * pPart = NULL; e_PartPosition ePartPosTmp = PART_POS_UNKNOWN; e_PlugPosition ePlugPosTmp = PLUG_POS_UNKNOWN; - CGameProcedure::MakeResrcFileNameForUPC(pItem, &szResrcFN, NULL, ePartPosTmp, ePlugPosTmp); - if (szResrcFN.empty()) { - pPart = pChr->PartSet(ePartPos, pLooks->szPartFNs[ePartPos]); // 기본 파트 + CGameProcedure::MakeResrcFileNameForUPC(pItem, &fsResrcFile, NULL, ePartPosTmp, ePlugPosTmp); + if (fsResrcFile.empty()) { + pPart = pChr->PartSet(ePartPos, pLooks->szPartFiles[ePartPos]); // 기본 파트 } else { - pPart = pChr->PartSet(ePartPos, szResrcFN); + pPart = pChr->PartSet(ePartPos, fsResrcFile); } if (pPart && pItem && pItem->siMaxDurability > 0) { int iPercentage = iItemDurability * 100 / pItem->siMaxDurability; if (iPercentage <= 30) { - pPart->TexOverlapSet("Misc\\Dust_Hard.dxt"); + pPart->TexOverlapSet(fs::path("Misc") / "dust_hard.dxt"); } else if (iPercentage <= 70) { - pPart->TexOverlapSet("Misc\\Dust_Soft.dxt"); + pPart->TexOverlapSet(fs::path("Misc") / "dust_soft.dxt"); } else { - pPart->TexOverlapSet(""); + pPart->TexOverlapSet(fs::path()); } } } diff --git a/src/game/GameProcLogIn.cpp b/src/game/GameProcLogIn.cpp index 870456a9..d206cd19 100644 --- a/src/game/GameProcLogIn.cpp +++ b/src/game/GameProcLogIn.cpp @@ -73,11 +73,13 @@ void CGameProcLogIn::Release() { void CGameProcLogIn::Init() { CGameProcedure::Init(); + fs::path fsIntroDir("Intro"); + m_pTexBkg = new CN3Texture(); - m_pTexBkg->LoadFromFile("Intro\\Moon.dxt"); + m_pTexBkg->LoadFromFile(fsIntroDir / "moon.dxt"); m_pChr = new CN3Chr(); - m_pChr->LoadFromFile("Intro\\Intro.N3Chr"); + m_pChr->LoadFromFile(fsIntroDir / "intro.n3chr"); m_pChr->AniCurSet(0); // 루핑 에니메이션.. m_pCamera = new CN3Camera(); @@ -90,9 +92,9 @@ void CGameProcLogIn::Init() { for (int i = 0; i < 3; i++) { m_pLights[i] = new CN3Light(); } - m_pLights[0]->LoadFromFile("Intro\\0.N3Light"); - m_pLights[1]->LoadFromFile("Intro\\1.N3Light"); - m_pLights[2]->LoadFromFile("Intro\\2.N3Light"); + m_pLights[0]->LoadFromFile(fsIntroDir / "0.n3light"); + m_pLights[1]->LoadFromFile(fsIntroDir / "1.n3light"); + m_pLights[2]->LoadFromFile(fsIntroDir / "2.n3light"); m_fCurAudioFrm = 0.0f; s_pEng->s_SndMgr.ReleaseStreamObj(&(CGameProcedure::s_pSnd_BGM)); @@ -117,18 +119,16 @@ void CGameProcLogIn::Init() { m_pUILogIn->SetRegion(rc); // 이걸 꼭 해줘야 UI 처리가 제대로 된다.. s_pUIMgr->SetFocusedUI((CN3UIBase *)m_pUILogIn); - // 소켓 접속.. - char szIniPath[_MAX_PATH] = ""; - lstrcpy(szIniPath, CN3Base::PathGet().c_str()); - lstrcat(szIniPath, "Server.Ini"); - int iServerCount = GetPrivateProfileInt("Server", "Count", 0, szIniPath); + // Socket connection.. + std::string fsIniFile = (CN3Base::PathGet() / "Server.ini").string(); + const char * pszIniFile = fsIniFile.c_str(); + + int iServerCount = GetPrivateProfileInt("Server", "Count", 0, pszIniFile); - char szIPs[256][32]; - memset(szIPs, 0, sizeof(szIPs)); + char szIPs[256][32]{}; for (int i = 0; i < iServerCount; i++) { - char szKey[32] = ""; - sprintf(szKey, "IP%d", i); - GetPrivateProfileString("Server", szKey, "", szIPs[i], 32, szIniPath); + std::string szKey = std::format("IP{:d}", i); + GetPrivateProfileString("Server", szKey.c_str(), "", szIPs[i], sizeof(szIPs[i]), pszIniFile); } int iServer = -1; if (iServerCount > 0) { diff --git a/src/game/GameProcMain.cpp b/src/game/GameProcMain.cpp index a1b1d08a..4b71ca67 100644 --- a/src/game/GameProcMain.cpp +++ b/src/game/GameProcMain.cpp @@ -1,8 +1,6 @@ // GameProcMain.cpp: implementation of the CGameProcMain class. // ////////////////////////////////////////////////////////////////////// -#include - #include "StdAfx.h" #include "Resource.h" @@ -308,130 +306,49 @@ void CGameProcMain::Init() { } } + auto fnLoadData = [&](fs::path && fsDirName, fs::path && fsSearchExt, auto & refMng) { + fs::path fsDir = fs::current_path() / fsDirName; + if (fs::is_directory(fsDir)) { + for (const auto & fi : fs::directory_iterator(fsDir)) { + if (fi.is_regular_file() && n3std::iequals(fi.path().extension(), fsSearchExt)) { + refMng.Get(fsDirName / fi.path().filename()); + } + } + } else { + N3_ERROR("Directory not found ({:s})", fsDir.string()); + } + }; + if (s_pUILoading) { s_pUILoading->Render("Loading Character Data...", 0); } - - // 경로 기억.. - char szPathOld[_MAX_PATH], szPathFind[_MAX_PATH]; - ::GetCurrentDirectory(_MAX_PATH, szPathOld); - - _finddata_t fi; - long hFind = -1; - - // 리소스 다 읽기.. - // 에니메이션 다 읽기.. - lstrcpy(szPathFind, szPathOld); - lstrcat(szPathFind, "\\Chr"); - ::SetCurrentDirectory(szPathFind); - hFind = _findfirst("*.N3Anim", &fi); - if (hFind) { - std::string szFN = "Chr\\"; - szFN += fi.name; - CN3AnimControl * pObjTmp = s_MngAniCtrl.Get(szFN.c_str()); - while (_findnext(hFind, &fi) != -1) { - szFN = "Chr\\"; - szFN += fi.name; - pObjTmp = s_MngAniCtrl.Get(szFN.c_str()); - } - } - _findclose(hFind); + fnLoadData("Chr", ".n3anim", s_MngAniCtrl); if (s_pUILoading) { s_pUILoading->Render("Loading Character Data... 10 %", 10); } - - // 리소스 다 읽기.. - // 텍스처 다 읽기.. - lstrcpy(szPathFind, szPathOld); - lstrcat(szPathFind, "\\Item"); - ::SetCurrentDirectory(szPathFind); - hFind = _findfirst("*.dxt", &fi); - if (hFind) { - std::string szFN = "Item\\"; - szFN += fi.name; - CN3Texture * pObjTmp = s_MngTex.Get(szFN.c_str()); - while (_findnext(hFind, &fi) != -1) { - szFN = "Item\\"; - szFN += fi.name; - pObjTmp = s_MngTex.Get(szFN.c_str()); - } - } - _findclose(hFind); + fnLoadData("Item", ".dxt", s_MngTex); if (s_pUILoading) { s_pUILoading->Render("Loading Character Data... 25 %", 25); } - - // 리소스 다 읽기.. - // 조인트 다 읽기.. - lstrcpy(szPathFind, szPathOld); - lstrcat(szPathFind, "\\Chr"); - ::SetCurrentDirectory(szPathFind); - hFind = _findfirst("*.N3Joint", &fi); - if (hFind) { - std::string szFN = "Chr\\"; - szFN += fi.name; - CN3Joint * pObjTmp = s_MngJoint.Get(szFN.c_str()); - while (_findnext(hFind, &fi) != -1) { - szFN = "Chr\\"; - szFN += fi.name; - pObjTmp = s_MngJoint.Get(szFN.c_str()); - } - } - _findclose(hFind); + fnLoadData("Chr", ".n3joint", s_MngJoint); if (s_pUILoading) { s_pUILoading->Render("Loading Character Data... 50 %", 50); } - - // 리소스 다 읽기.. - // 스킨 읽기.. - lstrcpy(szPathFind, szPathOld); - lstrcat(szPathFind, "\\Item"); - ::SetCurrentDirectory(szPathFind); - hFind = _findfirst("*.N3CSkins", &fi); - if (hFind) { - std::string szFN = "Item\\"; - szFN += fi.name; - CN3CPartSkins * pObjTmp = s_MngSkins.Get(szFN.c_str()); - while (_findnext(hFind, &fi) != -1) { - szFN = "Item\\"; - szFN += fi.name; - pObjTmp = s_MngSkins.Get(szFN.c_str()); - } - } - _findclose(hFind); + fnLoadData("Item", ".n3skins", s_MngSkins); if (s_pUILoading) { s_pUILoading->Render("Loading Character Data... 75 %", 75); } - - // 리소스 다 읽기.. - // PMesh 읽기.. - lstrcpy(szPathFind, szPathOld); - lstrcat(szPathFind, "\\Item"); - ::SetCurrentDirectory(szPathFind); - hFind = _findfirst("*.N3PMesh", &fi); - if (hFind) { - std::string szFN = "Item\\"; - szFN += fi.name; - CN3PMesh * pObjTmp = s_MngPMesh.Get(szFN.c_str()); - while (_findnext(hFind, &fi) != -1) { - szFN = "Item\\"; - szFN += fi.name; - pObjTmp = s_MngPMesh.Get(szFN.c_str()); - } - } - _findclose(hFind); + fnLoadData("Item", ".n3pmesh", s_MngPMesh); if (s_pUILoading) { s_pUILoading->Render("Loading Character Data... 100 %", 100); } this->MsgSend_GameStart(); - // 경로 돌리기.. - ::SetCurrentDirectory(szPathOld); } void CGameProcMain::InitPlayerPosition( @@ -1907,7 +1824,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { m_pUIInventory->ReleaseItem(); - std::string szResrcFN, szIconFN; + fs::path fsResrcFile, fsIconFile; for (int i = 0; i < ITEM_SLOT_COUNT; i++) // 슬롯 갯수마큼.. { if (0 == iItemIDInSlots[i]) { @@ -1929,7 +1846,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { e_PartPosition ePart; e_PlugPosition ePlug; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, &szResrcFN, &szIconFN, ePart, + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, &fsResrcFile, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { CLogWriter::Write("MyInfo - slot - Unknown Item"); @@ -1958,7 +1875,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { CLogWriter::Write("MyInfo - slot - Invalid Item"); } __ASSERT(ITEM_TYPE_PART == eType, "Invalid Item"); - s_pPlayer->PartSet(ePart, szResrcFN, pItem, pItemExt); // 파트를 셋팅.. + s_pPlayer->PartSet(ePart, fsResrcFile, pItem, pItemExt); // 파트를 셋팅.. } break; case ITEM_SLOT_HAND_RIGHT: // 오른손 case ITEM_SLOT_HAND_LEFT: // 왼손 @@ -1974,7 +1891,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { } else { ePlugPos = PLUG_POS_LEFTHAND; } - s_pPlayer->PlugSet(ePlugPos, szResrcFN, pItem, pItemExt); // 파트를 셋팅.. + s_pPlayer->PlugSet(ePlugPos, fsResrcFile, pItem, pItemExt); // 파트를 셋팅.. } break; case ITEM_SLOT_SHOULDER: // 망토 { @@ -1988,7 +1905,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { __IconItemSkill * spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iItemCountInSlots[i]; spItem->iDurability = iItemDurabilityInSlots[i]; @@ -2018,7 +1935,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { e_PartPosition ePart; e_PlugPosition ePlug; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { CLogWriter::Write("MyInfo - slot - Unknown Item"); @@ -2028,7 +1945,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { __IconItemSkill * spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iItemCountInInventorys[i]; spItem->iDurability = iItemDurabilityInInventorys[i]; @@ -2046,22 +1963,22 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { m_pUIHotKeyDlg->UpdateDisableCheck(); } - if (s_pPlayer->Part(PART_POS_UPPER)->FileName().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. - s_pPlayer->PartSet(PART_POS_UPPER, pLooks->szPartFNs[PART_POS_UPPER], NULL, NULL); // 상체.. + if (s_pPlayer->Part(PART_POS_UPPER)->FilePath().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. + s_pPlayer->PartSet(PART_POS_UPPER, pLooks->szPartFiles[PART_POS_UPPER], NULL, NULL); // 상체.. } - if (s_pPlayer->Part(PART_POS_LOWER)->FileName().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. - s_pPlayer->PartSet(PART_POS_LOWER, pLooks->szPartFNs[PART_POS_LOWER], NULL, NULL); // 하체.. + if (s_pPlayer->Part(PART_POS_LOWER)->FilePath().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. + s_pPlayer->PartSet(PART_POS_LOWER, pLooks->szPartFiles[PART_POS_LOWER], NULL, NULL); // 하체.. } - if (s_pPlayer->Part(PART_POS_HANDS)->FileName().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. - s_pPlayer->PartSet(PART_POS_HANDS, pLooks->szPartFNs[PART_POS_HANDS], NULL, NULL); // 팔.. + if (s_pPlayer->Part(PART_POS_HANDS)->FilePath().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. + s_pPlayer->PartSet(PART_POS_HANDS, pLooks->szPartFiles[PART_POS_HANDS], NULL, NULL); // 팔.. } - if (s_pPlayer->Part(PART_POS_FEET)->FileName().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. - s_pPlayer->PartSet(PART_POS_FEET, pLooks->szPartFNs[PART_POS_FEET], NULL, NULL); // 다리.. + if (s_pPlayer->Part(PART_POS_FEET)->FilePath().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. + s_pPlayer->PartSet(PART_POS_FEET, pLooks->szPartFiles[PART_POS_FEET], NULL, NULL); // 다리.. } - if (s_pPlayer->Part(PART_POS_FACE)->FileName().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. + if (s_pPlayer->Part(PART_POS_FACE)->FilePath().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. s_pPlayer->InitFace(); } - if (s_pPlayer->Part(PART_POS_HAIR_HELMET)->FileName().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. + if (s_pPlayer->Part(PART_POS_HAIR_HELMET)->FilePath().empty()) { // 아무것도 세팅안되어 있으면 파일 이름이 없다.. s_pPlayer->InitHair(); } @@ -2088,7 +2005,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { this->InitPlayerPosition(__Vector3(fX, fY, fZ)); // 플레이어 위치 초기화.. 일으켜 세우고, 기본동작을 취하게 한다. // berserk temp - //s_pPlayer->PlugSet(PLUG_POS_BACK, "item/babacloak.n3cplug_cloak", NULL); // 파트를 셋팅.. + //s_pPlayer->PlugSet(PLUG_POS_BACK, fs::path("Item") / "babacloak.n3cplug_cloak", NULL); // 파트를 셋팅.. // end berserk temp // berserk @@ -2825,11 +2742,10 @@ bool CGameProcMain::MsgRecv_NPCIn(DataPack * pDataPack, int & iOffset) { pNPC->InitChr(pLooks); // 관절 세팅.. pNPC->ScaleSet(iScale / 100.0f); - std::string szPartFN; e_PartPosition eParts[6] = {PART_POS_UPPER, PART_POS_LOWER, PART_POS_FACE, PART_POS_HANDS, PART_POS_FEET, PART_POS_HAIR_HELMET}; for (int i = 0; i < 6; i++) { - pNPC->PartSet(eParts[i], pLooks->szPartFNs[eParts[i]], NULL, NULL); + pNPC->PartSet(eParts[i], pLooks->szPartFiles[eParts[i]], NULL, NULL); } if (iItemID0) { @@ -2841,9 +2757,9 @@ bool CGameProcMain::MsgRecv_NPCIn(DataPack * pDataPack, int & iOffset) { if (pItem0 && pItemExt0) { e_PartPosition ePart; e_PlugPosition ePlug; - std::string szItemFN; - CGameProcedure::MakeResrcFileNameForUPC(pItem0, &szItemFN, NULL, ePart, ePlug); - pNPC->PlugSet(PLUG_POS_RIGHTHAND, szItemFN, pItem0, pItemExt0); + fs::path fsItemFile; + CGameProcedure::MakeResrcFileNameForUPC(pItem0, &fsItemFile, NULL, ePart, ePlug); + pNPC->PlugSet(PLUG_POS_RIGHTHAND, fsItemFile, pItem0, pItemExt0); } else { __ASSERT(0, "Invalid Item ID And Extension"); } @@ -2858,9 +2774,9 @@ bool CGameProcMain::MsgRecv_NPCIn(DataPack * pDataPack, int & iOffset) { if (pItem1 && pItemExt1) { e_PartPosition ePart; e_PlugPosition ePlug; - std::string szItemFN; - CGameProcedure::MakeResrcFileNameForUPC(pItem1, &szItemFN, NULL, ePart, ePlug); - pNPC->PlugSet(PLUG_POS_LEFTHAND, szItemFN, pItem1, pItemExt1); + fs::path fsItemFile; + CGameProcedure::MakeResrcFileNameForUPC(pItem1, &fsItemFile, NULL, ePart, ePlug); + pNPC->PlugSet(PLUG_POS_LEFTHAND, fsItemFile, pItem1, pItemExt1); } else { N3_WARN("Invalid Item ID And Extension"); } @@ -3345,9 +3261,9 @@ bool CGameProcMain::MsgRecv_UserLookChange(DataPack * pDataPack, int & iOffset) if (ePartPos != PART_POS_UNKNOWN) { if (dwItemID) // 아이템이 있는 경우 { - std::string szItemFN; - CGameProcedure::MakeResrcFileNameForUPC(pItem, &szItemFN, NULL, ePartPos2, ePlugPos2); - pUPC->PartSet(ePartPos, szItemFN, pItem, pItemExt); // 아이템 붙이기.. + fs::path fsItemFile; + CGameProcedure::MakeResrcFileNameForUPC(pItem, &fsItemFile, NULL, ePartPos2, ePlugPos2); + pUPC->PartSet(ePartPos, fsItemFile, pItem, pItemExt); // 아이템 붙이기.. pUPC->DurabilitySet(eSlot, iDurability); } else { __TABLE_PLAYER_LOOKS * pLooks = @@ -3360,7 +3276,7 @@ bool CGameProcMain::MsgRecv_UserLookChange(DataPack * pDataPack, int & iOffset) if (PART_POS_HAIR_HELMET == ePartPos) { pUPC->InitHair(); // 머리인데 없는 경우는.. } else { - pUPC->PartSet(ePartPos, pLooks->szPartFNs[ePartPos], NULL, NULL); + pUPC->PartSet(ePartPos, pLooks->szPartFiles[ePartPos], NULL, NULL); } } } @@ -3368,9 +3284,9 @@ bool CGameProcMain::MsgRecv_UserLookChange(DataPack * pDataPack, int & iOffset) return true; } else if (ePlugPos != PLUG_POS_UNKNOWN) { if (dwItemID) { - std::string szItemFN; - CGameProcedure::MakeResrcFileNameForUPC(pItem, &szItemFN, NULL, ePartPos2, ePlugPos2); - pUPC->PlugSet(ePlugPos, szItemFN, pItem, pItemExt); + fs::path fsItemFile; + CGameProcedure::MakeResrcFileNameForUPC(pItem, &fsItemFile, NULL, ePartPos2, ePlugPos2); + pUPC->PlugSet(ePlugPos, fsItemFile, pItem, pItemExt); pUPC->DurabilitySet(eSlot, iDurability); } else { pUPC->PlugSet(ePlugPos, "", NULL, NULL); @@ -4308,9 +4224,9 @@ void CGameProcMain::InitZone(int iZone, const __Vector3 & vPosPlayer) { // 미니맵 로딩.. CLogWriter::Write("%d->GetWidthByMeterWithTerrain()", ACT_WORLD); // TmpLog1122 float fWidth = ACT_WORLD->GetWidthByMeterWithTerrain(); - CLogWriter::Write("%d->LoadMap()", m_pUIStateBarAndMiniMap); // TmpLog1122 - CLogWriter::Write("%d->szMiniMapFNszMiniMapFN", pZoneData); // TmpLog1122 - m_pUIStateBarAndMiniMap->LoadMap(pZoneData->szMiniMapFN, fWidth, fWidth); + CLogWriter::Write("%d->LoadMiniMap()", m_pUIStateBarAndMiniMap); // TmpLog1122 + CLogWriter::Write("%d->szMiniMapFNszMiniMapFN", pZoneData); // TmpLog1122 + m_pUIStateBarAndMiniMap->LoadMiniMap(pZoneData->szMiniMapFile, fWidth, fWidth); CLogWriter::Write("GetRepresentClass()"); // TmpLog1122 // 줌 비율 정하기.. @@ -4322,16 +4238,11 @@ void CGameProcMain::InitZone(int iZone, const __Vector3 & vPosPlayer) { CLogWriter::Write("%d->ZoomSet()", m_pUIStateBarAndMiniMap); // TmpLog1122 m_pUIStateBarAndMiniMap->ZoomSet(fZoom); - CLogWriter::Write("%d->szTerrainFN.c_str()", pZoneData); // TmpLog1122 - //char szBuf[256]; - char szFName[_MAX_PATH]; - _splitpath(pZoneData->szTerrainFN.c_str(), NULL, NULL, szFName, NULL); - char szFName2[_MAX_PATH]; - char szFullPathName[_MAX_PATH]; - sprintf(szFName2, "%s_Bird", szFName); - _makepath(szFullPathName, NULL, "misc\\bird", szFName2, "lst"); + CLogWriter::Write("%d->szGtdFile.c_str()", pZoneData); // TmpLog1122 + + //fs::path fsBirdListFile = fs::path("Misc") / "bird" / fs::path(pZoneData->szGtdFile).stem() + "_Bird.lst"; - m_pLightMgr->LoadZoneLight(pZoneData->szLightObjFN.c_str()); + m_pLightMgr->LoadZoneLight(pZoneData->szGloFile.c_str()); m_bLoadComplete = true; // 로딩 끝남.. } diff --git a/src/game/GameProcNationSelect.cpp b/src/game/GameProcNationSelect.cpp index 2f3b1028..ed9a3b9c 100644 --- a/src/game/GameProcNationSelect.cpp +++ b/src/game/GameProcNationSelect.cpp @@ -39,15 +39,16 @@ void CGameProcNationSelect::Release() { void CGameProcNationSelect::Init() { CGameProcedure::Init(); - std::string szTemp = "UI\\Co_NationSelect.uif"; + fs::path fsFile = fs::path("UI") / "Co_NationSelect.uif"; + __TABLE_UI_RESRC * pTbl = s_pTbl_UI->Find(NATION_ELMORAD); if (pTbl) { - szTemp = pTbl->szNationSelect; + fsFile = pTbl->szNationSelect; } m_pUINationSelectDlg = new CUINationSelectDlg(); m_pUINationSelectDlg->Init(s_pUIMgr); - m_pUINationSelectDlg->LoadFromFile(szTemp); + m_pUINationSelectDlg->LoadFromFile(fsFile); m_pUINationSelectDlg->m_pProcNationSelectRef = this; // 참조 포인터 넣기.. s_pPlayer->m_InfoBase.eNation = NATION_NOTSELECTED; // 아직 국가를 선택하지 않았다.. @@ -121,4 +122,4 @@ bool CGameProcNationSelect::ProcessPacket(DataPack * pDataPack, int & iOffset) { } return false; -} \ No newline at end of file +} diff --git a/src/game/GameProcedure.cpp b/src/game/GameProcedure.cpp index 1063802f..2e63cbe8 100644 --- a/src/game/GameProcedure.cpp +++ b/src/game/GameProcedure.cpp @@ -184,7 +184,7 @@ void CGameProcedure::StaticMemberInit(HINSTANCE hInstance, HWND hWndMain, HWND h if (!CN3Base::s_Options.bWindowCursor) { s_pGameCursor = new CGameCursor(); - s_pGameCursor->LoadFromFile("ui\\cursor.uif"); + s_pGameCursor->LoadFromFile(fs::path("ui") / "cursor.uif"); } SetGameCursor(s_hCursorNormal); @@ -363,10 +363,9 @@ void CGameProcedure::Tick() { { SYSTEMTIME st; ::GetLocalTime(&st); - char szFN[128] = ""; - // sprintf(szFN, "%d_%d_%d_%d.%d.%d.jpg", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - sprintf(szFN, "%d_%d_%d_%d.%d.%d.ksc", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - this->CaptureScreenAndSaveToFile(szFN); + fs::path fsFile = std::format("{:d}_{:d}_{:d}_{:d}.{:d}.{:d}.ksc", st.wYear, st.wMonth, st.wDay, st.wHour, + st.wMinute, st.wSecond); + this->CaptureScreenAndSaveToFile(fsFile); } ////////////////////////////////// @@ -445,8 +444,8 @@ void CGameProcedure::RenderActive() { // } } -bool CGameProcedure::CaptureScreenAndSaveToFile(const std::string & szFN) { - if (szFN.empty()) { +bool CGameProcedure::CaptureScreenAndSaveToFile(const fs::path & fsFile) { + if (fsFile.empty()) { return false; } CJpegFile file; @@ -464,8 +463,8 @@ bool CGameProcedure::CaptureScreenAndSaveToFile(const std::string & szFN) { } std::string szError; - if (file.EncryptJPEG(hDIB, nQuality, szFN, szError) == TRUE) { - TRACE("Screen Captue %s\n", szFN.c_str()); + if (file.EncryptJPEG(hDIB, nQuality, fsFile, szError) == TRUE) { + TRACE("Screen Captue %s\n", fsFile.string().c_str()); } GlobalFree(hDIB); } @@ -474,37 +473,31 @@ bool CGameProcedure::CaptureScreenAndSaveToFile(const std::string & szFN) { int iW = CN3Base::s_CameraData.vp.Width; int iH = CN3Base::s_CameraData.vp.Height; - bool bResult = false; + bool bResult = false; LPDIRECT3DSURFACE9 lpDDSTmp = NULL; LPDIRECT3DSURFACE9 lpDDSBack = NULL; CN3Base::s_lpD3DDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &lpDDSBack); - if(lpDDSBack) - { + if (lpDDSBack) { CN3Base::s_lpD3DDev->CreateOffscreenPlainSurface(iW, iH, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &lpDDSTmp, NULL); - if(lpDDSTmp) - { + if (lpDDSTmp) { HRESULT rval = D3DXLoadSurfaceFromSurface(lpDDSTmp, NULL, NULL, lpDDSBack, NULL, NULL, D3DX_FILTER_NONE, 0); -// HRESULT rval = s_lpD3DDev->CopyRects(lpDDSBack, NULL, 0, lpDDSTmp, NULL); -// char szErr[256]; -// ::D3DXGetErrorString(rval, szErr, 256); + //HRESULT rval = s_lpD3DDev->CopyRects(lpDDSBack, NULL, 0, lpDDSTmp, NULL); + //char szErr[256]; + //::D3DXGetErrorString(rval, szErr, 256); - if(D3D_OK == rval) - { + if (D3D_OK == rval) { D3DLOCKED_RECT LR; - if(D3D_OK == lpDDSTmp->LockRect(&LR, NULL, 0)) - { -// std::vector buff(iW * iH * 3, 0); + if (D3D_OK == lpDDSTmp->LockRect(&LR, NULL, 0)) { + //std::vector buff(iW * iH * 3, 0); CBitMapFile bmf; bmf.Create(iW, iH); - for(int y = 0; y < iH; y++) - { - BYTE* pPS = ((BYTE*)LR.pBits) + LR.Pitch * y; -// BYTE* pPD = (BYTE*)(&(buff[y * (iW * 3)])); - BYTE* pPD = (BYTE*)(bmf.Pixels(0, y)); + for (int y = 0; y < iH; y++) { + BYTE * pPS = ((BYTE *)LR.pBits) + LR.Pitch * y; + //BYTE * pPD = (BYTE *)(&(buff[y * (iW * 3)])); + BYTE * pPD = (BYTE *)(bmf.Pixels(0, y)); - for(int x = 0; x < iW; x++, pPS += 4, pPD +=3 ) - { + for (int x = 0; x < iW; x++, pPS += 4, pPD += 3) { pPD[0] = pPS[0]; pPD[1] = pPS[1]; pPD[2] = pPS[2]; @@ -512,23 +505,22 @@ bool CGameProcedure::CaptureScreenAndSaveToFile(const std::string & szFN) { } lpDDSTmp->UnlockRect(); -// CJpeg jpg; -// jpg.SaveJPG(szFN.c_str(), iW, iH, &(buff[0])); - bmf.SaveToFile(szFN.c_str()); + //CJpeg jpg; + //jpg.SaveJPG(fsFile, iW, iH, buff.data()); + bmf.SaveToFile(fsFile); } } - + lpDDSTmp->Release(); lpDDSTmp = NULL; } - lpDDSBack->Release(); lpDDSBack = NULL; } return bResult; -*/ + */ } void CGameProcedure::ProcActiveSet(CGameProcedure * pProc) { diff --git a/src/game/GameProcedure.h b/src/game/GameProcedure.h index b8697cff..b31b15f7 100644 --- a/src/game/GameProcedure.h +++ b/src/game/GameProcedure.h @@ -141,7 +141,7 @@ class CGameProcedure : public CGameBase { static void UIPostData_Read(const std::string & szKey, class CN3UIBase * pUI, int iDefaultX, int iDefaultY); static void UIPostData_Write(const std::string & szKey, CN3UIBase * pUI); - static bool CaptureScreenAndSaveToFile(const std::string & szFN); + static bool CaptureScreenAndSaveToFile(const fs::path & fsFile); static void SetGameCursor(HCURSOR hCursor, bool bLocked = false); static void SetGameCursor(e_Cursor eCursor, bool bLocked = false); diff --git a/src/game/LightMgr.cpp b/src/game/LightMgr.cpp index cb7166cc..61fdb5de 100644 --- a/src/game/LightMgr.cpp +++ b/src/game/LightMgr.cpp @@ -135,13 +135,13 @@ void CLightMgr::AddLight(CN3Light * pLgt) { m_Lights.push_back(pLgt); } -void CLightMgr::LoadZoneLight(const char * szFN) { - if (!szFN) { +void CLightMgr::LoadZoneLight(const fs::path & fsFile) { + if (fsFile.empty()) { return; } DWORD dwRWC; - HANDLE hFile = CreateFile(szFN, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { return; } @@ -157,4 +157,4 @@ void CLightMgr::LoadZoneLight(const char * szFN) { AddLight(pLgt); } CloseHandle(hFile); -} \ No newline at end of file +} diff --git a/src/game/LightMgr.h b/src/game/LightMgr.h index 6082864a..6739b2e7 100644 --- a/src/game/LightMgr.h +++ b/src/game/LightMgr.h @@ -33,7 +33,7 @@ class CLightMgr : public CN3Base { void AddLight(CN3Light * pLgt); CN3Light * Light(int idx) { return m_pActiveLight[idx]; } - void LoadZoneLight(const char * szFN); + void LoadZoneLight(const fs::path & fsFile); CLightMgr(); virtual ~CLightMgr(); diff --git a/src/game/MachineBase.cpp b/src/game/MachineBase.cpp index 538edb4f..381caaf8 100644 --- a/src/game/MachineBase.cpp +++ b/src/game/MachineBase.cpp @@ -220,7 +220,7 @@ void CMachineBase::LoadMachine(FILE * stream) { // result = fscanf(stream, "WheelRadius_BR = %f\n", &(m_Wheel[WHEEL_BR].fRadius)); __ASSERT(result != EOF, "잘못된 Machine 세팅 파일"); // shape load하기 - this->Load(szSrcName); + //this->Load(szSrcName); // this looks outdated, but keeping it as comment for the record. __ASSERT(m_bSkipCalcPartMtx == NULL, "Machine에서 메모리 릭 가능성"); int iPartCount = PartCount(); diff --git a/src/game/MachineMng.cpp b/src/game/MachineMng.cpp index c76d9e60..deeb7c15 100644 --- a/src/game/MachineMng.cpp +++ b/src/game/MachineMng.cpp @@ -28,18 +28,14 @@ void CMachineMng::Release() { } m_Machines.clear(); } + /* -void CMachineMng::ReceiveReplyMsg(ReplyMsg& RPMsg) -{ - if ( RPMsg.s_iAddressLen > s_pMsgRouter->GetThisClassLevel(ID_MACHINE_MGR) ) - { +void CMachineMng::ReceiveReplyMsg(ReplyMsg & RPMsg) { + if (RPMsg.s_iAddressLen > s_pMsgRouter->GetThisClassLevel(ID_MACHINE_MGR)) { //.. - } - else if ( RPMsg.s_iAddressLen == s_pMsgRouter->GetThisClassLevel(ID_MACHINE_MGR) ) - { - CMachineBase* pMachine = NULL; - switch( RPMsg.s_iGameID ) - { + } else if (RPMsg.s_iAddressLen == s_pMsgRouter->GetThisClassLevel(ID_MACHINE_MGR)) { + CMachineBase * pMachine = NULL; + switch (RPMsg.s_iGameID) { case ID_MACHINE_IN: //.. Add Player.. AddMachine(RPMsg); @@ -47,62 +43,78 @@ void CMachineMng::ReceiveReplyMsg(ReplyMsg& RPMsg) case ID_MACHINE_STOP: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->Stop(); - break; + if (pMachine) { + pMachine->Stop(); + } + break; case ID_MACHINE_TURNLEFT_ON: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->ToggleTurnLeft(TRUE); + if (pMachine) { + pMachine->ToggleTurnLeft(TRUE); + } break; case ID_MACHINE_TURNLEFT_OFF: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->ToggleTurnLeft(FALSE); + if (pMachine) { + pMachine->ToggleTurnLeft(FALSE); + } break; case ID_MACHINE_TURNRIGHT_ON: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->ToggleTurnRight(TRUE); + if (pMachine) { + pMachine->ToggleTurnRight(TRUE); + } break; case ID_MACHINE_TURNRIGHT_OFF: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->ToggleTurnRight(FALSE); + if (pMachine) { + pMachine->ToggleTurnRight(FALSE); + } break; case ID_MACHINE_MOVEFORWARD_ON: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->ToggleMoveForward(TRUE); - break; + if (pMachine) { + pMachine->ToggleMoveForward(TRUE); + } + break; case ID_MACHINE_MOVEFORWARD_OFF: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->ToggleMoveForward(FALSE); - break; + if (pMachine) { + pMachine->ToggleMoveForward(FALSE); + } + break; case ID_MACHINE_MOVEBACKWARD_ON: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->ToggleMoveBackward(FALSE); - break; + if (pMachine) { + pMachine->ToggleMoveBackward(FALSE); + } + break; case ID_MACHINE_MOVEBACKWARD_OFF: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) pMachine->ToggleMoveBackward(FALSE); - break; + if (pMachine) { + pMachine->ToggleMoveBackward(FALSE); + } + break; case ID_MACHINE_FIRE: pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) - { + if (pMachine) { pMachine->SetFireRadian(RPMsg.s_fFireRadian); pMachine->SetFireSpeed(RPMsg.s_fFireSpeed); pMachine->Fire(); -// g_Facade.m_pSndMgr->Looping(SND3DOBJ_CATAPULTTHROW1 + g_Facade.m_pSndMgr->m_IdxCatapultThrow, false); -// g_Facade.m_pSndMgr->SetPos(SND3DOBJ_CATAPULTTHROW1 + g_Facade.m_pSndMgr->m_IdxCatapultThrow, (D3DVECTOR)pMachine->Pos()); -// g_Facade.m_pSndMgr->Play(SND3DOBJ_CATAPULTTHROW1 + g_Facade.m_pSndMgr->m_IdxCatapultThrow); -// g_Facade.m_pSndMgr->m_IdxCatapultThrow++; -// if(g_Facade.m_pSndMgr->m_IdxCatapultThrow == g_Facade.m_pSndMgr->m_NumCatapultThrow) g_Facade.m_pSndMgr->m_IdxCatapultThrow = 0; + // g_Facade.m_pSndMgr->Looping(SND3DOBJ_CATAPULTTHROW1 + g_Facade.m_pSndMgr->m_IdxCatapultThrow, false); + // g_Facade.m_pSndMgr->SetPos(SND3DOBJ_CATAPULTTHROW1 + g_Facade.m_pSndMgr->m_IdxCatapultThrow, (D3DVECTOR)pMachine->Pos()); + // g_Facade.m_pSndMgr->Play(SND3DOBJ_CATAPULTTHROW1 + g_Facade.m_pSndMgr->m_IdxCatapultThrow); + // g_Facade.m_pSndMgr->m_IdxCatapultThrow++; + // if(g_Facade.m_pSndMgr->m_IdxCatapultThrow == g_Facade.m_pSndMgr->m_NumCatapultThrow) g_Facade.m_pSndMgr->m_IdxCatapultThrow = 0; } - break; - case ID_MACHINE_POSITION: // 투석기 위치 재설정 + break; + case ID_MACHINE_POSITION: // 투석기 위치 재설정 pMachine = GetMachine(RPMsg.s_pStrID); - if (pMachine) - { + if (pMachine) { pMachine->Stop(); pMachine->PosSet(RPMsg.s_fPosX, RPMsg.s_fPosY, RPMsg.s_fPosZ); pMachine->SetDirRadian(RPMsg.s_fRotY); @@ -111,38 +123,33 @@ void CMachineMng::ReceiveReplyMsg(ReplyMsg& RPMsg) } } -void CMachineMng::AddMachine(ReplyMsg& RPMsg) -{ -// if (lstrlen(RPMsg.s_cprscID) == 0) return; +void CMachineMng::AddMachine(ReplyMsg & RPMsg) { + // if (lstrlen(RPMsg.s_cprscID) == 0) return; - char szFileName[_MAX_PATH] = "misc\\machines\\catapult.mcn"; - FILE* stream = fopen(szFileName, "r"); //text파일로 만든다 + fs::path fsFile = fs::path("misc") / "machines" / "catapult.mcn"; + FILE * stream = _wfopen(fsFile, L"r"); //text파일로 만든다 #if _DEBUG char szErr[512]; - if(NULL == stream) - { - wsprintf(szErr, "failed to open file - %s", szFileName); + if (NULL == stream) { + wsprintf(szErr, "failed to open file - %s", fsFile.string().c_str()); __ASSERT(stream, szErr); } #endif - char szMachineType[64]; // machine 종류 - int result = fscanf(stream, "Machine_Type = %s\n", szMachineType); __ASSERT(result != EOF, "잘못된 Machine 세팅 파일"); - CMachineBase* pMachine = NULL; + char szMachineType[64]; // machine 종류 + int result = fscanf(stream, "Machine_Type = %s\n", szMachineType); + __ASSERT(result != EOF, "잘못된 Machine 세팅 파일"); + CMachineBase * pMachine = NULL; - if (lstrcmpi(szMachineType, "catapult") == 0) - { + if (lstrcmpi(szMachineType, "catapult") == 0) { pMachine = new CCatapult; - } - else - { + } else { pMachine = new CMachineBase; } pMachine->LoadMachine(stream); fclose(stream); - pMachine->SetID(RPMsg.s_pStrID); pMachine->PosSet(RPMsg.s_fPosX, RPMsg.s_fPosY, RPMsg.s_fPosZ); pMachine->SetDirRadian(RPMsg.s_fRotY); @@ -150,6 +157,7 @@ void CMachineMng::AddMachine(ReplyMsg& RPMsg) m_Machines.push_back(pMachine); } */ + void CMachineMng::Render() { CMachineBase * pMachine = NULL; it_Machine it = m_Machines.begin(); @@ -173,14 +181,18 @@ void CMachineMng::Tick() { } pMachine->Tick(-1); - /* if(pMachine->GetMachineState()!=MS_STOP) - { + /* + if (pMachine->GetMachineState() != MS_STOP) { g_Facade.m_pSndMgr->Looping(SND3DOBJ_CATAPULTMOVE1 + g_Facade.m_pSndMgr->m_IdxCatapultMove, false); - g_Facade.m_pSndMgr->SetPos(SND3DOBJ_CATAPULTMOVE1 + g_Facade.m_pSndMgr->m_IdxCatapultMove, (D3DVECTOR)pMachine->Pos()); + g_Facade.m_pSndMgr->SetPos(SND3DOBJ_CATAPULTMOVE1 + g_Facade.m_pSndMgr->m_IdxCatapultMove, + (D3DVECTOR)pMachine->Pos()); g_Facade.m_pSndMgr->Play(SND3DOBJ_CATAPULTMOVE1 + g_Facade.m_pSndMgr->m_IdxCatapultMove); g_Facade.m_pSndMgr->m_IdxCatapultMove++; - if(g_Facade.m_pSndMgr->m_IdxCatapultMove == g_Facade.m_pSndMgr->m_NumCatapultMove) g_Facade.m_pSndMgr->m_IdxCatapultMove = 0; - }*/ + if (g_Facade.m_pSndMgr->m_IdxCatapultMove == g_Facade.m_pSndMgr->m_NumCatapultMove) { + g_Facade.m_pSndMgr->m_IdxCatapultMove = 0; + } + } + */ } } diff --git a/src/game/MagicSkillMng.cpp b/src/game/MagicSkillMng.cpp index a0d99187..a5408302 100644 --- a/src/game/MagicSkillMng.cpp +++ b/src/game/MagicSkillMng.cpp @@ -55,35 +55,37 @@ CMagicSkillMng::CMagicSkillMng(CGameProcMain * pGameProcMain) { } void CMagicSkillMng::Init() { + fs::path fsDataDir("Data"); + m_pTbl_Type_1 = new CN3TableBase; - m_pTbl_Type_1->LoadFromFile("Data\\Skill_Magic_1.tbl"); + m_pTbl_Type_1->LoadFromFile(fsDataDir / "Skill_Magic_1.tbl"); m_pTbl_Type_2 = new CN3TableBase; - m_pTbl_Type_2->LoadFromFile("Data\\Skill_Magic_2.tbl"); + m_pTbl_Type_2->LoadFromFile(fsDataDir / "Skill_Magic_2.tbl"); m_pTbl_Type_3 = new CN3TableBase; - m_pTbl_Type_3->LoadFromFile("Data\\Skill_Magic_3.tbl"); + m_pTbl_Type_3->LoadFromFile(fsDataDir / "Skill_Magic_3.tbl"); m_pTbl_Type_4 = new CN3TableBase; - m_pTbl_Type_4->LoadFromFile("Data\\Skill_Magic_4.tbl"); + m_pTbl_Type_4->LoadFromFile(fsDataDir / "Skill_Magic_4.tbl"); - // m_pTbl_Type_5 = new CN3TableBase; - // m_pTbl_Type_5->LoadFromFile("Data\\Skill_Magic_5.tbl"); + //m_pTbl_Type_5 = new CN3TableBase; + //m_pTbl_Type_5->LoadFromFile(fsDataDir / "Skill_Magic_5.tbl"); - // m_pTbl_Type_6 = new CN3TableBase; - // m_pTbl_Type_6->LoadFromFile("Data\\Skill_Magic_6.tbl"); + //m_pTbl_Type_6 = new CN3TableBase; + //m_pTbl_Type_6->LoadFromFile(fsDataDir / "Skill_Magic_6.tbl"); - // m_pTbl_Type_7 = new CN3TableBase; - // m_pTbl_Type_7->LoadFromFile("Data\\Skill_Magic_7.tbl"); + //m_pTbl_Type_7 = new CN3TableBase; + //m_pTbl_Type_7->LoadFromFile(fsDataDir / "Skill_Magic_7.tbl"); - // m_pTbl_Type_8 = new CN3TableBase; - // m_pTbl_Type_8->LoadFromFile("Data\\Skill_Magic_8.tbl"); + //m_pTbl_Type_8 = new CN3TableBase; + //m_pTbl_Type_8->LoadFromFile(fsDataDir / "Skill_Magic_8.tbl"); - // m_pTbl_Type_9 = new CN3TableBase; - // m_pTbl_Type_9->LoadFromFile("Data\\Skill_Magic_9.tbl"); + //m_pTbl_Type_9 = new CN3TableBase; + //m_pTbl_Type_9->LoadFromFile(fsDataDir / "Skill_Magic_9.tbl"); - // m_pTbl_Type_10 = new CN3TableBase; - // m_pTbl_Type_10->LoadFromFile("Data\\Skill_Magic_10.tbl"); + //m_pTbl_Type_10 = new CN3TableBase; + //m_pTbl_Type_10->LoadFromFile(fsDataDir / "Skill_Magic_10.tbl"); m_MySelf.clear(); @@ -3037,4 +3039,4 @@ void CMagicSkillMng::StunMySelf(__TABLE_UPC_SKILL_TYPE_3 * pType3) { m_pGameProcMain->CommandSitDown(false, false); // 일으켜 세운다. s_pPlayer->Stun(STUN_TIME); } -} \ No newline at end of file +} diff --git a/src/game/Main.cpp b/src/game/Main.cpp index 1895fc1e..1354991a 100644 --- a/src/game/Main.cpp +++ b/src/game/Main.cpp @@ -314,14 +314,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi // 스피드 핵 체킹용... ////////////////////////////// - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); // 세팅 읽기.. - char szIniPath[_MAX_PATH] = ""; - lstrcpy(szIniPath, CN3Base::PathGet().c_str()); - lstrcat(szIniPath, "Option.Ini"); + std::string szIniFile = (CN3Base::PathGet() / "Options.ini").string(); + const char * pszIniFile = szIniFile.c_str(); - CN3Base::s_Options.iTexLOD_Chr = GetPrivateProfileInt("Texture", "LOD_Chr", 0, szIniPath); + CN3Base::s_Options.iTexLOD_Chr = GetPrivateProfileInt("Texture", "LOD_Chr", 0, pszIniFile); if (CN3Base::s_Options.iTexLOD_Chr < 0) { CN3Base::s_Options.iTexLOD_Chr = 0; } @@ -329,7 +328,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi CN3Base::s_Options.iTexLOD_Chr = 1; } - CN3Base::s_Options.iTexLOD_Shape = GetPrivateProfileInt("Texture", "LOD_Shape", 0, szIniPath); + CN3Base::s_Options.iTexLOD_Shape = GetPrivateProfileInt("Texture", "LOD_Shape", 0, pszIniFile); if (CN3Base::s_Options.iTexLOD_Shape < 0) { CN3Base::s_Options.iTexLOD_Shape = 0; } @@ -337,7 +336,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi CN3Base::s_Options.iTexLOD_Shape = 1; } - CN3Base::s_Options.iTexLOD_Terrain = GetPrivateProfileInt("Texture", "LOD_Terrain", 0, szIniPath); + CN3Base::s_Options.iTexLOD_Terrain = GetPrivateProfileInt("Texture", "LOD_Terrain", 0, pszIniFile); if (CN3Base::s_Options.iTexLOD_Terrain < 0) { CN3Base::s_Options.iTexLOD_Terrain = 0; } @@ -345,10 +344,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi CN3Base::s_Options.iTexLOD_Terrain = 1; } - CN3Base::s_Options.iUseShadow = GetPrivateProfileInt("Shadow", "Use", 1, szIniPath); + CN3Base::s_Options.iUseShadow = GetPrivateProfileInt("Shadow", "Use", 1, pszIniFile); - CN3Base::s_Options.iViewWidth = GetPrivateProfileInt("ViewPort", "Width", 1024, szIniPath); - CN3Base::s_Options.iViewHeight = GetPrivateProfileInt("ViewPort", "Height", 768, szIniPath); + CN3Base::s_Options.iViewWidth = GetPrivateProfileInt("ViewPort", "Width", 1024, pszIniFile); + CN3Base::s_Options.iViewHeight = GetPrivateProfileInt("ViewPort", "Height", 768, pszIniFile); if (1024 == CN3Base::s_Options.iViewWidth) { CN3Base::s_Options.iViewHeight = 768; } else if (1280 == CN3Base::s_Options.iViewWidth) { @@ -360,11 +359,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi CN3Base::s_Options.iViewHeight = 768; } - CN3Base::s_Options.iViewColorDepth = GetPrivateProfileInt("ViewPort", "ColorDepth", 16, szIniPath); + CN3Base::s_Options.iViewColorDepth = GetPrivateProfileInt("ViewPort", "ColorDepth", 16, pszIniFile); if (CN3Base::s_Options.iViewColorDepth != 16 && CN3Base::s_Options.iViewColorDepth != 32) { CN3Base::s_Options.iViewColorDepth = 16; } - CN3Base::s_Options.iViewDist = GetPrivateProfileInt("ViewPort", "Distance", 512, szIniPath); + CN3Base::s_Options.iViewDist = GetPrivateProfileInt("ViewPort", "Distance", 512, pszIniFile); if (CN3Base::s_Options.iViewDist < 256) { CN3Base::s_Options.iViewDist = 256; } @@ -372,7 +371,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi CN3Base::s_Options.iViewDist = 512; } - CN3Base::s_Options.iEffectSndDist = GetPrivateProfileInt("Sound", "Distance", 48, szIniPath); + CN3Base::s_Options.iEffectSndDist = GetPrivateProfileInt("Sound", "Distance", 48, pszIniFile); if (CN3Base::s_Options.iEffectSndDist < 20) { CN3Base::s_Options.iEffectSndDist = 20; } @@ -380,16 +379,16 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi CN3Base::s_Options.iEffectSndDist = 48; } - int iSndEnable = GetPrivateProfileInt("Sound", "Enable", 1, szIniPath); + int iSndEnable = GetPrivateProfileInt("Sound", "Enable", 1, pszIniFile); CN3Base::s_Options.bSndEnable = (iSndEnable) ? true : false; // 사운드... - int iSndDuplicate = GetPrivateProfileInt("Sound", "Duplicate", 0, szIniPath); + int iSndDuplicate = GetPrivateProfileInt("Sound", "Duplicate", 0, pszIniFile); CN3Base::s_Options.bSndDuplicated = (iSndDuplicate) ? true : false; // 사운드... - int iWindowCursor = GetPrivateProfileInt("Cursor", "WindowCursor", 1, szIniPath); + int iWindowCursor = GetPrivateProfileInt("Cursor", "WindowCursor", 1, pszIniFile); CN3Base::s_Options.bWindowCursor = (iWindowCursor) ? true : false; // cursor... - int iWindowMode = GetPrivateProfileInt("Screen", "WindowMode", 0, szIniPath); + int iWindowMode = GetPrivateProfileInt("Screen", "WindowMode", 0, pszIniFile); CGameProcedure::s_bWindowed = iWindowMode ? true : false; #if _DEBUG CGameProcedure::s_bWindowed = true; @@ -408,13 +407,12 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi ::ShowWindow(hWndMain, nCmdShow); // 보여준다.. ::SetActiveWindow(hWndMain); - // Launcher 업그레이드.. - FILE * pFile = fopen("Launcher2.exe", "r"); // 업그레이드 할게 있음 해 준다.. - if (pFile) { - fclose(pFile); - if (::DeleteFile("Launcher.exe")) // 원래 걸 지우고.. - { - ::rename("Launcher2.exe", "Launcher.exe"); // 이름을 바꾸어 준다.. + // Launcher upgrade + if (fs::is_regular_file("Launcher2.exe")) { + if (fs::remove("Launcher.exe")) { + fs::rename("Launcher2.exe", "Launcher.exe"); + } else { + N3_WARN("Failed to upgrade Launcher.exe"); } } diff --git a/src/game/N3EffectWave2.cpp b/src/game/N3EffectWave2.cpp index dfdf73f3..bbf515d1 100644 --- a/src/game/N3EffectWave2.cpp +++ b/src/game/N3EffectWave2.cpp @@ -166,14 +166,13 @@ bool CN3EffectWave2::Load(HANDLE hFile) { return 0; } -void CN3EffectWave2::Init(const std::string & TexPath) { - char szFileName[30]; +void CN3EffectWave2::Init(const fs::path & fsTexFile) { for (int i = 0; i < MAX_POND_TEX; i++) { - sprintf(szFileName, "misc\\river\\caust%02d.dxt", i); - m_pTexPond[i] = CN3Base::s_MngTex.Get(szFileName); + fs::path fsTexFile = fs::path("Misc") / "river" / std::format("caust{:02d}.dxt", i); + m_pTexPond[i] = CN3Base::s_MngTex.Get(fsTexFile); __ASSERT(m_pTexPond[i], "CN3EffectWave2::texture load failed"); } - m_pTexWave = s_MngTex.Get(TexPath); //"misc\\river\\blupool3.tga"); /// + m_pTexWave = CN3Base::s_MngTex.Get(fsTexFile); __ASSERT(m_pTexWave, "CN3EffectWave2::texture load failed"); } diff --git a/src/game/N3EffectWave2.h b/src/game/N3EffectWave2.h index 418a8225..e17816aa 100644 --- a/src/game/N3EffectWave2.h +++ b/src/game/N3EffectWave2.h @@ -84,7 +84,7 @@ class CN3EffectWave2 : public CN3BaseFileAccess { bool Load(HANDLE hFile); void Render(); void Tick(); - void Init(const std::string & TexPath); + void Init(const fs::path & fsTexFile); private: void CheckHeight(float & ChkHeight) { diff --git a/src/game/N3FXBundleGame.cpp b/src/game/N3FXBundleGame.cpp index 25d9a581..9fd193e7 100644 --- a/src/game/N3FXBundleGame.cpp +++ b/src/game/N3FXBundleGame.cpp @@ -330,7 +330,7 @@ bool CN3FXBundleGame::Tick() { } void CN3FXBundleGame::Duplicate(CN3FXBundleGame * pDestBundle) { - pDestBundle->FileNameSet(this->FileName()); + pDestBundle->FilePathSet(FilePath()); pDestBundle->m_iVersion = m_iVersion; pDestBundle->m_fLife0 = m_fLife0; @@ -428,10 +428,7 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { else if (iType == FX_PART_TYPE_PARTICLE) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -440,17 +437,13 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_PARTICLE; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_BOARD) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -459,17 +452,13 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_BOARD; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_MESH) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -478,15 +467,11 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_MESH; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_BOTTOMBOARD) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -495,7 +480,6 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_BOTTOMBOARD; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } } @@ -513,10 +497,7 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { else if (iType == FX_PART_TYPE_PARTICLE) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -525,17 +506,13 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_PARTICLE; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_BOARD) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -544,17 +521,13 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_BOARD; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_MESH) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -563,15 +536,11 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_MESH; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } else if (iType == FX_PART_TYPE_BOTTOMBOARD) { m_pPart[i] = new FXPARTWITHSTARTTIME; - //char FName[80]; float fStartTime; - //ReadFile(hFile, FName, 80, &dwRWC, NULL); - ReadFile(hFile, &(fStartTime), sizeof(float), &dwRWC, NULL); m_pPart[i]->fStartTime = fStartTime; @@ -580,7 +549,6 @@ bool CN3FXBundleGame::Load(HANDLE hFile) { m_pPart[i]->pPart->m_pRefBundle = this; m_pPart[i]->pPart->m_pRefPrevPart = NULL; m_pPart[i]->pPart->m_iType = FX_PART_TYPE_BOTTOMBOARD; - //m_pPart[i]->pPart->LoadFromFile(FName); m_pPart[i]->pPart->Load(hFile); } } diff --git a/src/game/N3FXMgr.cpp b/src/game/N3FXMgr.cpp index 38316238..7ceb10ae 100644 --- a/src/game/N3FXMgr.cpp +++ b/src/game/N3FXMgr.cpp @@ -47,12 +47,9 @@ void CN3FXMgr::TriggerBundle(int SourceID, int SourceJoint, int FXID, int Target return; } - char buff[MAX_PATH]; - sprintf(buff, pFX->szFN.c_str()); - _strlwr(buff); - std::string strTmp = buff; + fs::path fsFxbFile = fs::path(pFX->szFile).lower(); - stlMAP_BUNDLEORIGIN_IT itOrigin = m_OriginBundle.find(strTmp); + stlMAP_BUNDLEORIGIN_IT itOrigin = m_OriginBundle.find(fsFxbFile); if (itOrigin != m_OriginBundle.end()) //같은 효과가 있다.. { @@ -75,7 +72,7 @@ void CN3FXMgr::TriggerBundle(int SourceID, int SourceJoint, int FXID, int Target { LPFXBUNDLEORIGIN pSrc = new FXBUNDLEORIGIN; pSrc->pBundle = new CN3FXBundleGame; - pSrc->pBundle->LoadFromFile(strTmp); + pSrc->pBundle->LoadFromFile(fsFxbFile); CN3FXBundleGame * pBundle = new CN3FXBundleGame; @@ -91,7 +88,7 @@ void CN3FXMgr::TriggerBundle(int SourceID, int SourceJoint, int FXID, int Target m_ListBundle.push_back(pBundle); pSrc->iNum++; - m_OriginBundle.insert(stlMAP_BUNDLEORIGIN_VALUE(strTmp, pSrc)); + m_OriginBundle.insert(stlMAP_BUNDLEORIGIN_VALUE(fsFxbFile, pSrc)); } } @@ -104,12 +101,9 @@ void CN3FXMgr::TriggerBundle(int SourceID, int SourceJoint, int FXID, __Vector3 return; } - char buff[MAX_PATH]; - sprintf(buff, pFX->szFN.c_str()); - _strlwr(buff); - std::string strTmp = buff; + fs::path fsFxbFile = fs::path(pFX->szFile).lower(); - stlMAP_BUNDLEORIGIN_IT itOrigin = m_OriginBundle.find(strTmp); + stlMAP_BUNDLEORIGIN_IT itOrigin = m_OriginBundle.find(fsFxbFile); if (itOrigin != m_OriginBundle.end()) //같은 효과가 있다.. { @@ -130,7 +124,7 @@ void CN3FXMgr::TriggerBundle(int SourceID, int SourceJoint, int FXID, __Vector3 { LPFXBUNDLEORIGIN pSrc = new FXBUNDLEORIGIN; pSrc->pBundle = new CN3FXBundleGame; - pSrc->pBundle->LoadFromFile(pFX->szFN); + pSrc->pBundle->LoadFromFile(pFX->szFile); CN3FXBundleGame * pBundle = new CN3FXBundleGame; @@ -145,7 +139,7 @@ void CN3FXMgr::TriggerBundle(int SourceID, int SourceJoint, int FXID, __Vector3 m_ListBundle.push_back(pBundle); pSrc->iNum++; - m_OriginBundle.insert(stlMAP_BUNDLEORIGIN_VALUE(strTmp, pSrc)); + m_OriginBundle.insert(stlMAP_BUNDLEORIGIN_VALUE(fsFxbFile, pSrc)); } } @@ -252,7 +246,7 @@ void CN3FXMgr::Tick() { continue; } if (pBundle->m_dwState == FX_BUNDLE_STATE_DEAD) { - stlMAP_BUNDLEORIGIN_IT itOrigin = m_OriginBundle.find(pBundle->FileName()); + stlMAP_BUNDLEORIGIN_IT itOrigin = m_OriginBundle.find(pBundle->FilePath()); if (itOrigin != m_OriginBundle.end()) //같은 효과가 있다.. { LPFXBUNDLEORIGIN pSrc = itOrigin->second; diff --git a/src/game/N3FXMgr.h b/src/game/N3FXMgr.h index 0cddba3a..4f36256a 100644 --- a/src/game/N3FXMgr.h +++ b/src/game/N3FXMgr.h @@ -29,9 +29,9 @@ typedef struct __FXBundleOrigin // 번들에서 파트들 관리할때.. } } FXBUNDLEORIGIN, *LPFXBUNDLEORIGIN; -typedef std::map stlMAP_BUNDLEORIGIN; -typedef stlMAP_BUNDLEORIGIN::value_type stlMAP_BUNDLEORIGIN_VALUE; -typedef stlMAP_BUNDLEORIGIN::iterator stlMAP_BUNDLEORIGIN_IT; +typedef std::map stlMAP_BUNDLEORIGIN; +typedef stlMAP_BUNDLEORIGIN::value_type stlMAP_BUNDLEORIGIN_VALUE; +typedef stlMAP_BUNDLEORIGIN::iterator stlMAP_BUNDLEORIGIN_IT; typedef std::list stlLIST_BUNDLEGAME; //typedef stlLIST_BUNDLEGAME::value_type stlLIST_BUNDLEGAME_VALUE; diff --git a/src/game/N3MP3.cpp b/src/game/N3MP3.cpp index 0a673184..f8266ec8 100644 --- a/src/game/N3MP3.cpp +++ b/src/game/N3MP3.cpp @@ -20,7 +20,6 @@ CN3Mp3::CN3Mp3() { m_IsLoop = false; m_Active = false; - ZeroMemory(m_FileName, MAX_PATH); } CN3Mp3::~CN3Mp3() { @@ -56,7 +55,7 @@ bool CN3Mp3::Init() { m_IsLoop = false; m_Active = false; - ZeroMemory(m_FileName, MAX_PATH); + m_fsFile = fs::path(); return true; } @@ -181,23 +180,16 @@ void CN3Mp3::Looping(bool loop) { // // // -bool CN3Mp3::Load(char * szPathName) { - WCHAR wFileName[MAX_PATH]; +bool CN3Mp3::Load(const fs::path & fsFile) { IBaseFilter * pFilter; IPin * pPin; -#ifndef UNICODE - MultiByteToWideChar(CP_ACP, 0, szPathName, -1, wFileName, MAX_PATH); -#else - lstrcpy(wFileName, szPathName); -#endif - Stop(); if (!ClearGraph()) { return false; } - if (m_pGraphBuilder->AddSourceFilter(wFileName, wFileName, &pFilter) != S_OK) { + if (m_pGraphBuilder->AddSourceFilter(fsFile.c_str(), fsFile.c_str(), &pFilter) != S_OK) { return false; } @@ -226,7 +218,7 @@ bool CN3Mp3::Load(char * szPathName) { pFilter = NULL; } - wsprintf(m_FileName, szPathName); + m_fsFile = fsFile; return true; } diff --git a/src/game/N3Terrain.cpp b/src/game/N3Terrain.cpp index 866c138d..aad9b05c 100644 --- a/src/game/N3Terrain.cpp +++ b/src/game/N3Terrain.cpp @@ -245,7 +245,7 @@ void CN3Terrain::Init() { } } - m_pBaseTex.LoadFromFile("Misc\\Terrain_Base.bmp"); + m_pBaseTex.LoadFromFile(fs::path("Misc") / "Terrain_Base.bmp"); m_iLodLevel = MIN_LOD_LEVEL; SetLODLevel(3); @@ -337,11 +337,9 @@ void CN3Terrain::TestAvailableTile() { // Load... // bool CN3Terrain::Load(HANDLE hFile) { - std::string szFNBackup = m_szFileName; // Init 를 하고 나면 파일 이름이 없어진다.... 그래서... - + fs::path fsFileBak = FilePath(); Init(); - - m_szFileName = szFNBackup; + FilePathSet(fsFileBak); CUILoading * pUILoading = CGameProcedure::s_pUILoading; // 로딩바.. if (pUILoading) { @@ -509,59 +507,51 @@ void CN3Terrain::LoadTileInfo(HANDLE hFile) { CGameProcedure::s_pUILoading->Render("Loading Terrain Tile Data...", 0); } - DWORD dwRWC; + DWORD dwRWC = 0; + + m_NumTileTex = 0; ReadFile(hFile, &m_NumTileTex, sizeof(int), &dwRWC, NULL); - if (m_NumTileTex == 0) { + if (m_NumTileTex <= 0) { return; } m_pTileTex = new CN3Texture[m_NumTileTex]; - int NumTileTexSrc; + int NumTileTexSrc = 0; ReadFile(hFile, &NumTileTexSrc, sizeof(int), &dwRWC, NULL); - if (NumTileTexSrc == 0) { + if (NumTileTexSrc <= 0) { return; } - char ** SrcName = new char *[NumTileTexSrc]; + std::vector vGttFiles(NumTileTexSrc); for (int i = 0; i < NumTileTexSrc; i++) { - SrcName[i] = new char[MAX_PATH]; - ReadFile(hFile, SrcName[i], MAX_PATH, &dwRWC, NULL); + char szBuff[260]{}; + ReadFile(hFile, szBuff, sizeof(szBuff), &dwRWC, NULL); + vGttFiles[i] = szBuff; } - short SrcIdx, TileIdx; - HANDLE hTTGFile; - char szLoadingBuff[128]; for (int i = 0; i < m_NumTileTex; i++) { - ReadFile(hFile, &SrcIdx, sizeof(short), &dwRWC, NULL); - ReadFile(hFile, &TileIdx, sizeof(short), &dwRWC, NULL); + short SrcIdx = 0, TileIdx = 0; + ReadFile(hFile, &SrcIdx, sizeof(SrcIdx), &dwRWC, NULL); + ReadFile(hFile, &TileIdx, sizeof(TileIdx), &dwRWC, NULL); - hTTGFile = CreateFile(SrcName[SrcIdx], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hGttFile = + CreateFileW(vGttFiles[SrcIdx].c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); for (int j = 0; j < TileIdx; j++) { - // m_pTileTex[i].m_iLOD = s_Options.iTexLOD_Terrain; // LOD 적용후 읽기.. - // m_pTileTex[i].Load(hTTGFile);// 앞에 있는 쓸때 없는 것들... - m_pTileTex[i].SkipFileHandle(hTTGFile); // 앞에 있는 쓸때 없는 것들... + m_pTileTex[i].SkipFileHandle(hGttFile); // 앞에 있는 쓸때 없는 것들... } m_pTileTex[i].m_iLOD = s_Options.iTexLOD_Terrain; // LOD 적용후 읽기.. - m_pTileTex[i].Load(hTTGFile); // 진짜 타일... + m_pTileTex[i].Load(hGttFile); // 진짜 타일... - //loading bar... - int iLoading = (i + 1) * 100 / m_NumTileTex; - sprintf(szLoadingBuff, "Loading Terrain Tile Data... %d %%", iLoading); if (CGameProcedure::s_pUILoading) { - CGameProcedure::s_pUILoading->Render(szLoadingBuff, iLoading); + int iPercent = (i + 1) * 100 / m_NumTileTex; + std::string szInfo = std::format("Loading Terrain Tile Data... {:d} %", iPercent); + CGameProcedure::s_pUILoading->Render(szInfo, iPercent); } - CloseHandle(hTTGFile); + CloseHandle(hGttFile); } - - for (int i = 0; i < NumTileTexSrc; i++) { - delete[] SrcName[i]; - SrcName[i] = NULL; - } - - delete[] SrcName; } // @@ -793,8 +783,8 @@ void CN3Terrain::SetLightMap(int dir) { return; } - HANDLE hFile = - CreateFile(pZoneData->szLightMapFN.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + fs::path fsFile = pZoneData->szTltFile; + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (!hFile) { return; } @@ -2017,7 +2007,7 @@ bool CN3Terrain::CheckCollision(__Vector3 & vPos, __Vector3 & vDir, float fVeloc return true; } -bool CN3Terrain::LoadColorMap(const std::string & szFN) { +bool CN3Terrain::LoadColorMap(const fs::path & fsFile) { CUILoading * pUILoading = CGameProcedure::s_pUILoading; // 로딩바.. m_iNumColorMap = (m_pat_MapSize * PATCH_PIXEL_SIZE) / COLORMAPTEX_SIZE; @@ -2026,9 +2016,10 @@ bool CN3Terrain::LoadColorMap(const std::string & szFN) { m_ppColorMapTex[x] = new CN3Texture[m_iNumColorMap]; } - HANDLE hColorMapFile = CreateFile(szFN.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hColorMapFile = + CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hColorMapFile) { - CLogWriter::Write("Failed to load ColorMap - %s", szFN.c_str()); + CLogWriter::Write("Failed to load ColorMap - %s", fsFile.string().c_str()); return false; } diff --git a/src/game/N3Terrain.h b/src/game/N3Terrain.h index f26e5584..197175e6 100644 --- a/src/game/N3Terrain.h +++ b/src/game/N3Terrain.h @@ -121,7 +121,7 @@ class CN3Terrain : public CN3BaseFileAccess { bool GetTileTexInfo(float x, float z, TERRAINTILETEXINFO & TexInfo1, TERRAINTILETEXINFO & TexInfo2); CN3Texture * GetTileTex(int x, int z); MAPDATA GetMapData(int x, int z); - bool LoadColorMap(const std::string & szFN); + bool LoadColorMap(const fs::path & fsFile); void GetNormal(float x, float z, __Vector3 & vNormal); bool IsInTerrain(float x, float z); //.. diff --git a/src/game/N3TerrainManager.cpp b/src/game/N3TerrainManager.cpp index c59a621d..00c9ace0 100644 --- a/src/game/N3TerrainManager.cpp +++ b/src/game/N3TerrainManager.cpp @@ -66,25 +66,20 @@ void CN3TerrainManager::InitWorld(int iZoneID, const __Vector3 & vPosPlayer) { } CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load\t%d", m_pTerrain); // TmpLog_11_22 - m_pTerrain->LoadFromFile(pZone->szTerrainFN); // 지형..로드.. + m_pTerrain->LoadFromFile(pZone->szGtdFile); // 지형..로드.. CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load ColorMap"); // TmpLog_11_22 - m_pTerrain->LoadColorMap(pZone->szColorMapFN); // 컬러맵 로드.. + m_pTerrain->LoadColorMap(pZone->szTctFile); // 컬러맵 로드.. CLogWriter::Write("CN3TerrainManager::InitWorld Pre Release Shapes\t%d", m_pShapes); // TmpLog_11_22 m_pShapes->Release(); CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load Shapes"); // TmpLog_11_22 - m_pShapes->LoadFromFile(pZone->szObjectPostDataFN); // 오브젝트 데이터 로드.. - - char szFName[_MAX_PATH]; - _splitpath(pZone->szTerrainFN.c_str(), NULL, NULL, szFName, NULL); - char szFName2[_MAX_PATH]; - char szFullPathName[_MAX_PATH]; - sprintf(szFName2, "%s_Bird", szFName); - _makepath(szFullPathName, NULL, "misc\\bird", szFName2, "lst"); + m_pShapes->LoadFromFile(pZone->szOpdFile); // 오브젝트 데이터 로드.. + CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load Birds\t%d", m_pBirdMng); // TmpLog_11_22 - m_pBirdMng->LoadFromFile(szFullPathName); + fs::path fsBirdListFile = fs::path("Misc") / "bird" / fs::path(pZone->szGtdFile).stem() + "_Bird.lst"; + m_pBirdMng->LoadFromFile(fsBirdListFile); CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load Sky\t%d", m_pSky); // TmpLog_11_22 - m_pSky->LoadFromFile(pZone->szSkySetting); // 하늘, 구름, 태양, 날씨 변화등 정보 및 텍스처 로딩.. + m_pSky->LoadFromFile(pZone->szSkyFile); // 하늘, 구름, 태양, 날씨 변화등 정보 및 텍스처 로딩.. m_pSky->SunAndMoonDirectionFixByHour( pZone->iFixedSundDirection); // 해, 달 방향을 고정하든가 혹은 0 이면 고정하지 않는다. } diff --git a/src/game/N3UIWndBase.h b/src/game/N3UIWndBase.h index f872d095..a880a484 100644 --- a/src/game/N3UIWndBase.h +++ b/src/game/N3UIWndBase.h @@ -67,7 +67,7 @@ enum e_UIIconType { struct __IconItemSkill { // e_UIIconType eIconType; CN3UIIcon * pUIIcon; - std::string szIconFN; + fs::path fsIconFile; union { struct { diff --git a/src/game/PlayerBase.cpp b/src/game/PlayerBase.cpp index 2b5cd10d..6e1e5003 100644 --- a/src/game/PlayerBase.cpp +++ b/src/game/PlayerBase.cpp @@ -97,12 +97,12 @@ CPlayerBase::CPlayerBase() { // By : Ecli666 ( On 2002-03-29 오후 4:23:36 ) /* m_pTexShadow = NULL; - m_pTexShadow = s_MngTex.Get("Chr\\Shadow_Character.tga"); + m_pTexShadow = s_MngTex.Get(fs::path("Chr") / "Shadow_Character.tga"); m_vShadows[0].Set(-0.7f, 0, 0.7f, 0, 0); - m_vShadows[1].Set( 0.7f, 0, 0.7f, 1, 0); - m_vShadows[2].Set( 0.7f, 0,-0.7f, 1, 1); - m_vShadows[3].Set(-0.7f, 0,-0.7f, 0, 1); -*/ + m_vShadows[1].Set(0.7f, 0, 0.7f, 1, 0); + m_vShadows[2].Set(0.7f, 0, -0.7f, 1, 1); + m_vShadows[3].Set(-0.7f, 0, -0.7f, 0, 1); + */ // ~(By Ecli666 On 2002-03-29 오후 4:23:36 ) // 폰트 초기화... // 정보 표시용 폰트와 풍선용은 따로 생성한다.. @@ -379,13 +379,14 @@ void CPlayerBase::IDSet(int iID, const std::string & szID, D3DCOLOR crID) { } void CPlayerBase::KnightsInfoSet(int iID, const std::string & szName, int iGrade, int iRank) { - char szPlug[128] = ""; + fs::path fsPlugFile; if (iGrade > 0 && iGrade <= 5) { - sprintf(szPlug, "Item\\ClanAddOn_%.3d_%d.n3cplug", m_InfoBase.eRace, - iGrade); // 종족과 등급으로 플러그 이름을 만든다.. + // Create plug names by race and class. + fsPlugFile = + fs::path("Item") / std::format("ClanAddOn_{:03d}_{:d}.n3cplug", static_cast(m_InfoBase.eRace), iGrade); } - CN3CPlugBase * pPlug = this->PlugSet(PLUG_POS_KNIGHTS_GRADE, szPlug, NULL, NULL); + CN3CPlugBase * pPlug = this->PlugSet(PLUG_POS_KNIGHTS_GRADE, fsPlugFile, NULL, NULL); if (NULL == pPlug) { return; @@ -394,14 +395,13 @@ void CPlayerBase::KnightsInfoSet(int iID, const std::string & szName, int iGrade CN3CPlug * pCPlug = (CN3CPlug *)pPlug; __TABLE_FX * pFXClanRank = s_pTbl_FXSource->Find(FXID_CLAN_RANK_1); - std::string szFXClanRank = ""; - std::string szEmpty = ""; + fs::path fsFxClanRankFile; if (pFXClanRank) { if (iRank <= 5 && iRank >= 1) { - szFXClanRank = pFXClanRank->szFN; + fsFxClanRankFile = pFXClanRank->szFile; } } - pCPlug->InitFX(szFXClanRank, szEmpty, 0xffffffff); + pCPlug->InitFX(fsFxClanRankFile, fs::path(), 0xffffffff); } /* @@ -1860,7 +1860,7 @@ bool CPlayerBase::CheckCollisionToTargetByPlug(CPlayerBase * pTarget, int nPlug, return pTarget->CheckCollisionByBox(v1, v2, pVCol, NULL); // 캐릭터 충돌 체크 상자와 충돌 체크.. } -CN3CPlugBase * CPlayerBase::PlugSet(e_PlugPosition ePos, const std::string & szFN, __TABLE_ITEM_BASIC * pItemBasic, +CN3CPlugBase * CPlayerBase::PlugSet(e_PlugPosition ePos, const fs::path & fsFile, __TABLE_ITEM_BASIC * pItemBasic, __TABLE_ITEM_EXT * pItemExt) { if (ePos < PLUG_POS_RIGHTHAND || ePos >= PLUG_POS_COUNT) { __ASSERT(0, "Invalid Plug Position"); @@ -1891,7 +1891,7 @@ CN3CPlugBase * CPlayerBase::PlugSet(e_PlugPosition ePos, const std::string & szF __ASSERT(0, "Invalid Plug Item position"); } - CN3CPlugBase * pPlug = m_Chr.PlugSet(ePos, szFN); + CN3CPlugBase * pPlug = m_Chr.PlugSet(ePos, fsFile); if (NULL == pPlug) { return NULL; } @@ -1909,7 +1909,7 @@ CN3CPlugBase * CPlayerBase::PlugSet(e_PlugPosition ePos, const std::string & szF // } if (pPlug && NULL == pItemBasic && NULL == pItemExt) { - pPlug->TexOverlapSet(""); // 기본 착용이면.. + pPlug->TexOverlapSet(fs::path()); // 기본 착용이면.. } ////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1920,81 +1920,65 @@ CN3CPlugBase * CPlayerBase::PlugSet(e_PlugPosition ePos, const std::string & szF (pItemExt->byDamageFire >= LIMIT_FX_DAMAGE)) // 17 추가데미지 - 불 { CN3CPlug * pCPlug = (CN3CPlug *)pPlug; - __TABLE_FX * pFXMain = s_pTbl_FXSource->Find(FXID_SWORD_FIRE_MAIN); - __TABLE_FX * pFXTail = s_pTbl_FXSource->Find(FXID_SWORD_FIRE_TAIL); + __TABLE_FX * pFxMain = s_pTbl_FXSource->Find(FXID_SWORD_FIRE_MAIN); + __TABLE_FX * pFxTail = s_pTbl_FXSource->Find(FXID_SWORD_FIRE_TAIL); - std::string szFXMain, szFXTail; - if (pFXMain) { - szFXMain = pFXMain->szFN; - } else { - szFXMain = ""; + fs::path fsFxMainFile, fsFxTailFile; + if (pFxMain) { + fsFxMainFile = pFxMain->szFile; } - if (pFXTail) { - szFXTail = pFXTail->szFN; - } else { - szFXTail = ""; + if (pFxTail) { + fsFxTailFile = pFxTail->szFile; } - pCPlug->InitFX(szFXMain, szFXTail, 0xffffff00); + pCPlug->InitFX(fsFxMainFile, fsFxTailFile, 0xffffff00); } else if ((pItemExt->byMagicOrRare == ITEM_UNIQUE && pItemExt->byDamageIce > 0) || (pItemExt->byDamageIce >= LIMIT_FX_DAMAGE)) // 18 추가데미지 - 얼음 { CN3CPlug * pCPlug = (CN3CPlug *)pPlug; - __TABLE_FX * pFXMain = s_pTbl_FXSource->Find(FXID_SWORD_ICE_MAIN); - __TABLE_FX * pFXTail = s_pTbl_FXSource->Find(FXID_SWORD_ICE_TAIL); + __TABLE_FX * pFxMain = s_pTbl_FXSource->Find(FXID_SWORD_ICE_MAIN); + __TABLE_FX * pFxTail = s_pTbl_FXSource->Find(FXID_SWORD_ICE_TAIL); - std::string szFXMain, szFXTail; - if (pFXMain) { - szFXMain = pFXMain->szFN; - } else { - szFXMain = ""; + fs::path fsFxMainFile, fsFxTailFile; + if (pFxMain) { + fsFxMainFile = pFxMain->szFile; } - if (pFXTail) { - szFXTail = pFXTail->szFN; - } else { - szFXTail = ""; + if (pFxTail) { + fsFxTailFile = pFxTail->szFile; } - pCPlug->InitFX(szFXMain, szFXTail, 0xff0000ff); + pCPlug->InitFX(fsFxMainFile, fsFxTailFile, 0xff0000ff); } else if ((pItemExt->byMagicOrRare == ITEM_UNIQUE && pItemExt->byDamageThuner > 0) || (pItemExt->byDamageThuner >= LIMIT_FX_DAMAGE)) // 19 추가데미지 - 전격 { CN3CPlug * pCPlug = (CN3CPlug *)pPlug; - __TABLE_FX * pFXMain = s_pTbl_FXSource->Find(FXID_SWORD_LIGHTNING_MAIN); - __TABLE_FX * pFXTail = s_pTbl_FXSource->Find(FXID_SWORD_LIGHTNING_TAIL); + __TABLE_FX * pFxMain = s_pTbl_FXSource->Find(FXID_SWORD_LIGHTNING_MAIN); + __TABLE_FX * pFxTail = s_pTbl_FXSource->Find(FXID_SWORD_LIGHTNING_TAIL); - std::string szFXMain, szFXTail; - if (pFXMain) { - szFXMain = pFXMain->szFN; - } else { - szFXMain = ""; + fs::path fsFxMainFile, fsFxTailFile; + if (pFxMain) { + fsFxMainFile = pFxMain->szFile; } - if (pFXTail) { - szFXTail = pFXTail->szFN; - } else { - szFXTail = ""; + if (pFxTail) { + fsFxTailFile = pFxTail->szFile; } - pCPlug->InitFX(szFXMain, szFXTail, 0xffffffff); + pCPlug->InitFX(fsFxMainFile, fsFxTailFile, 0xffffffff); } else if ((pItemExt->byMagicOrRare == ITEM_UNIQUE && pItemExt->byDamagePoison > 0) || (pItemExt->byDamagePoison >= LIMIT_FX_DAMAGE)) // 20 추가데미지 - 독 { CN3CPlug * pCPlug = (CN3CPlug *)pPlug; - __TABLE_FX * pFXMain = s_pTbl_FXSource->Find(FXID_SWORD_POISON_MAIN); - __TABLE_FX * pFXTail = s_pTbl_FXSource->Find(FXID_SWORD_POISON_TAIL); + __TABLE_FX * pFxMain = s_pTbl_FXSource->Find(FXID_SWORD_POISON_MAIN); + __TABLE_FX * pFxTail = s_pTbl_FXSource->Find(FXID_SWORD_POISON_TAIL); - std::string szFXMain, szFXTail; - if (pFXMain) { - szFXMain = pFXMain->szFN; - } else { - szFXMain = ""; + fs::path fsFxMainFile, fsFxTailFile; + if (pFxMain) { + fsFxMainFile = pFxMain->szFile; } - if (pFXTail) { - szFXTail = pFXTail->szFN; - } else { - szFXTail = ""; + if (pFxTail) { + fsFxTailFile = pFxTail->szFile; } - pCPlug->InitFX(szFXMain, szFXTail, 0xffff00ff); + pCPlug->InitFX(fsFxMainFile, fsFxTailFile, 0xffff00ff); } } // @@ -2003,7 +1987,7 @@ CN3CPlugBase * CPlayerBase::PlugSet(e_PlugPosition ePos, const std::string & szF return pPlug; } -CN3CPart * CPlayerBase::PartSet(e_PartPosition ePos, const std::string & szFN, __TABLE_ITEM_BASIC * pItemBasic, +CN3CPart * CPlayerBase::PartSet(e_PartPosition ePos, const fs::path & fsFile, __TABLE_ITEM_BASIC * pItemBasic, __TABLE_ITEM_EXT * pItemExt) { if (ePos < PART_POS_UPPER || ePos >= PART_POS_COUNT) { __ASSERT(0, "Invalid Item Position"); @@ -2026,19 +2010,19 @@ CN3CPart * CPlayerBase::PartSet(e_PartPosition ePos, const std::string & szFN, _ { if (m_pItemPartBasics[PART_POS_LOWER]) // 하체에 아이템이 입혀있으면.. { - std::string szFN2; + fs::path fsItemFile; e_PartPosition ePartPos2 = PART_POS_UNKNOWN; e_PlugPosition ePlugPos2 = PLUG_POS_UNKNOWN; - CGameProcedure::MakeResrcFileNameForUPC(m_pItemPartBasics[PART_POS_LOWER], &szFN2, NULL, ePartPos2, - ePlugPos2); - this->PartSet(PART_POS_LOWER, szFN2, m_pItemPartBasics[PART_POS_LOWER], + CGameProcedure::MakeResrcFileNameForUPC(m_pItemPartBasics[PART_POS_LOWER], &fsItemFile, NULL, + ePartPos2, ePlugPos2); + this->PartSet(PART_POS_LOWER, fsItemFile, m_pItemPartBasics[PART_POS_LOWER], m_pItemPartExts[PART_POS_LOWER]); // 하체에 전의 옷을 입힌다.. } else // 하체에 입고 있었던 아이템이 없다면.. { __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(m_InfoBase.eRace); // User Player Character Skin 구조체 포인터.. - this->PartSet(PART_POS_LOWER, pLooks->szPartFNs[PART_POS_LOWER], NULL, + this->PartSet(PART_POS_LOWER, pLooks->szPartFiles[PART_POS_LOWER], NULL, NULL); // 하체에 기본옷을 입힌다. } } @@ -2052,13 +2036,13 @@ CN3CPart * CPlayerBase::PartSet(e_PartPosition ePos, const std::string & szFN, _ { m_pItemPartBasics[ePos] = pItemBasic; m_pItemPartExts[ePos] = pItemExt; - return m_Chr.PartSet(ePos, ""); // 하체는 벗기고(?) 돌아간다. + return m_Chr.PartSet(ePos, fs::path()); // 하체는 벗기고(?) 돌아간다. } } } CN3CPart * pPart = NULL; - if (szFN.empty()) // 파일 이름이 없는거면.. 기본 착용.. + if (fsFile.empty()) // 파일 이름이 없는거면.. 기본 착용.. { if (PART_POS_HAIR_HELMET == ePos) { this->InitHair(); @@ -2070,21 +2054,21 @@ CN3CPart * CPlayerBase::PartSet(e_PartPosition ePos, const std::string & szFN, _ __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(m_InfoBase.eRace); // Player Character Skin 구조체 포인터.. if (pLooks) { - pPart = m_Chr.PartSet(ePos, pLooks->szPartFNs[ePos]); + pPart = m_Chr.PartSet(ePos, pLooks->szPartFiles[ePos]); if (pPart) { - pPart->TexOverlapSet(""); + pPart->TexOverlapSet(fs::path()); } } } } else { - pPart = m_Chr.PartSet(ePos, szFN); + pPart = m_Chr.PartSet(ePos, fsFile); } m_pItemPartBasics[ePos] = pItemBasic; // 아이템 적용 m_pItemPartExts[ePos] = pItemExt; if (pPart && NULL == pItemBasic && NULL == pItemExt) { - pPart->TexOverlapSet(""); // 기본 착용이면.. + pPart->TexOverlapSet(fs::path()); // 기본 착용이면.. } return pPart; @@ -2117,15 +2101,16 @@ void CPlayerBase::DurabilitySet(e_ItemSlot eSlot, int iDurability) { return; } - int iPercentage = iDurability * 100 / iDuMax; - std::string szFN; + int iPercentage = iDurability * 100 / iDuMax; + + fs::path fsTexFile; if (iPercentage <= 30) { - szFN = "Misc\\Dust_Hard.dxt"; + fsTexFile = fs::path("Misc") / "dust_hard.dxt"; } else if (iPercentage <= 70) { - szFN = "Misc\\Dust_Soft.dxt"; + fsTexFile = fs::path("Misc") / "dust_soft.dxt"; } - pPlug->TexOverlapSet(szFN); + pPlug->TexOverlapSet(fsTexFile); } else if (ITEM_SLOT_UPPER == eSlot) { ePartPos = PART_POS_UPPER; } else if (ITEM_SLOT_LOWER == eSlot) { @@ -2146,15 +2131,15 @@ void CPlayerBase::DurabilitySet(e_ItemSlot eSlot, int iDurability) { m_pItemPartExts[ePartPos]->siMaxDurability; // 기본내구력 + 확장 내구력 int iPercentage = iDurability * 100 / iDuMax; - std::string szFN; + fs::path fsTexFile; if (iPercentage <= 30) { - szFN = "Misc\\Dust_Hard.dxt"; + fsTexFile = fs::path("Misc") / "dust_hard.dxt"; } else if (iPercentage <= 70) { - szFN = "Misc\\Dust_Soft.dxt"; + fsTexFile = fs::path("Misc") / "dust_soft.dxt"; } - pPart->TexOverlapSet(szFN); + pPart->TexOverlapSet(fsTexFile); } else { - pPart->TexOverlapSet(""); + pPart->TexOverlapSet(fs::path()); } } else { __ASSERT(0, "Invalid Item Position"); @@ -2169,8 +2154,8 @@ bool CPlayerBase::InitChr(__TABLE_PLAYER_LOOKS * pTbl) { m_pLooksRef = pTbl; - m_Chr.JointSet(pTbl->szJointFN); - m_Chr.AniCtrlSet(pTbl->szAniFN); + m_Chr.JointSet(pTbl->szJointFile); + m_Chr.AniCtrlSet(pTbl->szAniFile); if (RACE_NPC != m_InfoBase.eRace) // 상,하체 따로 놀 준비.. { diff --git a/src/game/PlayerBase.h b/src/game/PlayerBase.h index 01ef67f3..809b03f6 100644 --- a/src/game/PlayerBase.h +++ b/src/game/PlayerBase.h @@ -259,9 +259,9 @@ class CPlayerBase : public CGameBase { virtual void InitFace(){}; CN3CPart * Part(e_PartPosition ePos) { return m_Chr.Part(ePos); } CN3CPlugBase * Plug(e_PlugPosition ePos) { return m_Chr.Plug(ePos); } - virtual CN3CPart * PartSet(e_PartPosition ePos, const std::string & szFN, __TABLE_ITEM_BASIC * pItemBasic, + virtual CN3CPart * PartSet(e_PartPosition ePos, const fs::path & fsFile, __TABLE_ITEM_BASIC * pItemBasic, __TABLE_ITEM_EXT * pItemExt); - virtual CN3CPlugBase * PlugSet(e_PlugPosition ePos, const std::string & szFN, __TABLE_ITEM_BASIC * pItemBasic, + virtual CN3CPlugBase * PlugSet(e_PlugPosition ePos, const fs::path & fsFile, __TABLE_ITEM_BASIC * pItemBasic, __TABLE_ITEM_EXT * pItemExt); virtual void DurabilitySet(e_ItemSlot eSlot, int iDurability); diff --git a/src/game/PlayerMySelf.cpp b/src/game/PlayerMySelf.cpp index 84a6050e..13b28d79 100644 --- a/src/game/PlayerMySelf.cpp +++ b/src/game/PlayerMySelf.cpp @@ -554,7 +554,7 @@ void CPlayerMySelf::InventoryChrAnimationInitialize() { m_ChrInv.Tick(); // 한번 해준다.. } -CN3CPlugBase * CPlayerMySelf::PlugSet(e_PlugPosition ePos, const std::string & szFN, __TABLE_ITEM_BASIC * pItemBasic, +CN3CPlugBase * CPlayerMySelf::PlugSet(e_PlugPosition ePos, const fs::path & fsFile, __TABLE_ITEM_BASIC * pItemBasic, __TABLE_ITEM_EXT * pItemExt) { int iJoint = 0; if (PLUG_POS_RIGHTHAND == ePos) { @@ -581,7 +581,7 @@ CN3CPlugBase * CPlayerMySelf::PlugSet(e_PlugPosition ePos, const std::string & s __ASSERT(0, "Invalid Plug Item position"); } - CN3CPlugBase * pPlug = m_ChrInv.PlugSet(ePos, szFN); + CN3CPlugBase * pPlug = m_ChrInv.PlugSet(ePos, fsFile); if (NULL == pPlug) { return NULL; } @@ -600,10 +600,10 @@ CN3CPlugBase * CPlayerMySelf::PlugSet(e_PlugPosition ePos, const std::string & s // } this->SetSoundPlug(pItemBasic); - return CPlayerBase::PlugSet(ePos, szFN, pItemBasic, pItemExt); + return CPlayerBase::PlugSet(ePos, fsFile, pItemBasic, pItemExt); } -CN3CPart * CPlayerMySelf::PartSet(e_PartPosition ePos, const std::string & szFN, __TABLE_ITEM_BASIC * pItemBasic, +CN3CPart * CPlayerMySelf::PartSet(e_PartPosition ePos, const fs::path & fsFile, __TABLE_ITEM_BASIC * pItemBasic, __TABLE_ITEM_EXT * pItemExt) { if (ePos < PART_POS_UPPER || ePos >= PART_POS_COUNT) { __ASSERT(0, "Invalid Item Position"); @@ -617,8 +617,8 @@ CN3CPart * CPlayerMySelf::PartSet(e_PartPosition ePos, const std::string & szFN, if (pItemBasic->byIsRobeType && m_Chr.Part(PART_POS_LOWER)) // 로브 타입의 통짜 윗옷이고 아래에 뭔가 입고 있으면.. { - m_ChrInv.PartSet(PART_POS_LOWER, ""); // 아래를 비워준다.. - m_Chr.PartSet(PART_POS_LOWER, ""); + m_ChrInv.PartSet(PART_POS_LOWER, fs::path()); // 아래를 비워준다.. + m_Chr.PartSet(PART_POS_LOWER, fs::path()); } } else // 상체를 벗는 경우 { @@ -626,20 +626,20 @@ CN3CPart * CPlayerMySelf::PartSet(e_PartPosition ePos, const std::string & szFN, { if (m_pItemPartBasics[PART_POS_LOWER]) // 하체에 아이템이 입혀있으면.. { - std::string szFN2; + fs::path fsItemFile; e_PartPosition ePartPos2 = PART_POS_UNKNOWN; e_PlugPosition ePlugPos2 = PLUG_POS_UNKNOWN; - CGameProcedure::MakeResrcFileNameForUPC(m_pItemPartBasics[PART_POS_LOWER], &szFN2, NULL, ePartPos2, - ePlugPos2); + CGameProcedure::MakeResrcFileNameForUPC(m_pItemPartBasics[PART_POS_LOWER], &fsItemFile, NULL, + ePartPos2, ePlugPos2); - m_ChrInv.PartSet(PART_POS_LOWER, szFN2); // 하체에 전의 옷을 입힌다.. - m_Chr.PartSet(PART_POS_LOWER, szFN2); + m_ChrInv.PartSet(PART_POS_LOWER, fsItemFile); // 하체에 전의 옷을 입힌다.. + m_Chr.PartSet(PART_POS_LOWER, fsItemFile); } else // 하체에 입고 있었던 아이템이 없다면.. { __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(m_InfoBase.eRace); // User Player Character Skin 구조체 포인터.. - m_ChrInv.PartSet(PART_POS_LOWER, pLooks->szPartFNs[PART_POS_LOWER]); // 하체에 기본옷을 입힌다. - m_Chr.PartSet(PART_POS_LOWER, pLooks->szPartFNs[PART_POS_LOWER]); // 하체에 기본옷을 입힌다. + m_ChrInv.PartSet(PART_POS_LOWER, pLooks->szPartFiles[PART_POS_LOWER]); // 하체에 기본옷을 입힌다. + m_Chr.PartSet(PART_POS_LOWER, pLooks->szPartFiles[PART_POS_LOWER]); // 하체에 기본옷을 입힌다. } } } @@ -651,14 +651,14 @@ CN3CPart * CPlayerMySelf::PartSet(e_PartPosition ePos, const std::string & szFN, { m_pItemPartBasics[ePos] = pItemBasic; // 아이템 적용 m_pItemPartExts[ePos] = pItemExt; - m_ChrInv.PartSet(ePos, ""); - m_Chr.PartSet(ePos, ""); // 하체는 벗기고(?).. - return NULL; // 돌아간다. + m_ChrInv.PartSet(ePos, fs::path()); + m_Chr.PartSet(ePos, fs::path()); // 하체는 벗기고(?).. + return NULL; // 돌아간다. } } CN3CPart * pPart = NULL; - if (szFN.empty()) // 파일 이름이 없는거면.. 기본 착용.. + if (fsFile.empty()) // 파일 이름이 없는거면.. 기본 착용.. { if (PART_POS_HAIR_HELMET == ePos) { this->InitHair(); @@ -670,16 +670,16 @@ CN3CPart * CPlayerMySelf::PartSet(e_PartPosition ePos, const std::string & szFN, __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(m_InfoBase.eRace); // Player Character Skin 구조체 포인터.. if (pLooks) { - m_ChrInv.PartSet(ePos, pLooks->szPartFNs[ePos]); - pPart = m_Chr.PartSet(ePos, pLooks->szPartFNs[ePos]); + m_ChrInv.PartSet(ePos, pLooks->szPartFiles[ePos]); + pPart = m_Chr.PartSet(ePos, pLooks->szPartFiles[ePos]); if (pPart) { - pPart->TexOverlapSet(""); + pPart->TexOverlapSet(fs::path()); } } } } else { - m_ChrInv.PartSet(ePos, szFN); - pPart = m_Chr.PartSet(ePos, szFN); + m_ChrInv.PartSet(ePos, fsFile); + pPart = m_Chr.PartSet(ePos, fsFile); } m_pItemPartBasics[ePos] = pItemBasic; // 아이템 적용 @@ -691,8 +691,8 @@ CN3CPart * CPlayerMySelf::PartSet(e_PartPosition ePos, const std::string & szFN, bool CPlayerMySelf::InitChr(__TABLE_PLAYER_LOOKS * pTbl) { CPlayerBase::InitChr(pTbl); - m_ChrInv.JointSet(pTbl->szJointFN); - m_ChrInv.AniCtrlSet(pTbl->szAniFN); + m_ChrInv.JointSet(pTbl->szJointFile); + m_ChrInv.AniCtrlSet(pTbl->szAniFile); float fScale = 2.1f / m_Chr.Height(); m_ChrInv.ScaleSet(fScale, fScale, fScale); // 인벤토리 창에 들어가게 크기를 줄여준다.. @@ -933,26 +933,22 @@ bool CPlayerMySelf::CheckCollision() { void CPlayerMySelf::InitFace() { __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(m_InfoBase.eRace); - if (pLooks && !pLooks->szPartFNs[PART_POS_FACE].empty()) // 아이템이 있고 얼굴 이름이 있으면.. - { - char szBuff[256] = "", szDir[128] = "", szFName[128] = "", szExt[16] = ""; - ::_splitpath(pLooks->szPartFNs[PART_POS_FACE].c_str(), NULL, szDir, szFName, szExt); - sprintf(szBuff, "%s%s%.2d%s", szDir, szFName, m_InfoExt.iFace, szExt); - this->PartSet(PART_POS_FACE, szBuff, NULL, NULL); + if (pLooks && !pLooks->szPartFiles[PART_POS_FACE].empty()) { // 아이템이 있고 얼굴 이름이 있으면.. + fs::path fsFile = pLooks->szPartFiles[PART_POS_FACE]; + fsFile = fsFile.parent_path() / (fsFile.stem() + std::format("{:02d}", m_InfoExt.iFace) + fsFile.extension()); + this->PartSet(PART_POS_FACE, fsFile, NULL, NULL); } } void CPlayerMySelf::InitHair() { __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(m_InfoBase.eRace); - if (pLooks && !pLooks->szPartFNs[PART_POS_HAIR_HELMET].empty()) // 아이템이 있고 얼굴 이름이 있으면.. - { - char szBuff[256] = "", szDir[128] = "", szFName[128] = "", szExt[16] = ""; - ::_splitpath(pLooks->szPartFNs[PART_POS_HAIR_HELMET].c_str(), NULL, szDir, szFName, szExt); - sprintf(szBuff, "%s%s%.2d%s", szDir, szFName, m_InfoExt.iHair, szExt); - this->PartSet(PART_POS_HAIR_HELMET, szBuff, NULL, NULL); + if (pLooks && !pLooks->szPartFiles[PART_POS_HAIR_HELMET].empty()) { // 아이템이 있고 얼굴 이름이 있으면.. + fs::path fsFile = pLooks->szPartFiles[PART_POS_HAIR_HELMET]; + fsFile = fsFile.parent_path() / (fsFile.stem() + std::format("{:02d}", m_InfoExt.iHair) + fsFile.extension()); + this->PartSet(PART_POS_HAIR_HELMET, fsFile, NULL, NULL); } else { - m_Chr.PartSet(PART_POS_HAIR_HELMET, ""); - m_ChrInv.PartSet(PART_POS_HAIR_HELMET, ""); + m_Chr.PartSet(PART_POS_HAIR_HELMET, fs::path()); + m_ChrInv.PartSet(PART_POS_HAIR_HELMET, fs::path()); } } diff --git a/src/game/PlayerMySelf.h b/src/game/PlayerMySelf.h index 73c5b000..797b107e 100644 --- a/src/game/PlayerMySelf.h +++ b/src/game/PlayerMySelf.h @@ -60,9 +60,9 @@ class CPlayerMySelf : public CPlayerBase { bool CheckCollision(); // 움직이는 처리와 충돌체크를 한다. 충돌되는게 있으면 움직이지 않는다. //.. bool InitChr(__TABLE_PLAYER_LOOKS * pTblUPC); - CN3CPart * PartSet(e_PartPosition ePos, const std::string & szFN, __TABLE_ITEM_BASIC * pItemBasic, + CN3CPart * PartSet(e_PartPosition ePos, const fs::path & fsFile, __TABLE_ITEM_BASIC * pItemBasic, __TABLE_ITEM_EXT * pItemExt); - CN3CPlugBase * PlugSet(e_PlugPosition ePos, const std::string & szFN, __TABLE_ITEM_BASIC * pItemBasic, + CN3CPlugBase * PlugSet(e_PlugPosition ePos, const fs::path & fsFile, __TABLE_ITEM_BASIC * pItemBasic, __TABLE_ITEM_EXT * pItemExt); void Tick(); diff --git a/src/game/PlayerOther.cpp b/src/game/PlayerOther.cpp index 6143f768..5be7fd65 100644 --- a/src/game/PlayerOther.cpp +++ b/src/game/PlayerOther.cpp @@ -49,7 +49,7 @@ bool CPlayerOther::Init(e_Race eRace, int iFace, int iHair, DWORD * pdwItemIDs, this->InitChr(pLooks); // 관절 세팅.. for (int i = 0; i < MAX_ITEM_SLOT_OPC; i++) { - std::string szFN; + fs::path fsItemFile; e_PartPosition ePart = PART_POS_UNKNOWN; e_PlugPosition ePlug = PLUG_POS_UNKNOWN; e_ItemSlot eSlot = ITEM_SLOT_UNKNOWN; @@ -59,22 +59,25 @@ bool CPlayerOther::Init(e_Race eRace, int iFace, int iHair, DWORD * pdwItemIDs, if (0 == pdwItemIDs[i]) { if (0 == i) { ePart = PART_POS_UPPER; - szFN = pLooks->szPartFNs[0]; + fsItemFile = pLooks->szPartFiles[0]; } else if (1 == i) { ePart = PART_POS_LOWER; - szFN = pLooks->szPartFNs[1]; - } - // else if(2 == i) { ePart = PART_POS_HAIR_HELMET; szFN = pLooks->szPartFNs[5]; } - else if (3 == i) { + fsItemFile = pLooks->szPartFiles[1]; + //} else if (2 == i) { + // ePart = PART_POS_HAIR_HELMET; + // fsItemFile = pLooks->szPartFiles[5]; + } else if (3 == i) { ePart = PART_POS_HANDS; - szFN = pLooks->szPartFNs[3]; + fsItemFile = pLooks->szPartFiles[3]; } else if (4 == i) { ePart = PART_POS_FEET; - szFN = pLooks->szPartFNs[4]; + fsItemFile = pLooks->szPartFiles[4]; } else if (5 == i) { - } // 망토 - // else if(6 == i) { ePlug = PLUG_POS_RIGHTHAND; } - // else if(7 == i) { ePlug = PLUG_POS_LEFTHAND; } + //} else if (6 == i) { + // ePlug = PLUG_POS_RIGHTHAND; + //} else if (7 == i) { + // ePlug = PLUG_POS_LEFTHAND; + } } else { pItem = s_pTbl_Items_Basic->Find(pdwItemIDs[i] / 1000 * 1000); // 유저 플레이어 아이템 얻기.. if (pItem && pItem->byExtIndex >= 0 && pItem->byExtIndex < MAX_ITEM_EXTENSION) { @@ -85,7 +88,7 @@ bool CPlayerOther::Init(e_Race eRace, int iFace, int iHair, DWORD * pdwItemIDs, continue; } - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, &szFN, NULL, ePart, + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, &fsItemFile, NULL, ePart, ePlug); // 리소스 파일 이름을 만들고.. if (0 == i) { @@ -115,13 +118,13 @@ bool CPlayerOther::Init(e_Race eRace, int iFace, int iHair, DWORD * pdwItemIDs, } if (PART_POS_UPPER == ePart || PART_POS_LOWER == ePart || PART_POS_HANDS == ePart || PART_POS_FEET == ePart) { - this->PartSet(ePart, szFN, pItem, pItemExt); + this->PartSet(ePart, fsItemFile, pItem, pItemExt); } else if (PART_POS_HAIR_HELMET == ePart) // 머리카락 혹은 헬멧이면.. { - this->PartSet(ePart, szFN, pItem, pItemExt); + this->PartSet(ePart, fsItemFile, pItem, pItemExt); } else if (5 == i) { } else if ((6 == i || 7 == i) && PLUG_POS_UNKNOWN != ePlug) { - this->PlugSet(ePlug, szFN, pItem, pItemExt); + this->PlugSet(ePlug, fsItemFile, pItem, pItemExt); } if (ITEM_SLOT_UNKNOWN != eSlot) { @@ -132,7 +135,7 @@ bool CPlayerOther::Init(e_Race eRace, int iFace, int iHair, DWORD * pdwItemIDs, // 얼굴은 따로하자.. this->InitFace(); CN3CPart * pPartHairHelmet = this->Part(PART_POS_HAIR_HELMET); - if (pPartHairHelmet->FileName().empty()) { // 헬멧에 해당되는게 없으면.. 머리카락 붙이기.. + if (pPartHairHelmet->FilePath().empty()) { // 헬멧에 해당되는게 없으면.. 머리카락 붙이기.. this->InitHair(); } @@ -141,25 +144,21 @@ bool CPlayerOther::Init(e_Race eRace, int iFace, int iHair, DWORD * pdwItemIDs, void CPlayerOther::InitFace() { __TABLE_PLAYER_LOOKS * pItem = s_pTbl_UPC_Looks->Find(m_InfoBase.eRace); - if (pItem && !pItem->szPartFNs[PART_POS_FACE].empty()) // 아이템이 있고 얼굴 이름이 있으면.. - { - char szBuff[256] = "", szDir[128] = "", szFName[128] = "", szExt[16] = ""; - ::_splitpath(pItem->szPartFNs[PART_POS_FACE].c_str(), NULL, szDir, szFName, szExt); - sprintf(szBuff, "%s%s%.2d%s", szDir, szFName, m_InfoExt.iFace, szExt); - this->PartSet(PART_POS_FACE, szBuff, NULL, NULL); + if (pItem && !pItem->szPartFiles[PART_POS_FACE].empty()) { // 아이템이 있고 얼굴 이름이 있으면.. + fs::path fsFile = pItem->szPartFiles[PART_POS_FACE]; + fsFile = fsFile.parent_path() / (fsFile.stem() + std::format("{:02d}", m_InfoExt.iFace) + fsFile.extension()); + this->PartSet(PART_POS_FACE, fsFile, NULL, NULL); } } void CPlayerOther::InitHair() { __TABLE_PLAYER_LOOKS * pItem = s_pTbl_UPC_Looks->Find(m_InfoBase.eRace); - if (pItem && !pItem->szPartFNs[PART_POS_HAIR_HELMET].empty()) // 아이템이 있고 얼굴 이름이 있으면.. - { - char szBuff[256] = "", szDir[128] = "", szFName[128] = "", szExt[16] = ""; - ::_splitpath(pItem->szPartFNs[PART_POS_HAIR_HELMET].c_str(), NULL, szDir, szFName, szExt); - sprintf(szBuff, "%s%s%.2d%s", szDir, szFName, m_InfoExt.iHair, szExt); - this->PartSet(PART_POS_HAIR_HELMET, szBuff, NULL, NULL); + if (pItem && !pItem->szPartFiles[PART_POS_HAIR_HELMET].empty()) { // 아이템이 있고 얼굴 이름이 있으면.. + fs::path fsFile = pItem->szPartFiles[PART_POS_HAIR_HELMET]; + fsFile = fsFile.parent_path() / (fsFile.stem() + std::format("{:02d}", m_InfoExt.iHair) + fsFile.extension()); + this->PartSet(PART_POS_HAIR_HELMET, fsFile, NULL, NULL); } else { - m_Chr.PartSet(PART_POS_HAIR_HELMET, ""); + m_Chr.PartSet(PART_POS_HAIR_HELMET, fs::path()); } } diff --git a/src/game/PortalVolume.cpp b/src/game/PortalVolume.cpp index eaf116d9..0b220cba 100644 --- a/src/game/PortalVolume.cpp +++ b/src/game/PortalVolume.cpp @@ -312,11 +312,8 @@ void CPortalVolume::RenderCollision() { bool CPortalVolume::Load(HANDLE hFile) { CN3Transform::Load(hFile); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - // 자신의 데이터 로드.. - DWORD dwNum; - std::string strSrc, strDest; + DWORD dwNum; // 링크된 갯수를 로드.. 일단 읽구 버린다.. int iLinkedCount = 0, iTID, iEWT; @@ -334,20 +331,17 @@ bool CPortalVolume::Load(HANDLE hFile) { ReadFile(hFile, &pSI->m_iID, sizeof(int), &dwNum, NULL); // 문자열 길이.. - strSrc = CPvsMgr::ReadDecryptString(hFile); - _splitpath(strSrc.c_str(), szDrive, szDir, szFName, szExt); - strDest = szFName; - strDest += szExt; - pSI->m_strShapeFile = m_pManager->GetIndoorFolderPath() + strDest; + fs::path fsSrcFile = CPvsMgr::ReadDecryptString(hFile); + pSI->m_fsShapeFile = m_pManager->GetIndoorFolderPath() / fsSrcFile.filename(); ReadFile(hFile, &pSI->m_iBelong, sizeof(int), &dwNum, NULL); ReadFile(hFile, &pSI->m_iEventID, sizeof(int), &dwNum, NULL); ReadFile(hFile, &pSI->m_iEventType, sizeof(int), &dwNum, NULL); ReadFile(hFile, &pSI->m_iNPC_ID, sizeof(int), &dwNum, NULL); ReadFile(hFile, &pSI->m_iNPC_Status, sizeof(int), &dwNum, NULL); if (pSI->m_iEventID || pSI->m_iEventType || pSI->m_iNPC_ID || pSI->m_iNPC_Status) { // 이벤트가 있으면 - pSI->m_pShape = CPvsMgr::s_MngShapeExt.Get(m_pManager->GetIndoorFolderPath() + strDest); + pSI->m_pShape = CPvsMgr::s_MngShapeExt.Get(pSI->m_fsShapeFile); } else { - pSI->m_pShape = CPvsMgr::s_MngShape.Get(m_pManager->GetIndoorFolderPath() + strDest); + pSI->m_pShape = CPvsMgr::s_MngShape.Get(pSI->m_fsShapeFile); } __ASSERT(pSI->m_pShape, "Shape Not Found"); pSI->Load(hFile); diff --git a/src/game/PortalVolume.h b/src/game/PortalVolume.h index 92100e72..d6623bd9 100644 --- a/src/game/PortalVolume.h +++ b/src/game/PortalVolume.h @@ -7,7 +7,6 @@ #include "N3Base/N3Base.h" #include "N3Base/N3Shape.h" -#define INDOOR_FOLDER "N3Indoor\\" const float fBaseVolumnSize = 1.0f; enum e_ExtBool { @@ -20,8 +19,8 @@ class CPortalVolume; ////////////////////////////////////////////////////////////////// typedef struct tagShapeInfo : public CN3Transform { - int m_iID; - std::string m_strShapeFile; + int m_iID; + fs::path m_fsShapeFile; int m_iBelong; // 소속 - 0:소속 없음 1:엘모라드 2:카루스 3:?? .... int m_iEventID; // Event ID @@ -34,7 +33,6 @@ typedef struct tagShapeInfo : public CN3Transform { //.. tagShapeInfo() { m_iID = -1; - m_strShapeFile = ""; m_pShape = NULL; m_iBelong = 0; @@ -46,7 +44,7 @@ typedef struct tagShapeInfo : public CN3Transform { const tagShapeInfo & operator=(const tagShapeInfo & si) { m_iID = si.m_iID; - m_strShapeFile = si.m_strShapeFile; + m_fsShapeFile = si.m_fsShapeFile; m_pShape = si.m_pShape; m_iBelong = si.m_iBelong; m_iEventID = si.m_iEventID; diff --git a/src/game/PvsMgr.cpp b/src/game/PvsMgr.cpp index d0bbd7cc..746ca711 100644 --- a/src/game/PvsMgr.cpp +++ b/src/game/PvsMgr.cpp @@ -12,8 +12,6 @@ #include "N3Base/N3Camera.h" #include "N3Base/N3ShapeMgr.h" -#define INDOOR_FOLDER "N3Indoor\\" - CN3Mng CPvsMgr::s_MngShape; CN3Mng CPvsMgr::s_MngShapeExt; std::list CPvsMgr::s_plShapeInfoList; @@ -23,7 +21,7 @@ std::list CPvsMgr::s_plShapeInfoList; ////////////////////////////////////////////////////////////////////// CPvsMgr::CPvsMgr() - : m_IndoorFolder("N3Indoor\\") + : m_fsIndoorDir("N3Indoor") , m_fVolumeOffs(0.6f) //.. { s_plShapeInfoList.clear(); @@ -135,16 +133,14 @@ bool CPvsMgr::Load(HANDLE hFile) { } // N3Scene 화일.. 안쓴다.. -.-; - std::string strSrc = ReadDecryptString(hFile), strDest; + fs::path fsSrcFile = ReadDecryptString(hFile); // 전체 이동값.. 안슨다.. -.-; ReadFile(hFile, &iT, sizeof(int), &dwNum, NULL); ReadFile(hFile, &iT, sizeof(int), &dwNum, NULL); ReadFile(hFile, &iT, sizeof(int), &dwNum, NULL); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - int iCount; - + int iCount; ReadFile(hFile, &iCount, sizeof(int), &dwNum, NULL); for (int i = 0; i < iCount; i++) { @@ -152,12 +148,9 @@ bool CPvsMgr::Load(HANDLE hFile) { ReadFile(hFile, &pSI->m_iID, sizeof(int), &dwNum, NULL); // 문자열 길이.. - strSrc = ReadDecryptString(hFile); - _splitpath(strSrc.c_str(), szDrive, szDir, szFName, szExt); - strDest = szFName; - strDest += szExt; - pSI->m_strShapeFile = m_IndoorFolder + strDest; - pSI->m_pShape = s_MngShape.Get(m_IndoorFolder + strDest); + fsSrcFile = ReadDecryptString(hFile); + pSI->m_fsShapeFile = m_fsIndoorDir / fsSrcFile.filename(); + pSI->m_pShape = s_MngShape.Get(pSI->m_fsShapeFile); __ASSERT(pSI->m_pShape, "Shape Not Found"); ReadFile(hFile, &pSI->m_iBelong, sizeof(int), &dwNum, NULL); @@ -227,16 +220,20 @@ CPortalVolume * CPvsMgr::GetPortalVolPointerByID(int iID) { std::string CPvsMgr::ReadDecryptString(HANDLE hFile) { DWORD dwNum; - int iCount; - ReadFile(hFile, &iCount, sizeof(int), &dwNum, NULL); - std::vector buffer(iCount, 0); - ReadFile(hFile, &buffer[0], iCount, &dwNum, NULL); // string - for (int i = 0; i < iCount; i++) { - buffer[i] ^= CRY_KEY; + int iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); + + std::string szStr; + if (iLen > 0) { + szStr.assign(iLen, '\0'); + ReadFile(hFile, szStr.data(), iLen, &dwNum, NULL); + for (int i = 0; i < iLen; i++) { + szStr[i] ^= CRY_KEY; + } } - return std::string(buffer.begin(), buffer.end()); + return szStr; } ////////////////////////////////////////////////////////////////////////////////// @@ -436,4 +433,4 @@ CN3Shape * CPvsMgr::ShapeGetByIDWithShape(int iID) { } return m_pCurVol->ShapeGetByIDWithShape(iID); -} \ No newline at end of file +} diff --git a/src/game/PvsMgr.h b/src/game/PvsMgr.h index 24cb59a0..667294fb 100644 --- a/src/game/PvsMgr.h +++ b/src/game/PvsMgr.h @@ -20,8 +20,8 @@ class CPvsMgr : public CN3BaseFileAccess { friend class CDungeonManager; friend class CPortalVolume; - const std::string m_IndoorFolder; - const float m_fVolumeOffs; // Volume 체크 높이.. + const fs::path m_fsIndoorDir; + const float m_fVolumeOffs; // Volume 체크 높이.. std::list m_pPvsList; @@ -42,7 +42,7 @@ class CPvsMgr : public CN3BaseFileAccess { // String Cryptograph.. ^^ static std::string ReadDecryptString(HANDLE hFile); - std::string GetIndoorFolderPath() { return m_IndoorFolder; } + const fs::path & GetIndoorFolderPath() { return m_fsIndoorDir; } CPortalVolume * GetPortalVolPointerByID(int iID); diff --git a/src/game/SubProcPerTrade.cpp b/src/game/SubProcPerTrade.cpp index fe062551..8ad543ce 100644 --- a/src/game/SubProcPerTrade.cpp +++ b/src/game/SubProcPerTrade.cpp @@ -111,11 +111,12 @@ void CSubProcPerTrade::InitPerTradeDlg(CUIManager * pUIManager) { __TABLE_ITEM_BASIC * pItem = NULL; // 아이템 테이블 구조체 포인터.. pItem = s_pTbl_Items_Basic->Find(dwGold); // 열 데이터 얻기.. - std::string szIconFN; + fs::path fsIconFile; e_PartPosition ePart; e_PlugPosition ePlug; - CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 - m_pUITradeEditDlg->m_pImageOfIcon->SetTex(szIconFN); + CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, + ePlug); // 아이템에 따른 파일 이름을 만들어서 + m_pUITradeEditDlg->m_pImageOfIcon->SetTex(fsIconFile); float fUVAspect = (float)45.0f / (float)64.0f; m_pUITradeEditDlg->m_pImageOfIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); m_pUITradeEditDlg->m_pImageOfIcon->SetRegion(m_pUITradeEditDlg->m_pArea->GetRegion()); @@ -708,7 +709,7 @@ void CSubProcPerTrade::ReceiveMsgPerTradeAdd(BYTE bResult) { spItemNew = new __IconItemSkill; spItemNew->pItemBasic = spItem->pItemBasic; spItemNew->pItemExt = spItem->pItemExt; - spItemNew->szIconFN = spItem->szIconFN; // 아이콘 파일 이름 복사.. + spItemNew->fsIconFile = spItem->fsIconFile; // 아이콘 파일 이름 복사.. spItemNew->iCount = m_pUIPerTradeDlg->m_iBackupiCount; spItemNew->iDurability = spItem->iDurability; @@ -716,7 +717,7 @@ void CSubProcPerTrade::ReceiveMsgPerTradeAdd(BYTE bResult) { spItemNew->pUIIcon = new CN3UIIcon; float fUVAspect = (float)45.0f / (float)64.0f; spItemNew->pUIIcon->Init(m_pUIPerTradeDlg); - spItemNew->pUIIcon->SetTex(spItemNew->szIconFN); + spItemNew->pUIIcon->SetTex(spItemNew->fsIconFile); spItemNew->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItemNew->pUIIcon->SetUIType(UI_TYPE_ICON); spItemNew->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -863,10 +864,10 @@ void CSubProcPerTrade::ReceiveMsgPerTradeOtherAdd(int iItemID, int iCount, int i { m_pUIPerTradeDlg->m_pPerTradeOther[iDestiOrder]->iCount += iCount; } else { - std::string szIconFN; + fs::path fsIconFile; e_PartPosition ePart; e_PlugPosition ePlug; - CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 __IconItemSkill * spItem; @@ -874,13 +875,13 @@ void CSubProcPerTrade::ReceiveMsgPerTradeOtherAdd(int iItemID, int iCount, int i spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iCount; spItem->iDurability = iDurability; float fUVAspect = (float)45.0f / (float)64.0f; spItem->pUIIcon = new CN3UIIcon; spItem->pUIIcon->Init(m_pUIPerTradeDlg); - spItem->pUIIcon->SetTex(szIconFN); + spItem->pUIIcon->SetTex(fsIconFile); spItem->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItem->pUIIcon->SetUIType(UI_TYPE_ICON); spItem->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -909,10 +910,10 @@ void CSubProcPerTrade::ReceiveMsgPerTradeOtherAdd(int iItemID, int iCount, int i return; // 못 찾았으므로.. 실패.. } - std::string szIconFN; + fs::path fsIconFile; e_PartPosition ePart; e_PlugPosition ePlug; - CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 __IconItemSkill * spItem; @@ -920,13 +921,13 @@ void CSubProcPerTrade::ReceiveMsgPerTradeOtherAdd(int iItemID, int iCount, int i spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = 1; spItem->iDurability = iDurability; float fUVAspect = (float)45.0f / (float)64.0f; spItem->pUIIcon = new CN3UIIcon; spItem->pUIIcon->Init(m_pUIPerTradeDlg); - spItem->pUIIcon->SetTex(szIconFN); + spItem->pUIIcon->SetTex(fsIconFile); spItem->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItem->pUIIcon->SetUIType(UI_TYPE_ICON); spItem->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -1021,22 +1022,23 @@ void CSubProcPerTrade::ReceiveMsgPerTradeDoneItemMove(BYTE bItemPos, int iItemID return; } - std::string szIconFN; + fs::path fsIconFile; e_PartPosition ePart; e_PlugPosition ePlug; - CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 + CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, + ePlug); // 아이템에 따른 파일 이름을 만들어서 spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iCount; spItem->iDurability = iDurability; float fUVAspect = (float)45.0f / (float)64.0f; spItem->pUIIcon = new CN3UIIcon; spItem->pUIIcon->Init(m_pUIPerTradeDlg); - spItem->pUIIcon->SetTex(szIconFN); + spItem->pUIIcon->SetTex(fsIconFile); spItem->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItem->pUIIcon->SetUIType(UI_TYPE_ICON); spItem->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); diff --git a/src/game/UIDroppedItemDlg.cpp b/src/game/UIDroppedItemDlg.cpp index e3e5551e..f8ee3b7c 100644 --- a/src/game/UIDroppedItemDlg.cpp +++ b/src/game/UIDroppedItemDlg.cpp @@ -134,7 +134,7 @@ void CUIDroppedItemDlg::InitIconUpdate() { if (m_pMyDroppedItem[i]) { m_pMyDroppedItem[i]->pUIIcon = new CN3UIIcon; m_pMyDroppedItem[i]->pUIIcon->Init(this); - m_pMyDroppedItem[i]->pUIIcon->SetTex(m_pMyDroppedItem[i]->szIconFN); + m_pMyDroppedItem[i]->pUIIcon->SetTex(m_pMyDroppedItem[i]->fsIconFile); m_pMyDroppedItem[i]->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); m_pMyDroppedItem[i]->pUIIcon->SetUIType(UI_TYPE_ICON); m_pMyDroppedItem[i]->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -206,7 +206,7 @@ void CUIDroppedItemDlg::AddToItemTable(int iItemID, int iItemCount, int iOrder) __IconItemSkill * spItem; __TABLE_ITEM_BASIC * pItem = NULL; // 아이템 테이블 구조체 포인터.. __TABLE_ITEM_EXT * pItemExt = NULL; // 아이템 테이블 구조체 포인터.. - std::string szIconFN; + fs::path fsIconFile; pItem = CGameBase::s_pTbl_Items_Basic->Find(iItemID / 1000 * 1000); // 열 데이터 얻기.. if (pItem && pItem->byExtIndex >= 0 && pItem->byExtIndex < MAX_ITEM_EXTENSION) { @@ -221,7 +221,7 @@ void CUIDroppedItemDlg::AddToItemTable(int iItemID, int iItemCount, int iOrder) TRACE("Dropped item from server to ItemDlg %d \n", iItemID); e_PartPosition ePart; e_PlugPosition ePlug; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { return; @@ -230,7 +230,7 @@ void CUIDroppedItemDlg::AddToItemTable(int iItemID, int iItemCount, int iOrder) spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iItemCount; spItem->iDurability = pItem->siMaxDurability + pItemExt->siMaxDurability; @@ -242,7 +242,7 @@ void CUIDroppedItemDlg::AddToItemTableToInventory(int iItemID, int iItemCount, i __IconItemSkill * spItem; __TABLE_ITEM_BASIC * pItem = NULL; // 아이템 테이블 구조체 포인터.. __TABLE_ITEM_EXT * pItemExt = NULL; // 아이템 테이블 구조체 포인터.. - std::string szIconFN; + fs::path fsIconFile; float fUVAspect = (float)45.0f / (float)64.0f; pItem = CGameBase::s_pTbl_Items_Basic->Find(iItemID / 1000 * 1000); // 열 데이터 얻기.. @@ -258,7 +258,7 @@ void CUIDroppedItemDlg::AddToItemTableToInventory(int iItemID, int iItemCount, i TRACE("Dropped item from server to ItemDlg %d \n", iItemID); e_PartPosition ePart; e_PlugPosition ePlug; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { return; @@ -267,13 +267,13 @@ void CUIDroppedItemDlg::AddToItemTableToInventory(int iItemID, int iItemCount, i spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iItemCount; spItem->iDurability = pItem->siMaxDurability + pItemExt->siMaxDurability; spItem->pUIIcon = new CN3UIIcon; spItem->pUIIcon->Init(CGameProcedure::s_pProcMain->m_pUIInventory); - spItem->pUIIcon->SetTex(spItem->szIconFN); + spItem->pUIIcon->SetTex(spItem->fsIconFile); spItem->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItem->pUIIcon->SetUIType(UI_TYPE_ICON); spItem->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -367,7 +367,7 @@ bool CUIDroppedItemDlg::ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg) { __TABLE_ITEM_BASIC * pItem; __IconItemSkill * spItem; - std::string szIconFN; + fs::path fsIconFile; e_PartPosition ePart; e_PlugPosition ePlug; e_ItemType eType; @@ -404,7 +404,7 @@ bool CUIDroppedItemDlg::ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg) { break; } - eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 // 보낸 아이콘 배열이랑 비교.. @@ -835,4 +835,4 @@ void CUIDroppedItemDlg::SetVisibleWithNoSound(bool bVisible, bool bWork, bool bR m_bSendedIconArray[i] = false; } } -//this_ui_add_end \ No newline at end of file +//this_ui_add_end diff --git a/src/game/UIHotKeyDlg.cpp b/src/game/UIHotKeyDlg.cpp index c8438a75..597b5083 100644 --- a/src/game/UIHotKeyDlg.cpp +++ b/src/game/UIHotKeyDlg.cpp @@ -374,12 +374,12 @@ void CUIHotKeyDlg::InitIconUpdate() { spSkill->pSkill = pUSkill; // 아이콘 이름 만들기.. ^^ - spSkill->szIconFN = std::format("UI\\skillicon_{:02d}_{:d}.dxt", HD.iID % 100, HD.iID / 100); + spSkill->fsIconFile = fs::path("UI") / std::format("skillicon_{:02d}_{:d}.dxt", HD.iID % 100, HD.iID / 100); // 아이콘 로드하기.. ^^ spSkill->pUIIcon = new CN3UIIcon; spSkill->pUIIcon->Init(this); - spSkill->pUIIcon->SetTex(spSkill->szIconFN); + spSkill->pUIIcon->SetTex(spSkill->fsIconFile); spSkill->pUIIcon->SetUVRect(0, 0, 1, 1); spSkill->pUIIcon->SetUIType(UI_TYPE_ICON); spSkill->pUIIcon->SetStyle(UISTYLE_ICON_SKILL); @@ -555,7 +555,7 @@ void CUIHotKeyDlg::SetReceiveSelectedSkill(int iIndex) { // 그 다음에.. 그 자리에 m_pMyHotkey[m_iCurPage][iIndex] = CN3UIWndBase::m_sSkillSelectInfo.pSkillDoneInfo; - m_pMyHotkey[m_iCurPage][iIndex]->szIconFN = CN3UIWndBase::m_sSkillSelectInfo.pSkillDoneInfo->szIconFN; + m_pMyHotkey[m_iCurPage][iIndex]->fsIconFile = CN3UIWndBase::m_sSkillSelectInfo.pSkillDoneInfo->fsIconFile; m_pMyHotkey[m_iCurPage][iIndex]->pUIIcon->SetRegion(pArea->GetRegion()); m_pMyHotkey[m_iCurPage][iIndex]->pUIIcon->SetMoveRect(pArea->GetRegion()); m_pMyHotkey[m_iCurPage][iIndex]->pUIIcon->SetParent(this); @@ -801,13 +801,14 @@ bool CUIHotKeyDlg::ReceiveIconDrop(__IconItemSkill * spItem, POINT ptCur) { spSkill->pSkill = pUSkill; // 아이콘 이름 만들기.. ^^ - spSkill->szIconFN = std::format("UI\\skillicon_{:02d}_{:d}.dxt", spItem->pItemBasic->dwEffectID1 % 100, - spItem->pItemBasic->dwEffectID1 / 100); + spSkill->fsIconFile = + fs::path("UI") / std::format("skillicon_{:02d}_{:d}.dxt", spItem->pItemBasic->dwEffectID1 % 100, + spItem->pItemBasic->dwEffectID1 / 100); // 아이콘 로드하기.. ^^ spSkill->pUIIcon = new CN3UIIcon; spSkill->pUIIcon->Init(this); - spSkill->pUIIcon->SetTex(spSkill->szIconFN); + spSkill->pUIIcon->SetTex(spSkill->fsIconFile); spSkill->pUIIcon->SetUVRect(0, 0, 1.0f, 1.0f); spSkill->pUIIcon->SetUIType(UI_TYPE_ICON); spSkill->pUIIcon->SetStyle(UISTYLE_ICON_SKILL); diff --git a/src/game/UIImageTooltipDlg.cpp b/src/game/UIImageTooltipDlg.cpp index a8bda376..9c3118a5 100644 --- a/src/game/UIImageTooltipDlg.cpp +++ b/src/game/UIImageTooltipDlg.cpp @@ -36,7 +36,7 @@ void CUIImageTooltipDlg::Release() { void CUIImageTooltipDlg::InitPos() { for (int i = 0; i < MAX_TOOLTIP_COUNT; i++) { - m_pStr[i] = (CN3UIString *)GetChildByID(std::format("string_{}", i)); + m_pStr[i] = (CN3UIString *)GetChildByID(std::format("string_{:d}", i)); __ASSERT(m_pStr[i], "NULL UI Component!!"); } diff --git a/src/game/UIInventory.cpp b/src/game/UIInventory.cpp index dd0f60f1..c95eccb6 100644 --- a/src/game/UIInventory.cpp +++ b/src/game/UIInventory.cpp @@ -411,7 +411,7 @@ void CUIInventory::InitIconUpdate() { if (m_pMySlot[i] != NULL) { m_pMySlot[i]->pUIIcon = new CN3UIIcon; m_pMySlot[i]->pUIIcon->Init(this); - m_pMySlot[i]->pUIIcon->SetTex(m_pMySlot[i]->szIconFN); + m_pMySlot[i]->pUIIcon->SetTex(m_pMySlot[i]->fsIconFile); m_pMySlot[i]->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); m_pMySlot[i]->pUIIcon->SetUIType(UI_TYPE_ICON); m_pMySlot[i]->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -430,7 +430,7 @@ void CUIInventory::InitIconUpdate() { if (m_pMyInvWnd[i] != NULL) { m_pMyInvWnd[i]->pUIIcon = new CN3UIIcon; m_pMyInvWnd[i]->pUIIcon->Init(this); - m_pMyInvWnd[i]->pUIIcon->SetTex(m_pMyInvWnd[i]->szIconFN); + m_pMyInvWnd[i]->pUIIcon->SetTex(m_pMyInvWnd[i]->fsIconFile); m_pMyInvWnd[i]->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); m_pMyInvWnd[i]->pUIIcon->SetUIType(UI_TYPE_ICON); m_pMyInvWnd[i]->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -2224,11 +2224,11 @@ bool CUIInventory::IsValidPosFromArmToArmInverse(int iOrder) { } void CUIInventory::ItemAdd(__TABLE_ITEM_BASIC * pItem, __TABLE_ITEM_EXT * pItemExt, e_ItemSlot eSlot) { - std::string szFN; + fs::path fsItemFile; e_PartPosition ePart; e_PlugPosition ePlug; - e_ItemType eType = - CGameProcedure::MakeResrcFileNameForUPC(pItem, &szFN, NULL, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, &fsItemFile, NULL, ePart, + ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_PLUG == eType) { if (ITEM_SLOT_HAND_LEFT == eSlot) { @@ -2239,10 +2239,10 @@ void CUIInventory::ItemAdd(__TABLE_ITEM_BASIC * pItem, __TABLE_ITEM_EXT * pItemE __ASSERT(0, "Invalid Item Plug Position"); } - CGameBase::s_pPlayer->PlugSet(ePlug, szFN, pItem, pItemExt); // 플러그 셋팅.. + CGameBase::s_pPlayer->PlugSet(ePlug, fsItemFile, pItem, pItemExt); // 플러그 셋팅.. CGameBase::s_pPlayer->DurabilitySet(eSlot, m_pMySlot[eSlot]->iDurability); } else if (ITEM_TYPE_PART == eType) { - CGameBase::s_pPlayer->PartSet(ePart, szFN, pItem, pItemExt); + CGameBase::s_pPlayer->PartSet(ePart, fsItemFile, pItem, pItemExt); CGameBase::s_pPlayer->DurabilitySet(eSlot, m_pMySlot[eSlot]->iDurability); } } @@ -2273,7 +2273,7 @@ void CUIInventory::ItemDelete(__TABLE_ITEM_BASIC * pItem, __TABLE_ITEM_EXT * pIt if (PART_POS_HAIR_HELMET == ePart) { CGameBase::s_pPlayer->InitHair(); } else { - CGameBase::s_pPlayer->PartSet(ePart, pLooks->szPartFNs[ePart], NULL, NULL); + CGameBase::s_pPlayer->PartSet(ePart, pLooks->szPartFiles[ePart], NULL, NULL); } } } @@ -2364,8 +2364,8 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI e_PartPosition ePart; e_PlugPosition ePlug; - std::string szIconFN; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + fs::path fsIconFile; + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { CLogWriter::Write("MyInfo - slot - Unknown Item"); @@ -2375,7 +2375,7 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iCount; spItem->iDurability = pItem->siMaxDurability + pItemExt->siMaxDurability; m_pMySlot[iIndex] = spItem; @@ -2418,8 +2418,8 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI e_PartPosition ePart; e_PlugPosition ePlug; - std::string szIconFN; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + fs::path fsIconFile; + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { CLogWriter::Write("MyInfo - slot - Unknown Item"); @@ -2429,7 +2429,7 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iCount; spItem->iDurability = pItem->siMaxDurability + pItemExt->siMaxDurability; m_pMySlot[iIndex] = spItem; @@ -2473,8 +2473,8 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI e_PartPosition ePart; e_PlugPosition ePlug; - std::string szIconFN; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + fs::path fsIconFile; + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { CLogWriter::Write("MyInfo - slot - Unknown Item"); @@ -2484,7 +2484,7 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iCount; spItem->iDurability = pItem->siMaxDurability + pItemExt->siMaxDurability; m_pMyInvWnd[iIndex] = spItem; @@ -2527,8 +2527,8 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI e_PartPosition ePart; e_PlugPosition ePlug; - std::string szIconFN; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + fs::path fsIconFile; + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { CLogWriter::Write("MyInfo - slot - Unknown Item"); @@ -2538,14 +2538,14 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iCount; spItem->iDurability = pItem->siMaxDurability + pItemExt->siMaxDurability; m_pMyInvWnd[iIndex] = spItem; m_pMyInvWnd[iIndex]->pUIIcon = new CN3UIIcon; m_pMyInvWnd[iIndex]->pUIIcon->Init(this); - m_pMyInvWnd[iIndex]->pUIIcon->SetTex(m_pMyInvWnd[iIndex]->szIconFN); + m_pMyInvWnd[iIndex]->pUIIcon->SetTex(m_pMyInvWnd[iIndex]->fsIconFile); float fUVAspect = (float)45.0f / (float)64.0f; m_pMyInvWnd[iIndex]->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); m_pMyInvWnd[iIndex]->pUIIcon->SetUIType(UI_TYPE_ICON); diff --git a/src/game/UILogin.cpp b/src/game/UILogin.cpp index 7e60b1cc..ebf975ac 100644 --- a/src/game/UILogin.cpp +++ b/src/game/UILogin.cpp @@ -68,10 +68,10 @@ bool CUILogIn::ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg) { CGameProcedure::MessageBoxPost(szMsg, "", MB_YESNO, BEHAVIOR_EXECUTE_OPTION); } else if (pSender == m_pBtn_Join) { char szRegistrationSite[2000]{}; - auto serverIni = fs::path(CN3Base::PathGet()) / "Server.ini"; + std::string szIniFile = (CN3Base::PathGet() / "Server.ini").string(); const char * szDefaultSite = "https://github.com/ko4life-net/ko"; GetPrivateProfileString("Join", "Registration site", szDefaultSite, szRegistrationSite, - sizeof(szRegistrationSite), serverIni.string().c_str()); + sizeof(szRegistrationSite), szIniFile.c_str()); ShellExecute(NULL, "open", szRegistrationSite, NULL, NULL, SW_NORMAL); PostQuitMessage(0); return true; diff --git a/src/game/UIPerTradeDlg.cpp b/src/game/UIPerTradeDlg.cpp index 207b80fd..9ee46a00 100644 --- a/src/game/UIPerTradeDlg.cpp +++ b/src/game/UIPerTradeDlg.cpp @@ -198,9 +198,9 @@ void CUIPerTradeDlg::InitIconWnd(e_UIWND eWnd) { CN3UIWndBase::InitIconWnd(eWnd); // 내 결정 버튼 보통 상태로.. - std::string szFN = "btn_trade_my"; + std::string szName = "btn_trade_my"; CN3UIButton * pButton; - pButton = (CN3UIButton *)GetChildButtonByName(szFN); + pButton = (CN3UIButton *)GetChildButtonByName(szName); if (pButton) { pButton->SetState(UI_STATE_BUTTON_NORMAL); } @@ -242,9 +242,9 @@ void CUIPerTradeDlg::LeavePerTradeState() { m_iBackupiOrder[i] = -1; } // 내 결정 버튼 보통 상태로.. - std::string szFN = "btn_trade_my"; + std::string szName = "btn_trade_my"; CN3UIButton * pButton; - pButton = (CN3UIButton *)GetChildButtonByName(szFN); + pButton = (CN3UIButton *)GetChildButtonByName(szName); if (pButton) { pButton->SetState(UI_STATE_BUTTON_NORMAL); } @@ -265,9 +265,9 @@ void CUIPerTradeDlg::EnterPerTradeState() { } // 내 결정 버튼 보통 상태로.. - std::string szFN = "btn_trade_my"; + std::string szName = "btn_trade_my"; CN3UIButton * pButton; - pButton = (CN3UIButton *)GetChildButtonByName(szFN); + pButton = (CN3UIButton *)GetChildButtonByName(szName); if (pButton) { pButton->SetState(UI_STATE_BUTTON_NORMAL); } @@ -591,7 +591,7 @@ bool CUIPerTradeDlg::ReceiveIconDrop(__IconItemSkill * spItem, POINT ptCur) { spItemNew = new __IconItemSkill; spItemNew->pItemBasic = spItem->pItemBasic; spItemNew->pItemExt = spItem->pItemExt; - spItemNew->szIconFN = spItem->szIconFN; // 아이콘 파일 이름 복사.. + spItemNew->fsIconFile = spItem->fsIconFile; // 아이콘 파일 이름 복사.. spItemNew->iCount = 0; spItemNew->iDurability = spItem->iDurability; @@ -599,7 +599,7 @@ bool CUIPerTradeDlg::ReceiveIconDrop(__IconItemSkill * spItem, POINT ptCur) { spItemNew->pUIIcon = new CN3UIIcon; float fUVAspect = (float)45.0f / (float)64.0f; spItemNew->pUIIcon->Init(this); - spItemNew->pUIIcon->SetTex(spItemNew->szIconFN); + spItemNew->pUIIcon->SetTex(spItemNew->fsIconFile); spItemNew->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItemNew->pUIIcon->SetUIType(UI_TYPE_ICON); spItemNew->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -832,10 +832,10 @@ bool CUIPerTradeDlg::ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg) { return true; } -CN3UIBase * CUIPerTradeDlg::GetChildButtonByName(const std::string & szFN) { +CN3UIBase * CUIPerTradeDlg::GetChildButtonByName(const std::string & szName) { for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (CN3UIBase *)(*itor); - if ((pChild->UIType() == UI_TYPE_BUTTON) && (szFN.compare(pChild->m_szID) == 0)) { + if ((pChild->UIType() == UI_TYPE_BUTTON) && (szName.compare(pChild->m_szID) == 0)) { return pChild; } } diff --git a/src/game/UIPerTradeDlg.h b/src/game/UIPerTradeDlg.h index 9e45497a..d24337d2 100644 --- a/src/game/UIPerTradeDlg.h +++ b/src/game/UIPerTradeDlg.h @@ -65,7 +65,7 @@ class CUIPerTradeDlg : public CN3UIWndBase { void SendToServerItemAddMsg(uint8_t pos, int itemID, int iCount); - CN3UIBase * GetChildButtonByName(const std::string & szFN); + CN3UIBase * GetChildButtonByName(const std::string & szName); // Item Count OK.. void ItemCountOK(); diff --git a/src/game/UISkillTreeDlg.cpp b/src/game/UISkillTreeDlg.cpp index 2c039355..8e96da9c 100644 --- a/src/game/UISkillTreeDlg.cpp +++ b/src/game/UISkillTreeDlg.cpp @@ -323,12 +323,12 @@ bool CUISkillTreeDlg::ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg) { spSkillCopy = new __IconItemSkill(); spSkillCopy->pSkill = spSkill->pSkill; - spSkillCopy->szIconFN = spSkill->szIconFN; + spSkillCopy->fsIconFile = spSkill->fsIconFile; // 아이콘 로드하기.. ^^ spSkillCopy->pUIIcon = new CN3UIIcon; spSkillCopy->pUIIcon->Init(this); - spSkillCopy->pUIIcon->SetTex(spSkill->szIconFN); + spSkillCopy->pUIIcon->SetTex(spSkill->fsIconFile); spSkillCopy->pUIIcon->SetUVRect(0, 0, 1, 1); spSkillCopy->pUIIcon->SetUIType(UI_TYPE_ICON); @@ -357,12 +357,12 @@ bool CUISkillTreeDlg::ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg) { // 복사본을 만든다.. spSkillCopy = new __IconItemSkill(); spSkillCopy->pSkill = spSkill->pSkill; - spSkillCopy->szIconFN = spSkill->szIconFN; + spSkillCopy->fsIconFile = spSkill->fsIconFile; // 아이콘 로드하기.. ^^ spSkillCopy->pUIIcon = new CN3UIIcon; spSkillCopy->pUIIcon->Init(this); - spSkillCopy->pUIIcon->SetTex(spSkill->szIconFN); + spSkillCopy->pUIIcon->SetTex(spSkill->fsIconFile); spSkillCopy->pUIIcon->SetUVRect(0, 0, 1, 1); spSkillCopy->pUIIcon->SetUIType(UI_TYPE_ICON); @@ -1447,12 +1447,13 @@ void CUISkillTreeDlg::AddSkillToPage(__TABLE_UPC_SKILL * pUSkill, int iOffset) { spSkill->pSkill = pUSkill; // 아이콘 이름 만들기.. ^^ - spSkill->szIconFN = std::format("UI\\skillicon_{:02d}_{:d}.dxt", pUSkill->dwID % 100, pUSkill->dwID / 100); + spSkill->fsIconFile = + fs::path("UI") / std::format("skillicon_{:02d}_{:d}.dxt", pUSkill->dwID % 100, pUSkill->dwID / 100); // 아이콘 로드하기.. ^^ spSkill->pUIIcon = new CN3UIIcon; spSkill->pUIIcon->Init(this); - spSkill->pUIIcon->SetTex(spSkill->szIconFN); + spSkill->pUIIcon->SetTex(spSkill->fsIconFile); spSkill->pUIIcon->SetUVRect(0, 0, 1, 1); spSkill->pUIIcon->SetUIType(UI_TYPE_ICON); spSkill->pUIIcon->SetStyle(UISTYLE_ICON_SKILL); @@ -1592,12 +1593,12 @@ void CUISkillTreeDlg::SetPageInIconRegion(int iKindOf, int iPageNum) // 아이 CN3UIString * pStrName = NULL; for (int k = 0; k < MAX_SKILL_IN_PAGE; k++) { if (m_pMySkillTree[m_iCurKindOf][m_iCurSkillPage][k] != NULL) { - pStrName = (CN3UIString *)GetChildByID(std::format("string_list_{}", k)); + pStrName = (CN3UIString *)GetChildByID(std::format("string_list_{:d}", k)); __ASSERT(pStrName, "NULL UI Component!!"); pStrName->SetString(m_pMySkillTree[m_iCurKindOf][m_iCurSkillPage][k]->pSkill->szName); pStrName->SetVisible(true); } else { - pStrName = (CN3UIString *)GetChildByID(std::format("string_list_{}", k)); + pStrName = (CN3UIString *)GetChildByID(std::format("string_list_{:d}", k)); __ASSERT(pStrName, "NULL UI Component!!"); pStrName->SetVisible(false); } @@ -1612,24 +1613,24 @@ void CUISkillTreeDlg::SetPageInIconRegion(int iKindOf, int iPageNum) // 아이 } } -void CUISkillTreeDlg::AllClearImageByName(const std::string & szFN, bool bTrueOrNot) { +void CUISkillTreeDlg::AllClearImageByName(const std::string & szName, bool bTrueOrNot) { // CN3UIImage* pImage; CN3UIBase * pBase = NULL; CN3UIButton * pButton = NULL; for (int i = 0; i < 4; i++) { - pBase = GetChildBaseByName(std::format("img_{}{}", szFN, i)); + pBase = GetChildBaseByName(std::format("img_{:s}{:d}", szName, i)); if (pBase) { pBase->SetVisible(bTrueOrNot); } } - pBase = GetChildBaseByName("img_" + szFN); + pBase = GetChildBaseByName("img_" + szName); if (pBase) { pBase->SetVisible(bTrueOrNot); } for (int i = 0; i < 4; i++) { - pButton = GetChildButtonByName(std::format("btn_{}{}", szFN, i)); + pButton = GetChildButtonByName(std::format("btn_{:s}{:d}", szName, i)); if (pButton) { pButton->SetVisible(bTrueOrNot); } @@ -1709,10 +1710,10 @@ void CUISkillTreeDlg::SetPageInCharRegion() // 문자 역역에서 현재 페이 } } -CN3UIImage * CUISkillTreeDlg::GetChildImageByName(const std::string & szFN) { +CN3UIImage * CUISkillTreeDlg::GetChildImageByName(const std::string & szName) { for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (CN3UIBase *)(*itor); - if ((pChild->UIType() == UI_TYPE_IMAGE) && (szFN.compare(pChild->m_szID) == 0)) { + if ((pChild->UIType() == UI_TYPE_IMAGE) && (szName.compare(pChild->m_szID) == 0)) { return (CN3UIImage *)pChild; } } @@ -1720,10 +1721,10 @@ CN3UIImage * CUISkillTreeDlg::GetChildImageByName(const std::string & szFN) { return NULL; } -CN3UIBase * CUISkillTreeDlg::GetChildBaseByName(const std::string & szFN) { +CN3UIBase * CUISkillTreeDlg::GetChildBaseByName(const std::string & szName) { for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (CN3UIBase *)(*itor); - if (szFN.compare(pChild->m_szID) == 0) { + if (szName.compare(pChild->m_szID) == 0) { return pChild; } } @@ -1731,10 +1732,10 @@ CN3UIBase * CUISkillTreeDlg::GetChildBaseByName(const std::string & szFN) { return NULL; } -CN3UIButton * CUISkillTreeDlg::GetChildButtonByName(const std::string & szFN) { +CN3UIButton * CUISkillTreeDlg::GetChildButtonByName(const std::string & szName) { for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (CN3UIBase *)(*itor); - if ((pChild->UIType() == UI_TYPE_BUTTON) && (szFN.compare(pChild->m_szID) == 0)) { + if ((pChild->UIType() == UI_TYPE_BUTTON) && (szName.compare(pChild->m_szID) == 0)) { return (CN3UIButton *)pChild; } } @@ -1781,4 +1782,4 @@ void CUISkillTreeDlg::SetVisible(bool bVisible) { CGameProcedure::s_pUIMgr->ReFocusUI(); //this_ui } } -//this_ui_add_end \ No newline at end of file +//this_ui_add_end diff --git a/src/game/UISkillTreeDlg.h b/src/game/UISkillTreeDlg.h index f3598c11..386ddf15 100644 --- a/src/game/UISkillTreeDlg.h +++ b/src/game/UISkillTreeDlg.h @@ -45,7 +45,7 @@ class CUISkillTreeDlg : public CN3UIWndBase { int m_iCurInPageOffset[MAX_SKILL_KIND_OF]; // 스킬당 현재 페이지 옵셋.. protected: - void AllClearImageByName(const std::string & szFN, bool bTrueOrNot); + void AllClearImageByName(const std::string & szName, bool bTrueOrNot); RECT GetSampleRect(); void PageButtonInitialize(); @@ -75,9 +75,9 @@ class CUISkillTreeDlg : public CN3UIWndBase { void SetPageInIconRegion(int iKindOf, int iPageNum); // 아이콘 역역에서 현재 페이지 설정.. void SetPageInCharRegion(); // 문자 역역에서 현재 페이지 설정.. - CN3UIImage * GetChildImageByName(const std::string & szFN); - CN3UIBase * GetChildBaseByName(const std::string & szFN); - CN3UIButton * GetChildButtonByName(const std::string & szFN); + CN3UIImage * GetChildImageByName(const std::string & szName); + CN3UIBase * GetChildBaseByName(const std::string & szName); + CN3UIButton * GetChildButtonByName(const std::string & szName); void PageLeft(); void PageRight(); diff --git a/src/game/UIStateBar.cpp b/src/game/UIStateBar.cpp index 83c575e4..b2c47bd4 100644 --- a/src/game/UIStateBar.cpp +++ b/src/game/UIStateBar.cpp @@ -203,14 +203,14 @@ bool CUIStateBar::Load(HANDLE hFile) { return true; } -bool CUIStateBar::LoadMap(const std::string & szMiniMapFN, float fMapSizeX, float fMapSizeZ) { +bool CUIStateBar::LoadMiniMap(const fs::path & fsFile, float fMapSizeX, float fMapSizeZ) { m_fMapSizeX = fMapSizeX; m_fMapSizeZ = fMapSizeZ; if (NULL == m_pImage_Map) { return false; } - m_pImage_Map->SetTex(szMiniMapFN); + m_pImage_Map->SetTex(fsFile); return true; } @@ -246,7 +246,7 @@ void CUIStateBar::UpdateExp(int iExp, int iExpNext, bool bUpdateImmediately) { } if (m_pText_ExpP) { - m_pText_ExpP->SetString(std::format("{} %", iPercentage)); + m_pText_ExpP->SetString(std::format("{:d} %", iPercentage)); } } @@ -268,7 +268,7 @@ void CUIStateBar::UpdateMSP(int iMSP, int iMSPMax, bool bUpdateImmediately) { } if (m_pText_MSP) { - m_pText_MSP->SetString(std::format("{} / {}", iMSP, iMSPMax)); + m_pText_MSP->SetString(std::format("{:d} / {:d}", iMSP, iMSPMax)); } } @@ -287,7 +287,7 @@ void CUIStateBar::UpdateHP(int iHP, int iHPMax, bool bUpdateImmediately) { } if (m_pText_HP) { - m_pText_HP->SetString(std::format("{} / {}", iHP, iHPMax)); + m_pText_HP->SetString(std::format("{:d} / {:d}", iHP, iHPMax)); } } @@ -296,7 +296,7 @@ void CUIStateBar::UpdatePosition(const __Vector3 & vPos, float fYaw) { return; } - m_pText_Position->SetString(std::format("{}, {}", (int)vPos.x, (int)vPos.z)); + m_pText_Position->SetString(std::format("{:d}, {:d}", (int)vPos.x, (int)vPos.z)); // 미니맵. m_vPosPlayer = vPos; @@ -694,7 +694,9 @@ void CUIStateBar::SetSystemTimeVisibility(bool bVisible) { } void CUIStateBar::AddMagic(__TABLE_UPC_SKILL * pSkill, float fDuration) { - std::string szTexFN = std::format("UI\\skillicon_{:02d}_{:d}.dxt", pSkill->dwID % 100, pSkill->dwID / 100); + fs::path fsTexFile = + fs::path("UI") / std::format("skillicon_{:02d}_{:d}.dxt", pSkill->dwID % 100, pSkill->dwID / 100); + __DurationMagicImg * pMagicImg = new __DurationMagicImg; pMagicImg->fDuration = fDuration; pMagicImg->pIcon = new CN3UIDBCLButton; @@ -702,7 +704,7 @@ void CUIStateBar::AddMagic(__TABLE_UPC_SKILL * pSkill, float fDuration) { CN3UIDBCLButton * pIcon = pMagicImg->pIcon; pIcon->Init(this); - pIcon->SetTex(szTexFN); + pIcon->SetTex(fsTexFile); pIcon->SetTooltipText(pSkill->szName.c_str()); pIcon->SetUVRect(0, 0, 1, 1); @@ -725,7 +727,8 @@ void CUIStateBar::AddMagic(__TABLE_UPC_SKILL * pSkill, float fDuration) { } void CUIStateBar::DelMagic(__TABLE_UPC_SKILL * pSkill) { - std::string szTexFN = std::format("UI\\skillicon_{:02d}_{:d}.dxt", pSkill->dwID % 100, pSkill->dwID / 100); + fs::path fsTexFile = + fs::path("UI") / std::format("skillicon_{:02d}_{:d}.dxt", pSkill->dwID % 100, pSkill->dwID / 100); it_MagicImg it, ite, itRemove; itRemove = ite = m_pMagic.end(); @@ -733,7 +736,7 @@ void CUIStateBar::DelMagic(__TABLE_UPC_SKILL * pSkill) { __DurationMagicImg * pMagicImg = (*it); CN3UIDBCLButton * pIcon = pMagicImg->pIcon; CN3Texture * pTex = pIcon->GetTex(); - if (pTex && n3std::iequals(szTexFN, pTex->FileName())) { + if (pTex && n3std::iequals(fsTexFile, pTex->FilePath())) { itRemove = it; } if (itRemove != ite) { diff --git a/src/game/UIStateBar.h b/src/game/UIStateBar.h index 16ec1a0e..214c6b06 100644 --- a/src/game/UIStateBar.h +++ b/src/game/UIStateBar.h @@ -84,8 +84,7 @@ class CUIStateBar : public CN3UIBase { void ZoomSet(float fZoom); void PositionInfoAdd(int iID, const __Vector3 & vPos, D3DCOLOR crID, bool bDrawTop); void PositionInfoClear(); - bool LoadMap(const std::string & szMiniMapFN, float fMapSizeX, - float fMapSizeZ); // 미니맵 비트맵 파일 이름, 매의 너비 길이..(Meter); + bool LoadMiniMap(const fs::path & fsFile, float fMapSizeX, float fMapSizeZ); bool ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg); // 메시지를 받는다.. 보낸놈, msg diff --git a/src/game/UITransactionDlg.cpp b/src/game/UITransactionDlg.cpp index 99307451..a72807cb 100644 --- a/src/game/UITransactionDlg.cpp +++ b/src/game/UITransactionDlg.cpp @@ -182,7 +182,7 @@ void CUITransactionDlg::InitIconUpdate() { if (m_pMyTrade[j][i] != NULL) { m_pMyTrade[j][i]->pUIIcon = new CN3UIIcon; m_pMyTrade[j][i]->pUIIcon->Init(this); - m_pMyTrade[j][i]->pUIIcon->SetTex(m_pMyTrade[j][i]->szIconFN); + m_pMyTrade[j][i]->pUIIcon->SetTex(m_pMyTrade[j][i]->fsIconFile); m_pMyTrade[j][i]->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); m_pMyTrade[j][i]->pUIIcon->SetUIType(UI_TYPE_ICON); m_pMyTrade[j][i]->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -241,7 +241,7 @@ void CUITransactionDlg::EnterTransactionState() { } } - std::string szIconFN; + fs::path fsIconFile; __IconItemSkill * spItem = NULL; __TABLE_ITEM_BASIC * pItem = NULL; // 아이템 테이블 구조체 포인터.. __TABLE_ITEM_EXT * pItemExt = NULL; @@ -290,14 +290,14 @@ void CUITransactionDlg::EnterTransactionState() { e_PartPosition ePart; e_PlugPosition ePlug; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 __ASSERT(ITEM_TYPE_UNKNOWN != eType, "Unknown Item"); spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = 1; spItem->iDurability = pItem->siMaxDurability + pItemExt->siMaxDurability; @@ -550,7 +550,7 @@ void CUITransactionDlg::ItemCountOK() { spItemNew = new __IconItemSkill; spItemNew->pItemBasic = spItem->pItemBasic; spItemNew->pItemExt = spItem->pItemExt; - spItemNew->szIconFN = spItem->szIconFN; // 아이콘 파일 이름 복사.. + spItemNew->fsIconFile = spItem->fsIconFile; // 아이콘 파일 이름 복사.. spItemNew->iCount = iGold; spItemNew->iDurability = spItem->pItemBasic->siMaxDurability + spItem->pItemExt->siMaxDurability; @@ -558,7 +558,7 @@ void CUITransactionDlg::ItemCountOK() { spItemNew->pUIIcon = new CN3UIIcon; float fUVAspect = (float)45.0f / (float)64.0f; spItemNew->pUIIcon->Init(this); - spItemNew->pUIIcon->SetTex(spItemNew->szIconFN); + spItemNew->pUIIcon->SetTex(spItemNew->fsIconFile); spItemNew->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItemNew->pUIIcon->SetUIType(UI_TYPE_ICON); spItemNew->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -923,12 +923,12 @@ bool CUITransactionDlg::ReceiveIconDrop(__IconItemSkill * spItem, POINT ptCur) { CN3UIWndBase::m_sRecoveryJobInfo.pItemSource->pItemExt->dwID, iDestiOrder, CN3UIWndBase::m_sRecoveryJobInfo.pItemSource->iCount); - std::string szIconFN; + fs::path fsIconFile; e_PartPosition ePart; e_PlugPosition ePlug; CGameProcedure::MakeResrcFileNameForUPC( m_pMyTrade[m_iCurPage][CN3UIWndBase::m_sRecoveryJobInfo.UIWndSourceStart.iOrder]->pItemBasic, NULL, - &szIconFN, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 + &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 __IconItemSkill * spItemNew; spItemNew = new __IconItemSkill; @@ -936,7 +936,7 @@ bool CUITransactionDlg::ReceiveIconDrop(__IconItemSkill * spItem, POINT ptCur) { m_pMyTrade[m_iCurPage][CN3UIWndBase::m_sRecoveryJobInfo.UIWndSourceStart.iOrder]->pItemBasic; spItemNew->pItemExt = m_pMyTrade[m_iCurPage][CN3UIWndBase::m_sRecoveryJobInfo.UIWndSourceStart.iOrder]->pItemExt; - spItemNew->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItemNew->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItemNew->iCount = 1; spItemNew->iDurability = m_pMyTrade[m_iCurPage][CN3UIWndBase::m_sRecoveryJobInfo.UIWndSourceStart.iOrder] @@ -948,7 +948,7 @@ bool CUITransactionDlg::ReceiveIconDrop(__IconItemSkill * spItem, POINT ptCur) { spItemNew->pUIIcon = new CN3UIIcon; float fUVAspect = (float)45.0f / (float)64.0f; spItemNew->pUIIcon->Init(this); - spItemNew->pUIIcon->SetTex(szIconFN); + spItemNew->pUIIcon->SetTex(fsIconFile); spItemNew->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItemNew->pUIIcon->SetUIType(UI_TYPE_ICON); spItemNew->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -1451,10 +1451,10 @@ bool CUITransactionDlg::ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg) { return true; } -CN3UIBase * CUITransactionDlg::GetChildButtonByName(const std::string & szFN) { +CN3UIBase * CUITransactionDlg::GetChildButtonByName(const std::string & szName) { for (UIListItor itor = m_Children.begin(); m_Children.end() != itor; ++itor) { CN3UIBase * pChild = (CN3UIBase *)(*itor); - if ((pChild->UIType() == UI_TYPE_BUTTON) && (szFN.compare(pChild->m_szID) == 0)) { + if ((pChild->UIType() == UI_TYPE_BUTTON) && (szName.compare(pChild->m_szID) == 0)) { return pChild; } } diff --git a/src/game/UITransactionDlg.h b/src/game/UITransactionDlg.h index f7dc5565..751e3669 100644 --- a/src/game/UITransactionDlg.h +++ b/src/game/UITransactionDlg.h @@ -89,7 +89,7 @@ class CUITransactionDlg : public CN3UIWndBase { // 물건 구입이 서버에게 보내기전 성공.. void ReceiveItemDropByTradeSuccess(); - CN3UIBase * GetChildButtonByName(const std::string & szFN); + CN3UIBase * GetChildButtonByName(const std::string & szName); // Item Count OK.. void ItemCountOK(); diff --git a/src/game/UIVarious.cpp b/src/game/UIVarious.cpp index 17cc3d1c..a84ae92f 100644 --- a/src/game/UIVarious.cpp +++ b/src/game/UIVarious.cpp @@ -259,7 +259,7 @@ void CUIState::UpdateHP(int iVal, int iValMax) { return; } - m_pText_HP->SetString(std::format("{} / {}", iVal, iValMax)); + m_pText_HP->SetString(std::format("{:d} / {:d}", iVal, iValMax)); } void CUIState::UpdateMSP(int iVal, int iValMax) { @@ -268,7 +268,7 @@ void CUIState::UpdateMSP(int iVal, int iValMax) { return; } - m_pText_MP->SetString(std::format("{} / {}", iVal, iValMax)); + m_pText_MP->SetString(std::format("{:d} / {:d}", iVal, iValMax)); } void CUIState::UpdateExp(int iVal, int iValMax) { @@ -277,7 +277,7 @@ void CUIState::UpdateExp(int iVal, int iValMax) { return; } - m_pText_Exp->SetString(std::format("{} / {}", iVal, iValMax)); + m_pText_Exp->SetString(std::format("{:d} / {:d}", iVal, iValMax)); } void CUIState::UpdatePoints(CN3UIString * pText, int iVal, int iDelta) { @@ -287,9 +287,9 @@ void CUIState::UpdatePoints(CN3UIString * pText, int iVal, int iDelta) { if (iDelta != 0) { if (iDelta > 0) { - pText->SetString(std::format("{}(+{})", iVal, iDelta)); + pText->SetString(std::format("{:d}(+{:d})", iVal, iDelta)); } else { - pText->SetString(std::format("{}({})", iVal, iDelta)); + pText->SetString(std::format("{:d}({:d})", iVal, iDelta)); } } else { pText->SetStringAsInt(iVal); @@ -1086,9 +1086,8 @@ bool CUIFriends::Load(HANDLE hFile) { m_pBtn_Delete = (CN3UIButton *)this->GetChildByID("Btn_Delete"); __ASSERT(m_pBtn_Delete, "NULL UI Component!!"); - std::string szFN = - CGameProcedure::s_szAccount + "_" + CGameProcedure::s_szServer + ".txt"; // 파일이름은 계정_서버.txt 로 한다. - FILE * pFile = fopen(szFN.c_str(), "r"); + fs::path fsFile = CGameProcedure::s_szAccount + "_" + CGameProcedure::s_szServer + ".txt"; + FILE * pFile = _wfopen(fsFile.c_str(), L"r"); if (pFile) { char szLine[256] = ""; char * pszResult = fgets(szLine, 256, pFile); // 줄을 읽고.. @@ -1119,15 +1118,9 @@ bool CUIFriends::Load(HANDLE hFile) { return true; } -void CUIFriends::SaveListToTextFile(const std::string & szID) // 문자열이 있으면 추가하고.. 없으면 몽땅 저장.. -{ - std::string szFN = - CGameProcedure::s_szAccount + "_" + CGameProcedure::s_szServer + ".txt"; // 파일이름은 계정_서버.txt 로 한다. - char szFlags[4] = "w"; - if (!szID.empty()) { - lstrcpy(szFlags, "a"); - } - FILE * pFile = fopen(szFN.c_str(), szFlags); +void CUIFriends::SaveListToTextFile(const std::string & szID) { + fs::path fsFile = CGameProcedure::s_szAccount + "_" + CGameProcedure::s_szServer + ".txt"; + FILE * pFile = _wfopen(fsFile.c_str(), szID.empty() ? L"w" : L"a"); if (NULL == pFile) { return; } diff --git a/src/game/UIWareHouseDlg.cpp b/src/game/UIWareHouseDlg.cpp index cef05e5b..d3883dd4 100644 --- a/src/game/UIWareHouseDlg.cpp +++ b/src/game/UIWareHouseDlg.cpp @@ -208,7 +208,7 @@ void CUIWareHouseDlg::InitIconUpdate() { if (m_pMyWare[j][i] != NULL) { m_pMyWare[j][i]->pUIIcon = new CN3UIIcon; m_pMyWare[j][i]->pUIIcon->Init(this); - m_pMyWare[j][i]->pUIIcon->SetTex(m_pMyWare[j][i]->szIconFN); + m_pMyWare[j][i]->pUIIcon->SetTex(m_pMyWare[j][i]->fsIconFile); m_pMyWare[j][i]->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); m_pMyWare[j][i]->pUIIcon->SetUIType(UI_TYPE_ICON); m_pMyWare[j][i]->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -1444,12 +1444,12 @@ void CUIWareHouseDlg::ItemCountOK() { spItemNew = new __IconItemSkill; spItemNew->pItemBasic = spItem->pItemBasic; spItemNew->pItemExt = spItem->pItemExt; - spItemNew->szIconFN = spItem->szIconFN; + spItemNew->fsIconFile = spItem->fsIconFile; spItemNew->iCount = iGold; spItemNew->iDurability = spItem->iDurability; spItemNew->pUIIcon = new CN3UIIcon; spItemNew->pUIIcon->Init(this); - spItemNew->pUIIcon->SetTex(spItem->szIconFN); + spItemNew->pUIIcon->SetTex(spItem->fsIconFile); spItemNew->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItemNew->pUIIcon->SetUIType(UI_TYPE_ICON); spItemNew->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -1557,12 +1557,12 @@ void CUIWareHouseDlg::ItemCountOK() { spItemNew = new __IconItemSkill; spItemNew->pItemBasic = spItem->pItemBasic; spItemNew->pItemExt = spItem->pItemExt; - spItemNew->szIconFN = spItem->szIconFN; + spItemNew->fsIconFile = spItem->fsIconFile; spItemNew->iCount = iGold; spItemNew->iDurability = spItem->iDurability; spItemNew->pUIIcon = new CN3UIIcon; spItemNew->pUIIcon->Init(this); - spItemNew->pUIIcon->SetTex(spItem->szIconFN); + spItemNew->pUIIcon->SetTex(spItem->fsIconFile); spItemNew->pUIIcon->SetUVRect(0, 0, fUVAspect, fUVAspect); spItemNew->pUIIcon->SetUIType(UI_TYPE_ICON); spItemNew->pUIIcon->SetStyle(UISTYLE_ICON_ITEM | UISTYLE_ICON_CERTIFICATION_NEED); @@ -1676,7 +1676,7 @@ void CUIWareHouseDlg::AddItemInWare(int iItem, int iDurability, int iCount, int if (!iItem) { return; } - std::string szIconFN; + fs::path fsIconFile; __IconItemSkill * spItem = NULL; __TABLE_ITEM_BASIC * pItem = NULL; // 아이템 테이블 구조체 포인터.. __TABLE_ITEM_EXT * pItemExt = NULL; @@ -1693,7 +1693,7 @@ void CUIWareHouseDlg::AddItemInWare(int iItem, int iDurability, int iCount, int e_PartPosition ePart; e_PlugPosition ePlug; - e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &szIconFN, ePart, + e_ItemType eType = CGameProcedure::MakeResrcFileNameForUPC(pItem, NULL, &fsIconFile, ePart, ePlug); // 아이템에 따른 파일 이름을 만들어서 if (ITEM_TYPE_UNKNOWN == eType) { CLogWriter::Write("MyInfo - slot - Unknown Item"); @@ -1703,7 +1703,7 @@ void CUIWareHouseDlg::AddItemInWare(int iItem, int iDurability, int iCount, int spItem = new __IconItemSkill; spItem->pItemBasic = pItem; spItem->pItemExt = pItemExt; - spItem->szIconFN = szIconFN; // 아이콘 파일 이름 복사.. + spItem->fsIconFile = fsIconFile; // 아이콘 파일 이름 복사.. spItem->iCount = iCount; spItem->iDurability = iDurability; diff --git a/src/server/AIServer/AIServerDlg.cpp b/src/server/AIServer/AIServerDlg.cpp index 258609d5..f9e51bdc 100644 --- a/src/server/AIServer/AIServerDlg.cpp +++ b/src/server/AIServer/AIServerDlg.cpp @@ -1470,9 +1470,7 @@ void CServerDlg::DeleteUserList(int uid) { } BOOL CServerDlg::MapFileLoad() { - CFile file; - CString szFullPath, errormsg, sZoneName; - MAP * pMap = NULL; + MAP * pMap = NULL; m_sTotalMap = 0; CZoneInfoSet ZoneInfoSet; @@ -1490,24 +1488,22 @@ BOOL CServerDlg::MapFileLoad() { ZoneInfoSet.MoveFirst(); while (!ZoneInfoSet.IsEOF()) { - sZoneName = ZoneInfoSet.m_strZoneName; + std::string szSmdFileName = ZoneInfoSet.m_strZoneName.GetString(); + fs::path fsSmdFile = fs::current_path() / "AIServer_MAP" / szSmdFileName; - szFullPath.Format(".\\AIServer_MAP\\%s", sZoneName); - - if (!file.Open(szFullPath, CFile::modeRead)) { - errormsg.Format("파일 Open 실패 - %s\n", szFullPath); - AfxMessageBox(errormsg); + CFile file; + if (!file.Open(fsSmdFile.string().c_str(), CFile::modeRead)) { + AfxMessageBox(std::format("Failed to open file - {:s}", fsSmdFile.string()).c_str()); return FALSE; } pMap = new MAP; pMap->m_nServerNo = ZoneInfoSet.m_ServerNo; pMap->m_nZoneNumber = ZoneInfoSet.m_ZoneNo; - strcpy(pMap->m_MapName, (char *)(LPCTSTR)sZoneName); + pMap->m_fsSmdFileName = szSmdFileName; if (!pMap->LoadMap((HANDLE)file.m_hFile)) { - errormsg.Format("Map Load 실패 - %s\n", szFullPath); - AfxMessageBox(errormsg); + AfxMessageBox(std::format("Map Load Failed - {:s}", fsSmdFile.string()).c_str()); delete pMap; return FALSE; } @@ -1515,8 +1511,7 @@ BOOL CServerDlg::MapFileLoad() { // dungeon work if (ZoneInfoSet.m_RoomEvent > 0) { if (!pMap->LoadRoomEvent(ZoneInfoSet.m_RoomEvent)) { - errormsg.Format("Map Room Event Load 실패 - %s\n", szFullPath); - AfxMessageBox(errormsg); + AfxMessageBox(std::format("Map Room Event Load Failed - {:s}", fsSmdFile.string()).c_str()); delete pMap; return FALSE; } @@ -1873,7 +1868,8 @@ void CServerDlg::GameServerAcceptThread() { } void CServerDlg::SyncTest() { - FILE * stream = fopen("c:\\aiserver.txt", "w"); + fs::path fsFile = fs::temp_directory_path() / "AIServer.txt"; + FILE * stream = _wfopen(fsFile.c_str(), L"w"); fprintf(stream, "***** Check ... List *****\n"); diff --git a/src/server/AIServer/MAP.cpp b/src/server/AIServer/MAP.cpp index a948de3c..c655f2ee 100644 --- a/src/server/AIServer/MAP.cpp +++ b/src/server/AIServer/MAP.cpp @@ -40,7 +40,6 @@ MAP::MAP() { m_byRoomEvent = 0; m_byRoomStatus = 1; m_byInitRoomCount = 0; - memset(m_MapName, NULL, 256); m_sKarusRoom = 0; m_sElmoradRoom = 0; // for(int i=0; i=0; z--) - { - for(int x=0; x= 0; z--) { + for (int x = 0; x < m_sizeMap.cx; x++) { int v = m_pMap[x][z].m_sEvent; - fprintf(stream, "%d",v); + fprintf(stream, "%d", v); } fprintf(stream, "\n"); } - fclose(stream); */ + fclose(stream); + */ if (pEvent) { for (int i = 0; i < m_sizeMap.cx; i++) { @@ -446,21 +445,20 @@ void MAP::LoadObjectEvent(HANDLE hFile) { } BOOL MAP::LoadRoomEvent(int zone_number) { - DWORD length, count; - CString filename; - CFile pFile; - BYTE byte; - char buf[4096]; - char first[1024]; - char temp[1024]; - int index = 0; - int t_index = 0, logic = 0, exec = 0; - int event_num = 0, nation = 0; + DWORD length, count; + CFile pFile; + BYTE byte; + char buf[4096]; + char first[1024]; + char temp[1024]; + int index = 0; + int t_index = 0, logic = 0, exec = 0; + int event_num = 0, nation = 0; CRoomEvent * pEvent = NULL; - filename.Format(".\\AIServer_MAP\\%d.evt", zone_number); + fs::path fsEvtFile = fs::current_path() / "AIServer_MAP" / std::format("{:d}.evt", zone_number); - if (!pFile.Open(filename, CFile::modeRead)) { + if (!pFile.Open(fsEvtFile.string().c_str(), CFile::modeRead)) { return FALSE; } @@ -769,4 +767,4 @@ void MAP::InitializeRoom() { m_byRoomStatus = 1; m_byInitRoomCount = 0; } -} \ No newline at end of file +} diff --git a/src/server/AIServer/MAP.h b/src/server/AIServer/MAP.h index 1653fd02..f098af08 100644 --- a/src/server/AIServer/MAP.h +++ b/src/server/AIServer/MAP.h @@ -38,7 +38,7 @@ class MAP { CSize m_sizeRegion; // 맵의 resion size int m_nZoneNumber; // zone number int m_nServerNo; - char m_MapName[256]; + fs::path m_fsSmdFileName; int m_nMapSize; // Grid Unit ex) 4m float m_fUnitDist; // i Grid Distance float ** m_fHeight; diff --git a/src/server/AIServer/N3BASE/N3ShapeMgr.cpp b/src/server/AIServer/N3BASE/N3ShapeMgr.cpp index 56e33c55..739cf970 100644 --- a/src/server/AIServer/N3BASE/N3ShapeMgr.cpp +++ b/src/server/AIServer/N3BASE/N3ShapeMgr.cpp @@ -339,7 +339,7 @@ void CN3ShapeMgr::GenerateCollisionData() { if (nCPC != (nFC * 3)) { #ifdef _N3GAME CLogWriter::Write("CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤의 점갯수와 면 갯수가 다릅니다. (%s)", - m_szFileName.c_str()); + FilePath().string().c_str()); #endif this->Release(); return; @@ -528,7 +528,7 @@ void CN3ShapeMgr::GenerateCollisionData() { #ifdef _N3GAME CLogWriter::Write( "CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤 수가 너무 많습니다. (%s)", - m_szFileName.c_str()); + FilePath().string().c_str()); #endif continue; } @@ -554,14 +554,15 @@ int CN3ShapeMgr::Add(CN3Shape * pShape) { int nZ = (int)(vPos.z / CELL_MAIN_SIZE); if (nX < 0 || nX >= MAX_CELL_MAIN || nZ < 0 || nZ >= MAX_CELL_MAIN) { #ifdef _N3GAME - CLogWriter::Write("CN3ShapeMgr::Add - Shape(%s) Add Failed. Check position", pShape->FileName().c_str()); + CLogWriter::Write("CN3ShapeMgr::Add - Shape(%s) Add Failed. Check position", + pShape->FilePath().string().c_str()); #endif return -1; } pShape->SaveToFile(); // 파일로 저장하고.. CN3Shape * pShapeAdd = new CN3Shape(); - if (false == pShapeAdd->LoadFromFile(pShape->FileName())) // 이 파일을 열은 다음 + if (false == pShapeAdd->LoadFromFile(pShape->FilePath())) // 이 파일을 열은 다음 { delete pShapeAdd; return -1; diff --git a/src/server/AIServer/Npc.cpp b/src/server/AIServer/Npc.cpp index f8443794..d3dbd1dc 100644 --- a/src/server/AIServer/Npc.cpp +++ b/src/server/AIServer/Npc.cpp @@ -4812,8 +4812,8 @@ void CNpc::SendAll(CIOCPort * pIOCP, TCHAR * pBuf, int nLength) { void CNpc::NpcTrace(const std::string & szMsg) { //if(g_bDebug == FALSE) return; - TRACE(std::format("{} : uid = {}, name = {}, xpos = {}, zpos = {}", szMsg, m_sNid + NPC_BAND, m_strName, m_fCurX, - m_fCurZ) + TRACE(std::format("{:s} : uid = {:d}, name = {:s}, xpos = {:f}, zpos = {:f}", szMsg, m_sNid + NPC_BAND, m_strName, + m_fCurX, m_fCurZ) .c_str()); } diff --git a/src/server/AIServer/Server/MAP.cpp b/src/server/AIServer/Server/MAP.cpp index 1b279146..5776aed8 100644 --- a/src/server/AIServer/Server/MAP.cpp +++ b/src/server/AIServer/Server/MAP.cpp @@ -36,7 +36,6 @@ MAP::MAP() { m_ppRegion = NULL; m_nZoneNumber = 0; - memset(m_MapName, NULL, 256); } MAP::~MAP() { @@ -344,19 +343,18 @@ void MAP::LoadMapTile(HANDLE hFile) { } TRACE("move = %d\n", count); - /* FILE* stream = fopen("c:\\move1.txt", "w"); - - for(int z=m_sizeMap.cy-1; z>=0; z--) - { - for(int x=0; x= 0; z--) { + for (int x = 0; x < m_sizeMap.cx; x++) { int v = m_pMap[x][z].m_sEvent; - fprintf(stream, "%d",v); + fprintf(stream, "%d", v); } fprintf(stream, "\n"); } - fclose(stream); -*/ + fclose(stream); + */ if (pEvent) { for (int i = 0; i < m_sizeMap.cx; i++) { diff --git a/src/server/Aujard/AujardDlg.cpp b/src/server/Aujard/AujardDlg.cpp index e238a956..8231b180 100644 --- a/src/server/Aujard/AujardDlg.cpp +++ b/src/server/Aujard/AujardDlg.cpp @@ -173,23 +173,23 @@ BOOL CAujardDlg::OnInitDialog() { return FALSE; } - std::string szIniPath = (n3std::get_app_dir() / "Aujard.ini").string(); - const char * inipath = szIniPath.c_str(); + std::string szIniFile = (n3std::get_app_dir() / "Aujard.ini").string(); + const char * pszIniFile = szIniFile.c_str(); - GetPrivateProfileString("ODBC", "ACCOUNT_DSN", "kodb", m_szOdbcAccountDsn, sizeof(m_szOdbcAccountDsn), inipath); + GetPrivateProfileString("ODBC", "ACCOUNT_DSN", "kodb", m_szOdbcAccountDsn, sizeof(m_szOdbcAccountDsn), pszIniFile); GetPrivateProfileString("ODBC", "ACCOUNT_UID", "kodb_user", m_szOdbcAccountUid, sizeof(m_szOdbcAccountUid), - inipath); + pszIniFile); GetPrivateProfileString("ODBC", "ACCOUNT_PWD", "kodb_user", m_szOdbcAccountPwd, sizeof(m_szOdbcAccountPwd), - inipath); - GetPrivateProfileString("ODBC", "GAME_DSN", "kodb", m_szOdbcGameDsn, sizeof(m_szOdbcGameDsn), inipath); - GetPrivateProfileString("ODBC", "GAME_UID", "kodb_user", m_szOdbcGameUid, sizeof(m_szOdbcGameUid), inipath); - GetPrivateProfileString("ODBC", "GAME_PWD", "kodb_user", m_szOdbcGamePwd, sizeof(m_szOdbcGamePwd), inipath); - GetPrivateProfileString("ODBC", "LOG_DSN", "kodb", m_szOdbcLogDsn, sizeof(m_szOdbcLogDsn), inipath); - GetPrivateProfileString("ODBC", "LOG_UID", "kodb_user", m_szOdbcLogUid, sizeof(m_szOdbcLogUid), inipath); - GetPrivateProfileString("ODBC", "LOG_PWD", "kodb_user", m_szOdbcLogPwd, sizeof(m_szOdbcLogPwd), inipath); - - m_nServerNo = GetPrivateProfileInt("ZONE_INFO", "GROUP_INFO", 1, inipath); - m_nZoneNo = GetPrivateProfileInt("ZONE_INFO", "ZONE_INFO", 1, inipath); + pszIniFile); + GetPrivateProfileString("ODBC", "GAME_DSN", "kodb", m_szOdbcGameDsn, sizeof(m_szOdbcGameDsn), pszIniFile); + GetPrivateProfileString("ODBC", "GAME_UID", "kodb_user", m_szOdbcGameUid, sizeof(m_szOdbcGameUid), pszIniFile); + GetPrivateProfileString("ODBC", "GAME_PWD", "kodb_user", m_szOdbcGamePwd, sizeof(m_szOdbcGamePwd), pszIniFile); + GetPrivateProfileString("ODBC", "LOG_DSN", "kodb", m_szOdbcLogDsn, sizeof(m_szOdbcLogDsn), pszIniFile); + GetPrivateProfileString("ODBC", "LOG_UID", "kodb_user", m_szOdbcLogUid, sizeof(m_szOdbcLogUid), pszIniFile); + GetPrivateProfileString("ODBC", "LOG_PWD", "kodb_user", m_szOdbcLogPwd, sizeof(m_szOdbcLogPwd), pszIniFile); + + m_nServerNo = GetPrivateProfileInt("ZONE_INFO", "GROUP_INFO", 1, pszIniFile); + m_nZoneNo = GetPrivateProfileInt("ZONE_INFO", "ZONE_INFO", 1, pszIniFile); if (!m_DBAgent.DatabaseInit()) { AfxPostQuitMessage(0); diff --git a/src/server/Ebenezer/EVENT.cpp b/src/server/Ebenezer/EVENT.cpp index 4cc08cd2..4a722583 100644 --- a/src/server/Ebenezer/EVENT.cpp +++ b/src/server/Ebenezer/EVENT.cpp @@ -27,25 +27,24 @@ EVENT::~EVENT() { } BOOL EVENT::LoadEvent(int zone) { - DWORD length, count; - CString filename; - CFile pFile; - BYTE byte; - char buf[4096]; - char first[1024]; - char temp[1024]; - int index = 0; - int t_index = 0; - int event_num; + DWORD length, count; + CFile pFile; + BYTE byte; + char buf[4096]; + char first[1024]; + char temp[1024]; + int index = 0; + int t_index = 0; + int event_num; EVENT_DATA * newData = NULL; EVENT_DATA * eventData = NULL; - filename.Format(".\\Ebenezer_MAP\\%d.evt", zone); + fs::path fsEvtFile = fs::current_path() / "Ebenezer_MAP" / std::format("{:d}.evt", zone); m_Zone = zone; - if (!pFile.Open(filename, CFile::modeRead)) { + if (!pFile.Open(fsEvtFile.string().c_str(), CFile::modeRead)) { return TRUE; } diff --git a/src/server/Ebenezer/EbenezerDlg.cpp b/src/server/Ebenezer/EbenezerDlg.cpp index 819bc45f..80678016 100644 --- a/src/server/Ebenezer/EbenezerDlg.cpp +++ b/src/server/Ebenezer/EbenezerDlg.cpp @@ -1098,8 +1098,6 @@ BOOL CEbenezerDlg::InitializeMMF() { } BOOL CEbenezerDlg::MapFileLoad() { - CFile file; - CString szFullPath, errormsg, sZoneName; C3DMap * pMap = NULL; EVENT * pEvent = NULL; @@ -1119,13 +1117,14 @@ BOOL CEbenezerDlg::MapFileLoad() { ZoneInfoSet.MoveFirst(); while (!ZoneInfoSet.IsEOF()) { - sZoneName = ZoneInfoSet.m_strZoneName; - szFullPath.Format(".\\Ebenezer_MAP\\%s", sZoneName); + std::string szSmdFileName = ZoneInfoSet.m_strZoneName.GetString(); + fs::path fsSmdFile = fs::current_path() / "Ebenezer_MAP" / szSmdFileName; n3std::log_file_write("mapfile load\r\n"); - if (!file.Open(szFullPath, CFile::modeRead)) { - errormsg.Format("File Open Fail - %s\n", szFullPath); - AfxMessageBox(errormsg); + + CFile file; + if (!file.Open(fsSmdFile.string().c_str(), CFile::modeRead)) { + AfxMessageBox(std::format("File Open Fail - {:s}", fsSmdFile.string()).c_str()); return FALSE; } @@ -1133,15 +1132,14 @@ BOOL CEbenezerDlg::MapFileLoad() { pMap->m_nServerNo = ZoneInfoSet.m_ServerNo; pMap->m_nZoneNumber = ZoneInfoSet.m_ZoneNo; - strcpy(pMap->m_MapName, (char *)(LPCTSTR)sZoneName); + pMap->m_fsSmdFileName = szSmdFileName; pMap->m_fInitX = (float)(ZoneInfoSet.m_InitX / 100.0); pMap->m_fInitZ = (float)(ZoneInfoSet.m_InitZ / 100.0); pMap->m_fInitY = (float)(ZoneInfoSet.m_InitY / 100.0); pMap->m_bType = ZoneInfoSet.m_Type; if (!pMap->LoadMap((HANDLE)file.m_hFile)) { - errormsg.Format("Map Load Fail - %s\n", szFullPath); - AfxMessageBox(errormsg); + AfxMessageBox(std::format("Map Load Fail - {:s}", fsSmdFile.string()).c_str()); delete pMap; return FALSE; } @@ -2657,14 +2655,13 @@ bool CEbenezerDlg::LoadNoticeData() { } void CEbenezerDlg::SyncTest(int nType) { - char strPath[100]; - memset(strPath, 0x00, 100); + fs::path fsFile; if (nType == 1) { - strcpy(strPath, "c:\\userlist.txt"); + fsFile = fs::temp_directory_path() / "Ebenezer_userlist.txt"; } else if (nType == 2) { - strcpy(strPath, "c:\\npclist.txt"); + fsFile = fs::temp_directory_path() / "Ebenezer_npclist.txt"; } - FILE * stream = fopen(strPath, "w"); + FILE * stream = _wfopen(fsFile.c_str(), L"w"); int size = m_arNpcArray.GetSize(); CNpc * pNpc = NULL; diff --git a/src/server/Ebenezer/Map.cpp b/src/server/Ebenezer/Map.cpp index 6e97ee96..66cfbac0 100644 --- a/src/server/Ebenezer/Map.cpp +++ b/src/server/Ebenezer/Map.cpp @@ -36,7 +36,6 @@ C3DMap::C3DMap() { m_bType = 0; m_wBundle = 1; m_sMaxUser = 150; // Max user in Battlezone!!! - memset(m_MapName, NULL, 256); m_pMain = NULL; } diff --git a/src/server/Ebenezer/Map.h b/src/server/Ebenezer/Map.h index 834b3655..67dd8cf3 100644 --- a/src/server/Ebenezer/Map.h +++ b/src/server/Ebenezer/Map.h @@ -63,14 +63,14 @@ class C3DMap { C3DMap(); virtual ~C3DMap(); - char m_MapName[256]; - int m_nServerNo; - int m_nZoneNumber; - float m_fInitX; - float m_fInitZ; - float m_fInitY; - BYTE m_bType; // Zone Type : 1 -> common zone, 2 -> battle zone, 3 -> 24 hour open battle zone - short m_sMaxUser; + fs::path m_fsSmdFileName; + int m_nServerNo; + int m_nZoneNumber; + float m_fInitX; + float m_fInitZ; + float m_fInitY; + BYTE m_bType; // Zone Type : 1 -> common zone, 2 -> battle zone, 3 -> 24 hour open battle zone + short m_sMaxUser; CRegion ** m_ppRegion; short ** m_ppnEvent; diff --git a/src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp b/src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp index 2022bb89..4772bfed 100644 --- a/src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp +++ b/src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp @@ -337,7 +337,7 @@ void CN3ShapeMgr::GenerateCollisionData() { if (nCPC != (nFC * 3)) { #ifdef _N3GAME CLogWriter::Write("CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤의 점갯수와 면 갯수가 다릅니다. (%s)", - m_szFileName.c_str()); + FilePath().string().c_str()); #endif this->Release(); return; @@ -526,7 +526,7 @@ void CN3ShapeMgr::GenerateCollisionData() { #ifdef _N3GAME CLogWriter::Write( "CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤 수가 너무 많습니다. (%s)", - m_szFileName.c_str()); + FilePath().string().c_str()); #endif continue; } @@ -552,14 +552,15 @@ int CN3ShapeMgr::Add(CN3Shape * pShape) { int nZ = (int)(vPos.z / CELL_MAIN_SIZE); if (nX < 0 || nX >= MAX_CELL_MAIN || nZ < 0 || nZ >= MAX_CELL_MAIN) { #ifdef _N3GAME - CLogWriter::Write("CN3ShapeMgr::Add - Shape(%s) Add Failed. Check position", pShape->FileName().c_str()); + CLogWriter::Write("CN3ShapeMgr::Add - Shape(%s) Add Failed. Check position", + pShape->FilePath().string().c_str()); #endif return -1; } pShape->SaveToFile(); // 파일로 저장하고.. CN3Shape * pShapeAdd = new CN3Shape(); - if (false == pShapeAdd->LoadFromFile(pShape->FileName())) // 이 파일을 열은 다음 + if (false == pShapeAdd->LoadFromFile(pShape->FilePath())) // 이 파일을 열은 다음 { delete pShapeAdd; return -1; diff --git a/src/server/ItemManager/ItemManagerDlg.cpp b/src/server/ItemManager/ItemManagerDlg.cpp index 040976d2..99b62397 100644 --- a/src/server/ItemManager/ItemManagerDlg.cpp +++ b/src/server/ItemManager/ItemManagerDlg.cpp @@ -110,15 +110,15 @@ BOOL CItemManagerDlg::OnInitDialog() { m_LoggerRecvQueue.InitailizeMMF(MAX_PKTSIZE, MAX_COUNT, SMQ_ITEMLOGGER, FALSE); // Dispatcher 의 Send Queue /* - std::string szIniPath = (n3std::get_app_path() / "ItemDB.ini").string(); - const char * inipath = szIniPath.c_str(); + std::string szIniFile = (n3std::get_app_path() / "ItemDB.ini").string(); + const char * pszIniFile = szIniFile.c_str(); - GetPrivateProfileString("ODBC", "GAME_DSN", "kodb", m_strGameDSN, 24, inipath); - GetPrivateProfileString("ODBC", "GAME_UID", "kodb_user", m_strGameUID, 24, inipath); - GetPrivateProfileString("ODBC", "GAME_PWD", "kodb_user", m_strGamePWD, 24, inipath); + GetPrivateProfileString("ODBC", "GAME_DSN", "kodb", m_strGameDSN, sizeof(m_strGameDSN), pszIniFile); + GetPrivateProfileString("ODBC", "GAME_UID", "kodb_user", m_strGameUID, sizeof(m_strGameUID), pszIniFile); + GetPrivateProfileString("ODBC", "GAME_PWD", "kodb_user", m_strGamePWD, sizeof(m_strGamePWD), pszIniFile); - m_nServerNo = GetPrivateProfileInt("ZONE_INFO", "GROUP_INFO", 1, inipath); - m_nZoneNo = GetPrivateProfileInt("ZONE_INFO", "ZONE_INFO", 1, inipath); + m_nServerNo = GetPrivateProfileInt("ZONE_INFO", "GROUP_INFO", 1, pszIniFile); + m_nZoneNo = GetPrivateProfileInt("ZONE_INFO", "ZONE_INFO", 1, pszIniFile); if (!m_DBAgent.DatabaseInit()) { AfxPostQuitMessage(0); diff --git a/src/server/LoginServer/DBProcess.cpp b/src/server/LoginServer/DBProcess.cpp index 4a205042..692ffecc 100644 --- a/src/server/LoginServer/DBProcess.cpp +++ b/src/server/LoginServer/DBProcess.cpp @@ -22,142 +22,111 @@ CDBProcess::CDBProcess() {} CDBProcess::~CDBProcess() {} -BOOL CDBProcess::InitDatabase(char * strconnection) { +BOOL CDBProcess::InitDatabase(char * szConnectString) { m_VersionDB.SetLoginTimeout(100); m_pMain = (CLoginServerDlg *)AfxGetApp()->GetMainWnd(); - if (!m_VersionDB.Open(NULL, FALSE, FALSE, strconnection)) { + if (!m_VersionDB.Open(NULL, FALSE, FALSE, szConnectString)) { return FALSE; } return TRUE; } -void CDBProcess::ReConnectODBC(CDatabase * m_db, const char * strdb, const char * strname, const char * strpwd) { - char strlog[256]; - memset(strlog, 0x00, 256); +void CDBProcess::ReConnectODBC(CDatabase * pDb, const char * szDsn, const char * szUid, const char * szPwd) { CTime t = CTime::GetCurrentTime(); - sprintf(strlog, "Try ReConnectODBC... %d월 %d일 %d시 %d분\r\n", t.GetMonth(), t.GetDay(), t.GetHour(), - t.GetMinute()); - n3std::log_file_write(strlog); + n3std::log_file_write(std::format("Try ReConnectODBC... {:d} month {:d} day {:d} hour {:d} minute", t.GetMonth(), + t.GetDay(), t.GetHour(), t.GetMinute()) + .c_str()); // DATABASE 연결... - CString strConnect; - strConnect.Format(_T("DSN=%s;UID=%s;PWD=%s"), strdb, strname, strpwd); - int iCount = 0; - - do { - iCount++; - if (iCount >= 4) { - break; - } - - m_db->SetLoginTimeout(10); + std::string szConnStr = std::format("DSN={:s};UID={:s};PWD={:s}", szDsn, szUid, szPwd); + int iCount = 0; + while (iCount++ < 4 && !pDb->IsOpen()) { + pDb->SetLoginTimeout(10); try { - m_db->OpenEx((LPCTSTR)strConnect, CDatabase::noOdbcDialog); + pDb->OpenEx(szConnStr.c_str(), CDatabase::noOdbcDialog); } catch (CDBException * e) { e->Delete(); } - - } while (!m_db->IsOpen()); + } } BOOL CDBProcess::LoadVersionList() { - SQLHSTMT hstmt = NULL; - SQLRETURN retcode; - TCHAR szSQL[1024]; + char szSQL[1024]{}; + wsprintf(szSQL, TEXT("SELECT * FROM %s"), m_pMain->m_TableName); - CString tempfilename, tempcompname; - - memset(szSQL, 0x00, 1024); - wsprintf(szSQL, TEXT("select * from %s"), m_pMain->m_TableName); - - SQLSMALLINT version = 0, historyversion = 0; - TCHAR strfilename[256], strcompname[256]; - memset(strfilename, NULL, 256); - memset(strcompname, NULL, 256); - SQLINTEGER Indexind = SQL_NTS; - - retcode = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hstmt); - if (retcode != SQL_SUCCESS) { + SQLHSTMT hStmt = NULL; + SQLRETURN rc = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hStmt); + if (rc != SQL_SUCCESS) { return FALSE; } - retcode = SQLExecDirect(hstmt, (unsigned char *)szSQL, SQL_NTS); - if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) { - if (DisplayErrorMsg(hstmt) == -1) { + rc = SQLExecDirect(hStmt, (unsigned char *)szSQL, SQL_NTS); + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + if (DisplayErrorMsg(hStmt) == -1) { m_VersionDB.Close(); if (!m_VersionDB.IsOpen()) { ReConnectODBC(&m_VersionDB, m_pMain->m_ODBCName, m_pMain->m_ODBCLogin, m_pMain->m_ODBCPwd); return FALSE; } } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); return FALSE; } - while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { - retcode = SQLFetch(hstmt); - if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { - SQLGetData(hstmt, 1, SQL_C_SSHORT, &version, 0, &Indexind); - SQLGetData(hstmt, 2, SQL_C_CHAR, strfilename, 256, &Indexind); - SQLGetData(hstmt, 3, SQL_C_CHAR, strcompname, 256, &Indexind); - SQLGetData(hstmt, 4, SQL_C_SSHORT, &historyversion, 0, &Indexind); - _VERSION_INFO * pInfo = new _VERSION_INFO; - - tempfilename = strfilename; - tempcompname = strcompname; - tempfilename.TrimRight(); - tempcompname.TrimRight(); + while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { + rc = SQLFetch(hStmt); + if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { + SQLSMALLINT sVersion = 0, sHistoryVersion = 0; + wchar_t szFile[261]{}; + char szPatchFileName[14]{}; - pInfo->sVersion = version; - pInfo->strFileName = tempfilename; - pInfo->strCompName = tempcompname; - pInfo->sHistoryVersion = historyversion; + SQLINTEGER cbParmRet = SQL_NTS; + SQLGetData(hStmt, 1, SQL_C_SSHORT, &sVersion, 0, &cbParmRet); + SQLGetData(hStmt, 2, SQL_C_WCHAR, szFile, sizeof(szFile), &cbParmRet); + SQLGetData(hStmt, 3, SQL_C_CHAR, szPatchFileName, sizeof(szPatchFileName), &cbParmRet); + SQLGetData(hStmt, 4, SQL_C_SSHORT, &sHistoryVersion, 0, &cbParmRet); - if (!m_pMain->m_VersionList.PutData(pInfo->strFileName, pInfo)) { - TRACE("VersionInfo PutData Fail - %d\n", pInfo->strFileName); + _VERSION_INFO * pInfo = new _VERSION_INFO; + pInfo->sVersion = sVersion; + pInfo->fsFile = szFile; + pInfo->fsPatchFileName = szPatchFileName; + pInfo->sHistoryVersion = sHistoryVersion; + if (!m_pMain->m_VersionList.PutData(pInfo->fsFile, pInfo)) { + TRACE("VersionInfo PutData Fail - %d\n", pInfo->fsFile); delete pInfo; pInfo = NULL; } } } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); m_pMain->m_nLastVersion = 0; - - map::iterator Iter1, Iter2; - Iter1 = m_pMain->m_VersionList.m_UserTypeMap.begin(); - Iter2 = m_pMain->m_VersionList.m_UserTypeMap.end(); - for (; Iter1 != Iter2; Iter1++) { - if (m_pMain->m_nLastVersion < ((*Iter1).second)->sVersion) { - m_pMain->m_nLastVersion = ((*Iter1).second)->sVersion; - } + for (const auto & [_, pInfo] : m_pMain->m_VersionList.m_UserTypeMap) { + m_pMain->m_nLastVersion = std::max(m_pMain->m_nLastVersion, pInfo->sVersion); } return TRUE; } -int CDBProcess::AccountLogin(const char * id, const char * pwd) { - SQLHSTMT hstmt = NULL; - SQLRETURN retcode; - TCHAR szSQL[1024]; - memset(szSQL, 0x00, 1024); +int CDBProcess::AccountLogin(const char * szId, const char * szPwd) { SQLSMALLINT sParmRet = 3; - SQLINTEGER cbParmRet = SQL_NTS; - - wsprintf(szSQL, TEXT("{call ACCOUNT_LOGIN(\'%s\',\'%s\',?)}"), id, pwd); - - retcode = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hstmt); - if (retcode == SQL_SUCCESS) { - retcode = - SQLBindParameter(hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_SMALLINT, 0, 0, &sParmRet, 0, &cbParmRet); - if (retcode == SQL_SUCCESS) { - retcode = SQLExecDirect(hstmt, (unsigned char *)szSQL, SQL_NTS); - if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) { - if (DisplayErrorMsg(hstmt) == -1) { + + char szSQL[1024]{}; + wsprintf(szSQL, TEXT("{CALL ACCOUNT_LOGIN(\'%s\',\'%s\',?)}"), szId, szPwd); + + SQLHSTMT hStmt = NULL; + SQLRETURN rc = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hStmt); + if (rc == SQL_SUCCESS) { + SQLINTEGER cbParmRet = SQL_NTS; + rc = SQLBindParameter(hStmt, 1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_SMALLINT, 0, 0, &sParmRet, 0, &cbParmRet); + if (rc == SQL_SUCCESS) { + rc = SQLExecDirect(hStmt, (unsigned char *)szSQL, SQL_NTS); + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + if (DisplayErrorMsg(hStmt) == -1) { m_VersionDB.Close(); if (!m_VersionDB.IsOpen()) { ReConnectODBC(&m_VersionDB, m_pMain->m_ODBCName, m_pMain->m_ODBCLogin, m_pMain->m_ODBCPwd); @@ -167,30 +136,27 @@ int CDBProcess::AccountLogin(const char * id, const char * pwd) { } } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); } return sParmRet; } -int CDBProcess::MgameLogin(const char * id, const char * pwd) { - SQLHSTMT hstmt = NULL; - SQLRETURN retcode; - TCHAR szSQL[1024]; - memset(szSQL, 0x00, 1024); +int CDBProcess::MgameLogin(const char * szId, const char * szPwd) { SQLSMALLINT sParmRet = -1; - SQLINTEGER cbParmRet = SQL_NTS; - - wsprintf(szSQL, TEXT("{call MGAME_LOGIN(\'%s\',\'%s\',?)}"), id, pwd); - - retcode = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hstmt); - if (retcode == SQL_SUCCESS) { - retcode = - SQLBindParameter(hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_SMALLINT, 0, 0, &sParmRet, 0, &cbParmRet); - if (retcode == SQL_SUCCESS) { - retcode = SQLExecDirect(hstmt, (unsigned char *)szSQL, SQL_NTS); - if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) { - if (DisplayErrorMsg(hstmt) == -1) { + + char szSQL[1024]{}; + wsprintf(szSQL, TEXT("{CALL MGAME_LOGIN(\'%s\',\'%s\',?)}"), szId, szPwd); + + SQLHSTMT hStmt = NULL; + SQLRETURN rc = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hStmt); + if (rc == SQL_SUCCESS) { + SQLINTEGER cbParmRet = SQL_NTS; + rc = SQLBindParameter(hStmt, 1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_SMALLINT, 0, 0, &sParmRet, 0, &cbParmRet); + if (rc == SQL_SUCCESS) { + rc = SQLExecDirect(hStmt, (unsigned char *)szSQL, SQL_NTS); + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + if (DisplayErrorMsg(hStmt) == -1) { m_VersionDB.Close(); if (!m_VersionDB.IsOpen()) { ReConnectODBC(&m_VersionDB, m_pMain->m_ODBCName, m_pMain->m_ODBCLogin, m_pMain->m_ODBCPwd); @@ -200,146 +166,133 @@ int CDBProcess::MgameLogin(const char * id, const char * pwd) { } } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); } return sParmRet; } -BOOL CDBProcess::InsertVersion(int version, const char * filename, const char * compname, int historyversion) { - SQLHSTMT hstmt = NULL; - SQLRETURN retcode; - TCHAR szSQL[1024]; - memset(szSQL, 0x00, 1024); +BOOL CDBProcess::InsertVersion(short sVersion, const fs::path & fsFile, const fs::path & fsPatchFileName, + short sHistoryVersion) { BOOL retvalue = TRUE; - wsprintf( - szSQL, - TEXT( - "INSERT INTO %s (sVersion, strFileName, strCompressName, sHistoryVersion) VALUES (%d, \'%s\', \'%s\', %d)"), - m_pMain->m_TableName, version, filename, compname, historyversion); - - retcode = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hstmt); - if (retcode == SQL_SUCCESS) { - retcode = SQLExecDirect(hstmt, (unsigned char *)szSQL, SQL_NTS); - if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) { - DisplayErrorMsg(hstmt); + std::string szSql = std::format( + "INSERT INTO {:s} (sVersion, strFile, strPatchFileName, sHistoryVersion) VALUES ({:d}, '{:s}', '{:s}', {:d})", + m_pMain->m_TableName, sVersion, fsFile, fsPatchFileName, sHistoryVersion); + + SQLHSTMT hStmt = NULL; + SQLRETURN rc = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hStmt); + if (rc == SQL_SUCCESS) { + rc = SQLExecDirect(hStmt, (SQLCHAR *)szSql.c_str(), SQL_NTS); + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + DisplayErrorMsg(hStmt); retvalue = FALSE; } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); } return retvalue; } -BOOL CDBProcess::DeleteVersion(const char * filename) { - SQLHSTMT hstmt = NULL; - SQLRETURN retcode; - TCHAR szSQL[1024]; - memset(szSQL, 0x00, 1024); +BOOL CDBProcess::DeleteVersion(const fs::path & fsFile) { BOOL retvalue = TRUE; - wsprintf(szSQL, TEXT("DELETE FROM %s WHERE strFileName = \'%s\'"), m_pMain->m_TableName, filename); + std::string szSql = std::format("DELETE FROM {:s} WHERE strFile = '{:s}'", m_pMain->m_TableName, fsFile); - retcode = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hstmt); - if (retcode == SQL_SUCCESS) { - retcode = SQLExecDirect(hstmt, (unsigned char *)szSQL, SQL_NTS); - if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) { - DisplayErrorMsg(hstmt); + SQLHSTMT hStmt = NULL; + SQLRETURN rc = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hStmt); + if (rc == SQL_SUCCESS) { + rc = SQLExecDirect(hStmt, (SQLCHAR *)szSql.c_str(), SQL_NTS); + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + DisplayErrorMsg(hStmt); retvalue = FALSE; } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); } return retvalue; } BOOL CDBProcess::LoadUserCountList() { - SQLHSTMT hstmt = NULL; - SQLRETURN retcode; - TCHAR szSQL[1024]; - - CString tempfilename, tempcompname; + TCHAR szSQL[1024]{}; + wsprintf(szSQL, TEXT("SELECT * FROM CONCURRENT")); - memset(szSQL, 0x00, 1024); - wsprintf(szSQL, TEXT("select * from CONCURRENT")); - - SQLCHAR serverid; - SQLSMALLINT zone_1 = 0, zone_2 = 0, zone_3 = 0; - SQLINTEGER Indexind = SQL_NTS; - - retcode = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hstmt); - if (retcode != SQL_SUCCESS) { + SQLHSTMT hStmt = NULL; + SQLRETURN rc = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hStmt); + if (rc != SQL_SUCCESS) { return FALSE; } - retcode = SQLExecDirect(hstmt, (unsigned char *)szSQL, SQL_NTS); - if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) { - if (DisplayErrorMsg(hstmt) == -1) { + rc = SQLExecDirect(hStmt, (unsigned char *)szSQL, SQL_NTS); + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + if (DisplayErrorMsg(hStmt) == -1) { m_VersionDB.Close(); if (!m_VersionDB.IsOpen()) { ReConnectODBC(&m_VersionDB, m_pMain->m_ODBCName, m_pMain->m_ODBCLogin, m_pMain->m_ODBCPwd); return FALSE; } } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); return FALSE; } - while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { - retcode = SQLFetch(hstmt); - if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { - SQLGetData(hstmt, 1, SQL_C_TINYINT, &serverid, 0, &Indexind); - SQLGetData(hstmt, 2, SQL_C_SSHORT, &zone_1, 0, &Indexind); - SQLGetData(hstmt, 3, SQL_C_SSHORT, &zone_2, 0, &Indexind); - SQLGetData(hstmt, 4, SQL_C_SSHORT, &zone_3, 0, &Indexind); + + while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { + rc = SQLFetch(hStmt); + if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { + SQLCHAR sServerId = 0; + SQLSMALLINT sZone1Count = 0, sZone2Count = 0, sZone3Count = 0; + + SQLINTEGER cbParmRet = SQL_NTS; + SQLGetData(hStmt, 1, SQL_C_TINYINT, &sServerId, 0, &cbParmRet); + SQLGetData(hStmt, 2, SQL_C_SSHORT, &sZone1Count, 0, &cbParmRet); + SQLGetData(hStmt, 3, SQL_C_SSHORT, &sZone2Count, 0, &cbParmRet); + SQLGetData(hStmt, 4, SQL_C_SSHORT, &sZone3Count, 0, &cbParmRet); // 여기에서 데이타를 받아서 알아서 사용.... - if (serverid - 1 < m_pMain->m_nServerCount) { - m_pMain->m_ServerList[serverid - 1]->sUserCount = zone_1 + zone_2 + zone_3; // 기범이가 ^^; + if (sServerId - 1 < m_pMain->m_nServerCount) { + m_pMain->m_ServerList[sServerId - 1]->sUserCount = + sZone1Count + sZone2Count + sZone3Count; // 기범이가 ^^; } } } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); return TRUE; } -BOOL CDBProcess::IsCurrentUser(const char * accountid, char * strServerIP, int & serverno) { - SQLHSTMT hstmt = NULL; - SQLRETURN retcode; - BOOL retval; - TCHAR szSQL[1024]; - memset(szSQL, 0x00, 1024); - - SQLINTEGER nServerNo = 0; - TCHAR strIP[20]; - memset(strIP, 0x00, 20); - SQLINTEGER Indexind = SQL_NTS; +BOOL CDBProcess::IsCurrentUser(const char * szAccountId, char * szServerIp, int & nServerNo) { + BOOL retval = FALSE; - wsprintf(szSQL, TEXT("SELECT nServerNo, strServerIP FROM CURRENTUSER WHERE strAccountID = \'%s\'"), accountid); + TCHAR szSQL[1024]{}; + wsprintf(szSQL, TEXT("SELECT nServerNo, strServerIP FROM CURRENTUSER WHERE strAccountID = \'%s\'"), szAccountId); - retcode = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hstmt); - if (retcode != SQL_SUCCESS) { + SQLHSTMT hStmt = NULL; + SQLRETURN rc = SQLAllocHandle((SQLSMALLINT)SQL_HANDLE_STMT, m_VersionDB.m_hdbc, &hStmt); + if (rc != SQL_SUCCESS) { return FALSE; } - retcode = SQLExecDirect(hstmt, (unsigned char *)szSQL, SQL_NTS); - if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { - retcode = SQLFetch(hstmt); - if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) { - SQLGetData(hstmt, 1, SQL_C_SSHORT, &nServerNo, 0, &Indexind); - SQLGetData(hstmt, 2, SQL_C_CHAR, strIP, 20, &Indexind); + rc = SQLExecDirect(hStmt, (unsigned char *)szSQL, SQL_NTS); + if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { + rc = SQLFetch(hStmt); + if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { + SQLINTEGER nServerNo = 0; + TCHAR szServerIp[20]{}; + + SQLINTEGER cbParmRet = SQL_NTS; + SQLGetData(hStmt, 1, SQL_C_SSHORT, &nServerNo, 0, &cbParmRet); + SQLGetData(hStmt, 2, SQL_C_CHAR, szServerIp, 20, &cbParmRet); - strcpy(strServerIP, strIP); - serverno = nServerNo; + strcpy(szServerIp, szServerIp); + nServerNo = nServerNo; retval = TRUE; } else { retval = FALSE; } } else { - if (DisplayErrorMsg(hstmt) == -1) { + if (DisplayErrorMsg(hStmt) == -1) { m_VersionDB.Close(); if (!m_VersionDB.IsOpen()) { ReConnectODBC(&m_VersionDB, m_pMain->m_ODBCName, m_pMain->m_ODBCLogin, m_pMain->m_ODBCPwd); @@ -349,7 +302,7 @@ BOOL CDBProcess::IsCurrentUser(const char * accountid, char * strServerIP, int & retval = FALSE; } - SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt); + SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hStmt); return retval; } diff --git a/src/server/LoginServer/DBProcess.h b/src/server/LoginServer/DBProcess.h index 2a1ee00e..793c2ca1 100644 --- a/src/server/LoginServer/DBProcess.h +++ b/src/server/LoginServer/DBProcess.h @@ -7,13 +7,14 @@ class CLoginServerDlg; class CDBProcess { public: - BOOL IsCurrentUser(const char * accountid, char * strServerIP, int & serverno); - void ReConnectODBC(CDatabase * m_db, const char * strdb, const char * strname, const char * strpwd); - BOOL DeleteVersion(const char * filename); - BOOL InsertVersion(int version, const char * filename, const char * compname, int historyversion); - BOOL InitDatabase(char * strconnection); - int MgameLogin(const char * id, const char * pwd); - int AccountLogin(const char * id, const char * pwd); + BOOL IsCurrentUser(const char * szAccountId, char * szServerIp, int & nServerNo); + void ReConnectODBC(CDatabase * pDb, const char * szDsn, const char * szUid, const char * szPwd); + BOOL DeleteVersion(const fs::path & fsFile); + BOOL InsertVersion(short sVersion, const fs::path & fsFile, const fs::path & fsPatchFileName, + short sHistoryVersion); + BOOL InitDatabase(char * szConnectString); + int MgameLogin(const char * szId, const char * szPwd); + int AccountLogin(const char * szId, const char * szPwd); BOOL LoadVersionList(); BOOL LoadUserCountList(); diff --git a/src/server/LoginServer/Define.h b/src/server/LoginServer/Define.h index 04c9755b..37b1c1ea 100644 --- a/src/server/LoginServer/Define.h +++ b/src/server/LoginServer/Define.h @@ -54,10 +54,10 @@ typedef union { } MYDWORD; struct _VERSION_INFO { - short sVersion; - short sHistoryVersion; - string strFileName; - string strCompName; + short sVersion; + fs::path fsFile; + fs::path fsPatchFileName; + short sHistoryVersion; }; struct _SERVER_INFO { diff --git a/src/server/LoginServer/LoginServerDlg.cpp b/src/server/LoginServer/LoginServerDlg.cpp index d2f707d8..428bf4f6 100644 --- a/src/server/LoginServer/LoginServerDlg.cpp +++ b/src/server/LoginServer/LoginServerDlg.cpp @@ -26,14 +26,11 @@ CLoginServerDlg::CLoginServerDlg(CWnd * pParent /*=NULL*/) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT - memset(m_strFtpUrl, NULL, 256); - memset(m_strFilePath, NULL, 256); - memset(m_strDefaultPath, NULL, _MAX_PATH); m_nLastVersion = 0; - memset(m_ODBCName, NULL, 32); - memset(m_ODBCLogin, NULL, 32); - memset(m_ODBCPwd, NULL, 32); - memset(m_TableName, NULL, 32); + memset(m_ODBCName, 0, sizeof(m_ODBCName)); + memset(m_ODBCLogin, 0, sizeof(m_ODBCLogin)); + memset(m_ODBCPwd, 0, sizeof(m_ODBCPwd)); + memset(m_TableName, 0, sizeof(m_TableName)); m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } @@ -82,10 +79,9 @@ BOOL CLoginServerDlg::OnInitDialog() { return FALSE; } - char strconnection[256]; - memset(strconnection, NULL, 256); - sprintf(strconnection, "ODBC;DSN=%s;UID=%s;PWD=%s", m_ODBCName, m_ODBCLogin, m_ODBCPwd); - if (!m_DBProcess.InitDatabase(strconnection)) { + char szConnectionString[256]{}; + sprintf(szConnectionString, "ODBC;DSN=%s;UID=%s;PWD=%s", m_ODBCName, m_ODBCLogin, m_ODBCPwd); + if (!m_DBProcess.InitDatabase(szConnectionString)) { AfxMessageBox("Database Connection Fail!!"); AfxPostQuitMessage(0); return FALSE; @@ -96,10 +92,9 @@ BOOL CLoginServerDlg::OnInitDialog() { return FALSE; } - m_OutputList.AddString(strconnection); - CString version; - version.Format("Latest Version : %d", m_nLastVersion); - m_OutputList.AddString(version); + m_OutputList.AddString(szConnectionString); + std::string szVersion = std::format("Latest Version : {:d}", m_nLastVersion); + m_OutputList.AddString(szVersion.c_str()); ::ResumeThread(m_Iocport.m_hAcceptThread); @@ -107,20 +102,32 @@ BOOL CLoginServerDlg::OnInitDialog() { } BOOL CLoginServerDlg::GetInfoFromIni() { - std::string szIniPath = (n3std::get_app_dir() / "Version.ini").string(); - const char * inipath = szIniPath.c_str(); - GetPrivateProfileString("DOWNLOAD", "URL", "ftp.your-site.net", m_strFtpUrl, 256, inipath); - GetPrivateProfileString("DOWNLOAD", "PATH", "/", m_strFilePath, 256, inipath); - - GetPrivateProfileString("ODBC", "DSN", "kodb", m_ODBCName, 32, inipath); - GetPrivateProfileString("ODBC", "UID", "kodb_user", m_ODBCLogin, 32, inipath); - GetPrivateProfileString("ODBC", "PWD", "kodb_user", m_ODBCPwd, 32, inipath); - GetPrivateProfileString("ODBC", "TABLE", "VERSION", m_TableName, 32, inipath); - GetPrivateProfileString("CONFIGURATION", "DEFAULT_PATH", "", m_strDefaultPath, 256, inipath); + std::string szIniFile = (n3std::get_app_dir() / "Version.ini").string(); + const char * pszIniFile = szIniFile.c_str(); + + char szBuff[500]{}; + GetPrivateProfileString("DOWNLOAD", "URL", "ftp.your-site.net", szBuff, sizeof(szBuff), pszIniFile); + m_szFtpUrl = szBuff; + + memset(szBuff, 0, sizeof(szBuff)); + GetPrivateProfileString("DOWNLOAD", "PATH", "/", szBuff, sizeof(szBuff), pszIniFile); + m_szFtpPath = szBuff; + + GetPrivateProfileString("ODBC", "DSN", "kodb", m_ODBCName, sizeof(m_ODBCName), pszIniFile); + GetPrivateProfileString("ODBC", "UID", "kodb_user", m_ODBCLogin, sizeof(m_ODBCLogin), pszIniFile); + GetPrivateProfileString("ODBC", "PWD", "kodb_user", m_ODBCPwd, sizeof(m_ODBCPwd), pszIniFile); + GetPrivateProfileString("ODBC", "TABLE", "VERSION", m_TableName, sizeof(m_TableName), pszIniFile); + + memset(szBuff, 0, sizeof(szBuff)); + GetPrivateProfileString("CONFIGURATION", "DEFAULT_PATH", "", szBuff, sizeof(szBuff), pszIniFile); + m_fsDefaultDir = szBuff; + if (!m_fsDefaultDir.is_absolute()) { + m_fsDefaultDir = n3std::get_app_dir().normalize(); + } - m_nServerCount = GetPrivateProfileInt("SERVER_LIST", "COUNT", 1, inipath); + m_nServerCount = GetPrivateProfileInt("SERVER_LIST", "COUNT", 1, pszIniFile); - if (!strlen(m_strFtpUrl) || !strlen(m_strFilePath)) { + if (m_szFtpUrl.empty() || m_szFtpPath.empty()) { return FALSE; } if (!strlen(m_ODBCName) || !strlen(m_ODBCLogin) || !strlen(m_ODBCPwd) || !strlen(m_TableName)) { @@ -130,20 +137,17 @@ BOOL CLoginServerDlg::GetInfoFromIni() { return FALSE; } - char ipkey[20]; - memset(ipkey, 0x00, 20); - char namekey[20]; - memset(namekey, 0x00, 20); - _SERVER_INFO * pInfo = NULL; - m_ServerList.reserve(20); for (int i = 0; i < m_nServerCount; i++) { - pInfo = new _SERVER_INFO; - sprintf(ipkey, "SERVER_%02d", i); - sprintf(namekey, "NAME_%02d", i); - GetPrivateProfileString("SERVER_LIST", ipkey, "127.0.0.1", pInfo->strServerIP, 32, inipath); - GetPrivateProfileString("SERVER_LIST", namekey, ipkey, pInfo->strServerName, 32, inipath); - m_ServerList.push_back(pInfo); + _SERVER_INFO * pInfo = new _SERVER_INFO; + std::string szKeyIp = std::format("SERVER_{:02d}", i); + GetPrivateProfileString("SERVER_LIST", szKeyIp.c_str(), "127.0.0.1", pInfo->strServerIP, + sizeof(pInfo->strServerIP), pszIniFile); + + std::string szKeyServerName = std::format("NAME_{:02d}", i); + GetPrivateProfileString("SERVER_LIST", szKeyServerName.c_str(), szKeyIp.c_str(), pInfo->strServerName, + sizeof(pInfo->strServerName), pszIniFile); + m_ServerList.emplace_back(pInfo); } return TRUE; @@ -204,12 +208,11 @@ BOOL CLoginServerDlg::DestroyWindow() { } void CLoginServerDlg::OnVersionSetting() { - std::string szIniPath = (n3std::get_app_dir() / "Version.ini").string(); - CSettingDlg setdlg(m_nLastVersion, this); - - strcpy(setdlg.m_strDefaultPath, m_strDefaultPath); - if (setdlg.DoModal() == IDOK) { - strcpy(m_strDefaultPath, setdlg.m_strDefaultPath); - WritePrivateProfileString("CONFIGURATION", "DEFAULT_PATH", m_strDefaultPath, szIniPath.c_str()); + fs::path fsIniPath = n3std::get_app_dir() / "Version.ini"; + CSettingDlg dlg(m_nLastVersion, this); + dlg.m_fsDefaultDir = m_fsDefaultDir; + if (dlg.DoModal() == IDOK) { + m_fsDefaultDir = dlg.m_fsDefaultDir; + WritePrivateProfileStringW(L"CONFIGURATION", L"DEFAULT_PATH", m_fsDefaultDir.c_str(), fsIniPath.c_str()); } } diff --git a/src/server/LoginServer/LoginServerDlg.h b/src/server/LoginServer/LoginServerDlg.h index 53d8353b..20dfbc61 100644 --- a/src/server/LoginServer/LoginServerDlg.h +++ b/src/server/LoginServer/LoginServerDlg.h @@ -12,8 +12,8 @@ ///////////////////////////////////////////////////////////////////////////// // CLoginServerDlg dialog -typedef CSTLMap VersionInfoList; -typedef std::vector<_SERVER_INFO *> ServerInfoList; +typedef CSTLMap VersionInfoList; // TODO: does the key need to be fs::path? +typedef std::vector<_SERVER_INFO *> ServerInfoList; class CLoginServerDlg : public CDialog { // Construction @@ -24,11 +24,13 @@ class CLoginServerDlg : public CDialog { static CIOCPort m_Iocport; - char m_strFtpUrl[256]; - char m_strFilePath[256]; - char m_strDefaultPath[_MAX_PATH]; + // m_szFtpUrl / m_szFtpPath / patch0000.zip + std::string m_szFtpUrl; // The url for the FTP server to download patches + std::string m_szFtpPath; // The directory path for the FTP - int m_nLastVersion; + fs::path m_fsDefaultDir; + + short m_nLastVersion; char m_ODBCName[32]; char m_ODBCLogin[32]; diff --git a/src/server/LoginServer/SettingDlg.cpp b/src/server/LoginServer/SettingDlg.cpp index a5833a7d..615a9442 100644 --- a/src/server/LoginServer/SettingDlg.cpp +++ b/src/server/LoginServer/SettingDlg.cpp @@ -12,16 +12,14 @@ static char THIS_FILE[] = __FILE__; ///////////////////////////////////////////////////////////////////////////// // CSettingDlg dialog -CSettingDlg::CSettingDlg(int version, CWnd * pParent /*=NULL*/) +CSettingDlg::CSettingDlg(short sVersion, CWnd * pParent /*=NULL*/) : CDialog(CSettingDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSettingDlg) - m_nVersion = version; - m_bCompressOption = FALSE; + m_nVersion = sVersion; + m_bRepackPrevVersions = FALSE; m_bAllFileAdd = FALSE; //}}AFX_DATA_INIT - memset(m_strDefaultPath, 0x00, MAX_PATH); - m_pMain = (CLoginServerDlg *)pParent; } @@ -32,19 +30,19 @@ void CSettingDlg::DoDataExchange(CDataExchange * pDX) { DDX_Control(pDX, IDC_FILE_LIST, m_FileList); DDX_Control(pDX, IDC_PROGRESS, m_Progress); DDX_Text(pDX, IDC_VERSION_EDIT, m_nVersion); - DDX_Check(pDX, IDC_CHECK, m_bCompressOption); - DDX_Check(pDX, IDC_CHECK2, m_bAllFileAdd); + DDX_Check(pDX, IDC_CHECK_REPACK_VERSIONS, m_bRepackPrevVersions); + DDX_Check(pDX, IDC_CHECK_ADD_ALL_FILES, m_bAllFileAdd); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSettingDlg, CDialog) //{{AFX_MSG_MAP(CSettingDlg) -ON_BN_CLICKED(IDC_ADDFILE, OnAddfile) -ON_BN_CLICKED(IDC_DELETEFILE, OnDeletefile) +ON_BN_CLICKED(IDC_ADDFILE, OnAddFile) +ON_BN_CLICKED(IDC_DELETEFILE, OnDeleteFile) ON_BN_CLICKED(IDC_COMPRESS, OnCompress) ON_BN_CLICKED(IDC_PATH_BROWSE, OnPathBrowse) ON_BN_CLICKED(IDC_REFRESH, OnRefresh) -ON_EN_KILLFOCUS(IDC_VERSION_EDIT, OnKillfocusVersionEdit) +ON_EN_KILLFOCUS(IDC_VERSION_EDIT, OnKillFocusVersionEdit) ON_BN_CLICKED(IDC_DBCSTEST, OnDbcstest) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -55,11 +53,20 @@ END_MESSAGE_MAP() BOOL CSettingDlg::OnInitDialog() { CDialog::OnInitDialog(); - m_PathEdit.SetWindowText(m_strDefaultPath); + m_PathEdit.SetWindowText(m_fsDefaultDir.string().c_str()); m_Progress.SetRange(0, 100); m_Progress.SetPos(0); + // Initialize the tooltip + m_ToolTip.Create(this); + m_ToolTip.AddTool(GetDlgItem(IDC_DBCSTEST), + _T("Checks all added files for invalid double-byte (DBCS) characters.")); + m_ToolTip.AddTool(GetDlgItem(IDC_CHECK_REPACK_VERSIONS), _T("Repacks previous patches to remove outdated files.")); + m_ToolTip.AddTool(GetDlgItem(IDC_CHECK_ADD_ALL_FILES), + _T("Adds all files automatically relative to the base path.")); + m_ToolTip.Activate(TRUE); + OnRefresh(); return TRUE; // return TRUE unless you set the focus to a control @@ -70,12 +77,7 @@ void CSettingDlg::OnOK() { CDialog::OnOK(); } -void CSettingDlg::OnAddfile() { - std::string addfilename, addfullpath, defaultpath; - char tempstr1[_MAX_PATH]; - memset(tempstr1, 0x00, _MAX_PATH); - int strsize = 0; - +void CSettingDlg::OnAddFile() { UpdateData(TRUE); if (m_bAllFileAdd) { @@ -83,15 +85,16 @@ void CSettingDlg::OnAddfile() { return; } BeginWaitCursor(); - FolderRecurse(m_strDefaultPath); + FolderRecurse(m_fsDefaultDir); EndWaitCursor(); return; } - fs::current_path(m_strDefaultPath); + fs::current_path(m_fsDefaultDir); + std::string szInitialDir = fs::path(m_fsDefaultDir).make_preferred().string(); CFileDialog dlg(TRUE); - dlg.m_ofn.lpstrInitialDir = m_strDefaultPath; + dlg.m_ofn.lpstrInitialDir = szInitialDir.c_str(); dlg.m_ofn.Flags |= OFN_ALLOWMULTISELECT | OFN_EXPLORER; std::vector vFilesBuff(512000); @@ -101,65 +104,50 @@ void CSettingDlg::OnAddfile() { return; } - if (dlg.DoModal() == IDOK) { - POSITION pos = dlg.GetStartPosition(); - while (pos) { - strcpy(tempstr1, dlg.GetNextPathName(pos)); - addfullpath = _strlwr(tempstr1); - defaultpath = _strlwr(m_strDefaultPath); - strsize = defaultpath.size(); - addfilename = addfullpath.substr(strsize); - - if (InsertProcess(&addfilename[0])) { - m_FileList.AddString(&addfilename[0]); - } + POSITION pos = dlg.GetStartPosition(); + while (pos) { + fs::path fsFile = fs::path(dlg.GetNextPathName(pos).GetString()); + fsFile.make_relative(m_fsDefaultDir, true).normalize(); + if (InsertProcess(fsFile)) { + m_FileList.AddString(fsFile.string().c_str()); } } } -void CSettingDlg::OnDeletefile() { - int selcount = 0; - CString delfilename, compname, errmsg; - std::string filename; - std::vector sellist; - _VERSION_INFO * pInfo = NULL; - - selcount = m_FileList.GetSelCount(); - if (selcount == 0) { +void CSettingDlg::OnDeleteFile() { + int iSelCount = m_FileList.GetSelCount(); + if (iSelCount == 0) { AfxMessageBox("File Not Selected."); return; } BeginWaitCursor(); - sellist.reserve(selcount); - - m_FileList.GetSelItems(selcount, &sellist[0]); + std::vector vSelFiles(iSelCount); + m_FileList.GetSelItems(iSelCount, vSelFiles.data()); - for (int i = 0; i < selcount; i++) { - m_FileList.GetText(sellist[i], delfilename); - filename = delfilename; + for (int i = 0; i < iSelCount; i++) { + CString szTmpStr; + m_FileList.GetText(vSelFiles[i], szTmpStr); + fs::path fsSelFile = szTmpStr.GetString(); - pInfo = m_pMain->m_VersionList.GetData(filename); + _VERSION_INFO * pInfo = m_pMain->m_VersionList.GetData(fsSelFile); if (pInfo) { - if (m_pMain->m_DBProcess.DeleteVersion(filename.c_str()) == FALSE) { - errmsg.Format("%s DB Delete Fail", filename.c_str()); - AfxMessageBox(errmsg); + if (!m_pMain->m_DBProcess.DeleteVersion(fsSelFile)) { + AfxMessageBox(std::format("{:s} DB Delete Fail", fsSelFile.string()).c_str()); return; } if (pInfo->sHistoryVersion > 0) { // Restore pInfo->sVersion = pInfo->sHistoryVersion; pInfo->sHistoryVersion = 0; - compname.Format("patch%.4d.zip", pInfo->sVersion); - if (m_pMain->m_DBProcess.InsertVersion(pInfo->sVersion, filename.c_str(), - (const char *)(LPCTSTR)compname, 0) == FALSE) { - m_pMain->m_VersionList.DeleteData(filename); - errmsg.Format("%s DB Insert Fail", filename.c_str()); - AfxMessageBox(errmsg); + fs::path fsPatchFileName = std::format("patch{:04d}.zip", pInfo->sVersion); + if (!m_pMain->m_DBProcess.InsertVersion(pInfo->sVersion, fsSelFile, fsPatchFileName, 0)) { + m_pMain->m_VersionList.DeleteData(fsSelFile); + AfxMessageBox(std::format("{:s} DB Insert Fail", fsSelFile.string()).c_str()); return; } } else { - if (m_pMain->m_VersionList.DeleteData(filename) == FALSE) { + if (!m_pMain->m_VersionList.DeleteData(fsSelFile)) { return; } } @@ -173,57 +161,47 @@ void CSettingDlg::OnDeletefile() { } void CSettingDlg::OnCompress() { - CString fullpathname, filename, errmsg, compname, compfullpath; - DWORD dwsize; - CFile file; - std::string addfilename; - _VERSION_INFO * pInfo = NULL; - UpdateData(TRUE); - int count = m_FileList.GetCount(); - if (count == 0) { + int iFilesCount = m_FileList.GetCount(); + if (iFilesCount == 0) { return; } BeginWaitCursor(); - compname.Format("patch%.4d.zip", m_nVersion); - compfullpath.Format("%s\\%s", m_strDefaultPath, compname); + m_RepackingVersionList.clear(); - set::iterator Iter; + fs::path fsPatchFileName = m_fsDefaultDir / std::format("patch{:04d}.zip", m_nVersion); + m_ZipArchive.Open(fsPatchFileName.string().c_str(), CZipArchive::create); - while (!m_RepackingVersionList.empty()) { - Iter = m_RepackingVersionList.begin(); - m_RepackingVersionList.erase(Iter); - } + SetDlgItemText(IDC_STATUS, "Compressing.."); - m_ZipArchive.Open(compfullpath, CZipArchive::create); + for (int i = 0; i < iFilesCount; i++) { + CString szTmpStr; + m_FileList.GetText(i, szTmpStr); + fs::path fsCurFile = szTmpStr.GetString(); - SetDlgItemText(IDC_STATUS, "Compressing.."); + fs::path fsCurFileAbs = m_fsDefaultDir / fsCurFile; - for (int i = 0; i < count; i++) { - m_FileList.GetText(i, filename); + std::string szCurFileAbs = fsCurFileAbs.string(); + std::string szDefaultDir = m_fsDefaultDir.string(); - fullpathname = m_strDefaultPath; - fullpathname += filename; - if (!file.Open(fullpathname, CFile::modeRead)) { - errmsg.Format("%s File Open Fail", filename); - AfxMessageBox(errmsg); + CFile file; + if (!file.Open(szCurFileAbs.c_str(), CFile::modeRead)) { + AfxMessageBox(std::format("{:s} File Open Fail", fsCurFile.string()).c_str()); continue; } - dwsize = file.GetLength(); + DWORD dwSize = file.GetLength(); file.Close(); - if (!m_ZipArchive.AddNewFile(fullpathname, m_strDefaultPath, -1, dwsize)) { - errmsg.Format("%s File Compress Fail", filename); - AfxMessageBox(errmsg); + if (!m_ZipArchive.AddNewFile(szCurFileAbs.c_str(), szDefaultDir.c_str(), -1, dwSize)) { + AfxMessageBox(std::format("{:s} File Compress Fail", fsCurFile.string()).c_str()); continue; } - m_Progress.SetPos(i * 100 / count); + m_Progress.SetPos(i * 100 / iFilesCount); - addfilename = (const char *)(LPCTSTR)filename; - pInfo = m_pMain->m_VersionList.GetData(addfilename); - if (pInfo) { + _VERSION_INFO * pInfo = m_pMain->m_VersionList.GetData(fsCurFile); + if (pInfo && pInfo->sHistoryVersion > 0) { m_RepackingVersionList.insert(pInfo->sHistoryVersion); } } @@ -231,10 +209,8 @@ void CSettingDlg::OnCompress() { m_ZipArchive.Close(); - if (!m_bCompressOption) { // Current Version 만 압축 - if (!m_RepackingVersionList.empty()) { - RepackingHistory(); - } + if (m_bRepackPrevVersions) { + RepackingHistory(); } m_Progress.SetPos(100); @@ -246,9 +222,8 @@ void CSettingDlg::OnPathBrowse() { CFolderPickerDialog dlg; dlg.m_ofn.lpstrTitle = "Select a base path to where your patch content"; if (dlg.DoModal() == IDOK) { - CString szDir = dlg.GetPathName(); - strcpy(m_strDefaultPath, szDir.GetString()); - m_PathEdit.SetWindowText(m_strDefaultPath); + m_fsDefaultDir = fs::path(dlg.GetPathName().GetString()).normalize(); + m_PathEdit.SetWindowText(m_fsDefaultDir.string().c_str()); } } @@ -256,81 +231,54 @@ void CSettingDlg::OnRefresh() { UpdateData(TRUE); m_FileList.ResetContent(); - - _VERSION_INFO * pInfo = NULL; - std::map::iterator Iter1, Iter2; - Iter1 = m_pMain->m_VersionList.m_UserTypeMap.begin(); - Iter2 = m_pMain->m_VersionList.m_UserTypeMap.end(); - for (; Iter1 != Iter2; Iter1++) { - pInfo = (*Iter1).second; + for (const auto & [_, pInfo] : m_pMain->m_VersionList.m_UserTypeMap) { if (pInfo->sVersion == m_nVersion) { - m_FileList.AddString(pInfo->strFileName.c_str()); + m_FileList.AddString(pInfo->fsFile.string().c_str()); } } } BOOL CSettingDlg::DestroyWindow() { - set::iterator Iter; - - while (!m_RepackingVersionList.empty()) { - Iter = m_RepackingVersionList.begin(); - m_RepackingVersionList.erase(Iter); - } - + m_RepackingVersionList.clear(); return CDialog::DestroyWindow(); } void CSettingDlg::RepackingHistory() { - _VERSION_INFO * pInfo = NULL; - CString errmsg; - set::iterator historyIter1, historyIter2; + if (m_RepackingVersionList.empty()) { + return; + } SetDlgItemText(IDC_STATUS, "Repacking..."); - - historyIter1 = m_RepackingVersionList.begin(); - historyIter2 = m_RepackingVersionList.end(); - - for (; historyIter1 != historyIter2; historyIter1++) { - if (!Repacking(*historyIter1)) { - errmsg.Format("%d Repacking Fail", *historyIter1); - AfxMessageBox(errmsg); + for (const auto & sVersion : m_RepackingVersionList) { + if (!Repacking(sVersion)) { + AfxMessageBox(std::format("{:d} Repacking Fail", sVersion).c_str()); } } - SetDlgItemText(IDC_STATUS, "Repacked"); } -bool CSettingDlg::Repacking(int version) { - _VERSION_INFO * pInfo = NULL; - std::string addfilename; - CString filename, errmsg, compname, compfullpath; - DWORD dwsize; - CFile file; - - compname.Format("patch%.4d.zip", version); - compfullpath.Format("%s\\%s", m_strDefaultPath, compname); - - m_ZipArchive.Open(compfullpath, CZipArchive::create); - - std::map::iterator Iter1, Iter2; - Iter1 = m_pMain->m_VersionList.m_UserTypeMap.begin(); - Iter2 = m_pMain->m_VersionList.m_UserTypeMap.end(); - for (; Iter1 != Iter2; Iter1++) { - pInfo = (*Iter1).second; - if (pInfo->sVersion == version) { - filename = m_strDefaultPath; - filename += pInfo->strFileName.c_str(); - if (file.Open(filename, CFile::modeRead) == FALSE) { - errmsg.Format("%s File Open Fail", filename); - AfxMessageBox(errmsg); +bool CSettingDlg::Repacking(short sVersion) { + fs::path fsCompFile = m_fsDefaultDir / std::format("patch{:04d}.zip", sVersion); + + std::string szCompFile = fsCompFile.string(); + m_ZipArchive.Open(szCompFile.c_str(), CZipArchive::create); + + for (const auto & [_, pInfo] : m_pMain->m_VersionList.m_UserTypeMap) { + if (pInfo->sVersion == sVersion) { + fs::path fsCurFile = m_fsDefaultDir / pInfo->fsFile; + + CFile file; + std::string szCurFile = fsCurFile.string(); + if (file.Open(szCurFile.c_str(), CFile::modeRead) == FALSE) { + AfxMessageBox(std::format("{:s} File Open Fail", szCurFile).c_str()); continue; } - dwsize = file.GetLength(); + DWORD dwSize = file.GetLength(); file.Close(); - if (!m_ZipArchive.AddNewFile(filename, m_strDefaultPath, -1, dwsize)) { - errmsg.Format("%s File Compress Fail", addfilename.c_str()); - AfxMessageBox(errmsg); + std::string szDefaultDir = m_fsDefaultDir.string(); + if (!m_ZipArchive.AddNewFile(szCurFile.c_str(), szDefaultDir.c_str(), -1, dwSize)) { + AfxMessageBox(std::format("{:s} File Compress Fail", szCurFile).c_str()); return false; } } @@ -341,114 +289,85 @@ bool CSettingDlg::Repacking(int version) { return true; } -bool CSettingDlg::InsertProcess(const char * filename) { - _VERSION_INFO *pInfo1 = NULL, *pInfo2 = NULL; - CString compname, errmsg; - std::string addfilename; - int historyversion = 0; - - if (IsDBCSString(filename)) { - errmsg.Format("%s include DBCS character", filename); - AfxMessageBox(errmsg); +bool CSettingDlg::InsertProcess(const fs::path & fsFile) { + if (IsDBCSString(fsFile.string())) { + AfxMessageBox(std::format("'{:s}' include DBCS character", fsFile.string()).c_str()); return false; } - addfilename = filename; - compname.Format("patch%.4d.zip", m_nVersion); - - pInfo1 = m_pMain->m_VersionList.GetData(addfilename); + short sHistoryVersion = 0; + _VERSION_INFO * pInfo1 = m_pMain->m_VersionList.GetData(fsFile); if (pInfo1) { - historyversion = pInfo1->sVersion; - if (m_pMain->m_VersionList.DeleteData(addfilename) == FALSE) { + sHistoryVersion = pInfo1->sVersion; + if (!m_pMain->m_VersionList.DeleteData(fsFile)) { return false; } - if (m_pMain->m_DBProcess.DeleteVersion(addfilename.c_str()) == FALSE) { - errmsg.Format("%s DB Delete Fail", addfilename.c_str()); - AfxMessageBox(errmsg); + if (!m_pMain->m_DBProcess.DeleteVersion(fsFile)) { + AfxMessageBox(std::format("'{:s}' DB Delete Fail", fsFile.string()).c_str()); return false; } } - pInfo2 = new _VERSION_INFO; - pInfo2->sVersion = m_nVersion; - pInfo2->strFileName = addfilename; - pInfo2->strCompName = compname; - pInfo2->sHistoryVersion = historyversion; - if (m_pMain->m_VersionList.PutData(addfilename, pInfo2) == FALSE) { + _VERSION_INFO * pInfo2 = new _VERSION_INFO; + pInfo2->sVersion = static_cast(m_nVersion); + pInfo2->fsFile = fsFile; + pInfo2->fsPatchFileName = std::format("patch{:04d}.zip", pInfo2->sVersion); + pInfo2->sHistoryVersion = sHistoryVersion; + if (!m_pMain->m_VersionList.PutData(fsFile, pInfo2)) { delete pInfo2; return false; } - if (m_pMain->m_DBProcess.InsertVersion(m_nVersion, addfilename.c_str(), (const char *)(LPCTSTR)compname, - historyversion) == FALSE) { - m_pMain->m_VersionList.DeleteData(addfilename); - errmsg.Format("%s DB Insert Fail", addfilename.c_str()); - AfxMessageBox(errmsg); + if (!m_pMain->m_DBProcess.InsertVersion(m_nVersion, fsFile, pInfo2->fsPatchFileName, sHistoryVersion)) { + m_pMain->m_VersionList.DeleteData(fsFile); + AfxMessageBox(std::format("'{:s}' DB Insert Fail", fsFile.string()).c_str()); return false; } return true; } -void CSettingDlg::OnKillfocusVersionEdit() { +void CSettingDlg::OnKillFocusVersionEdit() { OnRefresh(); } -void CSettingDlg::FolderRecurse(const char * foldername, bool b_test) { - CFileFind ff; - std::string addfilename, addfullpath, defaultpath; - char tempstr1[_MAX_PATH]; - memset(tempstr1, 0x00, _MAX_PATH); - int strsize = 0; - - ::SetCurrentDirectory(foldername); +void CSettingDlg::FolderRecurse(const fs::path & fsDir, bool bVerifyDbcs /*= false*/) { + for (const auto & fsEntry : fs::recursive_directory_iterator(fsDir)) { + fs::path fsFile = fsEntry.path(); - BOOL bFind = ff.FindFile(); - while (bFind) { - bFind = ff.FindNextFile(); - strcpy(tempstr1, ff.GetFilePath()); - - if (ff.IsDots()) { - continue; - } - if (ff.IsDirectory()) { - FolderRecurse(tempstr1, b_test); + // Skip directory names, since we anyway recursively iterating through them + if (fsEntry.is_directory()) { continue; } - if (b_test) { // 단순 검사만 수행... - if (IsDBCSString(tempstr1)) { - CString errmsg; - errmsg.Format("%s include DBCS character", tempstr1); - AfxMessageBox(errmsg); + fsFile.make_relative(m_fsDefaultDir, true).normalize(); + + if (bVerifyDbcs) { // Perform simple DBCS verification + if (IsDBCSString(fsFile.string().c_str())) { + AfxMessageBox(std::format("'{:s}' includes DBCS character", fsFile.string()).c_str()); } continue; } - addfullpath = _strlwr(tempstr1); - defaultpath = _strlwr(m_strDefaultPath); - strsize = defaultpath.size(); - addfilename = addfullpath.substr(strsize); - - if (InsertProcess(&addfilename[0])) { - m_FileList.AddString(&addfilename[0]); + if (InsertProcess(fsFile)) { + m_FileList.AddString(fsFile.string().c_str()); } } } -bool CSettingDlg::IsDBCSString(const char * string) { - int total_count = strlen(string); - - for (int i = 0; i < total_count; i++) { - if (IsDBCSLeadByte(string[i++])) { - return true; - } - } - - return false; +// IsDBCSLeadByte is deprecated and should be avoided. Its behavior may vary with different locales. +bool CSettingDlg::IsDBCSString(const std::string & szStr) { + return std::ranges::any_of(szStr, [](unsigned char ch) { return IsDBCSLeadByte(ch); }); } void CSettingDlg::OnDbcstest() { - FolderRecurse(m_strDefaultPath, true); + FolderRecurse(m_fsDefaultDir, true); AfxMessageBox("Test Done.."); } + +BOOL CSettingDlg::PreTranslateMessage(MSG * pMsg) { + if (m_ToolTip.m_hWnd != NULL) { + m_ToolTip.RelayEvent(pMsg); + } + return CDialog::PreTranslateMessage(pMsg); +} diff --git a/src/server/LoginServer/SettingDlg.h b/src/server/LoginServer/SettingDlg.h index e30d442e..176e3db3 100644 --- a/src/server/LoginServer/SettingDlg.h +++ b/src/server/LoginServer/SettingDlg.h @@ -1,27 +1,23 @@ #pragma once -// SettingDlg.h : header file -// +#include "ZipArchive.h" -#pragma warning(disable : 4786) // Visual C++ Only #include -using namespace std; -#include "ZipArchive.h" +typedef std::set HistoryList; -typedef std::set HistoryList; ///////////////////////////////////////////////////////////////////////////// // CSettingDlg dialog class CLoginServerDlg; class CSettingDlg : public CDialog { // Construction public: - bool IsDBCSString(const char * string); - void FolderRecurse(const char * foldername, bool b_test = false); - bool InsertProcess(const char * filename); - bool Repacking(int version); + bool IsDBCSString(const std::string & szStr); + void FolderRecurse(const fs::path & fsDir, bool bVerifyDbcs = false); + bool InsertProcess(const fs::path & fsFile); + bool Repacking(short sVersion); void RepackingHistory(); - CSettingDlg(int version, CWnd * pParent = NULL); // standard constructor + CSettingDlg(short sVersion, CWnd * pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CSettingDlg) @@ -32,21 +28,30 @@ class CSettingDlg : public CDialog { CListBox m_FileList; CProgressCtrl m_Progress; UINT m_nVersion; - BOOL m_bCompressOption; - BOOL m_bAllFileAdd; + + // If true, repacks previous patches to remove outdated files when they are updated in newer patches. + // Example: If KnightOnLine.exe is updated in patch1265.zip, patch1264.zip will be repacked to remove it, + // ensuring each patch version only contains the latest files. + BOOL m_bRepackPrevVersions; + + BOOL m_bAllFileAdd; //}}AFX_DATA - char m_strDefaultPath[_MAX_PATH]; + fs::path m_fsDefaultDir; CLoginServerDlg * m_pMain; CZipArchive m_ZipArchive; HistoryList m_RepackingVersionList; + private: + CToolTipCtrl m_ToolTip; + // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CSettingDlg) public: virtual BOOL DestroyWindow(); + BOOL PreTranslateMessage(MSG * pMsg) override; protected: virtual void DoDataExchange(CDataExchange * pDX); // DDX/DDV support @@ -56,14 +61,14 @@ class CSettingDlg : public CDialog { protected: // Generated message map functions //{{AFX_MSG(CSettingDlg) - afx_msg void OnAddfile(); - afx_msg void OnDeletefile(); + afx_msg void OnAddFile(); + afx_msg void OnDeleteFile(); afx_msg void OnCompress(); virtual void OnOK(); virtual BOOL OnInitDialog(); afx_msg void OnPathBrowse(); afx_msg void OnRefresh(); - afx_msg void OnKillfocusVersionEdit(); + afx_msg void OnKillFocusVersionEdit(); afx_msg void OnDbcstest(); //}}AFX_MSG DECLARE_MESSAGE_MAP() diff --git a/src/server/LoginServer/User.cpp b/src/server/LoginServer/User.cpp index 40e945cb..b54d959f 100644 --- a/src/server/LoginServer/User.cpp +++ b/src/server/LoginServer/User.cpp @@ -151,36 +151,26 @@ void CUser::MgameLogin(char * pBuf) { Send(send_buff, send_index); } -void CUser::SendDownloadInfo(int version) { - int send_index = 0, filecount = 0; - _VERSION_INFO * pInfo = NULL; - std::set downloadset; - char buff[2048]; - memset(buff, 0x00, 2048); - - std::map::iterator Iter1, Iter2; - Iter1 = m_pMain->m_VersionList.m_UserTypeMap.begin(); - Iter2 = m_pMain->m_VersionList.m_UserTypeMap.end(); - for (; Iter1 != Iter2; Iter1++) { - pInfo = (*Iter1).second; - if (pInfo->sVersion > version) { - downloadset.insert(pInfo->strCompName); +void CUser::SendDownloadInfo(short sVersion) { + int send_index = 0; + char send_buff[2048]{}; + SetByte(send_buff, LS_DOWNLOADINFO_REQ, send_index); + SetShort(send_buff, m_pMain->m_szFtpUrl.length(), send_index); + SetString(send_buff, m_pMain->m_szFtpUrl.data(), m_pMain->m_szFtpUrl.length(), send_index); + SetShort(send_buff, m_pMain->m_szFtpPath.length(), send_index); + SetString(send_buff, m_pMain->m_szFtpPath.data(), m_pMain->m_szFtpPath.length(), send_index); + + std::set vPatchFiles; + for (const auto & [_, pInfo] : m_pMain->m_VersionList.m_UserTypeMap) { + if (pInfo->sVersion == sVersion) { + vPatchFiles.insert(pInfo->fsPatchFileName.string()); } } - - SetByte(buff, LS_DOWNLOADINFO_REQ, send_index); - SetShort(buff, strlen(m_pMain->m_strFtpUrl), send_index); - SetString(buff, m_pMain->m_strFtpUrl, strlen(m_pMain->m_strFtpUrl), send_index); - SetShort(buff, strlen(m_pMain->m_strFilePath), send_index); - SetString(buff, m_pMain->m_strFilePath, strlen(m_pMain->m_strFilePath), send_index); - SetShort(buff, downloadset.size(), send_index); - - std::set::iterator filenameIter1, filenameIter2; - filenameIter1 = downloadset.begin(); - filenameIter2 = downloadset.end(); - for (; filenameIter1 != filenameIter2; filenameIter1++) { - SetShort(buff, strlen((*filenameIter1).c_str()), send_index); - SetString(buff, (char *)((*filenameIter1).c_str()), strlen((*filenameIter1).c_str()), send_index); + SetShort(send_buff, vPatchFiles.size(), send_index); + for (std::string szPatchFile : vPatchFiles) { + SetShort(send_buff, szPatchFile.length(), send_index); + SetString(send_buff, szPatchFile.data(), szPatchFile.length(), send_index); } - Send(buff, send_index); + + Send(send_buff, send_index); } diff --git a/src/server/LoginServer/User.h b/src/server/LoginServer/User.h index fa092626..2a868d3a 100644 --- a/src/server/LoginServer/User.h +++ b/src/server/LoginServer/User.h @@ -16,7 +16,7 @@ class CUser : public CIOCPSocket2 { void Parsing(int len, char * pData); void CloseProcess(); - void SendDownloadInfo(int version); + void SendDownloadInfo(short sVersion); void MgameLogin(char * pBuf); void LogInReq(char * pBuf); diff --git a/src/server/LoginServer/VersionSet.cpp b/src/server/LoginServer/VersionSet.cpp index 723c0f8c..0ecd3965 100644 --- a/src/server/LoginServer/VersionSet.cpp +++ b/src/server/LoginServer/VersionSet.cpp @@ -20,9 +20,8 @@ CVersionSet::CVersionSet(CDatabase * pdb) : CRecordset(pdb) { //{{AFX_FIELD_INIT(CVersionSet) m_sVersion = 0; - m_strFileName = _T(""); - m_bCompressed = 0; - m_nFields = 3; + m_sHistoryVersion = 0; + m_nFields = 4; //}}AFX_FIELD_INIT m_nDefaultType = snapshot; } @@ -39,8 +38,9 @@ void CVersionSet::DoFieldExchange(CFieldExchange * pFX) { //{{AFX_FIELD_MAP(CVersionSet) pFX->SetFieldType(CFieldExchange::outputColumn); RFX_Int(pFX, _T("[sVersion]"), m_sVersion); - RFX_Text(pFX, _T("[strFileName]"), m_strFileName); - RFX_Byte(pFX, _T("[bCompressed]"), m_bCompressed); + RFX_Text(pFX, _T("[strFile]"), m_strFile); + RFX_Text(pFX, _T("[strPatchFileName]"), m_strPatchFileName); + RFX_Int(pFX, _T("[sHistoryVersion]"), m_sHistoryVersion); //}}AFX_FIELD_MAP } diff --git a/src/server/LoginServer/VersionSet.h b/src/server/LoginServer/VersionSet.h index 2d308c03..56adbb15 100644 --- a/src/server/LoginServer/VersionSet.h +++ b/src/server/LoginServer/VersionSet.h @@ -14,8 +14,9 @@ class CVersionSet : public CRecordset { // Field/Param Data //{{AFX_FIELD(CVersionSet, CRecordset) int m_sVersion; - CString m_strFileName; - BYTE m_bCompressed; + CString m_strFile; + CString m_strPatchFileName; + int m_sHistoryVersion; //}}AFX_FIELD // Overrides diff --git a/src/server/LoginServer/res/LoginServer.rc b/src/server/LoginServer/res/LoginServer.rc index 37b47c95..c1322dee 100644 --- a/src/server/LoginServer/res/LoginServer.rc +++ b/src/server/LoginServer/res/LoginServer.rc @@ -81,43 +81,30 @@ BEGIN PUSHBUTTON "Version Setting...(&S)",IDC_SETTING,7,142,197,14 END -IDD_SETTING DIALOG 0, 0, 341, 265 +IDD_SETTING DIALOGEX 0, 0, 379, 265 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Version Setting" -FONT 9, "굴림" +CAPTION "Version Manager" +FONT 9, "굴림", 0, 0, 0x0 BEGIN EDITTEXT IDC_VERSION_EDIT,53,202,31,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER CTEXT "",IDC_STATUS,7,244,214,8 DEFPUSHBUTTON "OK",IDOK,227,244,50,14 - PUSHBUTTON "Cancel",IDCANCEL,284,244,50,14 + PUSHBUTTON "Cancel",IDCANCEL,322,244,50,14 LTEXT "Version :",IDC_STATIC,13,206,30,8 - GROUPBOX "File Compress",IDC_STATIC,7,7,327,176 - LISTBOX IDC_FILE_LIST,13,19,258,135,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Add(&A)...",IDC_ADDFILE,277,20,50,14 - PUSHBUTTON "Delete(&D)",IDC_DELETEFILE,277,40,50,14 - PUSHBUTTON "Compress(&C)",IDC_COMPRESS,277,61,50,14 + GROUPBOX "File Compress",IDC_STATIC,7,7,365,176 + LISTBOX IDC_FILE_LIST,13,19,273,135,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Add(&A)...",IDC_ADDFILE,290,20,80,14 + PUSHBUTTON "Delete(&D)",IDC_DELETEFILE,290,40,80,14 + PUSHBUTTON "Compress(&C)",IDC_COMPRESS,290,60,80,14 + PUSHBUTTON "Refresh(&R)",IDC_REFRESH,290,80,80,14 + PUSHBUTTON "DBCS Test",IDC_DBCSTEST,290,100,80,14 CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,13,166,316,7 - GROUPBOX "Configuration",IDC_STATIC,7,191,327,47 + GROUPBOX "Configuration",IDC_STATIC,7,191,365,47 LTEXT "Base Path :",IDC_STATIC,13,223,39,8 EDITTEXT IDC_PATH_EDIT,53,220,277,14,ES_AUTOHSCROLL PUSHBUTTON "Browse(&B)...",IDC_PATH_BROWSE,280,201,50,14 - PUSHBUTTON "Refresh(&R)",IDC_REFRESH,277,81,50,14 - CONTROL "CurrentVer.",IDC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,278,128,47,10 - CONTROL "All File Add",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,278,146,50,10 - PUSHBUTTON "DBCS Test",IDC_DBCSTEST,277,104,50,14 -END - -IDD_BROWSE_PATH DIALOGEX 0, 0, 167, 272 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Browse Path" -FONT 9, "굴림", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,6,249,72,14 - PUSHBUTTON "Cancel",IDCANCEL,90,249,68,14 - CONTROL "Tree1",IDC_BROWSE_TREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | WS_BORDER | WS_TABSTOP,6,24,153,219 - COMBOBOX IDC_FILELIST,5,5,133,80,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "->",IDC_SYNCH_FOLDERS,144,6,15,14 + CONTROL "Repack Patches",IDC_CHECK_REPACK_VERSIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,290,130,77,10 + CONTROL "Add All Files",IDC_CHECK_ADD_ALL_FILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,290,143,53,10 END @@ -178,7 +165,7 @@ BEGIN IDD_SETTING, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 334 + RIGHTMARGIN, 372 TOPMARGIN, 7 BOTTOMMARGIN, 258 END @@ -186,6 +173,17 @@ END #endif // APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// AFX_DIALOG_LAYOUT +// + +IDD_SETTING AFX_DIALOG_LAYOUT +BEGIN + 0 +END + + ///////////////////////////////////////////////////////////////////////////// // // String Table diff --git a/src/server/LoginServer/res/Resource.h b/src/server/LoginServer/res/Resource.h index 1e5c93dc..008fa99d 100644 --- a/src/server/LoginServer/res/Resource.h +++ b/src/server/LoginServer/res/Resource.h @@ -2,30 +2,26 @@ // Microsoft Visual C++ generated include file. // Used by LoginServer.rc // -#define IDD_LOGINSERVER_DIALOG 102 -#define IDP_SOCKETS_INIT_FAILED 103 -#define IDR_MAINFRAME 128 -#define IDD_SETTING 129 -#define IDD_BROWSE_PATH 130 -#define IDC_LIST1 1000 -#define IDC_SETTING 1001 -#define IDC_VERSION_EDIT 1002 -#define IDC_FILE_LIST 1004 -#define IDC_ADDFILE 1005 -#define IDC_DELETEFILE 1006 -#define IDC_COMPRESS 1007 -#define IDC_PROGRESS 1008 -#define IDC_PATH_EDIT 1009 -#define IDC_SETPATH 1010 -#define IDC_PATH_BROWSE 1011 -#define IDC_REFRESH 1012 -#define IDC_BROWSE_TREE 1013 -#define IDC_STATUS 1013 -#define IDC_FILELIST 1014 -#define IDC_CHECK 1014 -#define IDC_SYNCH_FOLDERS 1015 -#define IDC_CHECK2 1015 -#define IDC_DBCSTEST 1016 +#define IDD_LOGINSERVER_DIALOG 102 +#define IDP_SOCKETS_INIT_FAILED 103 +#define IDR_MAINFRAME 128 +#define IDD_SETTING 129 +#define IDC_LIST1 1000 +#define IDC_SETTING 1001 +#define IDC_VERSION_EDIT 1002 +#define IDC_FILE_LIST 1004 +#define IDC_ADDFILE 1005 +#define IDC_DELETEFILE 1006 +#define IDC_COMPRESS 1007 +#define IDC_PROGRESS 1008 +#define IDC_PATH_EDIT 1009 +#define IDC_SETPATH 1010 +#define IDC_PATH_BROWSE 1011 +#define IDC_REFRESH 1012 +#define IDC_STATUS 1013 +#define IDC_CHECK_REPACK_VERSIONS 1014 +#define IDC_CHECK_ADD_ALL_FILES 1015 +#define IDC_DBCSTEST 1016 // Next default values for new objects // diff --git a/src/tool/KscViewer/KscViewerDoc.cpp b/src/tool/KscViewer/KscViewerDoc.cpp index c98f87e7..8eebe678 100644 --- a/src/tool/KscViewer/KscViewerDoc.cpp +++ b/src/tool/KscViewer/KscViewerDoc.cpp @@ -48,7 +48,7 @@ BOOL CKscViewerDoc::OnNewDocument() { m_pJpegFile->Release(); } - m_szKscPath.Empty(); + m_fsKscFile.clear(); return TRUE; } @@ -81,24 +81,22 @@ void CKscViewerDoc::Dump(CDumpContext & dc) const { // CKscViewerDoc commands BOOL CKscViewerDoc::OnOpenDocument(LPCTSTR lpszPathName) { - // if (!CDocument::OnOpenDocument(lpszPathName)) - // return FALSE; + fs::path fsFile = lpszPathName; + //if (!CDocument::OnOpenDocument(lpszPathName)) { + // return FALSE; + //} if (m_pJpegFile == NULL) { return FALSE; } - char * szExt = NULL; - int nLen = strlen(lpszPathName); - - szExt = (char *)lpszPathName + nLen - 3; - - if (0 == lstrcmpi(szExt, "ksc")) { - if (m_pJpegFile->DecryptJPEG(lpszPathName)) { - m_szKscPath = lpszPathName; + fs::path fsExt = fsFile.extension(); + if (n3std::iequals(fsExt, ".ksc")) { + if (m_pJpegFile->DecryptJPEG(fsFile)) { + m_fsKscFile = fsFile; } - } else if (0 == lstrcmpi(szExt, "jpg")) { - if (m_pJpegFile->LoadJpegFile(lpszPathName)) { - m_szKscPath = lpszPathName; + } else if (n3std::iequals(fsExt, ".jpg")) { + if (m_pJpegFile->LoadJpegFile(fsFile)) { + m_fsKscFile = fsFile; } } @@ -111,63 +109,51 @@ CN3JpegFile * CKscViewerDoc::GetJpegFile() { } BOOL CKscViewerDoc::OnSaveDocument(LPCTSTR lpszPathName) { - if (m_pJpegFile == NULL) { + if (!m_pJpegFile) { return FALSE; } - if (m_szKscPath.IsEmpty()) { + if (m_fsKscFile.empty()) { return FALSE; } - - CString szTemp = m_szKscPath.Right(3); - if (szTemp.CompareNoCase("ksc") != 0) { + if (!n3std::iequals(m_fsKscFile.extension(), ".ksc")) { return FALSE; } - m_pJpegFile->SaveFromDecryptToJpeg(m_szKscPath.GetBuffer(m_szKscPath.GetLength()), lpszPathName); - - return TRUE; + return m_pJpegFile->SaveFromDecryptToJpeg(m_fsKscFile, lpszPathName); } void CKscViewerDoc::OnFileSave() { AfxGetApp()->DoWaitCursor(1); - CString fileName = m_szKscPath.Left(m_szKscPath.GetLength() - 3); - fileName += "jpg"; - - OnSaveDocument(fileName); + fs::path fsJpgFile = fs::path(m_fsKscFile).replace_extension(".jpg"); + OnSaveDocument(fsJpgFile.string().c_str()); AfxGetApp()->DoWaitCursor(-1); } void CKscViewerDoc::OnFileSaveAs() { - if (m_szKscPath.IsEmpty()) { + if (m_fsKscFile.empty()) { return; } - CString szTemp = m_szKscPath.Right(3); - if (szTemp.CompareNoCase("ksc") != 0) { + if (!n3std::iequals(m_fsKscFile.extension(), ".ksc")) { return; } - szTemp = m_szKscPath.Right(m_szKscPath.GetLength() - (m_szKscPath.ReverseFind('\\') + 1)); - szTemp = szTemp.Left(szTemp.GetLength() - 3) + "jpg"; - - CString fileName; - CString filt = "Jpeg File (*.jpg)|*.jpg||"; + fs::path fsFile = m_fsKscFile.stem() + ".jpg"; + CString szFile = fsFile.c_str(); + CString szFilter = "Jpeg File (*.jpg)|*.jpg||"; // OPENFILENAME - so i can get to its Help page easily DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - CFileDialog fileDlg(FALSE, szTemp, szTemp, dwFlags, filt); + CFileDialog fileDlg(FALSE, szFile, szFile, dwFlags, szFilter); - CString initial_dir; - GetCurrentDirectory(MAX_PATH, initial_dir.GetBuffer(MAX_PATH)); - fileDlg.m_ofn.lpstrInitialDir = (LPCTSTR)initial_dir; + std::string szCurDir = fs::current_path().string(); + fileDlg.m_ofn.lpstrInitialDir = szCurDir.c_str(); fileDlg.m_ofn.Flags |= OFN_FILEMUSTEXIST; if (fileDlg.DoModal() == IDOK) { AfxGetApp()->DoWaitCursor(1); - fileName = fileDlg.GetPathName(); - - OnSaveDocument(fileName); + OnSaveDocument(fileDlg.GetPathName()); AfxGetApp()->DoWaitCursor(-1); } } diff --git a/src/tool/KscViewer/KscViewerDoc.h b/src/tool/KscViewer/KscViewerDoc.h index f7cc06b2..5eb06ab6 100644 --- a/src/tool/KscViewer/KscViewerDoc.h +++ b/src/tool/KscViewer/KscViewerDoc.h @@ -27,7 +27,7 @@ class CKscViewerDoc : public CDocument { // Implementation public: - CString m_szKscPath; + fs::path m_fsKscFile; CN3JpegFile * m_pJpegFile; CN3JpegFile * GetJpegFile(); virtual ~CKscViewerDoc(); diff --git a/src/tool/KscViewer/KscViewerView.cpp b/src/tool/KscViewer/KscViewerView.cpp index 2422bf8a..cd53c7ab 100644 --- a/src/tool/KscViewer/KscViewerView.cpp +++ b/src/tool/KscViewer/KscViewerView.cpp @@ -87,21 +87,14 @@ void CKscViewerView::OnDropFiles(HDROP hDropInfo) { CKscViewerDoc * pDoc = GetDocument(); ASSERT_VALID(pDoc); - char szFile[MAX_PATH]; - char * szExt = NULL; - UINT uiFiles; - - uiFiles = DragQueryFile(hDropInfo, 0xFFFF, NULL, 0); - - ::DragQueryFile(hDropInfo, 0, szFile, MAX_PATH - 1); + fs::path::value_type szFile[260]{}; + ::DragQueryFileW(hDropInfo, 0xFFFF, NULL, 0); + ::DragQueryFileW(hDropInfo, 0, szFile, std::size(szFile) - 1); ::DragFinish(hDropInfo); - int nLen = strlen(szFile); - - szExt = szFile + nLen - 3; - + fs::path fsFile = szFile; if (pDoc) { - pDoc->OnOpenDocument(szFile); + pDoc->OnOpenDocument(fsFile.string().c_str()); } CView::OnDropFiles(hDropInfo); diff --git a/src/tool/KscViewer/N3JpegFile.cpp b/src/tool/KscViewer/N3JpegFile.cpp index 009e2bc6..f2558c1b 100644 --- a/src/tool/KscViewer/N3JpegFile.cpp +++ b/src/tool/KscViewer/N3JpegFile.cpp @@ -39,12 +39,12 @@ void CN3JpegFile::Release() { m_uiHeight = 0; } -BOOL CN3JpegFile::LoadJpegFile(std::string csJpeg) { +BOOL CN3JpegFile::LoadJpegFile(const fs::path & fsFile) { // m_buf is the global buffer Release(); // read to buffer tmp - m_pImageBuf = CJpegFile::JpegFileToRGB(csJpeg.c_str(), &m_uiWidth, &m_uiHeight); + m_pImageBuf = CJpegFile::JpegFileToRGB(fsFile, &m_uiWidth, &m_uiHeight); ////////////////////// // set up for display diff --git a/src/tool/KscViewer/N3JpegFile.h b/src/tool/KscViewer/N3JpegFile.h index 523116b0..f1e14922 100644 --- a/src/tool/KscViewer/N3JpegFile.h +++ b/src/tool/KscViewer/N3JpegFile.h @@ -14,7 +14,7 @@ class CN3JpegFile : public CJpegFile { public: void DrawImage(HDC hDC); - BOOL LoadJpegFile(std::string csJpeg); + BOOL LoadJpegFile(const fs::path & fsFile); UINT GetWidth() { return m_uiWidth; } UINT GetHeight() { return m_uiHeight; } BYTE * GetImageBuf() { return m_pImageBuf; } diff --git a/src/tool/Launcher/LauncherDlg.cpp b/src/tool/Launcher/LauncherDlg.cpp index 0ef6b5e7..0744972e 100644 --- a/src/tool/Launcher/LauncherDlg.cpp +++ b/src/tool/Launcher/LauncherDlg.cpp @@ -102,7 +102,7 @@ BOOL CLauncherDlg::OnInitDialog() { MessageBox(szErr); exit(-1); } - m_szInstalledPath = szBuff; + m_fsInstalledDir = szBuff; dwType = REG_SZ; dwBytes = 256; @@ -113,7 +113,7 @@ BOOL CLauncherDlg::OnInitDialog() { MessageBox(szErr); exit(-1); } - m_szExeName = szBuff; + m_fsExeFileName = szBuff; dwType = REG_SZ; dwBytes = 256; @@ -127,17 +127,15 @@ BOOL CLauncherDlg::OnInitDialog() { } // 소켓 접속.. - char szIniPath[_MAX_PATH] = ""; - ::GetCurrentDirectory(_MAX_PATH, szIniPath); - lstrcat(szIniPath, "\\Server.Ini"); - int iServerCount = GetPrivateProfileInt("Server", "Count", 0, szIniPath); + std::string szIniFile = (fs::current_path() / "Server.ini").string(); + const char * pszIniFile = szIniFile.c_str(); - char szIPs[256][128]; - memset(szIPs, 0, sizeof(szIPs)); + int iServerCount = GetPrivateProfileInt("Server", "Count", 0, pszIniFile); + + char szIPs[256][128]{}; for (int i = 0; i < iServerCount; i++) { - char szKey[32] = ""; - sprintf(szKey, "IP%d", i); - GetPrivateProfileString("Server", szKey, "", szIPs[i], 32, szIniPath); + std::string szKey = std::format("IP{:d}", i); + GetPrivateProfileString("Server", szKey.c_str(), "", szIPs[i], sizeof(szIPs[i]), pszIniFile); } if (iServerCount > 0) { @@ -240,17 +238,17 @@ void CLauncherDlg::PacketReceive_DownloadInfo(const BYTE * pBuf, int & iIndex) { AfxPostQuitMessage(0); } - char szBuf[MAX_PATH]; - std::string szVersion; - int nVersion = 0; for (int i = 0; i < m_nGetFileNum; i++) { iLen = m_pSocket->Parse_GetShort(pBuf, iIndex); m_pSocket->Parse_GetString(pBuf, iIndex, m_szGetFileNames[i], iLen); + if (m_szGetFileNames[i].size() != 13) { + MessageBox(std::format("Invalid patch file name ({:s})", m_szGetFileNames[i]).c_str(), "ERROR", MB_OK); + continue; + } - sscanf(m_szGetFileNames[i].c_str(), "patch%s", szBuf); - szVersion = szBuf; - szVersion.resize(4); - nVersion = atoi(szVersion.c_str()); + // "patch1234.zip" + int nVersion = 0; + std::from_chars(m_szGetFileNames[i].data() + 5, m_szGetFileNames[i].data() + 9, nVersion); if (m_nVersionNum[i] < nVersion) { m_nVersionNum[i] = nVersion; } @@ -276,11 +274,12 @@ void CLauncherDlg::PacketReceive_Version(const BYTE * pBuf, int & iIndex) { } void CLauncherDlg::StartGame() { - std::string szCmd = GetCommandLine(); - std::string szAppPath = n3std::get_app_path().string(); - std::string szArgs = szCmd.find(szAppPath) != std::string::npos ? szCmd.substr(szAppPath.length() + 2) : ""; - std::string szExePath = (fs::path(m_szInstalledPath) / m_szExeName).string(); - ::ShellExecute(NULL, "open", szExePath.c_str(), szArgs.c_str(), m_szInstalledPath.c_str(), SW_SHOWNORMAL); + std::wstring szCmd = GetCommandLineW(); + fs::path fsAppPath = n3std::get_app_path(); + std::wstring szArgs = + szCmd.find(fsAppPath) != std::string::npos ? szCmd.substr(fsAppPath.native().length() + 2) : L""; + fs::path fsExeFile = m_fsInstalledDir / m_fsExeFileName; + ::ShellExecuteW(NULL, L"open", fsExeFile.c_str(), szArgs.c_str(), m_fsInstalledDir.c_str(), SW_SHOWNORMAL); PostQuitMessage(0); } @@ -293,20 +292,17 @@ void CLauncherDlg::DownloadProcess() { m_progress.SetRange(0, 100); m_progress.SetPos(0); - std::string szFullPath; - std::string szLocalFName; - bool bExtractSuccess = true; for (int i = 0; i < m_nGetFileNum; i++) { - szFullPath = m_szFtpPath + "/" + m_szGetFileNames[i]; - BOOL bDownloadSuccess = GetDownloadFile(szFullPath, m_szGetFileNames[i]); + std::string szFtpUri = m_szFtpPath + "/" + m_szGetFileNames[i]; + BOOL bDownloadSuccess = GetDownloadFile(szFtpUri, m_szGetFileNames[i]); while (!bDownloadSuccess) { CString szErr; szErr.LoadString(IDS_ERR_DOWNLOAD_PATCH_FILE_AND_RETRY); // 다시 시도할까여?? int iID = MessageBox(szErr, "Patch error", MB_YESNO); if (IDYES == iID) { - bDownloadSuccess = GetDownloadFile(szFullPath, m_szGetFileNames[i]); + bDownloadSuccess = GetDownloadFile(szFtpUri, m_szGetFileNames[i]); } else { AfxPostQuitMessage(-1); break; @@ -314,7 +310,7 @@ void CLauncherDlg::DownloadProcess() { } if (bDownloadSuccess) { - szLocalFName = m_szInstalledPath + "\\" + m_szGetFileNames[i]; + std::string szLocalFile = (m_fsInstalledDir / m_szGetFileNames[i]).string(); CString szInfo; szInfo.LoadString(IDS_INFO_EXTRACTING); @@ -324,11 +320,11 @@ void CLauncherDlg::DownloadProcess() { bExtractSuccess = false; break; } - if (false == ArchiveOpen(szLocalFName.c_str())) { + if (false == ArchiveOpen(szLocalFile.c_str())) { bExtractSuccess = false; break; } - if (false == ArchiveExtract(m_szInstalledPath.c_str())) { + if (false == ArchiveExtract(m_fsInstalledDir.c_str())) { bExtractSuccess = false; break; } @@ -338,9 +334,9 @@ void CLauncherDlg::DownloadProcess() { } CFile file; - if (file.Open(szLocalFName.c_str(), CFile::modeRead | CFile::shareDenyNone, NULL)) { + if (file.Open(szLocalFile.c_str(), CFile::modeRead | CFile::shareDenyNone, NULL)) { file.Close(); - file.Remove(szLocalFName.c_str()); + file.Remove(szLocalFile.c_str()); if (m_hRegistryKey) // 압축 풀기와 쓰기, 압축 파일 삭제에 성공하면 버전을 쓰고.. { RegSetValueEx(m_hRegistryKey, "VERSION", NULL, REG_DWORD, ((BYTE *)(&m_nVersionNum[i])), 4); @@ -362,9 +358,9 @@ void CLauncherDlg::DownloadProcess() { FTP_Close(); - //std::string szIniPath = (n3std::get_app_path() / "server.ini").string(); + //std::string szIniFile = (n3std::get_app_path() / "Server.ini").string(); //std::string szVersion = std::to_string(m_nServerVersion); - //WritePrivateProfileString("VERSION", "CURRENT", szVersion.c_str(), szIniPath.c_str()); + //WritePrivateProfileString("VERSION", "CURRENT", szVersion.c_str(), szIniFile.c_str()); if (true == bExtractSuccess && m_hRegistryKey) // 압축 풀기와 쓰기, 압축 파일 삭제에 성공하면 버전을 쓰고.. { @@ -430,10 +426,8 @@ BOOL CLauncherDlg::GetDownloadFile(const std::string & szFtpUrl, const std::stri } // read & save the file... - std::string szLocalFName; - szLocalFName = m_szInstalledPath + "\\" + szFileName; - - FILE * fp = fopen(szLocalFName.c_str(), "wb"); + fs::path fsLocalFile = m_fsInstalledDir / szFileName; + FILE * fp = _wfopen(fsLocalFile.c_str(), L"wb"); if (fp == NULL) { MessageBox("Can`t open local file"); @@ -466,8 +460,7 @@ BOOL CLauncherDlg::GetDownloadFile(const std::string & szFtpUrl, const std::stri dwCurrent = ::GetTickCount(); dwElaspedTime += dwCurrent - dwLastTime; - std::string szInfo; - szInfo = szFileName + " Downloading..."; + std::string szInfo = std::format("{:s} Downloading...", szFileName); m_Status.SetWindowText(szInfo.c_str()); bPeekMessage = ::PeekMessage(&pMsg, NULL, NULL, NULL, PM_REMOVE); diff --git a/src/tool/Launcher/LauncherDlg.h b/src/tool/Launcher/LauncherDlg.h index f744cc71..3dd65af6 100644 --- a/src/tool/Launcher/LauncherDlg.h +++ b/src/tool/Launcher/LauncherDlg.h @@ -34,10 +34,10 @@ class CLauncherDlg : public CDialog { HINTERNET m_hFtpConnection; class CAPISocket * m_pSocket; - int m_nCurVersion; - char m_strServiceName[256]; - std::string m_szExeName; - std::string m_szInstalledPath; + int m_nCurVersion; + char m_strServiceName[256]; + fs::path m_fsExeFileName; + fs::path m_fsInstalledDir; int m_nServerVersion; std::string m_szFtpUrl; diff --git a/src/tool/N3CE/DlgChrProperty.cpp b/src/tool/N3CE/DlgChrProperty.cpp index 3f3059ec..1bfe3022 100644 --- a/src/tool/N3CE/DlgChrProperty.cpp +++ b/src/tool/N3CE/DlgChrProperty.cpp @@ -178,7 +178,7 @@ void CDlgChrProperty::UpdateInfo() { for (int i = 0; i < nPartCount; i++) { CString szTmp; if (pChr->Part(i)) { - szTmp.Format("Part(%d) : %s", i, pChr->Part(i)->Name()); + szTmp.Format("Part(%d) : %s", i, pChr->Part(i)->FilePath().string().c_str()); } else { szTmp.Format("Part(%d) : Null Pointer !!!", i); } @@ -197,7 +197,7 @@ void CDlgChrProperty::UpdateInfo() { if (pItem) { CN3Joint * pJoint = pChr->Joint(); if (pJoint) { - pItem->m_curValue = pJoint->Name(); + pItem->m_curValue = pJoint->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -207,19 +207,21 @@ void CDlgChrProperty::UpdateInfo() { if (pItem) { CN3VMesh * pMC = pChr->CollisionMesh(); if (pMC) { - pItem->m_curValue = pMC->Name(); + pItem->m_curValue = pMC->FilePath().c_str(); } else { pItem->m_curValue = ""; } } - // pItem = m_LPChr.GetPropItem("Collision Skin File"); - // if(pItem) - // { - // CN3Skin* pSkin = pChr->CollisionSkin(); - // if(pSkin) pItem->m_curValue = pSkin->Name(); - // else pItem->m_curValue = ""; - // } + //pItem = m_LPChr.GetPropItem("Collision Skin File"); + //if (pItem) { + // CN3Skin * pSkin = pChr->CollisionSkin(); + // if (pSkin) { + // pItem->m_curValue = pSkin->FilePath().c_str(); + // } else { + // pItem->m_curValue = ""; + // } + //} __Material * pMtl = NULL; if (nPart >= 0 && nPart < nPartCount) { @@ -229,7 +231,7 @@ void CDlgChrProperty::UpdateInfo() { pItem = m_LPCPart.GetPropItem("Part File"); if (pItem) { - pItem->m_curValue = pPart->Name(); + pItem->m_curValue = pPart->FilePath().c_str(); } pItem = m_LPCPart.GetPropItem("Part Type"); @@ -241,7 +243,7 @@ void CDlgChrProperty::UpdateInfo() { if (pItem) { CN3Texture * pTex = pPart->Tex(); if (pTex) { - pItem->m_curValue = pTex->Name(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -270,7 +272,7 @@ void CDlgChrProperty::UpdateInfo() { pItem = m_LPCPlug.GetPropItem("Plug Name"); if (pItem) { - pItem->m_curValue = pPlug->Name(); + pItem->m_curValue = pPlug->FilePath().c_str(); } pItem = m_LPCPlug.GetPropItem("Plug Type"); @@ -296,7 +298,7 @@ void CDlgChrProperty::UpdateInfo() { pItem = m_LPCPlug.GetPropItem("Plug Mesh File"); if (pItem) { if (pPlug->PMesh()) { - pItem->m_curValue = pPlug->PMesh()->Name(); + pItem->m_curValue = pPlug->PMesh()->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -305,7 +307,7 @@ void CDlgChrProperty::UpdateInfo() { pItem = m_LPCPlug.GetPropItem("Plug Texture File"); if (pItem) { if (pPlug->Tex()) { - pItem->m_curValue = pPlug->Tex()->Name(); + pItem->m_curValue = pPlug->Tex()->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -388,40 +390,27 @@ BOOL CDlgChrProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) int nPlugCount = pChr->PlugCount(); if (pItem->m_propName == "Joint File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.NameSet(pItem->m_curValue); - pChr->JointSet(tmp.Name()); + pChr->JointSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); - } - // else if(pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) - // { - // pChr->CollisionMeshSet(pItem->m_curValue); - // this->UpdateInfo(); - // } - // else if(pItem->m_propName == "Collision Mesh Delete") - // { - // pChr->CollisionMeshSet(""); - // this->UpdateInfo(); - // } - // else if(pItem->m_propName == "Collision Skin File" && pItem->m_curValue.GetLength() > 0) - // { - // pChr->CollisionSkinSet(pItem->m_curValue); - // this->UpdateInfo(); - // } - // else if(pItem->m_propName == "Collision Skin Delete") - // { - // pChr->CollisionSkinSet(""); - // this->UpdateInfo(); - // } - else if (pItem->m_propName == "Part Add") { + //} else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { + // pChr->CollisionMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + // this->UpdateInfo(); + //} else if (pItem->m_propName == "Collision Mesh Delete") { + // pChr->CollisionMeshSet(""); + // this->UpdateInfo(); + //} else if (pItem->m_propName == "Collision Skin File" && pItem->m_curValue.GetLength() > 0) { + // pChr->CollisionSkinSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + // this->UpdateInfo(); + //} else if (pItem->m_propName == "Collision Skin Delete") { + // pChr->CollisionSkinSet(""); + // this->UpdateInfo(); + } else if (pItem->m_propName == "Part Add") { pChr->PartAdd(); this->UpdateInfo(); } else if (pItem->m_propName == "Part Delete") { pChr->PartDelete(nPart); this->UpdateInfo(); - } - - else if (pItem->m_propName == "Plug Add") { + } else if (pItem->m_propName == "Plug Add") { pChr->PlugAdd(); this->UpdateInfo(); } else if (pItem->m_propName == "Plug Delete") { @@ -462,10 +451,7 @@ BOOL CDlgChrProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) } this->UpdateInfo(); } else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.NameSet(pItem->m_curValue); - pPart->TexSet(tmp.Name()); - + pPart->TexSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } } @@ -502,16 +488,11 @@ BOOL CDlgChrProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) pPlug->ScaleSet(__Vector3(pItem->VectorGet())); } else if (pItem->m_propName == "Plug Mesh File" && pItem->m_curValue.GetLength() > 0) { if (pItem->m_curValue != "") { - CN3Base tmp; - tmp.NameSet(pItem->m_curValue); - pPlug->PMeshSet(tmp.Name()); + pPlug->PMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); } this->UpdateInfo(); } else if (pItem->m_propName == "Plug Texture File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.NameSet(pItem->m_curValue); - pPlug->TexSet(tmp.Name()); - + pPlug->TexSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } } diff --git a/src/tool/N3CE/FormViewAnimation.cpp b/src/tool/N3CE/FormViewAnimation.cpp index a9c7e532..e66acfc0 100644 --- a/src/tool/N3CE/FormViewAnimation.cpp +++ b/src/tool/N3CE/FormViewAnimation.cpp @@ -315,7 +315,7 @@ void CFormViewAnimation::UpdateAllInfo() { SetDlgItemInt(IDC_E_SCENE_FRM_END, (int)fFrmE); m_SldSceneFrm.SetRange((int)(fFrmS * FRAME_PRECISION), (int)(fFrmE * FRAME_PRECISION)); - SetDlgItemText(IDC_E_ANI_FILE_NAME, pAniCtrl->FileName().c_str()); + SetDlgItemTextW(GetSafeHwnd(), IDC_E_ANI_FILE_NAME, pAniCtrl->FilePath().c_str()); this->UpdateInfo(); } @@ -600,20 +600,17 @@ void CFormViewAnimation::OnBLoad() { return; } - CString FileName; - DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "N3Anim", NULL, dwFlags, "Animation Data(*.N3Anim)|*.n3Anim||", NULL); - char szCurPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szCurPath); - dlg.m_ofn.lpstrInitialDir = szCurPath; + std::string szCurDir = fs::current_path().string(); + dlg.m_ofn.lpstrInitialDir = szCurDir.c_str(); if (dlg.DoModal() == IDCANCEL) { return; } - FileName = dlg.GetPathName(); - - pAniCtrl->LoadFromFile(std::string(FileName)); + fs::path fsFile = dlg.GetPathName().GetString(); + pAniCtrl->LoadFromFile(fsFile); this->UpdateAllInfo(); } @@ -641,20 +638,16 @@ void CFormViewAnimation::OnBSaveAs() { return; } - CString FileName; - DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(FALSE, "N3Anim", NULL, dwFlags, "Animation Data(*.N3Anim)|*.n3Anim||", NULL); - char szCurPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szCurPath); - dlg.m_ofn.lpstrInitialDir = szCurPath; + std::string szCurDir = fs::current_path().string(); + dlg.m_ofn.lpstrInitialDir = szCurDir.c_str(); if (dlg.DoModal() == IDCANCEL) { return; } - FileName = dlg.GetPathName(); - - pAniCtrl->SaveToFile(std::string(FileName)); + fs::path fsFile = dlg.GetPathName().GetString(); + pAniCtrl->SaveToFile(fsFile); this->UpdateAllInfo(); } diff --git a/src/tool/N3CE/FormViewProperty.cpp b/src/tool/N3CE/FormViewProperty.cpp index be518fbb..ba942114 100644 --- a/src/tool/N3CE/FormViewProperty.cpp +++ b/src/tool/N3CE/FormViewProperty.cpp @@ -274,7 +274,7 @@ void CFormViewProperty::UpdateInfo() { pItem = m_LPPlug.GetPropItem("Mesh"); if (pItem) { if (pPlug->PMesh()) { - pItem->m_curValue = pPlug->PMesh()->FileName().c_str(); + pItem->m_curValue = pPlug->PMesh()->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -282,7 +282,7 @@ void CFormViewProperty::UpdateInfo() { pItem = m_LPPlug.GetPropItem("Texture"); if (pItem) { if (pPlug->Tex()) { - pItem->m_curValue = pPlug->Tex()->FileName().c_str(); + pItem->m_curValue = pPlug->Tex()->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -325,7 +325,7 @@ void CFormViewProperty::UpdateInfo() { pItem = m_LPFXPlugPart.GetPropItem("FXB"); if (pItem) { if (pFXPPart->GetFXB()) { - pItem->m_curValue = pFXPPart->GetFXB()->FileName().c_str(); + pItem->m_curValue = pFXPPart->GetFXB()->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -394,7 +394,7 @@ void CFormViewProperty::UpdateInfo() { if (pTex) { pItem = m_LPMtl.GetPropItem("Texture"); if (pItem) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } } } @@ -442,9 +442,9 @@ BOOL CFormViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult } if (pItem->m_propName == "Texture") { if (pBase->Type() & OBJ_CHARACTER_PART) { - ((CN3CPart *)pBase)->TexSet((LPCTSTR)pItem->m_curValue); + ((CN3CPart *)pBase)->TexSet(pItem->m_curValue.GetString()); } else if (pBase->Type() & OBJ_CHARACTER_PLUG) { - ((CN3CPlug *)pBase)->TexSet((LPCTSTR)pItem->m_curValue); + ((CN3CPlug *)pBase)->TexSet(pItem->m_curValue.GetString()); } UpdateInfo(); } @@ -468,9 +468,9 @@ BOOL CFormViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult } else if (pItem->m_propName == "Rotation") { pFrm->GetPaneRender()->m_eCursorMode = eCM_PlugRotation; } else if (pItem->m_propName == "Mesh") { - pPlug->PMeshSet((const char *)pItem->m_curValue); + pPlug->PMeshSet(pItem->m_curValue.GetString()); } else if (pItem->m_propName == "Texture") { - pPlug->TexSet((const char *)pItem->m_curValue); + pPlug->TexSet(pItem->m_curValue.GetString()); } else if (pItem->m_propName == "Trace Step") { pPlug->m_nTraceStep = atoi(pItem->m_curValue); CN3Chr * pChr = this->GetDocument()->m_Scene.ChrGet(0); @@ -513,9 +513,9 @@ BOOL CFormViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult CN3FXPlugPart * pFXPPart = (CN3FXPlugPart *)pBase; if ("FXB" == pItem->m_propName) { - pFXPPart->SetFXB((LPCTSTR)pItem->m_curValue); + pFXPPart->SetFXB(pItem->m_curValue.GetString()); if (pFXPPart->GetFXB()) { - pItem->m_curValue = pFXPPart->GetFXB()->FileName().c_str(); + pItem->m_curValue = pFXPPart->GetFXB()->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -584,9 +584,8 @@ void CFormViewProperty::UpdateAllInfo() { if (pFXP) { int nFXPPC = pFXP->m_FXPParts.size(); for (int i = 0; i < nFXPPC; ++i) { - char szName[_MAX_PATH]; - wsprintf(szName, "FXPlugPart_%03d", i); - hInsert = m_TreeChr.InsertItem(szName, 11, 11, m_hTI_FXPlug); + std::string szName = std::format("FXPlugPart_{:03d}", i); + hInsert = m_TreeChr.InsertItem(szName.c_str(), 11, 11, m_hTI_FXPlug); m_TreeChr.SetItemData(hInsert, (DWORD)pFXP->m_FXPParts[i]); } } @@ -611,7 +610,7 @@ void CFormViewProperty::UpdateAllInfo() { continue; } - hInsert = m_TreeChr.InsertItem(pChr->Part(i)->FileName().c_str(), 10, 10, m_hTI_Parts); + hInsert = m_TreeChr.InsertItem(pChr->Part(i)->FilePath().string().c_str(), 10, 10, m_hTI_Parts); m_TreeChr.SetItemData(hInsert, (DWORD)pChr->Part(i)); } m_TreeChr.Expand(m_hTI_Parts, TVE_EXPAND); @@ -624,7 +623,7 @@ void CFormViewProperty::UpdateAllInfo() { } CN3CPlugBase * pPlug = pChr->Plug(i); - hInsert = m_TreeChr.InsertItem(pPlug->FileName().c_str(), 11, 11, m_hTI_Plugs); + hInsert = m_TreeChr.InsertItem(pPlug->FilePath().string().c_str(), 11, 11, m_hTI_Plugs); m_TreeChr.SetItemData(hInsert, (DWORD)pPlug); CString szTmp; @@ -677,7 +676,7 @@ void CFormViewProperty::OnTreeChrEndLabelEdit(NMHDR * pNMHDR, LRESULT * pResult) if (pBase) { if (pTDI->item.pszText) { if (pBase->Type() & OBJ_BASE_FILEACCESS) { - ((CN3BaseFileAccess *)pBase)->FileNameSet(pTDI->item.pszText); // 파일 이름을 바꾸어 준다.. + ((CN3BaseFileAccess *)pBase)->FilePathSet(pTDI->item.pszText); // 파일 이름을 바꾸어 준다.. } else { pBase->m_szName = pTDI->item.pszText; } @@ -754,18 +753,15 @@ void CFormViewProperty::OnEditChrJointSet() { pFrm->GetPaneRender()->m_pJointSelected = NULL; - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "N3Joint", NULL, dwFlags, "Joint File(*.N3Joint)|*.N3Joint||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } - FileName = dlg.GetPathName(); - pChr->JointSet(std::string(FileName)); - + fs::path fsFile = dlg.GetPathName().GetString(); + pChr->JointSet(fsFile); pDoc->UpdateAllViews(NULL); - ; } void CFormViewProperty::OnEditChrPartAdd() { @@ -819,16 +815,15 @@ void CFormViewProperty::OnEditChrPartSet() { CN3CPart * pPart = (CN3CPart *)pBase; - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "N3CPart", NULL, dwFlags, "Character Part File(*.N3CPart)|*.N3CPart||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } - FileName = dlg.GetPathName(); + fs::path fsFile = dlg.GetPathName().GetString(); pPart->Release(); - pPart->LoadFromFile(std::string(FileName)); // 파일에서 읽기. + pPart->LoadFromFile(fsFile); // 파일에서 읽기. CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); GetDocument()->UpdateAllViews(NULL); @@ -846,7 +841,7 @@ void CFormViewProperty::OnEditChrPlugAdd() { CN3CPlugBase * pPlug = pChr->PlugAdd(); if (pPlug) { pPlug->m_szName = "Untitled"; - pPlug->FileNameSet("Item\\Untitled.N3CPlug"); + pPlug->FilePathSet(fs::path("Item") / "Untitled.n3cplug"); } pDoc->UpdateAllViews(NULL); } @@ -862,7 +857,7 @@ void CFormViewProperty::OnEditChrPlugAddcloak() { CN3CPlugBase * pPlug = pChr->PlugAdd(PLUGTYPE_CLOAK); if (pPlug) { pPlug->m_szName = "Untitled"; - pPlug->FileNameSet("Item\\Untitled.N3CPlug_Cloak"); + pPlug->FilePathSet(fs::path("Item") / "Untitled.n3cplug_cloak"); } pDoc->UpdateAllViews(NULL); } @@ -905,16 +900,15 @@ void CFormViewProperty::OnEditChrPlugSet() { CN3CPlug * pPlug = (CN3CPlug *)pBase; - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "N3CPlug", NULL, dwFlags, "Character Plug File(*.N3CPlug)|*.N3CPlug||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } - FileName = dlg.GetPathName(); + fs::path fsFile = dlg.GetPathName().GetString(); pPlug->Release(); - pPlug->LoadFromFile(std::string(FileName)); + pPlug->LoadFromFile(fsFile); CN3Chr * pChr = GetDocument()->m_Scene.ChrGet(0); if (pChr) { @@ -1088,17 +1082,16 @@ void CFormViewProperty::OnEditChrPlugImportPMesh() { return; } - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "N3PMesh", NULL, dwFlags, "N3 Progressive Mesh(*.N3PMesh)|*.N3PMesh||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } - FileName = dlg.GetPathName(); + fs::path fsFile = dlg.GetPathName().GetString(); CN3CPlug * pPlug = (CN3CPlug *)pBase; - pPlug->ImportPMesh((const char *)FileName); + pPlug->ImportPMesh(fsFile); CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); pFrm->GetPaneRender()->InvalidateRect(NULL, FALSE); @@ -1112,15 +1105,14 @@ void CFormViewProperty::OnEditFxplugSet() { return; } - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "N3FXPlug", NULL, dwFlags, "FXPlug File(*.N3FXPlug)|*.N3FXPlug||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } - FileName = dlg.GetPathName(); - pChr->FXPlugSet(std::string(FileName)); + fs::path fsFile = dlg.GetPathName().GetString(); + pChr->FXPlugSet(fsFile); pDoc->UpdateAllViews(NULL); } diff --git a/src/tool/N3CE/FormViewTool.cpp b/src/tool/N3CE/FormViewTool.cpp index 8e8cff71..5ffba1df 100644 --- a/src/tool/N3CE/FormViewTool.cpp +++ b/src/tool/N3CE/FormViewTool.cpp @@ -158,9 +158,8 @@ void CFormViewTool::OnBDeleteTestSound0() { int iSel = m_ListSound0.GetCurSel(); if (iSel >= 0) { - CString szFN; - m_ListSound0.GetText(iSel, szFN); - std::string szFN2(szFN); + CString szFile; + m_ListSound0.GetText(iSel, szFile); pFrm->m_SndMgr.ReleaseObj(&(pFrm->m_pSndObj0)); m_ListSound0.DeleteString(iSel); @@ -173,11 +172,10 @@ void CFormViewTool::OnSelchangeListSound0() { int iSel = m_ListSound0.GetCurSel(); if (iSel >= 0) { - CString szFN; - m_ListSound0.GetText(iSel, szFN); - std::string szFN2(szFN); + CString szFile; + m_ListSound0.GetText(iSel, szFile); pFrm->m_SndMgr.ReleaseObj(&(pFrm->m_pSndObj0)); - pFrm->m_pSndObj0 = (pFrm->m_SndMgr.CreateObj(szFN2, SNDTYPE_3D)); + pFrm->m_pSndObj0 = pFrm->m_SndMgr.CreateObj(szFile.GetString(), SNDTYPE_3D); } } @@ -208,9 +206,8 @@ void CFormViewTool::OnBDeleteTestSound1() { int iSel = m_ListSound1.GetCurSel(); if (iSel >= 0) { - CString szFN; - m_ListSound1.GetText(iSel, szFN); - std::string szFN2(szFN); + CString szFile; + m_ListSound1.GetText(iSel, szFile); pFrm->m_SndMgr.ReleaseObj(&(pFrm->m_pSndObj0)); m_ListSound0.DeleteString(iSel); @@ -223,11 +220,10 @@ void CFormViewTool::OnSelchangeListSound1() { int iSel = m_ListSound1.GetCurSel(); if (iSel >= 0) { - CString szFN; - m_ListSound1.GetText(iSel, szFN); - std::string szFN2(szFN); + CString szFile; + m_ListSound1.GetText(iSel, szFile); pFrm->m_SndMgr.ReleaseObj(&(pFrm->m_pSndObj1)); - pFrm->m_pSndObj1 = pFrm->m_SndMgr.CreateObj(szFN2, SNDTYPE_3D); + pFrm->m_pSndObj1 = pFrm->m_SndMgr.CreateObj(szFile.GetString(), SNDTYPE_3D); } } diff --git a/src/tool/N3CE/MainFrm.cpp b/src/tool/N3CE/MainFrm.cpp index a325dd28..ac9a388e 100644 --- a/src/tool/N3CE/MainFrm.cpp +++ b/src/tool/N3CE/MainFrm.cpp @@ -71,7 +71,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); // Engine 생성 // m_Eng.InitEnv(); diff --git a/src/tool/N3CE/N3CEDoc.cpp b/src/tool/N3CE/N3CEDoc.cpp index d0becd85..924cd1d2 100644 --- a/src/tool/N3CE/N3CEDoc.cpp +++ b/src/tool/N3CE/N3CEDoc.cpp @@ -89,25 +89,20 @@ BOOL CN3CEDoc::OnOpenDocument(LPCTSTR lpszPathName) { return FALSE; } - // TODO: Add your specialized creation code here - char szPath[512]; // 경로를 잘 가려야 한다.. - lstrcpy(szPath, lpszPathName); - int nFind = 0; - for (int i = lstrlen(szPath) - 1; i >= 0; i--) { - if ('\\' == szPath[i] || '/' == szPath[i]) { - nFind++; - } - if (nFind >= 2) { - szPath[i] = NULL; - break; - } + // Set the base path based on the currently opened file: + // C:\KnightOnLine\Chr\file.n3chr -> C:\KnightOnLine + fs::path fsFile = lpszPathName; + fs::path fsDir = fsFile.parent_path(); + fs::path fsBaseDir = fsDir; + if (fsBaseDir.has_parent_path()) { + fsBaseDir = fsBaseDir.parent_path(); } m_bLoadingNow = TRUE; - CN3Base::PathSet(szPath); // 경로를 정해주고.. + CN3Base::PathSet(fsBaseDir); m_Scene.ChrGet(0)->Release(); - m_Scene.ChrGet(0)->LoadFromFile(lpszPathName); + m_Scene.ChrGet(0)->LoadFromFile(fsFile); CN3Joint * pJoint = m_Scene.ChrGet(0)->Joint(); if (pJoint) { m_Scene.m_fFrmEnd = pJoint->m_KeyPos.Count() * 30.0f / pJoint->m_KeyRot.SamplingRate(); @@ -130,32 +125,21 @@ BOOL CN3CEDoc::OnOpenDocument(LPCTSTR lpszPathName) { BOOL CN3CEDoc::OnSaveDocument(LPCTSTR lpszPathName) { CDocument::OnSaveDocument(lpszPathName); - // TODO: Add your specialized creation code here - char szPath[512]; // 경로를 잘 가려야 한다.. - lstrcpy(szPath, lpszPathName); - int nFind = 0; - for (int i = lstrlen(szPath) - 1; i >= 0; i--) { - if ('\\' == szPath[i] || '/' == szPath[i]) { - nFind++; - } - if (nFind >= 2) { - szPath[i] = NULL; - break; - } + fs::path fsFile = lpszPathName; + fs::path fsDir = fsFile.parent_path(); + fs::path fsBaseDir = fsDir; + if (fsBaseDir.has_parent_path()) { + fsBaseDir = fsBaseDir.parent_path(); } - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME]; - _splitpath(lpszPathName, szDrive, szDir, szFName, NULL); - - CN3Base::PathSet(szPath); // 경로를 정해주고.. + CN3Base::PathSet(fsBaseDir); CN3Chr * pChr = m_Scene.ChrGet(0); - pChr->m_szName = szFName; // 이름을 정하고.. + pChr->m_szName = fsFile.stem().string(); // 이름을 정하고.. - // CN3Joint* pJoint = pChr->Joint(); - // if(pJoint) - // { - // pJoint->SaveToFile(); // 관절도 저장해준다.. - // } + //CN3Joint * pJoint = pChr->Joint(); + //if (pJoint) { + // pJoint->SaveToFile(); // 관절도 저장해준다.. + //} CN3CPlugBase * pPlug = NULL; int nCPC = pChr->PlugCount(); @@ -169,7 +153,7 @@ BOOL CN3CEDoc::OnSaveDocument(LPCTSTR lpszPathName) { pAni->SaveToFile(); } - m_Scene.ChrGet(0)->SaveToFile(lpszPathName); + m_Scene.ChrGet(0)->SaveToFile(fsFile); m_Scene.SaveResrc(); return TRUE; // 그냥 저장하면 안된다.. 0 Byte 가 된다. @@ -182,32 +166,20 @@ void CN3CEDoc::OnFileSaveAsOneFolder() { if (dlg.DoModal() == IDCANCEL) { return; } - CString szFullFileName = dlg.GetPathName(); - - char szPath[512]; // 경로를 잘 가려야 한다.. - lstrcpy(szPath, szFullFileName); - int nFind = 0; - for (int i = lstrlen(szPath) - 1; i >= 0; i--) { - if ('\\' == szPath[i] || '/' == szPath[i]) { - nFind++; - } - if (nFind >= 2) { - szPath[i] = NULL; - break; - } - } - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - _splitpath(szFullFileName, szDrive, szDir, NULL, NULL); + fs::path fsFile = dlg.GetPathName().GetString(); + fs::path fsDir = fsFile.parent_path(); + fs::path fsBaseDir = fsDir; + if (fsBaseDir.has_parent_path()) { + fsBaseDir = fsBaseDir.parent_path(); + } - CN3Base::PathSet(szPath); // 경로를 정해주고.. + CN3Base::PathSet(fsBaseDir); // 경로를 정해주고.. CN3Chr * pChr = m_Scene.ChrGet(0); CN3Joint * pJoint = pChr->Joint(); if (pJoint) { - char szFN[256]; - _makepath(szFN, szDrive, szDir, pChr->m_szName.c_str(), ".N3Joint"); - pJoint->SaveToFile(szFN); // 관절도 저장해준다.. + pJoint->SaveToFile(fsDir / (pChr->m_szName + ".n3joint")); // 관절도 저장해준다.. } CN3CPlugBase * pPlug = NULL; @@ -218,18 +190,14 @@ void CN3CEDoc::OnFileSaveAsOneFolder() { continue; } - char szFN[256]; if (pPlug->PMesh()) { - _makepath(szFN, szDrive, szDir, pPlug->PMesh()->m_szName.c_str(), ".N3PMesh"); - pPlug->PMesh()->SaveToFile(szFN); + pPlug->PMesh()->SaveToFile(fsDir / (pPlug->PMesh()->m_szName + ".n3pmesh")); } if (pPlug->Tex()) { - _makepath(szFN, szDrive, szDir, pPlug->Tex()->m_szName.c_str(), NULL); - pPlug->Tex()->SaveToFile(szFN); + pPlug->Tex()->SaveToFile(fsDir / (pPlug->Tex()->m_szName + ".dxt")); } - _makepath(szFN, szDrive, szDir, pPlug->m_szName.c_str(), ".N3CPlug"); - pPlug->SaveToFile(szFN); + pPlug->SaveToFile(fsDir / (pPlug->m_szName + ".n3cplug")); } CN3CPart * pPart = NULL; @@ -240,35 +208,26 @@ void CN3CEDoc::OnFileSaveAsOneFolder() { continue; } - char szFN[256]; - if (pPart->Skins()) { - _makepath(szFN, szDrive, szDir, pPart->Skins()->m_szName.c_str(), ".N3CSkins"); - pPart->Skins()->SaveToFile(szFN); + pPart->Skins()->SaveToFile(fsDir / (pPart->Skins()->m_szName + ".n3cskins")); } if (pPart->Tex()) { - _makepath(szFN, szDrive, szDir, pPart->Tex()->m_szName.c_str(), ".DXT"); - pPart->Tex()->SaveToFile(szFN); + pPart->Tex()->SaveToFile(fsDir / (pPart->Tex()->m_szName + ".dxt")); } - _makepath(szFN, szDrive, szDir, pPart->m_szName.c_str(), ".N3CPart"); - pPart->SaveToFile(szFN); + pPart->SaveToFile(fsDir / (pPart->m_szName + ".n3cpart")); } CN3AnimControl * pAni = pChr->AniCtrl(); - if (pAni && pAni->Count() > 0) // 에니메이션은 같은 이름으로 저장해준다.. - { + if (pAni && pAni->Count() > 0) { // 에니메이션은 같은 이름으로 저장해준다.. pAni->m_szName = pChr->m_szName; - - char szFN[256]; - _makepath(szFN, szDrive, szDir, pChr->m_szName.c_str(), ".N3Anim"); CN3Base::s_MngAniCtrl.Add(pAni); - pAni->SaveToFile(szFN); + pAni->SaveToFile(fsDir / (pChr->m_szName + ".n3anim")); } - m_Scene.ChrGet(0)->SaveToFile(std::string(szFullFileName)); - this->SetPathName(szFullFileName); + m_Scene.ChrGet(0)->SaveToFile(fsFile); + this->SetPathName(fsFile.string().c_str()); this->UpdateAllViews(NULL); // 모두 업데이트.. } @@ -305,30 +264,27 @@ void CN3CEDoc::OnToolOptimizeAnimationData() { "원본 Joint 와 Animation File 을 다른 이름으로 저장해 둡니다. 이 파일은 나중에 다시 편집할때 필요합니다.", "Joint 및 Animation 파일 다른이름으로 저장", MB_OK); - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg1(FALSE, "N3Anim", NULL, dwFlags, "Animation Data(*.N3Anim)|*.n3Anim||", NULL); if (dlg1.DoModal() == IDCANCEL) { return; } - FileName = dlg1.GetPathName(); + fs::path fsFile = dlg1.GetPathName().GetString(); - std::string szFN(FileName); - std::string szFNPrev = pAniCtrl->FileName(); - pAniCtrl->SaveToFile(szFN); // 저장.. - pAniCtrl->FileNameSet(szFNPrev); + fs::path fsFilePrev = pAniCtrl->FilePath(); + pAniCtrl->SaveToFile(fsFile); // 저장.. + pAniCtrl->FilePathSet(fsFilePrev); CFileDialog dlg2(FALSE, "N3Joint", NULL, dwFlags, "Joint File(*.N3Joint)|*.N3Joint||", NULL); if (dlg2.DoModal() == IDCANCEL) { return; } - FileName = dlg2.GetPathName(); + fsFile = dlg2.GetPathName().GetString(); - szFNPrev = pJointSrc->FileName(); - pChr->Tick(0.0f); // 초기위치로 Tick - szFN = FileName; - pJointSrc->SaveToFile(szFN); // 원래걸 다른 이름으로 저장.. - pJointSrc->FileNameSet(szFNPrev); + fsFilePrev = pJointSrc->FilePath(); + pChr->Tick(0.0f); // 초기위치로 Tick + pJointSrc->SaveToFile(fsFile); // 원래걸 다른 이름으로 저장.. + pJointSrc->FilePathSet(fsFilePrev); int nK = pAniCtrl->Count(); CN3Joint JointDest; @@ -373,8 +329,8 @@ void CN3CEDoc::OnToolOptimizeAnimationData() { JointDest.SaveToFile(); pChr->Tick(0.0f); // 초기위치로 Tick - pChr->JointSet(""); - pChr->JointSet(JointDest.FileName()); + pChr->JointSet(fs::path()); + pChr->JointSet(JointDest.FilePath()); UpdateAllViews(NULL); // 모든 뷰 초기화.. } diff --git a/src/tool/N3CE/N3CEView.cpp b/src/tool/N3CE/N3CEView.cpp index 425e117b..34e2daff 100644 --- a/src/tool/N3CE/N3CEView.cpp +++ b/src/tool/N3CE/N3CEView.cpp @@ -483,12 +483,13 @@ BOOL CN3CEView::OnDrop(COleDataObject * pDataObject, DROPEFFECT dropEffect, CPoi void CN3CEView::OnDropFiles(HDROP hDropInfo) { // TODO: Add your message handler code here and/or call default - char szFN[256]; - ::DragQueryFile(hDropInfo, 0, szFN, 256); + fs::path::value_type szFile[260]{}; + ::DragQueryFileW(hDropInfo, 0, szFile, std::size(szFile) - 1); ::DragFinish(hDropInfo); - if (lstrlen(szFN) > 0) { - GetDocument()->OnOpenDocument(szFN); + fs::path fsFile = szFile; + if (!fsFile.empty()) { + GetDocument()->OnOpenDocument(fsFile.string().c_str()); } CView::OnDropFiles(hDropInfo); diff --git a/src/tool/N3FXE/DlgEditFxg.cpp b/src/tool/N3FXE/DlgEditFxg.cpp index bc605bdc..ca9f0627 100644 --- a/src/tool/N3FXE/DlgEditFxg.cpp +++ b/src/tool/N3FXE/DlgEditFxg.cpp @@ -104,10 +104,10 @@ BOOL CDlgEditFxg::OnInitDialog() { return TRUE; } -bool CDlgEditFxg::LoadScript(const char * szPath) { - m_strFileName = szPath; +bool CDlgEditFxg::LoadScript(const fs::path & fsFile) { + m_strFileName = fsFile.c_str(); CN3FXGroup * pGroup = new CN3FXGroup; - if (!pGroup->DecodeScriptFile(szPath)) { + if (!pGroup->DecodeScriptFile(fsFile)) { delete pGroup; return false; } @@ -120,7 +120,7 @@ bool CDlgEditFxg::LoadScript(const char * szPath) { m_pJoint[i]->SetCurSel(pInfo->joint); *(m_pLoop[i]) = pInfo->IsLooping; - m_pFXBName[i]->Format(pInfo->FXBName); + m_pFXBName[i]->Format(pInfo->szFxbFile); } UpdateData(FALSE); // @@ -131,23 +131,21 @@ bool CDlgEditFxg::LoadScript(const char * szPath) { } void CDlgEditFxg::SaveGameData() { + fs::path fsFile = m_strFileName.GetString(); + //OnBtnSave(); - if (m_strFileName.IsEmpty()) { + if (fsFile.empty()) { return; } CN3FXGroup * pGroup = new CN3FXGroup; - if (!pGroup->DecodeScriptFile((LPCTSTR)m_strFileName)) { + if (!pGroup->DecodeScriptFile(fsFile)) { delete pGroup; return; } - char szPath[_MAX_PATH]; - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(m_strFileName, szDrive, szDir, szFName, szExt); - _makepath(szPath, szDrive, szDir, szFName, "fxg"); - - pGroup->SaveToFile(szPath); + fs::path fsFxgFile = fs::path(fsFile).replace_extension(".fxg"); + pGroup->SaveToFile(fsFxgFile); delete pGroup; return; @@ -166,23 +164,17 @@ void CDlgEditFxg::OnBtnSaveAs() { UpdateData(TRUE); CDlgNewFileName dlg; - dlg.m_strExt = ".N3FXGroup"; - if (dlg.DoModal() == IDOK) { - CString PathName = "fx\\"; - PathName += dlg.m_strNewFileName; - PathName += dlg.m_strExt; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - - m_strFileName.Empty(); - m_strFileName = CN3Base::PathGet().c_str(); - m_strFileName += pBaseFileAccess->FileName().c_str(); - - delete pBaseFileAccess; - - UpdateData(FALSE); - OnBtnSave(); + dlg.m_strExt = ".n3fxgroup"; + if (dlg.DoModal() == IDCANCEL) { + return; } + + fs::path fsFile = CN3Base::PathGet() / "fx" / dlg.m_strNewFileName.GetString(); + fsFile += dlg.m_strExt.GetString(); + m_strFileName = fsFile.c_str(); + + UpdateData(FALSE); + OnBtnSave(); } void CDlgEditFxg::OnBtnSave() { @@ -227,8 +219,7 @@ void CDlgEditFxg::OnBtnLoadFxb0() { return; } - m_strFXBName_0 = "fx\\"; - m_strFXBName_0 = dlg.GetFileName(); + m_strFXBName_0 = (fs::path("fx") / dlg.GetFileName().GetString()).c_str(); UpdateData(FALSE); } @@ -240,8 +231,7 @@ void CDlgEditFxg::OnBtnLoadFxb1() { return; } - m_strFXBName_1 = "fx\\"; - m_strFXBName_1 = dlg.GetFileName(); + m_strFXBName_1 = (fs::path("fx") / dlg.GetFileName().GetString()).c_str(); UpdateData(FALSE); } @@ -253,8 +243,7 @@ void CDlgEditFxg::OnBtnLoadFxb2() { return; } - m_strFXBName_2 = "fx\\"; - m_strFXBName_2 = dlg.GetFileName(); + m_strFXBName_2 = (fs::path("fx") / dlg.GetFileName().GetString()).c_str(); UpdateData(FALSE); } @@ -266,7 +255,6 @@ void CDlgEditFxg::OnBtnLoadFxb3() { return; } - m_strFXBName_3 = "fx\\"; - m_strFXBName_3 = dlg.GetFileName(); + m_strFXBName_3 = (fs::path("fx") / dlg.GetFileName().GetString()).c_str(); UpdateData(FALSE); } diff --git a/src/tool/N3FXE/DlgEditFxg.h b/src/tool/N3FXE/DlgEditFxg.h index 73b050ea..e30168d1 100644 --- a/src/tool/N3FXE/DlgEditFxg.h +++ b/src/tool/N3FXE/DlgEditFxg.h @@ -21,7 +21,7 @@ class CDlgEditFxg : public CDialog { CString * m_pFXBName[MAX_FXB]; //functions... - bool LoadScript(const char * szPath); + bool LoadScript(const fs::path & fsFile); void SaveGameData(); // Dialog Data diff --git a/src/tool/N3FXE/DlgEditPartBillBoard.cpp b/src/tool/N3FXE/DlgEditPartBillBoard.cpp index 4995ad8d..548ddd2e 100644 --- a/src/tool/N3FXE/DlgEditPartBillBoard.cpp +++ b/src/tool/N3FXE/DlgEditPartBillBoard.cpp @@ -142,36 +142,22 @@ void CDlgEditPartBillBoard::OnPartBoardBtnLoadTex() { return; } - CString PathName = dlg.GetPathName(); - - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - PathName = pBaseFileAccess->FileName().c_str(); - - if ((PathName[0] == 'F' || PathName[0] == 'f') && (PathName[1] == 'X' || PathName[1] == 'x') && - (PathName[2] == '/' || PathName[2] == '\\')) { - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath((LPCTSTR)PathName, szDrive, szDir, szFName, szExt); - - CString strFName = szFName; - if (strFName.Right(4) == _T("0000")) { - strFName.TrimRight("0000"); - char szPath[_MAX_PATH]; - _makepath(szPath, szDrive, szDir, (LPCTSTR)strFName, szExt); - m_strTexName = szPath; - - //파일 갯수 세는 기능 넣을까 말까.. + fs::path fsFile = CN3BaseFileAccess::ToRelative(dlg.GetPathName().GetString()); + if (n3std::iequals(*fsFile.begin(), "fx")) { + std::string szStem = fsFile.stem().string(); + if (szStem.ends_with("0000")) { + szStem.erase((szStem.find_last_not_of("0000")) + 1); + fs::path fsTexFile = fsFile.parent_path() / (szStem + fsFile.extension()); + m_strTexName = fsTexFile.c_str(); } else { m_strTexName = _T(""); - MessageBox("파일 이름끝이 0000이 아니던데요..-.-;;", "ERR05", MB_OK); + MessageBox("The file name must end with 0000.", "ERR05", MB_OK); } UpdateData(FALSE); } else { - MessageBox("Texture파일은 fx폴더 아래, 혹은 fx폴더 아래에 있는 폴더에 위치해야 합니다..-.-;;", "ERR04", MB_OK); + MessageBox("Texture files must be located under the fx folder or a subfolder.", "ERR04", MB_OK); } - - delete pBaseFileAccess; } void CDlgEditPartBillBoard::OnPartBoardBtnSave() { @@ -279,23 +265,16 @@ void CDlgEditPartBillBoard::OnPartBoardBtnSaveAs() { UpdateData(TRUE); CDlgNewFileName dlg; - dlg.m_strExt = ".N3FXPart"; - if (dlg.DoModal() == IDOK) { - CString PathName = "fx\\"; - PathName += dlg.m_strNewFileName; - PathName += dlg.m_strExt; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - - m_strPathName.Empty(); - m_strPathName = CN3Base::PathGet().c_str(); - m_strPathName += pBaseFileAccess->FileName().c_str(); + dlg.m_strExt = ".n3fxpart"; + if (dlg.DoModal() == IDCANCEL) { + return; + } - delete pBaseFileAccess; + fs::path fsFile = CN3Base::PathGet() / "fx" / (dlg.m_strNewFileName + dlg.m_strExt).GetString(); + m_strPathName = fsFile.c_str(); - UpdateData(FALSE); - OnPartBoardBtnSave(); - } + UpdateData(FALSE); + OnPartBoardBtnSave(); } void CDlgEditPartBillBoard::OnOK() { @@ -341,10 +320,10 @@ BOOL CDlgEditPartBillBoard::OnInitDialog() { // EXCEPTION: OCX Property Pages should return FALSE } -bool CDlgEditPartBillBoard::LoadPartScript(const char * szPath) { - m_strPathName = szPath; +bool CDlgEditPartBillBoard::LoadPartScript(const fs::path & fsFile) { + m_strPathName = fsFile.c_str(); CN3FXPartBillBoard * pPart = new CN3FXPartBillBoard; - if (!pPart->DecodeScriptFile(szPath)) { + if (!pPart->DecodeScriptFile(fsFile)) { delete pPart; return false; } @@ -394,16 +373,17 @@ bool CDlgEditPartBillBoard::LoadPartScript(const char * szPath) { m_bRotateY = pPart->m_bRoateOnlyY; - if (m_iNumTex > 0) { - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath((LPCTSTR)pPart->m_ppRefTex[0]->FileName().c_str(), szDrive, szDir, szFName, szExt); - - CString strFName = szFName; - strFName.TrimRight("0000"); - - char szPath[_MAX_PATH]; - _makepath(szPath, szDrive, szDir, (LPCTSTR)strFName, szExt); - m_strTexName = szPath; + if (m_iNumTex > 0 && pPart->m_ppRefTex[0]) { + fs::path fsFile = pPart->m_ppRefTex[0]->FilePath(); + std::string szStem = fsFile.stem().string(); + if (szStem.ends_with("0000")) { + szStem.erase((szStem.find_last_not_of("0000")) + 1); + fs::path fsTexFile = fsFile.parent_path() / (szStem + fsFile.extension()); + m_strTexName = fsTexFile.c_str(); + } else { + m_strTexName = _T(""); + MessageBox("The file name must end with 0000.", "ERR05", MB_OK); + } } else { m_strTexName = _T(""); } diff --git a/src/tool/N3FXE/DlgEditPartBillBoard.h b/src/tool/N3FXE/DlgEditPartBillBoard.h index abadaf29..18d0e7cb 100644 --- a/src/tool/N3FXE/DlgEditPartBillBoard.h +++ b/src/tool/N3FXE/DlgEditPartBillBoard.h @@ -59,7 +59,7 @@ class CDlgEditPartBillBoard : public CDialog { float m_fRotBillBoardZ; //}}AFX_DATA - bool LoadPartScript(const char * szPath); + bool LoadPartScript(const fs::path & fsFile); // Overrides // ClassWizard generated virtual function overrides diff --git a/src/tool/N3FXE/DlgEditPartGround.cpp b/src/tool/N3FXE/DlgEditPartGround.cpp index 14399eb2..638b6f95 100644 --- a/src/tool/N3FXE/DlgEditPartGround.cpp +++ b/src/tool/N3FXE/DlgEditPartGround.cpp @@ -98,10 +98,10 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDlgEditPartGround message handlers -bool CDlgEditPartGround::LoadPartScript(const char * szPath) { - m_strPathName = szPath; +bool CDlgEditPartGround::LoadPartScript(const fs::path & fsFile) { + m_strPathName = fsFile.c_str(); CN3FXPartBottomBoard * pPart = new CN3FXPartBottomBoard; - if (!pPart->DecodeScriptFile(szPath)) { + if (!pPart->DecodeScriptFile(fsFile)) { delete pPart; return false; } @@ -152,16 +152,17 @@ bool CDlgEditPartGround::LoadPartScript(const char * szPath) { m_fGap = pPart->m_fGap; - if (m_iNumTex > 0) { - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath((LPCTSTR)pPart->m_ppRefTex[0]->FileName().c_str(), szDrive, szDir, szFName, szExt); - - CString strFName = szFName; - strFName.TrimRight("0000"); - - char szPath[_MAX_PATH]; - _makepath(szPath, szDrive, szDir, (LPCTSTR)strFName, szExt); - m_strTexName = szPath; + if (m_iNumTex > 0 && pPart->m_ppRefTex[0]) { + fs::path fsFile = pPart->m_ppRefTex[0]->FilePath(); + std::string szStem = fsFile.stem().string(); + if (szStem.ends_with("0000")) { + szStem.erase((szStem.find_last_not_of("0000")) + 1); + fs::path fsTexFile = fsFile.parent_path() / (szStem + fsFile.extension()); + m_strTexName = fsTexFile.c_str(); + } else { + m_strTexName = _T(""); + MessageBox("The file name must end with 0000.", "ERR05", MB_OK); + } } else { m_strTexName = _T(""); } @@ -269,59 +270,38 @@ void CDlgEditPartGround::OnPartGroundBtnLoadTex() { return; } - CString PathName = dlg.GetPathName(); - - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - PathName = pBaseFileAccess->FileName().c_str(); - - if ((PathName[0] == 'F' || PathName[0] == 'f') && (PathName[1] == 'X' || PathName[1] == 'x') && - (PathName[2] == '/' || PathName[2] == '\\')) { - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath((LPCTSTR)PathName, szDrive, szDir, szFName, szExt); - - CString strFName = szFName; - if (strFName.Right(4) == _T("0000")) { - strFName.TrimRight("0000"); - char szPath[_MAX_PATH]; - _makepath(szPath, szDrive, szDir, (LPCTSTR)strFName, szExt); - m_strTexName = szPath; - - //파일 갯수 세는 기능 넣을까 말까.. + fs::path fsFile = CN3BaseFileAccess::ToRelative(dlg.GetPathName().GetString()); + if (n3std::iequals(*fsFile.begin(), "fx")) { + std::string szStem = fsFile.stem().string(); + if (szStem.ends_with("0000")) { + szStem.erase((szStem.find_last_not_of("0000")) + 1); + fs::path fsTexFile = fsFile.parent_path() / (szStem + fsFile.extension()); + m_strTexName = fsTexFile.c_str(); } else { m_strTexName = _T(""); - MessageBox("파일 이름끝이 0000이 아니던데요..-.-;;", "ERR05", MB_OK); + MessageBox("The file name must end with 0000.", "ERR05", MB_OK); } UpdateData(FALSE); } else { - MessageBox("Texture파일은 fx폴더 아래, 혹은 fx폴더 아래에 있는 폴더에 위치해야 합니다..-.-;;", "ERR04", MB_OK); + MessageBox("Texture files must be located under the fx folder or a subfolder.", "ERR04", MB_OK); } - - delete pBaseFileAccess; } void CDlgEditPartGround::OnPartGroundBtnSaveAs() { UpdateData(TRUE); CDlgNewFileName dlg; - dlg.m_strExt = ".N3FXPart"; - if (dlg.DoModal() == IDOK) { - CString PathName = "fx\\"; - PathName += dlg.m_strNewFileName; - PathName += dlg.m_strExt; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - - m_strPathName.Empty(); - m_strPathName = CN3Base::PathGet().c_str(); - m_strPathName += pBaseFileAccess->FileName().c_str(); + dlg.m_strExt = ".n3fxpart"; + if (dlg.DoModal() == IDCANCEL) { + return; + } - delete pBaseFileAccess; + fs::path fsFile = CN3Base::PathGet() / "fx" / (dlg.m_strNewFileName + dlg.m_strExt).GetString(); + m_strPathName = fsFile.c_str(); - UpdateData(FALSE); - OnPartGroundBtnSave(); - } + UpdateData(FALSE); + OnPartGroundBtnSave(); } void CDlgEditPartGround::OnClose() { diff --git a/src/tool/N3FXE/DlgEditPartGround.h b/src/tool/N3FXE/DlgEditPartGround.h index 5b7aaf11..65690211 100644 --- a/src/tool/N3FXE/DlgEditPartGround.h +++ b/src/tool/N3FXE/DlgEditPartGround.h @@ -51,7 +51,7 @@ class CDlgEditPartGround : public CDialog { BOOL m_bZWrite; //}}AFX_DATA - bool LoadPartScript(const char * szPath); + bool LoadPartScript(const fs::path & fsFile); // Overrides // ClassWizard generated virtual function overrides diff --git a/src/tool/N3FXE/DlgEditPartMesh.cpp b/src/tool/N3FXE/DlgEditPartMesh.cpp index 704d179c..33efb991 100644 --- a/src/tool/N3FXE/DlgEditPartMesh.cpp +++ b/src/tool/N3FXE/DlgEditPartMesh.cpp @@ -237,29 +237,22 @@ void CDlgEditPartMesh::OnPartMeshBtnSaveAs() { UpdateData(TRUE); CDlgNewFileName dlg; - dlg.m_strExt = ".N3FXPart"; - if (dlg.DoModal() == IDOK) { - CString PathName = "fx\\"; - PathName += dlg.m_strNewFileName; - PathName += dlg.m_strExt; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - - m_strPathName.Empty(); - m_strPathName = CN3Base::PathGet().c_str(); - m_strPathName += pBaseFileAccess->FileName().c_str(); + dlg.m_strExt = ".n3fxpart"; + if (dlg.DoModal() == IDCANCEL) { + return; + } - delete pBaseFileAccess; + fs::path fsFile = CN3Base::PathGet() / "fx" / (dlg.m_strNewFileName + dlg.m_strExt).GetString(); + m_strPathName = fsFile.c_str(); - UpdateData(FALSE); - OnPartMeshBtnSave(); - } + UpdateData(FALSE); + OnPartMeshBtnSave(); } -bool CDlgEditPartMesh::LoadPartScript(const char * szPath) { - m_strPathName = szPath; +bool CDlgEditPartMesh::LoadPartScript(const fs::path & fsFile) { + m_strPathName = fsFile.c_str(); CN3FXPartMesh * pPart = new CN3FXPartMesh; - if (!pPart->DecodeScriptFile(szPath)) { + if (!pPart->DecodeScriptFile(fsFile)) { delete pPart; return false; } @@ -280,7 +273,7 @@ bool CDlgEditPartMesh::LoadPartScript(const char * szPath) { m_bZWrite = pPart->m_dwZWrite; m_bTexLoop = pPart->m_bTexLoop; - m_strShapeName = pPart->m_pShape->FileName().c_str(); + m_strShapeName = pPart->m_pShape->FilePath().c_str(); m_fTexVelocity = pPart->m_fTexFPS; if (pPart->m_cTextureMoveDir == 1) { @@ -394,21 +387,13 @@ void CDlgEditPartMesh::OnPartMeshBtnLoadShape() { return; } - CString PathName = dlg.GetPathName(); - - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - PathName = pBaseFileAccess->FileName().c_str(); - - if ((PathName[0] == 'F' || PathName[0] == 'f') && (PathName[1] == 'X' || PathName[1] == 'x') && - (PathName[2] == '/' || PathName[2] == '\\')) { - m_strShapeName = PathName; + fs::path fsFile = CN3BaseFileAccess::ToRelative(dlg.GetPathName().GetString()); + if (n3std::iequals(*fsFile.begin(), "fx")) { + m_strShapeName = fsFile.c_str(); UpdateData(FALSE); } else { - MessageBox("N3Shape파일은 fx폴더 아래, 혹은 fx폴더 아래에 있는 폴더에 위치해야 합니다..-.-;;", "ERR03", MB_OK); + MessageBox("N3Shape files must be located under the fx folder or a subfolder.", "ERR03", MB_OK); } - - delete pBaseFileAccess; } void CDlgEditPartMesh::OnClose() { diff --git a/src/tool/N3FXE/DlgEditPartMesh.h b/src/tool/N3FXE/DlgEditPartMesh.h index 7849223d..c9f622f5 100644 --- a/src/tool/N3FXE/DlgEditPartMesh.h +++ b/src/tool/N3FXE/DlgEditPartMesh.h @@ -61,7 +61,7 @@ class CDlgEditPartMesh : public CDialog { BOOL m_bZWrite; //}}AFX_DATA - bool LoadPartScript(const char * szPath); + bool LoadPartScript(const fs::path & fsFile); // Overrides // ClassWizard generated virtual function overrides diff --git a/src/tool/N3FXE/DlgEditPartParticle.cpp b/src/tool/N3FXE/DlgEditPartParticle.cpp index bf2be24b..e5263f04 100644 --- a/src/tool/N3FXE/DlgEditPartParticle.cpp +++ b/src/tool/N3FXE/DlgEditPartParticle.cpp @@ -333,10 +333,10 @@ void CDlgEditPartParticle::OnPartParticleBtnSave() { fclose(file); } -bool CDlgEditPartParticle::LoadPartScript(const char * szPath) { - m_strPathName = szPath; +bool CDlgEditPartParticle::LoadPartScript(const fs::path & fsFile) { + m_strPathName = fsFile.c_str(); CN3FXPartParticles * pPart = new CN3FXPartParticles; - if (!pPart->DecodeScriptFile(szPath)) { + if (!pPart->DecodeScriptFile(fsFile)) { delete pPart; return false; } @@ -378,15 +378,16 @@ bool CDlgEditPartParticle::LoadPartScript(const char * szPath) { m_fTexRotVelocity = pPart->m_fTexRotateVelocity; if (m_iNumTex > 0 && pPart->m_ppRefTex[0]) { - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath((LPCTSTR)pPart->m_ppRefTex[0]->FileName().c_str(), szDrive, szDir, szFName, szExt); - - CString strFName = szFName; - strFName.TrimRight("0000"); - - char szPath[_MAX_PATH]; - _makepath(szPath, szDrive, szDir, (LPCTSTR)strFName, szExt); - m_strTexName = szPath; + fs::path fsFile = pPart->m_ppRefTex[0]->FilePath(); + std::string szStem = fsFile.stem().string(); + if (szStem.ends_with("0000")) { + szStem.erase((szStem.find_last_not_of("0000")) + 1); + fs::path fsTexFile = fsFile.parent_path() / (szStem + fsFile.extension()); + m_strTexName = fsTexFile.c_str(); + } else { + m_strTexName = _T(""); + MessageBox("The file name must end with 0000.", "ERR05", MB_OK); + } } else { m_strTexName = _T(""); } @@ -457,7 +458,7 @@ bool CDlgEditPartParticle::LoadPartScript(const char * szPath) { } if (pPart->m_pShape) { - m_strShapeName = pPart->m_pShape->FileName().c_str(); + m_strShapeName = pPart->m_pShape->FilePath().c_str(); } m_fShapeFPS = pPart->m_fMeshFPS; m_bAnimKey = pPart->m_bAnimKey; @@ -474,23 +475,16 @@ void CDlgEditPartParticle::OnPartParticleBtnSaveAs() { UpdateData(TRUE); CDlgNewFileName dlg; - dlg.m_strExt = ".N3FXPart"; - if (dlg.DoModal() == IDOK) { - CString PathName = "fx\\"; - PathName += dlg.m_strNewFileName; - PathName += dlg.m_strExt; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - - m_strPathName.Empty(); - m_strPathName = CN3Base::PathGet().c_str(); - m_strPathName += pBaseFileAccess->FileName().c_str(); + dlg.m_strExt = ".n3fxpart"; + if (dlg.DoModal() == IDCANCEL) { + return; + } - delete pBaseFileAccess; + fs::path fsFile = CN3Base::PathGet() / "fx" / (dlg.m_strNewFileName + dlg.m_strExt).GetString(); + m_strPathName = fsFile.c_str(); - UpdateData(FALSE); - OnPartParticleBtnSave(); - } + UpdateData(FALSE); + OnPartParticleBtnSave(); } void CDlgEditPartParticle::OnPartParticleBtnLoadTex() { @@ -500,36 +494,22 @@ void CDlgEditPartParticle::OnPartParticleBtnLoadTex() { return; } - CString PathName = dlg.GetPathName(); - - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - PathName = pBaseFileAccess->FileName().c_str(); - - if ((PathName[0] == 'F' || PathName[0] == 'f') && (PathName[1] == 'X' || PathName[1] == 'x') && - (PathName[2] == '/' || PathName[2] == '\\')) { - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath((LPCTSTR)PathName, szDrive, szDir, szFName, szExt); - - CString strFName = szFName; - if (strFName.Right(4) == _T("0000")) { - strFName.TrimRight("0000"); - char szPath[_MAX_PATH]; - _makepath(szPath, szDrive, szDir, (LPCTSTR)strFName, szExt); - m_strTexName = szPath; + fs::path fsFile = CN3BaseFileAccess::ToRelative(dlg.GetPathName().GetString()); + if (n3std::iequals(*fsFile.begin(), "fx")) { + std::string szStem = fsFile.stem().string(); + if (szStem.ends_with("0000")) { + szStem.erase((szStem.find_last_not_of("0000")) + 1); + fs::path fsTexFile = fsFile.parent_path() / (szStem + fsFile.extension()); + m_strTexName = fsTexFile.c_str(); } else { m_strTexName = _T(""); - MessageBox("파일 이름끝이 0000이 아니던데요..-.-;;", "ERR05", MB_OK); + MessageBox("The file name must end with 0000.", "ERR05", MB_OK); } - //파일 갯수 세는 기능 넣을까 말까..^^ - UpdateData(FALSE); } else { - MessageBox("Texture파일은 fx폴더 아래, 혹은 fx폴더 아래에 있는 폴더에 위치해야 합니다..-.-;;", "ERR04", MB_OK); + MessageBox("Texture files must be located under the fx folder or a subfolder.", "ERR04", MB_OK); } - - delete pBaseFileAccess; } void CDlgEditPartParticle::OnClose() { @@ -610,19 +590,11 @@ void CDlgEditPartParticle::OnPartParticleBtnLoadMesh() { return; } - CString PathName = dlg.GetPathName(); - - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - PathName = pBaseFileAccess->FileName().c_str(); - - if ((PathName[0] == 'F' || PathName[0] == 'f') && (PathName[1] == 'X' || PathName[1] == 'x') && - (PathName[2] == '/' || PathName[2] == '\\')) { - m_strShapeName = PathName; + fs::path fsFile = CN3BaseFileAccess::ToRelative(dlg.GetPathName().GetString()); + if (n3std::iequals(*fsFile.begin(), "fx")) { + m_strShapeName = fsFile.c_str(); UpdateData(FALSE); } else { - MessageBox("N3Shape파일은 fx폴더 아래, 혹은 fx폴더 아래에 있는 폴더에 위치해야 합니다..-.-;;", "ERR03", MB_OK); + MessageBox("N3Shape files must be located under the fx folder or a subfolder.", "ERR03", MB_OK); } - - delete pBaseFileAccess; } diff --git a/src/tool/N3FXE/DlgEditPartParticle.h b/src/tool/N3FXE/DlgEditPartParticle.h index 0502aa45..31e1aafd 100644 --- a/src/tool/N3FXE/DlgEditPartParticle.h +++ b/src/tool/N3FXE/DlgEditPartParticle.h @@ -83,7 +83,7 @@ class CDlgEditPartParticle : public CDialog { float m_fScaleVelY; //}}AFX_DATA - bool LoadPartScript(const char * szPath); + bool LoadPartScript(const fs::path & fsFile); void SetEmitTypeState(int EmitType); // Overrides diff --git a/src/tool/N3FXE/DlgEditScript.cpp b/src/tool/N3FXE/DlgEditScript.cpp index 45c25067..d84c7474 100644 --- a/src/tool/N3FXE/DlgEditScript.cpp +++ b/src/tool/N3FXE/DlgEditScript.cpp @@ -230,11 +230,9 @@ void CDlgEditScript::OnBtnSave() { continue; } - char szBuff[_MAX_PATH]; - - m_pPartName[i]->GetLBText(SelIdx, szBuff); - - fprintf(file, " fx/%s %3.2f\n", szBuff, (*m_pPartStartTime[i])); + CString szPartName; + m_pPartName[i]->GetLBText(SelIdx, szPartName); + fprintf(file, " fx/%s %3.2f\n", szPartName.GetString(), *m_pPartStartTime[i]); } if (m_bDependScale) { @@ -253,7 +251,7 @@ void CDlgEditScript::OnBtnSave() { fclose(file); - LoadBundle(m_strPathName); + LoadBundle(m_strPathName.GetString()); SaveGameDataPartnBundle(); } @@ -273,7 +271,7 @@ void CDlgEditScript::OnBtnStop() { } //strPathName은 FullPath... -bool CDlgEditScript::LoadBundle(CString & strPathName) { +bool CDlgEditScript::LoadBundle(const fs::path & fsFile) { if (m_pFXBundle) { delete m_pFXBundle; m_pFXBundle = NULL; @@ -290,11 +288,11 @@ bool CDlgEditScript::LoadBundle(CString & strPathName) { // /////////////////////////////////////////////////// - m_strPathName = strPathName; + m_strPathName = fsFile.c_str(); m_pFXBundle = new CN3FXBundle; m_pRefFrm->m_pCurrFX = m_pFXBundle; - if (m_pFXBundle->DecodeScriptFile((LPCTSTR)strPathName)) //번들 스크립트 읽기 성공했으면... + if (m_pFXBundle->DecodeScriptFile(fsFile)) //번들 스크립트 읽기 성공했으면... { // // set part editor @@ -302,24 +300,13 @@ bool CDlgEditScript::LoadBundle(CString & strPathName) { for (int i = 0; i < MAX_FX_PART; i++) { CN3FXPartBase * pPart = m_pFXBundle->GetPart(i); if (pPart) { - std::string szPartFullPath; - szPartFullPath = CN3Base::PathGet() + pPart->FileName(); - - char szScriptFullPath[_MAX_PATH]; - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(szPartFullPath.c_str(), szDrive, szDir, szFName, szExt); - _makepath(szScriptFullPath, szDrive, szDir, szFName, "n3fxpart"); - - //콤보박스 셋팅.. - char szComboName[_MAX_PATH]; - _splitpath(szScriptFullPath, szDrive, szDir, szFName, szExt); - _makepath(szComboName, NULL, NULL, szFName, szExt); + fs::path fsFxPart = pPart->FilePath().stem() + ".n3fxpart"; int ComboCount = m_pPartName[i]->GetCount(); for (int j = 0; j < ComboCount; j++) { - char szComboNameTarget[_MAX_PATH]; - m_pPartName[i]->GetLBText(j, szComboNameTarget); - if (lstrcmpi(szComboNameTarget, szComboName) == 0) { + CString szFxPartTarget; + m_pPartName[i]->GetLBText(j, szFxPartTarget); + if (n3std::iequals(szFxPartTarget.GetString(), fsFxPart)) { m_pPartName[i]->SetCurSel(j); } } @@ -384,19 +371,8 @@ BOOL CDlgEditScript::OnInitDialog() { m_pPartName[i]->InsertString(0, "NONE"); m_pPartName[i]->SetCurSel(0); - // m_CBPartName들 채우기.. - - CString strPath; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - strPath = CN3Base::PathGet().c_str(); - delete pBaseFileAccess; - strPath += "fx\\"; - - char szCurrPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szCurrPath); - SetCurrentDirectory((LPCTSTR)strPath); - m_pPartName[i]->Dir(DDL_READONLY, "*.n3fxpart"); - SetCurrentDirectory(szCurrPath); + std::string szSearchPath = (CN3Base::PathGet() / "fx" / "*.n3fxpart").string(); + m_pPartName[i]->Dir(DDL_READONLY, szSearchPath.c_str()); } m_fVelocity = 0.0f; @@ -426,18 +402,11 @@ void CDlgEditScript::RefreshParts() { int idx = m_pPartName[i]->GetCurSel(); if (idx > 0) { - CString strPath; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - strPath = CN3Base::PathGet().c_str(); - delete pBaseFileAccess; - strPath += "fx\\"; - - char szBuff[_MAX_PATH]; - m_pPartName[i]->GetLBText(idx, szBuff); - strPath += szBuff; - - m_pFXBundle->m_pPart[i]->pPart = m_pFXBundle->SetPart((LPCTSTR)strPath); - m_pFXBundle->m_pPart[i]->fStartTime = (*m_pPartStartTime[i]); + CString szFileName; + m_pPartName[i]->GetLBText(idx, szFileName); + fs::path fsFile = CN3Base::PathGet() / "fx" / szFileName.GetString(); + m_pFXBundle->m_pPart[i]->pPart = m_pFXBundle->SetPart(fsFile); + m_pFXBundle->m_pPart[i]->fStartTime = *m_pPartStartTime[i]; } } m_pFXBundle->Init(); @@ -446,38 +415,28 @@ void CDlgEditScript::RefreshParts() { } void CDlgEditScript::ReloadCombo() { - CString strOldName; - int idx; + CString szOldName; + int iIdx; for (int i = 0; i < MAX_FX_PART; i++) { - idx = m_pPartName[i]->GetCurSel(); - m_pPartName[i]->GetLBText(idx, strOldName); + iIdx = m_pPartName[i]->GetCurSel(); + m_pPartName[i]->GetLBText(iIdx, szOldName); m_pPartName[i]->ResetContent(); m_pPartName[i]->Clear(); m_pPartName[i]->InsertString(0, "NONE"); m_pPartName[i]->SetCurSel(0); - // m_CBPartName들 채우기.. - CString strPath; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - strPath = CN3Base::PathGet().c_str(); - delete pBaseFileAccess; - strPath += "fx\\"; - - char szCurrPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szCurrPath); - SetCurrentDirectory((LPCTSTR)strPath); - m_pPartName[i]->Dir(DDL_READONLY, "*.n3fxpart"); - - int count = m_pPartName[i]->GetCount(); - for (int j = 0; j < count; j++) { - CString DestName; - m_pPartName[i]->GetLBText(j, DestName); - if (lstrcmpi((LPCTSTR)DestName, (LPCTSTR)strOldName) == 0) { + std::string szSearchPath = (CN3Base::PathGet() / "fx" / "*.n3fxpart").string(); + m_pPartName[i]->Dir(DDL_READONLY, szSearchPath.c_str()); + + int iCount = m_pPartName[i]->GetCount(); + for (int j = 0; j < iCount; j++) { + CString szDestName; + m_pPartName[i]->GetLBText(j, szDestName); + if (n3std::iequals(szDestName.GetString(), szOldName.GetString())) { m_pPartName[i]->SetCurSel(j); } } - SetCurrentDirectory(szCurrPath); } } @@ -646,31 +605,19 @@ void CDlgEditScript::OnDropdownComboPart16() { void CDlgEditScript::OnBtnSaveAs() { CDlgNewFileName dlg; - dlg.m_strExt = ".N3FXBundle"; - if (dlg.DoModal() == IDOK) { - CString PathName = "fx\\"; - PathName += dlg.m_strNewFileName; - PathName += dlg.m_strExt; - CN3BaseFileAccess * pBaseFileAccess = new CN3BaseFileAccess; - pBaseFileAccess->FileNameSet((LPCTSTR)PathName); - - m_strPathName.Empty(); - m_strPathName = CN3Base::PathGet().c_str(); - m_strPathName += pBaseFileAccess->FileName().c_str(); - - delete pBaseFileAccess; - - char szGameFileName[_MAX_PATH]; - char szExt[_MAX_EXT]; - char szDir[_MAX_DIR]; - char szDrive[_MAX_DRIVE]; - sprintf(szGameFileName, m_pFXBundle->FileName().c_str()); - _splitpath(szGameFileName, szDrive, szDir, NULL, szExt); - sprintf(szGameFileName, "%s%s%s%s", szDrive, szDir, dlg.m_strNewFileName, szExt); - m_pFXBundle->FileNameSet(szGameFileName); - - OnBtnSave(); + dlg.m_strExt = ".n3fxbundle"; + if (dlg.DoModal() == IDCANCEL) { + return; } + + fs::path fsScriptFile = fs::path("fx") / (dlg.m_strNewFileName + dlg.m_strExt).GetString(); + m_strPathName = (CN3Base::PathGet() / fsScriptFile).c_str(); + + fs::path fsGameFile = + m_pFXBundle->FilePath().parent_path() / (fsScriptFile.stem() + m_pFXBundle->FilePath().extension()); + m_pFXBundle->FilePathSet(fsGameFile); + + OnBtnSave(); } void CDlgEditScript::OnBtnRefresh() { diff --git a/src/tool/N3FXE/DlgEditScript.h b/src/tool/N3FXE/DlgEditScript.h index 9c48f457..b85bf6b1 100644 --- a/src/tool/N3FXE/DlgEditScript.h +++ b/src/tool/N3FXE/DlgEditScript.h @@ -21,7 +21,7 @@ class CDlgEditScript : public CDialog { // Construction public: bool NewBundle(); - bool LoadBundle(CString & strPathName); + bool LoadBundle(const fs::path & fsFile); void SaveGameDataPartnBundle(); CDlgEditScript(CWnd * pParent = NULL); // standard constructor void RefreshParts(); diff --git a/src/tool/N3FXE/Ground.cpp b/src/tool/N3FXE/Ground.cpp index e5fcc2d5..bbbf1a77 100644 --- a/src/tool/N3FXE/Ground.cpp +++ b/src/tool/N3FXE/Ground.cpp @@ -66,9 +66,9 @@ void CGround::Render() { s_lpD3DDev->SetRenderState(D3DRS_ZWRITEENABLE, dwZEnable); } -void CGround::SetTex(const char * szPath) { +void CGround::SetTex(const fs::path & fsFile) { if (m_pTile) { CN3Base::s_MngTex.Delete(&m_pTile); } - m_pTile = CN3Base::s_MngTex.Get(szPath); -} \ No newline at end of file + m_pTile = CN3Base::s_MngTex.Get(fsFile); +} diff --git a/src/tool/N3FXE/Ground.h b/src/tool/N3FXE/Ground.h index 6bd61540..fb72f6cb 100644 --- a/src/tool/N3FXE/Ground.h +++ b/src/tool/N3FXE/Ground.h @@ -16,7 +16,7 @@ class CGround : public CN3Base { CN3Texture * m_pTile; public: - void SetTex(const char * szPath); + void SetTex(const fs::path & fsFile); void Render(); CGround(); diff --git a/src/tool/N3FXE/MainFrm.cpp b/src/tool/N3FXE/MainFrm.cpp index f6cd2ead..7c26c481 100644 --- a/src/tool/N3FXE/MainFrm.cpp +++ b/src/tool/N3FXE/MainFrm.cpp @@ -163,7 +163,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { // TODO: Remove this if you don't want tool tips m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); // Engine 생성 if (m_Eng.Init(TRUE, m_hWnd, 64, 64, 0, TRUE) == false) { @@ -184,7 +184,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { m_Light[1].m_Data.InitDirection(1, __Vector3(0, 1, 0), crLgt); // - m_Chr.LoadFromFile("ChrSelect\\el_chairs.n3shape"); + m_Chr.LoadFromFile(fs::path("ChrSelect") / "el_chairs.n3shape"); m_pGround = new CGround; @@ -263,11 +263,11 @@ int CMainFrame::GetPartType(CString & PathName) { return NULL; } - char szLine[512] = "", szCommand[80] = "", szBuf[4][80] = {"", "", "", ""}; - char * pResult = fgets(szLine, 512, stream); + char szLine[512]{}, szCommand[80]{}, szBuf[4][80]{}; + char * pResult = fgets(szLine, sizeof(szLine), stream); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "")) { + if (!n3std::iequals(szCommand, "")) { fclose(stream); return FX_PART_TYPE_NONE; } @@ -278,21 +278,19 @@ int CMainFrame::GetPartType(CString & PathName) { continue; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); + sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - if (lstrcmpi(szCommand, "") == 0) { - if (lstrcmpi(szBuf[0], "particle") == 0) { + if (n3std::iequals(szCommand, "")) { + if (n3std::iequals(szBuf[0], "particle")) { PartType = FX_PART_TYPE_PARTICLE; - } else if (lstrcmpi(szBuf[0], "board") == 0) { + } else if (n3std::iequals(szBuf[0], "board")) { PartType = FX_PART_TYPE_BOARD; - } else if (lstrcmpi(szBuf[0], "mesh") == 0) { + } else if (n3std::iequals(szBuf[0], "mesh")) { PartType = FX_PART_TYPE_MESH; - } else if (lstrcmpi(szBuf[0], "ground") == 0) { + } else if (n3std::iequals(szBuf[0], "ground")) { PartType = FX_PART_TYPE_BOTTOMBOARD; } //^^v 더 넣을꺼 있으면 넣어라.. @@ -399,7 +397,7 @@ void CMainFrame::OnFileLoadBundle() { POSITION pos = dlg.GetStartPosition(); while (pos != NULL) { - CString PathName = dlg.GetNextPathName(pos); + fs::path fsFile = dlg.GetNextPathName(pos).GetString(); //스크립트 에디트 창 만들고, 스크립트 정보들 읽고, 셋팅.. CDlgEditScript * pEditWnd = new CDlgEditScript; @@ -407,7 +405,7 @@ void CMainFrame::OnFileLoadBundle() { pEditWnd->m_pRefFrm = this; // load 해서 성공하면 그대로 하고 실패하면 다 지워버려.. - if (pEditWnd->LoadBundle(PathName)) { + if (pEditWnd->LoadBundle(fsFile)) { pEditWnd->ShowWindow(TRUE); m_pEditWndList.push_back(pEditWnd); } else { diff --git a/src/tool/N3Indoor/DlgBase.cpp b/src/tool/N3Indoor/DlgBase.cpp index f08d9b79..953bf660 100644 --- a/src/tool/N3Indoor/DlgBase.cpp +++ b/src/tool/N3Indoor/DlgBase.cpp @@ -527,7 +527,7 @@ void CDlgBase::UpdateInfo() { if (pItem) { CN3Texture * pTex = pPD->Tex(0); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -536,7 +536,7 @@ void CDlgBase::UpdateInfo() { pItem = m_LPShape.GetPropItem("Mesh File"); if (pItem) { if (pPMesh) { - pItem->m_curValue = pPMesh->FileName().c_str(); + pItem->m_curValue = pPMesh->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -614,7 +614,7 @@ void CDlgBase::UpdateInfo() { if (pItem) { CN3Joint * pJoint = pC->Joint(); if (pJoint) { - pItem->m_curValue = pJoint->FileName().c_str(); + pItem->m_curValue = pJoint->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -624,7 +624,7 @@ void CDlgBase::UpdateInfo() { if (pItem) { CN3VMesh * pMC = pC->CollisionMesh(); if (pMC) { - pItem->m_curValue = pMC->FileName().c_str(); + pItem->m_curValue = pMC->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -640,7 +640,7 @@ void CDlgBase::UpdateInfo() { if (pItem) { CN3Texture * pTex = pPart->Tex(); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -686,7 +686,7 @@ void CDlgBase::UpdateInfo() { pItem = m_LPCPlug.GetPropItem("Plug Mesh File"); if (pItem) { if (pPlug->PMesh()) { - pItem->m_curValue = pPlug->PMesh()->FileName().c_str(); + pItem->m_curValue = pPlug->PMesh()->FilePath().c_str(); } else { pItem->m_curValue = "NULL"; } @@ -695,7 +695,7 @@ void CDlgBase::UpdateInfo() { pItem = m_LPCPlug.GetPropItem("Plug Texture File"); if (pItem) { if (pPlug->Tex()) { - pItem->m_curValue = pPlug->Tex()->FileName().c_str(); + pItem->m_curValue = pPlug->Tex()->FilePath().c_str(); } else { pItem->m_curValue = "NULL"; } @@ -897,58 +897,33 @@ BOOL CDlgBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { pSI->m_iNPC_ID = atoi(pItem->m_curValue); } else if (pItem->m_propName == "NPC Status" && pItem->m_curValue.GetLength() > 0) { pSI->m_iNPC_Status = atoi(pItem->m_curValue); // NPC 로 쓰는 오브젝트일 경우 NPC Type - } - - else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { - pS->CollisionMeshSet(std::string(pItem->m_curValue)); - } - - else if (pItem->m_propName == "Collision Mesh Delete") { + } else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { + pS->CollisionMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + } else if (pItem->m_propName == "Collision Mesh Delete") { pS->CollisionMeshSet(""); - } - - else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { - CStringArray szArr; - int n = 0, nPrev = 0; - while (1) { - n = pItem->m_curValue.Find('\n', n); - if (-1 == n) { - break; - } - - szArr.Add(pItem->m_curValue.Mid(nPrev, n - nPrev)); - nPrev = n + 1; - n++; + } else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { + std::vector vTexFiles; + for (const auto & itrTexFile : std::string(pItem->m_curValue.GetString()) | std::views::split('\n')) { + fs::path fsTexFile(itrTexFile.begin(), itrTexFile.end()); + CN3BaseFileAccess::ToRelative(fsTexFile); + vTexFiles.emplace_back(fsTexFile); } - CN3Base tmp; - n = szArr.GetSize(); - pPD->TexAlloc(n); - for (int i = 0; i < n; i++) { - tmp.m_szName = szArr[i]; - pPD->TexSet(i, tmp.m_szName); + int iTexCount = static_cast(vTexFiles.size()); + pPD->TexAlloc(iTexCount); + for (int i = 0; i < iTexCount; ++i) { + pPD->TexSet(i, vTexFiles[i]); } this->UpdateInfo(); - } - - else if (pItem->m_propName == "Mesh File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pPD->MeshSet(tmp.m_szName); - + } else if (pItem->m_propName == "Mesh File" && pItem->m_curValue.GetLength() > 0) { + pPD->MeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); - } - - else if (pItem->m_propName == "Part Add") { + } else if (pItem->m_propName == "Part Add") { pS->PartAdd(); - this->UpdateInfo(); - } - - else if (pItem->m_propName == "Part Delete") { + } else if (pItem->m_propName == "Part Delete") { pS->PartDelete(nPart); - this->UpdateInfo(); } } @@ -963,12 +938,10 @@ BOOL CDlgBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { int nPlugCount = pC->PlugCount(); if (pItem->m_propName == "Joint File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pC->JointSet(tmp.m_szName); + pC->JointSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { - pC->CollisionMeshSet(std::string(pItem->m_curValue)); + pC->CollisionMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } else if (pItem->m_propName == "Collision Mesh Delete") { pC->CollisionMeshSet(""); @@ -1006,10 +979,7 @@ BOOL CDlgBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { } this->UpdateInfo(); } else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pPart->TexSet(tmp.m_szName); - + pPart->TexSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } } @@ -1042,16 +1012,10 @@ BOOL CDlgBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { } else if (pItem->m_propName == "Plug Scale") { pPlug->ScaleSet(__Vector3(pItem->VectorGet())); } else if (pItem->m_propName == "Plug Mesh File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pPlug->PMeshSet(tmp.m_szName); - + pPlug->PMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } else if (pItem->m_propName == "Plug Texture File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pPlug->TexSet(tmp.m_szName); - + pPlug->TexSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } } diff --git a/src/tool/N3Indoor/DlgShapeList.cpp b/src/tool/N3Indoor/DlgShapeList.cpp index f5432549..8651acd2 100644 --- a/src/tool/N3Indoor/DlgShapeList.cpp +++ b/src/tool/N3Indoor/DlgShapeList.cpp @@ -70,14 +70,11 @@ void CDlgShapeList::UpdateTree(CN3Scene * pScene) { for (int i = 0; i < nSC; i++) { CN3Shape * pShape = m_pSceneRef->ShapeGet(i); if (pShape) { - char szFName[MAX_PATH]; - _splitpath(pShape->FileName().c_str(), NULL, NULL, szFName, NULL); - m_ListShape.InsertString(i, szFName); + m_ListShape.InsertString(i, pShape->FilePath().stem().string().c_str()); m_ListShape.SetItemDataPtr(i, pShape); } } - } else if (!pScene && !m_IsSourceObj) // Output용 버전.. - { + } else if (!pScene && !m_IsSourceObj) { // Output용 버전.. CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); COrganizeView * pView = pFrm->GetOrganizeView(); @@ -86,9 +83,7 @@ void CDlgShapeList::UpdateTree(CN3Scene * pScene) { siiter siit = pView->m_PVSMgr.m_plShapeInfoList.begin(); while (siit != pView->m_PVSMgr.m_plShapeInfoList.end()) { pSI = *siit++; - char szFName[MAX_PATH]; - _splitpath(pSI->m_strShapeFile.c_str(), NULL, NULL, szFName, NULL); - m_ListShape.InsertString(i, szFName); + m_ListShape.InsertString(i, pSI->m_fsShapeFile.stem().string().c_str()); m_ListShape.SetItemDataPtr(i, pSI); i++; } @@ -101,9 +96,7 @@ void CDlgShapeList::UpdateTree(CN3Scene * pScene) { siiter siit = pVol->m_plShapeInfoList.begin(); while (siit != pVol->m_plShapeInfoList.end()) { pSI = *siit++; - char szFName[MAX_PATH]; - _splitpath(pSI->m_strShapeFile.c_str(), NULL, NULL, szFName, NULL); - m_ListShape.InsertString(i, szFName); + m_ListShape.InsertString(i, pSI->m_fsShapeFile.stem().string().c_str()); m_ListShape.SetItemDataPtr(i, pSI); i++; } @@ -299,15 +292,11 @@ void CDlgShapeList::OnBtnSort() { int cnt = m_ListShape.GetCount(); for (int i = 0; i < cnt; i++) { - char buff[MAX_PATH]; - std::string str; - CN3Shape * pShape; - - pShape = (CN3Shape *)m_ListShape.GetItemDataPtr(i); - m_ListShape.GetText(i, buff); - str = buff; + CN3Shape * pShape = (CN3Shape *)m_ListShape.GetItemDataPtr(i); - Map.insert(SMValue(str, pShape)); + CString szShapeFileName; + m_ListShape.GetText(i, szShapeFileName); + Map.insert(SMValue(szShapeFileName.GetString(), pShape)); } m_ListShape.ResetContent(); @@ -329,15 +318,11 @@ void CDlgShapeList::OnBtnSort() { int cnt = m_ListShape.GetCount(); for (int i = 0; i < cnt; i++) { - char buff[MAX_PATH]; - std::string str; - ShapeInfo * pSI; - - pSI = (ShapeInfo *)m_ListShape.GetItemDataPtr(i); - m_ListShape.GetText(i, buff); - str = buff; + ShapeInfo * pSI = (ShapeInfo *)m_ListShape.GetItemDataPtr(i); - Map.insert(SIMValue(str, pSI)); + CString szShapeFileName; + m_ListShape.GetText(i, szShapeFileName); + Map.insert(SIMValue(szShapeFileName.GetString(), pSI)); } m_ListShape.ResetContent(); diff --git a/src/tool/N3Indoor/DlgUnusedFiles.cpp b/src/tool/N3Indoor/DlgUnusedFiles.cpp index a5f01a9a..b8a70152 100644 --- a/src/tool/N3Indoor/DlgUnusedFiles.cpp +++ b/src/tool/N3Indoor/DlgUnusedFiles.cpp @@ -41,26 +41,22 @@ END_MESSAGE_MAP() // CDlgUnusedFiles message handlers void CDlgUnusedFiles::OnDelete() { - // TODO: Add your control notification handler code here - int iSelFNC = m_ListFiles.GetSelCount(); - if (iSelFNC <= 0) { + int iSC = m_ListFiles.GetSelCount(); + if (iSC <= 0) { return; } - int iYesNo = MessageBox("지우시겠습니까?", "확인", MB_YESNO); - - if (IDYES != iYesNo) { + if (IDYES != MessageBox("Would you like to erase it?", "Check", MB_YESNO)) { return; } - std::vector sel; - sel.reserve(iSelFNC); - m_ListFiles.GetSelItems(iSelFNC, &(sel[0])); + std::vector vSels(iSC); + m_ListFiles.GetSelItems(iSC, vSels.data()); - CString szFN; - for (int i = 0; i < iSelFNC; i++) { - m_ListFiles.GetText(sel[i], szFN); - ::DeleteFile(szFN); + for (const auto & iSelIndex : vSels) { + CString szFile; + m_ListFiles.GetText(iSelIndex, szFile); + fs::remove(szFile.GetString()); } CDialog::OnOK(); @@ -69,11 +65,9 @@ void CDlgUnusedFiles::OnDelete() { BOOL CDlgUnusedFiles::OnInitDialog() { CDialog::OnInitDialog(); - // TODO: Add extra initialization here this->UpdateAll(); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE + return TRUE; } void CDlgUnusedFiles::OnCancel() { @@ -82,13 +76,11 @@ void CDlgUnusedFiles::OnCancel() { } void CDlgUnusedFiles::UpdateAll() { - int iFNC = m_FileNames.GetSize(); - for (int i = 0; i < iFNC; i++) { - m_ListFiles.AddString(m_FileNames[i]); + for (const auto & fsFile : m_vFiles) { + m_ListFiles.AddString(CString(fsFile.c_str())); } - iFNC = m_InvalidFileNames.GetSize(); - for (int i = 0; i < iFNC; i++) { - m_ListInvalidObjects.AddString(m_InvalidFileNames[i]); + for (const auto & szError : m_vErroredFiles) { + m_ListInvalidObjects.AddString(CString(szError.c_str())); } } diff --git a/src/tool/N3Indoor/DlgUnusedFiles.h b/src/tool/N3Indoor/DlgUnusedFiles.h index 3f4280ee..b8f3a9fb 100644 --- a/src/tool/N3Indoor/DlgUnusedFiles.h +++ b/src/tool/N3Indoor/DlgUnusedFiles.h @@ -8,8 +8,8 @@ class CDlgUnusedFiles : public CDialog { public: - CStringArray m_FileNames; - CStringArray m_InvalidFileNames; + std::vector m_vFiles; + std::vector m_vErroredFiles; public: void UpdateAll(); diff --git a/src/tool/N3Indoor/MainFrm.cpp b/src/tool/N3Indoor/MainFrm.cpp index 271b453a..b5eff71a 100644 --- a/src/tool/N3Indoor/MainFrm.cpp +++ b/src/tool/N3Indoor/MainFrm.cpp @@ -106,7 +106,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { return -1; // fail to create } - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); if (m_Eng.Init(TRUE, m_hWnd, 64, 64, 0, TRUE) == false) { return 0; @@ -164,14 +164,15 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { m_eEditState = EDIT_SELECT; // 경로 설정.. - std::string str; - char szPathCur[256] = ""; - GetCurrentDirectory(256, szPathCur); - GetOrganizeView()->SetDlgItemText(IDC_EDIT_RESOURCE_PATH, szPathCur); - str = szPathCur; - str += "\\N3Indoor"; - CN3Base::PathSet(str); - m_strResourcePath = str; + fs::path fsCurDir = fs::current_path(); + GetOrganizeView()->SetDlgItemText(IDC_EDIT_RESOURCE_PATH, fsCurDir.string().c_str()); + + fs::path fsIndoorDir = fsCurDir / "N3Indoor"; + if (!fs::is_directory(fsIndoorDir)) { + fs::create_directories(fsIndoorDir); + } + CN3Base::PathSet(fsIndoorDir); + m_fsResourceDir = fsIndoorDir; m_dwRenderingOption |= dw_Render_Add_Shape; @@ -365,44 +366,42 @@ void CMainFrame::OnUpdateViewOutputobject(CCmdUI * pCmdUI) { } } -CN3Transform * CMainFrame::AddChr(CN3Scene * pDestScene, const std::string & szFN, BOOL bGenerateChainNumber) { +CN3Transform * CMainFrame::AddChr(CN3Scene * pDestScene, const fs::path & fsFile, BOOL bGenerateChainNumber) { CN3Chr * pChr = new CN3Chr; - if (false == pChr->LoadFromFile(szFN)) // 부르기가 실패하면.. + if (!pChr->LoadFromFile(fsFile)) // 부르기가 실패하면.. { delete pChr; return NULL; } if (bGenerateChainNumber) { - int nCC = pDestScene->ChrCount(); - int nChainNumber = 0; - char szCompare[_MAX_PATH]; + int nChainNumber = 0; + int nCC = pDestScene->ChrCount(); for (int i = 0; i < nCC; i++) { - lstrcpy(szCompare, pDestScene->ChrGet(i)->m_szName.c_str()); - int nL = lstrlen(szCompare); - if (nL < 5) { + std::string szNameFull = pDestScene->ChrGet(i)->m_szName; + size_t iSeparatorPos = szNameFull.rfind('_'); + if (iSeparatorPos == std::string::npos) { continue; } - szCompare[nL - 5] = NULL; // 뒤에 붙는 언더바와 네자리 번호는 뺀다.. - if (pChr->m_szName == szCompare) // 이름이 같으면.. - { - nChainNumber = atoi(&(szCompare[nL - 4])) + 1; + std::string szName = szNameFull.substr(0, iSeparatorPos); + if (pChr->m_szName == szName) { + std::string szDigits = szNameFull.substr(iSeparatorPos + 1); + std::from_chars(szDigits.data(), szDigits.data() + szDigits.size(), nChainNumber); + ++nChainNumber; } } - char szName[_MAX_PATH]; - wsprintf(szName, "%s_%.4d", pChr->m_szName.c_str(), nChainNumber); - pChr->m_szName = szName; // .. 이름을 짓는다.. + pChr->m_szName = std::format("{:s}_{:04d}", pChr->m_szName, nChainNumber); } pDestScene->ChrAdd(pChr); return pChr; } -CN3Transform * CMainFrame::AddShape(CN3Scene * pDestScene, const std::string & szFN, BOOL bGenerateChainNumber) { +CN3Transform * CMainFrame::AddShape(CN3Scene * pDestScene, const fs::path & fsFile, BOOL bGenerateChainNumber) { CN3Shape * pShape = new CN3Shape; - if (false == pShape->LoadFromFile(szFN)) // 부르기가 실패하면.. + if (false == pShape->LoadFromFile(fsFile)) // 부르기가 실패하면.. { delete pShape; return NULL; @@ -417,34 +416,28 @@ void CMainFrame::LoadSourceObjects() { m_pSceneSource->Release(); - WIN32_FIND_DATA FindFileData; - - // source\Chr 폴더의 모든 캐릭터 추가 - CString szChrPath; - szChrPath.Format("%sChr\\", CN3Base::PathGet().c_str()); - SetCurrentDirectory(szChrPath); // szFolder\Chr 폴더로 경로를 바꾸고.. - HANDLE hFind = FindFirstFile("*.N3Chr", &FindFileData); + fs::path fsChrDir = fs::current_path() / "Chr"; + if (fs::is_directory(fsChrDir)) { + for (const auto & fi : fs::directory_iterator(fsChrDir)) { + if (!fi.is_regular_file() || !n3std::iequals(fi.path().extension(), ".n3chr")) { + continue; + } - if (hFind != INVALID_HANDLE_VALUE) { - AddChr(m_pSceneSource, std::string(szChrPath + FindFileData.cFileName), FALSE); - while (FindNextFile(hFind, &FindFileData)) { - AddChr(m_pSceneSource, std::string(szChrPath + FindFileData.cFileName), FALSE); + fs::path fsFile = "Chr" / fi.path().filename(); + AddChr(m_pSceneSource, fsFile, FALSE); } - FindClose(hFind); } - // source\Data 폴더의 모든 shape 추가 - CString szShapePath; - szShapePath.Format("%sObject\\", CN3Base::PathGet().c_str()); - SetCurrentDirectory(szShapePath); // szFolder\Mesh 폴더로 경로를 바꾸고.. - hFind = FindFirstFile("*.N3Shape", &FindFileData); // 파일 찾기. + fs::path fsObjectDir = fs::current_path() / "Object"; + if (fs::is_directory(fsObjectDir)) { + for (const auto & fi : fs::directory_iterator(fsObjectDir)) { + if (!fi.is_regular_file() || !n3std::iequals(fi.path().extension(), ".n3shape")) { + continue; + } - if (hFind != INVALID_HANDLE_VALUE) { - AddShape(m_pSceneSource, std::string(szShapePath + FindFileData.cFileName), FALSE); - while (FindNextFile(hFind, &FindFileData)) { - AddShape(m_pSceneSource, std::string(szShapePath + FindFileData.cFileName), FALSE); + fs::path fsFile = "Object" / fi.path().filename(); + AddShape(m_pSceneSource, fsFile, FALSE); } - FindClose(hFind); } m_pSceneSource->Tick(); // Object 초기화 @@ -459,7 +452,7 @@ void CMainFrame::RefreshSourceObjects() { siiter siit = pView->m_PVSMgr.m_plShapeInfoList.begin(); while (siit != pView->m_PVSMgr.m_plShapeInfoList.end()) { pSI = *siit++; - pSI->m_pShape = m_pSceneSource->ShapeGetByFileName(pSI->m_strShapeFile); + pSI->m_pShape = m_pSceneSource->ShapeGetByFile(pSI->m_fsShapeFile); } CPortalVolume * pVol = NULL; @@ -470,7 +463,7 @@ void CMainFrame::RefreshSourceObjects() { siiter siit = pVol->m_plShapeInfoList.begin(); while (siit != pVol->m_plShapeInfoList.end()) { pSI = *siit++; - pSI->m_pShape = m_pSceneSource->ShapeGetByFileName(pSI->m_strShapeFile); + pSI->m_pShape = m_pSceneSource->ShapeGetByFile(pSI->m_fsShapeFile); } } } @@ -1007,85 +1000,34 @@ void CMainFrame::TotalValidateCheckAfterDelete() { } } -void CMainFrame::OnFileMruFile1() { - // TODO: Add your command handler code here - CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); - std::string str = pApp->GetMRU1(); - std::string strT; - - char szExt[_MAX_EXT]; - _splitpath(str.c_str(), NULL, NULL, NULL, szExt); - strT = szExt; - +void CMainFrame::OnFileMruFile(size_t iIndex) { + CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); + fs::path fsFile = pApp->GetMRU(iIndex); COrganizeView * pView = GetOrganizeView(); - if (strT == ".wshop") { - pView->OpenWorkShopFile(str); + fs::path fsExt = fsFile.extension(); + if (n3std::iequals(fsExt, ".wshop")) { + pView->OpenWorkShopFile(fsFile); } - if (strT == ".n3indoor") { - pView->OpenGameDataFile(str); + if (n3std::iequals(fsExt, ".n3indoor")) { + pView->OpenGameDataFile(fsFile); } } -void CMainFrame::OnFileMruFile2() { - // TODO: Add your command handler code here - CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); - std::string str = pApp->GetMRU2(); - std::string strT; - - char szExt[_MAX_EXT]; - _splitpath(str.c_str(), NULL, NULL, NULL, szExt); - strT = szExt; - - COrganizeView * pView = GetOrganizeView(); +void CMainFrame::OnFileMruFile1() { + OnFileMruFile(0); +} - if (strT == ".wshop") { - pView->OpenWorkShopFile(str); - } - if (strT == ".n3indoor") { - pView->OpenGameDataFile(str); - } +void CMainFrame::OnFileMruFile2() { + OnFileMruFile(1); } void CMainFrame::OnFileMruFile3() { - // TODO: Add your command handler code here - CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); - std::string str = pApp->GetMRU3(); - std::string strT; - - char szExt[_MAX_EXT]; - _splitpath(str.c_str(), NULL, NULL, NULL, szExt); - strT = szExt; - - COrganizeView * pView = GetOrganizeView(); - strT = szExt; - - if (strT == ".wshop") { - pView->OpenWorkShopFile(str); - } - if (strT == ".n3indoor") { - pView->OpenGameDataFile(str); - } + OnFileMruFile(2); } void CMainFrame::OnFileMruFile4() { - // TODO: Add your command handler code here - CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); - std::string str = pApp->GetMRU4(); - std::string strT; - - char szExt[_MAX_EXT]; - _splitpath(str.c_str(), NULL, NULL, NULL, szExt); - strT = szExt; - - COrganizeView * pView = GetOrganizeView(); - - if (strT == ".wshop") { - pView->OpenWorkShopFile(str); - } - if (strT == ".n3indoor") { - pView->OpenGameDataFile(str); - } + OnFileMruFile(3); } void CMainFrame::OnEditProperty() { @@ -1117,134 +1059,75 @@ void CMainFrame::OnTipDeleteUnusedFiles() { return; } - // TODO: Add your command handler code here - typedef std::map mapBase; - typedef mapBase::value_type valBase; - typedef mapBase::iterator it_Base; - - std::vector invalidFNs; - std::vector unusedFNs; - std::string szFN; - - // 일단 몽땅 다 맵에 넣는다.. - mapBase mBases; - int iSC = m_pDlgOutputList->GetTotalShapeInfoCount(); - - CN3Shape * pShape = NULL; - CN3VMesh * pVMesh = NULL; - CN3SPart * pPart = NULL; - CN3PMesh * pPMesh = NULL; - CN3Texture * pTex = NULL; + std::map mBases; + std::vector vUnusedFiles; + std::vector vErroredFiles; + + int iSC = m_pDlgOutputList->GetTotalShapeInfoCount(); for (int i = 0; i < iSC; i++) { - pShape = m_pDlgOutputList->GetShapeByiOrder(i); + CN3Shape * pShape = m_pDlgOutputList->GetShapeByiOrder(i); if (NULL == pShape) { continue; } - szFN = CN3Base::PathGet() + pShape->FileName(); - CharLower(&(szFN[0])); - mBases.insert(valBase(szFN, pShape)); + mBases.emplace(pShape->FilePathAbs(), pShape); - pVMesh = pShape->CollisionMesh(); + CN3VMesh * pVMesh = pShape->CollisionMesh(); if (pVMesh) { - szFN = CN3Base::PathGet() + pVMesh->FileName(); - CharLower(&(szFN[0])); - mBases.insert(valBase(szFN, pVMesh)); + mBases.emplace(pVMesh->FilePathAbs(), pVMesh); } else { - invalidFNs.push_back("NULL VMesh : " + pShape->FileName()); + vErroredFiles.emplace_back(std::format(L"NULL VMesh : {:s}", pShape->FilePath().c_str())); } int iSPC = pShape->PartCount(); for (int j = 0; j < iSPC; j++) { - pPart = pShape->Part(j); + CN3SPart * pPart = pShape->Part(j); if (NULL == pPart) { - CString szErr; - szErr.Format("NULL Part : %s - %d번째 Part", pShape->FileName().c_str(), j); - invalidFNs.push_back(szErr.operator LPCTSTR()); + vErroredFiles.emplace_back( + std::format(L"NULL Part : {:s} - {:d}th Part", pShape->FilePath().c_str(), j)); continue; } - pPMesh = pPart->Mesh(); + CN3PMesh * pPMesh = pPart->Mesh(); if (pPMesh) { - szFN = CN3Base::PathGet() + pPMesh->FileName(); - CharLower(&(szFN[0])); - mBases.insert(valBase(szFN, pPMesh)); + mBases.emplace(pPMesh->FilePathAbs(), pPMesh); } else { - CString szErr; - szErr.Format("NULL PMesh : %s - %d번째 Part", pShape->FileName().c_str(), j); - invalidFNs.push_back(szErr.operator LPCTSTR()); + vErroredFiles.emplace_back( + std::format(L"NULL Part : {:s} - {:d}th Part", pShape->FilePath().c_str(), j)); } int iSTC = pPart->TexCount(); for (int k = 0; k < iSTC; k++) { - pTex = pPart->Tex(k); + CN3Texture * pTex = pPart->Tex(k); if (pTex) { - szFN = CN3Base::PathGet() + pTex->FileName(); - CharLower(&(szFN[0])); - mBases.insert(valBase(szFN, pTex)); + mBases.emplace(pTex->FilePathAbs(), pTex); } else { - CString szErr; - szErr.Format("NULL Texture : %s - %d번째 Part, %d번째 Texture", pShape->FileName().c_str(), j, k); - invalidFNs.push_back(szErr.operator LPCTSTR()); + vErroredFiles.emplace_back(std::format(L"NULL Texture : {:s} - {:d}th Part, {:d}th Texture", + pShape->FilePath().c_str(), j, k)); continue; } } } } - // 파일을 찾고.. - std::string szPath = CN3Base::PathGet() + "object\\"; - ::SetCurrentDirectory(szPath.c_str()); - CFileFind ff; - - BOOL bFind; - CString szFNTmp; - CString szFNTmp2; - - for (ff.FindFile(); bFind = ff.FindNextFile();) { - szFNTmp = ff.GetFilePath(); - szFNTmp2 = ff.GetFileName(); - - if (szFNTmp2 == "." || szFNTmp2 == "..") { - continue; - } - - szFNTmp.MakeLower(); - - szFN = szFNTmp; - it_Base it = mBases.find(szFN); - if (it != mBases.end()) { - continue; // 찾았으면 쓴거다.. - } - - unusedFNs.push_back(szFN); - } - - if (!bFind) { - szFNTmp = ff.GetFilePath(); - szFNTmp2 = ff.GetFileName(); - - szFNTmp.MakeLower(); + fs::path fsObjectDir = CN3Base::PathGet() / "Object"; + if (fs::is_directory(fsObjectDir)) { + for (const auto & fi : fs::directory_iterator(fsObjectDir)) { + if (!fi.is_regular_file()) { + continue; + } - szFN = szFNTmp; - it_Base it = mBases.find(szFN); - if (it == mBases.end()) { - unusedFNs.push_back(szFN); + fs::path fsFindFile = fi.path(); + fsFindFile.make_lower(); + if (mBases.contains(fsFindFile)) { + vUnusedFiles.emplace_back(fsFindFile); + } } } - // 파일 지우기 대화상자 띄우기.. CDlgUnusedFiles dlg; - int iUFC = unusedFNs.size(); - for (int i = 0; i < iUFC; i++) { - dlg.m_FileNames.Add(unusedFNs[i].c_str()); - } - - int iIFC = invalidFNs.size(); - for (int i = 0; i < iIFC; i++) { - dlg.m_InvalidFileNames.Add(invalidFNs[i].c_str()); - } - + dlg.m_vFiles = vUnusedFiles; + dlg.m_vErroredFiles = vErroredFiles; dlg.DoModal(); // 모두 업데이트.. diff --git a/src/tool/N3Indoor/MainFrm.h b/src/tool/N3Indoor/MainFrm.h index 3f205240..0ea0ceb4 100644 --- a/src/tool/N3Indoor/MainFrm.h +++ b/src/tool/N3Indoor/MainFrm.h @@ -65,8 +65,8 @@ class CMainFrame : public CFrameWnd, public CN3Base { DWORD m_dwRenderingOption; e_EditMode m_eEditState; - std::string m_strResourcePath; - std::string m_strFileName; + fs::path m_fsResourceDir; + fs::path m_fsFile; bool m_bViewSelectedTotalShape; bool m_bViewSelectedFloor; @@ -105,15 +105,17 @@ class CMainFrame : public CFrameWnd, public CN3Base { protected: virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext * pContext); + + void OnFileMruFile(size_t iIndex); //}}AFX_VIRTUAL // Implementation public: void FindMinMaxTotalShape(__Vector3 & vecMin, __Vector3 & vecMax); void OutputDlgRefresh(); // 소스목록에서 선택한 Object를 넣으면 OutputScene으로 복사해서 넣어준다. - CN3Transform * AddChr(CN3Scene * pDestScene, const std::string & szFN, + CN3Transform * AddChr(CN3Scene * pDestScene, const fs::path & fsFile, BOOL bGenerateChainNumber); // 특정Scene에 캐릭터 객체를 복사해 추가 - CN3Transform * AddShape(CN3Scene * pDestScene, const std::string & szFN, + CN3Transform * AddShape(CN3Scene * pDestScene, const fs::path & fsFile, BOOL bGenerateChainNumber); // 특정Scene에 Shape 객체를 복사해 추가 void UpdateShapeInfoDisplay(); diff --git a/src/tool/N3Indoor/N3Indoor.cpp b/src/tool/N3Indoor/N3Indoor.cpp index 49bbca94..baf9859e 100644 --- a/src/tool/N3Indoor/N3Indoor.cpp +++ b/src/tool/N3Indoor/N3Indoor.cpp @@ -166,7 +166,7 @@ BOOL CN3IndoorApp::OnIdle(LONG lCount) { } void CN3IndoorApp::Write(const char * lpszFormat, ...) { - std::string s_szFileName = "log.txt"; + fs::path fsLogFile = "log.txt"; static char szFinal[1024]; static SYSTEMTIME time; @@ -187,9 +187,9 @@ void CN3IndoorApp::Write(const char * lpszFormat, ...) { lstrcat(szFinal, "\r\n"); int iLength = lstrlen(szFinal); - HANDLE hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - hFile = CreateFile(s_szFileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileW(fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { hFile = NULL; } @@ -209,60 +209,13 @@ int CN3IndoorApp::Run() { return CWinApp::Run(); } -std::string CN3IndoorApp::GetMRU1() { +fs::path CN3IndoorApp::GetMRU(size_t iIndex) { m_pRecentFileList->ReadList(); - std::string str; - CString cstr; - if (m_pRecentFileList->GetSize() < 1) { - return str; + if (m_pRecentFileList->GetSize() < (iIndex + 1)) { + return fs::path(); } - cstr = (*(m_pRecentFileList))[0]; - str = cstr; - - return str; -} - -std::string CN3IndoorApp::GetMRU2() { - m_pRecentFileList->ReadList(); - std::string str = ""; - CString cstr; - if (m_pRecentFileList->GetSize() < 2) { - return str; - } - - cstr = (*(m_pRecentFileList))[1]; - str = cstr; - - return str; -} - -std::string CN3IndoorApp::GetMRU3() { - m_pRecentFileList->ReadList(); - std::string str = ""; - CString cstr; - if (m_pRecentFileList->GetSize() < 3) { - return str; - } - - cstr = (*(m_pRecentFileList))[2]; - str = cstr; - - return str; -} - -std::string CN3IndoorApp::GetMRU4() { - m_pRecentFileList->ReadList(); - std::string str = ""; - CString cstr; - if (m_pRecentFileList->GetSize() < 4) { - return str; - } - - cstr = (*(m_pRecentFileList))[3]; - str = cstr; - - return str; + return static_cast((*m_pRecentFileList)[iIndex]); } void CN3IndoorApp::UpdateMRU() { diff --git a/src/tool/N3Indoor/N3Indoor.h b/src/tool/N3Indoor/N3Indoor.h index cd94cf57..85493907 100644 --- a/src/tool/N3Indoor/N3Indoor.h +++ b/src/tool/N3Indoor/N3Indoor.h @@ -27,11 +27,8 @@ class CN3IndoorApp : public CWinApp { CN3IndoorApp(); - std::string GetMRU1(); - std::string GetMRU2(); - std::string GetMRU3(); - std::string GetMRU4(); - void UpdateMRU(); + fs::path GetMRU(size_t iIndex); + void UpdateMRU(); // Overrides // ClassWizard generated virtual function overrides diff --git a/src/tool/N3Indoor/OrganizeView.cpp b/src/tool/N3Indoor/OrganizeView.cpp index 9e9996d4..d5ee8eeb 100644 --- a/src/tool/N3Indoor/OrganizeView.cpp +++ b/src/tool/N3Indoor/OrganizeView.cpp @@ -144,7 +144,7 @@ void COrganizeView::InitEnvironSetting() { void COrganizeView::OnButtonFileName() { // TODO: Add your control notification handler code here CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); - if (pFrm->m_strResourcePath.empty()) { + if (pFrm->m_fsResourceDir.empty()) { AfxMessageBox("먼저 리소스 경로를 설정하세여.."); } @@ -153,30 +153,27 @@ void COrganizeView::OnButtonFileName() { pFrm->m_pSceneSource = NULL; } - TCHAR tch[256]; - GetCurrentDirectory(256, tch); - SetCurrentDirectory(pFrm->m_strResourcePath.c_str()); + fs::path fsCurDirPrev = fs::current_path(); + fs::current_path(pFrm->m_fsResourceDir); DWORD dwFlags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY; CFileDialog dlg(TRUE, "N3Scene File", NULL, dwFlags, "N3Scene (*.n3scene)|*.n3scene||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } - std::string szOpen(dlg.GetFileName().GetString()); - pFrm->m_strFileName = szOpen; - SetDlgItemText(IDC_EDIT_RESOURCE_NAME, szOpen.c_str()); - SetCurrentDirectory(tch); - - CString strExt = dlg.GetFileExt(); - strExt.MakeLower(); - if (strExt != "n3scene") { + fs::path fsFile = dlg.GetFileName().GetString(); + if (!n3std::iequals(fsFile.extension(), ".n3scene")) { AfxMessageBox("FileType Invalidate!!"); return; } + pFrm->m_fsFile = fsFile; + SetDlgItemTextW(GetSafeHwnd(), IDC_EDIT_RESOURCE_NAME, fsFile.c_str()); + fs::current_path(fsCurDirPrev); + pFrm->m_pSceneSource = new CN3Scene; pFrm->m_pSceneSource->m_szName = "SourceList"; - pFrm->m_pSceneSource->FileNameSet(szOpen); + pFrm->m_pSceneSource->FilePathSet(fsFile); pFrm->LoadSourceObjects(); } @@ -187,13 +184,12 @@ void COrganizeView::OnButtonResourcePath() { return; } - std::string szPath(dlg.GetPathName().GetString()); - SetDlgItemText(IDC_EDIT_RESOURCE_PATH, szPath.c_str()); - CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); - pFrm->m_strResourcePath = szPath + "\\N3Indoor"; + fs::path fsDir = fs::path(dlg.GetPathName().GetString()) / "N3Indoor"; + SetDlgItemTextW(GetSafeHwnd(), IDC_EDIT_RESOURCE_PATH, fsDir.c_str()); - // 경로 설정.. - CN3Base::PathSet(szPath + "\\N3Indoor"); + CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); + pFrm->m_fsResourceDir = fsDir; + CN3Base::PathSet(fsDir); } void COrganizeView::OnEdit() { @@ -458,7 +454,7 @@ void COrganizeView::ShapeRegisterToManager(CN3Base * pBase) { return; } - m_PVSMgr.RegisterShape(((CN3Shape *)pBase)->FileName(), ((CN3Shape *)pBase)); + m_PVSMgr.RegisterShape(((CN3Shape *)pBase)->FilePath(), ((CN3Shape *)pBase)); } void COrganizeView::ShapeLinkToPVolumn(CN3Base * pBase) { @@ -473,7 +469,7 @@ void COrganizeView::ShapeLinkToPVolumn(CN3Base * pBase) { return; } - pVol->SetShape(((CN3Shape *)pBase)->FileName(), ((CN3Shape *)pBase), m_PVSMgr.m_iIncreseShapeIndex++); + pVol->SetShape(((CN3Shape *)pBase)->FilePath(), ((CN3Shape *)pBase), m_PVSMgr.m_iIncreseShapeIndex++); } void COrganizeView::OnCurserSelect(e_EditMode eED) { @@ -650,15 +646,8 @@ void COrganizeView::RefreshLinkedList() { } int iCount = m_LinkedListCtrl.GetItemCount(); - - ShapeInfo * pSI; - char buffer[32]{}; - siiter siit = pVol->m_plShapeInfoList.begin(); - while (siit != pVol->m_plShapeInfoList.end()) { - pSI = *siit++; - sprintf(buffer, "Shape_%d", pSI->m_iID); - str = buffer; - m_LinkedListCtrl.InsertItem(iCount++, str.c_str(), 1); + for (const auto & pSI : pVol->m_plShapeInfoList) { + m_LinkedListCtrl.InsertItem(iCount++, std::format("Shape_{:d}", pSI->m_iID).c_str(), 1); } } @@ -872,16 +861,9 @@ void COrganizeView::RefreshTotalShape() { m_ShapesListCtrl.DeleteAllItems(); m_ShapesListCtrl.SetImageList(&m_GlobalImageList, LVSIL_NORMAL); - int iCount = 0; - ShapeInfo * pSI; - std::string str; - char buffer[32]{}; - siiter siit = m_PVSMgr.m_plShapeInfoList.begin(); - while (siit != m_PVSMgr.m_plShapeInfoList.end()) { - pSI = *siit++; - sprintf(buffer, "Part_%d", pSI->m_iID); - str = buffer; - m_ShapesListCtrl.InsertItem(iCount++, str.c_str(), 1); + int iCount = 0; + for (const auto & pSI : m_PVSMgr.m_plShapeInfoList) { + m_ShapesListCtrl.InsertItem(iCount++, std::format("Part_{:d}", pSI->m_iID).c_str(), 1); } } @@ -1267,13 +1249,13 @@ void COrganizeView::OnFileWorkshopOpen() { return; } - std::string szPath(dlg.GetPathName().GetString()), szExt(dlg.GetFileExt().GetString()); - if (!n3std::iequals(szExt, "wshop")) { + fs::path fsFile = dlg.GetPathName().GetString(); + if (!n3std::iequals(fsFile.extension(), ".wshop")) { return; } - OpenWSFileInternal(szPath); - AfxGetApp()->AddToRecentFileList(szPath.c_str()); + OpenWSFileInternal(fsFile); + AfxGetApp()->AddToRecentFileList(fsFile.string().c_str()); CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); pApp->UpdateMRU(); } @@ -1291,44 +1273,44 @@ void COrganizeView::OnFileOpenGamedata() { return; } - std::string szPath(dlg.GetPathName().GetString()), szExt(dlg.GetFileExt().GetString()); - if (!n3std::iequals(szExt, "n3indoor")) { + fs::path fsFile = dlg.GetPathName().GetString(); + if (!n3std::iequals(fsFile.extension(), ".n3indoor")) { return; } - OpenGDFileInternal(szPath); - AfxGetApp()->AddToRecentFileList(szPath.c_str()); + OpenGDFileInternal(fsFile); + AfxGetApp()->AddToRecentFileList(fsFile.string().c_str()); CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); pApp->UpdateMRU(); } -void COrganizeView::OpenWorkShopFile(std::string strFile) { +void COrganizeView::OpenWorkShopFile(const fs::path & fsFile) { if (!OnFileNew()) { return; } - OpenWSFileInternal(strFile); - AfxGetApp()->AddToRecentFileList(strFile.c_str()); + OpenWSFileInternal(fsFile); + AfxGetApp()->AddToRecentFileList(fsFile.string().c_str()); CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); pApp->UpdateMRU(); } -void COrganizeView::OpenGameDataFile(std::string strFile) { +void COrganizeView::OpenGameDataFile(const fs::path & fsFile) { if (!OnFileNew()) { return; } - OpenGDFileInternal(strFile); - AfxGetApp()->AddToRecentFileList(strFile.c_str()); + OpenGDFileInternal(fsFile); + AfxGetApp()->AddToRecentFileList(fsFile.string().c_str()); CN3IndoorApp * pApp = (CN3IndoorApp *)AfxGetApp(); pApp->UpdateMRU(); } -void COrganizeView::OpenWSFileInternal(std::string strFile) { +void COrganizeView::OpenWSFileInternal(const fs::path & fsFile) { CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); m_PVSMgr.m_bGameData = false; - m_PVSMgr.LoadFromFile(strFile); + m_PVSMgr.LoadFromFile(fsFile); RefreshSelectedList(); RefreshLinkToList(); @@ -1352,23 +1334,17 @@ void COrganizeView::OpenWSFileInternal(std::string strFile) { UpdateData(FALSE); - std::string strT; - char szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(strFile.c_str(), NULL, NULL, szFName, szExt); - strT = szFName; - strT += szExt; - - pFrm->SetWindowText(strT.c_str()); + pFrm->SetWindowText(fsFile.filename().string().c_str()); if (pFrm->m_pDlgOutputList && pFrm->m_pDlgOutputList->IsWindowVisible()) { pFrm->m_pDlgOutputList->UpdateTree(); } } -void COrganizeView::OpenGDFileInternal(std::string strFile) { +void COrganizeView::OpenGDFileInternal(const fs::path & fsFile) { CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); m_PVSMgr.m_bGameData = true; - m_PVSMgr.LoadFromFile(strFile); + m_PVSMgr.LoadFromFile(fsFile); m_PVSMgr.m_bCompiled = true; RefreshSelectedList(); @@ -1402,13 +1378,7 @@ void COrganizeView::OpenGDFileInternal(std::string strFile) { pFrm->GetOrganizeView()->m_PVSMgr.CheckcompileMode(pVol); } - std::string strT; - char szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(strFile.c_str(), NULL, NULL, szFName, szExt); - strT = szFName; - strT += szExt; - - pFrm->SetWindowText(strT.c_str()); + pFrm->SetWindowText(fsFile.filename().string().c_str()); if (pFrm->m_pDlgOutputList && pFrm->m_pDlgOutputList->IsWindowVisible()) { pFrm->m_pDlgOutputList->UpdateTree(); } @@ -1416,7 +1386,7 @@ void COrganizeView::OpenGDFileInternal(std::string strFile) { void COrganizeView::OnFileSaveWorkshop() { CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); - if (pFrm->m_strFileName.size() <= 0) { + if (pFrm->m_fsFile.empty()) { AfxMessageBox("SourceList가 없습니다..Data는 저장되지 않을것 입니다.."); return; } @@ -1438,7 +1408,7 @@ void COrganizeView::OnFileSaveWorkshop() { void COrganizeView::OnFileSaveGamedata() { CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); - if (pFrm->m_strFileName.size() <= 0) { + if (pFrm->m_fsFile.empty()) { AfxMessageBox("SourceList가 없습니다..Data는 저장되지 않을것 입니다.."); return; } @@ -1477,8 +1447,8 @@ void COrganizeView::OnFileServerData() { return; } - CString strOpen = dlg.GetPathName(), strExt = dlg.GetFileExt(), strFiles, strCount; - if (strExt.CompareNoCase("smd") != 0) { + fs::path fsFile = dlg.GetPathName().GetString(); + if (!n3std::iequals(fsFile.extension(), ".smd")) { return; } @@ -1486,27 +1456,19 @@ void COrganizeView::OnFileServerData() { m_PVSMgr.DoAllCompile(); } - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - char fname[_MAX_FNAME]; - char ext[_MAX_EXT]; - _splitpath(strOpen, drive, dir, fname, ext); - strFiles = drive; - strFiles += dir; - strFiles += fname; - CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); int iCount = pFrm->m_FloorList.size(); // Terrain Size Calc.. int iMax = GetTerrainSize(); + fs::path fsParentDir = fsFile.parent_path(); + std::string szStem = fsFile.stem().string(); + std::string szExt = fsFile.extension().string(); for (int i = 0; i < iCount; i++) { - CString strFName; - strCount.Format("_%d.", i); - strFName = strFiles + strCount + strExt; - - HANDLE hFile = CreateFile(strFName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fs::path fsIndexedFile = fsParentDir / std::format("{:s}_{:d}{:s}", szStem, i, szExt); + HANDLE hFile = + CreateFileW(fsIndexedFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { AfxMessageBox("File Create Error!!\n"); return; diff --git a/src/tool/N3Indoor/OrganizeView.h b/src/tool/N3Indoor/OrganizeView.h index 605faa61..6651e9d1 100644 --- a/src/tool/N3Indoor/OrganizeView.h +++ b/src/tool/N3Indoor/OrganizeView.h @@ -72,11 +72,11 @@ class COrganizeView : public CFormView { void OnFileServerData(); - void OpenWorkShopFile(std::string strFile); - void OpenGameDataFile(std::string strFile); + void OpenWorkShopFile(const fs::path & fsFile); + void OpenGameDataFile(const fs::path & fsFile); - void OpenWSFileInternal(std::string strFile); - void OpenGDFileInternal(std::string strFile); + void OpenWSFileInternal(const fs::path & fsFile); + void OpenGDFileInternal(const fs::path & fsFile); void ShapeLinkToPVolumn(CN3Base * pBase); bool IsSelectedPvs(); diff --git a/src/tool/N3Indoor/PVSManager.cpp b/src/tool/N3Indoor/PVSManager.cpp index 00463e0e..207b92aa 100644 --- a/src/tool/N3Indoor/PVSManager.cpp +++ b/src/tool/N3Indoor/PVSManager.cpp @@ -671,10 +671,10 @@ void CPVSManager::SplitShapeToVolumn(CDialog * pDlg) { } } -void CPVSManager::RegisterShape(std::string szStr, CN3Shape * pShape) { +void CPVSManager::RegisterShape(const fs::path & fsFile, CN3Shape * pShape) { ShapeInfo * pSI = new ShapeInfo; pSI->m_iID = m_iIncreseShapeIndex++; - pSI->m_strShapeFile = szStr; + pSI->m_fsShapeFile = fsFile; pSI->m_pShape = pShape; m_plShapeInfoList.push_back(pSI); @@ -923,14 +923,13 @@ void CPVSManager::DebugFunc() { } bool CPVSManager::Save(HANDLE hFile) { - DWORD dwNum; - std::string strSrc; + DWORD dwNum; // Version.. WriteFile(hFile, &ciVersion, sizeof(int), &dwNum, NULL); CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); - WriteCryptographString(hFile, pFrm->m_strFileName); + WriteCryptographString(hFile, fs::path(pFrm->m_fsFile).normalize('/', '\\').string()); COrganizeView * pView = pFrm->GetOrganizeView(); int iT = pView->GetDlgItemInt(IDC_TOTAL_MOVE_X); @@ -949,7 +948,7 @@ bool CPVSManager::Save(HANDLE hFile) { while (siit != m_plShapeInfoList.end()) { pSI = *siit++; WriteFile(hFile, &pSI->m_iID, sizeof(int), &dwNum, NULL); - WriteCryptographString(hFile, pSI->m_strShapeFile); + WriteCryptographString(hFile, fs::path(pSI->m_fsShapeFile).normalize('/', '\\').string()); // Shape의 데이터 저장.. WriteFile(hFile, &pSI->m_iBelong, sizeof(int), &dwNum, NULL); @@ -1008,21 +1007,21 @@ bool CPVSManager::Load(HANDLE hFile) { CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); COrganizeView * pView = pFrm->GetOrganizeView(); - std::string strSrc = ReadDecryptString(hFile); - if (pFrm->m_strFileName != strSrc) { - if (pFrm->m_strFileName.size()) { + fs::path fsSrcFile = ReadDecryptString(hFile); + if (pFrm->m_fsFile != fsSrcFile) { + if (!pFrm->m_fsFile.empty()) { if (pFrm->m_pSceneSource) { delete pFrm->m_pSceneSource; pFrm->m_pSceneSource = NULL; } } - pFrm->m_strFileName = strSrc; + pFrm->m_fsFile = fsSrcFile; pFrm->m_pSceneSource = new CN3Scene; pFrm->m_pSceneSource->m_szName = "SourceList"; - pFrm->m_pSceneSource->FileNameSet(strSrc); + pFrm->m_pSceneSource->FilePathSet(fsSrcFile); pFrm->LoadSourceObjects(); - pView->SetDlgItemText(IDC_EDIT_RESOURCE_NAME, strSrc.c_str()); + pView->SetDlgItemText(IDC_EDIT_RESOURCE_NAME, fsSrcFile.string().c_str()); } if (!pFrm->m_pSceneSource) { @@ -1055,11 +1054,11 @@ bool CPVSManager::Load(HANDLE hFile) { ReadFile(hFile, &pSI->m_iID, sizeof(int), &dwNum, NULL); // 문자열 길이.. - strSrc = ReadDecryptString(hFile); - pSI->m_strShapeFile = strSrc; + fsSrcFile = ReadDecryptString(hFile); + pSI->m_fsShapeFile = fsSrcFile; // SourceList에서.. Shape의 Pointer를 연결한다.. - pSI->m_pShape = pFrm->m_pSceneSource->ShapeGetByFileName(strSrc); + pSI->m_pShape = pFrm->m_pSceneSource->ShapeGetByFile(fsSrcFile); ASSERT(pSI->m_pShape); ReadFile(hFile, &pSI->m_iBelong, sizeof(int), &dwNum, NULL); @@ -1198,40 +1197,44 @@ CPortalVolume * CPVSManager::GetPortalVolPointerByID(int iID) { #define CRY_KEY 0x0816 -void CPVSManager::WriteCryptographString(HANDLE hFile, std::string strSrc) { +void CPVSManager::WriteCryptographString(HANDLE hFile, std::string szStr) { DWORD dwNum; - int iCount = strSrc.size(); - std::vector buffer(iCount, 0); - for (int i = 0; i < iCount; i++) { - buffer[i] = (int)strSrc[i] ^ CRY_KEY; + int iLen = szStr.length(); + WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); + if (iLen > 0) { + for (int i = 0; i < iLen; i++) { + szStr[i] ^= CRY_KEY; + } + WriteFile(hFile, szStr.c_str(), iLen, &dwNum, NULL); } - - WriteFile(hFile, &iCount, sizeof(int), &dwNum, NULL); - WriteFile(hFile, &buffer[0], iCount, &dwNum, NULL); } std::string CPVSManager::ReadDecryptString(HANDLE hFile) { DWORD dwNum; - int iCount; - ReadFile(hFile, &iCount, sizeof(int), &dwNum, NULL); - std::vector buffer(iCount, 0); - ReadFile(hFile, &buffer[0], iCount, &dwNum, NULL); // string - for (int i = 0; i < iCount; i++) { - buffer[i] ^= CRY_KEY; + int iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); + + std::string szStr; + if (iLen > 0) { + szStr.assign(iLen, '\0'); + ReadFile(hFile, szStr.data(), iLen, &dwNum, NULL); + for (int i = 0; i < iLen; i++) { + szStr[i] ^= CRY_KEY; + } } - return std::string(buffer.begin(), buffer.end()); + return szStr; } -CN3Shape * CPVSManager::GetShapeByManager(std::string szStr) { +CN3Shape * CPVSManager::GetShapeByManager(const fs::path & fsFile) { ShapeInfo * pSI = NULL; siiter siit = m_plShapeInfoList.begin(); while (siit != m_plShapeInfoList.end()) { pSI = *siit++; - if (pSI->m_pShape->FileName() == szStr) { + if (pSI->m_pShape->FilePath() == fsFile) { return pSI->m_pShape; } } diff --git a/src/tool/N3Indoor/PVSManager.h b/src/tool/N3Indoor/PVSManager.h index 4a1fc8a8..8de2722d 100644 --- a/src/tool/N3Indoor/PVSManager.h +++ b/src/tool/N3Indoor/PVSManager.h @@ -122,7 +122,7 @@ class CPVSManager : public CN3BaseFileAccess { void SplitShapeToVolumn(CDialog * pDlg); // Shape를 리스트에 등록한다.. - void RegisterShape(std::string szStr, CN3Shape * pShape); + void RegisterShape(const fs::path & fsFile, CN3Shape * pShape); bool IsValidPortalVolume(CPortalVolume * pVol); void UpdatePosAll(float fx, float fy, float fz); @@ -135,7 +135,7 @@ class CPVSManager : public CN3BaseFileAccess { public: //.. ShapeInfo * GetShapeInfoByManager(int iID); - CN3Shape * GetShapeByManager(std::string szStr); + CN3Shape * GetShapeByManager(const fs::path & fsFile); // String Cryptograph.. ^^ static void WriteCryptographString(HANDLE hFile, std::string strSrc); diff --git a/src/tool/N3Indoor/PortalFactory.cpp b/src/tool/N3Indoor/PortalFactory.cpp index 316635d9..53a4102b 100644 --- a/src/tool/N3Indoor/PortalFactory.cpp +++ b/src/tool/N3Indoor/PortalFactory.cpp @@ -25,9 +25,7 @@ CPortalFactory::CPortalFactory() {} CPortalFactory::~CPortalFactory() {} std::string CPortalFactory::MakePvsVolString(int iIndex) { - char buffer[32]{}; - sprintf(buffer, "Vol_%d", iIndex); - return std::string(buffer); + return std::format("Vol_{:d}", iIndex); } CPortalVolume * CPortalFactory::CreatePvsVol(int iIndex) { diff --git a/src/tool/N3Indoor/PortalVolume.cpp b/src/tool/N3Indoor/PortalVolume.cpp index 55e16448..11e48897 100644 --- a/src/tool/N3Indoor/PortalVolume.cpp +++ b/src/tool/N3Indoor/PortalVolume.cpp @@ -213,10 +213,10 @@ CPortalVolume * CPortalVolume::GetNthLinkedVolume(int iOrder) { return NULL; } -void CPortalVolume::SetShape(std::string szStr, CN3Shape * pShape, int iOrder) { +void CPortalVolume::SetShape(const fs::path & fsFile, CN3Shape * pShape, int iOrder) { ShapeInfo * pSI = new ShapeInfo; pSI->m_iID = iOrder; - pSI->m_strShapeFile = szStr; + pSI->m_fsShapeFile = fsFile; pSI->m_pShape = pShape; m_plShapeInfoList.push_back(pSI); @@ -730,8 +730,7 @@ bool CPortalVolume::Load(HANDLE hFile, bool bGameData) { CN3Transform::Load(hFile); // 자신의 데이터 로드.. - DWORD dwNum; - std::string strSrc; + DWORD dwNum; // 링크된 갯수를 로드.. int iLinkedCount = 0; @@ -756,12 +755,10 @@ bool CPortalVolume::Load(HANDLE hFile, bool bGameData) { ShapeInfo * pSI = new ShapeInfo; ReadFile(hFile, &pSI->m_iID, sizeof(int), &dwNum, NULL); - // 문자열 길이.. - strSrc = CPVSManager::ReadDecryptString(hFile); - pSI->m_strShapeFile = strSrc; + pSI->m_fsShapeFile = CPVSManager::ReadDecryptString(hFile); // SourceList에서.. Shape의 Pointer를 연결한다.. - pSI->m_pShape = pFrm->m_pSceneSource->ShapeGetByFileName(strSrc); + pSI->m_pShape = pFrm->m_pSceneSource->ShapeGetByFile(pSI->m_fsShapeFile); ASSERT(pSI->m_pShape); ReadFile(hFile, &pSI->m_iBelong, sizeof(int), &dwNum, NULL); @@ -784,8 +781,7 @@ bool CPortalVolume::Load(HANDLE hFile, bool bGameData) { } void CPortalVolume::LoadGameData(HANDLE hFile) { - DWORD dwNum; - std::string strSrc; + DWORD dwNum; //.. int iCount = 0; @@ -848,8 +844,7 @@ void CPortalVolume::LoadGameData(HANDLE hFile) { } bool CPortalVolume::Save(HANDLE hFile, bool bGameData) { - DWORD dwNum; - std::string strSrc; + DWORD dwNum; // 자신의 아이디를 저장.. WriteFile(hFile, &m_iID, sizeof(int), &dwNum, NULL); @@ -880,7 +875,7 @@ bool CPortalVolume::Save(HANDLE hFile, bool bGameData) { pSI = *siit++; WriteFile(hFile, &pSI->m_iID, sizeof(int), &dwNum, NULL); - CPVSManager::WriteCryptographString(hFile, pSI->m_strShapeFile); + CPVSManager::WriteCryptographString(hFile, fs::path(pSI->m_fsShapeFile).normalize('/', '\\').string()); // Shape의 데이터 저장.. WriteFile(hFile, &pSI->m_iBelong, sizeof(int), &dwNum, NULL); @@ -901,8 +896,7 @@ bool CPortalVolume::Save(HANDLE hFile, bool bGameData) { } void CPortalVolume::SaveGameData(HANDLE hFile) { - DWORD dwNum; - std::string strSrc; + DWORD dwNum; int iCount = 0; CPortalVolume * pVol = NULL; diff --git a/src/tool/N3Indoor/PortalVolume.h b/src/tool/N3Indoor/PortalVolume.h index c5395578..82d2381f 100644 --- a/src/tool/N3Indoor/PortalVolume.h +++ b/src/tool/N3Indoor/PortalVolume.h @@ -78,8 +78,8 @@ typedef struct tagCollisionIndex { } __ColIndex; typedef struct tagShapeInfo : public CN3Transform { - int m_iID; - std::string m_strShapeFile; + int m_iID; + fs::path m_fsShapeFile; int m_iBelong; // 소속 - 0:소속 없음 1:엘모라드 2:카루스 3:?? .... int m_iEventID; // Event ID @@ -92,7 +92,6 @@ typedef struct tagShapeInfo : public CN3Transform { //.. tagShapeInfo() { m_iID = -1; - m_strShapeFile = ""; m_pShape = NULL; m_iBelong = 0; @@ -104,7 +103,7 @@ typedef struct tagShapeInfo : public CN3Transform { const tagShapeInfo & operator=(const tagShapeInfo & si) { m_iID = si.m_iID; - m_strShapeFile = si.m_strShapeFile; + m_fsShapeFile = si.m_fsShapeFile; m_pShape = si.m_pShape; m_iBelong = si.m_iBelong; m_iEventID = si.m_iEventID; @@ -205,7 +204,7 @@ class CPortalVolume : public CN3Transform { CPortalVolume * GetNthLinkedVolume(int iOrder); int GetLinkedVolumeCount(); int GetLinkedShapeCount(); - void SetShape(std::string szStr, CN3Shape * pShape, int iOrder); + void SetShape(const fs::path & fsFile, CN3Shape * pShape, int iOrder); bool IsExistLinkedShapeByPointer(ShapeInfo * pSI); diff --git a/src/tool/N3Indoor/PvsObjFactory.cpp b/src/tool/N3Indoor/PvsObjFactory.cpp index c102ccb6..84a29284 100644 --- a/src/tool/N3Indoor/PvsObjFactory.cpp +++ b/src/tool/N3Indoor/PvsObjFactory.cpp @@ -68,11 +68,7 @@ HICON CPvsObjFactory::GetPvsWallIcon() { } std::string CPvsObjFactory::MakePvsWallString(int iIndex, e_WallType eWT) { - int iWT = (int)eWT; - iWT++; - char buffer[32]{}; - sprintf(buffer, "Wall_%d_%d", iIndex, iWT); - return std::string(buffer); + return std::format("Wall_{:d}_{:d}", iIndex, static_cast(eWT) + 1); } HICON CPvsObjFactory::GetPvsVolIcon() { @@ -80,7 +76,5 @@ HICON CPvsObjFactory::GetPvsVolIcon() { } std::string CPvsObjFactory::MakePvsVolString(int iIndex) { - char buffer[32]{}; - sprintf(buffer, "Vol_%d", iIndex); - return std::string(buffer); + return std::format("Vol_{:d}", iIndex); } diff --git a/src/tool/N3ME/DTexGroupMng.cpp b/src/tool/N3ME/DTexGroupMng.cpp index 46f0e5bc..395e8f02 100644 --- a/src/tool/N3ME/DTexGroupMng.cpp +++ b/src/tool/N3ME/DTexGroupMng.cpp @@ -344,19 +344,16 @@ char * CDTexGroupMng::GetGroupName(int id) { // // // -bool CDTexGroupMng::LoadFromFile(CString RealFileName) { +bool CDTexGroupMng::LoadFromFile(const fs::path & fsFileName) { Init(m_pMainFrm); - SetCurrentDirectory(CN3Base::PathGet().c_str()); - char szDTexInfoFileName[_MAX_PATH]; - sprintf(szDTexInfoFileName, "dtex\\%s.tgx", (LPCTSTR)RealFileName); - - FILE * stream = fopen(szDTexInfoFileName, "r"); + fs::path fsTgxFile = ("DTex" / fsFileName).replace_extension(".tgx"); + FILE * stream = _wfopen(fsTgxFile.c_str(), L"r"); if (stream) { int iCount; int result = fscanf(stream, "NumGroup = %d\n", &iCount); if (EOF == result) { - MessageBox(::GetActiveWindow(), szDTexInfoFileName, "Invalid DTex Info File...", MB_OK); + MessageBoxW(::GetActiveWindow(), fsTgxFile.c_str(), L"Invalid DTex Info File...", MB_OK); return false; } @@ -370,7 +367,7 @@ bool CDTexGroupMng::LoadFromFile(CString RealFileName) { //result = fscanf(stream, "%s", szDTexGroupName); //result = fscanf(stream, "%d\n", &id); if (EOF == result) { - MessageBox(::GetActiveWindow(), szDTexInfoFileName, "Invalid DTex Info File...", MB_OK); + MessageBoxW(::GetActiveWindow(), fsTgxFile.c_str(), L"Invalid DTex Info File...", MB_OK); return false; } @@ -388,16 +385,13 @@ bool CDTexGroupMng::LoadFromFile(CString RealFileName) { // // // -bool CDTexGroupMng::SaveToFile(CString RealFileName) { - SetCurrentDirectory(CN3Base::PathGet().c_str()); - - CreateDirectory("dtex", NULL); - - char szDTexInfoFileName[_MAX_PATH]; - sprintf(szDTexInfoFileName, "dtex\\%s.tgx", (LPCTSTR)RealFileName); +bool CDTexGroupMng::SaveToFile(const fs::path & fsFileName) { + fs::path fsDtexDir("DTex"); + fs::create_directory(fsDtexDir); - FILE * stream = fopen(szDTexInfoFileName, "w"); + fs::path fsTgxFile = (fsDtexDir / fsFileName).replace_extension(".tgx"); + FILE * stream = _wfopen(fsTgxFile.c_str(), L"w"); if (stream) { int iCount = m_Groups.size() - 1; fprintf(stream, "NumGroup = %d\n", iCount); diff --git a/src/tool/N3ME/DTexGroupMng.h b/src/tool/N3ME/DTexGroupMng.h index b7e4d8e3..131b5b88 100644 --- a/src/tool/N3ME/DTexGroupMng.h +++ b/src/tool/N3ME/DTexGroupMng.h @@ -35,8 +35,8 @@ class CDTexGroupMng : public CN3Base { int GetIndex2ID(int idx); int GetID2Index(int id); char * GetGroupName(int id); - bool SaveToFile(CString RealFileName); - bool LoadFromFile(CString RealFileName); + bool SaveToFile(const fs::path & fsFileName); + bool LoadFromFile(const fs::path & fsFileName); void Init(CWnd * pWndParent); void Release(); void SetGroup(const char * pName); diff --git a/src/tool/N3ME/DTexMng.cpp b/src/tool/N3ME/DTexMng.cpp index dd961f72..5686c6ec 100644 --- a/src/tool/N3ME/DTexMng.cpp +++ b/src/tool/N3ME/DTexMng.cpp @@ -62,30 +62,18 @@ void CDTexMng::Init(CMainFrame * pFrm) { // // // -bool CDTexMng::AddDTex(CString FileName) { - if (IsInDTex(FileName)) { +bool CDTexMng::AddDTex(const fs::path & fsFileName) { + if (IsInDTex(fsFileName)) { return false; } - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - - std::string szNewFN = "dtex\\"; - szNewFN += FileName; - CDTex * pDTex = new CDTex; pDTex->Init(); pDTex->m_ID = m_NextID; - - std::string szOldPath = CN3Base::PathGet(); - CN3Base::PathSet(szNewPath); - pDTex->m_pTex->LoadFromFile(szNewFN); - CN3Base::PathSet(szOldPath); + if (!pDTex->m_pTex->LoadFromFile("DTex" / fsFileName)) { + delete pDTex; + return false; + } m_pDTex.push_back(pDTex); m_NextID++; @@ -117,12 +105,10 @@ void CDTexMng::DelDTexByID(int id) { // Load.. // DTex정보들과 실제 텍스쳐 소스들을 읽어들인다. // -void CDTexMng::LoadFromFile(CString RealFileName) { +void CDTexMng::LoadFromFile(const fs::path & fsFileName) { Init(m_pMainFrm); - char szDTexInfoFileName[_MAX_PATH]; - wsprintf(szDTexInfoFileName, "%sDTEX\\%s.dtx", CN3Base::PathGet().c_str(), (LPCTSTR)RealFileName); - - FILE * stream = fopen(szDTexInfoFileName, "r"); + fs::path fsDtxFile = (CN3Base::PathGet() / "DTex" / fsFileName).replace_extension(".dtx"); + FILE * stream = _wfopen(fsDtxFile.c_str(), L"r"); if (!stream) { return; } @@ -130,7 +116,7 @@ void CDTexMng::LoadFromFile(CString RealFileName) { int iCount; int result = fscanf(stream, "NumDTex = %d\n", &iCount); if (EOF == result) { - MessageBox(::GetActiveWindow(), szDTexInfoFileName, "Invalid DTex Info File...", MB_OK); + MessageBoxW(::GetActiveWindow(), fsDtxFile.c_str(), L"Invalid DTex Info File...", MB_OK); return; } @@ -142,9 +128,8 @@ void CDTexMng::LoadFromFile(CString RealFileName) { CDTexGroupMng * pDTexGroupMng = m_pMainFrm->GetDTexGroupMng(); - int i; - char szDTexFileName[_MAX_PATH]; - DWORD dwRWC; + int i; + char szDTexFileName[_MAX_PATH]; for (i = 0; i < iCount; i++) { result = fscanf(stream, "%s\n", szDTexFileName); __ASSERT(result != EOF, "Invalid DTex Info File..."); @@ -158,13 +143,12 @@ void CDTexMng::LoadFromFile(CString RealFileName) { pDTex->m_pTex->LoadFromFile(szDTexFileName); // 그에 관한 타일 정보들을 읽고.. - char szDir[_MAX_DIR], szFName[_MAX_FNAME]; - _splitpath(szDTexFileName, NULL, szDir, szFName, NULL); - wsprintf(szDTexInfoFileName, "%s%s%s.dif", CN3Base::PathGet().c_str(), szDir, - szFName); // Texture Information file + // Texture Information file + fsDtxFile = (CN3Base::PathGet() / szDTexFileName).replace_extension(".dif"); + DWORD dwRWC; HANDLE hFile = - CreateFile(szDTexInfoFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + CreateFileW(fsDtxFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { for (int x = 0; x < NUM_DTEXTILE; x++) { for (int y = 0; y < NUM_DTEXTILE; y++) { @@ -195,7 +179,6 @@ void CDTexMng::LoadFromFile(CString RealFileName) { CDTexGroupMng * pDTexGroupMng = m_pMainFrm->GetDTexGroupMng(); char szDTexFileName[_MAX_PATH]; - DWORD dwRWC; CProgressBar ProgressBar; ProgressBar.Create("Load TileTex Info..", 50, iCount); @@ -236,13 +219,12 @@ void CDTexMng::LoadFromFile(CString RealFileName) { if (version == 1) { // 그에 관한 타일 정보들을 읽고.. - char szDir[_MAX_DIR], szFName[_MAX_FNAME]; - _splitpath(szDTexFileName, NULL, szDir, szFName, NULL); - wsprintf(szDTexInfoFileName, "%s%s%s.dif", CN3Base::PathGet().c_str(), szDir, - szFName); // Texture Information file + // Texture Information file + fsDtxFile = (CN3Base::PathGet() / szDTexFileName).replace_extension(".dif"); + DWORD dwRWC; HANDLE hFile = - CreateFile(szDTexInfoFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + CreateFileW(fsDtxFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { for (int x = 0; x < NUM_DTEXTILE; x++) { for (int y = 0; y < NUM_DTEXTILE; y++) { @@ -267,15 +249,12 @@ void CDTexMng::LoadFromFile(CString RealFileName) { // // // -void CDTexMng::SaveToFile(CString RealFileName) { - char szDTexDir[_MAX_PATH]; - wsprintf(szDTexDir, "%sDTex", CN3Base::PathGet().c_str()); - CreateDirectory("dtex", NULL); // 경로 만들고.. +void CDTexMng::SaveToFile(const fs::path & fsFileName) { + fs::path fsDtexDir = CN3Base::PathGet() / "DTex"; + fs::create_directory(fsDtexDir); - char szDTexInfoFileName[_MAX_PATH]; - wsprintf(szDTexInfoFileName, "%sDTEX\\%s.dtx", CN3Base::PathGet().c_str(), (LPCTSTR)RealFileName); - - FILE * stream = fopen(szDTexInfoFileName, "w"); + fs::path fsDtxFile = (fsDtexDir / fsFileName).replace_extension(".dtx"); + FILE * stream = _wfopen(fsDtxFile.c_str(), L"w"); if (!stream) { return; } @@ -287,17 +266,9 @@ void CDTexMng::SaveToFile(CString RealFileName) { CDTexGroupMng * pDTexGroupMng = m_pMainFrm->GetDTexGroupMng(); - int id; - it_DTex it; - char szDTexFileName[_MAX_PATH]; - //DWORD dwRWC; - CDTex * pDTex; - for (it = m_pDTex.begin(); it != m_pDTex.end(); it++) { - pDTex = (*it); - sprintf(szDTexFileName, "%s", pDTex->m_pTex->FileName().c_str()); - id = pDTex->m_ID; - - fprintf(stream, "%s %d\n", szDTexFileName, id); + for (it_DTex it = m_pDTex.begin(); it != m_pDTex.end(); it++) { + CDTex * pDTex = (*it); + fprintf(stream, "%s %d\n", pDTex->m_pTex->FilePathWin().c_str(), pDTex->m_ID); for (int y = 0; y < NUM_DTEXTILE; y++) { fprintf(stream, "%d\n", pDTex->m_Attr[0][y].Group); @@ -308,20 +279,18 @@ void CDTexMng::SaveToFile(CString RealFileName) { // version1 저장방식... // dif파일만들기... // - char szDir[_MAX_DIR], szFName[_MAX_FNAME]; - _splitpath(szDTexFileName, NULL, szDir, szFName, NULL); - wsprintf(szDTexInfoFileName, "%s%s%s.dif", CN3Base::PathGet().c_str(), szDir, szFName); // Texture Information file + // Texture Information file + fsDtxFile = fs::path(pDTex->m_pTex->FilePathAbs()).replace_extension(".dif"); // 그에 관한 타일 정보들을 읽고.. - HANDLE hFile = CreateFile(szDTexInfoFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - if(hFile != INVALID_HANDLE_VALUE) - { - for(int x=0; xm_Attr[x][y]), sizeof(DTEXATTR), &dwRWC, NULL); } } @@ -336,57 +305,41 @@ void CDTexMng::SaveToFile(CString RealFileName) { // 게임에서 쓸수 있는 타일 텍스쳐 포멧으로 변환후 저장.. // void CDTexMng::SaveGameTile() { - D3DFORMAT Format; - int Size = DTEX_SIZE / NUM_DTEXTILE; //단위텍스쳐의 길이.. - D3DLOCKED_RECT d3dlr; + int Size = DTEX_SIZE / NUM_DTEXTILE; // Length of unit texture - HANDLE hFile; - int ix, iz; - char * pSourceImg; - char * pTargetImg; + fs::path fsDtexDir = (CN3Base::PathGet() / "DTex"); + fs::create_directory(fsDtexDir); - char szDTexDir[_MAX_PATH]; - wsprintf(szDTexDir, "%sDTex\\", CN3Base::PathGet().c_str()); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME]; - _splitpath(szDTexDir, szDrive, szDir, NULL, NULL); - - CN3Texture * pTex; - char szDTexGameFileName[_MAX_PATH]; - char szNewFName[_MAX_PATH]; - - it_DTex it; //for(int i=0;im_pTex; + CN3Texture * pTex = pDTex->m_pTex; if (NULL == pTex || NULL == pTex->Get()) { MessageBox(::GetActiveWindow(), "Tile texture pointer is NULL!!!", "Save GameTile Data Error", MB_OK); continue; } //Source Info... - Format = pTex->PixelFormat(); + D3DFORMAT Format = pTex->PixelFormat(); + D3DLOCKED_RECT d3dlr; pTex->Get()->LockRect(0, &d3dlr, 0, 0); int Bits = d3dlr.Pitch / DTEX_SIZE; CN3Texture TileTex; D3DLOCKED_RECT d3dlrTarget; - for (iz = 0; iz < NUM_DTEXTILE; iz++) { - //file setting.. - _splitpath(pTex->FileName().c_str(), NULL, NULL, szFName, NULL); - sprintf(szNewFName, "%s_%d", szFName, iz); + std::string szTexStem = pTex->FilePath().stem().string(); + for (int iz = 0; iz < NUM_DTEXTILE; iz++) { + fs::path fsGttFile = fsDtexDir / std::format("{:s}_{:d}.gtt", szTexStem, iz); + HANDLE hFile = + CreateFileW(fsGttFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - _makepath(szDTexGameFileName, szDrive, szDir, szNewFName, ".gtt"); - hFile = - CreateFile(szDTexGameFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - for (ix = 0; ix < NUM_DTEXTILE; ix++) { + for (int ix = 0; ix < NUM_DTEXTILE; ix++) { //텍스쳐 서페이스 만들고, 텍스쳐 채우고, 형식 변환하고, 저장. TileTex.Create(Size, Size, Format, TRUE); TileTex.Get()->LockRect(0, &d3dlrTarget, 0, 0); - pSourceImg = (char *)((char *)d3dlr.pBits + (ix * Size * Bits) + (iz * Size * d3dlr.Pitch)); - pTargetImg = (char *)d3dlrTarget.pBits; + char * pSourceImg = (char *)((char *)d3dlr.pBits + (ix * Size * Bits) + (iz * Size * d3dlr.Pitch)); + char * pTargetImg = (char *)d3dlrTarget.pBits; for (int j = 0; j < Size; j++) { memcpy(&(pTargetImg[j * Bits * Size]), &(pSourceImg[j * d3dlr.Pitch]), Bits * Size); @@ -421,60 +374,21 @@ CDTex * CDTexMng::GetDTexByID(int id) { // // // -CDTex * CDTexMng::GetDTexByName(CString FileName) { - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - - CString NewFileName = "dtex\\"; +CDTex * CDTexMng::GetDTexByName(const fs::path & fsFileName) { + const fs::path & fsFileSearch = "dtex" / fsFileName; - NewFileName += FileName; + auto pDTex = std::ranges::find_if( + m_pDTex, [&fsFileSearch](CDTex * pDTex) { return n3std::iequals(pDTex->m_pTex->FilePath(), fsFileSearch); }); - CString DTexName; - CDTex * pDTex; - - it_DTex it; - for (it = m_pDTex.begin(); it != m_pDTex.end(); it++) { - pDTex = (*it); - DTexName = pDTex->m_pTex->FileName().c_str(); - - if (DTexName == NewFileName) { - return pDTex; - } - } - return NULL; + return (pDTex != m_pDTex.end()) ? *pDTex : NULL; } // // // -bool CDTexMng::IsInDTex(CString FileName) { - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - - CString NewFileName = "dtex\\"; - NewFileName += FileName; +bool CDTexMng::IsInDTex(const fs::path & fsFileName) { + const fs::path & fsFileSearch = "dtex" / fsFileName; - CString DTexName; - CDTex * pDTex; - - it_DTex it; - for (it = m_pDTex.begin(); it != m_pDTex.end(); it++) { - pDTex = (*it); - DTexName = pDTex->m_pTex->FileName().c_str(); - - if (DTexName == NewFileName) { - return true; - } - } - return false; + return std::ranges::any_of( + m_pDTex, [&](const auto & pDTex) { return n3std::iequals(pDTex->m_pTex->FilePath(), fsFileSearch); }); } diff --git a/src/tool/N3ME/DTexMng.h b/src/tool/N3ME/DTexMng.h index 647680e5..461e1c30 100644 --- a/src/tool/N3ME/DTexMng.h +++ b/src/tool/N3ME/DTexMng.h @@ -23,18 +23,18 @@ class CDTexMng : public CN3Base { //CDTex* m_pDTex[MAX_TILETEXTURE]; public: - bool IsInDTex(CString FileName); int GetMaxID() { return m_NextID - 1; } CDTex * GetDTexByID(int id); - CDTex * GetDTexByName(CString FileName); + CDTex * GetDTexByName(const fs::path & fsFileName); + bool IsInDTex(const fs::path & fsFileName); int GetNumDTex() { return m_pDTex.size(); } - bool AddDTex(CString FileName); + bool AddDTex(const fs::path & fsFileName); void DelDTexByID(int id); void Init(CMainFrame * pFrm = NULL); void Release(); - void SaveToFile(CString RealFileName); - void LoadFromFile(CString RealFileName); + void SaveToFile(const fs::path & fsFileName); + void LoadFromFile(const fs::path & fsFileName); void SaveGameTile(); CDTexMng(); diff --git a/src/tool/N3ME/DlgAddDTex.cpp b/src/tool/N3ME/DlgAddDTex.cpp index 773c944c..017dbff3 100644 --- a/src/tool/N3ME/DlgAddDTex.cpp +++ b/src/tool/N3ME/DlgAddDTex.cpp @@ -2,8 +2,9 @@ // #include "StdAfx.h" -#include "n3me.h" +#include "N3ME.h" #include "DlgAddDTex.h" +#include "N3Base/N3Base.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -51,19 +52,13 @@ void CDlgAddDTex::OnDblclkAdddtexlist() { BOOL CDlgAddDTex::OnInitDialog() { CDialog::OnInitDialog(); - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); + fs::path fsPrevPath = fs::current_path(); + fs::current_path(CN3Base::PathGet()); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); + std::string szSearchPath = (fs::path("DTex") / "*.bmp").string(); + m_TexList.Dir(DDL_READONLY, szSearchPath.c_str()); - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - SetCurrentDirectory(szNewPath); - m_TexList.Dir(DDL_READONLY, "dtex\\*.bmp"); - SetCurrentDirectory(szOldPath); + fs::current_path(fsPrevPath); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/src/tool/N3ME/DlgBase.cpp b/src/tool/N3ME/DlgBase.cpp index c5e2f7bd..0aacea1f 100644 --- a/src/tool/N3ME/DlgBase.cpp +++ b/src/tool/N3ME/DlgBase.cpp @@ -513,7 +513,7 @@ void CDlgBase::UpdateInfo() { if (pItem) { CN3Texture * pTex = pPD->Tex(0); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -522,7 +522,7 @@ void CDlgBase::UpdateInfo() { pItem = m_LPShape.GetPropItem("Mesh File"); if (pItem) { if (pPMesh) { - pItem->m_curValue = pPMesh->FileName().c_str(); + pItem->m_curValue = pPMesh->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -600,7 +600,7 @@ void CDlgBase::UpdateInfo() { if (pItem) { CN3Joint * pJoint = pC->Joint(); if (pJoint) { - pItem->m_curValue = pJoint->FileName().c_str(); + pItem->m_curValue = pJoint->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -610,7 +610,7 @@ void CDlgBase::UpdateInfo() { if (pItem) { CN3VMesh * pMC = pC->CollisionMesh(); if (pMC) { - pItem->m_curValue = pMC->FileName().c_str(); + pItem->m_curValue = pMC->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -620,7 +620,7 @@ void CDlgBase::UpdateInfo() { // if(pItem) // { // CN3Skin* pSkin = pC->CollisionSkin(); - // if(pSkin) pItem->m_curValue = pSkin->FileName().c_str(); + // if(pSkin) pItem->m_curValue = pSkin->FilePath().c_str(); // else pItem->m_curValue = ""; // } @@ -636,27 +636,31 @@ void CDlgBase::UpdateInfo() { if (pItem) { CN3Texture * pTex = pPart->Tex(); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } } - // pItem = m_LPCPart.GetPropItem("Mesh File"); - // if(pItem) - // { - // CN3IMesh* pMesh = pPart->Mesh(nLOD); - // if(pMesh) pItem->m_curValue = pMesh->FileName().c_str(); - // else pItem->m_curValue = ""; - // } - // - // pItem = m_LPCPart.GetPropItem("Skin File"); - // if(pItem) - // { - // CN3Skin* pSkin = pPart->Skin(nLOD); - // if(pSkin) pItem->m_curValue = pSkin->FileName().c_str(); - // else pItem->m_curValue = ""; - // } + //pItem = m_LPCPart.GetPropItem("Mesh File"); + //if (pItem) { + // CN3IMesh * pMesh = pPart->Mesh(nLOD); + // if (pMesh) { + // pItem->m_curValue = pMesh->FilePath().c_str(); + // } else { + // pItem->m_curValue = ""; + // } + //} + + //pItem = m_LPCPart.GetPropItem("Skin File"); + //if (pItem) { + // CN3Skin * pSkin = pPart->Skin(nLOD); + // if (pSkin) { + // pItem->m_curValue = pSkin->FilePath().c_str(); + // } else { + // pItem->m_curValue = ""; + // } + //} } // 붙이는 오브젝트(무기, 장신구 등...) 정보 표시 @@ -700,7 +704,7 @@ void CDlgBase::UpdateInfo() { pItem = m_LPCPlug.GetPropItem("Plug Mesh File"); if (pItem) { if (pPlug->PMesh()) { - pItem->m_curValue = pPlug->PMesh()->FileName().c_str(); + pItem->m_curValue = pPlug->PMesh()->FilePath().c_str(); } else { pItem->m_curValue = "NULL"; } @@ -709,7 +713,7 @@ void CDlgBase::UpdateInfo() { pItem = m_LPCPlug.GetPropItem("Plug Texture File"); if (pItem) { if (pPlug->Tex()) { - pItem->m_curValue = pPlug->Tex()->FileName().c_str(); + pItem->m_curValue = pPlug->Tex()->FilePath().c_str(); } else { pItem->m_curValue = "NULL"; } @@ -906,46 +910,29 @@ BOOL CDlgBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { pS->m_iNPC_ID = atoi(pItem->m_curValue); } else if (pItem->m_propName == "NPC Status" && pItem->m_curValue.GetLength() > 0) { pS->m_iNPC_Status = atoi(pItem->m_curValue); // NPC 로 쓰는 오브젝트일 경우 NPC Type - } - - else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { - pS->CollisionMeshSet(std::string(pItem->m_curValue)); - } - - else if (pItem->m_propName == "Collision Mesh Delete") { + } else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { + pS->CollisionMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + } else if (pItem->m_propName == "Collision Mesh Delete") { pS->CollisionMeshSet(""); - } - - else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { - CStringArray szArr; - int n = 0, nPrev = 0; - while (1) { - n = pItem->m_curValue.Find('\n', n); - if (-1 == n) { - break; - } - - szArr.Add(pItem->m_curValue.Mid(nPrev, n - nPrev)); - nPrev = n + 1; - n++; + } else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { + std::vector vTexFiles; + for (const auto & itrTexFile : std::string(pItem->m_curValue.GetString()) | std::views::split('\n')) { + fs::path fsTexFile(itrTexFile.begin(), itrTexFile.end()); + CN3BaseFileAccess::ToRelative(fsTexFile); + vTexFiles.emplace_back(fsTexFile); } - CN3Base tmp; - n = szArr.GetSize(); - pPD->TexAlloc(n); - for (int i = 0; i < n; i++) { - tmp.m_szName = szArr[i]; - pPD->TexSet(i, tmp.m_szName); + int iTexCount = static_cast(vTexFiles.size()); + pPD->TexAlloc(iTexCount); + for (int i = 0; i < iTexCount; ++i) { + pPD->TexSet(i, vTexFiles[i]); } this->UpdateInfo(); } else if (pItem->m_propName == "Mesh File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pPD->MeshSet(tmp.m_szName); - + pPD->MeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } @@ -972,28 +959,21 @@ BOOL CDlgBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { int nPlugCount = pC->PlugCount(); if (pItem->m_propName == "Joint File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pC->JointSet(tmp.m_szName); + pC->JointSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { - pC->CollisionMeshSet(std::string(pItem->m_curValue)); + pC->CollisionMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } else if (pItem->m_propName == "Collision Mesh Delete") { pC->CollisionMeshSet(""); this->UpdateInfo(); - } - // else if(pItem->m_propName == "Collision Skin File" && pItem->m_curValue.GetLength() > 0) - // { - // pC->CollisionSkinSet(pItem->m_curValue); - // this->UpdateInfo(); - // } - // else if(pItem->m_propName == "Collision Skin Delete") - // { - // pC->CollisionSkinSet(""); - // this->UpdateInfo(); - // } - else if (pItem->m_propName == "Part Add") { + //} else if (pItem->m_propName == "Collision Skin File" && pItem->m_curValue.GetLength() > 0) { + // pC->CollisionSkinSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + // this->UpdateInfo(); + //} else if (pItem->m_propName == "Collision Skin Delete") { + // pC->CollisionSkinSet(""); + // this->UpdateInfo(); + } else if (pItem->m_propName == "Part Add") { pC->PartAdd(); this->UpdateInfo(); } else if (pItem->m_propName == "Part Delete") { @@ -1033,28 +1013,15 @@ BOOL CDlgBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { } this->UpdateInfo(); } else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pPart->TexSet(tmp.m_szName); - + pPart->TexSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); + //} else if (pItem->m_propName == "Mesh File" && pItem->m_curValue.GetLength() > 0) { + // pPart->MeshSet(nLOD, CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + // this->UpdateInfo(); + //} else if (pItem->m_propName == "Skin File" && pItem->m_curValue.GetLength() > 0) { + // pPart->SkinSet(nLOD, CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + // this->UpdateInfo(); } - // else if(pItem->m_propName == "Mesh File" && pItem->m_curValue.GetLength() > 0) - // { - // CN3Base tmp; - // tmp.m_szName = pItem->m_curValue; - // pPart->MeshSet(nLOD, tmp.m_szName); - // - // this->UpdateInfo(); - // } - // else if(pItem->m_propName == "Skin File" && pItem->m_curValue.GetLength() > 0) - // { - // CN3Base tmp; - // tmp.m_szName = pItem->m_curValue; - // pPart->SkinSet(nLOD, tmp.m_szName); - // - // this->UpdateInfo(); - // } } } @@ -1085,16 +1052,10 @@ BOOL CDlgBase::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { } else if (pItem->m_propName == "Plug Scale") { pPlug->ScaleSet(__Vector3(pItem->VectorGet())); } else if (pItem->m_propName == "Plug Mesh File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pPlug->PMeshSet(tmp.m_szName); - + pPlug->PMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } else if (pItem->m_propName == "Plug Texture File" && pItem->m_curValue.GetLength() > 0) { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; - pPlug->TexSet(tmp.m_szName); - + pPlug->TexSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } } diff --git a/src/tool/N3ME/DlgEditEvent.cpp b/src/tool/N3ME/DlgEditEvent.cpp index 57a88265..9d7b0ae1 100644 --- a/src/tool/N3ME/DlgEditEvent.cpp +++ b/src/tool/N3ME/DlgEditEvent.cpp @@ -132,7 +132,7 @@ void CDlgEditEvent::OnBtnLoadEvtfile() { CDlgLoadEvt dlg; if (dlg.DoModal() == IDOK) { - m_pRefEventMgr->LoadFromFile((LPCTSTR)dlg.m_SelFileName); + m_pRefEventMgr->LoadFromFile(dlg.m_SelFileName.GetString()); ResetAll(); if (dlg.m_SelFileName.IsEmpty()) { @@ -149,7 +149,7 @@ void CDlgEditEvent::OnBtnSaveEvtfile() { CDlgSaveEvt dlg; if (dlg.DoModal() == IDOK) { - m_pRefEventMgr->SaveToFile((LPCTSTR)dlg.m_FileName); + m_pRefEventMgr->SaveToFile(dlg.m_FileName.GetString()); if (dlg.m_FileName.IsEmpty()) { m_CurrFileName = ""; diff --git a/src/tool/N3ME/DlgEditWarp.cpp b/src/tool/N3ME/DlgEditWarp.cpp index fab7a6b6..1cbbd782 100644 --- a/src/tool/N3ME/DlgEditWarp.cpp +++ b/src/tool/N3ME/DlgEditWarp.cpp @@ -169,11 +169,10 @@ void CDlgEditWarp::OnOK() { void CDlgEditWarp::OnBtnExport() { CFileDialog dlg(FALSE, "wap", "Noname", OFN_EXPLORER | OFN_LONGNAMES | OFN_OVERWRITEPROMPT, "Warp Info파일(*.wap)|*.wap||"); - - if (dlg.DoModal() == IDOK) { - CString str = dlg.GetPathName(); - m_pRefWarpMgr->SaveToFile((LPCTSTR)str); + if (dlg.DoModal() == IDCANCEL) { + return; } + m_pRefWarpMgr->SaveToFile(dlg.GetPathName().GetString()); } void CDlgEditWarp::OnBtnImport() { @@ -183,7 +182,5 @@ void CDlgEditWarp::OnBtnImport() { if (dlg.DoModal() == IDCANCEL) { return; } - - CString str = dlg.GetPathName(); - m_pRefWarpMgr->LoadFromFile((LPCTSTR)str); + m_pRefWarpMgr->LoadFromFile(dlg.GetPathName().GetString()); } diff --git a/src/tool/N3ME/DlgFolderSelect.cpp b/src/tool/N3ME/DlgFolderSelect.cpp index f3fc2740..d9c942ce 100644 --- a/src/tool/N3ME/DlgFolderSelect.cpp +++ b/src/tool/N3ME/DlgFolderSelect.cpp @@ -60,9 +60,7 @@ BOOL CDlgFolderSelect::OnInitDialog() { } CString szDir; - char szCurPath[256]; - GetCurrentDirectory(256, szCurPath); - int nSel = m_CBFolder.AddString(szCurPath); + int nSel = m_CBFolder.AddString(fs::current_path().string().c_str()); m_CBFolder.SetCurSel(nSel); m_CBFolder.GetLBText(nSel, szDir); diff --git a/src/tool/N3ME/DlgLight.cpp b/src/tool/N3ME/DlgLight.cpp index bb0c78b7..582196a4 100644 --- a/src/tool/N3ME/DlgLight.cpp +++ b/src/tool/N3ME/DlgLight.cpp @@ -91,11 +91,11 @@ void CDlgLight::OnBtnExport() { if (dlg.DoModal() == IDOK) { m_strPathName = dlg.GetPathName(); - m_pRefLightObjMgr->SaveToFile((LPCTSTR)m_strPathName); + m_pRefLightObjMgr->SaveToFile(m_strPathName.GetString()); UpdateData(FALSE); } } else { - m_pRefLightObjMgr->SaveToFile((LPCTSTR)m_strPathName); + m_pRefLightObjMgr->SaveToFile(m_strPathName.GetString()); } } @@ -106,8 +106,7 @@ void CDlgLight::OnBtnImport() { if (dlg.DoModal() == IDCANCEL) { return; } - - m_pRefLightObjMgr->LoadFromFile((LPCTSTR)dlg.GetPathName()); + m_pRefLightObjMgr->LoadFromFile(dlg.GetPathName().GetString()); CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); if (pFrm) { diff --git a/src/tool/N3ME/DlgLoadEvt.cpp b/src/tool/N3ME/DlgLoadEvt.cpp index e4cd11a5..2a1b1aa0 100644 --- a/src/tool/N3ME/DlgLoadEvt.cpp +++ b/src/tool/N3ME/DlgLoadEvt.cpp @@ -2,8 +2,9 @@ // #include "StdAfx.h" -#include "n3me.h" +#include "N3ME.h" #include "DlgLoadEvt.h" +#include "N3Base/N3Base.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -41,36 +42,23 @@ END_MESSAGE_MAP() BOOL CDlgLoadEvt::OnInitDialog() { CDialog::OnInitDialog(); - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); + fs::path fsPrevPath = fs::current_path(); + fs::current_path(CN3Base::PathGet()); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - SetCurrentDirectory(szNewPath); - m_EvtFileList.Dir(DDL_READONLY, "Event\\*.evt"); + std::string szSearchPath = (fs::path("Event") / "*.evt").string(); + m_EvtFileList.Dir(DDL_READONLY, szSearchPath.c_str()); int count = m_EvtFileList.GetCount(); CString str; for (int i = 0; i < count; i++) { m_EvtFileList.GetText(0, str); - - char szFileName[MAX_PATH]; - char szExt[_MAX_EXT]; - _splitpath((LPCTSTR)str, NULL, NULL, szFileName, szExt); - - //str.Format("%s%s",szFileName,szExt); - str.Format("%s", szFileName); + str = fs::path(str.GetString()).stem().c_str(); m_EvtFileList.InsertString(count, str); m_EvtFileList.DeleteString(0); } - SetCurrentDirectory(szOldPath); + fs::current_path(fsPrevPath); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/src/tool/N3ME/DlgLoadNPCPath.cpp b/src/tool/N3ME/DlgLoadNPCPath.cpp index 3099d3c2..79860e11 100644 --- a/src/tool/N3ME/DlgLoadNPCPath.cpp +++ b/src/tool/N3ME/DlgLoadNPCPath.cpp @@ -2,8 +2,9 @@ // #include "StdAfx.h" -#include "n3me.h" +#include "N3ME.h" #include "DlgLoadNPCPath.h" +#include "N3Base/N3Base.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -50,37 +51,23 @@ void CDlgLoadNPCPath::OnDblclkListNpcpath() { BOOL CDlgLoadNPCPath::OnInitDialog() { CDialog::OnInitDialog(); - // TODO: Add extra initialization here - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); + fs::path fsPrevPath = fs::current_path(); + fs::current_path(CN3Base::PathGet()); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - SetCurrentDirectory(szNewPath); - m_NPCPathFileList.Dir(DDL_READONLY, "NPCPath\\*.npi"); + std::string szSearchPath = (fs::path("NPCPath") / "*.npi").string(); + m_NPCPathFileList.Dir(DDL_READONLY, szSearchPath.c_str()); int count = m_NPCPathFileList.GetCount(); CString str; for (int i = 0; i < count; i++) { m_NPCPathFileList.GetText(0, str); - - char szFileName[MAX_PATH]; - char szExt[_MAX_EXT]; - _splitpath((LPCTSTR)str, NULL, NULL, szFileName, szExt); - - //str.Format("%s%s",szFileName,szExt); - str.Format("%s", szFileName); + str = fs::path(str.GetString()).stem().c_str(); m_NPCPathFileList.InsertString(count, str); m_NPCPathFileList.DeleteString(0); } - SetCurrentDirectory(szOldPath); + fs::current_path(fsPrevPath); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/src/tool/N3ME/DlgLoadTileSet.cpp b/src/tool/N3ME/DlgLoadTileSet.cpp index a73bf685..db05bef7 100644 --- a/src/tool/N3ME/DlgLoadTileSet.cpp +++ b/src/tool/N3ME/DlgLoadTileSet.cpp @@ -2,8 +2,9 @@ // #include "StdAfx.h" -#include "n3me.h" +#include "N3ME.h" #include "DlgLoadTileSet.h" +#include "N3Base/N3Base.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -41,35 +42,23 @@ END_MESSAGE_MAP() BOOL CDlgLoadTileSet::OnInitDialog() { CDialog::OnInitDialog(); - // TODO: Add extra initialization here - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); + fs::path fsPrevPath = fs::current_path(); + fs::current_path(CN3Base::PathGet()); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - SetCurrentDirectory(szNewPath); - m_ListTileSet.Dir(DDL_READONLY, "dtex\\*.dtx"); + std::string szSearchPath = (fs::path("DTex") / "*.dtx").string(); + m_ListTileSet.Dir(DDL_READONLY, szSearchPath.c_str()); int count = m_ListTileSet.GetCount(); CString str; for (int i = 0; i < count; i++) { m_ListTileSet.GetText(0, str); - - char szFileName[MAX_PATH]; - _splitpath((LPCTSTR)str, NULL, NULL, szFileName, NULL); - - str.Format(szFileName); + str = fs::path(str.GetString()).stem().c_str(); m_ListTileSet.InsertString(count, str); m_ListTileSet.DeleteString(0); } - SetCurrentDirectory(szOldPath); + fs::current_path(fsPrevPath); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE @@ -78,11 +67,7 @@ BOOL CDlgLoadTileSet::OnInitDialog() { void CDlgLoadTileSet::OnSelchangeListLoadTileset() { int CurrSel = m_ListTileSet.GetCurSel(); m_ListTileSet.GetText(CurrSel, m_SelFileName); // TODO: Add your control notification handler code here - - char szFileName[MAX_PATH]; - _splitpath((LPCTSTR)m_SelFileName, NULL, NULL, szFileName, NULL); - - m_SelFileName.Format(szFileName); + m_SelFileName = fs::path(m_SelFileName.GetString()).stem().c_str(); } void CDlgLoadTileSet::OnDblclkListLoadTileset() { diff --git a/src/tool/N3ME/DlgMakeNPCPath.cpp b/src/tool/N3ME/DlgMakeNPCPath.cpp index 7a095721..33aff1a6 100644 --- a/src/tool/N3ME/DlgMakeNPCPath.cpp +++ b/src/tool/N3ME/DlgMakeNPCPath.cpp @@ -128,9 +128,8 @@ BOOL CDlgMakeNPCPath::OnInitDialog() { char szName[512] = ""; //NPC종류에 관한 정의... - char szNpcFileName[MAX_PATH]; - wsprintf(szNpcFileName, "npclist\\npclist.txt"); - FILE * stream = fopen(szNpcFileName, "r"); + fs::path fsNpcListFile = fs::path("npclist") / "npclist.txt"; + FILE * stream = _wfopen(fsNpcListFile.c_str(), L"r"); if (stream) { //int result; while (true) { @@ -161,8 +160,8 @@ BOOL CDlgMakeNPCPath::OnInitDialog() { } //NPC움직임에 관한 정의.. - wsprintf(szNpcFileName, "npclist\\npcacttypelist.txt"); - stream = fopen(szNpcFileName, "r"); + fs::path fsNpcActTypeListFile = fs::path("npclist") / "npcacttypelist.txt"; + stream = _wfopen(fsNpcActTypeListFile.c_str(), L"r"); if (stream) { //int result; while (true) { @@ -264,7 +263,7 @@ void CDlgMakeNPCPath::OnBtnLoadPathset() { m_pSelPath = NULL; if (dlg.DoModal() == IDOK) { - m_pRefNPCPathMgr->LoadFromFile((LPCTSTR)dlg.m_SelFileName); + m_pRefNPCPathMgr->LoadFromFile(dlg.m_SelFileName.GetString()); m_PathSetFileName = dlg.m_SelFileName + ".npi"; m_ListPathGroup.ResetContent(); @@ -291,7 +290,7 @@ void CDlgMakeNPCPath::OnBtnSavePathset() { if (dlg.DoModal() == IDOK) { m_PathSetFileName = dlg.m_NewFileName + ".npi"; - m_pRefNPCPathMgr->SaveToFile((LPCTSTR)dlg.m_NewFileName); + m_pRefNPCPathMgr->SaveToFile(dlg.m_NewFileName.GetString()); UpdateData(FALSE); } } @@ -301,8 +300,7 @@ void CDlgMakeNPCPath::OnBtnSaveServerPathset() { "서버 NPC Route파일(*.snr)|*.snr||"); if (dlg.DoModal() == IDOK) { - CString str = dlg.GetPathName(); - m_pRefNPCPathMgr->MakeServerDataFile((LPCTSTR)str); + m_pRefNPCPathMgr->MakeServerDataFile(dlg.GetPathName().GetString()); } } diff --git a/src/tool/N3ME/DlgPondProperty.cpp b/src/tool/N3ME/DlgPondProperty.cpp index 3b907aed..975d963e 100644 --- a/src/tool/N3ME/DlgPondProperty.cpp +++ b/src/tool/N3ME/DlgPondProperty.cpp @@ -219,7 +219,7 @@ void CDlgPondProperty::UpdateInfo() { if (pItem) { CN3Texture * pTex = pSelPond->TexGet(); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -343,15 +343,14 @@ BOOL CDlgPondProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) UpdateWaterLength(pSelPond); } } else if (pItem->m_propName == "Texture File") { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; // 상대경로로 바꾸기 - if (pSelPond->SetTextureName(tmp.m_szName.c_str()) == FALSE) { - CString strMsg; - strMsg.Format("Cannot get \"%s\"Texture, check file and directory", pItem->m_curValue); - MessageBox(strMsg); + fs::path fsFile = CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString()); + if (!pSelPond->SetTextureName(fsFile)) { + std::wstring szMsg = + std::format(L"Cannot get \"{:s}\" Texture, check file and directory", fsFile.c_str()); + MessageBoxW(NULL, szMsg.c_str(), L"", MB_OK); pItem->m_curValue = ""; } else { - pItem->m_curValue = tmp.m_szName.c_str(); + pItem->m_curValue = fsFile.c_str(); } return TRUE; } diff --git a/src/tool/N3ME/DlgRegenUser.cpp b/src/tool/N3ME/DlgRegenUser.cpp index 86eb6c87..c5cc36c1 100644 --- a/src/tool/N3ME/DlgRegenUser.cpp +++ b/src/tool/N3ME/DlgRegenUser.cpp @@ -55,7 +55,7 @@ void CDlgRegenUser::OnBtnLoadPathset() { m_PathName = dlg.GetPathName(); - m_pRefRegenUser->LoadFromFile((LPCTSTR)m_PathName); + m_pRefRegenUser->LoadFromFile(m_PathName.GetString()); UpdateData(FALSE); } @@ -77,11 +77,11 @@ void CDlgRegenUser::OnBtnSavePathset() { if (dlg.DoModal() == IDOK) { m_PathName = dlg.GetPathName(); - m_pRefRegenUser->SaveToFile((LPCTSTR)m_PathName); + m_pRefRegenUser->SaveToFile(m_PathName.GetString()); UpdateData(FALSE); } } else { - m_pRefRegenUser->SaveToFile((LPCTSTR)m_PathName); + m_pRefRegenUser->SaveToFile(m_PathName.GetString()); } } @@ -132,7 +132,7 @@ void CDlgRegenUser::OnBtnSaveAs() { if (dlg.DoModal() == IDOK) { m_PathName = dlg.GetPathName(); - m_pRefRegenUser->SaveToFile((LPCTSTR)m_PathName); + m_pRefRegenUser->SaveToFile(m_PathName.GetString()); } UpdateData(FALSE); @@ -140,4 +140,4 @@ void CDlgRegenUser::OnBtnSaveAs() { void CDlgRegenUser::ClearList() { m_LBRegion.ResetContent(); -} \ No newline at end of file +} diff --git a/src/tool/N3ME/DlgRiverProperty.cpp b/src/tool/N3ME/DlgRiverProperty.cpp index b61e3f09..1003d83b 100644 --- a/src/tool/N3ME/DlgRiverProperty.cpp +++ b/src/tool/N3ME/DlgRiverProperty.cpp @@ -143,7 +143,7 @@ void CDlgRiverProperty::UpdateInfo() { if (pItem) { CN3Texture * pTex = pSelRiver->TexGet(); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -171,7 +171,7 @@ void CDlgRiverProperty::UpdateInfo() { int iCount = pSelRiver->GetAnimTexCount(); CN3Texture * pTex = pSelRiver->AnimTexGet(iCount - 1); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -248,15 +248,12 @@ BOOL CDlgRiverProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult } else if (pItem->m_propName == "meter / v") { pSelRiver->SetMeterPerV((float)atof(pItem->m_curValue)); } else if (pItem->m_propName == "Texture File") { - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; // 상대경로로 바꾸기 - if (pSelRiver->SetTextureName(tmp.m_szName.c_str()) == FALSE) { - CString strMsg; - strMsg.Format("Cannot get \"%s\"Texture, check file and directory", pItem->m_curValue); - MessageBox(strMsg); + fs::path fsFile = CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString()); + if (!pSelRiver->SetTextureName(fsFile)) { + std::wstring szMsg = + std::format(L"Cannot get \"{:s}\" Texture, check file and directory", fsFile.c_str()); + MessageBoxW(NULL, szMsg.c_str(), L"", MB_OK); pItem->m_curValue = ""; - } else { - pItem->m_curValue = tmp.m_szName.c_str(); } } else if (pItem->m_propName == "Animation Texture FPS") { pSelRiver->SetAnimTexFPS((float)atof(pItem->m_curValue)); @@ -268,26 +265,18 @@ BOOL CDlgRiverProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult pSelRiver->SetMeterPerV2((float)atof(pItem->m_curValue)); } else if (pItem->m_propName == "Animation Texture File") { // 에니메이션 되는 텍스쳐 지정 (갯수는 파일 이름으로부터 알아낸다. 따라서 맨 마지막번호파일을 지정해야함) + fs::path fsFile = CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString()); - CN3Base tmp; - tmp.m_szName = pItem->m_curValue; // 상대경로로 바꾸기 - // 화일 이름 분리 - char szDir[_MAX_DIR]; - char szFName[_MAX_FNAME]; - char szExt[_MAX_EXT]; - _splitpath(tmp.m_szName.c_str(), NULL, szDir, szFName, szExt); - int iCount = atoi(szFName + lstrlen(szFName) - 2) + 1; // 파일 이름의 끝에 두자리를 숫자로 변환 - CString strFName = szDir; - strFName += szFName; - strFName = strFName.Left(strFName.GetLength() - 2); - - if (pSelRiver->SetAnimTextureName(strFName, szExt, iCount) == FALSE) { - CString strMsg; - strMsg.Format("Cannot get \"%s\"Texture, check file and directory", pItem->m_curValue); - MessageBox(strMsg); + // Convert last two digits from the string to an integer and increment + std::string szFileStem = fsFile.stem().string(); + int iTexCount = std::stoi(szFileStem.substr(szFileStem.size() - 2)) + 1; + + fs::path fsFileClean = fsFile.parent_path() / szFileStem.substr(0, szFileStem.size() - 2); + if (!pSelRiver->SetAnimTextureName(fsFileClean, fsFile.extension(), iTexCount)) { + std::wstring szMsg = + std::format(L"Cannot get \"{:s}\" Texture, check file and directory", fsFile.c_str()); + MessageBoxW(NULL, szMsg.c_str(), L"", MB_OK); pItem->m_curValue = ""; - } else { - pItem->m_curValue = tmp.m_szName.c_str(); } } } diff --git a/src/tool/N3ME/DlgSaveDivision.cpp b/src/tool/N3ME/DlgSaveDivision.cpp index 6c1d2575..2b173645 100644 --- a/src/tool/N3ME/DlgSaveDivision.cpp +++ b/src/tool/N3ME/DlgSaveDivision.cpp @@ -226,15 +226,15 @@ void CDlgSaveDivision::RenderTexnRegion() { } void CDlgSaveDivision::SetTexView() { - CString strTmpFileName("c:\\MiniMap.bmp"); - m_pTerrain->GenerateMiniMap((LPCTSTR)strTmpFileName, TEX_VIEW_SIZE); + fs::path fsColorMapTmpFile = fs::temp_directory_path() / "N3ME_MiniMap.bmp"; + m_pTerrain->GenerateMiniMap(fsColorMapTmpFile, TEX_VIEW_SIZE); if (m_pMiniMap) { m_pMapMng->m_pMainFrm->m_pEng->s_MngTex.Delete(&m_pMiniMap); } - m_pMiniMap = m_pMapMng->m_pMainFrm->m_pEng->s_MngTex.Get((LPCTSTR)strTmpFileName); - DeleteFile((LPCTSTR)strTmpFileName); + m_pMiniMap = m_pMapMng->m_pMainFrm->m_pEng->s_MngTex.Get(fsColorMapTmpFile); + fs::remove(fsColorMapTmpFile); } void CDlgSaveDivision::OnOK() { diff --git a/src/tool/N3ME/DlgSaveEvt.cpp b/src/tool/N3ME/DlgSaveEvt.cpp index 5ccfc29f..eeb56b1c 100644 --- a/src/tool/N3ME/DlgSaveEvt.cpp +++ b/src/tool/N3ME/DlgSaveEvt.cpp @@ -2,8 +2,9 @@ // #include "StdAfx.h" -#include "n3me.h" +#include "N3ME.h" #include "DlgSaveEvt.h" +#include "N3Base/N3Base.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -53,36 +54,23 @@ void CDlgSaveEvt::OnDblclkListSavedEvtFile() { BOOL CDlgSaveEvt::OnInitDialog() { CDialog::OnInitDialog(); - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); + fs::path fsPrevPath = fs::current_path(); + fs::current_path(CN3Base::PathGet()); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - SetCurrentDirectory(szNewPath); - m_SavedFileList.Dir(DDL_READONLY, "event\\*.evt"); + std::string szSearchPath = (fs::path("event") / "*.evt").string(); + m_SavedFileList.Dir(DDL_READONLY, szSearchPath.c_str()); int count = m_SavedFileList.GetCount(); CString str; for (int i = 0; i < count; i++) { m_SavedFileList.GetText(0, str); - - char szFileName[_MAX_PATH]; - char szExt[_MAX_EXT]; - _splitpath((LPCTSTR)str, NULL, NULL, szFileName, szExt); - - //str.Format("%s%s",szFileName,szExt); - str.Format("%s", szFileName); + str = fs::path(str.GetString()).stem().c_str(); m_SavedFileList.InsertString(count, str); m_SavedFileList.DeleteString(0); } - SetCurrentDirectory(szOldPath); + fs::current_path(fsPrevPath); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/src/tool/N3ME/DlgSaveNPCPath.cpp b/src/tool/N3ME/DlgSaveNPCPath.cpp index 2960d3b9..a26bad76 100644 --- a/src/tool/N3ME/DlgSaveNPCPath.cpp +++ b/src/tool/N3ME/DlgSaveNPCPath.cpp @@ -2,8 +2,9 @@ // #include "StdAfx.h" -#include "n3me.h" +#include "N3ME.h" #include "DlgSaveNPCPath.h" +#include "N3Base/N3Base.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -52,36 +53,23 @@ void CDlgSaveNPCPath::OnDblclkListNpcpathfilename() { BOOL CDlgSaveNPCPath::OnInitDialog() { CDialog::OnInitDialog(); - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); + fs::path fsPrevPath = fs::current_path(); + fs::current_path(CN3Base::PathGet()); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - SetCurrentDirectory(szNewPath); - m_SavedFileList.Dir(DDL_READONLY, "npcpath\\*.npi"); + std::string szSearchPath = (fs::path("npcpath") / "*.npi").string(); + m_SavedFileList.Dir(DDL_READONLY, szSearchPath.c_str()); int count = m_SavedFileList.GetCount(); CString str; for (int i = 0; i < count; i++) { m_SavedFileList.GetText(0, str); - - char szFileName[_MAX_PATH]; - char szExt[_MAX_EXT]; - _splitpath((LPCTSTR)str, NULL, NULL, szFileName, szExt); - - //str.Format("%s%s",szFileName,szExt); - str.Format("%s", szFileName); + str = fs::path(str.GetString()).stem().c_str(); m_SavedFileList.InsertString(count, str); m_SavedFileList.DeleteString(0); } - SetCurrentDirectory(szOldPath); + fs::current_path(fsPrevPath); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/src/tool/N3ME/DlgSaveNewTileSet.cpp b/src/tool/N3ME/DlgSaveNewTileSet.cpp index 2a047d93..24df9b52 100644 --- a/src/tool/N3ME/DlgSaveNewTileSet.cpp +++ b/src/tool/N3ME/DlgSaveNewTileSet.cpp @@ -2,8 +2,9 @@ // #include "StdAfx.h" -#include "n3me.h" +#include "N3ME.h" #include "DlgSaveNewTileSet.h" +#include "N3Base/N3Base.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -40,35 +41,23 @@ END_MESSAGE_MAP() BOOL CDlgSaveNewTileSet::OnInitDialog() { CDialog::OnInitDialog(); - // TODO: Add extra initialization here - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); + fs::path fsPrevPath = fs::current_path(); + fs::current_path(CN3Base::PathGet()); - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR]; - char szModuleFilePath[_MAX_PATH]; - GetModuleFileName(NULL, szModuleFilePath, _MAX_PATH); - - char szNewPath[_MAX_PATH]; - _splitpath(szModuleFilePath, szDrive, szDir, NULL, NULL); - _makepath(szNewPath, szDrive, szDir, NULL, NULL); - SetCurrentDirectory(szNewPath); - m_ListTileSet.Dir(DDL_READONLY, "dtex\\*.dtx"); + std::string szSearchPath = (fs::path("DTex") / "*.dtx").string(); + m_ListTileSet.Dir(DDL_READONLY, szSearchPath.c_str()); int count = m_ListTileSet.GetCount(); CString str; for (int i = 0; i < count; i++) { m_ListTileSet.GetText(0, str); - - char szFileName[MAX_PATH]; - _splitpath((LPCTSTR)str, NULL, NULL, szFileName, NULL); - - str.Format(szFileName); + str = fs::path(str.GetString()).stem().c_str(); m_ListTileSet.InsertString(count, str); m_ListTileSet.DeleteString(0); } - SetCurrentDirectory(szOldPath); + fs::current_path(fsPrevPath); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/src/tool/N3ME/DlgSetDTex.cpp b/src/tool/N3ME/DlgSetDTex.cpp index 578a75ac..f942fc33 100644 --- a/src/tool/N3ME/DlgSetDTex.cpp +++ b/src/tool/N3ME/DlgSetDTex.cpp @@ -90,7 +90,7 @@ BOOL CDlgSetDTex::OnInitDialog() { for (int i = 0; i < iSize; i++) { pDTex = (*DTexIt); if (pDTex) { - m_FileList.InsertString(i, pDTex->m_pTex->FileName().c_str()); + m_FileList.InsertString(i, pDTex->m_pTex->FilePath().string().c_str()); m_FileList.SetItemDataPtr(i, pDTex); } DTexIt++; @@ -413,8 +413,9 @@ void CDlgSetDTex::OnBtnSave() { return; } - pDTexGroupMng->SaveToFile(m_TileSetName); - pDTexMng->SaveToFile(m_TileSetName); + fs::path fsFileName = m_TileSetName.GetString(); + pDTexGroupMng->SaveToFile(fsFileName); + pDTexMng->SaveToFile(fsFileName); pFrm->m_DTexInfoFileName = m_TileSetName; } @@ -517,8 +518,8 @@ void CDlgSetDTex::OnBtnAdddtex() { dlg.m_TexName.MakeLower(); - if (pDTexMng->AddDTex(dlg.m_TexName)) { - CDTex * pDTex = pDTexMng->GetDTexByName(dlg.m_TexName); + if (pDTexMng->AddDTex(dlg.m_TexName.GetString())) { + CDTex * pDTex = pDTexMng->GetDTexByName(dlg.m_TexName.GetString()); if (pDTex) { int idx = m_FileList.GetCount(); @@ -640,12 +641,13 @@ void CDlgSetDTex::OnBtnLoadTileset() { pFrm->m_DTexInfoFileName = dlg.m_SelFileName; m_TileSetName = dlg.m_SelFileName; + fs::path fsFileName = m_TileSetName.GetString(); CDTexMng * pDTexMng = pFrm->GetDTexMng(); CDTexGroupMng * pDTexGroupMng = pFrm->GetDTexGroupMng(); - pDTexGroupMng->LoadFromFile(m_TileSetName); - pDTexMng->LoadFromFile(m_TileSetName); + pDTexGroupMng->LoadFromFile(fsFileName); + pDTexMng->LoadFromFile(fsFileName); //reset dialog box... m_FileList.ResetContent(); @@ -656,7 +658,7 @@ void CDlgSetDTex::OnBtnLoadTileset() { for (int i = 0; i < iSize; i++) { pDTex = (*DTexIt); if (pDTex) { - m_FileList.InsertString(i, pDTex->m_pTex->FileName().c_str()); + m_FileList.InsertString(i, pDTex->m_pTex->FilePath().string().c_str()); m_FileList.SetItemDataPtr(i, pDTex); } DTexIt++; diff --git a/src/tool/N3ME/DlgShapeList.cpp b/src/tool/N3ME/DlgShapeList.cpp index 7c66c5ad..66fef98e 100644 --- a/src/tool/N3ME/DlgShapeList.cpp +++ b/src/tool/N3ME/DlgShapeList.cpp @@ -62,9 +62,7 @@ void CDlgShapeList::UpdateTree(CN3Scene * pScene) { for (int i = 0; i < nSC; i++) { CN3Shape * pShape = m_pSceneRef->ShapeGet(i); if (pShape) { - char szFName[MAX_PATH]; - _splitpath(pShape->FileName().c_str(), NULL, NULL, szFName, NULL); - m_ListShape.InsertString(i, szFName); + m_ListShape.InsertString(i, pShape->FilePath().stem().string().c_str()); m_ListShape.SetItemDataPtr(i, pShape); } } @@ -158,15 +156,11 @@ void CDlgShapeList::OnBtnSort() { int cnt = m_ListShape.GetCount(); for (int i = 0; i < cnt; i++) { - char buff[MAX_PATH]; - std::string str; - CN3Shape * pShape; + CN3Shape * pShape = (CN3Shape *)m_ListShape.GetItemDataPtr(i); - pShape = (CN3Shape *)m_ListShape.GetItemDataPtr(i); - m_ListShape.GetText(i, buff); - str = buff; - - Map.insert(SMValue(str, pShape)); + CString szShapeFileName; + m_ListShape.GetText(i, szShapeFileName); + Map.insert(SMValue(szShapeFileName.GetString(), pShape)); } m_ListShape.ResetContent(); diff --git a/src/tool/N3ME/DlgUnusedFiles.cpp b/src/tool/N3ME/DlgUnusedFiles.cpp index daaf51cf..2dee28fc 100644 --- a/src/tool/N3ME/DlgUnusedFiles.cpp +++ b/src/tool/N3ME/DlgUnusedFiles.cpp @@ -41,25 +41,22 @@ END_MESSAGE_MAP() // CDlgUnusedFiles message handlers void CDlgUnusedFiles::OnDelete() { - int iSelFNC = m_ListFiles.GetSelCount(); - if (iSelFNC <= 0) { + int iSC = m_ListFiles.GetSelCount(); + if (iSC <= 0) { return; } - int iYesNo = MessageBox("지우시겠습니까?", "확인", MB_YESNO); - - if (IDYES != iYesNo) { + if (IDYES != MessageBox("Would you like to erase it?", "Check", MB_YESNO)) { return; } - std::vector sel; - sel.reserve(iSelFNC); - m_ListFiles.GetSelItems(iSelFNC, &(sel[0])); + std::vector vSels(iSC); + m_ListFiles.GetSelItems(iSC, vSels.data()); - CString szFN; - for (int i = 0; i < iSelFNC; i++) { - m_ListFiles.GetText(sel[i], szFN); - ::DeleteFile(szFN); + for (const auto & iSelIndex : vSels) { + CString szFile; + m_ListFiles.GetText(iSelIndex, szFile); + fs::remove(szFile.GetString()); } CDialog::OnOK(); @@ -74,18 +71,15 @@ BOOL CDlgUnusedFiles::OnInitDialog() { this->UpdateAll(); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE + return TRUE; } void CDlgUnusedFiles::UpdateAll() { - int iFNC = m_FileNames.GetSize(); - for (int i = 0; i < iFNC; i++) { - m_ListFiles.AddString(m_FileNames[i]); + for (const auto & fsFile : m_vFiles) { + m_ListFiles.AddString(CString(fsFile.c_str())); } - iFNC = m_InvalidFileNames.GetSize(); - for (int i = 0; i < iFNC; i++) { - m_ListInvalidObjects.AddString(m_InvalidFileNames[i]); + for (const auto & szError : m_vErroredFiles) { + m_ListInvalidObjects.AddString(CString(szError.c_str())); } } diff --git a/src/tool/N3ME/DlgUnusedFiles.h b/src/tool/N3ME/DlgUnusedFiles.h index 74c71816..0b4593a5 100644 --- a/src/tool/N3ME/DlgUnusedFiles.h +++ b/src/tool/N3ME/DlgUnusedFiles.h @@ -8,8 +8,8 @@ class CDlgUnusedFiles : public CDialog { public: - CStringArray m_FileNames; - CStringArray m_InvalidFileNames; + std::vector m_vFiles; + std::vector m_vErroredFiles; public: void UpdateAll(); diff --git a/src/tool/N3ME/EventMgr.cpp b/src/tool/N3ME/EventMgr.cpp index ecbc8e89..c523a71e 100644 --- a/src/tool/N3ME/EventMgr.cpp +++ b/src/tool/N3ME/EventMgr.cpp @@ -268,30 +268,24 @@ void CEventMgr::SetActive(bool active) { } } -void CEventMgr::LoadFromFile(const char * RealFileName) { - char szNPCPathFileName[_MAX_PATH]; - wsprintf(szNPCPathFileName, "%sevent\\%s.evt", CN3Base::PathGet().c_str(), (LPCTSTR)RealFileName); - - //DWORD dwRWC; - HANDLE hFile = CreateFile(szNPCPathFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +void CEventMgr::LoadFromFile(const fs::path & fsFileName) { + fs::path fsFile = (CN3Base::PathGet() / "event" / fsFileName).replace_extension(".evt"); + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); Load(hFile); CloseHandle(hFile); } -void CEventMgr::SaveToFile(const char * RealFileName) { - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); - SetCurrentDirectory(CN3Base::PathGet().c_str()); - - CreateDirectory("event", NULL); // 경로 만들고.. - char szNPCPathFileName[_MAX_PATH]; - wsprintf(szNPCPathFileName, "%sevent\\%s.evt", CN3Base::PathGet().c_str(), (LPCTSTR)RealFileName); +void CEventMgr::SaveToFile(const fs::path & fsFileName) { + fs::path fsCurDirPrev = fs::current_path(); + fs::current_path(CN3Base::PathGet()); + fs::path fsDir("event"); + fs::create_directory(fsDir); - //DWORD dwRWC; - HANDLE hFile = CreateFile(szNPCPathFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fs::path fsFile = (CN3Base::PathGet() / fsDir / fsFileName).replace_extension(".evt"); + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); Save(hFile); CloseHandle(hFile); - SetCurrentDirectory(szOldPath); + fs::current_path(fsCurDirPrev); } bool CEventMgr::Load(HANDLE hFile) { @@ -357,9 +351,9 @@ void CEventMgr::MakeEventArray() { } } -void CEventMgr::SaveInfoTextFile(char * szEvent) { +void CEventMgr::SaveInfoTextFile(const fs::path & fsFile) { // text 파일 버전... - FILE * stream = fopen(szEvent, "r"); + FILE * stream = _wfopen(fsFile.c_str(), L"r"); //if(!stream) return; std::list TmpList; @@ -397,7 +391,7 @@ void CEventMgr::SaveInfoTextFile(char * szEvent) { } } - stream = fopen(szEvent, "w"); + stream = _wfopen(fsFile.c_str(), L"w"); if (!stream) { return; } @@ -471,8 +465,8 @@ void CEventMgr::SaveInfoTextFile(char* szEvent) } */ -bool CEventMgr::MakeGameFile(char * szEventName, int iSize) { - HANDLE hGevFile = CreateFile(szEventName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +bool CEventMgr::MakeGameFile(const fs::path & fsFile, int iSize) { + HANDLE hGevFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hGevFile) { return false; } diff --git a/src/tool/N3ME/EventMgr.h b/src/tool/N3ME/EventMgr.h index 25b5456e..0213b91e 100644 --- a/src/tool/N3ME/EventMgr.h +++ b/src/tool/N3ME/EventMgr.h @@ -23,10 +23,10 @@ class CEventMgr : public CN3Base { public: bool MakeGameFile(HANDLE hFile, int iSize); - bool MakeGameFile(char * szEventName, int iSize); - void LoadFromFile(const char * RealFileName); - void SaveToFile(const char * RealFileName); - void SaveInfoTextFile(char * szEvent); + bool MakeGameFile(const fs::path & fsFile, int iSize); + void LoadFromFile(const fs::path & fsFileName); + void SaveToFile(const fs::path & fsFileName); + void SaveInfoTextFile(const fs::path & fsFile); void MakeEventArray(); void DelEvent(CEventCell * pEvent); void SetCurrEvent(CEventCell * pEvent); diff --git a/src/tool/N3ME/LightObjMgr.cpp b/src/tool/N3ME/LightObjMgr.cpp index cde9cbc6..05dcbf4f 100644 --- a/src/tool/N3ME/LightObjMgr.cpp +++ b/src/tool/N3ME/LightObjMgr.cpp @@ -441,13 +441,13 @@ void CLightObjMgr::ChangeSelLights() { } } -bool CLightObjMgr::MakeGameFile(char * szFN) { +bool CLightObjMgr::MakeGameFile(const fs::path & fsFile) { int cnt = m_ListObj.size(); if (cnt <= 0) { return true; } - HANDLE hFile = CreateFile(szFN, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD dwRWC; WriteFile(hFile, &m_iVersion, sizeof(int), &dwRWC, NULL); @@ -462,4 +462,4 @@ bool CLightObjMgr::MakeGameFile(char * szFN) { } CloseHandle(hFile); return true; -} \ No newline at end of file +} diff --git a/src/tool/N3ME/LightObjMgr.h b/src/tool/N3ME/LightObjMgr.h index 4cdc2e17..a8374296 100644 --- a/src/tool/N3ME/LightObjMgr.h +++ b/src/tool/N3ME/LightObjMgr.h @@ -60,7 +60,7 @@ class CLightObjMgr : public CN3BaseFileAccess { void UpdateWall(); */ - bool MakeGameFile(char * szFN); + bool MakeGameFile(const fs::path & fsFile); void ChangeSelLights(); void RefreshCurrLights(float fRange, float fAtten, D3DCOLORVALUE crLgt); void DeleteLO(LPLIGHTOBJ pLO); diff --git a/src/tool/N3ME/LyTerrain.cpp b/src/tool/N3ME/LyTerrain.cpp index dce9620b..7af257b8 100644 --- a/src/tool/N3ME/LyTerrain.cpp +++ b/src/tool/N3ME/LyTerrain.cpp @@ -472,10 +472,10 @@ CN3Texture * CLyTerrain::GetTileTex(int id) { // // // -bool CLyTerrain::SaveToFilePartition(const char * lpszPath, float psx, float psz, float width) { - HANDLE hFile = CreateFile(lpszPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +bool CLyTerrain::SaveToFilePartition(const fs::path & fsFile, float psx, float psz, float width) { + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - MessageBox(::GetActiveWindow(), lpszPath, "Fail to save trn file!", MB_OK); + MessageBoxW(::GetActiveWindow(), fsFile.c_str(), L"Fail to save trn file!", MB_OK); return false; } @@ -603,12 +603,8 @@ bool CLyTerrain::SaveToFilePartition(const char * lpszPath, float psx, float psz ///////////////////////////////////////////////////////////////////////////////////////////////////// // 컬러맵 쓰기. - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszPath, szDrive, szDir, szFName, szExt); - char szNewFName[_MAX_PATH] = ""; - _makepath(szNewFName, szDrive, szDir, szFName, "tcm"); // 파일 이름과 동일한 이름으로 컬러맵 저장.. - - HANDLE hCMFile = CreateFile(szNewFName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fs::path fsTcmFile = fs::path(fsFile).replace_extension(".tcm"); + HANDLE hCMFile = CreateFileW(fsTcmFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); int NumColorMap = (((HeightMapSize - 1) * m_iColorMapPixelPerUnitDistance) / m_iColorMapTexSize) + 1; if (((HeightMapSize - 1) * m_iColorMapPixelPerUnitDistance) % m_iColorMapTexSize == 0) { @@ -633,20 +629,20 @@ bool CLyTerrain::SaveToFilePartition(const char * lpszPath, float psx, float psz // 다시 읽어온 다음에... // 다시 잘라서 저장한 다음에... // 잘라 저장한 bmp를 Import하는 것처럼 읽어서 셋팅.. - CString strTmpColorMap("c:\\MiniMap.bmp"); - ColorMapExport((LPCTSTR)strTmpColorMap); + fs::path fsColorMapTmpFile = fs::temp_directory_path() / "N3ME_MiniMap.bmp"; + ColorMapExport(fsColorMapTmpFile); CBitMapFile BMF; - if (BMF.LoadFromFile((LPCTSTR)strTmpColorMap)) { + if (BMF.LoadFromFile(fsColorMapTmpFile)) { RECT rc; rc.left = sx * m_iColorMapPixelPerUnitDistance; rc.right = rc.left + (m_iColorMapTexSize * NumColorMap); rc.bottom = (m_iHeightMapSize - 1 - sz) * m_iColorMapPixelPerUnitDistance; rc.top = rc.bottom - (m_iColorMapTexSize * NumColorMap); - BMF.SaveRectToFile((LPCTSTR)strTmpColorMap, rc); + BMF.SaveRectToFile(fsColorMapTmpFile, rc); - if (BMF.LoadFromFile((LPCTSTR)strTmpColorMap)) { + if (BMF.LoadFromFile(fsColorMapTmpFile)) { for (x = 0; x < NumColorMap; x++) { for (z = 0; z < NumColorMap; z++) { ProgressBar.StepIt(); @@ -655,11 +651,11 @@ bool CLyTerrain::SaveToFilePartition(const char * lpszPath, float psx, float psz rc.right = rc.left + m_iColorMapTexSize; rc.bottom = rc.top + m_iColorMapTexSize; - BMF.SaveRectToFile((LPCTSTR)strTmpColorMap, rc); + BMF.SaveRectToFile(fsColorMapTmpFile, rc); - pColorTexture[x][z].LoadFromFile((LPCTSTR)strTmpColorMap); + pColorTexture[x][z].LoadFromFile(fsColorMapTmpFile); pColorTexture[x][z].Convert(D3DFMT_X8R8G8B8, m_iColorMapTexSize, m_iColorMapTexSize); - DeleteFile((LPCTSTR)strTmpColorMap); + fs::remove(fsColorMapTmpFile); } } } @@ -683,10 +679,10 @@ bool CLyTerrain::SaveToFilePartition(const char * lpszPath, float psx, float psz // Save() // 맵에디터에서 쓰는 파일 타입으로 저장하기.. // -bool CLyTerrain::SaveToFile(const char * lpszPath) { - HANDLE hFile = CreateFile(lpszPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +bool CLyTerrain::SaveToFile(const fs::path & fsFile) { + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - MessageBox(::GetActiveWindow(), lpszPath, "Fail to save trn file!", MB_OK); + MessageBoxW(::GetActiveWindow(), fsFile.c_str(), L"Fail to save trn file!", MB_OK); return false; } @@ -806,12 +802,8 @@ bool CLyTerrain::SaveToFile(const char * lpszPath) { ///////////////////////////////////////////////////////////////////////////////////////////////////// // 컬러맵 쓰기. - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszPath, szDrive, szDir, szFName, szExt); - char szNewFName[_MAX_PATH] = ""; - _makepath(szNewFName, szDrive, szDir, szFName, "tcm"); // 파일 이름과 동일한 이름으로 컬러맵 저장.. - - HANDLE hCMFile = CreateFile(szNewFName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fs::path fsTcmFile = fs::path(fsFile).replace_extension(".tcm"); + HANDLE hCMFile = CreateFileW(fsTcmFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); ProgressBar.Create("Save color map..", 50, m_iNumColorMap * m_iNumColorMap); for (x = 0; x < m_iNumColorMap; x++) { @@ -822,25 +814,20 @@ bool CLyTerrain::SaveToFile(const char * lpszPath) { } CloseHandle(hCMFile); - /* old version.... - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszPath, szDrive, szDir, szFName, szExt); - char szNewFName[_MAX_PATH] = "", szAdd[_MAX_PATH] = ""; - + /* + // old version.... ProgressBar.Create("Save color map..", 50, m_iNumColorMap * m_iNumColorMap); - for(x=0;xSaveToFile("c:\\templightmap.bmp"); + fs::path fsLightMapBmpTmpFile = fs::temp_directory_path() / "N3ME_templightmap.bmp"; + pBMP->SaveToFile(fsLightMapBmpTmpFile); int SmallSize = LIGHTMAP_TEX_SIZE - 2; HANDLE hSrcBitmap = - LoadImage(0, "c:\\templightmap.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE); + LoadImageW(0, fsLightMapBmpTmpFile.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE); __ASSERT(hSrcBitmap, ""); HDC hSmallDC = CreateCompatibleDC(NULL); @@ -1106,7 +1084,7 @@ void CLyTerrain::ConvertLightMapToolDataV2toV3() { SelectObject(hBMDC, hOldBM); SelectObject(hSmallDC, hOldBM2); - DeleteFile("c:\\templightmap.bmp"); // 임시 파일을 지워준다.. + fs::remove(fsLightMapBmpTmpFile); } } @@ -1444,12 +1422,11 @@ void CLyTerrain::SaveGameData(HANDLE hFile) { pTexture = GetTileTex(TexIdx); if (pTexture) { - // 경로를 빼고 파일이름과 확장자만 저장해준다. - char szTileFN[MAX_PATH]; - char szFName[_MAX_FNAME]{}; - _splitpath(pTexture->FileName().c_str(), NULL, NULL, szFName, NULL); - wsprintf(szTileFN, "dtex\\%s_%d.gtt", szFName, YIdx); - WriteFile(hFile, szTileFN, MAX_PATH, &dwRWC, NULL); + fs::path fsGttFile = + (("DTex" / pTexture->FilePath().stem()) + std::format("_{:d}.gtt", YIdx)).normalize('/', '\\'); + char szGttFile[260]{}; + fsGttFile.string().copy(szGttFile, sizeof(szGttFile) - 1); + WriteFile(hFile, szGttFile, sizeof(szGttFile), &dwRWC, NULL); } TLIt++; } @@ -1516,7 +1493,7 @@ void CLyTerrain::SaveGameData(HANDLE hFile) { } } -void CLyTerrain::MakeGameLightMap(char * szFullPathName) { +void CLyTerrain::MakeGameLightMap(const fs::path & fsFile) { DetectRealLightMap(0, 0, m_iHeightMapSize); int PatchCount = (m_iHeightMapSize - 1) / PATCH_TILE_SIZE; //PATCH_TILE_SIZE = 8 @@ -1554,10 +1531,9 @@ void CLyTerrain::MakeGameLightMap(char * szFullPathName) { } //임시파일 만들고 저장함 해보고, 용량 알아낸다음....저장할까? - - char szTmpName[_MAX_PATH]; - sprintf(szTmpName, "c:\\temp_lightmap.binn"); - HANDLE hFile = CreateFile(szTmpName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fs::path fsLightTmpFile = fs::temp_directory_path() / "N3ME_lightmap.bin"; + HANDLE hFile = + CreateFileW(fsLightTmpFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); WriteFile(hFile, &(TexCount), sizeof(int), &dwRWC, NULL); // LightMap의 갯수 기록.. @@ -1581,11 +1557,11 @@ void CLyTerrain::MakeGameLightMap(char * szFullPathName) { Size += dwSize; } CloseHandle(hFile); - DeleteFile(szTmpName); + fs::remove(fsLightTmpFile); } } - HANDLE hFile = CreateFile(szFullPathName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); int version = 0; WriteFile(hFile, &(version), sizeof(int), &dwRWC, NULL); @@ -1636,8 +1612,8 @@ void CLyTerrain::MakeGameLightMap(char * szFullPathName) { delete[] PatchInfo; } -void CLyTerrain::MakeGameColorMap(char * szFullPathName) { - HANDLE hCMFile = CreateFile(szFullPathName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +void CLyTerrain::MakeGameColorMap(const fs::path & fsFile) { + HANDLE hCMFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); CProgressBar ProgressBar; // 진행 상황.. ProgressBar.Create("Save game color map..", 50, m_iNumColorMap * m_iNumColorMap); @@ -1648,9 +1624,8 @@ void CLyTerrain::MakeGameColorMap(char * szFullPathName) { //* CN3Texture TexTmp; TexTmp.Create(m_iColorMapTexSize, m_iColorMapTexSize, D3DFMT_A1R5G5B5, TRUE); - int x, z; - for (x = 0; x < m_iNumColorMap; x++) { - for (z = 0; z < m_iNumColorMap; z++) { + for (int x = 0; x < m_iNumColorMap; x++) { + for (int z = 0; z < m_iNumColorMap; z++) { ProgressBar.StepIt(); LPDIRECT3DSURFACE9 lpSurfSrc = NULL; @@ -1673,46 +1648,46 @@ void CLyTerrain::MakeGameColorMap(char * szFullPathName) { // // New...(축소시키는방법..) /* - int x,z; CBitMapFile BMP[3][3]; - char buff[80]; - unsigned char* pBMPImg; - for(x=0;x<3;x++) - { - for(z=0;z<3;z++) BMP[x][z].Create(m_iColorMapTexSize,m_iColorMapTexSize); + for (int x = 0; x < 3; x++) { + for (int z = 0; z < 3; z++) { + BMP[x][z].Create(m_iColorMapTexSize, m_iColorMapTexSize); + } } - CN3Texture TexTmp; TexTmp.Create(m_iColorMapTexSize, m_iColorMapTexSize, D3DFMT_X8R8G8B8, TRUE); - + D3DLOCKED_RECT d3dlrTex; - DWORD* pTexBits; - for(x=0;x=0 && (z+az-1)>=0 && (x+ax-1)= 0 && (z + az - 1) >= 0 && (x + ax - 1) < m_iNumColorMap && + (z + az - 1) < m_iNumColorMap) { + m_pColorTexture[x + ax - 1][z + az - 1].SaveToBitmapFile(fsTmpFile); + } else { + BMP[ax][az].SaveToFile(fsTmpFile); + } + } //for(int az=0;az<3;az++) + } //for(int ax=0;ax<3;ax++) //픽셀 재배열... int SmallSize = m_iColorMapTexSize - 2; TexTmp.Convert(D3DFMT_X8R8G8B8, m_iColorMapTexSize, m_iColorMapTexSize); TexTmp.Get()->LockRect(0, &d3dlrTex, 0, 0); - pTexBits = (DWORD*)d3dlrTex.pBits; - for(ax=0;ax<3;ax++) - { - for(az=0;az<3;az++) - { - sprintf(buff,"c:\\tmpcolormap%04d%04d.bmp", ax, az); - HANDLE hSrcBitmap = LoadImage(0, buff, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE); + pTexBits = (DWORD *)d3dlrTex.pBits; + for (ax = 0; ax < 3; ax++) { + for (az = 0; az < 3; az++) { + fs::path fsTmpFile = fs::temp_directory_path(); + fsTmpFile /= std::format("N3ME_tmpcolormap{:04d}{:04d}.bmp", ax, az); + + HANDLE hSrcBitmap = + LoadImageW(0, fsTmpFile.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE); __ASSERT(hSrcBitmap, ""); HDC hSmallDC = CreateCompatibleDC(NULL); @@ -1721,71 +1696,69 @@ void CLyTerrain::MakeGameColorMap(char * szFullPathName) { HBITMAP hOldBM = (HBITMAP)SelectObject(hBMDC, (HBITMAP)hSrcBitmap); // Prepare to create a bitmap - DWORD* pBitmapBits; + DWORD * pBitmapBits; BITMAPINFO bmi; - ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) ); - bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi.bmiHeader.biWidth = (int)SmallSize; - bmi.bmiHeader.biHeight = -(int)SmallSize; - bmi.bmiHeader.biPlanes = 1; + ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER)); + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = (int)SmallSize; + bmi.bmiHeader.biHeight = -(int)SmallSize; + bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biCompression = BI_RGB; - bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biBitCount = 32; - HBITMAP hbmBitmap = CreateDIBSection( hSmallDC, &bmi, DIB_RGB_COLORS, (VOID**)&pBitmapBits, NULL, 0 ); - HBITMAP hOldBM2 = (HBITMAP) SelectObject( hSmallDC, hbmBitmap ); + HBITMAP hbmBitmap = + CreateDIBSection(hSmallDC, &bmi, DIB_RGB_COLORS, (VOID **)&pBitmapBits, NULL, 0); + HBITMAP hOldBM2 = (HBITMAP)SelectObject(hSmallDC, hbmBitmap); SetStretchBltMode(hSmallDC, HALFTONE); - StretchBlt(hSmallDC, 0,0, SmallSize, SmallSize, hBMDC, 0,0, m_iColorMapTexSize, m_iColorMapTexSize, SRCCOPY); - - if(ax==0 && az==0) - pTexBits[(m_iColorMapTexSize-1)*m_iColorMapTexSize] = pBitmapBits[SmallSize-1]; - else if(ax==1 && az==0) - memcpy(&(pTexBits[(m_iColorMapTexSize-1)*m_iColorMapTexSize + 1]), &(pBitmapBits[0]), sizeof(DWORD)*SmallSize); - else if(ax==2 && az==0) - pTexBits[(m_iColorMapTexSize*m_iColorMapTexSize)-1] = pBitmapBits[0]; - else if(ax==0 && az==1) - { - for(int i=0;iUnlockRect(0); - sprintf(buff,"tmpb%04d%04d.bmp", x,z); - TexTmp.SaveToBitmapFile(buff); - + fs::path fsTmpFile = fs::temp_directory_path(); + fsTmpFile /= std::format("N3ME_tmpb{:04d}{:04d}.bmp", ax, az); + TexTmp.SaveToBitmapFile(fsTmpFile); TexTmp.Convert(D3DFMT_A1R5G5B5, m_iColorMapTexSize, m_iColorMapTexSize); TexTmp.Save(hCMFile); - - } //for(z=0;z=0;z--) - { - ProgressBar.StepIt(); + for (int x = 0; x < m_iNumColorMap; x++) { + for (int z = m_iNumColorMap - 1; z >= 0; z--) { + ProgressBar.StepIt(); TexTmp.Create(TexSize, TexSize, D3DFMT_X8R8G8B8, TRUE); - TexTmp.Get()->LockRect( 0, &d3dlrTarget, 0, 0 ); + TexTmp.Get()->LockRect(0, &d3dlrTarget, 0, 0); pImgTarget = (LPDWORD)d3dlrTarget.pBits; - sx = x * (TexSize-2) - 1; - sz = z * (TexSize-2) - 1; + sx = x * (TexSize - 2) - 1; + sz = z * (TexSize - 2) - 1; DestWidth = TexSize; DestHeight = TexSize; - - if(x==0) - { + + if (x == 0) { sx = 0; DestWidth = TexSize - 1; pImgTarget++; + } else if (x == m_iNumColorMap - 1) { + DestWidth = TexSize - 1; } - else if(x==m_iNumColorMap-1) - { - DestWidth = TexSize - 1; - } - - if(z==0) - { + + if (z == 0) { sz = 0; DestHeight = TexSize - 1; pImgTarget += TexSize; + } else if (z == m_iNumColorMap - 1) { + DestHeight = TexSize - 1; } - else if(z==m_iNumColorMap-1) - { - DestHeight = TexSize - 1; + + for (int i = 0; i < DestHeight; i++) { + memcpy(&(pImgTarget[i * TexSize]), &(pBitmapBits[sx + (sz + i) * SmallWidth]), + DestWidth * sizeof(DWORD)); } - - for(int i=0;iUnlockRect(0); TexTmp.Convert(D3DFMT_DXT1); // DXT1 형식으로 Convert - TexTmp.Save(hCMFile); + TexTmp.Save(hCMFile); } } CloseHandle(hCMFile); - SelectObject( hBMDC, hOldBM ); - SelectObject( hSmallDC, hOldBM2 ); + SelectObject(hBMDC, hOldBM); + SelectObject(hSmallDC, hOldBM2); - DeleteFile("c:\\TempColormap.bmp"); // 임시 파일을 지워준다.. -*/ + fs::remove(fsBmpTmpFile); + */ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1910,34 +1874,30 @@ void CLyTerrain::MakeGameColorMap(char * szFullPathName) { // 컬러 맵 이름.. 파일이름만(확장자는 없다.) 저장해준다. // 컬러맵을 패치별로 따로 저장... /* - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(m_szFileName, szDrive, szDir, szFName, szExt); - CProgressBar ProgressBar; // 진행 상황.. ProgressBar.Create("Save game color map..", m_iNumColorMap * m_iNumColorMap, 50); ProgressBar.SetStep(1); - WriteFile(hFile, szFName, _MAX_PATH, &dwRWC, NULL); // 컬러맵 이름 저장. + char szGttFile[260]{}; + fsGttFile.string().copy(szGttFile, sizeof(szGttFile) - 1); + WriteFile(hFile, szGttFile, sizeof(szGttFile), &dwRWC, NULL); // 컬러맵 이름 저장. - CN3Texture TexTmp; - char szNewFName[_MAX_PATH] = "", szAdd[_MAX_PATH] = ""; - for(x=0;xLoadFromFile(pFileName); + pVMesh->LoadFromFile(fsVmeshFile); __Vector3 vMax, vMin; vMax = pVMesh->Max(); @@ -4893,11 +4853,11 @@ void CLyTerrain::Import(LPCTSTR pFileName, float fSize) { // // // -void CLyTerrain::ImportHeight(LPCTSTR pFileName) { +void CLyTerrain::ImportHeight(const fs::path & fsVmeshFile) { CN3VMesh * pVMesh = new CN3VMesh; __ASSERT(pVMesh, "VMesh가 안읽혀여..ㅜ.ㅜ"); - pVMesh->LoadFromFile(pFileName); + pVMesh->LoadFromFile(fsVmeshFile); __Vector3 vMax, vMin; vMax = pVMesh->Max(); @@ -5031,12 +4991,12 @@ void CLyTerrain::ImportHeight(LPCTSTR pFileName) { delete pVMesh; } /* -void CLyTerrain::ImportHeight(LPCTSTR pFileName) +void CLyTerrain::ImportHeight(const fs::path & fsVmeshFile) { CN3VMesh* pVMesh = new CN3VMesh; __ASSERT(pVMesh, "VMesh가 안읽허여..ㅜ.ㅜ"); - pVMesh->LoadFromFile(pFileName); + pVMesh->LoadFromFile(fsVmeshFile); __Vector3 vMax, vMin; vMax = pVMesh->Max(); @@ -5123,9 +5083,9 @@ void CLyTerrain::ImportHeight(LPCTSTR pFileName) // // ImportColorMap.. // -void CLyTerrain::ColorMapImport(LPCTSTR lpszPathName) { +void CLyTerrain::ColorMapImport(const fs::path & fsFile) { CBitMapFile BMF; - if (false == BMF.LoadFromFile(lpszPathName)) { + if (false == BMF.LoadFromFile(fsFile)) { return; } @@ -5143,18 +5103,19 @@ void CLyTerrain::ColorMapImport(LPCTSTR lpszPathName) { rc.top = (m_iNumColorMap - z - 1) * m_iColorMapTexSize; rc.right = rc.left + m_iColorMapTexSize; rc.bottom = rc.top + m_iColorMapTexSize; - BMF.SaveRectToFile("C:\\TmpSave.BMP", rc); - m_pColorTexture[x][z].LoadFromFile("C:\\TmpSave.BMP"); - DeleteFile("C:\\TmpSave.BMP"); + fs::path szTmpBmpFile = fs::temp_directory_path() / "N3ME_TmpSave.bmp"; + BMF.SaveRectToFile(szTmpBmpFile, rc); + m_pColorTexture[x][z].LoadFromFile(szTmpBmpFile); + fs::remove(szTmpBmpFile); } } } -void CLyTerrain::ColorMapExport(LPCTSTR lpszPathName) { +void CLyTerrain::ColorMapExport(const fs::path & fsFile) { if (m_iNumColorMap <= 0) { return; } - if (lstrlen(lpszPathName) <= 0) { + if (fsFile.empty()) { return; } @@ -5202,14 +5163,14 @@ void CLyTerrain::ColorMapExport(LPCTSTR lpszPathName) { } } - BMF.SaveToFile(lpszPathName); // 비트맵으로 저장.. + BMF.SaveToFile(fsFile); // 비트맵으로 저장.. } -void CLyTerrain::GenerateMiniMap(LPCTSTR lpszPathName, int size) { +void CLyTerrain::GenerateMiniMap(const fs::path & fsFile, int size) { if (m_iNumColorMap <= 0) { return; } - if (lstrlen(lpszPathName) <= 0) { + if (fsFile.empty()) { return; } @@ -5259,11 +5220,11 @@ void CLyTerrain::GenerateMiniMap(LPCTSTR lpszPathName, int size) { TmpTex.Get()->UnlockRect(0); } } - BMF.SaveToFile(lpszPathName); // 비트맵으로 저장.. + BMF.SaveToFile(fsFile); // 비트맵으로 저장.. } -void CLyTerrain::ExportHeightBMP(const char * szPathName) { - if (lstrlen(szPathName) <= 0) { +void CLyTerrain::ExportHeightBMP(const fs::path & fsFile) { + if (fsFile.empty()) { return; } @@ -5322,7 +5283,7 @@ void CLyTerrain::ExportHeightBMP(const char * szPathName) { pPixelDest[2] = gray; } } - BMF.SaveToFile(szPathName); // 비트맵으로 저장.. + BMF.SaveToFile(fsFile); // 비트맵으로 저장.. char msg[256]; sprintf(msg, "Max : %.2f Min : %.2f", Max, Min); @@ -5330,9 +5291,9 @@ void CLyTerrain::ExportHeightBMP(const char * szPathName) { MessageBox(::GetActiveWindow(), msg, NULL, MB_OK); } -void CLyTerrain::ImportHeightBMP(const char * szPathName) { +void CLyTerrain::ImportHeightBMP(const fs::path & fsFile) { CBitMapFile BMF; - BMF.LoadFromFile(szPathName); + BMF.LoadFromFile(fsFile); CProgressBar ProgressBar; // 진행 상황.. ProgressBar.Create("Import HeightBMP..", 50, m_iHeightMapSize * m_iHeightMapSize); diff --git a/src/tool/N3ME/LyTerrain.h b/src/tool/N3ME/LyTerrain.h index 8803cbe1..6b3083ac 100644 --- a/src/tool/N3ME/LyTerrain.h +++ b/src/tool/N3ME/LyTerrain.h @@ -156,20 +156,20 @@ class CLyTerrain : public CN3BaseFileAccess { void UpdateBrushArea(POINT ptCenter); // Brush 영역 표시 vertex갱신 void RenderBrushArea(); // Brush 영역 표시 그리기 - void ExportHeightBMP(const char * szPathName); - void ImportHeightBMP(const char * szPathName); + void ExportHeightBMP(const fs::path & fsFile); + void ImportHeightBMP(const fs::path & fsFile); void MakeMoveTable(short ** ppEvent); void Init(int HeightMapSize = 5); - bool LoadFromFile(const char * lpszPath); - bool SaveToFile(const char * lpszPath); - bool SaveToFilePartition(const char * lpszPath, float psx, float psz, float width); + bool LoadFromFile(const fs::path & fsFile); + bool SaveToFile(const fs::path & fsFile); + bool SaveToFilePartition(const fs::path & fsFile, float psx, float psz, float width); void Tick(); void Render(); void Release(); - void MakeGameLightMap(char * szFullPathName); - void MakeGameColorMap(char * szFullPathName); + void MakeGameLightMap(const fs::path & fsFile); + void MakeGameColorMap(const fs::path & fsFile); void GeneraterColorMap(bool bIsAll = false); void TilingAll(); //지형 전체를 선택된 타일로 깔기.. @@ -184,16 +184,16 @@ class CLyTerrain : public CN3BaseFileAccess { SIZE GetPatchNum(float fSize); BOOL MouseMsgFilter(LPMSG pMsg); // 지형 고칠때 마우스 메세지 처리 bool Pick(int x, int y, __Vector3 * vec, POINT * pHeightMapPos = NULL); - void Import(LPCTSTR pFileName, float fSize); - void ImportHeight(LPCTSTR pFileName); + void Import(const fs::path & fsVmeshFile, float fSize); + void ImportHeight(const fs::path & fsVmeshFile); void SaveServerData(HANDLE hFile); void SetEditMode(int iEditMode); // 지형 Edit모드로 변경 void UpdateBrushIntensityMap(int iShape, int iSize, float fFallOff); // 브러쉬의 모양과 사이즈에 따라서 IntensityMap을 다시 구성한다. void SaveGameData(HANDLE hFile); - void ColorMapImport(LPCTSTR lpszPathName); - void ColorMapExport(LPCTSTR lpszPathName); - void GenerateMiniMap(LPCTSTR lpszPathName, int size); + void ColorMapImport(const fs::path & fsFile); + void ColorMapExport(const fs::path & fsFile); + void GenerateMiniMap(const fs::path & fsFile, int size); // CLyTerrain(); diff --git a/src/tool/N3ME/MainFrm.cpp b/src/tool/N3ME/MainFrm.cpp index 5e465a21..ccd0660e 100644 --- a/src/tool/N3ME/MainFrm.cpp +++ b/src/tool/N3ME/MainFrm.cpp @@ -181,7 +181,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { // TODO: Remove this if you don't want tool tips m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); // 엔진 초기화 m_pEng = new CN3EngTool(); @@ -207,7 +207,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { //m_pDTexMng->LoadFromFile(); // 툴바 다이얼로그 정보.. - m_wndDlgBar.SetDlgItemText(IDC_E_PATH, CN3Base::PathGet().c_str()); + m_wndDlgBar.SetDlgItemText(IDC_E_PATH, CN3Base::PathGet().string().c_str()); m_pDlgMapView = new CDlgMapView; m_pDlgMapView->Create(IDD_ALL_MAP_VIEW, this); @@ -277,8 +277,9 @@ void CMainFrame::OnFileExport() { return; } - m_szZoneName = dlg.GetFileTitle().GetString(); - m_pMapMng->MakeGameFiles(dlg.GetPathName()); + fs::path fsFile = dlg.GetPathName().GetString(); + m_szZoneName = fsFile.stem().string(); + m_pMapMng->MakeGameFiles(fsFile); } void CMainFrame::OnFileServerData() { @@ -287,8 +288,9 @@ void CMainFrame::OnFileServerData() { if (dlg.DoModal() == IDCANCEL) { return; } + fs::path fsFile = dlg.GetPathName().GetString(); - m_pMapMng->MakeServerDataFiles(dlg.GetPathName()); + m_pMapMng->MakeServerDataFiles(fsFile); } void CMainFrame::OnCursorSelect() { @@ -591,8 +593,9 @@ void CMainFrame::OnFileImport() { if (dlg.DoModal() == IDCANCEL) { return; } + fs::path fsFile = dlg.GetPathName().GetString(); - m_pMapMng->ImportTerrain(dlg.GetPathName()); + m_pMapMng->ImportTerrain(fsFile); } void CMainFrame::OnFileImportHeight() { @@ -601,8 +604,9 @@ void CMainFrame::OnFileImportHeight() { if (dlg.DoModal() == IDCANCEL) { return; } + fs::path fsFile = dlg.GetPathName().GetString(); - m_pMapMng->ImportTerrainHeight(dlg.GetPathName()); + m_pMapMng->ImportTerrainHeight(fsFile); } void CMainFrame::OnEditDtex() { @@ -635,9 +639,9 @@ void CMainFrame::OnResourcePathSet() { return; } - std::string szPath(dlg.GetPathName().GetString()); - CN3Base::PathSet(szPath); // 경로 설정.. - m_wndDlgBar.SetDlgItemText(IDC_E_PATH, szPath.c_str()); + fs::path fsDir = dlg.GetPathName().GetString(); + CN3Base::PathSet(fsDir); // 경로 설정.. + m_wndDlgBar.SetDlgItemText(IDC_E_PATH, fsDir.string().c_str()); // 기본 리소스 읽기.. m_pMapMng->LoadSourceObjects(); @@ -719,15 +723,15 @@ void CMainFrame::OnUpdateTipRemoveAlphaflag(CCmdUI * pCmdUI) { pCmdUI->Enable(m_pMapMng->GetSelOutputObjCount() ? TRUE : FALSE); } -void CMainFrame::LoadDTexSet(CString FileName) { - if (m_DTexInfoFileName == FileName) { +void CMainFrame::LoadDTexSet(const fs::path & fsFileName) { + if (m_DTexInfoFileName.GetString() == fsFileName) { return; } - m_DTexInfoFileName = FileName; + m_DTexInfoFileName = fsFileName.c_str(); - m_pDTexGroupMng->LoadFromFile(FileName); - m_pDTexMng->LoadFromFile(FileName); + m_pDTexGroupMng->LoadFromFile(fsFileName); + m_pDTexMng->LoadFromFile(fsFileName); } void CMainFrame::OnViewSelectedObjectWireframe() { diff --git a/src/tool/N3ME/MainFrm.h b/src/tool/N3ME/MainFrm.h index 78e6b650..24b61edb 100644 --- a/src/tool/N3ME/MainFrm.h +++ b/src/tool/N3ME/MainFrm.h @@ -29,7 +29,7 @@ class CMainFrame : public CFrameWnd { CDTexMng * GetDTexMng() const { return m_pDTexMng; } CDTexGroupMng * GetDTexGroupMng() const { return m_pDTexGroupMng; } - void LoadDTexSet(CString FileName); + void LoadDTexSet(const fs::path & fsFileName); protected: CMapMng * m_pMapMng; diff --git a/src/tool/N3ME/MapMng.cpp b/src/tool/N3ME/MapMng.cpp index feccb04a..699cdd06 100644 --- a/src/tool/N3ME/MapMng.cpp +++ b/src/tool/N3ME/MapMng.cpp @@ -55,7 +55,7 @@ CMapMng::CMapMng(CMainFrame * pMainFrm) // Path 지정하기 m_pSceneSource = new CN3Scene; m_pSceneSource->m_szName = "SourceList"; - m_pSceneSource->FileNameSet("SourceList.N3Scene"); + m_pSceneSource->FilePathSet("SourceList.n3scene"); m_pSceneOutput = new CN3Scene; @@ -237,34 +237,22 @@ void CMapMng::LoadSourceObjects() { m_pSceneSource->Release(); - WIN32_FIND_DATA FindFileData; - - // source\Chr 폴더의 모든 캐릭터 추가 - CString szChrPath; - szChrPath.Format("%sChr\\", CN3Base::PathGet().c_str()); - SetCurrentDirectory(szChrPath); // szFolder\Chr 폴더로 경로를 바꾸고.. - HANDLE hFind = FindFirstFile("*.N3Chr", &FindFileData); - - if (hFind != INVALID_HANDLE_VALUE) { - AddChr(m_pSceneSource, std::string(szChrPath + FindFileData.cFileName), FALSE); - while (FindNextFile(hFind, &FindFileData)) { - AddChr(m_pSceneSource, std::string(szChrPath + FindFileData.cFileName), FALSE); + fs::path fsChrDir = fs::current_path() / "Chr"; + if (fs::is_directory(fsChrDir)) { + for (const auto & fi : fs::directory_iterator(fsChrDir)) { + if (fi.is_regular_file() && n3std::iequals(fi.path().extension(), ".n3chr")) { + AddChr(m_pSceneSource, "Chr" / fi.path().filename(), FALSE); + } } - FindClose(hFind); } - // source\Data 폴더의 모든 shape 추가 - CString szShapePath; - szShapePath.Format("%sObject\\", CN3Base::PathGet().c_str()); - SetCurrentDirectory(szShapePath); // szFolder\Mesh 폴더로 경로를 바꾸고.. - hFind = FindFirstFile("*.N3Shape", &FindFileData); // 파일 찾기. - - if (hFind != INVALID_HANDLE_VALUE) { - AddShape(m_pSceneSource, std::string(szShapePath + FindFileData.cFileName), FALSE); - while (FindNextFile(hFind, &FindFileData)) { - AddShape(m_pSceneSource, std::string(szShapePath + FindFileData.cFileName), FALSE); + fs::path fsObjectDir = fs::current_path() / "Object"; + if (fs::is_directory(fsObjectDir)) { + for (const auto & fi : fs::directory_iterator(fsObjectDir)) { + if (fi.is_regular_file() && n3std::iequals(fi.path().extension(), ".n3shape")) { + AddShape(m_pSceneSource, "Object" / fi.path().filename(), FALSE); + } } - FindClose(hFind); } m_pSceneSource->Tick(); // Object 초기화 @@ -272,35 +260,32 @@ void CMapMng::LoadSourceObjects() { } // 지정한 Scene에 캐릭터 추가하는 함수 -CN3Transform * CMapMng::AddChr(CN3Scene * pDestScene, const std::string & szFN, BOOL bGenerateChainNumber) { +CN3Transform * CMapMng::AddChr(CN3Scene * pDestScene, const fs::path & fsFile, BOOL bGenerateChainNumber) { CN3Chr * pChr = new CN3Chr; - if (false == pChr->LoadFromFile(szFN)) // 부르기가 실패하면.. - { + if (!pChr->LoadFromFile(fsFile)) { // 부르기가 실패하면.. delete pChr; return NULL; } if (bGenerateChainNumber) { - int nCC = pDestScene->ChrCount(); - int nChainNumber = 0; - char szCompare[_MAX_PATH]; + int nChainNumber = 0; + int nCC = pDestScene->ChrCount(); for (int i = 0; i < nCC; i++) { - lstrcpy(szCompare, pDestScene->ChrGet(i)->m_szName.c_str()); - int nL = lstrlen(szCompare); - if (nL < 5) { + std::string szNameFull = pDestScene->ChrGet(i)->m_szName; + size_t iSeparatorPos = szNameFull.rfind('_'); + if (iSeparatorPos == std::string::npos) { continue; } - szCompare[nL - 5] = NULL; // 뒤에 붙는 언더바와 네자리 번호는 뺀다.. - if (pChr->m_szName == szCompare) // 이름이 같으면.. - { - nChainNumber = atoi(&(szCompare[nL - 4])) + 1; + std::string szName = szNameFull.substr(0, iSeparatorPos); + if (pChr->m_szName == szName) { + std::string szDigits = szNameFull.substr(iSeparatorPos + 1); + std::from_chars(szDigits.data(), szDigits.data() + szDigits.size(), nChainNumber); + ++nChainNumber; } } - char szName[_MAX_PATH]; - wsprintf(szName, "%s_%.4d", pChr->m_szName.c_str(), nChainNumber); - pChr->m_szName = szName; // .. 이름을 짓는다.. + pChr->m_szName = std::format("{:s}_{:04d}", pChr->m_szName, nChainNumber); } pDestScene->ChrAdd(pChr); @@ -308,43 +293,40 @@ CN3Transform * CMapMng::AddChr(CN3Scene * pDestScene, const std::string & szFN, } // 지정한 Scene에 Shape 추가하는 함수 -CN3Transform * CMapMng::AddShape(CN3Scene * pDestScene, const std::string & szFN, BOOL bGenerateChainNumber) { +CN3Transform * CMapMng::AddShape(CN3Scene * pDestScene, const fs::path & fsFile, BOOL bGenerateChainNumber) { CN3Shape * pShape = new CN3Shape; - if (false == pShape->LoadFromFile(szFN)) // 부르기가 실패하면.. + if (false == pShape->LoadFromFile(fsFile)) // 부르기가 실패하면.. { delete pShape; return NULL; } - /* if(bGenerateChainNumber) - { - int nSC = pDestScene->ShapeCount(); + /* + if (bGenerateChainNumber) { int nChainNumber = 0; - char szCompare[_MAX_PATH]; - for(int i = 0; i < nSC; i++) - { - lstrcpy(szCompare, pDestScene->ShapeGet(i)->Name()); - int nL = lstrlen(szCompare); - if(nL < 5) continue; + int nSC = pDestScene->ShapeCount(); + for (int i = 0; i < nSC; i++) { + std::string szNameFull = pDestScene->ShapeGet(i)->m_szName; + size_t iSeparatorPos = szNameFull.rfind('_'); + if (iSeparatorPos == std::string::npos) { + continue; + } - szCompare[nL-5] = NULL; // 뒤에 붙는 언더바와 네자리 번호는 뺀다.. - if(0 == lstrcmpi(pShape->Name(), szCompare)) // 이름이 같으면.. - { - nChainNumber = atoi(&(szCompare[nL-4])) + 1; + std::string szName = szNameFull.substr(0, iSeparatorPos); + if (pShape->m_szName == szName) { + std::string szDigits = szNameFull.substr(iSeparatorPos + 1); + std::from_chars(szDigits.data(), szDigits.data() + szDigits.size(), nChainNumber); + ++nChainNumber; } } - char szName[_MAX_PATH]; - wsprintf(szName, "%s_%.4d", pShape->Name(), nChainNumber); - pShape->m_szName = szName; // .. 이름을 짓는다.. + pShape->m_szName = std::format("{:s}_{:04d}", pShape->m_szName, nChainNumber); - char szFileName2[_MAX_PATH]; - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(szFileName, szDrive, szDir, szFName, szExt); - _makepath(szFileName2, szDrive, szDir, szName, szExt); - pShape->FileNameSet(szFileName2); // 파일 이름 짓기... + fs::path fsFile = pShape->FilePath().parent_path() / (pShape->m_szName + pShape->FilePath().extension()); + pShape->FilePathSet(fsFile); } -*/ + */ + pDestScene->ShapeAdd(pShape); // 추가 하고 return pShape; } @@ -359,9 +341,9 @@ CN3Transform * CMapMng::AddObjectToOutputScene(CN3Transform * pObj) { // m_pSceneOutput에 넣기 CN3Transform * pDestObj = NULL; if (pObj->Type() & OBJ_CHARACTER) { - pDestObj = AddChr(m_pSceneOutput, pObj->FileName(), TRUE); + pDestObj = AddChr(m_pSceneOutput, pObj->FilePath(), TRUE); } else if (pObj->Type() & OBJ_SHAPE) { - pDestObj = AddShape(m_pSceneOutput, pObj->FileName(), TRUE); + pDestObj = AddShape(m_pSceneOutput, pObj->FilePath(), TRUE); } if (pDestObj) { @@ -418,180 +400,128 @@ void CMapMng::SavePartition(float x, float z, float width) { return; } - CString lpszPathName = dlg.GetPathName(); - - // 파일 이름 - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath((LPCTSTR)lpszPathName, szDrive, szDir, szFName, szExt); + fs::path fsFileTmp = fs::path(dlg.GetPathName().GetString()).replace_extension(".n3m"); - //n3m만들기..^^ - char szN3M[_MAX_PATH]; - _makepath(szN3M, szDrive, szDir, szFName, "n3m"); - HANDLE hFile = CreateFile(szN3M, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsFileTmp.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - MessageBox(::GetActiveWindow(), lpszPathName, "Fail to open map data file for save, Pleas retry.", MB_OK); + MessageBoxW(::GetActiveWindow(), fsFileTmp.c_str(), L"Fail to open map data file for save, Pleas retry.", + MB_OK); return; } - char comment[80] = {"이파일 여는 사람 바보..^^"}; + char szComment[80] = {"이파일 여는 사람 바보..^^"}; DWORD dwRWC; - WriteFile(hFile, &comment, sizeof(char) * 80, &dwRWC, NULL); + WriteFile(hFile, &szComment, sizeof(char) * 80, &dwRWC, NULL); CloseHandle(hFile); // 지형 if (m_pTerrain) { - char szTerrain[_MAX_PATH]; - _makepath(szTerrain, szDrive, szDir, szFName, "trn"); - m_pTerrain->SaveToFilePartition(szTerrain, x, z, width); + m_pTerrain->SaveToFilePartition(fsFileTmp.replace_extension(".trn"), x, z, width); } // sdt파일 저장(shape data text) - char szSceneText[_MAX_PATH]; - _makepath(szSceneText, szDrive, szDir, szFName, "sdt"); - SaveObjectPostDataPartition(szSceneText, x, z, width); + SaveObjectPostDataPartition(fsFileTmp.replace_extension(".sdt"), x, z, width); /* // warp 정보 load.. - char szWarp[_MAX_PATH]; - _makepath(szWarp, szDrive, szDir, szFName, "wap"); - m_pWarpMgr->SaveToFile(szWarp); + m_pWarpMgr->SaveToFile(fsFileTmp.replace_extension(".wap")); //이벤트 정보 저장.. - //char szEvent[_MAX_PATH]; - //_makepath(szEvent, szDrive, szDir, szFName, "evt"); - //m_pEventMgr->SaveToFile(szEvent); - //*/ + m_pEventMgr->SaveToFile(fsFileTmp.replace_extension(".evt")); + */ } -void CMapMng::SaveToFile(LPCTSTR lpszPathName) { - if (lstrlen(lpszPathName) == 0) { +void CMapMng::SaveToFile(const fs::path & fsFile) { + if (fsFile.empty()) { return; } - // 파일 이름 - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszPathName, szDrive, szDir, szFName, szExt); + fs::path fsFileTmp = fs::path(fsFile).replace_extension(".n3m"); - //n3m만들기..^^ - char szN3M[_MAX_PATH]; - _makepath(szN3M, szDrive, szDir, szFName, "n3m"); - HANDLE hFile = CreateFile(szN3M, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsFileTmp.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - MessageBox(::GetActiveWindow(), lpszPathName, "Fail to open map data file for save, Pleas retry.", MB_OK); + MessageBoxW(::GetActiveWindow(), fsFileTmp.c_str(), L"Fail to open map data file for save, Please retry.", + MB_OK); return; } - char comment[80] = {"이파일 여는 사람 바보..^^"}; + char szComment[80] = {"이파일 여는 사람 바보..^^"}; DWORD dwRWC; - WriteFile(hFile, &comment, sizeof(char) * 80, &dwRWC, NULL); + WriteFile(hFile, &szComment, sizeof(char) * 80, &dwRWC, NULL); CloseHandle(hFile); // 지형 if (m_pTerrain) { - char szTerrain[_MAX_PATH]; - _makepath(szTerrain, szDrive, szDir, szFName, "trn"); - m_pTerrain->SaveToFile(szTerrain); + m_pTerrain->SaveToFile(fsFileTmp.replace_extension(".trn")); } // sdt파일 저장(shape data text) - char szSceneText[_MAX_PATH]; - _makepath(szSceneText, szDrive, szDir, szFName, "sdt"); - SaveObjectPostData(szSceneText); + SaveObjectPostData(fsFileTmp.replace_extension(".sdt")); // 강물 편집 정보 저장.. - char szRiver[_MAX_PATH]; - _makepath(szRiver, szDrive, szDir, szFName, "rvr"); - m_RiverMng.SaveToFile(szRiver); + m_RiverMng.SaveToFile(fsFileTmp.replace_extension(".rvr")); // 연못 편집 정보 저장.. - char szPond[_MAX_PATH]; - _makepath(szPond, szDrive, szDir, szFName, "pvr"); - m_PondMng.SaveToFile(szPond); + m_PondMng.SaveToFile(fsFileTmp.replace_extension(".pvr")); //벽 정보 저장.. - char szWall[_MAX_PATH]; - _makepath(szWall, szDrive, szDir, szFName, "wal"); - m_pWall->SaveToFile(szWall); + m_pWall->SaveToFile(fsFileTmp.replace_extension(".wal")); // warp 정보 load.. - char szWarp[_MAX_PATH]; - _makepath(szWarp, szDrive, szDir, szFName, "wap"); - m_pWarpMgr->SaveToFile(szWarp); + m_pWarpMgr->SaveToFile(fsFileTmp.replace_extension(".wap")); // sound 정보 Load.. - char szSound[_MAX_PATH]; - _makepath(szSound, szDrive, szDir, szFName, "tsd"); - m_pSoundMgr->SaveToFile(szSound); + m_pSoundMgr->SaveToFile(fsFileTmp.replace_extension(".tsd")); // light object 정보.. - char szLightObj[_MAX_PATH]; - _makepath(szLightObj, szDrive, szDir, szFName, "tld"); - m_pLightObjMgr->SaveToFile(szLightObj); + m_pLightObjMgr->SaveToFile(fsFileTmp.replace_extension(".tld")); - //이벤트 정보 저장.. - //char szEvent[_MAX_PATH]; - //_makepath(szEvent, szDrive, szDir, szFName, "evt"); - //m_pEventMgr->SaveToFile(szEvent); + /* + // 이벤트 정보 저장.. + m_pEventMgr->SaveToFile(fsFileTmp.replace_extension("evt")); + */ } -void CMapMng::LoadFromFile(LPCTSTR lpszPathName) { - if (lstrlen(lpszPathName) == 0) { +void CMapMng::LoadFromFile(const fs::path & fsFile) { + if (fsFile.empty()) { return; } - // 파일 이름 - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_PATH], szExt[_MAX_EXT]; - _splitpath(lpszPathName, szDrive, szDir, szFName, szExt); + fs::path fsFileTmp(fsFile); // 지형 delete m_pTerrain; m_pTerrain = new CLyTerrain; m_pTerrain->Init(); - char szTerrain[_MAX_PATH]; - _makepath(szTerrain, szDrive, szDir, szFName, "trn"); - m_pTerrain->LoadFromFile(szTerrain); + m_pTerrain->LoadFromFile(fsFileTmp.replace_extension(".trn")); // Scene ASSERT(m_pSceneOutput); - char szSceneText[_MAX_PATH]; - _makepath(szSceneText, szDrive, szDir, szFName, "sdt"); - LoadObjectPostData(szSceneText); + LoadObjectPostData(fsFileTmp.replace_extension(".sdt")); // river - char szRiver[_MAX_PATH]; - _makepath(szRiver, szDrive, szDir, szFName, "rvr"); - m_RiverMng.LoadFromFile(szRiver); + m_RiverMng.LoadFromFile(fsFileTmp.replace_extension(".rvr")); // Pond - char szPond[_MAX_PATH]; - _makepath(szPond, szDrive, szDir, szFName, "pvr"); - m_PondMng.LoadFromFile(szPond); + m_PondMng.LoadFromFile(fsFileTmp.replace_extension(".pvr")); //벽 정보 load.. - char szWall[_MAX_PATH]; - _makepath(szWall, szDrive, szDir, szFName, "wal"); - m_pWall->LoadFromFile(szWall); + m_pWall->LoadFromFile(fsFileTmp.replace_extension(".wal")); // warp 정보 load.. - char szWarp[_MAX_PATH]; - _makepath(szWarp, szDrive, szDir, szFName, "wap"); - m_pWarpMgr->LoadFromFile(szWarp); + m_pWarpMgr->LoadFromFile(fsFileTmp.replace_extension(".wap")); // sound 정보 Load.. - char szSound[_MAX_PATH]; - _makepath(szSound, szDrive, szDir, szFName, "tsd"); - m_pSoundMgr->LoadFromFile(szSound); + m_pSoundMgr->LoadFromFile(fsFileTmp.replace_extension(".tsd")); // light object 정보.. - char szLightObj[_MAX_PATH]; - _makepath(szLightObj, szDrive, szDir, szFName, "tld"); - m_pLightObjMgr->LoadFromFile(szLightObj); + m_pLightObjMgr->LoadFromFile(fsFileTmp.replace_extension(".tld")); - //이벤트 정보.. - //char szEvent[_MAX_PATH]; - //_makepath(szEvent, szDrive, szDir, szFName, "evt"); - //m_pEventMgr->LoadFromFile(szEvent); - //m_pEventMgr->SetActive(true); - //m_pEventMgr->SetActive(false); + /* + // 이벤트 정보.. + m_pEventMgr->LoadFromFile(fsFileTmp.replace_extension(".evt")); + m_pEventMgr->SetActive(true); + m_pEventMgr->SetActive(false); + */ m_pDlgOutputList->UpdateTree(m_pSceneOutput); } @@ -1413,94 +1343,83 @@ int CMapMng::SortByCameraDistance(const void * pArg1, const void * pArg2) { } } -void CMapMng::MakeGameFiles(LPCTSTR lpszPathName, float fSize) { +void CMapMng::MakeGameFiles(const fs::path & fsFile, float fSize) { if (NULL == m_pTerrain || NULL == m_pSceneOutput) { return; } - if (lstrlen(lpszPathName) == 0) { + if (fsFile.empty()) { return; } - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszPathName, szDrive, szDir, szFName, szExt); + fs::path fsFileTmp(fsFile); // 파일 저장. - HANDLE hFile = CreateFile(lpszPathName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { - MessageBox(::GetActiveWindow(), lpszPathName, "Fail to open map game data file for save, Pleas retry.", MB_OK); + HANDLE hGmdFile = + CreateFileW(fsFileTmp.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (INVALID_HANDLE_VALUE == hGmdFile) { + MessageBoxW(::GetActiveWindow(), fsFileTmp.c_str(), L"Fail to open map game data file for save, Pleas retry.", + MB_OK); return; } char comment[80] = {"이파일 여는 사람 바보..^^"}; DWORD dwRWC; - WriteFile(hFile, &m_iZoneID, sizeof(int), &dwRWC, NULL); - WriteFile(hFile, &comment, sizeof(char) * 80, &dwRWC, NULL); - CloseHandle(hFile); + WriteFile(hGmdFile, &m_iZoneID, sizeof(int), &dwRWC, NULL); + WriteFile(hGmdFile, &comment, sizeof(char) * 80, &dwRWC, NULL); + CloseHandle(hGmdFile); // 지형정보 저장 - HANDLE hTerrainGameFile = NULL; - char szTerrain[_MAX_PATH] = ""; - _makepath(szTerrain, szDrive, szDir, szFName, ".gtd"); - m_pTerrain->FileNameSet(szTerrain); - hTerrainGameFile = CreateFile(szTerrain, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hTerrainGameFile) { - MessageBox(::GetActiveWindow(), szTerrain, "Failed to open terrain file for save", MB_OK); + m_pTerrain->FilePathSet(fsFileTmp.replace_extension(".gtd")); + HANDLE hGtdFile = + CreateFileW(fsFileTmp.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (INVALID_HANDLE_VALUE == hGtdFile) { + MessageBoxW(::GetActiveWindow(), fsFileTmp.c_str(), L"Failed to open terrain file for save", MB_OK); } else { - m_pTerrain->m_szName = szFName; // 이름을 지정한다.. 이 이름대로 저장된다. - m_pTerrain->SaveGameData(hTerrainGameFile); - char szColorMapName[_MAX_PATH]; - _makepath(szColorMapName, szDrive, szDir, szFName, ".tct"); - m_pTerrain->MakeGameColorMap(szColorMapName); + m_pTerrain->m_szName = fsFileTmp.stem().string(); // 이름을 지정한다.. 이 이름대로 저장된다. + m_pTerrain->SaveGameData(hGtdFile); + + m_pTerrain->MakeGameColorMap(fsFileTmp.replace_extension(".tct")); - m_RiverMng.MakeGameFiles(hTerrainGameFile, fSize); - m_PondMng.MakeGameFiles(hTerrainGameFile, fSize); - //m_pSoundMgr->SaveGameData(hTerrainGameFile); - CloseHandle(hTerrainGameFile); + m_RiverMng.MakeGameFiles(hGtdFile, fSize); + m_PondMng.MakeGameFiles(hGtdFile, fSize); + //m_pSoundMgr->SaveGameData(hGtdFile); + CloseHandle(hGtdFile); - char szLightMapName[_MAX_PATH]; - _makepath(szLightMapName, szDrive, szDir, szFName, ".tlt"); - m_pTerrain->MakeGameLightMap(szLightMapName); + m_pTerrain->MakeGameLightMap(fsFileTmp.replace_extension(".tlt")); } // Shape Manager 만들고 저장... - // if(true == m_pSceneOutput->CheckOverlappedShapesAndReport()) // 이름이나 위치 중복 확인.. - // { - // int idYesNo = ::MessageBox(::GetActiveWindow(), "중복된 오브젝트들을 삭제 하시겠습니까?", "중복된 오브젝트 처리", MB_YESNO); - // if(IDYES == idYesNo) - // { - // m_pSceneOutput->DeleteOverlappedShapes(); - // m_pDlgOutputList->UpdateTree(m_pSceneOutput); // 아웃풋 리스트 체크.. - // m_SelOutputObjArray.RemoveAll(); // 셀렉션 초기화.. - // } + //if (true == m_pSceneOutput->CheckOverlappedShapesAndReport()) { // 이름이나 위치 중복 확인.. + // int idYesNo = ::MessageBox(::GetActiveWindow(), "중복된 오브젝트들을 삭제 하시겠습니까?", + // "중복된 오브젝트 처리", MB_YESNO); + // if (IDYES == idYesNo) { + // m_pSceneOutput->DeleteOverlappedShapes(); + // m_pDlgOutputList->UpdateTree(m_pSceneOutput); // 아웃풋 리스트 체크.. + // m_SelOutputObjArray.RemoveAll(); // 셀렉션 초기화.. // } + //} - CN3ShapeMgr ShapeMgr; - ShapeMgr.Create((m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE, - (m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE); + std::unique_ptr pShapeMgr = std::make_unique(); + pShapeMgr->Create((m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE, + (m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE); int nSC = m_pSceneOutput->ShapeCount(); for (int i = 0; i < nSC; i++) { - ShapeMgr.Add(m_pSceneOutput->ShapeGet(i)); // Shape 추가. + pShapeMgr->Add(m_pSceneOutput->ShapeGet(i)); // Shape 추가. } if (m_pWall) { - m_pWall->AddWall2Coll(&ShapeMgr); + m_pWall->AddWall2Coll(pShapeMgr.get()); } - ShapeMgr.GenerateCollisionData(); // 충돌 메시 데이터를 생성한다... - char szObjPosting[_MAX_PATH] = ""; - _makepath(szObjPosting, szDrive, szDir, szFName, - ".opd"); // "Object Posting Data" - Shape Manager file 이름을 정하고.. - ShapeMgr.SaveToFile(szObjPosting); + // "Object Posting Data" - Shape Manager file + pShapeMgr->GenerateCollisionData(); // 충돌 메시 데이터를 생성한다... + pShapeMgr->SaveToFile(fsFileTmp.replace_extension(".opd")); //이벤트 저장.. - char szEventName[_MAX_PATH] = ""; - _makepath(szEventName, szDrive, szDir, szFName, ".gev"); // - if (!m_pEventMgr->MakeGameFile(szEventName, m_pTerrain->m_iHeightMapSize)) { - MessageBox(::GetActiveWindow(), lpszPathName, "Fail to make game event file...", MB_OK); + if (!m_pEventMgr->MakeGameFile(fsFileTmp.replace_extension(".gev"), m_pTerrain->m_iHeightMapSize)) { + MessageBoxW(::GetActiveWindow(), fsFileTmp.c_str(), L"Failed to make game event file...", MB_OK); } - char szLightName[_MAX_PATH] = ""; - _makepath(szLightName, szDrive, szDir, szFName, ".glo"); // - if (!m_pLightObjMgr->MakeGameFile(szLightName)) { - MessageBox(::GetActiveWindow(), lpszPathName, "Fail to make game light info file...", MB_OK); + if (!m_pLightObjMgr->MakeGameFile(fsFileTmp.replace_extension(".glo"))) { + MessageBoxW(::GetActiveWindow(), fsFileTmp.c_str(), L"Failed to make game light info file...", MB_OK); } } @@ -1509,47 +1428,46 @@ void CMapMng::MakeTerrainMovableAttr(CN3ShapeMgr * pShapeMgr) { pShapeMgr->MakeMoveTable(m_pEventMgr->m_ppEvent); //움직임 속성 셋팅... } -void CMapMng::MakeServerDataFiles(LPCTSTR lpszPathName) { +void CMapMng::MakeServerDataFiles(const fs::path & fsFile) { if (NULL == m_pEventMgr->m_ppEvent) { m_pEventMgr->SetActive(true); m_pEventMgr->SetActive(false); } - HANDLE hFile = CreateFile(lpszPathName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { + HANDLE hSmdFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (INVALID_HANDLE_VALUE == hSmdFile) { m_pMainFrm->MessageBox("file write error"); return; } //terrain 저장.. - m_pTerrain->SaveServerData(hFile); + m_pTerrain->SaveServerData(hSmdFile); // // Shape Manager 만들고 저장... - // if(true == m_pSceneOutput->CheckOverlappedShapesAndReport()) // 이름이나 위치 중복 확인.. - // { - // int idYesNo = ::MessageBox(::GetActiveWindow(), "중복된 오브젝트들을 삭제 하시겠습니까?", "중복된 오브젝트 처리", MB_YESNO); - // if(IDYES == idYesNo) - // { - // m_pSceneOutput->DeleteOverlappedShapes(); - // m_pDlgOutputList->UpdateTree(m_pSceneOutput); // 아웃풋 리스트 체크.. - // m_SelOutputObjArray.RemoveAll(); // 셀렉션 초기화.. - // } + //if (true == m_pSceneOutput->CheckOverlappedShapesAndReport()) { // 이름이나 위치 중복 확인.. + // int idYesNo = ::MessageBox(::GetActiveWindow(), "중복된 오브젝트들을 삭제 하시겠습니까?", + // "중복된 오브젝트 처리", MB_YESNO); + // if (IDYES == idYesNo) { + // m_pSceneOutput->DeleteOverlappedShapes(); + // m_pDlgOutputList->UpdateTree(m_pSceneOutput); // 아웃풋 리스트 체크.. + // m_SelOutputObjArray.RemoveAll(); // 셀렉션 초기화.. // } + //} - CN3ShapeMgr ShapeMgr; - ShapeMgr.Create((m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE, - (m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE); + std::unique_ptr pShapeMgr = std::make_unique(); + pShapeMgr->Create((m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE, + (m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE); int nSC = m_pSceneOutput->ShapeCount(); for (int i = 0; i < nSC; i++) { - ShapeMgr.Add(m_pSceneOutput->ShapeGet(i)); // Shape 추가. + pShapeMgr->Add(m_pSceneOutput->ShapeGet(i)); // Shape 추가. } if (m_pWall) { - m_pWall->AddWall2Coll(&ShapeMgr); + m_pWall->AddWall2Coll(pShapeMgr.get()); } - ShapeMgr.GenerateCollisionData(); // 충돌 메시 데이터를 생성한다.. - MakeTerrainMovableAttr(&ShapeMgr); - ShapeMgr.SaveCollisionData(hFile); // 충돌 데이터만 저장... + pShapeMgr->GenerateCollisionData(); // 충돌 메시 데이터를 생성한다.. + MakeTerrainMovableAttr(pShapeMgr.get()); + pShapeMgr->SaveCollisionData(hSmdFile); // 충돌 데이터만 저장... // Object Event 저장. // @@ -1563,27 +1481,27 @@ void CMapMng::MakeServerDataFiles(LPCTSTR lpszPathName) { } } - WriteFile(hFile, &iEventObjectCount, 4, &dwNum, NULL); + WriteFile(hSmdFile, &iEventObjectCount, 4, &dwNum, NULL); for (int i = 0; i < nSC; i++) { CN3Shape * pShape = m_pSceneOutput->ShapeGet(i); short sEvent = 0; __Vector3 vPos; if (pShape->m_iEventID || pShape->m_iEventType || pShape->m_iNPC_ID || pShape->m_iNPC_Status) // 이벤트가 있으면 { - WriteFile(hFile, &(pShape->m_iBelong), 4, &dwNum, NULL); + WriteFile(hSmdFile, &(pShape->m_iBelong), 4, &dwNum, NULL); sEvent = (short)(pShape->m_iEventID); - WriteFile(hFile, &sEvent, 2, &dwNum, NULL); + WriteFile(hSmdFile, &sEvent, 2, &dwNum, NULL); sEvent = (short)(pShape->m_iEventType); - WriteFile(hFile, &sEvent, 2, &dwNum, NULL); + WriteFile(hSmdFile, &sEvent, 2, &dwNum, NULL); sEvent = (short)(pShape->m_iNPC_ID); - WriteFile(hFile, &sEvent, 2, &dwNum, NULL); + WriteFile(hSmdFile, &sEvent, 2, &dwNum, NULL); sEvent = (short)(pShape->m_iNPC_Status); - WriteFile(hFile, &sEvent, 2, &dwNum, NULL); + WriteFile(hSmdFile, &sEvent, 2, &dwNum, NULL); vPos = pShape->Pos(); - WriteFile(hFile, &(vPos.x), 4, &dwNum, NULL); - WriteFile(hFile, &(vPos.y), 4, &dwNum, NULL); - WriteFile(hFile, &(vPos.z), 4, &dwNum, NULL); + WriteFile(hSmdFile, &(vPos.x), 4, &dwNum, NULL); + WriteFile(hSmdFile, &(vPos.y), 4, &dwNum, NULL); + WriteFile(hSmdFile, &(vPos.z), 4, &dwNum, NULL); } } @@ -1591,35 +1509,26 @@ void CMapMng::MakeServerDataFiles(LPCTSTR lpszPathName) { // m_pEventMgr->MakeEventArray(); /* - for(int z=0; zm_iHeightMapSize; z++) - { - for(int x=0; xm_iHeightMapSize; x++) - { - WriteFile(hFile, &(m_pEventMgr->m_ppEvent[x][z]), sizeof(short), &dwNum, NULL); + for (int z = 0; z < m_pTerrain->m_iHeightMapSize; z++) { + for (int x = 0; x < m_pTerrain->m_iHeightMapSize; x++) { + WriteFile(hSmdFile, &(m_pEventMgr->m_ppEvent[x][z]), sizeof(short), &dwNum, NULL); } } */ for (int x = 0; x < m_pTerrain->m_iHeightMapSize; x++) { - WriteFile(hFile, m_pEventMgr->m_ppEvent[x], sizeof(short) * m_pTerrain->m_iHeightMapSize, &dwNum, NULL); + WriteFile(hSmdFile, m_pEventMgr->m_ppEvent[x], sizeof(short) * m_pTerrain->m_iHeightMapSize, &dwNum, NULL); } - m_pRegenUser->SaveServerData(hFile); - m_pWarpMgr->SaveServerData(hFile); - - // 이벤트 정보.. - // 파일 이름 - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_PATH], szExt[_MAX_EXT]; - _splitpath(lpszPathName, szDrive, szDir, szFName, szExt); + m_pRegenUser->SaveServerData(hSmdFile); + m_pWarpMgr->SaveServerData(hSmdFile); //이벤트 정보 저장.. - char szEvent[_MAX_PATH]; - char szEvtFName[_MAX_PATH]; - sprintf(szEvtFName, "%s_Event", szFName); - _makepath(szEvent, szDrive, szDir, szEvtFName, "txt"); - m_pEventMgr->SaveInfoTextFile(szEvent); //서버에서 쓰는 이벤트 아이디 조건들이 들어 있는 텍스트 파일.. + fs::path fsEventFile = fsFile.parent_path() / (fsFile.stem() + "_Event.txt"); + m_pEventMgr->SaveInfoTextFile(fsEventFile); //서버에서 쓰는 이벤트 아이디 조건들이 들어 있는 텍스트 파일.. // 텍스트파일로 함 뽑아보자.. - FILE * stream = fopen("c:\\move.txt", "w"); + fs::path fsTmpMoveFile = fs::temp_directory_path() / "N3ME_move.txt"; + FILE * stream = _wfopen(fsTmpMoveFile.c_str(), L"w"); for (int z = m_pTerrain->m_iHeightMapSize - 1; z >= 0; z--) { for (int x = 0; x < m_pTerrain->m_iHeightMapSize; x++) { int v = m_pEventMgr->m_ppEvent[x][z]; @@ -1631,16 +1540,13 @@ void CMapMng::MakeServerDataFiles(LPCTSTR lpszPathName) { //뽑았다. /* - char szCollisionFN[512]; - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszPathName, szDrive, szDir, szFName, szExt); - _makepath(szCollisionFN, szDrive,szDir, szFName, ".scd"); // 다른 이름으로 저장.. - CFile file; - file.Open(szCollisionFN, CFile::modeCreate | CFile::modeWrite); - ShapeMgr.SaveCollisionData((HANDLE)file.m_hFile); // 충돌 데이터만 저장... + fs::path fsCollisionFile = fs::path(fsFile).replace_extension(".scd"); + CFile file; + file.Open(fsCollisionFile.string().c_str(), CFile::modeCreate | CFile::modeWrite); + pShapeMgr->SaveCollisionData((HANDLE)file.m_hFile); // 충돌 데이터만 저장... file.Close(); -*/ - CloseHandle(hFile); + */ + CloseHandle(hSmdFile); } BOOL CMapMng::GetObjectMinMax(CN3Transform * pObj, __Vector3 & vMin, __Vector3 & vMax) { @@ -1908,19 +1814,19 @@ void CMapMng::SetCursorMode(int iMode) { m_pEventMgr->SetActive(true); m_pEventMgr->SetActive(false); - CN3ShapeMgr ShapeMgr; - ShapeMgr.Create((m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE, - (m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE); + std::unique_ptr pShapeMgr = std::make_unique(); + pShapeMgr->Create((m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE, + (m_pTerrain->m_iHeightMapSize - 1) * TERRAIN_CELL_SIZE); int nSC = m_pSceneOutput->ShapeCount(); for (int i = 0; i < nSC; i++) { - ShapeMgr.Add(m_pSceneOutput->ShapeGet(i)); // Shape 추가. + pShapeMgr->Add(m_pSceneOutput->ShapeGet(i)); // Shape 추가. } if (m_pWall) { - m_pWall->AddWall2Coll(&ShapeMgr); + m_pWall->AddWall2Coll(pShapeMgr.get()); } - ShapeMgr.GenerateCollisionData(); // 충돌 메시 데이터를 생성한다.. + pShapeMgr->GenerateCollisionData(); // 충돌 메시 데이터를 생성한다.. - MakeTerrainMovableAttr(&ShapeMgr); + MakeTerrainMovableAttr(pShapeMgr.get()); m_pNPCPath->m_pppRefEvent = m_pEventMgr->m_ppEvent; } m_pNPCPath->SetActive(true); @@ -1999,7 +1905,7 @@ void CMapMng::DropSelObjToTerrain() { // 선택한 객체를 지형에 붙인다 Invalidate(); } -void CMapMng::ImportTerrain(const char * szMeshFN) { +void CMapMng::ImportTerrain(const fs::path & fsVmeshFile) { CDlgTerrainSize dlg; dlg.m_fSize = 1024.0f * 4.0f; if (dlg.DoModal() != IDOK) { @@ -2017,7 +1923,7 @@ void CMapMng::ImportTerrain(const char * szMeshFN) { m_pTerrain = new CLyTerrain; } - m_pTerrain->Import(szMeshFN, dlg.m_fSize); + m_pTerrain->Import(fsVmeshFile, dlg.m_fSize); m_pEventMgr->SetActive(true); m_pEventMgr->SetActive(false); @@ -2027,7 +1933,7 @@ void CMapMng::ImportTerrain(const char * szMeshFN) { m_bLoadingComplete = true; } -void CMapMng::ImportTerrainHeight(const char * szMeshFN) { +void CMapMng::ImportTerrainHeight(const fs::path & fsVmeshFile) { HCURSOR hLoadCur, hCurrentCur; hCurrentCur = GetCursor(); hLoadCur = AfxGetApp()->LoadCursor(IDC_LOAD); @@ -2036,7 +1942,7 @@ void CMapMng::ImportTerrainHeight(const char * szMeshFN) { if (!m_pTerrain) { return; } else { - m_pTerrain->ImportHeight(szMeshFN); + m_pTerrain->ImportHeight(fsVmeshFile); } SetCursor(hCurrentCur); @@ -2100,66 +2006,58 @@ void CMapMng::RenderGrid(float fGridSize, float fMaxDistance) // fGridSize크기 pD3DDev->SetRenderState(D3DRS_ZENABLE, dwZEnable); } -void CMapMng::SaveObjectPostData(LPCTSTR lpszFileName) { +void CMapMng::SaveObjectPostData(const fs::path & fsFile) { /* ////////////////////////////////// // OldData - if (m_pSceneOutput == NULL) return; + if (m_pSceneOutput == NULL) { + return; + } - FILE* stream = fopen(lpszFileName, "w"); - if (stream == NULL) - { + FILE * stream = _wfopen(fsFile.c_str(), L"w"); + if (stream == NULL) { m_pMainFrm->MessageBox("파일을 만들수 없습니다."); return; } - // 폴더 이름을 분리하고.. - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszFileName, szDrive, szDir, szFName, szExt); - int iSC = m_pSceneOutput->ShapeCount(); fprintf(stream, "Shape Count : %d\n", iSC); - for(int i=0; iShapeGet(i); + for (int i = 0; i < iSC; ++i) { + CN3Shape * pShape = m_pSceneOutput->ShapeGet(i); ASSERT(pShape); - if (pShape == NULL) continue; + if (pShape == NULL) { + continue; + } - char szSFN[MAX_PATH]; - _makepath(szSFN, szDrive, szDir, pShape->Name(), ".n3shape"); - pShape->SaveToFile(szSFN); // Shape 정보 binary file로 저장.. + fs::path fsShapeFile = fsFile.parent_path() / (pShape->m_szName + ".n3shape"); + pShape->SaveToFile(fsShapeFile); // Shape 정보 binary file로 저장.. - fprintf(stream, "%s\n", pShape->Name()); // 텍스트에 Shape 파일 이름을 쓴다.. + fprintf(stream, "%s\n", pShape->m_szName); // 텍스트에 Shape 파일 이름을 쓴다.. } fclose(stream); // OldData ////////////////////////////////// -*/ + */ if (m_pSceneOutput == NULL) { return; } - FILE * stream = fopen(lpszFileName, "w"); + FILE * stream = _wfopen(fsFile.c_str(), L"w"); if (stream == NULL) { m_pMainFrm->MessageBox("파일을 만들수 없습니다."); return; } - // 폴더 이름을 분리하고.. - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszFileName, szDrive, szDir, szFName, szExt); // 파일 이름과 확장자만 갖고.. - int iSC = m_pSceneOutput->ShapeCount(); fprintf(stream, "Shape Post Count : %d\n", iSC); - char szSFN[MAX_PATH] = ""; + std::string szSFN; for (int i = 0; i < iSC; ++i) { CN3Shape * pShape = m_pSceneOutput->ShapeGet(i); - _splitpath(pShape->FileName().c_str(), NULL, NULL, szFName, szExt); // 파일 이름과 확장자만 갖고.. - _makepath(szSFN, NULL, NULL, szFName, szExt); // 파일 이름을 다시 만든다. + szSFN = pShape->FilePath().filename().string(); __Vector3 vPos = pShape->Pos(); __Vector3 vScale = pShape->Scale(); @@ -2168,8 +2066,9 @@ void CMapMng::SaveObjectPostData(LPCTSTR lpszFileName) { fprintf(stream, "FileName[ %s ] PartCount[ %d ] Position[ %f %f %f] Rotation[ %f %f %f %f ] Scale[ %f %f %f ] Belong [ " "%d ] Attribute [ %d %d %d %d ]\n", - szSFN, iSPC, vPos.x, vPos.y, vPos.z, qtRot.x, qtRot.y, qtRot.z, qtRot.w, vScale.x, vScale.y, vScale.z, - pShape->m_iBelong, pShape->m_iEventID, pShape->m_iEventType, pShape->m_iNPC_ID, pShape->m_iNPC_Status); + szSFN.c_str(), iSPC, vPos.x, vPos.y, vPos.z, qtRot.x, qtRot.y, qtRot.z, qtRot.w, vScale.x, vScale.y, + vScale.z, pShape->m_iBelong, pShape->m_iEventID, pShape->m_iEventType, pShape->m_iNPC_ID, + pShape->m_iNPC_Status); for (int j = 0; j < iSPC; j++) { CN3SPart * pPart = pShape->Part(j); fprintf(stream, "\tPart - DiffuseARGB[ %f %f %f %f ] AmbientARGB[ %f %f %f %f ]\n", pPart->m_Mtl.Diffuse.a, @@ -2181,21 +2080,17 @@ void CMapMng::SaveObjectPostData(LPCTSTR lpszFileName) { fclose(stream); } -void CMapMng::SaveObjectPostDataPartition(LPCTSTR lpszFileName, float psx, float psz, float width) { +void CMapMng::SaveObjectPostDataPartition(const fs::path & fsFile, float psx, float psz, float width) { if (m_pSceneOutput == NULL) { return; } - FILE * stream = fopen(lpszFileName, "w"); + FILE * stream = _wfopen(fsFile.c_str(), L"w"); if (stream == NULL) { m_pMainFrm->MessageBox("파일을 만들수 없습니다."); return; } - // 폴더 이름을 분리하고.. - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszFileName, szDrive, szDir, szFName, szExt); // 파일 이름과 확장자만 갖고.. - float sx = (int)(psx / TERRAIN_CELL_SIZE) * TERRAIN_CELL_SIZE; float sz = (int)(psz / TERRAIN_CELL_SIZE) * TERRAIN_CELL_SIZE; float ex = sx + width; @@ -2220,25 +2115,20 @@ void CMapMng::SaveObjectPostDataPartition(LPCTSTR lpszFileName, float psx, float continue; } - ShapeList.push_back(i); + ShapeList.emplace_back(i); } int RealCount = ShapeList.size(); fprintf(stream, "Shape Post Count : %d\n", RealCount); - char szSFN[MAX_PATH] = ""; - - std::list::iterator it, ite; - ite = ShapeList.end(); - ProgressBar.Create("Pick out Objects.", 50, RealCount); - for (it = ShapeList.begin(); it != ite; it++) { + std::string szSFN; + for (auto it = ShapeList.begin(); it != ShapeList.end(); it++) { ProgressBar.StepIt(); int idx = (*it); CN3Shape * pShape = m_pSceneOutput->ShapeGet(idx); - _splitpath(pShape->FileName().c_str(), NULL, NULL, szFName, szExt); // 파일 이름과 확장자만 갖고.. - _makepath(szSFN, NULL, NULL, szFName, szExt); // 파일 이름을 다시 만든다. + szSFN = pShape->FilePath().filename().string(); __Vector3 vPos = pShape->Pos(); vPos.x -= sx; @@ -2250,8 +2140,9 @@ void CMapMng::SaveObjectPostDataPartition(LPCTSTR lpszFileName, float psx, float fprintf(stream, "FileName[ %s ] PartCount[ %d ] Position[ %f %f %f] Rotation[ %f %f %f %f ] Scale[ %f %f %f ] Belong [ " "%d ] Attribute [ %d %d %d %d ]\n", - szSFN, iSPC, vPos.x, vPos.y, vPos.z, qtRot.x, qtRot.y, qtRot.z, qtRot.w, vScale.x, vScale.y, vScale.z, - pShape->m_iBelong, pShape->m_iEventID, pShape->m_iEventType, pShape->m_iNPC_ID, pShape->m_iNPC_Status); + szSFN.c_str(), iSPC, vPos.x, vPos.y, vPos.z, qtRot.x, qtRot.y, qtRot.z, qtRot.w, vScale.x, vScale.y, + vScale.z, pShape->m_iBelong, pShape->m_iEventID, pShape->m_iEventType, pShape->m_iNPC_ID, + pShape->m_iNPC_Status); for (int j = 0; j < iSPC; j++) { CN3SPart * pPart = pShape->Part(j); fprintf(stream, "\tPart - DiffuseARGB[ %f %f %f %f ] AmbientARGB[ %f %f %f %f ]\n", pPart->m_Mtl.Diffuse.a, @@ -2263,7 +2154,7 @@ void CMapMng::SaveObjectPostDataPartition(LPCTSTR lpszFileName, float psx, float fclose(stream); } -void CMapMng::LoadObjectPostData(LPCTSTR lpszFileName) { +void CMapMng::LoadObjectPostData(const fs::path & fsFile) { if (m_pSceneOutput == NULL) { return; } @@ -2272,16 +2163,12 @@ void CMapMng::LoadObjectPostData(LPCTSTR lpszFileName) { m_pSceneOutput->ShapeRelease(); m_pSceneOutput->ChrRelease(); - FILE * stream = fopen(lpszFileName, "r"); + FILE * stream = _wfopen(fsFile.c_str(), L"r"); if (stream == NULL) { m_pMainFrm->MessageBox("지정한 텍스트 파일을 찾을 수 없습니다."); return; } - // 폴더 이름을 분리하고.. - char szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFName[_MAX_FNAME], szExt[_MAX_EXT]; - _splitpath(lpszFileName, szDrive, szDir, szFName, szExt); - char szFirstLine[256]; fgets(szFirstLine, 256, stream); // 첫째 줄을 읽고.. if (strstr(szFirstLine, "Shape Count : ")) // 문자열이 있으면 예전 데이터이다.. @@ -2289,36 +2176,32 @@ void CMapMng::LoadObjectPostData(LPCTSTR lpszFileName) { int iSC = 0, result = 0; sscanf(szFirstLine, "Shape Count : %d\n", &iSC); for (int i = 0; i < iSC; ++i) { - char szDestName[_MAX_PATH]; + char szDestName[_MAX_PATH]{}; result = fscanf(stream, "%s\n", szDestName); // 파일 이름을 읽고.. if (result == EOF) { break; } - char szSFN[MAX_PATH]; - _makepath(szSFN, szDrive, szDir, szDestName, ".n3shape"); - CN3Shape * pShape = new CN3Shape; - if (false == pShape->LoadFromFile(szSFN)) { + fs::path fsShapeFile = (fsFile.parent_path() / szDestName).replace_extension(".n3shape"); + if (!pShape->LoadFromFile(fsShapeFile)) { delete pShape; pShape = NULL; continue; // Shape 정보 binary file로 읽기.. } - szDestName[lstrlen(szDestName) - 5] = NULL; // _0000 문자열을 뺀다.. - _makepath(szSFN, NULL, NULL, szDestName, ".n3shape"); + szDestName[lstrlen(szDestName) - 5] = '\0'; // Remove the _0000 suffix. pShape->m_szName = szDestName; - pShape->FileNameSet(std::string(szSFN)); // 다시 파일 이름 설정.. + pShape->FilePathSet(pShape->m_szName + ".n3shape"); // 다시 파일 이름 설정.. m_pSceneOutput->ShapeAdd(pShape); } - } else // 새로 만든 데이터이다.. - { + } else { // 새로 만든 데이터이다.. int iSC = 0; sscanf(szFirstLine, "Shape Post Count : %d\n", &iSC); - char szSFN[MAX_PATH] = "", szSFN2[MAX_PATH] = ""; - char szLine[1024] = ""; + char szSFN[MAX_PATH]{}; + char szLine[1024]{}; for (int i = 0; i < iSC; ++i) { CN3Shape * pShape = new CN3Shape(); m_pSceneOutput->ShapeAdd(pShape); // 추가.. @@ -2336,9 +2219,7 @@ void CMapMng::LoadObjectPostData(LPCTSTR lpszFileName) { szSFN, &iSPC, &(vPos.x), &(vPos.y), &(vPos.z), &(qtRot.x), &(qtRot.y), &(qtRot.z), &(qtRot.w), &(vScale.x), &(vScale.y), &(vScale.z), &(iBelong), &(iEventID), &(iEventType), &(iNPC_ID), &(iNPC_Status)); - // 텍스트에 Shape 파일 이름을 쓴다.. - wsprintf(szSFN2, "Object\\%s", szSFN); - pShape->LoadFromFile(szSFN2); // 파일에서 읽고.. + pShape->LoadFromFile("Object" / fs::path(szSFN)); // 파일에서 읽고.. for (int j = 0; j < iSPC; j++) { fgets(szLine, 1024, stream); @@ -2390,8 +2271,8 @@ void CMapMng::UpdateAll() { } } -void CMapMng::ImportPostDataFromScene(const char * szFileName) { - HANDLE hFile = CreateFile(szFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +void CMapMng::ImportPostDataFromScene(const fs::path & fsFile) { + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { return; } @@ -2405,58 +2286,52 @@ void CMapMng::ImportPostDataFromScene(const char * szFileName) { ReadFile(hFile, &fFrmStart, 4, &dwRWC, NULL); // 전체 프레임. ReadFile(hFile, &fFrmEnd, 4, &dwRWC, NULL); // 전체 프레임. - int nL = 0; - char szName[512] = ""; + int iLen = 0; + std::string szFile; int nCC = 0; ReadFile(hFile, &nCC, 4, &dwRWC, NULL); // 카메라.. for (int i = 0; i < nCC; i++) { - ReadFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL <= 0) { - continue; + iLen = 0; + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + szFile.assign(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); } - - ReadFile(hFile, szName, nL, &dwRWC, NULL); - szName[nL] = NULL; } int nLC = 0; ReadFile(hFile, &nLC, 4, &dwRWC, NULL); // 카메라.. for (int i = 0; i < nLC; i++) { - ReadFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL <= 0) { - continue; + iLen = 0; + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + szFile.assign(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); } - - ReadFile(hFile, szName, nL, &dwRWC, NULL); - szName[nL] = NULL; } int nSC = 0; ReadFile(hFile, &nSC, 4, &dwRWC, NULL); // Shapes.. for (int i = 0; i < nSC; i++) { - ReadFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL <= 0) { - continue; + iLen = 0; + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + szFile.assign(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); + AddShape(m_pSceneOutput, szFile, TRUE); } - - ReadFile(hFile, szName, nL, &dwRWC, NULL); - szName[nL] = NULL; - - // Import... - this->AddShape(m_pSceneOutput, std::string(szName), TRUE); } int nChrC = 0; ReadFile(hFile, &nChrC, 4, &dwRWC, NULL); // 캐릭터 for (int i = 0; i < nChrC; i++) { - ReadFile(hFile, &nL, 4, &dwRWC, NULL); - if (nL <= 0) { - continue; + iLen = 0; + ReadFile(hFile, &iLen, 4, &dwRWC, NULL); + if (iLen > 0) { + szFile.assign(iLen, '\0'); + ReadFile(hFile, szFile.data(), iLen, &dwRWC, NULL); } - - ReadFile(hFile, szName, nL, &dwRWC, NULL); - szName[nL] = NULL; } m_pDlgOutputList->UpdateTree(m_pSceneOutput); // 트리 업데이트... @@ -2464,146 +2339,87 @@ void CMapMng::ImportPostDataFromScene(const char * szFileName) { CloseHandle(hFile); } -void CMapMng::ImportShape(const char * szFullPath) { +void CMapMng::ImportShape(const fs::path & fsFile) { // Import... - this->AddShape(m_pSceneOutput, szFullPath, FALSE); + this->AddShape(m_pSceneOutput, fsFile, FALSE); } void CMapMng::DeleteUnusedFiles() { - typedef std::map mapBase; - typedef mapBase::value_type valBase; - typedef mapBase::iterator it_Base; - - std::vector invalidFNs; - std::vector unusedFNs; - std::string szFN; - - // 일단 몽땅 다 맵에 넣는다.. - mapBase mBases; - int iSC = m_pSceneOutput->ShapeCount(); - - CN3Shape * pShape = NULL; - CN3VMesh * pVMesh = NULL; - CN3SPart * pPart = NULL; - CN3PMesh * pPMesh = NULL; - CN3Texture * pTex = NULL; + std::map mBases; + std::vector vUnusedFiles; + std::vector vErroredFiles; + + int iSC = m_pSceneOutput->ShapeCount(); for (int i = 0; i < iSC; i++) { - pShape = m_pSceneOutput->ShapeGet(i); + CN3Shape * pShape = m_pSceneOutput->ShapeGet(i); if (NULL == pShape) { continue; } - szFN = CN3Base::PathGet() + pShape->FileName(); - CharLower(&(szFN[0])); - mBases.insert(valBase(szFN, pShape)); + mBases.emplace(pShape->FilePathAbs(), pShape); - pVMesh = pShape->CollisionMesh(); + CN3VMesh * pVMesh = pShape->CollisionMesh(); if (pVMesh) { - szFN = CN3Base::PathGet() + pVMesh->FileName(); - CharLower(&(szFN[0])); - mBases.insert(valBase(szFN, pVMesh)); + mBases.emplace(pVMesh->FilePathAbs(), pVMesh); } else { - invalidFNs.push_back("NULL VMesh : " + pShape->FileName()); + vErroredFiles.emplace_back(std::format(L"NULL VMesh : {:s}", pShape->FilePath().c_str())); } int iSPC = pShape->PartCount(); for (int j = 0; j < iSPC; j++) { - pPart = pShape->Part(j); + CN3SPart * pPart = pShape->Part(j); if (NULL == pPart) { - CString szErr; - szErr.Format("NULL Part : %s - %d번째 Part", pShape->FileName().c_str(), j); - invalidFNs.push_back(szErr.operator LPCTSTR()); + vErroredFiles.emplace_back( + std::format(L"NULL Part : {:s} - {:d}th Part", pShape->FilePath().c_str(), j)); continue; } - pPMesh = pPart->Mesh(); + CN3PMesh * pPMesh = pPart->Mesh(); if (pPMesh) { - szFN = CN3Base::PathGet() + pPMesh->FileName(); - CharLower(&(szFN[0])); - mBases.insert(valBase(szFN, pPMesh)); + mBases.emplace(pPMesh->FilePathAbs(), pPMesh); } else { - CString szErr; - szErr.Format("NULL PMesh : %s - %d번째 Part", pShape->FileName().c_str(), j); - invalidFNs.push_back(szErr.operator LPCTSTR()); + vErroredFiles.emplace_back( + std::format(L"NULL Part : {:s} - {:d}th Part", pShape->FilePath().c_str(), j)); } int iSTC = pPart->TexCount(); for (int k = 0; k < iSTC; k++) { - pTex = pPart->Tex(k); + CN3Texture * pTex = pPart->Tex(k); if (pTex) { - szFN = CN3Base::PathGet() + pTex->FileName(); - CharLower(&(szFN[0])); - mBases.insert(valBase(szFN, pTex)); + mBases.emplace(pTex->FilePathAbs(), pTex); } else { - CString szErr; - szErr.Format("NULL Texture : %s - %d번째 Part, %d번째 Texture", pShape->FileName().c_str(), j, k); - invalidFNs.push_back(szErr.operator LPCTSTR()); + vErroredFiles.emplace_back(std::format(L"NULL Texture : {:s} - {:d}th Part, {:d}th Texture", + pShape->FilePath().c_str(), j, k)); continue; } } } } - // 파일을 찾고.. - std::string szPath = CN3Base::PathGet() + "object\\"; - ::SetCurrentDirectory(szPath.c_str()); - CFileFind ff; - - BOOL bFind; - CString szFNTmp; - CString szFNTmp2; - - for (ff.FindFile(); bFind = ff.FindNextFile();) { - szFNTmp = ff.GetFilePath(); - szFNTmp2 = ff.GetFileName(); - - if (szFNTmp2 == "." || szFNTmp2 == "..") { - continue; - } - - szFNTmp.MakeLower(); - - szFN = szFNTmp; - it_Base it = mBases.find(szFN); - if (it != mBases.end()) { - continue; // 찾았으면 쓴거다.. - } - - unusedFNs.push_back(szFN); - } - - if (!bFind) { - szFNTmp = ff.GetFilePath(); - szFNTmp2 = ff.GetFileName(); - - szFNTmp.MakeLower(); + fs::path fsObjectDir = CN3Base::PathGet() / "Object"; + if (fs::is_directory(fsObjectDir)) { + for (const auto & fi : fs::directory_iterator(fsObjectDir)) { + if (!fi.is_regular_file()) { + continue; + } - szFN = szFNTmp; - it_Base it = mBases.find(szFN); - if (it == mBases.end()) { - unusedFNs.push_back(szFN); + fs::path fsFindFile = fi.path(); + fsFindFile.make_lower(); + if (mBases.contains(fsFindFile)) { + vUnusedFiles.emplace_back(fsFindFile); + } } } - // 파일 지우기 대화상자 띄우기.. CDlgUnusedFiles dlg; - int iUFC = unusedFNs.size(); - for (int i = 0; i < iUFC; i++) { - dlg.m_FileNames.Add(unusedFNs[i].c_str()); - } - - int iIFC = invalidFNs.size(); - for (int i = 0; i < iIFC; i++) { - dlg.m_InvalidFileNames.Add(invalidFNs[i].c_str()); - } - + dlg.m_vFiles = vUnusedFiles; + dlg.m_vErroredFiles = vErroredFiles; dlg.DoModal(); - // 모두 업데이트.. m_pSelSourceObj = NULL; // 이렇게 해주어야 뻑이 안난다. m_SelOutputObjArray.RemoveAll(); - this->LoadSourceObjects(); // Source Object 를 다시 읽고.. - this->UpdateAll(); // 몽땅 업데이트... + this->LoadSourceObjects(); + this->UpdateAll(); } void CMapMng::DeleteOverlappedObjects() // 위치가 겹친 젝트를 찾는다. @@ -2622,7 +2438,7 @@ void CMapMng::DeleteOverlappedObjects() // 위치가 겹친 젝트를 찾는다. for (int j = i + 1; j < iSC; j++) { pObj2 = m_pSceneOutput->ShapeGet(j); if (pObj1->Pos() == pObj2->Pos() || (pObj1->Pos() - pObj2->Pos()).Magnitude() < 0.3f) { - OverlappedObjects.push_back(pObj1); + OverlappedObjects.emplace_back(pObj1); break; } } @@ -2655,8 +2471,8 @@ void CMapMng::DeleteSelectedSourceObjects() { CN3Shape * pObj; for (int i = 0; i < iSC; i++) { pObj = m_pSceneOutput->ShapeGet(i); - if (pObj->FileName() == m_pSelSourceObj->FileName()) { - SameObjects.push_back(pObj); + if (pObj->FilePath() == m_pSelSourceObj->FilePath()) { + SameObjects.emplace_back(pObj); } } diff --git a/src/tool/N3ME/MapMng.h b/src/tool/N3ME/MapMng.h index f09f9297..8316109c 100644 --- a/src/tool/N3ME/MapMng.h +++ b/src/tool/N3ME/MapMng.h @@ -155,21 +155,21 @@ class CMapMng : public CN3Base { m_pTerrain->m_iZoneID = id; } } //지형 존 아이디 셋팅. - void ImportShape(const char * szFullPath); + void ImportShape(const fs::path & fsFile); void MakeTerrainMovableAttr(CN3ShapeMgr * pShapeMgr); //지형에서 갈수 있는 타일과 갈 수 없는 타일을 정리해라.. - void ImportPostDataFromScene(const char * szFileName); // Scene 에서 오브젝트 배치된걸 불러온다.. + void ImportPostDataFromScene(const fs::path & fsFile); // Scene 에서 오브젝트 배치된걸 불러온다.. void UpDateFP(); void Tick(); void Render(); void Release(); void SavePartition(float x, float z, float width); - void SaveToFile(LPCTSTR lpszPathName); // Map 파일 저장 - void LoadFromFile(LPCTSTR lpszPathName); // Map 파일 불러오기 - BOOL MouseMsgFilter(LPMSG pMsg); // 마우스의 기능 - void ImportTerrain(const char * szMeshFN); // VMesh 파일에서 지형 데이터 읽어오기 - void ImportTerrainHeight(const char * szMeshFN); // VMesh 파일에서 지형의 높이값만 읽어오기.. - void MakeGameFiles(LPCTSTR lpszPathName, float fSize = 128.0f); // 게임 데이터로 변환하기 - void MakeServerDataFiles(LPCTSTR lpszPathName); + void SaveToFile(const fs::path & fsFile); // Map 파일 저장 + void LoadFromFile(const fs::path & fsFile); // Map 파일 불러오기 + BOOL MouseMsgFilter(LPMSG pMsg); // 마우스의 기능 + void ImportTerrain(const fs::path & fsVmeshFile); // VMesh 파일에서 지형 데이터 읽어오기 + void ImportTerrainHeight(const fs::path & fsVmeshFile); // VMesh 파일에서 지형의 높이값만 읽어오기.. + void MakeGameFiles(const fs::path & fsFile, float fSize = 128.0f); // 게임 데이터로 변환하기 + void MakeServerDataFiles(const fs::path & fsFile); void SelectObject(CN3Base * pObj, BOOL IsSourceObj, BOOL bAdd = FALSE); // 객체를 선택한다. void RenderObjectToWindow(CN3TransformCollision * pObj, HWND hWnd); // 특정 윈도우에 Object를 그려준다. void SetCursorMode(int iMode); // 마우스커서의 이용방법을 바꾼다. @@ -183,16 +183,16 @@ class CMapMng : public CN3Base { void RenderDragRect(RECT * rc); // 드래그 영역을 그린다. void UpdateAll(); // source 와 output dialog를 update시킨다. - void LoadObjectPostData(LPCTSTR lpszFileName); // Shape 배치정보를 text파일에서 읽어온다. - void SaveObjectPostData(LPCTSTR lpszFileName); // Shape 배치정보를 text파일로 저장한다. - void SaveObjectPostDataPartition(LPCTSTR lpszFileName, float psx, float psz, float width); + void LoadObjectPostData(const fs::path & fsFile); // Shape 배치정보를 text파일에서 읽어온다. + void SaveObjectPostData(const fs::path & fsFile); // Shape 배치정보를 text파일로 저장한다. + void SaveObjectPostDataPartition(const fs::path & fsFile, float psx, float psz, float width); void RenderGrid(float fGridSize, float fMaxDistance); // 맵에 일정간격으로Grid를 그려준다 void OnSelChanged(); // 선택한 객체가 바뀌었을때 해줄것들 void SelectObjectByDragRect(RECT * pRect, BOOL bAdd); // 드래그 해서 객체 선택하기 void LoadSourceObjects(); // Folder 에서 Source Object 를 읽어온다. - CN3Transform * AddChr(CN3Scene * pDestScene, const std::string & szFN, + CN3Transform * AddChr(CN3Scene * pDestScene, const fs::path & fsFile, BOOL bGenerateChainNumber); // 특정Scene에 캐릭터 객체를 복사해 추가 - CN3Transform * AddShape(CN3Scene * pDestScene, const std::string & szFN, + CN3Transform * AddShape(CN3Scene * pDestScene, const fs::path & fsFile, BOOL bGenerateChainNumber); // 특정Scene에 Shape 객체를 복사해 추가 CN3Transform * AddObjectToOutputScene( CN3Transform * pObj); // 소스목록에서 선택한 Object를 넣으면 OutputScene으로 복사해서 넣어준다. diff --git a/src/tool/N3ME/N3MEDoc.cpp b/src/tool/N3ME/N3MEDoc.cpp index 46f75584..c9079c4c 100644 --- a/src/tool/N3ME/N3MEDoc.cpp +++ b/src/tool/N3ME/N3MEDoc.cpp @@ -122,11 +122,12 @@ void CN3MEDoc::OnFileImportPostDataFromScene() { if (dlg.DoModal() == IDCANCEL) { return; } + fs::path fsFile = dlg.GetPathName().GetString(); CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); if (pFrm && pFrm->GetMapMng()) { CMapMng * pMapMng = pFrm->GetMapMng(); - pMapMng->ImportPostDataFromScene(dlg.GetPathName()); + pMapMng->ImportPostDataFromScene(fsFile); } } @@ -151,10 +152,9 @@ void CN3MEDoc::OnFileImportShapes() { } POSITION pos = dlg.GetStartPosition(); - CString szPath; while (pos != NULL) { - szPath = dlg.GetNextPathName(pos); - pMapMng->ImportShape(szPath); + fs::path fsFile = dlg.GetNextPathName(pos).GetString(); + pMapMng->ImportShape(fsFile); } pMapMng->UpdateAll(); diff --git a/src/tool/N3ME/NPCPathMgr.cpp b/src/tool/N3ME/NPCPathMgr.cpp index 67eb6ced..b39d439a 100644 --- a/src/tool/N3ME/NPCPathMgr.cpp +++ b/src/tool/N3ME/NPCPathMgr.cpp @@ -108,7 +108,7 @@ CNPCPathMgr::~CNPCPathMgr() { // // FileName은 경로명 하나도 안들어간 순수한 파일이름과 확장자.. // -void CNPCPathMgr::LoadFromFile(const char * FileName) { +void CNPCPathMgr::LoadFromFile(const fs::path & fsFileStem) { if (m_pCurrPath) { delete m_pCurrPath; m_pCurrPath = NULL; @@ -120,11 +120,10 @@ void CNPCPathMgr::LoadFromFile(const char * FileName) { delete (*itPath); } - char szNPCPathFileName[_MAX_PATH]; - wsprintf(szNPCPathFileName, "%snpcpath\\%s.npi", CN3Base::PathGet().c_str(), FileName); + fs::path fsFile = CN3Base::PathGet() / "npcpath" / (fsFileStem + ".npi"); + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - DWORD dwRWC; - HANDLE hFile = CreateFile(szNPCPathFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + DWORD dwRWC; int NumPath; ReadFile(hFile, &NumPath, sizeof(int), &dwRWC, NULL); @@ -139,19 +138,17 @@ void CNPCPathMgr::LoadFromFile(const char * FileName) { CloseHandle(hFile); } -void CNPCPathMgr::SaveToFile(const char * FileName) { - char szOldPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szOldPath); - SetCurrentDirectory(CN3Base::PathGet().c_str()); +void CNPCPathMgr::SaveToFile(const fs::path & fsFileStem) { + fs::path fsCurDirPrev = fs::current_path(); + fs::current_path(CN3Base::PathGet()); + fs::path fsDir("npcpath"); + fs::create_directory(fsDir); - CreateDirectory("npcpath", NULL); // 경로 만들고.. - char szNPCPathFileName[_MAX_PATH]; - wsprintf(szNPCPathFileName, "%snpcpath\\%s.npi", CN3Base::PathGet().c_str(), FileName); + fs::path fsFile = CN3Base::PathGet() / fsDir / (fsFileStem + ".npi"); + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - DWORD dwRWC; - HANDLE hFile = CreateFile(szNPCPathFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - int NumPath = m_pPaths.size(); + DWORD dwRWC; + int NumPath = m_pPaths.size(); WriteFile(hFile, &NumPath, sizeof(int), &dwRWC, NULL); std::list::iterator itPath; @@ -162,12 +159,12 @@ void CNPCPathMgr::SaveToFile(const char * FileName) { pPath->Save(hFile); } CloseHandle(hFile); - SetCurrentDirectory(szOldPath); + fs::current_path(fsCurDirPrev); } -void CNPCPathMgr::MakeServerDataFile(const char * FullFileName) { +void CNPCPathMgr::MakeServerDataFile(const fs::path & fsFile) { // text 파일 버전... - FILE * stream = fopen(FullFileName, "w"); + FILE * stream = _wfopen(fsFile.c_str(), L"w"); if (!stream) { return; } diff --git a/src/tool/N3ME/NPCPathMgr.h b/src/tool/N3ME/NPCPathMgr.h index 94b332ab..68fea3a8 100644 --- a/src/tool/N3ME/NPCPathMgr.h +++ b/src/tool/N3ME/NPCPathMgr.h @@ -52,9 +52,9 @@ class CNPCPathMgr : public CN3Base { void DelPath(CNPCPath * pPath); int GetSize() { return m_pPaths.size(); } CNPCPath * GetpPath(int idx); - void LoadFromFile(const char * FileName); - void SaveToFile(const char * FileName); - void MakeServerDataFile(const char * FullFileName); + void LoadFromFile(const fs::path & fsFileStem); + void SaveToFile(const fs::path & fsFileStem); + void MakeServerDataFile(const fs::path & fsFile); void Render(); void UpdatePath(); diff --git a/src/tool/N3ME/PondMesh.cpp b/src/tool/N3ME/PondMesh.cpp index 218ad9d8..7f9d8e62 100644 --- a/src/tool/N3ME/PondMesh.cpp +++ b/src/tool/N3ME/PondMesh.cpp @@ -362,14 +362,14 @@ void CPondMesh::MakePondPos() { ReCalcUV(); } -BOOL CPondMesh::SetTextureName(LPCTSTR pszFName) { +BOOL CPondMesh::SetTextureName(const fs::path & fsFile) { if (m_pTexture) { - if (lstrcmpi(pszFName, m_pTexture->FileName().c_str()) == 0) { + if (n3std::iequals(fsFile, m_pTexture->FilePath())) { return TRUE; } s_MngTex.Delete(&m_pTexture); } - m_pTexture = s_MngTex.Get(pszFName, TRUE); + m_pTexture = s_MngTex.Get(fsFile, TRUE); return m_pTexture ? TRUE : FALSE; } @@ -769,9 +769,7 @@ __Vector3 CPondMesh::GetCenter() { bool CPondMesh::Load1001(HANDLE hFile) { Release(); - DWORD dwNum; - int iLen; - char szTextueFName[_MAX_PATH]; + DWORD dwNum = 0; ReadFile(hFile, &m_iPondID, sizeof(m_iPondID), &dwNum, NULL); // 연못 번호 ReadFile(hFile, &m_dwPondAlpha, sizeof(m_dwPondAlpha), &dwNum, NULL); // 연못 알파 @@ -793,11 +791,12 @@ bool CPondMesh::Load1001(HANDLE hFile) { } ReadFile(hFile, &m_iIC, sizeof(m_iIC), &dwNum, NULL); // IndexBuffer Count. - ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // texture file name length + int iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); if (iLen > 0) { - ReadFile(hFile, szTextueFName, iLen, &dwNum, NULL); // texture name - szTextueFName[iLen] = NULL; - m_pTexture = s_MngTex.Get(szTextueFName, TRUE); // load texture + std::string szTexFile(iLen, '\0'); + ReadFile(hFile, szTexFile.data(), iLen, &dwNum, NULL); + m_pTexture = s_MngTex.Get(szTexFile, TRUE); } MakeIndex(); // 인덱스를 다시 계산 @@ -811,16 +810,15 @@ bool CPondMesh::Load1001(HANDLE hFile) { bool CPondMesh::Load1000(HANDLE hFile) { Release(); - DWORD dwNum; - int iLen; - char szTextueFName[_MAX_PATH]; - float fScaleTemp; + + DWORD dwNum = 0; ReadFile(hFile, &m_iPondID, sizeof(m_iPondID), &dwNum, NULL); // 연못 번호 ReadFile(hFile, &m_dwPondAlpha, sizeof(m_dwPondAlpha), &dwNum, NULL); // 연못 알파 ReadFile(hFile, &m_iWaterScaleWidth, sizeof(m_iWaterScaleWidth), &dwNum, NULL); // 한줄에 있는 점 갯수 + float fScaleTemp; ReadFile(hFile, &fScaleTemp, sizeof(fScaleTemp), &dwNum, NULL); ReadFile(hFile, &fScaleTemp, sizeof(fScaleTemp), &dwNum, NULL); @@ -829,11 +827,13 @@ bool CPondMesh::Load1000(HANDLE hFile) { ReadFile(hFile, m_pVertices, m_iVC * sizeof(__Vector3), &dwNum, NULL); // vertex buffer } ReadFile(hFile, &m_iIC, sizeof(m_iIC), &dwNum, NULL); // IndexBufferCount. - ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // texture name length + + int iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); if (iLen > 0) { - ReadFile(hFile, szTextueFName, iLen, &dwNum, NULL); // texture name - szTextueFName[iLen] = NULL; - m_pTexture = s_MngTex.Get(szTextueFName, TRUE); // load texture + std::string szTexFile(iLen, '\0'); + ReadFile(hFile, szTexFile.data(), iLen, &dwNum, NULL); + m_pTexture = s_MngTex.Get(szTexFile, TRUE); } // --------------------------------------------------------------------------------------------------------- @@ -878,10 +878,8 @@ bool CPondMesh::Load1000(HANDLE hFile) { bool CPondMesh::Load(HANDLE hFile) { Release(); - DWORD dwNum; - int iLen; - char szTextueFName[_MAX_PATH]; - float fScaleTemp; + + DWORD dwNum = 0; ReadFile(hFile, &m_iPondID, sizeof(m_iPondID), &dwNum, NULL); // 연못 번호 @@ -889,6 +887,7 @@ bool CPondMesh::Load(HANDLE hFile) { ReadFile(hFile, &m_iWaterScaleWidth, sizeof(int), &dwNum, NULL); // 한줄에 있는 점 갯수 + float fScaleTemp; ReadFile(hFile, &fScaleTemp, sizeof(fScaleTemp), &dwNum, NULL); ReadFile(hFile, &fScaleTemp, sizeof(fScaleTemp), &dwNum, NULL); @@ -898,11 +897,13 @@ bool CPondMesh::Load(HANDLE hFile) { ReInputBackPos(); // 백업용에 새로좌표입력 } ReadFile(hFile, &m_iIC, sizeof(m_iIC), &dwNum, NULL); // IndexBufferCount. - ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // texture name length + + int iLen = 0; + ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); if (iLen > 0) { - ReadFile(hFile, szTextueFName, iLen, &dwNum, NULL); // texture name - szTextueFName[iLen] = NULL; - m_pTexture = s_MngTex.Get(szTextueFName, TRUE); // load texture + std::string szTexFile(iLen, '\0'); + ReadFile(hFile, szTexFile.data(), iLen, &dwNum, NULL); + m_pTexture = s_MngTex.Get(szTexFile, TRUE); } // --------------------------------------------------------------------------------------------------------- @@ -964,13 +965,15 @@ bool CPondMesh::Save(HANDLE hFile) { } WriteFile(hFile, &m_iIC, sizeof(m_iIC), &dwNum, NULL); // IndexBuffer Count. - int iLen = 0; + std::string szFile; + int iLen = 0; if (m_pTexture) { - iLen = m_pTexture->FileName().size(); + szFile = m_pTexture->FilePathWin().string(); + iLen = szFile.length(); } WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // texture file name length if (iLen > 0) { - WriteFile(hFile, m_pTexture->FileName().c_str(), iLen, &dwNum, NULL); // texture file name + WriteFile(hFile, szFile.c_str(), iLen, &dwNum, NULL); // texture file name } return 0; diff --git a/src/tool/N3ME/PondMesh.h b/src/tool/N3ME/PondMesh.h index 54ae92a6..2d38fcb9 100644 --- a/src/tool/N3ME/PondMesh.h +++ b/src/tool/N3ME/PondMesh.h @@ -97,7 +97,7 @@ class CPondMesh : public CN3BaseFileAccess { return m_pRectVts + iIndex; } - BOOL SetTextureName(LPCTSTR pszFName); + BOOL SetTextureName(const fs::path & fsFile); public: // 새로 추가한거나 고친거 diff --git a/src/tool/N3ME/PondMng.cpp b/src/tool/N3ME/PondMng.cpp index 5805edda..6f40b598 100644 --- a/src/tool/N3ME/PondMng.cpp +++ b/src/tool/N3ME/PondMng.cpp @@ -914,7 +914,7 @@ void CPondMng::MakeGameFiles(HANDLE hFile, float fSize) { CN3Texture * pPondTex = pRM->TexGet(); if (pPondTex) { - std::string szFile = fs::path(pPondTex->FileName()).filename().string(); + std::string szFile = pPondTex->FilePath().filename().string(); if (szFile.empty()) { WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); } else { diff --git a/src/tool/N3ME/RegenUser.cpp b/src/tool/N3ME/RegenUser.cpp index 34641f01..1c28ed26 100644 --- a/src/tool/N3ME/RegenUser.cpp +++ b/src/tool/N3ME/RegenUser.cpp @@ -291,23 +291,23 @@ void CRegenUser::DeleteSel() { m_vrSelRegion = NULL; } -void CRegenUser::LoadFromFile(LPCTSTR pFullFileName) { - FILE * stream = fopen(pFullFileName, "r"); +void CRegenUser::LoadFromFile(const fs::path & fsFile) { + FILE * stream = _wfopen(fsFile.c_str(), L"r"); if (!stream) { return; } - char szLine[512] = "", szCommand[80] = "", szBuf[4][80] = {"", "", "", ""}; - char * pResult = fgets(szLine, 512, stream); + char szLine[512]{}, szCommand[80]{}, szBuf[4][80]{}; + char * pResult = fgets(szLine, sizeof(szLine), stream); sscanf(szLine, "%s %s %s %s %s", szCommand, szBuf[0], szBuf[1], szBuf[2], szBuf[3]); - int NumRC; - if (lstrcmpi(szCommand, "") == 0) { - NumRC = atoi(szBuf[0]); - } else { + if (!n3std::iequals(szCommand, "")) { + fclose(stream); return; } + int NumRC = atoi(szBuf[0]); + ClearList(); for (int i = 0; i < NumRC; i++) { @@ -317,11 +317,8 @@ void CRegenUser::LoadFromFile(LPCTSTR pFullFileName) { if (pResult == NULL) { break; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); sscanf(szLine, "%s %s %s %s", szBuf[0], szBuf[1], szBuf[2], szBuf[3]); pVR->m_vLB.x = atof(szBuf[0]); pVR->m_vLB.y = atof(szBuf[1]); @@ -331,11 +328,8 @@ void CRegenUser::LoadFromFile(LPCTSTR pFullFileName) { if (pResult == NULL) { break; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); sscanf(szLine, "%s %s %s %s", szBuf[0], szBuf[1], szBuf[2], szBuf[3]); pVR->m_vLT.x = atof(szBuf[0]); pVR->m_vLT.y = atof(szBuf[1]); @@ -345,11 +339,8 @@ void CRegenUser::LoadFromFile(LPCTSTR pFullFileName) { if (pResult == NULL) { break; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); sscanf(szLine, "%s %s %s %s", szBuf[0], szBuf[1], szBuf[2], szBuf[3]); pVR->m_vRB.x = atof(szBuf[0]); pVR->m_vRB.y = atof(szBuf[1]); @@ -359,11 +350,8 @@ void CRegenUser::LoadFromFile(LPCTSTR pFullFileName) { if (pResult == NULL) { break; } - ZeroMemory(szCommand, 80); - ZeroMemory(szBuf[0], 80); - ZeroMemory(szBuf[1], 80); - ZeroMemory(szBuf[2], 80); - ZeroMemory(szBuf[3], 80); + memset(szCommand, 0, sizeof(szCommand)); + memset(szBuf, 0, sizeof(szBuf)); sscanf(szLine, "%s %s %s %s", szBuf[0], szBuf[1], szBuf[2], szBuf[3]); pVR->m_vRT.x = atof(szBuf[0]); pVR->m_vRT.y = atof(szBuf[1]); @@ -380,8 +368,8 @@ void CRegenUser::LoadFromFile(LPCTSTR pFullFileName) { m_vrSelRegion = NULL; } -void CRegenUser::SaveToFile(LPCTSTR pFullFileName) { - FILE * file = fopen(pFullFileName, "w"); +void CRegenUser::SaveToFile(const fs::path & fsFile) { + FILE * file = _wfopen(fsFile.c_str(), L"w"); if (!file) { return; } @@ -413,4 +401,4 @@ void CRegenUser::ClearList() { } m_vrListRegion.clear(); // m_pDlg->ClearList(); -} \ No newline at end of file +} diff --git a/src/tool/N3ME/RegenUser.h b/src/tool/N3ME/RegenUser.h index e2e78d44..a2f33258 100644 --- a/src/tool/N3ME/RegenUser.h +++ b/src/tool/N3ME/RegenUser.h @@ -40,8 +40,8 @@ class CRegenUser : public CN3Base { void ClearList(); void SaveServerData(HANDLE hFile); - void LoadFromFile(LPCTSTR pFullFileName); - void SaveToFile(LPCTSTR pFullFileName); + void LoadFromFile(const fs::path & fsFile); + void SaveToFile(const fs::path & fsFile); CRegenUser(); virtual ~CRegenUser(); diff --git a/src/tool/N3ME/RiverMesh.cpp b/src/tool/N3ME/RiverMesh.cpp index 52eefe3d..c623cefc 100644 --- a/src/tool/N3ME/RiverMesh.cpp +++ b/src/tool/N3ME/RiverMesh.cpp @@ -74,9 +74,8 @@ void CRiverMesh::ReleaseAnimTextures() { bool CRiverMesh::Load(HANDLE hFile) { Release(); - DWORD dwNum; - int iLen; - char szTextueFName[_MAX_PATH]; + + DWORD dwNum = 0; ReadFile(hFile, &m_iRiverID, sizeof(m_iRiverID), &dwNum, NULL); // 강 번호 ReadFile(hFile, &m_fSpeed1, sizeof(m_fSpeed1), &dwNum, NULL); // 유속 @@ -92,11 +91,15 @@ bool CRiverMesh::Load(HANDLE hFile) { ReadFile(hFile, m_pVertices, m_iVC * sizeof(__VertexXyzT2), &dwNum, NULL); // vertex buffer } ReadFile(hFile, &m_iIC, sizeof(m_iIC), &dwNum, NULL); // IndexBufferCount. - ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // texture name length + + int iLen = 0; + std::string szTexFile; + + ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); if (iLen > 0) { - ReadFile(hFile, szTextueFName, iLen, &dwNum, NULL); // texture name - szTextueFName[iLen] = NULL; - m_pTexture = s_MngTex.Get(szTextueFName, TRUE); // load texture + szTexFile.assign(iLen, '\0'); + ReadFile(hFile, szTexFile.data(), iLen, &dwNum, NULL); + m_pTexture = s_MngTex.Get(szTexFile, TRUE); } // Animation Texture Data @@ -110,16 +113,18 @@ bool CRiverMesh::Load(HANDLE hFile) { } for (int i = 0; i < m_iAnimTextureCount; ++i) { + iLen = 0; ReadFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // texture name length if (iLen <= 0) { m_pAnimTextures[i] = NULL; __ASSERT(0, "텍스쳐가 없다"); continue; } - ReadFile(hFile, szTextueFName, iLen, &dwNum, NULL); // texture name - szTextueFName[iLen] = NULL; - m_pAnimTextures[i] = s_MngTex.Get(szTextueFName, TRUE); // load texture + szTexFile.assign(iLen, '\0'); + ReadFile(hFile, szTexFile.data(), iLen, &dwNum, NULL); // texture name + m_pAnimTextures[i] = s_MngTex.Get(szTexFile, TRUE); // load texture } + return 0; } @@ -141,13 +146,15 @@ bool CRiverMesh::Save(HANDLE hFile) { } WriteFile(hFile, &m_iIC, sizeof(m_iIC), &dwNum, NULL); // IndexBuffer Count. - int iLen = 0; + std::string szFile; + int iLen = 0; if (m_pTexture) { - iLen = m_pTexture->FileName().size(); + szFile = m_pTexture->FilePathWin().string(); + iLen = szFile.length(); } WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // texture file name length if (iLen > 0) { - WriteFile(hFile, m_pTexture->FileName().c_str(), iLen, &dwNum, NULL); // texture file name + WriteFile(hFile, szFile.c_str(), iLen, &dwNum, NULL); // texture file name } // Animation Texture Data @@ -156,10 +163,11 @@ bool CRiverMesh::Save(HANDLE hFile) { for (int i = 0; i < m_iAnimTextureCount; ++i) { __ASSERT(m_pAnimTextures[i], "강물 텍스쳐 포인터가 NULL입니다."); - int iLen = m_pAnimTextures[i]->FileName().size(); + szFile = m_pAnimTextures[i]->FilePathWin().string(); + iLen = szFile.length(); WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); // texture name length if (iLen > 0) { - WriteFile(hFile, m_pAnimTextures[i]->FileName().c_str(), iLen, &dwNum, NULL); // texture name + WriteFile(hFile, szFile.c_str(), iLen, &dwNum, NULL); // texture name } } return 0; @@ -383,30 +391,31 @@ int CRiverMesh::DeleteVertex(int iIndex) { return m_iVC; } -BOOL CRiverMesh::SetTextureName(LPCTSTR pszFName) { +BOOL CRiverMesh::SetTextureName(const fs::path & fsFile) { if (m_pTexture) { - if (lstrcmpi(pszFName, m_pTexture->FileName().c_str()) == 0) { + if (n3std::iequals(fsFile, m_pTexture->FilePath())) { return TRUE; } s_MngTex.Delete(&m_pTexture); } - m_pTexture = s_MngTex.Get(pszFName, TRUE); + m_pTexture = s_MngTex.Get(fsFile, TRUE); return m_pTexture ? TRUE : FALSE; } -BOOL CRiverMesh::SetAnimTextureName(LPCTSTR pszFName, LPCTSTR pszExt, int iCount) { +BOOL CRiverMesh::SetAnimTextureName(const fs::path & fsFile, const fs::path & fsExt, int iCount) { ReleaseAnimTextures(); - if (lstrlen(pszFName) == 0 || iCount <= 0) { + if (fsFile.empty() || iCount <= 0) { return FALSE; } - __ASSERT(iCount < 100, "강물 에니메이션 텍스쳐가 너무 많습니다."); + __ASSERT(iCount < 100, "There are too many river animation textures."); m_iAnimTextureCount = iCount; m_pAnimTextures = new CN3Texture *[m_iAnimTextureCount]; - char szTemp[_MAX_PATH]; for (int i = 0; i < m_iAnimTextureCount; ++i) { - wsprintf(szTemp, "%s%02d%s", pszFName, i, pszExt); - m_pAnimTextures[i] = s_MngTex.Get(szTemp); + fs::path fsTexFile(fsFile); + fsTexFile += std::format("{:02}", i); + fsTexFile += fsExt; + m_pAnimTextures[i] = s_MngTex.Get(fsTexFile); } return TRUE; } @@ -481,4 +490,4 @@ __Vector3 CRiverMesh::GetCenter() { vCenter.z = m_pVertices[iCenter].z; return vCenter; -} \ No newline at end of file +} diff --git a/src/tool/N3ME/RiverMesh.h b/src/tool/N3ME/RiverMesh.h index 598bf129..d40a6a7e 100644 --- a/src/tool/N3ME/RiverMesh.h +++ b/src/tool/N3ME/RiverMesh.h @@ -85,8 +85,8 @@ class CRiverMesh : public CN3BaseFileAccess { } __Vector3 GetCenter(); - BOOL SetTextureName(LPCTSTR pszFName); - BOOL SetAnimTextureName(LPCTSTR pszFName, LPCTSTR pszExt, int iCount); + BOOL SetTextureName(const fs::path & fsFile); + BOOL SetAnimTextureName(const fs::path & fsFile, const fs::path & fsExt, int iCount); void ReCalcUV(); protected: diff --git a/src/tool/N3ME/RiverMng.cpp b/src/tool/N3ME/RiverMng.cpp index 5391274e..d8ec583e 100644 --- a/src/tool/N3ME/RiverMng.cpp +++ b/src/tool/N3ME/RiverMng.cpp @@ -657,7 +657,7 @@ void CRiverMng::MakeGameFiles(HANDLE hFile, float fSize) { CN3Texture * pRiverTex = pRM->TexGet(); if (pRiverTex) { - std::string szFile = fs::path(pRiverTex->FileName()).filename().string(); + std::string szFile = pRiverTex->FilePath().filename().string(); if (szFile.empty()) { WriteFile(hFile, &iLen, sizeof(iLen), &dwNum, NULL); } else { @@ -687,214 +687,214 @@ void CRiverMng::MakeGameFiles(HANDLE hFile, float fSize) { // 모든 강 정보 저장 (*.grm) game river main int iRiverCount = m_RiverMeshes.size(); - CLyTerrain* pTerrain = m_pMainFrm->GetMapMng()->GetTerrain(); - SIZE size = pTerrain->GetPatchNum(fSize); + CLyTerrain * pTerrain = m_pMainFrm->GetMapMng()->GetTerrain(); + SIZE size = pTerrain->GetPatchNum(fSize); - CN3River river; - __RiverInfo* RiverInfos = river.CreateRiverInfo(iRiverCount); + CN3River river; + __RiverInfo * RiverInfos = river.CreateRiverInfo(iRiverCount); river.SetMaxPatchSize(size.cx, size.cy); it_RiverMesh it = m_RiverMeshes.begin(); - for(int i = 0; i < iRiverCount; i++, it++) - { - CRiverMesh* pRM = *it; + for (int i = 0; i < iRiverCount; i++, it++) { + CRiverMesh * pRM = *it; ASSERT(pRM); - + RiverInfos[i].iRiverID = pRM->GetRiverID(); RiverInfos[i].dwAlphaFactor = pRM->GetAlphaFactor(); RiverInfos[i].fSpeed1 = pRM->GetSpeed1(); RiverInfos[i].fSpeed2 = pRM->GetSpeed2(); - CN3Texture* pTex = pRM->TexGet(); ASSERT(pTex); - if (pTex) RiverInfos[i].SetTexName(pTex->Name()); + CN3Texture * pTex = pRM->TexGet(); + ASSERT(pTex); + if (pTex) { + RiverInfos[i].SetTexName(pTex->Name()); + } // animation texture RiverInfos[i].fAnimTexFPS = pRM->GetAnimTexFPS(); int iAnimTexCount = pRM->GetAnimTexCount(); RiverInfos[i].SetAnimTexCount(iAnimTexCount); - for (int j=0; jAnimTexGet(j), ""); RiverInfos[i].SetAnimTexName(j, pRM->AnimTexGet(j)->Name()); } } river.Save(hFile); - if (iRiverCount <=0) return; + if (iRiverCount <= 0) { + return; + } // 각각의 패치 정보 저장 (*.grp) game river patch int iPatchCount = size.cx * size.cy; // 각 패치별로 정보 분류하기 - __TempPatch* TempPatches = new __TempPatch[iPatchCount]; + __TempPatch * TempPatches = new __TempPatch[iPatchCount]; it = m_RiverMeshes.begin(); - for(int i = 0; i < iRiverCount; i++, it++) - { - CRiverMesh* pRM = *it; - int iVC = pRM->VertexCount(); - for (int j=0; jGetVertex(j); - int iX = int(pVtx->x/fSize); int iZ = int(pVtx->z/fSize); - int iPatchPos = iZ*size.cx + iX; - __TempRiver* pTempRiver = TempPatches[iPatchPos].GetRiver(pRM->GetRiverID()); - if (pTempRiver == NULL) - { + for (int i = 0; i < iRiverCount; i++, it++) { + CRiverMesh * pRM = *it; + int iVC = pRM->VertexCount(); + for (int j = 0; j < iVC; ++j) { + __VertexXyzT2 * pVtx = pRM->GetVertex(j); + int iX = int(pVtx->x / fSize); + int iZ = int(pVtx->z / fSize); + int iPatchPos = iZ * size.cx + iX; + __TempRiver * pTempRiver = TempPatches[iPatchPos].GetRiver(pRM->GetRiverID()); + if (pTempRiver == NULL) { pTempRiver = new __TempRiver; pTempRiver->iRiverID = pRM->GetRiverID(); TempPatches[iPatchPos].RiverArray.Add(pTempRiver); } - __TempVertex* pTempVtx = new __TempVertex; - pTempVtx->index = j; pTempVtx->pVtx = pVtx; + __TempVertex * pTempVtx = new __TempVertex; + pTempVtx->index = j; + pTempVtx->pVtx = pVtx; pTempRiver->VtxArray.Add(pTempVtx); } } // CN3RiverPatch구조에 알맞게 넣기. - CN3RiverPatch* RiverPatches = new CN3RiverPatch[iPatchCount]; - for (int i=0; iiRiverID; int iVC = pTempRiver->VtxArray.GetSize(); Rivers[j].iVertexCount = iVC; - if (iVC<=0) continue; - __VertexRiver* pVertices; + if (iVC <= 0) { + continue; + } + __VertexRiver * pVertices; pVertices = Rivers[j].pVertices = new __VertexRiver[iVC]; - for(int k=0; kVtxArray.GetAt(k); + for (int k = 0; k < iVC; ++k) { + __TempVertex * pTempVtx = pTempRiver->VtxArray.GetAt(k); pVertices[k].index = pTempVtx->index; - pVertices[k].Set(pTempVtx->pVtx->v, pTempVtx->pVtx->tu, pTempVtx->pVtx->tv, pTempVtx->pVtx->tu2, pTempVtx->pVtx->tv2); - + pVertices[k].Set(pTempVtx->pVtx->v, pTempVtx->pVtx->tu, pTempVtx->pVtx->tv, pTempVtx->pVtx->tu2, + pTempVtx->pVtx->tv2); } } } // 메모리 할당한거 지우기 - delete [] TempPatches; + delete[] TempPatches; // RiverPatches 저장하기 - for (int i=0; iGetMapMng()->GetTerrain(); - SIZE size = pTerrain->GetPatchNum(fSize); + CLyTerrain * pTerrain = m_pMainFrm->GetMapMng()->GetTerrain(); + SIZE size = pTerrain->GetPatchNum(fSize); - CN3River river; - __RiverInfo* RiverInfos = river.CreateRiverInfo(iRiverCount); + CN3River river; + __RiverInfo * RiverInfos = river.CreateRiverInfo(iRiverCount); river.SetMaxPatchSize(size.cx, size.cy); - for (int i=0; iGetRiverID(); RiverInfos[i].dwAlphaFactor = pRM->GetAlphaFactor(); RiverInfos[i].fSpeed1 = pRM->GetSpeed1(); RiverInfos[i].fSpeed2 = pRM->GetSpeed2(); - CN3Texture* pTex = pRM->TexGet(); ASSERT(pTex); - if (pTex) RiverInfos[i].SetTexName(pTex->Name()); + CN3Texture * pTex = pRM->TexGet(); + ASSERT(pTex); + if (pTex) { + RiverInfos[i].SetTexName(pTex->Name()); + } // animation texture RiverInfos[i].fAnimTexFPS = pRM->GetAnimTexFPS(); int iAnimTexCount = pRM->GetAnimTexCount(); RiverInfos[i].SetAnimTexCount(iAnimTexCount); - for (int j=0; jAnimTexGet(j), ""); RiverInfos[i].SetAnimTexName(j, pRM->AnimTexGet(j)->Name()); } } - char szTmpFName[_MAX_FNAME]; - wsprintf(szTmpFName, "River\\%s.grm", lpszFName); - river.SaveToFile(szTmpFName); - if (iRiverCount <=0) return; + river.SaveToFile(("River" / fsFileStem).replace_extension(".grm")); + + if (iRiverCount <= 0) { + return; + } // 각각의 패치 정보 저장 (*.grp) game river patch int iPatchCount = size.cx * size.cy; // 각 패치별로 정보 분류하기 - __TempPatch* TempPatches = new __TempPatch[iPatchCount]; - - for (int i=0; iVertexCount(); - for (int j=0; jGetVertex(j); - int iX = int(pVtx->x/fSize); int iZ = int(pVtx->z/fSize); - int iPatchPos = iZ*size.cx + iX; - __TempRiver* pTempRiver = TempPatches[iPatchPos].GetRiver(pRM->GetRiverID()); - if (pTempRiver == NULL) - { + __TempPatch * TempPatches = new __TempPatch[iPatchCount]; + + for (int i = 0; i < iRiverCount; ++i) { + CRiverMesh * pRM = m_RiverMeshes.Get(i); + int iVC = pRM->VertexCount(); + for (int j = 0; j < iVC; ++j) { + __VertexXyzT2 * pVtx = pRM->GetVertex(j); + int iX = int(pVtx->x / fSize); + int iZ = int(pVtx->z / fSize); + int iPatchPos = iZ * size.cx + iX; + __TempRiver * pTempRiver = TempPatches[iPatchPos].GetRiver(pRM->GetRiverID()); + if (pTempRiver == NULL) { pTempRiver = new __TempRiver; pTempRiver->iRiverID = pRM->GetRiverID(); TempPatches[iPatchPos].RiverArray.Add(pTempRiver); } - __TempVertex* pTempVtx = new __TempVertex; - pTempVtx->index = j; pTempVtx->pVtx = pVtx; + __TempVertex * pTempVtx = new __TempVertex; + pTempVtx->index = j; + pTempVtx->pVtx = pVtx; pTempRiver->VtxArray.Add(pTempVtx); } } // CN3RiverPatch구조에 알맞게 넣기. - CN3RiverPatch* RiverPatches = new CN3RiverPatch[iPatchCount]; - for (int i=0; iiRiverID; int iVC = pTempRiver->VtxArray.GetSize(); Rivers[j].iVertexCount = iVC; - if (iVC<=0) continue; - __VertexRiver* pVertices; + if (iVC <= 0) { + continue; + } + __VertexRiver * pVertices; pVertices = Rivers[j].pVertices = new __VertexRiver[iVC]; - for(int k=0; kVtxArray.GetAt(k); + for (int k = 0; k < iVC; ++k) { + __TempVertex * pTempVtx = pTempRiver->VtxArray.GetAt(k); pVertices[k].index = pTempVtx->index; - pVertices[k].Set(pTempVtx->pVtx->v, pTempVtx->pVtx->tu, pTempVtx->pVtx->tv, pTempVtx->pVtx->tu2, pTempVtx->pVtx->tv2); - + pVertices[k].Set(pTempVtx->pVtx->v, pTempVtx->pVtx->tu, pTempVtx->pVtx->tv, pTempVtx->pVtx->tu2, + pTempVtx->pVtx->tv2); } } } // 메모리 할당한거 지우기 - delete [] TempPatches; + delete[] TempPatches; // RiverPatches 저장하기 - for (int i=0; iInvalidate(); -} \ No newline at end of file +} diff --git a/src/tool/N3ME/RiverMng2.cpp b/src/tool/N3ME/RiverMng2.cpp index 8a8a1453..dc6613e7 100644 --- a/src/tool/N3ME/RiverMng2.cpp +++ b/src/tool/N3ME/RiverMng2.cpp @@ -318,25 +318,21 @@ void CRiverMng2::SetActive(bool bActive, CLyTerrain * pTerrain) { ZeroMemory(m_ppRiver[i], sizeof(__River) * m_nMapSize); } } - // if (NULL == m_ppIsRiver) - // { - // ASSERT(m_nMapSize); - // m_ppIsRiver = new bool* [m_nMapSize]; - // for (int i=0;im_iHeightMapSize != m_nMapSize) { @@ -421,9 +417,8 @@ bool CRiverMng2::Load(HANDLE hFile) { // Map Size ReadFile(hFile, &m_nVer, sizeof(m_nVer), &dwRWC, NULL); if (m_nVer != VER_RIVER) { - char buf[80]; - sprintf(buf, "Old File Format,(Latest:%d, This:%d)", VER_RIVER, m_nVer); - MessageBox(NULL, buf, "Version", MB_OK); + std::string szErr = std::format("Old File Format,(Latest:{:d}, This:{:d})", VER_RIVER, m_nVer); + MessageBoxA(NULL, szErr.c_str(), "Version", MB_OK); return false; } ReadFile(hFile, &m_nMapSize, sizeof(m_nMapSize), &dwRWC, NULL); @@ -453,4 +448,4 @@ bool CRiverMng2::Save(HANDLE hFile) { } return true; -} \ No newline at end of file +} diff --git a/src/tool/N3ME/WallMgr.cpp b/src/tool/N3ME/WallMgr.cpp index 62638779..8b4f01ae 100644 --- a/src/tool/N3ME/WallMgr.cpp +++ b/src/tool/N3ME/WallMgr.cpp @@ -436,7 +436,8 @@ void CWallMgr::AddWall2Coll(CN3ShapeMgr * pShapeMgr) { __Vector3 v1, v2, v3; // 텍스트파일로 함 뽑아보자.. - FILE * stream = fopen("c:\\Wall_info.txt", "w"); + fs::path fsFile = fs::temp_directory_path() / "N3ME_Wall_info.txt"; + FILE * stream = _wfopen(fsFile.c_str(), L"w"); fprintf(stream, "Walls = %d\n", m_pWalls.size()); for (itWall = m_pWalls.begin(); itWall != m_pWalls.end(); itWall++) { diff --git a/src/tool/N3TexViewer/MainFrm.cpp b/src/tool/N3TexViewer/MainFrm.cpp index 76059613..f3b28746 100644 --- a/src/tool/N3TexViewer/MainFrm.cpp +++ b/src/tool/N3TexViewer/MainFrm.cpp @@ -77,7 +77,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); if (m_Eng.Init(TRUE, m_hWnd, 64, 64, 0, TRUE) == false) { return -1; @@ -180,8 +180,8 @@ void CMainFrame::OnToolConvertFilesAutomaticaly() { POSITION pos = dlg.GetStartPosition(); CString FileName; while (pos != NULL) { - fs::path fsPath(dlg.GetNextPathName(pos).GetString()); - Tex.LoadFromFile(fsPath.string()); + fs::path fsFile = dlg.GetNextPathName(pos).GetString(); + Tex.LoadFromFile(fsFile); if (Tex.Get()) { D3DFORMAT Fmt = Tex.PixelFormat(); @@ -191,8 +191,8 @@ void CMainFrame::OnToolConvertFilesAutomaticaly() { Tex.Convert(D3DFMT_DXT3); } - Tex.m_szName = fsPath.stem().string(); - Tex.SaveToFile(fsPath.replace_extension("dxt").string()); + Tex.m_szName = fsFile.stem().string(); + Tex.SaveToFile(fsFile.replace_extension("dxt")); Tex.Release(); } } @@ -217,12 +217,10 @@ void CMainFrame::OnToolConvertFilesManually() { return; } - CN3Texture Tex; - std::string szFN; - szFN = dlg.GetPathName(); - Tex.LoadFromFile(szFN); // 첨 하나 읽어보고.. + CN3Texture Tex; + Tex.LoadFromFile(dlg.GetPathName().GetString()); - CDlgFormat dlgFormat; // 포맷 정학... + CDlgFormat dlgFormat; dlgFormat.m_nWidth = Tex.Width(); dlgFormat.m_nHeight = Tex.Height(); dlgFormat.m_bMipMap = Tex.MipMapCount() > 1 ? TRUE : FALSE; @@ -231,22 +229,14 @@ void CMainFrame::OnToolConvertFilesManually() { } POSITION pos = dlg.GetStartPosition(); - CString FileName; while (pos != NULL) { - FileName = dlg.GetNextPathName(pos); - - szFN = FileName; - Tex.LoadFromFile(szFN); - + fs::path fsFile = dlg.GetNextPathName(pos).GetString(); + Tex.LoadFromFile(fsFile); if (Tex.Get()) { - char szFN2[_MAX_PATH] = "", szDrv[_MAX_DRIVE], szDir[_MAX_DIR], szFN[_MAX_FNAME], szExt[_MAX_EXT]; - ::_splitpath(FileName, szDrv, szDir, szFN, szExt); - lstrcpy(szExt, ".DXT"); - ::_makepath(szFN2, szDrv, szDir, szFN, szExt); // 파일 이름의 확장자를 DXT 로 바꿈... - + fsFile.replace_extension(".dxt"); Tex.Convert(dlgFormat.m_Fmt, dlgFormat.m_nWidth, dlgFormat.m_nHeight, dlgFormat.m_bMipMap); - Tex.m_szName = szFN2; - Tex.SaveToFile(szFN2); + Tex.m_szName = fsFile.stem().string(); + Tex.SaveToFile(fsFile); } } } @@ -273,21 +263,17 @@ void CMainFrame::OnToolCutBmp() { bSaveToDXT = true; } - BMPCutter(dlg.GetPathName(), nW, nH, bSaveToDXT, fmtSave); + BMPCutter(dlg.GetPathName().GetString(), nW, nH, bSaveToDXT, fmtSave); } -BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool bSaveToDXT, D3DFORMAT fmtDXT) { +BOOL CMainFrame::BMPCutter(const fs::path & fsFile, int iWidth, int iHeight, bool bSaveToDXT, D3DFORMAT fmtDXT) { CBitMapFile BMF; - if (false == BMF.LoadFromFile(lpszFileName)) { + if (false == BMF.LoadFromFile(fsFile)) { return FALSE; } - // 저장할 file 이름 - char szDrive[_MAX_DRIVE]; - char szDir[_MAX_DIR]; - char szFName[_MAX_FNAME]; - _splitpath(lpszFileName, szDrive, szDir, szFName, NULL); - CreateDirectory(szFName, NULL); // 하위 폴더 만들기 + fs::path fsDir = fsFile.parent_path() / fsFile.stem(); + fs::create_directory(fsDir); int xx = BMF.Width() / iWidth; int yy = BMF.Height() / iHeight; @@ -297,28 +283,27 @@ BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool b ProgressBar.Create("cutting bitmap..", 50, yy * xx); ProgressBar.SetStep(1); + std::string szStem = fsFile.stem().string(); for (int y = 0; y < yy; y++) { for (int x = 0; x < xx; x++) { - RECT rcDest = {x * iWidth, y * iHeight, (x + 1) * iWidth, (y + 1) * iHeight}; - char szDestFN[_MAX_PATH]; + fs::path fsDxtFile = fsDir / std::format("{:s}_{:02}{:02}.dxt", szStem, x, y); + RECT rcDest = {x * iWidth, y * iHeight, (x + 1) * iWidth, (y + 1) * iHeight}; if (bSaveToDXT) { - if (false == BMF.SaveRectToFile("c:\\TempConvert.BMP", rcDest)) { + fs::path fsBmpTmpFile = fs::temp_directory_path() / "N3TexViewer_TempConvert.bmp"; + if (!BMF.SaveRectToFile(fsBmpTmpFile, rcDest)) { continue; } CN3Texture Tex; - if (false == Tex.LoadFromFile("c:\\TempConvert.BMP")) { + if (!Tex.LoadFromFile(fsBmpTmpFile)) { continue; } Tex.Convert(fmtDXT); - wsprintf(szDestFN, "%s%s%s\\%s_%02d%02d.DXT", szDrive, szDir, szFName, szFName, x, y); - Tex.SaveToFile(szDestFN); - DeleteFile("c:\\TempConvert.BMP"); + Tex.SaveToFile(fsDxtFile); } else { - wsprintf(szDestFN, "%s%s%s\\%s_%02d%02d.bmp", szDrive, szDir, szFName, szFName, x, y); - BMF.SaveRectToFile(szDestFN, rcDest); + BMF.SaveRectToFile(fsDxtFile, rcDest); } ProgressBar.StepIt(); @@ -327,18 +312,16 @@ BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool b return TRUE; /* - if (lstrlen(lpszFileName) == 0 || iWidth<=0 || iHeight<=0) - { + if (fsFile.empty() || iWidth <= 0 || iHeight <= 0) { MessageBox("가로 세로가 0이하인 bitmap으로 나눌 수 없습니다.", "error"); return FALSE; } - CFile file; + CFile file; CFileException fe; // 읽기 모드로 파일 열기 - if (!file.Open(lpszFileName, CFile::modeRead|CFile::shareDenyWrite, &fe)) - { + if (!file.Open(fsFile.string().c_str(), CFile::modeRead | CFile::shareDenyWrite, &fe)) { MessageBox("원본 bitmap을 열 수 없습니다.", "error"); return FALSE; } @@ -349,26 +332,26 @@ BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool b // 파일 헤더 읽기 BITMAPFILEHEADER bmfHeader; - if (file.Read(&bmfHeader, sizeof(bmfHeader)) != sizeof(bmfHeader)) - { + if (file.Read(&bmfHeader, sizeof(bmfHeader)) != sizeof(bmfHeader)) { MessageBox("원본 bitmap이 이상합니다.", "error"); return FALSE; } // bmp 파일임을 나타내는 "BM"마커 확인 - if (bmfHeader.bfType != 0x4D42) - { + if (bmfHeader.bfType != 0x4D42) { MessageBox("원본 파일이 bitmap파일이 아닙니다.", "error"); return FALSE; } // BITMAPINFOHEADER 얻기 BITMAPINFOHEADER bmInfoHeader; - if (file.Read(&bmInfoHeader, sizeof(bmInfoHeader)) != sizeof(bmInfoHeader)) return FALSE; + if (file.Read(&bmInfoHeader, sizeof(bmInfoHeader)) != sizeof(bmInfoHeader)) { + return FALSE; + } // 픽셀당 비트 수 확인 WORD wBitCount = bmInfoHeader.biBitCount; - if (24 != wBitCount) // 24비트 bmp가 아니면 return해 버린다. + if (24 != wBitCount) // 24비트 bmp가 아니면 return해 버린다. { MessageBox("원본 bitmap이 24bit파일이 아닙니다.", "error"); return FALSE; @@ -376,27 +359,25 @@ BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool b // 가로, 세로로 나누어야 할 수 계산 int iCX, iCY; - iCX = (bmInfoHeader.biWidth+iWidth-1) / iWidth; - iCY = (bmInfoHeader.biHeight+iHeight-1) / iHeight; - if (iCX <= 0 || iCY <= 0) - { + iCX = (bmInfoHeader.biWidth + iWidth - 1) / iWidth; + iCY = (bmInfoHeader.biHeight + iHeight - 1) / iHeight; + if (iCX <= 0 || iCY <= 0) { MessageBox("나눌 수 없습니다.", "error"); return FALSE; } // 실제 이미지 비트 주소 -// LPVOID pSrcImageBit; -// pSrcImageBit = (LPVOID)((BYTE*)pSrcDIB + (bmfHeader.bfOffBits - sizeof(bmfHeader))); + // LPVOID pSrcImageBit; + // pSrcImageBit = (LPVOID)((BYTE*)pSrcDIB + (bmfHeader.bfOffBits - sizeof(bmfHeader))); // 실제 이미지의 메모리상에 잡힌 가로 길이 (24bit) - int iRealWidthSrc = ((int)((bmInfoHeader.biWidth*3 + 3)/4))*4; + int iRealWidthSrc = ((int)((bmInfoHeader.biWidth * 3 + 3) / 4)) * 4; // 새로 만들 이미지 메모리 할당 - int iRealWidthDest = ((int)((iWidth*3 + 3)/4))*4; - int iDestDIBSize = sizeof(BITMAPINFOHEADER) + iRealWidthDest * iHeight; + int iRealWidthDest = ((int)((iWidth * 3 + 3) / 4)) * 4; + int iDestDIBSize = sizeof(BITMAPINFOHEADER) + iRealWidthDest * iHeight; LPVOID pDestDIB; - if ((pDestDIB = ::GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, iDestDIBSize )) == NULL ) - { + if ((pDestDIB = ::GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, iDestDIBSize)) == NULL) { MessageBox("메모리를 할당하지 못했습니다.", "error"); return FALSE; } @@ -419,20 +400,14 @@ BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool b bmInfoHeaderDest.biSizeImage = iRealWidthDest * iHeight; memcpy(pDestDIB, &bmInfoHeaderDest, sizeof(bmInfoHeaderDest)); - // 저장할 file 이름 - char szDrive[_MAX_DRIVE]; - char szDir[_MAX_DIR]; - char szFName[_MAX_FNAME]; - char szFNameDest[_MAX_FNAME]; - _splitpath(lpszFileName, szDrive, szDir, szFName, NULL); - CreateDirectory(szFName, NULL); // 하위 폴더 만들기 + fs::path fsDir = fsFile.parent_path() / fsFile.stem(); + fs::create_directory(fsDir); // 쪼갠 정보를 tcd파일에 넣어서 저장 - DWORD dwNum; - wsprintf(szFNameDest, "%s\\%s.tcd", szFName, szFName); - HANDLE hFile = CreateFile(szFNameDest, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if(INVALID_HANDLE_VALUE != hFile) - { + DWORD dwNum; + fs::path fsTcdFile = fsDir / (fsFile.stem() + ".tcd"); + HANDLE hFile = CreateFileW(fsTcdFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (INVALID_HANDLE_VALUE != hFile) { WriteFile(hFile, &iCX, sizeof(iCX), &dwNum, NULL); WriteFile(hFile, &iCY, sizeof(iCX), &dwNum, NULL); CloseHandle(hFile); @@ -440,50 +415,46 @@ BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool b // progress bar CProgressBar ProgressBar; - ProgressBar.Create("cutting bitmap..", 50, iCY*iCX); + ProgressBar.Create("cutting bitmap..", 50, iCY * iCX); ProgressBar.SetStep(1); // 새로 쪼개서 저장하기 - BYTE *pTmpBitDest; - pTmpBitDest = ((BYTE*)pDestDIB) + sizeof(BITMAPINFOHEADER); - for (int j=0; j= bmInfoHeader.biHeight) break; // 맨 아래가 짤릴 경우가 있다 + for (int y = 0; y < iHeight; ++y) { + if ((iHeight * j + y) >= bmInfoHeader.biHeight) { + break; // 맨 아래가 짤릴 경우가 있다 + } // 원본파일의 읽어올 부분의 file position을 맞게 세팅한다. - file.Seek(bmfHeader.bfOffBits + - iRealWidthSrc*(bmInfoHeader.biHeight - 1 - (iHeight*j + y)) + - 3*(iWidth*i), - CFile::begin); - - if (i == (iCX-1)) - { // 맨 오른쪽 끝은 짤릴 가능성이 있다. - file.Read(pTmpBitDest + iRealWidthDest*(iHeight-1-y), bmInfoHeader.biWidth*3 - iRealWidthDest*(iCX-1)); - } - else - { - file.Read(pTmpBitDest + iRealWidthDest*(iHeight-1-y), iRealWidthDest); + file.Seek(bmfHeader.bfOffBits + iRealWidthSrc * (bmInfoHeader.biHeight - 1 - (iHeight * j + y)) + + 3 * (iWidth * i), + CFile::begin); + + if (i == (iCX - 1)) { // 맨 오른쪽 끝은 짤릴 가능성이 있다. + file.Read(pTmpBitDest + iRealWidthDest * (iHeight - 1 - y), + bmInfoHeader.biWidth * 3 - iRealWidthDest * (iCX - 1)); + } else { + file.Read(pTmpBitDest + iRealWidthDest * (iHeight - 1 - y), iRealWidthDest); } } // 저장하기 - if(bSaveToDXT) - { - wsprintf(szFNameDest, "%s%s%s\\ConversionTmp.bmp", szDrive, szDir, szFName, szFName, i, iCY-1-j); - } - else - { - wsprintf(szFNameDest, "%s%s%s\\%s_%02d%02d.bmp", szDrive, szDir, szFName, szFName, i, iCY-1-j); + fs::path fsTexFileTmp; + if (bSaveToDXT) { + fsTexFileTmp = fs::temp_directory_path() / "N3TexViewer_TempConvert.bmp"; + } else { + fsTexFileTmp = fsDir / std::format("{:s}_{:02}{:02}.dxt", szStem, i, iCY - 1 - j); } - hFile = CreateFile(szFNameDest, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if(INVALID_HANDLE_VALUE != hFile) - { + hFile = + CreateFileW(fsTexFileTmp.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (INVALID_HANDLE_VALUE != hFile) { WriteFile(hFile, &bmfHeaderDest, sizeof(bmfHeaderDest), &dwNum, NULL); WriteFile(hFile, pDestDIB, iDestDIBSize, &dwNum, NULL); CloseHandle(hFile); @@ -491,19 +462,16 @@ BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool b ProgressBar.StepIt(); this->UpdateWindow(); - if(bSaveToDXT) // DXT 를 저장하려면.. - { - char szDXT_FName[_MAX_PATH]; - wsprintf(szDXT_FName, "%s%s%s\\%s_%02d%02d.DXT", szDrive, szDir, szFName, szFName, i, iCY-1-j); - + if (bSaveToDXT) { // DXT 를 저장하려면.. CN3Texture TexTmp; - TexTmp.LoadFromFile(szFNameDest); // 로딩 - if(true == TexTmp.Convert(fmtDXT)) // 변환 + TexTmp.LoadFromFile(fsTcdFile); // 로딩 + if (true == TexTmp.Convert(fmtDXT)) // 변환 { - TexTmp.SaveToFile(szDXT_FName); + fs::path fsDxtFile = (fsDir / fsFile.stem()) + std::format("_{:02}{:02}.dxt", i, iCY - 1 - j); + TexTmp.SaveToFile(fsDxtFile); } - DeleteFile(szFNameDest); // 임시 비트맵 파일 지우기.. + fs::remove(fsTcdFile.c_str()); // 임시 비트맵 파일 지우기.. } } } @@ -511,9 +479,9 @@ BOOL CMainFrame::BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool b // 메모리 풀어줌 ::GlobalFree(pDestDIB); file.Close(); - - return TRUE; - */ + + return TRUE; + */ } void CMainFrame::OnFileOpenNext() { @@ -561,24 +529,22 @@ void CMainFrame::OnToolSaveRepeat() { return; } - CN3Texture Tex; - POSITION pos = dlg.GetStartPosition(); - CStringArray FileNames; - while (pos != NULL) { - FileNames.Add(dlg.GetNextPathName(pos)); - } + POSITION pos = dlg.GetStartPosition(); - int nFNC = FileNames.GetSize(); + std::vector vFiles; + while (pos) { + vFiles.emplace_back(dlg.GetNextPathName(pos).GetString()); + } // progress bar CProgressBar ProgressBar; - ProgressBar.Create("ReSave DXT Files..", 50, nFNC); + ProgressBar.Create("ReSave DXT Files..", 50, static_cast(vFiles.size())); ProgressBar.SetStep(1); - for (int i = 0; i < nFNC; i++) { - std::string szFN(FileNames[i].GetString()); - Tex.LoadFromFile(szFN); - Tex.SaveToFile(szFN); + for (const auto & fsFile : vFiles) { + CN3Texture Tex; + Tex.LoadFromFile(fsFile); + Tex.SaveToFile(fsFile); ProgressBar.StepIt(); } diff --git a/src/tool/N3TexViewer/MainFrm.h b/src/tool/N3TexViewer/MainFrm.h index 37f01eee..bef7baf6 100644 --- a/src/tool/N3TexViewer/MainFrm.h +++ b/src/tool/N3TexViewer/MainFrm.h @@ -15,7 +15,7 @@ class CMainFrame : public CFrameWnd { CMainFrame(); virtual ~CMainFrame(); - BOOL BMPCutter(LPCTSTR lpszFileName, int iWidth, int iHeight, bool bSaveToDXT = false, + BOOL BMPCutter(const fs::path & fsFile, int iWidth, int iHeight, bool bSaveToDXT = false, D3DFORMAT fmtDXT = D3DFMT_DXT1); // Overrides diff --git a/src/tool/N3TexViewer/N3TexViewerDoc.cpp b/src/tool/N3TexViewer/N3TexViewerDoc.cpp index ef2a39ef..0deaf050 100644 --- a/src/tool/N3TexViewer/N3TexViewerDoc.cpp +++ b/src/tool/N3TexViewer/N3TexViewerDoc.cpp @@ -28,11 +28,10 @@ END_MESSAGE_MAP() // CN3TexViewerDoc construction/destruction CN3TexViewerDoc::CN3TexViewerDoc() { - // TODO: add one-time construction code here m_pTex = new CN3Texture(); m_pTexAlpha = new CN3Texture(); - m_nCurFile = NULL; + m_nCurFile = 0; } CN3TexViewerDoc::~CN3TexViewerDoc() { @@ -76,7 +75,7 @@ BOOL CN3TexViewerDoc::OnNewDocument() { m_pTex->Release(); m_pTexAlpha->Release(); - this->UpdateAllViews(NULL); + UpdateAllViews(NULL); return TRUE; } @@ -86,11 +85,13 @@ BOOL CN3TexViewerDoc::OnOpenDocument(LPCTSTR lpszPathName) { return FALSE; } - this->FindFiles(); // 파일을 찾고.. + fs::path fsFile = lpszPathName; + + FindFiles(); // 파일을 찾고.. // TODO: Add your specialized creation code here m_pTexAlpha->Release(); - if (NULL == m_pTex->LoadFromFile(lpszPathName)) { + if (!m_pTex->LoadFromFile(fsFile)) { return FALSE; } @@ -124,50 +125,39 @@ BOOL CN3TexViewerDoc::OnOpenDocument(LPCTSTR lpszPathName) { // Alpha Texture 생성... //////////////////////////////////////////////////////////////////////////////// - char szDrv[_MAX_DRIVE], szDir[_MAX_DIR], szFN[_MAX_FNAME], szExt[_MAX_EXT]; - ::_splitpath(lpszPathName, szDrv, szDir, szFN, szExt); - CString szFileName = szFN; - szFileName += szExt; - - this->SetTitle(szFileName); + CString szFileName = fsFile.filename().c_str(); + SetTitle(szFileName); // Update status bar with the currently opened file path CFrameWnd * pFrm = (CFrameWnd *)AfxGetMainWnd(); ASSERT(pFrm); CStatusBar * pSB = (CStatusBar *)pFrm->GetMessageBar(); ASSERT(pSB); - pSB->SetPaneText(0, lpszPathName); + pSB->SetPaneText(0, fsFile.string().c_str()); - this->UpdateAllViews(NULL); + UpdateAllViews(NULL); return TRUE; } BOOL CN3TexViewerDoc::OnSaveDocument(LPCTSTR lpszPathName) { - char szDrv[_MAX_DRIVE], szDir[_MAX_DIR], szFN[_MAX_FNAME], szExt[_MAX_EXT]; - ::_splitpath(lpszPathName, szDrv, szDir, szFN, szExt); - - if (lstrcmpi(szExt, ".DXT") == 0) // 확장자가 DXT 면 그냥 저장.. - { - CDocument::OnSaveDocument(lpszPathName); - - if (false == m_pTex->SaveToFile(lpszPathName)) { - return FALSE; - } - - return TRUE; - } else { - MessageBox(::GetActiveWindow(), "확장자를 DXT 로 바꾸어야 합니다. Save As 로 저장해주세요.", "저장 실패", - MB_OK); + fs::path fsFile = lpszPathName; + if (!n3std::iequals(fsFile.extension(), ".dxt")) { + MessageBox(::GetActiveWindow(), "You need to change the extension to DXT. Please save it as Save As.", + "Save failed", MB_OK); + return FALSE; + } + if (!m_pTex->SaveToFile(fsFile)) { return FALSE; } + + return CDocument::OnSaveDocument(lpszPathName); } void CN3TexViewerDoc::SetTitle(LPCTSTR lpszTitle) { - // TODO: Add your specialized code here and/or call the base class - CString szFmt; - szFmt.Format("%s - %d, %d", lpszTitle, m_pTex->Width(), m_pTex->Height()); + std::string szFmt = std::format("{:s} - {:d}, {:d}", lpszTitle, m_pTex->Width(), m_pTex->Height()); + D3DFORMAT fmtTex = m_pTex->PixelFormat(); if (D3DFMT_DXT1 == fmtTex) { szFmt += " DXT1"; @@ -199,87 +189,62 @@ void CN3TexViewerDoc::SetTitle(LPCTSTR lpszTitle) { szFmt += " - has no MipMap"; } - CDocument::SetTitle(szFmt); - // CDocument::SetTitle(lpszTitle); + CDocument::SetTitle(szFmt.c_str()); } void CN3TexViewerDoc::FindFiles() { - char szPath[_MAX_PATH]; - GetCurrentDirectory(_MAX_PATH, szPath); - - CString szPath2 = szPath; - szPath2.MakeLower(); - - if (m_szPath == szPath2) { + if (m_fsWorkDir == CN3Base::PathGet()) { return; } - m_szPath = szPath2; - m_szFiles.RemoveAll(); - - CFileFind find; - + m_fsWorkDir = CN3Base::PathGet(); + m_vDxtFiles.clear(); m_nCurFile = 0; - if (FALSE == find.FindFile("*.DXT")) { - return; - } - for (int i = 0; find.FindNextFile(); i++) { - CString szPathTmp = find.GetFilePath(); - m_szFiles.Add(szPathTmp); + int i = 0; + for (const auto & fsEntry : fs::recursive_directory_iterator(fs::current_path())) { + if (!fsEntry.is_regular_file() || !n3std::iequals(fsEntry.path().extension(), ".dxt")) { + continue; + } + + fs::path fsDxtFile = fsEntry.path(); + m_vDxtFiles.emplace_back(fsDxtFile); - if (szPathTmp == this->GetPathName()) { + if (fsDxtFile.c_str() == GetPathName()) { m_nCurFile = i; } + ++i; } } -void CN3TexViewerDoc::OpenNextFile() { - m_nCurFile++; - int nFC = m_szFiles.GetSize(); - if (m_nCurFile < 0 || m_nCurFile >= nFC) { - m_nCurFile = nFC - 1; +void CN3TexViewerDoc::OpenFileAtIndex(int iIndex) { + if (m_vDxtFiles.empty()) { return; } - this->OnOpenDocument(m_szFiles[m_nCurFile]); + // Clamp the index to stay within valid range + m_nCurFile = std::clamp(iIndex, 0, static_cast(m_vDxtFiles.size()) - 1); + OnOpenDocument(m_vDxtFiles[m_nCurFile].string().c_str()); } -void CN3TexViewerDoc::OpenPrevFile() { - m_nCurFile--; - int nFC = m_szFiles.GetSize(); - if (m_nCurFile < 0 || m_nCurFile >= nFC) { - m_nCurFile = 0; - return; - } +void CN3TexViewerDoc::OpenNextFile() { + OpenFileAtIndex(m_nCurFile + 1); +} - this->OnOpenDocument(m_szFiles[m_nCurFile]); +void CN3TexViewerDoc::OpenPrevFile() { + OpenFileAtIndex(m_nCurFile - 1); } void CN3TexViewerDoc::OpenFirstFile() { - m_nCurFile = 0; - int nFC = m_szFiles.GetSize(); - if (m_nCurFile < 0 || m_nCurFile >= nFC) { - m_nCurFile = 0; - return; - } - - this->OnOpenDocument(m_szFiles[m_nCurFile]); + OpenFileAtIndex(0); } void CN3TexViewerDoc::OpenLastFile() { - m_nCurFile = m_szFiles.GetSize() - 1; - int nFC = m_szFiles.GetSize(); - if (m_nCurFile < 0 || m_nCurFile >= nFC) { - m_nCurFile = 0; - return; - } - - this->OnOpenDocument(m_szFiles[m_nCurFile]); + OpenFileAtIndex(static_cast(m_vDxtFiles.size()) - 1); } void CN3TexViewerDoc::OnFileSaveAsBitmap() { - if (NULL == m_pTex || NULL == m_pTex->Get()) { + if (!m_pTex || !m_pTex->Get()) { return; } diff --git a/src/tool/N3TexViewer/N3TexViewerDoc.h b/src/tool/N3TexViewer/N3TexViewerDoc.h index 1b137804..baa55e57 100644 --- a/src/tool/N3TexViewer/N3TexViewerDoc.h +++ b/src/tool/N3TexViewer/N3TexViewerDoc.h @@ -16,9 +16,9 @@ class CN3TexViewerDoc : public CDocument { CN3Texture * m_pTex; CN3Texture * m_pTexAlpha; - int m_nCurFile; - CString m_szPath; - CStringArray m_szFiles; + int m_nCurFile; + fs::path m_fsWorkDir; + std::vector m_vDxtFiles; // Operations public: @@ -35,6 +35,7 @@ class CN3TexViewerDoc : public CDocument { // Implementation public: + void OpenFileAtIndex(int iIndex); void OpenLastFile(); void OpenFirstFile(); void OpenPrevFile(); diff --git a/src/tool/N3Viewer/MainFrm.cpp b/src/tool/N3Viewer/MainFrm.cpp index 1f421c8c..f1a06699 100644 --- a/src/tool/N3Viewer/MainFrm.cpp +++ b/src/tool/N3Viewer/MainFrm.cpp @@ -79,7 +79,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); // Engine 생성 // m_Eng.InitEnv(); @@ -254,19 +254,18 @@ void CMainFrame::OnToolFixProgressiveMesh() { CFile file; file.Open("프로그레시브 메쉬 처리 안된 리스트.txt", CFile::modeWrite | CFile::modeCreate); - CString FileName; CN3PMesh PM; POSITION pos = dlg.GetStartPosition(); for (int i = 0; pos != NULL; i++) { - FileName = dlg.GetNextPathName(pos); + fs::path fsFile = dlg.GetNextPathName(pos).GetString(); PM.Release(); - PM.LoadFromFile(std::string(FileName)); - PM.SaveToFile(std::string(FileName)); + PM.LoadFromFile(fsFile); + PM.SaveToFile(fsFile); if (PM.LODCtrlCount() <= 0 || PM.CollapsesCount() <= 0) { CString szWarning; - szWarning.Format("LOD 처리 안됨 : %s\r\n", PM.FileName().c_str()); + szWarning.Format("LOD 처리 안됨 : %s\r\n", PM.FilePath().c_str()); file.Write(szWarning, szWarning.GetLength()); } } diff --git a/src/tool/N3Viewer/N3ViewerDoc.cpp b/src/tool/N3Viewer/N3ViewerDoc.cpp index 4dcb3889..d0d5e0a9 100644 --- a/src/tool/N3Viewer/N3ViewerDoc.cpp +++ b/src/tool/N3Viewer/N3ViewerDoc.cpp @@ -133,7 +133,7 @@ void CN3ViewerDoc::OnFileImport() { CString szExt = ""; //CString szFilter = // "N3D Object File|*.*|카메라 Data(*.N3Camera)|*.N3Camera|Light Data(*.N3Light)|*.N3Light|Shape Data(*.N3Shape)|*.N3Shape|\ -// Progressive Mesh Data(*.N3PMesh)|*.N3Mesh|Indexed Mesh Data(*.N3IMesh)|*.N3IMesh|Joint Data(*.N3Joint)|*.N3Joint|Skinning Data(*.N3Skin)|*.N3Skin|Character Data(*.N3Chr)|*.N3Chr||"; + // Progressive Mesh Data(*.N3PMesh)|*.N3Mesh|Indexed Mesh Data(*.N3IMesh)|*.N3IMesh|Joint Data(*.N3Joint)|*.N3Joint|Skinning Data(*.N3Skin)|*.N3Skin|Character Data(*.N3Chr)|*.N3Chr||"; CString szFilter = "N3D Object File|*.*|카메라(*.N3Camera)|*.N3Camera|Light(*.N3Light)|*.N3Light|Progressive " "Mesh(*.N3PMesh)|*.N3PMesh|Shape(*.N3Shape)|*.N3Shape|Character(*.N3Chr)|*.N3Chr|Plug(*.N3CPlug)|*.N3CPlug||"; @@ -148,61 +148,57 @@ void CN3ViewerDoc::OnFileImport() { return; } - CString FileName; POSITION pos = dlg.GetStartPosition(); for (int i = 0; pos != NULL; i++) { - FileName = dlg.GetNextPathName(pos); - CString szExt = FileName.Right(FileName.GetLength() - FileName.ReverseFind('.') - 1); + fs::path fsFile = dlg.GetNextPathName(pos).GetString(); + std::string szExt = fsFile.extension().string(); CN3BaseFileAccess * pBase = NULL; - if (lstrcmpi(szExt, "N3Camera") == 0) { + if (n3std::iequals(szExt, ".n3camera")) { CN3Camera * pCamera = new CN3Camera(); m_Scene.CameraAdd(pCamera); pBase = pCamera; - } else if (lstrcmpi(szExt, "N3Light") == 0) { + } else if (n3std::iequals(szExt, ".n3light")) { CN3Light * pLight = new CN3Light(); m_Scene.LightAdd(pLight); pBase = pLight; - } else if (lstrcmpi(szExt, "N3PMesh") == 0) { + } else if (n3std::iequals(szExt, ".n3pmesh")) { CN3PMesh * pMesh = new CN3PMesh(); m_Scene.s_MngPMesh.Add(pMesh); pBase = pMesh; - } - // else if(lstrcmpi(szExt, "N3Joint") == 0) - // { - // CN3Joint* pJoint = new CN3Joint(); - // m_Scene.s_MngJoint.Add(pJoint); - // pBase = pJoint; - // } - else if (lstrcmpi(szExt, "N3Shape") == 0) { + //} else if (n3std::iequals(szExt, ".n3joint")) { + // CN3Joint * pJoint = new CN3Joint(); + // m_Scene.s_MngJoint.Add(pJoint); + // pBase = pJoint; + } else if (n3std::iequals(szExt, ".n3shape")) { CN3Shape * pShape = new CN3Shape(); m_Scene.ShapeAdd(pShape); pBase = pShape; - } else if (lstrcmpi(szExt, "N3Chr") == 0) { + } else if (n3std::iequals(szExt, ".n3chr")) { CN3Chr * pChr = new CN3Chr(); m_Scene.ChrAdd(pChr); pBase = pChr; - } else if (lstrcmpi(szExt, "N3CPlug") == 0) { + } else if (n3std::iequals(szExt, ".n3cplug")) { CN3Shape * pShape = new CN3Shape(); m_Scene.ShapeAdd(pShape); CN3SPart * pPart = pShape->PartAdd(); CN3CPlug plug; - plug.LoadFromFile(std::string(FileName)); + plug.LoadFromFile(fsFile); pPart->m_szName = plug.m_szName; pShape->m_szName = plug.m_szName; - pShape->FileNameSet(plug.m_szName + ".N3Shape"); + pShape->FilePathSet(plug.m_szName + ".n3shape"); CN3PMesh * pPMesh = plug.PMesh(); m_Scene.s_MngPMesh.Add(pPMesh); CN3Texture * pTex = plug.Tex(); m_Scene.s_MngTex.Add(pTex); - pPart->MeshSet(pPMesh->FileName()); + pPart->MeshSet(pPMesh->FilePath()); pPart->TexAlloc(1); - pPart->TexSet(0, pTex->FileName()); + pPart->TexSet(0, pTex->FilePath()); pShape->FindMinMax(); // 큰값, 작은값 찾기.. @@ -211,14 +207,14 @@ void CN3ViewerDoc::OnFileImport() { continue; } - pBase->LoadFromFile(std::string(FileName)); // 파일에서 읽는다.. + pBase->LoadFromFile(fsFile); // 파일에서 읽는다.. m_pSelectedObj = pBase; - if (lstrcmpi(szExt, "N3PMesh") == 0) { + if (n3std::iequals(szExt, ".n3pmesh")) { CN3Shape * pShape = new CN3Shape(); m_Scene.ShapeAdd(pShape); CN3SPart * pPart = pShape->PartAdd(); - pPart->MeshSet(pBase->FileName()); + pPart->MeshSet(pBase->FilePath()); m_pSelectedObj = pShape; delete pBase; @@ -277,18 +273,17 @@ void CN3ViewerDoc::OnFileExport() { return; } - std::string szOldFN = pBase->FileName(); - CString szFullPath = dlg.GetPathName(); + fs::path fsFileBak = pBase->FilePath(); + fs::path fsFile = dlg.GetPathName().GetString(); - CString szOldName = pBase->m_szName.c_str(); if (dwType & OBJ_SHAPE) { CN3Shape * pShape = (CN3Shape *)pBase; - pShape->SaveToFile(std::string(szFullPath)); + pShape->SaveToFile(fsFile); } else { - pBase->SaveToFile(std::string(szFullPath)); + pBase->SaveToFile(fsFile); } - pBase->FileNameSet(szOldFN); + pBase->FilePathSet(fsFileBak); this->UpdateAllViews(NULL); } @@ -306,11 +301,10 @@ void CN3ViewerDoc::OnFileSaveToSameFolder() { if (dlg.DoModal() == IDCANCEL) { return; } - - CString szFullPath = dlg.GetPathName(); + fs::path fsFile = dlg.GetPathName().GetString(); CN3Shape * pShape = (CN3Shape *)m_pSelectedObj; - pShape->SaveToSameFolder(std::string(szFullPath)); + pShape->SaveToSameFolder(fsFile); } void CN3ViewerDoc::OnFileSaveToIndoor() { @@ -325,22 +319,21 @@ void CN3ViewerDoc::OnFileSaveToIndoor() { if (dlg.DoModal() == IDCANCEL) { return; } - CString szFullPath = dlg.GetPathName(); + fs::path fsFile = dlg.GetPathName().GetString(); for (int i = 0; i < iCount; i++) { CN3Shape * pShape = m_Scene.ShapeGet(i); - pShape->SaveToSameFolderAndMore(std::string(szFullPath), "N3Indoor\\"); + pShape->SaveToSameFolderAndMore(fsFile, "N3Indoor"); } - OnSaveDocument(std::string(szFullPath).c_str()); + OnSaveDocument(fsFile.string().c_str()); } void CN3ViewerDoc::OnEditInsertCamera() { CN3Camera * pCamera = new CN3Camera(); pCamera->m_szName = "DefaultCamera"; - char szFN[256]; - wsprintf(szFN, "Chr\\DefaultCamera_%d.N3Camera", m_Scene.CameraCount() + 1); - pCamera->FileNameSet(szFN); + fs::path fsFile = fs::path("Chr") / std::format("DefaultCamera_{:d}.n3camera", m_Scene.CameraCount() + 1); + pCamera->FilePathSet(fsFile); m_Scene.CameraAdd(pCamera); m_pSelectedObj = pCamera; @@ -351,9 +344,8 @@ void CN3ViewerDoc::OnEditInsertLight() { CN3Light * pLight = new CN3Light(); pLight->m_szName = "DefaultLight"; - char szFN[256]; - wsprintf(szFN, "Data\\DefaultLight_%d.N3Light", m_Scene.LightCount() + 1); - pLight->FileNameSet(szFN); + fs::path fsFile = fs::path("Data") / std::format("DefaultLight_{:d}.n3light", m_Scene.LightCount() + 1); + pLight->FilePathSet(fsFile); m_Scene.LightAdd(pLight); m_pSelectedObj = pLight; @@ -364,9 +356,8 @@ void CN3ViewerDoc::OnEditInsertShape() { CN3Shape * pShape = new CN3Shape(); pShape->m_szName = "DefaultShape"; - char szFN[256]; - wsprintf(szFN, "Object\\DefaultShape_%d.N3Shape", m_Scene.ShapeCount() + 1); - pShape->FileNameSet(szFN); + fs::path fsFile = fs::path("Object") / std::format("DefaultShape_{:d}.n3shape", m_Scene.ShapeCount() + 1); + pShape->FilePathSet(fsFile); m_Scene.ShapeAdd(pShape); m_pSelectedObj = pShape; @@ -377,9 +368,8 @@ void CN3ViewerDoc::OnEditInsertCharacter() { CN3Chr * pChr = new CN3Chr(); pChr->m_szName = "DefaultChr"; - char szFN[256]; - wsprintf(szFN, "Chr\\DefaultChr_%d.N3Chr", m_Scene.ChrCount() + 1); - pChr->FileNameSet(szFN); + fs::path fsFile = fs::path("Chr") / std::format("DefaultChr_{:d}.n3chr", m_Scene.ChrCount() + 1); + pChr->FilePathSet(fsFile); m_Scene.ChrAdd(pChr); m_pSelectedObj = pChr; diff --git a/src/tool/N3Viewer/ViewProperty.cpp b/src/tool/N3Viewer/ViewProperty.cpp index bf7110d5..ff5cda3c 100644 --- a/src/tool/N3Viewer/ViewProperty.cpp +++ b/src/tool/N3Viewer/ViewProperty.cpp @@ -353,7 +353,7 @@ void CViewProperty::UpdateInfo() { if (pItem) { CN3Texture * pTex = pPD->Tex(0); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -367,7 +367,7 @@ void CViewProperty::UpdateInfo() { pItem = m_LPShape.GetPropItem("Mesh File"); if (pItem) { if (pPMesh) { - pItem->m_curValue = pPMesh->FileName().c_str(); + pItem->m_curValue = pPMesh->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -457,13 +457,15 @@ void CViewProperty::UpdateInfo() { } } - // pItem = m_LPChr.GetPropItem("Collision Skin File"); - // if(pItem) - // { - // CN3Skin* pSkin = pC->CollisionSkin(); - // if(pSkin) pItem->m_curValue = pSkin->m_szName.c_str(); - // else pItem->m_curValue = ""; - // } + //pItem = m_LPChr.GetPropItem("Collision Skin File"); + //if (pItem) { + // CN3Skin * pSkin = pC->CollisionSkin(); + // if (pSkin) { + // pItem->m_curValue = pSkin->m_szName.c_str(); + // } else { + // pItem->m_curValue = ""; + // } + //} CN3CPart * pPart = pC->Part(nPart); if (pPart) { @@ -481,7 +483,7 @@ void CViewProperty::UpdateInfo() { if (pItem) { CN3Texture * pTex = pPart->Tex(); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue = ""; } @@ -734,7 +736,7 @@ BOOL CViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { } else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { - pS->CollisionMeshSet(std::string(pItem->m_curValue)); + pS->CollisionMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); } else if (pItem->m_propName == "Collision Mesh Delete") { @@ -742,28 +744,20 @@ BOOL CViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { } else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { - CStringArray szArr; - int n = 0, nPrev = 0; - while (1) { - n = pItem->m_curValue.Find('\n', n); - if (-1 == n) { - break; - } - - szArr.Add(pItem->m_curValue.Mid(nPrev, n - nPrev)); - nPrev = n + 1; - n++; + std::vector vTexFiles; + for (const auto & itrTexFile : std::string(pItem->m_curValue.GetString()) | std::views::split('\n')) { + fs::path fsTexFile(itrTexFile.begin(), itrTexFile.end()); + CN3BaseFileAccess::ToRelative(fsTexFile); + vTexFiles.emplace_back(fsTexFile); } - CN3BaseFileAccess tmp; - int nTC = szArr.GetSize(); - pPD->TexAlloc(nTC); - for (int i = 0; i < nTC; i++) { - tmp.FileNameSet(std::string(szArr[i])); - pPD->TexSet(i, tmp.FileName()); + int iTexCount = static_cast(vTexFiles.size()); + pPD->TexAlloc(iTexCount); + for (int i = 0; i < iTexCount; ++i) { + pPD->TexSet(i, vTexFiles[i]); } - this->UpdateInfo(); + this->UpdateInfo(); } else if (pItem->m_propName == "Texture Animaion Speed") { @@ -774,10 +768,7 @@ BOOL CViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { } else if (pItem->m_propName == "Mesh File" && pItem->m_curValue.GetLength() > 0) { - CN3BaseFileAccess tmp; - tmp.FileNameSet(std::string(pItem->m_curValue)); - pPD->MeshSet(tmp.FileName()); - + pPD->MeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } @@ -816,40 +807,27 @@ BOOL CViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { int nPlugCount = pC->PlugCount(); if (pItem->m_propName == "Joint File" && pItem->m_curValue.GetLength() > 0) { - CN3BaseFileAccess tmp; - tmp.FileNameSet(std::string(pItem->m_curValue)); - pC->JointSet(tmp.FileName()); + pC->JointSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); - } - // else if(pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) - // { - // pC->CollisionMeshSet(pItem->m_curValue); - // this->UpdateInfo(); - // } - // else if(pItem->m_propName == "Collision Mesh Delete") - // { - // pC->CollisionMeshSet(""); - // this->UpdateInfo(); - // } - // else if(pItem->m_propName == "Collision Skin File" && pItem->m_curValue.GetLength() > 0) - // { - // pC->CollisionSkinSet(pItem->m_curValue); - // this->UpdateInfo(); - // } - // else if(pItem->m_propName == "Collision Skin Delete") - // { - // pC->CollisionSkinSet(""); - // this->UpdateInfo(); - // } - else if (pItem->m_propName == "Part Add") { + //} else if (pItem->m_propName == "Collision Mesh File" && pItem->m_curValue.GetLength() > 0) { + // pC->CollisionMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + // this->UpdateInfo(); + //} else if (pItem->m_propName == "Collision Mesh Delete") { + // pC->CollisionMeshSet(""); + // this->UpdateInfo(); + //} else if (pItem->m_propName == "Collision Skin File" && pItem->m_curValue.GetLength() > 0) { + // pC->CollisionSkinSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); + // this->UpdateInfo(); + //} else if (pItem->m_propName == "Collision Skin Delete") { + // pC->CollisionSkinSet(""); + // this->UpdateInfo(); + } else if (pItem->m_propName == "Part Add") { pC->PartAdd(); this->UpdateInfo(); } else if (pItem->m_propName == "Part Delete") { pC->PartDelete(nPart); this->UpdateInfo(); - } - - else if (pItem->m_propName == "Plug Add") { + } else if (pItem->m_propName == "Plug Add") { pC->PlugAdd(); this->UpdateInfo(); } else if (pItem->m_propName == "Plug Delete") { @@ -887,10 +865,7 @@ BOOL CViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { // this->UpdateInfo(); // } else if (pItem->m_propName == "Texture File" && pItem->m_curValue.GetLength() > 0) { - CN3BaseFileAccess tmp; - tmp.FileNameSet(std::string(pItem->m_curValue)); - pPart->TexSet(tmp.FileName()); - + pPart->TexSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } } @@ -928,15 +903,11 @@ BOOL CViewProperty::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { pPlug->ScaleSet(__Vector3(pItem->VectorGet())); } else if (pItem->m_propName == "Plug Mesh File" && pItem->m_curValue.GetLength() > 0) { if (pItem->m_curValue != "") { - CN3BaseFileAccess tmp; - tmp.FileNameSet(std::string(pItem->m_curValue)); - pPlug->PMeshSet(tmp.FileName()); + pPlug->PMeshSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); } this->UpdateInfo(); } else if (pItem->m_propName == "Plug Texture File" && pItem->m_curValue.GetLength() > 0) { - CN3BaseFileAccess tmp; - tmp.FileNameSet(std::string(pItem->m_curValue)); - pPlug->TexSet(tmp.FileName()); + pPlug->TexSet(CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString())); this->UpdateInfo(); } diff --git a/src/tool/N3Viewer/ViewSceneTree.cpp b/src/tool/N3Viewer/ViewSceneTree.cpp index bda41950..9d4ee1e7 100644 --- a/src/tool/N3Viewer/ViewSceneTree.cpp +++ b/src/tool/N3Viewer/ViewSceneTree.cpp @@ -136,7 +136,7 @@ void CViewSceneTree::UpdateTreeItem(HTREEITEM hParent, CN3Base * pBase) { HTREEITEM hItem = NULL; if (pBFA) { - hItem = GetTreeCtrl().InsertItem(pBFA->FileName().c_str(), nItem, nItem, hParent, NULL); + hItem = GetTreeCtrl().InsertItem(pBFA->FilePath().string().c_str(), nItem, nItem, hParent, NULL); } else { hItem = GetTreeCtrl().InsertItem(pBase->m_szName.c_str(), nItem, nItem, hParent, NULL); } @@ -395,7 +395,7 @@ void CViewSceneTree::OnEndlabeledit(NMHDR * pNMHDR, LRESULT * pResult) { CN3BaseFileAccess * pBFA = (CN3BaseFileAccess *)pBase; if (pTDI->item.pszText) { - pBFA->FileNameSet(pTDI->item.pszText); // 파일 이름 정하기.. + pBFA->FilePathSet(pTDI->item.pszText); // 파일 이름 정하기.. } *pResult = 1; diff --git a/src/tool/Option/OptionDlg.cpp b/src/tool/Option/OptionDlg.cpp index 9dd5deb6..2f5c9f0f 100644 --- a/src/tool/Option/OptionDlg.cpp +++ b/src/tool/Option/OptionDlg.cpp @@ -140,9 +140,9 @@ BOOL COptionDlg::OnInitDialog() { // Loading all from ini - auto fsCurPath = fs::current_path(); - SettingLoad((fsCurPath / "Option.ini").string()); - SettingServerLoad((fsCurPath / "Server.ini").string()); + fs::path fsCurDir = fs::current_path(); + SettingLoad(fsCurDir / "Option.ini"); + SettingServerLoad(fsCurDir / "Server.ini"); // Setting all from ini SettingUpdate(); @@ -190,20 +190,20 @@ HCURSOR COptionDlg::OnQueryDragIcon() { } void COptionDlg::OnOK() { - auto fsCurPath = fs::current_path(); - SettingSave((fsCurPath / "Option.ini").string()); - SettingServerSave((fsCurPath / "Server.ini").string()); + fs::path fsCurDir = fs::current_path(); + SettingSave(fsCurDir / "Option.ini"); + SettingServerSave(fsCurDir / "Server.ini"); MessageBox("Settings saved successfully"); CDialog::OnOK(); } void COptionDlg::OnBApplyAndExecute() { - auto szLauncherFile = (fs::current_path() / "Launcher.exe").string(); + fs::path fsLauncherFile = fs::current_path() / "Launcher.exe"; OnOK(); - ShellExecute(NULL, "open", szLauncherFile.c_str(), "", "", SW_SHOWNORMAL); // Open Launcher + ShellExecuteW(NULL, L"open", fsLauncherFile.c_str(), L"", L"", SW_SHOWNORMAL); // Open Launcher } -void COptionDlg::SettingSave(const std::string & szIniFile) { +void COptionDlg::SettingSave(const fs::path & fsIniFile) { CString szBuff; if (IsDlgButtonChecked(IDC_R_TEX_CHR_HIGH)) { @@ -289,58 +289,68 @@ void COptionDlg::SettingSave(const std::string & szIniFile) { m_Option.bSndDuplicated = IsDlgButtonChecked(IDC_C_SOUND_DUPLICATE) ? true : false; m_Option.bWindowCursor = IsDlgButtonChecked(IDC_C_CURSOR_WINDOW) ? true : false; - auto szFile = szIniFile.c_str(); - WritePrivateProfileString("Texture", "LOD_Chr", to_str(m_Option.iTexLOD_Chr), szFile); - WritePrivateProfileString("Texture", "LOD_Shape", to_str(m_Option.iTexLOD_Shape), szFile); - WritePrivateProfileString("Texture", "LOD_Terrain", to_str(m_Option.iTexLOD_Terrain), szFile); - WritePrivateProfileString("Shadow", "Use", to_str(m_Option.iUseShadow), szFile); - WritePrivateProfileString("ViewPort", "Width", to_str(m_Option.iViewWidth), szFile); - WritePrivateProfileString("ViewPort", "Height", to_str(m_Option.iViewHeight), szFile); - WritePrivateProfileString("ViewPort", "ColorDepth", to_str(m_Option.iViewColorDepth), szFile); - WritePrivateProfileString("ViewPort", "Distance", to_str(m_Option.iViewDist), szFile); - WritePrivateProfileString("Effect", "Count", to_str(m_Option.iEffectCount), szFile); - WritePrivateProfileString("Sound", "Distance", to_str(m_Option.iEffectSndDist), szFile); - WritePrivateProfileString("Sound", "Bgm", to_str(m_Option.bSndBackground), szFile); - WritePrivateProfileString("Sound", "Effect", to_str(m_Option.bSndEffect), szFile); - WritePrivateProfileString("Sound", "Duplicate", to_str(m_Option.bSndDuplicated), szFile); - WritePrivateProfileString("Cursor", "WindowCursor", to_str(m_Option.bWindowCursor), szFile); - WritePrivateProfileString("Screen", "WindowMode", to_str(m_Option.bWindowMode), szFile); - WritePrivateProfileString("WeaponEffect", "EffectVisible", to_str(m_Option.bWeaponEffect), szFile); + std::string szIniFile = fsIniFile.string(); + const char * pszIniFile = szIniFile.c_str(); + + WritePrivateProfileString("Texture", "LOD_Chr", to_str(m_Option.iTexLOD_Chr), pszIniFile); + WritePrivateProfileString("Texture", "LOD_Shape", to_str(m_Option.iTexLOD_Shape), pszIniFile); + WritePrivateProfileString("Texture", "LOD_Terrain", to_str(m_Option.iTexLOD_Terrain), pszIniFile); + WritePrivateProfileString("Shadow", "Use", to_str(m_Option.iUseShadow), pszIniFile); + WritePrivateProfileString("ViewPort", "Width", to_str(m_Option.iViewWidth), pszIniFile); + WritePrivateProfileString("ViewPort", "Height", to_str(m_Option.iViewHeight), pszIniFile); + WritePrivateProfileString("ViewPort", "ColorDepth", to_str(m_Option.iViewColorDepth), pszIniFile); + WritePrivateProfileString("ViewPort", "Distance", to_str(m_Option.iViewDist), pszIniFile); + WritePrivateProfileString("Effect", "Count", to_str(m_Option.iEffectCount), pszIniFile); + WritePrivateProfileString("Sound", "Distance", to_str(m_Option.iEffectSndDist), pszIniFile); + WritePrivateProfileString("Sound", "Bgm", to_str(m_Option.bSndBackground), pszIniFile); + WritePrivateProfileString("Sound", "Effect", to_str(m_Option.bSndEffect), pszIniFile); + WritePrivateProfileString("Sound", "Duplicate", to_str(m_Option.bSndDuplicated), pszIniFile); + WritePrivateProfileString("Cursor", "WindowCursor", to_str(m_Option.bWindowCursor), pszIniFile); + WritePrivateProfileString("Screen", "WindowMode", to_str(m_Option.bWindowMode), pszIniFile); + WritePrivateProfileString("WeaponEffect", "EffectVisible", to_str(m_Option.bWeaponEffect), pszIniFile); } -void COptionDlg::SettingLoad(const std::string & szIniFile) { - auto szFile = szIniFile.c_str(); - m_Option.iTexLOD_Chr = GetPrivateProfileInt("Texture", "LOD_Chr", 0, szFile); - m_Option.iTexLOD_Shape = GetPrivateProfileInt("Texture", "LOD_Shape", 0, szFile); - m_Option.iTexLOD_Terrain = GetPrivateProfileInt("Texture", "LOD_Terrain", 0, szFile); - m_Option.iUseShadow = GetPrivateProfileInt("Shadow", "Use", 1, szFile); - m_Option.iViewWidth = GetPrivateProfileInt("ViewPort", "Width", 1024, szFile); - m_Option.iViewHeight = GetPrivateProfileInt("ViewPort", "Height", 768, szFile); - m_Option.iViewColorDepth = GetPrivateProfileInt("ViewPort", "ColorDepth", 16, szFile); - m_Option.iViewDist = GetPrivateProfileInt("ViewPort", "Distance", 512, szFile); - m_Option.iEffectSndDist = GetPrivateProfileInt("Sound", "Distance", 48, szFile); - m_Option.iEffectCount = GetPrivateProfileInt("Effect", "Count", 2000, szFile); - - int iSndBackground = GetPrivateProfileInt("Sound", "Bgm", 1, szFile); +void COptionDlg::SettingLoad(const fs::path & fsIniFile) { + std::string szIniFile = fsIniFile.string(); + const char * pszIniFile = szIniFile.c_str(); + + m_Option.iTexLOD_Chr = GetPrivateProfileInt("Texture", "LOD_Chr", 0, pszIniFile); + m_Option.iTexLOD_Shape = GetPrivateProfileInt("Texture", "LOD_Shape", 0, pszIniFile); + m_Option.iTexLOD_Terrain = GetPrivateProfileInt("Texture", "LOD_Terrain", 0, pszIniFile); + m_Option.iUseShadow = GetPrivateProfileInt("Shadow", "Use", 1, pszIniFile); + m_Option.iViewWidth = GetPrivateProfileInt("ViewPort", "Width", 1024, pszIniFile); + m_Option.iViewHeight = GetPrivateProfileInt("ViewPort", "Height", 768, pszIniFile); + m_Option.iViewColorDepth = GetPrivateProfileInt("ViewPort", "ColorDepth", 16, pszIniFile); + m_Option.iViewDist = GetPrivateProfileInt("ViewPort", "Distance", 512, pszIniFile); + m_Option.iEffectSndDist = GetPrivateProfileInt("Sound", "Distance", 48, pszIniFile); + m_Option.iEffectCount = GetPrivateProfileInt("Effect", "Count", 2000, pszIniFile); + + int iSndBackground = GetPrivateProfileInt("Sound", "Bgm", 1, pszIniFile); m_Option.bSndBackground = iSndBackground ? true : false; - int iSndEffect = GetPrivateProfileInt("Sound", "Effect", 1, szFile); + int iSndEffect = GetPrivateProfileInt("Sound", "Effect", 1, pszIniFile); m_Option.bSndEffect = iSndEffect ? true : false; - int iSndDuplicate = GetPrivateProfileInt("Sound", "Duplicate", 0, szFile); + int iSndDuplicate = GetPrivateProfileInt("Sound", "Duplicate", 0, pszIniFile); m_Option.bSndDuplicated = iSndDuplicate ? true : false; - int iWindowCursor = GetPrivateProfileInt("Cursor", "WindowCursor", 1, szFile); + int iWindowCursor = GetPrivateProfileInt("Cursor", "WindowCursor", 1, pszIniFile); m_Option.bWindowCursor = iWindowCursor ? true : false; - int iWindowMode = GetPrivateProfileInt("Screen", "WindowMode", false, szFile); + int iWindowMode = GetPrivateProfileInt("Screen", "WindowMode", false, pszIniFile); m_Option.bWindowMode = iWindowMode ? true : false; - int iWeaponEffect = GetPrivateProfileInt("WeaponEffect", "EffectVisible", true, szFile); + int iWeaponEffect = GetPrivateProfileInt("WeaponEffect", "EffectVisible", true, pszIniFile); m_Option.bWeaponEffect = iWeaponEffect ? true : false; } -void COptionDlg::SettingServerLoad(const std::string & szIniFile) { - m_ServerOption.Version = GetPrivateProfileInt("Version", "Files", 1264, szIniFile.c_str()); +void COptionDlg::SettingServerLoad(const fs::path & fsIniFile) { + std::string szIniFile = fsIniFile.string(); + const char * pszIniFile = szIniFile.c_str(); + + m_ServerOption.Version = GetPrivateProfileInt("Version", "Files", m_ServerOption.Version, pszIniFile); } -void COptionDlg::SettingServerSave(const std::string & szIniFile) { - WritePrivateProfileString("Version", "Files", to_str(m_ServerOption.Version), szIniFile.c_str()); +void COptionDlg::SettingServerSave(const fs::path & fsIniFile) { + std::string szIniFile = fsIniFile.string(); + const char * pszIniFile = szIniFile.c_str(); + + WritePrivateProfileString("Version", "Files", to_str(m_ServerOption.Version), pszIniFile); } void COptionDlg::SettingUpdate() { @@ -416,8 +426,11 @@ void COptionDlg::OnBVersion() { VersionUpdate((fs::current_path() / "Server.ini").string(), iVersion); } -void COptionDlg::VersionUpdate(const std::string & szIniFile, int Version) { +void COptionDlg::VersionUpdate(const fs::path & fsIniFile, int Version) { + std::string szIniFile = fsIniFile.string(); + const char * pszIniFile = szIniFile.c_str(); + m_ServerOption.Version = Version; - auto szVersion = std::to_string(m_ServerOption.Version); - WritePrivateProfileString("Version", "Files", szVersion.c_str(), szIniFile.c_str()); + std::string szVersion = std::to_string(m_ServerOption.Version); + WritePrivateProfileString("Version", "Files", szVersion.c_str(), pszIniFile); } diff --git a/src/tool/Option/OptionDlg.h b/src/tool/Option/OptionDlg.h index 1beb705d..7141a88c 100644 --- a/src/tool/Option/OptionDlg.h +++ b/src/tool/Option/OptionDlg.h @@ -59,11 +59,11 @@ class COptionDlg : public CDialog { // Construction public: void SettingUpdate(); - void SettingLoad(const std::string & szIniFile); - void SettingServerLoad(const std::string & szIniFile); - void SettingSave(const std::string & szIniFile); - void SettingServerSave(const std::string & szIniFile); - void VersionUpdate(const std::string & szIniFile, int Version); + void SettingLoad(const fs::path & fsIniFile); + void SettingServerLoad(const fs::path & fsIniFile); + void SettingSave(const fs::path & fsIniFile); + void SettingServerSave(const fs::path & fsIniFile); + void VersionUpdate(const fs::path & fsIniFile, int Version); COptionDlg(CWnd * pParent = NULL); // standard constructor // Dialog Data diff --git a/src/tool/PlugIn_Max/DllEntry.cpp b/src/tool/PlugIn_Max/DllEntry.cpp index 34c16ff6..bf31c450 100644 --- a/src/tool/PlugIn_Max/DllEntry.cpp +++ b/src/tool/PlugIn_Max/DllEntry.cpp @@ -10,6 +10,8 @@ *> Copyright (c) 1997, All Rights Reserved. **********************************************************************/ +#include "StdAfx.h" + #include "N3DExp.h" extern ClassDesc * GetCN3DExpDesc(); diff --git a/src/tool/PlugIn_Max/N3DExp.cpp b/src/tool/PlugIn_Max/N3DExp.cpp index 8d2d5780..dc2640a2 100644 --- a/src/tool/PlugIn_Max/N3DExp.cpp +++ b/src/tool/PlugIn_Max/N3DExp.cpp @@ -11,6 +11,8 @@ *> Copyright (c) 1997, All Rights Reserved. **********************************************************************/ +#include "StdAfx.h" + #include "N3Base/N3PMeshCreate.h" #include "N3DExp.h" @@ -37,10 +39,9 @@ CN3DExp::CN3DExp() { this->Init(); // allocation CN3Eng, CN3Scene | Init Engine - // if(NULL == g_Eng.s_lpD3DDev) - // { - // g_Eng.Init(TRUE, NULL, 64, 64, 0, FALSE); - // } + //if (!g_Eng.s_lpD3DDev) { + // g_Eng.Init(TRUE, NULL, 64, 64, 0, FALSE); + //} m_pScene = NULL; } @@ -66,8 +67,8 @@ void CN3DExp::Init() { m_nNodeCur = 0; m_nNodeCount = 0; - lstrcpy(m_szPath, ""); // Path Name - lstrcpy(m_szFileName, ""); // File Name + m_fsDir = fs::path(); + m_fsFile = fs::path(); } int CN3DExp::ExtCount() { @@ -119,7 +120,7 @@ void CN3DExp::ShowAbout(HWND hWnd) { // Optional } -int CN3DExp::DoExport(const TCHAR * szFileName, ExpInterface * pExpIntf, Interface * pIntf, BOOL suppressPrompts, +int CN3DExp::DoExport(const fs::path & fsFile, ExpInterface * pExpIntf, Interface * pIntf, BOOL suppressPrompts, DWORD dwOptions) { // Interface Object Pointer g_pIntf = pIntf; @@ -145,7 +146,7 @@ int CN3DExp::DoExport(const TCHAR * szFileName, ExpInterface * pExpIntf, Interfa delete m_pScene; m_pScene = new CN3Scene(); m_pScene->ReleaseResrc(); - lstrcpy(m_szFileName, szFileName); // Set File Name + m_fsFile = fsFile; // Option Dialog int rval = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_EXPORT_OPTION), pIntf->GetMAXHWnd(), DlgProcExportOption, @@ -175,16 +176,11 @@ int CN3DExp::DoExport(const TCHAR * szFileName, ExpInterface * pExpIntf, Interfa // Scene Save // sub directory가 있다면 sub directory 만들기 - char szDir[_MAX_DIR] = ""; - ::CreateDirectory(m_Option.szSubDir, NULL); - wsprintf(szDir, "%sData", m_Option.szSubDir); - ::CreateDirectory(szDir, NULL); - wsprintf(szDir, "%sChr", m_Option.szSubDir); - ::CreateDirectory(szDir, NULL); - wsprintf(szDir, "%sObject", m_Option.szSubDir); - ::CreateDirectory(szDir, NULL); - wsprintf(szDir, "%sItem", m_Option.szSubDir); - ::CreateDirectory(szDir, NULL); + fs::create_directory(m_Option.fsSubDir); + fs::create_directory(m_Option.fsSubDir / "Data"); + fs::create_directory(m_Option.fsSubDir / "Chr"); + fs::create_directory(m_Option.fsSubDir / "Object"); + fs::create_directory(m_Option.fsSubDir / "Item"); // 만약 카메라가 하나도 없다면.. if (m_pScene->CameraCount() <= 0) { @@ -193,7 +189,7 @@ int CN3DExp::DoExport(const TCHAR * szFileName, ExpInterface * pExpIntf, Interfa if (m_pScene->LightCount() <= 0) { m_pScene->DefaultLightAdd(); } - m_pScene->SaveDataAndResourcesToFile(szFileName); // Scene 파일 저장 및 리소스 도 모두 저장.. + m_pScene->SaveDataAndResourcesToFile(fsFile); // Scene 파일 저장 및 리소스 도 모두 저장.. m_pScene->Release(); m_pScene->ReleaseResrc(); @@ -428,12 +424,9 @@ bool CN3DExp::ProcessShape(INode * pNode) { __Material mtl; mtl.Init(); CN3Texture * pTex = NULL; - this->ProcessMaterial(pNode, &mtl, &pTex, "Object\\"); + this->ProcessMaterial(pNode, &mtl, &pTex, "Object"); if (pTex) { - // char szDrv[_MAX_DIR], szDir[_MAX_DIR], szFName[_MAX_FNAME]; - // _splitpath(pTex->FileName().c_str(), szDrv, szDir, szFName, NULL); - // char szFN[256]; wsprintf(szFN, "Object\\%s.dxt", szFName); - pTex->FileNameSet(pTex->FileName()); + pTex->FilePathSet(pTex->FilePath()); } CN3Shape * pShape = NULL; @@ -481,7 +474,7 @@ bool CN3DExp::ProcessShape(INode * pNode) { } bool bCollision = false; - ::CharLower(N3IMesh.m_szName.begin()); // 소문자로 만들고.. + n3std::to_lower(N3IMesh.m_szName); if (N3IMesh.m_szName.find("coll") != -1) { // "collision" 이라는 문자열 확인 .. 그러나 오타에 대비해서 "coll" 까지만 확인 bCollision = true; @@ -495,16 +488,15 @@ bool CN3DExp::ProcessShape(INode * pNode) { CN3VMesh * pVMesh = new CN3VMesh(); pVMesh->Import(&N3IMesh); // 메시 만들고.. Indexed 메시로부터 Import.. - std::string szVMeshFN = "Object\\" + pShape->m_szName + ".n3vmesh"; // 이름짓기.. - if (lstrlen(m_Option.szSubDir) > 0) { - szVMeshFN = std::string(m_Option.szSubDir) + szVMeshFN; // sub directory 있으면 추가 + fs::path fsVmeshFile = fs::path("Object") / (pShape->m_szName + ".n3vmesh"); // 이름짓기.. + if (!m_Option.fsSubDir.empty()) { + fsVmeshFile = m_Option.fsSubDir / fsVmeshFile; // sub directory 있으면 추가 } - pVMesh->FileNameSet(szVMeshFN); // 이름짓기.. - CN3Base::s_MngVMesh.Add(pVMesh); // 매니저에 넣고.. + pVMesh->FilePathSet(fsVmeshFile); // 이름짓기.. + CN3Base::s_MngVMesh.Add(pVMesh); // 매니저에 넣고.. - pShape->CollisionMeshSet(szVMeshFN); // 충돌메시 세팅.. - } else // 충돌 체크 메시가 아니면 파트 추가.. - { + pShape->CollisionMeshSet(fsVmeshFile); // 충돌메시 세팅.. + } else { // 충돌 체크 메시가 아니면 파트 추가.. // Part 추가.. Part Data 세팅.. CN3SPart * pPD = pShape->PartAdd(); this->ProcessName(pNode, pPD); // 파트 이름.. @@ -529,10 +521,10 @@ bool CN3DExp::ProcessShape(INode * pNode) { this->ProcessName(pNode, pPMesh); pShape->s_MngPMesh.Add(pPMesh); - pPD->MeshSet(pPMesh->FileName()); + pPD->MeshSet(pPMesh->FilePath()); if (pTex) { pPD->TexAlloc(1); // Texture 할당.. - pPD->TexSet(0, pTex->FileName()); + pPD->TexSet(0, pTex->FilePath()); } pPD->m_Mtl = mtl; pPD->m_vPivot = vOffset - pShape->Pos(); // Pivot point 를 얻고.. @@ -610,13 +602,9 @@ BOOL CALLBACK CN3DExp::DlgProcExportOption(HWND hWndDlg, UINT uMsg, WPARAM wPara m_Option.bGenerateHalfSizeTexture = IsDlgButtonChecked(hWndDlg, IDC_C_GENERATE_HALF_SIZE_TEXTURE); m_Option.bGenerateCompressedTexture = IsDlgButtonChecked(hWndDlg, IDC_C_GENERATE_COMPRESSED_TEXTURE); - GetDlgItemText(hWndDlg, IDC_E_SUBDIR, m_Option.szSubDir, _MAX_DIR); - int iStrLen = lstrlen(m_Option.szSubDir); - if (iStrLen > 0) { - if ('\\' != m_Option.szSubDir[iStrLen - 1]) { - lstrcat(m_Option.szSubDir, "\\"); - } - } + wchar_t szSubDir[_MAX_DIR]{}; + GetDlgItemText(hWndDlg, IDC_E_SUBDIR, szSubDir, std::size(szSubDir)); + m_Option.fsSubDir = szSubDir; EndDialog(hWndDlg, 1); @@ -712,7 +700,7 @@ bool CN3DExp::ProcessName(INode * pNode, CN3BaseFileAccess * pBase) { // 캐릭터 파트나 캐릭터 파트 스킨일 경우 내가 본 노드이면 나의 이름을 넣지 않는다. if ((dwType & (OBJ_CHARACTER_PART | OBJ_CHARACTER_PART_SKINS)) && IsBone(pNode)) { } else { - if (!(pBase->m_szName.empty())) { + if (!pBase->m_szName.empty()) { std::string szTmp = pNode->GetName(); szTmp += '_'; szTmp += pBase->m_szName; @@ -729,81 +717,74 @@ bool CN3DExp::ProcessName(INode * pNode, CN3BaseFileAccess * pBase) { } } - char szDir[32] = ""; - char szExt[32] = ""; - + fs::path fsDir; + std::string szExt; if (dwType & OBJ_SHAPE) { - lstrcpy(szDir, "Object\\"); - lstrcpy(szExt, ".N3Shape"); + fsDir = "Object"; + szExt = ".n3shape"; } else if (dwType & OBJ_SHAPE_PART) { - lstrcpy(szDir, "Object\\"); - lstrcpy(szExt, ".N3SPart"); + fsDir = "Object"; + szExt = ".n3spart"; } else if (dwType & OBJ_MESH) { - lstrcpy(szDir, "Object\\"); - lstrcpy(szExt, ".N3Mesh"); + fsDir = "Object"; + szExt = ".n3mesh"; } else if (dwType & OBJ_MESH_PROGRESSIVE) { - lstrcpy(szDir, "Object\\"); - lstrcpy(szExt, ".N3PMesh"); + fsDir = "Object"; + szExt = ".n3pmesh"; } else if (dwType & OBJ_MESH_VECTOR3) { - lstrcpy(szDir, "Object\\"); - lstrcpy(szExt, ".N3VMesh"); - } - - else if (dwType & OBJ_CHARACTER) { - lstrcpy(szDir, "Chr\\"); - lstrcpy(szExt, ".N3Chr"); + fsDir = "Object"; + szExt = ".n3vmesh"; + } else if (dwType & OBJ_CHARACTER) { + fsDir = "Chr"; + szExt = ".n3chr"; } else if (dwType & OBJ_JOINT) { - lstrcpy(szDir, "Chr\\"); - lstrcpy(szExt, ".N3Joint"); + fsDir = "Chr"; + szExt = ".n3joint"; } else if (dwType & OBJ_CHARACTER_PART) { - lstrcpy(szDir, "Item\\"); - lstrcpy(szExt, ".N3CPart"); + fsDir = "Item"; + szExt = ".n3cpart"; } else if (dwType & OBJ_CHARACTER_PART_SKINS) { - lstrcpy(szDir, "Item\\"); - lstrcpy(szExt, ".N3CSkins"); + fsDir = "Item"; + szExt = ".n3cskins"; } else if (dwType & OBJ_MESH_INDEXED) { - lstrcpy(szDir, "Item\\"); - lstrcpy(szExt, ".N3IMesh"); + fsDir = "Item"; + szExt = ".n3imesh"; } else if (dwType & OBJ_SKIN) { - lstrcpy(szDir, "Item\\"); - lstrcpy(szExt, ".N3Skin"); + fsDir = "Item"; + szExt = ".n3skin"; } else if (dwType & OBJ_CHARACTER_PLUG) { - lstrcpy(szDir, "Item\\"); - lstrcpy(szExt, ".N3CPlug"); - } - - else if (dwType & OBJ_TEXTURE) { - lstrcpy(szDir, "Texture\\"); - lstrcpy(szExt, ".DXT"); + fsDir = "Item"; + szExt = ".n3cplug"; + } else if (dwType & OBJ_TEXTURE) { + fsDir = "Texture"; + szExt = ".dxt"; } else if (dwType & OBJ_SCENE) { - lstrcpy(szDir, ""); - lstrcpy(szExt, ".N3Scene"); - } - - else { - lstrcpy(szDir, "Data\\"); + fsDir = ""; + szExt = ".n3scene"; + } else { + fsDir = "Data"; if (dwType & OBJ_CAMERA) { - lstrcpy(szExt, ".N3Camera"); + szExt = ".n3camera"; } else if (dwType & OBJ_LIGHT) { - lstrcpy(szExt, ".N3Light"); + szExt = ".n3light"; } else if (dwType & OBJ_TRANSFORM) { - lstrcpy(szExt, ".N3Transform"); + szExt = ".n3transform"; } else if (dwType & OBJ_BASE) { - lstrcpy(szExt, ".N3Base"); + szExt = ".n3base"; } else { - lstrcpy(szExt, ".Unknown"); + szExt = ".unknown"; } } // sub directory 가 있으면 추가한다. - std::string szFN; - if (lstrlen(m_Option.szSubDir) > 0) { - szFN = std::string(m_Option.szSubDir) + szDir + pBase->m_szName + szExt; + fs::path fsFile; + if (!m_Option.fsSubDir.empty()) { + fsFile = m_Option.fsSubDir / fsDir / (pBase->m_szName + szExt); } else { - szFN = szDir + pBase->m_szName + szExt; + fsFile = fsDir / (pBase->m_szName + szExt); } - pBase->FileNameSet(szFN); + pBase->FilePathSet(fsFile); return true; } @@ -856,20 +837,19 @@ bool CN3DExp::ProcessChr(INode * pNode) { this->ProcessName(pNode, pChr); pChr->s_MngJoint.Add(pJoint); - pChr->JointSet(pJoint->FileName()); + pChr->JointSet(pJoint->FilePath()); m_pScene->ChrAdd(pChr); - pChr->m_szName = "Temp"; - pChr->FileNameSet(std::string("Chr\\Temp.n3Chr")); + pChr->m_szName = "temp"; + pChr->FilePathSet("Chr" / "temp.n3chr"); pChr->PartAlloc(64); // 충분하게 Part Data 할당.. save할때 불필요한 데이터는 제거된다. for (int i = 0; i < 64; i++) { CN3CPart * pPDAdd = pChr->Part(i); CN3CPartSkins * pSkinAdd = new CN3CPartSkins(); - char szNameTmp[256]; - wsprintf(szNameTmp, "chr\\temp_%d.N3CSkins", i); - pSkinAdd->FileNameSet(szNameTmp); + fs::path fsTmpFile = fs::path("Chr") / std::format("temp_{:d}.n3cskins", i); + pSkinAdd->FilePathSet(fsTmpFile); CN3Base::s_MngSkins.Add(pSkinAdd); - pPDAdd->SkinsSet(szNameTmp); + pPDAdd->SkinsSet(fsTmpFile); CN3Base::s_MngSkins.Delete(&pSkinAdd); // 이렇게 해주어야 참조 카운트가 하나 줄어든다.. } @@ -886,7 +866,7 @@ bool CN3DExp::ProcessChr(INode * pNode) { bool bCollisionMesh = false; std::string szFNM = pNodeTmp->GetName(); if (szFNM.size() > 0) { - CharLower(&(szFNM[0])); + n3std::to_lower(szFNM); } if (szFNM.find("coll") != -1) { bCollisionMesh = true; @@ -970,13 +950,9 @@ bool CN3DExp::ProcessChr(INode * pNode) { } CN3Texture * pTex = NULL; - this->ProcessMaterial(pNodeTmp, &(pPart->m_Mtl), &pTex, "Item\\"); + this->ProcessMaterial(pNodeTmp, &(pPart->m_Mtl), &pTex, "Item"); if (pTex) { - // char szDrv[_MAX_DIR], szDir[_MAX_DIR], szFName[_MAX_FNAME]; - // _splitpath(pTex->FileName().c_str(), szDrv, szDir, szFName, NULL); - // char szFN[256]; wsprintf(szFN, "Item\\%s.dxt", szFName); - // pTex->FileNameSet(szFN); - pPart->TexSet(pTex->FileName()); + pPart->TexSet(pTex->FilePath()); } ProcessName(pNodeTmp, pPart); // 이름 짓기 ProcessName(pNodeTmp, pSkins); // 이름 짓기 @@ -1243,9 +1219,8 @@ bool CN3DExp::ProcessJoint(INode * pNode, CN3Joint * pJoint) { // 이름이 너무 기니까.. 강제로 한다. pJoint->m_szName = pNode->GetName(); - char szJFN[256]; - wsprintf(szJFN, "%sChr\\%s.N3Joint", m_Option.szSubDir, pNode->GetName()); - pJoint->FileNameSet(szJFN); + fs::path fsJointFile = m_Option.fsSubDir / "Chr" / (pJoint->m_szName + ".n3joint"); + pJoint->FilePathSet(fsJointFile); /////////////////////////////////////// // 자식 객체 처리.. @@ -1570,7 +1545,7 @@ bool CN3DExp::ProcessIMesh(INode * pNode, CN3IMesh * pIMesh) { return true; } -bool CN3DExp::ProcessMaterial(INode * pNode, __Material * pMtl, CN3Texture ** ppTex, LPCTSTR pszDir) { +bool CN3DExp::ProcessMaterial(INode * pNode, __Material * pMtl, CN3Texture ** ppTex, const fs::path & fsDir) { if (NULL == pNode || NULL == pMtl || NULL == ppTex) { return false; } @@ -1586,23 +1561,18 @@ bool CN3DExp::ProcessMaterial(INode * pNode, __Material * pMtl, CN3Texture ** pp } // Methods to access sub-materials of meta-materials - // Mtl* pmMtlTmp = NULL; + //Mtl * pmMtlTmp = NULL; int nSM = pmMtl->NumSubMtls(); - // if(nSM > 0) - // { - // for(int i = 0; i < nSM; i++) - // { - // if(pmMtl->GetSubMtl(i) != NULL) - // { - // pmMtlTmp = pmMtl->GetSubMtl(i); - // break; - // } + //if (nSM > 0) { + // for (int i = 0; i < nSM; i++) { + // if (pmMtl->GetSubMtl(i) != NULL) { + // pmMtlTmp = pmMtl->GetSubMtl(i); + // break; // } // } - // else - // { - // pmMtlTmp = pmMtl; - // } + //} else { + // pmMtlTmp = pmMtl; + //} if (pmMtl && pmMtl->GetSubTexmap(1) != NULL) // 텍스처가 씌어 있는 재질이면. { @@ -1614,44 +1584,28 @@ bool CN3DExp::ProcessMaterial(INode * pNode, __Material * pMtl, CN3Texture ** pp } if (pBMT && lstrlen(pBMT->GetMapName()) > 0) { - std::string szBMPFN, szBMPFN2; - char szDrv[32], szDir[128], szName[128], szExt[128]; - szBMPFN = pBMT->GetMapName(); - _splitpath(szBMPFN.c_str(), szDrv, szDir, szName, szExt); - - // sub directory 지정되어 있으면 붙이기 - if (lstrlen(m_Option.szSubDir) > 0) { - szBMPFN2 = std::string(m_Option.szSubDir); - } else { - szBMPFN2 = ""; - } - - // 텍스쳐 폴더 경로 붙이기 - if (pszDir) { - szBMPFN2 += pszDir; - } else { - szBMPFN2 += "Texture\\"; - } - szBMPFN2 += szName; - szBMPFN2 += ".DXT"; // 이름과 확장자를 바꾸어 준다.. + fs::path fsBmpFile = pBMT->GetMapName(); + fsBmpFile.make_lower(); - CharLower(szBMPFN.begin()); - CharLower(szBMPFN2.begin()); + fs::path fsBmpFile2 = m_Option.fsSubDir; + fsBmpFile2 /= fsDir.empty() ? "Texture" : fsDir; + fsBmpFile2 /= fsBmpFile.stem() + ".dxt"; + fsBmpFile2.make_lower(); int nTCPrev = m_pScene->s_MngTex.Count(); // 텍스처 중복 체크.. bool bOverlapped = false; for (int i = 0; i < nTCPrev; i++) { - if (m_pScene->s_MngTex.Get(i)->FileName() == szBMPFN2) { + if (m_pScene->s_MngTex.Get(i)->FilePath() == fsBmpFile2) { bOverlapped = true; } } if (bOverlapped) { - (*ppTex) = m_pScene->s_MngTex.Get(szBMPFN2); // 비트맵을 읽고.. + (*ppTex) = m_pScene->s_MngTex.Get(fsBmpFile2); // 비트맵을 읽고.. } else { (*ppTex) = new CN3Texture(); - if (false == (*ppTex)->LoadFromFile(szBMPFN)) // 비트맵 읽기가 실패하면.. + if (false == (*ppTex)->LoadFromFile(fsBmpFile)) // 비트맵 읽기가 실패하면.. { delete (*ppTex); (*ppTex) = NULL; @@ -1659,7 +1613,7 @@ bool CN3DExp::ProcessMaterial(INode * pNode, __Material * pMtl, CN3Texture ** pp } else // 비트맵을 읽었으면.. { (*ppTex)->m_szName = pBMT->GetName(); - (*ppTex)->FileNameSet(szBMPFN2); + (*ppTex)->FilePathSet(fsBmpFile2); m_pScene->s_MngTex.Add(*ppTex); // Texture Manager 에 넣어준다. CN3Texture * pTex = *ppTex; diff --git a/src/tool/PlugIn_Max/N3DExp.h b/src/tool/PlugIn_Max/N3DExp.h index 847421fb..c543587b 100644 --- a/src/tool/PlugIn_Max/N3DExp.h +++ b/src/tool/PlugIn_Max/N3DExp.h @@ -67,9 +67,9 @@ struct __UVWH { //------------------------------------------------------------------------------------------------------ class CN3DExp : public SceneExport { public: - char m_szPath[1024]; // Path Name - char m_szFileName[1024]; // File Name - CN3Scene * m_pScene; // N3Scene + fs::path m_fsDir; + fs::path m_fsFile; + CN3Scene * m_pScene; // N3Scene protected: static __EXPORT_OPTION m_Option; // Export Option - Window Procedure 땜시 Static 으로 쓴다.. @@ -84,7 +84,7 @@ class CN3DExp : public SceneExport { void Init(); bool ProcessIMesh(INode * pNode, CN3IMesh * pIMesh); - bool ProcessMaterial(INode * pNode, __Material * pMtl, CN3Texture ** pTex, LPCTSTR pszDir); + bool ProcessMaterial(INode * pNode, __Material * pMtl, CN3Texture ** pTex, const fs::path & fsDir); bool ProcessRecursive(INode * pNode); // Parent Node -> Child Node bool ProcessName(INode * pNode, CN3BaseFileAccess * pBase); // Process Make Name bool ProcessCamera(INode * pNode); // Export Camera Data @@ -125,7 +125,7 @@ class CN3DExp : public SceneExport { const TCHAR * OtherMessage2(); // Other message #2 unsigned int Version(); // Version number * 100 (i.e. v3.01 = 301) void ShowAbout(HWND hWnd); // Show DLL's "About..." box - int DoExport(const TCHAR * name, ExpInterface * ei, Interface * i, BOOL suppressPrompts, + int DoExport(const fs::path & fsFile, ExpInterface * ei, Interface * i, BOOL suppressPrompts, DWORD options); // Export file CN3DExp(); //Constructor diff --git a/src/tool/PlugIn_Maya/N3E2Translator.cpp b/src/tool/PlugIn_Maya/N3E2Translator.cpp index ec2b885b..7ac5bbee 100644 --- a/src/tool/PlugIn_Maya/N3E2Translator.cpp +++ b/src/tool/PlugIn_Maya/N3E2Translator.cpp @@ -19,8 +19,12 @@ // N3E2 Translator Maya specific source // +#include "StdAfx.h" + #include "N3E2Translator.h" +#include + // Initialize our magic "number" MString CN3E2Translator::magic("filetype gx"); // A GE2 file is an ascii file where the 1st line contains @@ -59,14 +63,13 @@ MStatus CN3E2Translator::writer(const MFileObject & fileObject, const MString & options.split(';', optionList); } - char szFN[256] = ""; - lstrcpy(szFN, fileObject.name().asChar()); - CharLower(szFN); - if (strstr(szFN, ".n3scene") == NULL) { - lstrcat(szFN, ".n3scene"); + fs::path fsFile = fileObject.name().asUTF8(); + fsFile.make_lower(); + if (!n3std::iequals(fsFile.extension(), ".n3scene")) { + fsFile.replace_extension(".n3scene"); } - m_Wrapper.SetFileName(szFN); + m_Wrapper.SetFileName(fsFile); m_Wrapper.SetPath(fileObject.path().asChar()); m_Wrapper.SceneExport(); @@ -77,21 +80,15 @@ MStatus CN3E2Translator::writer(const MFileObject & fileObject, const MString & MPxFileTranslator::MFileKind CN3E2Translator::identifyFile(const MFileObject & fileName, const char * buffer, short size) const { - //Check the buffer for the "GE2" magic number, the - // string "filetype gx" - MFileKind rval = kNotMyFileType; - - const char * szFN = fileName.name().asChar(); - int nFN = lstrlen(szFN); - if (lstrcmpi(&szFN[nFN - 4], ".N3Scene") == 0 || lstrcmpi(&szFN[nFN - 7], ".N3Camera") == 0 || - lstrcmpi(&szFN[nFN - 7], ".N3Light") == 0 || lstrcmpi(&szFN[nFN - 7], ".N3Mesh") == 0 || - lstrcmpi(&szFN[nFN - 7], ".N3PMesh") == 0 || lstrcmpi(&szFN[nFN - 7], ".N3Shape") == 0 || - lstrcmpi(&szFN[nFN - 7], ".N3Joint") == 0 || lstrcmpi(&szFN[nFN - 7], ".N3IMesh") == 0 || - lstrcmpi(&szFN[nFN - 7], ".N3DSKN") == 0) { - rval = kIsMyFileType; + static const std::unordered_set vSupportedExts = { + ".N3Scene", ".N3Camera", ".N3Light", ".N3Mesh", ".N3PMesh", ".N3Shape", ".N3Joint", ".N3IMesh", ".N3DSKN"}; + + fs::path fsFile = fileName.name().asUTF8(); + if (vSupportedExts.contains(fsFile.extension().string())) { + return kIsMyFileType; } - return rval; + return kNotMyFileType; } // Shouldn't be any C functions trying to call us, should there? diff --git a/src/tool/PlugIn_Maya/N3E2Wrapper.cpp b/src/tool/PlugIn_Maya/N3E2Wrapper.cpp index 118eca7b..f63a7d15 100644 --- a/src/tool/PlugIn_Maya/N3E2Wrapper.cpp +++ b/src/tool/PlugIn_Maya/N3E2Wrapper.cpp @@ -44,6 +44,8 @@ extern const char * objectName(MObject object); +#include + BOOL CN3E2Wrapper::m_bCancelExport = FALSE; __EXPORT_OPTION CN3E2Wrapper::m_Option; @@ -88,8 +90,8 @@ void CN3E2Wrapper::Release() { m_Option.bGenerateCompressedTexture = TRUE; m_Option.fSamplingRate = 30.0f; - lstrcpy(m_szPath, ""); // 경로 이름 - lstrcpy(m_szFileName, ""); // 파일 이름 + m_fsDir = fs::path(); + m_fsFile = fs::path(); delete m_pScene; m_pScene = NULL; @@ -97,12 +99,12 @@ void CN3E2Wrapper::Release() { g_pEng = NULL; } -void CN3E2Wrapper::SetFileName(const char * szFileName) { - lstrcpy(m_szFileName, szFileName); // 파일 이름 +void CN3E2Wrapper::SetFileName(const fs::path & fsFile) { + m_fsFile = fsFile; } -void CN3E2Wrapper::SetPath(const char * szPath) { - lstrcpy(m_szPath, szPath); // 파일 이름 +void CN3E2Wrapper::SetPath(const fs::path & fsDir) { + m_fsDir = fsDir; } // 라이트 종류를 리턴. @@ -111,8 +113,8 @@ CN3Light * CN3E2Wrapper::ProcessLight(MFnLight & mLight) { MFnTransform mT = MFnTransform(mLight.parent(0)); this->ProcessTransform(mT, pLight); // Transform Node - pLight->m_szName = mT.name().asChar(); - pLight->FileNameSet("Data\\" + pLight->m_szName + ".N3Light"); // 파일 이름 결정.. + pLight->m_szName = mT.name().asUTF8(); + pLight->FilePathSet(fs::path("Data") / (pLight->m_szName + ".n3light")); // 파일 이름 결정.. // 라이트 종류 D3DCOLORVALUE dcv = {1, 1, 1, 1}; @@ -173,8 +175,7 @@ CN3Camera * CN3E2Wrapper::ProcessCamera(MFnCamera & mCamera) { CN3Camera * pCamera = new CN3Camera(); MFnTransform mT(mCamera.parent(0)); this->ProcessTransform(mT, pCamera); // Transform 처리.. - std::string szFN = "Data\\" + pCamera->m_szName + ".N3Camera"; - pCamera->FileNameSet(szFN); + pCamera->FilePathSet(fs::path("Data") / (pCamera->m_szName + ".n3camera")); // double dHFOV, dVFOV; // mCamera.getPortFieldOfView(800, 600, dHFOV, dVFOV); @@ -224,9 +225,7 @@ void CN3E2Wrapper::SceneExport() { // g_pEng->InitEnv(); g_pEng->Init(TRUE, hWnd, 64, 64, 0, FALSE); - char szPath[256]; - ::GetCurrentDirectory(256, szPath); - CN3Base::PathSet(szPath); // 경로 설정... + CN3Base::PathSet(fs::current_path()); m_pScene = new CN3Scene(); @@ -316,7 +315,7 @@ void CN3E2Wrapper::SceneExport() { if (MFn::kCamera == mType && TRUE == m_Option.bExportCamera) // 카메라.. { MFnCamera mCamera(mObj); - const char * szCamera = mCamera.name().asChar(); + const char * szCamera = mCamera.name().asUTF8(); if (strstr(szCamera, "front") == NULL && strstr(szCamera, "side") == NULL && strstr(szCamera, "top") == NULL) { CN3Camera * pCamera = this->ProcessCamera(mCamera); @@ -332,7 +331,7 @@ void CN3E2Wrapper::SceneExport() { } else if (mType == MFn::kMesh && TRUE == m_Option.bExportGeometry) { MFnMesh mMesh(mObj); - const char * szMeshName = mMesh.name().asChar(); + const char * szMeshName = mMesh.name().asUTF8(); bool bHaveJoint = false; // 만약 뼈대를 처리해야 하면.. if (TRUE == m_Option.bExportCharacter) { @@ -340,7 +339,7 @@ void CN3E2Wrapper::SceneExport() { } if (true == bHaveJoint) // 관절에 연결된 메시면 지나간다.. { - // wsprintf(szInfo, "Skinning 이 된 메시(%s)를 무시합니다.", mMesh.name().asChar()); + // wsprintf(szInfo, "Skinning 이 된 메시(%s)를 무시합니다.", mMesh.name().asUTF8()); // nLI = ::SendMessage(m_hWndLB, LB_ADDSTRING, 0, (LPARAM)szInfo); // Progress dialog // ::SendMessage(m_hWndLB, LB_SETCURSEL, (WPARAM)nLI,0); // Progress dialog continue; @@ -374,7 +373,7 @@ void CN3E2Wrapper::SceneExport() { if (mObj.hasFn(MFn::kDependencyNode) == true) { MFnDependencyNode node(mObj); wsprintf(szInfo, "%d/%d - Type : %s Name : %s", i, nObjectCount, mObj.apiTypeStr(), - node.name().asChar()); + node.name().asUTF8()); } else { wsprintf(szInfo, "%d/%d - Type : %s NoName", i, nObjectCount, mObj.apiTypeStr()); } @@ -403,7 +402,7 @@ void CN3E2Wrapper::SceneExport() { m_pScene->DefaultLightAdd(); // 기본 라이트 추가.. } - m_pScene->SaveDataAndResourcesToFile(m_szFileName); // Scene , Resource 저장.. + m_pScene->SaveDataAndResourcesToFile(m_fsFile); // Scene , Resource 저장.. m_pScene->Release(); } @@ -424,7 +423,7 @@ bool CN3E2Wrapper::ProcessIMesh(MFnMesh & mMesh, CN3IMesh * pIMesh) { // 이름 짓기.. MFnTransform mTM(mMesh.parent(0)); - pIMesh->m_szName = mTM.name().asChar(); + pIMesh->m_szName = mTM.name().asUTF8(); // Polygon 을 모두 삼각형 메시로 만들고 갯수를 세어준다.. int nPC = mMesh.numPolygons(); @@ -588,7 +587,7 @@ bool CN3E2Wrapper::ProcessVMesh(MFnMesh & mMesh, CN3VMesh * pVMesh) { mMesh.getPolygonVertices(i, mVIs); // polygon 에 있는 점 Index if (mVIs.length() != 3) { char szErr[256]; - wsprintf(szErr, "%s 는 삼각 폴리곤이 아닙니다.", mMesh.name().asChar()); + wsprintf(szErr, "%s 는 삼각 폴리곤이 아닙니다.", mMesh.name().asUTF8()); break; } @@ -603,8 +602,7 @@ bool CN3E2Wrapper::ProcessVMesh(MFnMesh & mMesh, CN3VMesh * pVMesh) { // 이름 처리.. pVMesh->m_szName = ""; this->ProcessName(mTransform.object(), pVMesh->m_szName); - std::string szFN = pVMesh->m_szName + ".N3VMesh"; - pVMesh->FileNameSet(szFN); + pVMesh->FilePathSet(pVMesh->m_szName + ".n3vmesh"); return true; } @@ -617,7 +615,7 @@ bool CN3E2Wrapper::ProcessSkin(MFnSkinCluster & mSkin, CN3Skin * pSkin) { int nLI = 0; DWORD dwRWC = 0; - char szInfo[1024] = ""; + char szInfo[1024]{}; MObjectArray mMeshArray; mSkin.getOutputGeometry(mMeshArray); @@ -637,7 +635,7 @@ bool CN3E2Wrapper::ProcessSkin(MFnSkinCluster & mSkin, CN3Skin * pSkin) { if (nGVC != nVC) { char szWarning[256]; MFnDagNode nodeTmp(mMeshOutput.parent(0)); - wsprintf(szWarning, "Mesh - %s, Skin - %s", nodeTmp.name().asChar(), mSkin.name().asChar()); + wsprintf(szWarning, "Mesh - %s, Skin - %s", nodeTmp.name().asUTF8(), mSkin.name().asUTF8()); MessageBox(::GetActiveWindow(), szWarning, "Warning - Skin vertex count is different to mesh vertex count", MB_OK); } @@ -685,7 +683,7 @@ bool CN3E2Wrapper::ProcessSkin(MFnSkinCluster & mSkin, CN3Skin * pSkin) { if (iFind > 0) { pSkin->m_szName = pSkin->m_szName.substr(iFind + 1); // 언더바가 있으면 잘라준다.. } - pSkin->FileNameSet("Item\\" + pSkin->m_szName + ".N3Skin"); // 파일 이름 결정.. + pSkin->FilePathSet(fs::path("Item") / (pSkin->m_szName + ".n3skin")); // 파일 이름 결정.. for (int i = 0; !mGIt.isDone(); mGIt.next(), i++) // 루프를 돌면서 컴포넌트(Geometry 의 한점...)을 처리한다. { @@ -792,8 +790,8 @@ bool CN3E2Wrapper::ProcessShape(MFnMesh & mMesh) { pShape = new CN3Shape(); this->ProcessTransform(mTG, pShape); pShape->m_szName = ""; - this->ProcessName(mTG.object(), pShape->m_szName); // 이름을 다시정하기. - pShape->FileNameSet("Object\\" + pShape->m_szName + ".N3Shape"); // 파일 이름 정하기.. + this->ProcessName(mTG.object(), pShape->m_szName); // 이름을 다시정하기. + pShape->FilePathSet(fs::path("Object") / (pShape->m_szName + ".n3shape")); // 파일 이름 정하기.. m_pScene->ShapeAdd(pShape); @@ -816,7 +814,7 @@ bool CN3E2Wrapper::ProcessShape(MFnMesh & mMesh) { // 이름에 "collision" 이라는 문자열이 들어가면.. 충돌 메시다.. std::string szTmp = IMesh.m_szName; if (szTmp.size()) { - CharLower(&(szTmp[0])); + n3std::to_lower(szTmp); } if (szTmp.find("coll") != -1 || szTmp.find("climb") != -1) { // 메시의 점위치를 피벗점에 대해 다시 계산.. Shape 의 로컬 좌표로 맞추어 준다.. @@ -826,8 +824,8 @@ bool CN3E2Wrapper::ProcessShape(MFnMesh & mMesh) { CN3VMesh * pVMesh = new CN3VMesh(); szNodeFullName = ""; this->ProcessName(mTM.object(), szNodeFullName); - pVMesh->m_szName = mTM.name().asChar(); // 이름 다시 정하고.. - pVMesh->FileNameSet("Object\\" + szNodeFullName + ".N3VMesh"); // 파일 이름 결정.. + pVMesh->m_szName = mTM.name().asUTF8(); // 이름 다시 정하고.. + pVMesh->FilePathSet(fs::path("Object") / (szNodeFullName + ".n3vmesh")); // 파일 이름 결정.. pVMesh->CreateVertices(nFC * 3); @@ -840,17 +838,17 @@ bool CN3E2Wrapper::ProcessShape(MFnMesh & mMesh) { } pShape->s_MngVMesh.Add(pVMesh); if (szTmp.find("coll") != -1) { - pShape->CollisionMeshSet(pVMesh->FileName()); + pShape->CollisionMeshSet(pVMesh->FilePath()); } else if (szTmp.find("climb") != -1) { - pShape->ClimbMeshSet(pVMesh->FileName()); + pShape->ClimbMeshSet(pVMesh->FilePath()); } } else // 충돌 메시가 아니면.. { CN3SPart * pPD = pShape->PartAdd(); // Part 추가 해주고.. szNodeFullName = ""; this->ProcessName(mTM.object(), szNodeFullName); - pPD->m_szName = mTM.name().asChar(); // Part 이름 짓기.. - pPD->FileNameSet("Object\\" + szNodeFullName + "N3CPart"); + pPD->m_szName = mTM.name().asUTF8(); // Part 이름 짓기.. + pPD->FilePathSet(fs::path("Object") / (szNodeFullName + ".n3cpart")); // 피벗점 계산 MPoint mvPivot = mTM.rotatePivot(MSpace::kTransform); @@ -883,18 +881,18 @@ bool CN3E2Wrapper::ProcessShape(MFnMesh & mMesh) { PMeshCreate.m_PMCOption.fWeight = 1.0f; // 사라지는 삼각형 가중치 (중요도) CN3PMesh * pPMesh = PMeshCreate.CreateRendererMesh(); // Progressive Mesh 생성 - pPMesh->m_szName = mTM.name().asChar(); // 걍 이름.. - std::string szFN; - this->ProcessName(mTM.object(), szFN); + pPMesh->m_szName = mTM.name().asUTF8(); // 걍 이름.. + std::string szFileName; + this->ProcessName(mTM.object(), szFileName); - int iLen = szFN.size(); + int iLen = szFileName.size(); if (m_Option.bGenerateFileName && iLen >= 11) { // Item Code ::: 0_2345_78_0 - szFN = szFN.substr(iLen - 11); + szFileName = szFileName.substr(iLen - 11); } - pPMesh->FileNameSet("Object\\" + szFN + ".N3PMesh"); // 파일 이름 결정.. + pPMesh->FilePathSet(fs::path("Object") / (szFileName + ".n3pmesh")); // 파일 이름 결정.. pShape->s_MngPMesh.Add(pPMesh); // Progressive Mesh Manager 에 추가.. - pPD->MeshSet(pPMesh->FileName()); // Mesh 세팅.. + pPD->MeshSet(pPMesh->FilePath()); // Mesh 세팅.. //////////////////////////////////////////////// // 재질 및 텍스처 처리.. @@ -902,16 +900,11 @@ bool CN3E2Wrapper::ProcessShape(MFnMesh & mMesh) { pPD->m_Mtl.dwColorArg2 = D3DTA_TEXTURE; CN3Texture * pTex = this->ProcessTexture(mMesh); - if (pTex) // 텍스처가 쓰인 재질이면 재질은 기본적인 흰색.. 컬러 오퍼레이션은 Modulate - { - std::string szTFN = pTex->FileName(); // 파일 이름을 검사해서.. - if (szTFN.size() > 0) { - CharLower(&(szTFN[0])); - } - if (-1 == szTFN.find("object\\")) // "Item\" 이라는 문자열이 없으면 - { - szTFN = "Object\\" + pTex->FileName(); // Item 이라는 경로를 붙인다.. - pTex->FileNameSet(szTFN); + if (pTex) { // 텍스처가 쓰인 재질이면 재질은 기본적인 흰색.. 컬러 오퍼레이션은 Modulate + fs::path fsTexFile = pTex->FilePath(); // 파일 이름을 검사해서.. + if (!fsTexFile.contains("object")) { + fsTexFile = "Object" / pTex->FilePath(); + pTex->FilePathSet(fsTexFile); } pPD->m_Mtl.dwColorOp = D3DTOP_MODULATE; @@ -949,15 +942,15 @@ CN3Joint * CN3E2Wrapper::ProcessJoint(MFnIkJoint & mJoint) { // MessageBox(::GetActiveWindow(), "NotSupported rotation order. Must kXYZ or kYXZ", "Joint export Warning", MB_OK); // } - char szName[512]; + fs::path fsJointFile; if (mJoint.parent(0).apiType() == MFn::kTransform) { MFnTransform mTJ(mJoint.parent(0)); - wsprintf(szName, "Chr\\%s.N3Joint", mTJ.name().asChar()); // 파일 이름 정하기.. + fsJointFile = fs::path("Chr") / std::format("{:s}.n3joint", mTJ.name().asUTF8()); // 파일 이름 정하기.. } else { - wsprintf(szName, "Chr\\%s.N3Joint", mJoint.name().asChar()); // 파일 이름 정하기.. + fsJointFile = fs::path("Chr") / std::format("{:s}.n3joint", mJoint.name().asUTF8()); // 파일 이름 정하기.. } - pJoint->m_szName = mJoint.name().asChar(); // 이름짓기.. FullName 으로 짓지는 않는다.. + pJoint->m_szName = mJoint.name().asUTF8(); // 이름짓기.. FullName 으로 짓지는 않는다.. // 회전 축 값을 구한다.. if (pJoint->m_KeyOrient.Count() <= 0) // Joint Orient Key 값이 없으면.. Rotation Key 값을 Orient 만큼 비튼다.. @@ -1159,7 +1152,7 @@ CN3Texture * CN3E2Wrapper::ProcessTexture(MFnMesh & mMesh) { MString szCommand = MString("getAttr ") + szTexture + MString(".outSize"); MIntArray nWH; if (MGlobal::executeCommand(szCommand, nWH) != MS::kSuccess) { - wsprintf(szInfo, "텍스처 파일 처리 오류 : Surface - %s, Texture - %s", szSurface.asChar(), szTexture.asChar()); + wsprintf(szInfo, "텍스처 파일 처리 오류 : Surface - %s, Texture - %s", szSurface.asUTF8(), szTexture.asUTF8()); nLI = ::SendMessage(m_hWndLB, LB_ADDSTRING, 0, (LPARAM)szInfo); // Progress dialog ::SendMessage(m_hWndLB, LB_SETCURSEL, (WPARAM)nLI, 0); // Progress dialog @@ -1169,7 +1162,7 @@ CN3Texture * CN3E2Wrapper::ProcessTexture(MFnMesh & mMesh) { // int nW = nWH[1], nH = nWH[0]; // 사이즈를 알아내고.. // if(nW < 4 || nH < 4) // { - // wsprintf(szInfo, "텍스처 파일 처리 오류 : 너비, 높이가 너무 작습니다. Surface - %s, Texture - %s", szSurface.asChar(), szTexture.asChar()); + // wsprintf(szInfo, "텍스처 파일 처리 오류 : 너비, 높이가 너무 작습니다. Surface - %s, Texture - %s", szSurface.asUTF8(), szTexture.asUTF8()); // nLI = ::SendMessage(m_hWndLB, LB_ADDSTRING, 0, (LPARAM)szInfo); // Progress dialog // ::SendMessage(m_hWndLB, LB_SETCURSEL, (WPARAM)nLI,0); // Progress dialog // @@ -1185,66 +1178,33 @@ CN3Texture * CN3E2Wrapper::ProcessTexture(MFnMesh & mMesh) { //////////////////////////////////////////// // Texture List 에 등록되어 있는지 본다.. - char szFNSrc[1024]; // 파일 이름을 정하고.. - lstrcpy(szFNSrc, szFile.asChar()); - int nFN = lstrlen(szFNSrc); - for (int i = 0; i < nFN; i++) { - if (szFNSrc[i] == '/') { - szFNSrc[i] = '\\'; - } - } - - // 문자열에 ":" 이 없으면 앞의 두글자가 '\\' 혹은 '//' 이 아니면 풀네임을 만들어야 한다. - if (!strstr(szFNSrc, ":") && !(szFNSrc[0] == '\\' && szFNSrc[1] == '\\')) { + fs::path fsSrcFile = szFile.asUTF8(); + if (!fsSrcFile.is_absolute()) { MString szWorkSpace; MGlobal::executeCommand(MString("workspace -fullName"), szWorkSpace); - lstrcpy(szFNSrc, szWorkSpace.asChar()); - lstrcat(szFNSrc, szFile.asChar()); + fsSrcFile = fs::path(szWorkSpace.asUTF8()) / szFile.asUTF8(); } - // WorkSpace 이름을 가져오고.. - char szFNDest[1024]; // 저장할 이름 - lstrcpy(szFNDest, szFNSrc); - nFN = lstrlen(szFNDest); - for (int i = nFN - 1; i >= 0; i--) // 저장할 이름을 만든다.. - { - if (szFNDest[i] == '.') { - szFNDest[i + 1] = 'D'; - szFNDest[i + 2] = 'X'; - szFNDest[i + 3] = 'T'; - szFNDest[i + 4] = NULL; - } - if (szFNDest[i] == '\\' || szFNDest[i] == '/') { - lstrcpy(szFNDest, &szFNDest[i + 1]); - break; - } - } - - CN3Texture * pTex = NULL; + fs::path fsDstFile = fsSrcFile; + fsDstFile.replace_extension(".dxt"); - static char szFNs[1024][256]; // 파일 이름이 중복되는지 체크... + // Use a hash set for fast duplicate checking + static std::unordered_set setCurFiles; if (m_pScene->s_MngTex.Count() <= 0) { - memset(szFNs, 0, sizeof(szFNs)); + setCurFiles.clear(); } - for (int i = 0; i < 1024; i++) { - if (NULL == szFNs[i][0]) { - break; - } - if (lstrcmpi(szFNDest, szFNs[i]) == 0) { - pTex = m_pScene->s_MngTex.Get(szFNDest); - return pTex; - } + if (setCurFiles.contains(fsDstFile)) { + return m_pScene->s_MngTex.Get(fsDstFile); } + setCurFiles.insert(fsDstFile); - lstrcpy(szFNs[i], szFNDest); - pTex = new CN3Texture(); - if (pTex->LoadFromFile(szFNSrc)) // 파일을 읽고... - { - pTex->m_szName = szFNDest; // 이름 정하기.. - 파일 이름으로 정한다. - pTex->FileNameSet(szFNDest); // 파일 이름 정하기. - CN3Base::s_MngTex.Add(pTex); // Manager 에 등록 + CN3Texture * pTex = new CN3Texture(); + if (pTex->LoadFromFile(fsSrcFile)) { + pTex->m_szName = fsDstFile; // 이름 정하기.. - 파일 이름으로 정한다. + pTex->FilePathSet(fsDstFile); // 파일 이름 정하기. + CN3Base::s_MngTex.Add(pTex); // Manager 에 등록 } else { - wsprintf(szInfo, "텍스처 파일 처리 오류 : 파일을 읽을수 없습니다. - %s", szFNSrc); + wsprintf(szInfo, "텍스처 파일 처리 오류 : 파일을 읽을수 없습니다. - %s", fsSrcFile); nLI = ::SendMessage(m_hWndLB, LB_ADDSTRING, 0, (LPARAM)szInfo); // Progress dialog ::SendMessage(m_hWndLB, LB_SETCURSEL, (WPARAM)nLI, 0); // Progress dialog @@ -1284,7 +1244,7 @@ CN3Texture * CN3E2Wrapper::ProcessTexture(MFnMesh & mMesh) { Reader.getSize(nW2, nH2); if(nW != nW2 || nH != nH2) { - wsprintf(szInfo, "텍스처 파일 처리 오류 : 파일을 읽을수 없습니다. - %s", szFile.asChar()); + wsprintf(szInfo, "텍스처 파일 처리 오류 : 파일을 읽을수 없습니다. - %s", szFile.asUTF8()); nLI = ::SendMessage(m_hWndLB, LB_ADDSTRING, 0, (LPARAM)szInfo); // Progress dialog ::SendMessage(m_hWndLB, LB_SETCURSEL, (WPARAM)nLI,0); // Progress dialog @@ -1296,8 +1256,8 @@ CN3Texture * CN3E2Wrapper::ProcessTexture(MFnMesh & mMesh) { // else // { // Reader.close(); - // DeleteFile(szFile.asChar()); // 파일 지우기.. - // wsprintf(szInfo, "텍스처 파일 처리 오류 : GrayScale Texture 는 차후에 지원 됩니다. Surface - %s, Texture - %s", szSurface.asChar(), szTexture.asChar()); + // fs::remove(szFile.asUTF8()); // 파일 지우기.. + // wsprintf(szInfo, "텍스처 파일 처리 오류 : GrayScale Texture 는 차후에 지원 됩니다. Surface - %s, Texture - %s", szSurface.asUTF8(), szTexture.asUTF8()); // ::SendMessage(m_hWndLB, LB_ADDSTRING, 0, (LPARAM)szInfo); // Progress dialog // ::SendMessage(m_hWndLB, LB_SETCURSEL, (WPARAM)nLI,0); // Progress dialog // return false; @@ -1350,7 +1310,7 @@ CN3Texture * CN3E2Wrapper::ProcessTexture(MFnMesh & mMesh) { if(pTex->Get() == NULL) { wsprintf(szInfo, "### !!! Texture Export 실패(%.3d) : w,h,w2,h2(%.4d, %.4d, %.4d, %.4d) FileName : \"%s\" TextureName \"%s\" MeshName - \"%s\"", - m_pScene->s_MngTex.Count(), pTex->Width(), pTex->Height(), nW, nH, szFile.asChar(), pTex->m_szName.c_str(), mMesh.name().asChar()); + m_pScene->s_MngTex.Count(), pTex->Width(), pTex->Height(), nW, nH, szFile.asUTF8(), pTex->m_szName.c_str(), mMesh.name().asUTF8()); nLI = ::SendMessage(m_hWndLB, LB_ADDSTRING, 0, (LPARAM)szInfo); // Progress dialog ::SendMessage(m_hWndLB, LB_SETCURSEL, (WPARAM)nLI,0); // Progress dialog @@ -1362,7 +1322,7 @@ CN3Texture * CN3E2Wrapper::ProcessTexture(MFnMesh & mMesh) { // Output Window 에 텍스처 출력.. wsprintf(szInfo, "### Texture Export (%.3d) : w,h,w2,h2(%.4d, %.4d, %.4d, %.4d) FileName : \"%s\" TextureName \"%s\" MeshName - \"%s\"", - m_pScene->s_MngTex.Count(), pTex->Width(), pTex->Height(), nW, nH, szFile.asChar(), pTex->m_szName.c_str(), mMesh.name().asChar()); + m_pScene->s_MngTex.Count(), pTex->Width(), pTex->Height(), nW, nH, szFile.asUTF8(), pTex->m_szName.c_str(), mMesh.name().asUTF8()); nLI = ::SendMessage(m_hWndLB, LB_ADDSTRING, 0, (LPARAM)szInfo); // Progress dialog ::SendMessage(m_hWndLB, LB_SETCURSEL, (WPARAM)nLI,0); // Progress dialog */ @@ -1445,7 +1405,7 @@ int CN3E2Wrapper::ProcessTransform(MFnTransform & mTransform, CN3Transform * pTr if (NULL == pTransform) { return -1; } - pTransform->m_szName = mTransform.name().asChar(); // 이름 짓기.... + pTransform->m_szName = mTransform.name().asUTF8(); // 이름 짓기.... __Vector3 vPos, vScale; __Quaternion qtRot; @@ -1484,12 +1444,12 @@ int CN3E2Wrapper::ProcessTransform(MFnTransform & mTransform, CN3Transform * pTr int nAK = mAKs.length(); int nKType = -1, nT = 0, nR = 0, nS = 0; - char szTmp[512]; + char szTmp[512]{}; for (int i = 0; i < nAK; i++) { MFnAnimCurve mAC(mAKs[i]); - lstrcpy(szTmp, mAC.name().asChar()); // 일단 이름으로 비교해보고..... - CharLower(szTmp); + lstrcpy(szTmp, mAC.name().asUTF8()); // 일단 이름으로 비교해보고..... + n3std::to_lower(szTmp); if (NULL != strstr(szTmp, "translatex")) // 카메라의 경우에는 translate 값이 두개가 들어온다.. { @@ -1544,7 +1504,7 @@ int CN3E2Wrapper::ProcessTransform(MFnTransform & mTransform, CN3Transform * pTr // else if(dwID == 0x50435455) { nKType = 6 + nS; nS++; } // Scale // else nKType = -1; - lstrcpy(szTmp, mAC.typeName().asChar()); + lstrcpy(szTmp, mAC.typeName().asUTF8()); if (NULL != strstr(szTmp, "animCurveTL")) { nKType = 0 + nT; nT++; @@ -1605,7 +1565,7 @@ int CN3E2Wrapper::ProcessTransform(MFnTransform & mTransform, CN3Transform * pTr if (nKs[0] > 0 || nKs[1] > 0 || nKs[2] > 0) { if (nKs[0] <= 0 || nKs[1] <= 0 || nKs[2] <= 0) { wsprintf(szInfo, "Transform %s : All Animation Key must have at least over 1 Key value.", - mTransform.name().asChar()); + mTransform.name().asUTF8()); MessageBox(::GetActiveWindow(), szInfo, "Invalid Animation Key", MB_OK); } else { // if(i == 0) this->ProcessAnimKey(mACs[i], &pTransform->m_KeyPos, true, 0.01f, false); // Translation Animation Key 를 처리한다.. @@ -1822,14 +1782,14 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { } // 중복되는지 찾아본다.. - std::string szJointFN; + fs::path szJointFile; if (mJointRoot.parentCount() > 0 && mJointRoot.parent(0).hasFn(MFn::kTransform)) { MFnTransform mP1(mJointRoot.parent(0)); - szJointFN = ""; - this->ProcessName(mP1.parent(0), szJointFN); // 뼈의 이름을 알아보고.. - szJointFN = "Chr\\" + szJointFN + ".N3Joint"; + std::string szJointFileName; + this->ProcessName(mP1.parent(0), szJointFileName); // 뼈의 이름을 알아보고.. + szJointFile = fs::path("Chr") / (szJointFileName + ".n3joint"); } else { - szJointFN = mJointRoot.name().asChar(); // 뼈의 이름을 알아보고.. + szJointFile = mJointRoot.name().asUTF8(); // 뼈의 이름을 알아보고.. } static std::string szJointFNs[512]; // 중복되는지 체크... @@ -1844,7 +1804,7 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { if (szJointFNs[i].size() <= 0) { break; } - if (szJointFN == szJointFNs[i]) { + if (szJointFile == szJointFNs[i]) { bOverlapped = true; break; } @@ -1855,7 +1815,7 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { if (false == bOverlapped) // 중복되지 않는다면..새로 만든다.. { - szJointFNs[i] = szJointFN; // 조인트 이름을 기록하고.. + szJointFNs[i] = szJointFile; // 조인트 이름을 기록하고.. pChr = new CN3Chr(); m_pScene->ChrAdd(pChr); // Scene 에 캐릭터 추가.. @@ -1869,17 +1829,14 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { } else { this->ProcessName(mP1.parent(0), pChr->m_szName); // 이름 짓기.... } - pChr->FileNameSet("Chr\\" + pChr->m_szName + ".N3Chr"); // 파일 이름 결정.. + pChr->FilePathSet(fs::path("Chr") / (pChr->m_szName + ".n3chr")); // 파일 이름 결정.. } else { - this->ProcessName(mJointRoot.parent(0), pChr->m_szName); // 이름 짓기.... - pChr->FileNameSet("Chr\\" + pChr->m_szName + ".N3Chr"); // 파일 이름 결정..); + this->ProcessName(mJointRoot.parent(0), pChr->m_szName); // 이름 짓기.... + pChr->FilePathSet(fs::path("Chr") / (pChr->m_szName + ".n3chr")); // 파일 이름 결정..); } } else { - pChr->m_szName = mJointRoot.name().asChar(); - std::string szFN = "Chr\\"; - szFN += mJointRoot.name().asChar(); - szFN += ".N3Chr"; // 파일 이름 결정.. - pChr->FileNameSet(szFN); + pChr->m_szName = mJointRoot.name().asUTF8(); + pChr->FilePathSet(fs::path("Chr") / std::format("{:s}.n3chr", mJointRoot.name().asUTF8())); } pJoint = this->ProcessJoint(mJointRoot); // Joint 처리 @@ -1887,10 +1844,10 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { delete pChr; return NULL; } - pJoint->FileNameSet(szJointFN); // 파일 이름 설정.. + pJoint->FilePathSet(szJointFile); // 파일 이름 설정.. pChr->s_MngJoint.Add(pJoint); - pChr->JointSet(pJoint->FileName()); // Joint Setting; + pChr->JointSet(pJoint->FilePath()); // Joint Setting; /////////////////////////////////////////////////////////////////////// // Joint 가 그룹 되어 있다면 Parent Transform 처리.. @@ -1937,7 +1894,7 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { } } } else { - pJoint = m_pScene->s_MngJoint.Get(szJointFN); + pJoint = m_pScene->s_MngJoint.Get(szJointFile); int nChrCount = m_pScene->ChrCount(); // 같은 조인트 포인터를 갖는 캐릭터 포인터를 찾는다.. for (int i = 0; i < nChrCount; i++) { @@ -1975,9 +1932,9 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { } // 충돌 체크용으로 쓰일 메시인지 살펴본다.. - std::string szFNM = mMT.name().asChar(); - if (szFNM.size() > 0) { - CharLower(&(szFNM[0])); + std::string szFNM = mMT.name().asUTF8(); + if (!szFNM.empty()) { + n3std::to_lower(szFNM); } if (szFNM.find("coll") != -1) { bCollisionMesh = true; @@ -2005,8 +1962,7 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { pVMesh->m_szName = ""; this->ProcessName(mMeshOrg.object(), pVMesh); - std::string szFN = "Chr\\" + pVMesh->m_szName + ".N3VMesh"; // 파일 이름 결정.. - pVMesh->FileNameSet(szFN); + pVMesh->FilePathSet(fs::path("Chr") / (pVMesh->m_szName + ".n3vmesh")); pChr->s_MngVMesh.Add(pVMesh); pChr->CollisionMeshSet(pVMesh->m_szName); @@ -2070,40 +2026,40 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { if (pPart->m_szName.empty()) // 파트의 이름이 없으면.. { - pPart->m_szName = mGT.name().asChar(); - std::string szFN; - this->ProcessName(mGT.object(), szFN); + pPart->m_szName = mGT.name().asUTF8(); + std::string szFileName; + this->ProcessName(mGT.object(), szFileName); - int iLen = szFN.size(); + int iLen = szFileName.size(); int iLen2 = pPart->m_szName.size(); if (m_Option.bGenerateFileName && iLen >= 11 && iLen2 >= 11) { // Item Code ::: 0_2345_78_0 - szFN = szFN.substr(iLen - 11); + szFileName = szFileName.substr(iLen - 11); } - pPart->FileNameSet("item\\" + szFN + ".N3CPart"); + pPart->FilePathSet(fs::path("Item") / (szFileName + ".n3cpart")); } if (NULL == pSkin) // Skin 이 없으면 넣는다.. { CN3CPartSkins * pSkinsAdd = new CN3CPartSkins(); - pSkinsAdd->m_szName = mGT.name().asChar(); // 이름과 파일 이름을 정하고.. - std::string szFN; - this->ProcessName(mGT.object(), szFN); + pSkinsAdd->m_szName = mGT.name().asUTF8(); // 이름과 파일 이름을 정하고.. + std::string szFileName; + this->ProcessName(mGT.object(), szFileName); - int iLen = szFN.size(); + int iLen = szFileName.size(); int iLen2 = pSkinsAdd->m_szName.size(); if (m_Option.bGenerateFileName && iLen >= 11 && iLen2 >= 11) { // Item Code ::: 0_2345_78_0 - szFN = szFN.substr(iLen - 11); + szFileName = szFileName.substr(iLen - 11); } - pSkinsAdd->FileNameSet("item\\" + szFN + ".N3CSkins"); + pSkinsAdd->FilePathSet(fs::path("Item") / (szFileName + ".n3cskins")); CN3Base::s_MngSkins.Add(pSkinsAdd); - pPart->SkinsSet(pSkinsAdd->FileName()); + pPart->SkinsSet(pSkinsAdd->FilePath()); pSkin = pPart->Skin(nLOD); // 다시 포인터 구하기. } if (false == this->ProcessSkin(mSkin, pSkin)) // Skin 처리.. { - MessageBox(::GetActiveWindow(), mSkin.name().asChar(), "Skin processing failed", MB_OK); + MessageBox(::GetActiveWindow(), mSkin.name().asUTF8(), "Skin processing failed", MB_OK); return false; } @@ -2114,15 +2070,15 @@ bool CN3E2Wrapper::ProcessChr(MFnSkinCluster & mSkin) { CN3Texture * pTex = ProcessTexture(mMeshOutput); if (pTex) { - pTex->m_szName = mGT.name().asChar(); // 이름과 파일 이름을 정하고.. - std::string szFN; - this->ProcessName(mGT.object(), szFN); - int iLen = szFN.size(); + pTex->m_szName = mGT.name().asUTF8(); // 이름과 파일 이름을 정하고.. + std::string szFileName; + this->ProcessName(mGT.object(), szFileName); + int iLen = szFileName.size(); int iLen2 = pTex->m_szName.size(); if (m_Option.bGenerateFileName && iLen >= 11 && iLen2 >= 11) { // Item Code ::: 0_2345_78_0 - szFN = szFN.substr(iLen - 11); + szFileName = szFileName.substr(iLen - 11); } - pTex->FileNameSet("Item\\" + szFN + ".DXT"); // Part 이름과 Texture 이름을 같게 한다. + pTex->FilePathSet(fs::path("Item") / (szFileName + ".dxt")); // Part 이름과 Texture 이름을 같게 한다. pPart->m_Mtl.dwColorOp = D3DTOP_MODULATE; pPart->TexSet(pTex); @@ -2148,7 +2104,7 @@ void CN3E2Wrapper::ProcessName(MObject mObj, std::string & szName) { MFnDependencyNode mNode(mObj); std::string szNameBack = szName; - szName = mNode.name().asChar(); + szName = mNode.name().asUTF8(); if (szNameBack.size() > 0) { szName += '_'; szName += szNameBack; @@ -2201,7 +2157,7 @@ void CN3E2Wrapper::GetWorldTransform(MFnTransform & mTransform, MMatrix & mMtx) bool CN3E2Wrapper::IsSelected(MSelectionList & mSelList, MObject mObj) { if (mObj.hasFn(MFn::kDependencyNode)) { MFnDependencyNode mDag(mObj); - const char * szName = mDag.name().asChar(); + const char * szName = mDag.name().asUTF8(); int ttttt = 0; } diff --git a/src/tool/PlugIn_Maya/N3E2Wrapper.h b/src/tool/PlugIn_Maya/N3E2Wrapper.h index 564f342d..1f79b21d 100644 --- a/src/tool/PlugIn_Maya/N3E2Wrapper.h +++ b/src/tool/PlugIn_Maya/N3E2Wrapper.h @@ -80,8 +80,8 @@ const int MAX_TEXTURE = 1024; class CN3E2Wrapper { private: // different extensions will get added to this: - char m_szPath[1024]; // 경로 이름 - char m_szFileName[1024]; // 파일 이름 + fs::path m_fsDir; + fs::path m_fsFile; CN3Scene * m_pScene; static __EXPORT_OPTION m_Option; @@ -123,8 +123,8 @@ class CN3E2Wrapper { void SceneExport(); void Release(); - void SetPath(const char * szPath); - void SetFileName(const char * szFileName); + void SetPath(const fs::path & fsDir); + void SetFileName(const fs::path & fsFile); static BOOL CALLBACK DlgProcProgress(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); static BOOL CALLBACK DlgProcPane(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); diff --git a/src/tool/PlugIn_Maya/iffreader.cpp b/src/tool/PlugIn_Maya/iffreader.cpp index 782680ac..b648faac 100644 --- a/src/tool/PlugIn_Maya/iffreader.cpp +++ b/src/tool/PlugIn_Maya/iffreader.cpp @@ -14,6 +14,8 @@ // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. +#include "StdAfx.h" + #include #include #include "iffreader.h" diff --git a/src/tool/RscTables/RscTablesDlg.cpp b/src/tool/RscTables/RscTablesDlg.cpp index 1f432bd6..232be457 100644 --- a/src/tool/RscTables/RscTablesDlg.cpp +++ b/src/tool/RscTables/RscTablesDlg.cpp @@ -7,6 +7,7 @@ #include "DlgDataCount.h" #include +#include #ifdef _DEBUG #define new DEBUG_NEW @@ -399,80 +400,54 @@ void CRscTablesDlg::OnEditDelete() { } } -bool CRscTablesDlg::BrowseDataEnumAndTxt(int iIndex, BOOL bOpen, std::string * pszFN_Enm, std::string * pszFN_Txt) { - if (pszFN_Enm) { - *pszFN_Enm = ""; +bool CRscTablesDlg::BrowseDataEnumAndTxt(int iIndex, BOOL bOpen, fs::path * pfsEnmFile, fs::path * pfsTxtFile) { + if (pfsEnmFile) { + *pfsEnmFile = fs::path(); } - if (pszFN_Txt) { - *pszFN_Txt = ""; + if (pfsTxtFile) { + *pfsTxtFile = fs::path(); } - if (pszFN_Enm) { - CString FileName; + if (pfsEnmFile) { DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(bOpen, "enm", NULL, dwFlags, "Data Enum File(*.enm)|*.enm||", NULL); if (dlg.DoModal() == IDCANCEL) { return false; } - FileName = dlg.GetFileName(); - - *pszFN_Enm = FileName; + *pfsEnmFile = dlg.GetFileName().GetString(); } - if (pszFN_Txt) { - CString FileName2; + if (pfsTxtFile) { DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg2(bOpen, "txt", NULL, dwFlags, "Tab 으로 분리된 Txt File(*.txt)|*.txt||", NULL); if (dlg2.DoModal() == IDCANCEL) { return false; } - FileName2 = dlg2.GetFileName(); - *pszFN_Txt = FileName2; + *pfsTxtFile = dlg2.GetFileName().GetString(); } if (bOpen) { if (iIndex == -2) { - if (pszFN_Enm) { - char szFName[256], szExt[256]; - ::_splitpath(pszFN_Enm->c_str(), NULL, NULL, szFName, szExt); - std::string szFN = szFName; - szFN += szExt; - SetDlgItemText(IDC_E_TABLE_BASIC_ENM, szFN.c_str()); + if (pfsEnmFile) { + SetDlgItemTextW(GetSafeHwnd(), IDC_E_TABLE_BASIC_ENM, pfsEnmFile->filename().c_str()); } - if (pszFN_Txt) { - char szFName[256], szExt[256]; - ::_splitpath(pszFN_Txt->c_str(), NULL, NULL, szFName, szExt); - std::string szFN = szFName; - szFN += szExt; - SetDlgItemText(IDC_E_TABLE_BASIC_TXT, szFN.c_str()); + if (pfsTxtFile) { + SetDlgItemTextW(GetSafeHwnd(), IDC_E_TABLE_BASIC_TXT, pfsTxtFile->filename().c_str()); } } else if (iIndex == -1) { - if (pszFN_Enm) { - char szFName[256], szExt[256]; - ::_splitpath(pszFN_Enm->c_str(), NULL, NULL, szFName, szExt); - std::string szFN = szFName; - szFN += szExt; - SetDlgItemText(IDC_E_TABLE_EXT_ENM, szFN.c_str()); + if (pfsEnmFile) { + SetDlgItemTextW(GetSafeHwnd(), IDC_E_TABLE_EXT_ENM, pfsEnmFile->filename().c_str()); } } else if (iIndex >= 0 && iIndex < MAX_ITEM_EXTENSION) { - if (pszFN_Enm) { - char szFName[256], szExt[256]; - ::_splitpath(pszFN_Enm->c_str(), NULL, NULL, szFName, szExt); - std::string szFN = szFName; - szFN += szExt; - SetDlgItemText(IDC_E_TABLE_EXT_ENM, szFN.c_str()); + if (pfsEnmFile) { + SetDlgItemTextW(GetSafeHwnd(), IDC_E_TABLE_EXT_ENM, pfsEnmFile->filename().c_str()); } - if (pszFN_Txt) { - char szFName[256], szExt[256]; - ::_splitpath(pszFN_Txt->c_str(), NULL, NULL, szFName, szExt); - - CString szFN; - szFN.LoadString(IDS_FMT_TABLE_EXT0 + iIndex); - szFN += szFName; - szFN += szExt; - + if (pfsTxtFile) { + CString szFileName; + szFileName.LoadString(IDS_FMT_TABLE_EXT0 + iIndex); + szFileName += pfsTxtFile->filename().c_str(); m_ListTableExt.DeleteString(iIndex); - m_ListTableExt.InsertString(iIndex, szFN); + m_ListTableExt.InsertString(iIndex, szFileName); } } } @@ -481,19 +456,19 @@ bool CRscTablesDlg::BrowseDataEnumAndTxt(int iIndex, BOOL bOpen, std::string * p } void CRscTablesDlg::OnBOpenTableBasic() { - std::string szFN_Enm, szFN_Txt; - if (false == this->BrowseDataEnumAndTxt(-2, TRUE, &szFN_Enm, &szFN_Txt)) { + fs::path fsEnmFile, fsTxtFile; + if (!BrowseDataEnumAndTxt(-2, TRUE, &fsEnmFile, &fsTxtFile)) { return; } - m_Generator.OpenSource(szFN_Enm, szFN_Txt); + m_Generator.OpenSource(fsEnmFile, fsTxtFile); } void CRscTablesDlg::OnBOpenTableExtEnum() { - std::string szFN_Enm; - if (false == this->BrowseDataEnumAndTxt(-1, TRUE, &szFN_Enm, NULL)) { + fs::path fsEnmFile; + if (!BrowseDataEnumAndTxt(-1, TRUE, &fsEnmFile, NULL)) { return; } - m_Generator.OpenReference_Enum(szFN_Enm); + m_Generator.OpenReference_Enum(fsEnmFile); } void CRscTablesDlg::OnDblclkListTableExt() { @@ -502,11 +477,11 @@ void CRscTablesDlg::OnDblclkListTableExt() { return; } - std::string szFN_Txt; - if (false == this->BrowseDataEnumAndTxt(iSel, TRUE, NULL, &szFN_Txt)) { + fs::path fsTxtFile; + if (!BrowseDataEnumAndTxt(iSel, TRUE, NULL, &fsTxtFile)) { return; } - m_Generator.OpenReference_Txt(iSel, szFN_Txt); + m_Generator.OpenReference_Txt(iSel, fsTxtFile); } void CRscTablesDlg::OnBGenerateSelected() { @@ -515,49 +490,38 @@ void CRscTablesDlg::OnBGenerateSelected() { return; } - std::string szFN_Enm, szFN_Txt; - if (false == this->BrowseDataEnumAndTxt(-3, FALSE, &szFN_Enm, &szFN_Txt)) { + fs::path fsEnmFile, fsTxtFile; + if (!BrowseDataEnumAndTxt(-3, FALSE, &fsEnmFile, &fsTxtFile)) { return; } - m_Generator.Generate(iSel, szFN_Enm, szFN_Txt); + m_Generator.Generate(iSel, fsEnmFile, fsTxtFile); } void CRscTablesDlg::OnBGenerateAll() { - std::string szFN_Enm, szFN_Txt; - if (false == this->BrowseDataEnumAndTxt(-3, FALSE, &szFN_Enm, &szFN_Txt)) { + fs::path fsEnmFile, fsTxtFile; + if (!BrowseDataEnumAndTxt(-3, FALSE, &fsEnmFile, &fsTxtFile)) { return; } - m_Generator.Generate(-1, szFN_Enm, szFN_Txt); + m_Generator.Generate(-1, fsEnmFile, fsTxtFile); } void CRscTablesDlg::UpdateGenerationInfo() { - char szFName[256] = "", szExt[256] = ""; - CString szFN; + CString szFileName; - ::_splitpath(m_Generator.m_szEnmBasic.c_str(), NULL, NULL, szFName, szExt); - szFN = szFName; - szFN += szExt; - SetDlgItemText(IDC_E_TABLE_BASIC_ENM, szFN); + szFileName = m_Generator.m_fsEnmBasicFile.filename().c_str(); + SetDlgItemText(IDC_E_TABLE_BASIC_ENM, szFileName); - ::_splitpath(m_Generator.m_szTxtBasic.c_str(), NULL, NULL, szFName, szExt); - szFN = szFName; - szFN += szExt; - SetDlgItemText(IDC_E_TABLE_BASIC_TXT, szFN); + szFileName = m_Generator.m_fsTxtBasicFile.filename().c_str(); + SetDlgItemText(IDC_E_TABLE_BASIC_TXT, szFileName); - ::_splitpath(m_Generator.m_szEnmExt.c_str(), NULL, NULL, szFName, szExt); - szFN = szFName; - szFN += szExt; - SetDlgItemText(IDC_E_TABLE_EXT_ENM, szFN); + szFileName = m_Generator.m_fsEnmExtFile.filename().c_str(); + SetDlgItemText(IDC_E_TABLE_EXT_ENM, szFileName); m_ListTableExt.ResetContent(); for (int i = 0; i < MAX_ITEM_EXTENSION; i++) { - ::_splitpath(m_Generator.m_szTxtExts[i].c_str(), NULL, NULL, szFName, szExt); - - szFN.LoadString(IDS_FMT_TABLE_EXT0 + i); - szFN += szFName; - szFN += szExt; - - m_ListTableExt.AddString(szFN); + szFileName.LoadString(IDS_FMT_TABLE_EXT0 + i); + szFileName += m_Generator.m_fsTxtExtFiles[i].filename().c_str(); + m_ListTableExt.AddString(szFileName); } } @@ -568,29 +532,22 @@ void CRscTablesDlg::OnItemFileListLoad() { return; } - char szBuffs[32][256]; - memset(szBuffs, 0, sizeof(szBuffs)); + std::array arFiles; - FILE * pFile = fopen(dlg.GetPathName(), "r"); - if (NULL == pFile) { + std::ifstream iFile(dlg.GetPathName().GetString()); + if (!iFile) { return; } - for (int i = 0; i < MAX_ITEM_EXTENSION + 3; i++) { - fgets(szBuffs[i], 256, pFile); - int iLen = lstrlen(szBuffs[i]); - if (iLen > 0) { - szBuffs[i][iLen - 1] = NULL; // '\r' - } else { - szBuffs[i][0] = NULL; - } + + std::string szLine; + for (int i = 0; i < MAX_ITEM_EXTENSION + 3 && std::getline(iFile, szLine); ++i) { + arFiles[i] = szLine; } - fclose(pFile); - pFile = NULL; - m_Generator.OpenSource(szBuffs[0], szBuffs[1]); - m_Generator.OpenReference_Enum(szBuffs[2]); - for (int i = 0; i < MAX_ITEM_EXTENSION + 3; i++) { - m_Generator.OpenReference_Txt(i, szBuffs[i + 3]); + m_Generator.OpenSource(arFiles[0], arFiles[1]); + m_Generator.OpenReference_Enum(arFiles[2]); + for (int i = 0; i < MAX_ITEM_EXTENSION; ++i) { + m_Generator.OpenReference_Txt(i, arFiles[i + 3]); } this->UpdateGenerationInfo(); @@ -603,24 +560,20 @@ void CRscTablesDlg::OnItemFileListSave() { return; } - char szBuffs[32][256]; - memset(szBuffs, 0, sizeof(szBuffs)); - - lstrcpy(szBuffs[0], m_Generator.m_szEnmBasic.c_str()); - lstrcpy(szBuffs[1], m_Generator.m_szTxtBasic.c_str()); - lstrcpy(szBuffs[2], m_Generator.m_szEnmExt.c_str()); - for (int i = 0; i < MAX_ITEM_EXTENSION + 3; i++) { - lstrcpy(szBuffs[i + 3], m_Generator.m_szTxtExts[i].c_str()); + std::array arFiles; + arFiles[0] = m_Generator.m_fsEnmBasicFile; + arFiles[1] = m_Generator.m_fsTxtBasicFile; + arFiles[2] = m_Generator.m_fsEnmExtFile; + for (int i = 0; i < MAX_ITEM_EXTENSION; ++i) { + arFiles[i + 3] = m_Generator.m_fsTxtExtFiles[i]; } - FILE * pFile = fopen(dlg.GetPathName(), "w"); - if (NULL == pFile) { + std::ofstream oFile(dlg.GetPathName().GetString()); + if (!oFile) { return; } - for (int i = 0; i < MAX_ITEM_EXTENSION + 3; i++) { - fputs(szBuffs[i], pFile); - fputs("\n", pFile); + + for (const auto & fsTblFile : arFiles) { + oFile << fsTblFile.string() << '\n'; } - fclose(pFile); - pFile = NULL; } diff --git a/src/tool/RscTables/RscTablesDlg.h b/src/tool/RscTables/RscTablesDlg.h index 91354f20..56e3c63b 100644 --- a/src/tool/RscTables/RscTablesDlg.h +++ b/src/tool/RscTables/RscTablesDlg.h @@ -63,7 +63,7 @@ class CRscTablesDlg : public CDialog { DECLARE_MESSAGE_MAP() public: - bool BrowseDataEnumAndTxt(int iIndex, BOOL bOpen, std::string * pszFN_Enm, std::string * pszFN_Txt); + bool BrowseDataEnumAndTxt(int iIndex, BOOL bOpen, fs::path * pfsEnmFile, fs::path * pfsTxtFile); void UpdateGenerationInfo(); void UpdateAllInfo(); diff --git a/src/tool/RscTables/TableGenerator.cpp b/src/tool/RscTables/TableGenerator.cpp index 9c9b9916..71d27b53 100644 --- a/src/tool/RscTables/TableGenerator.cpp +++ b/src/tool/RscTables/TableGenerator.cpp @@ -13,16 +13,15 @@ CTableGenerator::CTableGenerator() {} CTableGenerator::~CTableGenerator() {} -bool CTableGenerator::OpenSource(const std::string & szEnumFileName, const std::string & szTxtFileName) { - if (szEnumFileName.empty() || szTxtFileName.empty()) { +bool CTableGenerator::OpenSource(const fs::path & fsEnumFile, const fs::path & fsTxtFile) { + if (fsEnumFile.empty() || fsTxtFile.empty()) { return false; } HWND hWnd = ::GetActiveWindow(); - HANDLE hFile = - CreateFile(szEnumFileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsEnumFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - MessageBox(hWnd, szEnumFileName.c_str(), "파일이 없거나 읽을 수 없습니다.", MB_OK); + MessageBoxW(hWnd, fsEnumFile.c_str(), L"파일이 없거나 읽을 수 없습니다.", MB_OK); return false; } @@ -33,7 +32,7 @@ bool CTableGenerator::OpenSource(const std::string & szEnumFileName, const std:: ReadFile(hFile, &iDataCount, sizeof(iDataCount), &dwNum, NULL); if (iDataCount <= 0) { CloseHandle(hFile); - MessageBox(hWnd, szEnumFileName.c_str(), "Data Type 이 없습니다.", MB_OK); + MessageBoxW(hWnd, fsEnumFile.c_str(), L"Data Type 이 없습니다.", MB_OK); return false; } @@ -43,15 +42,15 @@ bool CTableGenerator::OpenSource(const std::string & szEnumFileName, const std:: } CloseHandle(hFile); - FILE * pFile = fopen(szTxtFileName.c_str(), "r"); + FILE * pFile = _wfopen(fsTxtFile.c_str(), L"r"); if (NULL == pFile) { - MessageBox(hWnd, szTxtFileName.c_str(), "파일이 없거나 읽을 수 없습니다.", MB_OK); + MessageBoxW(hWnd, fsTxtFile.c_str(), L"파일이 없거나 읽을 수 없습니다.", MB_OK); return false; } // 파일 이름 기록.. - m_szEnmBasic = szEnumFileName; - m_szTxtBasic = szTxtFileName; + m_fsEnmBasicFile = fsEnumFile; + m_fsTxtBasicFile = fsTxtFile; char szLine[1024]; std::set KeySet; @@ -88,7 +87,7 @@ bool CTableGenerator::OpenSource(const std::string & szEnumFileName, const std:: if (false == pk.second) { char szErr[512]; sprintf(szErr, "Key 중복 : Line %d, Key : %d, File : %s", i + 1, iVal, - szTxtFileName.c_str()); + fsTxtFile.string().c_str()); MessageBox(hWnd, szErr, "Key 중복 - 테이블에 추가 실패", MB_OK); break; } @@ -100,7 +99,7 @@ bool CTableGenerator::OpenSource(const std::string & szEnumFileName, const std:: m_Datas[j].m_Texts.push_back(szText); } } else { - MessageBox(hWnd, szTxtFileName.c_str(), "Data 의 열 갯수가 적거나 다릅니다.", MB_OK); + MessageBoxW(hWnd, fsTxtFile.c_str(), L"Data 의 열 갯수가 적거나 다릅니다.", MB_OK); fclose(pFile); m_Datas.clear(); return false; @@ -113,16 +112,15 @@ bool CTableGenerator::OpenSource(const std::string & szEnumFileName, const std:: return true; } -bool CTableGenerator::OpenReference_Enum(const std::string & szEnumFileName) { - if (szEnumFileName.empty()) { +bool CTableGenerator::OpenReference_Enum(const fs::path & fsEnumFile) { + if (fsEnumFile.empty()) { return false; } HWND hWnd = ::GetActiveWindow(); - HANDLE hFile = - CreateFile(szEnumFileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsEnumFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - MessageBox(hWnd, szEnumFileName.c_str(), "파일이 없거나 읽을 수 없습니다.", MB_OK); + MessageBoxW(hWnd, fsEnumFile.c_str(), L"파일이 없거나 읽을 수 없습니다.", MB_OK); return false; } @@ -134,7 +132,7 @@ bool CTableGenerator::OpenReference_Enum(const std::string & szEnumFileName) { ReadFile(hFile, &iDataCount, sizeof(iDataCount), &dwNum, NULL); if (iDataCount <= 0) { CloseHandle(hFile); - MessageBox(hWnd, szEnumFileName.c_str(), "Data Type 이 없습니다.", MB_OK); + MessageBoxW(hWnd, fsEnumFile.c_str(), L"Data Type 이 없습니다.", MB_OK); return false; } @@ -145,13 +143,13 @@ bool CTableGenerator::OpenReference_Enum(const std::string & szEnumFileName) { CloseHandle(hFile); // 파일 이름 기록.. - m_szEnmExt = szEnumFileName; + m_fsEnmExtFile = fsEnumFile; return true; } -bool CTableGenerator::OpenReference_Txt(int iIndex, const std::string & szTxtFileName) { - if (szTxtFileName.empty()) { +bool CTableGenerator::OpenReference_Txt(int iIndex, const fs::path & fsTxtFile) { + if (fsTxtFile.empty()) { return false; } if (iIndex < 0 || iIndex >= MAX_ITEM_EXTENSION) { @@ -163,9 +161,9 @@ bool CTableGenerator::OpenReference_Txt(int iIndex, const std::string & szTxtFil HWND hWnd = ::GetActiveWindow(); - FILE * pFile = fopen(szTxtFileName.c_str(), "r"); + FILE * pFile = _wfopen(fsTxtFile.c_str(), L"r"); if (NULL == pFile) { - MessageBox(hWnd, szTxtFileName.c_str(), "파일이 없거나 읽을 수 없습니다.", MB_OK); + MessageBoxW(hWnd, fsTxtFile.c_str(), L"파일이 없거나 읽을 수 없습니다.", MB_OK); return false; } @@ -205,7 +203,7 @@ bool CTableGenerator::OpenReference_Txt(int iIndex, const std::string & szTxtFil if (false == pk.second) { char szErr[512]; sprintf(szErr, "Key 중복 : Line %d, Key : %d, File : %s", i + 1, iVal, - szTxtFileName.c_str()); + fsTxtFile.string().c_str()); MessageBox(hWnd, szErr, "Key 중복 - 테이블에 추가 실패", MB_OK); break; } @@ -230,12 +228,12 @@ bool CTableGenerator::OpenReference_Txt(int iIndex, const std::string & szTxtFil fclose(pFile); // 파일 이름 기록.. - m_szTxtExts[iIndex] = szTxtFileName; + m_fsTxtExtFiles[iIndex] = fsTxtFile; return true; } -bool CTableGenerator::Generate(int iIndex, const std::string & szEnumFileName, const std::string & szTxtFileName) { +bool CTableGenerator::Generate(int iIndex, const fs::path & fsEnumFile, const fs::path & fsTxtFile) { int iIndexS = iIndex, iIndexE = iIndex; if (-1 == iIndex) { iIndexS = 0; @@ -245,7 +243,7 @@ bool CTableGenerator::Generate(int iIndex, const std::string & szEnumFileName, c if (iIndexS < 0 || iIndexS >= MAX_ITEM_EXTENSION || iIndexE < 0 || iIndexE >= MAX_ITEM_EXTENSION) { return false; } - if (szTxtFileName.empty()) { + if (fsTxtFile.empty()) { return false; } @@ -256,10 +254,9 @@ bool CTableGenerator::Generate(int iIndex, const std::string & szEnumFileName, c } DWORD dwRWC = 0; - HANDLE hFile = - CreateFile(szTxtFileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsTxtFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - MessageBox(hWnd, szTxtFileName.c_str(), "파일이 없거나 쓸수 없습니다.", MB_OK); + MessageBoxW(hWnd, fsTxtFile.c_str(), L"파일이 없거나 쓸수 없습니다.", MB_OK); return false; } @@ -652,7 +649,7 @@ bool CTableGenerator::Generate(int iIndex, const std::string & szEnumFileName, c CloseHandle(hFile); // Data Type 저장.. - this->DataTypeSave(szEnumFileName); + this->DataTypeSave(fsEnumFile); m_DataTypes = DataTypesPrev; // 백업 받은걸로 돌려놓는다. return true; } @@ -700,8 +697,8 @@ int CTableGenerator::ParseLine( return 0; } -bool CTableGenerator::DataTypeSave(const std::string & szFN) { - HANDLE hFile = CreateFile(szFN.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +bool CTableGenerator::DataTypeSave(const fs::path & fsFile) { + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); HWND hWnd = ::GetActiveWindow(); if (INVALID_HANDLE_VALUE == hFile) { MessageBox(hWnd, "파일을 만들 수 없습니다.", "데이터 형식 저장", MB_OK); @@ -720,9 +717,9 @@ bool CTableGenerator::DataTypeSave(const std::string & szFN) { return true; } -bool CTableGenerator::DataTypeLoad(const std::string & szFN) { +bool CTableGenerator::DataTypeLoad(const fs::path & fsFile) { HWND hWnd = ::GetActiveWindow(); - HANDLE hFile = CreateFile(szFN.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { MessageBox(hWnd, "파일이 없거나 읽을 수 없습니다.", "데이터 형식 부르기", MB_OK); return false; @@ -747,9 +744,9 @@ bool CTableGenerator::DataTypeLoad(const std::string & szFN) { return true; } -bool CTableGenerator::Convert2Bin(const std::string & szFN) { +bool CTableGenerator::Convert2Bin(const fs::path & fsFile) { HWND hWnd = ::GetActiveWindow(); - FILE * stream = fopen(szFN.c_str(), "r"); + FILE * stream = _wfopen(fsFile.c_str(), L"r"); if (NULL == stream) { MessageBox(hWnd, "읽을 수 없는 파일입니다.", "Convert Error", MB_OK); return false; @@ -760,7 +757,7 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { // 맨 윗줄은 column의 이름들이 써있음 if (fgets(line, iMaxStrLen, stream) == NULL) { fclose(stream); - std::string szMsg = szFN + " - 파일 내용을 읽을 수 없습니다."; + std::string szMsg = fsFile.string() + " - 파일 내용을 읽을 수 없습니다."; MessageBox(hWnd, szMsg.c_str(), "Convert Error", MB_OK); return false; } @@ -774,7 +771,8 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { } if (iCount != iDataCount) { fclose(stream); - std::string szMsg = szFN + " - 파일 데이터와 설정한 데이터 수가 일치하지 않습니다.\n다시 확인해 주세요!"; + std::string szMsg = + fsFile.string() + " - 파일 데이터와 설정한 데이터 수가 일치하지 않습니다.\n다시 확인해 주세요!"; MessageBox(hWnd, szMsg.c_str(), "Convert Error", MB_OK); return false; } @@ -799,15 +797,11 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { } // binary file 생성하기 - char szFName[_MAX_PATH], szDrv[_MAX_DRIVE], szPath[_MAX_PATH]; - char szDestFN[_MAX_PATH]; - _splitpath(szFN.c_str(), szDrv, szPath, szFName, NULL); - _makepath(szDestFN, szDrv, szPath, szFName, ".tbl"); - HANDLE hFile = CreateFile(szDestFN, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + fs::path fsTblFile = fs::path(fsFile).replace_extension(".tbl"); + HANDLE hFile = CreateFileW(fsTblFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { fclose(stream); - std::string szMsg = szDestFN; - szMsg += " - 파일을 생성할 수 없습니다."; + std::string szMsg = fsTblFile.string() + " - 파일을 생성할 수 없습니다."; MessageBox(hWnd, szMsg.c_str(), "Convert Error", MB_OK); return false; } @@ -853,7 +847,7 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { pair_Key pk = KeySet.insert(iKey); if (false == pk.second) { char szErr[512]; - sprintf(szErr, "Key 중복 : Line %d, Key : %d, File : %s", iRowCount + 1, iKey, szFN.c_str()); + sprintf(szErr, "Key 중복 : Line %d, Key : %d, File : %s", iRowCount + 1, iKey, fsFile.string().c_str()); MessageBox(hWnd, szErr, "Key 중복 - 테이블에 추가 실패", MB_OK); CloseHandle(hFile); fclose(stream); @@ -877,7 +871,8 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { // 버퍼에 있는것 기록 if (FALSE == WriteData(hFile, m_DataTypes[iColCount], strValueBuffer.c_str())) { char szErr[512]; - wsprintf(szErr, "File - %s, Line - %d, Field - %d", szFN.c_str(), iRowCount + 1, iColCount); + wsprintf(szErr, "File - %s, Line - %d, Field - %d", fsFile.string().c_str(), iRowCount + 1, + iColCount); MessageBox( hWnd, szErr, "데이타 기록이 무시되는 것이 있습니다. 이 파일은 제대로 작동 되지 않을 것입니다.", @@ -906,7 +901,8 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { // 버퍼에 있는것 기록 if (FALSE == WriteData(hFile, m_DataTypes[iColCount], strValueBuffer.c_str())) { char szErr[512]; - wsprintf(szErr, "File - %s, Line - %d, Field - %d", szFN.c_str(), iRowCount + 1, iColCount); + wsprintf(szErr, "File - %s, Line - %d, Field - %d", fsFile.string().c_str(), iRowCount + 1, + iColCount); MessageBox(hWnd, szErr, "데이타 기록이 무시되는 것이 있습니다. 이 파일은 제대로 작동 되지 않을 것입니다.", MB_OK); @@ -948,7 +944,7 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { if (FALSE == WriteData(hFile, m_DataTypes[iColCount], token)) { char szErr[512]; - wsprintf(szErr, "File - %s, Line - %d, Field - %d", szFN.c_str(), iRowCount + 1, iColCount); + wsprintf(szErr, "File - %s, Line - %d, Field - %d", fsFile.string().c_str(), iRowCount + 1, iColCount); MessageBox(hWnd, szErr, "데이타 기록이 무시되는 것이 있습니다. 이 파일은 제대로 작동 되지 않을 것입니다.", MB_OK); CloseHandle(hFile); @@ -964,7 +960,7 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { } if (iDataCount != iColCount) { char szErr[512]; - wsprintf(szErr, "File - %s, Line - %d, Field - %d", szFN.c_str(), iRowCount + 1, iColCount); + wsprintf(szErr, "File - %s, Line - %d, Field - %d", fsFile.string().c_str(), iRowCount + 1, iColCount); MessageBox(hWnd, szErr, "현재 설정된 데이타 항목과 기록되는 데이타 항목이 일치하지 않는 항목이 있습니다.", MB_OK); CloseHandle(hFile); @@ -981,10 +977,10 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { //////////////////////////////////////////////////////////// // 암호화.. 게임의 키와 동일하다... - hFile = ::CreateFile(szDestFN, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = ::CreateFileW(fsTblFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - MessageBox(hWnd, szDestFN, "암호화 파일 만들기에 실패 했습니다.", MB_OK); - remove(szDestFN); // 파일 지우고.. + MessageBoxW(hWnd, fsTblFile.c_str(), L"암호화 파일 만들기에 실패 했습니다.", MB_OK); + fs::remove(fsTblFile); // 파일 지우고.. return false; } @@ -993,7 +989,7 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { DWORD dwSizeLow = ::GetFileSize(hFile, &dwSizeHigh); if (dwSizeLow <= 0) { CloseHandle(hFile); - ::remove(szDestFN); // 임시 파일 지우기.. + fs::remove(fsTblFile); // 임시 파일 지우기.. return false; } @@ -1008,18 +1004,16 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { WORD key_c1 = 0x6081; WORD key_c2 = 0x1608; - //BYTE Encrypt(BYTE plain) - //{ + //BYTE Encrypt(BYTE plain) { // BYTE cipher; - // cipher = (plain ^ (key_r>>8)); + // cipher = (plain ^ (key_r >> 8)); // key_r = (cipher + key_r) * key_c1 + key_c2; // return cipher; //} - //BYTE Decrypt(BYTE cipher) - //{ + //BYTE Decrypt(BYTE cipher) { // BYTE plain; - // plain = (cipher ^ (m_r>>8)); + // plain = (cipher ^ (m_r >> 8)); // m_r = (cipher + m_r) * m_c1 + m_c2; // return plain; //} @@ -1032,7 +1026,7 @@ bool CTableGenerator::Convert2Bin(const std::string & szFN) { } // 다시 파일을 연다.. - hFile = ::CreateFile(szDestFN, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = ::CreateFileW(fsTblFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); ::WriteFile(hFile, pDatas, dwSizeLow, &dwRWC, NULL); // 파일에 암호화 시킨 데이터 쓰기 CloseHandle(hFile); // 파일 닫기 delete[] pDatas; @@ -1224,11 +1218,11 @@ char * CTableGenerator::MyToken(LPCTSTR lpszInput) { } void CTableGenerator::Release() { - m_szEnmBasic = ""; - m_szTxtBasic = ""; - m_szEnmExt = ""; + m_fsEnmBasicFile = ""; + m_fsTxtBasicFile = ""; + m_fsEnmExtFile = ""; for (int i = 0; i < MAX_ITEM_EXTENSION; i++) { - m_szTxtExts[i] = ""; + m_fsTxtExtFiles[i] = ""; } m_DataTypes.clear(); diff --git a/src/tool/RscTables/TableGenerator.h b/src/tool/RscTables/TableGenerator.h index 9a7db804..d3478608 100644 --- a/src/tool/RscTables/TableGenerator.h +++ b/src/tool/RscTables/TableGenerator.h @@ -66,10 +66,10 @@ class CTableDataExt { class CTableGenerator { public: - std::string m_szEnmBasic; - std::string m_szTxtBasic; - std::string m_szEnmExt; - std::string m_szTxtExts[MAX_ITEM_EXTENSION]; + fs::path m_fsEnmBasicFile; + fs::path m_fsTxtBasicFile; + fs::path m_fsEnmExtFile; + fs::path m_fsTxtExtFiles[MAX_ITEM_EXTENSION]; protected: std::vector m_DataTypes; @@ -103,15 +103,15 @@ class CTableGenerator { bool DataTypeDelete(int iIndex); bool DataTypeInsert(int iIndex, DATA_TYPE Type); bool DataTypeAssign(int iCount, DATA_TYPE Type); - bool DataTypeLoad(const std::string & szFN); - bool DataTypeSave(const std::string & szFN); + bool DataTypeLoad(const fs::path & fsFile); + bool DataTypeSave(const fs::path & fsFile); - bool Convert2Bin(const std::string & szFN); + bool Convert2Bin(const fs::path & fsFile); - bool OpenSource(const std::string & szEnumFileName, const std::string & szTxtFileName); - bool OpenReference_Enum(const std::string & szEnumFileName); - bool OpenReference_Txt(int iIndex, const std::string & szTxtFileName); - bool Generate(int iIndex, const std::string & szEnumFileName, const std::string & szTxtFileName); + bool OpenSource(const fs::path & fsEnumFile, const fs::path & fsTxtFile); + bool OpenReference_Enum(const fs::path & fsEnumFile); + bool OpenReference_Txt(int iIndex, const fs::path & fsTxtFile); + bool Generate(int iIndex, const fs::path & fsEnumFile, const fs::path & fsTxtFile); void Release(); CTableGenerator(); diff --git a/src/tool/ServerInfoViewer/MainFrm.cpp b/src/tool/ServerInfoViewer/MainFrm.cpp index ed200ab9..1eb5ba94 100644 --- a/src/tool/ServerInfoViewer/MainFrm.cpp +++ b/src/tool/ServerInfoViewer/MainFrm.cpp @@ -65,7 +65,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); m_Camera.EyePosSet(100, 50, -100); m_Camera.UpVectorSet(0, 1, 0); diff --git a/src/tool/SkyViewer/FormViewProperty.cpp b/src/tool/SkyViewer/FormViewProperty.cpp index 40b063ab..b8d47a18 100644 --- a/src/tool/SkyViewer/FormViewProperty.cpp +++ b/src/tool/SkyViewer/FormViewProperty.cpp @@ -294,15 +294,15 @@ void CFormViewProperty::UpdateAllInfo() { CSkyViewerDoc * pDoc = GetDocument(); if (pDoc->m_Sky.MoonTextureGet()) { - SetDlgItemText(IDC_E_MOON_TEXTURE, pDoc->m_Sky.MoonTextureGet()->FileName().c_str()); + SetDlgItemTextW(GetSafeHwnd(), IDC_E_MOON_TEXTURE, pDoc->m_Sky.MoonTextureGet()->FilePath().c_str()); } else { - SetDlgItemText(IDC_E_MOON_TEXTURE, ""); + SetDlgItemTextW(GetSafeHwnd(), IDC_E_MOON_TEXTURE, L""); } m_ListSunTextures.ResetContent(); for (int i = 0; i < NUM_SUNPART; i++) { if (pDoc->m_Sky.SunTextureGet(i)) { - m_ListSunTextures.AddString(pDoc->m_Sky.SunTextureGet(i)->FileName().c_str()); + m_ListSunTextures.AddString(pDoc->m_Sky.SunTextureGet(i)->FilePath().string().c_str()); } else { m_ListSunTextures.AddString(""); } @@ -310,7 +310,7 @@ void CFormViewProperty::UpdateAllInfo() { m_ListCloudTextures.ResetContent(); for (int i = 0; i < NUM_CLOUD; i++) { - m_ListCloudTextures.AddString(pDoc->m_Sky.CloudTextureFileName(i)); + m_ListCloudTextures.AddString(pDoc->m_Sky.CloudTextureFile(i).string().c_str()); } int iIndexPrev = m_ListDayChanges.GetCurSel(); @@ -400,22 +400,21 @@ void CFormViewProperty::OnTimer(UINT nIDEvent) { } void CFormViewProperty::OnDblclkListCloudTextures() { - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "DXT", NULL, dwFlags, "Texture 로 쓸수 있는 그림 파일(*.DXT; *.BMP; *.TGA)|*.DXT; *.BMP; *.TGA||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } + fs::path fsFile = dlg.GetPathName().GetString(); int iIndex = m_ListCloudTextures.GetCurSel(); - FileName = dlg.GetPathName(); CSkyViewerDoc * pDoc = GetDocument(); - CN3Texture * pTex = pDoc->m_Sky.CloudTextureSet(iIndex, FileName); + CN3Texture * pTex = pDoc->m_Sky.CloudTextureSet(iIndex, fsFile); m_ListCloudTextures.DeleteString(iIndex); - m_ListCloudTextures.InsertString(iIndex, pTex->FileName().c_str()); + m_ListCloudTextures.InsertString(iIndex, pTex->FilePath().string().c_str()); m_ListCloudTextures.SetCurSel(iIndex); CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); @@ -423,22 +422,21 @@ void CFormViewProperty::OnDblclkListCloudTextures() { } void CFormViewProperty::OnDblclkListSunTextures() { - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "DXT", NULL, dwFlags, "Texture 로 쓸수 있는 그림 파일(*.DXT; *.BMP; *.TGA)|*.DXT; *.BMP; *.TGA||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } + fs::path fsFile = dlg.GetPathName().GetString(); int iIndex = m_ListSunTextures.GetCurSel(); - FileName = dlg.GetPathName(); CSkyViewerDoc * pDoc = GetDocument(); - CN3Texture * pTex = pDoc->m_Sky.SunTextureSet(iIndex, FileName); + CN3Texture * pTex = pDoc->m_Sky.SunTextureSet(iIndex, fsFile); m_ListSunTextures.DeleteString(iIndex); - m_ListSunTextures.InsertString(iIndex, pTex->FileName().c_str()); + m_ListSunTextures.InsertString(iIndex, pTex->FilePath().string().c_str()); m_ListSunTextures.SetCurSel(iIndex); CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); @@ -446,19 +444,18 @@ void CFormViewProperty::OnDblclkListSunTextures() { } void CFormViewProperty::OnBBrowseMoonTexture() { - CString FileName; DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "DXT", NULL, dwFlags, "Texture 로 쓸수 있는 그림 파일(*.DXT; *.BMP; *.TGA)|*.DXT; *.BMP; *.TGA||", NULL); if (dlg.DoModal() == IDCANCEL) { return; } + fs::path fsFile = dlg.GetPathName().GetString(); - FileName = dlg.GetPathName(); CSkyViewerDoc * pDoc = GetDocument(); - CN3Texture * pTex = pDoc->m_Sky.MoonTextureSet(FileName); + CN3Texture * pTex = pDoc->m_Sky.MoonTextureSet(fsFile); - SetDlgItemText(IDC_E_MOON_TEXTURE, pTex->FileName().c_str()); + SetDlgItemTextW(GetSafeHwnd(), IDC_E_MOON_TEXTURE, pTex->FilePath().c_str()); CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); pFrm->GetViewRender()->InvalidateRect(NULL, FALSE); diff --git a/src/tool/SkyViewer/MainFrm.cpp b/src/tool/SkyViewer/MainFrm.cpp index 0a6ef0e8..d4d5f631 100644 --- a/src/tool/SkyViewer/MainFrm.cpp +++ b/src/tool/SkyViewer/MainFrm.cpp @@ -62,7 +62,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); - CN3Base::PathSet(fs::current_path().string()); + CN3Base::PathSet(fs::current_path()); if (!m_Eng.Init(TRUE, m_hWnd, 64, 64, 0, TRUE)) { return -1; @@ -76,7 +76,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { m_Lights[1].m_Data.InitDirection(1, __Vector3(0, 0, -1), crLgt); m_Lights[2].m_Data.InitPoint(2, __Vector3(0, 0, 0), crLgt, 32.0f); - m_ObjectBundle.LoadFromFile("ChrSelect\\el_chairs.n3shape"); // 배경으로 쓸 오브젝트 부르기.. + m_ObjectBundle.LoadFromFile(fs::path("ChrSelect") / "el_chairs.n3shape"); // 배경으로 쓸 오브젝트 부르기.. return 0; } @@ -141,15 +141,13 @@ void CMainFrame::OnImportObject() { return; } - CString szFullPath = dlg.GetPathName(); - - std::string szObjPrev = m_ObjectBundle.FileName(); + fs::path fsFile = dlg.GetPathName().GetString(); + fs::path fsObjPrev = m_ObjectBundle.FilePath(); m_ObjectBundle.Release(); - if (m_ObjectBundle.LoadFromFile((const char *)szFullPath)) // 배경으로 쓸 오브젝트 부르기.. - { + if (m_ObjectBundle.LoadFromFile(fsFile)) { // 배경으로 쓸 오브젝트 부르기.. CSkyViewerView * pView = (CSkyViewerView *)(m_wndSplitter.GetPane(0, 1)); pView->InvalidateRect(NULL, FALSE); } else { - m_ObjectBundle.LoadFromFile(szObjPrev); + m_ObjectBundle.LoadFromFile(fsObjPrev); } } diff --git a/src/tool/UIE/DlgBar.cpp b/src/tool/UIE/DlgBar.cpp index e67b98a8..7c85bd74 100644 --- a/src/tool/UIE/DlgBar.cpp +++ b/src/tool/UIE/DlgBar.cpp @@ -45,7 +45,7 @@ void CDlgBar::OnButtonBasepath() { return; } - std::string szCurDir = CN3Base::PathGet(); + std::string szCurDir = fs::path(CN3Base::PathGet()).make_preferred().string(); CFolderPickerDialog dlg; dlg.m_ofn.lpstrTitle = "Please select the resource base path."; @@ -54,10 +54,10 @@ void CDlgBar::OnButtonBasepath() { return; } - std::string szDir = dlg.GetPathName().GetString(); - pFrm->SetBasePath(szDir.c_str()); + fs::path fsDir = dlg.GetPathName().GetString(); + pFrm->SetBasePath(fsDir); CWinApp * pApp = AfxGetApp(); ASSERT(pApp); - pApp->WriteProfileString("Work", "Path", szDir.c_str()); + pApp->WriteProfileString("Work", "Path", fsDir.string().c_str()); } diff --git a/src/tool/UIE/DlgChangeImage.cpp b/src/tool/UIE/DlgChangeImage.cpp index a109e915..be12a644 100644 --- a/src/tool/UIE/DlgChangeImage.cpp +++ b/src/tool/UIE/DlgChangeImage.cpp @@ -46,17 +46,9 @@ void CDlgChangeImage::OnBBrowseOldFile() { if (IDCANCEL == dlg.DoModal()) { return; } - CString szFN_Old = dlg.GetPathName(); - szFN_Old.MakeLower(); // 소문자로 만들고.. - - CString szPath = CN3Base::PathGet().c_str(); - szPath.MakeLower(); - int i = szFN_Old.Find(szPath); - if (i >= 0) { - szFN_Old = szFN_Old.Mid(i + szPath.GetLength()); - } - - SetDlgItemText(IDC_E_PATH_OLD, szFN_Old); + fs::path fsFile = dlg.GetPathName().GetString(); + CN3BaseFileAccess::ToRelative(fsFile); + SetDlgItemText(IDC_E_PATH_OLD, fsFile.string().c_str()); } void CDlgChangeImage::OnBBrowseNewFile() { @@ -66,24 +58,19 @@ void CDlgChangeImage::OnBBrowseNewFile() { if (IDCANCEL == dlg.DoModal()) { return; } - CString szFN_New = dlg.GetPathName(); - szFN_New.MakeLower(); // 소문자로 만들고.. - - CString szPath = CN3Base::PathGet().c_str(); - szPath.MakeLower(); // 소문자로 만든다 - int i = szFN_New.Find(szPath); - if (i >= 0) { - szFN_New = szFN_New.Mid(i + szPath.GetLength()); - } - - SetDlgItemText(IDC_E_PATH_NEW, szFN_New); + fs::path fsFile = dlg.GetPathName().GetString(); + CN3BaseFileAccess::ToRelative(fsFile); + SetDlgItemText(IDC_E_PATH_NEW, fsFile.string().c_str()); } void CDlgChangeImage::OnOK() { // TODO: Add extra validation here + CString szFile; + GetDlgItemText(IDC_E_PATH_OLD, szFile); + m_fsOldFile = szFile.GetString(); - GetDlgItemText(IDC_E_PATH_OLD, m_szFN_Old); - GetDlgItemText(IDC_E_PATH_NEW, m_szFN_New); + GetDlgItemText(IDC_E_PATH_NEW, szFile); + m_fsNewFile = szFile.GetString(); CDialog::OnOK(); } diff --git a/src/tool/UIE/DlgChangeImage.h b/src/tool/UIE/DlgChangeImage.h index 08af5ccb..081be7d2 100644 --- a/src/tool/UIE/DlgChangeImage.h +++ b/src/tool/UIE/DlgChangeImage.h @@ -8,8 +8,8 @@ class CDlgChangeImage : public CDialog { public: - CString m_szFN_Old; - CString m_szFN_New; + fs::path m_fsOldFile; + fs::path m_fsNewFile; // Construction public: CDlgChangeImage(CWnd * pParent = NULL); // standard constructor diff --git a/src/tool/UIE/DlgTexture.cpp b/src/tool/UIE/DlgTexture.cpp index d34f045e..f7f574cb 100644 --- a/src/tool/UIE/DlgTexture.cpp +++ b/src/tool/UIE/DlgTexture.cpp @@ -23,7 +23,7 @@ CDlgTexture::CDlgTexture(CWnd * pParent /*=NULL*/) //}}AFX_DATA_INIT m_pTexViewer = new CTexViewer; m_iImageTypeCount = 0; - ZeroMemory(m_szImageTypeNames, sizeof(char) * MAX_IMAGETYPE * _MAX_PATH); + memset(m_szImageTypeNames, 0, sizeof(m_szImageTypeNames)); m_hAccelTable = NULL; } @@ -135,9 +135,9 @@ void CDlgTexture::OnOK() { } } -void CDlgTexture::SetTexture(LPCTSTR pszFileName) { +void CDlgTexture::SetTexture(const fs::path & fsFile) { if (m_pTexViewer) { - m_pTexViewer->SetTexture(pszFileName); + m_pTexViewer->SetTexture(fsFile); } } diff --git a/src/tool/UIE/DlgTexture.h b/src/tool/UIE/DlgTexture.h index 13a87486..d42b0e53 100644 --- a/src/tool/UIE/DlgTexture.h +++ b/src/tool/UIE/DlgTexture.h @@ -27,12 +27,12 @@ class CDlgTexture : public CDialog { protected: CTexViewer * m_pTexViewer; int m_iImageTypeCount; - char m_szImageTypeNames[MAX_IMAGETYPE][_MAX_PATH]; + char m_szImageTypeNames[MAX_IMAGETYPE][100]; HACCEL m_hAccelTable; // Operations public: - void SetTexture(LPCTSTR pszFileName); + void SetTexture(const fs::path & fsFile); BOOL GetSelectedUVRect(struct __FLOAT_RECT * pFRect) const; void SetSelectedUVRect(const struct __FLOAT_RECT * pFRect); // 현재 선택된 UV좌표 넣기 CRect GetSelectedRect() const; diff --git a/src/tool/UIE/DlgUnusedFileList.cpp b/src/tool/UIE/DlgUnusedFileList.cpp index e48eeb78..6e138c68 100644 --- a/src/tool/UIE/DlgUnusedFileList.cpp +++ b/src/tool/UIE/DlgUnusedFileList.cpp @@ -43,24 +43,26 @@ void CDlgUnusedFileList::OnBDeleteSelect() { return; } - int * piSels = new int[iSC]; - m_ListFiles.GetSelItems(iSC, piSels); - for (int i = 0; i < iSC; i++) { - CString szPath; - m_ListFiles.GetText(piSels[i], szPath); - ::DeleteFile(szPath); + if (IDYES != MessageBox("Would you like to erase it?", "Check", MB_YESNO)) { + return; + } + + std::vector vSels(iSC); + m_ListFiles.GetSelItems(iSC, vSels.data()); + + for (const auto & iSelIndex : vSels) { + CString szFile; + m_ListFiles.GetText(iSelIndex, szFile); + fs::remove(szFile.GetString()); } - delete piSels; } BOOL CDlgUnusedFileList::OnInitDialog() { CDialog::OnInitDialog(); - int iFC = m_szFileNames.GetSize(); - for (int i = 0; i < iFC; i++) { - m_ListFiles.AddString(m_szFileNames[i]); + for (const auto & fsFile : m_vFiles) { + m_ListFiles.AddString(CString(fsFile.c_str())); } - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE + return TRUE; } diff --git a/src/tool/UIE/DlgUnusedFileList.h b/src/tool/UIE/DlgUnusedFileList.h index e28eaf1b..a41f7295 100644 --- a/src/tool/UIE/DlgUnusedFileList.h +++ b/src/tool/UIE/DlgUnusedFileList.h @@ -8,7 +8,7 @@ class CDlgUnusedFileList : public CDialog { public: - CStringArray m_szFileNames; + std::vector m_vFiles; // Construction public: CDlgUnusedFileList(CWnd * pParent = NULL); // standard constructor diff --git a/src/tool/UIE/MainFrm.cpp b/src/tool/UIE/MainFrm.cpp index 2d84411a..f7abe837 100644 --- a/src/tool/UIE/MainFrm.cpp +++ b/src/tool/UIE/MainFrm.cpp @@ -92,11 +92,11 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { ASSERT(pApp); CString szRet = pApp->GetProfileString("Work", "Path", "empty"); if (szRet == "empty") { - std::string szDir = n3std::get_app_dir().string(); - pApp->WriteProfileString("Work", "Path", szDir.c_str()); - SetBasePath(szDir.c_str()); + fs::path fsDir = n3std::get_app_dir(); + pApp->WriteProfileString("Work", "Path", fsDir.string().c_str()); + SetBasePath(fsDir); } else { - SetBasePath(szRet); + SetBasePath(szRet.GetString()); } // Engine 생성 @@ -209,12 +209,12 @@ void CMainFrame::OnUpdateViewEdit(CCmdUI * pCmdUI) { pCmdUI->SetRadio(CUIEView::UIEMODE_EDIT == GetRightPane()->GetMode() ? TRUE : FALSE); } -void CMainFrame::SetBasePath(LPCTSTR pszPath) { - CN3Base::PathSet(pszPath); - if (NULL == pszPath) { +void CMainFrame::SetBasePath(const fs::path & fsDir) { + CN3Base::PathSet(fsDir); + if (fsDir.empty()) { m_wndDlgBar.SetDlgItemText(IDC_EDIT_BASEPATH, _T("")); } else { - m_wndDlgBar.SetDlgItemText(IDC_EDIT_BASEPATH, CN3Base::PathGet().c_str()); + m_wndDlgBar.SetDlgItemText(IDC_EDIT_BASEPATH, CN3Base::PathGet().string().c_str()); } } diff --git a/src/tool/UIE/MainFrm.h b/src/tool/UIE/MainFrm.h index 0d1c8b6b..6ab7e092 100644 --- a/src/tool/UIE/MainFrm.h +++ b/src/tool/UIE/MainFrm.h @@ -26,7 +26,7 @@ class CMainFrame : public CFrameWnd { // Operations public: - void SetBasePath(LPCTSTR pszPath); + void SetBasePath(const fs::path & fsDir); void SetStatusText(LPCTSTR pszText); void EnableAccelerator(BOOL bEnable); // Overrides diff --git a/src/tool/UIE/PropertyView.cpp b/src/tool/UIE/PropertyView.cpp index dc0a690b..ec1f5fed 100644 --- a/src/tool/UIE/PropertyView.cpp +++ b/src/tool/UIE/PropertyView.cpp @@ -220,10 +220,10 @@ BOOL CPropertyView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { pUI->SetTooltipText(pItem->m_curValue); } else if (pItem->m_propName == "Open sound") { pUI->SetSndOpen((LPCTSTR)pItem->m_curValue); - pItem->m_curValue = pUI->GetSndFName_OpenUI().c_str(); + pItem->m_curValue = pUI->GetSndFileOpenUI().c_str(); } else if (pItem->m_propName == "Close sound") { pUI->SetSndClose((LPCTSTR)pItem->m_curValue); - pItem->m_curValue = pUI->GetSndFName_CloseUI().c_str(); + pItem->m_curValue = pUI->GetSndFileCloseUI().c_str(); } else if (pItem->m_propName == "Delete sound") { pUI->SetSndOpen(""); pUI->SetSndClose(""); @@ -246,19 +246,17 @@ BOOL CPropertyView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { if ((void *)wParam == (&m_UIImage) && UI_TYPE_IMAGE == pUI->UIType()) { CN3UIImage * pImage = (CN3UIImage *)pUI; if (pItem->m_propName == "Texture") { - CN3BaseFileAccess tmpBase; - tmpBase.FileNameSet((LPCTSTR)pItem->m_curValue); // Base경로에 대해서 상대적 경로를 넘겨준다. - - pImage->SetTex(tmpBase.FileName()); - pItem->m_curValue = tmpBase.FileName().c_str(); //tex file name 다시 설정 + fs::path fsTexFile = CN3BaseFileAccess::ToRelative(pItem->m_curValue.GetString()); + pImage->SetTex(fsTexFile); + pItem->m_curValue = fsTexFile.c_str(); //tex file name 다시 설정 m_UIImage.Invalidate(); } else if (pItem->m_propName == "UV left" || pItem->m_propName == "UV top" || pItem->m_propName == "UV right" || pItem->m_propName == "UV bottom") { // UV 설정하는 함수 만들어서 처리하기 CN3Texture * pTex = pImage->GetTex(); - if (pTex && pTex->FileName().size() > 0) { + if (pTex && !pTex->FilePath().empty()) { CDlgTexture dlg; - dlg.SetTexture(pTex->FileName().c_str()); + dlg.SetTexture(pTex->FilePath()); dlg.SetSelectedUVRect(pImage->GetUVRect()); if (IDOK == dlg.DoModal()) { __FLOAT_RECT frc; @@ -296,13 +294,13 @@ BOOL CPropertyView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { if (dlgAnim.m_iCount <= 0) { break; // 1장 이상이면 texture와 uv좌표 세팅 } - char szTexFName[_MAX_PATH]; - if (FALSE == SelectTexture(szTexFName)) { - break; // texture이름 정하기 + fs::path fsTexFile; + if (!SelectTexture(&fsTexFile)) { + break; // Decide on a texture name } // 여러장의 이미지 세팅하게 하기 CDlgTexture dlgTex; - dlgTex.SetTexture(szTexFName); + dlgTex.SetTexture(fsTexFile); char szNames[1000][20]; char * szImageTypeNames[1000]; for (int i = 0; i < dlgAnim.m_iCount; ++i) { @@ -321,7 +319,7 @@ BOOL CPropertyView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { if (NULL == pChildImage) { continue; } - pChildImage->SetTex(szTexFName); // texture설정 + pChildImage->SetTex(fsTexFile); // texture설정 pChildImage->SetUVRect(frcUV.left, frcUV.top, frcUV.right, frcUV.bottom); // uv 설정 } // 위치 설정 @@ -443,10 +441,10 @@ BOOL CPropertyView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { pFrm->GetRightPane()->SelectRectType(CUIEView::RT_CLICK); } else if (pItem->m_propName == "On sound") { pBtn->SetSndOn((LPCTSTR)pItem->m_curValue); - pItem->m_curValue = pBtn->GetSndFName_On().c_str(); + pItem->m_curValue = pBtn->GetSndFileOn().c_str(); } else if (pItem->m_propName == "Click sound") { pBtn->SetSndClick((LPCTSTR)pItem->m_curValue); - pItem->m_curValue = pBtn->GetSndFName_Click().c_str(); + pItem->m_curValue = pBtn->GetSndFileClick().c_str(); } else if (pItem->m_propName == "Delete sound") { pBtn->SetSndOn(""); pBtn->SetSndClick(""); @@ -467,7 +465,7 @@ BOOL CPropertyView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { CN3UIStatic * pStatic = (CN3UIStatic *)pUI; if (pItem->m_propName == "Click sound") { pStatic->SetSndClick((LPCTSTR)pItem->m_curValue); - pItem->m_curValue = pStatic->GetSndFName_Click().c_str(); + pItem->m_curValue = pStatic->GetSndFileClick().c_str(); } else if (pItem->m_propName == "Delete bkgnd image") { pStatic->DeleteImage(); GetDocument()->UpdateAllViews(NULL); @@ -498,7 +496,7 @@ BOOL CPropertyView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult) { pEdit->SetStyle(dwStyle); } else if (pItem->m_propName == "Typing sound") { pEdit->SetSndTyping((LPCTSTR)pItem->m_curValue); - pItem->m_curValue = pEdit->GetSndFName_Typing().c_str(); + pItem->m_curValue = pEdit->GetSndFileTyping().c_str(); } else if (pItem->m_propName == "Delete bkgnd image") { pEdit->DeleteImage(); GetDocument()->UpdateAllViews(NULL); @@ -807,12 +805,12 @@ void CPropertyView::UpdateUIBaseInfo() { pItem = m_UIBase.GetPropItem("Open sound"); // open sound if (pItem) { - pItem->m_curValue = pUIBase->GetSndFName_OpenUI().c_str(); + pItem->m_curValue = pUIBase->GetSndFileOpenUI().c_str(); } pItem = m_UIBase.GetPropItem("Close sound"); // close sound if (pItem) { - pItem->m_curValue = pUIBase->GetSndFName_CloseUI().c_str(); + pItem->m_curValue = pUIBase->GetSndFileCloseUI().c_str(); } pItem = m_UIBase.GetPropItem("Visible"); // visible @@ -844,10 +842,10 @@ void CPropertyView::UpdateUIImageInfo() { CPropertyItem * pItem = NULL; pItem = m_UIImage.GetPropItem("Texture"); // texture 이름 if (pItem) { - pItem->m_curValue = pUI->GetTexFN().c_str(); + pItem->m_curValue = pUI->GetTexFile().c_str(); CN3Texture * pTex = pUI->GetTex(); if (pTex) { - pItem->m_curValue = pTex->FileName().c_str(); + pItem->m_curValue = pTex->FilePath().c_str(); } else { pItem->m_curValue += " : Load fail."; } @@ -1070,12 +1068,12 @@ void CPropertyView::UpdateUIButtonInfo() { pItem = m_UIButton.GetPropItem("On sound"); // on sound if (pItem) { - pItem->m_curValue = pUI->GetSndFName_On().c_str(); + pItem->m_curValue = pUI->GetSndFileOn().c_str(); } pItem = m_UIButton.GetPropItem("Click sound"); // click sound if (pItem) { - pItem->m_curValue = pUI->GetSndFName_Click().c_str(); + pItem->m_curValue = pUI->GetSndFileClick().c_str(); } m_UIButton.Invalidate(); @@ -1191,7 +1189,7 @@ void CPropertyView::UpdateUIStaticInfo() { CPropertyItem * pItem = NULL; pItem = m_UIStatic.GetPropItem("Click sound"); // click sound if (pItem) { - pItem->m_curValue = pUI->GetSndFName_Click().c_str(); + pItem->m_curValue = pUI->GetSndFileClick().c_str(); } m_UIStatic.Invalidate(); @@ -1224,7 +1222,7 @@ void CPropertyView::UpdateUIEditInfo() { } pItem = m_UIEdit.GetPropItem("Typing sound"); // typing sound if (pItem) { - pItem->m_curValue = pUI->GetSndFName_Typing().c_str(); + pItem->m_curValue = pUI->GetSndFileTyping().c_str(); } m_UIEdit.Invalidate(); diff --git a/src/tool/UIE/TexViewer.cpp b/src/tool/UIE/TexViewer.cpp index f29a15be..817c0309 100644 --- a/src/tool/UIE/TexViewer.cpp +++ b/src/tool/UIE/TexViewer.cpp @@ -456,9 +456,9 @@ void CTexViewer::Render() { } } -void CTexViewer::SetTexture(LPCTSTR pszFName) { +void CTexViewer::SetTexture(const fs::path & fsFile) { CN3Base::s_MngTex.Delete(&m_pTex); - m_pTex = CN3Base::s_MngTex.Get(pszFName); + m_pTex = CN3Base::s_MngTex.Get(fsFile); // texture size 지정 if (m_pTex) { diff --git a/src/tool/UIE/TexViewer.h b/src/tool/UIE/TexViewer.h index 4db04b45..77194d0b 100644 --- a/src/tool/UIE/TexViewer.h +++ b/src/tool/UIE/TexViewer.h @@ -73,10 +73,10 @@ class CTexViewer : public CWnd { // Operations public: void Release(); - BOOL Zoom(BOOL bZoomIn); // in : 확대, out : 축소 - BOOL Zoom(float fScale); // f배로 Zoom 하기 - void Render(); // texture render하기 - void SetTexture(LPCTSTR pszFName); // texture 지정 + BOOL Zoom(BOOL bZoomIn); // in : 확대, out : 축소 + BOOL Zoom(float fScale); // f배로 Zoom 하기 + void Render(); // texture render하기 + void SetTexture(const fs::path & fsFile); // texture 지정 eEDITMODE SetEditMode(eEDITMODE eMode); // mode 바꾸기 (zoom, hand, select) 실패하면 이전 mode를 돌려준다. void SetLeftTopInImage(CPoint ptLeftTop); // 이미지의 좌측 상단 좌표 바꾸기 BOOL GetSelectedUVRect(struct __FLOAT_RECT * pFRect) const; // 현재 선택된 UV좌표 얻기 diff --git a/src/tool/UIE/UIE.cpp b/src/tool/UIE/UIE.cpp index 6fdf14e3..8e7692c3 100644 --- a/src/tool/UIE/UIE.cpp +++ b/src/tool/UIE/UIE.cpp @@ -90,7 +90,6 @@ BOOL CUIEApp::InitInstance() { RegisterShellFileTypes(); CString strFileTypeName; - pDocTemplate->GetDocString(strFileTypeName, CDocTemplate::regFileTypeId); SetRegKey(".uif", strFileTypeName); @@ -157,23 +156,22 @@ void CUIEApp::OnAppAbout() { // CUIEApp message handlers // global function -BOOL SelectTexture(char * pszBuff) { - if (NULL == pszBuff) { +BOOL SelectTexture(fs::path * pfsFile) { + if (!pfsFile) { return FALSE; } - pszBuff[0] = NULL; + pfsFile->clear(); + DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, "dxt", NULL, dwFlags, "Generic Image Files(*.bmp, *.tga, *.dxt)|*.bmp;*.tga;*.dxt||", NULL); - dlg.m_ofn.lpstrInitialDir = CN3Base::PathGet().c_str(); + std::string szInitialDir = fs::path(CN3Base::PathGet()).make_preferred().string(); + dlg.m_ofn.lpstrInitialDir = szInitialDir.c_str(); dlg.m_ofn.lpstrTitle = "Select texture file"; if (IDCANCEL == dlg.DoModal()) { return FALSE; } - lstrcpy(pszBuff, dlg.GetPathName()); - // CN3BaseFileAccess tmpBase; - // tmpBase.FileNameSet(pszBuff); // Base경로에 대해서 상대적 경로를 넘겨준다. - // const std::string strFN(tmpBase.FileName()); - // strcpy(pszBuff, strFN.c_str()); + *pfsFile = dlg.GetPathName().GetString(); + //CN3BaseFileAccess::ToRelative(*pfsFile); return TRUE; } diff --git a/src/tool/UIE/UIE.h b/src/tool/UIE/UIE.h index bf6c7c47..d570f860 100644 --- a/src/tool/UIE/UIE.h +++ b/src/tool/UIE/UIE.h @@ -37,7 +37,7 @@ class CUIEApp : public CWinApp { ///////////////////////////////////////////////////////////////////////////// // global function -BOOL SelectTexture(char * pszBuff); +BOOL SelectTexture(fs::path * pfsFile); //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/src/tool/UIE/UIEDoc.cpp b/src/tool/UIE/UIEDoc.cpp index 28f6152a..ea4a837c 100644 --- a/src/tool/UIE/UIEDoc.cpp +++ b/src/tool/UIE/UIEDoc.cpp @@ -128,7 +128,7 @@ BOOL CUIEDoc::OnOpenDocument(LPCTSTR lpszPathName) { // if (!CDocument::OnOpenDocument(lpszPathName)) // return FALSE; Release(); - SetCurrentDirectory(CN3Base::PathGet().c_str()); + fs::current_path(CN3Base::PathGet()); return m_RootUI.LoadFromFile(lpszPathName); } @@ -362,33 +362,36 @@ void CUIEDoc::OnInsertProgress() { // background이미지와 foreground이미지를 설정하고 CN3UIImage * pUIImage = pUI->GetBkGndImgRef(); ASSERT(pUIImage); - // texture 설정 - char szTexture[_MAX_PATH]; - while (1) { - if (FALSE == SelectTexture(szTexture)) { - if (IDYES == - pFrm->MessageBox("텍스쳐 지정이 취소되었습니다.\nProgress를 삭제하시겠습니까?", NULL, MB_YESNO)) { + + // texture settings + fs::path fsTexFile; + while (true) { + if (!SelectTexture(&fsTexFile)) { + if (IDYES == pFrm->MessageBox("Texture assignment has been cancelled.\nDo you want to delete Progress?", + NULL, MB_YESNO)) { OnEditDelete(); } else { - pFrm->MessageBox("텍스쳐지정 및 기타 설정을 해야 progress가 보일 것입니다."); + pFrm->MessageBox("You will need to specify textures and other settings to see progress."); } return; } - pUIImage->SetTex(szTexture); - if (NULL == pUIImage->GetTex()) { - if (IDYES == pFrm->MessageBox("텍스쳐를 Load할 수 없습니다.\n다시 지정하시겠습니까?", NULL, MB_YESNO)) { + + pUIImage->SetTex(fsTexFile); + if (!pUIImage->GetTex()) { + if (IDYES == pFrm->MessageBox("Could not load texture.\nDo you want to re-specify it?", NULL, MB_YESNO)) { continue; } else { - pFrm->MessageBox("텍스쳐지정 및 기타 설정을 해야 progress가 보일 것입니다."); + pFrm->MessageBox("You will need to specify textures and other settings to see progress."); } return; } else { break; } } - // image의 normal on down disable그림 영역 설정 + + // Set the image area to disable normal on down of the image CDlgTexture dlg; - dlg.SetTexture(szTexture); + dlg.SetTexture(fsTexFile); char szNames[2][20] = {"Back", "Fore"}; char * szImageTypeNames[2] = {szNames[0], szNames[1]}; dlg.SetImageTypes(2, szImageTypeNames); @@ -413,7 +416,7 @@ void CUIEDoc::OnInsertProgress() { ASSERT(pUIImage); __FLOAT_RECT frcUV; rcRegion = dlg.GetImageRect(i, &frcUV); - pUIImage->SetTex(szTexture); + pUIImage->SetTex(fsTexFile); pUIImage->SetUVRect(frcUV.left, frcUV.top, frcUV.right, frcUV.bottom); } @@ -422,7 +425,7 @@ void CUIEDoc::OnInsertProgress() { pUI->SetFrGndUVFromFrGndImage(); pUI->SetRegion(rcRegion); // style 지정 - pFrm->MessageBox("왼쪽창에서 스타일(가로/세로)을 지정해주세요."); + pFrm->MessageBox("Please specify the style (horizontal/vertical) in the left window."); pFrm->GetRightPane()->SetMode(CUIEView::UIEMODE_EDIT); pFrm->GetRightPane()->SelectRectType(CUIEView::RT_REGION); @@ -641,15 +644,17 @@ BOOL CUIEDoc::SetImageInfos(CN3UIImage * pUI) { return FALSE; } CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); - // texture 지정 - char szTexture[_MAX_PATH]; - while (1) { - if (FALSE == SelectTexture(szTexture)) { + + // texture settings + fs::path fsTexFile; + while (true) { + if (!SelectTexture(&fsTexFile)) { return FALSE; } - pUI->SetTex(szTexture); - if (NULL == pUI->GetTex()) { - if (IDYES == pFrm->MessageBox("텍스쳐를 Load할 수 없습니다.\n다시 지정하시겠습니까?", NULL, MB_YESNO)) { + + pUI->SetTex(fsTexFile); + if (!pUI->GetTex()) { + if (IDYES == pFrm->MessageBox("Could not load texture.\nDo you want to re-specify it?", NULL, MB_YESNO)) { continue; } return FALSE; @@ -657,9 +662,10 @@ BOOL CUIEDoc::SetImageInfos(CN3UIImage * pUI) { break; } } - // texture 위의 쓰이는 부분 지정 (영역과 UV지정을 하기 위해) + + // Specify the part to be used on the texture (to specify the area and UV) CDlgTexture dlg; - dlg.SetTexture(szTexture); + dlg.SetTexture(fsTexFile); if (IDCANCEL == dlg.DoModal()) { return FALSE; } @@ -707,22 +713,25 @@ BOOL CUIEDoc::SetTrackBarInfos(CN3UITrackBar * pUI) { // background이미지와 thumb이미지를 설정하고 CN3UIImage * pUIImage = pUI->GetBkGndImgRef(); ASSERT(pUIImage); - // texture 설정 - char szTexture[_MAX_PATH]; - while (1) { - if (FALSE == SelectTexture(szTexture)) { + + // texture settings + fs::path fsTexFile; + while (true) { + if (!SelectTexture(&fsTexFile)) { return FALSE; } - pUIImage->SetTex(szTexture); - if (NULL == pUIImage->GetTex()) { + + pUIImage->SetTex(fsTexFile); + if (!pUIImage->GetTex()) { return FALSE; } else { break; } } - // image의 normal on down disable그림 영역 설정 + + // Set the image area to disable normal on down of the image CDlgTexture dlg; - dlg.SetTexture(szTexture); + dlg.SetTexture(fsTexFile); char szNames[2][20] = {"Back", "Thumb"}; char * szImageTypeNames[2] = {szNames[0], szNames[1]}; dlg.SetImageTypes(2, szImageTypeNames); @@ -741,7 +750,7 @@ BOOL CUIEDoc::SetTrackBarInfos(CN3UITrackBar * pUI) { ASSERT(pUIImage); __FLOAT_RECT frcUV; rcRegion = dlg.GetImageRect(i, &frcUV); - pUIImage->SetTex(szTexture); + pUIImage->SetTex(fsTexFile); pUIImage->SetUVRect(frcUV.left, frcUV.top, frcUV.right, frcUV.bottom); rcRegion.OffsetRect(-rcRegion.TopLeft()); pUIImage->SetRegion(rcRegion); @@ -757,23 +766,25 @@ BOOL CUIEDoc::SetButtonInfos(CN3UIButton * pUI) { CMainFrame * pFrm = (CMainFrame *)AfxGetMainWnd(); CN3UIImage * pUIImage = pUI->GetImageRef(CN3UIButton::BS_NORMAL); ASSERT(pUIImage); - // texture 설정 - char szTexture[_MAX_PATH]; - while (1) { - if (FALSE == SelectTexture(szTexture)) { + + // texture settings + fs::path fsTexFile; + while (true) { + if (!SelectTexture(&fsTexFile)) { return FALSE; } - pUIImage->SetTex(szTexture); - if (NULL == pUIImage->GetTex()) { + pUIImage->SetTex(fsTexFile); + if (!pUIImage->GetTex()) { return FALSE; } else { break; } } - // image의 normal on down disable그림 영역 설정 + + // Set the image area to disable normal on down of the image CDlgTexture dlg; - dlg.SetTexture(szTexture); - char szNames[4][_MAX_PATH] = {"Normal", "Down", "On", "Disable"}; + dlg.SetTexture(fsTexFile); + char szNames[4][100] = {"Normal", "Down", "On", "Disable"}; char * szImageTypeNames[4] = {szNames[0], szNames[1], szNames[2], szNames[3]}; dlg.SetImageTypes(4, szImageTypeNames); if (IDCANCEL == dlg.DoModal()) { @@ -785,7 +796,7 @@ BOOL CUIEDoc::SetButtonInfos(CN3UIButton * pUI) { ASSERT(pUIImage); __FLOAT_RECT frcUV; rcRegion = dlg.GetImageRect(i, &frcUV); - pUIImage->SetTex(szTexture); + pUIImage->SetTex(fsTexFile); pUIImage->SetRegion(rcRegion); pUIImage->SetUVRect(frcUV.left, frcUV.top, frcUV.right, frcUV.bottom); } @@ -808,7 +819,7 @@ void CUIEDoc::OnFileExportTooltip() { return; } - pUI->SaveToFile((LPCTSTR)dlg.GetPathName()); + pUI->SaveToFile(dlg.GetPathName().GetString()); } void CUIEDoc::OnUpdateFileExportTooltip(CCmdUI * pCmdUI) { @@ -825,7 +836,7 @@ void CUIEDoc::OnFileImportTooltip() { CN3UIStatic * pStatic = new CN3UIStatic(); pStatic->Init(&m_RootUI); - pStatic->LoadFromFile((LPCTSTR)dlg.GetPathName()); + pStatic->LoadFromFile(dlg.GetPathName().GetString()); SetSelectedUI(NULL); SetSelectedUI(pStatic); } @@ -1158,18 +1169,14 @@ void CUIEDoc::OnBatchToolChangeImagePath() { return; } - CN3Texture Tex; - POSITION pos = dlg.GetStartPosition(); - CString FileName; - std::string szFNOld(dlg2.m_szFN_Old.GetString()); - std::string szFNNew(dlg2.m_szFN_New.GetString()); + POSITION pos = dlg.GetStartPosition(); while (pos != NULL) { - CN3UIBase base; - FileName = dlg.GetNextPathName(pos); + fs::path fsFile = dlg.GetNextPathName(pos).GetString(); - base.LoadFromFile((const char *)FileName); - base.ChangeImagePath(szFNOld, szFNNew); + CN3UIBase base; + base.LoadFromFile(fsFile); + base.ChangeImagePath(dlg2.m_fsOldFile, dlg2.m_fsNewFile); base.SaveToFile(); } } @@ -1192,22 +1199,20 @@ void CUIEDoc::OnBatchToolChangeFont() { return; } - CN3Texture Tex; - POSITION pos = dlg.GetStartPosition(); - CString FileName; - CString szFont = dlg2.GetFaceName(); + POSITION pos = dlg.GetStartPosition(); + CString szFont = dlg2.GetFaceName(); while (pos != NULL) { - CN3UIBase base; - FileName = dlg.GetNextPathName(pos); + CString FileName = dlg.GetNextPathName(pos); - base.LoadFromFile((const char *)FileName); - base.ChangeFont((const char *)szFont); + CN3UIBase base; + base.LoadFromFile(FileName.GetString()); + base.ChangeFont(szFont.GetString()); base.SaveToFile(); } } void CUIEDoc::OnBatchToolGatherImageFileName() { - std::string szDlgInitialDir = CN3Base::PathGet(); + std::string szDlgInitialDir = fs::path(CN3Base::PathGet()).make_preferred().string(); DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT; CFileDialog dlg(TRUE, "uif", NULL, dwFlags, "UI Files(*.uif)|*.uif;||", NULL); @@ -1220,13 +1225,12 @@ void CUIEDoc::OnBatchToolGatherImageFileName() { return; } - std::set setImgFNs; - POSITION pos = dlg.GetStartPosition(); + std::set setUifImageFiles; + POSITION pos = dlg.GetStartPosition(); while (pos != NULL) { CN3UIBase base; - CString FileName = dlg.GetNextPathName(pos); - base.LoadFromFile((const char *)FileName); - base.GatherImageFileName(setImgFNs); + base.LoadFromFile(dlg.GetNextPathName(pos).GetString()); + base.GatherImageFileName(setUifImageFiles); } CFolderPickerDialog dlgFolderPick; @@ -1236,35 +1240,19 @@ void CUIEDoc::OnBatchToolGatherImageFileName() { return; } - std::string szCompareDir = dlgFolderPick.GetPathName().GetString(); - - char szPathOld[256]; - ::GetCurrentDirectory(_MAX_PATH, szPathOld); - ::SetCurrentDirectory(szCompareDir.c_str()); + fs::path fsCompareDir = dlgFolderPick.GetPathName().GetString(); - CFileFind ff; - if (ff.FindFile("*.dxt")) { - CDlgUnusedFileList dlg2; - CString szBasePath = CN3Base::PathGet().c_str(); - while (ff.FindNextFile()) { - CString szPath = ff.GetFilePath(); - CString szFN; - szPath.MakeLower(); - int ii = szPath.Find(szBasePath); - if (ii >= 0) { - szFN = szPath.Mid(ii + szBasePath.GetLength()); - } - - if (szFN.GetLength() >= 0) { - std::set::iterator it = setImgFNs.find((const char *)szFN); - if (it == setImgFNs.end()) { - dlg2.m_szFileNames.Add(szPath); - } - } + CDlgUnusedFileList dlgUnusedFiles; + for (const auto & fsEntry : fs::directory_iterator(fsCompareDir)) { + if (!fsEntry.is_regular_file() || !n3std::iequals(fsEntry.path().extension(), ".dxt")) { + continue; } - dlg2.DoModal(); + fs::path fsCurFile = fsEntry.path(); + CN3BaseFileAccess::ToRelative(fsCurFile); + if (!setUifImageFiles.contains(fsCurFile)) { + dlgUnusedFiles.m_vFiles.emplace_back(fsCurFile); + } } - - ::SetCurrentDirectory(szPathOld); + dlgUnusedFiles.DoModal(); } diff --git a/src/tool/UIE/UIEView.cpp b/src/tool/UIE/UIEView.cpp index 074d28b5..ae46f1e2 100644 --- a/src/tool/UIE/UIEView.cpp +++ b/src/tool/UIE/UIEView.cpp @@ -960,21 +960,13 @@ void CUIEView::OnDropFiles(HDROP hDropInfo) { CUIEDoc * pDoc = GetDocument(); ASSERT_VALID(pDoc); - char szFile[MAX_PATH]; - char * szExt = NULL; - UINT uiFiles; - - uiFiles = DragQueryFile(hDropInfo, 0xFFFF, NULL, 0); - - ::DragQueryFile(hDropInfo, 0, szFile, MAX_PATH - 1); + fs::path::value_type szFile[260]{}; + ::DragQueryFileW(hDropInfo, 0, szFile, std::size(szFile) - 1); ::DragFinish(hDropInfo); - int nLen = strlen(szFile); - - szExt = szFile + nLen - 3; - - if (0 == lstrcmpi(szExt, "uif") && pDoc) { - pDoc->OnOpenDocument(szFile); + fs::path fsFile = szFile; + if (pDoc && n3std::iequals(fsFile.extension(), ".uif")) { + pDoc->OnOpenDocument(fsFile.string().c_str()); pDoc->UpdateAllViews(NULL); } diff --git a/src/tool/Widget/PropertyList.cpp b/src/tool/Widget/PropertyList.cpp index e912619f..7cc22ae1 100644 --- a/src/tool/Widget/PropertyList.cpp +++ b/src/tool/Widget/PropertyList.cpp @@ -353,12 +353,20 @@ void CPropertyList::OnButton() { } else if (pItem->m_nItemType == PIT_FILE) { CString SelectedFile; CFileDialog FileDlg(TRUE, NULL, NULL, NULL, pItem->m_szCBItemsOrFilter.GetAt(0)); - - CString currPath = pItem->m_curValue; FileDlg.m_ofn.lpstrTitle = "Select file"; - if (currPath.GetLength() > 0) { - FileDlg.m_ofn.lpstrInitialDir = currPath.Left(currPath.GetLength() - currPath.ReverseFind('\\')); + + std::string szInitialDir; + fs::path fsDir = fs::path(pItem->m_curValue.GetString()).parent_path(); + if (!fsDir.empty()) { + if (fsDir.is_absolute()) { + szInitialDir = fsDir.string(); + } else { + // Assumes the application has already set the current path to the client folder. + // If not, the constructed path will be invalid, but it will fail gracefully. + szInitialDir = (fs::current_path() / fsDir).make_preferred().string(); + } } + FileDlg.m_ofn.lpstrInitialDir = szInitialDir.c_str(); if (IDOK == FileDlg.DoModal()) { SelectedFile = FileDlg.GetPathName(); @@ -382,35 +390,26 @@ void CPropertyList::OnButton() { dlg.m_ofn.lpstrFile = vFilesBuff.data(); dlg.m_ofn.nMaxFile = static_cast(vFilesBuff.size()); if (IDOK == dlg.DoModal()) { - POSITION pos = dlg.GetStartPosition(); - CStringArray szFNs; + POSITION pos = dlg.GetStartPosition(); - while (pos != NULL) { - szFNs.Add(dlg.GetNextPathName(pos)); + std::vector vSelFiles; + while (pos) { + vSelFiles.emplace_back(dlg.GetNextPathName(pos).GetString()); } pItem->m_curValue = ""; - int iSC = szFNs.GetSize(); + size_t iSC = vSelFiles.size(); if (iSC > 0) { - pItem->m_curValue += szFNs[iSC - 1]; - pItem->m_curValue += '\n'; - - for ( - int i = 1; i < iSC - 1; - i++) // 1 부터 시작하는 이유는 파일 대화상자에서 여러 파일을 부르면 첨과 끝 파일 이름이 바뀌기 때문이다. - { - pItem->m_curValue += szFNs[i]; - pItem->m_curValue += '\n'; + pItem->m_curValue += std::format("{:s}\n", vSelFiles.back().string()).c_str(); + for (size_t i = 1; i < iSC - 1; ++i) { + pItem->m_curValue += std::format("{:s}\n", vSelFiles[i].string()).c_str(); } - - pItem->m_curValue += szFNs[0]; - pItem->m_curValue += '\n'; + pItem->m_curValue += std::format("{:s}", vSelFiles.front().string()).c_str(); m_ButtonPush.ShowWindow(SW_HIDE); Invalidate(); - CWnd * pWnd = GetParent(); - if (pWnd) { + if (CWnd * pWnd = GetParent(); pWnd) { pWnd->SendMessage(WM_NOTIFY, (DWORD)this, (DWORD)pItem); // 부모 윈도우에 메시지 보내기.. } } From 6697fc213fdc790277ee535e6119f191d74a986b Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:07:59 -0500 Subject: [PATCH 5/9] Remove unused branch tags from .gitmodules file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `branch` option in `.gitmodules` is only relevant when tracking remote changes to a specific branch, such as a dedicated development branch. However, we use `master` as both the default development branch and the tagging mechanism for releases. As we don’t rely on a complex branching strategy, the `branch` tags are unnecessary for our use case. --- .gitmodules | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 62676a39..a9ef9387 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,16 +1,15 @@ [submodule "src/assets"] path = src/assets url = ../ko-assets - branch = 1.1.1 shallow = true depth = 1 [submodule "src/db"] path = src/db url = ../ko-db - branch = 1.1.2 + shallow = true + depth = 1 [submodule "src/vendor"] path = src/vendor url = ../ko-vendor - branch = 1.1.0 shallow = true depth = 1 From 05cf5e52c59da651a5332785361b253245fbbec2 Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:14:44 -0500 Subject: [PATCH 6/9] Update submodule ko-db to latest commit. Note that we released a new 1.2.0 version, as well as added updates related to the changes in this PR where it affects how we read the VERSION table. --- src/db | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/db b/src/db index 115644f6..4c0306c7 160000 --- a/src/db +++ b/src/db @@ -1 +1 @@ -Subproject commit 115644f6e1e73885eb0468fe387260269923cae3 +Subproject commit 4c0306c73cf9a2738aba23d202fb29c344d72e3c From 5fd40028a67fb86d90135f05b7e692892f9880cc Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:18:08 -0500 Subject: [PATCH 7/9] Disable recursive clone of submodules. Note that ko-db now includes its own submodule for archived migration scripts. To speed-up clonning time, we don't init the submodules recursively. --- config.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.cmd b/config.cmd index 46fbf130..7c3eb2b8 100644 --- a/config.cmd +++ b/config.cmd @@ -13,7 +13,7 @@ if ERRORLEVEL 1 ( exit 1 ) -git submodule update --init --recursive +git submodule update --init @REM src\All.sln From 78796540842f54ee891882d545f9ca9872ce8f06 Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:29:43 -0500 Subject: [PATCH 8/9] Extend std::format to support std::filesystem::path. C++26 plans to make `std::filesystem::path` compatible with `std::format`, but why wait for the future when we can build it ourselves today? This change brings tomorrow's functionality to life. If C++26 eventually delivers the same support, we can gracefully retire our custom solution and let the future take over. --- src/common/N3Utils.h | 16 +++++++++++++--- src/engine/N3Base/JpegFile.cpp | 6 +++--- src/game/Bird.cpp | 2 +- src/game/BirdMng.cpp | 2 +- src/server/AIServer/AIServerDlg.cpp | 6 +++--- src/server/Ebenezer/EbenezerDlg.cpp | 4 ++-- src/server/LoginServer/SettingDlg.cpp | 14 +++++++------- src/tool/N3Indoor/DlgUnusedFiles.h | 4 ++-- src/tool/N3Indoor/MainFrm.cpp | 14 ++++++-------- src/tool/N3ME/DlgUnusedFiles.h | 4 ++-- src/tool/N3ME/LyTerrain.cpp | 2 +- src/tool/N3ME/MapMng.cpp | 14 ++++++-------- src/tool/Widget/PropertyList.cpp | 6 +++--- 13 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/common/N3Utils.h b/src/common/N3Utils.h index 09e0d17d..df9c447d 100644 --- a/src/common/N3Utils.h +++ b/src/common/N3Utils.h @@ -405,9 +405,17 @@ using path = pathx; } // namespace fs -// Trick ADL to prioritize our custom overloads so that we return pathx instead of path -namespace std::filesystem { +// Extending standard functionality +namespace std { +// Allows std::format to support std::filesystem::path and derived types. +template struct formatter : formatter { + auto format(const T & p, format_context & ctx) const { return formatter::format(p.string(), ctx); } +}; + +namespace filesystem { + +// Trick ADL to prioritize our custom overload so that we return pathx instead of path [[nodiscard]] fs::pathx operator/(const n3std::PathConstructible auto & lhs, const n3std::PathConstructible auto & rhs) { #if defined(FS_AUTO_NORMALIZE) @@ -417,7 +425,9 @@ namespace std::filesystem { #endif } -} // namespace std::filesystem +} // namespace filesystem + +} // namespace std namespace n3std { diff --git a/src/engine/N3Base/JpegFile.cpp b/src/engine/N3Base/JpegFile.cpp index 8b78a924..6be691a6 100644 --- a/src/engine/N3Base/JpegFile.cpp +++ b/src/engine/N3Base/JpegFile.cpp @@ -121,7 +121,7 @@ BYTE * CJpegFile::JpegFileToRGB(const fs::path & fsFile, UINT * width, UINT * he */ if ((infile = _wfopen(fsFile.c_str(), L"rb")) == NULL) { - //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile.string()).c_str()); + //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile).c_str()); return NULL; } @@ -283,7 +283,7 @@ BOOL CJpegFile::GetJPGDimensions(const fs::path & fsFile, UINT * width, UINT * h */ if ((infile = _wfopen(fsFile.c_str(), L"rb")) == NULL) { - //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile.string()).c_str()); + //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile).c_str()); return FALSE; } @@ -447,7 +447,7 @@ BOOL CJpegFile::RGBToJpegFile(const fs::path & fsFile, BYTE * dataBuf, UINT widt /* Note: steps 2 and 3 can be done in either order. */ if ((outfile = _wfopen(fsFile.c_str(), L"wb")) == NULL) { - //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile.string()).c_str()); + //AfxMessageBox(std::format("JpegFile :\nCan't open {:s}\n", fsFile).c_str()); return FALSE; } diff --git a/src/game/Bird.cpp b/src/game/Bird.cpp index 824c73f4..0d7022e8 100644 --- a/src/game/Bird.cpp +++ b/src/game/Bird.cpp @@ -114,7 +114,7 @@ int CBird::LoadBird(const fs::path & fsFile) { FILE * stream = _wfopen(fsFile.c_str(), L"r"); //text파일로 만든다 if (NULL == stream) { #if _DEBUG - __ASSERT(stream, std::format("failed to open file - {:s}", fsFile.string()).c_str()); + __ASSERT(stream, std::format("failed to open file - {:s}", fsFile).c_str()); #endif return false; } diff --git a/src/game/BirdMng.cpp b/src/game/BirdMng.cpp index 89bc1df9..1d996014 100644 --- a/src/game/BirdMng.cpp +++ b/src/game/BirdMng.cpp @@ -37,7 +37,7 @@ void CBirdMng::LoadFromFile(const fs::path & fsFile) { FILE * stream = _wfopen(fsFile.c_str(), L"r"); //text파일로 만든다 if (NULL == stream) { #if _DEBUG - __ASSERT(stream, std::format("failed to open file - {:s}", fsFile.string()).c_str()); + __ASSERT(stream, std::format("failed to open file - {:s}", fsFile).c_str()); #endif return; } diff --git a/src/server/AIServer/AIServerDlg.cpp b/src/server/AIServer/AIServerDlg.cpp index f9e51bdc..bd25aa5b 100644 --- a/src/server/AIServer/AIServerDlg.cpp +++ b/src/server/AIServer/AIServerDlg.cpp @@ -1493,7 +1493,7 @@ BOOL CServerDlg::MapFileLoad() { CFile file; if (!file.Open(fsSmdFile.string().c_str(), CFile::modeRead)) { - AfxMessageBox(std::format("Failed to open file - {:s}", fsSmdFile.string()).c_str()); + AfxMessageBox(std::format("Failed to open file - {:s}", fsSmdFile).c_str()); return FALSE; } @@ -1503,7 +1503,7 @@ BOOL CServerDlg::MapFileLoad() { pMap->m_fsSmdFileName = szSmdFileName; if (!pMap->LoadMap((HANDLE)file.m_hFile)) { - AfxMessageBox(std::format("Map Load Failed - {:s}", fsSmdFile.string()).c_str()); + AfxMessageBox(std::format("Map Load Failed - {:s}", fsSmdFile).c_str()); delete pMap; return FALSE; } @@ -1511,7 +1511,7 @@ BOOL CServerDlg::MapFileLoad() { // dungeon work if (ZoneInfoSet.m_RoomEvent > 0) { if (!pMap->LoadRoomEvent(ZoneInfoSet.m_RoomEvent)) { - AfxMessageBox(std::format("Map Room Event Load Failed - {:s}", fsSmdFile.string()).c_str()); + AfxMessageBox(std::format("Map Room Event Load Failed - {:s}", fsSmdFile).c_str()); delete pMap; return FALSE; } diff --git a/src/server/Ebenezer/EbenezerDlg.cpp b/src/server/Ebenezer/EbenezerDlg.cpp index 80678016..eab1e014 100644 --- a/src/server/Ebenezer/EbenezerDlg.cpp +++ b/src/server/Ebenezer/EbenezerDlg.cpp @@ -1124,7 +1124,7 @@ BOOL CEbenezerDlg::MapFileLoad() { CFile file; if (!file.Open(fsSmdFile.string().c_str(), CFile::modeRead)) { - AfxMessageBox(std::format("File Open Fail - {:s}", fsSmdFile.string()).c_str()); + AfxMessageBox(std::format("File Open Fail - {:s}", fsSmdFile).c_str()); return FALSE; } @@ -1139,7 +1139,7 @@ BOOL CEbenezerDlg::MapFileLoad() { pMap->m_bType = ZoneInfoSet.m_Type; if (!pMap->LoadMap((HANDLE)file.m_hFile)) { - AfxMessageBox(std::format("Map Load Fail - {:s}", fsSmdFile.string()).c_str()); + AfxMessageBox(std::format("Map Load Fail - {:s}", fsSmdFile).c_str()); delete pMap; return FALSE; } diff --git a/src/server/LoginServer/SettingDlg.cpp b/src/server/LoginServer/SettingDlg.cpp index 615a9442..718d7a2f 100644 --- a/src/server/LoginServer/SettingDlg.cpp +++ b/src/server/LoginServer/SettingDlg.cpp @@ -143,7 +143,7 @@ void CSettingDlg::OnDeleteFile() { fs::path fsPatchFileName = std::format("patch{:04d}.zip", pInfo->sVersion); if (!m_pMain->m_DBProcess.InsertVersion(pInfo->sVersion, fsSelFile, fsPatchFileName, 0)) { m_pMain->m_VersionList.DeleteData(fsSelFile); - AfxMessageBox(std::format("{:s} DB Insert Fail", fsSelFile.string()).c_str()); + AfxMessageBox(std::format("{:s} DB Insert Fail", fsSelFile).c_str()); return; } } else { @@ -188,14 +188,14 @@ void CSettingDlg::OnCompress() { CFile file; if (!file.Open(szCurFileAbs.c_str(), CFile::modeRead)) { - AfxMessageBox(std::format("{:s} File Open Fail", fsCurFile.string()).c_str()); + AfxMessageBox(std::format("{:s} File Open Fail", fsCurFile).c_str()); continue; } DWORD dwSize = file.GetLength(); file.Close(); if (!m_ZipArchive.AddNewFile(szCurFileAbs.c_str(), szDefaultDir.c_str(), -1, dwSize)) { - AfxMessageBox(std::format("{:s} File Compress Fail", fsCurFile.string()).c_str()); + AfxMessageBox(std::format("{:s} File Compress Fail", fsCurFile).c_str()); continue; } m_Progress.SetPos(i * 100 / iFilesCount); @@ -291,7 +291,7 @@ bool CSettingDlg::Repacking(short sVersion) { bool CSettingDlg::InsertProcess(const fs::path & fsFile) { if (IsDBCSString(fsFile.string())) { - AfxMessageBox(std::format("'{:s}' include DBCS character", fsFile.string()).c_str()); + AfxMessageBox(std::format("'{:s}' include DBCS character", fsFile).c_str()); return false; } @@ -303,7 +303,7 @@ bool CSettingDlg::InsertProcess(const fs::path & fsFile) { return false; } if (!m_pMain->m_DBProcess.DeleteVersion(fsFile)) { - AfxMessageBox(std::format("'{:s}' DB Delete Fail", fsFile.string()).c_str()); + AfxMessageBox(std::format("'{:s}' DB Delete Fail", fsFile).c_str()); return false; } } @@ -320,7 +320,7 @@ bool CSettingDlg::InsertProcess(const fs::path & fsFile) { if (!m_pMain->m_DBProcess.InsertVersion(m_nVersion, fsFile, pInfo2->fsPatchFileName, sHistoryVersion)) { m_pMain->m_VersionList.DeleteData(fsFile); - AfxMessageBox(std::format("'{:s}' DB Insert Fail", fsFile.string()).c_str()); + AfxMessageBox(std::format("'{:s}' DB Insert Fail", fsFile).c_str()); return false; } @@ -344,7 +344,7 @@ void CSettingDlg::FolderRecurse(const fs::path & fsDir, bool bVerifyDbcs /*= fal if (bVerifyDbcs) { // Perform simple DBCS verification if (IsDBCSString(fsFile.string().c_str())) { - AfxMessageBox(std::format("'{:s}' includes DBCS character", fsFile.string()).c_str()); + AfxMessageBox(std::format("'{:s}' includes DBCS character", fsFile).c_str()); } continue; } diff --git a/src/tool/N3Indoor/DlgUnusedFiles.h b/src/tool/N3Indoor/DlgUnusedFiles.h index b8f3a9fb..6dfdbbf8 100644 --- a/src/tool/N3Indoor/DlgUnusedFiles.h +++ b/src/tool/N3Indoor/DlgUnusedFiles.h @@ -8,8 +8,8 @@ class CDlgUnusedFiles : public CDialog { public: - std::vector m_vFiles; - std::vector m_vErroredFiles; + std::vector m_vFiles; + std::vector m_vErroredFiles; public: void UpdateAll(); diff --git a/src/tool/N3Indoor/MainFrm.cpp b/src/tool/N3Indoor/MainFrm.cpp index b5eff71a..da15b2a8 100644 --- a/src/tool/N3Indoor/MainFrm.cpp +++ b/src/tool/N3Indoor/MainFrm.cpp @@ -1061,7 +1061,7 @@ void CMainFrame::OnTipDeleteUnusedFiles() { std::map mBases; std::vector vUnusedFiles; - std::vector vErroredFiles; + std::vector vErroredFiles; int iSC = m_pDlgOutputList->GetTotalShapeInfoCount(); for (int i = 0; i < iSC; i++) { @@ -1076,15 +1076,14 @@ void CMainFrame::OnTipDeleteUnusedFiles() { if (pVMesh) { mBases.emplace(pVMesh->FilePathAbs(), pVMesh); } else { - vErroredFiles.emplace_back(std::format(L"NULL VMesh : {:s}", pShape->FilePath().c_str())); + vErroredFiles.emplace_back(std::format("NULL VMesh : {:s}", pShape->FilePath())); } int iSPC = pShape->PartCount(); for (int j = 0; j < iSPC; j++) { CN3SPart * pPart = pShape->Part(j); if (NULL == pPart) { - vErroredFiles.emplace_back( - std::format(L"NULL Part : {:s} - {:d}th Part", pShape->FilePath().c_str(), j)); + vErroredFiles.emplace_back(std::format("NULL Part : {:s} - {:d}th Part", pShape->FilePath(), j)); continue; } @@ -1092,8 +1091,7 @@ void CMainFrame::OnTipDeleteUnusedFiles() { if (pPMesh) { mBases.emplace(pPMesh->FilePathAbs(), pPMesh); } else { - vErroredFiles.emplace_back( - std::format(L"NULL Part : {:s} - {:d}th Part", pShape->FilePath().c_str(), j)); + vErroredFiles.emplace_back(std::format("NULL Part : {:s} - {:d}th Part", pShape->FilePath(), j)); } int iSTC = pPart->TexCount(); @@ -1102,8 +1100,8 @@ void CMainFrame::OnTipDeleteUnusedFiles() { if (pTex) { mBases.emplace(pTex->FilePathAbs(), pTex); } else { - vErroredFiles.emplace_back(std::format(L"NULL Texture : {:s} - {:d}th Part, {:d}th Texture", - pShape->FilePath().c_str(), j, k)); + vErroredFiles.emplace_back( + std::format("NULL Texture : {:s} - {:d}th Part, {:d}th Texture", pShape->FilePath(), j, k)); continue; } } diff --git a/src/tool/N3ME/DlgUnusedFiles.h b/src/tool/N3ME/DlgUnusedFiles.h index 0b4593a5..120c1040 100644 --- a/src/tool/N3ME/DlgUnusedFiles.h +++ b/src/tool/N3ME/DlgUnusedFiles.h @@ -8,8 +8,8 @@ class CDlgUnusedFiles : public CDialog { public: - std::vector m_vFiles; - std::vector m_vErroredFiles; + std::vector m_vFiles; + std::vector m_vErroredFiles; public: void UpdateAll(); diff --git a/src/tool/N3ME/LyTerrain.cpp b/src/tool/N3ME/LyTerrain.cpp index 7af257b8..03f202d4 100644 --- a/src/tool/N3ME/LyTerrain.cpp +++ b/src/tool/N3ME/LyTerrain.cpp @@ -822,7 +822,7 @@ bool CLyTerrain::SaveToFile(const fs::path & fsFile) { ProgressBar.StepIt(); fs::path fsColorMapFile = fs::path(fsFile).replace_extension(); - fsColorMapFile = std::format("{:s}_{:02}{:02}.dxt", fsColorMapFile.string(), x, z); + fsColorMapFile = std::format("{:s}_{:02}{:02}.dxt", fsColorMapFile, x, z); m_pColorTexture[x][z].SaveToFile(fsColorMapFile); } } diff --git a/src/tool/N3ME/MapMng.cpp b/src/tool/N3ME/MapMng.cpp index 699cdd06..f0ab1591 100644 --- a/src/tool/N3ME/MapMng.cpp +++ b/src/tool/N3ME/MapMng.cpp @@ -2347,7 +2347,7 @@ void CMapMng::ImportShape(const fs::path & fsFile) { void CMapMng::DeleteUnusedFiles() { std::map mBases; std::vector vUnusedFiles; - std::vector vErroredFiles; + std::vector vErroredFiles; int iSC = m_pSceneOutput->ShapeCount(); for (int i = 0; i < iSC; i++) { @@ -2362,15 +2362,14 @@ void CMapMng::DeleteUnusedFiles() { if (pVMesh) { mBases.emplace(pVMesh->FilePathAbs(), pVMesh); } else { - vErroredFiles.emplace_back(std::format(L"NULL VMesh : {:s}", pShape->FilePath().c_str())); + vErroredFiles.emplace_back(std::format("NULL VMesh : {:s}", pShape->FilePath())); } int iSPC = pShape->PartCount(); for (int j = 0; j < iSPC; j++) { CN3SPart * pPart = pShape->Part(j); if (NULL == pPart) { - vErroredFiles.emplace_back( - std::format(L"NULL Part : {:s} - {:d}th Part", pShape->FilePath().c_str(), j)); + vErroredFiles.emplace_back(std::format("NULL Part : {:s} - {:d}th Part", pShape->FilePath(), j)); continue; } @@ -2378,8 +2377,7 @@ void CMapMng::DeleteUnusedFiles() { if (pPMesh) { mBases.emplace(pPMesh->FilePathAbs(), pPMesh); } else { - vErroredFiles.emplace_back( - std::format(L"NULL Part : {:s} - {:d}th Part", pShape->FilePath().c_str(), j)); + vErroredFiles.emplace_back(std::format("NULL Part : {:s} - {:d}th Part", pShape->FilePath(), j)); } int iSTC = pPart->TexCount(); @@ -2388,8 +2386,8 @@ void CMapMng::DeleteUnusedFiles() { if (pTex) { mBases.emplace(pTex->FilePathAbs(), pTex); } else { - vErroredFiles.emplace_back(std::format(L"NULL Texture : {:s} - {:d}th Part, {:d}th Texture", - pShape->FilePath().c_str(), j, k)); + vErroredFiles.emplace_back( + std::format("NULL Texture : {:s} - {:d}th Part, {:d}th Texture", pShape->FilePath(), j, k)); continue; } } diff --git a/src/tool/Widget/PropertyList.cpp b/src/tool/Widget/PropertyList.cpp index 7cc22ae1..9b7cf18b 100644 --- a/src/tool/Widget/PropertyList.cpp +++ b/src/tool/Widget/PropertyList.cpp @@ -400,11 +400,11 @@ void CPropertyList::OnButton() { pItem->m_curValue = ""; size_t iSC = vSelFiles.size(); if (iSC > 0) { - pItem->m_curValue += std::format("{:s}\n", vSelFiles.back().string()).c_str(); + pItem->m_curValue += std::format("{:s}\n", vSelFiles.back()).c_str(); for (size_t i = 1; i < iSC - 1; ++i) { - pItem->m_curValue += std::format("{:s}\n", vSelFiles[i].string()).c_str(); + pItem->m_curValue += std::format("{:s}\n", vSelFiles[i]).c_str(); } - pItem->m_curValue += std::format("{:s}", vSelFiles.front().string()).c_str(); + pItem->m_curValue += std::format("{:s}", vSelFiles.front()).c_str(); m_ButtonPush.ShowWindow(SW_HIDE); Invalidate(); From cf24965cafdc3f066a8e497e3e20ab8440b247e0 Mon Sep 17 00:00:00 2001 From: Steve Williams <90905675+stevewgr@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:35:33 -0500 Subject: [PATCH 9/9] Refactor CLogWriter for portability and optimization. This update improves the `CLogWriter` class by enhancing portability and performance: - Replaced WinAPI's `CreateFile` with `std::fstream` for file operations, ensuring compatibility across platforms. - Updated timestamp generation to use `std::chrono`, improving code clarity and modernizing time handling. - Introduced a `std::mutex` for thread-safe logging to address potential concurrency issues. - Simplified and standardized log messages using `std::format`, improving readability and maintainability. These changes modernize the logging implementation, making it more portable and easier to maintain while adhering to modern C++ standards. --- src/common/StdBase.h | 2 + src/engine/N3Base/LogWriter.cpp | 140 ++++++---------------- src/engine/N3Base/LogWriter.h | 22 ++-- src/engine/N3Base/N3BaseFileAccess.cpp | 6 +- src/engine/N3Base/N3Eng.cpp | 6 +- src/engine/N3Base/N3FXShape.cpp | 2 +- src/engine/N3Base/N3IMesh.cpp | 4 +- src/engine/N3Base/N3Mesh.cpp | 6 +- src/engine/N3Base/N3SndEng.cpp | 6 +- src/engine/N3Base/N3SndObj.cpp | 6 +- src/engine/N3Base/N3TableBase.h | 4 +- src/engine/N3Base/N3Texture.cpp | 19 ++- src/engine/N3Base/N3VMesh.cpp | 2 +- src/game/APISocket.cpp | 4 +- src/game/DungeonManager.cpp | 2 +- src/game/GameProcMain.cpp | 78 +++++------- src/game/GameProcedure.cpp | 16 +-- src/game/MachineMng.cpp | 4 +- src/game/MagicSkillMng.cpp | 8 +- src/game/N3Terrain.cpp | 2 +- src/game/N3TerrainManager.cpp | 29 ++--- src/game/N3WorldManager.cpp | 4 +- src/game/PlayerOther.cpp | 2 +- src/game/UIDroppedItemDlg.cpp | 16 +-- src/game/UIInventory.cpp | 16 +-- src/game/UITransactionDlg.cpp | 4 +- src/game/UIWareHouseDlg.cpp | 2 +- src/server/AIServer/N3BASE/N3ShapeMgr.cpp | 11 +- src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp | 12 +- src/tool/N3CE/DlgChrProperty.cpp | 8 +- 30 files changed, 176 insertions(+), 267 deletions(-) diff --git a/src/common/StdBase.h b/src/common/StdBase.h index 5dee11ad..53244c5d 100644 --- a/src/common/StdBase.h +++ b/src/common/StdBase.h @@ -19,3 +19,5 @@ #include #include +#include +#include diff --git a/src/engine/N3Base/LogWriter.cpp b/src/engine/N3Base/LogWriter.cpp index 7b8f20e1..f8ede96c 100644 --- a/src/engine/N3Base/LogWriter.cpp +++ b/src/engine/N3Base/LogWriter.cpp @@ -1,138 +1,74 @@ -// LogWriter.cpp: implementation of the CLogWriter class. -// -////////////////////////////////////////////////////////////////////// - -#include #include "StdAfx.h" #include "LogWriter.h" -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -//HANDLE CLogWriter::s_hFile = NULL; fs::path CLogWriter::s_fsLogFile; -CLogWriter::CLogWriter() {} - -CLogWriter::~CLogWriter() {} +static std::mutex s_mtxLog; void CLogWriter::Open(const fs::path & fsFile) { - // if (s_hFile || fsFile.empty()) { - // return; - // } if (fsFile.empty()) { return; } - s_fsLogFile = fsFile; + std::lock_guard lock(s_mtxLog); - HANDLE hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { - hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { - return; - } - } + s_fsLogFile = fsFile; - DWORD dwSizeHigh = 0; - DWORD dwSizeLow = ::GetFileSize(hFile, &dwSizeHigh); - if (dwSizeLow > 256000) // 파일 사이즈가 너무 크면 지운다.. - { - CloseHandle(hFile); + // Remove the file if its size exceeds 512 KB + if (fs::exists(s_fsLogFile) && fs::file_size(s_fsLogFile) > 512000) { fs::remove(s_fsLogFile); - hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { - return; - } } - ::SetFilePointer(hFile, 0, NULL, FILE_END); // 추가 하기 위해서 파일의 끝으로 옮기고.. - - char szBuff[1024]; - SYSTEMTIME time; - GetLocalTime(&time); - DWORD dwRWC = 0; - - sprintf(szBuff, "---------------------------------------------------------------------------\r\n"); - int iLength = lstrlen(szBuff); - WriteFile(hFile, szBuff, iLength, &dwRWC, NULL); + std::ofstream ofsFile(s_fsLogFile, std::ios::app | std::ios::binary); + if (!ofsFile) { + return; + } - sprintf(szBuff, "// Begin writing log... [%.2d/%.2d %.2d:%.2d]\r\n", time.wMonth, time.wDay, time.wHour, - time.wMinute); - iLength = lstrlen(szBuff); - WriteFile(hFile, szBuff, iLength, &dwRWC, NULL); + auto tpNow = std::chrono::system_clock::now(); + auto tmLocal = std::chrono::current_zone()->to_local(tpNow); - CloseHandle(hFile); + ofsFile << "---------------------------------------------------------------------------\n"; + ofsFile << std::format("// Begin writing log... [{:%m/%d %H:%M}]\n", tmLocal); } void CLogWriter::Close() { - HANDLE hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { - hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { - hFile = NULL; - } + if (s_fsLogFile.empty()) { + return; } - if (hFile) { - ::SetFilePointer(hFile, 0, NULL, FILE_END); // 추가 하기 위해서 파일의 끝으로 옮기고.. + std::lock_guard lock(s_mtxLog); - char szBuff[1024]; - SYSTEMTIME time; - GetLocalTime(&time); - DWORD dwRWC = 0; + std::ofstream ofsFile(s_fsLogFile, std::ios::app | std::ios::binary); + if (!ofsFile) { + return; + } - sprintf(szBuff, "// End writing log... [%.2d/%.2d %.2d:%.2d]\r\n", time.wMonth, time.wDay, time.wHour, - time.wMinute); - int iLength = lstrlen(szBuff); - WriteFile(hFile, szBuff, iLength, &dwRWC, NULL); + auto tpNow = std::chrono::system_clock::now(); + auto tmLocal = std::chrono::current_zone()->to_local(tpNow); - sprintf(szBuff, "---------------------------------------------------------------------------\r\n"); - iLength = lstrlen(szBuff); - WriteFile(hFile, szBuff, iLength, &dwRWC, NULL); + ofsFile << std::format("// End writing log... [{:%m/%d %H:%M}]\n", tmLocal); + ofsFile << "---------------------------------------------------------------------------\n"; - CloseHandle(hFile); - hFile = NULL; - } + s_fsLogFile.clear(); } -void CLogWriter::Write(const char * lpszFormat, ...) { - if (s_fsLogFile.empty() || NULL == lpszFormat) { +void CLogWriter::WriteImpl(std::string_view szFmt, const std::format_args fmtArgs) { + if (s_fsLogFile.empty() || szFmt.empty()) { return; } - static char szFinal[1024]; - static SYSTEMTIME time; - GetLocalTime(&time); - szFinal[0] = NULL; - - DWORD dwRWC = 0; - sprintf(szFinal, " [%.2d:%.2d:%.2d] ", time.wHour, time.wMinute, time.wSecond); - - static char szBuff[1024]; - szBuff[0] = NULL; - va_list argList; - va_start(argList, lpszFormat); - vsprintf(szBuff, lpszFormat, argList); - va_end(argList); - N3_DEBUG("CLogWriter::Write: {}", szBuff); - - lstrcat(szFinal, szBuff); - lstrcat(szFinal, "\r\n"); - int iLength = lstrlen(szFinal); - - HANDLE hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { - hFile = CreateFileW(s_fsLogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (INVALID_HANDLE_VALUE == hFile) { - hFile = NULL; - } - } + std::lock_guard lock(s_mtxLog); + + std::string szMsg = std::vformat(szFmt, fmtArgs); + N3_DEBUG("CLogWriter::Write: {:s}", szMsg); + + auto tpNow = std::chrono::system_clock::now(); + auto tmLocal = std::chrono::current_zone()->to_local(tpNow); - if (hFile) { - ::SetFilePointer(hFile, 0, NULL, FILE_END); // 추가 하기 위해서 파일의 끝으로 옮기고.. + std::string szLog = std::format(" [{:%H:%M:%S}] ", tmLocal) + szMsg + "\n"; - WriteFile(hFile, szFinal, iLength, &dwRWC, NULL); - CloseHandle(hFile); + std::ofstream ofsFile(s_fsLogFile, std::ios::app | std::ios::binary); + if (ofsFile) { + ofsFile.write(szLog.c_str(), szLog.size()); } } diff --git a/src/engine/N3Base/LogWriter.h b/src/engine/N3Base/LogWriter.h index 67fb49dd..f5c94e8e 100644 --- a/src/engine/N3Base/LogWriter.h +++ b/src/engine/N3Base/LogWriter.h @@ -1,21 +1,17 @@ -// LogWriter.h: interface for the CLogWriter class. -// -////////////////////////////////////////////////////////////////////// - #pragma once -#include - class CLogWriter { - protected: - // static HANDLE s_hFile; - static fs::path s_fsLogFile; - public: static void Open(const fs::path & fsFile); static void Close(); - static void Write(const char * lpszFormat, ...); - CLogWriter(); - virtual ~CLogWriter(); + template static void Write(std::string_view szFmt, T &&... fmtArgs) { + WriteImpl(szFmt, std::make_format_args(fmtArgs...)); + } + + private: + static void WriteImpl(std::string_view szFmt, const std::format_args fmtArgs); + + private: + static fs::path s_fsLogFile; }; diff --git a/src/engine/N3Base/N3BaseFileAccess.cpp b/src/engine/N3Base/N3BaseFileAccess.cpp index ec82eaa8..0850534c 100644 --- a/src/engine/N3Base/N3BaseFileAccess.cpp +++ b/src/engine/N3Base/N3BaseFileAccess.cpp @@ -68,12 +68,12 @@ bool CN3BaseFileAccess::LoadFromFile() { HANDLE hFile = ::CreateFileW(FilePathAbs().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { - std::string szErr = FilePathAbs().string() + " - Can't open file (read)"; + std::string szErr = std::format("{:s} - Can't open file (read)", FilePathAbs()); #ifdef _N3TOOL MessageBox(::GetActiveWindow(), szErr.c_str(), "File Handle error", MB_OK); #endif #ifdef _N3GAME - CLogWriter::Write(szErr.c_str()); + CLogWriter::Write(szErr); #endif return false; } @@ -98,7 +98,7 @@ bool CN3BaseFileAccess::SaveToFile() { HANDLE hFile = ::CreateFileW(FilePathAbs().c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - std::string szErr = FilePathAbs().string() + " - Can't open file(write)"; + std::string szErr = std::format("{:s} - Can't open file(write)", FilePathAbs()); MessageBox(::GetActiveWindow(), szErr.c_str(), "File Handle error", MB_OK); return false; } diff --git a/src/engine/N3Base/N3Eng.cpp b/src/engine/N3Base/N3Eng.cpp index 5b338aaa..efe33a10 100644 --- a/src/engine/N3Base/N3Eng.cpp +++ b/src/engine/N3Base/N3Eng.cpp @@ -205,7 +205,7 @@ bool CN3Eng::Init(BOOL bWindowed, HWND hWnd, DWORD dwWidth, DWORD dwHeight, DWOR errMsg << "]"; MessageBox(hWnd, errMsg.str().c_str(), "Initialization", MB_OK); #ifdef _N3GAME - CLogWriter::Write(errMsg.str().c_str()); + CLogWriter::Write(errMsg.str()); #endif LocalFree(pszDebug); // for (int iii = 0; iii < 3; iii++) { // 여러번 삑~ @@ -403,7 +403,7 @@ void CN3Eng::Present(HWND hWnd, RECT * pRC) { #ifdef _N3GAME // char szErr[256]; // D3DXGetErrorString(rval, szErr, 256); - // CLogWriter::Write("CNEng::Present - device present failed (%s)", szErr); + // CLogWriter::Write("CNEng::Present - device present failed ({:s})", szErr); // Beep(2000, 50); #endif } else { @@ -414,7 +414,7 @@ void CN3Eng::Present(HWND hWnd, RECT * pRC) { #ifdef _N3GAME // char szErr[256]; // D3DXGetErrorString(rval, szErr, 256); - // CLogWriter::Write("CNEng::Present - device present failed (%s)", szErr); + // CLogWriter::Write("CNEng::Present - device present failed ({:s})", szErr); // Beep(2000, 50); #endif } diff --git a/src/engine/N3Base/N3FXShape.cpp b/src/engine/N3Base/N3FXShape.cpp index f61fb502..bf0808af 100644 --- a/src/engine/N3Base/N3FXShape.cpp +++ b/src/engine/N3Base/N3FXShape.cpp @@ -243,7 +243,7 @@ bool CN3FXSPart::Load(HANDLE hFile) { ReadFile(hFile, &iLen, 4, &dwRWC, NULL); // Mesh FileName if (iLen <= 0) { - N3_ERROR("CN3FXShape's n3shape file without n3pmesh ({:s})", FilePath().string()); + N3_ERROR("CN3FXShape's n3shape file without n3pmesh ({:s})", FilePath()); return false; } diff --git a/src/engine/N3Base/N3IMesh.cpp b/src/engine/N3Base/N3IMesh.cpp index 4caad0ca..63f737e2 100644 --- a/src/engine/N3Base/N3IMesh.cpp +++ b/src/engine/N3Base/N3IMesh.cpp @@ -73,7 +73,7 @@ bool CN3IMesh::Create(int nFC, int nVC, int nUVC) { #ifdef _N3GAME if (nFC > 32768) { - CLogWriter::Write("CN3IMesh::Create - Too many faces. (more than 32768) (%s)", FilePath().string().c_str()); + CLogWriter::Write("CN3IMesh::Create - Too many faces. (more than 32768) ({:s})", FilePath()); } #endif @@ -96,7 +96,7 @@ bool CN3IMesh::Create(int nFC, int nVC, int nUVC) { // // if (NULL == m_lpVB) { //#ifdef _N3GAME - // CLogWriter::Write("CN3IMesh::Create - Can't Create VertexBuffer (%s)", FilePath().string().c_str()); + // CLogWriter::Write("CN3IMesh::Create - Can't Create VertexBuffer ({:s})", FilePath()); //#endif // this->Release(); // return false; diff --git a/src/engine/N3Base/N3Mesh.cpp b/src/engine/N3Base/N3Mesh.cpp index d8d43746..b0b1793c 100644 --- a/src/engine/N3Base/N3Mesh.cpp +++ b/src/engine/N3Base/N3Mesh.cpp @@ -146,8 +146,7 @@ void CN3Mesh::Create(int nVC, int nIC) { { #ifdef _N3GAME if (nVC > 32768) { - CLogWriter::Write("CN3IMesh::Create - Too many vertices. (more than 32768) (%s)", - FilePath().string().c_str()); + CLogWriter::Write("CN3IMesh::Create - Too many vertices. (more than 32768) ({:s})", FilePath()); } #endif if (m_pVertices) { @@ -162,8 +161,7 @@ void CN3Mesh::Create(int nVC, int nIC) { { #ifdef _N3GAME if (nIC > 32768) { - CLogWriter::Write("CN3IMesh::Create - Too many indices. (more than 32768) (%s)", - FilePath().string().c_str()); + CLogWriter::Write("CN3IMesh::Create - Too many indices. (more than 32768) ({:s})", FilePath()); } #endif if (m_psnIndices) { diff --git a/src/engine/N3Base/N3SndEng.cpp b/src/engine/N3Base/N3SndEng.cpp index d9ea4ab8..7fc916bb 100644 --- a/src/engine/N3Base/N3SndEng.cpp +++ b/src/engine/N3Base/N3SndEng.cpp @@ -134,7 +134,7 @@ bool CN3SndEng::LoadSource(LPSOUNDSOURCE pSrc) { HRESULT hr = WaveFile.Open(pSrc->fsFile, NULL, 1); //#define WAVEFILE_READ 1 if (FAILED(hr)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndEng::LoadSource - WaveFile Open Failed.. (%)", pSrc->fsFile.string().c_str()); + CLogWriter::Write("CN3SndEng::LoadSource - WaveFile Open Failed.. ({:s})", pSrc->fsFile); #endif return false; } @@ -157,14 +157,14 @@ bool CN3SndEng::LoadSource(LPSOUNDSOURCE pSrc) { hr = m_pDS->CreateSoundBuffer(&dsbd, &(pSrc->pDSBuff), NULL); if (FAILED(hr)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndEng::LoadSource - CreateSoundBuffer Failed.. (%)", pSrc->fsFile.string().c_str()); + CLogWriter::Write("CN3SndEng::LoadSource - CreateSoundBuffer Failed.. ({:s})", pSrc->fsFile); #endif return false; } if (!FillBufferWithSound(pSrc, &WaveFile)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndEng::LoadSource - FillBufferWithSound Failed.. (%)", pSrc->fsFile.string().c_str()); + CLogWriter::Write("CN3SndEng::LoadSource - FillBufferWithSound Failed.. ({:s})", pSrc->fsFile); #endif return false; } diff --git a/src/engine/N3Base/N3SndObj.cpp b/src/engine/N3Base/N3SndObj.cpp index b2e56fd2..831761a5 100644 --- a/src/engine/N3Base/N3SndObj.cpp +++ b/src/engine/N3Base/N3SndObj.cpp @@ -188,7 +188,7 @@ bool CN3SndObj::Create(const fs::path & fsFile, e_SndType eType) { if (FAILED(hr)) { #ifdef _N3GAME if (!fsFile.empty()) { - CLogWriter::Write("CN3SndEng::LoadSource - WaveFile Open Failed.. (%s)", fsFile.string().c_str()); + CLogWriter::Write("CN3SndEng::LoadSource - WaveFile Open Failed.. ({:s})", fsFile); } #endif return false; @@ -212,14 +212,14 @@ bool CN3SndObj::Create(const fs::path & fsFile, e_SndType eType) { hr = s_lpDS->CreateSoundBuffer(&dsbd, &m_lpDSBuff, NULL); if (FAILED(hr)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndObj::Create - CreateSoundBuffer Failed.. (%)", fsFile.string().c_str()); + CLogWriter::Write("CN3SndObj::Create - CreateSoundBuffer Failed.. {:s})", fsFile); #endif return false; } if (!FillBufferWithSound(&WaveFile)) { #ifdef _N3GAME - CLogWriter::Write("CN3SndObj::Create - FillBufferWithSound Failed.. (%)", fsFile.string().c_str()); + CLogWriter::Write("CN3SndObj::Create - FillBufferWithSound Failed.. {:s})", fsFile); #endif return false; } diff --git a/src/engine/N3Base/N3TableBase.h b/src/engine/N3Base/N3TableBase.h index 4aa2b061..e1c57576 100644 --- a/src/engine/N3Base/N3TableBase.h +++ b/src/engine/N3Base/N3TableBase.h @@ -277,7 +277,7 @@ template BOOL CN3TableBase::LoadFromFile(const fs::path & fsF if (INVALID_HANDLE_VALUE == hFile) { #ifdef _N3GAME - CLogWriter::Write("N3TableBase - Can't open file(read) File Handle error (%s)", fsFile.string().c_str()); + CLogWriter::Write("N3TableBase - Can't open file(read) File Handle error ({:s})", fsFile); #endif return FALSE; } @@ -342,7 +342,7 @@ template BOOL CN3TableBase::LoadFromFile(const fs::path & fsF if (FALSE == bResult) { #ifdef _N3GAME - CLogWriter::Write("N3TableBase - incorrect table (%s)", fsFile.string().c_str()); + CLogWriter::Write("N3TableBase - incorrect table ({:s})", fsFile); #endif } diff --git a/src/engine/N3Base/N3Texture.cpp b/src/engine/N3Base/N3Texture.cpp index ccf76ef4..2e229d7c 100644 --- a/src/engine/N3Base/N3Texture.cpp +++ b/src/engine/N3Base/N3Texture.cpp @@ -115,13 +115,13 @@ bool CN3Texture::Create(int nWidth, int nHeight, D3DFORMAT Format, BOOL bGenerat #ifdef _N3GAME if (rval == D3DERR_INVALIDCALL) { - CLogWriter::Write("N3Texture: createtexture err D3DERR_INVALIDCALL(%s)", FilePath().string().c_str()); + CLogWriter::Write("N3Texture: createtexture err D3DERR_INVALIDCALL({:s})", FilePath()); return false; } else if (rval == D3DERR_OUTOFVIDEOMEMORY) { - CLogWriter::Write("N3Texture: createtexture err D3DERR_OUTOFVIDEOMEMORY(%s)", FilePath().string().c_str()); + CLogWriter::Write("N3Texture: createtexture err D3DERR_OUTOFVIDEOMEMORY({:s})", FilePath()); return false; } else if (rval == E_OUTOFMEMORY) { - CLogWriter::Write("N3Texture: createtexture err E_OUTOFMEMORY(%s)", FilePath().string().c_str()); + CLogWriter::Write("N3Texture: createtexture err E_OUTOFMEMORY({:s})", FilePath()); return false; } #endif @@ -187,8 +187,7 @@ bool CN3Texture::LoadFromFile(const fs::path & fsFile) { ::CreateFileW(FilePathAbs().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { #ifdef _N3GAME - CLogWriter::Write("invalid file handle(%d) - Can't open texture file(%s)", (int)hFile, - FilePathAbs().string().c_str()); + CLogWriter::Write("invalid file handle - Can't open texture file({:s})", FilePathAbs()); #endif return false; } @@ -210,7 +209,7 @@ bool CN3Texture::LoadFromFile(const fs::path & fsFile) { bSuccess = true; } else { #ifdef _N3GAME - CLogWriter::Write("N3Texture - Failed to load texture(%s)", FilePathAbs().string().c_str()); + CLogWriter::Write("N3Texture - Failed to load texture({:s})", FilePathAbs()); #endif } @@ -250,7 +249,7 @@ bool CN3Texture::Load(HANDLE hFile) { 3 != HeaderOrg.szID[3]) // "NTF"3 - Noah Texture File Ver. 3.0 { #ifdef _N3GAME - CLogWriter::Write("N3Texture Warning - Old format DXT file (%s)", FilePath().string().c_str()); + CLogWriter::Write("N3Texture Warning - Old format DXT file ({:s})", FilePath()); #endif } @@ -310,7 +309,7 @@ bool CN3Texture::Load(HANDLE hFile) { if (m_lpTexture == NULL) { #ifdef _N3GAME - CLogWriter::Write("N3Texture error - Can't create texture (%s)", FilePath().string().c_str()); + CLogWriter::Write("N3Texture error - Can't create texture ({:s})", FilePath()); #endif return false; } @@ -501,7 +500,7 @@ bool CN3Texture::SkipFileHandle(HANDLE hFile) { 3 != HeaderOrg.szID[3]) // "NTF"3 - Noah Texture File Ver. 3.0 { #ifdef _N3GAME - CLogWriter::Write("N3Texture Warning - Old format DXT file (%s)", FilePath().string().c_str()); + CLogWriter::Write("N3Texture Warning - Old format DXT file ({:s})", FilePath()); #endif } @@ -611,7 +610,7 @@ bool CN3Texture::Save(HANDLE hFile) { } if (nMMC < nMMC2) { #ifdef _N3GAME - CLogWriter::Write("N3Texture save warning - Invalid MipMap Count (%s)", FilePath().string().c_str()); + CLogWriter::Write("N3Texture save warning - Invalid MipMap Count ({:s})", FilePath()); #endif m_Header.bMipMap = FALSE; nMMC = 1; diff --git a/src/engine/N3Base/N3VMesh.cpp b/src/engine/N3Base/N3VMesh.cpp index 8046e018..173c90cd 100644 --- a/src/engine/N3Base/N3VMesh.cpp +++ b/src/engine/N3Base/N3VMesh.cpp @@ -123,7 +123,7 @@ void CN3VMesh::CreateIndex(int nIC) { #ifdef _N3GAME if (nIC > 32768) { - CLogWriter::Write("N3VMesh creation warning (%s) - Too many Indices.", FilePath().string().c_str()); + CLogWriter::Write("N3VMesh creation warning ({:s}) - Too many Indices.", FilePath()); } #endif diff --git a/src/game/APISocket.cpp b/src/game/APISocket.cpp index 780e042e..571f4e97 100644 --- a/src/game/APISocket.cpp +++ b/src/game/APISocket.cpp @@ -305,7 +305,7 @@ void CAPISocket::Receive() { __ASSERT(0, "socket receive error!"); #ifdef _N3GAME int iErr = ::GetLastError(); - CLogWriter::Write("socket receive error! : %d", iErr); + CLogWriter::Write("socket receive error! : {:d}", iErr); TRACE("socket receive error! : %d\n", iErr); #endif break; @@ -402,7 +402,7 @@ void CAPISocket::Send(BYTE * pData, int nSize) { __ASSERT(0, "socket send error!"); #ifdef _N3GAME int iErr = ::GetLastError(); - CLogWriter::Write("socket send error! : %d", iErr); + CLogWriter::Write("socket send error! : {:d}", iErr); TRACE("socket send error! : %d\n", iErr); PostQuitMessage(-1); #endif diff --git a/src/game/DungeonManager.cpp b/src/game/DungeonManager.cpp index 089c7fad..c135d834 100644 --- a/src/game/DungeonManager.cpp +++ b/src/game/DungeonManager.cpp @@ -20,7 +20,7 @@ CDungeonManager::~CDungeonManager() {} void CDungeonManager::InitWorld(int iZoneID, const __Vector3 & vPosPlayer) { __TABLE_ZONE * pZone = s_pTbl_Zones->Find(s_pPlayer->m_InfoExt.iZoneCur); if (NULL == pZone) { - CLogWriter::Write("Null Zone data : %d", iZoneID); + CLogWriter::Write("Null Zone data : {:d}", iZoneID); return; } diff --git a/src/game/GameProcMain.cpp b/src/game/GameProcMain.cpp index 4b71ca67..c0052dcd 100644 --- a/src/game/GameProcMain.cpp +++ b/src/game/GameProcMain.cpp @@ -315,7 +315,7 @@ void CGameProcMain::Init() { } } } else { - N3_ERROR("Directory not found ({:s})", fsDir.string()); + N3_ERROR("Directory not found ({:s})", fsDir); } }; @@ -400,17 +400,14 @@ void CGameProcMain::Tick() { CAPISocket::MP_AddByte(byBuff, iOffset, N3_TEMP_TEST); s_pSocket->Send(byBuff, iOffset); - int iNPC = s_pOPMgr->m_NPCs.size(); - char szBuff[1024]; - sprintf(szBuff, "NPC Region Test : %d", iNPC); - CLogWriter::Write(szBuff); + int iNPC = s_pOPMgr->m_NPCs.size(); + CLogWriter::Write("NPC Region Test : {:d}", iNPC); it_NPC it = s_pOPMgr->m_NPCs.begin(), itEnd = s_pOPMgr->m_NPCs.end(); for (; it != itEnd; it++) { CPlayerNPC * pNPC = it->second; - sprintf(szBuff, " ID(%d) Name(%s) Pos(%.1f, %.1f)", pNPC->IDNumber(), pNPC->IDString().c_str(), - pNPC->m_vPosFromServer.x, pNPC->m_vPosFromServer.z); - CLogWriter::Write(szBuff); + CLogWriter::Write(" ID({:d}) Name({:s}) Pos({:.1f}, {:.1f})", pNPC->IDNumber(), pNPC->IDString(), + pNPC->m_vPosFromServer.x, pNPC->m_vPosFromServer.z); } } #endif @@ -726,16 +723,13 @@ bool CGameProcMain::ProcessPacket(DataPack * pDataPack, int & iOffset) { { #ifdef _DEBUG case N3_TEMP_TEST: { - int iNPC = CAPISocket::Parse_GetShort(pDataPack->m_pData, iOffset); - char szBuff[32]; - sprintf(szBuff, "NPC Region Test : %d -> ", iNPC); - std::string szLog = szBuff; + int iNPC = CAPISocket::Parse_GetShort(pDataPack->m_pData, iOffset); + std::string szLog = std::format("NPC Region Test : {:d} -> ", iNPC); for (int i = 0; i < iNPC; i++) { int iID = CAPISocket::Parse_GetShort(pDataPack->m_pData, iOffset); - sprintf(szBuff, "%d, ", iID); - szLog += szBuff; + szLog += std::format("{:d}, ", iID); } - CLogWriter::Write(szLog.c_str()); + CLogWriter::Write(szLog); } return true; #endif @@ -1697,8 +1691,8 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(s_pPlayer->m_InfoBase.eRace); // User Player Character Skin 구조체 포인터.. if (NULL == pLooks) { - CLogWriter::Write("CGameProcMain::MsgRecv_MyInfo_All : failed find character resource data (Race : %d)", - s_pPlayer->m_InfoBase.eRace); + CLogWriter::Write("CGameProcMain::MsgRecv_MyInfo_All : failed find character resource data (Race : {:d})", + (int)s_pPlayer->m_InfoBase.eRace); } __ASSERT(pLooks, "failed find character resource data"); s_pPlayer->InitChr(pLooks); // 관절 세팅.. @@ -1840,7 +1834,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { if (NULL == pItem || NULL == pItemExt) { N3_WARN("NULL slot Item!!!"); - CLogWriter::Write("MyInfo - slot - Unknown Item %d, IDNumber", iItemIDInSlots[i]); + CLogWriter::Write("MyInfo - slot - Unknown Item {:d}, IDNumber", iItemIDInSlots[i]); continue; // 아이템이 없으면.. } @@ -1929,7 +1923,7 @@ bool CGameProcMain::MsgRecv_MyInfo_All(DataPack * pDataPack, int & iOffset) { } if (NULL == pItem || NULL == pItemExt) { N3_WARN("NULL Inv Item"); - CLogWriter::Write("MyInfo - Inv - Unknown Item %d, IDNumber", iItemIDInInventorys[i]); + CLogWriter::Write("MyInfo - Inv - Unknown Item {:d}, IDNumber", iItemIDInInventorys[i]); continue; // 아이템이 없으면.. } @@ -2413,7 +2407,7 @@ bool CGameProcMain::MsgRecv_UserIn(DataPack * pDataPack, int & iOffset, bool bWi CPlayerOther * pUPC = s_pOPMgr->UPCGetByID(iID, false); if (pUPC) // 이미 아이디 같은 캐릭이 있으면.. { - CLogWriter::Write("User In - Duplicated ID (%d, %s) Pos(%.2f,%.2f,%.2f)", iID, szName.c_str(), fXPos, fYPos, + CLogWriter::Write("User In - Duplicated ID ({:d}, {:s}) Pos({:.2f},{:.2f},{:.2f})", iID, szName, fXPos, fYPos, fZPos); TRACE("User In - Duplicated ID (%d, %s) Pos(%.2f,%.2f,%.2f)\n", iID, szName.c_str(), fXPos, fYPos, fZPos); @@ -2666,7 +2660,7 @@ bool CGameProcMain::MsgRecv_NPCIn(DataPack * pDataPack, int & iOffset) { } //#ifdef _DEBUG - // CLogWriter::Write("NPC In - ID(%d) Name(%s) Time(%.1f)", iID, szName.c_str(), CN3Base::TimeGet()); // 캐릭 세팅.. + // CLogWriter::Write("NPC In - ID({:d}) Name({:s}) Time({:.1f})", iID, szName, CN3Base::TimeGet()); // 캐릭 세팅.. //#endif e_Nation eNation = (e_Nation)CAPISocket::Parse_GetByte(pDataPack->m_pData, iOffset); // 소속 국가. 0 이면 없다. 1 @@ -2693,7 +2687,7 @@ bool CGameProcMain::MsgRecv_NPCIn(DataPack * pDataPack, int & iOffset) { CPlayerNPC * pNPC = s_pOPMgr->NPCGetByID(iID, false); if (pNPC) // 이미 아이디 같은 캐릭이 있으면.. { - CLogWriter::Write("NPC In - Duplicated ID (%d, %s) Pos(%.2f,%.2f,%.2f)", iID, szName.c_str(), fXPos, fYPos, + CLogWriter::Write("NPC In - Duplicated ID ({:d}, {:s}) Pos({:.2f},{:.2f},{:.2f})", iID, szName, fXPos, fYPos, fZPos); TRACE("NPC In - Duplicated ID (%d, %s) Pos(%.2f,%.2f,%.2f)\n", iID, szName.c_str(), fXPos, fYPos, fZPos); pNPC->Action(PSA_BASIC, true, NULL, true); // 강제로 살리고.. @@ -2832,9 +2826,7 @@ bool CGameProcMain::MsgRecv_NPCIn(DataPack * pDataPack, int & iOffset) { } } } else { - char szBuff[256]; - sprintf(szBuff, "No Resource NPC In : [Name(%s), ResourceID(%d)]", szName.c_str(), iIDResrc); - CLogWriter::Write(szBuff); + CLogWriter::Write("No Resource NPC In : [Name({:s}), ResourceID({:d})]", szName, iIDResrc); } pNPC->PositionSet(__Vector3(fXPos, fYPos, fZPos), true); // 현재 위치 셋팅.. @@ -3269,8 +3261,8 @@ bool CGameProcMain::MsgRecv_UserLookChange(DataPack * pDataPack, int & iOffset) __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(pUPC->m_InfoBase.eRace); // User Player Character Skin 구조체 포인터.. if (NULL == pLooks) { - CLogWriter::Write("CGameProcMain::MsgRecv_UserLookChange() - failed find table : Race (%d)", - pUPC->m_InfoBase.eRace); + CLogWriter::Write("CGameProcMain::MsgRecv_UserLookChange() - failed find table : Race ({:d})", + (int)pUPC->m_InfoBase.eRace); __ASSERT(pLooks, "failed find table"); } else { if (PART_POS_HAIR_HELMET == ePartPos) { @@ -3302,7 +3294,8 @@ bool CGameProcMain::MsgRecv_UserLookChange(DataPack * pDataPack, int & iOffset) return true; } else { - CLogWriter::Write("CGameProcMain::MsgRecv_UserLookChange() - Unknown Slot(%d) Item(%d)", eSlot, dwItemID); + CLogWriter::Write("CGameProcMain::MsgRecv_UserLookChange() - Unknown Slot({:d}) Item({:d})", (int)eSlot, + dwItemID); return false; } @@ -3992,7 +3985,7 @@ void CGameProcMain::MsgRecv_TargetHP(DataPack * pDataPack, int & iOffset) { szBuff += pTarget->IDString(); } szBuff += ')'; - CLogWriter::Write(szBuff.c_str()); + CLogWriter::Write(szBuff); } __ASSERT(iTargetHPMax > 0, "최대 체력 수치는 0이상이어야 합니다."); @@ -4190,13 +4183,11 @@ void CGameProcMain::InitZone(int iZone, const __Vector3 & vPosPlayer) { s_pPlayer->m_bMoveContinous = true; // 멈춘다.. this->CommandToggleMoveContinous(); - CLogWriter::Write("CGameProcMain::InitZone -> Zone Change (%d -> %d) Position(%.1f, %.1f, %.1f)", iZonePrev, - iZone, vPosPlayer.x, vPosPlayer.y, vPosPlayer.z); + CLogWriter::Write("CGameProcMain::InitZone -> Zone Change ({:d} -> {:d}) Position({:.1f}, {:.1f}, {:.1f})", + iZonePrev, iZone, vPosPlayer.x, vPosPlayer.y, vPosPlayer.z); - m_bLoadComplete = false; // 로딩 끝남.. - CLogWriter::Write("%d->ClearDurationalMagic()", m_pMagicSkillMng); // TmpLog1122 + m_bLoadComplete = false; // 로딩 끝남.. m_pMagicSkillMng->ClearDurationalMagic(); - CLogWriter::Write("%d->ClearAll()", s_pFX); // TmpLog1122 s_pFX->ClearAll(); if (s_pUILoading) { @@ -4207,25 +4198,18 @@ void CGameProcMain::InitZone(int iZone, const __Vector3 & vPosPlayer) { s_pPlayer->m_InfoExt.iZoneCur = iZone; iZonePrev = iZone; // 최근에 읽은 존 번호를 기억해둔다. - CLogWriter::Write("%d->Find(s_pPlayer->m_InfoExt.iZoneCur)", s_pTbl_Zones); // TmpLog1122 __TABLE_ZONE * pZoneData = s_pTbl_Zones->Find(s_pPlayer->m_InfoExt.iZoneCur); if (NULL == pZoneData) { - CLogWriter::Write("can't find zone data. (zone : %d)", s_pPlayer->m_InfoExt.iZoneCur); + CLogWriter::Write("can't find zone data. (zone : {:d})", s_pPlayer->m_InfoExt.iZoneCur); __ASSERT(0, "Zone Data Not Found!"); return; } - CLogWriter::Write("%d->Release()", s_pOPMgr); // TmpLog1122 - - s_pOPMgr->Release(); // 다른 넘들 다 날린다.. - CLogWriter::Write("%d->InitWorld()", s_pWorldMgr); // TmpLog1122 + s_pOPMgr->Release(); // 다른 넘들 다 날린다.. s_pWorldMgr->InitWorld(iZone, vPosPlayer); // 미니맵 로딩.. - CLogWriter::Write("%d->GetWidthByMeterWithTerrain()", ACT_WORLD); // TmpLog1122 float fWidth = ACT_WORLD->GetWidthByMeterWithTerrain(); - CLogWriter::Write("%d->LoadMiniMap()", m_pUIStateBarAndMiniMap); // TmpLog1122 - CLogWriter::Write("%d->szMiniMapFNszMiniMapFN", pZoneData); // TmpLog1122 m_pUIStateBarAndMiniMap->LoadMiniMap(pZoneData->szMiniMapFile, fWidth, fWidth); CLogWriter::Write("GetRepresentClass()"); // TmpLog1122 @@ -4235,11 +4219,8 @@ void CGameProcMain::InitZone(int iZone, const __Vector3 & vPosPlayer) { if (CLASS_REPRESENT_ROGUE == eCR) { fZoom = 3.0f; // 로그 계열은 맵이 좀더 널리 자세히 보인다.. } - CLogWriter::Write("%d->ZoomSet()", m_pUIStateBarAndMiniMap); // TmpLog1122 m_pUIStateBarAndMiniMap->ZoomSet(fZoom); - CLogWriter::Write("%d->szGtdFile.c_str()", pZoneData); // TmpLog1122 - //fs::path fsBirdListFile = fs::path("Misc") / "bird" / fs::path(pZoneData->szGtdFile).stem() + "_Bird.lst"; m_pLightMgr->LoadZoneLight(pZoneData->szGloFile.c_str()); @@ -4264,11 +4245,10 @@ void CGameProcMain::InitZone(int iZone, const __Vector3 & vPosPlayer) { // 기본적인 캐릭터위치와 카메라 위치 잡기.. //////////////////////////////////////////////////////////////////////////////// - CLogWriter::Write("InitPlayerPosition() Position(%.1f, %.1f, %.1f)", vPosPlayer.x, vPosPlayer.y, + CLogWriter::Write("InitPlayerPosition() Position({:.1f}, {:.1f}, {:.1f})", vPosPlayer.x, vPosPlayer.y, vPosPlayer.z); // TmpLog1122 this->InitPlayerPosition(vPosPlayer); // 플레이어 위치 초기화.. 일으켜 세우고, 기본동작을 취하게 한다. - CLogWriter::Write("%d->Release()2", s_pOPMgr); // TmpLog1122 - s_pOPMgr->Release(); // 다른 플레이어 삭제... + s_pOPMgr->Release(); // 다른 플레이어 삭제... } void CGameProcMain::MsgSend_GameStart() { diff --git a/src/game/GameProcedure.cpp b/src/game/GameProcedure.cpp index 2e63cbe8..815bd0cf 100644 --- a/src/game/GameProcedure.cpp +++ b/src/game/GameProcedure.cpp @@ -379,7 +379,7 @@ void CGameProcedure::Tick() { // 패킷을 처리할 상황이 아니다. int iTempOffst = 0; int iCmd = CAPISocket::Parse_GetByte(pDataPack->m_pData, iTempOffst); - CLogWriter::Write("Invalid Packet... (%d)", iCmd); + CLogWriter::Write("Invalid Packet... ({:d})", iCmd); } delete pDataPack; s_pSocket->PktQueuePop(); // 패킷을 큐에서 꺼냄.. @@ -819,8 +819,8 @@ void CGameProcedure::ReportServerConnectionClosed(bool bNeedQuitGame) { if (s_pPlayer) { __Vector3 vPos = s_pPlayer->Position(); - CLogWriter::Write("Socket Closed... Zone(%d) Pos(%.1f, %.1f, %.1f) Exp(%d)", s_pPlayer->m_InfoExt.iZoneCur, - vPos.x, vPos.y, vPos.z, s_pPlayer->m_InfoExt.iExp); + CLogWriter::Write("Socket Closed... Zone({:d}) Pos({:.1f}, {:.1f}, {:.1f}) Exp({:d})", + s_pPlayer->m_InfoExt.iZoneCur, vPos.x, vPos.y, vPos.z, s_pPlayer->m_InfoExt.iExp); } else { CLogWriter::Write("Socket Closed..."); } @@ -835,7 +835,7 @@ void CGameProcedure::ReportDebugStringAndSendToServer(const std::string & szDebu return; } - CLogWriter::Write(szDebug.c_str()); + CLogWriter::Write(szDebug); if (s_pSocket && s_pSocket->IsConnected()) { int iLen = szDebug.size(); @@ -887,8 +887,8 @@ void CGameProcedure::MsgSend_CharacterSelect() // virtual CAPISocket::MP_AddByte(byBuff, iOffset, s_pPlayer->m_InfoExt.iZoneCur); // 캐릭터 선택창에서의 캐릭터 존 번호 s_pSocket->Send(byBuff, iOffset); // 보낸다 - CLogWriter::Write("MsgSend_CharacterSelect - name(%s) zone(%d)", s_pPlayer->IDString().c_str(), - s_pPlayer->m_InfoExt.iZoneCur); // 디버깅 로그.. + CLogWriter::Write("MsgSend_CharacterSelect - name({:s}) zone({:d})", s_pPlayer->IDString(), + s_pPlayer->m_InfoExt.iZoneCur); } void CGameProcedure::MsgSend_AliveCheck() { @@ -949,12 +949,12 @@ bool CGameProcedure::MsgRecv_CharacterSelect(DataPack * pDataPack, int & iOffset int iZonePrev = s_pPlayer->m_InfoExt.iZoneCur = iZoneCur; s_pPlayer->PositionSet(__Vector3(fX, fY, fZ), true); - CLogWriter::Write("MsgRecv_CharacterSelect - name(%s) zone(%d -> %d)", s_pPlayer->m_InfoBase.szID.c_str(), + CLogWriter::Write("MsgRecv_CharacterSelect - name({:s}) zone({:d} -> {:d})", s_pPlayer->m_InfoBase.szID, iZonePrev, iZoneCur); return true; } else // 실패 { - CLogWriter::Write("MsgRecv_CharacterSelect - failed(%d)", iResult); + CLogWriter::Write("MsgRecv_CharacterSelect - failed({:d})", iResult); return false; } diff --git a/src/game/MachineMng.cpp b/src/game/MachineMng.cpp index deeb7c15..18c7ba8b 100644 --- a/src/game/MachineMng.cpp +++ b/src/game/MachineMng.cpp @@ -129,10 +129,8 @@ void CMachineMng::AddMachine(ReplyMsg & RPMsg) { fs::path fsFile = fs::path("misc") / "machines" / "catapult.mcn"; FILE * stream = _wfopen(fsFile, L"r"); //text파일로 만든다 #if _DEBUG - char szErr[512]; if (NULL == stream) { - wsprintf(szErr, "failed to open file - %s", fsFile.string().c_str()); - __ASSERT(stream, szErr); + __ASSERT(stream, std::format("failed to open file - {:s}", fsFile).c_str()); } #endif diff --git a/src/game/MagicSkillMng.cpp b/src/game/MagicSkillMng.cpp index a5408302..5a614aa0 100644 --- a/src/game/MagicSkillMng.cpp +++ b/src/game/MagicSkillMng.cpp @@ -264,7 +264,7 @@ bool CMagicSkillMng::CheckValidSkillMagic(__TABLE_UPC_SKILL * pSkill) { } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "NULL Item"); - CLogWriter::Write("MyInfo - Inv - Unknown Item %d, IDNumber", pSkill->dwExhaustItem); + CLogWriter::Write("MyInfo - Inv - Unknown Item {:d}, IDNumber", pSkill->dwExhaustItem); return false; // 아이템이 없으면.. } @@ -632,7 +632,7 @@ bool CMagicSkillMng::CheckValidCondition(int iTargetID, __TABLE_UPC_SKILL * pSki } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "NULL Item"); - CLogWriter::Write("MyInfo - Inv - Unknown Item %d, IDNumber", pSkill->dwExhaustItem); + CLogWriter::Write("MyInfo - Inv - Unknown Item {:d}, IDNumber", pSkill->dwExhaustItem); return false; // 아이템이 없으면.. } @@ -1168,7 +1168,7 @@ bool CMagicSkillMng::MsgSend_MagicProcess(int iTargetID, __TABLE_UPC_SKILL * pSk return false; } StartSkillMagicAtTargetPacket(pSkill, (short)pTarget->IDNumber()); - //CLogWriter::Write("send msg : %.4f", CN3Base::TimeGet()); + //CLogWriter::Write("send msg : {:.4f}", CN3Base::TimeGet()); //TRACE("send msg : %.4f\n", CN3Base::TimeGet()); return true; } @@ -1986,7 +1986,7 @@ void CMagicSkillMng::MsgRecv_Casting(DataPack * pDataPack, int & iOffset) { pPlayer->m_fCastFreezeTime = 10.0f; pPlayer->Action(PSA_SPELLMAGIC, false, pTargetPlayer); - //CLogWriter::Write("send casting : %.4f", CN3Base::TimeGet()); + //CLogWriter::Write("send casting : {:.4f}", CN3Base::TimeGet()); //TRACE("recv casting : %.4f\n", CN3Base::TimeGet()); if (pSkill->iTarget == SKILLMAGIC_TARGET_ENEMY_ONLY) { diff --git a/src/game/N3Terrain.cpp b/src/game/N3Terrain.cpp index aad9b05c..be8c8441 100644 --- a/src/game/N3Terrain.cpp +++ b/src/game/N3Terrain.cpp @@ -2019,7 +2019,7 @@ bool CN3Terrain::LoadColorMap(const fs::path & fsFile) { HANDLE hColorMapFile = CreateFileW(fsFile.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hColorMapFile) { - CLogWriter::Write("Failed to load ColorMap - %s", fsFile.string().c_str()); + CLogWriter::Write("Failed to load ColorMap - {:s}", fsFile); return false; } diff --git a/src/game/N3TerrainManager.cpp b/src/game/N3TerrainManager.cpp index 00c9ace0..a44c4d76 100644 --- a/src/game/N3TerrainManager.cpp +++ b/src/game/N3TerrainManager.cpp @@ -60,28 +60,29 @@ CN3TerrainManager::~CN3TerrainManager() { void CN3TerrainManager::InitWorld(int iZoneID, const __Vector3 & vPosPlayer) { __TABLE_ZONE * pZone = s_pTbl_Zones->Find(s_pPlayer->m_InfoExt.iZoneCur); - if (NULL == pZone) { - CLogWriter::Write("Null Zone Data : %d", iZoneID); + if (!pZone) { + CLogWriter::Write("Null Zone Data : {:d}", iZoneID); return; } - CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load\t%d", m_pTerrain); // TmpLog_11_22 - m_pTerrain->LoadFromFile(pZone->szGtdFile); // 지형..로드.. - CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load ColorMap"); // TmpLog_11_22 - m_pTerrain->LoadColorMap(pZone->szTctFile); // 컬러맵 로드.. - CLogWriter::Write("CN3TerrainManager::InitWorld Pre Release Shapes\t%d", m_pShapes); // TmpLog_11_22 + CLogWriter::Write("CN3TerrainManager::InitWorld Load Terrain"); + m_pTerrain->LoadFromFile(pZone->szGtdFile); + + CLogWriter::Write("CN3TerrainManager::InitWorld Load ColorMap"); + m_pTerrain->LoadColorMap(pZone->szTctFile); + + CLogWriter::Write("CN3TerrainManager::InitWorld Release Shapes"); m_pShapes->Release(); - CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load Shapes"); // TmpLog_11_22 - m_pShapes->LoadFromFile(pZone->szOpdFile); // 오브젝트 데이터 로드.. + CLogWriter::Write("CN3TerrainManager::InitWorld Load Shapes"); + m_pShapes->LoadFromFile(pZone->szOpdFile); - CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load Birds\t%d", m_pBirdMng); // TmpLog_11_22 + CLogWriter::Write("CN3TerrainManager::InitWorld Load Birds"); fs::path fsBirdListFile = fs::path("Misc") / "bird" / fs::path(pZone->szGtdFile).stem() + "_Bird.lst"; m_pBirdMng->LoadFromFile(fsBirdListFile); - CLogWriter::Write("CN3TerrainManager::InitWorld Pre Load Sky\t%d", m_pSky); // TmpLog_11_22 - m_pSky->LoadFromFile(pZone->szSkyFile); // 하늘, 구름, 태양, 날씨 변화등 정보 및 텍스처 로딩.. - m_pSky->SunAndMoonDirectionFixByHour( - pZone->iFixedSundDirection); // 해, 달 방향을 고정하든가 혹은 0 이면 고정하지 않는다. + CLogWriter::Write("CN3TerrainManager::InitWorld Load Sky"); + m_pSky->LoadFromFile(pZone->szSkyFile); + m_pSky->SunAndMoonDirectionFixByHour(pZone->iFixedSundDirection); } void CN3TerrainManager::Tick() { diff --git a/src/game/N3WorldManager.cpp b/src/game/N3WorldManager.cpp index 9f30d2c9..fd40e688 100644 --- a/src/game/N3WorldManager.cpp +++ b/src/game/N3WorldManager.cpp @@ -48,12 +48,12 @@ void CN3WorldManager::InitWorld(int iZoneID, const __Vector3 & vPosPlayer) { // Zone 선택.. if (iZoneID != 51) // N3Terrain.. { - CLogWriter::Write("CN3WorldManager::InitWorld Pre new Terrain ZoneID(%d)", iZoneID); // TmpLog_11_22 + CLogWriter::Write("CN3WorldManager::InitWorld Pre new Terrain ZoneID({:d})", iZoneID); // TmpLog_11_22 m_pActiveWorld = new CN3TerrainManager(); m_bIndoor = false; } else { - CLogWriter::Write("CN3WorldManager::InitWorld Pre new Dungeon ZoneID(%d)", iZoneID); // TmpLog_11_22 + CLogWriter::Write("CN3WorldManager::InitWorld Pre new Dungeon ZoneID({:d})", iZoneID); // TmpLog_11_22 m_pActiveWorld = new CDungeonManager(); m_bIndoor = true; diff --git a/src/game/PlayerOther.cpp b/src/game/PlayerOther.cpp index 5be7fd65..4f0ead3e 100644 --- a/src/game/PlayerOther.cpp +++ b/src/game/PlayerOther.cpp @@ -43,7 +43,7 @@ bool CPlayerOther::Init(e_Race eRace, int iFace, int iHair, DWORD * pdwItemIDs, // 이제 패킷에 따라 캐릭터를 치장..(?) 시켜준다.. 아이템장착, 무기 장착등... __TABLE_PLAYER_LOOKS * pLooks = s_pTbl_UPC_Looks->Find(eRace); // 테이블에서 기본 스킨 .. if (NULL == pLooks) { - CLogWriter::Write("CPlayerOther::Init() Basic Resource Pointer is NULL Race(%d)", eRace); + CLogWriter::Write("CPlayerOther::Init() Basic Resource Pointer is NULL Race({:d})", (int)eRace); return false; } this->InitChr(pLooks); // 관절 세팅.. diff --git a/src/game/UIDroppedItemDlg.cpp b/src/game/UIDroppedItemDlg.cpp index f8ee3b7c..4be25be2 100644 --- a/src/game/UIDroppedItemDlg.cpp +++ b/src/game/UIDroppedItemDlg.cpp @@ -214,7 +214,7 @@ void CUIDroppedItemDlg::AddToItemTable(int iItemID, int iItemCount, int iOrder) } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "아이템 포인터 테이블에 없음!!"); - CLogWriter::Write("CUIDroppedItemDlg::AddToItemTable - Invalidate ItemID : %d", iItemID); + CLogWriter::Write("CUIDroppedItemDlg::AddToItemTable - Invalidate ItemID : {:d}", iItemID); return; } @@ -251,7 +251,7 @@ void CUIDroppedItemDlg::AddToItemTableToInventory(int iItemID, int iItemCount, i } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "아이템 포인터 테이블에 없음!!"); - CLogWriter::Write("CUIDroppedItemDlg::AddToItemTableToInventory - Invalidate ItemID : %d", iItemID); + CLogWriter::Write("CUIDroppedItemDlg::AddToItemTableToInventory - Invalidate ItemID : {:d}", iItemID); return; } @@ -399,7 +399,7 @@ bool CUIDroppedItemDlg::ReceiveMessage(CN3UIBase * pSender, DWORD dwMsg) { pItem = CGameBase::s_pTbl_Items_Basic->Find(spItem->pItemBasic->dwID); // 열 데이터 얻기.. if (pItem == NULL) { __ASSERT(0, "NULL Item!!!"); - CLogWriter::Write("CUIDroppedItemDlg::ReceiveMessage - UIMSG_ICON_UP - NULL Icon : %d", + CLogWriter::Write("CUIDroppedItemDlg::ReceiveMessage - UIMSG_ICON_UP - NULL Icon : {:d}", spItem->pItemBasic->dwID); break; } @@ -557,7 +557,7 @@ void CUIDroppedItemDlg::GetItemByIDToInventory(BYTE bResult, int iItemID, int64_ } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "아이템 포인터 테이블에 없음!!"); - CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - NULL Icon : %d", iItemID); + CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - NULL Icon : {:d}", iItemID); return; } @@ -643,13 +643,13 @@ void CUIDroppedItemDlg::GetItemByIDToInventory(BYTE bResult, int iItemID, int64_ { if (iItemID == dwGold) { __ASSERT(0, "Invalidate Item ID From Server.. "); - CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - ID Pos : %d", iPos); + CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - ID Pos : {:d}", iPos); return; } if ((iPos < 0) || (iPos > (MAX_ITEM_INVENTORY - 1))) { __ASSERT(0, "Invalidate Item Pos From Server.. "); - CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - Invalidate Pos : %d", iPos); + CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - Invalidate Pos : {:d}", iPos); return; } @@ -688,7 +688,7 @@ void CUIDroppedItemDlg::GetItemByIDToInventory(BYTE bResult, int iItemID, int64_ pItem = CGameBase::s_pTbl_Items_Basic->Find(iItemID / 1000 * 1000); // 열 데이터 얻기.. if (NULL == pItem) { __ASSERT(0, "아이템 포인터 테이블에 없음!!"); - CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - NULL Icon : %d", iItemID); + CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - NULL Icon : {:d}", iItemID); return; } @@ -722,7 +722,7 @@ void CUIDroppedItemDlg::GetItemByIDToInventory(BYTE bResult, int iItemID, int64_ if (iItemID != dwGold) { if ((iPos < 0) || (iPos > (MAX_ITEM_INVENTORY - 1))) { __ASSERT(0, "Invalidate Item Pos From Server.. "); - CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - Invalidate Pos : %d", iPos); + CLogWriter::Write("CUIDroppedItemDlg::GetItemByIDToInventory - Invalidate Pos : {:d}", iPos); return; } diff --git a/src/game/UIInventory.cpp b/src/game/UIInventory.cpp index c95eccb6..f6b91531 100644 --- a/src/game/UIInventory.cpp +++ b/src/game/UIInventory.cpp @@ -2285,7 +2285,7 @@ void CUIInventory::DurabilityChange(e_ItemSlot eSlot, int iDurability) { if (eSlot < ITEM_SLOT_EAR_RIGHT || eSlot >= ITEM_SLOT_COUNT) { __ASSERT(0, "Durability Change Item Index Weird."); - CLogWriter::Write("Durability Change Item Index Weird. Slot(%d) Durability(%d)", eSlot, iDurability); + CLogWriter::Write("Durability Change Item Index Weird. Slot({:d}) Durability({:d})", (int)eSlot, iDurability); return; } @@ -2300,13 +2300,13 @@ void CUIInventory::DurabilityChange(e_ItemSlot eSlot, int iDurability) { CGameProcedure::s_pProcMain->MsgOutput(szBuf, 0xffff3b3b); } else { __ASSERT(0, "Durability Change Item NULL icon or NULL item."); - CLogWriter::Write("Durability Change Item NULL icon or NULL item. Slot(%d) Durability(%d)", eSlot, - iDurability); + CLogWriter::Write("Durability Change Item NULL icon or NULL item. Slot({:d}) Durability({:d})", + (int)eSlot, iDurability); } } } else { __ASSERT(0, "Durability Change Item NULL Slot."); - CLogWriter::Write("Durability Change Item ... NULL Slot. Slot(%d) Durability(%d)", eSlot, iDurability); + CLogWriter::Write("Durability Change Item ... NULL Slot. Slot({:d}) Durability({:d})", (int)eSlot, iDurability); } } @@ -2358,7 +2358,7 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "NULL Item"); - CLogWriter::Write("MyInfo - Inv - Unknown Item %d, IDNumber", iID); + CLogWriter::Write("MyInfo - Inv - Unknown Item {:d}, IDNumber", iID); return; } @@ -2412,7 +2412,7 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "NULL Item"); - CLogWriter::Write("MyInfo - Inv - Unknown Item %d, IDNumber", iID); + CLogWriter::Write("MyInfo - Inv - Unknown Item {:d}, IDNumber", iID); return; } @@ -2467,7 +2467,7 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "NULL Item"); - CLogWriter::Write("MyInfo - Inv - Unknown Item %d, IDNumber", iID); + CLogWriter::Write("MyInfo - Inv - Unknown Item {:d}, IDNumber", iID); return; } @@ -2521,7 +2521,7 @@ void CUIInventory::ItemCountChange(int iDistrict, int iIndex, int iCount, int iI } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "NULL Item"); - CLogWriter::Write("MyInfo - Inv - Unknown Item %d, IDNumber", iID); + CLogWriter::Write("MyInfo - Inv - Unknown Item {:d}, IDNumber", iID); return; } diff --git a/src/game/UITransactionDlg.cpp b/src/game/UITransactionDlg.cpp index a72807cb..aecc2741 100644 --- a/src/game/UITransactionDlg.cpp +++ b/src/game/UITransactionDlg.cpp @@ -264,7 +264,7 @@ void CUITransactionDlg::EnterTransactionState() { if (NULL == pItem) // 아이템이 없으면.. { __ASSERT(0, "아이템 포인터 테이블에 없음!!"); - CLogWriter::Write("CUITransactionDlg::EnterTransactionState - Invalid Item ID : %d, %d", iOrg, iExt); + CLogWriter::Write("CUITransactionDlg::EnterTransactionState - Invalid Item ID : {:d}, {:d}", iOrg, iExt); continue; } @@ -280,7 +280,7 @@ void CUITransactionDlg::EnterTransactionState() { if (NULL == pItemExt) // 아이템이 없으면.. { __ASSERT(0, "아이템 포인터 테이블에 없음!!"); - CLogWriter::Write("CUITransactionDlg::EnterTransactionState - Invalid Item ID : %d, %d", iOrg, iExt); + CLogWriter::Write("CUITransactionDlg::EnterTransactionState - Invalid Item ID : {:d}, {:d}", iOrg, iExt); continue; } diff --git a/src/game/UIWareHouseDlg.cpp b/src/game/UIWareHouseDlg.cpp index d3883dd4..8239c522 100644 --- a/src/game/UIWareHouseDlg.cpp +++ b/src/game/UIWareHouseDlg.cpp @@ -1687,7 +1687,7 @@ void CUIWareHouseDlg::AddItemInWare(int iItem, int iDurability, int iCount, int } if (NULL == pItem || NULL == pItemExt) { __ASSERT(0, "NULL Item!!!"); - CLogWriter::Write("WareHouse - Ware - Unknown Item %d, IDNumber", iItem); + CLogWriter::Write("WareHouse - Ware - Unknown Item {:d}, IDNumber", iItem); return; // 아이템이 없으면.. } diff --git a/src/server/AIServer/N3BASE/N3ShapeMgr.cpp b/src/server/AIServer/N3BASE/N3ShapeMgr.cpp index 739cf970..86704b8c 100644 --- a/src/server/AIServer/N3BASE/N3ShapeMgr.cpp +++ b/src/server/AIServer/N3BASE/N3ShapeMgr.cpp @@ -338,8 +338,8 @@ void CN3ShapeMgr::GenerateCollisionData() { if (nCPC != (nFC * 3)) { #ifdef _N3GAME - CLogWriter::Write("CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤의 점갯수와 면 갯수가 다릅니다. (%s)", - FilePath().string().c_str()); + CLogWriter::Write("CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤의 점갯수와 면 갯수가 다릅니다. ({:s})", + FilePath()); #endif this->Release(); return; @@ -527,8 +527,8 @@ void CN3ShapeMgr::GenerateCollisionData() { if (nCCPC >= 256) { #ifdef _N3GAME CLogWriter::Write( - "CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤 수가 너무 많습니다. (%s)", - FilePath().string().c_str()); + "CN3ShapeMgr::GenerateCollisionData - Too many collision check polygons. ({:s})", + FilePath()); #endif continue; } @@ -554,8 +554,7 @@ int CN3ShapeMgr::Add(CN3Shape * pShape) { int nZ = (int)(vPos.z / CELL_MAIN_SIZE); if (nX < 0 || nX >= MAX_CELL_MAIN || nZ < 0 || nZ >= MAX_CELL_MAIN) { #ifdef _N3GAME - CLogWriter::Write("CN3ShapeMgr::Add - Shape(%s) Add Failed. Check position", - pShape->FilePath().string().c_str()); + CLogWriter::Write("CN3ShapeMgr::Add - Shape({:s}) Add Failed. Check position", pShape->FilePath()); #endif return -1; } diff --git a/src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp b/src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp index 4772bfed..033b7e7a 100644 --- a/src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp +++ b/src/server/Ebenezer/N3BASE/N3ShapeMgr.cpp @@ -336,8 +336,9 @@ void CN3ShapeMgr::GenerateCollisionData() { if (nCPC != (nFC * 3)) { #ifdef _N3GAME - CLogWriter::Write("CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤의 점갯수와 면 갯수가 다릅니다. (%s)", - FilePath().string().c_str()); + CLogWriter::Write("CN3ShapeMgr::GenerateCollisionData - The number of points and faces of the collision check " + "polygon are different. ({:s})", + FilePath()); #endif this->Release(); return; @@ -525,8 +526,8 @@ void CN3ShapeMgr::GenerateCollisionData() { if (nCCPC >= 256) { #ifdef _N3GAME CLogWriter::Write( - "CN3ShapeMgr::GenerateCollisionData - 충돌 체크 폴리곤 수가 너무 많습니다. (%s)", - FilePath().string().c_str()); + "CN3ShapeMgr::GenerateCollisionData - Too many collision check polygons. ({:s})", + FilePath()); #endif continue; } @@ -552,8 +553,7 @@ int CN3ShapeMgr::Add(CN3Shape * pShape) { int nZ = (int)(vPos.z / CELL_MAIN_SIZE); if (nX < 0 || nX >= MAX_CELL_MAIN || nZ < 0 || nZ >= MAX_CELL_MAIN) { #ifdef _N3GAME - CLogWriter::Write("CN3ShapeMgr::Add - Shape(%s) Add Failed. Check position", - pShape->FilePath().string().c_str()); + CLogWriter::Write("CN3ShapeMgr::Add - Shape({:s}) Add Failed. Check position", pShape->FilePath()); #endif return -1; } diff --git a/src/tool/N3CE/DlgChrProperty.cpp b/src/tool/N3CE/DlgChrProperty.cpp index 1bfe3022..f1136264 100644 --- a/src/tool/N3CE/DlgChrProperty.cpp +++ b/src/tool/N3CE/DlgChrProperty.cpp @@ -176,13 +176,13 @@ void CDlgChrProperty::UpdateInfo() { int nPartCount = pChr->PartCount(); m_CBChrPart.ResetContent(); for (int i = 0; i < nPartCount; i++) { - CString szTmp; + std::string szTmp; if (pChr->Part(i)) { - szTmp.Format("Part(%d) : %s", i, pChr->Part(i)->FilePath().string().c_str()); + szTmp = std::format("Part({:d}) : {:s}", i, pChr->Part(i)->FilePath()); } else { - szTmp.Format("Part(%d) : Null Pointer !!!", i); + szTmp = std::format("Part({:d}) : Null Pointer !!!", i); } - m_CBChrPart.AddString(szTmp); + m_CBChrPart.AddString(szTmp.c_str()); } if (nPart < 0) {