#include "Main.h" void GeneratePagePacket(CompiledPacket* pCp, short* pPageId, long* pIsa, short* pStreamId, int storageLoc) { (*pPageId)++; //append the item page packet header pCp->AddShort(ServerOpcode(11)); pCp->AddShort(*pStreamId); if (storageLoc==LOC_IS_BACKPACK) { pCp->AddByte(1); pCp->AddByte(0); } else if (storageLoc==LOC_IN_EQUIPPED) { pCp->AddByte(0x02); pCp->AddByte(0x0a); } pCp->AddShort(*pPageId); if (storageLoc==LOC_IS_BACKPACK) { pCp->AddByte(0x14); } else if (storageLoc==LOC_IN_EQUIPPED) { pCp->AddByte(0x07); } //if this is connected to an item, append the item glue if (pIsa!=NULL) { pCp->AddLong(*pIsa); } else { pCp->Fill(0, 2); pCp->Fill(0, 2); } } void OutputItemsOnPage(int permitted, short* pStreamId, short* pStartPage, long* pIsa, CompiledPacket* pCp, PLAYER_DATA* pLir, Player* pPlayer, Instance* pInstance) { char buf[500]; int count=0; hash_map::iterator itr; for (itr=pPlayer->mItems.begin(); itr!=pPlayer->mItems.end(); itr++) { if (itr->second.GetItemStorageLocation()==permitted) { *pIsa=pInstance->mIsaMan.GetFreeID(); int s=itr->second.CreateItemPacket(ServerOpcode(3),ServerOpcode(5),ServerOpcode(10),ServerOpcode(4),pIsa, pStartPage, pStreamId, buf); pCp->Add((unsigned char*)buf, s, false); } } } bool Instance::SendCharacterInfo(void* pLir2) { PLAYER_DATA* pLir=(PLAYER_DATA*)pLir2; Player* pPlayer=AccessPlayer(((PLAYER_DATA*)pLir)->networkId); assert(pPlayer!=NULL); //We are starting a new stream. Generate a new stream ID. pPlayer->SetStreamID(mStreamMan.GetFreeID()); //Grab the generated stream id short stream_id=pPlayer->GetStreamId(); //Generate a new item start ID, the item glue so to speak long isa=320; //Generate a starting page id short start_page=300; //Create a new compiled packet and start adding stuff to it CompiledPacket cp; //The first stream packet cp.AddShort(ServerOpcode(14)); cp.AddShort(stream_id); cp.AddByte(0); //The second stream packet cp.AddShort(ServerOpcode(15)); cp.AddShort(stream_id); cp.AddByte(0); //Allocate an item buffer char item_buf[500]; int s=0; short equip_processed=false; short start_of_equipped=0; gCoreLog.debug("Num items %d", pPlayer->mItems.size()); hash_map::iterator itr; for (itr=pPlayer->mItems.begin(); itr!=pPlayer->mItems.end(); itr++) { switch(itr->second.GetItemStorageLocation()) { case LOC_IS_BACKPACK: isa=mIsaMan.GetFreeID(); //Generate the backpack stuff and fill it with items xD s=itr->second.CreateItemPacket(ServerOpcode(3),ServerOpcode(5),ServerOpcode(10),ServerOpcode(4),&isa, NULL, &stream_id, item_buf); cp.Add((unsigned char*)item_buf, s, false); GeneratePagePacket(&cp, &start_page, &isa, &stream_id, LOC_IS_BACKPACK); OutputItemsOnPage(LOC_IN_BACKPACK, &stream_id, &start_page, &isa, &cp, pLir, pPlayer, this); break; case LOC_IN_EQUIPPED: if (!equip_processed) { GeneratePagePacket(&cp, &start_page, NULL, &stream_id, LOC_IN_EQUIPPED); OutputItemsOnPage(LOC_IN_EQUIPPED, &stream_id, &start_page, &isa, &cp, pLir, pPlayer, this); equip_processed=true; } break; } } start_of_equipped=0; //Append the certification packets? //Generate the charinfo confirmation packets? cp.AddShort(ServerOpcode(16)); cp.AddShort(stream_id); cp.AddByte(3); cp.AddLong(0); cp.AddLong(0); /* for (int i=0; i<3; i++) { cp.AddShort(PckHeaders.INSTANCE_LOAD_WEAPON_BAR_SLOT); cp.AddShort(streamID); cp.AddByte(i+3); cp.Fill(0, 8); } //*/ ///////////////////////////////// NetMessage ss; gPacketManager.DirSwitch("Data/Packets/"); ss.pData = gPacketManager.GetData("InterfaceInfo", &ss.dataSize); if (ss.pData != NULL) { memcpy(&ss.pData[0], &ServerOpcode(17), 2); memcpy(ss.pData+2, &stream_id, 2); cp.Add(ss.pData, ss.dataSize, false); } cp.AddShort(ServerOpcode(18)); cp.AddByte(0); cp.AddShort(this->mZoneId); cp.Fill(0, 4); //DEBUG /*int size; unsigned char *data=cp.GetString(&size); CoreLog.LogKnownData("CharInfo", data, size); CoreLog.BinaryDump("CharInfoMY.bin", data, size); ss.data=(unsigned char*)&size;//*/ while((ss.pData=cp.GetString(&ss.dataSize, 2920))!=NULL)//2920 { if (ss.pData==NULL){break;} ss.networkId=pLir->networkId; gpGameServer->SendData(&ss); } cp.Clear(); pPlayer->StartCharInfoTimer(); return true; }