Changeset View
Standalone View
source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp
Show First 20 Lines • Show All 512 Lines • ▼ Show 20 Lines | void Do() | ||||
// Opposite direction offset, as we move the destination onto the source, not the source into the destination. | // Opposite direction offset, as we move the destination onto the source, not the source into the destination. | ||||
const int mapCenterX = (m_OldPatches / 2 - m_OffsetX) * PATCH_SIZE * TERRAIN_TILE_SIZE; | const int mapCenterX = (m_OldPatches / 2 - m_OffsetX) * PATCH_SIZE * TERRAIN_TILE_SIZE; | ||||
const int mapCenterZ = (m_OldPatches / 2 - m_OffsetY) * PATCH_SIZE * TERRAIN_TILE_SIZE; | const int mapCenterZ = (m_OldPatches / 2 - m_OffsetY) * PATCH_SIZE * TERRAIN_TILE_SIZE; | ||||
// The offset to move units by is opposite the direction the map is moved, and from the corner. | // The offset to move units by is opposite the direction the map is moved, and from the corner. | ||||
const int offsetX = ((m_NewPatches - m_OldPatches) / 2 + m_OffsetX) * PATCH_SIZE * TERRAIN_TILE_SIZE; | const int offsetX = ((m_NewPatches - m_OldPatches) / 2 + m_OffsetX) * PATCH_SIZE * TERRAIN_TILE_SIZE; | ||||
const int offsetZ = ((m_NewPatches - m_OldPatches) / 2 + m_OffsetY) * PATCH_SIZE * TERRAIN_TILE_SIZE; | const int offsetZ = ((m_NewPatches - m_OldPatches) / 2 + m_OffsetY) * PATCH_SIZE * TERRAIN_TILE_SIZE; | ||||
const CFixedVector3D offset = CFixedVector3D(fixed::FromInt(offsetX), fixed::FromInt(0), fixed::FromInt(offsetZ)); | const CFixedVector3D offset = CFixedVector3D(fixed::FromInt(offsetX), fixed::FromInt(0), fixed::FromInt(offsetZ)); | ||||
const CSimulation2::InterfaceListUnordered& ents = sim.GetEntitiesWithInterfaceUnordered(IID_Selectable); | SComponentDataGenerator ents = sim.GetEntitiesWithInterfaceUnordered(IID_Selectable); | ||||
for (const std::pair<const entity_id_t, IComponent*>& ent : ents) | while (IComponent* cmp = ents.Next()) | ||||
Stan: wrong indent? Can it be made iterable like a range loop? | |||||
Done Inline ActionsFixed the indentation, sorry about wasting your time with all that, ill try to do better in the future. I think in order to use ranged based loop syntax the generator would have to be rewritten as an iterator. I didn't do it that way because I suspect the result would be about 10% slower and 5 times as many lines of code. But we could try it and see. My opinion is that low level code should be written in C because C is a good language for the task and taking a simple C algorithm and contorting it into compatibility with STL is only worth doing if you are using the functionality of STL. Mercury: Fixed the indentation, sorry about wasting your time with all that, ill try to do better in the… | |||||
Done Inline ActionsMy experience with low level C code and 0 A.D. isn't that great ^^ Lots of heated discussions weird bugs and stuff. So when we can use the STL it's nice to do so :) But I understand if it's not possible Stan: My experience with low level C code and 0 A.D. isn't that great ^^ Lots of heated discussions… | |||||
Not Done Inline ActionsOk, Ill try to make a more STLified alternative patch. Mercury: Ok, Ill try to make a more STLified alternative patch. | |||||
{ | { | ||||
const entity_id_t entityId = ent.first; | const entity_id_t entityId = cmp->GetEntityId(); | ||||
CmpPtr<ICmpPosition> cmpPosition(sim, entityId); | CmpPtr<ICmpPosition> cmpPosition(sim, entityId); | ||||
if (cmpPosition && cmpPosition->IsInWorld() && Within(cmpPosition->GetPosition(), mapCenterX, mapCenterZ, radiusInTerrainUnits)) | if (cmpPosition && cmpPosition->IsInWorld() && Within(cmpPosition->GetPosition(), mapCenterX, mapCenterZ, radiusInTerrainUnits)) | ||||
{ | { | ||||
CFixedVector3D position = cmpPosition->GetPosition(); | CFixedVector3D position = cmpPosition->GetPosition(); | ||||
m_NewPositions.emplace_back(entityId, position + offset); | m_NewPositions.emplace_back(entityId, position + offset); | ||||
m_OldPositions.emplace_back(entityId, position); | m_OldPositions.emplace_back(entityId, position); | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |
wrong indent? Can it be made iterable like a range loop?