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

Function MultiDoPlayerPos

Descent3/multi.cpp:3061–3239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3059}
3060
3061void MultiDoPlayerPos(uint8_t *data) {
3062 int use_smoothing = (Netgame.flags & NF_USE_SMOOTHING);
3063 int count = 0;
3064
3065 // Skip header stuff
3066 SKIP_HEADER(data, &count);
3067
3068 uint8_t slot = MultiGetByte(data, &count);
3069
3070 // Make sure its not out of order
3071 float packet_time = MultiGetFloat(data, &count);
3072 if (packet_time < NetPlayers[slot].packet_time)
3073 return;
3074 NetPlayers[slot].packet_time = packet_time;
3075
3076 object *obj = &Objects[Players[slot].objnum];
3077
3078 vector pos;
3079 matrix orient;
3080 uint16_t short_roomnum;
3081 int roomnum;
3082
3083 // Get position
3084 MultiExtractPositionData(&pos, data, &count);
3085
3086 // Get orientation
3087 uint16_t p = MultiGetShort(data, &count);
3088 uint16_t h = MultiGetShort(data, &count);
3089 uint16_t b = MultiGetShort(data, &count);
3090
3091 vm_AnglesToMatrix(&orient, p, h, b);
3092
3093 // Get room and terrain flag
3094 short_roomnum = MultiGetUshort(data, &count);
3095
3096 roomnum = short_roomnum;
3097
3098 vector vel = {0, 0, 0}, rotvel;
3099 angle turnroll;
3100
3101 // float dist=vm_VectorDistance (&pos,&obj->pos);
3102
3103 // Get velocity
3104 vel.x = ((float)MultiGetShort(data, &count)) / 128.0;
3105 vel.y = ((float)MultiGetShort(data, &count)) / 128.0;
3106 vel.z = ((float)MultiGetShort(data, &count)) / 128.0;
3107
3108 // mprintf(0,"INCOMING x=%f y=%f z=%f dist=%f\n",vel.x,vel.y,vel.z,dist);
3109
3110 // Get rotational velocity
3111 if (Netgame.flags & NF_SENDROTVEL) {
3112 rotvel.x = MultiGetShort(data, &count) * 4;
3113 rotvel.y = MultiGetShort(data, &count) * 4;
3114 rotvel.z = MultiGetShort(data, &count) * 4;
3115
3116 turnroll = MultiGetShort(data, &count);
3117
3118 obj->mtype.phys_info.rotvel = rotvel;

Callers 1

MultiProcessDataFunction · 0.85

Calls 11

SKIP_HEADERFunction · 0.85
MultiGetByteFunction · 0.85
MultiGetFloatFunction · 0.85
MultiExtractPositionDataFunction · 0.85
MultiGetShortFunction · 0.85
MultiGetUshortFunction · 0.85
MultiGetUbyteFunction · 0.85
ObjSetPosFunction · 0.85
vm_AnglesToMatrixFunction · 0.50
vm_VectorDistanceFunction · 0.50

Tested by

no test coverage detected