diff --git a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java index 953c7429..7a5d2138 100644 --- a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java +++ b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java @@ -37,17 +37,17 @@ public class DiscordHandler { byte[] sendData = ResponseMsg.getBytes("UTF-8"); int deliver_port = 0; switch (port) { - case 48470: - deliver_port = 48479; + case 48474: + deliver_port = 48470; break; - case 48471: - deliver_port = 48482; + case 48475: + deliver_port = 48471; break; - case 48472: - deliver_port = 48476; + case 48476: + deliver_port = 48472; break; - case 48473: - deliver_port = 48481; + case 48477: + deliver_port = 48473; break; } DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, ipAddress, deliver_port); @@ -56,13 +56,9 @@ public class DiscordHandler { public static void handleUDPTraffic(int port, Datahandler datahandler, StanfordCoreNLP stanfordCoreNLP, StanfordCoreNLP stanfordCoreNLPSentiment) { + try (DatagramSocket serverSocket = new DatagramSocket(port)) { - String hostIP = ""; - if (port == 48473 || port == 48471) { - hostIP = "51.15.159.31"; - } else { - hostIP = "195.154.53.196"; - } + String hostIP = "195.154.53.196"; InetAddress ipAddress = InetAddress.getByName(hostIP);//used ip' while (true) { receiveAndSendPacket(serverSocket, ipAddress, port, datahandler, stanfordCoreNLP, stanfordCoreNLPSentiment); @@ -95,7 +91,7 @@ public class DiscordHandler { for (int i = 0; i < autismbotCount; i++) { final int j = i; new Thread(() -> { - List ports = List.of(48470, 48471, 48472, 48473); + List ports = List.of(48475, 48476, 48477, 48478); handleUDPTraffic(ports.get(j), datahandler, stanfordCoreNLP, stanfordCoreNLPSentiment); }).start(); } diff --git a/AutismBotIngame/python/config.json b/AutismBotIngame/python/config.json index 0a2f59d9..b262cb42 100644 --- a/AutismBotIngame/python/config.json +++ b/AutismBotIngame/python/config.json @@ -1,6 +1,6 @@ { - "udp_port": 48482, - "chat_external_port": 48471, + "udp_port": 48470, + "chat_external_port": 48475, "steam_port": 29074, "server_ip_port": "135.125.188.157:27015" } diff --git a/AutismBotIngame/python/udp_redirecter.py b/AutismBotIngame/python/udp_redirecter.py index 9caa303e..9f00d116 100644 --- a/AutismBotIngame/python/udp_redirecter.py +++ b/AutismBotIngame/python/udp_redirecter.py @@ -14,13 +14,13 @@ import time if __name__ == '__main__': local_ip = "127.0.0.1" - local_port = 48479 + local_port = 48470 udp_external_ip = "195.154.53.196" buffer_size = 4096 #potentially not large enough? sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock_external = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - sock.bind(("", local_port)) + sock.bind(("135.125.188.157", local_port)) print('reached deadlock') try: while True: diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index e30a3409..ae095931 100644 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -18,7 +18,7 @@ int targethuman[MAXPLAYERS + 1]; int target_enemy[MAXPLAYERS + 1]; int buttons_old[MAXPLAYERS + 1]; int flags_old[MAXPLAYERS + 1]; -int ports[4] = {48479, 48482, 48476, 48481}; +int ports[5] = {48470, 48471, 48472, 48473, 48474}; //last index is port its sending udp from bool surf_cooldown = false; int bot_avoid_edge[MAXPLAYERS + 1]; float client_old_coords[MAXPLAYERS + 1][3]; @@ -867,8 +867,8 @@ stock void connect_socket() //socket otherwise declare in public OnConfigsExecuted(){} global_socket = SocketCreate(SOCKET_UDP, OnSocketError); SocketSetOption(global_socket, SocketReuseAddr, 1); - SocketBind(global_socket, "127.0.0.0", 48475); - SocketConnect(global_socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, "127.0.0.1", 48475); + SocketBind(global_socket, "127.0.0.0", ports[4]); + SocketConnect(global_socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, "127.0.0.1", ports[4]); //48474 } }