Feature: Now server ports and IP are parsed using args.

This commit is contained in:
Afonso Clerigo Mendes de Sousa 2025-10-22 03:16:10 +01:00
parent 95f5652c8d
commit 73ffb9d8d2
2 changed files with 23 additions and 16 deletions

Binary file not shown.

View File

@ -18,14 +18,10 @@
#define DEBUG_CAR_INFO 0 #define DEBUG_CAR_INFO 0
const int SERVER_OUT_PORT = 12000;
const int SERVER_IN_PORT = 11000;
const char *SERVER_OUT_IP = "127.0.0.1";
const char *API_SOCKET_PATH = "/tmp/ACplayer_socket"; const char *API_SOCKET_PATH = "/tmp/ACplayer_socket";
const int MAX_PLAYERS = 64; const int MAX_PLAYERS = 64;
const int SERVER_ID = 130; const int SERVER_ID = 137;
api_packet current_packet; api_packet current_packet;
int apiSent = 0; int apiSent = 0;
@ -204,7 +200,19 @@ void init_carupdate(carAtributes *car) {
car->normalizedSplinePos = 0.0f; car->normalizedSplinePos = 0.0f;
} }
int main(void) { int main(int argc, char *argv[]) {
// Parse command-line arguments
if (argc != 4) {
fprintf(stderr, "Usage: %s <server_id> <in_port> <out_port>\n", argv[0]);
fprintf(stderr, "Example: %s 131 11001 12001\n", argv[0]);
return EXIT_FAILURE;
}
int SERVER_ID = atoi(argv[1]);
int SERVER_IN_PORT = atoi(argv[2]);
int SERVER_OUT_PORT = atoi(argv[3]);
printf("[+] Starting server...\n"); printf("[+] Starting server...\n");
printf("[+] Server listening on port %d\n", SERVER_IN_PORT); printf("[+] Server listening on port %d\n", SERVER_IN_PORT);
printf("[+] Server sending to %s:%d\n\n", SERVER_OUT_IP, SERVER_OUT_PORT); printf("[+] Server sending to %s:%d\n\n", SERVER_OUT_IP, SERVER_OUT_PORT);
@ -395,7 +403,6 @@ int main(void) {
break; break;
} }
update.isConnected = 0; // Mark as disconnected update.isConnected = 0; // Mark as disconnected
current_packet.connected_cars--; current_packet.connected_cars--;