summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/Makefile.in4
-rw-r--r--src/char/char.c54
-rw-r--r--src/char/int_elemental.c164
-rw-r--r--src/char/int_elemental.h15
-rw-r--r--src/char/inter.c6
5 files changed, 214 insertions, 29 deletions
diff --git a/src/char/Makefile.in b/src/char/Makefile.in
index 4ef8ae7ea..1c93cfa6d 100644
--- a/src/char/Makefile.in
+++ b/src/char/Makefile.in
@@ -25,8 +25,8 @@ COMMON_SQL_OBJ = ../common/obj_sql/sql.o
COMMON_H = ../common/sql.h
CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \
- obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o
-CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h
+ obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o obj_sql/int_elemental.o
+CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h int_elemental.h
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
diff --git a/src/char/char.c b/src/char/char.c
index a26f81174..46a255716 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -16,6 +16,7 @@
#include "int_guild.h"
#include "int_homun.h"
#include "int_mercenary.h"
+#include "int_elemental.h"
#include "int_party.h"
#include "int_storage.h"
#include "char.h"
@@ -471,7 +472,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
(p->option != cp->option) ||
(p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) ||
(p->pet_id != cp->pet_id) || (p->weapon != cp->weapon) || (p->hom_id != cp->hom_id) ||
- (p->shield != cp->shield) || (p->head_top != cp->head_top) ||
+ (p->ele_id != cp->ele_id) || (p->shield != cp->shield) || (p->head_top != cp->head_top) ||
(p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) ||
(p->rename != cp->rename) || (p->robe != cp->robe)
)
@@ -480,7 +481,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
"`base_exp`='%u', `job_exp`='%u', `zeny`='%d',"
"`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
"`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
- "`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',"
+ "`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',`elemental_id`='%d',"
"`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d',"
"`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `rename`='%d',"
"`delete_date`='%lu',`robe`='%d'"
@@ -489,7 +490,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
p->base_exp, p->job_exp, p->zeny,
p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point,
p->str, p->agi, p->vit, p->int_, p->dex, p->luk,
- p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id,
+ p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->ele_id,
p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom,
mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y,
mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename,
@@ -969,7 +970,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT "
"`char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`,"
"`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`,"
- "`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`hair`,"
+ "`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`elemental_id`,`hair`,"
"`hair_color`,`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`last_x`,`last_y`,"
"`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`"
" FROM `%s` WHERE `char_id`=? LIMIT 1", char_db)
@@ -1004,28 +1005,29 @@ 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, 48, SQLDT_SHORT, &p->rename, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_SHORT, &p->robe, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_INT, &p->ele_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)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_SHORT, &p->rename, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 51, SQLDT_SHORT, &p->robe, 0, NULL, NULL)
)
{
SqlStmt_ShowDebug(stmt);
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
new file mode 100644
index 000000000..0146c8926
--- /dev/null
+++ b/src/char/int_elemental.c
@@ -0,0 +1,164 @@
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#include "../common/mmo.h"
+#include "../common/malloc.h"
+#include "../common/strlib.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
+#include "../common/utils.h"
+#include "../common/sql.h"
+#include "char.h"
+#include "inter.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+bool mapif_elemental_save(struct s_elemental* ele) {
+ bool flag = true;
+
+ if( ele->elemental_id == 0 ) { // Create new DB entry
+ if( SQL_ERROR == Sql_Query(sql_handle,
+ "INSERT INTO `elemental` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`life_time`)"
+ "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')",
+ ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->str, ele->agi, ele->vit, ele->int_, ele->dex, ele->luk, ele->life_time) )
+ {
+ Sql_ShowDebug(sql_handle);
+ flag = false;
+ }
+ else
+ ele->elemental_id = (int)Sql_LastInsertId(sql_handle);
+ } else if( SQL_ERROR == Sql_Query(sql_handle,
+ "UPDATE `elemental` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d',"
+ "`max_hp` = '%d', `max_sp` = '%d', `str` = '%d', `agi` = '%d', `vit` = '%d', `int` = '%d', `dex` = '%d',"
+ "`luk` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'",
+ ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->str, ele->agi,
+ ele->vit, ele->int_, ele->dex, ele->luk, ele->life_time, ele->elemental_id) )
+ { // Update DB entry
+ Sql_ShowDebug(sql_handle);
+ flag = false;
+ }
+ return flag;
+}
+
+bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
+ char* data;
+
+ memset(ele, 0, sizeof(struct s_elemental));
+ ele->elemental_id = ele_id;
+ ele->char_id = char_id;
+
+ if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `str`, `agi`, `vit`, `int`, `dex`,"
+ "`luk`, `life_time` FROM `elemental` WHERE `ele_id` = '%d' AND `char_id` = '%d'",
+ ele_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, 0, &data, NULL); ele->class_ = atoi(data);
+ Sql_GetData(sql_handle, 1, &data, NULL); ele->mode = atoi(data);
+ Sql_GetData(sql_handle, 2, &data, NULL); ele->hp = atoi(data);
+ Sql_GetData(sql_handle, 3, &data, NULL); ele->sp = atoi(data);
+ Sql_GetData(sql_handle, 4, &data, NULL); ele->max_hp = atoi(data);
+ Sql_GetData(sql_handle, 5, &data, NULL); ele->max_sp = atoi(data);
+ Sql_GetData(sql_handle, 6, &data, NULL); ele->str = atoi(data);
+ Sql_GetData(sql_handle, 7, &data, NULL); ele->agi = atoi(data);
+ Sql_GetData(sql_handle, 8, &data, NULL); ele->vit = atoi(data);
+ Sql_GetData(sql_handle, 9, &data, NULL); ele->int_ = atoi(data);
+ Sql_GetData(sql_handle, 10, &data, NULL); ele->dex = atoi(data);
+ Sql_GetData(sql_handle, 11, &data, NULL); ele->luk = atoi(data);
+ Sql_GetData(sql_handle, 12, &data, NULL); ele->life_time = atoi(data);
+ Sql_FreeResult(sql_handle);
+ if( save_log )
+ ShowInfo("Elemental loaded (%d - %d).\n", ele->elemental_id, ele->char_id);
+
+ return true;
+}
+
+bool mapif_elemental_delete(int ele_id) {
+ if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `elemental` WHERE `ele_id` = '%d'", ele_id) ) {
+ Sql_ShowDebug(sql_handle);
+ return false;
+ }
+
+ return true;
+}
+
+#ifndef TXT_SQL_CONVERT
+
+static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
+ int size = sizeof(struct s_elemental) + 5;
+
+ WFIFOHEAD(fd,size);
+ WFIFOW(fd,0) = 0x387c;
+ WFIFOW(fd,2) = size;
+ WFIFOB(fd,4) = flag;
+ memcpy(WFIFOP(fd,5),ele,sizeof(struct s_elemental));
+ WFIFOSET(fd,size);
+}
+
+static void mapif_parse_elemental_create(int fd, struct s_elemental* ele) {
+ bool result = mapif_elemental_save(ele);
+ mapif_elemental_send(fd, ele, result);
+}
+
+static void mapif_parse_elemental_load(int fd, int ele_id, int char_id) {
+ struct s_elemental ele;
+ bool result = mapif_elemental_load(ele_id, char_id, &ele);
+ mapif_elemental_send(fd, &ele, result);
+}
+
+static void mapif_elemental_deleted(int fd, unsigned char flag) {
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x387d;
+ WFIFOB(fd,2) = flag;
+ WFIFOSET(fd,3);
+}
+
+static void mapif_parse_elemental_delete(int fd, int ele_id) {
+ bool result = mapif_elemental_delete(ele_id);
+ mapif_elemental_deleted(fd, result);
+}
+
+static void mapif_elemental_saved(int fd, unsigned char flag) {
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x387e;
+ WFIFOB(fd,2) = flag;
+ WFIFOSET(fd,3);
+}
+
+static void mapif_parse_elemental_save(int fd, struct s_elemental* ele) {
+ bool result = mapif_elemental_save(ele);
+ mapif_elemental_saved(fd, result);
+}
+
+int inter_elemental_sql_init(void) {
+ return 0;
+}
+void inter_elemental_sql_final(void) {
+ return;
+}
+
+/*==========================================
+ * Inter Packets
+ *------------------------------------------*/
+int inter_elemental_parse_frommap(int fd) {
+ unsigned short cmd = RFIFOW(fd,0);
+
+ switch( cmd ) {
+ case 0x307c: mapif_parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
+ case 0x307d: mapif_parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
+ case 0x307e: mapif_parse_elemental_delete(fd, (int)RFIFOL(fd,2)); break;
+ case 0x307f: mapif_parse_elemental_save(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+#endif //TXT_SQL_CONVERT
diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h
new file mode 100644
index 000000000..89001dd95
--- /dev/null
+++ b/src/char/int_elemental.h
@@ -0,0 +1,15 @@
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#ifndef _INT_ELEMENTAL_SQL_H_
+#define _INT_ELEMENTAL_SQL_H_
+
+struct s_elemental;
+
+int inter_elemental_sql_init(void);
+void inter_elemental_sql_final(void);
+int inter_elemental_parse_frommap(int fd);
+
+bool mapif_elemental_delete(int ele_id);
+
+#endif /* _INT_ELEMENTAL_SQL_H_ */
diff --git a/src/char/inter.c b/src/char/inter.c
index 752fe5163..6d4073c57 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -19,6 +19,7 @@
#include "int_mail.h"
#include "int_auction.h"
#include "int_quest.h"
+#include "int_elemental.h"
#include <stdio.h>
#include <string.h>
@@ -50,7 +51,7 @@ int inter_recv_packet_length[] = {
-1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- Quest system [Kevin] [Inkfish]
- -1,10, 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070- Mercenary packets [Zephyrus]
+ -1,10, 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, -1,10, 6,-1, // 3070- Mercenary packets [Zephyrus], Elemental packets [pakpil]
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]
};
@@ -295,6 +296,7 @@ int inter_init_sql(const char *file)
inter_pet_sql_init();
inter_homunculus_sql_init();
inter_mercenary_sql_init();
+ inter_elemental_sql_init();
inter_accreg_sql_init();
inter_mail_sql_init();
inter_auction_sql_init();
@@ -313,6 +315,7 @@ void inter_final(void)
inter_pet_sql_final();
inter_homunculus_sql_final();
inter_mercenary_sql_final();
+ inter_elemental_sql_init();
inter_mail_sql_final();
inter_auction_sql_final();
@@ -723,6 +726,7 @@ int inter_parse_frommap(int fd)
|| inter_pet_parse_frommap(fd)
|| inter_homunculus_parse_frommap(fd)
|| inter_mercenary_parse_frommap(fd)
+ || inter_elemental_parse_frommap(fd)
|| inter_mail_parse_frommap(fd)
|| inter_auction_parse_frommap(fd)
|| inter_quest_parse_frommap(fd)