moved Color to Defines.h
This commit is contained in:
@@ -14,11 +14,15 @@ struct Vec2 {
|
|||||||
T g;
|
T g;
|
||||||
};
|
};
|
||||||
|
|
||||||
Vec2(T X = 0, T Y = 0) : x(X), y(Y) {}
|
constexpr Vec2(T X = 0, T Y = 0) : x(X), y(Y) {}
|
||||||
|
|
||||||
friend bool operator==(const Vec2& vec2, const Vec2& other) { return vec2.x == other.x && vec2.y == other.y; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline bool operator==(const Vec2<T>& vec2, const Vec2<T>& other) {
|
||||||
|
return vec2.x == other.x && vec2.y == other.y;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Vec3 {
|
struct Vec3 {
|
||||||
union {
|
union {
|
||||||
@@ -36,9 +40,14 @@ struct Vec3 {
|
|||||||
T b;
|
T b;
|
||||||
};
|
};
|
||||||
|
|
||||||
Vec3(T X = 0, T Y = 0, T Z = 0) : x(X), y(Y), z(Z) {}
|
constexpr Vec3(T X = 0, T Y = 0, T Z = 0) : x(X), y(Y), z(Z) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline bool operator==(const Vec3<T>& vec3, const Vec3<T>& other) {
|
||||||
|
return vec3.x == other.x && vec3.y == other.y && vec3.z == other.z;
|
||||||
|
}
|
||||||
|
|
||||||
using Vec2i = Vec2<int>;
|
using Vec2i = Vec2<int>;
|
||||||
using Vec2u = Vec2<unsigned int>;
|
using Vec2u = Vec2<unsigned int>;
|
||||||
using Vec2f = Vec2<float>;
|
using Vec2f = Vec2<float>;
|
||||||
@@ -48,5 +57,7 @@ using Vec3i = Vec3<int>;
|
|||||||
using Vec3u = Vec3<unsigned int>;
|
using Vec3u = Vec3<unsigned int>;
|
||||||
using Vec3f = Vec3<float>;
|
using Vec3f = Vec3<float>;
|
||||||
using Vec3d = Vec3<double>;
|
using Vec3d = Vec3<double>;
|
||||||
|
|
||||||
|
using Color = Vec3<unsigned char>;
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|||||||
@@ -58,10 +58,6 @@ enum class TileType : std::uint8_t {
|
|||||||
Ice,*/
|
Ice,*/
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Color {
|
|
||||||
std::uint8_t r, g, b;
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr Color BLACK{ 0, 0, 0 };
|
static constexpr Color BLACK{ 0, 0, 0 };
|
||||||
static constexpr Color WHITE{ 255, 255, 255 };
|
static constexpr Color WHITE{ 255, 255, 255 };
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ enum class PacketType : std::uint8_t {
|
|||||||
|
|
||||||
struct WorldHeader {
|
struct WorldHeader {
|
||||||
game::TowerTileColorPalette m_TowerPlacePalette;
|
game::TowerTileColorPalette m_TowerPlacePalette;
|
||||||
game::Color m_WalkablePalette;
|
Color m_WalkablePalette;
|
||||||
std::vector<game::Color> m_DecorationPalette;
|
std::vector<Color> m_DecorationPalette;
|
||||||
game::Color m_Background;
|
Color m_Background;
|
||||||
|
|
||||||
game::SpawnColorPalette m_SpawnColorPalette;
|
game::SpawnColorPalette m_SpawnColorPalette;
|
||||||
|
|
||||||
@@ -135,9 +135,9 @@ public:
|
|||||||
virtual PacketType GetType() const { return PacketType::WorldBeginData; }
|
virtual PacketType GetType() const { return PacketType::WorldBeginData; }
|
||||||
|
|
||||||
const game::TowerTileColorPalette& GetTowerTilePalette() const { return m_Header.m_TowerPlacePalette; }
|
const game::TowerTileColorPalette& GetTowerTilePalette() const { return m_Header.m_TowerPlacePalette; }
|
||||||
const game::Color& GetWalkableTileColor() const { return m_Header.m_WalkablePalette; }
|
const Color& GetWalkableTileColor() const { return m_Header.m_WalkablePalette; }
|
||||||
const std::vector<game::Color>& GetDecorationPalette() const { return m_Header.m_DecorationPalette; }
|
const std::vector<Color>& GetDecorationPalette() const { return m_Header.m_DecorationPalette; }
|
||||||
const game::Color& GetBackgroundColor() const { return m_Header.m_Background; }
|
const Color& GetBackgroundColor() const { return m_Header.m_Background; }
|
||||||
|
|
||||||
const game::Spawn& GetRedSpawn() const { return m_Header.m_RedSpawn; }
|
const game::Spawn& GetRedSpawn() const { return m_Header.m_RedSpawn; }
|
||||||
const game::Spawn& GetBlueSpawn() const { return m_Header.m_BlueSpawn; }
|
const game::Spawn& GetBlueSpawn() const { return m_Header.m_BlueSpawn; }
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ WorldClient::WorldClient(ClientGame* game) : game::World(game), protocol::Packet
|
|||||||
void WorldClient::HandlePacket(const protocol::WorldBeginDataPacket* packet) {
|
void WorldClient::HandlePacket(const protocol::WorldBeginDataPacket* packet) {
|
||||||
LoadMap(packet);
|
LoadMap(packet);
|
||||||
if (m_Game->GetGameState() == game::GameState::Game) {
|
if (m_Game->GetGameState() == game::GameState::Game) {
|
||||||
const game::Color& backgroundColor = GetBackgroundColor();
|
const Color& backgroundColor = GetBackgroundColor();
|
||||||
m_Game->GetRenderer()->SetBackgroundColor({ static_cast<float>(backgroundColor.r / 255.0f), static_cast<float>(backgroundColor.g / 255.0f),
|
m_Game->GetRenderer()->SetBackgroundColor({ static_cast<float>(backgroundColor.r / 255.0f), static_cast<float>(backgroundColor.g / 255.0f),
|
||||||
static_cast<float>(backgroundColor.b / 255.0f) });
|
static_cast<float>(backgroundColor.b / 255.0f) });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void PlayerLoginPacket::Deserialize(DataBuffer& data) {
|
|||||||
DataBuffer WorldBeginDataPacket::Serialize(bool packetID) const {
|
DataBuffer WorldBeginDataPacket::Serialize(bool packetID) const {
|
||||||
DataBuffer data;
|
DataBuffer data;
|
||||||
const game::TowerTileColorPalette& towerTilePalette = m_Header.m_World->GetTowerTileColorPalette();
|
const game::TowerTileColorPalette& towerTilePalette = m_Header.m_World->GetTowerTileColorPalette();
|
||||||
const std::vector<game::Color>& decoTilePalette = m_Header.m_World->GetDecorationPalette();
|
const std::vector<Color>& decoTilePalette = m_Header.m_World->GetDecorationPalette();
|
||||||
|
|
||||||
WritePacketID(data, packetID);
|
WritePacketID(data, packetID);
|
||||||
|
|
||||||
@@ -105,9 +105,9 @@ DataBuffer WorldBeginDataPacket::Serialize(bool packetID) const {
|
|||||||
|
|
||||||
// deco color palette
|
// deco color palette
|
||||||
std::size_t bufferSize = data.GetSize();
|
std::size_t bufferSize = data.GetSize();
|
||||||
data.Resize(bufferSize + decoTilePalette.size() * sizeof(game::Color));
|
data.Resize(bufferSize + decoTilePalette.size() * sizeof(Color));
|
||||||
|
|
||||||
memcpy(reinterpret_cast<std::uint8_t*>(data.data()) + bufferSize, decoTilePalette.data(), decoTilePalette.size() * sizeof(game::Color));
|
memcpy(reinterpret_cast<std::uint8_t*>(data.data()) + bufferSize, decoTilePalette.data(), decoTilePalette.size() * sizeof(Color));
|
||||||
|
|
||||||
data << m_Header.m_World->GetBackgroundColor();
|
data << m_Header.m_World->GetBackgroundColor();
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ void WorldBeginDataPacket::Deserialize(DataBuffer& data) {
|
|||||||
std::uint16_t decoPaletteSize;
|
std::uint16_t decoPaletteSize;
|
||||||
data >> decoPaletteSize;
|
data >> decoPaletteSize;
|
||||||
|
|
||||||
std::size_t decoPalletteSizeByte = decoPaletteSize * sizeof(game::Color);
|
std::size_t decoPalletteSizeByte = decoPaletteSize * sizeof(Color);
|
||||||
|
|
||||||
m_Header.m_DecorationPalette.resize(decoPaletteSize);
|
m_Header.m_DecorationPalette.resize(decoPaletteSize);
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
|||||||
static_cast<float>(chunkX + tileX + 1), static_cast<float>(chunkY + tileY + 1),
|
static_cast<float>(chunkX + tileX + 1), static_cast<float>(chunkY + tileY + 1),
|
||||||
});
|
});
|
||||||
|
|
||||||
const td::game::Color* tileColor = world->GetTileColor(tile);
|
const td::Color* tileColor = world->GetTileColor(tile);
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
int color = 255;
|
int color = 255;
|
||||||
|
|||||||
Reference in New Issue
Block a user