WIP fixing exiting splitscreen mode breaking

This commit is contained in:
UnknownShadow200 2024-06-27 00:11:26 +10:00
parent 4cb9e200ed
commit 3b0f54bc6a
3 changed files with 9 additions and 6 deletions

View file

@ -483,7 +483,7 @@ static void Entities_ContextLost(void* obj) {
}
/* No OnContextCreated, skin textures remade when needed */
void Entities_Remove(EntityID id) {
void Entities_Remove(int id) {
struct Entity* e = Entities.List[id];
if (!e) return;
@ -492,7 +492,7 @@ void Entities_Remove(EntityID id) {
Entities.List[id] = NULL;
/* TODO: Move to EntityEvents.Removed callback instead */
if (TabList_EntityLinked_Get(id)) {
if (id < TABLIST_MAX_NAMES && TabList_EntityLinked_Get(id)) {
TabList_Remove(id);
TabList_EntityLinked_Reset(id);
}
@ -756,7 +756,6 @@ static void LocalPlayer_Init(struct LocalPlayer* p, int index) {
p->index = index;
hacks->Enabled = !Game_PureClassic && Options_GetBool(OPT_HACKS_ENABLED, true);
/* p->Base.Health = 20; TODO: survival mode stuff */
if (Game_ClassicMode) return;
hacks->SpeedMultiplier = Options_GetFloat(OPT_SPEED_FACTOR, 0.1f, 50.0f, 10.0f);
@ -1087,6 +1086,10 @@ static void Entities_Init(void) {
LocalPlayer_Init(&LocalPlayer_Instances[i], i);
Entities.List[MAX_NET_PLAYERS + i] = &LocalPlayer_Instances[i].Base;
}
for (; i < MAX_LOCAL_PLAYERS; i++)
{
Entities.List[MAX_NET_PLAYERS + i] = NULL;
}
Entities.CurPlayer = &LocalPlayer_Instances[0];
LocalPlayer_HookBinds();
}
@ -1095,7 +1098,7 @@ static void Entities_Free(void) {
int i;
for (i = 0; i < ENTITIES_MAX_COUNT; i++)
{
Entities_Remove((EntityID)i);
Entities_Remove(i);
}
sources_head = NULL;
}

View file

@ -179,7 +179,7 @@ void Entities_Tick(struct ScheduledTask* task);
/* Renders all entities */
void Entities_RenderModels(float delta, float t);
/* Removes the given entity, raising EntityEvents.Removed event */
void Entities_Remove(EntityID id);
void Entities_Remove(int id);
/* Gets the ID of the closest entity to the given entity */
/* Returns -1 if there is no other entity nearby */
int Entities_GetClosest(struct Entity* src);

View file

@ -499,7 +499,7 @@ static void OnNewMap(void) {
/* wipe all existing entities */
for (i = 0; i < MAX_NET_PLAYERS; i++)
{
Entities_Remove((EntityID)i);
Entities_Remove(i);
}
}