mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-29 08:32:14 -04:00
Core: Fix very rare ZS crash when a player had been added twice to the infected or alive list.
This commit is contained in:
parent
ed0767b1a7
commit
6325e256f2
@ -192,7 +192,7 @@ namespace MCGalaxy.Games {
|
|||||||
aliveList = Alive.Items;
|
aliveList = Alive.Items;
|
||||||
|
|
||||||
foreach (Player alive in aliveList) {
|
foreach (Player alive in aliveList) {
|
||||||
if (alive == null || alive == dead) continue;
|
if (alive == dead) continue;
|
||||||
UpdatePlayerColor(alive, alive.color);
|
UpdatePlayerColor(alive, alive.color);
|
||||||
int dx = Math.Abs(alive.pos[0] - dead.pos[0]);
|
int dx = Math.Abs(alive.pos[0] - dead.pos[0]);
|
||||||
int dy = Math.Abs(alive.pos[1] - dead.pos[1]);
|
int dy = Math.Abs(alive.pos[1] - dead.pos[1]);
|
||||||
|
@ -59,14 +59,24 @@ namespace MCGalaxy {
|
|||||||
if (Items.Length == 0) return;
|
if (Items.Length == 0) return;
|
||||||
|
|
||||||
T[] newItems = new T[Items.Length - 1];
|
T[] newItems = new T[Items.Length - 1];
|
||||||
for (int i = 0, j = 0; i < Items.Length; i++) {
|
int j = 0;
|
||||||
|
for (int i = 0; i < Items.Length; i++) {
|
||||||
if (object.ReferenceEquals(Items[i], value)) continue;
|
if (object.ReferenceEquals(Items[i], value)) continue;
|
||||||
|
|
||||||
// For some reason item wasn't in the list
|
// For some reason item wasn't in the list
|
||||||
if (j == newItems.Length) return;
|
if (j == newItems.Length) return;
|
||||||
newItems[j] = Items[i]; j++;
|
newItems[j] = Items[i]; j++;
|
||||||
}
|
}
|
||||||
Items = newItems;
|
|
||||||
|
// Handle very rare case when an item has been added twice
|
||||||
|
if (newItems.Length != j) {
|
||||||
|
T[] temp = new T[j];
|
||||||
|
for (int i = 0; i < temp.Length; i++)
|
||||||
|
temp[i] = newItems[i];
|
||||||
|
Items = temp;
|
||||||
|
} else {
|
||||||
|
Items = newItems;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user