MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / DefineConsoleFunction

Function DefineConsoleFunction

Engine/source/app/game.cpp:85–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84static const U32 MaxPlayerNameLength = 16;
85DefineConsoleFunction( strToPlayerName, const char*, (const char* ptr ), , "strToPlayerName(string);" )
86{
87
88 // Strip leading spaces and underscores:
89 while ( *ptr == ' ' || *ptr == '_' )
90 ptr++;
91
92 U32 len = dStrlen( ptr );
93 if ( len )
94 {
95 char* ret = Con::getReturnBuffer( MaxPlayerNameLength + 1 );
96 char* rptr = ret;
97 ret[MaxPlayerNameLength - 1] = '\0';
98 ret[MaxPlayerNameLength] = '\0';
99 bool space = false;
100
101 U8 ch;
102 while ( *ptr && dStrlen( ret ) < MaxPlayerNameLength )
103 {
104 ch = (U8) *ptr;
105
106 // Strip all illegal characters:
107 if ( ch < 32 || ch == ',' || ch == '.' || ch == '\'' || ch == '`' )
108 {
109 ptr++;
110 continue;
111 }
112
113 // Don't allow double spaces or space-underline combinations:
114 if ( ch == ' ' || ch == '_' )
115 {
116 if ( space )
117 {
118 ptr++;
119 continue;
120 }
121 else
122 space = true;
123 }
124 else
125 space = false;
126
127 *rptr++ = *ptr;
128 ptr++;
129 }
130 *rptr = '\0';
131
132 //finally, strip out the ML text control chars...
133 return GuiMLTextCtrl::stripControlChars(ret);
134 }
135
136 return( "" );
137}
138
139ConsoleFunctionGroupBegin( Platform , "General platform functions.");
140

Callers 7

version.cppFile · 0.70
game.cppFile · 0.70
i18n.cppFile · 0.50
navMesh.cppFile · 0.50
mathTypes.cppFile · 0.50

Calls 2

getReturnBufferFunction · 0.85
dStrlenFunction · 0.50

Tested by

no test coverage detected