|
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 |
15 | 18 |
|
16 | 19 | // memdbgon must be the last include file in a .cpp file!!! |
17 | 20 | #include "tier0/memdbgon.h" |
@@ -579,13 +582,48 @@ 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 |
| 612 | + |
582 | 613 |
|
583 | 614 | enum tRemapOperation |
584 | 615 | { |
585 | 616 | REMAP_NAME = 0, |
586 | 617 | REMAP_POSITION, |
587 | 618 | REMAP_ANGLE, |
588 | 619 | REMAP_ANGLE_NEGATIVE_PITCH, |
| 620 | +#ifdef MAPBASE |
| 621 | + // Remaps the node ID for instance/manifest AI node support |
| 622 | + REMAP_NODE_ID, |
| 623 | + |
| 624 | + // Remaps brush sides and sidelists |
| 625 | + REMAP_SIDES, |
| 626 | +#endif |
589 | 627 | }; |
590 | 628 |
|
591 | 629 |
|
@@ -624,6 +662,12 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char * |
624 | 662 | RemapOperation.Insert( ivOrigin, REMAP_POSITION ); |
625 | 663 | RemapOperation.Insert( ivAxis, REMAP_ANGLE ); |
626 | 664 | RemapOperation.Insert( ivAngleNegativePitch, REMAP_ANGLE_NEGATIVE_PITCH ); |
| 665 | +#ifdef MAPBASE |
| 666 | + RemapOperation.Insert( ivNodeDest, REMAP_NODE_ID ); |
| 667 | + RemapOperation.Insert( ivSide, REMAP_SIDES ); |
| 668 | + RemapOperation.Insert( ivSideList, REMAP_SIDES ); |
| 669 | + RemapOperation.Insert( ivVecLine, REMAP_POSITION ); |
| 670 | +#endif |
627 | 671 | } |
628 | 672 |
|
629 | 673 | if ( !m_InstanceClass ) |
@@ -657,6 +701,12 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char * |
657 | 701 |
|
658 | 702 | case REMAP_POSITION: |
659 | 703 | { |
| 704 | +#ifdef MAPBASE |
| 705 | + // Only remap ivVecLine if the keyvalue is enabled |
| 706 | + if (KVType == ivVecLine && !m_bRemapVecLines) |
| 707 | + break; |
| 708 | +#endif |
| 709 | + |
660 | 710 | Vector inPoint( 0.0f, 0.0f, 0.0f ), outPoint; |
661 | 711 |
|
662 | 712 | sscanf ( pszInValue, "%f %f %f", &inPoint.x, &inPoint.y, &inPoint.z ); |
@@ -697,6 +747,54 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char * |
697 | 747 | sprintf( pszOutValue, "%g", -outAngles.x ); // just the pitch |
698 | 748 | } |
699 | 749 | break; |
| 750 | + |
| 751 | +#ifdef MAPBASE |
| 752 | + case REMAP_NODE_ID: |
| 753 | + { |
| 754 | + int value = atoi( pszInValue ); |
| 755 | + if (value == -1) |
| 756 | + break; |
| 757 | + |
| 758 | + //Warning( " %s %s: Remapped %i to %i", m_InstanceClass->GetName(), KVVar->GetName(), value, value + m_InstanceStartAINodes ); |
| 759 | + |
| 760 | + value += m_InstanceStartAINodes; |
| 761 | + |
| 762 | + sprintf( pszOutValue, "%i", value ); |
| 763 | + } |
| 764 | + break; |
| 765 | + |
| 766 | + case REMAP_SIDES: |
| 767 | + { |
| 768 | + CUtlStringList sideList; |
| 769 | + V_SplitString( pszInValue, " ", sideList ); |
| 770 | + |
| 771 | + // Convert sides |
| 772 | + CUtlStringList newSideList; |
| 773 | + for (int i = 0; i < sideList.Count(); i++) |
| 774 | + { |
| 775 | + int iSide = atoi( sideList[i] ); |
| 776 | + |
| 777 | + //Warning( " %s %s: Remapped %i to %i", m_InstanceClass->GetName(), KVVar->GetName(), iSide, iSide + m_InstanceStartSide ); |
| 778 | + |
| 779 | + iSide += m_InstanceStartSide; |
| 780 | + |
| 781 | + newSideList.AddToTail( const_cast<char*>( CNumStr( iSide ).String() ) ); |
| 782 | + } |
| 783 | + |
| 784 | + // Initial side |
| 785 | + strcpy( pszOutValue, newSideList[0] ); |
| 786 | + |
| 787 | + // Start at 1 for subsequent sides |
| 788 | + for (int i = 1; i < newSideList.Count(); i++) |
| 789 | + { |
| 790 | + // Any subsequent sides are spaced |
| 791 | + sprintf( pszOutValue, "%s %s", pszOutValue, newSideList[i] ); |
| 792 | + } |
| 793 | + |
| 794 | + //Warning("Old side list: \"%s\", new side list: \"%s\"\n", pszInValue, pszOutValue); |
| 795 | + } |
| 796 | + break; |
| 797 | +#endif |
700 | 798 | } |
701 | 799 |
|
702 | 800 | return ( strcmpi( pszInValue, pszOutValue ) != 0 ); |
|
0 commit comments