mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-25 17:53:47 +00:00
Give script-spawned entities a negative ID.
This should prevent most ID conflicts and problems related to that, e.g. spurious changes to entity positions while working on a map.
This commit is contained in:
parent
d8da8576e8
commit
f55a70b459
5 changed files with 7 additions and 42 deletions
|
@ -220,7 +220,6 @@ Entity::Entity()
|
|||
//energyChargeTarget = energyShotTarget = true;
|
||||
deathSound = "GenericDeath";
|
||||
entityID = 0;
|
||||
//assignUniqueID();
|
||||
hair = 0;
|
||||
maxSpeedLerp = 1;
|
||||
fillGridFromQuad = false;
|
||||
|
@ -1141,17 +1140,6 @@ void Entity::frozenUpdate(float dt)
|
|||
|
||||
void Entity::update(float dt)
|
||||
{
|
||||
/*
|
||||
if (position.isnan())
|
||||
position = backupPos;
|
||||
if (vel.isnan())
|
||||
vel = backupVel;
|
||||
*/
|
||||
/*
|
||||
if (entityID == 0)
|
||||
assignUniqueID();
|
||||
*/
|
||||
|
||||
Vector backupPos = position;
|
||||
Vector backupVel = vel;
|
||||
|
||||
|
@ -2956,9 +2944,10 @@ void Entity::fillGrid()
|
|||
}
|
||||
}
|
||||
|
||||
void Entity::assignUniqueID()
|
||||
void Entity::assignUniqueID(bool temporary)
|
||||
{
|
||||
int id = 1;
|
||||
const int inc = temporary ? -1 : 1;
|
||||
int id = inc;
|
||||
while (1)
|
||||
{
|
||||
bool isFree = true;
|
||||
|
@ -2978,7 +2967,7 @@ void Entity::assignUniqueID()
|
|||
{
|
||||
break;
|
||||
}
|
||||
id++;
|
||||
id += inc;
|
||||
}
|
||||
entityID = id;
|
||||
}
|
||||
|
@ -2996,7 +2985,7 @@ void Entity::setID(int id)
|
|||
std::ostringstream os;
|
||||
os << "ID conflict between " << name << " and " << e->name;
|
||||
debugLog(os.str());
|
||||
e->assignUniqueID();
|
||||
e->assignUniqueID(e->getID() < 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -395,7 +395,7 @@ public:
|
|||
InterpolatedVector maxSpeedLerp;
|
||||
Hair *hair;
|
||||
|
||||
void assignUniqueID();
|
||||
void assignUniqueID(bool temporary);
|
||||
int entityID;
|
||||
int getMaxSpeed();
|
||||
std::string deathSound;
|
||||
|
|
|
@ -2659,7 +2659,7 @@ Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool
|
|||
}
|
||||
else
|
||||
{
|
||||
e->assignUniqueID();
|
||||
e->assignUniqueID(!createSaveData); // when entity is placed on map, give positive ID; otherwise, if script-spawned, give negative ID
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2718,19 +2718,6 @@ void Game::initEntities()
|
|||
}
|
||||
}
|
||||
|
||||
void Game::assignEntitiesUniqueIDs()
|
||||
{
|
||||
FOR_ENTITIES(i)
|
||||
{
|
||||
Entity *e = *i;
|
||||
if (e && e->entityID == 0)
|
||||
{
|
||||
e->assignUniqueID();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EntitySaveData *Game::getEntitySaveDataForEntity(Entity *e, Vector pos)
|
||||
{
|
||||
|
||||
|
|
|
@ -465,7 +465,6 @@ public:
|
|||
bool multiSelecting;
|
||||
Vector multiSelectPoint;
|
||||
std::vector <Element*> selectedElements;
|
||||
void fixEntityIDs();
|
||||
|
||||
Vector groupCenter;
|
||||
Vector getSelectedElementsCenter();
|
||||
|
@ -1088,7 +1087,6 @@ protected:
|
|||
Quad *options;
|
||||
|
||||
Quad *image;
|
||||
void assignEntitiesUniqueIDs();
|
||||
void initEntities();
|
||||
|
||||
|
||||
|
|
|
@ -1864,15 +1864,6 @@ void SceneEditor::skinLevel(pngRawInfo *png, int minX, int minY, int maxX, int m
|
|||
}
|
||||
}
|
||||
|
||||
void SceneEditor::fixEntityIDs()
|
||||
{
|
||||
FOR_ENTITIES(i)
|
||||
{
|
||||
Entity *e = *i;
|
||||
e->assignUniqueID();
|
||||
}
|
||||
}
|
||||
|
||||
void SceneEditor::generateLevel()
|
||||
{
|
||||
//pngSetStandardOrientation(0);
|
||||
|
|
Loading…
Reference in a new issue