MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / AddEntity

Function AddEntity

src/Protocol.c:209–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208static void Classic_ReadAbsoluteLocation(cc_uint8* data, EntityID id, cc_uint8 flags);
209static void AddEntity(cc_uint8* data, EntityID id, const cc_string* name, const cc_string* skin, cc_bool readPosition) {
210 struct LocalPlayer* p = Entities.CurPlayer;
211 struct Entity* e;
212
213 if (id != ENTITIES_SELF_ID) {
214 Entities_Remove(id);
215 e = &NetPlayers_List[id].Base;
216
217 NetPlayer_Init((struct NetPlayer*)e);
218 Entities.List[id] = e;
219 Event_RaiseInt(&EntityEvents.Added, id);
220 } else {
221 e = &Entities.CurPlayer->Base;
222 }
223 Entity_SetSkin(e, skin);
224 Entity_SetName(e, name);
225
226 if (!readPosition) return;
227 Classic_ReadAbsoluteLocation(data, id,
228 LU_HAS_POS | LU_HAS_YAW | LU_HAS_PITCH | LU_POS_ABSOLUTE_INSTANT);
229 if (id != ENTITIES_SELF_ID) return;
230
231 p->Spawn = p->Base.Position;
232 p->SpawnYaw = p->Base.Yaw;
233 p->SpawnPitch = p->Base.Pitch;
234}
235
236static void UpdateLocation(EntityID id, struct LocationUpdate* update) {
237 struct Entity* e = Entities.List[id];

Callers 3

Classic_AddEntityFunction · 0.85
CPE_ExtAddEntityFunction · 0.85
CPE_ExtAddEntity2Function · 0.85

Calls 6

Entities_RemoveFunction · 0.85
NetPlayer_InitFunction · 0.85
Event_RaiseIntFunction · 0.85
Entity_SetSkinFunction · 0.85
Entity_SetNameFunction · 0.85

Tested by

no test coverage detected