annotate mm7_6.cpp @ 2428:c99c99439f6c

Merge
author a.parshin
date Wed, 23 Jul 2014 13:32:09 +0300
parents f4af3b203f65
children
rev   line source
2415
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2334
diff changeset
1 #define _CRTDBG_MAP_ALLOC
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2334
diff changeset
2 #include <stdlib.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2334
diff changeset
3 #include <crtdbg.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2334
diff changeset
4
2253
aff7a7b072b7 adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents: 2245
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
1016
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 1003
diff changeset
6
c45d51b3f4f4 Included header files cleanup
Grumpy7
parents: 1003
diff changeset
7 #include "Vis.h"
0
Ritor1
parents:
diff changeset
8 #include "Game.h"
2331
9551756f46c4 Moving functions out of mm7_6.cpp into appropriate classes as static methods or free functions
Grumpy7
parents: 2303
diff changeset
9 #include "MM7_data.h"
0
Ritor1
parents:
diff changeset
10 #include "Actor.h"
Ritor1
parents:
diff changeset
11
Ritor1
parents:
diff changeset
12
Ritor1
parents:
diff changeset
13
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18 //----- (00427546) --------------------------------------------------------
Ritor1
parents:
diff changeset
19 int stru319::_427546(int a2)
Ritor1
parents:
diff changeset
20 {
Ritor1
parents:
diff changeset
21 int result; // eax@2
Ritor1
parents:
diff changeset
22
Ritor1
parents:
diff changeset
23 if ( a2 >= 0 )
Ritor1
parents:
diff changeset
24 {
Ritor1
parents:
diff changeset
25 if ( a2 >= 1 )
Ritor1
parents:
diff changeset
26 result = (a2 >= 2) + 2;
Ritor1
parents:
diff changeset
27 else
Ritor1
parents:
diff changeset
28 result = 1;
Ritor1
parents:
diff changeset
29 }
Ritor1
parents:
diff changeset
30 else
Ritor1
parents:
diff changeset
31 {
Ritor1
parents:
diff changeset
32 result = 0;
Ritor1
parents:
diff changeset
33 }
Ritor1
parents:
diff changeset
34 return result;
Ritor1
parents:
diff changeset
35 }
Ritor1
parents:
diff changeset
36
437
0a1ea44b4a0a ui mesages & spellcasting
Nomad
parents: 430
diff changeset
37
0
Ritor1
parents:
diff changeset
38
Ritor1
parents:
diff changeset
39 //----- (0042F184) --------------------------------------------------------
295
640a176c030f sub_42ECB5
Nomad
parents: 271
diff changeset
40 int stru319::FindClosestActor(int pick_depth, int a3, int a4)
0
Ritor1
parents:
diff changeset
41 {
Ritor1
parents:
diff changeset
42 int v4; // edi@1
Ritor1
parents:
diff changeset
43 stru319 *v5; // esi@1
Ritor1
parents:
diff changeset
44 int v6; // eax@2
Ritor1
parents:
diff changeset
45 int v7; // eax@4
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
46 // int result; // eax@5
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
47 // int *v9; // edx@8
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
48 // signed int v10; // ebx@10
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
49 // int v11; // edi@11
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
50 //Actor *v12; // esi@12
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
51 //unsigned __int16 v13; // ax@12
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
52 // int v14; // eax@22
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
53 //char v15; // zf@30
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
54 // int v16; // esi@32
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
55 // int v17; // ecx@34
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
56 // stru319 *v18; // eax@39
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
57 // int v19; // edx@39
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
58 // int v20; // ecx@41
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
59 // unsigned __int16 v21; // ax@42
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
60 // unsigned int v22; // [sp+8h] [bp-24h]@11
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
61 //unsigned int v23; // [sp+Ch] [bp-20h]@7
0
Ritor1
parents:
diff changeset
62 stru319 *v24; // [sp+10h] [bp-1Ch]@1
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
63 // unsigned int v25; // [sp+14h] [bp-18h]@8
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
64 // int *v26; // [sp+18h] [bp-14h]@8
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
65 // int v27; // [sp+1Ch] [bp-10h]@10
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
66 // int *v28; // [sp+20h] [bp-Ch]@10
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
67 //unsigned int v29; // [sp+24h] [bp-8h]@7
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
68 // int v30; // [sp+28h] [bp-4h]@6
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
69 // int i; // [sp+38h] [bp+Ch]@33
ddb803517a48 unused local variables I commented
Ritor1
parents: 2331
diff changeset
70 // signed int v32; // [sp+3Ch] [bp+10h]@32
0
Ritor1
parents:
diff changeset
71
Ritor1
parents:
diff changeset
72 v4 = 0;
Ritor1
parents:
diff changeset
73 v5 = this;
Ritor1
parents:
diff changeset
74 v24 = this;
2153
d28d3c006077 Some Render decoupling.
Nomad
parents: 2121
diff changeset
75 //if ( pRenderer->pRenderD3D )
0
Ritor1
parents:
diff changeset
76 {
Ritor1
parents:
diff changeset
77 v6 = a3 != 0;
Ritor1
parents:
diff changeset
78 if ( a4 )
Ritor1
parents:
diff changeset
79 LOBYTE(v6) = v6 | 8;
295
640a176c030f sub_42ECB5
Nomad
parents: 271
diff changeset
80 v7 = pGame->pVisInstance->PickClosestActor(OBJECT_Actor, pick_depth, v6, 657456, -1);
0
Ritor1
parents:
diff changeset
81 if ( v7 != -1 )
Ritor1
parents:
diff changeset
82 return (unsigned __int16)v7;
295
640a176c030f sub_42ECB5
Nomad
parents: 271
diff changeset
83 else return 0;
0
Ritor1
parents:
diff changeset
84 }
2153
d28d3c006077 Some Render decoupling.
Nomad
parents: 2121
diff changeset
85 /*else // software impl
0
Ritor1
parents:
diff changeset
86 {
Ritor1
parents:
diff changeset
87 v30 = 0;
Ritor1
parents:
diff changeset
88 if ( pRenderer->pActiveZBuffer )
Ritor1
parents:
diff changeset
89 {
692
066e2b29b30f viewport.cpp added
Gloval
parents: 651
diff changeset
90 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
0
Ritor1
parents:
diff changeset
91 {
692
066e2b29b30f viewport.cpp added
Gloval
parents: 651
diff changeset
92 v9 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
066e2b29b30f viewport.cpp added
Gloval
parents: 651
diff changeset
93 v26 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
94 for ( v25 = viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y; v25; --v25 )
0
Ritor1
parents:
diff changeset
95 {
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
96 if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X )
0
Ritor1
parents:
diff changeset
97 {
Ritor1
parents:
diff changeset
98 v28 = v9;
Ritor1
parents:
diff changeset
99 v10 = v4;
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
100 for ( v27 = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X; v27; --v27 )
0
Ritor1
parents:
diff changeset
101 {
Ritor1
parents:
diff changeset
102 v22 = *v28;
Ritor1
parents:
diff changeset
103 v11 = *v28 & 0xFFFF;
828
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
104 if (PID_TYPE(v11) == OBJECT_Actor)
0
Ritor1
parents:
diff changeset
105 {
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
106 if ( pActors[PID_ID(v11)].uAIState != Dead )
0
Ritor1
parents:
diff changeset
107 {
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
108 if ( pActors[PID_ID(v11)].uAIState != Dying && pActors[PID_ID(v11)].uAIState != Removed
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
109 && pActors[PID_ID(v11)].uAIState != Summoned && pActors[PID_ID(v11)].uAIState != Disabled
828
0f56abdcce94 Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents: 824
diff changeset
110 && (!a3 || pActors[PID_ID(v11)].GetActorsRelation(0)) )
0
Ritor1
parents:
diff changeset
111 {
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
112 if ( (!a4 || MonsterStats::BelongsToSupertype(pActors[PID_ID(v11)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD))
295
640a176c030f sub_42ECB5
Nomad
parents: 271
diff changeset
113 && v22 <= pick_depth << 16 )
0
Ritor1
parents:
diff changeset
114 {
Ritor1
parents:
diff changeset
115 v14 = 0;
Ritor1
parents:
diff changeset
116 if ( v10 > 0 )
Ritor1
parents:
diff changeset
117 {
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
118 for ( v14; v14 < v30; ++v14 )
0
Ritor1
parents:
diff changeset
119 {
Ritor1
parents:
diff changeset
120 if ( dword_50BDA0[v14] == v11 )
Ritor1
parents:
diff changeset
121 break;
Ritor1
parents:
diff changeset
122 }
Ritor1
parents:
diff changeset
123 }
Ritor1
parents:
diff changeset
124 if ( v14 == v30 && v10 < 100 )
Ritor1
parents:
diff changeset
125 {
Ritor1
parents:
diff changeset
126 ++v30;
Ritor1
parents:
diff changeset
127 dword_50BC10[v10] = v22;
Ritor1
parents:
diff changeset
128 dword_50BDA0[v10] = v11;
Ritor1
parents:
diff changeset
129 ++v10;
Ritor1
parents:
diff changeset
130 }
Ritor1
parents:
diff changeset
131 }
Ritor1
parents:
diff changeset
132 }
Ritor1
parents:
diff changeset
133 }
Ritor1
parents:
diff changeset
134 }
Ritor1
parents:
diff changeset
135 ++v28;
Ritor1
parents:
diff changeset
136 }
Ritor1
parents:
diff changeset
137 v4 = v30;
Ritor1
parents:
diff changeset
138 v5 = v24;
Ritor1
parents:
diff changeset
139 }
Ritor1
parents:
diff changeset
140 v9 = v26 + 640;
Ritor1
parents:
diff changeset
141 v26 += 640;
Ritor1
parents:
diff changeset
142 }
Ritor1
parents:
diff changeset
143 }
Ritor1
parents:
diff changeset
144 if ( v4 > 0 )
Ritor1
parents:
diff changeset
145 {
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
146 v16 = (int)dword_50BC10.data();
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
147 for ( v32 = 1; v32 - 1 < v4; ++v32 )
0
Ritor1
parents:
diff changeset
148 {
Ritor1
parents:
diff changeset
149 for ( i = v32; i < v4; ++i )
Ritor1
parents:
diff changeset
150 {
Ritor1
parents:
diff changeset
151 v17 = dword_50BC10[i];
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
152 if ( dword_50BC10[i] < *(int *)v16 )
0
Ritor1
parents:
diff changeset
153 {
Ritor1
parents:
diff changeset
154 dword_50BC10[i] = *(int *)v16;
Ritor1
parents:
diff changeset
155 *(int *)v16 = v17;
Ritor1
parents:
diff changeset
156 }
Ritor1
parents:
diff changeset
157 }
Ritor1
parents:
diff changeset
158 v16 += 4;
Ritor1
parents:
diff changeset
159 }
Ritor1
parents:
diff changeset
160 v5 = v24;
Ritor1
parents:
diff changeset
161 if ( v4 > 0 )
Ritor1
parents:
diff changeset
162 {
Ritor1
parents:
diff changeset
163 v18 = v24;
2117
c7bf59066842 mm7_4-6 cleaned
Ritor1
parents: 2114
diff changeset
164 for ( v19 = v4; v19; --v19 )
0
Ritor1
parents:
diff changeset
165 {
1205
8c02e6f74b29 arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents: 1202
diff changeset
166 *(int *)&v18->field_0 = (*(int *)&v18[(char *)dword_50BC10.data() - (char *)v24].field_0 >> 3) & 0x1FFF;
0
Ritor1
parents:
diff changeset
167 v18 += 4;
Ritor1
parents:
diff changeset
168 }
Ritor1
parents:
diff changeset
169 }
Ritor1
parents:
diff changeset
170 }
Ritor1
parents:
diff changeset
171 v20 = 0;
Ritor1
parents:
diff changeset
172 for ( *(int *)&v5[2000].field_0 = v4; v20 < v4; ++v20 )
Ritor1
parents:
diff changeset
173 {
Ritor1
parents:
diff changeset
174 v21 = pActors[*(int *)&v5[4 * v20].field_0].uAIState;
Ritor1
parents:
diff changeset
175 if ( v21 != 4 && v21 != 5 )
Ritor1
parents:
diff changeset
176 break;
Ritor1
parents:
diff changeset
177 }
Ritor1
parents:
diff changeset
178 if ( v20 != v4 )
Ritor1
parents:
diff changeset
179 {
Ritor1
parents:
diff changeset
180 result = 8 * *(int *)&v5[4 * v20].field_0;
Ritor1
parents:
diff changeset
181 LOBYTE(result) = result | 3;
Ritor1
parents:
diff changeset
182 return result;
Ritor1
parents:
diff changeset
183 }
Ritor1
parents:
diff changeset
184 }
Ritor1
parents:
diff changeset
185 }
2153
d28d3c006077 Some Render decoupling.
Nomad
parents: 2121
diff changeset
186 return 0;*/
0
Ritor1
parents:
diff changeset
187 }
Ritor1
parents:
diff changeset
188
1052
d48c762de563 -nomarg
Nomad
parents: 1038
diff changeset
189
d48c762de563 -nomarg
Nomad
parents: 1038
diff changeset
190