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

Function MultiDoRequestToMove

Descent3/multi.cpp:8979–9059  ·  view source on GitHub ↗

Client is asking permission to move

Source from the content-addressed store, hash-verified

8977float Last_update_time[MAX_PLAYERS];
8978// Client is asking permission to move
8979void MultiDoRequestToMove(uint8_t *data) {
8980 MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER);
8981
8982 int count = 0;
8983 SKIP_HEADER(data, &count);
8984
8985 vector thrust, rotthrust, pos;
8986 matrix orient;
8987
8988 int slot = MultiGetByte(data, &count);
8989 object *obj = &Objects[Players[slot].objnum];
8990
8991 float timestamp = MultiGetFloat(data, &count);
8992
8993 if (timestamp < NetPlayers[slot].packet_time)
8994 return; // Got out of order packet
8995
8996 if (Players[slot].flags & (PLAYER_FLAGS_DEAD | PLAYER_FLAGS_DYING))
8997 return;
8998
8999 // Get pos
9000 // memcpy (&pos,&data[count],sizeof(vector));
9001 // count+=sizeof(vector);
9002 pos = MultiGetVector(data, &count);
9003
9004 // Get thrust
9005 // memcpy (&thrust,&data[count],sizeof(vector));
9006 // count+=sizeof(vector);
9007 thrust = MultiGetVector(data, &count);
9008
9009 // Get rotational thrust
9010 // memcpy (&rotthrust,&data[count],sizeof(vector));
9011 // count+=sizeof(vector);
9012 rotthrust = MultiGetVector(data, &count);
9013
9014 // Get orientation
9015 uint16_t p = MultiGetShort(data, &count);
9016 uint16_t h = MultiGetShort(data, &count);
9017 uint16_t b = MultiGetShort(data, &count);
9018
9019 vm_AnglesToMatrix(&orient, p, h, b);
9020
9021 float delta_time = Gametime - NetPlayers[slot].packet_time;
9022 NetPlayers[slot].packet_time = Gametime;
9023
9024 obj->mtype.phys_info.thrust = thrust;
9025 obj->mtype.phys_info.rotthrust = rotthrust;
9026
9027 // Perform autonomous movement
9028 float save_frametime = Frametime;
9029
9030 obj->movement_type = MT_PHYSICS;
9031 obj->mtype.phys_info.flags |= PF_USES_THRUST;
9032 obj->mtype.phys_info.flags &= ~PF_FIXED_VELOCITY;
9033
9034 obj->mtype.phys_info.thrust = thrust;
9035 obj->mtype.phys_info.rotthrust = rotthrust;
9036 Frametime = delta_time;

Callers 1

MultiProcessDataFunction · 0.85

Calls 9

SKIP_HEADERFunction · 0.85
MultiGetByteFunction · 0.85
MultiGetFloatFunction · 0.85
MultiGetVectorFunction · 0.85
MultiGetShortFunction · 0.85
do_physics_simFunction · 0.85
MultiSendAdjustPositionFunction · 0.85
vm_AnglesToMatrixFunction · 0.50
vm_VectorDistanceFunction · 0.50

Tested by

no test coverage detected