Skip to content

Commit

Permalink
Mapbase v5.1
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Blixibon committed Sep 23, 2020
1 parent 5c20518 commit add1571
Show file tree
Hide file tree
Showing 45 changed files with 1,477 additions and 71 deletions.
4 changes: 3 additions & 1 deletion CONTRIBUTING
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ All contributions must follow the following rules:
* All content in a contribution must be either already legally open-source or done with the
full permission of the contribution's original creator(s).

* Contributions must not break existing maps/content or interfere with them in a negative or non-objective way.

* Code contributions are not obliged to follow Mapbase's preprocessor conventions (e.g. #ifdef MAPBASE),
although it is acceptable.
although following them is acceptable.

* If you are contributing a file you created yourself specifically for Mapbase, you are required to
use the custom "Mapbase - Source 2013" header used in other Mapbase files as of Mapbase v5.0.
Expand Down
98 changes: 98 additions & 0 deletions sp/src/fgdlib/gamedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "filesystem_tools.h"
#include "tier1/strtools.h"
#include "utlmap.h"
#ifdef MAPBASE
#include "fmtstr.h"
#endif

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

#ifdef MAPBASE
//-----------------------------------------------------------------------------
// Purpose: Sets up for additional instance remap fixes from Mapbase
//-----------------------------------------------------------------------------
void GameData::SetupInstanceRemapParams( int iStartNodes, int iStartBrushSide, bool bRemapVecLines )
{
// Set the numer of nodes in the level
m_InstanceStartAINodes = iStartNodes;

// If we have a "nodeid" key, set it to ivNodeDest so it's properly recognized
// during AI node remapping
GDinputvariable *var = m_InstanceClass->VarForName( "nodeid" );
if ( var )
{
var->ForceSetType( ivNodeDest );
}

//---------------------------------------------

// Set the number of brush sides in the level
m_InstanceStartSide = iStartBrushSide;

//---------------------------------------------

m_bRemapVecLines = bRemapVecLines;
}
#endif


enum tRemapOperation
{
REMAP_NAME = 0,
REMAP_POSITION,
REMAP_ANGLE,
REMAP_ANGLE_NEGATIVE_PITCH,
#ifdef MAPBASE
// Remaps the node ID for instance/manifest AI node support
REMAP_NODE_ID,

// Remaps brush sides and sidelists
REMAP_SIDES,
#endif
};


Expand Down Expand Up @@ -624,6 +662,12 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
RemapOperation.Insert( ivOrigin, REMAP_POSITION );
RemapOperation.Insert( ivAxis, REMAP_ANGLE );
RemapOperation.Insert( ivAngleNegativePitch, REMAP_ANGLE_NEGATIVE_PITCH );
#ifdef MAPBASE
RemapOperation.Insert( ivNodeDest, REMAP_NODE_ID );
RemapOperation.Insert( ivSide, REMAP_SIDES );
RemapOperation.Insert( ivSideList, REMAP_SIDES );
RemapOperation.Insert( ivVecLine, REMAP_POSITION );
#endif
}

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

case REMAP_POSITION:
{
#ifdef MAPBASE
// Only remap ivVecLine if the keyvalue is enabled
if (KVType == ivVecLine && !m_bRemapVecLines)
break;
#endif

Vector inPoint( 0.0f, 0.0f, 0.0f ), outPoint;

sscanf ( pszInValue, "%f %f %f", &inPoint.x, &inPoint.y, &inPoint.z );
Expand Down Expand Up @@ -697,6 +747,54 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
sprintf( pszOutValue, "%g", -outAngles.x ); // just the pitch
}
break;

#ifdef MAPBASE
case REMAP_NODE_ID:
{
int value = atoi( pszInValue );
if (value == -1)
break;

//Warning( " %s %s: Remapped %i to %i", m_InstanceClass->GetName(), KVVar->GetName(), value, value + m_InstanceStartAINodes );

value += m_InstanceStartAINodes;

sprintf( pszOutValue, "%i", value );
}
break;

case REMAP_SIDES:
{
CUtlStringList sideList;
V_SplitString( pszInValue, " ", sideList );

// Convert sides
CUtlStringList newSideList;
for (int i = 0; i < sideList.Count(); i++)
{
int iSide = atoi( sideList[i] );

//Warning( " %s %s: Remapped %i to %i", m_InstanceClass->GetName(), KVVar->GetName(), iSide, iSide + m_InstanceStartSide );

iSide += m_InstanceStartSide;

newSideList.AddToTail( const_cast<char*>( CNumStr( iSide ).String() ) );
}

// Initial side
strcpy( pszOutValue, newSideList[0] );

// Start at 1 for subsequent sides
for (int i = 1; i < newSideList.Count(); i++)
{
// Any subsequent sides are spaced
sprintf( pszOutValue, "%s %s", pszOutValue, newSideList[i] );
}

//Warning("Old side list: \"%s\", new side list: \"%s\"\n", pszInValue, pszOutValue);
}
break;
#endif
}

return ( strcmpi( pszInValue, pszOutValue ) != 0 );
Expand Down
18 changes: 18 additions & 0 deletions sp/src/game/client/c_baselesson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include "vprof.h"
#include "view.h"
#include "vstdlib/ikeyvaluessystem.h"
#ifdef MAPBASE
#include "usermessages.h"
#endif

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
Expand Down Expand Up @@ -442,6 +445,9 @@ void CIconLesson::Init()
m_iFlags = LOCATOR_ICON_FX_NONE;
#ifdef MAPBASE
m_szCaptionColor = gameinstructor_default_captioncolor.GetString();

m_iIconTargetPos = ICON_TARGET_EYE_POSITION;
m_szHudHint = "";
#else
m_szCaptionColor = "255,255,255";// Default to white
#endif
Expand Down Expand Up @@ -653,6 +659,17 @@ void CIconLesson::UpdateInactive()
m_fCurrentDistance = pLocalPlayer->EyePosition().DistTo( pIconTarget->WorldSpaceCenter() );
}

#ifdef MAPBASE
if (m_szHudHint.String()[0] != '\0' && GetRoot()->IsLearned())
{
DevMsg("Showing hint\n");
CUtlBuffer msg_data;
msg_data.PutChar( 1 );
msg_data.PutString( m_szHudHint.String() );
usermessages->DispatchUserMessage( usermessages->LookupUserMessage( "KeyHintText" ), bf_read( msg_data.Base(), msg_data.TellPut() ) );
}
#endif

m_fUpdateDistanceTime = gpGlobals->curtime + LESSON_DISTANCE_UPDATE_RATE;
}
}
Expand Down Expand Up @@ -1014,6 +1031,7 @@ Vector CIconLesson::GetIconTargetPosition( C_BaseEntity *pIconTarget )
LESSON_VARIABLE_MACRO_STRING( START_SOUND, m_szStartSound, CGameInstructorSymbol ) \
\
LESSON_VARIABLE_MACRO( ICON_TARGET_POS, m_iIconTargetPos, int ) \
LESSON_VARIABLE_MACRO_STRING( HUD_HINT_AFTER_LEARNED, m_szHudHint, CGameInstructorSymbol ) \


// Create keyvalues name symbol
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/client/c_baselesson.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ class CIconLesson : public CTextLesson
ICON_TARGET_ORIGIN,
ICON_TARGET_CENTER,
};

CGameInstructorSymbol m_szHudHint;
#endif
};

Expand Down
2 changes: 1 addition & 1 deletion sp/src/game/client/c_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ BEGIN_RECV_TABLE( C_World, DT_World )
RecvPropString(RECVINFO(m_iszChapterTitle)),
#endif
#ifdef MAPBASE_VSCRIPT
RecvPropInt(RECVINFO(m_iScriptLanguage)),
RecvPropInt(RECVINFO(m_iScriptLanguageClient)),
#endif
END_RECV_TABLE()

Expand Down
4 changes: 2 additions & 2 deletions sp/src/game/client/c_world.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class C_World : public C_BaseEntity
const char *GetDetailSpriteMaterial() const;

#ifdef MAPBASE_VSCRIPT
ScriptLanguage_t GetScriptLanguage() { return (ScriptLanguage_t)m_iScriptLanguage; }
ScriptLanguage_t GetScriptLanguage() { return (ScriptLanguage_t)m_iScriptLanguageClient; }
#endif

public:
Expand All @@ -64,7 +64,7 @@ class C_World : public C_BaseEntity
char m_iszChapterTitle[64];
#endif
#ifdef MAPBASE_VSCRIPT
int m_iScriptLanguage;
int m_iScriptLanguageClient;
#endif

private:
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/client/detailobjectsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,12 +1624,14 @@ void CDetailObjectSystem::UnserializeModelDict( CUtlBuffer& buf )
DetailModelDict_t dict;
dict.m_pModel = (model_t *)engine->LoadModel( lump.m_Name, true );

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

m_DetailObjectDict.AddToTail( dict );
}
Expand Down
29 changes: 24 additions & 5 deletions sp/src/game/client/viewrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3349,11 +3349,11 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
//
// Monitor sky handling
//
if ( pCameraEnt->SkyMode() == SKYBOX_3DSKYBOX_VISIBLE )
SkyboxVisibility_t nSkyMode = pCameraEnt->SkyMode();
if ( nSkyMode == SKYBOX_3DSKYBOX_VISIBLE )
{
int nClearFlags = (VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR);
bool bDrew3dSkybox = false;
SkyboxVisibility_t nSkyMode = pCameraEnt->SkyMode();

Frustum frustum;
render->Push3DView( monitorView, nClearFlags, pRenderTarget, (VPlane *)frustum );
Expand All @@ -3369,13 +3369,32 @@ bool CViewRender::DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_Poin
ViewDrawScene( bDrew3dSkybox, nSkyMode, monitorView, nClearFlags, VIEW_MONITOR );
render->PopView( frustum );
}
else if (nSkyMode == SKYBOX_NOT_VISIBLE)
{
// @MULTICORE (toml 8/11/2006): this should be a renderer....
Frustum frustum;
render->Push3DView( monitorView, VIEW_CLEAR_DEPTH, pRenderTarget, (VPlane *)frustum );

CMatRenderContextPtr pRenderContext( materials );
pRenderContext->PushRenderTargetAndViewport( pRenderTarget );
pRenderContext->SetIntRenderingParameter( INT_RENDERPARM_WRITE_DEPTH_TO_DESTALPHA, 1 );
if ( pRenderTarget )
{
pRenderContext->OverrideAlphaWriteEnable( true, true );
}

ViewDrawScene( false, nSkyMode, monitorView, 0, VIEW_MONITOR );

pRenderContext->PopRenderTargetAndViewport();
render->PopView( frustum );
}
else
{
// @MULTICORE (toml 8/11/2006): this should be a renderer....
Frustum frustum;
render->Push3DView( monitorView, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, pRenderTarget, (VPlane *)frustum );
ViewDrawScene( false, SKYBOX_2DSKYBOX_VISIBLE, monitorView, 0, VIEW_MONITOR );
render->PopView( frustum );
render->Push3DView( monitorView, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, pRenderTarget, (VPlane *)frustum );
ViewDrawScene( false, nSkyMode, monitorView, 0, VIEW_MONITOR );
render->PopView( frustum );
}
#else
// @MULTICORE (toml 8/11/2006): this should be a renderer....
Expand Down
6 changes: 6 additions & 0 deletions sp/src/game/client/vscript_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ bool VScriptClientInit()
{
scriptLanguage = SL_PYTHON;
}
#ifdef MAPBASE_VSCRIPT
else if( !Q_stricmp(pszScriptLanguage, "lua") )
{
scriptLanguage = SL_LUA;
}
#endif
else
{
DevWarning("-scriptlang does not recognize a language named '%s'. virtual machine did NOT start.\n", pszScriptLanguage );
Expand Down
13 changes: 13 additions & 0 deletions sp/src/game/server/ai_basenpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ HSCRIPT CAI_BaseNPC::VScriptGetExpresser()

return hScript;
}

HSCRIPT CAI_BaseNPC::VScriptGetCine()
{
return ToHScript(m_hCine.Get());
}
#endif

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

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

DEFINE_SCRIPTFUNC( GetLastAttackTime, "Get the last time the NPC has used an attack (e.g. fired a bullet from a gun)." )
DEFINE_SCRIPTFUNC( GetLastDamageTime, "Get the last time the NPC has been damaged." )
DEFINE_SCRIPTFUNC( GetLastPlayerDamageTime, "Get the last time the NPC has been damaged by a player." )
DEFINE_SCRIPTFUNC( GetLastEnemyTime, "Get the last time the NPC has seen an enemy." )

DEFINE_SCRIPTFUNC_NAMED( VScriptGetState, "GetNPCState", "Get the NPC's current state." )

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

DEFINE_SCRIPTFUNC_NAMED( VScriptGetCine, "GetCine", "Get the NPC's currently running scripted sequence if it has one." )
DEFINE_SCRIPTFUNC( GetScriptState, "Get the NPC's current scripted sequence state." )

END_SCRIPTDESC();
#endif

Expand Down
3 changes: 3 additions & 0 deletions sp/src/game/server/ai_basenpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,9 @@ class CAI_BaseNPC : public CBaseCombatCharacter,
void VScriptClearCondition( const char *szCondition ) { ClearCondition( GetConditionID( szCondition ) ); }

HSCRIPT VScriptGetExpresser();

HSCRIPT VScriptGetCine();
int GetScriptState() { return m_scriptState; }
#endif

//-----------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions sp/src/game/server/ai_behavior_rappel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,14 @@ void CAI_RappelBehavior::GatherConditions()
if( HasCondition( COND_CAN_RANGE_ATTACK1 ) )
{
// Shoot at the enemy so long as I'm six feet or more above them.
#ifdef MAPBASE
// There seems to be an underlying issue here. COND_CAN_RANGE_ATTACK1 should not be valid without an enemy,
// but crashes have been reported from GetEnemy() returning null in this code.
Assert( GetEnemy() );
if( GetEnemy() && (GetAbsOrigin().z - GetEnemy()->GetAbsOrigin().z >= 36.0f) && GetOuter()->GetShotRegulator()->ShouldShoot() )
#else
if( (GetAbsOrigin().z - GetEnemy()->GetAbsOrigin().z >= 36.0f) && GetOuter()->GetShotRegulator()->ShouldShoot() )
#endif
{
Activity activity = GetOuter()->TranslateActivity( ACT_GESTURE_RANGE_ATTACK1 );
Assert( activity != ACT_INVALID );
Expand Down
Loading

0 comments on commit add1571

Please sign in to comment.