summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql-files/main.sql1
-rw-r--r--sql-files/upgrade_svn13117_char.sql1
-rw-r--r--src/char_sql/char.c55
-rw-r--r--src/char_sql/int_homun.c57
-rw-r--r--src/char_sql/inter.c2
-rw-r--r--src/map/intif.c18
-rw-r--r--src/map/intif.h1
-rw-r--r--src/map/pc.c4
8 files changed, 105 insertions, 34 deletions
diff --git a/sql-files/main.sql b/sql-files/main.sql
index a79eee0e1..a5c23421a 100644
--- a/sql-files/main.sql
+++ b/sql-files/main.sql
@@ -79,6 +79,7 @@ CREATE TABLE IF NOT EXISTS `char` (
`guild_id` int(11) unsigned NOT NULL default '0',
`pet_id` int(11) unsigned NOT NULL default '0',
`homun_id` int(11) unsigned NOT NULL default '0',
+ `mer_id` int(11) unsigned NOT NULL default '0',
`hair` tinyint(4) unsigned NOT NULL default '0',
`hair_color` smallint(5) unsigned NOT NULL default '0',
`clothes_color` smallint(5) unsigned NOT NULL default '0',
diff --git a/sql-files/upgrade_svn13117_char.sql b/sql-files/upgrade_svn13117_char.sql
new file mode 100644
index 000000000..99fea2086
--- /dev/null
+++ b/sql-files/upgrade_svn13117_char.sql
@@ -0,0 +1 @@
+ALTER TABLE `char` ADD COLUMN `mer_id` INTEGER UNSIGNED NOT NULL DEFAULT '0' AFTER `homun_id`; \ No newline at end of file
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 28743d51f..55e7a9145 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -943,25 +943,26 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT, &p->hair, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT, &p->weapon, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT, &p->shield, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT, &p->head_top, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_INT, &p->partner_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_INT, &p->father, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_INT, &p->mother, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_INT, &p->child, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_INT, &p->fame, 0, NULL, NULL) )
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_INT, &p->mer_id, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p->hair, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT, &p->weapon, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT, &p->shield, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT, &p->head_top, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_INT, &p->partner_id, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_INT, &p->father, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_INT, &p->mother, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_INT, &p->child, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 48, SQLDT_INT, &p->fame, 0, NULL, NULL) )
{
SqlStmt_ShowDebug(stmt);
SqlStmt_Free(stmt);
@@ -1283,11 +1284,11 @@ int delete_char_sql(int char_id)
{
char name[NAME_LENGTH];
char esc_name[NAME_LENGTH*2+1]; //Name needs be escaped.
- int account_id, party_id, guild_id, hom_id, base_level, partner_id, father_id, mother_id;
+ int account_id, party_id, guild_id, hom_id, mer_id, base_level, partner_id, father_id, mother_id;
char* data;
size_t len;
- if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id`,`partner_id`,`father`,`mother` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
+ if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name`,`account_id`,`party_id`,`guild_id`,`base_level`,`homun_id`,`mer_id`,`partner_id`,`father`,`mother` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
Sql_ShowDebug(sql_handle);
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
@@ -1303,9 +1304,10 @@ int delete_char_sql(int char_id)
Sql_GetData(sql_handle, 3, &data, NULL); guild_id = atoi(data);
Sql_GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
Sql_GetData(sql_handle, 5, &data, NULL); hom_id = atoi(data);
- Sql_GetData(sql_handle, 6, &data, NULL); partner_id = atoi(data);
- Sql_GetData(sql_handle, 7, &data, NULL); father_id = atoi(data);
- Sql_GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data);
+ Sql_GetData(sql_handle, 6, &data, NULL); mer_id = atoi(data);
+ Sql_GetData(sql_handle, 7, &data, NULL); partner_id = atoi(data);
+ Sql_GetData(sql_handle, 8, &data, NULL); father_id = atoi(data);
+ Sql_GetData(sql_handle, 9, &data, NULL); mother_id = atoi(data);
Sql_EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH));
Sql_FreeResult(sql_handle);
@@ -1357,8 +1359,11 @@ int delete_char_sql(int char_id)
Sql_ShowDebug(sql_handle);
/* remove homunculus */
- if (hom_id)
+ if( hom_id )
mapif_homunculus_delete(hom_id);
+ /* remove mercenary */
+ if( mer_id )
+ mapif_mercenary_delete(hom_id);
/* delete char's friends list */
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) )
diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c
index 14a142ef9..f949ac4f9 100644
--- a/src/char_sql/int_homun.c
+++ b/src/char_sql/int_homun.c
@@ -322,12 +322,55 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
return flag;
}
-static void mapif_mercenary_created(int fd, struct s_mercenary *merc, unsigned char flag)
+bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
+{
+ char* data;
+
+ memset(merc, 0, sizeof(struct s_mercenary));
+ merc->mercenary_id = merc_id;
+ merc->char_id = char_id;
+
+ if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `mercenary` WHERE `merc_id` = '%d' AND `char_id` = '%d'", merc_id, char_id) )
+ {
+ Sql_ShowDebug(sql_handle);
+ return false;
+ }
+
+ if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
+ {
+ Sql_FreeResult(sql_handle);
+ return false;
+ }
+
+ Sql_GetData(sql_handle, 1, &data, NULL); merc->class_ = atoi(data);
+ Sql_GetData(sql_handle, 2, &data, NULL); merc->hp = atoi(data);
+ Sql_GetData(sql_handle, 3, &data, NULL); merc->sp = atoi(data);
+ Sql_GetData(sql_handle, 4, &data, NULL); merc->kill_count = atoi(data);
+ Sql_GetData(sql_handle, 5, &data, NULL); merc->remain_life_time = atoi(data);
+ Sql_FreeResult(sql_handle);
+ if( save_log )
+ ShowInfo("Mercenary loaded (%d - %d).\n", merc->mercenary_id, merc->char_id);
+
+ return true;
+}
+
+bool mapif_mercenary_delete(int merc_id)
+{
+ if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `merc_id` = '%d'", merc_id) )
+ {
+ Sql_ShowDebug(sql_handle);
+ return false;
+ }
+
+ return true;
+}
+
+static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag)
{
int size = sizeof(struct s_mercenary) + 5;
WFIFOHEAD(fd,size);
- WFIFOW(fd,0) = 0x3860;
+ WFIFOW(fd,0) = 0x3870;
WFIFOW(fd,2) = size;
WFIFOB(fd,4) = flag;
memcpy(WFIFOP(fd,5),merc,sizeof(struct s_mercenary));
@@ -337,7 +380,14 @@ static void mapif_mercenary_created(int fd, struct s_mercenary *merc, unsigned c
static void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc)
{
bool result = mapif_mercenary_save(merc);
- mapif_mercenary_created(fd, merc, result);
+ mapif_mercenary_send(fd, merc, result);
+}
+
+static void mapif_parse_mercenary_load(int fd, int merc_id, int char_id)
+{
+ struct s_mercenary merc;
+ bool result = mapif_mercenary_load(merc_id, char_id, &merc);
+ mapif_mercenary_send(fd, &merc, result);
}
/*==========================================
@@ -357,6 +407,7 @@ int inter_homunculus_parse_frommap(int fd)
case 0x3094: mapif_parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break;
// Mercenary Packets
case 0x3070: mapif_parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,8)); break;
+ case 0x3071: mapif_parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
default:
return 0;
}
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c
index f396a7a98..f29d44ea9 100644
--- a/src/char_sql/inter.c
+++ b/src/char_sql/inter.c
@@ -51,7 +51,7 @@ int inter_recv_packet_length[] = {
5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040-
-1,-1,10,10, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus]
6,-1,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- Quest system [Kevin]
- -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070- Mercenary packets [Zephyrus]
+ -1,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070- Mercenary packets [Zephyrus]
48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3080-
-1,10,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator]
};
diff --git a/src/map/intif.c b/src/map/intif.c
index 7288ec8f8..6a46c6d3c 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1882,7 +1882,7 @@ int intif_mercenary_create(struct s_mercenary *merc)
return 0;
}
-int intif_parse_mercenary_create(int fd)
+int intif_parse_mercenary_received(int fd)
{
int len = RFIFOW(fd,2) - 5;
if( sizeof(struct s_mercenary) != len )
@@ -1892,12 +1892,22 @@ int intif_parse_mercenary_create(int fd)
return 0;
}
- merc_data_received((struct s_mercenary*)RFIFOP(fd,9), RFIFOB(fd,8));
+ merc_data_received((struct s_mercenary*)RFIFOP(fd,5), RFIFOB(fd,4));
return 0;
}
+int intif_mercenary_request(int merc_id, int char_id)
+{
+ if (CheckForCharServer())
+ return 0;
-
+ WFIFOHEAD(inter_fd,10);
+ WFIFOW(inter_fd,0) = 0x3071;
+ WFIFOL(inter_fd,2) = merc_id;
+ WFIFOL(inter_fd,6) = char_id;
+ WFIFOSET(inter_fd,10);
+ return 0;
+}
//-----------------------------------------------------------------
// inter serverからの通信
@@ -1988,7 +1998,7 @@ int intif_parse(int fd)
case 0x3855: intif_parse_Auction_bid(fd); break;
#endif
// Mercenary System
- case 0x3870: intif_parse_mercenary_create(fd); break;
+ case 0x3870: intif_parse_mercenary_received(fd); break;
case 0x3880: intif_parse_CreatePet(fd); break;
case 0x3881: intif_parse_RecvPetData(fd); break;
diff --git a/src/map/intif.h b/src/map/intif.h
index 0b4cf348f..b1ee824e0 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -79,6 +79,7 @@ int intif_quest_add(int char_id, struct quest * qd);
// MERCENARY SYSTEM
int intif_mercenary_create(struct s_mercenary *merc);
+int intif_mercenary_request(int merc_id, int char_id);
#ifndef TXT_ONLY
// MAIL SYSTEM
diff --git a/src/map/pc.c b/src/map/pc.c
index 0d173927d..4cd983768 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -917,8 +917,10 @@ int pc_reg_received(struct map_session_data *sd)
intif_request_petdata(sd->status.account_id, sd->status.char_id, sd->status.pet_id);
// Homunculus [albator]
- if (sd->status.hom_id > 0)
+ if( sd->status.hom_id > 0 )
intif_homunculus_requestload(sd->status.account_id, sd->status.hom_id);
+ if( sd->status.mer_id > 0 )
+ intif_mercenary_request(sd->status.mer_id, sd->status.char_id);
map_addiddb(&sd->bl);
map_delnickdb(sd->status.char_id, sd->status.name);