MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / SetOrCreateToken

Method SetOrCreateToken

Code/CryEngine/CryAction/GameTokens/GameTokenSystem.cpp:149–183  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

147
148//////////////////////////////////////////////////////////////////////////
149IGameToken* CGameTokenSystem::SetOrCreateToken(const char* sTokenName, const TFlowInputData& defaultValue)
150{
151 CRY_ASSERT(sTokenName);
152 if (*sTokenName == 0) // empty string
153 {
154 GameWarning(_HELP("Creating game token with empty name"));
155 return 0;
156 }
157
158#ifdef DEBUG_GAME_TOKENS
159 GameTokensMap::iterator iter(m_pGameTokensMap->begin());
160 CryLogAlways("GT 0x%p: DEBUG looking for token '%s'", this, sTokenName);
161 while (iter != m_pGameTokensMap->end())
162 {
163 CryLogAlways("GT 0x%p: Token key='%s' name='%s' Val='%s'", this, (*iter).first, (*iter).second->GetName(), (*iter).second->GetValueAsString());
164 ++iter;
165 }
166#endif
167
168 // Check if token already exist, if it is return existing token.
169 CGameToken* pToken = stl::find_in_map(*m_pGameTokensMap, sTokenName, NULL);
170 if (pToken)
171 {
172 pToken->SetValue(defaultValue);
173 // Should we also output a warning here?
174 // GameWarning( "Game Token 0x%p %s already exist. New value %s", pToken, sTokenName, pToken->GetValueAsString());
175 return pToken;
176 }
177 pToken = new CGameToken;
178 pToken->m_name = sTokenName;
179 pToken->m_value = defaultValue;
180 (*m_pGameTokensMap)[pToken->m_name.c_str()] = pToken;
181
182 return pToken;
183}
184
185//////////////////////////////////////////////////////////////////////////
186void CGameTokenSystem::DeleteToken(IGameToken* pToken)

Callers 6

ResetGraphTokenMethod · 0.80
GetGameTokenFunction · 0.80
SetTokenMethod · 0.80
ExecuteMethod · 0.80
UpdateMethod · 0.80
StopEngineMethod · 0.80

Calls 9

CryLogAlwaysFunction · 0.85
find_in_mapFunction · 0.85
GameWarningFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
GetNameMethod · 0.45
GetValueAsStringMethod · 0.45
SetValueMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected