commit
a2b80dc74e
29 changed files with 223 additions and 142 deletions
|
@ -2057,6 +2057,11 @@ namespace pvpgn
|
|||
res_maps[j++] = maplists_get_map(queue, clienttag, i + 1);
|
||||
}
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "j == 0; returning \"eb2.map\"");
|
||||
return "eb2.map";
|
||||
}
|
||||
i = std::rand() % j;
|
||||
if (res_maps[i])
|
||||
selected = res_maps[i];
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace pvpgn
|
|||
{
|
||||
hero = (t_client_w3route_gameresult_hero *)packet_get_raw_data_const(packet, offset);
|
||||
|
||||
gameresult->heroes[counter].level = bn_int_get(hero->level);
|
||||
gameresult->heroes[counter].level = bn_short_get(hero->level);
|
||||
gameresult->heroes[counter].race_and_name = bn_int_get(hero->race_and_name);
|
||||
gameresult->heroes[counter].hero_xp = bn_int_get(hero->hero_xp);
|
||||
|
||||
|
|
|
@ -257,47 +257,50 @@ namespace pvpgn
|
|||
|
||||
extern int character_create(t_account * account, t_clienttag clienttag, char const * realmname, char const * name, t_character_class chclass, t_character_expansion expansion)
|
||||
{
|
||||
t_character * ch;
|
||||
|
||||
if (!account)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got NULL account");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!clienttag)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got bad clienttag");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!realmname)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got NULL realmname");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!name)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got NULL name");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ch = (t_character*)xmalloc(sizeof(t_character));
|
||||
if (account_check_closed_character(account, clienttag, realmname, name))
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "a character with the name \"{}\" does already exist in realm \"{}\"", name, realmname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
t_character* ch = (t_character*)xmalloc(sizeof(t_character));
|
||||
ch->name = xstrdup(name);
|
||||
ch->realmname = xstrdup(realmname);
|
||||
ch->guildname = xstrdup(""); /* FIXME: how does this work on Battle.net? */
|
||||
|
||||
if (account_check_closed_character(account, clienttag, realmname, name))
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "a character with the name \"{}\" does already exist in realm \"{}\"", name, realmname);
|
||||
xfree((void *)ch->realmname); /* avoid warning */
|
||||
xfree((void *)ch->name); /* avoid warning */
|
||||
xfree(ch);
|
||||
return -1;
|
||||
}
|
||||
|
||||
load_initial_data(ch, chclass, expansion);
|
||||
|
||||
account_add_closed_character(account, clienttag, ch);
|
||||
|
||||
xfree((void *)ch->name);
|
||||
xfree((void *)ch->realmname);
|
||||
xfree((void *)ch->guildname);
|
||||
xfree(ch);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -2734,6 +2734,9 @@ namespace pvpgn
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
message_destroy(message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2902,8 +2905,11 @@ namespace pvpgn
|
|||
t_connection *c = (t_connection*)data;
|
||||
|
||||
tm = std::localtime(&date);
|
||||
if (tm) std::strftime(strdate, 64, "%B %d, %Y", tm);
|
||||
else std::strcpy(strdate, localize(c, "(invalid date)").c_str());
|
||||
if (tm)
|
||||
std::strftime(strdate, 64, "%B %d, %Y", tm);
|
||||
else
|
||||
std::snprintf(strdate, sizeof strdate, "%s", localize(c, "(invalid date)").c_str());
|
||||
|
||||
message_send_text(c, message_type_info, c, strdate);
|
||||
|
||||
for (p = lstr_get_str(lstr); *p;) {
|
||||
|
@ -4667,10 +4673,9 @@ namespace pvpgn
|
|||
|
||||
static int _handle_motd_command(t_connection * c, char const *text)
|
||||
{
|
||||
char const * filename;
|
||||
std::FILE * fp;
|
||||
|
||||
filename = i18n_filename(prefs_get_motdfile(), conn_get_gamelang_localized(c));
|
||||
const char* const filename = i18n_filename(prefs_get_motdfile(), conn_get_gamelang_localized(c));
|
||||
|
||||
if (fp = std::fopen(filename, "r"))
|
||||
{
|
||||
|
@ -4683,6 +4688,9 @@ namespace pvpgn
|
|||
eventlog(eventlog_level_error, __FUNCTION__, "could not open motd file \"{}\" for reading (std::fopen: {})", filename, std::strerror(errno));
|
||||
message_send_text(c, message_type_error, c, localize(c, "Unable to open motd."));
|
||||
}
|
||||
|
||||
xfree((void*)filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4690,11 +4698,9 @@ namespace pvpgn
|
|||
{
|
||||
/* handle /tos - shows terms of service by user request -raistlinthewiz */
|
||||
|
||||
const char * filename = NULL;
|
||||
const char* const filename = i18n_filename(prefs_get_tosfile(), conn_get_gamelang_localized(c));
|
||||
std::FILE * fp;
|
||||
|
||||
filename = i18n_filename(prefs_get_tosfile(), conn_get_gamelang_localized(c));
|
||||
|
||||
/* FIXME: if user enters relative path to tos file in config,
|
||||
above routine will fail */
|
||||
|
||||
|
@ -4744,6 +4750,9 @@ namespace pvpgn
|
|||
eventlog(eventlog_level_error, __FUNCTION__, "could not open tos file \"{}\" for reading (std::fopen: {})", filename, std::strerror(errno));
|
||||
message_send_text(c, message_type_error, c, localize(c, "Unable to send TOS (Terms of Service)."));
|
||||
}
|
||||
|
||||
xfree((void*)filename);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -5148,9 +5157,6 @@ namespace pvpgn
|
|||
/* Send message to all clients (similar to announce, but in messagebox) */
|
||||
static int _handle_alert_command(t_connection * c, char const * text)
|
||||
{
|
||||
|
||||
return 0;
|
||||
/*********************************************************************/
|
||||
t_clienttag clienttag;
|
||||
t_clienttag clienttag_dest;
|
||||
|
||||
|
|
|
@ -3692,7 +3692,6 @@ namespace pvpgn
|
|||
char raceicon; /* appeared in 1.03 */
|
||||
unsigned int raceiconnumber;
|
||||
unsigned int wins;
|
||||
char const * usericon;
|
||||
char clantag_str_tmp[5];
|
||||
const char * clantag_str = NULL;
|
||||
char revtag[5];
|
||||
|
@ -3733,22 +3732,31 @@ namespace pvpgn
|
|||
}
|
||||
|
||||
// allow set icon to a user directly from the database (override default icon always if not null)
|
||||
usericon = account_get_user_icon(account, clienttag);
|
||||
const char* usericon = account_get_user_icon(account, clienttag);
|
||||
|
||||
// if custom stats is enabled then set a custom client icon by player rating
|
||||
if (prefs_get_custom_icons() == 1)
|
||||
{
|
||||
t_icon_info * icon;
|
||||
bool to_free = false;
|
||||
|
||||
// do not override userselectedicon if it's not null
|
||||
if (!usericon && (icon = customicons_get_icon_by_account(account, clienttag)))
|
||||
{
|
||||
usericon = xstrdup(icon->icon_code);
|
||||
to_free = true;
|
||||
}
|
||||
|
||||
acctlevel = 0;
|
||||
if (clantag)
|
||||
std::sprintf(tempplayerinfo, "%s %s %u %s", revtag, usericon, acctlevel, clantag_str);
|
||||
else
|
||||
std::sprintf(tempplayerinfo, "%s %s %u", revtag, usericon, acctlevel);
|
||||
|
||||
if (to_free == true)
|
||||
{
|
||||
xfree((void*)usericon);
|
||||
}
|
||||
}
|
||||
// default icon "WAR3" or "W3XP"
|
||||
else if (acctlevel == 0 && !usericon) {
|
||||
|
|
|
@ -455,13 +455,10 @@ namespace pvpgn
|
|||
|
||||
static int apireg_send(t_connection * conn, char const * command)
|
||||
{
|
||||
t_packet * p;
|
||||
char data[MAX_IRC_MESSAGE_LEN + 1];
|
||||
unsigned len = 0;
|
||||
t_elem * curr;
|
||||
|
||||
p = packet_create(packet_class_raw);
|
||||
|
||||
if (command)
|
||||
len = (std::strlen(command));
|
||||
|
||||
|
@ -473,11 +470,14 @@ namespace pvpgn
|
|||
std::sprintf(data, "%s", command);
|
||||
}
|
||||
|
||||
packet_set_size(p, 0);
|
||||
packet_append_data(p, data, len);
|
||||
DEBUG2("[{}] sent \"{}\"", conn_get_socket(conn), data);
|
||||
conn_push_outqueue(conn, p);
|
||||
packet_del_ref(p);
|
||||
{
|
||||
t_packet* const p = packet_create(packet_class_raw);
|
||||
packet_set_size(p, 0);
|
||||
packet_append_data(p, data, len);
|
||||
DEBUG2("[{}] sent \"{}\"", conn_get_socket(conn), data);
|
||||
conn_push_outqueue(conn, p);
|
||||
packet_del_ref(p);
|
||||
}
|
||||
|
||||
/* In apiregister server we must destroy apiregmember and connection after send packet */
|
||||
|
||||
|
@ -889,7 +889,10 @@ namespace pvpgn
|
|||
t_apiregmember * apiregmemberlist = (t_apiregmember*)elem_get_data(curr);
|
||||
|
||||
if (conn == apiregmember_get_conn(apiregmemberlist))
|
||||
{
|
||||
apiregmember_destroy(apiregmember, &curr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
conn_set_state(conn, conn_state_destroy);
|
||||
|
|
|
@ -669,10 +669,8 @@ namespace pvpgn
|
|||
|
||||
static int _client_createaccountw3(t_connection * c, t_packet const *const packet)
|
||||
{
|
||||
t_packet *rpacket;
|
||||
char const *username;
|
||||
char const *plainpass;
|
||||
char lpass[20];
|
||||
t_hash sc_hash;
|
||||
unsigned int i;
|
||||
const char *account_salt;
|
||||
|
@ -717,39 +715,51 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
rpacket = packet_create(packet_class_bnet);
|
||||
t_packet* const rpacket = packet_create(packet_class_bnet);
|
||||
if (!rpacket)
|
||||
return -1;
|
||||
|
||||
packet_set_size(rpacket, sizeof(t_server_createaccount_w3));
|
||||
packet_set_type(rpacket, SERVER_CREATEACCOUNT_W3);
|
||||
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[{}] new account requested for \"{}\"", conn_get_socket(c), username);
|
||||
|
||||
if (prefs_get_allow_new_accounts() == 0) {
|
||||
if (prefs_get_allow_new_accounts() == 0)
|
||||
{
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[{}] account not created (disabled)", conn_get_socket(c));
|
||||
bn_int_set(&rpacket->u.server_createaccount_w3.result, SERVER_CREATEACCOUNT_W3_RESULT_EXIST);
|
||||
goto out;
|
||||
conn_push_outqueue(c, rpacket);
|
||||
packet_del_ref(rpacket);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (account_check_name(username) < 0) {
|
||||
if (account_check_name(username) < 0)
|
||||
{
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[{}] account not created (invalid symbols)", conn_get_socket(c));
|
||||
bn_int_set(&rpacket->u.server_createaccount_w3.result, SERVER_CREATEACCOUNT_W3_RESULT_INVALID);
|
||||
goto out;
|
||||
conn_push_outqueue(c, rpacket);
|
||||
packet_del_ref(rpacket);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (plainpass) {
|
||||
char lpass[20] = {};
|
||||
if (plainpass)
|
||||
{
|
||||
/* convert plaintext password to lowercase for sc etc. */
|
||||
std::strncpy(lpass, plainpass, 16);
|
||||
lpass[16] = 0;
|
||||
std::snprintf(lpass, sizeof lpass, "%s", plainpass);
|
||||
strtolower(lpass);
|
||||
}
|
||||
|
||||
//set password hash for sc etc.
|
||||
bnet_hash(&sc_hash, std::strlen(lpass), lpass);
|
||||
if (!(account = accountlist_create_account(username, hash_get_str(sc_hash))))
|
||||
{
|
||||
bn_int_set(&rpacket->u.server_createaccount_w3.result, SERVER_CREATEACCOUNT_W3_RESULT_EXIST);
|
||||
else {
|
||||
if (presume_plainpass) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (presume_plainpass)
|
||||
{
|
||||
BigInt salt = BigInt((unsigned char*)account_salt, 32, 4, false);
|
||||
BnetSRP3 srp3 = BnetSRP3(username, plainpass);
|
||||
srp3.setSalt(salt);
|
||||
|
@ -765,7 +775,6 @@ namespace pvpgn
|
|||
bn_int_set(&rpacket->u.server_createaccount_w3.result, SERVER_CREATEACCOUNT_W3_RESULT_OK);
|
||||
}
|
||||
|
||||
out:
|
||||
conn_push_outqueue(c, rpacket);
|
||||
packet_del_ref(rpacket);
|
||||
|
||||
|
@ -1668,6 +1677,8 @@ namespace pvpgn
|
|||
else {
|
||||
bn_int_set(&rpacket->u.server_loginreply2.message, SERVER_LOGINREPLY2_MESSAGE_BADPASS);
|
||||
}
|
||||
|
||||
packet_del_ref(rpacket);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1766,6 +1777,7 @@ namespace pvpgn
|
|||
{
|
||||
// feature to break login from Lua
|
||||
conn_set_state(c, conn_state_destroy);
|
||||
packet_del_ref(rpacket);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -2255,7 +2267,10 @@ namespace pvpgn
|
|||
packet_set_type(rpacket, SERVER_FRIENDSLISTREPLY);
|
||||
|
||||
if ((flist = account_get_friends(account)) == NULL)
|
||||
{
|
||||
packet_del_ref(rpacket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
frienduid = account_get_friend(account, i);
|
||||
|
@ -2746,7 +2761,6 @@ namespace pvpgn
|
|||
static int _client_motdw3(t_connection * c, t_packet const *const packet)
|
||||
{
|
||||
t_packet *rpacket;
|
||||
char serverinfo[512];
|
||||
t_clienttag ctag;
|
||||
t_motd_data motdd;
|
||||
|
||||
|
@ -2785,20 +2799,19 @@ namespace pvpgn
|
|||
|
||||
|
||||
// read text from bnmotd_w3.txt
|
||||
char const * filename;
|
||||
char * buff, *line;
|
||||
char * buff;
|
||||
std::FILE * fp;
|
||||
|
||||
filename = i18n_filename(prefs_get_motdw3file(), conn_get_gamelang_localized(c));
|
||||
const char* const filename = i18n_filename(prefs_get_motdw3file(), conn_get_gamelang_localized(c));
|
||||
|
||||
char serverinfo[512] = {};
|
||||
if (fp = std::fopen(filename, "r"))
|
||||
{
|
||||
strcpy(serverinfo, ""); // init
|
||||
while ((buff = file_get_line(fp)))
|
||||
{
|
||||
line = message_format_line(c, buff);
|
||||
strcat(serverinfo, &line[1]);
|
||||
strcat(serverinfo, "\n");
|
||||
char* line = message_format_line(c, buff);
|
||||
std::snprintf(serverinfo, sizeof serverinfo, "%s\n", &line[1]);
|
||||
xfree((void*)line);
|
||||
}
|
||||
if (std::fclose(fp) < 0)
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "could not close motdw3 file \"{}\" after reading (std::fopen: {})", filename, std::strerror(errno));
|
||||
|
@ -2807,6 +2820,7 @@ namespace pvpgn
|
|||
|
||||
conn_push_outqueue(c, rpacket);
|
||||
packet_del_ref(rpacket);
|
||||
xfree((void*)filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -4841,6 +4855,7 @@ namespace pvpgn
|
|||
char membercount;
|
||||
if (packet_get_size(packet) < offset + 1) {
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad CLAN_CREATEINVITEREQ packet (missing membercount)", conn_get_socket(c));
|
||||
packet_del_ref(rpacket);
|
||||
return -1;
|
||||
}
|
||||
membercount = *((char *)packet_get_data_const(packet, offset, 1));
|
||||
|
@ -4900,6 +4915,11 @@ namespace pvpgn
|
|||
}
|
||||
offset = sizeof(t_client_clan_createinvitereply);
|
||||
username = packet_get_str_const(packet, offset, MAX_USERNAME_LEN);
|
||||
if (!username)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad CLAN_CREATEINVITEREPLY packet (bad username)", conn_get_socket(c));
|
||||
return -1;
|
||||
}
|
||||
offset += (std::strlen(username) + 1);
|
||||
if (packet_get_size(packet) < offset + 1) {
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad CLAN_CREATEINVITEREPLY packet (mising status)", conn_get_socket(c));
|
||||
|
@ -4958,9 +4978,9 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((rpacket = packet_create(packet_class_bnet)) != NULL) {
|
||||
if ((rpacket = packet_create(packet_class_bnet)) != NULL)
|
||||
{
|
||||
int offset = sizeof(t_client_clanmember_rankupdate_req);
|
||||
const char *username;
|
||||
char status;
|
||||
t_clan *clan;
|
||||
t_clanmember *dest_member;
|
||||
|
@ -4971,10 +4991,19 @@ namespace pvpgn
|
|||
packet_set_type(rpacket, SERVER_CLANMEMBER_RANKUPDATE_REPLY);
|
||||
bn_int_set(&rpacket->u.server_clanmember_rankupdate_reply.count,
|
||||
bn_int_get(packet->u.client_clanmember_rankupdate_req.count));
|
||||
username = packet_get_str_const(packet, offset, MAX_USERNAME_LEN);
|
||||
const char* const username = packet_get_str_const(packet, offset, MAX_USERNAME_LEN);
|
||||
if (!username)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[{}] Could not retrieve username from CLANMEMBER_RANKUPDATE_REQ packet", conn_get_socket(c));
|
||||
packet_del_ref(rpacket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset += (std::strlen(username) + 1);
|
||||
if (packet_get_size(packet) < offset + 1) {
|
||||
if (packet_get_size(packet) < offset + 1)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad CLANMEMBER_RANKUPDATE_REQ packet (mising status)", conn_get_socket(c));
|
||||
packet_del_ref(rpacket);
|
||||
return -1;
|
||||
}
|
||||
status = *((char *)packet_get_data_const(packet, offset, 1));
|
||||
|
@ -5395,8 +5424,8 @@ namespace pvpgn
|
|||
const char * data;
|
||||
std::string data_s;
|
||||
|
||||
gametype = bn_int_get(packet->u.client_extrawork.gametype);
|
||||
length = bn_int_get(packet->u.client_extrawork.length);
|
||||
gametype = bn_short_get(packet->u.client_extrawork.gametype);
|
||||
length = bn_short_get(packet->u.client_extrawork.length);
|
||||
|
||||
if (!(data = (const char *)packet_get_raw_data_const(packet, sizeof(t_client_extrawork)))) {
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[{}] got bad EXTRAWORK packet (missing or too long data)", conn_get_socket(c));
|
||||
|
|
|
@ -104,10 +104,10 @@ namespace pvpgn
|
|||
{
|
||||
case CLIENT_FILE_REQ3:
|
||||
{
|
||||
char rawname[MAX_FILENAME_STR];
|
||||
char rawname[MAX_FILENAME_STR] = {};
|
||||
|
||||
psock_recv(conn_get_socket(c), rawname, MAX_FILENAME_STR, 0);
|
||||
file_send(c, rawname, 0, 0, 0, 1);
|
||||
psock_recv(conn_get_socket(c), rawname, MAX_FILENAME_STR, 0);
|
||||
file_send(c, rawname, 0, 0, 0, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include "compat/strcasecmp.h"
|
||||
#include "common/eventlog.h"
|
||||
|
@ -154,12 +155,9 @@ namespace pvpgn
|
|||
char * bnet_command = NULL; /* amadeo: used for battle.net.commands */
|
||||
int unrecognized_before = 0;
|
||||
int linelen; /* amadeo: counter for stringlenghts */
|
||||
|
||||
int numparams = 0;
|
||||
char * tempparams;
|
||||
int i;
|
||||
char paramtemp[MAX_IRC_MESSAGE_LEN * 2];
|
||||
int first = 1;
|
||||
|
||||
if (!conn) {
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got NULL connection");
|
||||
|
@ -229,17 +227,25 @@ namespace pvpgn
|
|||
for (numparams = 0; params[numparams]; numparams++);
|
||||
}
|
||||
|
||||
std::memset(paramtemp, 0, sizeof(paramtemp));
|
||||
for (i = 0; ((numparams > 0) && (params[i])); i++) {
|
||||
if (!first)
|
||||
std::strcat(paramtemp, " ");
|
||||
std::strcat(paramtemp, "\"");
|
||||
std::strcat(paramtemp, params[i]);
|
||||
std::strcat(paramtemp, "\"");
|
||||
first = 0;
|
||||
}
|
||||
{
|
||||
std::string paramtemp;
|
||||
bool first = true;
|
||||
for (i = 0; ((numparams > 0) && (params[i])); i++)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
paramtemp.append(" ");
|
||||
}
|
||||
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[{}] got \"{}\" \"{}\" [{}] \"{}\"", conn_get_socket(conn), ((prefix) ? (prefix) : ("")), command, paramtemp, ((text) ? (text) : ("")));
|
||||
paramtemp.append("\"" + std::string(params[i]) + "\"");
|
||||
}
|
||||
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[{}] got \"{}\" \"{}\" [{}] \"{}\"", conn_get_socket(conn), ((prefix) ? (prefix) : ("")), command, paramtemp, ((text) ? (text) : ("")));
|
||||
}
|
||||
|
||||
if (conn_get_class(conn) == conn_class_ircinit) {
|
||||
handle_irc_common_set_class(conn, command, numparams, params, text);
|
||||
|
|
|
@ -341,6 +341,7 @@ namespace pvpgn
|
|||
strtolower(pass);
|
||||
|
||||
bnet_hash(&pass_hash, std::strlen(pass), pass);
|
||||
xfree((void *)pass);
|
||||
|
||||
tempacct = accountlist_create_account(user, hash_get_str(pass_hash));
|
||||
if (!tempacct) {
|
||||
|
@ -348,8 +349,6 @@ namespace pvpgn
|
|||
irc_send(conn, RPL_BAD_LOGIN, ":Account creating failed");
|
||||
return 0;
|
||||
}
|
||||
if (pass)
|
||||
xfree((void *)pass);
|
||||
|
||||
conn_set_user(conn, user);
|
||||
conn_set_owner(conn, user);
|
||||
|
@ -1287,15 +1286,15 @@ namespace pvpgn
|
|||
|
||||
if ((numparams >= 2) && (params[1])) {
|
||||
int i;
|
||||
char ** e;
|
||||
|
||||
std::memset(temp, 0, sizeof(temp));
|
||||
|
||||
e = irc_get_listelems(params[1]);
|
||||
char ** e = irc_get_listelems(params[1]);
|
||||
/* FIXME: support wildcards! */
|
||||
|
||||
if (!(game = conn_get_game(conn))) {
|
||||
ERROR0("conn has not game");
|
||||
irc_unget_listelems(e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1573,6 +1572,9 @@ namespace pvpgn
|
|||
message_send_text(user, message_type_invmsg, conn, temp);
|
||||
}
|
||||
}
|
||||
|
||||
if (e)
|
||||
irc_unget_listelems(e);
|
||||
}
|
||||
else {
|
||||
irc_send(conn, ERR_NEEDMOREPARAMS, "INVMSG :Not enough parameters");
|
||||
|
|
|
@ -810,7 +810,7 @@ namespace pvpgn
|
|||
break;
|
||||
default:
|
||||
WARN1("got unknown gameres type {} for SDFX", static_cast<int>(type));
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sdfx)
|
||||
|
@ -856,7 +856,7 @@ namespace pvpgn
|
|||
break;
|
||||
default:
|
||||
WARN1("got unknown gameres type {} for GSKU", static_cast<int>(type));
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((sku) && (game) && (game_get_clienttag(game) == tag_sku_to_uint(sku))) {
|
||||
|
@ -1032,7 +1032,7 @@ namespace pvpgn
|
|||
break;
|
||||
default:
|
||||
WARN1("got unknown gameres type {} for SHRT", static_cast<int>(type));
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (shortgame)
|
||||
|
@ -1112,7 +1112,7 @@ namespace pvpgn
|
|||
break;
|
||||
default:
|
||||
WARN1("got unknown gameres type {} for CRAT", static_cast<int>(type));
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (crates)
|
||||
|
@ -1478,7 +1478,7 @@ namespace pvpgn
|
|||
break;
|
||||
default:
|
||||
WARN1("got unknown gameres type {} for FLAG", static_cast<int>(type));
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (captureflag)
|
||||
|
|
|
@ -88,7 +88,6 @@ namespace pvpgn
|
|||
{
|
||||
char temp[MAX_IRC_MESSAGE_LEN];
|
||||
t_clienttag clienttag;
|
||||
char *filestring;
|
||||
char const *ftphostname;
|
||||
char const *ftpusername;
|
||||
char const *ftppassword;
|
||||
|
@ -104,22 +103,28 @@ namespace pvpgn
|
|||
* :[servername] 606 [username] :[ftpserveraddr] [ftpusername] [ftppaswd] [path] [file.rtp] [newversion] [SKU] REQ
|
||||
*/
|
||||
|
||||
if (numparams >= 2) {
|
||||
if (numparams >= 2)
|
||||
{
|
||||
clienttag = tag_sku_to_uint(std::atoi(params[0]));
|
||||
|
||||
if (clienttag != CLIENTTAG_WWOL_UINT)
|
||||
conn_set_clienttag(conn, clienttag);
|
||||
|
||||
if (filestring = autoupdate_check(ARCHTAG_WINX86_UINT, clienttag, TAG_UNKNOWN_UINT, params[1], params[0])) {
|
||||
const char* const filestring = autoupdate_check(ARCHTAG_WINX86_UINT, clienttag, TAG_UNKNOWN_UINT, params[1], params[0]);
|
||||
if (filestring)
|
||||
{
|
||||
//:westwood-patch.ea.com update world96 lore3/1.003 65539_65536_6400.rtp 65539 6400 REQ
|
||||
ftphostname = prefs_get_wol_autoupdate_serverhost();
|
||||
ftpusername = prefs_get_wol_autoupdate_username();
|
||||
ftppassword = prefs_get_wol_autoupdate_password();
|
||||
std::snprintf(temp, sizeof(temp), ":%s %s %s %s 131075 %s REQ", ftphostname, ftpusername, ftppassword, filestring, params[0]);
|
||||
irc_send(conn, RPL_UPDATE_FTP, temp);
|
||||
xfree((void*)filestring);
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_send(conn, RPL_UPDATE_NONEX, ":Update record non-existant");
|
||||
}
|
||||
}
|
||||
else
|
||||
irc_send(conn, ERR_NEEDMOREPARAMS, "VERCHK :Not enough parameters");
|
||||
|
|
|
@ -536,13 +536,11 @@ namespace pvpgn
|
|||
}
|
||||
|
||||
|
||||
char const * val = (return_alias)
|
||||
? xstrdup(var->key)
|
||||
: xstrdup(var->value);
|
||||
std::string val = (return_alias) ? var->key: var->value;
|
||||
|
||||
if (!output.empty())
|
||||
output += ", ";
|
||||
output += std::string(val);
|
||||
output += val;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -584,6 +584,7 @@ namespace pvpgn
|
|||
if (!entry)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "ipbanlist contains NULL item");
|
||||
ipban_unload_entry(to_delete);
|
||||
return -1;
|
||||
}
|
||||
if (ipban_identical_entry(to_delete, entry))
|
||||
|
|
|
@ -1444,10 +1444,15 @@ namespace pvpgn
|
|||
std::snprintf(temp, sizeof(temp), "%s :You're not on that channel", e[0]);
|
||||
irc_send(conn, ERR_NOTONCHANNEL, temp);
|
||||
}
|
||||
irc_unget_listelems(e);
|
||||
}
|
||||
else
|
||||
irc_send(conn, ERR_NEEDMOREPARAMS, "TOPIC :Not enough parameters");
|
||||
|
||||
if (e)
|
||||
{
|
||||
irc_unget_listelems(e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -679,6 +679,7 @@ namespace pvpgn
|
|||
std::sprintf(msgtemp, "%s change mode: %s\r\n", tname, text);
|
||||
conn_unget_chatcharname(me, tname);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got bad message type {}", (int)type);
|
||||
return -1;
|
||||
|
|
|
@ -160,15 +160,19 @@ namespace pvpgn
|
|||
if (!len) continue; /* empty line */
|
||||
buff[len] = '\0';
|
||||
|
||||
if (buff[0] == '{') {
|
||||
if (_news_parsetime(buff + 1, &date, line)) {
|
||||
if (buff[0] == '{')
|
||||
{
|
||||
if (_news_parsetime(buff + 1, &date, line))
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "error parsing news date on line {}", line);
|
||||
xfree((void*)ENfilename);
|
||||
std::fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
date_set = 1;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
ni = (t_news_index*)xmalloc(sizeof(t_news_index));
|
||||
if (date_set)
|
||||
ni->date = std::mktime(&date);
|
||||
|
|
|
@ -88,46 +88,24 @@ namespace pvpgn
|
|||
t_elem const * currl;
|
||||
t_addr const * addrt;
|
||||
t_elem const * currt;
|
||||
t_trackpacket packet;
|
||||
struct sockaddr_in tempaddr;
|
||||
t_laddr_info * laddr_info;
|
||||
char tempa[64];
|
||||
char tempb[64];
|
||||
|
||||
t_trackpacket packet = {};
|
||||
if (addrlist_get_length(track_servers) > 0)
|
||||
{
|
||||
std::memset(&packet, 0, sizeof(packet));
|
||||
bn_short_nset(&packet.packet_version, (unsigned short)TRACK_VERSION);
|
||||
bn_short_nset(&packet.packet_version, static_cast<unsigned short>(TRACK_VERSION));
|
||||
/* packet.port is set below */
|
||||
bn_int_nset(&packet.flags, 0);
|
||||
std::strncpy((char *)packet.server_location,
|
||||
prefs_get_location(),
|
||||
sizeof(packet.server_location));
|
||||
bn_byte_set(&packet.server_location[sizeof(packet.server_location) - 1], '\0');
|
||||
std::strncpy((char *)packet.software,
|
||||
PVPGN_SOFTWARE,
|
||||
sizeof(packet.software));
|
||||
bn_byte_set(&packet.software[sizeof(packet.software) - 1], '\0');
|
||||
std::strncpy((char *)packet.version,
|
||||
PVPGN_VERSION,
|
||||
sizeof(packet.version));
|
||||
bn_byte_set(&packet.version[sizeof(packet.version) - 1], '\0');
|
||||
std::strncpy((char *)packet.server_desc,
|
||||
prefs_get_description(),
|
||||
sizeof(packet.server_desc));
|
||||
bn_byte_set(&packet.server_desc[sizeof(packet.server_desc) - 1], '\0');
|
||||
std::strncpy((char *)packet.server_url,
|
||||
prefs_get_url(),
|
||||
sizeof(packet.server_url));
|
||||
bn_byte_set(&packet.server_url[sizeof(packet.server_url) - 1], '\0');
|
||||
std::strncpy((char *)packet.contact_name,
|
||||
prefs_get_contact_name(),
|
||||
sizeof(packet.contact_name));
|
||||
bn_byte_set(&packet.contact_name[sizeof(packet.contact_name) - 1], '\0');
|
||||
std::strncpy((char *)packet.contact_email,
|
||||
prefs_get_contact_email(),
|
||||
sizeof(packet.contact_email));
|
||||
bn_byte_set(&packet.contact_email[sizeof(packet.contact_email) - 1], '\0');
|
||||
std::snprintf(reinterpret_cast<char*>(packet.server_location), sizeof packet.server_location, "%s", prefs_get_location());
|
||||
std::snprintf(reinterpret_cast<char*>(packet.software), sizeof packet.software, PVPGN_SOFTWARE);
|
||||
std::snprintf(reinterpret_cast<char*>(packet.version), sizeof packet.version, PVPGN_VERSION);
|
||||
std::snprintf(reinterpret_cast<char*>(packet.server_desc), sizeof packet.server_desc, "%s", prefs_get_description());
|
||||
std::snprintf(reinterpret_cast<char*>(packet.server_url), sizeof packet.server_url, "%s", prefs_get_url());
|
||||
std::snprintf(reinterpret_cast<char*>(packet.contact_name), sizeof packet.contact_name, "%s", prefs_get_contact_name());
|
||||
std::snprintf(reinterpret_cast<char*>(packet.contact_email), sizeof packet.contact_email, "%s", prefs_get_contact_email());
|
||||
bn_int_nset(&packet.users, connlist_login_get_length());
|
||||
bn_int_nset(&packet.channels, channellist_get_length());
|
||||
bn_int_nset(&packet.games, gamelist_get_length());
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace pvpgn
|
|||
std::strftime(time_string, USEREVENT_TIME_MAXLEN, USEREVENT_TIME_FORMAT, tmnow);
|
||||
|
||||
|
||||
char * filename = userlog_filename(account_get_name(account), true);
|
||||
const char* const filename = userlog_filename(account_get_name(account), true);
|
||||
|
||||
if (FILE *fp = fopen(filename, "a"))
|
||||
{
|
||||
|
@ -152,6 +152,8 @@ namespace pvpgn
|
|||
{
|
||||
ERROR1("could not write into user log file \"{}\"", filename);
|
||||
}
|
||||
|
||||
xfree((void*)filename);
|
||||
}
|
||||
|
||||
// read "count" lines from the end starting from "startline"
|
||||
|
@ -160,7 +162,12 @@ namespace pvpgn
|
|||
if (!username)
|
||||
throw std::runtime_error("username is a nullptr");
|
||||
|
||||
FILE* fp = std::fopen(userlog_filename(username), "r");
|
||||
FILE* fp = nullptr;
|
||||
{
|
||||
const char* const filename = userlog_filename(username);
|
||||
fp = std::fopen(filename, "r");
|
||||
xfree((void*)filename);
|
||||
}
|
||||
if (!fp)
|
||||
throw std::runtime_error("Could not open userlog");
|
||||
|
||||
|
@ -168,7 +175,7 @@ namespace pvpgn
|
|||
std::fseek(fp, 0, SEEK_END);
|
||||
|
||||
long pos = std::ftell(fp);
|
||||
char c = {}, prev_c = {};
|
||||
int c = {}, prev_c = {};
|
||||
std::map<long, char*> lines;
|
||||
long linecount = 0;
|
||||
char line[MAX_MESSAGE_LEN + 1] = {};
|
||||
|
|
|
@ -253,6 +253,7 @@ namespace pvpgn
|
|||
pktlen = 0;
|
||||
}
|
||||
std::fprintf(stderr, "RLE_compress: wrote %u bytes (%u uncompressed)\n", actual, perceived);
|
||||
xfree((void*)pktdata);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -554,6 +554,10 @@ namespace pvpgn
|
|||
}
|
||||
|
||||
packet_destroy(rpacket);
|
||||
|
||||
if (lsock >= 0)
|
||||
psock_close(lsock);
|
||||
|
||||
return sd;
|
||||
}
|
||||
|
||||
|
|
|
@ -234,14 +234,17 @@ namespace pvpgn
|
|||
else
|
||||
port = defport;
|
||||
|
||||
char addrstr[INET_ADDRSTRLEN] = {};
|
||||
|
||||
if (tstr[0] != '\0')
|
||||
{
|
||||
hoststr = tstr;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct sockaddr_in tsa;
|
||||
|
||||
struct sockaddr_in tsa {};
|
||||
tsa.sin_addr.s_addr = htonl(defipaddr);
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
|
||||
hoststr = inet_ntop(AF_INET, &(tsa.sin_addr), addrstr, sizeof(addrstr));
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,9 @@ namespace pvpgn
|
|||
|
||||
extern const char* conf_get_int(unsigned ival)
|
||||
{
|
||||
return std::to_string(ival).c_str();
|
||||
static char buffer[128] = {};
|
||||
std::snprintf(buffer, sizeof buffer, "%u", ival);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
extern const char* conf_get_bool(unsigned ival)
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace pvpgn
|
|||
fmt.yHeight = 160;
|
||||
fmt.dwEffects = 0;
|
||||
fmt.crTextColor = clr;
|
||||
std::swprintf(fmt.szFaceName, sizeof fmt.szFaceName, L"%ls", L"Courier New");
|
||||
std::swprintf(fmt.szFaceName, sizeof fmt.szFaceName / sizeof *fmt.szFaceName, L"%ls", L"Courier New");
|
||||
|
||||
SendMessageW(ghwndConsole, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
|
||||
SendMessageA(ghwndConsole, EM_REPLACESEL, FALSE, (LPARAM)str);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#ifndef PVPGN_VERSION
|
||||
#define PVPGN_VERSION "1.99.7-PRO"
|
||||
#define PVPGN_VERSIONW WIDEN(PVPGN_VERSIONW)
|
||||
#define PVPGN_VERSIONW WIDEN(PVPGN_VERSION)
|
||||
#endif
|
||||
|
||||
#ifndef PVPGN_SOFTWARE
|
||||
|
|
|
@ -80,8 +80,9 @@ namespace pvpgn
|
|||
bn_short_set((bn_short *)((char *)buffer + D2CHARSAVE_STATUS_OFFSET_109), status);
|
||||
|
||||
// charname
|
||||
std::strncpy((char *)buffer + D2CHARSAVE_CHARNAME_OFFSET_109, new char[MAX_CHARNAME_LEN], MAX_CHARNAME_LEN); // clear first
|
||||
std::strncpy((char *)buffer + D2CHARSAVE_CHARNAME_OFFSET_109, charname, MAX_CHARNAME_LEN);
|
||||
std::memset(buffer + D2CHARSAVE_CHARNAME_OFFSET_109, '\0', MAX_CHARNAME_LEN); // clear first
|
||||
std::strncpy((char *)buffer + D2CHARSAVE_CHARNAME_OFFSET_109, charname, MAX_CHARNAME_LEN);
|
||||
std::memset(buffer + D2CHARSAVE_CHARNAME_OFFSET_109 + MAX_CHARNAME_LEN - 1, '\0', 1);
|
||||
|
||||
// checksum
|
||||
checksum = d2charsave_checksum((unsigned char *)buffer, size, D2CHARSAVE_CHECKSUM_OFFSET);
|
||||
|
|
|
@ -190,7 +190,7 @@ namespace pvpgn
|
|||
bn_int_set(&ladderinfo->explow, bn_int_get(info->experience));
|
||||
bn_int_set(&ladderinfo->exphigh, 0);
|
||||
bn_short_set(&ladderinfo->status, ladderstatus);
|
||||
bn_byte_set(&ladderinfo->level, bn_int_get(info->level));
|
||||
bn_byte_set(&ladderinfo->level, bn_byte_get(info->level));
|
||||
bn_byte_set(&ladderinfo->u1, 0);
|
||||
std::strncpy(ladderinfo->charname, info->charname, MAX_CHARNAME_LEN);
|
||||
ladder_data[type].curr_len++;
|
||||
|
|
|
@ -252,23 +252,26 @@ extern int main(int argc, char ** argv)
|
|||
#endif
|
||||
{
|
||||
int pid;
|
||||
char * pidfile;
|
||||
|
||||
eventlog_set(stderr);
|
||||
if (!((pid = config_init(argc, argv)) == 0)) {
|
||||
// if (pid==1) pid=0;
|
||||
return pid;
|
||||
}
|
||||
pidfile = write_to_pidfile();
|
||||
const char* const pidfile = write_to_pidfile();
|
||||
eventlog(eventlog_level_info,__FUNCTION__,D2CS_VERSION);
|
||||
if (init()<0) {
|
||||
eventlog(eventlog_level_error,__FUNCTION__,"failed to init");
|
||||
if (pidfile)
|
||||
xfree((void*)pidfile);
|
||||
return -1;
|
||||
} else {
|
||||
eventlog(eventlog_level_info,__FUNCTION__,"server initialized");
|
||||
}
|
||||
if (d2cs_server_process()<0) {
|
||||
eventlog(eventlog_level_error,__FUNCTION__,"failed to run server");
|
||||
if (pidfile)
|
||||
xfree((void*)pidfile);
|
||||
return -1;
|
||||
}
|
||||
cleanup();
|
||||
|
|
|
@ -432,7 +432,7 @@ namespace pvpgn
|
|||
dta.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
dta.uCallbackMessage = WM_SHELLNOTIFY;
|
||||
dta.hIcon = LoadIconW(GetWindowInstance(hwnd), MAKEINTRESOURCE(IDI_ICON1));
|
||||
std::swprintf(dta.szTip, sizeof dta.szTip / sizeof *dta.szTip, L"%ls %ls", PVPGN_SOFTWAREW, PVPGN_VERSION);
|
||||
std::swprintf(dta.szTip, sizeof dta.szTip / sizeof *dta.szTip, L"%ls %ls", PVPGN_SOFTWAREW, PVPGN_VERSIONW);
|
||||
Shell_NotifyIconW(NIM_ADD, &dta);
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
return;
|
||||
|
@ -883,7 +883,10 @@ void make_minidump(EXCEPTION_POINTERS* e)
|
|||
|
||||
auto pMiniDumpWriteDump = reinterpret_cast<decltype(&MiniDumpWriteDump)>(GetProcAddress(hDbgHelp, "MiniDumpWriteDump"));
|
||||
if (pMiniDumpWriteDump == nullptr)
|
||||
{
|
||||
FreeLibrary(hDbgHelp);
|
||||
return;
|
||||
}
|
||||
|
||||
wchar_t name[MAX_PATH] = {};
|
||||
{
|
||||
|
@ -895,7 +898,10 @@ void make_minidump(EXCEPTION_POINTERS* e)
|
|||
|
||||
auto hFile = CreateFileW(name, GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
FreeLibrary(hDbgHelp);
|
||||
return;
|
||||
}
|
||||
|
||||
MINIDUMP_EXCEPTION_INFORMATION exceptionInfo = {};
|
||||
exceptionInfo.ThreadId = GetCurrentThreadId();
|
||||
|
|
Loading…
Reference in a new issue