summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/ChunkDef.h1
-rw-r--r--source/ChunkSender.h2
-rw-r--r--source/WGFlat.cpp8
-rw-r--r--source/WGFlat.h2
-rw-r--r--source/WSSCompact.cpp12
-rw-r--r--source/cChunk.cpp14
-rw-r--r--source/cChunk.h2
-rw-r--r--source/cChunkGenerator.cpp2
-rw-r--r--source/cChunkMap.cpp8
-rw-r--r--source/cWorld.cpp15
-rw-r--r--source/cWorldGenerator.cpp8
-rw-r--r--source/cWorldGenerator.h2
-rw-r--r--source/cWorldGenerator_Test.cpp2
-rw-r--r--source/cWorldGenerator_Test.h2
-rw-r--r--source/packets/cPacket_MapChunk.cpp2
-rw-r--r--source/packets/cPacket_MapChunk.h3
16 files changed, 52 insertions, 33 deletions
diff --git a/source/ChunkDef.h b/source/ChunkDef.h
index 38dfcd7b4..647f9b51e 100644
--- a/source/ChunkDef.h
+++ b/source/ChunkDef.h
@@ -43,6 +43,7 @@ typedef std::list<cBlockEntity *> cBlockEntityList;
/// The datatype used by blockdata, metadata, blocklight and skylight
typedef char BLOCKTYPE;
+typedef char BIOMETYPE;
diff --git a/source/ChunkSender.h b/source/ChunkSender.h
index b5b58b854..59fab5b6c 100644
--- a/source/ChunkSender.h
+++ b/source/ChunkSender.h
@@ -102,7 +102,7 @@ protected:
// Data about the chunk that is being sent:
// NOTE that m_BlockData[] is inherited from the cChunkDataCollector
- BLOCKTYPE m_BiomeData[cChunkDef::Width * cChunkDef::Width];
+ BIOMETYPE m_BiomeData[cChunkDef::Width * cChunkDef::Width];
PacketList m_Packets; // Accumulator for the entity-packets to send
// cIsThread override:
diff --git a/source/WGFlat.cpp b/source/WGFlat.cpp
index 5c901c916..cb1392a77 100644
--- a/source/WGFlat.cpp
+++ b/source/WGFlat.cpp
@@ -33,7 +33,7 @@ cWGFlat::cWGFlat(cWorld * a_World) :
-void cWGFlat::GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
+void cWGFlat::GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
{
int SliceSize = cChunkDef::Width * cChunkDef::Width;
memset(a_BlockData, E_BLOCK_BEDROCK, SliceSize);
@@ -76,14 +76,14 @@ void cWGFlat::GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_B
memset(a_BlockData + SliceSize * m_Height, E_BLOCK_AIR, cChunkDef::NumBlocks - SliceSize * m_Height);
SliceSize /= 2; // Nibbles from now on
- char * Meta = a_BlockData + cChunkDef::NumBlocks;
+ BLOCKTYPE * Meta = a_BlockData + cChunkDef::NumBlocks;
memset(Meta, 0, cChunkDef::NumBlocks / 2);
- char * SkyLight = Meta + cChunkDef::NumBlocks / 2;
+ BLOCKTYPE * SkyLight = Meta + cChunkDef::NumBlocks / 2;
memset(SkyLight, 0, m_Height * SliceSize);
memset(SkyLight + m_Height * SliceSize, 0xff, cChunkDef::NumBlocks / 2 - m_Height * SliceSize);
- char * BlockLight = SkyLight + cChunkDef::NumBlocks / 2;
+ BLOCKTYPE * BlockLight = SkyLight + cChunkDef::NumBlocks / 2;
memset(BlockLight, 0, cChunkDef::NumBlocks / 2);
}
diff --git a/source/WGFlat.h b/source/WGFlat.h
index 79a2053c5..a1f2d2244 100644
--- a/source/WGFlat.h
+++ b/source/WGFlat.h
@@ -23,7 +23,7 @@ class cWGFlat :
protected:
int m_Height;
- virtual void GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities) override;
+ virtual void GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities) override;
virtual void PostGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) override;
public:
diff --git a/source/WSSCompact.cpp b/source/WSSCompact.cpp
index ae920e55f..8c27dba51 100644
--- a/source/WSSCompact.cpp
+++ b/source/WSSCompact.cpp
@@ -734,12 +734,14 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_Uncomp
}
}
+ BLOCKTYPE * BlockData = (BLOCKTYPE *)UncompressedData.data();
+
a_World->ChunkDataLoaded(
a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ,
- UncompressedData.data(),
- UncompressedData.data() + cChunkDef::MetaOffset,
- UncompressedData.data() + cChunkDef::LightOffset,
- UncompressedData.data() + cChunkDef::SkyLightOffset,
+ BlockData,
+ BlockData + cChunkDef::MetaOffset,
+ BlockData + cChunkDef::LightOffset,
+ BlockData + cChunkDef::SkyLightOffset,
NULL,
Entities,
BlockEntities
@@ -788,7 +790,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld
}
AString Data;
- Data.assign(Serializer.GetBlockData(), cChunkDef::BlockDataSize);
+ Data.assign((const char *)Serializer.GetBlockData(), cChunkDef::BlockDataSize);
if (Serializer.HasJsonData())
{
AString JsonData;
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index dad101204..2dde0cc0d 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -735,7 +735,7 @@ void cChunk::CalculateLighting()
-void cChunk::SpreadLight(char* a_LightBuffer)
+void cChunk::SpreadLight(BLOCKTYPE * a_LightBuffer)
{
// Spread the light
for(int x = 0; x < Width; x++) for(int z = 0; z < Width; z++) for(int y = 0; y < Height; y++)
@@ -762,7 +762,7 @@ void cChunk::SpreadLight(char* a_LightBuffer)
// Spread to neighbour chunks X-axis
cChunkPtr LeftChunk = m_ChunkMap->GetChunkNoGen( m_PosX - 1, m_PosY, m_PosZ );
cChunkPtr RightChunk = m_ChunkMap->GetChunkNoGen( m_PosX + 1, m_PosY, m_PosZ );
- char * LeftSky = NULL, *RightSky = NULL;
+ BLOCKTYPE * LeftSky = NULL, *RightSky = NULL;
if (LeftChunk->IsValid())
{
LeftSky = (a_LightBuffer == m_BlockSkyLight) ? LeftChunk->m_BlockSkyLight : LeftChunk->m_BlockLight;
@@ -779,8 +779,8 @@ void cChunk::SpreadLight(char* a_LightBuffer)
int index = MakeIndexNoCheck( 0, y, z );
if( g_BlockSpreadLightFalloff[ m_BlockTypes[index] ] > 0 )
{
- char CurrentLight = GetNibble( a_LightBuffer, 0, y, z );
- char LeftLight = GetNibble( LeftSky, Width-1, y, z );
+ BLOCKTYPE CurrentLight = GetNibble( a_LightBuffer, 0, y, z );
+ BLOCKTYPE LeftLight = GetNibble( LeftSky, Width-1, y, z );
if( LeftLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockTypes[index] ] )
{
SetNibble( LeftSky, Width - 1, y, z, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockTypes[index] ]) );
@@ -793,8 +793,8 @@ void cChunk::SpreadLight(char* a_LightBuffer)
int index = MakeIndexNoCheck( Width - 1, y, z );
if( g_BlockSpreadLightFalloff[ m_BlockTypes[index] ] > 0 )
{
- char CurrentLight = GetNibble( a_LightBuffer, Width-1, y, z );
- char RightLight = GetNibble( RightSky, 0, y, z );
+ BLOCKTYPE CurrentLight = GetNibble( a_LightBuffer, Width-1, y, z );
+ BLOCKTYPE RightLight = GetNibble( RightSky, 0, y, z );
if( RightLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockTypes[index] ] )
{
SetNibble( RightSky, 0, y, z, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockTypes[index] ]) );
@@ -807,7 +807,7 @@ void cChunk::SpreadLight(char* a_LightBuffer)
// Spread to neighbour chunks Z-axis
cChunkPtr FrontChunk = m_ChunkMap->GetChunkNoGen( m_PosX, m_PosY, m_PosZ - 1 );
cChunkPtr BackChunk = m_ChunkMap->GetChunkNoGen( m_PosX, m_PosY, m_PosZ + 1 );
- char * FrontSky = NULL, * BackSky = NULL;
+ BLOCKTYPE * FrontSky = NULL, * BackSky = NULL;
if (FrontChunk->IsValid())
{
FrontSky = (a_LightBuffer == m_BlockSkyLight) ? FrontChunk->m_BlockSkyLight : FrontChunk->m_BlockLight;
diff --git a/source/cChunk.h b/source/cChunk.h
index cd43f2fe3..ed15b696c 100644
--- a/source/cChunk.h
+++ b/source/cChunk.h
@@ -211,7 +211,7 @@ private:
cBlockEntity * GetBlockEntity( int a_X, int a_Y, int a_Z );
cBlockEntity * GetBlockEntity( const Vector3i & a_BlockPos ) { return GetBlockEntity( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); }
- void SpreadLightOfBlock(char* a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff);
+ void SpreadLightOfBlock(BLOCKTYPE * a_LightBuffer, int a_X, int a_Y, int a_Z, BLOCKTYPE a_Falloff);
void CreateBlockEntities(void);
diff --git a/source/cChunkGenerator.cpp b/source/cChunkGenerator.cpp
index 95b43e5b4..fdfdeab46 100644
--- a/source/cChunkGenerator.cpp
+++ b/source/cChunkGenerator.cpp
@@ -180,7 +180,7 @@ void cChunkGenerator::Execute(void)
void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
- char BlockData[cChunkDef::BlockDataSize];
+ BLOCKTYPE BlockData[cChunkDef::BlockDataSize];
cEntityList Entities;
cBlockEntityList BlockEntities;
m_pWorldGenerator->GenerateChunk(a_ChunkX, a_ChunkY, a_ChunkZ, BlockData, Entities, BlockEntities);
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index 02ea0917e..97f6a659f 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -521,7 +521,7 @@ void cChunkMap::CollectPickupsByPlayer(cPlayer * a_Player)
-char cChunkMap::GetBlock(int a_X, int a_Y, int a_Z)
+BLOCKTYPE cChunkMap::GetBlock(int a_X, int a_Y, int a_Z)
{
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkZ );
@@ -539,7 +539,7 @@ char cChunkMap::GetBlock(int a_X, int a_Y, int a_Z)
-char cChunkMap::GetBlockMeta(int a_X, int a_Y, int a_Z)
+BLOCKTYPE cChunkMap::GetBlockMeta(int a_X, int a_Y, int a_Z)
{
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkZ );
@@ -557,7 +557,7 @@ char cChunkMap::GetBlockMeta(int a_X, int a_Y, int a_Z)
-void cChunkMap::SetBlockMeta(int a_X, int a_Y, int a_Z, char a_BlockMeta)
+void cChunkMap::SetBlockMeta(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockMeta)
{
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkZ );
@@ -576,7 +576,7 @@ void cChunkMap::SetBlockMeta(int a_X, int a_Y, int a_Z, char a_BlockMeta)
-void cChunkMap::SetBlock(int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta)
+void cChunkMap::SetBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
{
int ChunkX, ChunkZ, X = a_X, Y = a_Y, Z = a_Z;
cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 9abcac4f7..bb5fbfdeb 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -182,6 +182,21 @@ cWorld::cWorld( const AString & a_WorldName )
, m_RSList ( 0 )
, m_Weather ( eWeather_Sunny )
{
+ /*
+ // DEBUG:
+ DWORD Tick = GetTickCount();
+ for (int i = 0; i < 3000; i++)
+ {
+ BLOCKTYPE Playground[cChunkDef::NumBlocks / 2];
+ for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) for (int y = 0; y < 256; y++)
+ {
+ cChunkDef::SetNibble(Playground, x, y, z, x);
+ } // for x, y, z
+ } // for i
+ Tick = GetTickCount() - Tick;
+ LOGINFO("3000 chunkfulls of SetNibble() took %d ticks", Tick);
+ //*/
+
LOG("cWorld::cWorld(%s)", a_WorldName.c_str());
m_WorldName = a_WorldName;
m_IniFileName = m_WorldName + "/world.ini";
diff --git a/source/cWorldGenerator.cpp b/source/cWorldGenerator.cpp
index 80b01e963..19dc7835a 100644
--- a/source/cWorldGenerator.cpp
+++ b/source/cWorldGenerator.cpp
@@ -81,7 +81,7 @@ cWorldGenerator::~cWorldGenerator()
-void cWorldGenerator::GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
+void cWorldGenerator::GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
{
GenerateTerrain(a_ChunkX, a_ChunkY, a_ChunkZ, a_BlockData);
}
@@ -190,7 +190,7 @@ unsigned int cWorldGenerator::MakeIndex(int x, int y, int z )
-void cWorldGenerator::GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData)
+void cWorldGenerator::GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData)
{
const int WATER_LEVEL = 60;
const int SAND_LEVEL = 3;
@@ -327,7 +327,7 @@ void cWorldGenerator::GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ,
-void cWorldGenerator::GenerateOre(char a_OreType, int a_MaxHeight, int a_NumNests, int a_NestSize, char * a_BlockData)
+void cWorldGenerator::GenerateOre(char a_OreType, int a_MaxHeight, int a_NumNests, int a_NestSize, BLOCKTYPE * a_BlockData)
{
// This function generates several "nests" of ore, each nest consisting of number of ore blocks relatively adjacent to each other.
// It does so by making a random XYZ walk and adding ore along the way in cuboids of different (random) sizes
@@ -397,7 +397,7 @@ void cWorldGenerator::GenerateOre(char a_OreType, int a_MaxHeight, int a_NumNest
void cWorldGenerator::GenerateFoliage(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
- char BlockType[cChunkDef::NumBlocks];
+ BLOCKTYPE BlockType[cChunkDef::NumBlocks];
if (!m_World->GetChunkBlockTypes(a_ChunkX, a_ChunkY, a_ChunkZ, BlockType))
{
diff --git a/source/cWorldGenerator.h b/source/cWorldGenerator.h
index 832680e28..157f93d83 100644
--- a/source/cWorldGenerator.h
+++ b/source/cWorldGenerator.h
@@ -25,7 +25,7 @@ public:
cWorldGenerator(cWorld * a_World);
~cWorldGenerator();
- virtual void GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities);
+ virtual void GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities);
virtual void PostGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Called when the chunk has been already generated and set valid
diff --git a/source/cWorldGenerator_Test.cpp b/source/cWorldGenerator_Test.cpp
index 86a7b8388..b7257f35f 100644
--- a/source/cWorldGenerator_Test.cpp
+++ b/source/cWorldGenerator_Test.cpp
@@ -8,7 +8,7 @@
-void cWorldGenerator_Test::GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData)
+void cWorldGenerator_Test::GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData)
{
memset(a_BlockData, E_BLOCK_DIRT, cChunkDef::NumBlocks);
for(int x = 0; x < cChunkDef::Width; x++)
diff --git a/source/cWorldGenerator_Test.h b/source/cWorldGenerator_Test.h
index d5580ffc8..966ce4a8d 100644
--- a/source/cWorldGenerator_Test.h
+++ b/source/cWorldGenerator_Test.h
@@ -16,7 +16,7 @@ public:
protected:
- virtual void GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData) override;
+ virtual void GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData) override;
virtual void GenerateFoliage(int a_ChunkX, int a_ChunkY, int a_ChunkZ) override;
};
diff --git a/source/packets/cPacket_MapChunk.cpp b/source/packets/cPacket_MapChunk.cpp
index 3c94ef012..17249c25d 100644
--- a/source/packets/cPacket_MapChunk.cpp
+++ b/source/packets/cPacket_MapChunk.cpp
@@ -19,7 +19,7 @@ cPacket_MapChunk::~cPacket_MapChunk()
-cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, const char * a_BiomeData)
+cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const BLOCKTYPE * a_BlockData, const BIOMETYPE * a_BiomeData)
{
m_PacketID = E_MAP_CHUNK;
diff --git a/source/packets/cPacket_MapChunk.h b/source/packets/cPacket_MapChunk.h
index 1dd05f9ef..0b2bef7ad 100644
--- a/source/packets/cPacket_MapChunk.h
+++ b/source/packets/cPacket_MapChunk.h
@@ -2,6 +2,7 @@
#pragma once
#include "cPacket.h"
+#include "../ChunkDef.h"
@@ -33,7 +34,7 @@ public:
{ m_PacketID = E_MAP_CHUNK; m_CompressedData = 0; }
cPacket_MapChunk( const cPacket_MapChunk & a_Copy );
- cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, const char * a_BiomeData);
+ cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const BLOCKTYPE * a_BlockData, const BIOMETYPE * a_BiomeData);
~cPacket_MapChunk();
virtual cPacket* Clone() const { return new cPacket_MapChunk(*this); }