moved Color to Defines.h
This commit is contained in:
@@ -14,11 +14,15 @@ struct Vec2 {
|
||||
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>
|
||||
struct Vec3 {
|
||||
union {
|
||||
@@ -36,9 +40,14 @@ struct Vec3 {
|
||||
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 Vec2u = Vec2<unsigned int>;
|
||||
using Vec2f = Vec2<float>;
|
||||
@@ -48,5 +57,7 @@ using Vec3i = Vec3<int>;
|
||||
using Vec3u = Vec3<unsigned int>;
|
||||
using Vec3f = Vec3<float>;
|
||||
using Vec3d = Vec3<double>;
|
||||
|
||||
|
||||
using Color = Vec3<unsigned char>;
|
||||
|
||||
} // namespace td
|
||||
|
||||
@@ -58,10 +58,6 @@ enum class TileType : std::uint8_t {
|
||||
Ice,*/
|
||||
};
|
||||
|
||||
struct Color {
|
||||
std::uint8_t r, g, b;
|
||||
};
|
||||
|
||||
static constexpr Color BLACK{ 0, 0, 0 };
|
||||
static constexpr Color WHITE{ 255, 255, 255 };
|
||||
|
||||
|
||||
@@ -49,9 +49,9 @@ enum class PacketType : std::uint8_t {
|
||||
|
||||
struct WorldHeader {
|
||||
game::TowerTileColorPalette m_TowerPlacePalette;
|
||||
game::Color m_WalkablePalette;
|
||||
std::vector<game::Color> m_DecorationPalette;
|
||||
game::Color m_Background;
|
||||
Color m_WalkablePalette;
|
||||
std::vector<Color> m_DecorationPalette;
|
||||
Color m_Background;
|
||||
|
||||
game::SpawnColorPalette m_SpawnColorPalette;
|
||||
|
||||
@@ -135,9 +135,9 @@ public:
|
||||
virtual PacketType GetType() const { return PacketType::WorldBeginData; }
|
||||
|
||||
const game::TowerTileColorPalette& GetTowerTilePalette() const { return m_Header.m_TowerPlacePalette; }
|
||||
const game::Color& GetWalkableTileColor() const { return m_Header.m_WalkablePalette; }
|
||||
const std::vector<game::Color>& GetDecorationPalette() const { return m_Header.m_DecorationPalette; }
|
||||
const game::Color& GetBackgroundColor() const { return m_Header.m_Background; }
|
||||
const Color& GetWalkableTileColor() const { return m_Header.m_WalkablePalette; }
|
||||
const std::vector<Color>& GetDecorationPalette() const { return m_Header.m_DecorationPalette; }
|
||||
const Color& GetBackgroundColor() const { return m_Header.m_Background; }
|
||||
|
||||
const game::Spawn& GetRedSpawn() const { return m_Header.m_RedSpawn; }
|
||||
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) {
|
||||
LoadMap(packet);
|
||||
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),
|
||||
static_cast<float>(backgroundColor.b / 255.0f) });
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ void PlayerLoginPacket::Deserialize(DataBuffer& data) {
|
||||
DataBuffer WorldBeginDataPacket::Serialize(bool packetID) const {
|
||||
DataBuffer data;
|
||||
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);
|
||||
|
||||
@@ -105,9 +105,9 @@ DataBuffer WorldBeginDataPacket::Serialize(bool packetID) const {
|
||||
|
||||
// deco color palette
|
||||
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();
|
||||
|
||||
@@ -135,7 +135,7 @@ void WorldBeginDataPacket::Deserialize(DataBuffer& data) {
|
||||
std::uint16_t decoPaletteSize;
|
||||
data >> decoPaletteSize;
|
||||
|
||||
std::size_t decoPalletteSizeByte = decoPaletteSize * sizeof(game::Color);
|
||||
std::size_t decoPalletteSizeByte = decoPaletteSize * sizeof(Color);
|
||||
|
||||
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),
|
||||
});
|
||||
|
||||
const td::game::Color* tileColor = world->GetTileColor(tile);
|
||||
const td::Color* tileColor = world->GetTileColor(tile);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int color = 255;
|
||||
|
||||
Reference in New Issue
Block a user