mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -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) {
|
void Entities_Remove(EntityID id) {
|
||||||
|
struct Entity* e = Entities.List[id];
|
||||||
|
if (!e) return;
|
||||||
|
|
||||||
Event_RaiseInt(&EntityEvents.Removed, id);
|
Event_RaiseInt(&EntityEvents.Removed, id);
|
||||||
Entities.List[id]->VTABLE->Despawn(Entities.List[id]);
|
e->VTABLE->Despawn(e);
|
||||||
Entities.List[id] = NULL;
|
Entities.List[id] = NULL;
|
||||||
|
|
||||||
/* TODO: Move to EntityEvents.Removed callback instead */
|
/* TODO: Move to EntityEvents.Removed callback instead */
|
||||||
@ -1207,8 +1210,8 @@ static void Entities_Init(void) {
|
|||||||
|
|
||||||
static void Entities_Free(void) {
|
static void Entities_Free(void) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ENTITIES_MAX_COUNT; i++) {
|
for (i = 0; i < ENTITIES_MAX_COUNT; i++)
|
||||||
if (!Entities.List[i]) continue;
|
{
|
||||||
Entities_Remove((EntityID)i);
|
Entities_Remove((EntityID)i);
|
||||||
}
|
}
|
||||||
Gfx_DeleteTexture(&ShadowComponent_ShadowTex);
|
Gfx_DeleteTexture(&ShadowComponent_ShadowTex);
|
||||||
|
@ -197,7 +197,7 @@ static void AddEntity(cc_uint8* data, EntityID id, const cc_string* name, const
|
|||||||
struct Entity* e;
|
struct Entity* e;
|
||||||
|
|
||||||
if (id != ENTITIES_SELF_ID) {
|
if (id != ENTITIES_SELF_ID) {
|
||||||
if (Entities.List[id]) Entities_Remove(id);
|
Entities_Remove(id);
|
||||||
e = &NetPlayers_List[id].Base;
|
e = &NetPlayers_List[id].Base;
|
||||||
|
|
||||||
NetPlayer_Init((struct NetPlayer*)e);
|
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;
|
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) {
|
static void UpdateLocation(EntityID id, struct LocationUpdate* update) {
|
||||||
struct Entity* e = Entities.List[id];
|
struct Entity* e = Entities.List[id];
|
||||||
if (e) { e->VTABLE->SetLocation(e, update); }
|
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) {
|
static void Classic_RemoveEntity(cc_uint8* data) {
|
||||||
EntityID id = data[0];
|
EntityID id = data[0];
|
||||||
Protocol_RemoveEntity(id);
|
if (id != ENTITIES_SELF_ID) Entities_Remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Classic_Message(cc_uint8* data) {
|
static void Classic_Message(cc_uint8* data) {
|
||||||
@ -942,7 +935,7 @@ static void CPE_SendCpeExtInfoReply(void) {
|
|||||||
{
|
{
|
||||||
ext = cpe_clientExtensions[i];
|
ext = cpe_clientExtensions[i];
|
||||||
name = String_FromReadonly(ext->name);
|
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 */
|
/* Don't reply with version higher than what server supports to workaround some buggy server software */
|
||||||
|
|
||||||
if (!Game_AllowCustomBlocks) {
|
if (!Game_AllowCustomBlocks) {
|
||||||
|
@ -61,7 +61,6 @@ struct RayTracer;
|
|||||||
struct IGameComponent;
|
struct IGameComponent;
|
||||||
extern struct IGameComponent Protocol_Component;
|
extern struct IGameComponent Protocol_Component;
|
||||||
|
|
||||||
void Protocol_RemoveEntity(EntityID id);
|
|
||||||
void Protocol_Tick(void);
|
void Protocol_Tick(void);
|
||||||
|
|
||||||
extern cc_bool cpe_needD3Fix;
|
extern cc_bool cpe_needD3Fix;
|
||||||
|
@ -461,8 +461,9 @@ static void OnNewMap(void) {
|
|||||||
if (Server.IsSinglePlayer) return;
|
if (Server.IsSinglePlayer) return;
|
||||||
|
|
||||||
/* wipe all existing entities */
|
/* wipe all existing entities */
|
||||||
for (i = 0; i < ENTITIES_MAX_COUNT; i++) {
|
for (i = 0; i < ENTITIES_SELF_ID; i++)
|
||||||
Protocol_RemoveEntity((EntityID)i);
|
{
|
||||||
|
Entities_Remove((EntityID)i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user