MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / DefineEngineFunction

Function DefineEngineFunction

Engine/source/app/game.cpp:94–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 6

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

Calls 2

getReturnBufferFunction · 0.85
dStrlenFunction · 0.50

Tested by

no test coverage detected