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

Function MultiDoObject

Descent3/multi.cpp:5162–5345  ·  view source on GitHub ↗

Server is telling us to create an object

Source from the content-addressed store, hash-verified

5160
5161// Server is telling us to create an object
5162void MultiDoObject(uint8_t *data) {
5163 int count = 0;
5164 int parent_handle;
5165 bool self_parent = false;
5166
5167 SKIP_HEADER(data, &count);
5168
5169 // Extract info about this object
5170 uint8_t announce = MultiGetByte(data, &count);
5171 int server_objnum = MultiGetUshort(data, &count);
5172 int parent_objnum = MultiGetUshort(data, &count);
5173
5174 if (parent_objnum == server_objnum)
5175 self_parent = true;
5176/*
5177 mprintf(0,"MultiDoObject() got a new object. Server's objnum = %d Parent objnum = %d\n",
5178 server_objnum,
5179 parent_objnum);
5180 */
5181 if (self_parent || parent_objnum == 65535)
5182 parent_handle = OBJECT_HANDLE_NONE;
5183 else {
5184 int local_parent = Server_object_list[parent_objnum];
5185
5186 if (local_parent == 65535) // || !(Objects[local_parent].flags2 & OF2_SERVER_OBJECT))
5187 {
5188 MULTI_ASSERT(1, "Invalid parent for object!");
5189 return;
5190 }
5191
5192 parent_handle = Objects[local_parent].handle;
5193 }
5194
5195 uint8_t type = MultiGetByte(data, &count);
5196 uint32_t checksum = MultiGetUint(data, &count);
5197 uint8_t dummy_type = OBJ_NONE;
5198 if (type == OBJ_DUMMY) // we need to get the original type
5199 dummy_type = MultiGetByte(data, &count);
5200
5201 /*char name[255];
5202 uint8_t len=MultiGetByte (data,&count);
5203 memcpy (name,&data[count],len);*/
5204
5205 int id;
5206 if (type == OBJ_WEAPON)
5207 id = MultiMatchWeapon(checksum);
5208 else if (type == OBJ_MARKER)
5209 id = checksum;
5210 else
5211 id = MultiMatchGeneric(checksum);
5212
5213 if (id == -1) {
5214 mprintf(0, "Server data doesn't match!\n");
5215 MULTI_ASSERT(id != -1, "Server data doesn't match!");
5216
5217 if (type == OBJ_WEAPON)
5218 MultiMatchWeapon(checksum);
5219 else if (type != OBJ_MARKER)

Callers 1

MultiProcessDataFunction · 0.85

Calls 15

SKIP_HEADERFunction · 0.85
MultiGetByteFunction · 0.85
MultiGetUshortFunction · 0.85
MultiGetUintFunction · 0.85
MultiMatchWeaponFunction · 0.85
MultiMatchGenericFunction · 0.85
BailOnMultiplayerFunction · 0.85
MultiGetVectorFunction · 0.85
MultiGetShortFunction · 0.85
MultiGetUbyteFunction · 0.85
ObjCreateFunction · 0.85
ObjGhostObjectFunction · 0.85

Tested by

no test coverage detected