Commit e7cdd8e6 authored by louiz’'s avatar louiz’

Fix various warnings

parent 40b75c4c
......@@ -75,7 +75,8 @@ link_directories(${CRYPTO++_LIBRARIES})
if(BUILD_CLIENT)
add_executable(batajelo_client src/main/batajelo_client.cpp)
target_link_libraries(batajelo_client
server
game_client
client
gui
)
endif()
......@@ -243,7 +244,16 @@ add_library(network STATIC ${source_server} ${source_client})
## Game
#
file(GLOB source_game
src/game/*.[ch]pp
src/game/game.[ch]pp
src/game/game_server.[ch]pp
src/game/occupant.[ch]pp
src/game/occupants_handler.[ch]pp
src/game/remote_game_client.[ch]pp
src/game/replay.[ch]pp
src/game/selection.[ch]pp
src/game/time.[ch]pp
src/game/turn.[ch]pp
src/game/turn_handler.[ch]pp
)
add_library(game STATIC ${source_game})
......@@ -255,16 +265,20 @@ target_link_libraries(game
logging
config
world
gui
)
#
## Game client
#
add_library(game_client STATIC ${source_game})
file(GLOB source_game_client
src/game/game_client.[ch]pp
)
add_library(game_client STATIC ${source_game_client})
target_link_libraries(game_client
game
gui
)
#
......
......@@ -2,14 +2,15 @@
Occupant::Occupant(uint32_t id, const std::string& name):
id(id),
team(0),
name(name)
{
}
Occupant::Occupant(const ser::game::Occupant& srl):
id(srl.id()),
name(srl.name()),
team(srl.team())
team(srl.team()),
name(srl.name())
{
}
......
......@@ -97,7 +97,7 @@ bool Camera::handle_event(const sf::Event& event)
return false;
}
void Camera::handle_middle_click(const sf::Event& event)
void Camera::handle_middle_click(const sf::Event&)
{
}
......@@ -140,7 +140,7 @@ void Camera::handle_left_click(const sf::Event& event)
}
}
void Camera::handle_left_release(const sf::Event& event)
void Camera::handle_left_release(const sf::Event&)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::RShift) ||
sf::Keyboard::isKeyPressed(sf::Keyboard::LShift))
......@@ -151,8 +151,6 @@ void Camera::handle_left_release(const sf::Event& event)
void Camera::set_mouse_selection_to_selection()
{
Entity* entity;
sf::Vector2i mouse_pos = this->get_mouse_position();
// First check the number of entities inside the selection. If it's 0, do
......@@ -218,7 +216,7 @@ void Camera::add_mouse_selection_to_selection()
this->mouse_selection.end();
}
void Camera::handle_middle_release(const sf::Event& event)
void Camera::handle_middle_release(const sf::Event&)
{
}
......@@ -492,7 +490,6 @@ Position Camera::camera_to_world_position(const int x, const int y) const
std::to_string(heights.corners.right) + ", " +
std::to_string(heights.corners.bottom));
const Fix16 cell_size_16 = static_cast<fix16_t>(CELL_SIZE);
// Relative x and y position on the base square of the grid-aligned tile
unsigned int rel_x = (x + this->x) - (TILE_WIDTH * col);
unsigned int rel_y = (y + this->y - top_offset) - ((TILE_HEIGHT / 2) * row);
......
......@@ -102,27 +102,6 @@ void Screen::set_left_click_callback(const t_left_click left_click)
this->on_left_click = left_click;
}
cursor::type Screen::draw_build_cursor(const uint x, const uint y, const std::size_t id)
{
// log_error("id: " << id);
// sf::Sprite sprite;
// sprite.setTexture(*(this->building_textures[id]));
// Position world_pos = this->camera.camera_to_world_position(x, y);
// short xa, ya;
// std::tie(xa, ya) = this->world->et_cell_at_position(world_pos);
// Fix16 height = this->world->get_position_height(world_pos);
// float xpos = xa * TILE_WIDTH - this->camera.x;
// float ypos = ya * TILE_HEIGHT - this->camera.y - static_cast<int>(height) * LAYER_HEIGHT - 32;
// if (this->world->can_build_at_cell(xa, ya))
// sprite.setColor(sf::Color(0, 0, 255, 150));
// else
// sprite.setColor(sf::Color(255, 0, 0, 150));
// sprite.setPosition(xpos, ypos);
// this->win->draw(sprite);
// return cursor::Build;
}
cursor::type Screen::draw_move_cursor(const uint, const uint, const std::size_t)
{
return cursor::Move;
......
......@@ -84,7 +84,6 @@ public:
return on_left_click;
}
void set_left_click_callback(const t_left_click left_click);
cursor::type draw_build_cursor(const unsigned int, const unsigned int y, const std::size_t);
cursor::type draw_move_cursor(const uint, const uint, const std::size_t);
void reset_left_click_action();
......
......@@ -25,8 +25,8 @@ struct EnergyBar
* the scale of the bar, in addition to the percentage of its fullness.
* Use 0 to disable that kind of line.
*/
std::size_t little_graduation;
std::size_t big_graduation;
int little_graduation;
int big_graduation;
};
#endif /* ENERGY_BAR_HPP_INCLUDE */
......@@ -42,7 +42,6 @@ void PicpicSprite::draw(GameClient* game) const
sf::Sprite eye_sprite(PicpicSprite::eye_texture);
const sf::Vector2u eye_size = PicpicSprite::eye_texture.getSize();
eye_sprite.setPosition(x - 10 - eye_size.x/2, y - size.y / 5 * 3 - this->height - eye_size.y/2 + 5);
sf::Vector2i mouse_pos = game->get_screen().get_mouse_position();
game->get_camera().draw(eye_sprite);
eye_sprite.setPosition(x + 10 - eye_size.x/2, y - size.y / 5 * 3 - this->height - eye_size.y/2 + 5);
game->get_camera().draw(eye_sprite);
......
......@@ -72,13 +72,13 @@ public:
* copying data twice.
*/
char* body;
std::string header;
std::string name;
size_t body_size;
/**
* If not empty, will be called from the send_handler.
*/
std::function<void(void)> callback;
std::string header;
std::string name;
/**
* Converts the body to a protobuf object. Does not check if it's valid
* nor complete.
......
......@@ -18,7 +18,7 @@ void RemoteClient::install_callbacks()
this->install_callback("TRANSFER", std::bind(&RemoteClient::transfer_callback, this, std::placeholders::_1));
}
void RemoteClient::auth_callback(Message* received_message)
void RemoteClient::auth_callback(Message*)
{
}
......
......@@ -27,14 +27,6 @@
#include <network/base_socket.hpp>
#include <network/message.hpp>
/**
* Does nothing, it is just used to exit the io_service.run_one() after
* a timeout.
*/
static void poll_timeout_handler(const boost::system::error_code&)
{
}
template <class T>
class Server: public BaseIoservice, public BaseSocket
{
......@@ -86,7 +78,7 @@ public:
// we reinstall it. If that's not the case
// (something actually happened on the socket)
// we just need to reset the time of expiration, but not reinstall it.
this->timeout.async_wait(&poll_timeout_handler);
this->timeout.async_wait([](const boost::system::error_code&){});
// Wait for one event to happen (either a timeout or something
// on the socket).
this->io_service.run_one();
......@@ -119,7 +111,7 @@ public:
for (it = this->clients.begin(); it < this->clients.end(); ++it)
if ((*it)->get_user() && (*it)->get_user()->get("login") == login)
return *it;
return 0;
return nullptr;
}
/**
......
#include <utils/maths.hpp>
/**
* Values used to make an angular rotation
* See http://en.wikipedia.org/wiki/Rotation_%28mathematics%29#Matrix_algebra
* or your school lessons.
*/
// sin(7π/4)
static const float sin_45 = 0.6496369390800625;
// cos(7π/4)
static const float cos_45 = 0.7602445970756301;
......@@ -14,7 +14,7 @@ EntityFactory::~EntityFactory()
{
}
std::unique_ptr<Entity> EntityFactory::make_entity(const EntityType type)
std::unique_ptr<Entity> EntityFactory::make_entity(const EntityType)
{
auto res = std::make_unique<Entity>();
res->add_component(std::make_unique<Health>(100));
......
......@@ -187,32 +187,32 @@ bool Map::get_layer_data(boost::property_tree::ptree& tree, std::string& data)
return false;
}
uint Map::get_height_in_pixels() const
unsigned int Map::get_height_in_pixels() const
{
return this->height;
}
uint Map::get_width_in_pixels() const
unsigned int Map::get_width_in_pixels() const
{
return this->width;
}
uint Map::get_height_in_tiles() const
unsigned int Map::get_height_in_tiles() const
{
return this->height_in_tiles;
}
uint Map::get_width_in_tiles() const
unsigned int Map::get_width_in_tiles() const
{
return this->width_in_tiles;
}
void Map::generate_walking_map()
{
const uint map_size = this->get_width_in_tiles() * this->get_height_in_tiles();
const unsigned int map_size = this->get_width_in_tiles() * this->get_height_in_tiles();
this->walking_map = new TileHeights[map_size];
int level;
for (uint i = 0; i < map_size; ++i)
for (unsigned int i = 0; i < map_size; ++i)
{
level = this->get_max_level_for_cell(i);
if (level == -1)
......@@ -254,7 +254,7 @@ int Map::get_max_level_for_cell(const uint cell) const
return ret;
}
TileHeights Map::get_cell_heights(const int col, const int row) const
TileHeights Map::get_cell_heights(const unsigned int col, const unsigned int row) const
{
assert(col >= 0);
assert(row >= 0);
......@@ -270,24 +270,6 @@ TileHeights Map::get_cell_heights(const CellIndex cell) const
cell / this->get_width_in_tiles());
}
bool Map::can_be_built_on(const int cellx, const int celly) const
{
// assert(cellx >= 0);
// assert(celly >= 0);
// assert(cellx < this->get_width_in_tiles());
// assert(celly < this->get_height_in_tiles());
// std::size_t index = (this->get_width_in_tiles() * celly) + cellx;
// TileHeights heights = this->walking_map[index];
// ushort a = (heights >> 12) & 15;
// ushort b = (heights >> 8) & 15;
// ushort c = (heights >> 4) & 15;
// ushort d = (heights) & 15;
// if (a == b && b == c && c == d)
// return true;
return false;
}
CellPath Map::do_astar(const Cell start, const Cell goal)
{
unsigned short startx;
......@@ -418,8 +400,6 @@ int heuristic()
void insert_node(AStarNodes& nodes, CellIndex index, int g, int f)
{
bool inserted = false;
AStarNode node;
node.f = f;
node.g = g;
......
......@@ -93,12 +93,8 @@ public:
/**
* Returns an ushort containing the 4 corners' heights of the given cell.
*/
TileHeights get_cell_heights(const int cellx, const int celly) const;
TileHeights get_cell_heights(const unsigned int cellx, const unsigned int celly) const;
TileHeights get_cell_heights(const CellIndex cell) const;
/**
* Returns whether or not this cell can be built on.
*/
bool can_be_built_on(const int cellx, const int celly) const;
CellPath do_astar(const Cell start, const Cell end);
/**
* Returns the neighbour cells of the given one if it's walkable to it.
......@@ -121,19 +117,19 @@ protected:
/**
* The width (in pixels) of the map.
*/
uint width;
unsigned int width;
/**
* The height (in pixels) of the map.
*/
uint height;
unsigned int height;
/**
* The number of tiles, horizontally.
*/
uint width_in_tiles;
unsigned int width_in_tiles;
/**
* The number of tiles, vertically.
*/
uint height_in_tiles;
unsigned int height_in_tiles;
/**
* The list of all layers. A layer can be NULL.
*/
......
......@@ -22,7 +22,7 @@ Fix16 Mobility::get_speed() const
return this->speed;
}
void Mobility::follow_path(Path& path, World* world, Location* location)
void Mobility::follow_path(Path& path, World*, Location* location)
{
Position goal = path.front();
Vec2 movement(goal - location->position());
......
......@@ -22,6 +22,6 @@ void Team::set(const Team::type number)
this->number = number;
}
void Team::tick(Entity* entity, World* world)
void Team::tick(Entity*, World*)
{
}
......@@ -543,8 +543,3 @@ Position World::get_nearest_corner(const Position& pos, const CellIndex cell, co
}
return nearest_position;
}
bool World::can_build_at_cell(const int x, const int y) const
{
return this->map.can_be_built_on(x, y);
}
......@@ -83,10 +83,6 @@ public:
* position and the tile height (see tile_heights in map.hpp)
*/
Fix16 get_position_height(const Position& pos) const;
/**
* Convert a path made of cells by a path composed of world positions
*/
bool can_build_at_cell(const int x, const int y) const;
/**
* Return true if the given location can be seen by any entity of the given
* team.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment