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

Method CommandCallback

src/engine/shared/config.cpp:40–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38// -----
39
40void SIntConfigVariable::CommandCallback(IConsole::IResult *pResult, void *pUserData)
41{
42 SIntConfigVariable *pData = static_cast<SIntConfigVariable *>(pUserData);
43
44 if(pResult->NumArguments())
45 {
46 if(pData->CheckReadOnly())
47 return;
48
49 int Value = pResult->GetInteger(0);
50
51 // do clamping
52 if(pData->m_Min != pData->m_Max)
53 {
54 if(Value < pData->m_Min)
55 Value = pData->m_Min;
56 if(pData->m_Max != 0 && Value > pData->m_Max)
57 Value = pData->m_Max;
58 }
59
60 *pData->m_pVariable = Value;
61 if(pResult->m_ClientId != IConsole::CLIENT_ID_GAME)
62 pData->m_OldValue = Value;
63 }
64 else
65 {
66 char aBuf[32];
67 str_format(aBuf, sizeof(aBuf), "Value: %d", *pData->m_pVariable);
68 pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "config", aBuf);
69 }
70}
71
72void SIntConfigVariable::Register()
73{

Callers

nothing calls this directly

Calls 12

str_formatFunction · 0.85
round_to_intFunction · 0.85
NumArgumentsMethod · 0.80
CheckReadOnlyMethod · 0.80
UnclampLightingMethod · 0.80
ColorHSLAClass · 0.50
str_copyFunction · 0.50
GetIntegerMethod · 0.45
PrintMethod · 0.45
GetColorMethod · 0.45
PackMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected