refactor: cpp style casts
This commit is contained in:
@@ -44,7 +44,7 @@ void Mob::AttackCastle(std::uint64_t delta, World* world) {
|
||||
void Mob::Walk(std::uint64_t delta, World* world) {
|
||||
float mobWalkSpeed = GetStats()->GetMovementSpeed();
|
||||
|
||||
float walkAmount = mobWalkSpeed * ((float)delta / 1000.0f);
|
||||
float walkAmount = mobWalkSpeed * (static_cast<float>(delta) / 1000.0f);
|
||||
|
||||
if (HasEffect(EffectType::Slowness))
|
||||
walkAmount *= 0.70; // walk 30% slower
|
||||
|
||||
@@ -143,14 +143,14 @@ void World::TickMobs(std::uint64_t delta) {
|
||||
const Color* World::GetTileColor(TilePtr tile) const {
|
||||
switch (tile->GetType()) {
|
||||
case TileType::Tower: {
|
||||
TowerTile* towerTile = (TowerTile*)tile.get();
|
||||
TowerTile* towerTile = dynamic_cast<TowerTile*>(tile.get());
|
||||
return &m_TowerPlacePalette[towerTile->color_palette_ref];
|
||||
}
|
||||
case TileType::Walk: {
|
||||
return &m_WalkablePalette;
|
||||
}
|
||||
case TileType::Decoration: {
|
||||
DecorationTile* towerTile = (DecorationTile*)tile.get();
|
||||
DecorationTile* towerTile = dynamic_cast<DecorationTile*>(tile.get());
|
||||
return &m_DecorationPalette[towerTile->color_palette_ref];
|
||||
break;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ bool World::CanPlaceLittleTower(const glm::vec2& worldPos, PlayerID playerID) co
|
||||
}
|
||||
|
||||
if (tile->GetType() == game::TileType::Tower) {
|
||||
const TowerTile* towerTile = (const TowerTile*)tile.get();
|
||||
const TowerTile* towerTile = dynamic_cast<TowerTile*>(tile.get());
|
||||
if (towerTile->team_owner != player.GetTeamColor())
|
||||
return false;
|
||||
for (int x = -1; x < 2; x++) {
|
||||
@@ -198,7 +198,7 @@ bool World::CanPlaceBigTower(const glm::vec2& worldPos, PlayerID playerID) const
|
||||
}
|
||||
|
||||
if (tile->GetType() == game::TileType::Tower) {
|
||||
const TowerTile* towerTile = (const TowerTile*)tile.get();
|
||||
const TowerTile* towerTile = dynamic_cast<const TowerTile*>(tile.get());
|
||||
if (towerTile->team_owner != player.GetTeamColor())
|
||||
return false;
|
||||
for (int x = -2; x < 3; x++) {
|
||||
|
||||
@@ -99,7 +99,7 @@ void ServerConnexion::HandlePacket(const protocol::PlayerLoginPacket* packet) {
|
||||
void ServerConnexion::HandlePacket(const protocol::SelectTeamPacket* packet) {
|
||||
if (m_Server->GetGame().GetGameState() != game::GameState::Lobby)
|
||||
return;
|
||||
if ((std::int8_t)packet->GetSelectedTeam() >= -1 || (std::int8_t)packet->GetSelectedTeam() <= 1) {
|
||||
if (static_cast<std::int8_t>(packet->GetSelectedTeam()) >= -1 || static_cast<std::int8_t>(packet->GetSelectedTeam()) <= 1) {
|
||||
if (m_Player->GetTeamColor() == game::TeamColor::None) { // join a team
|
||||
m_Server->GetGame().GetTeam(packet->GetSelectedTeam()).AddPlayer(m_Player);
|
||||
} else if (packet->GetSelectedTeam() == game::TeamColor::None) { // leave a team
|
||||
|
||||
@@ -69,14 +69,14 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
||||
continue;
|
||||
|
||||
positions.insert(positions.end(), {
|
||||
(float)chunkX + tileX, (float)chunkY + tileY,
|
||||
(float)chunkX + tileX + 1, (float)chunkY + tileY,
|
||||
(float)chunkX + tileX, (float)chunkY + tileY + 1,
|
||||
static_cast<float>(chunkX + tileX), static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX + 1), static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX), static_cast<float>(chunkY + tileY + 1),
|
||||
|
||||
(float)chunkX + tileX + 1, (float)chunkY + tileY,
|
||||
(float)chunkX + tileX, (float)chunkY + tileY + 1,
|
||||
(float)chunkX + tileX + 1, (float)chunkY + tileY + 1,
|
||||
});
|
||||
static_cast<float>(chunkX + tileX + 1), static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX), 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);
|
||||
|
||||
@@ -178,7 +178,7 @@ GL::VertexArray LoadTileSelectModel() {
|
||||
int color = 255 << 24 | 255 << 16 | 255 << 8 | 150;
|
||||
float colorFloat;
|
||||
|
||||
memcpy((std::uint8_t*)&colorFloat, &color, sizeof(float));
|
||||
memcpy(reinterpret_cast<std::uint8_t*>(&colorFloat), &color, sizeof(float));
|
||||
|
||||
std::vector<float> colors(6, colorFloat);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user