This is a beta,wont work very well but at least is a start.Im working on it,if someone can help me a little,it will be very good.Not sure if opcodes are still up to date.
opcodes
Code:
#define OP_SendSearchResults 0x01f9
#define OP_SearchRecipe 0x01f8
#define OP_RecipeInfo 0x01fa
#define OP_RequestFavRecipe 0x0321
structure for packets:
Code:
struct SearchRecipe_Struct
{
/*
0: 13 00 00 00 00 00 00 00 - 00 00 00 00 F4 01 00 00 | ................
16: 68 6F 6C 61 00 00 00 00 - 00 00 00 00 00 00 00 00 | name............
32: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 | ................
48: 00 03 00 00 34 DD 13 00 - 9C E8 13 00 A0 F7 50 01 | ....4.........P.
64: 00 00 00 00 94 04 00 00 - A4 C9 33 00 A4 C9 33 00 | ..........3...3.
*/
/*000*/ uint32 tradeskill;
/*004*/ uint32 unknown004;
/*008*/ uint32 mintrivial;
/*012*/ uint32 maxtrivial;
/*016*/ char recipename[32];
};
struct SendRecipeSearch_Struct
{
// [OPCode: 0x01fd] [Raw OPCode: 0x01fd] [Size: 84]
// 0: 0F 00 00 00 1B 46 00 00 - 03 00 00 00 08 01 00 00 | .....F..........
// 16: 24 00 00 00 52 61 74 20 - 45 61 72 20 53 61 6E 64 | $...Rat Ear Sand
// 32: 77 69 63 68 00 00 00 00 - 00 00 00 00 00 00 00 00 | wich............
// 48: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 | ................
// 64: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 | ................
// 80: 00 00 00 00 | ....
int8 unknown000[8];
uint32 components;
uint32 recipeid;
uint32 trivial;
char recipename[64];
};
function to process it,in client_process.cpp:
Code:
case OP_SearchRecipe:{
SearchRecipe_Struct* sr = (SearchRecipe_Struct*) app->pBuffer;
SendSearchResults(sr->recipename,sr->tradeskill,sr->mintrivial,sr->maxtrivial);
break;
}
void Client::SendSearchResults(char* recipename,int tradeskill,int mintriv,int maxtriv)
{
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
char* query2=0;
MYSQL_RES *result;
MYSQL_RES *result2;
MYSQL_ROW row;
MYSQL_ROW row2;
int p=1;
unsigned int ids;
APPLAYER* outapp = new APPLAYER(OP_SendSearchResults,sizeof(SendRecipeSearch_Struct));
SendRecipeSearch_Struct* ss = (SendRecipeSearch_Struct*)outapp->pBuffer;
memset(outapp->pBuffer,0,outapp->size);
ss->unknown000[0]=0x0F;
ss->unknown000[4]=0x1B;
ss->unknown000[5]=0x46;
ss->unknown000[8]=0x03;
if (database.RunQuery(query,MakeAnyLenString(&query, "select id,name from items where name like '%s%%'",recipename),errbuf,&result)){
while(row=mysql_fetch_row(result)){
ids=atoi(row[0]);
if (database.RunQuery(query2,MakeAnyLenString(&query2, "select trivial,id from tradeskillrecipe where product=%i AND trivial>=%i AND trivial<=%i",ids,mintriv,maxtriv),errbuf,&result2))
{
if(mysql_num_rows(result2)==0)
break;
if(p>=10)
break;
row2=0;
row2=mysql_fetch_row(result2);
strcpy(ss->recipename,row[1]);
ss->trivial=atoi(row2[0]);
ss->recipeid=atoi(row2[1]);
ss->components=3; // need to work this
this->QueuePacket(outapp);
DumpPacket(outapp);
p++;
}
safe_delete_array(query);
safe_delete_array(query2);
}
}
safe_delete(outapp);
}
and declare it in client.h
Code:
void SendSearchResults(char* recipename,int tradeskill,int mintriv,int maxtriv);
Things need to be finished:
-Send recipe information(when you click on the recipe)
-Favorites
-Auto combine.
-Check opcodes.
I will post updates when I finish them,working on several things atm.Thanks. :twisted: