#include "Main.h" //Adds the header of the stream with the old item glues from either the replay or the last used void GenerateOldItemGlue(CompiledPacket* pCp, PLAYER_DATA* pLir) { for (int i=0; i<5; i++) { pCp->AddShort(ServerOpcode(2)); pCp->AddShort(pLir->pCharCreate->streamGlue); pCp->AddShort(pLir->pCharCreate->itemGlue[i]); pCp->Fill(0, 2); } } //Converts a Body Part to a GW item position int BPToPosition(int num) { if (num==0){return 4;}//head if (num==1){return 2;}//chest if (num==2){return 6;}//hands if (num==3){return 3;}//legs if (num==4){return 5;}//feet return 0; } void GenerateTheItemPacket(CompiledPacket* pCp, PLAYER_DATA* pLir, short* pGlue, char* pArmorSet, int piece) { //CoreLog.debug("Generating an item packet for character creation!"); unsigned char pck[200]; memset(pck, 0, 200); unsigned char* p=pck; memcpy(p, &ServerOpcode(3), 2); p+=2; memcpy(p, pGlue, 2); memset(p+2, 0, 2); p+=4; //Generate the item xD //CoreLog.debug("+ Attempting to create the armor from the armor set!"); gItemDefMan.CreateArmor(pArmorSet, &pLir->pCharCreate->armor[piece], piece, pLir->pCharCreate->profession); pLir->pCharCreate->armor[piece].SetColorWithDye(pLir->pCharCreate->defaultdye); pLir->pCharCreate->armor[piece].SetItemStoragePosition(BPToPosition(piece)); int g=pLir->pCharCreate->armor[piece].ToItemPacket(p); //CoreLog.BinaryDump("wtf.bin", p, g); p+=g; //Add the position packet to it? memcpy(p, &ServerOpcode(4), 2); p+=2; memcpy(p, pGlue, 2); p+=2; memset(p, 0, 2); p+=2; memset(p, pLir->pCharCreate->profession, 1); ++p; pCp->Add(pck, (unsigned int)(p-(unsigned char*)pck), false); } //Generates the packet that contains the item position void GenerateItemPosPack(CompiledPacket* pCp, PLAYER_DATA* pLir, short* pGlue) { pCp->AddShort(ServerOpcode(5)); pCp->AddShort(pLir->pCharCreate->streamGlue); pCp->AddLong(*pGlue); pCp->AddShort(pLir->pCharCreate->PosGlue); pCp->AddByte(0); } //Converts a Body Part to the server int BPToServer(int num) { if (num==0){return 4;}//head if (num==1){return 2;}//chest if (num==2){return 6;}//hands if (num==3){return 3;}//legs if (num==4){return 5;}//feet return 0; } void GenerateItemBPPack(CompiledPacket* pCp, PLAYER_DATA* pLir, unsigned char bp, short* pGlue) { pCp->AddShort(ServerOpcode(6)); pCp->AddShort(pLir->pCharCreate->streamGlue); pCp->AddLong(*pGlue); pCp->AddShort(pLir->pCharCreate->bpGlue); pCp->AddByte(BPToServer(bp)); } void GenerateItemFinish(CompiledPacket* pCp, PLAYER_DATA* pLir, short* pGlue) { pCp->AddShort(ServerOpcode(7)); pCp->AddLong(*pGlue); pCp->AddLong(*pGlue); } void GenerateNewItemGlue(PLAYER_DATA* pLir) { short temp[5]; memset(temp, 0, sizeof(short)*5); for (int i=0; i<5; i++) { short num; while(true) { num=10+rand()%65000; if (num==pLir->pCharCreate->bpGlue){} else if (num==pLir->pCharCreate->streamGlue){} else if (num==pLir->pCharCreate->PosGlue){} else if (num==pLir->pCharCreate->itemGlue[0]){} else if (num==pLir->pCharCreate->itemGlue[1]){} else if (num==pLir->pCharCreate->itemGlue[2]){} else if (num==pLir->pCharCreate->itemGlue[3]){} else if (num==pLir->pCharCreate->itemGlue[4]){} else if (num==temp[0]){} else if (num==temp[1]){} else if (num==temp[2]){} else if (num==temp[3]){} else if (num==temp[4]){} else{break;} } temp[i]=num; } memcpy(&pLir->pCharCreate->itemGlue, &temp, sizeof(short)*5); } //Prophecies Role playing Game Character Creation Profession //Manages sending the correct profession packet when selecting //a character profession at the prophecies RPG character creation screen. void PropheciesRPGCCProf(PLAYER_DATA* pLir) { assert(pLir>=0); NetMessage s; s.networkId=pLir->networkId; //Generate the reply packet with all the armors CompiledPacket cp; GenerateOldItemGlue(&cp, pLir); unsigned char pckl[13]={0x9E, 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0xC5, 0x00, 0x00, 0x00}; memcpy(pckl, &ServerOpcode(8), 2); memcpy(pckl+2, &pLir->pCharCreate->itemDivGlue, 2); pckl[6]=pLir->pCharCreate->profession; cp.Add(pckl, 13, false); //Generate new item glues GenerateNewItemGlue(pLir); //Generate the first five item packets with body part int num_armors=1;//5 int start_armor=0; //TODO: The following item stuff is incompatible with the damn client for (int i=start_armor; ipCharCreate->itemGlue[i], "Starter", i); //GenerateItemPosPack(&cp, pLir, &pLir->pCharCreate->itemGlue[i]); //GenerateItemBPPack(&cp, pLir, i, &pLir->pCharCreate->itemGlue[i]); } /* //Generate the second part of the response packet for (int i=start_armor; ipCharCreate->itemGlue[i], "Starter", i); GenerateItemFinish(&cp, pLir, &pLir->pCharCreate->itemGlue[i]); }//*/ s.pData=cp.GetString(&s.dataSize); //LogUnknownPacket(&s); //CoreLog.BinaryDump("itemres.bin", s.data, s.dataSize); gpGameServer->SendData(&s); cp.Clear(); }