Sync #202
17 changed files with 441 additions and 422 deletions
|
@ -1105,7 +1105,7 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\wins");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\wins");
|
||||
|
||||
return account_get_numattr(account, key.c_str());
|
||||
}
|
||||
|
@ -1119,7 +1119,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\wins");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\wins");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), account_get_ladder_wins(account, clienttag, id) + 1);
|
||||
}
|
||||
|
@ -1133,7 +1133,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\wins");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\wins");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), wins);
|
||||
}
|
||||
|
@ -1147,7 +1147,7 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\losses");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\losses");
|
||||
|
||||
return account_get_numattr(account, key.c_str());
|
||||
}
|
||||
|
@ -1161,7 +1161,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\losses");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\losses");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), account_get_ladder_losses(account, clienttag, id) + 1);
|
||||
}
|
||||
|
@ -1175,7 +1175,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\losses");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\losses");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), losses);
|
||||
}
|
||||
|
@ -1189,7 +1189,7 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\draws");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\draws");
|
||||
|
||||
return account_get_numattr(account, key.c_str());
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\draws");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\draws");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), account_get_ladder_draws(account, clienttag, id) + 1);
|
||||
}
|
||||
|
@ -1217,7 +1217,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\draws");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\draws");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), draws);
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\disconnects");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\disconnects");
|
||||
|
||||
return account_get_numattr(account, key.c_str());
|
||||
}
|
||||
|
@ -1245,7 +1245,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\disconnects");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\disconnects");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), account_get_ladder_disconnects(account, clienttag, id) + 1);
|
||||
}
|
||||
|
@ -1259,7 +1259,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\disconnects");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\disconnects");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), discs);
|
||||
}
|
||||
|
@ -1336,7 +1336,7 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\rank");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\rank");
|
||||
|
||||
return account_get_numattr(account, key.c_str());
|
||||
}
|
||||
|
@ -1350,7 +1350,7 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\rank");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\rank");
|
||||
|
||||
int retval = 0;
|
||||
if (account_set_numattr(account, key.c_str(), rank) < 0)
|
||||
|
@ -1359,7 +1359,7 @@ namespace pvpgn
|
|||
unsigned int oldrank = account_get_ladder_high_rank(account, clienttag, id);
|
||||
if (oldrank == 0 || rank < oldrank)
|
||||
{
|
||||
key = "Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\high rank";
|
||||
key = "Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\high rank";
|
||||
|
||||
if (account_set_numattr(account, key.c_str(), rank) < 0)
|
||||
retval = -1;
|
||||
|
@ -2026,9 +2026,10 @@ namespace pvpgn
|
|||
|
||||
// WAR3 Play Game & Profile Funcs
|
||||
|
||||
extern char const * race_get_str(unsigned int race)
|
||||
extern std::string race_get_str(unsigned int race)
|
||||
{
|
||||
switch (race) {
|
||||
switch (race)
|
||||
{
|
||||
case W3_RACE_ORCS:
|
||||
return "orcs";
|
||||
case W3_RACE_HUMANS:
|
||||
|
@ -2046,17 +2047,17 @@ namespace pvpgn
|
|||
return "demons";
|
||||
default:
|
||||
eventlog(eventlog_level_warn, __FUNCTION__, "unknown race: %x", race);
|
||||
return nullptr;
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
extern int account_inc_racewins(t_account * account, unsigned int intrace, t_clienttag clienttag)
|
||||
{
|
||||
char const * race = race_get_str(intrace);
|
||||
if (race == nullptr)
|
||||
std::string race = race_get_str(intrace);
|
||||
if (race.empty())
|
||||
return -1;
|
||||
|
||||
std::string table("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(race) + "\\wins");
|
||||
std::string table("Record\\" + tag_uint_to_str2(clienttag) + "\\" + race + "\\wins");
|
||||
unsigned int wins = account_get_numattr(account, table.c_str()); wins++;
|
||||
|
||||
return account_set_numattr(account, table.c_str(), wins);
|
||||
|
@ -2064,22 +2065,22 @@ namespace pvpgn
|
|||
|
||||
extern int account_get_racewins(t_account * account, unsigned int intrace, t_clienttag clienttag)
|
||||
{
|
||||
char const *race = race_get_str(intrace);
|
||||
if (race == nullptr)
|
||||
std::string race = race_get_str(intrace);
|
||||
if (race.empty())
|
||||
return 0;
|
||||
|
||||
std::string table("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(race) + "\\wins");
|
||||
std::string table("Record\\" + tag_uint_to_str2(clienttag) + "\\" + race + "\\wins");
|
||||
|
||||
return account_get_numattr(account, table.c_str());
|
||||
}
|
||||
|
||||
extern int account_inc_racelosses(t_account * account, unsigned int intrace, t_clienttag clienttag)
|
||||
{
|
||||
char const *race = race_get_str(intrace);
|
||||
if (race == nullptr)
|
||||
std::string race = race_get_str(intrace);
|
||||
if (race.empty())
|
||||
return -1;
|
||||
|
||||
std::string table("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(race) + "\\losses");
|
||||
std::string table("Record\\" + tag_uint_to_str2(clienttag) + "\\" + race + "\\losses");
|
||||
|
||||
unsigned int losses = account_get_numattr(account, table.c_str()); losses++;
|
||||
|
||||
|
@ -2089,11 +2090,11 @@ namespace pvpgn
|
|||
|
||||
extern int account_get_racelosses(t_account * account, unsigned int intrace, t_clienttag clienttag)
|
||||
{
|
||||
char const *race = race_get_str(intrace);
|
||||
if (race == nullptr)
|
||||
std::string race = race_get_str(intrace);
|
||||
if (race.empty())
|
||||
return 0;
|
||||
|
||||
std::string table("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(race) + "\\losses");
|
||||
std::string table("Record\\" + tag_uint_to_str2(clienttag) + "\\" + race + "\\losses");
|
||||
|
||||
return account_get_numattr(account, table.c_str());
|
||||
|
||||
|
@ -2142,28 +2143,28 @@ namespace pvpgn
|
|||
|
||||
extern int account_get_ladder_xp(t_account * account, t_clienttag clienttag, t_ladder_id id)
|
||||
{
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\xp");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\xp");
|
||||
|
||||
return account_get_numattr(account, key.c_str());
|
||||
}
|
||||
|
||||
extern int account_set_ladder_xp(t_account * account, t_clienttag clienttag, t_ladder_id id, unsigned int xp)
|
||||
{
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\xp");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\xp");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), xp);
|
||||
}
|
||||
|
||||
extern int account_get_ladder_level(t_account * account, t_clienttag clienttag, t_ladder_id id)
|
||||
{
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\level");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\level");
|
||||
|
||||
return account_get_numattr(account, key.c_str());
|
||||
}
|
||||
|
||||
extern int account_set_ladder_level(t_account * account, t_clienttag clienttag, t_ladder_id id, unsigned int level)
|
||||
{
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\level");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\level");
|
||||
|
||||
return account_set_numattr(account, key.c_str(), level);
|
||||
}
|
||||
|
@ -2737,14 +2738,14 @@ namespace pvpgn
|
|||
|
||||
extern int account_get_ladder_points(t_account * account, t_clienttag clienttag, t_ladder_id id)
|
||||
{
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\points");
|
||||
std::string key("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\points");
|
||||
|
||||
return account_get_numattr(account, key.c_str());
|
||||
}
|
||||
|
||||
extern int account_set_ladder_points(t_account * account, t_clienttag clienttag, t_ladder_id id, unsigned int points)
|
||||
{
|
||||
std::string key ("Record\\" + tag_uint_to_str2(clienttag) + "\\" + std::string(ladder_id_str[static_cast<int>(id)]) + "\\points");
|
||||
std::string key ("Record\\" + tag_uint_to_str2(clienttag) + "\\" + ladder_id_str.at(static_cast<size_t>(id)) + "\\points");
|
||||
return account_set_numattr(account, key.c_str(), points);
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace pvpgn
|
|||
extern int account_remove_friend(t_account * account, int friendnum);
|
||||
extern int account_remove_friend2(t_account * account, const char * friendname);
|
||||
|
||||
extern char const * race_get_str(unsigned int race);
|
||||
extern std::string race_get_str(unsigned int race);
|
||||
extern int account_set_admin(t_account * account);
|
||||
extern int account_set_demoteadmin(t_account * account);
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ namespace pvpgn
|
|||
return;
|
||||
}
|
||||
|
||||
// check if where allready knows about ctag
|
||||
// check if where already knows about ctag
|
||||
AdCtagRefMap::iterator cit2(where.find(adKey));
|
||||
// if not register ctag
|
||||
if (cit2 == where.end())
|
||||
|
|
|
@ -1234,7 +1234,7 @@ namespace pvpgn
|
|||
*/
|
||||
|
||||
/* opponent level calculation has to be done here, because later on, the level of other players
|
||||
* may allready be modified
|
||||
* may already be modified
|
||||
*/
|
||||
for (i = 0; i < tp; i++) {
|
||||
int j, k, l;
|
||||
|
|
|
@ -289,37 +289,40 @@ namespace pvpgn
|
|||
|
||||
static int _send_msg(t_connection * conn, char const * command, char const * text)
|
||||
{
|
||||
t_packet * p;
|
||||
char data[MAX_IRC_MESSAGE_LEN + 1];
|
||||
char const * nick;
|
||||
|
||||
if (!conn) {
|
||||
if (!conn)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got NULL connection");
|
||||
return -1;
|
||||
}
|
||||
if (!command) {
|
||||
if (!command)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got NULL command");
|
||||
return -1;
|
||||
}
|
||||
if (!text) {
|
||||
if (!text)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got NULL text");
|
||||
return -1;
|
||||
}
|
||||
if (!(p = packet_create(packet_class_raw))) {
|
||||
|
||||
t_packet * p = packet_create(packet_class_raw);
|
||||
if (!p)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "could not create packet");
|
||||
return -1;
|
||||
}
|
||||
|
||||
nick = conn_get_loggeduser(conn);
|
||||
const char *nick = conn_get_loggeduser(conn);
|
||||
if (!nick)
|
||||
nick = "UserName";
|
||||
|
||||
std::snprintf(data, sizeof(data), ":matchbot!u@h %s %s %s", command, nick, text);
|
||||
std::string data(":matchbot!u@h " + std::string(command) + " " + std::string(nick) + " " + std::string(text));
|
||||
data.erase(MAX_IRC_MESSAGE_LEN, std::string::npos);
|
||||
|
||||
DEBUG2("[%d] sent \"%s\"", conn_get_socket(conn), data);
|
||||
std::strcat(data, "\r\n");
|
||||
DEBUG2("[%d] sent \"%s\"", conn_get_socket(conn), data.c_str());
|
||||
data.append("\r\n");
|
||||
packet_set_size(p, 0);
|
||||
packet_append_data(p, data, std::strlen(data));
|
||||
packet_append_data(p, data.c_str(), data.length());
|
||||
conn_push_outqueue(conn, p);
|
||||
packet_del_ref(p);
|
||||
return 0;
|
||||
|
@ -391,37 +394,37 @@ namespace pvpgn
|
|||
if ((player1 != player2) && ((conn_get_channel(conn_pl1)) == (conn_get_channel(conn_pl2)))) {
|
||||
switch (ctag) {
|
||||
case CLIENTTAG_REDALERT2_UINT: {
|
||||
random = rand();
|
||||
random = rand();
|
||||
|
||||
if (std::strcmp(channelname, RAL2_CHANNEL_FFA) == 0) {
|
||||
int pl1_colour = anongame_wol_player_get_colour(player1);
|
||||
int pl1_country = anongame_wol_player_get_country(player1);
|
||||
int pl2_colour = anongame_wol_player_get_colour(player2);
|
||||
int pl2_country = anongame_wol_player_get_country(player2);
|
||||
if (std::strcmp(channelname, RAL2_CHANNEL_FFA) == 0) {
|
||||
int pl1_colour = anongame_wol_player_get_colour(player1);
|
||||
int pl1_country = anongame_wol_player_get_country(player1);
|
||||
int pl2_colour = anongame_wol_player_get_colour(player2);
|
||||
int pl2_country = anongame_wol_player_get_country(player2);
|
||||
|
||||
DEBUG0("Generating SOLO game for Red Alert 2");
|
||||
DEBUG0("Generating SOLO game for Red Alert 2");
|
||||
|
||||
_get_pair(&pl1_colour, &pl2_colour, 7, true);
|
||||
_get_pair(&pl1_country, &pl2_country, 8, false);
|
||||
mapname = anongame_get_map_from_prefs(ANONGAME_TYPE_1V1, ctag);
|
||||
_get_pair(&pl1_colour, &pl2_colour, 7, true);
|
||||
_get_pair(&pl1_country, &pl2_country, 8, false);
|
||||
mapname = anongame_get_map_from_prefs(ANONGAME_TYPE_1V1, ctag);
|
||||
|
||||
/* We have madatory of game */
|
||||
std::snprintf(_temp, sizeof(_temp), ":Start %d,0,0,10000,0,1,0,1,1,0,1,x,2,1,165368,%s,1:", random, mapname);
|
||||
std::strcat(temp, _temp);
|
||||
/* We have madatory of game */
|
||||
std::snprintf(_temp, sizeof(_temp), ":Start %d,0,0,10000,0,1,0,1,1,0,1,x,2,1,165368,%s,1:", random, mapname);
|
||||
std::strcat(temp, _temp);
|
||||
|
||||
/* GameHost informations */
|
||||
std::snprintf(_temp, sizeof(_temp), "%s,%d,%d,%x,1,%x,", conn_get_chatname(conn_pl1), pl1_country, pl1_colour, anongame_wol_player_get_address(player1), anongame_wol_player_get_port(player1));
|
||||
std::strcat(temp, _temp);
|
||||
/* GameHost informations */
|
||||
std::snprintf(_temp, sizeof(_temp), "%s,%d,%d,%x,1,%x,", conn_get_chatname(conn_pl1), pl1_country, pl1_colour, anongame_wol_player_get_address(player1), anongame_wol_player_get_port(player1));
|
||||
std::strcat(temp, _temp);
|
||||
|
||||
/* GameJoinie informations */
|
||||
std::snprintf(_temp, sizeof(_temp), "%s,%d,%d,%x,1,%x", conn_get_chatname(conn_pl2), pl2_country, pl2_colour, anongame_wol_player_get_address(player2), anongame_wol_player_get_port(player2));
|
||||
std::strcat(temp, _temp);
|
||||
/* GameJoinie informations */
|
||||
std::snprintf(_temp, sizeof(_temp), "%s,%d,%d,%x,1,%x", conn_get_chatname(conn_pl2), pl2_country, pl2_colour, anongame_wol_player_get_address(player2), anongame_wol_player_get_port(player2));
|
||||
std::strcat(temp, _temp);
|
||||
|
||||
_send_msg(conn_pl1, "PRIVMSG", temp);
|
||||
_send_msg(conn_pl2, "PRIVMSG", temp);
|
||||
}
|
||||
else
|
||||
ERROR1("undefined channel type for %s channel", channelname);
|
||||
_send_msg(conn_pl1, "PRIVMSG", temp);
|
||||
_send_msg(conn_pl2, "PRIVMSG", temp);
|
||||
}
|
||||
else
|
||||
ERROR1("undefined channel type for %s channel", channelname);
|
||||
}
|
||||
return 0;
|
||||
case CLIENTTAG_YURISREV_UINT: {
|
||||
|
|
|
@ -181,7 +181,7 @@ namespace pvpgn
|
|||
|
||||
if (now == (std::time_t)0) /* zero means user logged out before expiration */
|
||||
{
|
||||
eventlog(eventlog_level_trace, __FUNCTION__, "[%d] connection allready closed", conn_get_socket(c));
|
||||
eventlog(eventlog_level_trace, __FUNCTION__, "[%d] connection already closed", conn_get_socket(c));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -699,7 +699,7 @@ namespace pvpgn
|
|||
lua_handle_user(c, NULL, NULL, luaevent_user_disconnect);
|
||||
#endif
|
||||
|
||||
if (account_get_conn(c->protocol.account) == c) /* make sure you don't set this when allready on new conn (relogin with same account) */
|
||||
if (account_get_conn(c->protocol.account) == c) /* make sure you don't set this when already on new conn (relogin with same account) */
|
||||
account_set_conn(c->protocol.account, NULL);
|
||||
c->protocol.account = NULL; /* the account code will free the memory later */
|
||||
}
|
||||
|
@ -1535,18 +1535,18 @@ namespace pvpgn
|
|||
else {
|
||||
unsigned int userid = 0;
|
||||
str_to_uint(&username[1], &userid);
|
||||
if (userid != 0){
|
||||
if (prefs_get_account_force_username()){
|
||||
if (userid != 0)
|
||||
{
|
||||
if (prefs_get_account_force_username())
|
||||
{
|
||||
t_account* account = accountlist_find_account_by_uid(userid);
|
||||
temp = xstrdup(account_get_name(account));
|
||||
}
|
||||
else{
|
||||
char uid_string[MAX_USERNAME_LEN] = {};
|
||||
std::snprintf(uid_string, sizeof(uid_string), "#%u", userid);
|
||||
temp = xstrdup(uid_string);
|
||||
}
|
||||
else
|
||||
temp = xstrdup(std::string("#" + userid).c_str());
|
||||
}
|
||||
else{ //theoretically this should never happen...
|
||||
else
|
||||
{ //theoretically this should never happen...
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "got invalid numeric uid \"%s\"", username);
|
||||
// set value that would have been set prior to this bugfix...
|
||||
temp = xstrdup(username);
|
||||
|
@ -1922,15 +1922,13 @@ namespace pvpgn
|
|||
if ((!clan) || (clan_get_clantag(clan) != clantag)) {
|
||||
if (!channel)
|
||||
{
|
||||
char msgtemp[MAX_MESSAGE_LEN];
|
||||
std::snprintf(msgtemp, sizeof(msgtemp), "Unable to join channel %s, there is no member of that clan in the channel!", channelname);
|
||||
message_send_text(c, message_type_error, c, msgtemp);
|
||||
message_send_text(c, message_type_error, c, std::string("Unable to join channel " + std::string(channelname) + ", there is no member of that clan in the channel!").c_str());
|
||||
|
||||
if (conn_get_game(c) || c->protocol.chat.channel == NULL) {
|
||||
if (conn_get_game(c) || c->protocol.chat.channel == NULL)
|
||||
{
|
||||
// FIXME: This is not tested to be according to battle.net!!
|
||||
// This is fix for empty clan channels with preventing to join CHANNEL_NAME_BANNED when is used _handle_join_command
|
||||
std::snprintf(msgtemp, sizeof(msgtemp), "You have been redirected to %s.", CHANNEL_NAME_BANNED);
|
||||
message_send_text(c, message_type_error, c, msgtemp);
|
||||
message_send_text(c, message_type_error, c, std::string("You have been redirected to " + std::string(CHANNEL_NAME_BANNED)).c_str());
|
||||
channel = channellist_find_channel_by_name(CHANNEL_NAME_BANNED, conn_get_country(c), realm_get_name(conn_get_realm(c)));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1885,7 +1885,7 @@ namespace pvpgn
|
|||
|
||||
if (game->reported_results[i])
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "player \"%s\" allready reported results - skipping this report", account_get_name(account));
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "player \"%s\" already reported results - skipping this report", account_get_name(account));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1677,7 +1677,7 @@ namespace pvpgn
|
|||
eventlog(eventlog_level_info, __FUNCTION__, "[%d] login for \"%s\" refused (already logged in)", conn_get_socket(c), username);
|
||||
if (supports_locked_reply) {
|
||||
bn_int_set(&rpacket->u.server_loginreply1.message, SERVER_LOGINREPLY2_MESSAGE_LOCKED);
|
||||
packet_append_string(rpacket, "This account is allready logged in.");
|
||||
packet_append_string(rpacket, "This account is already logged in.");
|
||||
}
|
||||
else {
|
||||
bn_int_set(&rpacket->u.server_loginreply1.message, SERVER_LOGINREPLY2_MESSAGE_BADPASS);
|
||||
|
@ -2131,7 +2131,7 @@ namespace pvpgn
|
|||
int i;
|
||||
const char * client_password_proof;
|
||||
|
||||
/* PELISH: This can not occur - We allready tested packet size which must be wrong firstly.
|
||||
/* PELISH: This can not occur - We already tested packet size which must be wrong firstly.
|
||||
Also pvpgn will crash when will dereferencing NULL pointer (so we cant got this errorlog message)
|
||||
I vote for deleting this "if" */
|
||||
if (!(client_password_proof = (const char*)packet_get_data_const(packet, offsetof(t_client_logonproofreq, client_password_proof), 20))) {
|
||||
|
@ -2557,12 +2557,12 @@ namespace pvpgn
|
|||
|
||||
|
||||
if (!(team = account_find_team_by_accounts(members[0], members, ctag))) {
|
||||
team = create_team(members, ctag); //no need to free on return -1 because it's allready in teamlist
|
||||
team = create_team(members, ctag); //no need to free on return -1 because it's already in teamlist
|
||||
|
||||
eventlog(eventlog_level_trace, __FUNCTION__, "this team has never played before, creating new team");
|
||||
}
|
||||
else {
|
||||
eventlog(eventlog_level_trace, __FUNCTION__, "this team has allready played before");
|
||||
eventlog(eventlog_level_trace, __FUNCTION__, "this team has already played before");
|
||||
}
|
||||
|
||||
teamid = team_get_teamid(team);
|
||||
|
@ -3502,7 +3502,7 @@ namespace pvpgn
|
|||
}
|
||||
|
||||
if ((channel = conn_get_channel(c)) && (strcasecmp(channel_get_name(channel), cname) == 0))
|
||||
return 0; //we are allready in this channel
|
||||
return 0; //we are already in this channel
|
||||
|
||||
std::string tmpstr;
|
||||
clienttag = conn_get_clienttag(c);
|
||||
|
@ -5125,12 +5125,12 @@ namespace pvpgn
|
|||
(conn_account = conn_get_account(conn)))) {
|
||||
response_code = CLAN_RESPONSE_NOT_FOUND;
|
||||
|
||||
// target user allready in a clan or creating a clan
|
||||
// target user already in a clan or creating a clan
|
||||
}
|
||||
else if (account_get_clanmember_forced(conn_get_account(conn))) {
|
||||
response_code = CLAN_RESPONSE_NOT_FOUND;
|
||||
|
||||
// clan allready full
|
||||
// clan allready ful
|
||||
}
|
||||
else if (clan_get_member_count(clan) >= prefs_get_clan_max_members()) {
|
||||
response_code = CLAN_RESPONSE_CLAN_FULL;
|
||||
|
@ -5232,14 +5232,17 @@ namespace pvpgn
|
|||
clan_remove_member(clan, member);
|
||||
bn_byte_set(&rpacket->u.server_clan_invitereply.result, CLAN_RESPONSE_CLAN_FULL);
|
||||
}
|
||||
else {
|
||||
char channelname[10];
|
||||
else
|
||||
{
|
||||
clanmember_set_fullmember(member, 1);
|
||||
std::snprintf(channelname, sizeof(channelname), "Clan %s", clantag_to_str(clan_get_clantag(clan)));
|
||||
if (conn_get_channel(c)) {
|
||||
if (conn_get_channel(c))
|
||||
{
|
||||
conn_update_w3_playerinfo(c);
|
||||
channel_set_userflags(c);
|
||||
if (conn_set_channel(c, channelname) < 0) {
|
||||
|
||||
std::string channelname("Clan " + std::string(clantag_to_str(clan_get_clantag(clan))));
|
||||
if (conn_set_channel(c, channelname.c_str()) < 0)
|
||||
{
|
||||
conn_set_channel(c, CHANNEL_NAME_BANNED); /* should not fail */
|
||||
}
|
||||
clanmember_set_online(c);
|
||||
|
|
|
@ -325,8 +325,7 @@ namespace pvpgn
|
|||
|
||||
bnet_hash(&passhash, std::strlen(pass), pass);
|
||||
|
||||
std::snprintf(msgtemp, sizeof(msgtemp), "Trying to create account \"%s\" with password \"%s\"", username, pass);
|
||||
message_send_text(conn, message_type_info, conn, msgtemp);
|
||||
message_send_text(conn, message_type_info, conn, std::string("Trying to create account \"" + std::string(username) + "\" with password \"" + std::string(pass) + "\"").c_str());
|
||||
|
||||
temp = accountlist_create_account(username, hash_get_str(passhash));
|
||||
if (!temp) {
|
||||
|
@ -336,16 +335,13 @@ namespace pvpgn
|
|||
break;
|
||||
}
|
||||
|
||||
std::snprintf(msgtemp, sizeof(msgtemp), "Account " UID_FORMAT " created.", account_get_uid(temp));
|
||||
message_send_text(conn, message_type_info, conn, msgtemp);
|
||||
message_send_text(conn, message_type_info, conn, std::string("Account #" + std::to_string(account_get_uid(temp)) + " created."));
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] account \"%s\" created", conn_get_socket(conn), username);
|
||||
conn_unget_chatname(conn, username);
|
||||
}
|
||||
else {
|
||||
char tmp[MAX_IRC_MESSAGE_LEN + 1];
|
||||
message_send_text(conn, message_type_notice, NULL, "Invalid arguments for NICKSERV");
|
||||
std::snprintf(tmp, sizeof(tmp), ":Unrecognized command \"%s\"", text);
|
||||
message_send_text(conn, message_type_notice, NULL, tmp);
|
||||
message_send_text(conn, message_type_notice, nullptr, "Invalid arguments for NICKSERV");
|
||||
message_send_text(conn, message_type_notice, nullptr, std::string(":Unrecognized command \"" + std::string(text) + "\"").c_str());
|
||||
}
|
||||
}
|
||||
else if (conn_get_state(conn) == conn_state_loggedin) {
|
||||
|
@ -443,38 +439,30 @@ namespace pvpgn
|
|||
|
||||
static int _handle_list_command(t_connection * conn, int numparams, char ** params, char * text)
|
||||
{
|
||||
char temp[MAX_IRC_MESSAGE_LEN];
|
||||
|
||||
std::string tmp;
|
||||
irc_send(conn, RPL_LISTSTART, "Channel :Users Names"); /* backward compatibility */
|
||||
|
||||
if (numparams == 0) {
|
||||
if (numparams == 0)
|
||||
{
|
||||
t_elem const * curr;
|
||||
class_topic Topic;
|
||||
LIST_TRAVERSE_CONST(channellist(), curr)
|
||||
{
|
||||
t_channel const * channel = (const t_channel*)elem_get_data(curr);
|
||||
char const * tempname;
|
||||
char const * tempname = irc_convert_channel(channel, conn);
|
||||
std::string topicstr = Topic.get(channel_get_name(channel));
|
||||
|
||||
tempname = irc_convert_channel(channel, conn);
|
||||
|
||||
/* FIXME: AARON: only list channels like in /channels command */
|
||||
if (topicstr.empty() == false) {
|
||||
if (std::strlen(tempname) + 1 + 20 + 1 + 1 + std::strlen(topicstr.c_str()) < MAX_IRC_MESSAGE_LEN)
|
||||
std::snprintf(temp, sizeof(temp), "%s %u :%s", tempname, channel_get_length(channel), topicstr.c_str());
|
||||
else
|
||||
eventlog(eventlog_level_warn, __FUNCTION__, "LISTREPLY length exceeded");
|
||||
}
|
||||
else {
|
||||
if (std::strlen(tempname) + 1 + 20 + 1 + 1 < MAX_IRC_MESSAGE_LEN)
|
||||
std::snprintf(temp, sizeof(temp), "%s %u :", tempname, channel_get_length(channel));
|
||||
else
|
||||
eventlog(eventlog_level_warn, __FUNCTION__, "LISTREPLY length exceeded");
|
||||
}
|
||||
irc_send(conn, RPL_LIST, temp);
|
||||
tmp = std::string(tempname) + " " + std::to_string(channel_get_length(channel)) + " :" + topicstr;
|
||||
|
||||
if (tmp.length() > MAX_IRC_MESSAGE_LEN)
|
||||
eventlog(eventlog_level_warn, __FUNCTION__, "LISTREPLY length exceeded");
|
||||
|
||||
irc_send(conn, RPL_LIST, tmp.c_str());
|
||||
}
|
||||
}
|
||||
else if (numparams >= 1) {
|
||||
else if (numparams >= 1)
|
||||
{
|
||||
int i;
|
||||
char ** e;
|
||||
class_topic Topic;
|
||||
|
@ -482,40 +470,33 @@ namespace pvpgn
|
|||
e = irc_get_listelems(params[0]);
|
||||
/* FIXME: support wildcards! */
|
||||
|
||||
for (i = 0; ((e) && (e[i])); i++) {
|
||||
t_channel const * channel;
|
||||
char const * verytemp; /* another good example for creative naming conventions :) */
|
||||
char const * tempname;
|
||||
std::string topicstr;
|
||||
|
||||
verytemp = irc_convert_ircname(e[i]);
|
||||
for (i = 0; ((e) && (e[i])); i++)
|
||||
{
|
||||
char const * verytemp = irc_convert_ircname(e[i]);
|
||||
if (!verytemp)
|
||||
continue; /* something is wrong with the name ... */
|
||||
channel = channellist_find_channel_by_name(verytemp, NULL, NULL);
|
||||
|
||||
t_channel const * channel = channellist_find_channel_by_name(verytemp, NULL, NULL);
|
||||
if (!channel)
|
||||
continue; /* channel doesn't exist */
|
||||
|
||||
topicstr = Topic.get(channel_get_name(channel));
|
||||
tempname = irc_convert_channel(channel, conn);
|
||||
std::string topicstr = Topic.get(channel_get_name(channel));
|
||||
char const * tempname = irc_convert_channel(channel, conn);
|
||||
|
||||
if (topicstr.c_str()) {
|
||||
if (std::strlen(tempname) + 1 + 20 + 1 + 1 + std::strlen(topicstr.c_str()) < MAX_IRC_MESSAGE_LEN)
|
||||
std::snprintf(temp, sizeof(temp), "%s %u :%s", tempname, channel_get_length(channel), topicstr.c_str());
|
||||
else
|
||||
eventlog(eventlog_level_warn, __FUNCTION__, "LISTREPLY length exceeded");
|
||||
}
|
||||
else {
|
||||
if (std::strlen(tempname) + 1 + 20 + 1 + 1 < MAX_IRC_MESSAGE_LEN)
|
||||
std::snprintf(temp, sizeof(temp), "%s %u :", tempname, channel_get_length(channel));
|
||||
else
|
||||
eventlog(eventlog_level_warn, __FUNCTION__, "LISTREPLY length exceeded");
|
||||
}
|
||||
irc_send(conn, RPL_LIST, temp);
|
||||
tmp = std::string(tempname) + " " + std::to_string(channel_get_length(channel)) + " :" + topicstr;
|
||||
|
||||
if (tmp.length() > MAX_IRC_MESSAGE_LEN)
|
||||
eventlog(eventlog_level_warn, __FUNCTION__, "LISTREPLY length exceeded");
|
||||
|
||||
irc_send(conn, RPL_LIST, tmp.c_str());
|
||||
}
|
||||
|
||||
if (e)
|
||||
irc_unget_listelems(e);
|
||||
}
|
||||
|
||||
irc_send(conn, RPL_LISTEND, ":End of LIST command");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -589,30 +570,29 @@ namespace pvpgn
|
|||
|
||||
static int _handle_whois_command(t_connection * conn, int numparams, char ** params, char * text)
|
||||
{
|
||||
char temp[MAX_IRC_MESSAGE_LEN];
|
||||
char temp2[MAX_IRC_MESSAGE_LEN];
|
||||
if (numparams >= 1) {
|
||||
std::string tmp;
|
||||
|
||||
if (numparams >= 1)
|
||||
{
|
||||
int i;
|
||||
char ** e;
|
||||
char ** e = irc_get_listelems(params[0]);
|
||||
t_connection * c;
|
||||
t_channel * chan;
|
||||
|
||||
temp[0] = '\0';
|
||||
temp2[0] = '\0';
|
||||
e = irc_get_listelems(params[0]);
|
||||
for (i = 0; ((e) && (e[i])); i++) {
|
||||
if ((c = connlist_find_connection_by_accountname(e[i]))) {
|
||||
for (i = 0; ((e) && (e[i])); i++)
|
||||
{
|
||||
if ((c = connlist_find_connection_by_accountname(e[i])))
|
||||
{
|
||||
if (prefs_get_hide_addr() && !(account_get_command_groups(conn_get_account(conn)) & command_get_group("/admin-addr")))
|
||||
std::snprintf(temp, sizeof(temp), "%s %s hidden * :%s", e[i], clienttag_uint_to_str(conn_get_clienttag(c)), "PvPGN user");
|
||||
tmp = std::string(e[i]) + " " + std::string(clienttag_uint_to_str(conn_get_clienttag(c))) + " hidden * :PvPGN user";
|
||||
else
|
||||
std::snprintf(temp, sizeof(temp), "%s %s %s * :%s", e[i], clienttag_uint_to_str(conn_get_clienttag(c)), addr_num_to_ip_str(conn_get_addr(c)), "PvPGN user");
|
||||
irc_send(conn, RPL_WHOISUSER, temp);
|
||||
tmp = std::string(e[i]) + " " + std::string(clienttag_uint_to_str(conn_get_clienttag(c))) + " " + std::string(addr_num_to_ip_str(conn_get_addr(c))) + " * :PvPGN user";
|
||||
irc_send(conn, RPL_WHOISUSER, tmp.c_str());
|
||||
|
||||
if ((chan = conn_get_channel(conn))) {
|
||||
char flg;
|
||||
unsigned int flags;
|
||||
|
||||
flags = conn_get_flags(c);
|
||||
if ((chan = conn_get_channel(conn)))
|
||||
{
|
||||
std::string flg;
|
||||
auto flags = conn_get_flags(c);
|
||||
|
||||
if (flags & MF_BLIZZARD)
|
||||
flg = '@';
|
||||
|
@ -620,9 +600,11 @@ namespace pvpgn
|
|||
flg = '%';
|
||||
else if (flags & MF_VOICE)
|
||||
flg = '+';
|
||||
else flg = ' ';
|
||||
std::snprintf(temp2, sizeof(temp2), "%s :%c%s", e[i], flg, irc_convert_channel(chan, conn));
|
||||
irc_send(conn, RPL_WHOISCHANNELS, temp2);
|
||||
else
|
||||
flg = ' ';
|
||||
|
||||
tmp = std::string(e[i]) + " :" + flg + std::string(irc_convert_channel(chan, conn));
|
||||
irc_send(conn, RPL_WHOISCHANNELS, tmp.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -258,18 +258,16 @@ namespace pvpgn
|
|||
}
|
||||
|
||||
if (handle_irc_common_con_command(conn, command, numparams, params, text) != -1) {}
|
||||
else if (conn_get_state(conn) != conn_state_loggedin) {
|
||||
char temp[MAX_IRC_MESSAGE_LEN + 1];
|
||||
|
||||
if ((38 + std::strlen(command) + 16 + 1) < sizeof(temp)) {
|
||||
std::snprintf(temp, sizeof(temp), ":Unrecognized command \"%s\" (before login)", command);
|
||||
irc_send(conn, ERR_UNKNOWNCOMMAND, temp);
|
||||
}
|
||||
else {
|
||||
else if (conn_get_state(conn) != conn_state_loggedin)
|
||||
{
|
||||
std::string tmp(":Unrecognized command \"" + std::string(command) + "\" (before login)");
|
||||
if (tmp.length() > MAX_IRC_MESSAGE_LEN)
|
||||
irc_send(conn, ERR_UNKNOWNCOMMAND, tmp.c_str());
|
||||
else
|
||||
irc_send(conn, ERR_UNKNOWNCOMMAND, ":Unrecognized command (before login)");
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
/* command is handled later */
|
||||
unrecognized_before = 1;
|
||||
}
|
||||
|
|
|
@ -233,11 +233,12 @@ namespace pvpgn
|
|||
tempapgar = conn_wol_get_apgar(conn);
|
||||
temphash = account_get_wol_apgar(a);
|
||||
|
||||
if (connlist_find_connection_by_account(a) && prefs_get_kick_old_login() == 0) {
|
||||
std::snprintf(temp, sizeof(temp), "%s :Account is already in use!", conn_get_loggeduser(conn));
|
||||
irc_send(conn, ERR_NICKNAMEINUSE, temp);
|
||||
if (connlist_find_connection_by_account(a) && prefs_get_kick_old_login() == 0)
|
||||
{
|
||||
irc_send(conn, ERR_NICKNAMEINUSE, std::string(std::string(conn_get_loggeduser(conn)) + " :Account is already in use!").c_str());
|
||||
}
|
||||
else if (account_get_auth_lock(a) == 1) {
|
||||
else if (account_get_auth_lock(a) == 1)
|
||||
{
|
||||
/* FIXME: Send real error code */
|
||||
message_send_text(conn, message_type_notice, NULL, "Authentication rejected (account is locked) ");
|
||||
}
|
||||
|
@ -280,29 +281,28 @@ namespace pvpgn
|
|||
|
||||
static int handle_wol_send_claninfo(t_connection * conn, t_clan * clan)
|
||||
{
|
||||
char _temp[MAX_IRC_MESSAGE_LEN];
|
||||
unsigned int clanid;
|
||||
const char * clantag;
|
||||
const char * clanname;
|
||||
|
||||
std::memset(_temp, 0, sizeof(_temp));
|
||||
|
||||
if (!conn) {
|
||||
if (!conn)
|
||||
{
|
||||
ERROR0("got NULL connection");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (clan) {
|
||||
if (clan)
|
||||
{
|
||||
clanid = clan_get_clanid(clan);
|
||||
clantag = clantag_to_str(clan_get_clantag(clan));
|
||||
clanname = clan_get_name(clan);
|
||||
std::snprintf(_temp, sizeof(_temp), "%u`%s`%s`0`0`1`0`0`0`0`0`0`0`x`x`x", clanid, clanname, clantag);
|
||||
irc_send(conn, RPL_BATTLECLAN, _temp);
|
||||
irc_send(conn, RPL_BATTLECLAN, std::string(std::to_string(clanid) + "`" + std::string(clanname) + "`" + std::string(clantag) + "`0`0`1`0`0`0`0`0`0`0`x`x`x").c_str());
|
||||
}
|
||||
else {
|
||||
std::snprintf(_temp, sizeof(_temp), ":ID does not exist");
|
||||
irc_send(conn, ERR_IDNOEXIST, _temp);
|
||||
else
|
||||
{
|
||||
irc_send(conn, ERR_IDNOEXIST, ":ID does not exist");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -420,8 +420,7 @@ namespace pvpgn
|
|||
}
|
||||
}
|
||||
else {
|
||||
std::snprintf(msgtemp, sizeof(msgtemp), "%s :No such channel", e[0]);
|
||||
irc_send(conn, ERR_NOSUCHCHANNEL, msgtemp);
|
||||
irc_send(conn, ERR_NOSUCHCHANNEL, std::string(std::string(e[0]) + " :No such channel").c_str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -717,17 +716,19 @@ namespace pvpgn
|
|||
* :[servername] 379 [username] :none none none [oldversnum] [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);
|
||||
|
||||
std::snprintf(temp, sizeof(temp), ":none none none 1 %s NONREQ", params[0]);
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[** WOL **] VERCHK %s", temp);
|
||||
irc_send(conn, RPL_VERCHK_NONREQ, temp);
|
||||
std::string tmp(":none none none 1 " + std::string(params[0]) + " NONREQ");
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "[** WOL **] VERCHK %s", tmp.c_str());
|
||||
irc_send(conn, RPL_VERCHK_NONREQ, tmp.c_str());
|
||||
}
|
||||
else
|
||||
irc_send(conn, ERR_NEEDMOREPARAMS, "VERCHK :Not enough parameters");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -829,28 +830,24 @@ namespace pvpgn
|
|||
|
||||
static int _handle_getcodepage_command(t_connection * conn, int numparams, char ** params, char * text)
|
||||
{
|
||||
char temp[MAX_IRC_MESSAGE_LEN];
|
||||
char _temp[MAX_IRC_MESSAGE_LEN];
|
||||
std::string temp;
|
||||
|
||||
std::memset(temp, 0, sizeof(temp));
|
||||
std::memset(_temp, 0, sizeof(_temp));
|
||||
|
||||
if ((numparams >= 1) && (params[0])) {
|
||||
int i;
|
||||
for (i = 0; i < numparams; i++) {
|
||||
t_connection * user;
|
||||
if ((numparams >= 1) && (params[0]))
|
||||
{
|
||||
for (auto i = 0; i < numparams; i++)
|
||||
{
|
||||
int codepage = 0;
|
||||
|
||||
if (user = connlist_find_connection_by_accountname(params[i]))
|
||||
t_connection * user = connlist_find_connection_by_accountname(params[i]);
|
||||
if (user)
|
||||
codepage = conn_wol_get_codepage(user);
|
||||
|
||||
std::snprintf(_temp, sizeof(_temp), "%s`%u", params[i], codepage);
|
||||
std::strcat(temp, _temp);
|
||||
temp.append(std::string(params[i]) + "`" + std::to_string(codepage));
|
||||
|
||||
if (i < numparams - 1)
|
||||
std::strcat(temp, "`");
|
||||
temp.append("`");
|
||||
}
|
||||
irc_send(conn, RPL_GET_CODEPAGE, temp);
|
||||
|
||||
irc_send(conn, RPL_GET_CODEPAGE, temp.c_str());
|
||||
}
|
||||
else
|
||||
irc_send(conn, ERR_NEEDMOREPARAMS, "GETCODEPAGE :Not enough parameters");
|
||||
|
@ -874,27 +871,22 @@ namespace pvpgn
|
|||
|
||||
static int _handle_getlocale_command(t_connection * conn, int numparams, char ** params, char * text)
|
||||
{
|
||||
char temp[MAX_IRC_MESSAGE_LEN];
|
||||
char _temp[MAX_IRC_MESSAGE_LEN];
|
||||
std::string temp;
|
||||
|
||||
std::memset(temp, 0, sizeof(temp));
|
||||
std::memset(_temp, 0, sizeof(_temp));
|
||||
|
||||
if ((numparams >= 1) && (params[0])) {
|
||||
int i;
|
||||
for (i = 0; i < numparams; i++) {
|
||||
t_account * account;
|
||||
if ((numparams >= 1) && (params[0]))
|
||||
{
|
||||
for (auto i = 0; i < numparams; i++)
|
||||
{
|
||||
int locale = 0;
|
||||
|
||||
if (account = accountlist_find_account(params[i]))
|
||||
t_account * account = accountlist_find_account(params[i]);
|
||||
if (account)
|
||||
locale = account_get_locale(account);
|
||||
|
||||
std::snprintf(_temp, sizeof(_temp), "%s`%u", params[i], locale);
|
||||
std::strcat(temp, _temp);
|
||||
temp.append(std::string(params[i]) + "`" + std::to_string(locale));
|
||||
if (i < numparams - 1)
|
||||
std::strcat(temp, "`");
|
||||
temp.append("`");
|
||||
}
|
||||
irc_send(conn, RPL_GET_LOCALE, temp);
|
||||
irc_send(conn, RPL_GET_LOCALE, temp.c_str());
|
||||
}
|
||||
else
|
||||
irc_send(conn, ERR_NEEDMOREPARAMS, "GETLOCALE :Not enough parameters");
|
||||
|
@ -903,8 +895,6 @@ namespace pvpgn
|
|||
|
||||
static int _handle_getinsider_command(t_connection * conn, int numparams, char ** params, char * text)
|
||||
{
|
||||
char _temp[MAX_IRC_MESSAGE_LEN];
|
||||
|
||||
/**
|
||||
* Here is imput expected:
|
||||
* GETINSIDER [nickname]
|
||||
|
@ -912,14 +902,11 @@ namespace pvpgn
|
|||
* :[servername] 399 [nick] [nickname]`0
|
||||
*/
|
||||
|
||||
std::memset(_temp, 0, sizeof(_temp));
|
||||
|
||||
if ((numparams >= 1) && (params[0])) {
|
||||
std::snprintf(_temp, sizeof(_temp), "%s`%u", params[0], 0);
|
||||
irc_send(conn, RPL_GET_INSIDER, _temp);
|
||||
}
|
||||
if ((numparams >= 1) && (params[0]))
|
||||
irc_send(conn, RPL_GET_INSIDER, std::string(std::string(params[0]) + "`0").c_str());
|
||||
else
|
||||
irc_send(conn, ERR_NEEDMOREPARAMS, "GETINSIDER :Not enough parameters");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -970,52 +957,63 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!(gamename) || !(game = gamelist_find_game_available(gamename, conn_get_clienttag(conn), game_type_all))) {
|
||||
std::snprintf(_temp, sizeof(_temp), "%s :Game channel has closed", e[0]);
|
||||
irc_send(conn, ERR_GAMEHASCLOSED, _temp);
|
||||
if (!(gamename) || !(game = gamelist_find_game_available(gamename, conn_get_clienttag(conn), game_type_all)))
|
||||
{
|
||||
irc_send(conn, ERR_GAMEHASCLOSED, std::string(std::string(e[0]) + " :Game channel has closed").c_str());
|
||||
|
||||
if (e)
|
||||
irc_unget_listelems(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
channel = game_get_channel(game);
|
||||
|
||||
if (game_get_ref(game) == game_get_maxplayers(game)) {
|
||||
std::snprintf(_temp, sizeof(_temp), "%s :Channel is full", e[0]);
|
||||
irc_send(conn, ERR_CHANNELISFULL, _temp);
|
||||
if (game_get_ref(game) == game_get_maxplayers(game))
|
||||
{
|
||||
irc_send(conn, ERR_CHANNELISFULL, std::string(std::string(e[0]) + " :Channel is full.").c_str());
|
||||
|
||||
if (e)
|
||||
irc_unget_listelems(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (channel_check_banning(channel, conn)) {
|
||||
std::snprintf(_temp, sizeof(_temp), "%s :You are banned from that channel.", e[0]);
|
||||
irc_send(conn, ERR_BANNEDFROMCHAN, _temp);
|
||||
if (channel_check_banning(channel, conn))
|
||||
{
|
||||
irc_send(conn, ERR_BANNEDFROMCHAN, std::string(std::string(e[0]) + " :You are banned from that channel.").c_str());
|
||||
|
||||
if (e)
|
||||
irc_unget_listelems(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (std::strcmp(game_get_pass(game), "") != 0) {
|
||||
if ((numparams == 3) && (params[2]) && (std::strcmp(params[2], game_get_pass(game)) == 0)) {
|
||||
strcpy(gamepass, params[2]);
|
||||
if (std::strcmp(game_get_pass(game), "") != 0)
|
||||
{
|
||||
if ((numparams == 3) && (params[2]) && (std::strcmp(params[2], game_get_pass(game)) == 0))
|
||||
{
|
||||
std::strcpy(gamepass, params[2]);
|
||||
}
|
||||
else {
|
||||
std::snprintf(_temp, sizeof(_temp), "%s :Bad password", e[0]);
|
||||
irc_send(conn, ERR_BADCHANNELKEY, _temp);
|
||||
else
|
||||
{
|
||||
irc_send(conn, ERR_BADCHANNELKEY, std::string(std::string(e[0]) + ":Bad password").c_str());
|
||||
|
||||
if (e)
|
||||
irc_unget_listelems(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gametype = game_get_type(game);
|
||||
|
||||
if ((conn_set_game(conn, gamename, gamepass, "", gametype, 0)) < 0) {
|
||||
std::snprintf(_temp, sizeof(_temp), "%s :JOINGAME failed", e[0]);
|
||||
irc_send(conn, ERR_GAMEHASCLOSED, _temp);
|
||||
if ((conn_set_game(conn, gamename, gamepass, "", gametype, 0)) < 0)
|
||||
{
|
||||
irc_send(conn, ERR_GAMEHASCLOSED, std::string(std::string(e[0]) + " :JOINGAME failed").c_str());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
/*conn_set_channel()*/
|
||||
channel = game_get_channel(game);
|
||||
conn_set_channel_var(conn, channel);
|
||||
|
@ -1048,9 +1046,9 @@ namespace pvpgn
|
|||
|
||||
irc_send_rpl_namreply(conn, channel);
|
||||
}
|
||||
else {
|
||||
std::snprintf(_temp, sizeof(_temp), "%s :JOINGAME failed", e[0]);
|
||||
irc_send(conn, ERR_GAMEHASCLOSED, _temp);
|
||||
else
|
||||
{
|
||||
irc_send(conn, ERR_GAMEHASCLOSED, std::string(std::string(e[0]) + " :JOINGAME failed").c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <map>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
|
@ -65,10 +66,10 @@ namespace pvpgn
|
|||
static t_xplevel_entry * xplevels;
|
||||
int w3_xpcalc_maxleveldiff;
|
||||
|
||||
const char * ladder_id_str[] = { "0", "1", "", "3", "", "solo", "team", "ffa" };
|
||||
const char * bin_ladder_id_str[] = { "", "", "", "I", "", "SOLO", "TEAM", "FFA", "AT" };
|
||||
const char * bin_ladder_sort_str[] = { "R", "W", "G", "" };
|
||||
const char * bin_ladder_time_str[] = { "A", "C", "" };
|
||||
const std::vector<std::string> ladder_id_str = { "0", "1", "", "3", "", "solo", "team", "ffa" };
|
||||
const std::vector<std::string> bin_ladder_id_str = { "", "", "", "I", "", "SOLO", "TEAM", "FFA", "AT" };
|
||||
const std::vector<std::string> bin_ladder_sort_str = { "R", "W", "G", "" };
|
||||
const std::vector<std::string> bin_ladder_time_str = { "A", "C", "" };
|
||||
|
||||
Ladders ladders;
|
||||
|
||||
|
@ -955,9 +956,9 @@ namespace pvpgn
|
|||
{
|
||||
ladderFilename = clienttag_uint_to_str(ladderKey_.getClienttag());
|
||||
ladderFilename += "_";
|
||||
ladderFilename += bin_ladder_time_str[ladderKey_.getLadderTime()];
|
||||
ladderFilename += bin_ladder_sort_str[ladderKey_.getLadderSort()];
|
||||
ladderFilename += bin_ladder_id_str[ladderKey_.getLadderId()];
|
||||
ladderFilename += bin_ladder_time_str.at(static_cast<size_t>(ladderKey_.getLadderTime()));
|
||||
ladderFilename += bin_ladder_sort_str.at(static_cast<size_t>(ladderKey_.getLadderSort()));
|
||||
ladderFilename += bin_ladder_id_str.at(static_cast<size_t>(ladderKey_.getLadderId()));
|
||||
ladderFilename += "_LADDER";
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace pvpgn
|
|||
ladder_sort_default
|
||||
} t_ladder_sort;
|
||||
|
||||
extern const char * bin_ladder_sort_str[];
|
||||
extern const std::vector<std::string> bin_ladder_sort_str;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ namespace pvpgn
|
|||
ladder_time_default
|
||||
} t_ladder_time;
|
||||
|
||||
extern const char * bin_ladder_time_str[];
|
||||
extern const std::vector<std::string> bin_ladder_time_str;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -66,8 +66,8 @@ namespace pvpgn
|
|||
ladder_id_ateam = 8
|
||||
} t_ladder_id;
|
||||
|
||||
const extern char * ladder_id_str[];
|
||||
const extern char * bin_ladder_id_str[];
|
||||
const extern std::vector<std::string> ladder_id_str;
|
||||
const extern std::vector<std::string> bin_ladder_id_str;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
|
|
@ -154,7 +154,7 @@ static void oom_free(void)
|
|||
|
||||
FILE *hexstrm = NULL;
|
||||
|
||||
char serviceLongName[] = "PvPGN service";
|
||||
char serviceLongName[] = PVPGN_SOFTWARE " service";
|
||||
char serviceName[] = "pvpgn";
|
||||
char serviceDescription[] = "Player vs. Player Gaming Network - Server";
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
#include "common/eventlog.h"
|
||||
#include "common/xalloc.h"
|
||||
|
@ -88,9 +89,7 @@ namespace pvpgn
|
|||
|
||||
extern const char* conf_get_int(unsigned ival)
|
||||
{
|
||||
static char tmpbuf[128];
|
||||
std::snprintf(tmpbuf, sizeof(tmpbuf), "%u", ival);
|
||||
return tmpbuf;
|
||||
return std::to_string(ival).c_str();
|
||||
}
|
||||
|
||||
extern const char* conf_get_bool(unsigned ival)
|
||||
|
|
|
@ -201,10 +201,10 @@ const char * const BNETD_SERV_ADDRS = ""; /* this means none */
|
|||
const int BNETD_SERV_PORT = 6112;
|
||||
const char * const BNETD_W3ROUTE_ADDR = "0.0.0.0";
|
||||
const int BNETD_W3ROUTE_PORT = 6200;
|
||||
const char * const BNETD_SERVERNAME = "PvPGN Realm";
|
||||
const char * const BNETD_SERVERNAME = PVPGN_SOFTWARE " Realm";
|
||||
const char * const BNETD_IRC_ADDRS = ""; /* this means none */
|
||||
const int BNETD_IRC_PORT = 6667; /* used if port not specified */
|
||||
const char * const BNETD_IRC_NETWORK_NAME = "PvPGN";
|
||||
const char * const BNETD_IRC_NETWORK_NAME = PVPGN_SOFTWARE;
|
||||
const char * const BNETD_TRACK_ADDRS = "track.pvpgn.org";
|
||||
const int BNETD_TRACK_PORT = 6114; /* use this port if not specified */
|
||||
const int BNETD_DEF_TEST_PORT = 6112; /* default guess for UDP test port */
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "winmain.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#if _DEBUG
|
||||
#include <dbghelp.h>
|
||||
|
@ -32,7 +34,6 @@
|
|||
#include <winuser.h>
|
||||
#include <process.h>
|
||||
#include <richedit.h>
|
||||
#include <cstring>
|
||||
#include <commctrl.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -71,7 +72,8 @@ namespace pvpgn
|
|||
static void guiThread(void*);
|
||||
static void guiAddText(const char *, COLORREF);
|
||||
static void guiAddText_user(const char *, COLORREF);
|
||||
static void guiDEAD(char*);
|
||||
static void guiDEAD(std::string msg);
|
||||
static void guiDEAD(char* msg);
|
||||
static void guiMoveWindow(HWND, RECT*);
|
||||
static void guiClearLogWindow(void);
|
||||
static void guiKillTrayIcon(void);
|
||||
|
@ -159,7 +161,8 @@ namespace pvpgn
|
|||
wc.lpszClassName = "BnetdWndClass";
|
||||
wc.hIconSm = NULL;
|
||||
|
||||
if (!RegisterClassEx(&wc)) guiDEAD("cant register WNDCLASS");
|
||||
if (!RegisterClassEx(&wc))
|
||||
guiDEAD("cant register WNDCLASS");
|
||||
|
||||
gui.hwnd = CreateWindowEx(
|
||||
0,
|
||||
|
@ -175,7 +178,8 @@ namespace pvpgn
|
|||
(HINSTANCE)param,
|
||||
NULL);
|
||||
|
||||
if (!gui.hwnd) guiDEAD("cant create window");
|
||||
if (!gui.hwnd)
|
||||
guiDEAD("cant create window");
|
||||
|
||||
ShowWindow(gui.hwnd, SW_SHOW);
|
||||
SetEvent(gui.event_ready);
|
||||
|
@ -228,7 +232,8 @@ namespace pvpgn
|
|||
0,
|
||||
NULL);
|
||||
|
||||
if (!ghwndConsole) return FALSE;
|
||||
if (!ghwndConsole)
|
||||
return FALSE;
|
||||
|
||||
gui.hwndUsers = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
|
@ -242,7 +247,8 @@ namespace pvpgn
|
|||
0,
|
||||
NULL);
|
||||
|
||||
if (!gui.hwndUsers) return FALSE;
|
||||
if (!gui.hwndUsers)
|
||||
return FALSE;
|
||||
|
||||
//amadeo: temp. button for useredit until rightcklick is working....
|
||||
gui.hwndUserEditButton = CreateWindow(
|
||||
|
@ -256,7 +262,8 @@ namespace pvpgn
|
|||
0,
|
||||
NULL);
|
||||
|
||||
if (!gui.hwndUserEditButton) return FALSE;
|
||||
if (!gui.hwndUserEditButton)
|
||||
return FALSE;
|
||||
|
||||
gui.hwndUserCount = CreateWindowEx(
|
||||
WS_EX_CLIENTEDGE,
|
||||
|
@ -270,13 +277,14 @@ namespace pvpgn
|
|||
0,
|
||||
NULL);
|
||||
|
||||
if (!gui.hwndUserCount) return FALSE;
|
||||
if (!gui.hwndUserCount)
|
||||
return FALSE;
|
||||
|
||||
SendMessage(gui.hwndUserCount, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
|
||||
SendMessage(gui.hwndUsers, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
|
||||
SendMessage(gui.hwndUserEditButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
|
||||
BringWindowToTop(gui.hwndUsers);
|
||||
strcpy(gui.szDefaultStatus, "Void");
|
||||
std::strcpy(gui.szDefaultStatus, "Void");
|
||||
|
||||
gui.y_ratio = (100 << 10) / 100;
|
||||
gui.x_ratio = (0 << 10) / 100;
|
||||
|
@ -346,20 +354,24 @@ namespace pvpgn
|
|||
|
||||
static int guiOnShellNotify(int uID, int uMessage)
|
||||
{
|
||||
if (uID == IDI_TRAY) {
|
||||
if (uMessage == WM_LBUTTONDBLCLK) {
|
||||
if (uID == IDI_TRAY)
|
||||
{
|
||||
if (uMessage == WM_LBUTTONDBLCLK)
|
||||
{
|
||||
if (!IsWindowVisible(gui.hwnd))
|
||||
ShowWindow(gui.hwnd, SW_RESTORE);
|
||||
|
||||
SetForegroundWindow(gui.hwnd);
|
||||
}
|
||||
else if (uMessage == WM_RBUTTONDOWN) {
|
||||
else if (uMessage == WM_RBUTTONDOWN)
|
||||
{
|
||||
POINT cp;
|
||||
GetCursorPos(&cp);
|
||||
SetForegroundWindow(gui.hwnd);
|
||||
TrackPopupMenu(gui.hmenuTray, TPM_LEFTALIGN | TPM_LEFTBUTTON, cp.x, cp.y, 0, gui.hwnd, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -385,11 +397,13 @@ namespace pvpgn
|
|||
static void guiOnClose(HWND hwnd)
|
||||
{
|
||||
guiKillTrayIcon();
|
||||
if (!gui.main_finished) {
|
||||
if (!gui.main_finished)
|
||||
{
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "GUI wants server dead...");
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "GUI wants to exit...");
|
||||
eventlog_close();
|
||||
SetEvent(gui.event_ready);
|
||||
|
@ -400,7 +414,8 @@ namespace pvpgn
|
|||
{
|
||||
int cy_console, cy_edge, cx_edge, cy_frame, cy_status;
|
||||
|
||||
if (state == SIZE_MINIMIZED) {
|
||||
if (state == SIZE_MINIMIZED)
|
||||
{
|
||||
NOTIFYICONDATA dta;
|
||||
|
||||
dta.cbSize = sizeof(NOTIFYICONDATA);
|
||||
|
@ -409,15 +424,14 @@ namespace pvpgn
|
|||
dta.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||
dta.uCallbackMessage = WM_SHELLNOTIFY;
|
||||
dta.hIcon = LoadIcon(GetWindowInstance(hwnd), MAKEINTRESOURCE(IDI_ICON1));
|
||||
strcpy(dta.szTip, "PvPGN");
|
||||
strcat(dta.szTip, " ");
|
||||
strcat(dta.szTip, PVPGN_VERSION);
|
||||
std::strcpy(dta.szTip, std::string(std::string(PVPGN_SOFTWARE) + " " + std::string(PVPGN_VERSION)).c_str());
|
||||
Shell_NotifyIcon(NIM_ADD, &dta);
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state == SIZE_RESTORED) {
|
||||
if (state == SIZE_RESTORED)
|
||||
{
|
||||
NOTIFYICONDATA dta;
|
||||
|
||||
dta.hWnd = hwnd;
|
||||
|
@ -456,7 +470,8 @@ namespace pvpgn
|
|||
{
|
||||
POINT p;
|
||||
|
||||
if (hwnd == hwndCursor && codeHitTest == HTCLIENT) {
|
||||
if (hwnd == hwndCursor && codeHitTest == HTCLIENT)
|
||||
{
|
||||
GetCursorPos(&p);
|
||||
ScreenToClient(hwnd, &p);
|
||||
if (PtInRect(&gui.rectHDivider, p))
|
||||
|
@ -475,7 +490,8 @@ namespace pvpgn
|
|||
p.x = x;
|
||||
p.y = y;
|
||||
|
||||
if (PtInRect(&gui.rectHDivider, p)) {
|
||||
if (PtInRect(&gui.rectHDivider, p))
|
||||
{
|
||||
SetCapture(hwnd);
|
||||
gui.mode |= MODE_HDIVIDE;
|
||||
}
|
||||
|
@ -497,7 +513,8 @@ namespace pvpgn
|
|||
int offset, cy_console, cy_users;
|
||||
RECT r;
|
||||
|
||||
if (gui.mode & MODE_HDIVIDE) {
|
||||
if (gui.mode & MODE_HDIVIDE)
|
||||
{
|
||||
offset = y - gui.rectHDivider.top;
|
||||
if (!offset) return;
|
||||
cy_console = gui.rectConsole.bottom - gui.rectConsole.top;
|
||||
|
@ -552,7 +569,6 @@ namespace pvpgn
|
|||
t_connection * c;
|
||||
t_elem const * curr;
|
||||
t_account * acc;
|
||||
char UserCount[80];
|
||||
|
||||
SendMessage(gui.hwndUsers, LB_RESETCONTENT, 0, 0);
|
||||
|
||||
|
@ -564,9 +580,8 @@ namespace pvpgn
|
|||
SendMessage(gui.hwndUsers, LB_ADDSTRING, 0, (LPARAM)account_get_name(acc));
|
||||
}
|
||||
|
||||
sprintf(UserCount, "%d", connlist_login_get_length());
|
||||
strcat(UserCount, " user(s) online:");
|
||||
SendMessage(gui.hwndUserCount, WM_SETTEXT, 0, (LPARAM)UserCount);
|
||||
std::string UserCount(std::to_string(connlist_login_get_length()) + " user(s) online:");
|
||||
SendMessage(gui.hwndUserCount, WM_SETTEXT, 0, (LPARAM)UserCount.c_str());
|
||||
}
|
||||
|
||||
static void guiAddText(const char *str, COLORREF clr)
|
||||
|
@ -577,7 +592,8 @@ namespace pvpgn
|
|||
CHARFORMAT fmt;
|
||||
text_length = SendMessage(ghwndConsole, WM_GETTEXTLENGTH, 0, 0);
|
||||
|
||||
if (text_length > 30000) {
|
||||
if (text_length > 30000)
|
||||
{
|
||||
ds.cpMin = 0;
|
||||
ds.cpMax = text_length - 30000;
|
||||
SendMessage(ghwndConsole, EM_EXSETSEL, 0, (LPARAM)&ds);
|
||||
|
@ -594,17 +610,15 @@ namespace pvpgn
|
|||
fmt.yHeight = 160;
|
||||
fmt.dwEffects = 0;
|
||||
fmt.crTextColor = clr;
|
||||
strcpy(fmt.szFaceName, "Courier New");
|
||||
std::strcpy(fmt.szFaceName, "Courier New");
|
||||
|
||||
SendMessage(ghwndConsole, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
|
||||
SendMessage(ghwndConsole, EM_REPLACESEL, FALSE, (LPARAM)str);
|
||||
}
|
||||
|
||||
static void guiDEAD(char *message)
|
||||
static void guiDEAD(std::string message)
|
||||
{
|
||||
char *nl;
|
||||
char errorStr[4096];
|
||||
char *msgLastError;
|
||||
char *msgLastError = nullptr;
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
|
@ -615,14 +629,21 @@ namespace pvpgn
|
|||
0,
|
||||
NULL);
|
||||
|
||||
nl = strchr(msgLastError, '\r');
|
||||
if (nl) *nl = 0;
|
||||
char *nl = std::strchr(msgLastError, '\r');
|
||||
if (nl)
|
||||
*nl = 0;
|
||||
|
||||
sprintf(errorStr, "%s\nGetLastError() = '%s'\n", message, msgLastError);
|
||||
std::string errorStr(message + "\nGetLastError() = '" + std::string(msgLastError) + "'\n");
|
||||
|
||||
LocalFree(msgLastError);
|
||||
MessageBox(0, errorStr, "guiDEAD", MB_ICONSTOP | MB_OK);
|
||||
exit(1);
|
||||
|
||||
MessageBox(0, errorStr.c_str(), "guiDEAD", MB_ICONSTOP | MB_OK);
|
||||
|
||||
std::exit(1);
|
||||
}
|
||||
static void guiDEAD(char *message)
|
||||
{
|
||||
guiDEAD(std::string(message));
|
||||
}
|
||||
|
||||
static void guiMoveWindow(HWND hwnd, RECT* r)
|
||||
|
@ -648,11 +669,13 @@ namespace pvpgn
|
|||
|
||||
BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (Message) {
|
||||
switch (Message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
EndDialog(hwnd, IDOK);
|
||||
break;
|
||||
|
@ -667,34 +690,38 @@ namespace pvpgn
|
|||
|
||||
BOOL CALLBACK AnnDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
t_message *message;
|
||||
|
||||
switch (Message) {
|
||||
switch (Message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT1));
|
||||
int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT1));
|
||||
|
||||
if (len > 0) {
|
||||
char* buf;
|
||||
buf = (char*)GlobalAlloc(GPTR, len + 1);
|
||||
GetDlgItemText(hwnd, IDC_EDIT1, buf, len + 1);
|
||||
if (len > 0)
|
||||
{
|
||||
char* buf = static_cast<char*>(GlobalAlloc(GPTR, len + 1));
|
||||
GetDlgItemText(hwnd, IDC_EDIT1, buf, len + 1);
|
||||
|
||||
if ((message = message_create(message_type_error, NULL, buf))) {
|
||||
message_send_all(message);
|
||||
message_destroy(message);
|
||||
}
|
||||
t_message *message = message_create(message_type_error, nullptr, buf);
|
||||
if (message)
|
||||
{
|
||||
message_send_all(message);
|
||||
message_destroy(message);
|
||||
}
|
||||
|
||||
GlobalFree((HANDLE)buf);
|
||||
SetDlgItemText(hwnd, IDC_EDIT1, "");
|
||||
}
|
||||
else {
|
||||
MessageBox(hwnd, "You didn't enter anything!", "Warning", MB_OK);
|
||||
}
|
||||
break;
|
||||
GlobalFree((HGLOBAL)buf);
|
||||
SetDlgItemText(hwnd, IDC_EDIT1, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(hwnd, "You didn't enter anything!", "Warning", MB_OK);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -709,9 +736,11 @@ namespace pvpgn
|
|||
|
||||
BOOL CALLBACK KickDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (Message) {
|
||||
switch (Message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
if (selected_item[0] != 0) {
|
||||
if (selected_item[0] != 0)
|
||||
{
|
||||
SetDlgItemText(hwnd, IDC_EDITKICK, selected_item);
|
||||
}
|
||||
|
||||
|
@ -720,99 +749,104 @@ namespace pvpgn
|
|||
switch (LOWORD(wParam)) {
|
||||
case IDC_KICK_EXECUTE:
|
||||
{
|
||||
t_connection * conngui;
|
||||
t_account * accountgui;
|
||||
BOOL messageq;
|
||||
BOOL kickq;
|
||||
char temp[60];
|
||||
char ipadr[110];
|
||||
GetDlgItemText(hwnd, IDC_EDITKICK, selected_item, 32);
|
||||
|
||||
messageq = FALSE;
|
||||
kickq = FALSE;
|
||||
t_connection * conngui = connlist_find_connection_by_accountname(selected_item);
|
||||
t_account * accountgui = accountlist_find_account(selected_item);
|
||||
|
||||
GetDlgItemText(hwnd, IDC_EDITKICK, selected_item, 32);
|
||||
if (conngui == nullptr)
|
||||
{
|
||||
std::strcat(selected_item, " could not be found in Userlist!");
|
||||
MessageBox(hwnd, selected_item, "Error", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
HWND hButton = GetDlgItem(hwnd, IDC_CHECKBAN);
|
||||
HWND hButton1 = GetDlgItem(hwnd, IDC_CHECKKICK);
|
||||
HWND hButton2 = GetDlgItem(hwnd, IDC_CHECKADMIN);
|
||||
HWND hButton3 = GetDlgItem(hwnd, IDC_CHECKMOD);
|
||||
HWND hButton4 = GetDlgItem(hwnd, IDC_CHECKANN);
|
||||
|
||||
conngui = connlist_find_connection_by_accountname(selected_item);
|
||||
accountgui = accountlist_find_account(selected_item);
|
||||
BOOL messageq = FALSE;
|
||||
BOOL kickq = FALSE;
|
||||
|
||||
if (conngui == NULL) {
|
||||
strcat(selected_item, " could not be found in Userlist!");
|
||||
MessageBox(hwnd, selected_item, "ERROR", MB_OK);
|
||||
}
|
||||
else {
|
||||
if (SendMessage(hButton2, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
{
|
||||
account_set_admin(accountgui);
|
||||
account_set_command_groups(accountgui, 255);
|
||||
messageq = TRUE;
|
||||
}
|
||||
|
||||
HWND hButton = GetDlgItem(hwnd, IDC_CHECKBAN);
|
||||
HWND hButton1 = GetDlgItem(hwnd, IDC_CHECKKICK);
|
||||
HWND hButton2 = GetDlgItem(hwnd, IDC_CHECKADMIN);
|
||||
HWND hButton3 = GetDlgItem(hwnd, IDC_CHECKMOD);
|
||||
HWND hButton4 = GetDlgItem(hwnd, IDC_CHECKANN);
|
||||
if (SendMessage(hButton3, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
{
|
||||
account_set_auth_operator(accountgui, nullptr, 1);
|
||||
messageq = TRUE;
|
||||
}
|
||||
|
||||
if (SendMessage(hButton2, BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
||||
account_set_admin(accountgui);
|
||||
account_set_command_groups(accountgui, 255);
|
||||
messageq = TRUE;
|
||||
}
|
||||
if (SendMessage(hButton4, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
{
|
||||
account_set_strattr(accountgui, "BNET\\auth\\announce", "true");
|
||||
messageq = TRUE;
|
||||
}
|
||||
|
||||
if (SendMessage(hButton3, BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
||||
account_set_auth_operator(accountgui, NULL, 1);
|
||||
messageq = TRUE;
|
||||
}
|
||||
if (SendMessage(hButton, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
{
|
||||
char temp[60];
|
||||
char ipadr[110];
|
||||
unsigned int i_GUI;
|
||||
|
||||
if (SendMessage(hButton4, BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
||||
account_set_strattr(accountgui, "BNET\\auth\\announce", "true");
|
||||
messageq = TRUE;
|
||||
}
|
||||
std::strcpy(temp, addr_num_to_addr_str(conn_get_addr(conngui), 0));
|
||||
|
||||
if (SendMessage(hButton, BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
||||
unsigned int i_GUI;
|
||||
for (i_GUI = 0; temp[i_GUI] != ':'; i_GUI++)
|
||||
ipadr[i_GUI] = temp[i_GUI];
|
||||
|
||||
strcpy(temp, addr_num_to_addr_str(conn_get_addr(conngui), 0));
|
||||
ipadr[i_GUI] = 0;
|
||||
|
||||
for (i_GUI = 0; temp[i_GUI] != ':'; i_GUI++)
|
||||
ipadr[i_GUI] = temp[i_GUI];
|
||||
std::strcpy(temp, " a ");
|
||||
std::strcat(temp, ipadr);
|
||||
handle_ipban_command(NULL, temp);
|
||||
|
||||
ipadr[i_GUI] = 0;
|
||||
temp[0] = 0;
|
||||
std::strcpy(temp, " has been added to IpBanList");
|
||||
std::strcat(ipadr, temp);
|
||||
if (messageq == TRUE)
|
||||
{
|
||||
std::strcat(ipadr, " and UserStatus changed");
|
||||
MessageBox(hwnd, ipadr, "ipBan & StatusChange", MB_OK);
|
||||
messageq = FALSE;
|
||||
kickq = FALSE;
|
||||
}
|
||||
else
|
||||
MessageBox(hwnd, ipadr, "ipBan", MB_OK);
|
||||
}
|
||||
|
||||
strcpy(temp, " a ");
|
||||
strcat(temp, ipadr);
|
||||
handle_ipban_command(NULL, temp);
|
||||
if (SendMessage(hButton1, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
||||
{
|
||||
conn_set_state(conngui, conn_state_destroy);
|
||||
kickq = TRUE;
|
||||
}
|
||||
|
||||
temp[0] = 0;
|
||||
strcpy(temp, " has been added to IpBanList");
|
||||
strcat(ipadr, temp);
|
||||
if (messageq == TRUE) {
|
||||
strcat(ipadr, " and UserStatus changed");
|
||||
MessageBox(hwnd, ipadr, "ipBan & StatusChange", MB_OK);
|
||||
messageq = FALSE;
|
||||
kickq = FALSE;
|
||||
}
|
||||
else
|
||||
MessageBox(hwnd, ipadr, "ipBan", MB_OK);
|
||||
}
|
||||
if ((messageq == TRUE) && (kickq == TRUE))
|
||||
{
|
||||
std::strcat(selected_item, "has been kicked and Status has changed");
|
||||
MessageBox(hwnd, selected_item, "UserKick & StatusChange", MB_OK);
|
||||
}
|
||||
|
||||
if (SendMessage(hButton1, BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
||||
conn_set_state(conngui, conn_state_destroy);
|
||||
kickq = TRUE;
|
||||
}
|
||||
if ((kickq == TRUE) && (messageq == FALSE))
|
||||
{
|
||||
std::strcat(selected_item, " has been kicked from the server");
|
||||
MessageBox(hwnd, selected_item, "UserKick", MB_OK);
|
||||
}
|
||||
|
||||
if ((messageq == TRUE) && (kickq == TRUE)) {
|
||||
strcat(selected_item, "has been kicked and Status has changed");
|
||||
MessageBox(hwnd, selected_item, "UserKick & StatusChange", MB_OK);
|
||||
}
|
||||
if ((kickq == FALSE) && (messageq == TRUE))
|
||||
{
|
||||
std::strcat(selected_item, "'s Status has been changed");
|
||||
MessageBox(hwnd, selected_item, "StatusChange", MB_OK);
|
||||
}
|
||||
|
||||
if ((kickq == TRUE) && (messageq == FALSE)) {
|
||||
strcat(selected_item, " has been kicked from the server");
|
||||
MessageBox(hwnd, selected_item, "UserKick", MB_OK);
|
||||
}
|
||||
|
||||
if ((kickq == FALSE) && (messageq == TRUE)) {
|
||||
strcat(selected_item, "'s Status has been changed");
|
||||
MessageBox(hwnd, selected_item, "StatusChange", MB_OK);
|
||||
}
|
||||
|
||||
selected_item[0] = 0;
|
||||
}
|
||||
break;
|
||||
selected_item[0] = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -890,11 +924,13 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE reserved, LPSTR lpCmdLine, i
|
|||
#endif
|
||||
Console console;
|
||||
|
||||
if (cmdline_load(__argc, __argv) != 1) {
|
||||
if (cmdline_load(__argc, __argv) != 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cmdline_get_console()){
|
||||
if (cmdline_get_console())
|
||||
{
|
||||
console.RedirectIOToConsole();
|
||||
return app_main(__argc, __argv);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue