replace class Str uses, replace std::list<DEPair*>

This commit is contained in:
Garux
2024-12-11 09:20:27 +05:00
parent dbe6089cdc
commit e251587788
24 changed files with 67 additions and 152 deletions
+3 -6
View File
@@ -25,11 +25,8 @@
//#include "misc.h"
#include "funchandlers.h"
#include <list>
#include "iglrender.h"
#include "qerplugin.h"
#include "str.h"
#include "math/matrix.h"
#include "DEntity.h"
@@ -202,9 +199,9 @@ void DBobView_setEntity( Entity& entity, float multiplier, int points, float var
DEntity trigger;
trigger.LoadEPairList( &entity );
if ( !strcmp( trigger.m_Classname, "trigger_push" ) ) {
if ( trigger.m_Classname == "trigger_push" ) {
if ( DEPair* trigger_ep = trigger.FindEPairByKey( "target" ) ) {
const scene::Path* entTarget = FindEntityFromTargetname( trigger_ep->value );
const scene::Path* entTarget = FindEntityFromTargetname( trigger_ep->value.c_str() );
if ( entTarget ) {
g_PathView.reset(); // delete old at first
g_PathView.reset( new DBobView );
@@ -215,7 +212,7 @@ void DBobView_setEntity( Entity& entity, float multiplier, int points, float var
g_PathView->target = target;
target->attach( *g_PathView );
}
g_PathView->Begin( trigger_ep->value, multiplier, points, varGravity, bShowExtra );
g_PathView->Begin( trigger_ep->value.c_str(), multiplier, points, varGravity, bShowExtra );
}
else{
globalErrorStream() << "bobToolz PathPlotter: trigger_push ARGH\n";
+5 -15
View File
@@ -24,7 +24,6 @@
#include "DBrush.h"
#include <list>
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
@@ -619,22 +618,13 @@ bool DBrush::BBoxTouch( DBrush *chkBrush ){
return true;
}
void DBrush::ResetChecks( std::list<Str>* exclusionList ){
void DBrush::ResetChecks( const std::vector<CopiedString>& exclusionList ){
for ( DPlane *plane : faceList )
{
bool set = false;
if ( exclusionList ) {
for ( const Str& texture : *exclusionList )
{
if ( strstr( plane->m_shader.c_str(), texture.GetBuffer() ) ) {
set = true;
break;
}
}
}
plane->m_bChkOk = set;
plane->m_bChkOk = std::any_of( exclusionList.cbegin(), exclusionList.cend(),
[plane]( const CopiedString& texture ){
return strstr( plane->m_shader.c_str(), texture.c_str() ) != nullptr;
} );
}
}
+3 -2
View File
@@ -25,8 +25,9 @@
#include <cstdio>
#include <list>
#include <vector>
#include "mathlib.h"
#include "str.h"
#include "string/string.h"
class DPlane;
class DWinding;
@@ -73,7 +74,7 @@ public:
scene::Node* BuildInRadiant( bool allowDestruction, int* changeCnt, scene::Node* entity = NULL );
void selectInRadiant() const;
void ResetChecks( std::list<Str>* exclusionList );
void ResetChecks( const std::vector<CopiedString>& exclusionList );
void ClearFaces();
void ClearPoints();
-13
View File
@@ -27,19 +27,6 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DEPair::DEPair(){
}
DEPair::~DEPair(){
}
//////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////
void DEPair::Build( const char *pKey, const char *pValue ){
key = pKey;
value = pValue;
}
+6 -12
View File
@@ -23,18 +23,12 @@
#pragma once
#include "str.h"
#include "string/string.h"
class DEPair
struct DEPair
{
public:
DEPair();
virtual ~DEPair();
void Build( const char* pKey, const char* pValue );
Str key;
Str value;
DEPair( const char* pKey, const char* pValue ) : key( pKey ), value( pValue ){
}
CopiedString key;
CopiedString value;
};
//typedef CList<DEPair*, DEPair*> DEPairList;
+21 -34
View File
@@ -23,9 +23,7 @@
#include "DEntity.h"
#include <list>
#include <utility>
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
@@ -43,9 +41,6 @@
#include "generic/referencecounted.h"
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include "scenelib.h"
@@ -348,9 +343,9 @@ bool DEntity::LoadFromEntity( scene::Node& ent, const LoadOptions options ) {
return true;
}
void DEntity::RemoveNonCheckBrushes( std::list<Str>* exclusionList ){
void DEntity::RemoveNonCheckBrushes( const std::vector<CopiedString>& exclusionList ){
brushList.erase( std::remove_if( brushList.begin(), brushList.end(), [&]( DBrush *brush ){
if ( std::any_of( exclusionList->cbegin(), exclusionList->cend(), [brush]( const Str& tex ){ return brush->HasTexture( tex.GetBuffer() ); } ) ) {
if ( std::any_of( exclusionList.cbegin(), exclusionList.cend(), [brush]( const CopiedString& tex ){ return brush->HasTexture( tex.c_str() ); } ) ) {
delete brush;
return true;
}
@@ -358,7 +353,7 @@ void DEntity::RemoveNonCheckBrushes( std::list<Str>* exclusionList ){
} ), brushList.end() );
}
void DEntity::ResetChecks( std::list<Str>* exclusionList ){
void DEntity::ResetChecks( const std::vector<CopiedString>& exclusionList ){
for ( DBrush *brush : brushList )
{
brush->ResetChecks( exclusionList );
@@ -377,14 +372,14 @@ int DEntity::FixBrushes(){
}
void DEntity::BuildInRadiant( bool allowDestruction ){
bool makeEntity = strcmp( m_Classname, "worldspawn" ) ? true : false;
const bool makeEntity = m_Classname != "worldspawn";
if ( makeEntity ) {
NodeSmartReference node( GlobalEntityCreator().createEntity( GlobalEntityClassManager().findOrInsert( m_Classname.GetBuffer(), !brushList.empty() || !patchList.empty() ) ) );
NodeSmartReference node( GlobalEntityCreator().createEntity( GlobalEntityClassManager().findOrInsert( m_Classname.c_str(), !brushList.empty() || !patchList.empty() ) ) );
for ( const DEPair *epair : epairList )
for ( const DEPair& epair : epairList )
{
Node_getEntity( node )->setKeyValue( epair->key, epair->value );
Node_getEntity( node )->setKeyValue( epair.key.c_str(), epair.value.c_str() );
}
Node_getTraversable( GlobalSceneGraph().root() )->insert( node );
@@ -416,11 +411,11 @@ void DEntity::SetClassname( const char *classname ) {
void DEntity::SaveToFile( FILE *pFile ){
fprintf( pFile, "{\n" );
fprintf( pFile, "\"classname\" \"%s\"\n", (const char *)m_Classname );
fprintf( pFile, "\"classname\" \"%s\"\n", m_Classname.c_str() );
for ( const DEPair *ep : epairList )
for ( const DEPair& ep : epairList )
{
fprintf( pFile, "\"%s\" \"%s\"\n", (const char *)ep->key, (const char *)ep->value );
fprintf( pFile, "\"%s\" \"%s\"\n", ep.key.c_str(), ep.value.c_str() );
}
for ( DBrush *brush : brushList )
@@ -432,23 +427,15 @@ void DEntity::SaveToFile( FILE *pFile ){
}
void DEntity::ClearEPairs(){
for ( DEPair *epair : epairList )
{
delete epair;
}
epairList.clear();
}
void DEntity::AddEPair( const char *key, const char *value ) {
DEPair* newEPair;
newEPair = FindEPairByKey( key );
if ( !newEPair ) {
newEPair = new DEPair;
newEPair->Build( key, value );
epairList.push_back( newEPair );
if ( DEPair* pair = FindEPairByKey( key ) ) {
*pair = DEPair( key, value );
}
else {
newEPair->Build( key, value );
epairList.push_back( DEPair( key, value ) );
}
}
@@ -508,13 +495,13 @@ bool DEntity::ResetTextures( const char* textureName, float fScale[2], float
}
DEPair* DEntity::FindEPairByKey( const char* keyname ){
for ( DEPair *ep : epairList )
for ( DEPair& ep : epairList )
{
if ( !strcmp( ep->key, keyname ) ) {
return ep;
if ( ep.key == keyname ) {
return &ep;
}
}
return NULL;
return nullptr;
}
void DEntity::RemoveFromRadiant(){
@@ -526,7 +513,7 @@ void DEntity::RemoveFromRadiant(){
void DEntity::SpawnString( const char* key, const char* defaultstring, const char** out ){
DEPair* pEP = FindEPairByKey( key );
if ( pEP ) {
*out = pEP->value;
*out = pEP->value.c_str();
}
else {
*out = defaultstring;
@@ -536,7 +523,7 @@ void DEntity::SpawnString( const char* key, const char* defaultstring, const cha
void DEntity::SpawnInt( const char* key, const char* defaultstring, int* out ){
DEPair* pEP = FindEPairByKey( key );
if ( pEP ) {
*out = atoi( pEP->value );
*out = atoi( pEP->value.c_str() );
}
else {
*out = atoi( defaultstring );
@@ -546,7 +533,7 @@ void DEntity::SpawnInt( const char* key, const char* defaultstring, int* out ){
void DEntity::SpawnFloat( const char* key, const char* defaultstring, float* out ){
DEPair* pEP = FindEPairByKey( key );
if ( pEP ) {
*out = static_cast<float>( atof( pEP->value ) );
*out = static_cast<float>( atof( pEP->value.c_str() ) );
}
else {
*out = static_cast<float>( atof( defaultstring ) );
@@ -556,7 +543,7 @@ void DEntity::SpawnFloat( const char* key, const char* defaultstring, float* out
void DEntity::SpawnVector( const char* key, const char* defaultstring, vec_t* out ){
DEPair* pEP = FindEPairByKey( key );
if ( pEP ) {
sscanf( pEP->value, "%f %f %f", &out[0], &out[1], &out[2] );
sscanf( pEP->value.c_str(), "%f %f %f", &out[0], &out[1], &out[2] );
}
else {
sscanf( defaultstring, "%f %f %f", &out[0], &out[1], &out[2] );
+6 -7
View File
@@ -23,13 +23,12 @@
#pragma once
#include <list>
#include <vector>
#include "str.h"
#include "string/string.h"
#include "mathlib.h"
#include "DMap.h"
#include "DEPair.h"
class DEPair;
class DBrush;
class DPlane;
class DPatch;
@@ -66,8 +65,8 @@ public:
void SetClassname( const char* classname );
void BuildInRadiant( bool allowDestruction );
void ResetChecks( std::list<Str>* exclusionList );
void RemoveNonCheckBrushes( std::list<Str>* exclusionList );
void ResetChecks( const std::vector<CopiedString>& exclusionList );
void RemoveNonCheckBrushes( const std::vector<CopiedString>& exclusionList );
int GetBrushCount( void );
DBrush* FindBrushByPointer( scene::Node& brush );
@@ -94,11 +93,11 @@ public:
// ---------------------------------------------
// vars
std::list<DEPair*> epairList;
std::vector<DEPair> epairList;
std::vector<DBrush*> brushList;
// new patches, wahey!!!
std::vector<DPatch*> patchList;
Str m_Classname;
CopiedString m_Classname;
// ---------------------------------------------
+1 -7
View File
@@ -23,9 +23,6 @@
#include "DMap.h"
#include "str.h"
#include <list>
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
@@ -37,9 +34,6 @@
#include "generic/referencecounted.h"
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include "scenelib.h"
@@ -147,7 +141,7 @@ void DMap::ResetTextures( const char* textureName, float fScale[2], float f
bool bResetTextureName, bool bResetScale[2], bool bResetShift[2], bool bResetRotation ){
for ( DEntity *entity : entityList )
{
if ( string_equal_nocase( "worldspawn", entity->m_Classname ) ) {
if ( string_equal_nocase( "worldspawn", entity->m_Classname.c_str() ) ) {
entity->ResetTextures( textureName, fScale, fShift, rotation, newTextureName,
bResetTextureName, bResetScale, bResetShift, bResetRotation, true );
}
-1
View File
@@ -24,7 +24,6 @@
#include "DPatch.h"
#include <list>
#include "str.h"
#include "scenelib.h"
#include "ipatch.h"
-1
View File
@@ -28,7 +28,6 @@
#include "DPoint.h"
#include "DWinding.h"
#include "str.h"
#include "misc.h"
//////////////////////////////////////////////////////////////////////
-2
View File
@@ -23,9 +23,7 @@
#include "DShape.h"
#include <list>
#include <ctime>
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
+1 -2
View File
@@ -20,7 +20,6 @@
#include "DTrainDrawer.h"
#include <list>
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
@@ -177,7 +176,7 @@ public:
e.ClearEPairs();
e.LoadEPairList( Node_getEntity( instance.path().top() ) );
const char* classname = e.m_Classname.GetBuffer();
const char* classname = e.m_Classname.c_str();
const char* target;
const char* control;
const char* targetname;
+1 -4
View File
@@ -19,9 +19,6 @@
#include "DTreePlanter.h"
#include <list>
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
@@ -184,7 +181,7 @@ public:
}
vec3_t vec, out;
sscanf( pEpair->value.GetBuffer(), "%f %f %f", &vec[0], &vec[1], &vec[2] );
sscanf( pEpair->value.c_str(), "%f %f %f", &vec[0], &vec[1], &vec[2] );
planter.FindDropPoint( vec, out );
-3
View File
@@ -26,9 +26,6 @@
#include "iglrender.h"
#include "math/matrix.h"
#include <list>
#include "str.h"
#include "DPoint.h"
#include "misc.h"
-2
View File
@@ -23,8 +23,6 @@
#include "DWinding.h"
#include <list>
#include "DPoint.h"
#include "DPlane.h"
-1
View File
@@ -19,7 +19,6 @@
#include "str.h"
#include "qerplugin.h"
#include "mathlib.h"
#include "string/string.h"
-3
View File
@@ -20,9 +20,6 @@
#include "dialogs-gtk.h"
#include "../funchandlers.h"
#include "str.h"
#include <list>
#include "../lists.h"
#include "../misc.h"
+6 -10
View File
@@ -21,8 +21,7 @@
#include "dialogs/dialogs-gtk.h"
#include <list>
#include "str.h"
#include "string/string.h"
#include "DPoint.h"
#include "DPlane.h"
@@ -47,19 +46,16 @@
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include "scenelib.h"
// for autocaulk
std::list<Str> exclusionList; // whole brush exclusion
std::list<Str> exclusionList_Face; // single face exclusion
std::vector<CopiedString> exclusionList; // whole brush exclusion
std::vector<CopiedString> exclusionList_Face; // single face exclusion
bool el1Loaded = false;
bool el2Loaded = false;
bool clrLst1Loaded = false;
bool clrLst2Loaded = false;
std::unique_ptr<DBobView> g_PathView;
std::unique_ptr<DVisDrawer> g_VisView;
@@ -75,10 +71,10 @@ void LoadLists(){
char buffer[256];
if ( !el1Loaded ) {
el1Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el1.txt" ), &exclusionList );
el1Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el1.txt" ), exclusionList );
}
if ( !el2Loaded ) {
el2Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el2.txt" ), &exclusionList_Face );
el2Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el2.txt" ), exclusionList_Face );
}
}
@@ -116,7 +112,7 @@ void DoIntersect(){
break;
}
}
world.RemoveNonCheckBrushes( &exclusionList );
world.RemoveNonCheckBrushes( exclusionList );
bool* pbSelectList;
if ( rs.bDuplicateOnly ) {
+4 -4
View File
@@ -21,17 +21,17 @@
#include "misc.h"
bool LoadExclusionList( char* filename, std::list<Str>* exclusionList ){
bool LoadExclusionList( const char* filename, std::vector<CopiedString>& exclusionList ){
FILE* eFile = fopen( filename, "r" );
if ( eFile ) {
char buffer[256];
while ( !feof( eFile ) )
{
memset( buffer, 0, 256 );
memset( buffer, 0, sizeof( buffer ) );
fscanf( eFile, "%s\n", buffer );
if ( strlen( buffer ) > 0 ) {
exclusionList->push_back( buffer );
if ( !string_empty( buffer ) ) {
exclusionList.push_back( buffer );
}
}
+3 -3
View File
@@ -19,9 +19,9 @@
#pragma once
#include <list>
#include "str.h"
#include <vector>
#include "string/string.h"
#include <QStringList>
bool LoadExclusionList( char* filename, std::list<Str>* exclusionList );
bool LoadExclusionList( const char* filename, std::vector<CopiedString>& exclusionList );
QStringList LoadListStore( char* filename );
+4 -9
View File
@@ -19,9 +19,6 @@
#include "misc.h"
#include <list>
#include "str.h"
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
@@ -42,8 +39,6 @@
#include "qerplugin.h"
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include "scenelib.h"
@@ -206,15 +201,15 @@ class EntityWriteMiniPrt
{
mutable DEntity world;
FILE* pFile;
std::list<Str>* exclusionList;
const std::vector<CopiedString>& exclusionList;
public:
EntityWriteMiniPrt( FILE* pFile, std::list<Str>* exclusionList )
EntityWriteMiniPrt( FILE* pFile, const std::vector<CopiedString>& exclusionList )
: pFile( pFile ), exclusionList( exclusionList ){
}
void operator()( scene::Instance& instance ) const {
const char* classname = Node_getEntity( instance.path().top() )->getClassName();
if ( !strcmp( classname, "worldspawn" ) ) {
if ( string_equal( classname, "worldspawn" ) ) {
world.LoadFromEntity( instance.path().top() );
world.RemoveNonCheckBrushes( exclusionList );
world.SaveToFile( pFile );
@@ -228,7 +223,7 @@ public:
}
};
void BuildMiniPrt( std::list<Str>* exclusionList ){
void BuildMiniPrt( const std::vector<CopiedString>& exclusionList ){
// yes, we could just use -fulldetail option, but, as SPOG said
// it'd be faster without all the hint, donotenter etc textures and
// doors, etc
+3 -3
View File
@@ -20,8 +20,8 @@
#pragma once
#include "mathlib.h"
#include <list>
#include "str.h"
#include <vector>
#include "string/string.h"
#include "iscenegraph.h"
#define MAX_ROUND_ERROR 0.05
@@ -34,7 +34,7 @@ const char* GetCurrentTexture();
class _QERFaceData;
void FillDefaultTexture( _QERFaceData* faceData, vec3_t va, vec3_t vb, vec3_t vc, const char* texture );
void BuildMiniPrt( std::list<Str>* exclusionList );
void BuildMiniPrt( const std::vector<CopiedString>& exclusionList );
void MoveBlock( int dir, vec3_t min, vec3_t max, float dist );
void SetInitialStairPos( int dir, vec3_t min, vec3_t max, float width );
-6
View File
@@ -20,12 +20,9 @@
#include "shapes.h"
#include <list>
#include "DPoint.h"
#include "DPlane.h"
#include "str.h"
#include "misc.h"
#include "funchandlers.h"
@@ -36,9 +33,6 @@
#include "ipatch.h"
#include "qerplugin.h"
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <ctime>
-2
View File
@@ -7,8 +7,6 @@
#include "bsploader.h"
#include "DVisDrawer.h"
#include <list>
typedef struct {
int portalclusters;
int leafbytes; //leafbytes = ((portalclusters+63)&~63)>>3;