Skip to content

Commit add1571

Browse files
committed
Mapbase v5.1
- Fixed a major oversight in Source 2013 which was causing some code to think all logic entities were worldspawn - Added WIP background nodraw for point_cameras set to not draw skybox at all - Fixed map-specific talker not flushing on restore - Added optional HUD hint to code-based game instructor hints - Added workaround for suspicious crashes in HL2 NPC rappelling code (reported by 1upD) - Made antlions summoned by npc_antlionguard report as dead when removed with the "Kill" input - Fixed math_mod not saving mod value (reported by Klems) - Added SDK_WindowImposter, which uses the SteamPipe cubemap bug workaround and includes support for parallax corrected cubemaps - Updated thirdpartylegalnotices.txt to mention the Squirrel API - Fixed incorrect type checking for script instances in VScript - Added a bunch of new misc. VScript constants - Added a few new base VScript functions - Added a separate "Clientside Script Language" keyvalue to worldspawn for VScript, allowing client scripts to use a different language from server scripts - Fixed worldspawn crashing the game when running entity scripts (reported by krassell) - Fixed manifests creating a second worldspawn, allowing them to function properly in HL2 - Added tons of remapping-related fixes for instances and manifests, including node IDs and overlay remapping - Added a keyvalue to func_instance which allows vector axis lines to be remapped properly - Added support for manifest root path instances in VBSP - Added missing PrintBrushContents() contents to VBSP - Added -nohiddenmaps parameter - Made manifest cordon somewhat functional
1 parent 5c20518 commit add1571

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1477
-71
lines changed

CONTRIBUTING

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ All contributions must follow the following rules:
2525
* All content in a contribution must be either already legally open-source or done with the
2626
full permission of the contribution's original creator(s).
2727

28+
* Contributions must not break existing maps/content or interfere with them in a negative or non-objective way.
29+
2830
* Code contributions are not obliged to follow Mapbase's preprocessor conventions (e.g. #ifdef MAPBASE),
29-
although it is acceptable.
31+
although following them is acceptable.
3032

3133
* If you are contributing a file you created yourself specifically for Mapbase, you are required to
3234
use the custom "Mapbase - Source 2013" header used in other Mapbase files as of Mapbase v5.0.

sp/src/fgdlib/gamedata.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include "filesystem_tools.h"
1313
#include "tier1/strtools.h"
1414
#include "utlmap.h"
15+
#ifdef MAPBASE
16+
#include "fmtstr.h"
17+
#endif
1518

1619
// memdbgon must be the last include file in a .cpp file!!!
1720
#include "tier0/memdbgon.h"
@@ -579,13 +582,48 @@ GDclass *GameData::BeginInstanceRemap( const char *pszClassName, const char *psz
579582
return m_InstanceClass;
580583
}
581584

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+
582613

583614
enum tRemapOperation
584615
{
585616
REMAP_NAME = 0,
586617
REMAP_POSITION,
587618
REMAP_ANGLE,
588619
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
589627
};
590628

591629

@@ -624,6 +662,12 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
624662
RemapOperation.Insert( ivOrigin, REMAP_POSITION );
625663
RemapOperation.Insert( ivAxis, REMAP_ANGLE );
626664
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
627671
}
628672

629673
if ( !m_InstanceClass )
@@ -657,6 +701,12 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
657701

658702
case REMAP_POSITION:
659703
{
704+
#ifdef MAPBASE
705+
// Only remap ivVecLine if the keyvalue is enabled
706+
if (KVType == ivVecLine && !m_bRemapVecLines)
707+
break;
708+
#endif
709+
660710
Vector inPoint( 0.0f, 0.0f, 0.0f ), outPoint;
661711

662712
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 *
697747
sprintf( pszOutValue, "%g", -outAngles.x ); // just the pitch
698748
}
699749
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
700798
}
701799

702800
return ( strcmpi( pszInValue, pszOutValue ) != 0 );

sp/src/game/client/c_baselesson.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include "vprof.h"
1717
#include "view.h"
1818
#include "vstdlib/ikeyvaluessystem.h"
19+
#ifdef MAPBASE
20+
#include "usermessages.h"
21+
#endif
1922

2023
// memdbgon must be the last include file in a .cpp file!!!
2124
#include "tier0/memdbgon.h"
@@ -442,6 +445,9 @@ void CIconLesson::Init()
442445
m_iFlags = LOCATOR_ICON_FX_NONE;
443446
#ifdef MAPBASE
444447
m_szCaptionColor = gameinstructor_default_captioncolor.GetString();
448+
449+
m_iIconTargetPos = ICON_TARGET_EYE_POSITION;
450+
m_szHudHint = "";
445451
#else
446452
m_szCaptionColor = "255,255,255";// Default to white
447453
#endif
@@ -653,6 +659,17 @@ void CIconLesson::UpdateInactive()
653659
m_fCurrentDistance = pLocalPlayer->EyePosition().DistTo( pIconTarget->WorldSpaceCenter() );
654660
}
655661

662+
#ifdef MAPBASE
663+
if (m_szHudHint.String()[0] != '\0' && GetRoot()->IsLearned())
664+
{
665+
DevMsg("Showing hint\n");
666+
CUtlBuffer msg_data;
667+
msg_data.PutChar( 1 );
668+
msg_data.PutString( m_szHudHint.String() );
669+
usermessages->DispatchUserMessage( usermessages->LookupUserMessage( "KeyHintText" ), bf_read( msg_data.Base(), msg_data.TellPut() ) );
670+
}
671+
#endif
672+
656673
m_fUpdateDistanceTime = gpGlobals->curtime + LESSON_DISTANCE_UPDATE_RATE;
657674
}
658675
}
@@ -1014,6 +1031,7 @@ Vector CIconLesson::GetIconTargetPosition( C_BaseEntity *pIconTarget )
10141031
LESSON_VARIABLE_MACRO_STRING( START_SOUND, m_szStartSound, CGameInstructorSymbol ) \
10151032
\
10161033
LESSON_VARIABLE_MACRO( ICON_TARGET_POS, m_iIconTargetPos, int ) \
1034+
LESSON_VARIABLE_MACRO_STRING( HUD_HINT_AFTER_LEARNED, m_szHudHint, CGameInstructorSymbol ) \
10171035

10181036

10191037
// Create keyvalues name symbol

sp/src/game/client/c_baselesson.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ class CIconLesson : public CTextLesson
275275
ICON_TARGET_ORIGIN,
276276
ICON_TARGET_CENTER,
277277
};
278+
279+
CGameInstructorSymbol m_szHudHint;
278280
#endif
279281
};
280282

sp/src/game/client/c_world.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ BEGIN_RECV_TABLE( C_World, DT_World )
6363
RecvPropString(RECVINFO(m_iszChapterTitle)),
6464
#endif
6565
#ifdef MAPBASE_VSCRIPT
66-
RecvPropInt(RECVINFO(m_iScriptLanguage)),
66+
RecvPropInt(RECVINFO(m_iScriptLanguageClient)),
6767
#endif
6868
END_RECV_TABLE()
6969

sp/src/game/client/c_world.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class C_World : public C_BaseEntity
4242
const char *GetDetailSpriteMaterial() const;
4343

4444
#ifdef MAPBASE_VSCRIPT
45-
ScriptLanguage_t GetScriptLanguage() { return (ScriptLanguage_t)m_iScriptLanguage; }
45+
ScriptLanguage_t GetScriptLanguage() { return (ScriptLanguage_t)m_iScriptLanguageClient; }
4646
#endif
4747

4848
public:
@@ -64,7 +64,7 @@ class C_World : public C_BaseEntity
6464
char m_iszChapterTitle[64];
6565
#endif
6666
#ifdef MAPBASE_VSCRIPT
67-
int m_iScriptLanguage;
67+
int m_iScriptLanguageClient;
6868
#endif
6969

7070
private:

sp/src/game/client/detailobjectsystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,12 +1624,14 @@ void CDetailObjectSystem::UnserializeModelDict( CUtlBuffer& buf )
16241624
DetailModelDict_t dict;
16251625
dict.m_pModel = (model_t *)engine->LoadModel( lump.m_Name, true );
16261626

1627+
#ifndef MAPBASE
16271628
// Don't allow vertex-lit models
16281629
if (modelinfo->IsModelVertexLit(dict.m_pModel))
16291630
{
16301631
Warning("Detail prop model %s is using vertex-lit materials!\nIt must use unlit materials!\n", lump.m_Name );
16311632
dict.m_pModel = (model_t *)engine->LoadModel( "models/error.mdl" );
16321633
}
1634+
#endif
16331635

16341636
m_DetailObjectDict.AddToTail( dict );
16351637
}

sp/src/game/client/viewrender.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,11 +3349,11 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
33493349
//
33503350
// Monitor sky handling
33513351
//
3352-
if ( pCameraEnt->SkyMode() == SKYBOX_3DSKYBOX_VISIBLE )
3352+
SkyboxVisibility_t nSkyMode = pCameraEnt->SkyMode();
3353+
if ( nSkyMode == SKYBOX_3DSKYBOX_VISIBLE )
33533354
{
33543355
int nClearFlags = (VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR);
33553356
bool bDrew3dSkybox = false;
3356-
SkyboxVisibility_t nSkyMode = pCameraEnt->SkyMode();
33573357

33583358
Frustum frustum;
33593359
render->Push3DView( monitorView, nClearFlags, pRenderTarget, (VPlane *)frustum );
@@ -3369,13 +3369,32 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
33693369
ViewDrawScene( bDrew3dSkybox, nSkyMode, monitorView, nClearFlags, VIEW_MONITOR );
33703370
render->PopView( frustum );
33713371
}
3372+
else if (nSkyMode == SKYBOX_NOT_VISIBLE)
3373+
{
3374+
// @MULTICORE (toml 8/11/2006): this should be a renderer....
3375+
Frustum frustum;
3376+
render->Push3DView( monitorView, VIEW_CLEAR_DEPTH, pRenderTarget, (VPlane *)frustum );
3377+
3378+
CMatRenderContextPtr pRenderContext( materials );
3379+
pRenderContext->PushRenderTargetAndViewport( pRenderTarget );
3380+
pRenderContext->SetIntRenderingParameter( INT_RENDERPARM_WRITE_DEPTH_TO_DESTALPHA, 1 );
3381+
if ( pRenderTarget )
3382+
{
3383+
pRenderContext->OverrideAlphaWriteEnable( true, true );
3384+
}
3385+
3386+
ViewDrawScene( false, nSkyMode, monitorView, 0, VIEW_MONITOR );
3387+
3388+
pRenderContext->PopRenderTargetAndViewport();
3389+
render->PopView( frustum );
3390+
}
33723391
else
33733392
{
33743393
// @MULTICORE (toml 8/11/2006): this should be a renderer....
33753394
Frustum frustum;
3376-
render->Push3DView( monitorView, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, pRenderTarget, (VPlane *)frustum );
3377-
ViewDrawScene( false, SKYBOX_2DSKYBOX_VISIBLE, monitorView, 0, VIEW_MONITOR );
3378-
render->PopView( frustum );
3395+
render->Push3DView( monitorView, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, pRenderTarget, (VPlane *)frustum );
3396+
ViewDrawScene( false, nSkyMode, monitorView, 0, VIEW_MONITOR );
3397+
render->PopView( frustum );
33793398
}
33803399
#else
33813400
// @MULTICORE (toml 8/11/2006): this should be a renderer....

sp/src/game/client/vscript_client.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ bool VScriptClientInit()
466466
{
467467
scriptLanguage = SL_PYTHON;
468468
}
469+
#ifdef MAPBASE_VSCRIPT
470+
else if( !Q_stricmp(pszScriptLanguage, "lua") )
471+
{
472+
scriptLanguage = SL_LUA;
473+
}
474+
#endif
469475
else
470476
{
471477
DevWarning("-scriptlang does not recognize a language named '%s'. virtual machine did NOT start.\n", pszScriptLanguage );

sp/src/game/server/ai_basenpc.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,11 @@ HSCRIPT CAI_BaseNPC::VScriptGetExpresser()
812812

813813
return hScript;
814814
}
815+
816+
HSCRIPT CAI_BaseNPC::VScriptGetCine()
817+
{
818+
return ToHScript(m_hCine.Get());
819+
}
815820
#endif
816821

817822
bool CAI_BaseNPC::PassesDamageFilter( const CTakeDamageInfo &info )
@@ -11989,6 +11994,11 @@ BEGIN_ENT_SCRIPTDESC( CAI_BaseNPC, CBaseCombatCharacter, "The base class all NPC
1198911994

1199011995
DEFINE_SCRIPTFUNC_NAMED( VScriptFindEnemyMemory, "FindEnemyMemory", "Get information about the NPC's current enemy." )
1199111996

11997+
DEFINE_SCRIPTFUNC( GetLastAttackTime, "Get the last time the NPC has used an attack (e.g. fired a bullet from a gun)." )
11998+
DEFINE_SCRIPTFUNC( GetLastDamageTime, "Get the last time the NPC has been damaged." )
11999+
DEFINE_SCRIPTFUNC( GetLastPlayerDamageTime, "Get the last time the NPC has been damaged by a player." )
12000+
DEFINE_SCRIPTFUNC( GetLastEnemyTime, "Get the last time the NPC has seen an enemy." )
12001+
1199212002
DEFINE_SCRIPTFUNC_NAMED( VScriptGetState, "GetNPCState", "Get the NPC's current state." )
1199312003

1199412004
DEFINE_SCRIPTFUNC_NAMED( VScriptGetHintGroup, "GetHintGroup", "Get the name of the NPC's hint group." )
@@ -12027,6 +12037,9 @@ BEGIN_ENT_SCRIPTDESC( CAI_BaseNPC, CBaseCombatCharacter, "The base class all NPC
1202712037
DEFINE_SCRIPTFUNC( IsCommandable, "Check if the NPC is commandable." )
1202812038
DEFINE_SCRIPTFUNC( IsInPlayerSquad, "Check if the NPC is in the player's squad." )
1202912039

12040+
DEFINE_SCRIPTFUNC_NAMED( VScriptGetCine, "GetCine", "Get the NPC's currently running scripted sequence if it has one." )
12041+
DEFINE_SCRIPTFUNC( GetScriptState, "Get the NPC's current scripted sequence state." )
12042+
1203012043
END_SCRIPTDESC();
1203112044
#endif
1203212045

0 commit comments

Comments
 (0)