From a0c29e7dd67abb15c74c85f07741784877edfdcd Mon Sep 17 00:00:00 2001 From: Joe Ludwig Date: Mon, 2 Sep 2013 11:39:10 -0700 Subject: General: * Fixed a variety of server browser issues with mods based on this SDK * Fixed many warnings on various platforms * Added source code for fgdlib and raytrace * Updated many source files with the latest shared source from TF2. OSX: * Added support for Xcode 4.6 * Switched OSX builds to use Xcode instead of makefiles * Moved libs from src/lib/osx32 to src/lib/public/osx32 or src/lib/common/osx32 to match windows better. Linux: * Moved libs from src/lib/linux32 to src/lib/public/linux32 or src/lib/common/linux32 to match windows better. --- sp/src/fgdlib/inputoutput.cpp | 171 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 sp/src/fgdlib/inputoutput.cpp (limited to 'sp/src/fgdlib/inputoutput.cpp') diff --git a/sp/src/fgdlib/inputoutput.cpp b/sp/src/fgdlib/inputoutput.cpp new file mode 100644 index 00000000..11c97df0 --- /dev/null +++ b/sp/src/fgdlib/inputoutput.cpp @@ -0,0 +1,171 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + + +#include +#include "fgdlib/InputOutput.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include + + +typedef struct +{ + InputOutputType_t eType; // The enumeration of this type. + char *pszName; // The name of this type. +} TypeMap_t; + + +char *CClassInputOutputBase::g_pszEmpty = ""; + + +//----------------------------------------------------------------------------- +// Maps type names to type enums for inputs and outputs. +//----------------------------------------------------------------------------- +static TypeMap_t TypeMap[] = +{ + { iotVoid, "void" }, + { iotInt, "integer" }, + { iotBool, "bool" }, + { iotString, "string" }, + { iotFloat, "float" }, + { iotVector, "vector" }, + { iotEHandle, "target_destination" }, + { iotColor, "color255" }, + { iotEHandle, "ehandle" }, // for backwards compatibility +}; + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CClassInputOutputBase::CClassInputOutputBase(void) +{ + m_eType = iotInvalid; + m_pszDescription = NULL; +} + + +//----------------------------------------------------------------------------- +// Purpose: +// Input : pszName - +// eType - +//----------------------------------------------------------------------------- +CClassInputOutputBase::CClassInputOutputBase(const char *pszName, InputOutputType_t eType) +{ + m_pszDescription = NULL; +} + + +//----------------------------------------------------------------------------- +// Purpose: Destructor. +//----------------------------------------------------------------------------- +CClassInputOutputBase::~CClassInputOutputBase(void) +{ + delete m_pszDescription; + m_pszDescription = NULL; +} + + +//----------------------------------------------------------------------------- +// Purpose: Returns a string representing the type of this I/O, eg. "integer". +//----------------------------------------------------------------------------- +const char *CClassInputOutputBase::GetTypeText(void) +{ + for (int i = 0; i < sizeof(TypeMap) / sizeof(TypeMap[0]); i++) + { + if (TypeMap[i].eType == m_eType) + { + return(TypeMap[i].pszName); + } + } + + return("unknown"); +} + + +//----------------------------------------------------------------------------- +// Purpose: +// Input : szType - +// Output : InputOutputType_t +//----------------------------------------------------------------------------- +InputOutputType_t CClassInputOutputBase::SetType(const char *szType) +{ + for (int i = 0; i < sizeof(TypeMap) / sizeof(TypeMap[0]); i++) + { + if (!stricmp(TypeMap[i].pszName, szType)) + { + m_eType = TypeMap[i].eType; + return(m_eType); + } + } + + return(iotInvalid); +} + + +//----------------------------------------------------------------------------- +// Purpose: Assignment operator. +//----------------------------------------------------------------------------- +CClassInputOutputBase &CClassInputOutputBase::operator =(CClassInputOutputBase &Other) +{ + strcpy(m_szName, Other.m_szName); + m_eType = Other.m_eType; + + // + // Copy the description. + // + delete m_pszDescription; + if (Other.m_pszDescription != NULL) + { + m_pszDescription = new char[strlen(Other.m_pszDescription) + 1]; + strcpy(m_pszDescription, Other.m_pszDescription); + } + else + { + m_pszDescription = NULL; + } + + return(*this); +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CClassInput::CClassInput(void) +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: +// Input : pszName - +// eType - +//----------------------------------------------------------------------------- +CClassInput::CClassInput(const char *pszName, InputOutputType_t eType) + : CClassInputOutputBase(pszName, eType) +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CClassOutput::CClassOutput(void) +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: +// Input : pszName - +// eType - +//----------------------------------------------------------------------------- +CClassOutput::CClassOutput(const char *pszName, InputOutputType_t eType) + : CClassInputOutputBase(pszName, eType) +{ +} -- cgit v1.2.3