summaryrefslogtreecommitdiff
path: root/game/client/tf/tf_autorp.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf/tf_autorp.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/tf/tf_autorp.h')
-rw-r--r--game/client/tf/tf_autorp.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/game/client/tf/tf_autorp.h b/game/client/tf/tf_autorp.h
new file mode 100644
index 0000000..814356e
--- /dev/null
+++ b/game/client/tf/tf_autorp.h
@@ -0,0 +1,88 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef TF_AUTORP_H
+#define TF_AUTORP_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "igamesystem.h"
+#include "utlvector.h"
+#include "utlmap.h"
+
+enum matchresult_t
+{
+ MATCHES_NOT,
+ MATCHES_SINGULAR,
+ MATCHES_PLURAL,
+};
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+class CTFAutoRP : public CAutoGameSystem
+{
+public:
+ CTFAutoRP() : CAutoGameSystem( "CTFAutoRP" )
+ {
+ m_pDataFileKV = NULL;
+ m_pWordTable = new CUtlSymbolTable( 0, 32, true );
+ }
+
+ void ParseDataFile( void );
+ void ApplyRPTo( char *pBuf, int iBufSize );
+
+private:
+ struct wordreplacement_t
+ {
+ int iChance;
+ int iPrePendCount;
+ CUtlVector<const char*> a_pszPrepended; // Words that prepend the replacement
+ CUtlVector<const char*> a_pszReplacements; // Words that replace the original word
+ CUtlVector<const char*> a_pszPluralReplacements; // If the match was a plural match, use these replacements instead, if they exist. Otherwise, use a_pszReplacements.
+ CUtlVector<CUtlSymbol> m_Words; // Word that matches this replacement
+ CUtlVector<CUtlSymbol> m_Plurals; // Word that must come before to match this replacement, for double word replacements (i.e. "it is" -> "'tis")
+ CUtlVector<CUtlSymbol> m_PrevWords; // Word that must come before to match this replacement, for double word replacements (i.e. "it is" -> "'tis")
+ };
+
+ struct replacementcheck_t
+ {
+ char szWord[128];
+ int iWordLen;
+ char szPrevWord[128];
+ int iPrevLen;
+
+ bool bUsedPrevWord;
+ };
+
+private:
+ const char *GetRandomPre( void );
+ const char *GetRandomPost( void );
+ void ModifySpeech( const char *pszInText, char *pszOutText, int iOutLen, bool bGeneratePreAndPost, bool bInPrePost );
+ matchresult_t WordMatches( wordreplacement_t *pRep, replacementcheck_t *pCheck );
+ bool ReplaceWord( replacementcheck_t *pCheck, char *szRep, int iRepSize, bool bSymbols, bool bWordListOnly );
+ bool PerformReplacement( const char *pszReplacement, replacementcheck_t *pRepCheck, char *szStoredWord, int iStoredWordSize, char *pszOutText, int iOutLen );
+
+private:
+ // Database
+ KeyValues *m_pDataFileKV;
+ // Storage of all replacement blocks
+ CUtlVector<wordreplacement_t> m_a_Replacements;
+ CUtlSymbolTable *m_pWordTable;
+
+ // Extra lists for random selection
+ CUtlVector<const char*> m_a_pszPrependedWords;
+ CUtlVector<const char*> m_a_pszAppendedWords;
+
+ // Current application
+ CUtlVector<const char*> *m_pszCurrentList;
+ int m_iCurrentReplacement;
+};
+
+extern CTFAutoRP *AutoRP( void );
+
+#endif // TF_AUTORP_H