MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / Remote_ServerProcess

Function Remote_ServerProcess

netgames/dmfc/dmfcremote.cpp:336–398  ·  view source on GitHub ↗

handles a remote command (server side)

Source from the content-addressed store, hash-verified

334
335// handles a remote command (server side)
336void Remote_ServerProcess(int precnum, char *command) {
337 if (basethis->GetLocalRole() != LR_SERVER)
338 return;
339 if (precnum < 0 || precnum >= MAX_PLAYER_RECORDS)
340 return;
341 if (!Use_remote_admin)
342 return;
343
344 if (!Authorized_players[precnum].authorized) {
345 // check to see if the player is trying to login
346 int loginlen = strlen("login ");
347 if (!strnicmp(command, "login ", loginlen)) {
348 char *ptr = &command[loginlen - 1];
349 while (*ptr == ' ')
350 ptr++;
351 if (Remote_Login(precnum, ptr)) {
352 // successful login
353 player_record *pr = PRec_GetPRecord(precnum);
354 DLLAddColoredHUDMessage(GR_RGB(200, 200, 40), DTXT_HUDMSGLOGGEDIN, pr->callsign);
355 Remote_SendStringToClient(pr->pnum, "LOGINSUCCESS");
356 Remote_SendMessage(pr->pnum, DTXT_REMOTELOGGEDIN);
357 }
358 return;
359 }
360 }
361
362 player_record *pr = PRec_GetPRecord(precnum);
363
364 // check to see if they are logging out
365 if (!stricmp(command, "logout")) {
366 // log the player out
367 Remote_Logout(precnum);
368 return;
369 }
370
371 // process the command
372 if (command[0] == '$') {
373 switch (FilterNonRemoteCommands(command)) {
374 case 1: {
375 DLLAddColoredHUDMessage(GR_RGB(200, 200, 40), DTXT_REMOTEEXECUTE, pr->callsign, command);
376
377 if (basethis->InputCommandHandle(command)) {
378 // command handled
379 Remote_SendMessage(pr->pnum, DTXT_REMOTESUCCESS);
380 } else {
381 // command not handled
382 Remote_SendMessage(pr->pnum, DTXT_REMOTENOTSUCCESS);
383 }
384 } break;
385 case 0: {
386 // command not handled
387 Remote_SendMessage(pr->pnum, DTXT_REMOTENOTALLOWED);
388 } break;
389 default: {
390 // command not handled
391 Remote_SendMessage(pr->pnum, DTXT_REMOTENOTFOUND);
392 } break;
393 }

Callers 1

Calls 9

Remote_LoginFunction · 0.85
PRec_GetPRecordFunction · 0.85
Remote_SendMessageFunction · 0.85
Remote_LogoutFunction · 0.85
FilterNonRemoteCommandsFunction · 0.85
GetLocalRoleMethod · 0.80
InputCommandHandleMethod · 0.80
GR_RGBFunction · 0.50

Tested by

no test coverage detected