1 (edited by obana 2015-08-02 12:42:50)

Where search more info about table item_instance in Characters database?
I need to to find a specific Item and he amount via php script

May be convert this table to TC structure?

Sorry for my bad english

all of this values are in the data field, you can split the data field (string value) via PHP on space (" " separtor) to get each field separated.

to find the exact array position look at OC Item Code, should be simple to find.

but as you say i would find it realy good to remove the data blob and add own fields for each value like TC has

expect answer from OC developers smile

Sorry for my bad english

Eventually plan to remove data blob but our list of "eventual plans" is a very long one with much more higher priority tasks. Desteny is also an Oregon developer big_smile

LordUsagi i'm scared, you have wrote almost the same answer as i wanted to write wink are you hacking my brain? O.o
(only joking)

I wanted to write teh same stuff about the long list of important thing to do, with more priority, cause saving items is working, for sure the blob is not the most elegant solution but the priority is on not working stuff, before we should cleanup things wink

Desteny is also an Oregon developer big_smile

thanks wink you have only forgotten to say "retired OC Dev" ^^

@obana, if you splitt teh data field like i told you uppon you can use the ITEM_FIELD_* Enum to know what the positions are for your array.

but if you want to remove the blob feel free to do it, should be simple for items, just replace the save and load algorithm and save values to separated DB fields.

in the core code you can still fill the UInt32Value Fields to safe time and problems.
and don't forget a convert sql script from data blob to fields wink

This is the commit by TrinityCore which we'll most likely use when we decide to remove the data blob.

If you'd like to beat us to the punch and help us out, it would be MUCH appreciated!

@desteny: Yes.. retired OC dev big_smile but still means you are very knowledgeable, even more so than myself in how OC works!

Thanks you, I will try to do it under OC

@desteny, I'm confused, I can not select a value from DATA
In PHP Code:

SELECT CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 8), ' ', -1) AS UNSIGNED) AS `count` FROM item_instance WHERE CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 5), ' ', -1) AS UNSIGNED) = ?d AND owner_guid = ?d

This is not work sad

Sorry for my bad english

Patch file: http://pastebin.com/huHp25h2

Im tested and compiling with error, i dont know...
17>c:\source\oregoncore\src\game\Item.h(232): error C2548: 'Item::LoadFromDB' : missing default parameter for parameter 4
17>c:\source\oregoncore\src\game\Item.h(395): fatal error C1903: unable to recover from previous error(s); stopping compilation

Sorry for my bad english

What i ment to say, was that you can select all where owner_guid = xyz then filter the result in php, you can use php string functions like split and arrays.

but you can do this as well with SQL like you have done, and i have tested it, it works on my mysql server with test data
maybe you have null values or empty data in your database?

i have tested:

SELECT CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 8), ' ', -1) AS UNSIGNED) AS `count`
FROM item_instance
WHERE CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 5), ' ', -1) AS UNSIGNED) = 1
AND owner_guid = 1

only one other thing:
if we plan to remove this data blob, we may have problems with existing 3rd party code like armory and such things.
they read from the data column if we remove it people have to change the armory code! (only as reminder)

or we can add a config feature like "WriteLegacyDataFields" this will cause to write data redundant to the data field (field needs to be added manualy) but the data will be read from the real columns...

obana wrote:

Patch file: http://pastebin.com/huHp25h2

Im tested and compiling with error, i dont know...
17>c:\source\oregoncore\src\game\Item.h(232): error C2548: 'Item::LoadFromDB' : missing default parameter for parameter 4
17>c:\source\oregoncore\src\game\Item.h(395): fatal error C1903: unable to recover from previous error(s); stopping compilation

I changed in Item.h

virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result = QueryResult_AutoPtr(NULL), uint32 entry);

to

virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result, uint32 entry);

And next compiling error:

10>..\..\..\src\game\Player.cpp(15861): error C2660: 'Item::LoadFromDB' : function does not take 3 arguments
10>..\..\..\src\game\Item.cpp(315): error C2065: 'ITEM_FIELD_CREATE_PLAYED_TIME' : undeclared identifier
10>..\..\..\src\game\Item.cpp(344): error C2065: 'ITEM_FIELD_CREATE_PLAYED_TIME' : undeclared identifier
10>..\..\..\src\game\Item.cpp(417): error C2065: 'ITEM_FIELD_ENCHANTMENT_1_1' : undeclared identifier
10>..\..\..\src\game\Item.cpp(433): error C2065: 'ITEM_FIELD_CREATE_PLAYED_TIME' : undeclared identifier
10>..\..\..\src\game\Item.cpp(434): error C3861: 'SetText': identifier not found

Sorry for my bad english

you have only imported the TC2 patch?
there are some differences between OC and TC, what you need to do is to use TC commit as a kind of templete but write the code for OregonCore, thats a lot better and more error prone.

if you want i write the code and make a pull request for this,

i will not make it 100% like TC2 has made but it should work wink

Haha, I'll do it today I think.

Edit: Nevermind. Feel free to!

wink its like you want (i don't want to steal the task tongue)

but i think you have other more important things to do right?

BTW for your query @obana, you missed a little thing, the correct query is:

SELECT CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 15), ' ', -1) AS UNSIGNED) AS `count`
FROM item_instance
WHERE CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ', 15), ' ', -1) AS UNSIGNED) = 1
AND owner_guid = 1
ITEM_FIELD_STACK_COUNT                    = OBJECT_END + 0x0008

and

OBJECT_END                                = 0x0006

6 + 8 = 14 and the sql substring index needs +1 for this you need 15 in your query

[edit]
the patch can not work, there are different fields for 2.4.3 (as i already expected)
i will do a little research on what fields are realy needed then i will finialze my work.

only one question to you all, should i keep the data field for third party systems like armory (can be disabled by option) or should i remove it?
the update will be cleaner but will break armory for sure!

remove it! Screw armory! Most new armories have support for no data blobs etc. big_smile

Ok i will kill the data field wink

i have finished my work: https://bitbucket.org/oregon/oregoncore … d-and/diff
i have tested it and its working, but i don't have the possability to test it in a real scenario, for this please can someone test it?
maybe you @obana? big_smile

PLEASE BACKUP YOUR CHARACTERS DB BEFORE TESTING!!!

like i have written in pull request, the auto sql updater has problems with the script, maybe the updater or script needs to be modified!

the server code should work as ecpected, the sql convert script may needs to be checked, is only the TC2 script adapted, but if the "uint32toint32" conversion is realy needed?! its there but maybe it can be removed or problematic...

the "Fix heroic item flag" part is commented, maybe we need it but this needs to be researched!

have fun with the patch wink

PunBB bbcode test

Sorry for my bad english

ohh, im fully converted "delete datablod" in another emulator, and tested. Work successfully.
Maybe add to OC repo?

Sorry for my bad english