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

Function MultiDoRobotPos

Descent3/multi.cpp:3241–3291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3239}
3240
3241void MultiDoRobotPos(uint8_t *data) {
3242 int count = 0;
3243 //@@multi_orientation multi_mat;
3244 // Skip header stuff
3245 SKIP_HEADER(data, &count);
3246
3247 uint16_t server_objnum = MultiGetUshort(data, &count);
3248 uint16_t objectnum = Server_object_list[server_objnum];
3249 if (objectnum == 65535 || !(Objects[objectnum].flags & OF_SERVER_OBJECT)) {
3250 mprintf(0, "Bad robotposition object number!\n");
3251 return;
3252 }
3253 object *obj = &Objects[objectnum];
3254
3255 vector pos;
3256 matrix orient;
3257 uint16_t short_roomnum;
3258 int roomnum;
3259
3260 // Get position
3261 MultiExtractPositionData(&pos, data, &count);
3262
3263 // Get orientation
3264 uint16_t p = MultiGetShort(data, &count);
3265 uint16_t h = MultiGetShort(data, &count);
3266 uint16_t b = MultiGetShort(data, &count);
3267
3268 vm_AnglesToMatrix(&orient, p, h, b);
3269
3270 // Get room and terrain flag
3271 short_roomnum = MultiGetUshort(data, &count);
3272 uint8_t terrain = MultiGetByte(data, &count);
3273
3274 roomnum = short_roomnum;
3275 if (terrain)
3276 roomnum = MAKE_ROOMNUM(roomnum);
3277 vector vel = {0, 0, 0};
3278
3279 // Get velocity
3280 vel.x = ((float)MultiGetShort(data, &count)) / 128.0;
3281 vel.y = ((float)MultiGetShort(data, &count)) / 128.0;
3282 vel.z = ((float)MultiGetShort(data, &count)) / 128.0;
3283 obj->mtype.phys_info.velocity = vel;
3284
3285 obj->mtype.phys_info.flags &= ~PF_NO_COLLIDE;
3286 obj->render_type = RT_POLYOBJ;
3287
3288 if (!(obj->flags & (OF_DEAD)) && obj->type != OBJ_NONE) {
3289 ObjSetPos(obj, &pos, roomnum, &orient, false);
3290 }
3291}
3292
3293// Stuffs a players firing information into a packet
3294int MultiStuffPlayerFire(int slot, uint8_t *data) {

Callers 1

MultiProcessDataFunction · 0.85

Calls 7

SKIP_HEADERFunction · 0.85
MultiGetUshortFunction · 0.85
MultiExtractPositionDataFunction · 0.85
MultiGetShortFunction · 0.85
MultiGetByteFunction · 0.85
ObjSetPosFunction · 0.85
vm_AnglesToMatrixFunction · 0.50

Tested by

no test coverage detected