diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index 00be59b2..4576ebd2 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -24,6 +24,7 @@ #include "stream/stringstream.h" #include "convert.h" +#include "os/path.h" #include "qerplugin.h" @@ -51,7 +52,6 @@ bool DoLoadPortalFileDialog(){ auto vbox = new QVBoxLayout( &dialog ); { vbox->addWidget( line = new QLineEdit ); - line->setMaxLength( std::size( portals.fn ) - 1 ); auto button = line->addAction( QApplication::style()->standardIcon( QStyle::SP_FileDialogStart ), QLineEdit::ActionPosition::TrailingPosition ); QObject::connect( button, &QAction::triggered, [line](){ if ( const char* filename = GlobalRadiant().m_pfnFileDialog( g_pRadiantWnd, true, "Locate portal (.prt) file", line->text().toLatin1().constData(), 0, true, false, false ) ) @@ -71,18 +71,14 @@ bool DoLoadPortalFileDialog(){ } - strcpy( portals.fn, GlobalRadiant().getMapName() ); - char* fn = strrchr( portals.fn, '.' ); - if ( fn != NULL ) { - strcpy( fn, ".prt" ); - } + portals.fn = StringOutputStream( 256 )( PathExtensionless( GlobalRadiant().getMapName() ), ".prt" ); - line->setText( portals.fn ); + line->setText( portals.fn.c_str() ); check3d->setChecked( portals.show_3d ); check2d->setChecked( portals.show_2d ); if ( dialog.exec() ) { - strcpy( portals.fn, line->text().toLatin1().constData() ); + portals.fn = line->text().toLatin1().constData(); portals.Purge(); diff --git a/contrib/prtview/portals.cpp b/contrib/prtview/portals.cpp index 7a5e41ab..0ae278bc 100644 --- a/contrib/prtview/portals.cpp +++ b/contrib/prtview/portals.cpp @@ -135,7 +135,7 @@ void CPortals::Load(){ FILE *in; - in = fopen( fn, "rt" ); + in = fopen( fn.c_str(), "rt" ); if ( in == NULL ) { globalErrorStream() << " ERROR - could not open file.\n"; diff --git a/contrib/prtview/portals.h b/contrib/prtview/portals.h index 6770f8ae..43293a7b 100644 --- a/contrib/prtview/portals.h +++ b/contrib/prtview/portals.h @@ -22,6 +22,7 @@ #include "irender.h" #include "renderable.h" #include "math/vector.h" +#include "string/string.h" #include @@ -45,12 +46,6 @@ public: bool Build( char *def ); }; -#ifdef PATH_MAX -#define PRTVIEW_PATH_MAX PATH_MAX -#else -#define PRTVIEW_PATH_MAX 260 -#endif - using PackedColour = std::uint32_t; #define RGB_PACK( r, g, b ) ( (std::uint32_t)( ( (std::uint8_t)( r ) | ( (std::uint16_t)( (std::uint8_t)( g ) ) << 8 ) ) | ( ( (std::uint32_t)(std::uint8_t)( b ) ) << 16 ) ) ) #define RGB_UNPACK_R( rgb ) ( (std::uint8_t)( rgb ) ) @@ -75,7 +70,7 @@ public: void FixColors(); - char fn[PRTVIEW_PATH_MAX]; + CopiedString fn; int zbuffer; bool polygons;