attempted fix for
amb243, timers now simulate ticks if gameframe doesn't give changed curtimes
3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #ifndef _INCLUDE_SOURCEMOD_TRANSLATOR_H_
16 #define _INCLUDE_SOURCEMOD_TRANSLATOR_H_
19 #include <sh_string.h>
20 #include <sh_vector.h>
21 #include "sm_globals.h"
22 #include "sm_memtable.h"
23 #include "ITextParsers.h"
25 #define MAX_TRANSLATE_PARAMS 32
27 /* :TODO: write a templatized version of tries? */
29 using namespace SourceHook;
47 const char *szPhrase; /**< Translated phrase. */
48 unsigned int fmt_count; /**< Number of format parameters. */
49 int *fmt_order; /**< Format phrase order. */
52 #define LANGUAGE_ENGLISH 0
57 Trans_BadLanguage = 1,
59 Trans_BadPhraseLanguage = 3,
60 Trans_BadPhraseFile = 4,
63 class CPhraseFile : public ITextListener_SMC
66 CPhraseFile(Translator *pTranslator, const char *file);
70 const char *GetFilename();
71 TransError GetTranslation(const char *szPhrase, unsigned int lang_id, Translation *pTrans);
72 public: //ITextListener_SMC
73 void ReadSMC_ParseStart();
74 void ReadSMC_ParseEnd(bool halted, bool failed);
75 SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);
76 SMCParseResult ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes);
77 SMCParseResult ReadSMC_LeavingSection();
78 SMCParseResult ReadSMC_RawLine(const char *line, unsigned int curline);
80 void ParseError(const char *message, ...);
81 void ParseWarning(const char *message, ...);
83 Trie *m_pPhraseLookup;
85 Translator *m_pTranslator;
86 PhraseParseState m_ParseState;
88 BaseMemTable *m_pMemory;
89 BaseStringTable *m_pStringTab;
90 unsigned int m_LangCount;
92 String m_LastPhraseString;
93 unsigned int m_CurLine;
98 public ITextListener_SMC,
104 public: // SMGlobalClass
105 ConfigResult OnSourceModConfigChanged(const char *key,
110 void OnSourceModAllInitialized();
111 void OnSourceModLevelChange(const char *mapName);
112 public: // ITextListener_SMC
113 void ReadSMC_ParseStart();
114 SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);
115 SMCParseResult ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes);
116 SMCParseResult ReadSMC_LeavingSection();
118 void RebuildLanguageDatabase(const char *lang_header_file);
119 unsigned int FindOrAddPhraseFile(const char *phrase_file);
120 BaseStringTable *GetStringTable();
121 unsigned int GetLanguageCount();
122 bool GetLanguageByCode(const char *code, unsigned int *index);
123 size_t Translate(char *buffer, size_t maxlength, void **params, const Translation *pTrans);
124 CPhraseFile *GetFileByIndex(unsigned int index);
125 TransError CoreTrans(int client,
130 size_t *outlen=NULL);
131 unsigned int GetServerLanguage();
133 bool AddLanguage(const char *langcode, const char *description);
135 CVector<Language *> m_Languages;
136 CVector<CPhraseFile *> m_Files;
137 BaseStringTable *m_pStringTab;
138 Trie *m_pLCodeLookup;
139 bool m_InLanguageSection;
140 String m_CustomError;
141 unsigned int m_ServerLang;
142 char m_InitialLang[3];
145 extern CPhraseFile *g_pCorePhrases;
146 extern Translator g_Translator;
148 #endif //_INCLUDE_SOURCEMOD_TRANSLATOR_H_