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;
|
//energyChargeTarget = energyShotTarget = true;
|
||||||
deathSound = "GenericDeath";
|
deathSound = "GenericDeath";
|
||||||
entityID = 0;
|
entityID = 0;
|
||||||
//assignUniqueID();
|
|
||||||
hair = 0;
|
hair = 0;
|
||||||
maxSpeedLerp = 1;
|
maxSpeedLerp = 1;
|
||||||
fillGridFromQuad = false;
|
fillGridFromQuad = false;
|
||||||
|
@ -1141,17 +1140,6 @@ void Entity::frozenUpdate(float dt)
|
||||||
|
|
||||||
void Entity::update(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 backupPos = position;
|
||||||
Vector backupVel = vel;
|
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)
|
while (1)
|
||||||
{
|
{
|
||||||
bool isFree = true;
|
bool isFree = true;
|
||||||
|
@ -2978,7 +2967,7 @@ void Entity::assignUniqueID()
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
id++;
|
id += inc;
|
||||||
}
|
}
|
||||||
entityID = id;
|
entityID = id;
|
||||||
}
|
}
|
||||||
|
@ -2996,7 +2985,7 @@ void Entity::setID(int id)
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "ID conflict between " << name << " and " << e->name;
|
os << "ID conflict between " << name << " and " << e->name;
|
||||||
debugLog(os.str());
|
debugLog(os.str());
|
||||||
e->assignUniqueID();
|
e->assignUniqueID(e->getID() < 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,7 +395,7 @@ public:
|
||||||
InterpolatedVector maxSpeedLerp;
|
InterpolatedVector maxSpeedLerp;
|
||||||
Hair *hair;
|
Hair *hair;
|
||||||
|
|
||||||
void assignUniqueID();
|
void assignUniqueID(bool temporary);
|
||||||
int entityID;
|
int entityID;
|
||||||
int getMaxSpeed();
|
int getMaxSpeed();
|
||||||
std::string deathSound;
|
std::string deathSound;
|
||||||
|
|
|
@ -2659,7 +2659,7 @@ Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool
|
||||||
}
|
}
|
||||||
else
|
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)
|
EntitySaveData *Game::getEntitySaveDataForEntity(Entity *e, Vector pos)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -465,7 +465,6 @@ public:
|
||||||
bool multiSelecting;
|
bool multiSelecting;
|
||||||
Vector multiSelectPoint;
|
Vector multiSelectPoint;
|
||||||
std::vector <Element*> selectedElements;
|
std::vector <Element*> selectedElements;
|
||||||
void fixEntityIDs();
|
|
||||||
|
|
||||||
Vector groupCenter;
|
Vector groupCenter;
|
||||||
Vector getSelectedElementsCenter();
|
Vector getSelectedElementsCenter();
|
||||||
|
@ -1088,7 +1087,6 @@ protected:
|
||||||
Quad *options;
|
Quad *options;
|
||||||
|
|
||||||
Quad *image;
|
Quad *image;
|
||||||
void assignEntitiesUniqueIDs();
|
|
||||||
void initEntities();
|
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()
|
void SceneEditor::generateLevel()
|
||||||
{
|
{
|
||||||
//pngSetStandardOrientation(0);
|
//pngSetStandardOrientation(0);
|
||||||
|
|
Loading…
Reference in a new issue