1
0

Fix comments

This commit is contained in:
tycho 2015-05-28 12:29:26 +01:00
parent e19693e529
commit b2fa71a32a
20 changed files with 82 additions and 64 deletions

1
.gitignore vendored
View File

@ -75,7 +75,6 @@ src/MCServer
lib/tolua++/tolua lib/tolua++/tolua
src/Bindings/Bindings.* src/Bindings/Bindings.*
src/Bindings/BindingDependencies.txt src/Bindings/BindingDependencies.txt
src/Bindings/LuaState_Call.inc
MCServer.dir/ MCServer.dir/
src/AllFiles.lst src/AllFiles.lst

View File

@ -146,12 +146,12 @@ set_source_files_properties(${BINDING_OUTPUTS} PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_source_files_properties(DeprecatedBindings.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") set_source_files_properties(DeprecatedBindings.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(LuaState.cpp COMPILE_FLAGS "-Wno-error=old-style-cast") set_source_files_properties(LuaState.cpp COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(LuaWindow.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum") set_source_files_properties(LuaWindow.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
set_source_files_properties(ManualBindings.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") set_source_files_properties(ManualBindings.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(ManualBindings_World.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") set_source_files_properties(ManualBindings_World.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
set_source_files_properties(PluginLua.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast") set_source_files_properties(PluginLua.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
endif() endif()
if(NOT MSVC) if(NOT MSVC)

View File

@ -177,7 +177,8 @@ void cMobSpawnerEntity::SpawnEntity(void)
static_cast<int>(PosX * 8.0), static_cast<int>(PosX * 8.0),
static_cast<int>(RelY * 8.0), static_cast<int>(RelY * 8.0),
static_cast<int>(PosZ * 8.0), static_cast<int>(PosZ * 8.0),
0); 0
);
m_NearbyEntitiesNum++; m_NearbyEntitiesNum++;
} }
} }

View File

@ -92,11 +92,13 @@ void cNoteEntity::MakeSound(void)
// TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all // TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all
float calcPitch = pow(2.0f, static_cast<float>(m_Pitch - 12.0f) / 12.0f); float calcPitch = pow(2.0f, static_cast<float>(m_Pitch - 12.0f) / 12.0f);
m_World->BroadcastSoundEffect( m_World->BroadcastSoundEffect(
sampleName, sampleName,
static_cast<double>(m_PosX), static_cast<double>(m_PosX),
static_cast<double>(m_PosY), static_cast<double>(m_PosY),
static_cast<double>(m_PosZ), static_cast<double>(m_PosZ),
3.0f, calcPitch); 3.0f,
calcPitch
);
} }

View File

@ -117,11 +117,12 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
m_World->ForEachEntity(Callback); m_World->ForEachEntity(Callback);
m_World->BroadcastSoundParticleEffect( m_World->BroadcastSoundParticleEffect(
2002, 2002,
static_cast<int>(floor(a_HitPos.x)), FloorC(a_HitPos.x),
static_cast<int>(floor(a_HitPos.y)), FloorC(a_HitPos.y),
static_cast<int>(floor(a_HitPos.z)), FloorC(a_HitPos.z),
m_PotionColor); m_PotionColor
);
} }

View File

@ -158,7 +158,7 @@ void cChunkDesc::SetHeightFromShape(const Shape & a_Shape)
{ {
for (int x = 0; x < cChunkDef::Width; x++) for (int x = 0; x < cChunkDef::Width; x++)
{ {
for (unsigned char y = cChunkDef::Height - 1; y > 0; y--) for (HEIGHTTYPE y = cChunkDef::Height - 1; y > 0; y--)
{ {
if (a_Shape[y + x * 256 + z * 16 * 256] != 0) if (a_Shape[y + x * 256 + z * 16 * 256] != 0)
{ {

View File

@ -96,17 +96,17 @@ bool cLineBlockTracer::Trace(double a_StartX, double a_StartY, double a_StartZ,
m_Callbacks->OnIntoWorld(m_StartX, m_StartY, m_StartZ); m_Callbacks->OnIntoWorld(m_StartX, m_StartY, m_StartZ);
} }
m_CurrentX = static_cast<int>(floor(m_StartX)); m_CurrentX = FloorC(m_StartX);
m_CurrentY = static_cast<int>(floor(m_StartY)); m_CurrentY = FloorC(m_StartY);
m_CurrentZ = static_cast<int>(floor(m_StartZ)); m_CurrentZ = FloorC(m_StartZ);
m_DiffX = m_EndX - m_StartX; m_DiffX = m_EndX - m_StartX;
m_DiffY = m_EndY - m_StartY; m_DiffY = m_EndY - m_StartY;
m_DiffZ = m_EndZ - m_StartZ; m_DiffZ = m_EndZ - m_StartZ;
// The actual trace is handled with ChunkMapCS locked by calling our Item() for the specified chunk // The actual trace is handled with ChunkMapCS locked by calling our Item() for the specified chunk
int BlockX = static_cast<int>(floor(m_StartX)); int BlockX = FloorC(m_StartX);
int BlockZ = static_cast<int>(floor(m_StartZ)); int BlockZ = FloorC(m_StartZ);
int ChunkX, ChunkZ; int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ); cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
return m_World->DoWithChunk(ChunkX, ChunkZ, *this); return m_World->DoWithChunk(ChunkX, ChunkZ, *this);

View File

@ -283,8 +283,12 @@ cFileListener::cFileListener(void)
cFile::CreateFolder(FILE_IO_PREFIX + AString("logs")); cFile::CreateFolder(FILE_IO_PREFIX + AString("logs"));
AString FileName; AString FileName;
auto time = std::chrono::system_clock::now(); auto time = std::chrono::system_clock::now();
FileName = Printf("%s%sLOG_%d.txt", FILE_IO_PREFIX, "logs/", FileName = Printf(
std::chrono::duration_cast<std::chrono::duration<int, std::milli>>(time.time_since_epoch()).count()); "%s%sLOG_%d.txt",
FILE_IO_PREFIX,
"logs/",
std::chrono::duration_cast<std::chrono::duration<int, std::milli>>(time.time_since_epoch()).count()
);
m_File.Open(FileName, cFile::fmAppend); m_File.Open(FileName, cFile::fmAppend);
} }

View File

@ -43,13 +43,13 @@ void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
Vector3d Pos = GetPosition(); Vector3d Pos = GetPosition();
// TODO: Not a real behavior, but cool :D // TODO: Not a real behavior, but cool :D
int RelY = static_cast<int>(floor(Pos.y)); int RelY = FloorC(Pos.y);
if ((RelY < 0) || (RelY >= cChunkDef::Height)) if ((RelY < 0) || (RelY >= cChunkDef::Height))
{ {
return; return;
} }
int RelX = static_cast<int>(floor(Pos.x)) - a_Chunk.GetPosX() * cChunkDef::Width; int RelX = FloorC(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width;
int RelZ = static_cast<int>(floor(Pos.z)) - a_Chunk.GetPosZ() * cChunkDef::Width; int RelZ = FloorC(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType; BLOCKTYPE BlockType;
if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire()) if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire())
{ {

View File

@ -55,10 +55,10 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{ {
if (m_World->GetTickRandomNumber(50) == 25) if (m_World->GetTickRandomNumber(50) == 25)
{ {
m_World->BroadcastSoundParticleEffect(2000, static_cast<int>(GetPosX()), static_cast<int>(GetPosY()), static_cast<int>(GetPosZ()), 0); m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 0);
m_World->BroadcastSoundParticleEffect(2000, static_cast<int>(GetPosX()), static_cast<int>(GetPosY()), static_cast<int>(GetPosZ()), 2); m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 2);
m_World->BroadcastSoundParticleEffect(2000, static_cast<int>(GetPosX()), static_cast<int>(GetPosY()), static_cast<int>(GetPosZ()), 6); m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 6);
m_World->BroadcastSoundParticleEffect(2000, static_cast<int>(GetPosX()), static_cast<int>(GetPosY()), static_cast<int>(GetPosZ()), 8); m_World->BroadcastSoundParticleEffect(2000, FloorC(GetPosX()), FloorC(GetPosY()), FloorC(GetPosZ()), 8);
m_Attachee->Detach(); m_Attachee->Detach();
m_bIsRearing = true; m_bIsRearing = true;

View File

@ -46,18 +46,18 @@ cPath::cPath(
a_BoundingBoxWidth = 1; // Until we improve physics, if ever. a_BoundingBoxWidth = 1; // Until we improve physics, if ever.
m_BoundingBoxWidth = static_cast<int>(ceil(a_BoundingBoxWidth)); m_BoundingBoxWidth = CeilC(a_BoundingBoxWidth);
m_BoundingBoxHeight = static_cast<int>(ceil(a_BoundingBoxHeight)); m_BoundingBoxHeight = CeilC(a_BoundingBoxHeight);
m_HalfWidth = a_BoundingBoxWidth / 2; m_HalfWidth = a_BoundingBoxWidth / 2;
int HalfWidthInt = static_cast<int>(a_BoundingBoxWidth / 2); int HalfWidthInt = FloorC(a_BoundingBoxWidth / 2);
m_Source.x = static_cast<int>(floor(a_StartingPoint.x - HalfWidthInt)); m_Source.x = FloorC(a_StartingPoint.x - HalfWidthInt);
m_Source.y = static_cast<int>(floor(a_StartingPoint.y)); m_Source.y = FloorC(a_StartingPoint.y);
m_Source.z = static_cast<int>(floor(a_StartingPoint.z - HalfWidthInt)); m_Source.z = FloorC(a_StartingPoint.z - HalfWidthInt);
m_Destination.x = static_cast<int>(floor(a_EndingPoint.x - HalfWidthInt)); m_Destination.x = FloorC(a_EndingPoint.x - HalfWidthInt);
m_Destination.y = static_cast<int>(floor(a_EndingPoint.y)); m_Destination.y = FloorC(a_EndingPoint.y);
m_Destination.z = static_cast<int>(floor(a_EndingPoint.z - HalfWidthInt)); m_Destination.z = FloorC(a_EndingPoint.z - HalfWidthInt);
if (GetCell(m_Source)->m_IsSolid || GetCell(m_Destination)->m_IsSolid) if (GetCell(m_Source)->m_IsSolid || GetCell(m_Destination)->m_IsSolid)
{ {

View File

@ -41,13 +41,13 @@ void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
Vector3d Pos = GetPosition(); Vector3d Pos = GetPosition();
// TODO: Not a real behavior, but cool :D // TODO: Not a real behavior, but cool :D
int RelY = static_cast<int>(floor(Pos.y)); int RelY = FloorC(Pos.y);
if ((RelY < 0) || (RelY >= cChunkDef::Height)) if ((RelY < 0) || (RelY >= cChunkDef::Height))
{ {
return; return;
} }
int RelX = static_cast<int>(floor(Pos.x)) - a_Chunk.GetPosX() * cChunkDef::Width; int RelX = FloorC(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width;
int RelZ = static_cast<int>(floor(Pos.z)) - a_Chunk.GetPosZ() * cChunkDef::Width; int RelZ = FloorC(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width;
BLOCKTYPE BlockType; BLOCKTYPE BlockType;
if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire()) if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire())
{ {

View File

@ -210,7 +210,8 @@ NOISE_DATATYPE cNoise::IntNoise3D(int a_X, int a_Y, int a_Z) const
int n = a_X + a_Y * 57 + a_Z * 57 * 57 + m_Seed * 57 * 57 * 57; int n = a_X + a_Y * 57 + a_Z * 57 * 57 + m_Seed * 57 * 57 * 57;
n = (n << 13) ^ n; n = (n << 13) ^ n;
return (static_cast<NOISE_DATATYPE>(1) - return (static_cast<NOISE_DATATYPE>(1) -
static_cast<NOISE_DATATYPE>((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f); static_cast<NOISE_DATATYPE>((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f
);
// returns a float number in the range of [-1, 1] // returns a float number in the range of [-1, 1]
} }

View File

@ -127,13 +127,13 @@ protected:
/** The callback used by PolarSSL when it wants to read encrypted data. */ /** The callback used by PolarSSL when it wants to read encrypted data. */
static int ReceiveEncrypted(void * a_This, unsigned char * a_Buffer, size_t a_NumBytes) static int ReceiveEncrypted(void * a_This, unsigned char * a_Buffer, size_t a_NumBytes)
{ {
return (static_cast<cSslContext *>(a_This))->ReceiveEncrypted(a_Buffer, a_NumBytes); return (reinterpret_cast<cSslContext *>(a_This))->ReceiveEncrypted(a_Buffer, a_NumBytes);
} }
/** The callback used by PolarSSL when it wants to write encrypted data. */ /** The callback used by PolarSSL when it wants to write encrypted data. */
static int SendEncrypted(void * a_This, const unsigned char * a_Buffer, size_t a_NumBytes) static int SendEncrypted(void * a_This, const unsigned char * a_Buffer, size_t a_NumBytes)
{ {
return (static_cast<cSslContext *>(a_This))->SendEncrypted(a_Buffer, a_NumBytes); return (reinterpret_cast<cSslContext *>(a_This))->SendEncrypted(a_Buffer, a_NumBytes);
} }
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -99,7 +99,7 @@ void cDelayedFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ,
return; return;
} }
void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData(); auto ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
cDelayedFluidSimulatorChunkData * ChunkData = static_cast<cDelayedFluidSimulatorChunkData *>(ChunkDataRaw); cDelayedFluidSimulatorChunkData * ChunkData = static_cast<cDelayedFluidSimulatorChunkData *>(ChunkDataRaw);
cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum]; cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_AddSlotNum];
@ -132,7 +132,7 @@ void cDelayedFluidSimulator::Simulate(float a_Dt)
void cDelayedFluidSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) void cDelayedFluidSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{ {
void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData(); auto ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
cDelayedFluidSimulatorChunkData * ChunkData = static_cast<cDelayedFluidSimulatorChunkData *>(ChunkDataRaw); cDelayedFluidSimulatorChunkData * ChunkData = static_cast<cDelayedFluidSimulatorChunkData *>(ChunkDataRaw);
cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_SimSlotNum]; cDelayedFluidSimulatorChunkData::cSlot & Slot = ChunkData->m_Slots[m_SimSlotNum];

View File

@ -260,7 +260,9 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
static_cast<double>(BlockX), static_cast<double>(BlockX),
static_cast<double>(a_RelY), static_cast<double>(a_RelY),
static_cast<double>(BlockZ), static_cast<double>(BlockZ),
0.5f, 1.5f); 0.5f,
1.5f
);
return; return;
} }
} }
@ -280,7 +282,9 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
static_cast<double>(BlockX), static_cast<double>(BlockX),
static_cast<double>(a_RelY), static_cast<double>(a_RelY),
static_cast<double>(BlockZ), static_cast<double>(BlockZ),
0.5f, 1.5f); 0.5f,
1.5f
);
return; return;
} }
} }

View File

@ -267,10 +267,11 @@ void cSandSimulator::FinishFalling(
cItems Pickups; cItems Pickups;
Pickups.Add(static_cast<ENUM_ITEM_ID>(a_FallingBlockType), 1, a_FallingBlockMeta); Pickups.Add(static_cast<ENUM_ITEM_ID>(a_FallingBlockType), 1, a_FallingBlockMeta);
a_World->SpawnItemPickups( a_World->SpawnItemPickups(
Pickups, Pickups,
static_cast<double>(a_BlockX) + 0.5, static_cast<double>(a_BlockX) + 0.5,
static_cast<double>(a_BlockY) + 0.5, static_cast<double>(a_BlockY) + 0.5,
static_cast<double>(a_BlockZ) + 0.5); static_cast<double>(a_BlockZ) + 0.5
);
} }

View File

@ -40,7 +40,9 @@ void cVaporizeFluidSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ,
static_cast<double>(a_BlockX), static_cast<double>(a_BlockX),
static_cast<double>(a_BlockY), static_cast<double>(a_BlockY),
static_cast<double>(a_BlockZ), static_cast<double>(a_BlockZ),
1.0f, 0.6f); 1.0f,
0.6f
);
} }
} }

View File

@ -29,7 +29,9 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
static_cast<double>(m_BlockX), static_cast<double>(m_BlockX),
static_cast<double>(m_BlockY), static_cast<double>(m_BlockY),
static_cast<double>(m_BlockZ), static_cast<double>(m_BlockZ),
1, 1); 1,
1
);
// Send out the chest-open packet: // Send out the chest-open packet:
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST); m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST);
@ -46,11 +48,12 @@ cEnderChestWindow::~cEnderChestWindow()
// Play the closing sound // Play the closing sound
m_World->BroadcastSoundEffect( m_World->BroadcastSoundEffect(
"random.chestclosed", "random.chestclosed",
static_cast<double>(m_BlockX), static_cast<double>(m_BlockX),
static_cast<double>(m_BlockY), static_cast<double>(m_BlockY),
static_cast<double>(m_BlockZ), static_cast<double>(m_BlockZ),
1, 1); 1, 1
);
} }

View File

@ -648,7 +648,7 @@ void cWebAdmin::OnRequestBegun(cHTTPConnection & a_Connection, cHTTPRequest & a_
void cWebAdmin::OnRequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size) void cWebAdmin::OnRequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size)
{ {
UNUSED(a_Connection); UNUSED(a_Connection);
cRequestData * Data = static_cast<cRequestData *>(a_Request.GetUserData()); cRequestData * Data = reinterpret_cast<cRequestData *>(a_Request.GetUserData());
if (Data == nullptr) if (Data == nullptr)
{ {
return; return;
@ -681,7 +681,7 @@ void cWebAdmin::OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest &
} }
// Delete any request data assigned to the request: // Delete any request data assigned to the request:
cRequestData * Data = static_cast<cRequestData *>(a_Request.GetUserData()); cRequestData * Data = reinterpret_cast<cRequestData *>(a_Request.GetUserData());
delete Data; delete Data;
Data = nullptr; Data = nullptr;
} }