mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
Fix portal cache key to use chunk coordinates
This commit is contained in:
parent
1036b7368e
commit
0631aefec2
|
|
@ -93,7 +93,7 @@ bool PortalForcer::findPortal(shared_ptr<Entity> e, double xOriginal, double yOr
|
||||||
int xc = Mth::floor(e->x);
|
int xc = Mth::floor(e->x);
|
||||||
int zc = Mth::floor(e->z);
|
int zc = Mth::floor(e->z);
|
||||||
|
|
||||||
long hash = ChunkPos::hashCode(xc, zc);
|
long hash = ChunkPos::hashCode(xc >> 4, zc >> 4);
|
||||||
bool updateCache = true;
|
bool updateCache = true;
|
||||||
|
|
||||||
auto it = cachedPortals.find(hash);
|
auto it = cachedPortals.find(hash);
|
||||||
|
|
@ -148,8 +148,17 @@ bool PortalForcer::findPortal(shared_ptr<Entity> e, double xOriginal, double yOr
|
||||||
|
|
||||||
if (updateCache)
|
if (updateCache)
|
||||||
{
|
{
|
||||||
cachedPortals[hash] = new PortalPosition(x, y, z, level->getGameTime());
|
auto existing = cachedPortals.find(hash);
|
||||||
cachedPortalKeys.push_back(hash);
|
if (existing != cachedPortals.end())
|
||||||
|
{
|
||||||
|
delete existing->second;
|
||||||
|
existing->second = new PortalPosition(x, y, z, level->getGameTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cachedPortals[hash] = new PortalPosition(x, y, z, level->getGameTime());
|
||||||
|
cachedPortalKeys.push_back(hash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double xt = x + 0.5;
|
double xt = x + 0.5;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue