1
0

Changed int parameters to vector parameters in cCuboid and simulators (#3874)

This commit is contained in:
Lane Kolbly 2017-08-17 08:48:38 -05:00 committed by Mattes D
parent 09e94bd947
commit 7bdbfad1bb
39 changed files with 283 additions and 215 deletions

View File

@ -21,6 +21,12 @@ Here are the conventions:
- `ThisIsAProperFunction()` `This_is_bad()` `this_is_bad()` `GoodVariableName` `badVariableName`.
* All member variables start with `m_`, all function parameters start with `a_`, all class names start with `c`.
- `class cMonster { int m_Health; int DecreaseHealth(int a_Amount); }`
* Function parameters that are coordinates should be passed using an appropriate storage container, and not as three separate arguments.
- e.g. for a block position, Vector3i. For an entity position, Vector3d. For a chunk coordinate, cChunkCoords.
- For a 3-dimensional box of blocks, use cCuboid. For an axis-aligned bounding box, use cBoundingBox.
* Parameters smaller than 4 elements (e.g. Vector3, cChunkCoords) should be passed by value. All other parameters should be passed by const reference, where applicable.
- `Foo(Vector3d a_Param1, const cCuboid & a_Param2)`
- See the discussion in issue #3853
* Put spaces after commas. `Vector3d(1, 2, 3)` instead of `Vector3d(1,2,3)`
* Put spaces before and after every operator.
- `a = b + c;`

View File

@ -3352,6 +3352,17 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
},
},
WakeUpSimulators =
{
{
Params =
{
{
Name = "Block",
Type = "Vector3i",
},
},
Notes = "Wakes up the simulators for the specified block.",
},
{
Params =
{
@ -3368,9 +3379,21 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
Type = "number",
},
},
Notes = "Wakes up the simulators for the specified block.",
Notes = "Wakes up the simulators for the specified block. (DEPRECATED, use vector-parametered version)",
},
},
WakeUpSimulatorsInArea =
{
{
Params =
{
{
Name = "Area",
Type = "cCuboid",
},
},
Notes = "Wakes up the simulators for all the blocks in the specified area (edges inclusive).",
},
{
Params =
{
@ -3399,7 +3422,8 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
Type = "number",
},
},
Notes = "Wakes up the simulators for all the blocks in the specified area (edges inclusive).",
Notes = "Wakes up the simulators for all the blocks in the specified area (edges inclusive). (DEPRECATED, use vector-parametered version)",
},
},
},
AdditionalInfo =

View File

@ -129,14 +129,17 @@ end
-- a_FunctionDoc is a single documentation item for a function, as loaded from ToLua++'s parser
local function functionDescMatchesDocs(a_FunctionDesc, a_FunctionDoc)
-- Check the number of parameters:
local numParams
local numParams = 0
local numOptionalParams = 0
if (not(a_FunctionDesc.Params) or (a_FunctionDesc.Params == "")) then
numParams = 0
else
_, numParams = string.gsub(a_FunctionDesc.Params, ",", "")
for _, Param in pairs(a_FunctionDesc.Params) do
numParams = numParams + 1
_, numOptionalParams = string.gsub(a_FunctionDesc.Params, "%b[]", "")
if Param.IsOptional then
numOptionalParams = numOptionalParams + 1
end
end
end
local numDocParams = #(a_FunctionDoc.Params)
if ((numDocParams > numParams) or (numDocParams < numParams - numOptionalParams)) then

View File

@ -1954,8 +1954,8 @@ void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTY
cCuboid cBlockArea::GetBounds(void) const
{
return cCuboid(
m_Origin.x, m_Origin.y, m_Origin.z,
m_Origin.x + m_Size.x - 1, m_Origin.y + m_Size.y - 1, m_Origin.z + m_Size.z - 1
m_Origin,
m_Origin + m_Size - Vector3i(1, 1, 1)
);
}

View File

@ -34,7 +34,7 @@ public:
Meta |= 0x08;
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta, false);
a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
a_WorldInterface.WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.stone_button.click_on", x, y, z, 0.5f, 0.6f);
// Queue a button reset (unpress)
@ -45,7 +45,7 @@ public:
{
// Block hasn't change in the meantime; set its meta
a_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x07, false);
a_World.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
a_World.WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
a_World.BroadcastSoundEffect("block.stone_button.click_off", x, y, z, 0.5f, 0.5f);
}
}

View File

@ -650,7 +650,7 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
// Wake up the simulators for this block:
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, &a_Chunk);
a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp({BlockX, a_RelY, BlockZ}, &a_Chunk);
}
}

View File

@ -23,7 +23,7 @@ public:
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
a_WorldInterface.WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
a_WorldInterface.WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("block.lever.click", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
return true;
}

View File

@ -159,7 +159,7 @@ public:
// Wake up the simulators for this block:
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, &a_Chunk);
a_Chunk.GetWorld()->GetSimulatorManager()->WakeUp({BlockX, a_RelY, BlockZ}, &a_Chunk);
}
}

View File

@ -74,6 +74,6 @@ public:
virtual int GetHeight(int a_BlockX, int a_BlockZ) = 0;
/** Wakes up the simulators for the specified block */
virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
virtual void WakeUpSimulators(Vector3i a_Block) = 0;
};

View File

@ -19,7 +19,7 @@ cBoundingBox::cBoundingBox(double a_MinX, double a_MaxX, double a_MinY, double a
cBoundingBox::cBoundingBox(const Vector3d & a_Min, const Vector3d & a_Max) :
cBoundingBox::cBoundingBox(Vector3d a_Min, Vector3d a_Max) :
m_Min(a_Min),
m_Max(a_Max)
{
@ -29,7 +29,7 @@ cBoundingBox::cBoundingBox(const Vector3d & a_Min, const Vector3d & a_Max) :
cBoundingBox::cBoundingBox(const Vector3d & a_Pos, double a_Radius, double a_Height) :
cBoundingBox::cBoundingBox(Vector3d a_Pos, double a_Radius, double a_Height) :
m_Min(a_Pos.x - a_Radius, a_Pos.y, a_Pos.z - a_Radius),
m_Max(a_Pos.x + a_Radius, a_Pos.y + a_Height, a_Pos.z + a_Radius)
{
@ -39,7 +39,7 @@ cBoundingBox::cBoundingBox(const Vector3d & a_Pos, double a_Radius, double a_Hei
cBoundingBox::cBoundingBox(const Vector3d & a_Pos, double a_CubeLength) :
cBoundingBox::cBoundingBox(Vector3d a_Pos, double a_CubeLength) :
m_Min(a_Pos.x - a_CubeLength / 2, a_Pos.y - a_CubeLength / 2, a_Pos.z - a_CubeLength / 2),
m_Max(a_Pos.x + a_CubeLength / 2, a_Pos.y + a_CubeLength / 2, a_Pos.z + a_CubeLength / 2)
{
@ -84,7 +84,7 @@ void cBoundingBox::Move(double a_OffX, double a_OffY, double a_OffZ)
void cBoundingBox::Move(const Vector3d & a_Off)
void cBoundingBox::Move(Vector3d a_Off)
{
m_Min.x += a_Off.x;
m_Min.y += a_Off.y;
@ -141,7 +141,7 @@ cBoundingBox cBoundingBox::Union(const cBoundingBox & a_Other)
bool cBoundingBox::IsInside(const Vector3d & a_Point)
bool cBoundingBox::IsInside(Vector3d a_Point)
{
return IsInside(m_Min, m_Max, a_Point);
}
@ -169,7 +169,7 @@ bool cBoundingBox::IsInside(cBoundingBox & a_Other)
bool cBoundingBox::IsInside(const Vector3d & a_Min, const Vector3d & a_Max)
bool cBoundingBox::IsInside(Vector3d a_Min, Vector3d a_Max)
{
// If both coords are inside this, then the entire a_Other is inside
return (IsInside(a_Min) && IsInside(a_Max));
@ -179,7 +179,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Min, const Vector3d & a_Max)
bool cBoundingBox::IsInside(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Point)
bool cBoundingBox::IsInside(Vector3d a_Min, Vector3d a_Max, Vector3d a_Point)
{
return (
((a_Point.x >= a_Min.x) && (a_Point.x <= a_Max.x)) &&
@ -192,7 +192,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Min, const Vector3d & a_Max, cons
bool cBoundingBox::IsInside(const Vector3d & a_Min, const Vector3d & a_Max, double a_X, double a_Y, double a_Z)
bool cBoundingBox::IsInside(Vector3d a_Min, Vector3d a_Max, double a_X, double a_Y, double a_Z)
{
return (
((a_X >= a_Min.x) && (a_X <= a_Max.x)) &&
@ -205,7 +205,7 @@ bool cBoundingBox::IsInside(const Vector3d & a_Min, const Vector3d & a_Max, doub
bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, eBlockFace & a_Face) const
bool cBoundingBox::CalcLineIntersection(Vector3d a_Line1, Vector3d a_Line2, double & a_LineCoeff, eBlockFace & a_Face) const
{
return CalcLineIntersection(m_Min, m_Max, a_Line1, a_Line2, a_LineCoeff, a_Face);
}
@ -214,7 +214,7 @@ bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Line1, const Vector3d
bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, eBlockFace & a_Face)
bool cBoundingBox::CalcLineIntersection(Vector3d a_Min, Vector3d a_Max, Vector3d a_Line1, Vector3d a_Line2, double & a_LineCoeff, eBlockFace & a_Face)
{
if (IsInside(a_Min, a_Max, a_Line1))
{

View File

@ -24,9 +24,9 @@ class cBoundingBox
{
public:
cBoundingBox(double a_MinX, double a_MaxX, double a_MinY, double a_MaxY, double a_MinZ, double a_MaxZ);
cBoundingBox(const Vector3d & a_Min, const Vector3d & a_Max);
cBoundingBox(const Vector3d & a_Pos, double a_Radius, double a_Height);
cBoundingBox(const Vector3d & a_Pos, double a_CubeLength);
cBoundingBox(Vector3d a_Min, Vector3d a_Max);
cBoundingBox(Vector3d a_Pos, double a_Radius, double a_Height);
cBoundingBox(Vector3d a_Pos, double a_CubeLength);
cBoundingBox(const cBoundingBox & a_Orig);
cBoundingBox & operator=(const cBoundingBox & a_Other);
@ -35,7 +35,7 @@ public:
void Move(double a_OffX, double a_OffY, double a_OffZ);
/** Moves the entire boundingbox by the specified offset */
void Move(const Vector3d & a_Off);
void Move(Vector3d a_Off);
/** Expands the bounding box by the specified amount in each direction (so the box becomes larger by 2 * Expand in each direction) */
void Expand(double a_ExpandX, double a_ExpandY, double a_ExpandZ);
@ -47,7 +47,7 @@ public:
cBoundingBox Union(const cBoundingBox & a_Other);
/** Returns true if the point is inside the bounding box */
bool IsInside(const Vector3d & a_Point);
bool IsInside(Vector3d a_Point);
/** Returns true if the point is inside the bounding box */
bool IsInside(double a_X, double a_Y, double a_Z);
@ -56,13 +56,13 @@ public:
bool IsInside(cBoundingBox & a_Other);
/** Returns true if a boundingbox specified by a_Min and a_Max is inside this bounding box */
bool IsInside(const Vector3d & a_Min, const Vector3d & a_Max);
bool IsInside(Vector3d a_Min, Vector3d a_Max);
/** Returns true if the specified point is inside the bounding box specified by its min / max corners */
static bool IsInside(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Point);
static bool IsInside(Vector3d a_Min, Vector3d a_Max, Vector3d a_Point);
/** Returns true if the specified point is inside the bounding box specified by its min / max corners */
static bool IsInside(const Vector3d & a_Min, const Vector3d & a_Max, double a_X, double a_Y, double a_Z);
static bool IsInside(Vector3d a_Min, Vector3d a_Max, double a_X, double a_Y, double a_Z);
// tolua_end
@ -70,13 +70,13 @@ public:
Also calculates the distance along the line in which the intersection occurs, and the face hit (BLOCK_FACE_ constants)
Only forward collisions (a_LineCoeff >= 0) are returned.
Exported to Lua manually, because ToLua++ would generate needless input params (a_LineCoeff, a_Face). */
bool CalcLineIntersection(const Vector3d & a_LinePoint1, const Vector3d & a_LinePoint2, double & a_LineCoeff, eBlockFace & a_Face) const;
bool CalcLineIntersection(Vector3d a_LinePoint1, Vector3d a_LinePoint2, double & a_LineCoeff, eBlockFace & a_Face) const;
/** Returns true if the specified bounding box is intersected by the line specified by its two points
Also calculates the distance along the line in which the intersection occurs, and the face hit (BLOCK_FACE_ constants)
Only forward collisions (a_LineCoeff >= 0) are returned.
Exported to Lua manually, because ToLua++ would generate needless input params (a_LineCoeff, a_Face). */
static bool CalcLineIntersection(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_LinePoint1, const Vector3d & a_LinePoint2, double & a_LineCoeff, eBlockFace & a_Face);
static bool CalcLineIntersection(Vector3d a_Min, Vector3d a_Max, Vector3d a_LinePoint1, Vector3d a_LinePoint2, double & a_LineCoeff, eBlockFace & a_Face);
/** Calculates the intersection of the two bounding boxes; returns true if nonempty.
Exported manually, because ToLua++ would generate needless input params (a_Intersection). */
@ -92,8 +92,8 @@ public:
double GetMaxY(void) const { return m_Max.y; }
double GetMaxZ(void) const { return m_Max.z; }
const Vector3d & GetMin(void) const { return m_Min; }
const Vector3d & GetMax(void) const { return m_Max; }
Vector3d GetMin(void) const { return m_Min; }
Vector3d GetMax(void) const { return m_Max; }
// tolua_end

View File

@ -453,7 +453,10 @@ void cChunk::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock
} // for y
// Erase all affected block entities:
cCuboid affectedArea(OffX, a_MinBlockY, OffZ, OffX + SizeX - 1, a_MinBlockY + SizeY - 1, OffZ + SizeZ - 1);
cCuboid affectedArea(
{OffX, a_MinBlockY, OffZ},
{OffX + SizeX - 1, a_MinBlockY + SizeY - 1, OffZ + SizeZ - 1}
);
for (auto itr = m_BlockEntities.begin(); itr != m_BlockEntities.end();)
{
if (affectedArea.IsInside(itr->second->GetPos()))
@ -1489,7 +1492,7 @@ void cChunk::WakeUpSimulators(void)
// The redstone sim takes multiple blocks, use the inbuilt checker
if (RedstoneSimulator->IsAllowedBlock(Block))
{
RedstoneSimulator->AddBlock(BlockX, y, BlockZ, this);
RedstoneSimulator->AddBlock({BlockX, y, BlockZ}, this);
continue;
}
@ -1497,12 +1500,12 @@ void cChunk::WakeUpSimulators(void)
{
case E_BLOCK_WATER:
{
WaterSimulator->AddBlock(BlockX, y, BlockZ, this);
WaterSimulator->AddBlock({BlockX, y, BlockZ}, this);
break;
}
case E_BLOCK_LAVA:
{
LavaSimulator->AddBlock(BlockX, y, BlockZ, this);
LavaSimulator->AddBlock({BlockX, y, BlockZ}, this);
break;
}
default:

View File

@ -27,6 +27,7 @@ class cBlockEntity;
class cEntity;
class cClientHandle;
class cBlockEntity;
class cChunkCoords;
typedef std::list<cEntity *> cEntityList;
typedef std::map<int, cBlockEntity *> cBlockEntities;
@ -50,6 +51,25 @@ typedef unsigned char HEIGHTTYPE;
class cChunkCoords
{
public:
int m_ChunkX;
int m_ChunkZ;
cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {}
bool operator == (const cChunkCoords & a_Other) const
{
return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ));
}
} ;
/** Constants used throughout the code, useful typedefs and utility functions */
class cChunkDef
{
@ -107,9 +127,9 @@ public:
}
/** Converts relative block coordinates into absolute coordinates with a known chunk location */
inline static Vector3i RelativeToAbsolute(const Vector3i & a_RelBlockPosition, int a_ChunkX, int a_ChunkZ)
inline static Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition, int a_ChunkX, int a_ChunkZ)
{
return Vector3i(a_RelBlockPosition.x + a_ChunkX * Width, a_RelBlockPosition.y, a_RelBlockPosition.z + a_ChunkZ * Width);
return {a_RelBlockPosition.x + a_ChunkX * Width, a_RelBlockPosition.y, a_RelBlockPosition.z + a_ChunkZ * Width};
}
/** Validates a height-coordinate. Returns false if height-coordiante is out of height bounds */
@ -127,16 +147,26 @@ public:
/** Converts absolute block coords to chunk coords: */
inline static void BlockToChunk(int a_X, int a_Z, int & a_ChunkX, int & a_ChunkZ)
{
a_ChunkX = a_X / Width;
if ((a_X < 0) && (a_X % Width != 0))
{
a_ChunkX--;
// This version is deprecated in favor of the vector version
// If you're developing new code, use the other version.
auto ChunkCoords = BlockToChunk({a_X, 0, a_Z});
a_ChunkX = ChunkCoords.m_ChunkX;
a_ChunkZ = ChunkCoords.m_ChunkZ;
}
a_ChunkZ = a_Z / cChunkDef::Width;
if ((a_Z < 0) && (a_Z % Width != 0))
/** The Y coordinate of a_Pos is ignored */
inline static cChunkCoords BlockToChunk(Vector3i a_Pos)
{
a_ChunkZ--;
cChunkCoords Chunk(a_Pos.x / Width, a_Pos.z / Width);
if ((a_Pos.x < 0) && (a_Pos.x % Width != 0))
{
Chunk.m_ChunkX--;
}
if ((a_Pos.z < 0) && (a_Pos.z % Width != 0))
{
Chunk.m_ChunkZ--;
}
return Chunk;
}
@ -407,24 +437,6 @@ struct sSetBlock
typedef std::list<sSetBlock> sSetBlockList;
typedef std::vector<sSetBlock> sSetBlockVector;
class cChunkCoords
{
public:
int m_ChunkX;
int m_ChunkZ;
cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {}
bool operator == (const cChunkCoords & a_Other) const
{
return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ));
}
} ;
typedef std::list<cChunkCoords> cChunkCoordsList;
typedef std::vector<cChunkCoords> cChunkCoordsVector;

View File

@ -114,11 +114,11 @@ cChunkPtr cChunkMap::GetChunk(int a_ChunkX, int a_ChunkZ)
cChunkPtr cChunkMap::GetChunkNoGen(int a_ChunkX, int a_ChunkZ)
cChunkPtr cChunkMap::GetChunkNoGen(cChunkCoords a_Chunk)
{
ASSERT(m_CSChunks.IsLockedByCurrentThread()); // m_CSChunks should already be locked by the operation that called us
auto Chunk = ConstructChunk(a_ChunkX, a_ChunkZ);
auto Chunk = ConstructChunk(a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
if (Chunk == nullptr)
{
return nullptr;
@ -126,7 +126,7 @@ cChunkPtr cChunkMap::GetChunkNoGen(int a_ChunkX, int a_ChunkZ)
if (!Chunk->IsValid() && !Chunk->IsQueued())
{
Chunk->SetPresence(cChunk::cpQueued);
m_World->GetStorage().QueueLoadChunk(a_ChunkX, a_ChunkZ);
m_World->GetStorage().QueueLoadChunk(a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
}
return Chunk;
@ -739,17 +739,15 @@ bool cChunkMap::DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)>
void cChunkMap::WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
void cChunkMap::WakeUpSimulators(Vector3i a_Block)
{
cCSLock Lock(m_CSChunks);
int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(a_BlockX, a_BlockZ, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(cChunkDef::BlockToChunk(a_Block));
if ((Chunk == nullptr) || !Chunk->IsValid())
{
return;
}
m_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ, Chunk);
m_World->GetSimulatorManager()->WakeUp(a_Block, Chunk);
}
@ -1139,7 +1137,7 @@ void cChunkMap::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_B
if ((Chunk != nullptr) && Chunk->IsValid())
{
Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta, a_SendToClients);
m_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ, Chunk);
m_World->GetSimulatorManager()->WakeUp({a_BlockX, a_BlockY, a_BlockZ}, Chunk);
}
BlockHandler(a_BlockType)->OnPlaced(ChunkInterface, *m_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
@ -1360,7 +1358,7 @@ bool cChunkMap::DigBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
}
DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0);
m_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ, DestChunk);
m_World->GetSimulatorManager()->WakeUp({a_BlockX, a_BlockY, a_BlockZ}, DestChunk);
}
return true;
@ -1821,8 +1819,8 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
// Wake up all simulators for the area, so that water and lava flows and sand falls into the blasted holes (FS #391):
m_World->GetSimulatorManager()->WakeUpArea(cCuboid(
bx - ExplosionSizeInt - 1, MinY, bz - ExplosionSizeInt - 1,
bx + ExplosionSizeInt + 1, MaxY, bz + ExplosionSizeInt + 1
{bx - ExplosionSizeInt - 1, MinY, bz - ExplosionSizeInt - 1},
{bx + ExplosionSizeInt + 1, MaxY, bz + ExplosionSizeInt + 1}
));
}

View File

@ -110,7 +110,14 @@ public:
bool DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)> a_Callback);
/** Wakes up simulators for the specified block */
void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ);
void WakeUpSimulators(Vector3i a_Block);
// DEPRECATED, use the vector-parametered version instead.
void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
{
LOGWARNING("cChunkMap::WakeUpSimulators(int, int, int) is deprecated, use cChunkMap::WakeUpSimulators(Vector3i) instead.");
WakeUpSimulators(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
}
void MarkChunkDirty (int a_ChunkX, int a_ChunkZ);
void MarkChunkSaving (int a_ChunkX, int a_ChunkZ);
@ -484,7 +491,13 @@ private:
cChunkPtr GetChunk(int a_ChunkX, int a_ChunkZ);
/** Constructs a chunk and queues the chunk for loading if not valid, returning it; doesn't generate */
cChunkPtr GetChunkNoGen(int a_ChunkX, int a_ChunkZ);
cChunkPtr GetChunkNoGen(cChunkCoords a_Chunk);
// Deprecated in favor of the vector version
cChunkPtr GetChunkNoGen(int a_ChunkX, int a_ChunkZ)
{
return GetChunkNoGen(cChunkCoords(a_ChunkX, a_ChunkZ));
}
/** Constructs a chunk, returning it. Doesn't load, doesn't generate */
cChunkPtr GetChunkNoLoad(int a_ChunkX, int a_ChunkZ);

View File

@ -10,13 +10,6 @@
////////////////////////////////////////////////////////////////////////////////
// cCuboid:
cCuboid & cCuboid::operator =(cCuboid a_Other)
{
std::swap(p1, a_Other.p1);
std::swap(p2, a_Other.p2);
return *this;
}
@ -198,7 +191,7 @@ bool cCuboid::IsSorted(void) const
void cCuboid::Engulf(const Vector3i & a_Point)
void cCuboid::Engulf(Vector3i a_Point)
{
if (a_Point.x < p1.x)
{

View File

@ -13,16 +13,14 @@ public:
Vector3i p1, p2;
cCuboid(void) {}
cCuboid(const cCuboid & a_Cuboid) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {}
cCuboid(const Vector3i & a_p1, const Vector3i & a_p2) : p1(a_p1), p2(a_p2) {}
cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {}
cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {}
// tolua_end
cCuboid & operator =(cCuboid a_Other);
// tolua_begin
// DEPRECATED, use cCuboid(Vector3i, Vector3i) instead
cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2)
{
LOGWARNING("cCuboid(int, int, int, int, int, int) constructor is deprecated, use cCuboid(Vector3i, Vector3i) constructor instead.");
}
void Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2);
void Assign(const cCuboid & a_SrcCuboid);
@ -53,7 +51,7 @@ public:
);
}
bool IsInside(const Vector3i & v) const
bool IsInside(Vector3i v) const
{
return (
(v.x >= p1.x) && (v.x <= p2.x) &&
@ -71,7 +69,7 @@ public:
);
}
bool IsInside( const Vector3d & v) const
bool IsInside(Vector3d v) const
{
return (
(v.x >= p1.x) && (v.x <= p2.x) &&
@ -105,7 +103,7 @@ public:
bool IsSorted(void) const;
/** If needed, expands the cuboid so that it contains the specified point. Assumes sorted. Doesn't contract. */
void Engulf(const Vector3i & a_Point);
void Engulf(Vector3i a_Point);
private:

View File

@ -18,8 +18,8 @@ uses a prefabricate in a cBlockArea for drawing itself.
cPrefab::cPrefab(const cPrefab::sDef & a_Def) :
m_Size(a_Def.m_SizeX, a_Def.m_SizeY, a_Def.m_SizeZ),
m_HitBox(
a_Def.m_HitboxMinX, a_Def.m_HitboxMinY, a_Def.m_HitboxMinZ,
a_Def.m_HitboxMaxX, a_Def.m_HitboxMaxY, a_Def.m_HitboxMaxZ
{a_Def.m_HitboxMinX, a_Def.m_HitboxMinY, a_Def.m_HitboxMinZ},
{a_Def.m_HitboxMaxX, a_Def.m_HitboxMaxY, a_Def.m_HitboxMaxZ}
),
m_AllowedRotations(a_Def.m_AllowedRotations),
m_MergeStrategy(a_Def.m_MergeStrategy),

View File

@ -128,7 +128,10 @@ public:
m_Noise(a_Seed),
m_MaxSize(a_MaxSize),
m_Density(a_Density),
m_Borders(a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize, a_OriginX + a_MaxSize, cChunkDef::Height - 1, a_OriginZ + a_MaxSize),
m_Borders(
{a_OriginX - a_MaxSize, 0, a_OriginZ - a_MaxSize},
{a_OriginX + a_MaxSize, cChunkDef::Height - 1, a_OriginZ + a_MaxSize}
),
m_Prefabs(a_Prefabs),
m_HeightGen(a_HeightGen)
{

View File

@ -78,9 +78,9 @@ cDelayedFluidSimulator::cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Flu
void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
void cDelayedFluidSimulator::AddBlock(Vector3i a_Block, cChunk * a_Chunk)
{
if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
if ((a_Block.y < 0) || (a_Block.y >= cChunkDef::Height))
{
// Not inside the world (may happen when rclk with a full bucket - the client sends Y = -1)
return;
@ -91,9 +91,9 @@ void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ,
return;
}
int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
int RelX = a_Block.x - a_Chunk->GetPosX() * cChunkDef::Width;
int RelZ = a_Block.z - a_Chunk->GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_Block.y, RelZ);
if (BlockType != m_FluidBlock)
{
return;
@ -104,7 +104,7 @@ void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ,
cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum];
// Add, if not already present:
if (!Slot.Add(RelX, a_BlockY, RelZ))
if (!Slot.Add(RelX, a_Block.y, RelZ))
{
return;
}

View File

@ -54,7 +54,7 @@ public:
cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay);
// cSimulator overrides:
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override;
virtual void Simulate(float a_Dt) override;
virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
virtual cFluidSimulatorData * CreateChunkData(void) override { return new cDelayedFluidSimulatorChunkData(m_TickDelay); }

View File

@ -218,16 +218,16 @@ bool cFireSimulator::DoesBurnForever(BLOCKTYPE a_BlockType)
void cFireSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
void cFireSimulator::AddBlock(Vector3i a_Block, cChunk * a_Chunk)
{
if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
{
return;
}
int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
int RelX = a_Block.x - a_Chunk->GetPosX() * cChunkDef::Width;
int RelZ = a_Block.z - a_Chunk->GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_Block.y, RelZ);
if (!IsAllowedBlock(BlockType))
{
return;
@ -237,15 +237,15 @@ void cFireSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk *
cFireSimulatorChunkData & ChunkData = a_Chunk->GetFireSimulatorData();
for (cCoordWithIntList::iterator itr = ChunkData.begin(), end = ChunkData.end(); itr != end; ++itr)
{
if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ))
if ((itr->x == RelX) && (itr->y == a_Block.y) && (itr->z == RelZ))
{
// Already present, skip adding
return;
}
} // for itr - ChunkData[]
FLOG("FS: Adding block {%d, %d, %d}", a_BlockX, a_BlockY, a_BlockZ);
ChunkData.push_back(cCoordWithInt(RelX, a_BlockY, RelZ, 100));
FLOG("FS: Adding block {%d, %d, %d}", a_Block.x, a_Block.y, a_Block.z);
ChunkData.push_back(cCoordWithInt(RelX, a_Block.y, RelZ, 100));
}

View File

@ -43,7 +43,7 @@ protected:
int m_ReplaceFuelChance;
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override;
/** Returns the time [msec] after which the specified fire block is stepped again; based on surrounding fuels */
int GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);

View File

@ -325,7 +325,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
// Spread:
FLOG(" Spreading to {%d, %d, %d} with meta %d", BlockX, a_RelY, BlockZ, a_NewMeta);
a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
m_World.GetSimulatorManager()->WakeUp(BlockX, a_RelY, BlockZ, a_NearChunk);
m_World.GetSimulatorManager()->WakeUp({BlockX, a_RelY, BlockZ}, a_NearChunk);
HardenBlock(a_NearChunk, a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
}

View File

@ -31,9 +31,9 @@ public:
return IsRedstone(a_BlockType);
}
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override
{
m_Data.WakeUp({ a_BlockX, a_BlockY, a_BlockZ });
m_Data.WakeUp(a_Block);
}
/** Returns if a block is a mechanism (something that accepts power and does something)

View File

@ -27,11 +27,9 @@ public:
}
// cSimulator overrides:
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override
{
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
UNUSED(a_Block);
UNUSED(a_Chunk);
}
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);}

View File

@ -27,11 +27,9 @@ public:
UNUSED(a_Chunk);
}
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType) override { return false; }
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override
{
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
UNUSED(a_Block);
UNUSED(a_Chunk);
}

View File

@ -33,7 +33,7 @@ public:
virtual void Simulate(float a_Dt) = 0;
virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) = 0;
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) = 0;
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) = 0;
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) = 0;
virtual cRedstoneSimulatorChunkData * CreateChunkData() = 0;

View File

@ -101,15 +101,15 @@ bool cSandSimulator::IsAllowedBlock(BLOCKTYPE a_BlockType)
void cSandSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
void cSandSimulator::AddBlock(Vector3i a_Block, cChunk * a_Chunk)
{
if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
{
return;
}
int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
if (!IsAllowedBlock(a_Chunk->GetBlock(RelX, a_BlockY, RelZ)))
int RelX = a_Block.x - a_Chunk->GetPosX() * cChunkDef::Width;
int RelZ = a_Block.z - a_Chunk->GetPosZ() * cChunkDef::Width;
if (!IsAllowedBlock(a_Chunk->GetBlock(RelX, a_Block.y, RelZ)))
{
return;
}
@ -118,14 +118,14 @@ void cSandSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk *
cSandSimulatorChunkData & ChunkData = a_Chunk->GetSandSimulatorData();
for (cSandSimulatorChunkData::iterator itr = ChunkData.begin(); itr != ChunkData.end(); ++itr)
{
if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ))
if ((itr->x == RelX) && (itr->y == a_Block.y) && (itr->z == RelZ))
{
return;
}
}
m_TotalBlocks += 1;
ChunkData.push_back(cCoordWithInt(RelX, a_BlockY, RelZ));
ChunkData.push_back(cCoordWithInt(RelX, a_Block.y, RelZ));
}

View File

@ -59,7 +59,7 @@ protected:
int m_TotalBlocks; // Total number of blocks currently in the queue for simulating
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override;
/** Performs the instant fall of the block - removes it from top, Finishes it at the bottom */
void DoInstantFall(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);

View File

@ -18,20 +18,20 @@
void cSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
void cSimulator::WakeUp(Vector3i a_Block, cChunk * a_Chunk)
{
AddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
AddBlock(a_BlockX - 1, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX - 1, a_BlockZ));
AddBlock(a_BlockX + 1, a_BlockY, a_BlockZ, a_Chunk->GetNeighborChunk(a_BlockX + 1, a_BlockZ));
AddBlock(a_BlockX, a_BlockY, a_BlockZ - 1, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ - 1));
AddBlock(a_BlockX, a_BlockY, a_BlockZ + 1, a_Chunk->GetNeighborChunk(a_BlockX, a_BlockZ + 1));
if (a_BlockY > 0)
AddBlock(a_Block, a_Chunk);
AddBlock(a_Block + Vector3i(-1, 0, 0), a_Chunk->GetNeighborChunk(a_Block.x - 1, a_Block.z));
AddBlock(a_Block + Vector3i( 1, 0, 0), a_Chunk->GetNeighborChunk(a_Block.x + 1, a_Block.z));
AddBlock(a_Block + Vector3i(0, 0, -1), a_Chunk->GetNeighborChunk(a_Block.x, a_Block.z - 1));
AddBlock(a_Block + Vector3i(0, 0, 1), a_Chunk->GetNeighborChunk(a_Block.x, a_Block.z + 1));
if (a_Block.y > 0)
{
AddBlock(a_BlockX, a_BlockY - 1, a_BlockZ, a_Chunk);
AddBlock(a_Block + Vector3i(0, -1, 0), a_Chunk);
}
if (a_BlockY < cChunkDef::Height - 1)
if (a_Block.y < cChunkDef::Height - 1)
{
AddBlock(a_BlockX, a_BlockY + 1, a_BlockZ, a_Chunk);
AddBlock(a_Block + Vector3i(0, 1, 0), a_Chunk);
}
}
@ -47,12 +47,11 @@ void cSimulator::WakeUpArea(const cCuboid & a_Area)
area.ClampY(0, cChunkDef::Height - 1);
// Add all blocks, in a per-chunk manner:
int chunkStartX, chunkStartZ, chunkEndX, chunkEndZ;
cChunkDef::BlockToChunk(area.p1.x, area.p1.z, chunkStartX, chunkStartZ);
cChunkDef::BlockToChunk(area.p2.x, area.p2.z, chunkEndX, chunkEndZ);
for (int cz = chunkStartZ; cz <= chunkEndZ; ++cz)
cChunkCoords ChunkStart = cChunkDef::BlockToChunk(area.p1);
cChunkCoords ChunkEnd = cChunkDef::BlockToChunk(area.p2);
for (int cz = ChunkStart.m_ChunkZ; cz <= ChunkEnd.m_ChunkZ; ++cz)
{
for (int cx = chunkStartX; cx <= chunkEndX; ++cx)
for (int cx = ChunkStart.m_ChunkX; cx <= ChunkEnd.m_ChunkX; ++cx)
{
m_World.DoWithChunk(cx, cz, [this, &area](cChunk & a_CBChunk) -> bool
{
@ -73,7 +72,7 @@ void cSimulator::WakeUpArea(const cCuboid & a_Area)
{
for (int x = startX; x <= endX; ++x)
{
AddBlock(x, y, z, &a_CBChunk);
AddBlock({x, y, z}, &a_CBChunk);
} // for x
} // for z
} // for y

View File

@ -39,7 +39,7 @@ public:
}
/** Called when a block changes */
void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk);
void WakeUp(Vector3i a_Block, cChunk * a_Chunk);
/** Does the same processing as WakeUp, but for all blocks within the specified area.
Has better performance than calling WakeUp for each block individually, due to neighbor-checking.
@ -55,7 +55,7 @@ protected:
friend class cChunk; // Calls AddBlock() in its WakeUpSimulators() function, to speed things up
/** Called to simulate a new block */
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) = 0;
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) = 0;
cWorld & m_World;
} ;

View File

@ -58,11 +58,11 @@ void cSimulatorManager::SimulateChunk(std::chrono::milliseconds a_Dt, int a_Chun
void cSimulatorManager::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
void cSimulatorManager::WakeUp(Vector3i a_Block, cChunk * a_Chunk)
{
for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr)
{
itr->first->WakeUp(a_BlockX, a_BlockY, a_BlockZ, a_Chunk);
itr->first->WakeUp(a_Block, a_Chunk);
}
}

View File

@ -36,7 +36,7 @@ public:
void SimulateChunk(std::chrono::milliseconds a_DT, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk);
/* Called when a single block changes, wakes all simulators up for the block and its face-neighbors. */
void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk);
void WakeUp(Vector3i a_Block, cChunk * a_Chunk);
/** Does the same processing as WakeUp, but for all blocks within the specified area.
Has better performance than calling WakeUp for each block individually, due to neighbor-checking.

View File

@ -20,26 +20,26 @@ cVaporizeFluidSimulator::cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_F
void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
void cVaporizeFluidSimulator::AddBlock(Vector3i a_Block, cChunk * a_Chunk)
{
if (a_Chunk == nullptr)
{
return;
}
int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_BlockY, RelZ);
int RelX = a_Block.x - a_Chunk->GetPosX() * cChunkDef::Width;
int RelZ = a_Block.z - a_Chunk->GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_Block.y, RelZ);
if (
(BlockType == m_FluidBlock) ||
(BlockType == m_StationaryFluidBlock)
)
{
a_Chunk->SetBlock(RelX, a_BlockY, RelZ, E_BLOCK_AIR, 0);
a_Chunk->SetBlock(RelX, a_Block.y, RelZ, E_BLOCK_AIR, 0);
a_Chunk->BroadcastSoundEffect(
"block.fire.extinguish",
static_cast<double>(a_BlockX),
static_cast<double>(a_BlockY),
static_cast<double>(a_BlockZ),
static_cast<double>(a_Block.x),
static_cast<double>(a_Block.y),
static_cast<double>(a_Block.z),
1.0f,
0.6f
);

View File

@ -25,7 +25,7 @@ public:
cVaporizeFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
// cSimulator overrides:
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override;
virtual void Simulate(float a_Dt) override;
} ;

View File

@ -76,12 +76,12 @@ cChestWindow::~cChestWindow()
bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
{
m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() - 1);
m_PrimaryChest->GetWorld()->WakeUpSimulators(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosY(), m_PrimaryChest->GetPosZ());
m_PrimaryChest->GetWorld()->WakeUpSimulators(m_PrimaryChest->GetPos());
if (m_SecondaryChest != nullptr)
{
m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() - 1);
m_SecondaryChest->GetWorld()->WakeUpSimulators(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosY(), m_SecondaryChest->GetPosZ());
m_SecondaryChest->GetWorld()->WakeUpSimulators(m_SecondaryChest->GetPos());
}
cWindow::ClosedByPlayer(a_Player, a_CanRefuse);
@ -95,12 +95,12 @@ bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
void cChestWindow::OpenedByPlayer(cPlayer & a_Player)
{
m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() + 1);
m_PrimaryChest->GetWorld()->WakeUpSimulators(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosY(), m_PrimaryChest->GetPosZ());
m_PrimaryChest->GetWorld()->WakeUpSimulators(m_PrimaryChest->GetPos());
if (m_SecondaryChest != nullptr)
{
m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() + 1);
m_SecondaryChest->GetWorld()->WakeUpSimulators(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosY(), m_SecondaryChest->GetPosZ());
m_SecondaryChest->GetWorld()->WakeUpSimulators(m_SecondaryChest->GetPos());
}
cWindow::OpenedByPlayer(a_Player);

View File

@ -1288,9 +1288,9 @@ void cWorld::UpdateSkyDarkness(void)
void cWorld::WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
void cWorld::WakeUpSimulators(Vector3i a_Block)
{
return m_ChunkMap->WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
return m_ChunkMap->WakeUpSimulators(a_Block);
}
@ -1299,7 +1299,17 @@ void cWorld::WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
void cWorld::WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ)
{
m_SimulatorManager->WakeUpArea(cCuboid(a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ));
LOGWARNING("cWorld::WakeUpSimulatorsInArea(int, int, int) is deprecated, use cWorld::WakeUpSimulatorsInArea(Vector3i) instead.");
WakeUpSimulatorsInArea(cCuboid({a_MinBlockX, a_MinBlockY, a_MinBlockZ}, {a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ}));
}
void cWorld::WakeUpSimulatorsInArea(const cCuboid & a_Area)
{
m_SimulatorManager->WakeUpArea(a_Area);
}
@ -3204,7 +3214,7 @@ bool cWorld::DoWithPlayerByUUID(const AString & a_PlayerUUID, cLambdaPlayerCallb
cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight)
cPlayer * cWorld::FindClosestPlayer(Vector3d a_Pos, float a_SightLimit, bool a_CheckLineOfSight)
{
double ClosestDistance = a_SightLimit;
cPlayer * ClosestPlayer = nullptr;

View File

@ -40,13 +40,13 @@ class cChunkGenerator; // The thread responsible for generating chunks
class cBeaconEntity;
class cBrewingstandEntity;
class cChestEntity;
class cCuboid;
class cDispenserEntity;
class cFlowerPotEntity;
class cFurnaceEntity;
class cNoteEntity;
class cMobHeadEntity;
class cCompositeChat;
class cCuboid;
class cSetChunkData;
class cBroadcaster;
class cDeadlockDetect;
@ -277,7 +277,7 @@ public:
bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
cPlayer * FindClosestPlayer(Vector3d a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
/** Finds the player over his uuid and calls the callback */
bool DoWithPlayerByUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
@ -412,11 +412,11 @@ public:
// tolua_begin
// Vector3i variants:
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); }
BLOCKTYPE GetBlock (const Vector3i & a_Pos) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z); }
NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z); }
void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData); }
NIBBLETYPE GetBlockBlockLight(const Vector3i & a_Pos) { return GetBlockBlockLight( a_Pos.x, a_Pos.y, a_Pos.z); }
void FastSetBlock(Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); }
BLOCKTYPE GetBlock (Vector3i a_Pos) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z); }
NIBBLETYPE GetBlockMeta(Vector3i a_Pos) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z); }
void SetBlockMeta(Vector3i a_Pos, NIBBLETYPE a_MetaData) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData); }
NIBBLETYPE GetBlockBlockLight(Vector3i a_Pos) { return GetBlockBlockLight( a_Pos.x, a_Pos.y, a_Pos.z); }
// tolua_end
/** Writes the block area into the specified coords.
@ -484,9 +484,19 @@ public:
double GetSpawnZ(void) const { return m_SpawnZ; }
/** Wakes up the simulators for the specified block */
virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void WakeUpSimulators(Vector3i a_Block) override;
/** Wakes up the simulators for the specified area of blocks */
void WakeUpSimulatorsInArea(const cCuboid & a_Area);
// DEPRECATED, use vector-parametered version instead
void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
{
LOGWARNING("cWorld::WakeUpSimulators(int, int, int) is deprecated, use cWorld::WakeUpSimulators(Vector3i) instead.");
WakeUpSimulators({a_BlockX, a_BlockY, a_BlockZ});
}
// DEPRECATED, use vector-parametered version instead
void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ);
// tolua_end