MCPcopy Create free account
hub / github.com/ddnet/ddnet / GetKeyBindCommand

Method GetKeyBindCommand

src/game/client/components/binds.cpp:463–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461}
462
463char *CBinds::GetKeyBindCommand(int ModifierCombination, int Key) const
464{
465 char aBindName[128];
466 GetKeyBindName(Key, ModifierCombination, aBindName, sizeof(aBindName));
467 // worst case the str_escape can double the string length
468 int Size = str_length(m_aapKeyBindings[ModifierCombination][Key]) * 2 + str_length(aBindName) + 16;
469 auto *pBuf = static_cast<char *>(malloc(Size));
470 str_format(pBuf, Size, "bind %s \"", aBindName);
471 char *pDst = pBuf + str_length(pBuf);
472 // process the string. we need to escape some characters
473 str_escape(&pDst, m_aapKeyBindings[ModifierCombination][Key], pBuf + Size);
474 str_append(pBuf, "\"", Size);
475 return pBuf;
476}
477
478void CBinds::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData)
479{

Callers 2

ConBindsMethod · 0.80
ConfigSaveCallbackMethod · 0.80

Calls 4

str_lengthFunction · 0.85
str_formatFunction · 0.85
str_escapeFunction · 0.85
str_appendFunction · 0.50

Tested by

no test coverage detected