Commit 40f4094c authored by louiz’'s avatar louiz’
Browse files

Commit various little unimportant changes, mostly debug and some esthitics stuf

parent ce1c64e7
......@@ -19,6 +19,9 @@ else(${CMAKE_BUILD_TYPE} MATCHES "debug")
endif(${CMAKE_BUILD_TYPE} MATCHES "debug")
configure_file("${PROJECT_SOURCE_DIR}/src/constant.hpp.in" "${PROJECT_SOURCE_DIR}/src/constant.hpp")
## This flag is very important, if one client is compiled without it, its world representation
## may not be identical with the other’s one.
set(CMAKE_C_FLAGS "-DFIXMATH_SIN_LUT")
if(NOT DEFINED BUILD_SERVER)
set(BUILD_SERVER true CACHE BOOL "build the server")
......
data/images/gui_cursor.png

1.7 KB | W: | H:

data/images/gui_cursor.png

1.88 KB | W: | H:

data/images/gui_cursor.png
data/images/gui_cursor.png
data/images/gui_cursor.png
data/images/gui_cursor.png
  • 2-up
  • Swipe
  • Onion skin
#include <config/config.hpp>
#include <sstream>
#define CONF_DEFAULT_PATH "C:/Work/pelaze/git/batajelo/src/batajelo.conf"
#define CONF_DEFAULT_PATH "./batajelo.conf"
Config* Config::instance = 0;
......
......@@ -39,7 +39,7 @@ void Camera::draw_entity(const Entity* entity, const uint x, const uint y,
{
sf::CircleShape selection_circle;
selection_circle.setRadius(entity->width/2 + 8);
selection_circle.setOutlineColor(sf::Color(0xff, 0x00, 0x36, 200));
selection_circle.setOutlineColor(sf::Color(0x00, 0x00, 0xff, 200));
selection_circle.setFillColor(sf::Color::Transparent);
selection_circle.setOutlineThickness(3);
selection_circle.setPosition(x - entity->width/2 - 8, y - entity->width + 5);
......@@ -113,11 +113,12 @@ void Camera::handle_right_click(const sf::Event& event)
{
const Position pos = this->camera_to_world_position(event.mouseButton.x,
event.mouseButton.y);
// int x;
// int y;
// this->world->get_cell_at_position(pos, x, y);
// this->world->handle_event(actions::Move, pos.x.toLong(), pos.y.toLong());
this->world->action_move(pos.x.toLong(), pos.y.toLong());
// A right click when there's an action associated with the left click
// just resets the default action of the right click.
if (this->screen->get_left_click_callback())
this->screen->set_left_click_callback(0);
else // otherwise it always does the move action.
this->world->action_move(pos.x.toLong(), pos.y.toLong());
}
void Camera::handle_left_click(const sf::Event& event)
......@@ -322,7 +323,7 @@ void Camera::draw()
this->draw_entity(entity, entpos.x - this->x, entpos.y - this->y,
this->mouse_selection.contains(mouse_pos,
entpos, entity->width + 4) ||
screen->is_entity_hovered(entity),
this->screen->is_entity_hovered(entity),
rectangle);
}
}
......
......@@ -53,7 +53,7 @@ void Screen::set_cursor_type(const cursor::type type)
void Screen::draw_mouse_cursor()
{
const sf::Vector2i pos = sf::Mouse::getPosition(*this->win);
this->cursor_sprite.setPosition(static_cast<float>(pos.x),
static_cast<float>(pos.y));
this->cursor_sprite.setPosition(static_cast<float>(pos.x) - 42.f,
static_cast<float>(pos.y) - 42.f);
this->win->draw(this->cursor_sprite);
}
......@@ -271,6 +271,6 @@ int Ui::get_display_mode()
if (display == 0)
return sf::Style::Close;
else if (display == 1)
return sf::Style::None;
return sf::Style::Titlebar;
return sf::Style::Fullscreen;
}
......@@ -30,8 +30,8 @@ public:
private:
void connect_handler(boost::function< void(void) >,
boost::function< void(void) >,
const boost::system::error_code&);
boost::function< void(void) >,
const boost::system::error_code&);
boost::asio::io_service io_service;
};
......
......@@ -36,11 +36,11 @@ void InterfaceClient::connect(const std::string& host,
{
// TODO use resolve and DNS
tcp::endpoint endpoint(boost::asio::ip::address::from_string(host), port);
log_info("Connecting");
this->socket->async_connect(endpoint,
boost::bind(&InterfaceClient::connect_handler, this,
on_success, on_failure,
boost::asio::placeholders::error));
log_info("Connecting to " << host << ":" << port);
}
void InterfaceClient::connect_handler(boost::function< void(void) > on_success,
......
opensteer @ ec62ba70
Subproject commit 3c4632360f69d11fda21d637ae6872b48fc1a42b
Subproject commit ec62ba70d30d377582a9b2a11c50dcbe8ed36e5e
......@@ -37,7 +37,7 @@ public:
}
catch (const std::exception& e)
{
return false;
return false;
}
return true;
}
......
......@@ -3,6 +3,7 @@
ClientWorld::ClientWorld():
World()
{
this->init();
}
ClientWorld::ClientWorld(Map* map):
......@@ -14,6 +15,11 @@ ClientWorld::~ClientWorld()
{
}
void ClientWorld::init()
{
}
void ClientWorld::new_occupant_callback(Command* command)
{
log_debug("new_occupant_callback");
......@@ -142,7 +148,6 @@ void ClientWorld::on_next_turn(unsigned long turn)
this->confirm_turn(turn+1);
}
bool ClientWorld::action_move(const unsigned int x, const unsigned y)
{
MoveEvent event;
......
......@@ -10,6 +10,7 @@ public:
ClientWorld();
ClientWorld(Map*);
~ClientWorld();
void init();
/**
* Tells the server that we received and inserted the action into
* our turn_handler, so we are ready to execute it when its turn comes.
......
......@@ -278,7 +278,6 @@ cell_path_t Map::do_astar(const uint startx, const uint starty,
while (open.empty() == false)
{
current = open.front();
log_error("Current node: " << current.index << ":(" << current.g << "." << current.f << ")");
if (current.index == goal)
{
return reconstruct_path(came_from, current.index);
......@@ -289,10 +288,8 @@ cell_path_t Map::do_astar(const uint startx, const uint starty,
for (std::vector<std::size_t>::const_iterator it = neighbours.begin();
it != neighbours.end(); ++it)
{
log_error("Neighbour: " << (*it));
if (is_in_set((*it), closed) == true)
{
log_error("Is already closed");
continue;
}
int tentative_g = current.g + 1;
......@@ -353,12 +350,6 @@ std::vector<std::size_t> Map::get_neighbour_nodes(const std::size_t index)
ushort neighbour_heights = this->get_cell_heights(
neighbour % this->get_width_in_tiles(),
neighbour / this->get_width_in_tiles());
log_error("Neighbour heights: " <<
((neighbour_heights) & 15) << "," <<
((neighbour_heights >> 4) & 15) << "," <<
((neighbour_heights >> 8) & 15) << "," <<
((neighbour_heights >> 12) & 15) << ".")
if ((((heights >> 8) & 15) == ((neighbour_heights >> 4) & 15)) &&
(((heights >> 12) & 15) == ((neighbour_heights) & 15)))
res.push_back(neighbour);
......@@ -431,13 +422,10 @@ cell_path_t reconstruct_path(const std::map<std::size_t, std::size_t>& came_from
{
cell_path_t res;
std::map<std::size_t, std::size_t>::const_iterator it;
log_error("Path in backward: ");
log_error(end);
res.push_back(end);
it = came_from.find(end);
while (it != came_from.end())
{
log_error((*it).second);
res.push_back((*it).second);
it = came_from.find((*it).second);
}
......
......@@ -28,6 +28,30 @@ void ServerWorld::init()
this->spawn_unit(0, 154, 512);
this->spawn_unit(0, 254, 512);
this->spawn_unit(0, 154, 312);
// this->spawn_unit(0, 254, 412);
// this->spawn_unit(0, 214, 422);
// this->spawn_unit(0, 334, 402);
// this->spawn_unit(0, 434, 452);
// this->spawn_unit(0, 534, 472);
// this->spawn_unit(0, 634, 482);
// this->spawn_unit(0, 734, 492);
// this->spawn_unit(0, 834, 392);
// this->spawn_unit(0, 734, 392);
// this->spawn_unit(0, 634, 392);
// this->spawn_unit(0, 534, 392);
// this->spawn_unit(0, 434, 392);
// this->spawn_unit(0, 334, 392);
// this->spawn_unit(0, 234, 392);
// this->spawn_unit(0, 334, 792);
// this->spawn_unit(0, 434, 792);
// this->spawn_unit(0, 534, 792);
// this->spawn_unit(0, 634, 792);
// this->spawn_unit(0, 734, 792);
// this->spawn_unit(0, 834, 792);
// this->spawn_unit(0, 934, 792);
// for (int x = 200; x < 1000; x += 62)
// for (int y = 200; y < 1000; y += 62)
// this->spawn_unit(0, x, y);
log_debug("done");
}
......
......@@ -232,6 +232,10 @@ protected:
bool started;
Replay* replay;
Map* map;
public:
// for debug
cell_path_t current_path;
};
#endif // __WORLD_HPP__
......
......@@ -15,12 +15,10 @@ int main()
window->setMouseCursorVisible(false);
GameClient* c = new GameClient();
GraphMap* map = new GraphMap;
map->load_from_file("test.tmx");
ClientWorld* world = new ClientWorld;
map->load_from_file("test4.tmx");
ClientWorld* world = new ClientWorld(map);
world->set_next_turn_callback(boost::bind(&ClientWorld::on_next_turn, world, _1));
Screen screen(world, map, window);
c->install_callback("NEW_OCCUPANT",
boost::bind(&ClientWorld::new_occupant_callback, world, _1));
......
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