summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
authorIbrahim Hossam <ibrahem.h.basyone@gmail.com>2014-04-08 20:40:12 +0200
committerIbrahim Hossam <ibrahem.h.basyone@gmail.com>2014-04-18 09:58:42 +0200
commitdd49dbc3e8d2033c0dddc80f1d5b3c8e6710a419 (patch)
tree219025c6ac65f2cf72798a45c926507633f3446f /src/char/char.c
parent47680829048288376aec23102b9660f36f4463ee (diff)
downloadhercules-dd49dbc3e8d2033c0dddc80f1d5b3c8e6710a419.tar.gz
hercules-dd49dbc3e8d2033c0dddc80f1d5b3c8e6710a419.tar.bz2
hercules-dd49dbc3e8d2033c0dddc80f1d5b3c8e6710a419.tar.xz
hercules-dd49dbc3e8d2033c0dddc80f1d5b3c8e6710a419.zip
Rewritten NSI_UNIQUE_ID system to get rid of the cross-database interreg dependency
- Removes the need for map-server to access the interreg table to store the last used ID. - Login, char and map databases can now be hosted separately. - Note: the unique_id structure has changed, and it now contains the generator character ID in its upper 32 bits. - Now NSI_UNIQUE_ID System is enabled always Special thanks to Haruna.
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/char/char.c b/src/char/char.c
index d460e4c85..a4bc9cef9 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -469,7 +469,8 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
(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->slotchange != cp->slotchange) || (p->robe != cp->robe) ||
- (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font)
+ (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) ||
+ (p->uniqueitem_counter != cp->uniqueitem_counter )
) { //Save status
unsigned int opt = 0;
@@ -485,7 +486,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
"`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',`slotchange`='%d', `char_opt`='%u', `font`='%u'"
+ "`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u', `uniqueitem_counter` ='%u'"
" WHERE `account_id`='%d' AND `char_id` = '%d'",
char_db, p->base_level, p->job_level,
p->base_exp, p->job_exp, p->zeny,
@@ -496,7 +497,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
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,
(unsigned long)p->delete_date, // FIXME: platform-dependent size
- p->robe,p->slotchange,opt,p->font,
+ p->robe,p->slotchange,opt,p->font,p->uniqueitem_counter,
p->account_id, p->char_id) )
{
Sql_ShowDebug(sql_handle);
@@ -841,10 +842,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", '%d'", items[i].card[j]);
StrBuf->AppendStr(&buf, ")");
-
- updateLastUid(items[i].unique_id); // Unique Non Stackable Item ID
}
- dbUpdateUid(sql_handle); // Unique Non Stackable Item ID
if( found && SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) )
{
@@ -982,10 +980,7 @@ int inventory_to_sql(const struct item items[], int max, int id) {
for( j = 0; j < MAX_SLOTS; ++j )
StrBuf->Printf(&buf, ", '%d'", items[i].card[j]);
StrBuf->AppendStr(&buf, ")");
-
- updateLastUid(items[i].unique_id);// Unique Non Stackable Item ID
}
- dbUpdateUid(sql_handle);
if( found && SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) ) {
Sql_ShowDebug(sql_handle);
@@ -1130,7 +1125,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
"`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`,`slotchange`,"
- "`char_opt`,`font`"
+ "`char_opt`,`font`,`uniqueitem_counter`"
" FROM `%s` WHERE `char_id`=? LIMIT 1", char_db)
|| SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
|| SQL_ERROR == SQL->StmtExecute(stmt)
@@ -1189,6 +1184,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 54, SQLDT_UCHAR, &p->font, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 55, SQLDT_UINT, &p->uniqueitem_counter, 0, NULL, NULL)
)
{
SqlStmt_ShowDebug(stmt);