Skip to content

Commit

Permalink
cosmetic (dvlnet)
Browse files Browse the repository at this point in the history
  • Loading branch information
pionere committed Nov 18, 2023
1 parent 3ba1a25 commit 4c1b708
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Source/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static void DrawAutomapDoorDiamond(int dir, int sx, int sy)
{
// int y2;
unsigned d32 = AmLine32;
unsigned d16 = (d32 >> 1), d8 = (d32 >> 2), d4 = (d32 >> 3), d2 = (d32 >> 4);
unsigned d16 = (d32 >> 1), d8 = (d32 >> 2), d4 = (d32 >> 3);

if (dir == 0) { // WEST
sx -= d8;
Expand Down
24 changes: 13 additions & 11 deletions Source/dvlnet/base_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class base_protocol : public base_client {
virtual ~base_protocol() = default;

protected:
virtual void poll();
virtual void send_packet(packet& pkt);
virtual void disconnect_net(plr_t pnum);
virtual void close();
void poll() override;
void send_packet(packet& pkt) override;
void disconnect_net(plr_t pnum) override;
void close() override;

private:
P proto;
Expand All @@ -50,7 +50,7 @@ class base_protocol : public base_client {
template <class P>
plr_t base_protocol<P>::get_master()
{
for (plr_t i = 0; i < MAX_PLRS; ++i)
for (plr_t i = 0; i < MAX_PLRS; i++)
if (peers[i])
return i;
return plr_self;
Expand Down Expand Up @@ -90,7 +90,7 @@ template <class P>
bool base_protocol<P>::wait_firstpeer()
{
// wait for peer for 5 seconds
for (auto i = 0; i < 500; ++i) {
for (auto i = 0; i < 500; i++) {
if (game_list.count(gamename)) {
firstpeer = game_list[gamename];
break;
Expand Down Expand Up @@ -129,14 +129,16 @@ void base_protocol<P>::wait_join()
template <class P>
bool base_protocol<P>::setup_game(_uigamedata* gameData, const char* addrstr, unsigned port, const char* passwd, char (&errorText)[256])
{
bool createGame = gameData != NULL;
bool createGame;

setup_password(passwd);

createGame = gameData != NULL;
if (createGame) {
setup_gameinfo(gameData);
}
//addrstr = "fd80:56c2:e21c:0:199:931d:b14:c4d2";
plr_self = PLR_BROADCAST;
setup_password(passwd);
gamename = std::string(addrstr);
if (wait_network()) {
if (createGame) {
Expand Down Expand Up @@ -191,7 +193,7 @@ void base_protocol<P>::poll()
delete pkt;
}
while (proto.get_disconnected(sender)) {
for (plr_t i = 0; i < MAX_PLRS; ++i) {
for (plr_t i = 0; i < MAX_PLRS; i++) {
if (peers[i] == sender) {
disconnect_net(i);
break;
Expand All @@ -208,7 +210,7 @@ template <class P>
void base_protocol<P>::handle_join_request(packet& pkt, endpoint sender)
{
plr_t i;
for (i = 0; i < MAX_PLRS; ++i) {
for (i = 0; i < MAX_PLRS; i++) {
if (i != plr_self && !peers[i]) {
peers[i] = sender;
break;
Expand All @@ -218,7 +220,7 @@ void base_protocol<P>::handle_join_request(packet& pkt, endpoint sender)
//already full
return;
}
for (plr_t j = 0; j < MAX_PLRS; ++j) {
for (plr_t j = 0; j < MAX_PLRS; j++) {
if ((j != plr_self) && (j != i) && peers[j]) {
packet* infopkt = pktfty.make_out_packet<PT_CONNECT>(PLR_MASTER, PLR_BROADCAST, j, buffer_t(peers[j].addr.begin(), peers[j].addr.end()));
proto.send(sender, infopkt->encrypted_data());
Expand Down
3 changes: 1 addition & 2 deletions Source/dvlnet/tcp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ bool tcp_client::setup_game(_uigamedata* gameData, const char* addrstr, unsigned
return true; // join successful
SDL_Delay(MS_SLEEP);
}
if (i == NUM_SLEEP)
copy_cstr(errorText, "Unable to connect");
copy_cstr(errorText, "Unable to connect");
close();
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions Source/dvlnet/tcpd_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ bool tcpd_client::setup_game(_uigamedata* gameData, const char* addrstr, unsigne
return true; // join successful
SDL_Delay(MS_SLEEP);
}
if (i == NUM_SLEEP)
copy_cstr(errorText, "Unable to connect");
copy_cstr(errorText, "Unable to connect");
close();
return false;
}
Expand Down Expand Up @@ -377,7 +376,7 @@ void tcpd_client::close()

// close the server
if (local_server != NULL) {
local_server->close();
// local_server->close();
delete local_server;
local_server = NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/dvlnet/tcpd_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class tcpd_client : public base_client {
protected:
void poll() override;
void send_packet(packet& pkt) override;
void recv_connect(packet& pkt);
void recv_connect(packet& pkt) override;
void disconnect_net(plr_t pnum) override;
void close() override;

private:
Expand Down Expand Up @@ -51,7 +52,6 @@ class tcpd_client : public base_client {
bool handle_recv_newplr(const tcp_server::scc& con, packet& pkt);
bool handle_recv_packet(const tcp_server::scc& con, packet& pkt);
void drop_connection(const tcp_server::scc& con);
void disconnect_net(plr_t pnum);

void handle_recv(const asio::error_code& ec, size_t bytesRead);
void start_recv();
Expand Down

0 comments on commit 4c1b708

Please sign in to comment.