12
12
#include " filesystem_tools.h"
13
13
#include " tier1/strtools.h"
14
14
#include " utlmap.h"
15
+ #ifdef MAPBASE
16
+ #include " fmtstr.h"
17
+ #endif // MAPBASE
15
18
16
19
// memdbgon must be the last include file in a .cpp file!!!
17
20
#include " tier0/memdbgon.h"
@@ -579,13 +582,47 @@ GDclass *GameData::BeginInstanceRemap( const char *pszClassName, const char *psz
579
582
return m_InstanceClass;
580
583
}
581
584
585
+ #ifdef MAPBASE
586
+ // -----------------------------------------------------------------------------
587
+ // Purpose: Sets up for additional instance remap fixes from Mapbase
588
+ // -----------------------------------------------------------------------------
589
+ void GameData::SetupInstanceRemapParams ( int iStartNodes, int iStartBrushSide, bool bRemapVecLines )
590
+ {
591
+ // Set the numer of nodes in the level
592
+ m_InstanceStartAINodes = iStartNodes;
593
+
594
+ // If we have a "nodeid" key, set it to ivNodeDest so it's properly recognized
595
+ // during AI node remapping
596
+ GDinputvariable *var = m_InstanceClass->VarForName ( " nodeid" );
597
+ if ( var )
598
+ {
599
+ var->ForceSetType ( ivNodeDest );
600
+ }
601
+
602
+ // ---------------------------------------------
603
+
604
+ // Set the number of brush sides in the level
605
+ m_InstanceStartSide = iStartBrushSide;
606
+
607
+ // ---------------------------------------------
608
+
609
+ m_bRemapVecLines = bRemapVecLines;
610
+ }
611
+ #endif // MAPBASE
582
612
583
613
enum tRemapOperation
584
614
{
585
615
REMAP_NAME = 0 ,
586
616
REMAP_POSITION,
587
617
REMAP_ANGLE,
588
618
REMAP_ANGLE_NEGATIVE_PITCH,
619
+ #ifdef MAPBASE
620
+ // Remaps the node ID for instance/manifest AI node support
621
+ REMAP_NODE_ID,
622
+
623
+ // Remaps brush sides and sidelists
624
+ REMAP_SIDES,
625
+ #endif // MAPBASE
589
626
};
590
627
591
628
@@ -624,6 +661,12 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
624
661
RemapOperation.Insert ( ivOrigin, REMAP_POSITION );
625
662
RemapOperation.Insert ( ivAxis, REMAP_ANGLE );
626
663
RemapOperation.Insert ( ivAngleNegativePitch, REMAP_ANGLE_NEGATIVE_PITCH );
664
+ #ifdef MAPBASE
665
+ RemapOperation.Insert ( ivNodeDest, REMAP_NODE_ID );
666
+ RemapOperation.Insert ( ivSide, REMAP_SIDES );
667
+ RemapOperation.Insert ( ivSideList, REMAP_SIDES );
668
+ RemapOperation.Insert ( ivVecLine, REMAP_POSITION );
669
+ #endif // MAPBASE
627
670
}
628
671
629
672
if ( !m_InstanceClass )
@@ -657,6 +700,11 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
657
700
658
701
case REMAP_POSITION:
659
702
{
703
+ #ifdef MAPBASE
704
+ // Only remap ivVecLine if the keyvalue is enabled
705
+ if (KVType == ivVecLine && !m_bRemapVecLines)
706
+ break ;
707
+ #endif // MAPBASE
660
708
Vector inPoint ( 0 .0f , 0 .0f , 0 .0f ), outPoint;
661
709
662
710
sscanf ( pszInValue, " %f %f %f" , &inPoint.x , &inPoint.y , &inPoint.z );
@@ -697,6 +745,53 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
697
745
sprintf ( pszOutValue, " %g" , -outAngles.x ); // just the pitch
698
746
}
699
747
break ;
748
+ #ifdef MAPBASE
749
+ case REMAP_NODE_ID:
750
+ {
751
+ int value = atoi ( pszInValue );
752
+ if (value == -1 )
753
+ break ;
754
+
755
+ // Warning( " %s %s: Remapped %i to %i", m_InstanceClass->GetName(), KVVar->GetName(), value, value + m_InstanceStartAINodes );
756
+
757
+ value += m_InstanceStartAINodes;
758
+
759
+ sprintf ( pszOutValue, " %i" , value );
760
+ }
761
+ break ;
762
+
763
+ case REMAP_SIDES:
764
+ {
765
+ CUtlStringList sideList;
766
+ V_SplitString ( pszInValue, " " , sideList );
767
+
768
+ // Convert sides
769
+ CUtlStringList newSideList;
770
+ for (int i = 0 ; i < sideList.Count (); i++)
771
+ {
772
+ int iSide = atoi ( sideList[i] );
773
+
774
+ // Warning( " %s %s: Remapped %i to %i", m_InstanceClass->GetName(), KVVar->GetName(), iSide, iSide + m_InstanceStartSide );
775
+
776
+ iSide += m_InstanceStartSide;
777
+
778
+ newSideList.AddToTail ( const_cast <char *>( CNumStr ( iSide ).String () ) );
779
+ }
780
+
781
+ // Initial side
782
+ strcpy ( pszOutValue, newSideList[0 ] );
783
+
784
+ // Start at 1 for subsequent sides
785
+ for (int i = 1 ; i < newSideList.Count (); i++)
786
+ {
787
+ // Any subsequent sides are spaced
788
+ sprintf ( pszOutValue, " %s %s" , pszOutValue, newSideList[i] );
789
+ }
790
+
791
+ // Warning("Old side list: \"%s\", new side list: \"%s\"\n", pszInValue, pszOutValue);
792
+ }
793
+ break ;
794
+ #endif // MAPBASE
700
795
}
701
796
702
797
return ( strcmpi ( pszInValue, pszOutValue ) != 0 );
@@ -713,7 +808,11 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
713
808
// -----------------------------------------------------------------------------
714
809
bool GameData::RemapNameField ( const char *pszInValue, char *pszOutValue, TNameFixup NameFixup )
715
810
{
811
+ #ifdef MAPBASE
812
+ if ( pszInValue[ 0 ] && pszInValue[ 0 ] != ' @' && pszInValue[ 0 ] != ' !' )
813
+ #else
716
814
strcpy ( pszOutValue, pszInValue );
815
+ #endif // MAPBASE
717
816
718
817
if ( pszInValue[ 0 ] && pszInValue[ 0 ] != ' @' )
719
818
{ // ! at the start of a value means it is global and should not be remaped
0 commit comments