Skip to content

Commit

Permalink
Disable network play and remove SDL2_Net
Browse files Browse the repository at this point in the history
  • Loading branch information
erysdren committed Dec 18, 2023
1 parent b64252e commit 9b85704
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 72 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ jobs:
sudo apt-get install \
cmake \
libsdl2-dev \
libsdl2-mixer-dev \
libsdl2-net-dev
libsdl2-mixer-dev
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
Expand All @@ -61,8 +60,7 @@ jobs:
brew install \
cmake \
sdl2 \
sdl2_mixer \
sdl2_net
sdl2_mixer
- name: Install dependencies (MSYS2)
if: matrix.config.shell == 'msys2 {0}'
Expand All @@ -75,7 +73,6 @@ jobs:
${{ matrix.config.msys-env }}-cmake
${{ matrix.config.msys-env }}-SDL2
${{ matrix.config.msys-env }}-SDL2_mixer
${{ matrix.config.msys-env }}-SDL2_net
- uses: actions/checkout@v3

Expand Down
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ option(ROTTEN_DEB "Enable .deb file target" OFF)

find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(SDL2_net REQUIRED)

#
# sources
Expand All @@ -53,7 +52,7 @@ endif()

# registered
add_executable(rotten ${ROTTEN_SOURCES})
target_link_libraries(rotten PUBLIC SDL2::Main SDL2::Mixer SDL2::Net)
target_link_libraries(rotten PUBLIC SDL2::Main SDL2::Mixer)
target_compile_definitions(rotten PUBLIC PACKAGE_STRING="${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_VERSION}")
target_compile_definitions(rotten PUBLIC PACKAGE_TARNAME="${CMAKE_PROJECT_NAME}")
if(MSVC)
Expand All @@ -65,7 +64,7 @@ endif()
# shareware
add_executable(rotten_sw ${ROTTEN_SOURCES})
target_compile_definitions(rotten_sw PUBLIC SHAREWARE=1)
target_link_libraries(rotten_sw PUBLIC SDL2::Main SDL2::Mixer SDL2::Net)
target_link_libraries(rotten_sw PUBLIC SDL2::Main SDL2::Mixer)
target_compile_definitions(rotten_sw PUBLIC PACKAGE_STRING="${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_VERSION}")
target_compile_definitions(rotten_sw PUBLIC PACKAGE_TARNAME="${CMAKE_PROJECT_NAME}")
if(MSVC)
Expand Down
5 changes: 5 additions & 0 deletions source/develop.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SHAREWARE 0
#endif

/* disable comm-bat because it's very broken */
#ifndef ENABLE_COMMBAT
#define ENABLE_COMMBAT 0
#endif

// cute little dopefish thing, only works with special patch?
#define DOPEFISH 0

Expand Down
64 changes: 1 addition & 63 deletions source/rt_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdarg.h>

#include "SDL.h"
#include "SDL_net.h"

#include "rt_def.h"
#include "_rt_com.h"
Expand Down Expand Up @@ -57,48 +56,17 @@ int controlsynctime;
static int ComStarted = false;
static int transittimes[MAXPLAYERS];

/* SDLNet */
static UDPsocket udp_socket;
static UDPpacket **udp_packets;
static UDPpacket *udp_client_packet;
static IPaddress udp_server_address;

void SyncTime(int client);
void SetTransitTime(int client, int time);

static void ReadUDPPacket()
{
int ready;

ready = SDLNet_UDP_RecvV(udp_socket, udp_packets);

if (ready < 0)
{
Error("SDLNet_UDP_RecvV(): %s", SDLNet_GetError());
}
else if (ready == 0)
{
rottcom->remotenode = -1;
}
else
{
rottcom->remotenode = ready;
printf("\tAddress: %x %x\n", udp_packets[0]->address.host, udp_packets[0]->address.port);
}
}

static void WriteUDPPacket()
{
/* copy data */
memcpy(udp_client_packet->data, rottcom->data, rottcom->datalength);
udp_client_packet->len = rottcom->datalength;

/* set address and port */
udp_client_packet->address.host = udp_server_address.host;
udp_client_packet->address.port = udp_server_address.port;

/* send packet */
SDLNet_UDP_Send(udp_socket, -1, udp_client_packet);
}

/*
Expand All @@ -111,9 +79,7 @@ static void WriteUDPPacket()

void QuitROTTNET(void)
{
SDLNet_FreePacketV(udp_packets);
SDLNet_FreePacket(udp_client_packet);
SDLNet_Quit();

}

/*
Expand All @@ -132,10 +98,6 @@ void InitROTTNET(void)
return;
ComStarted = true;

/* init SDLNet */
if (SDLNet_Init() < 0)
Error("SDLNet_Init(): %s", SDLNet_GetError());

/*
server-specific options:
-net: enables netplay
Expand Down Expand Up @@ -191,35 +153,11 @@ void InitROTTNET(void)
}

rottcom->client = 0;

/* open socket */
udp_socket = SDLNet_UDP_Open(DEFAULTPORT);
if (udp_socket == NULL)
Error("SDLNet_UDP_Open(): %s", SDLNet_GetError());

/* allocate packets */
udp_packets = SDLNet_AllocPacketV(MAXPACKET, MAXPACKETSIZE);
if (udp_packets == NULL)
Error("SDLNet_AllocPacketV(): %s", SDLNet_GetError());
}
else
{
rottcom->client = 1;

/* open socket */
udp_socket = SDLNet_UDP_Open(0);
if (udp_socket == NULL)
Error("SDLNet_UDP_Open(): %s", SDLNet_GetError());

/* resolve server name */
if (SDLNet_ResolveHost(&udp_server_address, "192.168.0.141", DEFAULTPORT) < 0)
Error("SDLNet_ResolveHost(): %s", SDLNet_GetError());

/* open a connection with the provided IP */
udp_client_packet = SDLNet_AllocPacket(MAXPACKETSIZE);
if (udp_client_packet == NULL)
Error("SDLNet_AllocPacket(): %s", SDLNet_GetError());

/* consoleplayer will be initialized after connecting */
/* numplayers will be initialized after connecting */
/* remoteridicule will be initialized after connecting */
Expand Down
7 changes: 6 additions & 1 deletion source/rt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void CheckCommandLineParameters(void)
char *PStrings[] = {
"TEDLEVEL", "NOWAIT", "NOSOUND", "NOW", "TRANSPORT",
"DOPEFISH", "SCREENSHOTS", "MONO", "MAPSTATS", "TILESTATS",
"VER", "net", "PAUSE", "SOUNDSETUP", "WARP",
"VER", "NET", "PAUSE", "SOUNDSETUP", "WARP",
"IS8250", "ENABLEVR", "TIMELIMIT", "MAXTIMELIMIT", "NOECHO",
"DEMOEXIT", "QUIET", NULL
};
Expand Down Expand Up @@ -674,6 +674,7 @@ void CheckCommandLineParameters(void)
exit(0);
break;
case 11:
#if (ENABLE_COMMBAT == 1)
InitROTTNET();
numplayers = rottcom->numplayers;
if (numplayers > MAXPLAYERS)
Expand All @@ -693,6 +694,10 @@ void CheckCommandLineParameters(void)
printf("MODEM GAME\n");
}
break;
#else
printf("WARNING: Network play is not currently supported.\n");
break;
#endif
case 12:
infopause = true;
break;
Expand Down

0 comments on commit 9b85704

Please sign in to comment.