Fixed a severe bug in inventory saving code (caused by r11192).
The fix was to revert the changes; I totally misunderstood how it was supposed to work... git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11275 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
ba12271335
commit
8998f367c1
@ -4,10 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
|
||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
|
||||
2007/09/22
|
||||
* Updated sql files [Playtester]
|
||||
* Added a sanity check for MAX_ZENY (doesn't compile if too big).
|
||||
* Redid the buildin_query_sql function. (fixes bugreport:81). [FlavioJS]
|
||||
2007/09/21
|
||||
* Fixed a severe bug in inventory saving code (caused by r11192)
|
||||
* Applied changes to clif_parse_globalmessage() from my WiP code
|
||||
- clearer processing of the individual packet components
|
||||
- proper code ordering, some more integrity checks
|
||||
@ -15,6 +12,10 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
- global chat logging no longer logs the entire string (w/ player name)
|
||||
* Fixed global chat logging always crashing on a null pointer
|
||||
* Added 'safestrnlen' to prevent null pointer crashes [ultramage]
|
||||
* Updated sql files [Playtester]
|
||||
* Added a sanity check for MAX_ZENY (doesn't compile if too big).
|
||||
* Redid the buildin_query_sql function. (fixes bugreport:81). [FlavioJS]
|
||||
2007/09/21
|
||||
* itemdb.c/h using a static array of 32k struct item_data* entries (faster
|
||||
itemdb loockup and a first step to remove map_session_data->inventory_data).
|
||||
* Fixed a typo in the configure script that replaced CFLAGS with CPPFLAGS
|
||||
|
@ -410,26 +410,7 @@ void read_gm_account(void)
|
||||
|
||||
mapif_send_gmaccounts();
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
int compare_item(const struct item* a, const struct item* b)
|
||||
{
|
||||
|
||||
if(a->id == b->id &&
|
||||
a->nameid == b->nameid &&
|
||||
a->amount == b->amount &&
|
||||
a->equip == b->equip &&
|
||||
a->identify == b->identify &&
|
||||
a->refine == b->refine &&
|
||||
a->attribute == b->attribute)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<MAX_SLOTS && a->card[i]==b->card[i]; i++);
|
||||
return (i == MAX_SLOTS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
static void* create_charstatus(DBKey key, va_list args)
|
||||
{
|
||||
struct mmo_charstatus *cp;
|
||||
@ -750,21 +731,27 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
|
||||
|
||||
while( SQL_SUCCESS == SqlStmt_NextRow(stmt) )
|
||||
{
|
||||
bool found = false;
|
||||
found = false;
|
||||
// search for the presence of the item in the char's inventory
|
||||
for( i = 0; i < max; ++i )
|
||||
{
|
||||
if( flag[i] )
|
||||
continue; // this item was matched already, skip it
|
||||
|
||||
if( items[i].id == 0 )
|
||||
{ // to make skipping empty entries faster and to prevent saving them later
|
||||
flag[i] = true;
|
||||
// skip empty and already matched entries
|
||||
if( items[i].nameid == 0 || flag[i] )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( compare_item(&items[i], &item) )
|
||||
; // Equal - do nothing.
|
||||
if( items[i].nameid == item.nameid
|
||||
&& items[i].card[0] == item.card[0]
|
||||
&& items[i].card[2] == item.card[2]
|
||||
&& items[i].card[3] == item.card[3]
|
||||
) { //They are the same item.
|
||||
ARR_FIND( 0, MAX_SLOTS, j, items[i].card[j] != item.card[j] );
|
||||
if( j == MAX_SLOTS &&
|
||||
items[i].amount == item.amount &&
|
||||
items[i].equip == item.equip &&
|
||||
items[i].identify == item.identify &&
|
||||
items[i].refine == item.refine &&
|
||||
items[i].attribute == item.attribute )
|
||||
; //Do nothing.
|
||||
else
|
||||
{
|
||||
// update all fields.
|
||||
@ -777,12 +764,12 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
|
||||
|
||||
if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
}
|
||||
|
||||
found = flag[i] = true; //Item dealt with,
|
||||
break; //skip to next item in the db.
|
||||
}
|
||||
}
|
||||
if( !found )
|
||||
{// Item not present in inventory, remove it.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `id`='%d'", tablename, item.id) )
|
||||
@ -799,10 +786,12 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
|
||||
|
||||
found = false;
|
||||
// insert non-matched items into the db as new items
|
||||
for( i = 0, found = 0; i < max; ++i )
|
||||
{
|
||||
if( !flag[i] )
|
||||
for( i = 0; i < max; ++i )
|
||||
{
|
||||
// skip empty and already matched entries
|
||||
if( items[i].nameid == 0 || flag[i] )
|
||||
continue;
|
||||
|
||||
if( found )
|
||||
StringBuf_AppendStr(&buf, ",");
|
||||
else
|
||||
@ -814,7 +803,6 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
|
||||
StringBuf_Printf(&buf, ", '%d'", items[i].card[j]);
|
||||
StringBuf_AppendStr(&buf, ")");
|
||||
}
|
||||
}
|
||||
|
||||
if( found && SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user