comparison Player.cpp @ 1829:e4e27261d84e

sub_421B2C_PlaceInInventory_or_DropPickedItem to Party::sub_421B2C_PlaceInInventory_or_DropPickedItem
author Grumpy7
date Fri, 11 Oct 2013 07:29:14 +0200
parents 35c1e4ff6ba7
children 211dfe2d8db1
comparison
equal deleted inserted replaced
1828:35c1e4ff6ba7 1829:e4e27261d84e
1345 _expression21_frameset = 0; 1345 _expression21_frameset = 0;
1346 1346
1347 lastOpenedSpellbookPage = 0; 1347 lastOpenedSpellbookPage = 0;
1348 } 1348 }
1349 1349
1350 //----- (0048C6F6) --------------------------------------------------------
1351 bool Party::AddItemToParty(ItemGen *pItem) //TODO move to party.cpp
1352 {
1353 unsigned int v2; // eax@1
1354 char *v5; // eax@8
1355 Texture *v7; // ebx@10
1356 signed int v8; // esi@10
1357 Player *v9; // edi@11
1358 int v10; // eax@11
1359 int v21; // [sp+24h] [bp-4h]@10
1360
1361 v2 = pItem->uItemID;
1362 if ( !pItemsTable->pItems[v2].uItemID_Rep_St )
1363 pItem->SetIdentified();
1364
1365 v5 = pItemsTable->pItems[v2].pIconName;
1366 if ( v5 )
1367 {
1368 v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE);
1369 v21 = areWeLoadingTexture;
1370 v8 = 0;
1371 int startId = uActiveCharacter >= 0 ? uActiveCharacter - 1 : 0;
1372 for (int i = 0; i < 4; i++)
1373 {
1374 v9 = &pPlayers[(startId + i) % 4]; //start with current active player, then cycle right if item won't fit
1375 v10 = v9->AddItem(-1, pItem->uItemID);
1376 if ( v10 )
1377 {
1378 memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u);
1379 pItem->Reset();
1380 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
1381 v9->PlaySound(SPEECH_60, 0);
1382 if ( !v21 )
1383 {
1384 v7->Release();
1385 pIcons_LOD->SyncLoadedFilesCount();
1386 }
1387 return true;
1388 }
1389 }
1390 if ( !v21 )
1391 {
1392 v7->Release();
1393 pIcons_LOD->SyncLoadedFilesCount();
1394 }
1395 return false;
1396 }
1397 else
1398 {
1399 MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0);
1400 return false;
1401 }
1402 }
1403 // 506128: using guessed type int areWeLoadingTexture;
1404 1350
1405 //----- (0048C855) -------------------------------------------------------- 1351 //----- (0048C855) --------------------------------------------------------
1406 int Player::GetBaseStrength() 1352 int Player::GetBaseStrength()
1407 { 1353 {
1408 return this->uMight + GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH); 1354 return this->uMight + GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH);
2172 itemToSteal->Reset(); 2118 itemToSteal->Reset();
2173 carriedItemId = tempItem.uItemID; 2119 carriedItemId = tempItem.uItemID;
2174 } 2120 }
2175 if (carriedItemId != 0) // looks odd in current context, but avoids accessing zeroth element of pItemsTable->pItems 2121 if (carriedItemId != 0) // looks odd in current context, but avoids accessing zeroth element of pItemsTable->pItems
2176 { 2122 {
2177 sub_421B2C_PlaceInInventory_or_DropPickedItem(); 2123 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
2178 sprintf( 2124 sprintf(
2179 pTmpBuf2.data(), 2125 pTmpBuf2.data(),
2180 pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message 2126 pGlobalTXT_LocalizationStrings[304], // Official //TODO: add a normal "%d stole %d" message
2181 this->pName, 2127 this->pName,
2182 pItemsTable->pItems[carriedItemId].pUnidentifiedName); 2128 pItemsTable->pItems[carriedItemId].pUnidentifiedName);
2183 ShowStatusBarString(pTmpBuf2.data(), 2u); 2129 ShowStatusBarString(pTmpBuf2.data(), 2u);
2184 sub_421B2C_PlaceInInventory_or_DropPickedItem(); 2130 pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
2185 memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen)); 2131 memcpy(&pParty->pPickedItem, &tempItem, sizeof(ItemGen));
2186 pMouse->SetCursorBitmapFromItemID(carriedItemId); 2132 pMouse->SetCursorBitmapFromItemID(carriedItemId);
2187 return 2; 2133 return 2;
2188 } 2134 }
2189 } 2135 }