MCPcopy Create free account
hub / github.com/crownengine/crown / console_command_physics

Function console_command_physics

src/world/physics_world_bullet.cpp:135–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 }
134
135 static void console_command_physics(ConsoleServer &cs, u32 client_id, const JsonArray &args, void * /*user_data*/)
136 {
137 TempAllocator1024 ta;
138
139 if (array::size(args) < 2) {
140 cs.error(client_id, "Usage: physics <debug|scale|show|hide> ...");
141 return;
142 }
143
144 DynamicString subcmd(ta);
145 sjson::parse_string(subcmd, args[1]);
146
147 if (subcmd == "help") {
148 command_help();
149 return;
150 }
151
152 if (subcmd == "debug") {
153 if (array::size(args) != 3) {
154 cs.error(client_id, "Usage: physics debug <ON/OFF>");
155 return;
156 }
157
158 DynamicString value(ta);
159 sjson::parse_string(value, args[2]);
160 if (value.length() == 2 && strncasecmp(value.c_str(), "on", 2) == 0) {
161 _debug_enabled = true;
162 } else if (value.length() == 3 && strncasecmp(value.c_str(), "off", 3) == 0) {
163 _debug_enabled = false;
164 } else {
165 cs.error(client_id, "Usage: physics debug <ON/OFF>");
166 return;
167 }
168 return;
169 }
170
171 if (subcmd == "scale") {
172 if (array::size(args) != 3) {
173 cs.error(client_id, "Usage: physics scale <VALUE>");
174 return;
175 }
176
177 DynamicString value(ta);
178 sjson::parse_string(value, args[2]);
179 const f32 scale = sjson::parse_float(value.c_str());
180 if (scale < 0.0f) {
181 cs.error(client_id, "Physics scale must be >= 0");
182 return;
183 }
184 _debug_scale = scale;
185 return;
186 }
187
188 if (subcmd == "show" || subcmd == "hide") {
189 if (array::size(args) != 3) {
190 cs.error(client_id, "Usage: physics <show|hide> <PARAMETER>");
191 return;
192 }

Callers

nothing calls this directly

Calls 9

parameter_flagFunction · 0.85
command_helpFunction · 0.70
sizeFunction · 0.50
parse_stringFunction · 0.50
strncasecmpFunction · 0.50
parse_floatFunction · 0.50
errorMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected