diff --git a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp index de401b52..5966e867 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXEnumerate.cpp @@ -66,12 +66,12 @@ HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devR int i; for( i = 0; i < GetNumDrivers(); i++ ) { - if( !stricmp(GetDriver(i)->fAdapterInfo.Description, devRec->GetDriverDesc()) ) + if (devRec->GetDriverDesc().CompareI(GetDriver(i)->fAdapterInfo.Description) == 0) { int j; for( j = 0; j < GetDriver(i)->fDevices.GetCount(); j++ ) { - if( !stricmp(GetDriver(i)->fDevices[j].fStrName, devRec->GetDeviceDesc()) ) + if (devRec->GetDeviceDesc().CompareI(GetDriver(i)->fDevices[j].fStrName) == 0) { SetCurrentDriver(GetDriver(i)); SetCurrentDevice(&GetDriver(i)->fDevices[j]); @@ -87,11 +87,11 @@ HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devR char errStr[256]; sprintf(errStr, "Can't find requested device - %s:%s:%s:%s:%s", - devRec->GetG3DDeviceTypeName(), - devRec->GetDriverDesc(), - devRec->GetDriverName(), - devRec->GetDriverVersion(), - devRec->GetDeviceDesc()); + devRec->GetG3DDeviceTypeName(), + devRec->GetDriverDesc().c_str(), + devRec->GetDriverName().c_str(), + devRec->GetDriverVersion().c_str(), + devRec->GetDeviceDesc().c_str()); DWORD enumFlags = 0; int width = devMode->GetWidth(); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.cpp b/Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.cpp index c896b3df..2c8495a2 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.cpp @@ -97,7 +97,6 @@ void hsG3DDeviceMode::Clear() hsG3DDeviceRecord::hsG3DDeviceRecord() : fFlags(kNone), fG3DDeviceType(hsG3DDeviceSelector::kDevTypeUnknown), - fG3DDriverDesc(nil), fG3DDriverName(nil), fG3DDriverVersion(nil), fG3DDeviceDesc(nil), fLayersAtOnce(0), fMemoryBytes(0), fG3DHALorHEL(hsG3DDeviceSelector::kHHTypeUnknown), fZBiasRating( 0 ), fLODBiasRating( 0 ), @@ -115,7 +114,6 @@ hsG3DDeviceRecord::~hsG3DDeviceRecord() hsG3DDeviceRecord::hsG3DDeviceRecord(const hsG3DDeviceRecord& src) : fFlags(kNone), fG3DDeviceType(hsG3DDeviceSelector::kDevTypeUnknown), - fG3DDriverDesc(nil), fG3DDriverName(nil), fG3DDriverVersion(nil), fG3DDeviceDesc(nil), fG3DHALorHEL(hsG3DDeviceSelector::kHHTypeUnknown), fZBiasRating( src.fZBiasRating ), fLODBiasRating( 0 ), fFogExpApproxStart( src.fFogExpApproxStart ), fFogExp2ApproxStart( src.fFogExp2ApproxStart ), @@ -162,30 +160,6 @@ hsG3DDeviceRecord& hsG3DDeviceRecord::operator=(const hsG3DDeviceRecord& src) return *this; } -void hsG3DDeviceRecord::SetDriverDesc( const char *s ) -{ - delete [] fG3DDriverDesc; - fG3DDriverDesc = s ? hsStrcpy(s) : nil; -} - -void hsG3DDeviceRecord::SetDriverName( const char *s ) -{ - delete [] fG3DDriverName; - fG3DDriverName = s ? hsStrcpy(s) : nil; -} - -void hsG3DDeviceRecord::SetDriverVersion( const char *s ) -{ - delete [] fG3DDriverVersion; - fG3DDriverVersion = s ? hsStrcpy(s) : nil; -} - -void hsG3DDeviceRecord::SetDeviceDesc( const char *s ) -{ - delete [] fG3DDeviceDesc; - fG3DDeviceDesc = s ? hsStrcpy(s) : nil; -} - const char* hsG3DDeviceRecord::GetG3DDeviceTypeName() const { static const char* deviceNames[hsG3DDeviceSelector::kNumDevTypes] = { @@ -230,17 +204,10 @@ void hsG3DDeviceRecord::Clear() { fFlags = kNone; - delete [] fG3DDriverDesc; - fG3DDriverDesc = nil; - - delete [] fG3DDriverName; - fG3DDriverName = nil; - - delete [] fG3DDriverVersion; - fG3DDriverVersion = nil; - - delete [] fG3DDeviceDesc; - fG3DDeviceDesc = nil; + fG3DDriverDesc = plString::Null; + fG3DDriverName = plString::Null; + fG3DDriverVersion = plString::Null; + fG3DDeviceDesc = plString::Null; fCaps.Clear(); fLayersAtOnce = 0; @@ -268,14 +235,6 @@ hsG3DDeviceModeRecord::hsG3DDeviceModeRecord(const hsG3DDeviceRecord& devRec, co { } -hsG3DDeviceModeRecord::hsG3DDeviceModeRecord() -{ -} - -hsG3DDeviceModeRecord::~hsG3DDeviceModeRecord() -{ -} - hsG3DDeviceModeRecord::hsG3DDeviceModeRecord(const hsG3DDeviceModeRecord& src) { *this = src; @@ -291,10 +250,6 @@ hsG3DDeviceModeRecord& hsG3DDeviceModeRecord::operator=(const hsG3DDeviceModeRec /////////////////////////////////////////////////// /////////////////////////////////////////////////// -hsG3DDeviceSelector::hsG3DDeviceSelector() -{ -} - hsG3DDeviceSelector::~hsG3DDeviceSelector() { IClear(); @@ -629,7 +584,6 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record, D3DEnum_DriverInfo *driverInfo, D3DEnum_DeviceInfo *deviceInfo ) { - char desc[ 512 ]; // Can't rely on D3D constant, since that's in another file now uint32_t vendorID, deviceID; char *szDriver, *szDesc; @@ -649,21 +603,18 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record, } /// So capitalization won't matter in our tests - hsAssert( strlen( szDesc ) < sizeof( desc ), "D3D device description longer than expected!" ); - hsStrcpy( desc, szDesc ); - hsStrLower( desc ); + plString desc = plString::FromIso8859_1(szDesc).ToLower(); /// Detect ATI Radeon chipset // We will probably need to differentiate between different Radeons at some point in // the future, but not now. - if (stricmp(szDriver, "ati2dvag.dll") == 0 || strstr(desc, "radeon") != nullptr) + ssize_t radeon = desc.Find("radeon"); + if (stricmp(szDriver, "ati2dvag.dll") == 0 || radeon >= 0) { int series = 0; - const char* str = strstr(desc, "radeon"); - if( str ) - str += strlen("radeon"); - if( str ) + if (radeon >= 0) { + const char* str = desc.c_str() + radeon + strlen("radeon"); if( 1 == sscanf(str, "%d", &series) ) { if( (series >= 8000) && (series < 9000) ) @@ -693,13 +644,13 @@ void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record, /// Detect Intel i810 chipset else if( deviceID == 0x00007125 && ( stricmp( szDriver, "i81xdd.dll" ) == 0 - || ( strstr( desc, "intel" ) != nil && strstr( desc, "810" ) != nil ) ) ) + || ( desc.Find("intel") >= 0 && desc.Find("810") >= 0 ) ) ) { hsStatusMessage( "== Using fudge factors for an Intel i810 chipset ==\n" ); ISetFudgeFactors( kIntelI810Chipset, record ); } /// Detect for a GeForc FX card. We only need to nerf the really low end one. - else if( strstr( desc, "nvidia" ) != nil && strstr( desc, "geforce fx 5200" ) != nil ) + else if( desc.Find("nvidia") >= 0 && desc.Find("geforce fx 5200") >= 0 ) { hsStatusMessage( "== Using fudge factors for an NVidia GeForceFX-based chipset ==\n" ); ISetFudgeFactors( kNVidiaGeForceFXChipset, record ); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.h b/Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.h index 1ae4602a..36d07edc 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.h @@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsTemplates.h" #include "hsBitVector.h" +#include "plString.h" #ifdef HS_BUILD_FOR_WIN32 #define HS_SELECT_DIRECT3D // not supported on the Mac. @@ -143,20 +144,20 @@ public: protected: - uint32_t fFlags; + uint32_t fFlags; - uint32_t fG3DDeviceType; - uint32_t fG3DHALorHEL; + uint32_t fG3DDeviceType; + uint32_t fG3DHALorHEL; - char* fG3DDriverDesc; - char* fG3DDriverName; - char* fG3DDriverVersion; - char* fG3DDeviceDesc; + plString fG3DDriverDesc; + plString fG3DDriverName; + plString fG3DDriverVersion; + plString fG3DDeviceDesc; - hsBitVector fCaps; - uint32_t fLayersAtOnce; - uint32_t fMemoryBytes; + hsBitVector fCaps; + uint32_t fLayersAtOnce; + uint32_t fMemoryBytes; hsTArray fModes; @@ -188,19 +189,19 @@ public: uint32_t GetMemoryBytes() const { return fMemoryBytes; } - const char* GetDriverDesc() const { return fG3DDriverDesc; } - const char* GetDriverName() const { return fG3DDriverName; } - const char* GetDriverVersion() const { return fG3DDriverVersion; } - const char* GetDeviceDesc() const { return fG3DDeviceDesc; } + plString GetDriverDesc() const { return fG3DDriverDesc; } + plString GetDriverName() const { return fG3DDriverName; } + plString GetDriverVersion() const { return fG3DDriverVersion; } + plString GetDeviceDesc() const { return fG3DDeviceDesc; } void SetG3DDeviceType(uint32_t t) { fG3DDeviceType = t; } void SetG3DHALorHEL(uint32_t h) { fG3DHALorHEL = h; } void SetMemoryBytes(uint32_t b) { fMemoryBytes = b; } - void SetDriverDesc(const char* s); - void SetDriverName(const char* s); - void SetDriverVersion(const char* s); - void SetDeviceDesc(const char* s); + void SetDriverDesc(const plString& s) { fG3DDriverDesc = s; } + void SetDriverName(const plString& s) { fG3DDriverName = s; } + void SetDriverVersion(const plString& s) { fG3DDriverVersion = s; } + void SetDeviceDesc(const plString& s) { fG3DDeviceDesc = s; } bool GetCap(uint32_t cap) const { return fCaps.IsBitSet(cap); } void SetCap(uint32_t cap, bool on=true) { fCaps.SetBit(cap, on); } @@ -252,9 +253,8 @@ protected: hsG3DDeviceRecord fDevice; hsG3DDeviceMode fMode; public: - hsG3DDeviceModeRecord(); + hsG3DDeviceModeRecord() { } hsG3DDeviceModeRecord(const hsG3DDeviceRecord& devRec, const hsG3DDeviceMode& devMode); - ~hsG3DDeviceModeRecord(); hsG3DDeviceModeRecord(const hsG3DDeviceModeRecord& src); hsG3DDeviceModeRecord& operator=(const hsG3DDeviceModeRecord& src); @@ -343,7 +343,7 @@ protected: void ISetFudgeFactors( uint8_t chipsetID, hsG3DDeviceRecord &record ); public: - hsG3DDeviceSelector(); + hsG3DDeviceSelector() { } virtual ~hsG3DDeviceSelector(); void RemoveUnusableDevModes(bool bTough); // Removes modes and devices not allowed supported in release