Skip to content

Commit

Permalink
Fixed tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian Shelley committed Oct 22, 2014
1 parent 59948e0 commit b88e58f
Show file tree
Hide file tree
Showing 12 changed files with 514 additions and 517 deletions.
54 changes: 27 additions & 27 deletions chunk.cpp
Expand Up @@ -43,8 +43,8 @@ void Chunk::load(NBT &nbt)
highest=0;

Tag *level=nbt.at("Level");
chunkX = level->at("xPos")->toInt();
chunkZ = level->at("zPos")->toInt();
chunkX = level->at("xPos")->toInt();
chunkZ = level->at("zPos")->toInt();

Tag *biomes=level->at("Biomes");
memcpy(this->biomes,biomes->toByteArray(),biomes->length());
Expand Down Expand Up @@ -74,14 +74,14 @@ void Chunk::load(NBT &nbt)
loaded=true;


Tag* entitylist = level->at("Entities");
int numEntities = entitylist->length();
for (int i = 0; i < numEntities; ++i)
{
Entity e;
e.load(entitylist->at(i));
entities.insertMulti("Entity", e);
}
Tag* entitylist = level->at("Entities");
int numEntities = entitylist->length();
for (int i = 0; i < numEntities; ++i)
{
Entity e;
e.load(entitylist->at(i));
entities.insertMulti("Entity", e);
}


for (int i=15;i>=0;i--) //check for the highest block in this chunk
Expand All @@ -93,7 +93,7 @@ void Chunk::load(NBT &nbt)
highest=i*16+(j>>8);
return;
}
}
}
}
Chunk::~Chunk()
{
Expand All @@ -109,28 +109,28 @@ Chunk::~Chunk()

quint16 ChunkSection::getBlock(int x, int y, int z)
{
int xoffset = x;
int yoffset = (y&0x0f)<<8;
int zoffset = z<<4;
return blocks[xoffset+yoffset+zoffset];
int xoffset = x;
int yoffset = (y&0x0f)<<8;
int zoffset = z<<4;
return blocks[xoffset+yoffset+zoffset];
}

quint8 ChunkSection::getData(int x, int y, int z)
{
int xoffset = x;
int yoffset = (y&0x0f)<<8;
int zoffset = z<<4;
int value = data[(xoffset+yoffset+zoffset)/2];
if (x&1) value>>=4;
return value&0x0f;
int xoffset = x;
int yoffset = (y&0x0f)<<8;
int zoffset = z<<4;
int value = data[(xoffset+yoffset+zoffset)/2];
if (x&1) value>>=4;
return value&0x0f;
}

quint8 ChunkSection::getLight(int x, int y, int z)
{
int xoffset = x;
int yoffset = (y&0x0f)<<8;
int zoffset = z<<4;
int value = light[(xoffset+yoffset+zoffset)/2];
if (x&1) value>>=4;
return value&0x0f;
int xoffset = x;
int yoffset = (y&0x0f)<<8;
int zoffset = z<<4;
int value = light[(xoffset+yoffset+zoffset)/2];
if (x&1) value>>=4;
return value&0x0f;
}
8 changes: 4 additions & 4 deletions chunk.h
Expand Up @@ -60,12 +60,12 @@ class Chunk
ChunkSection *sections[16];
int renderedAt;
int renderedFlags;
QSet<QString> renderedSpecialBlockTypes;
QSet<QString> renderedSpecialBlockTypes;
bool loaded;
uchar image[16*16*4]; //cached render
QMap<QString, Entity> entities;
int chunkX;
int chunkZ;
QMap<QString, Entity> entities;
int chunkX;
int chunkZ;
friend class MapView;
friend class ChunkCache;
friend class WorldSave;
Expand Down
28 changes: 14 additions & 14 deletions entity.cpp
Expand Up @@ -3,24 +3,24 @@
#include "nbt.h"

Entity::Entity(qint64 nx, qint64 ny, qint64 nz, QString nid):
id(nid),
x(nx),
y(ny),
z(nz)
id(nid),
x(nx),
y(ny),
z(nz)
{
}


void Entity::load(Tag *nbt)
{
Tag* pos = nbt->at("Pos");
x = (qint64)pos->at(0)->toDouble();
y = (qint64)pos->at(1)->toDouble();
z = (qint64)pos->at(2)->toDouble();
Tag* id = nbt->at("id");
if (id)
{
this->id = id->toString();
properties = nbt->getData();
}
Tag* pos = nbt->at("Pos");
x = (qint64)pos->at(0)->toDouble();
y = (qint64)pos->at(1)->toDouble();
z = (qint64)pos->at(2)->toDouble();
Tag* id = nbt->at("id");
if (id)
{
this->id = id->toString();
properties = nbt->getData();
}
}
24 changes: 12 additions & 12 deletions entity.h
Expand Up @@ -9,22 +9,22 @@ class Tag;
class Entity
{
public:
Entity(qint64 nx = 0, qint64 ny = 0, qint64 nz = 0, QString nid = "");
Entity(qint64 nx = 0, qint64 ny = 0, qint64 nz = 0, QString nid = "");

void load(Tag *t);
void load(Tag *t);

const QString& getId() const { return id; }
const QVariant& getProperties() const { return properties; }
qint64 getX() const { return x; }
qint64 getY() const { return y; }
qint64 getZ() const { return z; }
const QString& getId() const { return id; }
const QVariant& getProperties() const { return properties; }
qint64 getX() const { return x; }
qint64 getY() const { return y; }
qint64 getZ() const { return z; }

private:
QString id;
QVariant properties;
qint64 x;
qint64 y;
qint64 z;
QString id;
QVariant properties;
qint64 x;
qint64 y;
qint64 z;
};

#endif // ENTITY_H

0 comments on commit b88e58f

Please sign in to comment.