Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

an other part of WOL fixes #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions pvpgn/src/bnetd/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ extern t_channel * channel_create(char const * fullname, char const * shortname,
channel->log = NULL;
}

channel->minmembers = 0;
channel->gameType = 0;
channel->gameExtension = NULL;

Expand Down
3 changes: 1 addition & 2 deletions pvpgn/src/bnetd/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,7 @@ static int game_report(t_game * game)
// war3 game reporting is done elsewhere, so we can skip this function
return 0;

if ((game->clienttag == CLIENTTAG_WCHAT_UINT) || (game->clienttag == CLIENTTAG_REDALERT_UINT)
|| (game->clienttag == CLIENTTAG_DUNE2000_UINT) || (game->clienttag == CLIENTTAG_NOX_UINT)
if ((game->clienttag == CLIENTTAG_WCHAT_UINT) || (game->clienttag == CLIENTTAG_NOX_UINT)
|| (game->clienttag == CLIENTTAG_NOXQUEST_UINT) || (game->clienttag == CLIENTTAG_RENEGADE_UINT)
|| (game->clienttag == CLIENTTAG_RENGDFDS_UINT) || (game->clienttag == CLIENTTAG_EMPERORBD_UINT)
|| (game->clienttag == CLIENTTAG_LOFLORE3_UINT) || (game->clienttag == CLIENTTAG_WWOL_UINT))
Expand Down
54 changes: 33 additions & 21 deletions pvpgn/src/bnetd/handle_wol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ static int _handle_privmsg_command(t_connection * conn, int numparams, char ** p
struct gamelist_data {
unsigned tcount, counter;
t_connection *conn;
t_clienttag clienttag;
};

static int append_game_info(t_game* game, void* vdata)
Expand All @@ -475,7 +476,7 @@ static int append_game_info(t_game* game, void* vdata)
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open", conn_get_socket(data->conn));
return 0;
}
if (game_get_clienttag(game) != conn_get_clienttag(data->conn)) {
if (game_get_clienttag(game) != data->clienttag) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is for a different client", conn_get_socket(data->conn));
return 0;
}
Expand Down Expand Up @@ -514,6 +515,13 @@ static int append_game_info(t_game* game, void* vdata)
/**
* The layout of the game list entry is something like this:
* #game_channel_name currentusers maxplayers gameType gameIsTournment gameExtension longIP LOCK::topic
*
* Known channel game types:
* 0 = Westwood Chat channels, 1 = Command & Conquer Win95 channels, 2 = Red Alert Win95 channels,
* 3 = Red Alert Counterstrike channels, 4 = Red Alert Aftermath channels, 5 = CnC Sole Survivor channels,
* 12 = C&C Renegade channels, 14 = Dune 2000 channels, 16 = Nox channels, 18 = Tiberian Sun channels,
* 21 = Red Alert 1 v 3.03 channels, 31 = Emperor: Battle for Dune, 33 = Red Alert 2,
* 37 = Nox Quest channels, 38,39,40 = Quickgame channels, 41 = Yuri's Revenge
*/

std::strcat(temp,gamename);
Expand Down Expand Up @@ -562,12 +570,12 @@ static int _handle_list_command(t_connection * conn, int numparams, char ** para

irc_send(conn,RPL_LISTSTART,"Channel :Users Names"); /* backward compatibility */

if ((numparams == 0) || ((numparams == 2) && (params[0]) && (params[1]) && (std::strcmp(params[0], params[1]) != 0))) {
if ((numparams == 0) || ((numparams == 2) && (params[0]) && ((std::strcmp(params[0], "0") == 0)
|| (std::strcmp(params[0], "-1") == 0)))) {
/**
* LIST all chat channels
* Emperor sends as params[0] == -1 if want QuickMatch channels too, 0 if not.
* This sends also NOX but we dunno why.
* DUNE 2000 use params[0] to determine channels by channeltype
*/

LIST_TRAVERSE_CONST(channellist(),curr) {
Expand Down Expand Up @@ -601,21 +609,18 @@ static int _handle_list_command(t_connection * conn, int numparams, char ** para
irc_send(conn,RPL_CHANNEL,temp);
}
}
/**
* Known channel game types:
* 0 = Westwood Chat channels, 1 = Command & Conquer Win95 channels, 2 = Red Alert Win95 channels,
* 3 = Red Alert Counterstrike channels, 4 = Red Alert Aftermath channels, 5 = CnC Sole Survivor channels,
* 12 = C&C Renegade channels, 14 = Dune 2000 channels, 16 = Nox channels, 18 = Tiberian Sun channels,
* 21 = Red Alert 1 v 3.03 channels, 31 = Emperor: Battle for Dune, 33 = Red Alert 2,
* 37 = Nox Quest channels, 38,39,40 = Quickgame channels, 41 = Yuri's Revenge
*/
if ((numparams == 0) || ((numparams == 2) && (params[0]) && (params[1]) && (std::strcmp(params[0], params[1]) == 0))) {
if ((numparams == 0) || ((numparams == 2) && (params[0]) && ((std::strcmp(params[0], "0") != 0)
&& (std::strcmp(params[0], "-1") != 0)))) {
eventlog(eventlog_level_debug,__FUNCTION__,"[** WOL **] LIST [Game]");
/* list games */
struct gamelist_data data;
data.tcount = 0;
data.counter = 0;
data.conn = conn;
if ((numparams == 2) && (params[0]))
data.clienttag = tag_channeltype_to_uint(std::atoi(params[0]));
else
data.clienttag = conn_get_clienttag(conn);
gamelist_traverse(&append_game_info, &data);
DEBUG3("[%d] LIST sent %u of %u games", conn_get_socket(conn), data.counter, data.tcount);
}
Expand Down Expand Up @@ -941,14 +946,14 @@ static int _handle_joingame_command(t_connection * conn, int numparams, char **
* hack in here, for Red Alert 1, it use's JOINGAME for some reason to join a lobby channel.
*
* Here is WOLv1 input expected:
* JOINGAME [#Game_channel_name] [MinPlayers] [MaxPlayers] [channelType] 1 1 [gameIsTournament]
* JOINGAME [#Game_channel_name] [MinPlayers] [MaxPlayers] [channelType] [currentPlayers] 1 [gameIsTournament]
* Knowed channelTypes (0-chat, 1-cnc, 2-ra1, 3-racs, 4-raam, 5-solsurv... listed in tag.cpp)
*
* Here is WOLv2 input expected:
* JOINGAME [#Game_channel_name] [MinPlayers] [MaxPlayers] [channelType] unknown unknown [gameIsTournament] [gameExtension] [password_optional]
* JOINGAME [#Game_channel_name] [MinPlayers] [MaxPlayers] [channelType] [currentPlayers] unknown [gameIsTournament] [gameExtension] [password_optional]
*
* Heres the output expected:
* user!WWOL@hostname JOINGAME [MinPlayers] [MaxPlayers] [channelType] unknown clanID [longIP] [gameIsTournament] :[#Game_channel_name]
* user!WWOL@hostname JOINGAME [MinPlayers] [MaxPlayers] [channelType] [currentPlayers] [clanID] [longIP] [gameIsTournament] :[#Game_channel_name]
*/
if((numparams==2) || (numparams==3)) {
char ** e;
Expand Down Expand Up @@ -1031,8 +1036,8 @@ static int _handle_joingame_command(t_connection * conn, int numparams, char **
if (channel!=old_channel) {
if (tag_check_wolv1(conn_get_clienttag(conn))) {
/* WOLv1 JOINGAME message */
std::sprintf(_temp,"%u %u %u 1 1 %u :%s", channel_get_min(channel), game_get_maxplayers(game), channel_wol_get_game_type(channel),
((game_get_type(game) == game_type_ladder) ? 1 : 0), irc_convert_channel(channel,conn));
std::sprintf(_temp,"%u %u %u %u 1 %u :%s", channel_get_min(channel), game_get_maxplayers(game), channel_wol_get_game_type(channel),
game_get_ref(game), ((game_get_type(game) == game_type_ladder) ? 1 : 0), irc_convert_channel(channel,conn));
}
else {
/* WOLv2 JOINGAME message with BATTLECLAN support */
Expand All @@ -1042,8 +1047,8 @@ static int _handle_joingame_command(t_connection * conn, int numparams, char **
if (clan)
clanid = clan_get_clanid(clan);

std::sprintf(_temp,"%u %u %u 1 %u %u %u :%s", channel_get_min(channel), game_get_maxplayers(game), channel_wol_get_game_type(channel),
clanid, conn_get_addr(conn), ((game_get_type(game) == game_type_ladder) ? 1 : 0), irc_convert_channel(channel,conn));
std::sprintf(_temp,"%u %u %u %u %u %u %u :%s", channel_get_min(channel), game_get_maxplayers(game), channel_wol_get_game_type(channel),
game_get_ref(game), clanid, conn_get_addr(conn), ((game_get_type(game) == game_type_ladder) ? 1 : 0), irc_convert_channel(channel,conn));
}

channel_set_userflags(conn);
Expand Down Expand Up @@ -1144,8 +1149,8 @@ static int _handle_gameopt_command(t_connection * conn, int numparams, char ** p
char temp[MAX_IRC_MESSAGE_LEN];

/**
* Basically this has 2 modes as like in PRIVMSG - whisper and talk. What is in
* text is pretty much unknown, we just dump this to the client to deal with...
* Basically this has 2 modes as like in PRIVMSG - whisper and talk. What is in
* text is pretty much unknown, we just dump this to the client to deal with...
*
* Heres the output expected (when gameopt is channel talk):
* user!WWOL@hostname GAMEOPT #game_channel_name :gameOptions
Expand Down Expand Up @@ -1685,6 +1690,13 @@ static int _handle_listsearch_command(t_connection * conn, int numparams, char *

if ((numparams>=1) && (params[0]) && (text)) {
cl_tag = tag_sku_to_uint(std::atoi(params[0]));

if (std::strcmp(params[0], "1005") == 0)
cl_tag = CLIENTTAG_REDALERT_UINT;
if (std::strcmp(params[0], "500") == 0)
cl_tag = CLIENTTAG_REDALAFM_UINT;

DEBUG1("Client wants LISTSEARCH for %s client", clienttag_get_title(cl_tag));

e = irc_get_ladderelems(text);

Expand Down
Loading