mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Get rid of Protocol_RemoveEntity
This commit is contained in:
parent
ebb45d00a2
commit
3124538b94
@ -620,8 +620,11 @@ static void Entities_ChatFontChanged(void* obj) {
|
||||
}
|
||||
|
||||
void Entities_Remove(EntityID id) {
|
||||
struct Entity* e = Entities.List[id];
|
||||
if (!e) return;
|
||||
|
||||
Event_RaiseInt(&EntityEvents.Removed, id);
|
||||
Entities.List[id]->VTABLE->Despawn(Entities.List[id]);
|
||||
e->VTABLE->Despawn(e);
|
||||
Entities.List[id] = NULL;
|
||||
|
||||
/* TODO: Move to EntityEvents.Removed callback instead */
|
||||
@ -1207,8 +1210,8 @@ static void Entities_Init(void) {
|
||||
|
||||
static void Entities_Free(void) {
|
||||
int i;
|
||||
for (i = 0; i < ENTITIES_MAX_COUNT; i++) {
|
||||
if (!Entities.List[i]) continue;
|
||||
for (i = 0; i < ENTITIES_MAX_COUNT; i++)
|
||||
{
|
||||
Entities_Remove((EntityID)i);
|
||||
}
|
||||
Gfx_DeleteTexture(&ShadowComponent_ShadowTex);
|
||||
|
@ -197,7 +197,7 @@ static void AddEntity(cc_uint8* data, EntityID id, const cc_string* name, const
|
||||
struct Entity* e;
|
||||
|
||||
if (id != ENTITIES_SELF_ID) {
|
||||
if (Entities.List[id]) Entities_Remove(id);
|
||||
Entities_Remove(id);
|
||||
e = &NetPlayers_List[id].Base;
|
||||
|
||||
NetPlayer_Init((struct NetPlayer*)e);
|
||||
@ -219,13 +219,6 @@ static void AddEntity(cc_uint8* data, EntityID id, const cc_string* name, const
|
||||
p->SpawnPitch = p->Base.Pitch;
|
||||
}
|
||||
|
||||
void Protocol_RemoveEntity(EntityID id) {
|
||||
struct Entity* e = Entities.List[id];
|
||||
if (!e || id == ENTITIES_SELF_ID) return;
|
||||
|
||||
Entities_Remove(id);
|
||||
}
|
||||
|
||||
static void UpdateLocation(EntityID id, struct LocationUpdate* update) {
|
||||
struct Entity* e = Entities.List[id];
|
||||
if (e) { e->VTABLE->SetLocation(e, update); }
|
||||
@ -711,7 +704,7 @@ static void Classic_OrientationUpdate(cc_uint8* data) {
|
||||
|
||||
static void Classic_RemoveEntity(cc_uint8* data) {
|
||||
EntityID id = data[0];
|
||||
Protocol_RemoveEntity(id);
|
||||
if (id != ENTITIES_SELF_ID) Entities_Remove(id);
|
||||
}
|
||||
|
||||
static void Classic_Message(cc_uint8* data) {
|
||||
@ -942,7 +935,7 @@ static void CPE_SendCpeExtInfoReply(void) {
|
||||
{
|
||||
ext = cpe_clientExtensions[i];
|
||||
name = String_FromReadonly(ext->name);
|
||||
ver = ext->serverVersion;
|
||||
ver = ext->serverVersion ? ext->serverVersion : ext->clientVersion;
|
||||
/* Don't reply with version higher than what server supports to workaround some buggy server software */
|
||||
|
||||
if (!Game_AllowCustomBlocks) {
|
||||
|
@ -61,7 +61,6 @@ struct RayTracer;
|
||||
struct IGameComponent;
|
||||
extern struct IGameComponent Protocol_Component;
|
||||
|
||||
void Protocol_RemoveEntity(EntityID id);
|
||||
void Protocol_Tick(void);
|
||||
|
||||
extern cc_bool cpe_needD3Fix;
|
||||
|
@ -461,8 +461,9 @@ static void OnNewMap(void) {
|
||||
if (Server.IsSinglePlayer) return;
|
||||
|
||||
/* wipe all existing entities */
|
||||
for (i = 0; i < ENTITIES_MAX_COUNT; i++) {
|
||||
Protocol_RemoveEntity((EntityID)i);
|
||||
for (i = 0; i < ENTITIES_SELF_ID; i++)
|
||||
{
|
||||
Entities_Remove((EntityID)i);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user