Skip to content
Snippets Groups Projects
Commit 4d45373e authored by Samuel Moore's avatar Samuel Moore
Browse files

ipa not sfd

Derp
parent 48216daa
No related merge requests found
...@@ -67,9 +67,9 @@ class Vixen(BasicAI): ...@@ -67,9 +67,9 @@ class Vixen(BasicAI):
moveList.sort(key = lambda e : e["score"], reverse=True) moveList.sort(key = lambda e : e["score"], reverse=True)
#sys.stderr.write("vixen - best move: " + str(moveList[0]["unit"].x) + " " + str(moveList[0]["unit"].y) + " " + moveList[0]["direction"] + " [ score = " + str(moveList[0]["score"]) + " ]\n") #sys.stderr.write("vixen - best move: " + str(moveList[0]["unit"].x) + " " + str(moveList[0]["unit"].y) + " " + moveList[0]["direction"] + " [ score = " + str(moveList[0]["score"]) + " ]\n")
if moveList[0]["score"] == 0: #if moveList[0]["score"] == 0:
print "NO_MOVE" # print "NO_MOVE"
return True # return True
print str(moveList[0]["unit"].x) + " " + str(moveList[0]["unit"].y) + " " + moveList[0]["direction"] print str(moveList[0]["unit"].x) + " " + str(moveList[0]["unit"].y) + " " + moveList[0]["direction"]
......
...@@ -5,9 +5,10 @@ NetworkController::NetworkController(const Piece::Colour & newColour, const char ...@@ -5,9 +5,10 @@ NetworkController::NetworkController(const Piece::Colour & newColour, const char
struct protoent * tcp = getprotobyname("tcp"); struct protoent * tcp = getprotobyname("tcp");
sfd = socket(PF_INET, SOCK_STREAM, tcp->p_proto); sfd = socket(PF_INET, SOCK_STREAM, tcp->p_proto);
if (sfd == -1) if (sfd < 0)
{ {
fprintf(stderr, "NetworkController::NetworkController - couldn't create a TCP socket!"); // fprintf(stderr, "NetworkController::NetworkController - couldn't create a TCP socket!");
perror("NetworkController::NetworkController - creating TCP socket... ");
return; return;
} }
} }
...@@ -18,7 +19,8 @@ NetworkController::~NetworkController() ...@@ -18,7 +19,8 @@ NetworkController::~NetworkController()
{ {
if (shutdown(sfd, SHUT_RDWR) == -1) if (shutdown(sfd, SHUT_RDWR) == -1)
{ {
fprintf(stderr, "NetworkController::~NetworkController - Can't shutdown socket %d!", sfd); // fprintf(stderr, "NetworkController::~NetworkController - Can't shutdown socket %d!", sfd);
perror("NetworkController::~NetworkController - shutting down socket... ");
close(sfd); close(sfd);
sfd = -1; sfd = -1;
} }
...@@ -34,9 +36,10 @@ Server::Server(const Piece::Colour & newColour, const char * newName) : NetworkC ...@@ -34,9 +36,10 @@ Server::Server(const Piece::Colour & newColour, const char * newName) : NetworkC
ipa.sin_addr.s_addr = INADDR_ANY; ipa.sin_addr.s_addr = INADDR_ANY;
memset(&ipa,0, sizeof ipa); memset(&ipa,0, sizeof ipa);
if (bind(sfd, (struct sockaddr*)&sfd, sizeof sfd) == -1) if (bind(sfd, (struct sockaddr*)&ipa, sizeof (ipa)) == -1) //dERP DERP DERP
{ {
fprintf(stderr, "Server::Server - Couldn't bind to socket! Abort\n"); // fprintf(stderr, "Server::Server - Couldn't bind to socket! Abort\n");
perror("Server::Server - binding to socket... ");
close(sfd); close(sfd);
sfd = -1; sfd = -1;
return; return;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <unistd.h> #include <unistd.h>
#include <netdb.h> #include <netdb.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h>
#include "controller.h" #include "controller.h"
......
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