[Dev V Rev 12] Fixed ItemMall List

If you want to help us or give some corrections / codes, put it here ;)

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

[Dev V Rev 12] Fixed ItemMall List

Postby WiseGuy on Tue May 20, 2014 10:26 am

First, thanks to Vetyst and others for the sharing.

my problem:
If I insert more than 41 records to itemmall tabel, wordserver crash when showing the itemmall

my solution:
replace wordpackets with this:
  1.  
  2. bool CWorldServer::pakItemMallList( CPlayer* thisclient, CPacket* P )
  3. {
  4.     MYSQL_RES *result = GServer->DB->QStore("SELECT id, itemid, itemtype, price, amount, icon, category, subcategory, slot, promotion FROM itemmall WHERE active='1'");
  5.     if(result==NULL) return false;
  6.  
  7.     result->current_row = 0;
  8.  
  9.     int count = mysql_num_rows(result);
  10.     int CountLeft = count;
  11.     int SendCount = 37;
  12.     int SendTimes = (int)count / SendCount;
  13.  
  14.     if(SendTimes < 1)
  15.         SendTimes = 1;
  16.  
  17.     for(int k=0; k <= SendTimes; k++)
  18.     {
  19.         BEGINPACKET(pak,0x7be);
  20.         if(k == 0)
  21.         {
  22.             ADDBYTE(pak, 0x01);// Start
  23.         } else {
  24.             ADDBYTE(pak, 0x02);// Send More
  25.         }
  26.         if((SendTimes - k) > 0) { ADDBYTE(pak, SendCount); }
  27.         else { ADDBYTE(pak, CountLeft); }
  28.  
  29.         ADDDWORD(pak, 0x00000000);
  30.  
  31.         if(CountLeft > SendCount)
  32.         {
  33.             //SendCount = 37;
  34.             CountLeft-=SendCount;
  35.         } else {
  36.             SendCount = CountLeft;
  37.             CountLeft = 0;
  38.         }
  39.  
  40.         for(int i = 0; i < SendCount; i++)
  41.         {
  42.             MYSQL_ROW row = mysql_fetch_row(result);
  43.             result->current_row++;
  44.  
  45.             ADDDWORD(pak, i);
  46.             ADDDWORD(pak, atoi(row[1])); // item id
  47.             ADDDWORD(pak, atoi(row[2])); // item type
  48.             ADDDWORD(pak, atoi(row[3])); // price
  49.             ADDDWORD(pak, atoi(row[4])); // amount
  50.             ADDDWORD(pak, atoi(row[5])); // 0 = empty, 1 = new, 2 = hot, 3 = sale
  51.             ADDBYTE(pak, atoi(row[9])); // Promotion 0 = false, 1 = true
  52.             ADDDWORD(pak, atoi(row[6])); // Category
  53.             ADDDWORD(pak, atoi(row[7])); // SubCategory
  54.             ADDDWORD(pak, atoi(row[8])); // slot
  55.             ADDDWORD(pak, 0x00000000); // null
  56.             ADDDWORD(pak, 0xcccccccc); // null
  57.             ADDDWORD(pak, 0xcccccccc); // null
  58.         }
  59.         thisclient->client->SendPacket(&pak);
  60.     }
  61.     GServer->DB->FreeResult();
  62.  
  63.     BEGINPACKET(pak, 0x7be)
  64.     ADDWORD(pak, 0x0003); // End
  65.     ADDDWORD(pak, 0x00000000);
  66.     thisclient->client->SendPacket( &pak);
  67.  
  68. // Observe: Send Itemmall Points fix
  69.     RESETPACKET( pak, 0x7c9 ); // Send Itemmall Points to client
  70.     ADDBYTE    ( pak, 0 );
  71.     ADDQWORD   ( pak, thisclient->CharInfo->Itemmall );
  72.     thisclient->client->SendPacket( &pak);
  73.     return true;
  74. }
  75.  


I'm not good programmer, and dev rev is my first learning of c++ :lol:
Attachments
itemmall-118rec.rar
this itemmall dataa with 118 records:
(2.89 KiB) Downloaded 841 times
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev V Rev 12] Fixed ItemMall List

Postby Qctiimatt on Tue May 20, 2014 7:16 pm

Wow awesome !! i have tested and Work !
Qctiimatt
Smoulie
Smoulie
 
Posts: 58
Joined: Tue Mar 16, 2010 10:12 pm

Re: [Dev V Rev 12] Fixed ItemMall List

Postby rl2171 on Tue May 20, 2014 7:29 pm

How many are you able to have in that list now?

I noticed the carts didn't show up and a few here and there had blank spaces between them too.

Looks great, I added the code as well and saw the lists, very nicely done!
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev V Rev 12] Fixed ItemMall List

Postby rl2171 on Tue May 20, 2014 8:13 pm

Nice job,

I added some and corrected a couple I saw were wrong numbers.

Added in all the new carts, engines, wheels along with all the permanent dragon mounts.
Attachments
itemmall.zip
more item mall updates
(3.13 KiB) Downloaded 740 times
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev V Rev 12] Fixed ItemMall List

Postby rl2171 on Wed May 21, 2014 3:21 am

Found a couple of entries that did not have the proper item number, fixed and made them active
Attachments
itemmall.zip
(3.14 KiB) Downloaded 744 times
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev V Rev 12] Fixed ItemMall List

Postby WiseGuy on Thu May 22, 2014 2:30 pm

Thank's rl2171,

here is my program to make it easier to manage the item mall list

edit: forgot to mention :D
it read wordserver conf to connect to database,
so place it in the folder where worldserver.conf are

edit2:
fixed itemmall.exe because with debug code some av will block
Attachments
ItemMall.rar
Fixed Itemmall Administration (w/o debug code)
(510.33 KiB) Downloaded 855 times
ItemMall.jpg
Last edited by WiseGuy on Sat May 24, 2014 4:16 am, edited 1 time in total.
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev V Rev 12] Fixed ItemMall List

Postby rl2171 on Thu May 22, 2014 2:53 pm

WiseGuy wrote:Thank's rl2171,

here is my program to make it easier to manage the item mall list

edit: forgot to mention :D
it read wordserver conf to connect to database,
so place it in the folder where worldserver.conf are


Wow, very impressive, I can't wait to try it when I get home.

Any idea what Cmd1 and Cmd2 are used for?

Thanks again!
Image
rl2171
Admin
Admin
 
Posts: 1706
Joined: Mon Aug 06, 2007 5:17 pm
Location: Sacramento, CA USA - GMT-8

Re: [Dev V Rev 12] Fixed ItemMall List

Postby WiseGuy on Thu May 22, 2014 3:06 pm

rl2171 wrote:Any idea what Cmd1 and Cmd2 are used for?


Nope sorry :D
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta

Re: [Dev V Rev 12] Fixed ItemMall List

Postby WiseGuy on Sat May 24, 2014 4:22 am

Fix: itemmall.exe has been compiled without debugging code

sorry for this inconvenience
It is nice to be important
but very very important to be nice
User avatar
WiseGuy
Pomic
Pomic
 
Posts: 112
Joined: Sat Nov 21, 2009 4:03 am
Location: Jakarta


Return to Submit Code

Who is online

Users browsing this forum: No registered users and 5 guests

cron