annotate Chest.cpp @ 2432:99e7bd7ec0a2

* Fixed OpenAL crash for videos * Fixed double release of movie for Emerald Intro
author a.parshin
date Wed, 23 Jul 2014 21:38:34 +0300
parents f4af3b203f65
children 104fdbea0386
rev   line source
2415
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2343
diff changeset
1 #define _CRTDBG_MAP_ALLOC
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2343
diff changeset
2 #include <stdlib.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2343
diff changeset
3 #include <crtdbg.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2343
diff changeset
4
2253
aff7a7b072b7 adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents: 2215
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
0
Ritor1
parents:
diff changeset
6 #include <stdio.h>
2336
d6887ee81068 header file include cleanup
Grumpy7
parents: 2334
diff changeset
7 #include "mm7_unsorted_subs.h"
d6887ee81068 header file include cleanup
Grumpy7
parents: 2334
diff changeset
8 #include "ErrorHandling.h"
0
Ritor1
parents:
diff changeset
9
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 987
diff changeset
10 #include "BSPModel.h"
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 987
diff changeset
11 #include "Items.h"
0
Ritor1
parents:
diff changeset
12 #include "Chest.h"
Ritor1
parents:
diff changeset
13 #include "FrameTableInc.h"
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
14 #include "LOD.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
15 #include "MapInfo.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
16 #include "Actor.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
17 #include "Outdoor.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
18 #include "DecorationList.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
19 #include "Party.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
20 #include "AudioPlayer.h"
2037
7a9477135943 Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents: 2018
diff changeset
21 #include "OurMath.h"
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
22 #include "Texts.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
23 #include "ObjectList.h"
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
24 #include "GUIWindow.h"
2044
28cb79ae2f6f Time.h rename
Ritor1
parents: 2037
diff changeset
25 #include "Timer.h"
1414
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
26 #include "Overlays.h"
0
Ritor1
parents:
diff changeset
27
Ritor1
parents:
diff changeset
28 #include "mm7_data.h"
848
ceef50611567 * AI fixed (temporary)
zipi
parents: 832
diff changeset
29 #include "MM7.h"
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 987
diff changeset
30 #include "SpriteObject.h"
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
31 #include "Mouse.h"
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
32 #include "Viewport.h"
1828
35c1e4ff6ba7 party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents: 1709
diff changeset
33 #include "Level/Decoration.h"
0
Ritor1
parents:
diff changeset
34
Ritor1
parents:
diff changeset
35 size_t uNumChests; // idb
Ritor1
parents:
diff changeset
36 struct ChestList *pChestList;
1202
0dbf6c4dd029 arrays to std::arrays phase 1
Grumpy7
parents: 1165
diff changeset
37 std::array<Chest, 20> pChests;
0
Ritor1
parents:
diff changeset
38
Ritor1
parents:
diff changeset
39
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
40 const int pChestPixelOffsetX[8] = {42, 18, 18, 42, 42, 42, 18, 42};
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
41 const int pChestPixelOffsetY[8] = {34, 30, 30, 34, 34, 34, 30, 34};
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
42 const int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
43 const int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
0
Ritor1
parents:
diff changeset
44
Ritor1
parents:
diff changeset
45
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
46 //----- (0042041E) --------------------------------------------------------
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
47 bool Chest::Open( signed int uChestID )
822
c232f160e6f3 Named SpriteObject spell-related fields.
Nomad
parents: 706
diff changeset
48 {
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
49 unsigned int pMapID; // eax@8
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
50 int pRandom; // edx@16
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
51 int v6; // eax@16
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
52 ODMFace *pODMFace; // eax@19
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
53 BLVFace *pBLVFace; // eax@20
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
54 int pObjectX; // ebx@21
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
55 int pObjectZ; // edi@21
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
56 double dir_x; // st7@23
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
57 double dir_y; // st6@23
1407
d4f57df4c299 PlayerSpeechID and uSpeakingCharacter
Ritor1
parents: 1406
diff changeset
58 double length_vector; // st7@23
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
59 int pDepth; // ecx@26
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
60 Vec3_int_ v; // ST4C_12@28
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
61 bool flag_shout; // edi@28
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
62 int pSpriteID[4]; // [sp+84h] [bp-40h]@16
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
63 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
64 int pObjectY; // [sp+B0h] [bp-14h]@21
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
65 int sRotX; // [sp+B4h] [bp-10h]@23
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
66 float dir_z; // [sp+BCh] [bp-8h]@23
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
67 int sRotY; // [sp+C0h] [bp-4h]@8
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
68 SpriteObject pSpellObject; // [sp+14h] [bp-B0h]@28
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
69
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
70 assert( uChestID < 20 );
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
71 if ( ( uChestID < 0 ) && ( uChestID >= 20 ) )
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
72 return false;
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1828
diff changeset
73 Chest* chest = &pChests[uChestID];
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
74
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
75 ++pIcons_LOD->uTexturePacksCount;
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
76 if (!pIcons_LOD->uNumPrevLoadedFiles)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
77 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
78
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
79 if (!chest->Initialized())
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
80 Chest::PlaceItems(uChestID);
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
81
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
82 if ( !uActiveCharacter )
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
83 return false;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
84 flag_shout = false;
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
85 pMapID = pMapStats->GetMapInfo(pCurrentMapName);
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
86 if ( chest->Trapped() && pMapID )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
87 {
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
88 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[pMapID].LockX5 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
89 {
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
90 pSpriteID[0] = 811;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
91 pSpriteID[1] = 812;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
92 pSpriteID[2] = 813;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
93 pSpriteID[3] = 814;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
94 pRandom = rand() % 4;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
95 v6 = PID_ID(EvtTargetObj);
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
96 if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration)
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
97 {
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
98 pObjectX = pLevelDecorations[v6].vPosition.x;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
99 pObjectY = pLevelDecorations[v6].vPosition.y;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
100 pObjectZ = pLevelDecorations[v6].vPosition.z + ( pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight / 2 );
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
101 }
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
102 if ( PID_TYPE(EvtTargetObj) == OBJECT_BModel)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
103 {
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
104 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
105 {
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
106 pODMFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F];
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
107 pObjectX = ( pODMFace->pBoundingBox.x1 + pODMFace->pBoundingBox.x2 ) / 2;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
108 pObjectY = ( pODMFace->pBoundingBox.y1 + pODMFace->pBoundingBox.y2 ) / 2;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
109 pObjectZ = ( pODMFace->pBoundingBox.z1 + pODMFace->pBoundingBox.z2 ) / 2;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
110 }
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
111 else//Indoor
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
112 {
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
113 pBLVFace = &pIndoor->pFaces[v6];
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
114 pObjectX = ( pBLVFace->pBounding.x1 + pBLVFace->pBounding.x2 ) / 2;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
115 pObjectY = ( pBLVFace->pBounding.y1 + pBLVFace->pBounding.y2 ) / 2;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
116 pObjectZ = ( pBLVFace->pBounding.z1 + pBLVFace->pBounding.z2 ) / 2;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
117 }
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
118 }
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
119 dir_x = (double)pParty->vPosition.x - (double)pObjectX;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
120 dir_y = (double)pParty->vPosition.y - (double)pObjectY;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
121 dir_z = ( (double)pParty->sEyelevel + (double)pParty->vPosition.z ) - (double)pObjectZ;
1407
d4f57df4c299 PlayerSpeechID and uSpeakingCharacter
Ritor1
parents: 1406
diff changeset
122 length_vector = sqrt( (dir_x * dir_x) + (dir_y * dir_y) + (dir_z * dir_z) );
d4f57df4c299 PlayerSpeechID and uSpeakingCharacter
Ritor1
parents: 1406
diff changeset
123 if ( length_vector <= 1.0 )
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
124 {
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
125 *(float *)&sRotX = 0.0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
126 *(float *)&sRotY = 0.0;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
127 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
128 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
129 {
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
130 sRotY = (signed __int64)sqrt(dir_x * dir_x + dir_y * dir_y);
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
131 sRotX = stru_5C6E00->Atan2((signed __int64)dir_x, (signed __int64)dir_y);
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
132 sRotY = stru_5C6E00->Atan2(dir_y * dir_y, (signed __int64)dir_z);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
133 }
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
134 pDepth = 256;
1407
d4f57df4c299 PlayerSpeechID and uSpeakingCharacter
Ritor1
parents: 1406
diff changeset
135 if ( length_vector < 256.0 )
d4f57df4c299 PlayerSpeechID and uSpeakingCharacter
Ritor1
parents: 1406
diff changeset
136 pDepth = (signed __int64)length_vector / 4;
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
137 v.x = pObjectX;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
138 v.y = pObjectY;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
139 v.z = pObjectZ;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
140 Vec3_int_::Rotate(pDepth, sRotX, sRotY, v, &pOut.x, &pOut.z, &pOut.y);
2331
9551756f46c4 Moving functions out of mm7_6.cpp into appropriate classes as static methods or free functions
Grumpy7
parents: 2268
diff changeset
141 SpriteObject::sub_42F7EB_DropItemAt(pSpriteID[pRandom], pOut.x, pOut.z, pOut.y, 0, 1, 0, 48, 0);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
142
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
143 pSpellObject.stru_24.Reset();
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
144 pSpellObject.spell_skill = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
145 pSpellObject.spell_level = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
146 pSpellObject.spell_id = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
147 pSpellObject.field_54 = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
148 pSpellObject.uType = pSpriteID[pRandom];
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
149 pSpellObject.uObjectDescID = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
150 if ( pObjectList->uNumObjects )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
151 {
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
152 for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i )
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
153 {
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
154 if ( pSpriteID[pRandom] == pObjectList->pObjects[i].uObjectID )
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
155 pSpellObject.uObjectDescID = i;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
156 }
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
157 }
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
158 pSpellObject.vPosition.y = pOut.z;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
159 pSpellObject.vPosition.x = pOut.x;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
160 pSpellObject.vPosition.z = pOut.y;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
161 pSpellObject.uSoundID = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
162 pSpellObject.uAttributes = 48;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
163 pSpellObject.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y);
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
164 pSpellObject.uSpriteFrameID = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
165 pSpellObject.spell_caster_pid = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
166 pSpellObject.spell_target_pid = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
167 pSpellObject.uFacing = 0;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
168 pSpellObject.Create(0, 0, 0, 0);
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
169 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
170 pSpellObject.ExplosionTraps();
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
171 chest->uFlags &= 0xFEu;
2182
e1e4a8a20b5f _46Рђ6РђРЎ_GetActorsInViewport
Ritor1
parents: 2155
diff changeset
172 if ( uActiveCharacter && !_A750D8_player_speech_timer && !OpenedTelekinesis )
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
173 {
2182
e1e4a8a20b5f _46Рђ6РђРЎ_GetActorsInViewport
Ritor1
parents: 2155
diff changeset
174 _A750D8_player_speech_timer = 256i64;
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
175 PlayerSpeechID = SPEECH_5;
1407
d4f57df4c299 PlayerSpeechID and uSpeakingCharacter
Ritor1
parents: 1406
diff changeset
176 uSpeakingCharacter = uActiveCharacter;
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
177 }
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
178 pIcons_LOD->RemoveTexturesPackFromTextureList();
1408
204cce84300b FindSound
Ritor1
parents: 1407
diff changeset
179 OpenedTelekinesis = false;
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
180 return false;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
181 }
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
182 chest->uFlags &= 0xFEu;
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
183 flag_shout = true;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
184 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
185 pAudioPlayer->StopChannels(-1, -1);
426
94546824edad Chests party fixed
Nomad
parents: 421
diff changeset
186 pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0);
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
187 if ( flag_shout == true )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
188 {
1408
204cce84300b FindSound
Ritor1
parents: 1407
diff changeset
189 if ( !OpenedTelekinesis )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
190 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
191 }
1408
204cce84300b FindSound
Ritor1
parents: 1407
diff changeset
192 OpenedTelekinesis = false;
2215
e9625ad08541 fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents: 2182
diff changeset
193 pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Chest, uChestID, 0);
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
194 pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
195 pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
196 pCurrentScreen = SCREEN_CHEST;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
197 pEventTimer->Pause();
1406
d071e0e9ba75 Explosion Traps fix
Ritor1
parents: 1405
diff changeset
198 return true;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
199 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
200
1414
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
201 //----- (0042038D) --------------------------------------------------------
2343
5d263539bbec Moving functions from unsorted_subs.h pt5
Grumpy7
parents: 2336
diff changeset
202 void Chest::ChestUI_WritePointedObjectStatusString()
1414
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
203 {
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
204 int v1; // ecx@2
2010
Ritor1
parents: 1980
diff changeset
205 POINT cursor; // [sp+8h] [bp-8h]@1
1414
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
206
2010
Ritor1
parents: 1980
diff changeset
207 pMouse->GetCursorPos(&cursor);
Ritor1
parents: 1980
diff changeset
208 if ( cursor.y < 350 )
1414
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
209 {
2010
Ritor1
parents: 1980
diff changeset
210 v1 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]];
2018
4c3e8ec07d12 ChestUI_WritePointedObjectStatusString() fix
Ritor1
parents: 2010
diff changeset
211 if ( v1 != 0 && v1 != -65536 )
1414
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
212 {
2018
4c3e8ec07d12 ChestUI_WritePointedObjectStatusString() fix
Ritor1
parents: 2010
diff changeset
213 if ( v1 )
4c3e8ec07d12 ChestUI_WritePointedObjectStatusString() fix
Ritor1
parents: 2010
diff changeset
214 {
4c3e8ec07d12 ChestUI_WritePointedObjectStatusString() fix
Ritor1
parents: 2010
diff changeset
215 ItemGen* item = &pChests[pChestWindow->par1C].igChestItems[pChests[pChestWindow->par1C].pInventoryIndices[(v1 & 0xFFFF) - 1] - 1];
4c3e8ec07d12 ChestUI_WritePointedObjectStatusString() fix
Ritor1
parents: 2010
diff changeset
216 GameUI_SetFooterString(item->GetDisplayName());
4c3e8ec07d12 ChestUI_WritePointedObjectStatusString() fix
Ritor1
parents: 2010
diff changeset
217 }
1414
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
218 }
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
219 }
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
220 }
110eac219e5a ChestUI_WritePointedObjectStatusString
Nomad
parents: 1408
diff changeset
221
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
222 //----- (0042092D) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
223 void Chest::DrawChestUI(signed int uChestID)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
224 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
225
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
226 int chestBitmapId; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
227 unsigned int v5; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
228 int chest_item_index; // ecx@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
229 unsigned int item_texture_id; // eax@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
230 Texture *item_texture; // esi@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
231 signed int itemPixelWidth; // ecx@4
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
232 signed int itemPixelHeght; // edx@4
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
233 // signed int v11; // eax@4
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
234 int v12; // eax@6
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
235 int v13; // eax@6
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
236 unsigned int itemPixelPosX; // ST34_4@8
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
237 int itemPixelPosY; // edi@8
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
238 int *v16; // [sp+Ch] [bp-28h]@1
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
239 // int v17; // [sp+10h] [bp-24h]@4
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
240 int chest_offs_y; // [sp+14h] [bp-20h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
241 signed int chestHeghtCells; // [sp+18h] [bp-1Ch]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
242 int chest_offs_x; // [sp+1Ch] [bp-18h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
243 signed int chestWidthCells; // [sp+20h] [bp-14h]@1
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
244 signed int item_counter; // [sp+30h] [bp-4h]@1
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
245
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
246 v16 = pRenderer->pActiveZBuffer;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
247 pRenderer->ClearZBuffer(0, 479);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
248 chestBitmapId = pChests[uChestID].uChestBitmapID;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
249 chest_offs_x = pChestPixelOffsetX[chestBitmapId];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
250 chest_offs_y = pChestPixelOffsetY[chestBitmapId];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
251 chestWidthCells = pChestWidthsByType[chestBitmapId];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
252 chestHeghtCells = pChestHeightsByType[chestBitmapId];
1394
8ea496564034 Some LightmapBuilder renames.
Nomad
parents: 1297
diff changeset
253 sprintfex(pTmpBuf.data(), "chest%02d", pChestList->pChests[chestBitmapId].uTextureID);
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
254 v5 = pIcons_LOD->LoadTexture(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
255 pRenderer->DrawTextureIndexed(8u, 8u, pIcons_LOD->GetTexture(v5));
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
256
1394
8ea496564034 Some LightmapBuilder renames.
Nomad
parents: 1297
diff changeset
257 for (item_counter = 0; item_counter < chestWidthCells * chestHeghtCells; ++item_counter)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
258 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
259 chest_item_index = pChests[uChestID].pInventoryIndices[item_counter];
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
260 if ( chest_item_index > 0 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
261 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
262 item_texture_id = pIcons_LOD->LoadTexture(
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
263 //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
1709
8251e59fd7c1 ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents: 1679
diff changeset
264 pChests[uChestID].igChestItems[chest_item_index - 1].GetIconName(), TEXTURE_16BIT_PALETTE);
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
265 item_texture = pIcons_LOD->GetTexture(item_texture_id);
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
266 itemPixelWidth = item_texture->uTextureWidth;
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
267 itemPixelHeght = item_texture->uTextureHeight;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
268 if ( itemPixelWidth < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
269 itemPixelWidth = 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
270 v12 = itemPixelWidth - 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
271 v12 = v12 & 0xFFFFFFE0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
272 v13 = v12 + 32;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
273 if ( itemPixelHeght < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
274 itemPixelHeght = 14;
600
db4a23580e6c Chest item view fixed, gold can be taken
Gloval
parents: 592
diff changeset
275 itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((signed int)(v13 - itemPixelWidth)/2);
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
276 itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) +
600
db4a23580e6c Chest item view fixed, gold can be taken
Gloval
parents: 592
diff changeset
277 ((signed int)(((itemPixelHeght - 14) & 0xFFFFFFE0) + 32- item_texture->uTextureHeight ) /2);
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
278 pRenderer->DrawTextureTransparent( itemPixelPosX, itemPixelPosY, item_texture);
1458
934074e7fcc1 ModalWindow
Nomad
parents: 1445
diff changeset
279 ZBuffer_DoFill2(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1);
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
280 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
281 }
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
282 pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId));
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
283 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
284
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
285
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
286 //----- (0041FE71) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
287 bool Chest::CanPlaceItemAt( signed int test_cell_position, int item_id, signed int uChestID )
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
288 {
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
289 // int v3; // eax@1
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
290 unsigned int item_texture_id; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
291 Texture *item_texture; // ecx@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
292 signed int v6; // eax@1
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
293 // signed int v7; // edi@3
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
294 signed int v8; // eax@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
295 int texture_cell_width; // edi@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
296 int texture_cell_height; // ebx@5
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
297 int _row; // esi@9
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
298 int _cell_rows; // edx@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
299 int _column; // ecx@11
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
300 // char *v14; // eax@12
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
301 int chest_cell_heght; // [sp+Ch] [bp-Ch]@1
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
302 // signed int v17; // [sp+10h] [bp-8h]@1
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
303 signed int chest_cell_width; // [sp+14h] [bp-4h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
304
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
305 chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
306 chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
307 item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE);
945
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
308 item_texture = pIcons_LOD->GetTexture(item_texture_id);
0d96349d8c87 Restoring inlined methods
Nomad
parents: 848
diff changeset
309 v6 = item_texture->uTextureWidth;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
310 if ( v6 < 14 )
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
311 v6 = 14;
1110
cf6cd674c398 bitwise operator ambiguity reduced
Grumpy7
parents: 1052
diff changeset
312 texture_cell_width = ((v6 - 14) >> 5) + 1;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
313 v8 = item_texture->uTextureHeight;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
314 if ( v8 < 14 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
315 v8 = 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
316 texture_cell_height = ((v8 - 14) >> 5) + 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
317 if ( !areWeLoadingTexture )
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
318 {
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
319 item_texture->Release();
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
320 pIcons_LOD->SyncLoadedFilesCount();
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
321 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
322 if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) &&
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
323 (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) )
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
324 { //we not put over borders
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
325 _row = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
326 if ( texture_cell_height <= 0 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
327 return true;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
328 _cell_rows = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
329 while ( 1 )
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
330 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
331 _column = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
332 if ( texture_cell_width > 0 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
333 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
334 while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
335 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
336 ++_column;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
337 if ( _column >= texture_cell_width )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
338 break;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
339 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
340 if (pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]!=0)
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
341 return false;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
342 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
343 _cell_rows += chest_cell_width;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
344 ++_row;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
345 if ( _row >= texture_cell_height )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
346 return true;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
347 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
348
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
349 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
350 return false;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
351 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
352 // 506128: using guessed type int areWeLoadingTexture;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
353
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
354 //----- (0041FF64) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
355 int Chest::CountChestItems(signed int uChestID)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
356 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
357 signed int item_count; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
358 int max_items; // edx@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
359 item_count = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
360 max_items = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
361 if ( max_items <= 0 )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
362 item_count = -1;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
363 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
364 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
365 while ( pChests[uChestID].igChestItems[item_count].uItemID )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
366 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
367 ++item_count;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
368 if ( item_count >= max_items )
2264
Ritor1
parents: 2253
diff changeset
369 {
Ritor1
parents: 2253
diff changeset
370 item_count = -1;
Ritor1
parents: 2253
diff changeset
371 break;
Ritor1
parents: 2253
diff changeset
372 }
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
373 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
374 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
375 return item_count;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
376 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
377
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
378 //----- (0041FFA2) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
379 int Chest::PutItemInChest(int position, ItemGen *put_item, signed int uChestID)
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
380 {//(rus: положить предмет в ящик)
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
381 ItemGen *v4; // edi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
382 int v5; // esi@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
383 int result; // eax@11
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
384 unsigned int v7; // eax@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
385 int v8; // edx@12
2264
Ritor1
parents: 2253
diff changeset
386 Texture *texture; // ecx@12
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
387 signed int v10; // eax@12
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
388 signed int v11; // edi@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
389 unsigned int v12; // esi@14
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
390 int v13; // edi@16
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
391 void *v14; // edi@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
392 int v15; // edi@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
393 int i; // ecx@21
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
394 ItemGen *Src; // [sp+Ch] [bp-18h]@1
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
395 signed int item_in_chest_count; // [sp+10h] [bp-14h]@2
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
396 int v19; // [sp+14h] [bp-10h]@1
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
397 int v20; // [sp+18h] [bp-Ch]@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
398 signed int v21; // [sp+1Ch] [bp-8h]@1
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
399 // signed int v22; // [sp+20h] [bp-4h]@3
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
400 int v23; // [sp+20h] [bp-4h]@19
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
401
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
402 v21 = 0;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
403 v4 = put_item;
2264
Ritor1
parents: 2253
diff changeset
404 v5 = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
405 Src = put_item;
2264
Ritor1
parents: 2253
diff changeset
406 v19 = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
407 if ( position == -1 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
408 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
409 item_in_chest_count = CountChestItems(uChestID);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
410 if ( item_in_chest_count == -1 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
411 return 0;
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
412 for( int _i = 0; _i < v5; _i++)
1420
e11c498c0dc6 more label cleaning 3
zipi
parents: 1414
diff changeset
413 {
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
414 if ( Chest::CanPlaceItemAt(_i, v4->uItemID, pChestWindow->par1C) )
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
415 v21 = _i;
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
416 }
2057
b7485a6502f2 AgressorAtackInfo
Ritor1
parents: 2044
diff changeset
417 if ( v21 == v5 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
418 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
419 if ( uActiveCharacter )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
420 pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
421 return 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
422 }
1709
8251e59fd7c1 ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents: 1679
diff changeset
423 v7 = pIcons_LOD->LoadTexture(v4->GetIconName(), TEXTURE_16BIT_PALETTE);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
424 HIWORD(v8) = 0;
2264
Ritor1
parents: 2253
diff changeset
425 texture = pIcons_LOD->GetTexture(v7);
Ritor1
parents: 2253
diff changeset
426 v10 = texture->uTextureWidth;
Ritor1
parents: 2253
diff changeset
427 if ( texture->uTextureWidth < 14 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
428 v10 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
429 v12 = ((v10 - 14) >> 5) + 1;
2264
Ritor1
parents: 2253
diff changeset
430 v11 = texture->uTextureHeight;
Ritor1
parents: 2253
diff changeset
431 if ( texture->uTextureHeight < 14 )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
432 v11 = 14;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
433 v13 = ((v11 - 14) >> 5) + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
434 if ( !areWeLoadingTexture )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
435 {
2264
Ritor1
parents: 2253
diff changeset
436 texture->Release();
1006
e865f349aa41 ui cleanup
Gloval
parents: 987
diff changeset
437 pIcons_LOD->SyncLoadedFilesCount();
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
438 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
439 if ( v13 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
440 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
441 v23 = 0;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
442 v20 = v13;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
443 do
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
444 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
445 if ( (signed int)v12 > 0 )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
446 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
447 v14 = &pChests[uChestID].pInventoryIndices[v21 + v23];
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
448 LOWORD(v8) = -1 - v21;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
449 v8 <<= 16;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
450 LOWORD(v8) = -1 - v21;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
451 memset32(v14, v8, v12 >> 1);
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
452 v15 = (int)((char *)v14 + 4 * (v12 >> 1));
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
453 for ( i = v12 & 1; i; --i )
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
454 {
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
455 *(short *)v15 = v8;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
456 v15 += 2;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
457 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
458 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
459 v23 += v19;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
460 --v20;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
461 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
462 while ( v20 );
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
463 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
464 pChests[uChestID].pInventoryIndices[v21] = item_in_chest_count + 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
465 memcpy(&pChests[uChestID].igChestItems[item_in_chest_count], put_item, sizeof(ItemGen));
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
466 result = v21 + 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
467 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
468 else
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
469 result = 1;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
470 return result;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
471 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
472 // 506128: using guessed type int areWeLoadingTexture;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
473
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
474 //----- (0042013E) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
475 void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, signed int uChestID )
2264
Ritor1
parents: 2253
diff changeset
476 {
Ritor1
parents: 2253
diff changeset
477 int uItemID; // edi@1
Ritor1
parents: 2253
diff changeset
478 int v6; // edx@4
Ritor1
parents: 2253
diff changeset
479 unsigned int v7; // eax@5
Ritor1
parents: 2253
diff changeset
480 Texture *texture; // ecx@5
Ritor1
parents: 2253
diff changeset
481 signed int v9; // eax@5
Ritor1
parents: 2253
diff changeset
482 signed int v10; // edi@7
Ritor1
parents: 2253
diff changeset
483 unsigned int texture_cell_width; // ebx@7
Ritor1
parents: 2253
diff changeset
484 int textute_cell_height; // edi@9
Ritor1
parents: 2253
diff changeset
485 int chest_cell_row_pos; // edx@12
Ritor1
parents: 2253
diff changeset
486 int chest_cell_width; // [sp+10h] [bp-Ch]@11
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
487
2264
Ritor1
parents: 2253
diff changeset
488 uItemID = pChests[ uChestID].igChestItems[item_at_cell].uItemID;
Ritor1
parents: 2253
diff changeset
489 pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[item_at_cell]);
Ritor1
parents: 2253
diff changeset
490 if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[item_at_cell].uNumCharges)
Ritor1
parents: 2253
diff changeset
491 {
Ritor1
parents: 2253
diff changeset
492 v6 = rand() % 21 + 10;
Ritor1
parents: 2253
diff changeset
493 pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6;
Ritor1
parents: 2253
diff changeset
494 pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6;
Ritor1
parents: 2253
diff changeset
495 }
Ritor1
parents: 2253
diff changeset
496 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
Ritor1
parents: 2253
diff changeset
497 texture = pIcons_LOD->GetTexture(v7);
Ritor1
parents: 2253
diff changeset
498 v9 = texture->uTextureWidth;
Ritor1
parents: 2253
diff changeset
499 if ( texture->uTextureWidth < 14 )
Ritor1
parents: 2253
diff changeset
500 v9 = 14;
Ritor1
parents: 2253
diff changeset
501 texture_cell_width = ((v9 - 14) >> 5) + 1;
Ritor1
parents: 2253
diff changeset
502 v10 = texture->uTextureHeight;
Ritor1
parents: 2253
diff changeset
503 if ( texture->uTextureHeight < 14 )
Ritor1
parents: 2253
diff changeset
504 v10 = 14;
Ritor1
parents: 2253
diff changeset
505 textute_cell_height = ((v10 - 14) >> 5) + 1;
Ritor1
parents: 2253
diff changeset
506 if ( !areWeLoadingTexture )
Ritor1
parents: 2253
diff changeset
507 {
Ritor1
parents: 2253
diff changeset
508 texture->Release();
Ritor1
parents: 2253
diff changeset
509 pIcons_LOD->SyncLoadedFilesCount();
Ritor1
parents: 2253
diff changeset
510 }
Ritor1
parents: 2253
diff changeset
511 chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID];
Ritor1
parents: 2253
diff changeset
512 chest_cell_row_pos = 0;
Ritor1
parents: 2253
diff changeset
513 for(int i = 0; i < textute_cell_height; ++i)
Ritor1
parents: 2253
diff changeset
514 {
Ritor1
parents: 2253
diff changeset
515 for (int j = 0; j < texture_cell_width; ++j)
Ritor1
parents: 2253
diff changeset
516 pChests[uChestID].pInventoryIndices[put_cell_pos + chest_cell_row_pos+j]=(signed __int16)-(put_cell_pos+1);
Ritor1
parents: 2253
diff changeset
517 chest_cell_row_pos += chest_cell_width;
Ritor1
parents: 2253
diff changeset
518 }
Ritor1
parents: 2253
diff changeset
519 pChests[uChestID].pInventoryIndices[put_cell_pos] = item_at_cell + 1;
Ritor1
parents: 2253
diff changeset
520 }
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
521 // 506128: using guessed type int areWeLoadingTexture;
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
522
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
523 //----- (00420284) --------------------------------------------------------
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
524 void Chest::PlaceItems(signed int uChestID )
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
525 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
526 int uChestArea; // edi@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
527 int random_chest_pos; // eax@2
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
528 int test_position; // ebx@11
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
529 char chest_cells_map[144]; // [sp+Ch] [bp-A0h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
530 int chest_item_id; // [sp+9Ch] [bp-10h]@10
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
531 unsigned int items_counter; // [sp+A4h] [bp-8h]@8
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
532
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
533 pRenderer->ClearZBuffer(0, 479);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
534 uChestArea = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
535 memset(chest_cells_map, 0, 144);
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
536 //fill cell map at random positions
608
Ritor1
parents: 544
diff changeset
537 for ( items_counter = 0; items_counter < uChestArea; ++items_counter )
Ritor1
parents: 544
diff changeset
538 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
539 //get random position in chest
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
540 do
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
541 random_chest_pos = (unsigned __int8)rand();
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
542 while ( random_chest_pos >= uChestArea );
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
543 //if this pos occupied move to next
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
544 while ( chest_cells_map[random_chest_pos] )
608
Ritor1
parents: 544
diff changeset
545 {
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
546 ++random_chest_pos;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
547 if ( random_chest_pos == uChestArea )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
548 random_chest_pos = 0;
608
Ritor1
parents: 544
diff changeset
549 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
550 chest_cells_map[random_chest_pos] = items_counter;
608
Ritor1
parents: 544
diff changeset
551 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
552 items_counter = 0;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
553
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
554 for (items_counter = 0; items_counter<uChestArea; ++items_counter)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
555 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
556 chest_item_id = pChests[uChestID].igChestItems[items_counter].uItemID;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
557 if ( chest_item_id )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
558 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
559 test_position = 0;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
560 while ( !Chest::CanPlaceItemAt((unsigned __int8)chest_cells_map[test_position], chest_item_id, uChestID) )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
561 {
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
562 ++test_position;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
563 if ( test_position >= uChestArea )
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
564 break;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
565 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
566 if(test_position<uChestArea)
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
567 {
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
568 Chest::PlaceItemAt((unsigned __int8)chest_cells_map[test_position], items_counter, uChestID);
592
96f48cfdd657 some flags
Nomad
parents: 544
diff changeset
569 if ( pChests[uChestID].uFlags & CHEST_OPENED)
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
570 pChests[uChestID].igChestItems[items_counter].SetIdentified();
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
571 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
572 }
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
573 }
528
b1598f110b07 Chest working
Gloval
parents: 526
diff changeset
574 pChests[uChestID].SetInitialized(true);
421
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
575 }
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
576 // 420284: using guessed type char Dst[144];
80a5aab68b67 Chest subs moved to Chest.cpp
Nomad
parents: 0
diff changeset
577
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
578 //----- (00448A17) --------------------------------------------------------
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
579 void Chest::ToggleFlag(signed int uChestID, unsigned __int16 uFlag, unsigned int bToggle)
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
580 {
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
581 if ( uChestID >= 0 && uChestID <= 19 )
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
582 {
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
583 if ( bToggle )
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
584 pChests[uChestID].uFlags |= uFlag;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
585 else
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
586 pChests[uChestID].uFlags &= ~uFlag;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
587 }
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
588 }
706
d6236f6a9882 Rough function rearranging to new files
Gloval
parents: 704
diff changeset
589
0
Ritor1
parents:
diff changeset
590 //----- (00458B03) --------------------------------------------------------
Ritor1
parents:
diff changeset
591 void ChestList::ToFile()
Ritor1
parents:
diff changeset
592 {
Ritor1
parents:
diff changeset
593 FILE *v2; // eax@1
Ritor1
parents:
diff changeset
594 FILE *v3; // edi@1
Ritor1
parents:
diff changeset
595
Ritor1
parents:
diff changeset
596 v2 = fopen("data\\dchest.bin", "wb");
Ritor1
parents:
diff changeset
597 v3 = v2;
Ritor1
parents:
diff changeset
598 if ( !v2 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
599 Error("Unable to save dchest.bin!");
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
600
2264
Ritor1
parents: 2253
diff changeset
601 fwrite(this, 4, 1, v2);
Ritor1
parents: 2253
diff changeset
602 fwrite(this->pChests, 36, this->uNumChests, v3);
0
Ritor1
parents:
diff changeset
603 fclose(v3);
Ritor1
parents:
diff changeset
604 }
Ritor1
parents:
diff changeset
605
Ritor1
parents:
diff changeset
606
Ritor1
parents:
diff changeset
607 //----- (00458B4F) --------------------------------------------------------
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
608 void ChestList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
0
Ritor1
parents:
diff changeset
609 {
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
610 uint num_mm6_chests = data_mm6 ? *(int *)data_mm6 : 0,
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
611 num_mm7_chests = data_mm7 ? *(int *)data_mm7 : 0,
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
612 num_mm8_chests = data_mm8 ? *(int *)data_mm8 : 0;
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
613
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
614 uNumChests = num_mm6_chests + num_mm7_chests + num_mm8_chests;
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
615 assert(uNumChests);
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
616 assert(!num_mm8_chests);
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
617
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
618 pChests = (ChestDesc *)malloc(uNumChests * sizeof(ChestDesc));
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
619 memcpy(pChests, (char *)data_mm7 + 4, num_mm7_chests * sizeof(ChestDesc));
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
620 memcpy(pChests + num_mm7_chests, (char *)data_mm6 + 4, num_mm6_chests * sizeof(ChestDesc));
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1458
diff changeset
621 memcpy(pChests + num_mm6_chests + num_mm7_chests, (char *)data_mm8 + 4, num_mm8_chests * sizeof(ChestDesc));
0
Ritor1
parents:
diff changeset
622 }
Ritor1
parents:
diff changeset
623
Ritor1
parents:
diff changeset
624
Ritor1
parents:
diff changeset
625 //----- (00458B9C) --------------------------------------------------------
Ritor1
parents:
diff changeset
626 int ChestList::FromFileTxt(const char *Args)
Ritor1
parents:
diff changeset
627 {
2264
Ritor1
parents: 2253
diff changeset
628 //ChestList *v2; // ebx@1
0
Ritor1
parents:
diff changeset
629 __int32 v3; // edi@1
Ritor1
parents:
diff changeset
630 FILE *v4; // eax@1
Ritor1
parents:
diff changeset
631 unsigned int v5; // esi@3
Ritor1
parents:
diff changeset
632 const void *v6; // ST18_4@9
Ritor1
parents:
diff changeset
633 void *v7; // eax@9
Ritor1
parents:
diff changeset
634 FILE *v8; // ST0C_4@11
Ritor1
parents:
diff changeset
635 char *i; // eax@11
Ritor1
parents:
diff changeset
636 char v10; // al@14
Ritor1
parents:
diff changeset
637 const char *v11; // ST14_4@14
Ritor1
parents:
diff changeset
638 char v12; // al@14
Ritor1
parents:
diff changeset
639 const char *v13; // ST10_4@14
Ritor1
parents:
diff changeset
640 char Buf; // [sp+8h] [bp-2F0h]@3
Ritor1
parents:
diff changeset
641 FrameTableTxtLine v16; // [sp+1FCh] [bp-FCh]@4
Ritor1
parents:
diff changeset
642 FrameTableTxtLine v17; // [sp+278h] [bp-80h]@4
Ritor1
parents:
diff changeset
643 FILE *File; // [sp+2F4h] [bp-4h]@1
Ritor1
parents:
diff changeset
644 unsigned int Argsa; // [sp+300h] [bp+8h]@3
Ritor1
parents:
diff changeset
645
2264
Ritor1
parents: 2253
diff changeset
646 //v2 = this;
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
647 free(this->pChests);
0
Ritor1
parents:
diff changeset
648 v3 = 0;
2264
Ritor1
parents: 2253
diff changeset
649 this->pChests = 0;
Ritor1
parents: 2253
diff changeset
650 this->uNumChests = 0;
0
Ritor1
parents:
diff changeset
651 v4 = fopen(Args, "r");
Ritor1
parents:
diff changeset
652 File = v4;
Ritor1
parents:
diff changeset
653 if ( !v4 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
654 Error("ChestDescriptionList::load - Unable to open file: %s.");
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
655
0
Ritor1
parents:
diff changeset
656 v5 = 0;
Ritor1
parents:
diff changeset
657 Argsa = 0;
Ritor1
parents:
diff changeset
658 if ( fgets(&Buf, 490, v4) )
Ritor1
parents:
diff changeset
659 {
Ritor1
parents:
diff changeset
660 do
Ritor1
parents:
diff changeset
661 {
Ritor1
parents:
diff changeset
662 *strchr(&Buf, 10) = 0;
703
a9c1fb7483c2 monster parser almost complete.
Gloval
parents: 701
diff changeset
663 memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17));
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
664 if ( v17.uPropCount && *v17.pProperties[0] != 47 )
0
Ritor1
parents:
diff changeset
665 ++Argsa;
Ritor1
parents:
diff changeset
666 }
Ritor1
parents:
diff changeset
667 while ( fgets(&Buf, 490, File) );
Ritor1
parents:
diff changeset
668 v5 = Argsa;
Ritor1
parents:
diff changeset
669 v3 = 0;
Ritor1
parents:
diff changeset
670 }
2264
Ritor1
parents: 2253
diff changeset
671 v6 = this->pChests;
Ritor1
parents: 2253
diff changeset
672 this->uNumChests = v5;
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
673 v7 = malloc(36 * v5);
2264
Ritor1
parents: 2253
diff changeset
674 this->pChests = (ChestDesc *)v7;
0
Ritor1
parents:
diff changeset
675 if ( v7 == (void *)v3 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
676 Error("ChestDescriptionList::load - Out of Memory!");
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
677
2264
Ritor1
parents: 2253
diff changeset
678 memset(v7, v3, 36 * this->uNumChests);
0
Ritor1
parents:
diff changeset
679 v8 = File;
2264
Ritor1
parents: 2253
diff changeset
680 this->uNumChests = v3;
0
Ritor1
parents:
diff changeset
681 fseek(v8, v3, v3);
Ritor1
parents:
diff changeset
682 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
Ritor1
parents:
diff changeset
683 {
Ritor1
parents:
diff changeset
684 *strchr(&Buf, 10) = 0;
703
a9c1fb7483c2 monster parser almost complete.
Gloval
parents: 701
diff changeset
685 memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17));
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
686 if ( v17.uPropCount && *v17.pProperties[0] != 47 )
0
Ritor1
parents:
diff changeset
687 {
2264
Ritor1
parents: 2253
diff changeset
688 strcpy(this->pChests[this->uNumChests].pName, v17.pProperties[0]);
0
Ritor1
parents:
diff changeset
689 v10 = atoi(v17.pProperties[1]);
Ritor1
parents:
diff changeset
690 v11 = v17.pProperties[2];
2264
Ritor1
parents: 2253
diff changeset
691 this->pChests[this->uNumChests].uWidth = v10;
0
Ritor1
parents:
diff changeset
692 v12 = atoi(v11);
Ritor1
parents:
diff changeset
693 v13 = v17.pProperties[3];
2264
Ritor1
parents: 2253
diff changeset
694 this->pChests[this->uNumChests].uHeight = v12;
Ritor1
parents: 2253
diff changeset
695 this->pChests[this->uNumChests++].uTextureID = atoi(v13);
0
Ritor1
parents:
diff changeset
696 }
Ritor1
parents:
diff changeset
697 }
Ritor1
parents:
diff changeset
698 fclose(File);
Ritor1
parents:
diff changeset
699 return 1;
Ritor1
parents:
diff changeset
700 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
701
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
702 //----- (00420B13) --------------------------------------------------------
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
703 void __fastcall sub_420B13(int a1, int a2)
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
704 { //Give item from chest(rus: Взять предмет из ящика)
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
705 void *v2; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
706 unsigned int v4; // eax@1
2264
Ritor1
parents: 2253
diff changeset
707 Texture *texture; // ecx@1
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
708 signed int v6; // eax@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
709 signed int v7; // edi@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
710 signed int v8; // eax@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
711 int v9; // edi@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
712 int v10; // eax@5
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
713 int v11; // esi@8
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
714 unsigned int v12; // ecx@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
715 void *v13; // edi@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
716 unsigned __int8 v14; // cf@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
717 int v15; // edi@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
718 int i; // ecx@10
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
719 int v17; // [sp+Ch] [bp-14h]@1
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
720 int v18; // [sp+10h] [bp-10h]@3
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
721 int v21; // [sp+1Ch] [bp-4h]@5
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
722 int v22; // [sp+1Ch] [bp-4h]@8
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
723
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
724 v2 = (void *)(5324 * (int)pChestWindow->ptr_1C);
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
725 v17 = pChestWidthsByType[pChests[(int)pChestWindow->ptr_1C].uChestBitmapID];
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
726 v4 = pIcons_LOD->LoadTexture(pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].GetIconName(), TEXTURE_16BIT_PALETTE);
2264
Ritor1
parents: 2253
diff changeset
727 texture = pIcons_LOD->GetTexture(v4);
Ritor1
parents: 2253
diff changeset
728
Ritor1
parents: 2253
diff changeset
729 v6 = texture->uTextureWidth;
Ritor1
parents: 2253
diff changeset
730 if ( texture->uTextureWidth < 14 )
Ritor1
parents: 2253
diff changeset
731 v6 = 14;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
732 v7 = v6 - 14;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
733 v9 = (v7 >> 5) + 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
734 v18 = v9;
2264
Ritor1
parents: 2253
diff changeset
735
Ritor1
parents: 2253
diff changeset
736 v8 = texture->uTextureHeight;
Ritor1
parents: 2253
diff changeset
737 if ( texture->uTextureHeight < 14 )
Ritor1
parents: 2253
diff changeset
738 v8 = 14;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
739 v10 = ((v8 - 14) >> 5) + 1;
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
740 v21 = v10;
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
741
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
742 if ( !areWeLoadingTexture )
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
743 {
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
744 texture->Release();
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
745 pIcons_LOD->SyncLoadedFilesCount();
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
746 v10 = v21;
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
747 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
748 if ( v10 > 0 )
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
749 {
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
750 v11 = 0;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
751 for ( v22 = v10; v22; --v22 )
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
752 {
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
753 if ( v9 > 0 )
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
754 {
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
755 v12 = v9;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
756 v13 = &pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11];
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
757 v14 = v12 & 1;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
758 v12 >>= 1;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
759 memset(&pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11], 0, 4 * v12);
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
760 v15 = (int)((char *)v13 + 4 * v12);
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
761 for ( i = v14; i; --i )
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
762 {
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
763 *(short *)v15 = 0;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
764 v15 += 2;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
765 }
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
766 v9 = v18;
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
767 }
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
768 v11 += v17;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
769 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
770 }
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
771 pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].Reset();
702
efde64b3e147 sub_4BDAAF clean
zipi
parents: 701
diff changeset
772 }
526
214d9d47cf1f Chest working, but items are not laid correctly
Gloval
parents: 515
diff changeset
773 // 506128: using guessed type int areWeLoadingTexture;
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
774 //----- (00420E01) --------------------------------------------------------
2343
5d263539bbec Moving functions from unsorted_subs.h pt5
Grumpy7
parents: 2336
diff changeset
775 void Chest::OnChestLeftClick()
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
776 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
777 int v2; // eax@2
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
778 int v3; // ebx@4
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
779 int v4; // esi@6
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
780 POINT cursor; // [sp+84h] [bp-8h]@2
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
781
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
782 SpriteObject v6; // [sp+Ch] [bp-80h]@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
783 if ( pParty->pPickedItem.uItemID )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
784 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
785 if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
786 pMouse->RemoveHoldingItem();
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
787 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
788 else
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
789 {
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
790 pMouse->GetCursorPos(&cursor);
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
791 v2 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF;
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
792 if ( v2 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
793 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
794 if ( v2 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
795 v3 = v2 - 1;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
796 else
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
797 v3 = -1;
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
798 v4 = pChests[(int)pGUIWindow_CurrentMenu->par1C].pInventoryIndices[v3] - 1;
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
799 if ( pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].GetItemEquipType() == EQUIP_GOLD )
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
800 {
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
801 pParty->PartyFindsGold(pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].uSpecEnchantmentType, 0);
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
802 viewparams->bRedrawGameUI = 1;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
803 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
804 else
2268
fd788d2e9585 EventProcessor cleaned and ODM_NearClip fix
Ritor1
parents: 2264
diff changeset
805 pParty->SetHoldingItem(&pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4]);
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
806 sub_420B13(v4, v3);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
807 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
808 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1205
diff changeset
809 }