Skip to content

Commit

Permalink
Merge branch 'ddnet' into chillerbot
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Aug 21, 2024
2 parents 02dce54 + db9b5f5 commit 9fe0115
Show file tree
Hide file tree
Showing 79 changed files with 1,079 additions and 763 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/game/editor/mapitems/map_io.cpp @Patiga
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ set(EXPECTED_DATA
editor/audio_source.png
editor/automap/basic_freeze.rules
editor/automap/ddmax_freeze.rules
editor/automap/ddnet_grass.rules
editor/automap/ddnet_tiles.rules
editor/automap/ddnet_walls.rules
editor/automap/desert_main.rules
Expand All @@ -1411,7 +1412,6 @@ set(EXPECTED_DATA
editor/automap/generic_unhookable.rules
editor/automap/generic_unhookable_0.7.rules
editor/automap/grass_main.rules
editor/automap/grass_main_0.7.rules
editor/automap/jungle_main.rules
editor/automap/jungle_midground.rules
editor/automap/round_tiles.rules
Expand Down Expand Up @@ -1502,6 +1502,7 @@ set(EXPECTED_DATA
mapres/bg_cloud2.png
mapres/bg_cloud3.png
mapres/ddmax_freeze.png
mapres/ddnet_grass.png
mapres/ddnet_start.png
mapres/ddnet_tiles.json
mapres/ddnet_tiles.png
Expand Down Expand Up @@ -2158,6 +2159,7 @@ set_src(ENGINE_SHARED GLOB_RECURSE src/engine/shared
teehistorian_ex.cpp
teehistorian_ex.h
teehistorian_ex_chunks.h
translation_context.cpp
translation_context.h
uuid_manager.cpp
uuid_manager.h
Expand Down
File renamed without changes.
Binary file modified data/hud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/mapres/ddnet_grass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/mapres/grass_main_0.7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/skins7/feet/standard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions datasrc/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@
NetIntAny("m_Angle"),
]),

NetEventEx("Birthday:Common", "[email protected]", []),

NetEventEx("Finish:Common", "[email protected]", []),

NetObjectEx("MyOwnEvent", "[email protected]", [
Expand Down Expand Up @@ -372,6 +374,10 @@
NetIntAny("m_Layer"),
NetIntAny("m_EntityClass"),
]),

NetEventEx("MapSoundWorld:Common", "[email protected]", [
NetIntAny("m_SoundId"),
]),
]

Messages = [
Expand Down Expand Up @@ -583,6 +589,10 @@
NetMessageEx("Sv_ChangeInfoCooldown", "[email protected]", [
NetTick("m_WaitUntil")
]),

NetMessageEx("Sv_MapSoundGlobal", "[email protected]", [
NetIntAny("m_SoundId"),
]),
]

# ddnet++ / chillerbot-ux messages
Expand Down
75 changes: 25 additions & 50 deletions src/base/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,10 +876,15 @@ void sphore_destroy(SEMAPHORE *sem)
#elif defined(CONF_PLATFORM_MACOS)
void sphore_init(SEMAPHORE *sem)
{
char aBuf[32];
str_format(aBuf, sizeof(aBuf), "%p", (void *)sem);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "/%d.%p", pid(), (void *)sem);
*sem = sem_open(aBuf, O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, 0);
dbg_assert(*sem != SEM_FAILED, "sem_open failure");
if(*sem == SEM_FAILED)
{
char aError[128];
str_format(aError, sizeof(aError), "sem_open failure, errno=%d, name='%s'", errno, aBuf);
dbg_assert(false, aError);
}
}
void sphore_wait(SEMAPHORE *sem)
{
Expand All @@ -897,8 +902,8 @@ void sphore_signal(SEMAPHORE *sem)
void sphore_destroy(SEMAPHORE *sem)
{
dbg_assert(sem_close(*sem) == 0, "sem_close failure");
char aBuf[32];
str_format(aBuf, sizeof(aBuf), "%p", (void *)sem);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "/%d.%p", pid(), (void *)sem);
dbg_assert(sem_unlink(aBuf) == 0, "sem_unlink failure");
}
#elif defined(CONF_FAMILY_UNIX)
Expand Down Expand Up @@ -1139,22 +1144,6 @@ bool net_addr_str(const NETADDR *addr, char *string, int max_length, int add_por
return true;
}

void net_addr_url_str(const NETADDR *addr, char *string, int max_length, int add_port)
{
char ipaddr[512];
if(!net_addr_str(addr, ipaddr, sizeof(ipaddr), add_port))
{
str_copy(string, ipaddr, max_length);
return;
}
str_format(
string,
max_length,
"tw-%s+udp://%s",
addr->type & NETTYPE_TW7 ? "0.7" : "0.6",
ipaddr);
}

static int priv_net_extract(const char *hostname, char *host, int max_host, int *port)
{
int i;
Expand Down Expand Up @@ -1557,24 +1546,21 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
{
NETSOCKET sock = (NETSOCKET_INTERNAL *)malloc(sizeof(*sock));
*sock = invalid_socket;
NETADDR tmpbindaddr = bindaddr;
int broadcast = 1;
int socket = -1;

if(bindaddr.type & NETTYPE_IPV4)
{
struct sockaddr_in addr;

/* bind, we should check for error */
NETADDR tmpbindaddr = bindaddr;
tmpbindaddr.type = NETTYPE_IPV4;
netaddr_to_sockaddr_in(&tmpbindaddr, &addr);
socket = priv_net_create_socket(AF_INET, SOCK_DGRAM, (struct sockaddr *)&addr, sizeof(addr));
int socket = priv_net_create_socket(AF_INET, SOCK_DGRAM, (struct sockaddr *)&addr, sizeof(addr));
if(socket >= 0)
{
sock->type |= NETTYPE_IPV4;
sock->ipv4sock = socket;

/* set broadcast */
int broadcast = 1;
if(setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char *)&broadcast, sizeof(broadcast)) != 0)
{
dbg_msg("socket", "Setting BROADCAST on ipv4 failed: %d", net_errno());
Expand All @@ -1590,17 +1576,15 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
}
}
}

#if defined(CONF_WEBSOCKETS)
if(bindaddr.type & NETTYPE_WEBSOCKET_IPV4)
{
char addr_str[NETADDR_MAXSTRSIZE];

/* bind, we should check for error */
NETADDR tmpbindaddr = bindaddr;
tmpbindaddr.type = NETTYPE_WEBSOCKET_IPV4;

net_addr_str(&tmpbindaddr, addr_str, sizeof(addr_str), 0);
socket = websocket_create(addr_str, tmpbindaddr.port);

int socket = websocket_create(addr_str, tmpbindaddr.port);
if(socket >= 0)
{
sock->type |= NETTYPE_WEBSOCKET_IPV4;
Expand All @@ -1612,17 +1596,17 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
if(bindaddr.type & NETTYPE_IPV6)
{
struct sockaddr_in6 addr;

/* bind, we should check for error */
NETADDR tmpbindaddr = bindaddr;
tmpbindaddr.type = NETTYPE_IPV6;
netaddr_to_sockaddr_in6(&tmpbindaddr, &addr);
socket = priv_net_create_socket(AF_INET6, SOCK_DGRAM, (struct sockaddr *)&addr, sizeof(addr));
int socket = priv_net_create_socket(AF_INET6, SOCK_DGRAM, (struct sockaddr *)&addr, sizeof(addr));
if(socket >= 0)
{
sock->type |= NETTYPE_IPV6;
sock->ipv6sock = socket;

/* set broadcast */
int broadcast = 1;
if(setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char *)&broadcast, sizeof(broadcast)) != 0)
{
dbg_msg("socket", "Setting BROADCAST on ipv6 failed: %d", net_errno());
Expand All @@ -1642,20 +1626,17 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
}
}

if(socket < 0)
if(sock->type == NETTYPE_INVALID)
{
free(sock);
sock = nullptr;
}
else
{
/* set non-blocking */
net_set_non_blocking(sock);

net_buffer_init(&sock->buffer);
}

/* return */
return sock;
}

Expand Down Expand Up @@ -1871,47 +1852,41 @@ NETSOCKET net_tcp_create(NETADDR bindaddr)
{
NETSOCKET sock = (NETSOCKET_INTERNAL *)malloc(sizeof(*sock));
*sock = invalid_socket;
NETADDR tmpbindaddr = bindaddr;
int socket4 = -1;

if(bindaddr.type & NETTYPE_IPV4)
{
struct sockaddr_in addr;

/* bind, we should check for error */
NETADDR tmpbindaddr = bindaddr;
tmpbindaddr.type = NETTYPE_IPV4;
netaddr_to_sockaddr_in(&tmpbindaddr, &addr);
socket4 = priv_net_create_socket(AF_INET, SOCK_STREAM, (struct sockaddr *)&addr, sizeof(addr));
int socket4 = priv_net_create_socket(AF_INET, SOCK_STREAM, (struct sockaddr *)&addr, sizeof(addr));
if(socket4 >= 0)
{
sock->type |= NETTYPE_IPV4;
sock->ipv4sock = socket4;
}
}

int socket6 = -1;
if(bindaddr.type & NETTYPE_IPV6)
{
struct sockaddr_in6 addr;

/* bind, we should check for error */
NETADDR tmpbindaddr = bindaddr;
tmpbindaddr.type = NETTYPE_IPV6;
netaddr_to_sockaddr_in6(&tmpbindaddr, &addr);
socket6 = priv_net_create_socket(AF_INET6, SOCK_STREAM, (struct sockaddr *)&addr, sizeof(addr));
int socket6 = priv_net_create_socket(AF_INET6, SOCK_STREAM, (struct sockaddr *)&addr, sizeof(addr));
if(socket6 >= 0)
{
sock->type |= NETTYPE_IPV6;
sock->ipv6sock = socket6;
}
}

if(socket4 < 0 && socket6 < 0)
if(sock->type == NETTYPE_INVALID)
{
free(sock);
sock = nullptr;
}

/* return */
return sock;
}

Expand Down
17 changes: 0 additions & 17 deletions src/base/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -818,23 +818,6 @@ int net_addr_comp_noport(const NETADDR *a, const NETADDR *b);
*/
bool net_addr_str(const NETADDR *addr, char *string, int max_length, int add_port);

/**
* Turns a network address into a url string.
* Examples:
* tw-0.6+udp://127.0.0.1:8303
* tw-0.7+udp://127.0.0.1
*
* @ingroup Network-General
*
* @param addr Address to turn into a string.
* @param string Buffer to fill with the url string.
* @param max_length Maximum size of the url string.
* @param add_port add port to url string or not
*
* @remark The string will always be zero terminated
*/
void net_addr_url_str(const NETADDR *addr, char *string, int max_length, int add_port);

/**
* Turns url string into a network address struct.
* The url format is tw-0.6+udp://{ipaddr}[:{port}]
Expand Down
1 change: 1 addition & 0 deletions src/engine/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class IClient : public IInterface

// server info
virtual void GetServerInfo(class CServerInfo *pServerInfo) const = 0;
virtual bool ServerCapAnyPlayerFlag() const = 0;

virtual int GetPredictionTime() = 0;

Expand Down
Loading

0 comments on commit 9fe0115

Please sign in to comment.