Jump to content
  • 0
Sign in to follow this  
stiflerxx

Diff Harmony>>Hercules

Question

someone help me make this diff harmony compatible with Hercules?

 

 

src/char/char.c | 28 +++++++++++++++++
src/common/Makefile.in | 4 +--
src/common/core.c | 6 ++++
src/common/mmo.h | 7 +++++
src/common/socket.c | 14 +++++++++
src/common/socket.h | 2 ++
src/login/account.h | 4 +++
src/login/account_sql.c | 35 +++++++++++++++++++--
src/login/login.c | 81 +++++++++++++++++++++++++++++++++++++++++++-----
src/login/login.h | 3 ++
src/login/loginlog.h | 2 +-
src/login/loginlog_sql.c | 6 ++--
src/map/Makefile.in | 4 +--
src/map/atcommand.c | 5 +++
src/map/chrif.c | 20 ++++++++++++
src/map/chrif.h | 2 ++
src/map/clif.c | 6 +++-
src/map/map.c | 5 +++
src/map/packets.h | 1 +
src/map/pc_groups.c | 21 +++++++++++++
src/map/pc_groups.h | 2 ++
src/map/script.c | 3 ++
22 files changed, 242 insertions(+), 19 deletions(-)

diff --git a/src/char/char.c b/src/char/char.c
index 824c782..7ff01ce 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2423,6 +2423,17 @@ int parse_fromlogin(int fd) {
session[fd]->flag.ping = 0;
break;

+ // Harmony
+ case 0x40a3:
+ if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
+ return 0;
+ {
+ RFIFOW(fd, 0) = 0x40a4;
+ mapif_sendall(RFIFOP(fd, 0), RFIFOW(fd,2));
+ }
+ RFIFOSKIP(fd, RFIFOW(fd,2));
+ break;
+
// changesex reply
case 0x2723:
if (RFIFOREST(fd) < 7)
@@ -3590,6 +3601,23 @@ int parse_frommap(int fd)
RFIFOSKIP(fd,10);
break;

+ case 0x40a1: // Harmony
+ {
+ uint16 len;
+
+ if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < (len = RFIFOW(fd,2)))
+ return 0;
+
+ if (login_fd > 0) {
+ WFIFOHEAD(login_fd,len);
+ WFIFOW(login_fd, 0) = 0x40a2;
+ memcpy(WFIFOP(login_fd, 2), RFIFOP(fd, 2), len-2);
+ WFIFOSET(login_fd, len);
+ }
+
+ RFIFOSKIP(fd, len);
+ }
+
case 0x2b1a: // Build and send fame ranking lists [DracoRPG]
if (RFIFOREST(fd) < 2)
return 0;
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index 5dfdd35..2ce8e50 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -20,7 +20,7 @@ MT19937AR_INCLUDE = -I$(MT19937AR_D)

COMMON_SHARED_C = conf.c db.c des.c ers.c grfio.c HPM.c mapindex.c md5calc.c
mutex.c nullpo.c random.c showmsg.c strlib.c sysinfo.c
- thread.c timer.c utils.c
+ thread.c timer.c utils.c harmonycore.c
COMMON_C = $(COMMON_SHARED_C)
COMMON_SHARED_OBJ = $(patsubst %.c,%.o,$(COMMON_SHARED_C))
COMMON_OBJ = $(addprefix obj_all/, $(COMMON_SHARED_OBJ)
@@ -30,7 +30,7 @@ COMMON_MINI_OBJ = $(addprefix obj_all/, $(COMMON_SHARED_OBJ)
COMMON_C += console.c core.c malloc.c socket.c
COMMON_H = atomic.h cbasetypes.h conf.h console.h core.h db.h des.h ers.h
grfio.h HPM.h HPMi.h malloc.h mapindex.h md5calc.h mmo.h mutex.h
- nullpo.h random.h showmsg.h socket.h spinlock.h sql.h strlib.h
+ nullpo.h random.h showmsg.h harmony.h harmserv.h socket.h spinlock.h sql.h strlib.h
sysinfo.h thread.h timer.h utils.h winapi.h

COMMON_SQL_OBJ = obj_sql/sql.o
diff --git a/src/common/core.c b/src/common/core.c
index 99dbc36..d649941 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -30,9 +30,11 @@
# include "../common/sql.h"
# include "../common/thread.h"
# include "../common/timer.h"
+#include "../common/harmony.h"
# include "../common/utils.h"
#endif

+
#ifndef _WIN32
# include
#else
@@ -248,6 +250,8 @@ int main (int argc, char **argv) {

sockt->init();

+ harmony_core_init();
+
do_init(argc,argv);
{// Main runtime cycle
int next;
@@ -257,6 +261,8 @@ int main (int argc, char **argv) {
}
}

+ harmony_core_final();
+
console->final();

retval = do_final();
diff --git a/src/common/mmo.h b/src/common/mmo.h
index ff7c1da..68409e2 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -331,6 +331,13 @@ struct storage_data {
struct item items[MAX_STORAGE];
};

+#ifdef HARMSW
+ #undef HARMSW
+#endif
+#define HARMSW HARMSW_RATHENA_GROUP
+#define HARM_HERCULES
+#define HARMONY_USE_POINTLESS_OOP_INTERFACE
+
struct guild_storage {
int dirty;
int guild_id;
diff --git a/src/common/socket.c b/src/common/socket.c
index c57cba3..811cedd 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -21,6 +21,7 @@
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/timer.h"
+#include "../common/harmony.h"

#ifdef WIN32
# include "../common/winapi.h"
@@ -374,6 +375,9 @@ int recv_to_fifo(int fd)
return 0;
}

+ if (!session[fd]->flag.server)
+ len = harm_funcs->net_recv(fd, session[fd]->rdata + session[fd]->rdata_size, len, session[fd]->rdata, session[fd]->rdata_size + len);
+
session[fd]->rdata_size += len;
session[fd]->rdata_tick = sockt->last_tick;
#ifdef SHOW_SERVER_STATS
@@ -489,6 +493,11 @@ int connect_client(int listen_fd) {
create_session(fd, recv_to_fifo, send_from_fifo, default_func_parse);
session[fd]->client_addr = ntohl(client_address.sin_addr.s_addr);

+ if (!harm_funcs->session_new(fd, session[fd]->client_addr)) {
+ sockt->close(fd);
+ return -1;
+ }
+
return fd;
}

@@ -630,6 +639,8 @@ static void delete_session(int fd)
}
if( session[fd]->hdata )
aFree(session[fd]->hdata);
+ if (session[fd]->harm_sd)
+ harm_funcs->session_del(fd);
aFree(session[fd]);
session[fd] = NULL;
}
@@ -745,6 +756,9 @@ int WFIFOSET(int fd, size_t len)
}

}
+ if (!session[fd]->flag.server)
+ harm_funcs->net_send(fd, s->wdata+s->wdata_size, len);
+
s->wdata_size += len;
#ifdef SHOW_SERVER_STATS
socket_data_qo += len;
diff --git a/src/common/socket.h b/src/common/socket.h
index 42b0efe..941c4e2 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -86,6 +86,8 @@ struct socket_data {

uint32 client_addr; // remote client address

+ void *harm_sd;
+
uint8 *rdata, *wdata;
size_t max_rdata, max_wdata;
size_t rdata_size, wdata_size;
diff --git a/src/login/account.h b/src/login/account.h
index e15143c..b09a062 100644
--- a/src/login/account.h
+++ b/src/login/account.h
@@ -23,6 +23,7 @@ struct mmo_account
char pass[32+1]; // 23+1 for plaintext, 32+1 for md5-ed passwords
char sex; // gender (M/F/S)
char email[40]; // e-mail (by default: [email protected])
+ char mac_address[20]; // Harmony v3
int group_id; // player group id
uint8 char_slots; // this accounts maximum character slots (maximum is limited to MAX_CHARS define in char server)
unsigned int state; // packet 0x006a value + 1 (0: complete OK)
@@ -67,6 +68,9 @@ struct AccountDB
/// @param self Database
void (*destroy)(AccountDB* self);

+ /*** HARMONY v3 ***/
+ bool (*is_mac_banned)(AccountDB* self, const char *mac);
+
/// Gets a property from this database.
/// These read-only properties must be implemented:
/// "engine.name" -> "txt", "sql", ...
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index 10852e5..6f92395 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -14,6 +14,7 @@
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
+#include "../common/harmony.h"
#include "../common/socket.h"
#include "../common/sql.h"
#include "../common/strlib.h"
@@ -78,6 +79,9 @@
static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id);
static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new);

+// Harmony
+static bool account_db_sql_is_mac_banned(AccountDB* db, const char *mac);
+
/// public constructor
AccountDB* account_db_sql(void)
{
@@ -94,6 +98,7 @@ AccountDB* account_db_sql(void)
db->vtable.load_num = &account_db_sql_load_num;
db->vtable.load_str = &account_db_sql_load_str;
db->vtable.iterator = &account_db_sql_iterator;
+ db->vtable.is_mac_banned= &account_db_sql_is_mac_banned;

// initialize to default values
db->accounts = NULL;
@@ -420,6 +425,27 @@ static bool account_db_sql_remove(AccountDB* self, const int account_id)
return result;
}

+// Harmony
+static bool account_db_sql_is_mac_banned(AccountDB* self, const char *mac) {
+ AccountDB_SQL* db = (AccountDB_SQL*)self;
+ Sql *db_handle = db->accounts;
+ SqlStmt* stmt = SQL->StmtMalloc(db_handle);
+
+ bool result = false;
+
+ if (SQL_SUCCESS != SQL->StmtPrepare(stmt, "SELECT 1 FROM mac_bans WHERE mac = ?") ||
+ SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (void*)mac, strlen(mac)) ||
+ SQL_SUCCESS != SQL->StmtExecute(stmt)) {
+ Sql_ShowDebug(db_handle);
+ } else {
+ result = (SQL->NumRows(db_handle) > 0);
+ SQL->FreeResult(db_handle);
+ }
+ SQL->StmtFree(stmt);
+
+ return result;
+}
+
/// update an existing account with the provided new data (both account and regs)
static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc)
{
@@ -540,7 +566,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc

// retrieve login entry for the specified account
if( SQL_ERROR == SQL->Query(sql_handle,
- "SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`group_id`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate`,`character_slots`,`pincode`,`pincode_change` FROM `%s` WHERE `account_id` = %d",
+ "SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`group_id`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate`,`character_slots`,`pincode`,`pincode_change`, `last_mac` FROM `%s` WHERE `account_id` = %d",
db->account_db, account_id )
) {
Sql_ShowDebug(sql_handle);
@@ -569,6 +595,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data);
SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode));
SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data);
+ SQL->GetData(sql_handle, 16, &data, NULL); safestrncpy(acc->mac_address, data, sizeof(acc->mac_address));

SQL->FreeResult(sql_handle);

@@ -594,7 +621,7 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
if( is_new )
{// insert into account table
if( SQL_SUCCESS != SQL->StmtPrepare(stmt,
- "INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`, `character_slots`, `pincode`, `pincode_change`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`, `character_slots`, `pincode`, `pincode_change`, `last_mac`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)",
db->account_db)
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
@@ -612,13 +639,14 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 16, SQLDT_LONG, (void*)&acc->mac_address, sizeof(acc->mac_address))
|| SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
break;
}
} else {// update account table
- if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?,`pincode_change`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?,`pincode_change`=?, `last_mac`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
@@ -634,6 +662,7 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_STRING, (void*)acc->mac_address, strlen(acc->mac_address))
|| SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
diff --git a/src/login/login.c b/src/login/login.c
index 1290496..a343cd2 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -15,6 +15,7 @@
#include "loginlog.h"
#include "../common/HPM.h"
#include "../common/core.h"
+#include "../common/harmony.h"
#include "../common/db.h"
#include "../common/malloc.h"
#include "../common/md5calc.h"
@@ -660,6 +661,15 @@ int parse_fromchar(int fd)
}
break;

+ case 0x40a2: // Harmony
+ if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) )
+ return 0;
+ {
+ harm_funcs->login_process(fd, RFIFOP(fd, 4), RFIFOW(fd, 2)-4);
+ RFIFOSKIP(fd, RFIFOW(fd, 2));
+ }
+ break;
+
case 0x2727: // Change of sex (sex is reversed)
if( RFIFOREST(fd) < 6 )
return 0;
@@ -824,7 +834,7 @@ int parse_fromchar(int fd)
if( ( ld = (struct online_login_data*)idb_get(online_db,acc.account_id) ) == NULL )
return 0;

- login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" );
+ login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed", "" );
}

remove_online_user(acc.account_id);
@@ -1056,6 +1066,11 @@ int mmo_auth(struct login_session_data* sd, bool isServer) {
}
}

+ if (acc.sex != 'S' && acc.sex != 's' && (len = harm_funcs->login_process_auth2(sd->fd, acc.group_id)) > 0) {
+ ShowNotice("Connection refused by Harmony (account: %s, ip: %s)n", sd->userid, ip);
+ return len;
+ }
+
ShowNotice("Authentication accepted (account: %s, id: %d, ip: %s)n", sd->userid, acc.account_id, ip);

// update session data
@@ -1067,6 +1082,8 @@ int mmo_auth(struct login_session_data* sd, bool isServer) {
sd->group_id = (uint8)acc.group_id;
sd->expiration_time = acc.expiration_time;

+ memcpy(acc.mac_address, sd->mac_address, sizeof(acc.mac_address));
+
// update account data
timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), "%Y-%m-%d %H:%M:%S");
safestrncpy(acc.last_ip, ip, sizeof(acc.last_ip));
@@ -1163,7 +1180,7 @@ void login_auth_ok(struct login_session_data* sd)
}
}

- login_log(ip, sd->userid, 100, "login ok");
+ login_log(ip, sd->userid, 100, "login ok", sd->mac_address);
ShowStatus("Connection of the account '%s' accepted.n", sd->userid);

WFIFOHEAD(fd,47+32*server_num);
@@ -1256,7 +1273,7 @@ void login_auth_failed(struct login_session_data* sd, int result)
default : error = "Unknown Error."; break;
}

- login_log(ip, sd->userid, result, error);
+ login_log(ip, sd->userid, result, error, sd->mac_address);
}

if( result == 1 && login_config.dynamic_pass_failure_ban )
@@ -1315,7 +1332,7 @@ int parse_login(int fd)
if( login_config.ipban && ipban_check(ipl) )
{
ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).n", ip);
- login_log(ipl, "unknown", -3, "ip banned");
+ login_log(ipl, "unknown", -3, "ip banned", "");
WFIFOHEAD(fd,23);
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = 3; // 3 = Rejected from Server
@@ -1472,6 +1489,32 @@ int parse_login(int fd)
}
break;

+ case 0x254:
+ case 0x255:
+ case 0x256:
+ {
+ int result = harm_funcs->login_process_auth(fd, RFIFOP(fd, 0), RFIFOREST(fd), sd->userid, sd->passwd, &sd->version);
+ RFIFOSKIP(fd, RFIFOREST(fd));
+
+ harm_funcs->login_get_mac_address(fd, sd->mac_address);
+
+ if( login_config.use_md5_passwds )
+ MD5_String(sd->passwd, sd->passwd);
+
+ if (result > 0) {
+ login_auth_failed(sd, result);
+ } else if (result == 0) {
+ return 0;
+ } else {
+ result = mmo_auth(sd, false);
+ if (result == -1)
+ login_auth_ok(sd);
+ else
+ login_auth_failed(sd, result);
+ }
+ }
+ break;
+
case 0x2710: // Connection request of a char-server
if (RFIFOREST(fd) < 86)
return 0;
@@ -1498,7 +1541,7 @@ int parse_login(int fd)

ShowInfo("Connection request of the char-server '%s' @ %u.%u.%u.%u:%u (account: '%s', pass: '%s', ip: '%s')n", server_name, CONVIP(server_ip), server_port, sd->userid, sd->passwd, ip);
sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port);
- login_log(session[fd]->client_addr, sd->userid, 100, message);
+ login_log(session[fd]->client_addr, sd->userid, 100, message, "");

result = mmo_auth(sd, true);
if( runflag == LOGINSERVER_ST_RUNNING &&
@@ -1712,7 +1755,9 @@ int do_final(void) {
aFree(tmp);
}

- login_log(0, "login server", 100, "login server shutdown");
+ login_log(0, "login server", 100, "login server shutdown", "");
+
+ harm_funcs->login_final();

if( login_config.log_login )
loginlog_final();
@@ -1741,6 +1786,23 @@ int do_final(void) {
return EXIT_SUCCESS;
}

+void _FASTCALL harmony_action(int fd, int task, int id, intptr data) {
+ if (task == HARMTASK_ZONE_ACTION) {
+ if (id > 10*1024)
+ return;
+
+ WFIFOHEAD(fd, id);
+ WFIFOW(fd, 0) = 0x40a3;
+ WFIFOW(fd, 2) = id + 4;
+ memcpy(WFIFOP(fd, 4), (const void*)data, id);
+ WFIFOSET(fd, id+4);
+ }
+}
+
+bool _FASTCALL check_mac_banned(const int8 *mac) {
+ return accounts->is_mac_banned(accounts, mac);
+}
+
//------------------------------
// Function called when the server
// has received a crash signal.
@@ -1839,13 +1901,18 @@ int do_init(int argc, char** argv)
exit(EXIT_FAILURE);
}

+ // Initialize Harmony
+ ea_funcs->ea_is_mac_banned = check_mac_banned;
+ harm_funcs->login_init();
+ ea_funcs->action_request = harmony_action;
+
if( runflag != CORE_ST_STOP ) {
shutdown_callback = do_shutdown;
runflag = LOGINSERVER_ST_RUNNING;
}

ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).nn", login_config.login_port);
- login_log(0, "login server", 100, "login server started");
+ login_log(0, "login server", 100, "login server started", "");

HPM->event(HPET_READY);

diff --git a/src/login/login.h b/src/login/login.h
index 9b9d1e8..611951f 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -28,6 +28,9 @@ struct login_session_data {
int login_id2;
char sex;// 'F','M','S'

+ void *harm_sd;
+ char mac_address[20];
+
char userid[NAME_LENGTH];
char passwd[PASSWD_LEN];
int passwdenc;
diff --git a/src/login/loginlog.h b/src/login/loginlog.h
index 52e18f3..7ba5c9d 100644
--- a/src/login/loginlog.h
+++ b/src/login/loginlog.h
@@ -7,7 +7,7 @@
#include "../common/cbasetypes.h"

unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes);
-void login_log(uint32 ip, const char* username, int rcode, const char* message);
+void login_log(uint32 ip, const char* username, int rcode, const char* message, const char* mac);
bool loginlog_init(void);
bool loginlog_final(void);
bool loginlog_config_read(const char* w1, const char* w2);
diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c
index 5654b4c..ea3022a 100644
--- a/src/login/loginlog_sql.c
+++ b/src/login/loginlog_sql.c
@@ -61,7 +61,7 @@ unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes)
/*=============================================
* Records an event in the login log
*---------------------------------------------*/
-void login_log(uint32 ip, const char* username, int rcode, const char* message)
+void login_log(uint32 ip, const char* username, int rcode, const char* message, const char* mac)
{
char esc_username[NAME_LENGTH*2+1];
char esc_message[255*2+1];
@@ -74,8 +74,8 @@ void login_log(uint32 ip, const char* username, int rcode, const char* message)
SQL->EscapeStringLen(sql_handle, esc_message, message, strnlen(message, 255));

retcode = SQL->Query(sql_handle,
- "INSERT INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%s', '%s', '%d', '%s')",
- log_login_db, ip2str(ip,NULL), esc_username, rcode, esc_message);
+ "INSERT INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`, `mac`) VALUES (NOW(), '%s', '%s', '%d', '%s')",
+ log_login_db, ip2str(ip,NULL), esc_username, rcode, esc_message, mac);

if( retcode != SQL_SUCCESS )
Sql_ShowDebug(sql_handle);
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index ee8b7ac..430db80 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -22,14 +22,14 @@ MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
MT19937AR_INCLUDE = -I$(MT19937AR_D)

-MAP_C = atcommand.c battle.c battleground.c buyingstore.c chat.c chrif.c
+MAP_C = harmony.c atcommand.c battle.c battleground.c buyingstore.c chat.c chrif.c
clif.c date.c duel.c elemental.c guild.c homunculus.c HPMmap.c
instance.c intif.c irc-bot.c itemdb.c log.c mail.c map.c mapreg_sql.c
mercenary.c mob.c npc.c npc_chat.c party.c path.c pc.c pc_groups.c
pet.c quest.c script.c searchstore.c skill.c status.c storage.c
trade.c unit.c vending.c
MAP_OBJ = $(addprefix obj_sql/, $(patsubst %c,%o,$(MAP_C)))
-MAP_H = atcommand.h battle.h battleground.h buyingstore.h chat.h chrif.h
+MAP_H = harmony.h harmony_scriptdef.h atcommand.h battle.h battleground.h buyingstore.h chat.h chrif.h
clif.h date.h duel.h elemental.h guild.h homunculus.h HPMmap.h
instance.h intif.h irc-bot.h itemdb.h log.h mail.h map.h mapreg.h
mercenary.h mob.h npc.h packets.h packets_struct.h party.h path.h
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index ef528c4..7e05fe0 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -26,6 +26,7 @@
#include "log.h"
#include "mail.h"
#include "map.h"
+#include "harmony.h"
#include "mapreg.h"
#include "mercenary.h"
#include "mob.h"
@@ -44,6 +45,7 @@
#include "unit.h"
#include "../common/cbasetypes.h"
#include "../common/conf.h"
+#include "../common/harmony.h"
#include "../common/core.h"
#include "../common/malloc.h"
#include "../common/mmo.h" // MAX_CARTS
@@ -1422,6 +1424,8 @@ static inline const char* atcommand_help_string(AtCommandInfo *info) {
return true;
}

+#include "harmony_atcommand.inc"
+
/*==========================================
* @help
*------------------------------------------*/
@@ -9418,6 +9422,7 @@ void atcommand_basecommands(void) {
ACMD_DEF(clearcart),
ACMD_DEF2("blvl", baselevelup),
ACMD_DEF2("jlvl", joblevelup),
+#include "harmony_atcommanddef_ra.inc"
ACMD_DEF(help),
ACMD_DEF(pvpoff),
ACMD_DEF(pvpon),
diff --git a/src/map/chrif.c b/src/map/chrif.c
index c78b343..37b86bc 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -35,6 +35,7 @@
#include "../common/nullpo.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
+#include "../common/harmony.h"
#include "../common/strlib.h"
#include "../common/timer.h"

@@ -1208,6 +1209,17 @@ bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) {
return true;
}

+int chrif_harmony_request(uint8 *dat, size_t dat_size) {
+ chrif_check(-1);
+
+ WFIFOHEAD(chrif->fd,4+dat_size);
+ WFIFOW(chrif->fd,0) = 0x40a1;
+ WFIFOW(chrif->fd,2) = 4+dat_size;
+ memcpy(WFIFOP(chrif->fd,4), dat, dat_size);
+ WFIFOSET(chrif->fd,4+dat_size);
+
+ return 0;
+}

/*=========================================
* Tell char-server character disconnected [Wizputer]
@@ -1368,6 +1380,14 @@ int chrif_parse(int fd) {

cmd = RFIFOW(fd,0);

+ if (cmd == 0x40a4) {
+ if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ return 0;
+ harm_funcs->zone_login_pak(RFIFOP(fd, 4), RFIFOW(fd, 2)-4);
+ RFIFOSKIP(fd, RFIFOW(fd, 2));
+ continue;
+ }
+
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(chrif->packet_len_table) || chrif->packet_len_table[cmd-0x2af8] == 0) {
r = intif->parse(fd); // Passed on to the intif

diff --git a/src/map/chrif.h b/src/map/chrif.h
index 11baaf5..4e4673e 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -40,6 +40,8 @@ struct auth_node {
enum sd_state state; //To track whether player was login in/out or changing maps.
};

+int chrif_harmony_request(uint8 *dat, size_t dat_size);
+
/*=====================================
* Interface : chrif.h
* Generated by HerculesInterfaceMaker
diff --git a/src/map/clif.c b/src/map/clif.c
index b9cd4cb..77e2d32 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -42,6 +42,7 @@
#include "trade.h"
#include "unit.h"
#include "vending.h"
+#include "harmony.h"
#include "../common/HPM.h"
#include "../common/cbasetypes.h"
#include "../common/conf.h"
@@ -50,6 +51,7 @@
#include "../common/malloc.h"
#include "../common/mmo.h" // NEW_CARTS
#include "../common/nullpo.h"
+#include "../common/harmony.h"
#include "../common/random.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
@@ -18406,8 +18408,10 @@ int clif_parse(int fd) {
if( packet_db[cmd].func == clif->pDebug )
packet_db[cmd].func(fd, sd);
else if( packet_db[cmd].func != NULL ) {
- if( !sd && packet_db[cmd].func != clif->pWantToConnection )
+ if( !sd && packet_db[cmd].func != clif->pWantToConnection && !(cmd >= 0x6A0 && cmd <= 0x6E0) )
; //Only valid packet when there is no session
+ else if (!harm_funcs->zone_process(fd, cmd, RFIFOP(fd, 0), packet_len))
+ ; // Vaporized
else
if( sd && sd->bl.prev == NULL && packet_db[cmd].func != clif->pLoadEndAck )
; //Only valid packet when player is not on a map
diff --git a/src/map/map.c b/src/map/map.c
index 045233e..10f43c8 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -46,6 +46,7 @@
#include "storage.h"
#include "trade.h"
#include "unit.h"
+#include "harmony.h"
#include "../common/HPM.h"
#include "../common/cbasetypes.h"
#include "../common/conf.h"
@@ -1712,6 +1713,8 @@ int map_quit(struct map_session_data *sd) {

npc->script_event(sd, NPCE_LOGOUT);

+ harmony_logout(sd);
+
//Unit_free handles clearing the player related data,
//map->quit handles extra specific data which is related to quitting normally
//(changing map-servers invokes unit_free but bypasses map->quit)
@@ -5292,6 +5295,7 @@ int do_final(void) {
gstorage->final();
guild->final();
party->final();
+ harmony_final();
pc->final();
pet->final();
mob->final();
@@ -5811,6 +5815,7 @@ int do_init(int argc, char *argv[])
mob->init(minimal);
pc->init(minimal);
status->init(minimal);
+ harmony_init();
party->init(minimal);
guild->init(minimal);
gstorage->init(minimal);
diff --git a/src/map/packets.h b/src/map/packets.h
index 699bb3f..acdf0ed 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -22,6 +22,7 @@
* - Example: packet(0x0072,19,clif->pWantToConnection,2,6,10,14,18);
*/

+#include "harmony_packets_hercules.inc"
packet(0x0064,55);
packet(0x0065,17);
packet(0x0066,6);
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index e577c64..77e1164 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -288,6 +288,27 @@ static void read_config(void) {
}

/**
+* Iterates groups with a given callback functipn
+ * @public
+ */
+void pc_group_iterate(bool(*callback)(int group_id, int level, const char* name))
+{
+ GroupSettings *group_settings = NULL;
+ DBIterator *iter = NULL;
+
+ iter = db_iterator(pcg->db);
+ for (group_settings = (GroupSettings*)dbi_first(iter);
+ dbi_exists(iter);
+ group_settings = (GroupSettings*)dbi_next(iter))
+ {
+ if (!callback(group_settings->id, group_settings->level, group_settings->name)) {
+ break;
+ }
+ }
+ iter->destroy(iter);
+}
+
+/**
* Checks if player group has a permission
* @param group group
* @param permission permission to check
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index f52e2ba..f627cd5 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -92,6 +92,8 @@ struct pc_groups_interface {
int (*get_idx) (GroupSettings *group);
};

+void pc_group_iterate(bool(*callback)(int group_id, int level, const char* name));
+
struct pc_groups_interface *pcg;

void pc_groups_defaults(void);
diff --git a/src/map/script.c b/src/map/script.c
index 0532156..485245c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18947,6 +18947,8 @@ bool script_add_builtin(const struct script_function *buildin, bool override) {
return true;
}

+#include "harmony_scriptfunc.inc"
+
bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)) {
struct script_function buildin;
buildin.name = name;
@@ -18994,6 +18996,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(setarray,"rv*"),
BUILDIN_DEF(cleararray,"rvi"),
BUILDIN_DEF(copyarray,"rri"),
+#include "harmony_scriptdef.h"
BUILDIN_DEF(getarraysize,"r"),
BUILDIN_DEF(deletearray,"r?"),
BUILDIN_DEF(getelementofarray,"ri"),

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.