Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CDbManager::UpdateOfflineVendor(CQuery* pQuery, LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus)
- {
- CAr ar(lpDbOverlappedPlus->lpBuf, lpDbOverlappedPlus->uBufSize);
- DWORD dwVendorId, dwPlayerId, dwSkinSet, dwFace, dwHairMesh, dwHairColor, dwHeadMesh;
- FLOAT dwAngle, dwHairColorR, dwHairColorG, dwHairColorB;
- BYTE dwSex;
- D3DXVECTOR3 dwPosition;
- TCHAR dwStrTitle[MAX_VENDORNAME];
- TCHAR dwVendorPlayerName[64]; //MAX_NAME
- //basic data
- ar >> dwVendorId;
- ar >> dwPlayerId;
- ar.ReadString(dwStrTitle);
- ar.ReadString(dwVendorPlayerName);
- //mover data
- ar >> dwSex >> dwPosition >> dwAngle >> dwFace >> dwSkinSet >> dwHeadMesh >> dwHairMesh >> dwHairColor >> dwHairColorB >> dwHairColorR >> dwHairColorG;
- int inventoryItemCount = 0;
- ar >> inventoryItemCount;
- inventoryItemCount = min(inventoryItemCount, MAX_VENDITEM); //safety
- CItemElem* inventoryItems = new CItemElem[inventoryItemCount];
- for (int i = 0; i < inventoryItemCount; i++)
- {
- CItemElem item = CItemElem();
- item.Serialize(ar);
- inventoryItems[i] = item;
- }
- //clothing
- DWORD clothingCount = 0;
- ar >> clothingCount;
- clothingCount = min(clothingCount, MAX_HUMAN_PARTS); //safety
- char dwEquipment[1024] = { 0, };
- *dwEquipment = '\0';
- if (clothingCount > 0)
- {
- DWORD* itemIds = new DWORD[clothingCount];
- for (unsigned char index = 0; index < clothingCount; index++)
- {
- DWORD itemID;
- ar >> itemID;
- itemIds[index] = itemID;
- }
- /*for (int nIndex = 0; nIndex < MAX_HUMAN_PARTS; nIndex++)
- {
- char s[32] = { 0, };
- sprintf(s, "%d/", itemIds[nIndex]);
- strcat(dwEquipment, s);
- }*/
- char OneEquipment[16] = { 0, };
- for (int i = 0; i < MAX_HUMAN_PARTS; i++)
- {
- sprintf(OneEquipment, "%d/", itemIds[i]);
- strncat(dwEquipment, OneEquipment, sizeof(OneEquipment));
- }
- strncat(dwEquipment, NullStr, sizeof(NullStr));
- }
- ItemStruct is;
- char Onem_apIndex[10] = { 0, };
- char sPerObjIndex[16] = { 0, };
- BOOL bExtInven = FALSE;
- BOOL bPirecingInven = FALSE;
- PItemContainerStruct pItemContainerStruct = new ItemContainerStruct();
- BOOL bPet = FALSE;
- for (DWORD ch = 0; ch < MAX_VENDITEM; ch++) // 0-504
- {
- SaveOneItem(&inventoryItems[ch], &is);
- strncat(pItemContainerStruct->szItem, is.szItem, sizeof(is.szItem));
- strncat(pItemContainerStruct->szExt, is.szExt, sizeof(is.szExt));
- strncat(pItemContainerStruct->szPiercing, is.szPiercing, sizeof(is.szPiercing));
- sprintf(Onem_apIndex, "%d/", ch); //slot position ?
- strncat(pItemContainerStruct->szIndex, Onem_apIndex, sizeof(Onem_apIndex));
- sprintf(sPerObjIndex, "%d/", inventoryItems[ch].m_dwObjIndex);
- strcat(pItemContainerStruct->szObjIndex, sPerObjIndex);
- strncat(pItemContainerStruct->szPet, is.szPet, sizeof(is.szPet));
- if (inventoryItems[ch].m_bCharged || 0 <inventoryItems[ch].m_dwKeepTime || 0 != inventoryItems[ch].GetRandomOptItemId())
- bExtInven = TRUE;
- if (inventoryItems[ch].IsPiercedItem())
- bPirecingInven = TRUE;
- if (inventoryItems[ch].m_pPet)
- bPet = TRUE;
- }
- strncat(pItemContainerStruct->szItem, NullStr, sizeof(NullStr));
- strncat(pItemContainerStruct->szIndex, NullStr, sizeof(NullStr));
- strcat(pItemContainerStruct->szObjIndex, NullStr);
- if (bExtInven == FALSE)
- *pItemContainerStruct->szExt = '\0';
- if (bPirecingInven == FALSE)
- *pItemContainerStruct->szPiercing = '\0';
- if (bPet == FALSE)
- *pItemContainerStruct->szPet = '\0';
- strcat(pItemContainerStruct->szExt, NullStr);
- strcat(pItemContainerStruct->szPiercing, NullStr);
- strcat(pItemContainerStruct->szPet, NullStr);
- //check if a vendor exists for the player
- char szSQL[8196] = { 0, };
- sprintf(szSQL, "[SYSTEM_DBF].[dbo].[OFFLINE_VENDOR_STR] @iGu='G1', @im_dwPlayerOwnerId=%lu,@im_dwVendorId=%lu",dwPlayerId,dwVendorId);
- if (pQuery->Exec(szSQL) == FALSE)
- {
- WriteLog("%s, %d\t%s", __FILE__, __LINE__, szSQL);
- return;
- }
- if (pQuery->Fetch()) {
- OutputDebugString("Has Entry For Player!");
- }
- else
- {
- OutputDebugString("Has No Entry For Player!");
- sprintf(szSQL, "[SYSTEM_DBF].[dbo].[OFFLINE_VENDOR_STR] @iGu='C1', @im_dwPlayerOwnerId=%lu, @im_dwShopName='%s', @im_dwPlayerName='%s', @im_dwSex=%i, @im_dwPosX=%f, @im_dwPosY=%f, @im_dwPosZ=%f, @im_dwAngle=%f, @im_dwInventory='%s', @im_dwApIndex='%s', @im_dwObjIndex='%s', @im_dwFace=%i, @im_dwSkinSet=%i, @im_dwHeadMesh=%i, @im_dwHairMesh=%i, @im_dwHairColor=%lu, @im_dwHairColorB=%lu,@im_dwHairColorR=%lu,@im_dwHairColorG=%lu,@im_dwEquipInfo='%s'", dwPlayerId, dwStrTitle, dwVendorPlayerName, dwSex, dwPosition.x, dwPosition.y, dwPosition.z, dwAngle, pItemContainerStruct->szItem, pItemContainerStruct->szIndex, pItemContainerStruct, pItemContainerStruct->szObjIndex, dwFace, dwSkinSet, dwHeadMesh, dwHairMesh, dwHairColor, dwHairColorB, dwHairColorR, dwHairColorG, dwEquipment);
- if (pQuery->Exec(szSQL) == FALSE)
- {
- WriteLog("%s, %d\t%s", __FILE__, __LINE__, szSQL);
- return;
- }
- if (pQuery->Fetch()) {
- OutputDebugString("Has Entry For Player!");
- }
- }
- //BEFORESENDDUAL(ar, PACKETTYPE_SEND_RECORD_BOOK_BACK, DPID_UNKNOWN, DPID_UNKNOWN);
- //ar << createdVendorId
- //SEND(ar, this, DPID_ALLPLAYERS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement