summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorsmokexyz <sagunkho@hotmail.com>2017-05-30 21:09:58 +0800
committersmokexyz <sagunkho@hotmail.com>2017-05-30 21:11:15 +0800
commit7c6673e13fdd75a4137a9d7ef94e04d96e053422 (patch)
tree25976e78fea70001b534903f92db591a16934412 /src/char
parentd966a8e6860d418bb3a235e57928436127eba555 (diff)
downloadhercules-7c6673e13fdd75a4137a9d7ef94e04d96e053422.tar.gz
hercules-7c6673e13fdd75a4137a9d7ef94e04d96e053422.tar.bz2
hercules-7c6673e13fdd75a4137a9d7ef94e04d96e053422.tar.xz
hercules-7c6673e13fdd75a4137a9d7ef94e04d96e053422.zip
Fix storage saving checks and amount update.
Special thanks to @MishimaHaruna for the fix.
Diffstat (limited to 'src/char')
-rw-r--r--src/char/int_storage.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 5f005005e..f19180243 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -44,7 +44,7 @@ struct inter_storage_interface *inter_storage;
int inter_storage_tosql(int account_id, struct storage_data *cp, const struct storage_data *p)
{
int i = 0, j = 0;
- bool updated_p[MAX_STORAGE] = { false };
+ bool matched_p[MAX_STORAGE] = { false };
int delete[MAX_STORAGE] = { 0 };
int total_deletes = 0, total_updates = 0, total_inserts = 0;
int total_changes = 0;
@@ -55,7 +55,6 @@ int inter_storage_tosql(int account_id, struct storage_data *cp, const struct st
StrBuf->Init(&buf);
-
if (VECTOR_LENGTH(cp->item) > 0) {
/**
* Compare and update items, if any.
@@ -65,7 +64,7 @@ int inter_storage_tosql(int account_id, struct storage_data *cp, const struct st
struct item *p_it = NULL;
ARR_FIND(0, VECTOR_LENGTH(p->item), j,
- updated_p[j] != true
+ matched_p[j] != true
&& (p_it = &VECTOR_INDEX(p->item, j)) != NULL
&& cp_it->nameid == p_it->nameid
&& cp_it->unique_id == p_it->unique_id
@@ -93,8 +92,8 @@ int inter_storage_tosql(int account_id, struct storage_data *cp, const struct st
StrBuf->Printf(&buf, ", '%u', '%d', '%"PRIu64"')%s", p_it->expire_time, p_it->bound, p_it->unique_id, total_updates > 0 ? ", " : "");
total_updates++;
- updated_p[j] = true;
}
+ matched_p[j] = true;
} else { // Does not exist, so set for deletion.
delete[total_deletes++] = cp_it->id;
}
@@ -125,7 +124,7 @@ int inter_storage_tosql(int account_id, struct storage_data *cp, const struct st
for (i = 0; i < VECTOR_LENGTH(p->item); i++) {
struct item *p_it = &VECTOR_INDEX(p->item, i);
- if (p_it->id != 0)
+ if (matched_p[i])
continue; // Item is not a new entry, so lets continue.
// Store the remaining items.
@@ -140,8 +139,8 @@ int inter_storage_tosql(int account_id, struct storage_data *cp, const struct st
}
StrBuf->Printf(&buf, "%s('%d', '%d', '%d', '%u', '%d', '%d', '%d', '%u', '%d', '%"PRIu64"'",
- total_inserts > 0 ? ", " : "", account_id, p_it->nameid, p_it->amount, p_it->equip, p_it->identify, p_it->refine,
- p_it->attribute, p_it->expire_time, p_it->bound, p_it->unique_id);
+ total_inserts > 0 ? ", " : "", account_id, p_it->nameid, p_it->amount, p_it->equip, p_it->identify, p_it->refine,
+ p_it->attribute, p_it->expire_time, p_it->bound, p_it->unique_id);
for (j = 0; j < MAX_SLOTS; ++j)
StrBuf->Printf(&buf, ", '%d'", p_it->card[j]);
for (j = 0; j < MAX_ITEM_OPTIONS; ++j)