summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorHaruna <haru@dotalux.com>2014-04-19 22:37:54 +0200
committerHaruna <haru@dotalux.com>2014-04-19 22:37:54 +0200
commit93584f7416164985220293b7c08fcc29c4d5060f (patch)
tree2f2f533682e54dfe501ff4a470953e3a6bd2462f /src/char
parentcebfdc692ef4a5897c69304f88e585f8f1272c7e (diff)
parentdd49dbc3e8d2033c0dddc80f1d5b3c8e6710a419 (diff)
downloadhercules-93584f7416164985220293b7c08fcc29c4d5060f.tar.gz
hercules-93584f7416164985220293b7c08fcc29c4d5060f.tar.bz2
hercules-93584f7416164985220293b7c08fcc29c4d5060f.tar.xz
hercules-93584f7416164985220293b7c08fcc29c4d5060f.zip
Merge pull request #272 from hemagx/master
Rewritten NSI_UNIQUE_ID system
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.c16
-rw-r--r--src/char/int_auction.c4
-rw-r--r--src/char/int_mail.c4
-rw-r--r--src/char/inter.c19
-rw-r--r--src/char/inter.h13
5 files changed, 6 insertions, 50 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 1820c4b0c..cf961fd93 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);
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index 47f3421c3..924930867 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -90,10 +90,6 @@ unsigned int auction_create(struct auction_data *auction)
for( j = 0; j < MAX_SLOTS; j++ )
StrBuf->Printf(&buf, ",'%d'", auction->item.card[j]);
StrBuf->AppendStr(&buf, ")");
-
- //Unique Non Stackable Item ID
- updateLastUid(auction->item.unique_id);
- dbUpdateUid(sql_handle);
stmt = SQL->StmtMalloc(sql_handle);
if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index b69824d4b..826771676 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -117,10 +117,6 @@ int mail_savemessage(struct mail_message* msg)
for (j = 0; j < MAX_SLOTS; j++)
StrBuf->Printf(&buf, ", '%d'", msg->item.card[j]);
StrBuf->AppendStr(&buf, ")");
-
- //Unique Non Stackable Item ID
- updateLastUid(msg->item.unique_id);
- dbUpdateUid(sql_handle);
// prepare and execute query
stmt = SQL->StmtMalloc(sql_handle);
diff --git a/src/char/inter.c b/src/char/inter.c
index 059c33784..6a8412b25 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -1372,23 +1372,4 @@ int inter_parse_frommap(int fd)
return 1;
}
-uint64 inter_chk_lastuid(int8 flag, uint64 value){
- static uint64 last_updt_uid = 0;
- static int8 update = 0;
- if(flag)
- {
- if(last_updt_uid < value){
- last_updt_uid = value;
- update = 1;
- }
-
- return 0;
- }else if(update)
- {
- update = 0;
- return last_updt_uid;
- }
- return 0;
-}
-
diff --git a/src/char/inter.h b/src/char/inter.h
index b484a1610..25b0c2a96 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -29,17 +29,4 @@ extern Sql* lsql_handle;
int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type);
-uint64 inter_chk_lastuid(int8 flag, uint64 value);
-#ifdef NSI_UNIQUE_ID
- #define updateLastUid(val_) inter_chk_lastuid(1, (val_))
- #define dbUpdateUid(handler_) do { \
- uint64 unique_id_ = inter_chk_lastuid(0, 0); \
- if (unique_id_ && SQL_ERROR == SQL->Query((handler_), "UPDATE `%s` SET `value`='%"PRIu64"' WHERE `varname`='unique_id'", interreg_db, unique_id_)) \
- Sql_ShowDebug(handler_);\
- } while(0)
-#else
- #define dbUpdateUid(handler_)
- #define updateLastUid(val_)
-#endif
-
#endif /* _CHAR_INTER_H_ */