annotate Engine/Objects/Chest.cpp @ 2550:fb42e2662c38

Chest UI refactored to a class
author a.parshin
date Tue, 12 May 2015 11:28:22 +0200
parents c674d547cc7c
children 30eb6dcac768
rev   line source
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
2550
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
2 #define _CRT_SECURE_NO_WARNINGS
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
3 #include <stdlib.h>
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
4 #include <crtdbg.h>
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
5 #include <stdio.h>
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
6
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2534
diff changeset
7 #include "Engine/Engine.h"
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
8
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
9 #include "Items.h"
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
10 #include "Chest.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
11 #include "../Tables/FrameTableInc.h"
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
12 #include "../LOD.h"
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
13 #include "../MapInfo.h"
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
14 #include "Actor.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
15 #include "../Graphics/Outdoor.h"
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
16 #include "../Graphics/DecorationList.h"
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
17 #include "../Party.h"
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
18 #include "../OurMath.h"
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
19 #include "../Texts.h"
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
20 #include "ObjectList.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
21 #include "../Timer.h"
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
22 #include "SpriteObject.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
23 #include "../Graphics/Viewport.h"
68cdef6879a0 engine folder
Ritor1
parents: 2497
diff changeset
24 #include "../Graphics/Level/Decoration.h"
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
25
2550
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
26 #include "IO/Mouse.h"
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
27
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
28 #include "GUI/UI/Chest.h"
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
29
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
30 #include "Media/Audio/AudioPlayer.h"
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
31
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
32
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
33
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
34 size_t uNumChests; // idb
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
35 struct ChestList *pChestList;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
36 std::array<Chest, 20> pChests;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
37
2550
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
38 extern int pChestWidthsByType[8];
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
39 extern int pChestHeightsByType[8];
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
40
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
41
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
42
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
43 //----- (0042041E) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
44 bool Chest::Open( signed int uChestID )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
45 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
46 unsigned int pMapID; // eax@8
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
47 int pRandom; // edx@16
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
48 int v6; // eax@16
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
49 ODMFace *pODMFace; // eax@19
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
50 BLVFace *pBLVFace; // eax@20
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
51 int pObjectX; // ebx@21
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
52 int pObjectZ; // edi@21
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
53 double dir_x; // st7@23
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
54 double dir_y; // st6@23
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
55 double length_vector; // st7@23
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
56 int pDepth; // ecx@26
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
57 Vec3_int_ v; // ST4C_12@28
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
58 bool flag_shout; // edi@28
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
59 int pSpriteID[4]; // [sp+84h] [bp-40h]@16
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
60 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
61 int pObjectY; // [sp+B0h] [bp-14h]@21
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
62 int sRotX; // [sp+B4h] [bp-10h]@23
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
63 float dir_z; // [sp+BCh] [bp-8h]@23
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
64 int sRotY; // [sp+C0h] [bp-4h]@8
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
65 SpriteObject pSpellObject; // [sp+14h] [bp-B0h]@28
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
66
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
67 assert( uChestID < 20 );
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
68 if ( ( uChestID < 0 ) && ( uChestID >= 20 ) )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
69 return false;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
70 Chest* chest = &pChests[uChestID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
71
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
72 ++pIcons_LOD->uTexturePacksCount;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
73 if (!pIcons_LOD->uNumPrevLoadedFiles)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
74 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
75
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
76 if (!chest->Initialized())
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
77 Chest::PlaceItems(uChestID);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
78
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
79 if ( !uActiveCharacter )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
80 return false;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
81 flag_shout = false;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
82 pMapID = pMapStats->GetMapInfo(pCurrentMapName);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
83 if ( chest->Trapped() && pMapID )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
84 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
85 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[pMapID].LockX5 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
86 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
87 pSpriteID[0] = 811;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
88 pSpriteID[1] = 812;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
89 pSpriteID[2] = 813;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
90 pSpriteID[3] = 814;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
91 pRandom = rand() % 4;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
92 v6 = PID_ID(EvtTargetObj);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
93 if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
94 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
95 pObjectX = pLevelDecorations[v6].vPosition.x;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
96 pObjectY = pLevelDecorations[v6].vPosition.y;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
97 pObjectZ = pLevelDecorations[v6].vPosition.z + ( pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight / 2 );
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
98 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
99 if ( PID_TYPE(EvtTargetObj) == OBJECT_BModel)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
100 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
101 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
102 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
103 pODMFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
104 pObjectX = ( pODMFace->pBoundingBox.x1 + pODMFace->pBoundingBox.x2 ) / 2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
105 pObjectY = ( pODMFace->pBoundingBox.y1 + pODMFace->pBoundingBox.y2 ) / 2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
106 pObjectZ = ( pODMFace->pBoundingBox.z1 + pODMFace->pBoundingBox.z2 ) / 2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
107 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
108 else//Indoor
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
109 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
110 pBLVFace = &pIndoor->pFaces[v6];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
111 pObjectX = ( pBLVFace->pBounding.x1 + pBLVFace->pBounding.x2 ) / 2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
112 pObjectY = ( pBLVFace->pBounding.y1 + pBLVFace->pBounding.y2 ) / 2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
113 pObjectZ = ( pBLVFace->pBounding.z1 + pBLVFace->pBounding.z2 ) / 2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
114 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
115 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
116 dir_x = (double)pParty->vPosition.x - (double)pObjectX;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
117 dir_y = (double)pParty->vPosition.y - (double)pObjectY;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
118 dir_z = ( (double)pParty->sEyelevel + (double)pParty->vPosition.z ) - (double)pObjectZ;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
119 length_vector = sqrt( (dir_x * dir_x) + (dir_y * dir_y) + (dir_z * dir_z) );
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
120 if ( length_vector <= 1.0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
121 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
122 *(float *)&sRotX = 0.0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
123 *(float *)&sRotY = 0.0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
124 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
125 else
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
126 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
127 sRotY = (signed __int64)sqrt(dir_x * dir_x + dir_y * dir_y);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
128 sRotX = stru_5C6E00->Atan2((signed __int64)dir_x, (signed __int64)dir_y);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
129 sRotY = stru_5C6E00->Atan2(dir_y * dir_y, (signed __int64)dir_z);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
130 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
131 pDepth = 256;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
132 if ( length_vector < 256.0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
133 pDepth = (signed __int64)length_vector / 4;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
134 v.x = pObjectX;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
135 v.y = pObjectY;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
136 v.z = pObjectZ;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
137 Vec3_int_::Rotate(pDepth, sRotX, sRotY, v, &pOut.x, &pOut.z, &pOut.y);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
138 SpriteObject::sub_42F7EB_DropItemAt(pSpriteID[pRandom], pOut.x, pOut.z, pOut.y, 0, 1, 0, 48, 0);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
139
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
140 pSpellObject.stru_24.Reset();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
141 pSpellObject.spell_skill = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
142 pSpellObject.spell_level = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
143 pSpellObject.spell_id = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
144 pSpellObject.field_54 = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
145 pSpellObject.uType = pSpriteID[pRandom];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
146 pSpellObject.uObjectDescID = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
147 if ( pObjectList->uNumObjects )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
148 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
149 for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
150 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
151 if ( pSpriteID[pRandom] == pObjectList->pObjects[i].uObjectID )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
152 pSpellObject.uObjectDescID = i;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
153 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
154 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
155 pSpellObject.vPosition.y = pOut.z;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
156 pSpellObject.vPosition.x = pOut.x;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
157 pSpellObject.vPosition.z = pOut.y;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
158 pSpellObject.uSoundID = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
159 pSpellObject.uAttributes = 48;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
160 pSpellObject.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
161 pSpellObject.uSpriteFrameID = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
162 pSpellObject.spell_caster_pid = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
163 pSpellObject.spell_target_pid = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
164 pSpellObject.uFacing = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
165 pSpellObject.Create(0, 0, 0, 0);
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2524
diff changeset
166 pAudioPlayer->PlaySound(SOUND_fireBall, 0, 0, -1, 0, 0, 0, 0);
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
167 pSpellObject.ExplosionTraps();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
168 chest->uFlags &= 0xFEu;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
169 if ( uActiveCharacter && !_A750D8_player_speech_timer && !OpenedTelekinesis )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
170 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
171 _A750D8_player_speech_timer = 256i64;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
172 PlayerSpeechID = SPEECH_5;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
173 uSpeakingCharacter = uActiveCharacter;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
174 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
175 pIcons_LOD->RemoveTexturesPackFromTextureList();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
176 OpenedTelekinesis = false;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
177 return false;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
178 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
179 chest->uFlags &= 0xFEu;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
180 flag_shout = true;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
181 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
182 pAudioPlayer->StopChannels(-1, -1);
2534
1bcadc6dd203 enum SOUND_
Ritor1
parents: 2524
diff changeset
183 pAudioPlayer->PlaySound(SOUND_openchest0101, 0, 0, -1, 0, 0, 0, 0);
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
184 if ( flag_shout == true )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
185 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
186 if ( !OpenedTelekinesis )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
187 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
188 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
189 OpenedTelekinesis = false;
2550
fb42e2662c38 Chest UI refactored to a class
a.parshin
parents: 2544
diff changeset
190 pChestWindow = pGUIWindow_CurrentMenu = new GUIWindow_Chest(uChestID);
2497
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
191 return true;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
192 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
193
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
194 //----- (0042038D) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
195 void Chest::ChestUI_WritePointedObjectStatusString()
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
196 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
197 int v1; // ecx@2
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
198 POINT cursor; // [sp+8h] [bp-8h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
199
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
200 pMouse->GetCursorPos(&cursor);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
201 if ( cursor.y < 350 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
202 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
203 v1 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
204 if ( v1 != 0 && v1 != -65536 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
205 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
206 if ( v1 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
207 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
208 ItemGen* item = &pChests[pChestWindow->par1C].igChestItems[pChests[pChestWindow->par1C].pInventoryIndices[(v1 & 0xFFFF) - 1] - 1];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
209 GameUI_SetFooterString(item->GetDisplayName());
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
210 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
211 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
212 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
213 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
214
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
215
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
216
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
217 //----- (0041FE71) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
218 bool Chest::CanPlaceItemAt( signed int test_cell_position, int item_id, signed int uChestID )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
219 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
220 // int v3; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
221 unsigned int item_texture_id; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
222 Texture *item_texture; // ecx@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
223 signed int v6; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
224 // signed int v7; // edi@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
225 signed int v8; // eax@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
226 int texture_cell_width; // edi@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
227 int texture_cell_height; // ebx@5
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
228 int _row; // esi@9
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
229 int _cell_rows; // edx@10
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
230 int _column; // ecx@11
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
231 // char *v14; // eax@12
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
232 int chest_cell_heght; // [sp+Ch] [bp-Ch]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
233 // signed int v17; // [sp+10h] [bp-8h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
234 signed int chest_cell_width; // [sp+14h] [bp-4h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
235
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
236 chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
237 chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
238 item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
239 item_texture = pIcons_LOD->GetTexture(item_texture_id);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
240 v6 = item_texture->uTextureWidth;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
241 if ( v6 < 14 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
242 v6 = 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
243 texture_cell_width = ((v6 - 14) >> 5) + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
244 v8 = item_texture->uTextureHeight;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
245 if ( v8 < 14 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
246 v8 = 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
247 texture_cell_height = ((v8 - 14) >> 5) + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
248 if ( !areWeLoadingTexture )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
249 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
250 item_texture->Release();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
251 pIcons_LOD->SyncLoadedFilesCount();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
252 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
253 if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) &&
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
254 (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
255 { //we not put over borders
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
256 _row = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
257 if ( texture_cell_height <= 0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
258 return true;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
259 _cell_rows = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
260 while ( 1 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
261 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
262 _column = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
263 if ( texture_cell_width > 0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
264 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
265 while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
266 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
267 ++_column;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
268 if ( _column >= texture_cell_width )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
269 break;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
270 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
271 if (pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]!=0)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
272 return false;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
273 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
274 _cell_rows += chest_cell_width;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
275 ++_row;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
276 if ( _row >= texture_cell_height )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
277 return true;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
278 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
279
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
280 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
281 return false;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
282 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
283 // 506128: using guessed type int areWeLoadingTexture;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
284
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
285 //----- (0041FF64) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
286 int Chest::CountChestItems(signed int uChestID)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
287 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
288 signed int item_count; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
289 int max_items; // edx@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
290 item_count = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
291 max_items = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
292 if ( max_items <= 0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
293 item_count = -1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
294 else
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
295 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
296 while ( pChests[uChestID].igChestItems[item_count].uItemID )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
297 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
298 ++item_count;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
299 if ( item_count >= max_items )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
300 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
301 item_count = -1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
302 break;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
303 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
304 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
305 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
306 return item_count;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
307 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
308
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
309 //----- (0041FFA2) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
310 int Chest::PutItemInChest(int position, ItemGen *put_item, signed int uChestID)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
311 {//(rus: положить предмет в ящик)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
312 ItemGen *v4; // edi@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
313 int v5; // esi@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
314 int result; // eax@11
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
315 unsigned int v7; // eax@12
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
316 int v8; // edx@12
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
317 Texture *texture; // ecx@12
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
318 signed int v10; // eax@12
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
319 signed int v11; // edi@14
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
320 unsigned int v12; // esi@14
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
321 int v13; // edi@16
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
322 void *v14; // edi@21
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
323 int v15; // edi@21
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
324 int i; // ecx@21
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
325 ItemGen *Src; // [sp+Ch] [bp-18h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
326 signed int item_in_chest_count; // [sp+10h] [bp-14h]@2
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
327 int v19; // [sp+14h] [bp-10h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
328 int v20; // [sp+18h] [bp-Ch]@19
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
329 signed int v21; // [sp+1Ch] [bp-8h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
330 // signed int v22; // [sp+20h] [bp-4h]@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
331 int v23; // [sp+20h] [bp-4h]@19
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
332
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
333 v21 = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
334 v4 = put_item;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
335 v5 = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
336 Src = put_item;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
337 v19 = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
338 if ( position == -1 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
339 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
340 item_in_chest_count = CountChestItems(uChestID);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
341 if ( item_in_chest_count == -1 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
342 return 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
343 for( int _i = 0; _i < v5; _i++)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
344 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
345 if ( Chest::CanPlaceItemAt(_i, v4->uItemID, pChestWindow->par1C) )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
346 v21 = _i;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
347 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
348 if ( v21 == v5 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
349 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
350 if ( uActiveCharacter )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
351 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
352 return 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
353 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
354 v7 = pIcons_LOD->LoadTexture(v4->GetIconName(), TEXTURE_16BIT_PALETTE);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
355 HIWORD(v8) = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
356 texture = pIcons_LOD->GetTexture(v7);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
357 v10 = texture->uTextureWidth;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
358 if ( texture->uTextureWidth < 14 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
359 v10 = 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
360 v12 = ((v10 - 14) >> 5) + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
361 v11 = texture->uTextureHeight;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
362 if ( texture->uTextureHeight < 14 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
363 v11 = 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
364 v13 = ((v11 - 14) >> 5) + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
365 if ( !areWeLoadingTexture )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
366 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
367 texture->Release();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
368 pIcons_LOD->SyncLoadedFilesCount();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
369 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
370 if ( v13 > 0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
371 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
372 v23 = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
373 v20 = v13;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
374 do
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
375 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
376 if ( (signed int)v12 > 0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
377 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
378 v14 = &pChests[uChestID].pInventoryIndices[v21 + v23];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
379 LOWORD(v8) = -1 - v21;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
380 v8 <<= 16;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
381 LOWORD(v8) = -1 - v21;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
382 memset32(v14, v8, v12 >> 1);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
383 v15 = (int)((char *)v14 + 4 * (v12 >> 1));
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
384 for ( i = v12 & 1; i; --i )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
385 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
386 *(short *)v15 = v8;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
387 v15 += 2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
388 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
389 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
390 v23 += v19;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
391 --v20;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
392 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
393 while ( v20 );
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
394 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
395 pChests[uChestID].pInventoryIndices[v21] = item_in_chest_count + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
396 memcpy(&pChests[uChestID].igChestItems[item_in_chest_count], put_item, sizeof(ItemGen));
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
397 result = v21 + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
398 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
399 else
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
400 result = 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
401 return result;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
402 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
403 // 506128: using guessed type int areWeLoadingTexture;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
404
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
405 //----- (0042013E) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
406 void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, signed int uChestID )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
407 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
408 int uItemID; // edi@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
409 int v6; // edx@4
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
410 unsigned int v7; // eax@5
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
411 Texture *texture; // ecx@5
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
412 signed int v9; // eax@5
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
413 signed int v10; // edi@7
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
414 unsigned int texture_cell_width; // ebx@7
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
415 int textute_cell_height; // edi@9
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
416 int chest_cell_row_pos; // edx@12
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
417 int chest_cell_width; // [sp+10h] [bp-Ch]@11
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
418
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
419 uItemID = pChests[ uChestID].igChestItems[item_at_cell].uItemID;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
420 pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[item_at_cell]);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
421 if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[item_at_cell].uNumCharges)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
422 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
423 v6 = rand() % 21 + 10;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
424 pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
425 pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
426 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
427 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
428 texture = pIcons_LOD->GetTexture(v7);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
429 v9 = texture->uTextureWidth;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
430 if ( texture->uTextureWidth < 14 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
431 v9 = 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
432 texture_cell_width = ((v9 - 14) >> 5) + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
433 v10 = texture->uTextureHeight;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
434 if ( texture->uTextureHeight < 14 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
435 v10 = 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
436 textute_cell_height = ((v10 - 14) >> 5) + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
437 if ( !areWeLoadingTexture )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
438 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
439 texture->Release();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
440 pIcons_LOD->SyncLoadedFilesCount();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
441 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
442 chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
443 chest_cell_row_pos = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
444 for(int i = 0; i < textute_cell_height; ++i)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
445 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
446 for (int j = 0; j < texture_cell_width; ++j)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
447 pChests[uChestID].pInventoryIndices[put_cell_pos + chest_cell_row_pos+j]=(signed __int16)-(put_cell_pos+1);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
448 chest_cell_row_pos += chest_cell_width;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
449 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
450 pChests[uChestID].pInventoryIndices[put_cell_pos] = item_at_cell + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
451 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
452 // 506128: using guessed type int areWeLoadingTexture;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
453
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
454 //----- (00420284) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
455 void Chest::PlaceItems(signed int uChestID )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
456 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
457 int uChestArea; // edi@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
458 int random_chest_pos; // eax@2
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
459 int test_position; // ebx@11
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
460 char chest_cells_map[144]; // [sp+Ch] [bp-A0h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
461 int chest_item_id; // [sp+9Ch] [bp-10h]@10
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
462 unsigned int items_counter; // [sp+A4h] [bp-8h]@8
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
463
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
464 pRenderer->ClearZBuffer(0, 479);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
465 uChestArea = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
466 memset(chest_cells_map, 0, 144);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
467 //fill cell map at random positions
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
468 for ( items_counter = 0; items_counter < uChestArea; ++items_counter )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
469 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
470 //get random position in chest
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
471 do
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
472 random_chest_pos = (unsigned __int8)rand();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
473 while ( random_chest_pos >= uChestArea );
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
474 //if this pos occupied move to next
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
475 while ( chest_cells_map[random_chest_pos] )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
476 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
477 ++random_chest_pos;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
478 if ( random_chest_pos == uChestArea )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
479 random_chest_pos = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
480 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
481 chest_cells_map[random_chest_pos] = items_counter;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
482 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
483 items_counter = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
484
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
485 for (items_counter = 0; items_counter<uChestArea; ++items_counter)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
486 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
487 chest_item_id = pChests[uChestID].igChestItems[items_counter].uItemID;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
488 if ( chest_item_id )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
489 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
490 test_position = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
491 while ( !Chest::CanPlaceItemAt((unsigned __int8)chest_cells_map[test_position], chest_item_id, uChestID) )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
492 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
493 ++test_position;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
494 if ( test_position >= uChestArea )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
495 break;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
496 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
497 if(test_position<uChestArea)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
498 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
499 Chest::PlaceItemAt((unsigned __int8)chest_cells_map[test_position], items_counter, uChestID);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
500 if ( pChests[uChestID].uFlags & CHEST_OPENED)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
501 pChests[uChestID].igChestItems[items_counter].SetIdentified();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
502 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
503 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
504 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
505 pChests[uChestID].SetInitialized(true);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
506 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
507 // 420284: using guessed type char Dst[144];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
508
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
509 //----- (00448A17) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
510 void Chest::ToggleFlag(signed int uChestID, unsigned __int16 uFlag, unsigned int bToggle)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
511 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
512 if ( uChestID >= 0 && uChestID <= 19 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
513 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
514 if ( bToggle )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
515 pChests[uChestID].uFlags |= uFlag;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
516 else
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
517 pChests[uChestID].uFlags &= ~uFlag;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
518 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
519 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
520
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
521 //----- (00458B03) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
522 void ChestList::ToFile()
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
523 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
524 FILE *v2; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
525 FILE *v3; // edi@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
526
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
527 v2 = fopen("data\\dchest.bin", "wb");
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
528 v3 = v2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
529 if ( !v2 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
530 Error("Unable to save dchest.bin!");
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
531
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
532 fwrite(this, 4, 1, v2);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
533 fwrite(this->pChests, 36, this->uNumChests, v3);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
534 fclose(v3);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
535 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
536
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
537
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
538 //----- (00458B4F) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
539 void ChestList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
540 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
541 uint num_mm6_chests = data_mm6 ? *(int *)data_mm6 : 0,
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
542 num_mm7_chests = data_mm7 ? *(int *)data_mm7 : 0,
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
543 num_mm8_chests = data_mm8 ? *(int *)data_mm8 : 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
544
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
545 uNumChests = num_mm6_chests + num_mm7_chests + num_mm8_chests;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
546 assert(uNumChests);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
547 assert(!num_mm8_chests);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
548
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
549 pChests = (ChestDesc *)malloc(uNumChests * sizeof(ChestDesc));
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
550 memcpy(pChests, (char *)data_mm7 + 4, num_mm7_chests * sizeof(ChestDesc));
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
551 memcpy(pChests + num_mm7_chests, (char *)data_mm6 + 4, num_mm6_chests * sizeof(ChestDesc));
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
552 memcpy(pChests + num_mm6_chests + num_mm7_chests, (char *)data_mm8 + 4, num_mm8_chests * sizeof(ChestDesc));
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
553 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
554
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
555
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
556 //----- (00458B9C) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
557 int ChestList::FromFileTxt(const char *Args)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
558 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
559 //ChestList *v2; // ebx@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
560 __int32 v3; // edi@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
561 FILE *v4; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
562 unsigned int v5; // esi@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
563 const void *v6; // ST18_4@9
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
564 void *v7; // eax@9
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
565 FILE *v8; // ST0C_4@11
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
566 char *i; // eax@11
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
567 char v10; // al@14
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
568 const char *v11; // ST14_4@14
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
569 char v12; // al@14
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
570 const char *v13; // ST10_4@14
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
571 char Buf; // [sp+8h] [bp-2F0h]@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
572 FrameTableTxtLine v16; // [sp+1FCh] [bp-FCh]@4
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
573 FrameTableTxtLine v17; // [sp+278h] [bp-80h]@4
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
574 FILE *File; // [sp+2F4h] [bp-4h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
575 unsigned int Argsa; // [sp+300h] [bp+8h]@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
576
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
577 //v2 = this;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
578 free(this->pChests);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
579 v3 = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
580 this->pChests = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
581 this->uNumChests = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
582 v4 = fopen(Args, "r");
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
583 File = v4;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
584 if ( !v4 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
585 Error("ChestDescriptionList::load - Unable to open file: %s.");
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
586
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
587 v5 = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
588 Argsa = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
589 if ( fgets(&Buf, 490, v4) )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
590 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
591 do
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
592 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
593 *strchr(&Buf, 10) = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
594 memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17));
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
595 if ( v17.uPropCount && *v17.pProperties[0] != 47 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
596 ++Argsa;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
597 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
598 while ( fgets(&Buf, 490, File) );
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
599 v5 = Argsa;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
600 v3 = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
601 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
602 v6 = this->pChests;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
603 this->uNumChests = v5;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
604 v7 = malloc(36 * v5);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
605 this->pChests = (ChestDesc *)v7;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
606 if ( v7 == (void *)v3 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
607 Error("ChestDescriptionList::load - Out of Memory!");
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
608
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
609 memset(v7, v3, 36 * this->uNumChests);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
610 v8 = File;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
611 this->uNumChests = v3;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
612 fseek(v8, v3, v3);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
613 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
614 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
615 *strchr(&Buf, 10) = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
616 memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17));
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
617 if ( v17.uPropCount && *v17.pProperties[0] != 47 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
618 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
619 strcpy(this->pChests[this->uNumChests].pName, v17.pProperties[0]);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
620 v10 = atoi(v17.pProperties[1]);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
621 v11 = v17.pProperties[2];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
622 this->pChests[this->uNumChests].uWidth = v10;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
623 v12 = atoi(v11);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
624 v13 = v17.pProperties[3];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
625 this->pChests[this->uNumChests].uHeight = v12;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
626 this->pChests[this->uNumChests++].uTextureID = atoi(v13);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
627 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
628 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
629 fclose(File);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
630 return 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
631 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
632
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
633 //----- (00420B13) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
634 void __fastcall sub_420B13(int a1, int a2)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
635 { //Give item from chest(rus: Взять предмет из ящика)
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
636 void *v2; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
637 unsigned int v4; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
638 Texture *texture; // ecx@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
639 signed int v6; // eax@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
640 signed int v7; // edi@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
641 signed int v8; // eax@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
642 int v9; // edi@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
643 int v10; // eax@5
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
644 int v11; // esi@8
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
645 unsigned int v12; // ecx@10
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
646 void *v13; // edi@10
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
647 unsigned __int8 v14; // cf@10
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
648 int v15; // edi@10
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
649 int i; // ecx@10
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
650 int v17; // [sp+Ch] [bp-14h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
651 int v18; // [sp+10h] [bp-10h]@3
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
652 int v21; // [sp+1Ch] [bp-4h]@5
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
653 int v22; // [sp+1Ch] [bp-4h]@8
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
654
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
655 v2 = (void *)(5324 * (int)pChestWindow->ptr_1C);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
656 v17 = pChestWidthsByType[pChests[(int)pChestWindow->ptr_1C].uChestBitmapID];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
657 v4 = pIcons_LOD->LoadTexture(pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].GetIconName(), TEXTURE_16BIT_PALETTE);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
658 texture = pIcons_LOD->GetTexture(v4);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
659
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
660 v6 = texture->uTextureWidth;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
661 if ( texture->uTextureWidth < 14 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
662 v6 = 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
663 v7 = v6 - 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
664 v9 = (v7 >> 5) + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
665 v18 = v9;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
666
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
667 v8 = texture->uTextureHeight;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
668 if ( texture->uTextureHeight < 14 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
669 v8 = 14;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
670 v10 = ((v8 - 14) >> 5) + 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
671 v21 = v10;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
672
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
673 if ( !areWeLoadingTexture )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
674 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
675 texture->Release();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
676 pIcons_LOD->SyncLoadedFilesCount();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
677 v10 = v21;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
678 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
679 if ( v10 > 0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
680 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
681 v11 = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
682 for ( v22 = v10; v22; --v22 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
683 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
684 if ( v9 > 0 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
685 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
686 v12 = v9;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
687 v13 = &pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11];
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
688 v14 = v12 & 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
689 v12 >>= 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
690 memset(&pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11], 0, 4 * v12);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
691 v15 = (int)((char *)v13 + 4 * v12);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
692 for ( i = v14; i; --i )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
693 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
694 *(short *)v15 = 0;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
695 v15 += 2;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
696 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
697 v9 = v18;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
698 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
699 v11 += v17;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
700 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
701 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
702 pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].Reset();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
703 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
704 // 506128: using guessed type int areWeLoadingTexture;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
705 //----- (00420E01) --------------------------------------------------------
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
706 void Chest::OnChestLeftClick()
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
707 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
708 int v2; // eax@2
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
709 int v3; // ebx@4
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
710 int v4; // esi@6
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
711 POINT cursor; // [sp+84h] [bp-8h]@2
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
712
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
713 SpriteObject v6; // [sp+Ch] [bp-80h]@1
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
714 if ( pParty->pPickedItem.uItemID )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
715 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
716 if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
717 pMouse->RemoveHoldingItem();
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
718 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
719 else
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
720 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
721 pMouse->GetCursorPos(&cursor);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
722 v2 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
723 if ( v2 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
724 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
725 if ( v2 )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
726 v3 = v2 - 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
727 else
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
728 v3 = -1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
729 v4 = pChests[(int)pGUIWindow_CurrentMenu->par1C].pInventoryIndices[v3] - 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
730 if ( pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].GetItemEquipType() == EQUIP_GOLD )
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
731 {
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
732 pParty->PartyFindsGold(pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].uSpecEnchantmentType, 0);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
733 viewparams->bRedrawGameUI = 1;
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
734 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
735 else
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
736 pParty->SetHoldingItem(&pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4]);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
737 sub_420B13(v4, v3);
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
738 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
739 }
82d5d92a097c for MVS2012
Ritor1
parents:
diff changeset
740 }