From 27b5672d1546863d26d8dc96babc2671a9838b4e Mon Sep 17 00:00:00 2001 From: CryoTheRenegade Date: Mon, 26 Oct 2026 15:48:32 -0600 Subject: [PATCH 1/2] refactor(ww3d2): Read the Dazzle flare UVs through INIClass instead of a DazzleINIClass cast Init_From_INI cast its INIClass pointer to DazzleINIClass to call Get_Vector4, but ww3d.cpp creates a plain INIClass, so the object never was a DazzleINIClass. Replace the class with a file-static Get_INI_Vector4 that takes the INIClass and has the same body. The unused Get_Vector2 and Get_Vector3 go with the class. Co-Authored-By: Claude Opus 5.5 --- .../Libraries/Source/WWVegas/WW3D2/dazzle.cpp | 45 ++----------------- .../Libraries/Source/WWVegas/WW3D2/dazzle.cpp | 45 ++----------------- 2 files changed, 8 insertions(+), 82 deletions(-) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp index 9f87b70015a..2318bee8eba 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp @@ -284,48 +284,12 @@ static void Init_Shaders() } /* -** Derived INI to support Vector4 +** Reads four comma separated floats from an INI entry */ -class DazzleINIClass : public INIClass { -public: - DazzleINIClass(FileClass & file) : INIClass(file) {} - const Vector2 Get_Vector2(char const *section, char const *entry, const Vector2 & defvalue = Vector2(0,0) ); - const Vector3 Get_Vector3(char const *section, char const *entry, const Vector3 & defvalue = Vector3(0,0,0) ); - const Vector4 Get_Vector4(char const *section, char const *entry, const Vector4 & defvalue = Vector4(0,0,0,0) ) const; -}; - -const Vector2 DazzleINIClass::Get_Vector2(char const *section, char const *entry, const Vector2 & defvalue) +static const Vector4 Get_INI_Vector4(const INIClass & ini, char const *section, char const *entry, const Vector4 & defvalue) { if (section != nullptr && entry != nullptr) { - INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr && entryptr->Value != nullptr) { - Vector2 ret; - if ( sscanf( entryptr->Value, "%f,%f", &ret[0], &ret[1] ) == 2 ) { - return ret; - } - } - } - return defvalue; -} - -const Vector3 DazzleINIClass::Get_Vector3(char const *section, char const * entry, const Vector3 & defvalue ) -{ - if (section != nullptr && entry != nullptr) { - INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr && entryptr->Value != nullptr) { - Vector3 ret; - if ( sscanf( entryptr->Value, "%f,%f,%f", &ret[0], &ret[1], &ret[2] ) == 3 ) { - return ret; - } - } - } - return defvalue; -} - -const Vector4 DazzleINIClass::Get_Vector4(char const *section, char const *entry, const Vector4 & defvalue) const -{ - if (section != nullptr && entry != nullptr) { - INIEntry * entryptr = Find_Entry(section, entry); + INIEntry * entryptr = ini.Find_Entry(section, entry); if (entryptr && entryptr->Value != nullptr) { Vector4 ret; if ( sscanf( entryptr->Value, "%f,%f,%f,%f", &ret[0], &ret[1], &ret[2], &ret[3] ) == 4 ) { @@ -586,9 +550,8 @@ void DazzleRenderObjClass::Init_From_INI(const INIClass* ini) TPoint3D tp=ini->Get_Point(section_name,tmp_name,TPoint3D(1.0f,1.0f,1.0f)); lic.flare_colors[flare]=reinterpret_cast(tp); // Flare uv - const DazzleINIClass* dini=reinterpret_cast(ini); tmp_name.Format("%s%d",FLARE_UV_STRING,flare+1); - lic.flare_uv[flare]=dini->Get_Vector4(section_name,tmp_name,Vector4(0.0f,0.0f,1.0f,1.0f)); + lic.flare_uv[flare]=Get_INI_Vector4(*ini,section_name,tmp_name,Vector4(0.0f,0.0f,1.0f,1.0f)); } lic.type=entry; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp index f6eb30dad35..70f5e9f52b6 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp @@ -286,48 +286,12 @@ static void Init_Shaders() } /* -** Derived INI to support Vector4 +** Reads four comma separated floats from an INI entry */ -class DazzleINIClass : public INIClass { -public: - DazzleINIClass(FileClass & file) : INIClass(file) {} - const Vector2 Get_Vector2(char const *section, char const *entry, const Vector2 & defvalue = Vector2(0,0) ); - const Vector3 Get_Vector3(char const *section, char const *entry, const Vector3 & defvalue = Vector3(0,0,0) ); - const Vector4 Get_Vector4(char const *section, char const *entry, const Vector4 & defvalue = Vector4(0,0,0,0) ) const; -}; - -const Vector2 DazzleINIClass::Get_Vector2(char const *section, char const *entry, const Vector2 & defvalue) +static const Vector4 Get_INI_Vector4(const INIClass & ini, char const *section, char const *entry, const Vector4 & defvalue) { if (section != nullptr && entry != nullptr) { - INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr && entryptr->Value != nullptr) { - Vector2 ret; - if ( sscanf( entryptr->Value, "%f,%f", &ret[0], &ret[1] ) == 2 ) { - return ret; - } - } - } - return defvalue; -} - -const Vector3 DazzleINIClass::Get_Vector3(char const *section, char const * entry, const Vector3 & defvalue ) -{ - if (section != nullptr && entry != nullptr) { - INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr && entryptr->Value != nullptr) { - Vector3 ret; - if ( sscanf( entryptr->Value, "%f,%f,%f", &ret[0], &ret[1], &ret[2] ) == 3 ) { - return ret; - } - } - } - return defvalue; -} - -const Vector4 DazzleINIClass::Get_Vector4(char const *section, char const *entry, const Vector4 & defvalue) const -{ - if (section != nullptr && entry != nullptr) { - INIEntry * entryptr = Find_Entry(section, entry); + INIEntry * entryptr = ini.Find_Entry(section, entry); if (entryptr && entryptr->Value != nullptr) { Vector4 ret; if ( sscanf( entryptr->Value, "%f,%f,%f,%f", &ret[0], &ret[1], &ret[2], &ret[3] ) == 4 ) { @@ -604,9 +568,8 @@ void DazzleRenderObjClass::Init_From_INI(const INIClass* ini) TPoint3D tp=ini->Get_Point(section_name,tmp_name,TPoint3D(1.0f,1.0f,1.0f)); lic.flare_colors[flare]=reinterpret_cast(tp); // Flare uv - const DazzleINIClass* dini=reinterpret_cast(ini); tmp_name.Format("%s%d",FLARE_UV_STRING,flare+1); - lic.flare_uv[flare]=dini->Get_Vector4(section_name,tmp_name,Vector4(0.0f,0.0f,1.0f,1.0f)); + lic.flare_uv[flare]=Get_INI_Vector4(*ini,section_name,tmp_name,Vector4(0.0f,0.0f,1.0f,1.0f)); } lic.type=entry; From cd3410fa6f92f72e9add907a9b68e15c96cd77a8 Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Thu, 5 Nov 2026 10:03:48 -0700 Subject: [PATCH 2/2] style(ww3d2): Attach pointer and reference symbols to the type in Get_INI_Vector4 Co-Authored-By: Claude Opus 5.5 --- Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp | 2 +- GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp index 2318bee8eba..d7cc1d948f0 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp @@ -286,7 +286,7 @@ static void Init_Shaders() /* ** Reads four comma separated floats from an INI entry */ -static const Vector4 Get_INI_Vector4(const INIClass & ini, char const *section, char const *entry, const Vector4 & defvalue) +static Vector4 Get_INI_Vector4(const INIClass& ini, const char* section, const char* entry, const Vector4& defvalue) { if (section != nullptr && entry != nullptr) { INIEntry * entryptr = ini.Find_Entry(section, entry); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp index 70f5e9f52b6..218c45290f2 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp @@ -288,7 +288,7 @@ static void Init_Shaders() /* ** Reads four comma separated floats from an INI entry */ -static const Vector4 Get_INI_Vector4(const INIClass & ini, char const *section, char const *entry, const Vector4 & defvalue) +static Vector4 Get_INI_Vector4(const INIClass& ini, const char* section, const char* entry, const Vector4& defvalue) { if (section != nullptr && entry != nullptr) { INIEntry * entryptr = ini.Find_Entry(section, entry);