comparison Party.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 f4f63f565a72
comparison
equal deleted inserted replaced
1828:35c1e4ff6ba7 1829:e4e27261d84e
1006 if ( pTmpBuf2[0] ) 1006 if ( pTmpBuf2[0] )
1007 ShowStatusBarString(pTmpBuf2.data(), 2u); 1007 ShowStatusBarString(pTmpBuf2.data(), 2u);
1008 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); 1008 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
1009 } 1009 }
1010 //----- (00421B2C) -------------------------------------------------------- 1010 //----- (00421B2C) --------------------------------------------------------
1011 bool sub_421B2C_PlaceInInventory_or_DropPickedItem() 1011 void Party::sub_421B2C_PlaceInInventory_or_DropPickedItem()
1012 { 1012 {
1013 unsigned int v0; // eax@2 1013 unsigned int v0; // eax@2
1014 Texture *v1; // ebx@2 1014 Texture *v1; // ebx@2
1015 int v2; // eax@3 1015 int v2; // eax@3
1016 Player *v3; // esi@5
1017 int v4; // eax@6 1016 int v4; // eax@6
1018 unsigned __int16 v5; // dx@11 1017 unsigned __int16 v5; // dx@11
1019 signed int v6; // eax@11 1018 signed int v6; // eax@11
1020 char *v7; // edi@12
1021 __int16 v8; // ax@16 1019 __int16 v8; // ax@16
1022 SpriteObject a1; // [sp+4h] [bp-78h]@11 1020 SpriteObject a1; // [sp+4h] [bp-78h]@11
1023 int v11; // [sp+74h] [bp-8h]@2 1021 int v11; // [sp+74h] [bp-8h]@2
1024 int v12; // [sp+78h] [bp-4h]@5 1022 int v12; // [sp+78h] [bp-4h]@5
1025 1023
1026 if ( !pParty->pPickedItem.uItemID ) 1024 if ( !pParty->pPickedItem.uItemID )
1027 return 1; 1025 return;
1028 v0 = pIcons_LOD->LoadTexture( 1026 v0 = pIcons_LOD->LoadTexture(
1029 pParty->pPickedItem.GetIconName(), 1027 pParty->pPickedItem.GetIconName(),
1030 TEXTURE_16BIT_PALETTE); 1028 TEXTURE_16BIT_PALETTE);
1031 v1 = pIcons_LOD->GetTexture(v0); 1029 v1 = pIcons_LOD->GetTexture(v0);
1032 v11 = areWeLoadingTexture; 1030 v11 = areWeLoadingTexture;
1033 if ( uActiveCharacter 1031 if ( uActiveCharacter
1034 && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) 1032 && (v2 = ::pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 )
1035 { 1033 {
1036 memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v2-1], &pParty->pPickedItem, 0x24u); 1034 memcpy(&::pPlayers[uActiveCharacter]->pInventoryItemList[v2-1], &pParty->pPickedItem, 0x24u);
1037 pMouse->RemoveHoldingItem(); 1035 pMouse->RemoveHoldingItem();
1038 } 1036 }
1039 else 1037 else
1040 { 1038 {
1041 v12 = 0; 1039 for (v12 = 0; v12 < 4; v12++)
1042 v3 = pParty->pPlayers; 1040 {
1043 while ( v3 <= &pParty->pPlayers[3] ) 1041 v4 = pParty->pPlayers[v12].AddItem(-1, pParty->pPickedItem.uItemID);
1044 {
1045 v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID);
1046 if ( v4 ) 1042 if ( v4 )
1047 { 1043 {
1048 memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, 0x24u); 1044 memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, sizeof(ItemGen));
1049 pMouse->RemoveHoldingItem(); 1045 pMouse->RemoveHoldingItem();
1050 break; 1046 break;
1051 } 1047 }
1052 ++v12;
1053 ++v3;
1054 } 1048 }
1055 if ( v12 == 4 ) 1049 if ( v12 == 4 )
1056 { 1050 {
1057 v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; 1051 v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
1058 v6 = 0; 1052 v6 = 0;
1059 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; 1053 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
1060 if ( (signed int)pObjectList->uNumObjects <= 0 ) 1054 for ( uint i = 0; i < pObjectList->uNumObjects; i++ )
1061 { 1055 {
1062 LOWORD(v6) = 0; 1056 if ( v5 == pObjectList->pObjects[i].uObjectID )
1063 } 1057 {
1064 else 1058 v6 = i;
1065 { 1059 break;
1066 v7 = (char *)&pObjectList->pObjects->uObjectID; 1060 }
1067 while ( v5 != *(short *)v7 ) 1061 }
1068 { 1062 a1.spell_caster_pid = OBJECT_Player;
1069 ++v6; 1063 a1.uObjectDescID = v6;
1070 v7 += 56; 1064 a1.vPosition.y = pParty->vPosition.y;
1071 if ( v6 >= (signed int)pObjectList->uNumObjects ) 1065 a1.vPosition.x = pParty->vPosition.x;
1072 { 1066 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
1073 LOWORD(v6) = 0; 1067 a1.uSoundID = 0;
1074 break; 1068 a1.uFacing = 0;
1075 } 1069 a1.uAttributes = 8;
1076 } 1070 v8 = pIndoor->GetSector(
1077 } 1071 pParty->vPosition.x,
1078 a1.spell_caster_pid = OBJECT_Player; 1072 pParty->vPosition.y,
1079 a1.uObjectDescID = v6; 1073 pParty->sEyelevel + pParty->vPosition.z);
1080 a1.vPosition.y = pParty->vPosition.y; 1074 a1.uSpriteFrameID = 0;
1081 a1.vPosition.x = pParty->vPosition.x; 1075 a1.uSectorID = v8;
1082 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; 1076 memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24));
1083 a1.uSoundID = 0; 1077 a1.Create(pParty->sRotationY, 184, 200, 0);
1084 a1.uFacing = 0; 1078 pMouse->RemoveHoldingItem();
1085 a1.uAttributes = 8; 1079 }
1086 v8 = pIndoor->GetSector(
1087 pParty->vPosition.x,
1088 pParty->vPosition.y,
1089 pParty->sEyelevel + pParty->vPosition.z);
1090 a1.uSpriteFrameID = 0;
1091 a1.uSectorID = v8;
1092 memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24));
1093 a1.Create(pParty->sRotationY, 184, 200, 0);
1094 pMouse->RemoveHoldingItem();
1095 }
1096 } 1080 }
1097 if ( !v11 ) 1081 if ( !v11 )
1098 { 1082 {
1099 v1->Release(); 1083 v1->Release();
1100 pIcons_LOD->SyncLoadedFilesCount(); 1084 pIcons_LOD->SyncLoadedFilesCount();
1101 } 1085 }
1102 return 1; 1086 return;
1103 } 1087 }
1104 1088
1089
1090 //----- (0048C6F6) --------------------------------------------------------
1091 bool Party::AddItemToParty(ItemGen *pItem)
1092 {
1093 unsigned int v2; // eax@1
1094 char *v5; // eax@8
1095 Texture *v7; // ebx@10
1096 signed int v8; // esi@10
1097 Player *v9; // edi@11
1098 int v10; // eax@11
1099 int v21; // [sp+24h] [bp-4h]@10
1100
1101 v2 = pItem->uItemID;
1102 if ( !pItemsTable->pItems[v2].uItemID_Rep_St )
1103 pItem->SetIdentified();
1104
1105 v5 = pItemsTable->pItems[v2].pIconName;
1106 if ( v5 )
1107 {
1108 v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE);
1109 v21 = areWeLoadingTexture;
1110 v8 = 0;
1111 int startId = uActiveCharacter >= 0 ? uActiveCharacter - 1 : 0;
1112 for (int i = 0; i < 4; i++)
1113 {
1114 v9 = &pPlayers[(startId + i) % 4]; //start with current active player, then cycle right if item won't fit
1115 v10 = v9->AddItem(-1, pItem->uItemID);
1116 if ( v10 )
1117 {
1118 memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u);
1119 pItem->Reset();
1120 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
1121 v9->PlaySound(SPEECH_60, 0);
1122 if ( !v21 )
1123 {
1124 v7->Release();
1125 pIcons_LOD->SyncLoadedFilesCount();
1126 }
1127 return true;
1128 }
1129 }
1130 if ( !v21 )
1131 {
1132 v7->Release();
1133 pIcons_LOD->SyncLoadedFilesCount();
1134 }
1135 return false;
1136 }
1137 else
1138 {
1139 MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0);
1140 return false;
1141 }
1142 }
1143 // 506128: using guessed type int areWeLoadingTexture;
1105 1144
1106 bool Party::IsPartyEvil() 1145 bool Party::IsPartyEvil()
1107 { 1146 {
1108 return _449B57_test_bit(_quest_bits, 100); 1147 return _449B57_test_bit(_quest_bits, 100);
1109 } 1148 }