summaryrefslogtreecommitdiff
path: root/src/char_sql/int_homun.c
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-08-23 13:09:50 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-08-23 13:09:50 +0000
commit94281a398ef3a288a23cebb9f2d9a5227c570996 (patch)
treeb55207b5a40b9c019d150772ddbb1ffc6661f80c /src/char_sql/int_homun.c
parent59b08db5fcebd6e3d94f5353602fc685dbf9e3f5 (diff)
downloadhercules-94281a398ef3a288a23cebb9f2d9a5227c570996.tar.gz
hercules-94281a398ef3a288a23cebb9f2d9a5227c570996.tar.bz2
hercules-94281a398ef3a288a23cebb9f2d9a5227c570996.tar.xz
hercules-94281a398ef3a288a23cebb9f2d9a5227c570996.zip
- Mercenary Packets (Server to Client). Still need a little more info.
- Packet for Mercenary Menu. - Some other progress as creation but need more code. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13116 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/int_homun.c')
-rw-r--r--src/char_sql/int_homun.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c
index 042db85aa..14a142ef9 100644
--- a/src/char_sql/int_homun.c
+++ b/src/char_sql/int_homun.c
@@ -292,18 +292,71 @@ static void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, c
mapif_homunculus_renamed(fd, account_id, char_id, result, name);
}
+/*==========================================
+ * Mercenary's System
+ *------------------------------------------*/
+bool mapif_mercenary_save(struct s_mercenary* merc)
+{
+ bool flag = true;
+
+ if( merc->mercenary_id == 0 )
+ { // Create new DB entry
+ if( SQL_ERROR == Sql_Query(sql_handle,
+ "INSERT INTO `mercenary` (`char_id`,`class`,`hp`,`sp`,`kill_counter`,`life_time`) VALUES ('%d','%d','%d','%d','%u','%u')",
+ merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->remain_life_time) )
+ {
+ Sql_ShowDebug(sql_handle);
+ flag = false;
+ }
+ else
+ merc->mercenary_id = (int)Sql_LastInsertId(sql_handle);
+ }
+ else if( SQL_ERROR == Sql_Query(sql_handle,
+ "UPDATE `mercenary` SET `char_id` = '%d', `class` = '%d', `hp` = '%d', `sp` = '%d', `kill_counter` = '%u', `life_time` = '%u' WHERE `mer_id` = '%d'",
+ merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->remain_life_time, merc->mercenary_id) )
+ { // Update DB entry
+ Sql_ShowDebug(sql_handle);
+ flag = false;
+ }
+
+ return flag;
+}
+
+static void mapif_mercenary_created(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,2) = size;
+ WFIFOB(fd,4) = flag;
+ memcpy(WFIFOP(fd,5),merc,sizeof(struct s_mercenary));
+ WFIFOSET(fd,size);
+}
+
+static void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc)
+{
+ bool result = mapif_mercenary_save(merc);
+ mapif_mercenary_created(fd, merc, result);
+}
+/*==========================================
+ * Inter Packets
+ *------------------------------------------*/
int inter_homunculus_parse_frommap(int fd)
{
unsigned short cmd = RFIFOW(fd,0);
switch( cmd )
{
+ // Homunculus Packets
case 0x3090: mapif_parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
case 0x3091: mapif_parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
case 0x3092: mapif_parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
case 0x3093: mapif_parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break;
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;
default:
return 0;
}