Mercurial > mm7
comparison Viewport.cpp @ 1297:5450af4f57ef
moving files mm7_x ending
author | Ritor1 |
---|---|
date | Wed, 19 Jun 2013 17:06:58 +0600 |
parents | fac7751b2dc9 |
children | cc8d58f2bf0c |
comparison
equal
deleted
inserted
replaced
1296:c423f946dc99 | 1297:5450af4f57ef |
---|---|
2 | 2 |
3 #include "Party.h" | 3 #include "Party.h" |
4 #include "Indoor.h" | 4 #include "Indoor.h" |
5 #include "Math.h" | 5 #include "Math.h" |
6 #include "mm7_data.h" | 6 #include "mm7_data.h" |
7 #include "Actor.h" | |
8 #include "Outdoor.h" | |
9 #include "Events.h" | |
10 #include "BSPModel.h" | |
11 #include "Mouse.h" | |
12 #include "SpriteObject.h" | |
13 #include "ObjectList.h" | |
14 #include "DecorationList.h" | |
15 #include "texts.h" | |
16 #include "Game.h" | |
17 #include "Vis.h" | |
18 #include "LOD.h" | |
19 #include "GUIWindow.h" | |
20 #include "TurnEngine.h" | |
21 #include "stru123.h" | |
22 #include "MM7.h" | |
7 | 23 |
8 | 24 |
9 //----- (004C0262) -------------------------------------------------------- | 25 //----- (004C0262) -------------------------------------------------------- |
10 void Viewport::SetScreen( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y ) | 26 void Viewport::SetScreen( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y ) |
11 { | 27 { |
232 uMinimapZoom = _576E2C_current_minimap_zoom; | 248 uMinimapZoom = _576E2C_current_minimap_zoom; |
233 field_28 = dword_576E28; | 249 field_28 = dword_576E28; |
234 } | 250 } |
235 field_2C = 384; | 251 field_2C = 384; |
236 } | 252 } |
253 //----- (0042213C) -------------------------------------------------------- | |
254 void OnGameViewportClick() | |
255 { | |
256 signed int v0; // ebx@2 | |
257 POINT *v1; // esi@3 | |
258 signed int v2; // eax@9 | |
259 BLVFace *v3; // eax@10 | |
260 unsigned int v4; // eax@11 | |
261 unsigned __int16 v5; // dx@14 | |
262 signed int v6; // eax@14 | |
263 char *v7; // esi@15 | |
264 //int *v8; // eax@19 | |
265 int v9; // eax@19 | |
266 unsigned int v10; // eax@19 | |
267 int v11; // ecx@21 | |
268 ODMFace *v12; // eax@22 | |
269 LevelDecoration *v13; // esi@24 | |
270 __int16 v14; // ax@25 | |
271 int v15; // ecx@29 | |
272 signed int v16; // edx@30 | |
273 Actor *v17; // esi@30 | |
274 int v18; // ebx@47 | |
275 unsigned __int16 v19; // ax@50 | |
276 const char *v20; // eax@51 | |
277 signed int v21; // eax@58 | |
278 ItemGen *v22; // esi@62 | |
279 unsigned int v23; // eax@62 | |
280 SpriteObject a1; // [sp+Ch] [bp-80h]@1 | |
281 //POINT v25; // [sp+7Ch] [bp-10h]@3 | |
282 POINT a2; // [sp+84h] [bp-8h]@3 | |
283 | |
284 v1 = pMouse->GetCursorPos(&a2); | |
285 if ( pRenderer->pRenderD3D ) | |
286 v0 = pGame->pVisInstance->get_picked_object_zbuf_val(); | |
287 else | |
288 { | |
289 v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]]; | |
290 } | |
291 | |
292 if ( PID_TYPE(v0) == OBJECT_Item) | |
293 { | |
294 a2.y = (signed int)(unsigned __int16)v0 >> 3; | |
295 v21 = (signed int)(unsigned __int16)v0 >> 3; | |
296 if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID | |
297 && (unsigned int)v0 < 0x2000000 ) | |
298 { | |
299 v22 = &pSpriteObjects[v21].stru_24; | |
300 v23 = pSpriteObjects[v21].stru_24.uItemID; | |
301 if ( pItemsTable->pItems[v23].uEquipType == 18 ) | |
302 { | |
303 party_finds_gold(v22->uSpecEnchantmentType, 0); | |
304 viewparams->bRedrawGameUI = 1; | |
305 } | |
306 else | |
307 { | |
308 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName); | |
309 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
310 if ( v22->uItemID == 506 ) | |
311 _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); | |
312 if ( v22->uItemID == 455 ) | |
313 _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); | |
314 if ( !pParty->AddItem(v22) ) | |
315 pParty->SetHoldingItem(v22); | |
316 } | |
317 SpriteObject::OnInteraction(a2.y); | |
318 return; | |
319 } | |
320 v4 = pParty->pPickedItem.uItemID; | |
321 if ( !pParty->pPickedItem.uItemID ) | |
322 return; | |
323 goto LABEL_14; | |
324 } | |
325 if ( PID_TYPE(v0) != OBJECT_Actor) | |
326 { | |
327 if ( PID_TYPE(v0) == OBJECT_Decoration) | |
328 { | |
329 v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; | |
330 if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) | |
331 { | |
332 v4 = pParty->pPickedItem.uItemID; | |
333 if ( !pParty->pPickedItem.uItemID ) | |
334 return; | |
335 goto LABEL_14; | |
336 } | |
337 v14 = v13->field_16_event_id; | |
338 if ( !v14 ) | |
339 { | |
340 if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) | |
341 { | |
342 v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; | |
343 activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; | |
344 EventProcessor(v15, 0, 1); | |
345 activeLevelDecoration = NULL; | |
346 } | |
347 return; | |
348 } | |
349 v11 = v14; | |
350 } | |
351 else | |
352 { | |
353 if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= 512 ) | |
354 { | |
355 v4 = pParty->pPickedItem.uItemID; | |
356 if ( !pParty->pPickedItem.uItemID ) | |
357 return; | |
358 goto LABEL_14; | |
359 } | |
360 v2 = PID_ID(v0); | |
361 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
362 { | |
363 v3 = &pIndoor->pFaces[v2]; | |
364 if ( !(v3->uAttributes & 0x2000000) ) | |
365 { | |
366 LABEL_11: | |
367 v4 = pParty->pPickedItem.uItemID; | |
368 if ( !pParty->pPickedItem.uItemID ) | |
369 { | |
370 ShowNothingHereStatus(); | |
371 v4 = pParty->pPickedItem.uItemID; | |
372 if ( !pParty->pPickedItem.uItemID ) | |
373 return; | |
374 } | |
375 LABEL_14: | |
376 v5 = pItemsTable->pItems[v4].uSpriteID; | |
377 v6 = 0; | |
378 a1.uType = v5; | |
379 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
380 LOWORD(v6) = 0; | |
381 else | |
382 { | |
383 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
384 while ( v5 != *(short *)v7 ) | |
385 { | |
386 ++v6; | |
387 v7 += 56; | |
388 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
389 { | |
390 LOWORD(v6) = 0; | |
391 break; | |
392 } | |
393 } | |
394 } | |
395 a1.uObjectDescID = v6; | |
396 a1.vPosition.y = pParty->vPosition.y; | |
397 a1.spell_caster_pid = OBJECT_Player; | |
398 a1.vPosition.x = pParty->vPosition.x; | |
399 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
400 a1.uSoundID = 0; | |
401 a1.uFacing = 0; | |
402 a1.uAttributes = 8; | |
403 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
404 a1.uSpriteFrameID = 0; | |
405 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
406 | |
407 extern int UnprojectX(int); | |
408 v9 = UnprojectX(v1->x); | |
409 a1.Create(pParty->sRotationY + v9, 184, 200, 0); | |
410 v10 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); | |
411 if (v10 != -1) | |
412 pIcons_LOD->pTextures[v10].Release(); | |
413 pMouse->RemoveHoldingItem(); | |
414 pIcons_LOD->SyncLoadedFilesCount(); | |
415 return; | |
416 } | |
417 v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID; | |
418 } | |
419 else | |
420 { | |
421 v12 = &pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[v2 & 0x3F]; | |
422 if ( !v12->Clickable()) | |
423 goto LABEL_11; | |
424 v11 = v12->sCogTriggeredID; | |
425 } | |
426 } | |
427 EventProcessor(v11, (unsigned __int16)v0, 1); | |
428 return; | |
429 } | |
430 v16 = (signed int)(unsigned __int16)v0 >> 3; | |
431 a2.y = v16; | |
432 v17 = &pActors[v16]; | |
433 if ( v17->uAIState == 5 ) | |
434 { | |
435 if ( (unsigned int)v0 < 0x2000000 ) | |
436 { | |
437 stru_50C198.LootActor(&pActors[v16]); | |
438 return; | |
439 } | |
440 v4 = pParty->pPickedItem.uItemID; | |
441 if ( !pParty->pPickedItem.uItemID ) | |
442 return; | |
443 goto LABEL_14; | |
444 } | |
445 if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) | |
446 { | |
447 if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) ) | |
448 { | |
449 if ( HIWORD(v0) >= 512) | |
450 { | |
451 v4 = pParty->pPickedItem.uItemID; | |
452 if ( !pParty->pPickedItem.uItemID ) | |
453 return; | |
454 goto LABEL_14; | |
455 } | |
456 if ( !v17->CanAct() ) | |
457 return; | |
458 v18 = a2.y; | |
459 Actor::AI_FaceObject(a2.y, 4u, 0, 0); | |
460 if ( !v17->sNPC_ID ) | |
461 { | |
462 v19 = pNPCStats->pGroups_copy[v17->uGroup]; | |
463 if ( v19 ) | |
464 { | |
465 v20 = pNPCStats->pCatchPhrases[v19]; | |
466 if ( v20 ) | |
467 { | |
468 pParty->uFlags |= 2u; | |
469 strcpy(byte_5B0938.data(), v20); | |
470 sub_4451A8_press_any_key(0, 0, 0); | |
471 } | |
472 } | |
473 return; | |
474 } | |
475 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) | |
476 return; | |
477 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_StartNPCDialogue; | |
478 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18; | |
479 LABEL_42: | |
480 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
481 ++pMessageQueue_50CBD0->uNumMessages; | |
482 return;*/ | |
483 pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); | |
484 return; | |
485 } | |
486 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) | |
487 { | |
488 pTurnEngine->field_18 |= 8u; | |
489 return; | |
490 } | |
491 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
492 { | |
493 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack; | |
494 goto LABEL_41; | |
495 }*/ | |
496 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); | |
497 } | |
498 else | |
499 { | |
500 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) | |
501 { | |
502 pParty->uFlags |= PARTY_FLAGS_1_FALLING; | |
503 return; | |
504 } | |
505 if ( uActiveCharacter | |
506 && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) | |
507 { | |
508 pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0); | |
509 /*&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
510 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CastQuickSpell; | |
511 LABEL_41: | |
512 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; | |
513 goto LABEL_42;*/ | |
514 } | |
515 } | |
516 } |