annotate Engine/Objects/Chest.cpp @ 2543:b6140dfeac27

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