MCPcopy Create free account
hub / github.com/demoth/jake2 / SendCmd

Method SendCmd

client/src/main/java/jake2/client/CL_input.java:403–467  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

401 * ================= CL_SendCmd =================
402 */
403 static void SendCmd() {
404
405 // build a command even if not connected
406
407 // save this command off for prediction
408 int cmdIndex = ClientGlobals.cls.netchan.outgoing_sequence & (Defines.CMD_BACKUP - 1);
409 usercmd_t cmd = ClientGlobals.cl.cmds[cmdIndex];
410 ClientGlobals.cl.cmd_time[cmdIndex] = (int) ClientGlobals.cls.realtime; // for netgraph
411 // ping calculation
412
413 // fill the cmd
414 CreateCmd(cmd);
415
416 ClientGlobals.cl.cmd.set(cmd);
417
418 if (ClientGlobals.cls.state == Defines.ca_disconnected || ClientGlobals.cls.state == Defines.ca_connecting)
419 return;
420
421 if (ClientGlobals.cls.state == Defines.ca_connected) {
422 if (ClientGlobals.cls.netchan.reliablePending.size() != 0 || Globals.curtime - ClientGlobals.cls.netchan.last_sent > 1000)
423 ClientGlobals.cls.netchan.transmit(null);
424 return;
425 }
426
427 // send a userinfo update if needed
428 if (Globals.userinfo_modified) {
429 CL.FixUpGender();
430 Globals.userinfo_modified = false;
431 ClientGlobals.cls.netchan.reliablePending.add(new UserInfoMessage(Cvar.getInstance().Userinfo()));
432 }
433
434
435 if (cmd.buttons != 0 && ClientGlobals.cl.cinematictime > 0
436 && !ClientGlobals.cl.attractloop
437 && ClientGlobals.cls.realtime - ClientGlobals.cl.cinematictime > 1000) {
438 // skip the rest of the cinematic
439 SCR.nextServerCommand();
440 }
441
442 // let the server know what the last frame we
443 // got was, so the next message can be delta compressed
444 boolean noCompress = cl_nodelta.value != 0.0f || !ClientGlobals.cl.frame.valid || ClientGlobals.cls.demowaiting;
445
446 // Send 3 latest commands with compression
447 int oldestCmdIndex = (ClientGlobals.cls.netchan.outgoing_sequence - 2) & (Defines.CMD_BACKUP - 1);
448 usercmd_t oldestCmd = ClientGlobals.cl.cmds[oldestCmdIndex];
449
450 int oldCmdIndex = (ClientGlobals.cls.netchan.outgoing_sequence - 1) & (Defines.CMD_BACKUP - 1);
451 usercmd_t oldCmd = ClientGlobals.cl.cmds[oldCmdIndex];
452
453 int latestCmdIndex = ClientGlobals.cls.netchan.outgoing_sequence & (Defines.CMD_BACKUP - 1);
454 usercmd_t latestCmd = ClientGlobals.cl.cmds[latestCmdIndex];
455
456 //
457 // deliver the message
458 //
459 ClientGlobals.cls.netchan.transmit(List.of(new MoveMessage(
460 noCompress,

Callers 1

SendCommandMethod · 0.95

Calls 9

CreateCmdMethod · 0.95
FixUpGenderMethod · 0.95
getInstanceMethod · 0.95
nextServerCommandMethod · 0.95
sizeMethod · 0.80
transmitMethod · 0.80
UserinfoMethod · 0.80
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected