Mercurial > mm7
annotate Viewport.cpp @ 2430:cb66a1082fcf
* ITrack, IMovie now properly propogate destructors
* VideoPlayer correctly deallocates memory after playing a movie
author | a.parshin |
---|---|
date | Wed, 23 Jul 2014 20:28:28 +0300 |
parents | f4af3b203f65 |
children | 104fdbea0386 |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2242
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
692 | 6 #include "Viewport.h" |
7 | |
2336 | 8 #include "mm7_unsorted_subs.h" |
692 | 9 #include "Party.h" |
10 #include "Indoor.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
1987
diff
changeset
|
11 #include "OurMath.h" |
692 | 12 #include "mm7_data.h" |
1297 | 13 #include "Actor.h" |
14 #include "Outdoor.h" | |
15 #include "Events.h" | |
16 #include "BSPModel.h" | |
17 #include "Mouse.h" | |
18 #include "SpriteObject.h" | |
19 #include "ObjectList.h" | |
20 #include "DecorationList.h" | |
21 #include "texts.h" | |
22 #include "Game.h" | |
23 #include "Vis.h" | |
24 #include "LOD.h" | |
25 #include "GUIWindow.h" | |
26 #include "TurnEngine.h" | |
27 #include "stru123.h" | |
28 #include "MM7.h" | |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1736
diff
changeset
|
29 #include "Level/Decoration.h" |
692 | 30 |
31 | |
32 //----- (004C0262) -------------------------------------------------------- | |
33 void Viewport::SetScreen( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y ) | |
34 { | |
35 unsigned int tl_x; // edx@1 | |
36 unsigned int br_x; // esi@1 | |
37 unsigned int tl_y; // edi@3 | |
38 unsigned int br_y; // eax@3 | |
39 | |
40 tl_x = sTL_X; | |
41 br_x = sBR_X; | |
42 if ( sTL_X > sBR_X ) | |
2196 | 43 { |
44 br_x = sTL_X; // swap x's | |
45 tl_x = sBR_X; | |
46 } | |
692 | 47 tl_y = sTL_Y; |
48 br_y = sBR_Y; | |
711 | 49 if ( sTL_Y > sBR_Y ) |
2196 | 50 { |
51 br_y = sTL_Y; // swap y's | |
52 tl_y = sBR_Y; | |
53 } | |
692 | 54 this->uScreen_TL_X = tl_x; |
55 this->uScreen_TL_Y = tl_y; | |
56 this->uScreen_BR_X = br_x; | |
57 this->uScreen_BR_Y = br_y; | |
58 this->uScreenWidth = br_x - tl_x + 1; | |
693 | 59 this->uScreenHeight = br_y - tl_y + 1; |
60 this->uScreenCenterX = (signed int)(br_x + tl_x) /2; | |
2069 | 61 //if ( pRenderer->pRenderD3D == 0 ) |
62 // this->uScreenCenterY = this->uScreen_BR_Y - fixpoint_mul(field_30, uScreenHeight); | |
63 //else | |
1987 | 64 this->uScreenCenterY = (br_y + tl_y)/2; |
692 | 65 SetViewport(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y); |
66 } | |
67 | |
68 //----- (004C02F8) -------------------------------------------------------- | |
2151 | 69 void Viewport::SetFOV(int field_of_view) |
1583 | 70 { |
2151 | 71 this->field_of_view = field_of_view; |
72 SetScreen(uScreen_TL_X, uScreen_TL_Y, uScreen_BR_X, uScreen_BR_Y); | |
1583 | 73 } |
692 | 74 |
75 //----- (004C0312) -------------------------------------------------------- | |
693 | 76 void Viewport::SetViewport( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y ) |
692 | 77 { |
693 | 78 signed int tl_x; // ebx@1 |
79 signed int tl_y; // edi@3 | |
80 signed int br_x; // edx@5 | |
81 signed int br_y; // eax@7 | |
692 | 82 |
693 | 83 tl_x = sTL_X; |
84 if ( sTL_X < this->uScreen_TL_X ) | |
85 tl_x = this->uScreen_TL_X; | |
86 tl_y = sTL_Y; | |
87 if ( sTL_Y < this->uScreen_TL_Y ) | |
88 tl_y = this->uScreen_TL_Y; | |
89 br_x = sBR_X; | |
90 if ( sBR_X > this->uScreen_BR_X ) | |
91 br_x = this->uScreen_BR_X; | |
92 br_y = sBR_Y; | |
93 if ( sBR_Y > this->uScreen_BR_Y ) | |
94 br_y = this->uScreen_BR_Y; | |
95 this->uViewportTL_Y = tl_y; | |
96 this->uViewportTL_X = tl_x; | |
97 this->uViewportBR_X = br_x; | |
98 this->uViewportBR_Y = br_y; | |
692 | 99 } |
100 | |
101 //----- (00443219) -------------------------------------------------------- | |
102 void ViewingParams::_443219() | |
1545 | 103 { |
104 this->sViewCenterY += 512; | |
105 | |
106 AdjustPosition(); | |
107 } | |
692 | 108 |
109 //----- (00443225) -------------------------------------------------------- | |
110 void ViewingParams::_443225() | |
1545 | 111 { |
112 this->sViewCenterX -= 512; | |
113 | |
114 AdjustPosition(); | |
115 } | |
692 | 116 |
117 //----- (00443231) -------------------------------------------------------- | |
118 void ViewingParams::_443231() | |
1545 | 119 { |
120 this->sViewCenterY -= 512; | |
121 | |
122 AdjustPosition(); | |
123 } | |
692 | 124 |
125 //----- (0044323D) -------------------------------------------------------- | |
126 void ViewingParams::_44323D() | |
1545 | 127 { |
128 this->sViewCenterX += 512; | |
129 | |
130 AdjustPosition(); | |
131 } | |
692 | 132 |
133 //----- (00443249) -------------------------------------------------------- | |
693 | 134 void ViewingParams::CenterOnParty() |
1545 | 135 { |
2207 | 136 this->uMapBookMapZoom = fixpoint_mul(0x8000, this->uMapBookMapZoom); |
1720 | 137 if (this->uMapBookMapZoom < 384) |
138 this->uMapBookMapZoom = 384; | |
692 | 139 |
1545 | 140 this->sViewCenterX = pParty->vPosition.x; |
141 this->sViewCenterY = pParty->vPosition.y; | |
142 | |
143 AdjustPosition(); | |
144 } | |
692 | 145 |
146 //----- (00443291) -------------------------------------------------------- | |
693 | 147 void ViewingParams::CenterOnParty2() |
1545 | 148 { |
692 | 149 int v2; // eax@1 |
150 | |
1545 | 151 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
152 v2 = 1536; | |
153 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
154 v2 = 3072; | |
155 else assert(false); | |
156 | |
1720 | 157 this->uMapBookMapZoom *= 2; |
158 if (this->uMapBookMapZoom > v2 ) | |
159 this->uMapBookMapZoom = v2; | |
1545 | 160 |
693 | 161 this->sViewCenterX = pParty->vPosition.x; |
162 this->sViewCenterY = pParty->vPosition.y; | |
163 AdjustPosition(); | |
1545 | 164 } |
692 | 165 |
166 //----- (004432E7) -------------------------------------------------------- | |
693 | 167 void ViewingParams::AdjustPosition() |
1545 | 168 { |
692 | 169 ViewingParams *v1; // esi@1 |
170 int v2; // ebx@1 | |
171 signed int v3; // edx@1 | |
172 int v4; // ecx@1 | |
173 int v5; // edi@3 | |
174 int v6; // eax@3 | |
175 int v7; // eax@5 | |
693 | 176 |
692 | 177 |
178 v1 = this; | |
711 | 179 v2 = this->indoor_center_y; |
1720 | 180 v3 = 88 >> (this->uMapBookMapZoom / 384); |
692 | 181 v4 = (44 - v3) << 9; |
693 | 182 if ( v1->sViewCenterY > v2 + v4 ) |
183 v1->sViewCenterY = v2 + v4; | |
692 | 184 |
711 | 185 v5 = v1->indoor_center_x; |
692 | 186 v6 = (v3 - 44) << 9; |
693 | 187 if ( v1->sViewCenterX < v5 + v6 ) |
188 v1->sViewCenterX = v5 + v6; | |
692 | 189 |
190 v7 = v2 + v6; | |
693 | 191 if ( v1->sViewCenterY < v7 ) |
192 v1->sViewCenterY = v7; | |
692 | 193 |
693 | 194 if ( v1->sViewCenterX > v5 + v4 ) |
195 v1->sViewCenterX = v5 + v4; | |
692 | 196 } |
197 | |
198 //----- (00443343) -------------------------------------------------------- | |
199 void ViewingParams::InitGrayPalette() | |
200 { | |
201 for (unsigned short i=0; i<256; ++i) | |
2069 | 202 pPalette[i]=Color16(i, i, i); |
692 | 203 } |
204 | |
205 //----- (00443365) -------------------------------------------------------- | |
206 void ViewingParams::_443365() | |
1222 | 207 { |
208 Vec3_short_ *v3; // eax@4 | |
209 Vec3_short_ *v6; // eax@12 | |
210 int minimum_y; // [sp+10h] [bp-10h]@2 | |
211 int maximum_y; // [sp+14h] [bp-Ch]@2 | |
212 int minimum_x; // [sp+18h] [bp-8h]@2 | |
213 int maximum_x; // [sp+1Ch] [bp-4h]@2 | |
692 | 214 |
1222 | 215 InitGrayPalette(); |
216 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
217 { | |
218 minimum_x = 0x40000000; | |
219 minimum_y = 0x40000000; | |
711 | 220 |
1222 | 221 maximum_x = -0x40000000; |
222 maximum_y = -0x40000000; | |
223 for (int i=0; i<pIndoor->pMapOutlines->uNumOutlines; ++i) | |
224 { | |
225 v3 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace1ID]; | |
711 | 226 |
1222 | 227 if ( v3->x < minimum_x ) |
228 minimum_x = v3->x; | |
229 if ( v3->x > maximum_x ) | |
230 maximum_x = v3->x; | |
231 if ( v3->y < minimum_y ) | |
232 minimum_y = v3->x; | |
233 if ( v3->y > maximum_y ) | |
234 maximum_y = v3->x; | |
711 | 235 |
1222 | 236 v6 = &pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uFace2ID]; |
237 | |
238 if ( v6->x < minimum_x ) | |
239 minimum_x = v3->x; | |
240 if ( v6->x > maximum_x ) | |
241 maximum_x = v3->x; | |
711 | 242 |
1222 | 243 if ( v6->y < minimum_y ) |
244 minimum_y = v3->y; | |
245 if ( v6->y > maximum_y ) | |
246 maximum_y = v3->y; | |
247 } | |
711 | 248 |
1222 | 249 uMinimapZoom = 1024; |
250 indoor_center_x = (signed int)(minimum_x + maximum_x) / 2; | |
251 field_28 = 10; | |
252 indoor_center_y = (signed int)(minimum_y + maximum_y) / 2; | |
253 } | |
254 else | |
255 { | |
256 indoor_center_x = 0; | |
257 indoor_center_y = 0; | |
258 uMinimapZoom = _576E2C_current_minimap_zoom; | |
259 field_28 = dword_576E28; | |
260 } | |
1720 | 261 uMapBookMapZoom = 384; |
1297 | 262 } |
263 //----- (0042213C) -------------------------------------------------------- | |
264 void OnGameViewportClick() | |
265 { | |
266 signed int v0; // ebx@2 | |
267 POINT *v1; // esi@3 | |
268 signed int v6; // eax@14 | |
269 char *v7; // esi@15 | |
270 int v9; // eax@19 | |
1321 | 271 unsigned int pTextureID; // eax@19 |
272 int pEventID; // ecx@21 | |
1297 | 273 int v15; // ecx@29 |
2334 | 274 // signed int v16; // edx@30 |
275 // int v18; // ebx@47 | |
276 // signed int v21; // eax@58 | |
1297 | 277 SpriteObject a1; // [sp+Ch] [bp-80h]@1 |
278 POINT a2; // [sp+84h] [bp-8h]@3 | |
279 | |
1321 | 280 int clickable_distance = 512; |
281 | |
1297 | 282 v1 = pMouse->GetCursorPos(&a2); |
2154 | 283 //if ( pRenderer->pRenderD3D ) |
1297 | 284 v0 = pGame->pVisInstance->get_picked_object_zbuf_val(); |
2154 | 285 //else |
286 // v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]]; | |
1297 | 287 |
288 if ( PID_TYPE(v0) == OBJECT_Item) | |
289 { | |
2203 | 290 int item_id = PID_ID(v0); |
291 //v21 = (signed int)(unsigned __int16)v0 >> 3; | |
292 if ( !(pObjectList->pObjects[pSpriteObjects[item_id].uObjectDescID].uFlags & 0x10) && item_id < 1000 && pSpriteObjects[item_id].uObjectDescID | |
1297 | 293 && (unsigned int)v0 < 0x2000000 ) |
294 { | |
2203 | 295 if ( pSpriteObjects[item_id].stru_24.GetItemEquipType() == 18 ) |
1297 | 296 { |
2203 | 297 pParty->PartyFindsGold(pSpriteObjects[item_id].stru_24.uSpecEnchantmentType, 0); |
1297 | 298 viewparams->bRedrawGameUI = 1; |
299 } | |
300 else | |
301 { | |
2203 | 302 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[item_id].stru_24.uItemID].pUnidentifiedName);//You found an item (%s)! |
303 ShowStatusBarString(pTmpBuf2.data(), 2); | |
304 if ( pSpriteObjects[item_id].stru_24.uItemID == ITEM_ARTIFACT_SPLITTER ) | |
1321 | 305 _449B7E_toggle_bit(pParty->_quest_bits, 184, 1); |
2203 | 306 if ( pSpriteObjects[item_id].stru_24.uItemID == 455 ) |
1321 | 307 _449B7E_toggle_bit(pParty->_quest_bits, 185, 1); |
2203 | 308 if ( !pParty->AddItemToParty(&pSpriteObjects[item_id].stru_24) ) |
309 pParty->SetHoldingItem(&pSpriteObjects[item_id].stru_24); | |
1297 | 310 } |
2203 | 311 SpriteObject::OnInteraction(item_id); |
1297 | 312 return; |
313 } | |
314 if ( !pParty->pPickedItem.uItemID ) | |
1321 | 315 return; |
1328 | 316 __debugbreak();//no checker |
1321 | 317 v6 = 0; |
318 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
319 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
320 LOWORD(v6) = 0; | |
321 else | |
322 { | |
323 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
324 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) | |
325 { | |
326 ++v6; | |
327 v7 += 56; | |
328 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
329 { | |
330 LOWORD(v6) = 0; | |
331 break; | |
332 } | |
333 } | |
334 } | |
335 a1.uObjectDescID = v6; | |
336 a1.vPosition.y = pParty->vPosition.y; | |
337 a1.spell_caster_pid = OBJECT_Player; | |
338 a1.vPosition.x = pParty->vPosition.x; | |
339 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
340 a1.uSoundID = 0; | |
341 a1.uFacing = 0; | |
342 a1.uAttributes = 8; | |
343 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
344 a1.uSpriteFrameID = 0; | |
345 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
346 | |
347 extern int UnprojectX(int); | |
2203 | 348 //v9 = UnprojectX(v1->x); |
349 a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0); | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1643
diff
changeset
|
350 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
1321 | 351 if (pTextureID != -1) |
352 pIcons_LOD->pTextures[pTextureID].Release(); | |
353 pMouse->RemoveHoldingItem(); | |
354 pIcons_LOD->SyncLoadedFilesCount(); | |
355 return; | |
1297 | 356 } |
1321 | 357 if ( PID_TYPE(v0) == OBJECT_Actor) |
1297 | 358 { |
2203 | 359 int mon_id = PID_ID(v0); |
360 //a2.y = v16; | |
361 if ( pActors[mon_id].uAIState == Dead ) | |
1297 | 362 { |
1321 | 363 if ( (unsigned int)v0 < 0x2000000 ) |
364 { | |
2203 | 365 pActors[mon_id].LootActor(); |
1321 | 366 return; |
367 } | |
368 if ( !pParty->pPickedItem.uItemID ) | |
369 return; | |
1328 | 370 __debugbreak();//no checker |
1321 | 371 v6 = 0; |
372 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
373 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
374 LOWORD(v6) = 0; | |
375 else | |
376 { | |
377 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
378 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) | |
379 { | |
380 ++v6; | |
381 v7 += 56; | |
382 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
383 { | |
384 LOWORD(v6) = 0; | |
385 break; | |
386 } | |
387 } | |
388 } | |
389 a1.uObjectDescID = v6; | |
390 a1.vPosition.y = pParty->vPosition.y; | |
391 a1.spell_caster_pid = OBJECT_Player; | |
392 a1.vPosition.x = pParty->vPosition.x; | |
393 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
394 a1.uSoundID = 0; | |
395 a1.uFacing = 0; | |
396 a1.uAttributes = 8; | |
397 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
398 a1.uSpriteFrameID = 0; | |
399 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
400 | |
401 extern int UnprojectX(int); | |
2203 | 402 //v9 = UnprojectX(v1->x); |
403 a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0); | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1643
diff
changeset
|
404 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
1321 | 405 if (pTextureID != -1) |
406 pIcons_LOD->pTextures[pTextureID].Release(); | |
407 pMouse->RemoveHoldingItem(); | |
408 pIcons_LOD->SyncLoadedFilesCount(); | |
409 return; | |
410 } | |
411 if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) | |
412 { | |
2203 | 413 if ( !pActors[mon_id].GetActorsRelation(0) && !(pActors[mon_id].uAttributes & 0x80000) ) |
1321 | 414 { |
415 if ( HIWORD(v0) >= clickable_distance) | |
416 { | |
1297 | 417 if ( !pParty->pPickedItem.uItemID ) |
418 return; | |
1328 | 419 __debugbreak();//no checker |
1321 | 420 v6 = 0; |
421 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
422 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
423 LOWORD(v6) = 0; | |
424 else | |
425 { | |
426 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
427 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) | |
428 { | |
429 ++v6; | |
430 v7 += 56; | |
431 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
432 { | |
433 LOWORD(v6) = 0; | |
434 break; | |
435 } | |
436 } | |
437 } | |
438 a1.uObjectDescID = v6; | |
439 a1.vPosition.y = pParty->vPosition.y; | |
440 a1.spell_caster_pid = OBJECT_Player; | |
441 a1.vPosition.x = pParty->vPosition.x; | |
442 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
443 a1.uSoundID = 0; | |
444 a1.uFacing = 0; | |
445 a1.uAttributes = 8; | |
446 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
447 a1.uSpriteFrameID = 0; | |
448 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
449 | |
450 extern int UnprojectX(int); | |
2203 | 451 //v9 = UnprojectX(v1->x); |
452 a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0); | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1643
diff
changeset
|
453 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
1321 | 454 if (pTextureID != -1) |
455 pIcons_LOD->pTextures[pTextureID].Release(); | |
456 pMouse->RemoveHoldingItem(); | |
457 pIcons_LOD->SyncLoadedFilesCount(); | |
458 return; | |
459 } | |
2203 | 460 if ( !pActors[mon_id].CanAct() ) |
1321 | 461 return; |
2203 | 462 //v18 = mon_id; |
463 Actor::AI_FaceObject(mon_id, 4, 0, 0); | |
464 if ( !pActors[mon_id].sNPC_ID ) | |
1297 | 465 { |
2203 | 466 if ( pNPCStats->pGroups_copy[pActors[mon_id].uGroup] ) |
1321 | 467 { |
2203 | 468 if ( pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[mon_id].uGroup]] ) |
1321 | 469 { |
2203 | 470 pParty->uFlags |= 2; |
471 strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[mon_id].uGroup]]); | |
1321 | 472 sub_4451A8_press_any_key(0, 0, 0); |
473 } | |
474 } | |
475 return; | |
1297 | 476 } |
2402 | 477 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_StartNPCDialogue, mon_id, 0); |
1297 | 478 return; |
479 } | |
2242 | 480 if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT ) |
1321 | 481 { |
1332 | 482 pTurnEngine->field_18 |= TE_FLAG_8; |
1321 | 483 return; |
484 } | |
2402 | 485 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Attack, 0, 0); |
1297 | 486 } |
487 else | |
488 { | |
2242 | 489 if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT ) |
1297 | 490 { |
1321 | 491 pParty->uFlags |= PARTY_FLAGS_1_FALLING; |
492 return; | |
1297 | 493 } |
2107
85e9766d6124
sub_427769_spell to sub_427769_isSpellQuickCastableOnShiftClick
Grumpy7
parents:
2086
diff
changeset
|
494 if ( uActiveCharacter && sub_427769_isSpellQuickCastableOnShiftClick(pPlayers[uActiveCharacter]->uQuickSpell)) |
2402 | 495 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CastQuickSpell, 0, 0); |
1297 | 496 } |
497 return; | |
498 } | |
1321 | 499 if ( PID_TYPE(v0) == OBJECT_Decoration) |
1297 | 500 { |
1321 | 501 if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uDecorationDescID].uRadius) >= clickable_distance ) |
1297 | 502 { |
1321 | 503 if ( !pParty->pPickedItem.uItemID ) |
504 return; | |
1328 | 505 __debugbreak();//no checker |
1321 | 506 v6 = 0; |
507 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
508 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
509 LOWORD(v6) = 0; | |
510 else | |
511 { | |
512 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
513 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) | |
514 { | |
515 ++v6; | |
516 v7 += 56; | |
517 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
518 { | |
519 LOWORD(v6) = 0; | |
520 break; | |
521 } | |
522 } | |
523 } | |
524 a1.uObjectDescID = v6; | |
525 a1.vPosition.y = pParty->vPosition.y; | |
526 a1.spell_caster_pid = OBJECT_Player; | |
527 a1.vPosition.x = pParty->vPosition.x; | |
528 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
529 a1.uSoundID = 0; | |
530 a1.uFacing = 0; | |
531 a1.uAttributes = 8; | |
532 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
533 a1.uSpriteFrameID = 0; | |
534 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
535 | |
536 extern int UnprojectX(int); | |
2203 | 537 //v9 = UnprojectX(v1->x); |
538 a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0); | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1643
diff
changeset
|
539 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
1321 | 540 if (pTextureID != -1) |
541 pIcons_LOD->pTextures[pTextureID].Release(); | |
542 pMouse->RemoveHoldingItem(); | |
543 pIcons_LOD->SyncLoadedFilesCount(); | |
1297 | 544 return; |
545 } | |
1514
965af46e8793
Rename LevelDecoration::field_16_event_id to LevelDecoration::uEventID.
yoctozepto
parents:
1358
diff
changeset
|
546 if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uEventID ) |
1321 | 547 { |
548 if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) | |
549 { | |
1736
c6fe09a06712
Player::CompareVariable finished, renamed stru_5E4C90 to stru_5E4C90_MapPersistVars, party::field_4A0 to party::CounterEventValues
Grumpy7
parents:
1721
diff
changeset
|
550 v15 = stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]._idx_in_stru123 - 75] + 380; |
1321 | 551 activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; |
552 EventProcessor(v15, 0, 1); | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2336
diff
changeset
|
553 activeLevelDecoration = nullptr; |
1321 | 554 } |
555 return; | |
556 } | |
1514
965af46e8793
Rename LevelDecoration::field_16_event_id to LevelDecoration::uEventID.
yoctozepto
parents:
1358
diff
changeset
|
557 pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uEventID; |
1837 | 558 EventProcessor(pEventID, (unsigned __int16)v0, 1); |
559 return; | |
1297 | 560 } |
1321 | 561 if ( PID_TYPE(v0) == OBJECT_BModel && HIWORD(v0) < clickable_distance) |
1297 | 562 { |
1321 | 563 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) |
1297 | 564 { |
2166 | 565 if ( !pIndoor->pFaces[PID_ID(v0)].Clickable() ) |
1321 | 566 { |
567 if ( !pParty->pPickedItem.uItemID ) | |
568 { | |
569 ShowNothingHereStatus(); | |
1297 | 570 if ( !pParty->pPickedItem.uItemID ) |
571 return; | |
1321 | 572 } |
1328 | 573 __debugbreak();//no checker |
1321 | 574 v6 = 0; |
575 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
576 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
577 LOWORD(v6) = 0; | |
578 else | |
1297 | 579 { |
1321 | 580 v7 = (char *)&pObjectList->pObjects->uObjectID; |
581 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) | |
1297 | 582 { |
1321 | 583 ++v6; |
584 v7 += 56; | |
585 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
586 { | |
587 LOWORD(v6) = 0; | |
588 break; | |
589 } | |
1297 | 590 } |
591 } | |
1321 | 592 a1.uObjectDescID = v6; |
593 a1.vPosition.y = pParty->vPosition.y; | |
594 a1.spell_caster_pid = OBJECT_Player; | |
595 a1.vPosition.x = pParty->vPosition.x; | |
596 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
597 a1.uSoundID = 0; | |
598 a1.uFacing = 0; | |
599 a1.uAttributes = 8; | |
600 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
601 a1.uSpriteFrameID = 0; | |
602 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
603 | |
604 extern int UnprojectX(int); | |
605 v9 = UnprojectX(v1->x); | |
606 a1.Create(pParty->sRotationY + v9, 184, 200, 0); | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1643
diff
changeset
|
607 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
1321 | 608 if (pTextureID != -1) |
609 pIcons_LOD->pTextures[pTextureID].Release(); | |
610 pMouse->RemoveHoldingItem(); | |
611 pIcons_LOD->SyncLoadedFilesCount(); | |
1297 | 612 return; |
613 } | |
1321 | 614 pEventID = pIndoor->pFaceExtras[pIndoor->pFaces[PID_ID(v0)].uFaceExtraID].uEventID; |
1297 | 615 } |
1321 | 616 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
1297 | 617 { |
1321 | 618 if ( !pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].Clickable()) |
619 { | |
620 if ( !pParty->pPickedItem.uItemID ) | |
621 { | |
622 ShowNothingHereStatus(); | |
623 if ( !pParty->pPickedItem.uItemID ) | |
624 return; | |
625 } | |
1328 | 626 __debugbreak();//no checker |
1321 | 627 v6 = 0; |
628 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
629 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
630 LOWORD(v6) = 0; | |
631 else | |
632 { | |
633 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
634 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) | |
635 { | |
636 ++v6; | |
637 v7 += 56; | |
638 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
639 { | |
640 LOWORD(v6) = 0; | |
641 break; | |
642 } | |
643 } | |
644 } | |
645 a1.uObjectDescID = v6; | |
646 a1.vPosition.y = pParty->vPosition.y; | |
647 a1.spell_caster_pid = OBJECT_Player; | |
648 a1.vPosition.x = pParty->vPosition.x; | |
649 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
650 a1.uSoundID = 0; | |
651 a1.uFacing = 0; | |
652 a1.uAttributes = 8; | |
653 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
654 a1.uSpriteFrameID = 0; | |
655 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
656 | |
657 extern int UnprojectX(int); | |
658 v9 = UnprojectX(v1->x); | |
659 a1.Create(pParty->sRotationY + v9, 184, 200, 0); | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1643
diff
changeset
|
660 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
1321 | 661 if (pTextureID != -1) |
662 pIcons_LOD->pTextures[pTextureID].Release(); | |
663 pMouse->RemoveHoldingItem(); | |
664 pIcons_LOD->SyncLoadedFilesCount(); | |
665 return; | |
666 } | |
667 pEventID = pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].sCogTriggeredID; | |
668 } | |
669 EventProcessor(pEventID, (unsigned __int16)v0, 1); | |
670 return; | |
1297 | 671 } |
1321 | 672 if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= clickable_distance ) |
1297 | 673 { |
1321 | 674 if ( !pParty->pPickedItem.uItemID ) |
1297 | 675 return; |
2085 | 676 //__debugbreak();//no checker |
1321 | 677 v6 = 0; |
678 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
679 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
680 LOWORD(v6) = 0; | |
681 else | |
1297 | 682 { |
1321 | 683 v7 = (char *)&pObjectList->pObjects->uObjectID; |
684 while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) | |
685 { | |
686 ++v6; | |
687 v7 += 56; | |
688 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
689 { | |
690 LOWORD(v6) = 0; | |
691 break; | |
692 } | |
693 } | |
1297 | 694 } |
1321 | 695 a1.uObjectDescID = v6; |
696 a1.vPosition.y = pParty->vPosition.y; | |
697 a1.spell_caster_pid = OBJECT_Player; | |
698 a1.vPosition.x = pParty->vPosition.x; | |
699 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
700 a1.uSoundID = 0; | |
701 a1.uFacing = 0; | |
702 a1.uAttributes = 8; | |
703 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
704 a1.uSpriteFrameID = 0; | |
705 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
706 | |
707 extern int UnprojectX(int); | |
2203 | 708 //v9 = UnprojectX(v1->x); |
709 a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0); | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1643
diff
changeset
|
710 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
1321 | 711 if (pTextureID != -1) |
712 pIcons_LOD->pTextures[pTextureID].Release(); | |
713 pMouse->RemoveHoldingItem(); | |
714 pIcons_LOD->SyncLoadedFilesCount(); | |
715 return; | |
1297 | 716 } |
717 } |