- bool CWorldServer::pakItemMallList( CPlayer* thisclient, CPacket* P )
- {
- MYSQL_RES *result = GServer->DB->QStore("SELECT id, itemid, itemtype, price, amount, icon, category, subcategory, slot, promotion FROM itemmall WHERE active='1'");
- if(result==NULL) return false;
- result->current_row = 0;
- int count = mysql_num_rows(result);
- int CountLeft = count;
- int SendCount = 37;
- int SendTimes = (int)count / SendCount;
- if(SendTimes < 1)
- SendTimes = 1;
- for(int k=0; k <= SendTimes; k++)
- {
- BEGINPACKET(pak,0x7be);
- if(k == 0)
- {
- ADDBYTE(pak, 0x01);// Start
- } else {
- ADDBYTE(pak, 0x02);// Send More
- }
- if((SendTimes - k) > 0) { ADDBYTE(pak, SendCount); }
- else { ADDBYTE(pak, CountLeft); }
- ADDDWORD(pak, 0x00000000);
- if(CountLeft > SendCount)
- {
- //SendCount = 37;
- CountLeft-=SendCount;
- } else {
- SendCount = CountLeft;
- CountLeft = 0;
- }
- for(int i = 0; i < SendCount; i++)
- {
- MYSQL_ROW row = mysql_fetch_row(result);
- result->current_row++;
- ADDDWORD(pak, i);
- ADDDWORD(pak, atoi(row[1])); // item id
- ADDDWORD(pak, atoi(row[2])); // item type
- ADDDWORD(pak, atoi(row[3])); // price
- ADDDWORD(pak, atoi(row[4])); // amount
- ADDDWORD(pak, atoi(row[5])); // 0 = empty, 1 = new, 2 = hot, 3 = sale
- ADDBYTE(pak, atoi(row[9])); // Promotion 0 = false, 1 = true
- ADDDWORD(pak, atoi(row[6])); // Category
- ADDDWORD(pak, atoi(row[7])); // SubCategory
- ADDDWORD(pak, atoi(row[8])); // slot
- ADDDWORD(pak, 0x00000000); // null
- ADDDWORD(pak, 0xcccccccc); // null
- ADDDWORD(pak, 0xcccccccc); // null
- }
- thisclient->client->SendPacket(&pak);
- }
- GServer->DB->FreeResult();
- BEGINPACKET(pak, 0x7be)
- ADDWORD(pak, 0x0003); // End
- ADDDWORD(pak, 0x00000000);
- thisclient->client->SendPacket( &pak);
- // Observe: Send Itemmall Points fix
- RESETPACKET( pak, 0x7c9 ); // Send Itemmall Points to client
- ADDBYTE ( pak, 0 );
- ADDQWORD ( pak, thisclient->CharInfo->Itemmall );
- thisclient->client->SendPacket( &pak);
- return true;
- }
my problem:
If I insert more than 41 records to itemmall tabel, wordserver crash when showing the itemmall
my solution:
replace wordpackets with this:
I'm not good programmer, and dev rev is my first learning of c++