1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-14 16:53:38 +02:00

Only remove duplicate player entities in scriptclass::hardreset()

Looks like duplicate player entities persisting across rooms is a
semi-useful feature used by some levels. Still, though, it's a bit of a
nuisance to have duplicate player entities persisting across game
sessions. And levels can't rely on this persistence anyway, anyone could
just close the game and re-open it to get rid of the duplicate entities
regardless.
This commit is contained in:
Misa 2020-06-15 16:19:25 -07:00 committed by Ethan Lee
parent a8cedd2f91
commit 9a8dc4b6ff
2 changed files with 15 additions and 6 deletions

View File

@ -855,13 +855,11 @@ void mapclass::gotoroom(int rx, int ry)
}
}
int theplayer = obj.getplayer();
for (int i = 0; i < (int) obj.entities.size(); i++)
for (size_t i = 0; i < obj.entities.size(); i++)
{
if (i != theplayer)
if (obj.entities[i].rule != 0)
{
removeentity_iter(i);
theplayer--; //just in case indice of player is not 0
}
}

View File

@ -3628,8 +3628,19 @@ void scriptclass::hardreset()
obj.customcollect.resize(100);
i = 100; //previously a for-loop iterating over collect/customcollect set this to 100
if (obj.getplayer() > -1){
obj.entities[obj.getplayer()].tile = 0;
int theplayer = obj.getplayer();
if (theplayer > -1){
obj.entities[theplayer].tile = 0;
}
// Remove duplicate player entities
for (int i = 0; i < (int) obj.entities.size(); i++)
{
if (i != theplayer)
{
removeentity_iter(i);
theplayer--; // just in case indice of player is not 0
}
}
//Script Stuff