diff options
author | DracoRPG <DracoRPG@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-07-17 00:15:33 +0000 |
---|---|---|
committer | DracoRPG <DracoRPG@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-07-17 00:15:33 +0000 |
commit | 7b2f7c0503cb5be8bc45f57353d838a4dbf84d7b (patch) | |
tree | 34fb42eb5bf938c6c02b56e26931c6b1937e4c89 /src/map/charsave.c | |
parent | 5a064d5a6723601d08610082ab6c203bc94cdab0 (diff) | |
download | hercules-7b2f7c0503cb5be8bc45f57353d838a4dbf84d7b.tar.gz hercules-7b2f7c0503cb5be8bc45f57353d838a4dbf84d7b.tar.bz2 hercules-7b2f7c0503cb5be8bc45f57353d838a4dbf84d7b.tar.xz hercules-7b2f7c0503cb5be8bc45f57353d838a4dbf84d7b.zip |
Orn's and Albator's Homunculus system, finally, YAY!!
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7706 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/charsave.c')
-rw-r--r-- | src/map/charsave.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/map/charsave.c b/src/map/charsave.c index 3f5241900..41a3293e4 100644 --- a/src/map/charsave.c +++ b/src/map/charsave.c @@ -26,6 +26,7 @@ struct mmo_charstatus *charsave_loadchar(int charid){ char *str_p;
friends = 0;
+ ShowDebug("charsave_loadchar : charid = %d | hd->master->status.char_id = %d\n", charid) ;
c = (struct mmo_charstatus *)aCalloc(1,sizeof(struct mmo_charstatus));
if(charid <= 0){
@@ -33,9 +34,9 @@ struct mmo_charstatus *charsave_loadchar(int charid){ aFree(c);
return NULL;
}
-
+ // add homun_id [albator]
//Tested, Mysql 4.1.9+ has no problems with the long query, the buf is 65k big and the sql server needs for it 0.00009 secs on an athlon xp 2400+ WinXP (1GB Mem) .. [Sirius]
- sprintf(tmp_sql, "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`,`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` FROM `char` WHERE `char_id` = '%d'", charid);
+ sprintf(tmp_sql, "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`,`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`, `homun_id` FROM `char` WHERE `char_id` = '%d'", charid);
if(mysql_query(&charsql_handle, tmp_sql)){
ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
@@ -102,9 +103,10 @@ struct mmo_charstatus *charsave_loadchar(int charid){ c->mother = atoi(charsql_row[44]);
c->child = atoi(charsql_row[45]);
c->fame = atoi(charsql_row[46]);
-
+ c->hom_id = atoi(charsql_row[47]); // albator
mysql_free_result(charsql_res);
+
//Check for '0' Savepoint / LastPoint
if (c->last_point.x == 0 || c->last_point.y == 0 || c->last_point.map == 0){
c->last_point.map = mapindex_name2id(MAP_PRONTERA);
@@ -237,8 +239,10 @@ struct mmo_charstatus *charsave_loadchar(int charid){ c->global_reg_num = i;
}
*/
+
+
//Shamelessly stolen from its_sparky (ie: thanks) and then assimilated by [Skotlex]
- //Friend list
+ //Friend list
sprintf(tmp_sql, "SELECT f.friend_account, f.friend_id, c.name FROM friends f LEFT JOIN `char` c ON f.friend_account=c.account_id AND f.friend_id=c.char_id WHERE f.char_id='%d'", charid);
if(mysql_query(&charsql_handle, tmp_sql)){
@@ -248,7 +252,7 @@ struct mmo_charstatus *charsave_loadchar(int charid){ }
else
sql_res = mysql_store_result(&charsql_handle);
-
+
if(sql_res)
{
for(i = 0; (sql_row = mysql_fetch_row(sql_res)) && i<MAX_FRIENDS; i++)
@@ -273,6 +277,7 @@ int charsave_savechar(int charid, struct mmo_charstatus *c){ // char tmp_str[64];
// char tmp_str2[512];
//First save the 'char'
+ ShowDebug("charsave_savechar : charid = %d | hd->master->status.char_id = %d\n", charid) ;
sprintf(tmp_sql ,"UPDATE `char` SET `class`='%d', `base_level`='%d', `job_level`='%d',"
"`base_exp`='%d', `job_exp`='%d', `zeny`='%d',"
"`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
@@ -280,7 +285,7 @@ int charsave_savechar(int charid, struct mmo_charstatus *c){ "`option`='%d',`karma`='%d',`manner`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',"
"`hair`='%d',`hair_color`='%d',`clothes_color`='%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',"
- "`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d', `fame`='%d'"
+ "`partner_id`='%d', `father`='%d', `mother`='%d', `child`='%d', `fame`='%d', `homun_id`='%d'"
"WHERE `account_id`='%d' AND `char_id` = '%d'",
c->class_, c->base_level, c->job_level,
c->base_exp, c->job_exp, c->zeny,
@@ -291,7 +296,7 @@ int charsave_savechar(int charid, struct mmo_charstatus *c){ c->weapon, c->shield, c->head_top, c->head_mid, c->head_bottom,
mapindex_id2name(c->last_point.map), c->last_point.x, c->last_point.y,
mapindex_id2name(c->save_point.map), c->save_point.x, c->save_point.y, c->partner_id, c->father, c->mother,
- c->child, c->fame, c->account_id, c->char_id
+ c->child, c->fame, c->hom_id, c->account_id, c->char_id
);
if(mysql_query(&charsql_handle, tmp_sql)){
ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
@@ -311,16 +316,16 @@ int charsave_savechar(int charid, struct mmo_charstatus *c){ str_p += sprintf(str_p, "INSERT INTO `inventory` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`");
for (j = 0; j < MAX_SLOTS; j++)
str_p += sprintf(str_p, ", `card%d`", j);
-
+
str_p += sprintf(str_p, ") VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d'",
charid, c->inventory[i].nameid, c->inventory[i].amount, c->inventory[i].equip,
c->inventory[i].identify, c->inventory[i].refine, c->inventory[i].attribute);
for (j = 0; j < MAX_SLOTS; j++)
str_p += sprintf(str_p, ", '%d'", c->inventory[i].card[j]);
-
+
strcat(tmp_sql,")");
-
+
if(mysql_query(&charsql_handle, tmp_sql)){
ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
@@ -340,16 +345,16 @@ int charsave_savechar(int charid, struct mmo_charstatus *c){ str_p += sprintf(str_p, "INSERT INTO `cart_inventory` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`");
for (j = 0; j < MAX_SLOTS; j++)
str_p += sprintf(str_p, ", `card%d`", j);
-
+
str_p += sprintf(str_p, ") VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d'",
charid, c->cart[i].nameid, c->cart[i].amount, c->cart[i].equip,
c->cart[i].identify, c->cart[i].refine, c->cart[i].attribute);
for (j = 0; j < MAX_SLOTS; j++)
str_p += sprintf(str_p, ", '%d'", c->cart[i].card[j]);
-
+
strcat(tmp_sql,")");
-
+
if(mysql_query(&charsql_handle, tmp_sql)){
ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
@@ -436,7 +441,7 @@ int charsave_savechar(int charid, struct mmo_charstatus *c){ int charsave_load_scdata(int account_id, int char_id)
{ //Loads character's sc_data
struct map_session_data *sd;
-
+
sd = map_id2sd(account_id);
if (!sd)
{
@@ -450,7 +455,7 @@ int charsave_load_scdata(int account_id, int char_id) }
sprintf(tmp_sql, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` FROM `sc_data`"
"WHERE `account_id`='%d' AND `char_id`='%d'", account_id, char_id);
-
+
if(mysql_query(&charsql_handle, tmp_sql)){
ShowSQL("DB error - %s\n",mysql_error(&charsql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
@@ -490,7 +495,7 @@ void charsave_save_scdata(int account_id, int char_id, struct status_change* sc_ char *p = tmp_sql;
p += sprintf(p, "INSERT INTO `sc_data` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ");
-
+
for(i = 0; i < max_sc; i++)
{
if (sc_data->data[i].timer == -1)
@@ -498,10 +503,10 @@ void charsave_save_scdata(int account_id, int char_id, struct status_change* sc_ timer = get_timer(sc_data->data[i].timer);
if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
continue;
-
+
p += sprintf(p, " ('%d','%d','%hu','%d','%d','%d','%d','%d'),", account_id, char_id,
i, DIFF_TICK(timer->tick,tick), sc_data->data[i].val1, sc_data->data[i].val2, sc_data->data[i].val3, sc_data->data[i].val4);
-
+
count++;
}
if (count > 0)
|