mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-05 22:09:59 +03:00
upload "kind" alien swarm
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Template entities are used by spawners to create copies of entities
|
||||
// that were configured by the level designer. This allows us to spawn
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "eventqueue.h"
|
||||
#include "TemplateEntities.h"
|
||||
#include "utldict.h"
|
||||
#include "entitydefs.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@@ -42,6 +43,8 @@ struct TemplateEntityData_t
|
||||
bool bNeedsEntityIOFixup; // If true, this template has entity I/O in its mapdata that needs fixup before spawning.
|
||||
char *pszFixedMapData; // A single copy of this template that we used to fix up the Entity I/O whenever someone wants a fixed version of this template
|
||||
|
||||
int m_nHammerID; // Used to update the template in Foundry
|
||||
|
||||
DECLARE_SIMPLE_DATADESC();
|
||||
};
|
||||
|
||||
@@ -67,11 +70,23 @@ static CUtlVector<TemplateEntityData_t *> g_Templates;
|
||||
|
||||
int g_iCurrentTemplateInstance;
|
||||
|
||||
void Templates_FreeTemplate( TemplateEntityData_t *pTemplate )
|
||||
{
|
||||
free((void *)pTemplate->pszName);
|
||||
free(pTemplate->pszMapData);
|
||||
if ( pTemplate->pszFixedMapData )
|
||||
{
|
||||
free(pTemplate->pszFixedMapData);
|
||||
}
|
||||
|
||||
free(pTemplate);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Saves the given entity's keyvalue data for later use by a spawner.
|
||||
// Returns the index into the templates.
|
||||
//-----------------------------------------------------------------------------
|
||||
int Templates_Add(CBaseEntity *pEntity, const char *pszMapData, int nLen)
|
||||
int Templates_Add(CBaseEntity *pEntity, const char *pszMapData, int nLen, int nHammerID)
|
||||
{
|
||||
const char *pszName = STRING(pEntity->GetEntityName());
|
||||
if ((!pszName) || (!strlen(pszName)))
|
||||
@@ -81,6 +96,7 @@ int Templates_Add(CBaseEntity *pEntity, const char *pszMapData, int nLen)
|
||||
}
|
||||
|
||||
TemplateEntityData_t *pEntData = (TemplateEntityData_t *)malloc(sizeof(TemplateEntityData_t));
|
||||
pEntData->m_nHammerID = nHammerID;
|
||||
pEntData->pszName = strdup( pszName );
|
||||
|
||||
// We may modify the values of the keys in this mapdata chunk later on to fix Entity I/O
|
||||
@@ -104,6 +120,19 @@ int Templates_Add(CBaseEntity *pEntity, const char *pszMapData, int nLen)
|
||||
}
|
||||
|
||||
|
||||
void Templates_RemoveByHammerID( int nHammerID )
|
||||
{
|
||||
for ( int i=g_Templates.Count()-1; i >= 0; i-- )
|
||||
{
|
||||
if ( g_Templates[i]->m_nHammerID == nHammerID )
|
||||
{
|
||||
Templates_FreeTemplate( g_Templates[i] );
|
||||
g_Templates.Remove( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if the specified index needs to be fixed up to be unique
|
||||
// when the template is spawned.
|
||||
@@ -224,8 +253,15 @@ void Templates_ReconnectIOForGroup( CPointTemplate *pGroup )
|
||||
|
||||
// Entity I/O values are stored as "Targetname,<data>", so we need to see if there's a ',' in the string
|
||||
char *sValue = value;
|
||||
|
||||
// FIXME: This is very brittle. Any key with a , will not be found.
|
||||
char *s = strchr( value, ',' );
|
||||
char delimiter = VMF_IOPARAM_STRING_DELIMITER;
|
||||
if( strchr( value, delimiter ) == NULL )
|
||||
{
|
||||
delimiter = ',';
|
||||
}
|
||||
|
||||
char *s = strchr( value, delimiter );
|
||||
if ( s )
|
||||
{
|
||||
// Grab just the targetname of the receiver
|
||||
@@ -335,7 +371,7 @@ char *Templates_GetEntityIOFixedMapData( int iIndex )
|
||||
Q_strncpy( g_Templates[iIndex]->pszFixedMapData, g_Templates[iIndex]->pszMapData, g_Templates[iIndex]->iMapDataLength );
|
||||
}
|
||||
|
||||
int iFixupSize = strlen(ENTITYIO_FIXUP_STRING); // don't include \0 when copying in the fixup
|
||||
int iFixupSize = strlen(ENTITYIO_FIXUP_STRING); // strlen("&0000\0") = 5!
|
||||
char *sOurFixup = new char[iFixupSize+1]; // do alloc room here for the null terminator
|
||||
Q_snprintf( sOurFixup, iFixupSize+1, "%c%.4d", ENTITYIO_FIXUP_STRING[0], g_iCurrentTemplateInstance );
|
||||
|
||||
@@ -380,15 +416,7 @@ void Templates_RemoveAll(void)
|
||||
for (int i = 0; i < nCount; i++)
|
||||
{
|
||||
TemplateEntityData_t *pTemplate = g_Templates.Element(i);
|
||||
|
||||
free((void *)pTemplate->pszName);
|
||||
free(pTemplate->pszMapData);
|
||||
if ( pTemplate->pszFixedMapData )
|
||||
{
|
||||
delete[] pTemplate->pszFixedMapData;
|
||||
}
|
||||
|
||||
free(pTemplate);
|
||||
Templates_FreeTemplate( pTemplate );
|
||||
}
|
||||
|
||||
g_Templates.RemoveAll();
|
||||
|
||||
Reference in New Issue
Block a user