Mercurial > mm7
annotate mm7_5.cpp @ 2457:17ac6a47f8fb
speed actors
author | Ritor1 |
---|---|
date | Sat, 26 Jul 2014 10:42:29 +0600 |
parents | f4af3b203f65 |
children | 0f17a30149ec |
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:
2245
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
2336 | 6 #include "ErrorHandling.h" |
1016 | 7 #include "LightmapBuilder.h" |
0 | 8 #include "mm7.h" |
9 #include "GUIWindow.h" | |
10 #include "Party.h" | |
11 #include "Outdoor.h" | |
12 #include "LOD.h" | |
13 #include "Actor.h" | |
14 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2006
diff
changeset
|
15 #include "OurMath.h" |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
513
diff
changeset
|
16 #include "SpriteObject.h" |
2044 | 17 #include "Timer.h" |
0 | 18 #include "stru298.h" |
1262 | 19 #include "Lights.h" |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1793
diff
changeset
|
20 #include "Level/Decoration.h" |
2336 | 21 #include "mm7_unsorted_subs.h" |
22 #include "mm7_data.h" | |
0 | 23 |
2207 | 24 |
0 | 25 //----- (004356FF) -------------------------------------------------------- |
1575 | 26 void back_to_game() |
0 | 27 { |
28 dword_507BF0_is_there_popup_onscreen = 0; | |
29 dword_4E455C = 1; | |
1575 | 30 |
31 extern int no_rightlick_in_inventory; | |
32 no_rightlick_in_inventory = false; | |
33 | |
0 | 34 if ( pGUIWindow_ScrollWindow ) |
35 free_book_subwindow(); | |
36 if ( !pCurrentScreen && !pGUIWindow_Settings ) | |
37 pEventTimer->Resume(); | |
38 viewparams->bRedrawGameUI = 1; | |
39 } | |
782 | 40 |
0 | 41 //----- (004369DB) -------------------------------------------------------- |
42 void Vec3_float_::Normalize() | |
43 { | |
1025 | 44 this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x; |
45 this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y; | |
46 this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z; | |
0 | 47 } |
48 | |
49 //----- (00438F8F) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1384
diff
changeset
|
50 void area_of_effect__damage_evaluate() |
0 | 51 { |
2059 | 52 int attacker_type; // ecx@3 |
0 | 53 signed int v3; // eax@3 |
2059 | 54 unsigned int target_id; // edi@6 |
55 int target_type; // eax@6 | |
0 | 56 int v10; // edi@8 |
2059 | 57 Vec3_int_ attacker_coord; // ST04_12@9 |
2334 | 58 // int v12; // ST0C_4@10 |
0 | 59 int v15; // edx@15 |
60 int v19; // edi@15 | |
61 int v23; // edx@18 | |
62 int v24; // eax@18 | |
2334 | 63 // int v30; // eax@29 |
0 | 64 int v31; // edx@29 |
65 int v32; // eax@29 | |
66 int v33; // ST24_4@29 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
513
diff
changeset
|
67 SpriteObject *v36; // [sp+0h] [bp-28h]@0 |
2059 | 68 int attacker_id; // [sp+10h] [bp-18h]@1 |
0 | 69 int v44; // [sp+14h] [bp-14h]@15 |
2059 | 70 //Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2 |
2205 | 71 signed int a1; // [sp+20h] [bp-8h]@8 |
0 | 72 int v48; // [sp+24h] [bp-4h]@8 |
73 | |
2059 | 74 |
75 for ( attacker_id = 0; attacker_id < AttackerInfo.count; ++attacker_id ) | |
0 | 76 { |
2059 | 77 attacker_type = PID_TYPE(AttackerInfo.pIDs[attacker_id]); |
78 v3 = PID_ID(AttackerInfo.pIDs[attacker_id]); | |
2057 | 79 |
2059 | 80 if ( attacker_type == 2 ) |
81 { | |
82 v36 = &pSpriteObjects[v3]; | |
83 attacker_type = PID_TYPE(pSpriteObjects[v3].spell_caster_pid); | |
84 v3 = PID_ID(pSpriteObjects[v3].spell_caster_pid); | |
85 } | |
2057 | 86 |
2059 | 87 if ( AttackerInfo.field_3EC[attacker_id] & 1 ) |
88 { | |
89 target_id = PID_ID(ai_near_actors_targets_pid[v3]); | |
90 target_type = PID_TYPE(ai_near_actors_targets_pid[v3]) - 3; | |
91 if ( target_type ) | |
0 | 92 { |
2059 | 93 if ( target_type == 1 )//party damage from monsters(повреждения группе от монстров) |
0 | 94 { |
2059 | 95 v10 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
96 a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; | |
2117 | 97 v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 98 if ( a1 * a1 + v10 * v10 |
99 + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) | |
100 * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) | |
101 < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32)) ) | |
0 | 102 { |
2059 | 103 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
104 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
105 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
106 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord) ) | |
107 DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], stru_50C198.which_player_to_attack(&pActors[v3])); | |
0 | 108 } |
109 } | |
2059 | 110 } |
111 else//Actor damage from monsters(повреждение местного жителя) | |
112 { | |
113 if ( SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) > 0 | |
114 || SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) >= 0 | |
115 && LODWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) | |
116 || pActors[target_id].CanAct() ) | |
0 | 117 { |
2059 | 118 v15 = pActors[target_id].vPosition.y - AttackerInfo.pYs[attacker_id]; |
119 a1 = pActors[target_id].vPosition.x - AttackerInfo.pXs[attacker_id]; | |
120 v44 = pActors[target_id].vPosition.z; | |
2390
c631b1877204
area_of_effect_damage_evaluate - fixed spells radius problem
zipi
parents:
2348
diff
changeset
|
121 v19 = AttackerInfo.field_324[attacker_id] + pActors[target_id].uActorRadius; |
2059 | 122 v48 = v15; |
123 if ( a1 * a1 + v15 * v15 + (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) | |
124 * (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) < (unsigned int)(v19 * v19) ) | |
0 | 125 { |
2059 | 126 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
127 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
128 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
129 if ( sub_407A1C(pActors[target_id].vPosition.x, pActors[target_id].vPosition.y, pActors[target_id].vPosition.z + 50, attacker_coord) ) | |
0 | 130 { |
2059 | 131 Vec3_int_::Normalize(&a1, &v48, &v44); |
132 AttackerInfo.vec_4B4[attacker_id].x = a1; | |
133 AttackerInfo.vec_4B4[attacker_id].y = v48; | |
134 AttackerInfo.vec_4B4[attacker_id].z = v44; | |
2310 | 135 Actor::ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], target_id, &AttackerInfo.vec_4B4[attacker_id], AttackerInfo.field_450[attacker_id]); |
0 | 136 } |
137 } | |
138 } | |
139 } | |
2059 | 140 } |
141 else //damage from spells(повреждения от заклов(метеоритный дождь)) | |
142 { | |
143 v23 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; | |
2216 | 144 v24 = ((signed int)pParty->uPartyHeight / 2) - AttackerInfo.pZs[attacker_id]; |
2059 | 145 a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; |
2117 | 146 v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 147 if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32)) ) |
148 {//party damage (повреждения группе) | |
149 attacker_coord.x = AttackerInfo.pXs[attacker_id]; | |
150 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
151 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
152 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord) ) | |
153 { | |
154 for ( uint i = 0; i < 4; ++i ) | |
0 | 155 { |
2059 | 156 if ( !(HIDWORD(pParty->pPlayers[i].pConditions[Condition_Dead]) | LODWORD(pParty->pPlayers[i].pConditions[Condition_Dead])) |
157 && !pParty->pPlayers[i].pConditions[Condition_Pertified] && !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) | |
158 DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], i); | |
0 | 159 } |
160 } | |
2059 | 161 } |
162 if ( (signed int)uNumActors > 0 ) | |
163 {//actors damage(повреждения другим участникам) | |
164 for ( int actorID = 0; (signed int)actorID < (signed int)uNumActors; ++actorID ) | |
165 { | |
166 if ( pActors[actorID].CanAct() ) | |
0 | 167 { |
2205 | 168 //v30 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 169 a1 = pActors[actorID].vPosition.x - AttackerInfo.pXs[attacker_id]; |
170 v31 = pActors[actorID].vPosition.z; | |
2205 | 171 v48 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 172 v44 = pActors[actorID].vPosition.z; |
2205 | 173 v32 = (pActors[actorID].uActorHeight / 2) - AttackerInfo.pZs[attacker_id]; |
2390
c631b1877204
area_of_effect_damage_evaluate - fixed spells radius problem
zipi
parents:
2348
diff
changeset
|
174 v33 = pActors[actorID].uActorRadius + AttackerInfo.field_324[attacker_id]; |
2059 | 175 if ( a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33) ) |
0 | 176 { |
2059 | 177 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
178 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
179 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
2205 | 180 if ( sub_407A1C(pActors[actorID].vPosition.x, pActors[actorID].vPosition.y, pActors[actorID].vPosition.z + 50, attacker_coord) )//что делает ф-ция? |
0 | 181 { |
2059 | 182 Vec3_int_::Normalize(&a1, &v48, &v44); |
183 AttackerInfo.vec_4B4[attacker_id].x = a1; | |
184 AttackerInfo.vec_4B4[attacker_id].y = v48; | |
185 AttackerInfo.vec_4B4[attacker_id].z = v44; | |
186 switch ( attacker_type ) | |
0 | 187 { |
2059 | 188 case OBJECT_Player: |
2338
1e865e8690ba
Moving some function declarations from unsorted subs to Actor.h and SpriteObject.h
Grumpy7
parents:
2336
diff
changeset
|
189 Actor::DamageMonsterFromParty(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); |
2059 | 190 break; |
191 case OBJECT_Actor: | |
192 if ( v36 && pActors[v3].GetActorsRelation(&pActors[actorID]) ) | |
2310 | 193 Actor::ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id], v36->field_61); |
2059 | 194 break; |
195 case OBJECT_Item: | |
2132 | 196 ItemDamageFromActor(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); |
2059 | 197 break; |
0 | 198 } |
199 } | |
200 } | |
201 } | |
202 } | |
203 } | |
204 } | |
205 } | |
2059 | 206 AttackerInfo.count = 0; |
0 | 207 } |
208 | |
209 | |
210 //----- (0043A97E) -------------------------------------------------------- | |
211 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2) | |
212 { | |
1979 | 213 if (PID_TYPE(a2) == OBJECT_Player) |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
214 { |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
215 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
216 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
217 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
218 |
0 | 219 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); |
2006 | 220 DamagePlayerFromMonster(PID(OBJECT_Item, uLayingItemID), pSpriteObjects[uLayingItemID].field_61, &layingitem_vel_50FDFC, -1); |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
221 } |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
222 else if (PID_TYPE(a2) == OBJECT_Actor) |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
223 { |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
224 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
225 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
226 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
227 |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
228 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
229 switch (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid)) |
0 | 230 { |
231 case OBJECT_Actor: | |
2310 | 232 Actor::ActorDamageFromMonster(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC, pSpriteObjects[uLayingItemID].field_61); |
0 | 233 break; |
234 case OBJECT_Player: | |
2338
1e865e8690ba
Moving some function declarations from unsorted subs to Actor.h and SpriteObject.h
Grumpy7
parents:
2336
diff
changeset
|
235 Actor::DamageMonsterFromParty(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); |
0 | 236 break; |
237 case OBJECT_Item: | |
2132 | 238 ItemDamageFromActor(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); |
0 | 239 break; |
240 } | |
241 } | |
242 } | |
243 | |
244 //----- (0043AE12) -------------------------------------------------------- | |
245 double __fastcall sub_43AE12(signed int a1) | |
246 { | |
2117 | 247 //signed int v1; // ST00_4@1 |
0 | 248 signed int v2; // ecx@1 |
249 double v3; // st7@1 | |
250 double result; // st7@6 | |
251 | |
2117 | 252 v3 = (double)a1; |
253 for ( v2 = 0; v2 < 5; ++v2 ) | |
0 | 254 { |
255 if ( v3 < flt_4E4A80[v2 + 5] ) | |
256 break; | |
257 } | |
258 if ( v2 <= 0 || v2 >= 5 ) | |
259 { | |
260 if ( v2 ) | |
261 result = flt_4E4A80[4]; | |
262 else | |
263 result = flt_4E4A80[0]; | |
264 } | |
265 else | |
1469 | 266 result = (flt_4E4A80[v2] - flt_4E4A80[v2 - 1]) * (v3 - flt_4E4A80[v2 + 4]) / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4]) + flt_4E4A80[v2]; |
0 | 267 return result; |
268 } | |
269 | |
270 //----- (0043B057) -------------------------------------------------------- | |
2132 | 271 void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) |
0 | 272 { |
273 int v6; // eax@4 | |
2132 | 274 int damage; // edi@4 |
0 | 275 int a2a; // [sp+Ch] [bp-4h]@8 |
276 | |
303 | 277 if ( !pActors[uActorID].IsNotAlive() ) |
0 | 278 { |
2117 | 279 if ( PID_TYPE(uObjID) == OBJECT_Item) |
848 | 280 { |
2117 | 281 if ( pSpriteObjects[PID_ID(uObjID)].spell_id ) |
0 | 282 { |
2117 | 283 v6 = _43AFE3_calc_spell_damage(pSpriteObjects[PID_ID(uObjID)].spell_id, pSpriteObjects[PID_ID(uObjID)].spell_level, pSpriteObjects[PID_ID(uObjID)].spell_skill, pActors[uActorID].sCurrentHP); |
2293
b0f10ef66e00
stru319::CalcMagicalDamageToActor moved to Actor class
Grumpy7
parents:
2292
diff
changeset
|
284 damage = pActors[uActorID].CalcMagicalDamageToActor((DAMAGE_TYPE)0, v6); |
2132 | 285 pActors[uActorID].sCurrentHP -= damage; |
286 if ( damage ) | |
0 | 287 { |
2117 | 288 if ( pActors[uActorID].sCurrentHP > 0 ) |
289 Actor::AI_Stun(uActorID, uObjID, 0); | |
0 | 290 else |
2117 | 291 Actor::Die(uActorID); |
2132 | 292 a2a = 20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP; |
293 if ( 20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP > 10 ) | |
0 | 294 a2a = 10; |
2117 | 295 if ( !MonsterStats::BelongsToSupertype(pActors[uActorID].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) |
0 | 296 { |
2207 | 297 pVelocity->x = fixpoint_mul(a2a, pVelocity->x); |
298 pVelocity->y = fixpoint_mul(a2a, pVelocity->y); | |
299 pVelocity->z = fixpoint_mul(a2a, pVelocity->z); | |
2117 | 300 pActors[uActorID].vVelocity.x = 50 * LOWORD(pVelocity->x); |
301 pActors[uActorID].vVelocity.y = 50 * LOWORD(pVelocity->y); | |
302 pActors[uActorID].vVelocity.z = 50 * LOWORD(pVelocity->z); | |
0 | 303 } |
2132 | 304 Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, damage); |
0 | 305 } |
306 else | |
2117 | 307 Actor::AI_Stun(uActorID, uObjID, 0); |
0 | 308 } |
309 } | |
310 } | |
311 } | |
312 | |
313 | |
314 //----- (0043F515) -------------------------------------------------------- | |
657 | 315 void FindBillboardsLightLevels_BLV() |
0 | 316 { |
317 for (uint i = 0; i < uNumBillboardsToDraw; ++i) | |
318 { | |
2114 | 319 if (pBillboardRenderList[i].field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !pBillboardRenderList[i].uIndoorSectorID) |
320 pBillboardRenderList[i].dimming_level = 0; | |
0 | 321 else |
2114 | 322 pBillboardRenderList[i].dimming_level = _43F55F_get_billboard_light_level(&pBillboardRenderList[i], -1); |
0 | 323 } |
324 } | |
325 | |
326 //----- (0043F55F) -------------------------------------------------------- | |
327 int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel) | |
328 { | |
329 signed int v3; // ecx@2 | |
330 | |
331 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
332 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel; | |
333 else | |
334 { | |
335 if ( uBaseLightLevel == -1 ) | |
657 | 336 v3 = a1->dimming_level; |
0 | 337 else |
338 v3 = uBaseLightLevel; | |
339 } | |
430 | 340 return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->world_x, a1->world_y, a1->world_z); |
0 | 341 } |
342 | |
343 //----- (0043F5C8) -------------------------------------------------------- | |
344 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z) | |
345 { | |
2334 | 346 // int v5; // esi@1 |
0 | 347 signed int v6; // edi@1 |
348 int v8; // eax@6 | |
349 int v9; // ebx@6 | |
350 unsigned int v10; // ecx@6 | |
351 unsigned int v11; // edx@9 | |
352 unsigned int v12; // edx@11 | |
353 signed int v13; // ecx@12 | |
354 BLVLightMM7 *v16; // esi@20 | |
355 int v17; // ebx@21 | |
2334 | 356 // int v18; // eax@24 |
357 // int v19; // ebx@24 | |
358 // unsigned int v20; // ecx@24 | |
359 // int v21; // edx@25 | |
360 // unsigned int v22; // edx@27 | |
361 // unsigned int v23; // edx@29 | |
0 | 362 signed int v24; // ecx@30 |
363 int v26; // ebx@35 | |
2334 | 364 // int v27; // eax@38 |
365 // int v28; // ebx@38 | |
366 // unsigned int v29; // ecx@38 | |
367 // int v30; // edx@39 | |
368 // unsigned int v31; // edx@41 | |
369 // unsigned int v32; // edx@43 | |
2251 | 370 //signed int v33; // ecx@44 |
0 | 371 int v37; // [sp+Ch] [bp-18h]@37 |
2334 | 372 // int v38; // [sp+10h] [bp-14h]@5 |
0 | 373 int v39; // [sp+10h] [bp-14h]@23 |
374 int v40; // [sp+10h] [bp-14h]@36 | |
375 int v42; // [sp+14h] [bp-10h]@22 | |
376 unsigned int v43; // [sp+18h] [bp-Ch]@12 | |
377 unsigned int v44; // [sp+18h] [bp-Ch]@30 | |
378 unsigned int v45; // [sp+18h] [bp-Ch]@44 | |
379 | |
380 v6 = uBaseLightLevel; | |
381 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) | |
382 { | |
1980 | 383 MobileLight* p = &pMobileLightsStack->pLights[i]; |
0 | 384 |
1980 | 385 float distX = abs(p->vPosition.x - x); |
0 | 386 if ( distX <= p->uRadius) |
387 { | |
1980 | 388 float distY = abs(p->vPosition.y - y); |
0 | 389 if ( distY <= p->uRadius) |
390 { | |
1980 | 391 float distZ = abs(p->vPosition.z - z); |
0 | 392 if ( distZ <= p->uRadius) |
393 { | |
394 v8 = distX; | |
395 v9 = distY; | |
396 v10 = distZ; | |
397 if (distX < distY) | |
398 { | |
399 v8 = distY; | |
400 v9 = distX; | |
401 } | |
402 if ( v8 < distZ ) | |
403 { | |
404 v11 = v8; | |
405 v8 = distZ; | |
406 v10 = v11; | |
407 } | |
408 if ( v9 < (signed int)v10 ) | |
409 { | |
410 v12 = v10; | |
411 v10 = v9; | |
412 v9 = v12; | |
413 } | |
414 v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8; | |
415 v13 = p->uRadius; | |
416 if ( (signed int)v43 < v13 ) | |
417 v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30; | |
418 } | |
419 } | |
420 } | |
421 } | |
422 | |
423 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
424 { | |
1980 | 425 BLVSector* pSector = &pIndoor->pSectors[uSectorID]; |
0 | 426 |
427 for (uint i = 0; i < pSector->uNumLights; ++i) | |
428 { | |
429 v16 = pIndoor->pLights + pSector->pLights[i]; | |
430 if (~v16->uAtributes & 8) | |
431 { | |
432 v17 = abs(v16->vPosition.x - x); | |
433 if ( v17 <= v16->uRadius ) | |
434 { | |
435 v42 = abs(v16->vPosition.y - y); | |
436 if ( v42 <= v16->uRadius ) | |
437 { | |
438 v39 = abs(v16->vPosition.z - z); | |
439 if ( v39 <= v16->uRadius ) | |
440 { | |
2235
6ab7d7c112bb
adding int_get_vector_length calls where the calls were inlined
Grumpy7
parents:
2216
diff
changeset
|
441 v44 = int_get_vector_length(v17, v42, v39); |
0 | 442 v24 = v16->uRadius; |
443 if ( (signed int)v44 < v24 ) | |
444 v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30; | |
445 } | |
446 } | |
447 } | |
448 } | |
449 } | |
450 } | |
451 | |
452 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) | |
453 { | |
2251 | 454 //StationaryLight* p = &pStationaryLightsStack->pLights[i]; |
455 v26 = abs(pStationaryLightsStack->pLights[i].vPosition.x - x); | |
456 if ( v26 <= pStationaryLightsStack->pLights[i].uRadius) | |
0 | 457 { |
2251 | 458 v40 = abs(pStationaryLightsStack->pLights[i].vPosition.y - y); |
459 if ( v40 <= pStationaryLightsStack->pLights[i].uRadius) | |
0 | 460 { |
2251 | 461 v37 = abs(pStationaryLightsStack->pLights[i].vPosition.z - z); |
462 if ( v37 <= pStationaryLightsStack->pLights[i].uRadius) | |
0 | 463 { |
2235
6ab7d7c112bb
adding int_get_vector_length calls where the calls were inlined
Grumpy7
parents:
2216
diff
changeset
|
464 v45 = int_get_vector_length(v26, v40, v37); |
2251 | 465 //v33 = pStationaryLightsStack->pLights[i].uRadius; |
466 if ( (signed int)v45 < pStationaryLightsStack->pLights[i].uRadius ) | |
467 v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / pStationaryLightsStack->pLights[i].uRadius) >> 16) - 30; | |
0 | 468 } |
469 } | |
470 } | |
471 } | |
472 | |
473 if ( v6 <= 31 ) | |
474 { | |
475 if ( v6 < 0 ) | |
476 v6 = 0; | |
477 } | |
478 else | |
479 v6 = 31; | |
480 return v6; | |
481 } | |
482 | |
483 | |
484 | |
485 //----- (004075DB) -------------------------------------------------------- | |
2114 | 486 bool __fastcall sub_4075DB(int x, int y, int z, BLVFace *face) |
0 | 487 { |
488 int v8; // edi@2 | |
489 signed int v25; // eax@22 | |
490 bool result; // eax@25 | |
491 signed int a3a; // [sp+24h] [bp+8h]@14 | |
492 int a4a; // [sp+28h] [bp+Ch]@2 | |
493 | |
2000 | 494 std::array<int, 52> dword_4F5CC8_ys; // idb |
495 std::array<int, 52> dword_4F5D98_xs; // idb | |
496 | |
1493 | 497 //__debugbreak(); |
1458 | 498 |
2114 | 499 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 500 { |
1616 | 501 a4a = x; |
502 v8 = y; | |
2114 | 503 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 504 { |
2114 | 505 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].x; |
506 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].y; | |
1471 | 507 } |
0 | 508 } |
509 else | |
510 { | |
1616 | 511 v8 = z; |
2114 | 512 if ( face->uAttributes & FACE_XZ_PLANE ) |
0 | 513 { |
1616 | 514 a4a = x; |
2114 | 515 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 516 { |
2114 | 517 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].x; |
518 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].z; | |
1471 | 519 } |
0 | 520 } |
521 else | |
522 { | |
1616 | 523 a4a = y; |
2114 | 524 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 525 { |
2114 | 526 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].y; |
527 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].z; | |
1471 | 528 } |
0 | 529 } |
530 } | |
531 a3a = 0; | |
2114 | 532 dword_4F5D98_xs[face->uNumVertices] = dword_4F5D98_xs[0]; |
533 dword_4F5CC8_ys[face->uNumVertices] = dword_4F5CC8_ys[0]; | |
534 for(int i = 0; i < face->uNumVertices && a3a < 2; i++) | |
0 | 535 { |
1615 | 536 if ( dword_4F5CC8_ys[i] >= v8 ^ (dword_4F5CC8_ys[i + 1] >= v8) ) |
0 | 537 { |
1615 | 538 //if( dword_4F5D98_xs[i + 1] >= a4a || dword_4F5D98_xs[i] >= a4a) |
539 if( !(dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] < a4a)) | |
0 | 540 { |
1615 | 541 if ( (dword_4F5D98_xs[i + 1] < a4a && dword_4F5D98_xs[i] >= a4a) ) |
542 ++a3a; | |
543 //|| (v25 = dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i],LODWORD(v26) = v25 << 16, HIDWORD(v26) = v25 >> 16, | |
544 //dword_4F5D98_xs[i] + ((signed int)(((unsigned __int64)(v26 / (dword_4F5CC4_ys[i + 2] - dword_4F5CC4_ys[i + 1])* ((v8 - dword_4F5CC4_ys[i + 1]) << 16)) >> 16) | |
545 // + 32768) >> 16) >= a4a) ) | |
546 else | |
547 { | |
1643 | 548 v25 = fixpoint_div(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]); |
2114 | 549 if( dword_4F5D98_xs[i] + (fixpoint_mul(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 0x8000 >> 16) >= a4a) |
1615 | 550 ++a3a; |
551 } | |
0 | 552 } |
553 } | |
554 } | |
555 result = 1; | |
556 if ( a3a != 1 ) | |
557 result = 0; | |
558 return result; | |
559 } | |
560 | |
561 //----- (004077F1) -------------------------------------------------------- | |
2114 | 562 bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *face, BSPVertexBuffer *a5) |
0 | 563 { |
564 int a4a; // [sp+28h] [bp+Ch]@2 | |
565 signed int a5a; // [sp+2Ch] [bp+10h]@14 | |
566 | |
2000 | 567 std::array<int, 52> dword_4F5B24_ys; // idb |
568 std::array<int, 52> dword_4F5BF4_xs; // idb | |
2114 | 569 |
2057 | 570 //__debugbreak(); //срабатывает при нападении стрекозавров с огнём |
1458 | 571 |
2114 | 572 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 573 { |
574 a4a = a1; | |
575 a3 = a2; | |
2114 | 576 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
577 { |
2114 | 578 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].x; |
579 dword_4F5B24_ys[i+1] = a5->pVertices[face->pVertexIDs[i]].y; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
580 } |
0 | 581 } |
582 else | |
583 { | |
2114 | 584 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 585 { |
586 a4a = a1; | |
2114 | 587 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
588 { |
2114 | 589 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].x; |
590 dword_4F5B24_ys[i+1] = a5->pVertices[face->pVertexIDs[i]].z; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
591 } |
0 | 592 } |
593 else | |
594 { | |
595 a4a = a2; | |
2114 | 596 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
597 { |
2114 | 598 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].y; |
599 dword_4F5B24_ys[i+1] = a5->pVertices[face->pVertexIDs[i]].z; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
600 } |
0 | 601 } |
602 } | |
603 a5a = 0; | |
2114 | 604 dword_4F5BF4_xs[face->uNumVertices + 1] = dword_4F5BF4_xs[1]; |
605 dword_4F5B24_ys[face->uNumVertices + 1] = dword_4F5B24_ys[1]; | |
606 for(int i = 0; i < face->uNumVertices; i++) | |
0 | 607 { |
608 if ( a5a >= 2 ) | |
609 break; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
610 if ( dword_4F5B24_ys[i + 1] >= a3 ^ (dword_4F5B24_ys[i + 2] >= a3) ) |
0 | 611 { |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
612 if( dword_4F5BF4_xs[i + 2] >= a4a || dword_4F5BF4_xs[i] >= a4a) |
0 | 613 { |
1545 | 614 if (dword_4F5BF4_xs[i + 2] >= a4a && dword_4F5BF4_xs[i + 1] >= a4a) |
615 ++a5a; | |
616 else | |
617 { | |
2114 | 618 //v23 = (__int64)(dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1]) << 16; |
1545 | 619 __int64 _a = dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1]; |
620 __int64 _b = (__int64)(a3 - dword_4F5B24_ys[i + 1]) << 16; | |
621 | |
2114 | 622 if (dword_4F5BF4_xs[i + 1] + ((((((__int64)(dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1]) << 16) / _a * _b) >> 16) + 0x8000) >> 16) >= a4a) |
1545 | 623 ++a5a; |
624 } | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
625 } |
0 | 626 } |
627 } | |
1545 | 628 |
0 | 629 if ( a5a != 1 ) |
1545 | 630 return false; |
631 return true; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
632 |
0 | 633 } |
634 | |
635 | |
636 //----- (0040F82D) -------------------------------------------------------- | |
637 void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue) | |
638 { | |
973 | 639 assert(uTextureId != -1); |
640 ZBuffer_DoFill(pZBuffer, pIcons_LOD->GetTexture(uTextureId), iZValue); | |
0 | 641 } |
642 | |
643 //----- (0040F89C) -------------------------------------------------------- | |
644 void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue) | |
2114 | 645 {//срабатывает при продаже в магазине |
0 | 646 void *v3; // eax@3 |
2114 | 647 //void *v4; // esi@5 |
648 //int *v5; // edi@5 | |
649 //int v6; // eax@5 | |
2334 | 650 // int v7; // ecx@6 |
651 // int v11; // [sp+18h] [bp-8h]@1 | |
2114 | 652 //void *v12; // [sp+1Ch] [bp-4h]@5 |
0 | 653 |
654 if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize ) | |
655 v3 = pTex->UnzipPalette(); | |
656 else | |
710 | 657 v3 = pTex->pLevelOfDetail0_prolly_alpha_mask; |
2114 | 658 //v12 = v3; |
659 //v4 = v3; | |
660 //v5 = pZBuffer; | |
661 //v6 = 0; | |
662 for ( uint i = 0; i < pTex->uTextureHeight; i++ ) | |
0 | 663 { |
2114 | 664 for ( uint j = 0; j < pTex->uTextureWidth; j++ ) |
0 | 665 { |
2114 | 666 //LOBYTE(v6) = *(char *)v4; |
667 //v4 = (char *)v4 + 1; | |
668 //if ( v6 ) | |
669 *pZBuffer = uZValue; | |
670 ++pZBuffer; | |
0 | 671 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
672 pZBuffer += window->GetWidth() - pTex->uTextureWidth; |
0 | 673 } |
674 if ( pIcons_LOD->dword_011BA4 ) | |
675 { | |
2114 | 676 if ( pTex->uDecompressedSize ) |
677 free(v3); | |
0 | 678 } |
679 } | |
680 | |
681 //----- (0040F92A) -------------------------------------------------------- | |
1458 | 682 void __fastcall ZBuffer_DoFill2(int *pZBuffer, Texture *a2, int a3) |
2114 | 683 {//срабатывает в покупке в магазине |
0 | 684 void *v4; // eax@3 |
2114 | 685 //int *v5; // edi@5 |
2334 | 686 // int v6; // ecx@6 |
687 // int v9; // [sp+18h] [bp-4h]@1 | |
0 | 688 |
689 if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize ) | |
690 v4 = a2->UnzipPalette(); | |
691 else | |
710 | 692 v4 = a2->pLevelOfDetail0_prolly_alpha_mask; |
2114 | 693 //v5 = pZBuffer; |
694 for ( uint i = 0; i < a2->uTextureHeight; i++ ) | |
0 | 695 { |
2114 | 696 for ( uint j = 0; j < a2->uTextureWidth; j++ ) |
0 | 697 { |
2114 | 698 *pZBuffer = a3; |
699 ++pZBuffer; | |
0 | 700 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
701 pZBuffer += window->GetWidth() - a2->uTextureWidth; |
0 | 702 } |
703 if ( pIcons_LOD->dword_011BA4 ) | |
704 { | |
2114 | 705 if ( a2->uDecompressedSize ) |
0 | 706 free(v4); |
707 } | |
708 } | |
709 | |
710 | |
711 // 4E28F8: using guessed type int pCurrentScreen; | |
712 | |
713 //----- (00417AD4) -------------------------------------------------------- | |
983 | 714 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) |
1393 | 715 { |
716 switch (uPlayerClass % 4) | |
269 | 717 { |
1393 | 718 case 0: |
269 | 719 { |
1393 | 720 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) |
721 return ui_character_skillinfo_can_learn; | |
722 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level && | |
723 byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) | |
724 { | |
725 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType] < skill_level) | |
726 return ui_character_skillinfo_cant_learn; | |
727 } | |
728 return ui_character_skillinfo_can_learn_gm; | |
0 | 729 } |
1393 | 730 break; |
731 | |
732 case 1: | |
269 | 733 { |
1393 | 734 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) |
735 return ui_character_skillinfo_can_learn; | |
736 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level) | |
737 { | |
738 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) | |
739 return ui_character_skillinfo_cant_learn; | |
740 } | |
741 return ui_character_skillinfo_can_learn_gm; | |
0 | 742 } |
1393 | 743 break; |
744 | |
745 case 2: | |
746 case 3: | |
747 { | |
748 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level) | |
749 return ui_character_skillinfo_cant_learn; | |
750 return ui_character_skillinfo_can_learn; | |
751 } | |
752 break; | |
0 | 753 } |
1575 | 754 Error("Invalid player class: %u", uPlayerClass); |
1296 | 755 } |