Commit d8cc3d68 authored by louiz’'s avatar louiz’

[dirty] more indentation ugliness

parent 5d009b60
......@@ -37,8 +37,8 @@ void Client::on_transfer_ended(const TransferReceiver* receiver)
for (it = this->receivers.begin(); it < this->receivers.end(); ++it)
if (*it == receiver)
{
this->receivers.erase(it);
break ;
this->receivers.erase(it);
break ;
}
delete receiver;
}
......
......@@ -12,14 +12,14 @@ CommandHandler::~CommandHandler()
}
void CommandHandler::install_callback(const std::string& command,
t_read_callback callback)
t_read_callback callback)
{
log_debug("installing callback for command " << command);
this->callbacks[command] = callback;
}
void CommandHandler::install_callback_once(const std::string& command,
t_read_callback callback)
t_read_callback callback)
{
log_debug("installing ONCE callback for command " << command);
this->callbacks_once[command] = callback;
......@@ -104,18 +104,18 @@ void CommandHandler::read_handler(const boost::system::error_code& error, const
const std::size_t length_to_read = this->data.size() >= size ? 0 : size - this->data.size();
boost::asio::async_read(*this->socket,
this->data,
boost::asio::transfer_at_least(length_to_read),
std::bind(&CommandHandler::binary_read_handler, this,
this->data,
boost::asio::transfer_at_least(length_to_read),
std::bind(&CommandHandler::binary_read_handler, this,
std::placeholders::_1,
command,
size, callback));
}
void CommandHandler::binary_read_handler(const boost::system::error_code& error,
Command* command,
std::size_t bytes_transferred,
t_read_callback callback)
Command* command,
std::size_t bytes_transferred,
t_read_callback callback)
{
if (error)
{
......@@ -138,9 +138,9 @@ void CommandHandler::binary_read_handler(const boost::system::error_code& error,
void CommandHandler::install_read_handler(void)
{
boost::asio::async_read_until(*this->socket,
this->data,
':',
std::bind(&CommandHandler::read_handler, this,
this->data,
':',
std::bind(&CommandHandler::read_handler, this,
std::placeholders::_1,
std::placeholders::_2));
}
......@@ -180,16 +180,16 @@ void CommandHandler::actually_send(Command* command)
buffs.push_back(boost::asio::buffer(command->header.data(), command->header.length()));
buffs.push_back(boost::asio::buffer(command->body, command->body_size));
async_write(*this->socket,
buffs,
std::bind(&CommandHandler::send_handler, this,
buffs,
std::bind(&CommandHandler::send_handler, this,
std::placeholders::_1,
std::placeholders::_2,
command));
}
void CommandHandler::send_handler(const boost::system::error_code& error,
std::size_t bytes_transferred,
Command* command)
std::size_t bytes_transferred,
Command* command)
{
this->writing = false;
assert(bytes_transferred == command->header.length() + command->body_size);
......
......@@ -35,13 +35,13 @@ void GameServer::on_new_client(RemoteGameClient* new_client)
for (it = this->world->occupants.begin(); it < this->world->occupants.end(); ++it)
{
if ((*it)->number != new_client->get_number())
{ // Do not send the information about itself, it
// already just received that.
command = new Command();
command->set_name("NEW_OCCUPANT");
command->set_body((*it)->to_string().c_str());
new_client->send(command);
}
{ // Do not send the information about itself, it
// already just received that.
command = new Command();
command->set_name("NEW_OCCUPANT");
command->set_body((*it)->to_string().c_str());
new_client->send(command);
}
}
// Send the replay to the new client.
this->send_replay(new_client);
......@@ -157,15 +157,15 @@ void GameServer::on_client_left(RemoteGameClient* client)
for (it = this->world->occupants.begin(); it < this->world->occupants.end(); ++it)
{
if ((*it)->number == client->get_number())
{
occupant_to_remove = (*it);
command->set_body(occupant_to_remove->to_string().c_str());
this->send_to_all_clients(command);
this->world->occupants.erase(it);
delete occupant_to_remove;
{
occupant_to_remove = (*it);
command->set_body(occupant_to_remove->to_string().c_str());
this->send_to_all_clients(command);
this->world->occupants.erase(it);
delete occupant_to_remove;
this->adjust_and_revalidate_futur_commands();
return ;
}
return ;
}
}
assert(false);
}
......
......@@ -52,7 +52,7 @@ void InterfaceClient::connect_handler(std::function< void(void) > on_success,
{
log_info("Connection failed: " << error);
if (on_failure)
on_failure();
on_failure();
}
else
{
......@@ -61,7 +61,7 @@ void InterfaceClient::connect_handler(std::function< void(void) > on_success,
this->install_callbacks();
this->install_read_handler();
if (on_success)
on_success();
on_success();
}
}
......
......@@ -3,7 +3,7 @@
#include <database/db_object.hpp>
RemoteClient::RemoteClient(boost::asio::io_service& io_service,
Server<RemoteClient>* server):
Server<RemoteClient>* server):
InterfaceRemoteClient(io_service),
server(server),
user(nullptr)
......@@ -61,11 +61,11 @@ void RemoteClient::auth_callback(Command* received_command)
delete user;
}
// else if (this->server->find_client_by_login(login) != 0)
// {
// log_info("Authentication: user already logged in from an other location: " << login);
// body = "4";
// delete user;
// }
// {
// log_info("Authentication: user already logged in from an other location: " << login);
// body = "4";
// delete user;
// }
else
{
log_info("Authentication: succes for user " << login);
......@@ -126,8 +126,8 @@ void RemoteClient::on_transfer_ended(const TransferSender* transfer)
for (it = this->senders.begin(); it < this->senders.end(); ++it)
if (*it == transfer)
{
this->senders.erase(it);
break ;
this->senders.erase(it);
break ;
}
delete transfer;
}
......@@ -4,7 +4,7 @@
#include <world/server_world.hpp>
RemoteGameClient::RemoteGameClient(boost::asio::io_service& io_service,
Server<RemoteGameClient>* server):
Server<RemoteGameClient>* server):
InterfaceRemoteClient(io_service),
server(server)
{
......
......@@ -3,8 +3,8 @@
#include <network/timed_event_handler.hpp>
TimedEvent::TimedEvent(TimedEventHandler* handler,
boost::asio::deadline_timer* timer,
const t_timed_callback callback):
boost::asio::deadline_timer* timer,
const t_timed_callback callback):
handler(handler),
timer(timer),
callback(callback)
......
......@@ -17,7 +17,7 @@ TimedEventHandler::~TimedEventHandler()
}
void TimedEventHandler::install_timed_event(const t_timed_callback callback,
const int delay)
const int delay)
{
log_debug("installing timed_event");
boost::asio::deadline_timer* timer = new boost::asio::deadline_timer(this->get_io_service(), boost::posix_time::seconds(delay));
......@@ -31,12 +31,12 @@ void TimedEventHandler::remove_event(TimedEvent* event)
for (it = this->events.begin(); it < this->events.end(); ++it)
{
if ((*it) == event)
{
(*it)->cancel();
delete (*it);
this->events.erase(it);
return ;
}
{
(*it)->cancel();
delete (*it);
this->events.erase(it);
return ;
}
}
}
......@@ -3,9 +3,9 @@
#include <network/client.hpp>
TransferReceiver::TransferReceiver(Client* client,
const std::string& sid,
const std::string& filename,
int length):
const std::string& sid,
const std::string& filename,
int length):
client(client),
id(sid),
filename(FILES_TO_RECEIVE_DIRECTORY + filename),
......
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