Jump to content
Dastgir

ItemDB can support items with > 32k id

Recommended Posts

While I was working on some item_data reconstruction(A Paid Source requested to me..) I discovered that we can create ItemID with greater than 32k ID. (Atleast on 2013-08-07,Since I use this mostly, I tested it with this client.), so maybe as kRO has reached almost 30k, they already increased itemid range...

 

Some of the testings: http://imgur.com/zKGwMFZ

Also I tried to make different items like equipable, usable, and I was able to wear and use them....

 

We would need to modify some mysql tables and change some "short" type(in source)...

 

Atleast I tested until 65535 , So maybe client is restricting ID > 65535 now?(Since Item Failed to create when tried with ID>65535).

 

 

So my suggestion is to change short types and mysql tables, and make itemdb support to 65535 by default...

Edited by Dastgir Pojee

Share this post


Link to post
Share on other sites

confused in ' more adjust info '

and more adjustmysql card0~ card3 field type change to int // im using txt dbs not sql_db, how ??and adjust bonus script param type // the script change and add y value, then must i change the src part to ??bonus2 bAddMonsterDropItem,n,xbonus3 bAddMonsterDropItem,n,x,y; 

 


 

Share this post


Link to post
Share on other sites

the sql part is about main.sql for example:

 

`card0` smallint(11) NOT NULL default '0',
  `card1` smallint(11) NOT NULL default '0',
  `card2` smallint(11) NOT NULL default '0',
  `card3` smallint(11) NOT NULL default '0',
 
change smallint to int, the bonus part I didn't looked at it :/

Share this post


Link to post
Share on other sites

 

 

It would be good, For custom item

, Can you at least make a diff file for this ??

if you really need it fast :P just take it here:

http://herc.ws/board/topic/5045-increasing-max-values-allowed-in-itemdb/?p=32497

haha, I thought theres no post like this..

 

and , changing card field to smallint 11 is not good(signed smallint limits to 32k), maybe using

unsigned smallint(5)

Or

mediumint(5)

Edited by Dastgir Pojee

Share this post


Link to post
Share on other sites

 

the sql part is about main.sql for example:

 

`card0` smallint(11) NOT NULL default '0',
  `card1` smallint(11) NOT NULL default '0',
  `card2` smallint(11) NOT NULL default '0',
  `card3` smallint(11) NOT NULL default '0',
 
change smallint to int, the bonus part I didn't looked at it :/

 

for bonus script  param

 

pc.h

struct s_add_drop {

  short id, group;

  int race, rate;

};

 

int (*bonus_item_drop) (struct s_add_drop *drop, const short max, short id, short group, int race, int rate);

 

pc.c

int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int race, int rate) {

 

short --> unsigned short

 

Edited by Angelmelody

Share this post


Link to post
Share on other sites

for me who haven't understand this and that, it make me more confused, which parth i must replace or add

or someone can make a mini guide for this or my be a diff file can be more convinient

 

thanks

Edited by Litro

Share this post


Link to post
Share on other sites

Hi guys,

 

I made a modification to increase the native limit to 64k and added the possibility to increase the limit over 65k..

 

I haven't tested yet, so please, fell free to indicate any bug or improvement

 

https://github.com/ragnaBR/Hercules/commit/c7a9ce03fddef370bec96f9d137051a4932ae00c

 

percentage chance doesn't need to be changed into mediumint since we are changing only itemIDs, not their drop chance :P

 

also there is no need to manually edit the HPM hooks since they will be updated automatically once it goes into main src

Edited by evilpuncker

Share this post


Link to post
Share on other sites

 

Hi guys,

 

I made a modification to increase the native limit to 64k and added the possibility to increase the limit over 65k..

 

I haven't tested yet, so please, fell free to indicate any bug or improvement

 

https://github.com/ragnaBR/Hercules/commit/c7a9ce03fddef370bec96f9d137051a4932ae00c

 

percentage chance doesn't need to be changed into mediumint since we are changing only itemIDs, not their drop chance :P

 

also there is no need to manually edit the HPM hooks since they will be updated automatically once it goes into main src

 

Thanks evil, i've made this in a little hurry, i missed the sql detail.

 

About the HPM, i didin't know about it.. anyway, soon as possible i ll fix those small issues.

 

Thx!

Share this post


Link to post
Share on other sites

One important thing:

 

i've used mediumint instead unsigned smallint on the cardX fields because they can receive negative values in some cases.

Edited by Frey

Share this post


Link to post
Share on other sites

Well i dont understand at all, from the guide @Angelmelody provide, there is slight different from what provided by @Frey

Angelmelody Guide :

pc.h- short id, group;+ unsigned short id, group;- int (*bonus_item_drop) (struct s_add_drop *drop, const short max, short id, short group, int race, int rate);+ int (*bonus_item_drop) (struct s_add_drop *drop, const short max, unsigned short id, short group, int race, int rate);pc.c- int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int race, int rate) {+ int pc_bonus_item_drop(struct s_add_drop *drop, const short max, unsigned short id, short group, int race, int rate) {

Frey Patch File :

pc.h-	short id, group;+	#ifdef ITEMDB_OVER65K+		unsigned int id;+	#else+		unsigned short id;+	#endif+	short group;-	int (*bonus_item_drop) (struct s_add_drop *drop, const short max, short id, short group, int race, int rate);+	int (*bonus_item_drop) (struct s_add_drop *drop, const short max, int id, short group, int race, int rate);pc.c-int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int race, int rate) {+int pc_bonus_item_drop(struct s_add_drop *drop, const short max, int id, short group, int race, int rate) {

from Frey Patch File there is ITEMDB_OVER65K dif, is it mean can make item_db id more than 65 K ??

and when Angelmelody Just Adjust main.sql file and pc.h and pc.c from src part, Frey Patch File have addition src file to be patched

buyingstore.h, clif.c, npc.h, packets_struct.h, pet.c, script.c, searchstore.h, HPMHooking.Hooks.inc

for HPMHooking.Hooks.inc, read back comment from @evilpuncker, then its fine to leave it untoched ??

i was planning apply patch for this last week but my office work make me have no time to, test it and now im have free time to back testing it on offline server.

 

and here come my question,

 

1. what is different the part from Angelmelody and Frey on pc.c and pc.ha part ? "Int id / unsigned short id" ?

2. from frey patch file thereis src file that i listed before what is it stand for ?

3. Just for Frey, have you fixed the small isue that you mentioned above ?? i have take a look on ragnaBR repo thereis change 8 day ago and the file seems same from before

 

Im Sorry for being a noob, if some one have a time to answer it what i can do is being grateful for it, and thanks for you guys anyways

Share this post


Link to post
Share on other sites

Hi there,

 

I've tried to cover all the places in the source code where the increase of the item_id could cause some trouble, because of that i've changed the size of some variables in another places.

 

About the differences in pc.c and pc.h

 

My one makes "native" the limit to 64k and gives you the option to go beyond, if you activate the ITEMDB_OVER65K, the limit becomes virtualy around 2kkk, but im pretty sure that there will be some client-side issues with high number ids.

 

 

The another differences are just conventions, i've used int instead unsigned short in some places just to keep the convention of positive and negative numbers that some of those parameters could receive.

 

 

 

The patch order is the following:

Aplly this one: https://github.com/ragnaBR/Hercules/commit/c7a9ce03fddef370bec96f9d137051a4932ae00c.patch

Then this one: https://github.com/ragnaBR/Hercules/commit/2050606df697456074d0592768dad66daa43c006.patch

Run this sql: /sql-files/upgrades/2014-04-19-14-21.sql

 

If you wanna active the ITEMDB_OVER65K you must run this sql too: /sql-files/patch_itemdb_over65k.sql

 

 

 

That is it, its pretty straight foward, i havent time yet to test it, but everything looks fine besides some optimizations that could be made.

Edited by Frey

Share this post


Link to post
Share on other sites

I don't think there's a need to increase over 65K , 65K space is large enough for general use , over it  is too crazy -_-

 

im agreed with Angelmelody, 64 K was enough space for its dont you think so??

 

@@Frey since im using txt db for mob_db then is there adition to add??

Share this post


Link to post
Share on other sites

 

I don't think there's a need to increase over 65K , 65K space is large enough for general use , over it  is too crazy -_-

 

im agreed with Angelmelody, 64 K was enough space for its dont you think so??

 

@@Frey since im using txt db for mob_db then is there adition to add??

 

NOP, this patch should work both for sql and txt dbs

Share this post


Link to post
Share on other sites

Hi @Frey i have countered error on my map server after make item with item id 40001

Message appeared on Char Server console

[SQL]: DB error - data of field 'nameid' was truncated.[Debug]: column - 1[Debug]: data   - type=UNSIGNED MYSQL_TYPE_LONG, length=2[Debug]: buffer - type=MYSQL_TYPE_SHORT, length=2

 it appeared when i relog-jng my char, see my char server console log here http://upaste.me/r/7d20120740fdce91c

and here my patch files using lattest hercules git http://upaste.me/r/846a12075b37e0de8

Share this post


Link to post
Share on other sites

Message appeared on Char Server console

[SQL]: DB error - data of field 'nameid' was truncated.[Debug]: column - 1[Debug]: data - type=UNSIGNED MYSQL_TYPE_LONG, length=2[Debug]: buffer - type=MYSQL_TYPE_SHORT, length=2
and here my patch files using lattest hercules git http://upaste.me/r/846a12075b37e0de8

 

 

diff --git a/src/char/char.c b/src/char/char.cindex 0b7d858..a417eda 100644--- a/src/char/char.c+++ b/src/char/char.c@@ -747,7 +747,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit 	}  	SQL->StmtBindColumn(stmt, 0, SQLDT_INT,       &item.id,          0, NULL, NULL);-	SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT,     &item.nameid,      0, NULL, NULL);+	SQL->StmtBindColumn(stmt, 1, SQLDT_USHORT,     &item.nameid,      0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,      0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 3, SQLDT_UINT,      &item.equip,       0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,    0, NULL, NULL)@@ -890,7 +890,7 @@ int inventory_to_sql(const struct item items[], int max, int id) { 	}  	SQL->StmtBindColumn(stmt, 0, SQLDT_INT,       &item.id,          0, NULL, NULL);-	SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT,     &item.nameid,      0, NULL, NULL);+	SQL->StmtBindColumn(stmt, 1, SQLDT_USHORT,     &item.nameid,      0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,      0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 3, SQLDT_UINT,      &item.equip,       0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,    0, NULL, NULL);@@ -1251,7 +1251,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything 	||	SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) 	||	SQL_ERROR == SQL->StmtExecute(stmt) 	||	SQL_ERROR == SQL->StmtBindColumn(stmt,  0, SQLDT_INT,       &tmp_item.id, 0, NULL, NULL)-	||	SQL_ERROR == SQL->StmtBindColumn(stmt,  1, SQLDT_SHORT,     &tmp_item.nameid, 0, NULL, NULL)+	||	SQL_ERROR == SQL->StmtBindColumn(stmt,  1, SQLDT_USHORT,     &tmp_item.nameid, 0, NULL, NULL) 	||	SQL_ERROR == SQL->StmtBindColumn(stmt,  2, SQLDT_SHORT,     &tmp_item.amount, 0, NULL, NULL) 	||	SQL_ERROR == SQL->StmtBindColumn(stmt,  3, SQLDT_UINT,      &tmp_item.equip, 0, NULL, NULL) 	||	SQL_ERROR == SQL->StmtBindColumn(stmt,  4, SQLDT_CHAR,      &tmp_item.identify, 0, NULL, NULL)@@ -1284,7 +1284,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything 	||	SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) 	||	SQL_ERROR == SQL->StmtExecute(stmt) 	||	SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT,         &tmp_item.id, 0, NULL, NULL)-	||	SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT,       &tmp_item.nameid, 0, NULL, NULL)+	||	SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_USHORT,       &tmp_item.nameid, 0, NULL, NULL) 	||	SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT,       &tmp_item.amount, 0, NULL, NULL) 	||	SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT,        &tmp_item.equip, 0, NULL, NULL) 	||	SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR,        &tmp_item.identify, 0, NULL, NULL)diff --git a/src/char/int_storage.c b/src/char/int_storage.cindex 966e61b..b065f3d 100644--- a/src/char/int_storage.c+++ b/src/char/int_storage.c@@ -282,7 +282,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd) 	}  	SQL->StmtBindColumn(stmt, 0, SQLDT_INT,       &item.id,          0, NULL, NULL);-	SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT,     &item.nameid,      0, NULL, NULL);+	SQL->StmtBindColumn(stmt, 1, SQLDT_USHORT,     &item.nameid,      0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,      0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT,    &item.equip,       0, NULL, NULL); 	SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,    0, NULL, NULL);

 

Edited by Angelmelody

Share this post


Link to post
Share on other sites

I agree with it being added to source by default (with no ifdefs ;P) since gravity is already using 28k ID for some items, we are in need of higher IDs :) and btw 64k is enough IMO

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.