Mercurial > mm7
annotate mm7_5.cpp @ 2343:5d263539bbec
Moving functions from unsorted_subs.h pt5
author | Grumpy7 |
---|---|
date | Sun, 06 Apr 2014 21:12:24 +0200 |
parents | 1e865e8690ba |
children | 4100fb5c4913 |
rev | line source |
---|---|
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
|
1 #define _CRT_SECURE_NO_WARNINGS |
2336 | 2 #include "ErrorHandling.h" |
1016 | 3 #include "LightmapBuilder.h" |
0 | 4 #include "mm7.h" |
5 #include "GUIWindow.h" | |
6 #include "Party.h" | |
7 #include "Outdoor.h" | |
8 #include "LOD.h" | |
9 #include "Actor.h" | |
10 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2006
diff
changeset
|
11 #include "OurMath.h" |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
513
diff
changeset
|
12 #include "SpriteObject.h" |
2044 | 13 #include "Timer.h" |
0 | 14 #include "stru298.h" |
1262 | 15 #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
|
16 #include "Level/Decoration.h" |
2336 | 17 #include "mm7_unsorted_subs.h" |
18 #include "mm7_data.h" | |
0 | 19 |
2207 | 20 |
0 | 21 //----- (004356FF) -------------------------------------------------------- |
1575 | 22 void back_to_game() |
0 | 23 { |
24 dword_507BF0_is_there_popup_onscreen = 0; | |
25 dword_4E455C = 1; | |
1575 | 26 |
27 extern int no_rightlick_in_inventory; | |
28 no_rightlick_in_inventory = false; | |
29 | |
0 | 30 if ( pGUIWindow_ScrollWindow ) |
31 free_book_subwindow(); | |
32 if ( !pCurrentScreen && !pGUIWindow_Settings ) | |
33 pEventTimer->Resume(); | |
34 viewparams->bRedrawGameUI = 1; | |
35 } | |
782 | 36 |
0 | 37 //----- (004369DB) -------------------------------------------------------- |
38 void Vec3_float_::Normalize() | |
39 { | |
1025 | 40 this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x; |
41 this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y; | |
42 this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z; | |
0 | 43 } |
44 | |
45 //----- (00438F8F) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1384
diff
changeset
|
46 void area_of_effect__damage_evaluate() |
0 | 47 { |
2059 | 48 int attacker_type; // ecx@3 |
0 | 49 signed int v3; // eax@3 |
2059 | 50 unsigned int target_id; // edi@6 |
51 int target_type; // eax@6 | |
0 | 52 int v10; // edi@8 |
2059 | 53 Vec3_int_ attacker_coord; // ST04_12@9 |
2334 | 54 // int v12; // ST0C_4@10 |
0 | 55 int v15; // edx@15 |
56 int v19; // edi@15 | |
57 int v23; // edx@18 | |
58 int v24; // eax@18 | |
2334 | 59 // int v30; // eax@29 |
0 | 60 int v31; // edx@29 |
61 int v32; // eax@29 | |
62 int v33; // ST24_4@29 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
513
diff
changeset
|
63 SpriteObject *v36; // [sp+0h] [bp-28h]@0 |
2059 | 64 int attacker_id; // [sp+10h] [bp-18h]@1 |
0 | 65 int v44; // [sp+14h] [bp-14h]@15 |
2059 | 66 //Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2 |
2205 | 67 signed int a1; // [sp+20h] [bp-8h]@8 |
0 | 68 int v48; // [sp+24h] [bp-4h]@8 |
69 | |
2059 | 70 |
71 for ( attacker_id = 0; attacker_id < AttackerInfo.count; ++attacker_id ) | |
0 | 72 { |
2059 | 73 attacker_type = PID_TYPE(AttackerInfo.pIDs[attacker_id]); |
74 v3 = PID_ID(AttackerInfo.pIDs[attacker_id]); | |
2057 | 75 |
2059 | 76 if ( attacker_type == 2 ) |
77 { | |
78 v36 = &pSpriteObjects[v3]; | |
79 attacker_type = PID_TYPE(pSpriteObjects[v3].spell_caster_pid); | |
80 v3 = PID_ID(pSpriteObjects[v3].spell_caster_pid); | |
81 } | |
2057 | 82 |
2059 | 83 if ( AttackerInfo.field_3EC[attacker_id] & 1 ) |
84 { | |
85 target_id = PID_ID(ai_near_actors_targets_pid[v3]); | |
86 target_type = PID_TYPE(ai_near_actors_targets_pid[v3]) - 3; | |
87 if ( target_type ) | |
0 | 88 { |
2059 | 89 if ( target_type == 1 )//party damage from monsters(повреждения группе от монстров) |
0 | 90 { |
2059 | 91 v10 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
92 a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; | |
2117 | 93 v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 94 if ( a1 * a1 + v10 * v10 |
95 + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) | |
96 * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) | |
97 < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32)) ) | |
0 | 98 { |
2059 | 99 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
100 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
101 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
102 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord) ) | |
103 DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], stru_50C198.which_player_to_attack(&pActors[v3])); | |
0 | 104 } |
105 } | |
2059 | 106 } |
107 else//Actor damage from monsters(повреждение местного жителя) | |
108 { | |
109 if ( SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) > 0 | |
110 || SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) >= 0 | |
111 && LODWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) | |
112 || pActors[target_id].CanAct() ) | |
0 | 113 { |
2059 | 114 v15 = pActors[target_id].vPosition.y - AttackerInfo.pYs[attacker_id]; |
115 a1 = pActors[target_id].vPosition.x - AttackerInfo.pXs[attacker_id]; | |
116 v44 = pActors[target_id].vPosition.z; | |
117 v19 = AttackerInfo.pYs[attacker_id] + pActors[target_id].uActorRadius; | |
118 v48 = v15; | |
119 if ( a1 * a1 + v15 * v15 + (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) | |
120 * (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) < (unsigned int)(v19 * v19) ) | |
0 | 121 { |
2059 | 122 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
123 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
124 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
125 if ( sub_407A1C(pActors[target_id].vPosition.x, pActors[target_id].vPosition.y, pActors[target_id].vPosition.z + 50, attacker_coord) ) | |
0 | 126 { |
2059 | 127 Vec3_int_::Normalize(&a1, &v48, &v44); |
128 AttackerInfo.vec_4B4[attacker_id].x = a1; | |
129 AttackerInfo.vec_4B4[attacker_id].y = v48; | |
130 AttackerInfo.vec_4B4[attacker_id].z = v44; | |
2310 | 131 Actor::ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], target_id, &AttackerInfo.vec_4B4[attacker_id], AttackerInfo.field_450[attacker_id]); |
0 | 132 } |
133 } | |
134 } | |
135 } | |
2059 | 136 } |
137 else //damage from spells(повреждения от заклов(метеоритный дождь)) | |
138 { | |
139 v23 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; | |
2216 | 140 v24 = ((signed int)pParty->uPartyHeight / 2) - AttackerInfo.pZs[attacker_id]; |
2059 | 141 a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; |
2117 | 142 v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 143 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)) ) |
144 {//party damage (повреждения группе) | |
145 attacker_coord.x = AttackerInfo.pXs[attacker_id]; | |
146 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
147 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
148 if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord) ) | |
149 { | |
150 for ( uint i = 0; i < 4; ++i ) | |
0 | 151 { |
2059 | 152 if ( !(HIDWORD(pParty->pPlayers[i].pConditions[Condition_Dead]) | LODWORD(pParty->pPlayers[i].pConditions[Condition_Dead])) |
153 && !pParty->pPlayers[i].pConditions[Condition_Pertified] && !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) | |
154 DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], i); | |
0 | 155 } |
156 } | |
2059 | 157 } |
158 if ( (signed int)uNumActors > 0 ) | |
159 {//actors damage(повреждения другим участникам) | |
160 for ( int actorID = 0; (signed int)actorID < (signed int)uNumActors; ++actorID ) | |
161 { | |
162 if ( pActors[actorID].CanAct() ) | |
0 | 163 { |
2205 | 164 //v30 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 165 a1 = pActors[actorID].vPosition.x - AttackerInfo.pXs[attacker_id]; |
166 v31 = pActors[actorID].vPosition.z; | |
2205 | 167 v48 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; |
2059 | 168 v44 = pActors[actorID].vPosition.z; |
2205 | 169 v32 = (pActors[actorID].uActorHeight / 2) - AttackerInfo.pZs[attacker_id]; |
2059 | 170 v33 = pActors[actorID].uActorRadius + AttackerInfo.pYs[attacker_id]; |
171 if ( a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33) ) | |
0 | 172 { |
2059 | 173 attacker_coord.x = AttackerInfo.pXs[attacker_id]; |
174 attacker_coord.y = AttackerInfo.pYs[attacker_id]; | |
175 attacker_coord.z = AttackerInfo.pZs[attacker_id]; | |
2205 | 176 if ( sub_407A1C(pActors[actorID].vPosition.x, pActors[actorID].vPosition.y, pActors[actorID].vPosition.z + 50, attacker_coord) )//что делает ф-ция? |
0 | 177 { |
2059 | 178 Vec3_int_::Normalize(&a1, &v48, &v44); |
179 AttackerInfo.vec_4B4[attacker_id].x = a1; | |
180 AttackerInfo.vec_4B4[attacker_id].y = v48; | |
181 AttackerInfo.vec_4B4[attacker_id].z = v44; | |
182 switch ( attacker_type ) | |
0 | 183 { |
2059 | 184 case OBJECT_Player: |
2338
1e865e8690ba
Moving some function declarations from unsorted subs to Actor.h and SpriteObject.h
Grumpy7
parents:
2336
diff
changeset
|
185 Actor::DamageMonsterFromParty(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); |
2059 | 186 break; |
187 case OBJECT_Actor: | |
188 if ( v36 && pActors[v3].GetActorsRelation(&pActors[actorID]) ) | |
2310 | 189 Actor::ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id], v36->field_61); |
2059 | 190 break; |
191 case OBJECT_Item: | |
2132 | 192 ItemDamageFromActor(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); |
2059 | 193 break; |
0 | 194 } |
195 } | |
196 } | |
197 } | |
198 } | |
199 } | |
200 } | |
201 } | |
2059 | 202 AttackerInfo.count = 0; |
0 | 203 } |
204 | |
205 | |
206 //----- (0043A97E) -------------------------------------------------------- | |
207 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2) | |
208 { | |
1979 | 209 if (PID_TYPE(a2) == OBJECT_Player) |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
210 { |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
211 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
212 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
213 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
214 |
0 | 215 Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); |
2006 | 216 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
|
217 } |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
218 else if (PID_TYPE(a2) == OBJECT_Actor) |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
219 { |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
220 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
221 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
222 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; |
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 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
|
225 switch (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid)) |
0 | 226 { |
227 case OBJECT_Actor: | |
2310 | 228 Actor::ActorDamageFromMonster(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC, pSpriteObjects[uLayingItemID].field_61); |
0 | 229 break; |
230 case OBJECT_Player: | |
2338
1e865e8690ba
Moving some function declarations from unsorted subs to Actor.h and SpriteObject.h
Grumpy7
parents:
2336
diff
changeset
|
231 Actor::DamageMonsterFromParty(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); |
0 | 232 break; |
233 case OBJECT_Item: | |
2132 | 234 ItemDamageFromActor(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); |
0 | 235 break; |
236 } | |
237 } | |
238 } | |
239 | |
240 //----- (0043AE12) -------------------------------------------------------- | |
241 double __fastcall sub_43AE12(signed int a1) | |
242 { | |
2117 | 243 //signed int v1; // ST00_4@1 |
0 | 244 signed int v2; // ecx@1 |
245 double v3; // st7@1 | |
246 double result; // st7@6 | |
247 | |
2117 | 248 v3 = (double)a1; |
249 for ( v2 = 0; v2 < 5; ++v2 ) | |
0 | 250 { |
251 if ( v3 < flt_4E4A80[v2 + 5] ) | |
252 break; | |
253 } | |
254 if ( v2 <= 0 || v2 >= 5 ) | |
255 { | |
256 if ( v2 ) | |
257 result = flt_4E4A80[4]; | |
258 else | |
259 result = flt_4E4A80[0]; | |
260 } | |
261 else | |
1469 | 262 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 | 263 return result; |
264 } | |
265 | |
266 //----- (0043B057) -------------------------------------------------------- | |
2132 | 267 void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) |
0 | 268 { |
269 int v6; // eax@4 | |
2132 | 270 int damage; // edi@4 |
0 | 271 int a2a; // [sp+Ch] [bp-4h]@8 |
272 | |
303 | 273 if ( !pActors[uActorID].IsNotAlive() ) |
0 | 274 { |
2117 | 275 if ( PID_TYPE(uObjID) == OBJECT_Item) |
848 | 276 { |
2117 | 277 if ( pSpriteObjects[PID_ID(uObjID)].spell_id ) |
0 | 278 { |
2117 | 279 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
|
280 damage = pActors[uActorID].CalcMagicalDamageToActor((DAMAGE_TYPE)0, v6); |
2132 | 281 pActors[uActorID].sCurrentHP -= damage; |
282 if ( damage ) | |
0 | 283 { |
2117 | 284 if ( pActors[uActorID].sCurrentHP > 0 ) |
285 Actor::AI_Stun(uActorID, uObjID, 0); | |
0 | 286 else |
2117 | 287 Actor::Die(uActorID); |
2132 | 288 a2a = 20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP; |
289 if ( 20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP > 10 ) | |
0 | 290 a2a = 10; |
2117 | 291 if ( !MonsterStats::BelongsToSupertype(pActors[uActorID].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) |
0 | 292 { |
2207 | 293 pVelocity->x = fixpoint_mul(a2a, pVelocity->x); |
294 pVelocity->y = fixpoint_mul(a2a, pVelocity->y); | |
295 pVelocity->z = fixpoint_mul(a2a, pVelocity->z); | |
2117 | 296 pActors[uActorID].vVelocity.x = 50 * LOWORD(pVelocity->x); |
297 pActors[uActorID].vVelocity.y = 50 * LOWORD(pVelocity->y); | |
298 pActors[uActorID].vVelocity.z = 50 * LOWORD(pVelocity->z); | |
0 | 299 } |
2132 | 300 Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, damage); |
0 | 301 } |
302 else | |
2117 | 303 Actor::AI_Stun(uActorID, uObjID, 0); |
0 | 304 } |
305 } | |
306 } | |
307 } | |
308 | |
309 | |
310 //----- (0043F515) -------------------------------------------------------- | |
657 | 311 void FindBillboardsLightLevels_BLV() |
0 | 312 { |
313 for (uint i = 0; i < uNumBillboardsToDraw; ++i) | |
314 { | |
2114 | 315 if (pBillboardRenderList[i].field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !pBillboardRenderList[i].uIndoorSectorID) |
316 pBillboardRenderList[i].dimming_level = 0; | |
0 | 317 else |
2114 | 318 pBillboardRenderList[i].dimming_level = _43F55F_get_billboard_light_level(&pBillboardRenderList[i], -1); |
0 | 319 } |
320 } | |
321 | |
322 //----- (0043F55F) -------------------------------------------------------- | |
323 int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel) | |
324 { | |
325 signed int v3; // ecx@2 | |
326 | |
327 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
328 v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel; | |
329 else | |
330 { | |
331 if ( uBaseLightLevel == -1 ) | |
657 | 332 v3 = a1->dimming_level; |
0 | 333 else |
334 v3 = uBaseLightLevel; | |
335 } | |
430 | 336 return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->world_x, a1->world_y, a1->world_z); |
0 | 337 } |
338 | |
339 //----- (0043F5C8) -------------------------------------------------------- | |
340 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z) | |
341 { | |
2334 | 342 // int v5; // esi@1 |
0 | 343 signed int v6; // edi@1 |
344 int v8; // eax@6 | |
345 int v9; // ebx@6 | |
346 unsigned int v10; // ecx@6 | |
347 unsigned int v11; // edx@9 | |
348 unsigned int v12; // edx@11 | |
349 signed int v13; // ecx@12 | |
350 BLVLightMM7 *v16; // esi@20 | |
351 int v17; // ebx@21 | |
2334 | 352 // int v18; // eax@24 |
353 // int v19; // ebx@24 | |
354 // unsigned int v20; // ecx@24 | |
355 // int v21; // edx@25 | |
356 // unsigned int v22; // edx@27 | |
357 // unsigned int v23; // edx@29 | |
0 | 358 signed int v24; // ecx@30 |
359 int v26; // ebx@35 | |
2334 | 360 // int v27; // eax@38 |
361 // int v28; // ebx@38 | |
362 // unsigned int v29; // ecx@38 | |
363 // int v30; // edx@39 | |
364 // unsigned int v31; // edx@41 | |
365 // unsigned int v32; // edx@43 | |
2251 | 366 //signed int v33; // ecx@44 |
0 | 367 int v37; // [sp+Ch] [bp-18h]@37 |
2334 | 368 // int v38; // [sp+10h] [bp-14h]@5 |
0 | 369 int v39; // [sp+10h] [bp-14h]@23 |
370 int v40; // [sp+10h] [bp-14h]@36 | |
371 int v42; // [sp+14h] [bp-10h]@22 | |
372 unsigned int v43; // [sp+18h] [bp-Ch]@12 | |
373 unsigned int v44; // [sp+18h] [bp-Ch]@30 | |
374 unsigned int v45; // [sp+18h] [bp-Ch]@44 | |
375 | |
376 v6 = uBaseLightLevel; | |
377 for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) | |
378 { | |
1980 | 379 MobileLight* p = &pMobileLightsStack->pLights[i]; |
0 | 380 |
1980 | 381 float distX = abs(p->vPosition.x - x); |
0 | 382 if ( distX <= p->uRadius) |
383 { | |
1980 | 384 float distY = abs(p->vPosition.y - y); |
0 | 385 if ( distY <= p->uRadius) |
386 { | |
1980 | 387 float distZ = abs(p->vPosition.z - z); |
0 | 388 if ( distZ <= p->uRadius) |
389 { | |
390 v8 = distX; | |
391 v9 = distY; | |
392 v10 = distZ; | |
393 if (distX < distY) | |
394 { | |
395 v8 = distY; | |
396 v9 = distX; | |
397 } | |
398 if ( v8 < distZ ) | |
399 { | |
400 v11 = v8; | |
401 v8 = distZ; | |
402 v10 = v11; | |
403 } | |
404 if ( v9 < (signed int)v10 ) | |
405 { | |
406 v12 = v10; | |
407 v10 = v9; | |
408 v9 = v12; | |
409 } | |
410 v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8; | |
411 v13 = p->uRadius; | |
412 if ( (signed int)v43 < v13 ) | |
413 v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30; | |
414 } | |
415 } | |
416 } | |
417 } | |
418 | |
419 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
420 { | |
1980 | 421 BLVSector* pSector = &pIndoor->pSectors[uSectorID]; |
0 | 422 |
423 for (uint i = 0; i < pSector->uNumLights; ++i) | |
424 { | |
425 v16 = pIndoor->pLights + pSector->pLights[i]; | |
426 if (~v16->uAtributes & 8) | |
427 { | |
428 v17 = abs(v16->vPosition.x - x); | |
429 if ( v17 <= v16->uRadius ) | |
430 { | |
431 v42 = abs(v16->vPosition.y - y); | |
432 if ( v42 <= v16->uRadius ) | |
433 { | |
434 v39 = abs(v16->vPosition.z - z); | |
435 if ( v39 <= v16->uRadius ) | |
436 { | |
2235
6ab7d7c112bb
adding int_get_vector_length calls where the calls were inlined
Grumpy7
parents:
2216
diff
changeset
|
437 v44 = int_get_vector_length(v17, v42, v39); |
0 | 438 v24 = v16->uRadius; |
439 if ( (signed int)v44 < v24 ) | |
440 v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30; | |
441 } | |
442 } | |
443 } | |
444 } | |
445 } | |
446 } | |
447 | |
448 for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) | |
449 { | |
2251 | 450 //StationaryLight* p = &pStationaryLightsStack->pLights[i]; |
451 v26 = abs(pStationaryLightsStack->pLights[i].vPosition.x - x); | |
452 if ( v26 <= pStationaryLightsStack->pLights[i].uRadius) | |
0 | 453 { |
2251 | 454 v40 = abs(pStationaryLightsStack->pLights[i].vPosition.y - y); |
455 if ( v40 <= pStationaryLightsStack->pLights[i].uRadius) | |
0 | 456 { |
2251 | 457 v37 = abs(pStationaryLightsStack->pLights[i].vPosition.z - z); |
458 if ( v37 <= pStationaryLightsStack->pLights[i].uRadius) | |
0 | 459 { |
2235
6ab7d7c112bb
adding int_get_vector_length calls where the calls were inlined
Grumpy7
parents:
2216
diff
changeset
|
460 v45 = int_get_vector_length(v26, v40, v37); |
2251 | 461 //v33 = pStationaryLightsStack->pLights[i].uRadius; |
462 if ( (signed int)v45 < pStationaryLightsStack->pLights[i].uRadius ) | |
463 v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / pStationaryLightsStack->pLights[i].uRadius) >> 16) - 30; | |
0 | 464 } |
465 } | |
466 } | |
467 } | |
468 | |
469 if ( v6 <= 31 ) | |
470 { | |
471 if ( v6 < 0 ) | |
472 v6 = 0; | |
473 } | |
474 else | |
475 v6 = 31; | |
476 return v6; | |
477 } | |
478 | |
479 | |
480 //----- (004070EF) -------------------------------------------------------- | |
1493 | 481 bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID) |
0 | 482 { |
483 signed int v2; // eax@1 | |
2334 | 484 // int v5; // ecx@2 |
1615 | 485 int obj1_sector; // eax@4 |
0 | 486 float v8; // ST24_4@5 |
2334 | 487 // double v9; // ST18_8@5 |
488 // int v11; // ecx@6 | |
0 | 489 signed int v12; // eax@7 |
2334 | 490 // int v13; // esi@7 |
491 // int v14; // esi@8 | |
492 // int v15; // esi@9 | |
1493 | 493 int obj2_z; // edi@11 |
494 int obj2_x; // esi@11 | |
495 int obj2_sector; // eax@13 | |
0 | 496 float v20; // ST24_4@14 |
2334 | 497 // double v21; // ST18_8@14 |
1615 | 498 int dist_x; // ebx@16 |
499 signed int dist_3d; // ecx@16 | |
0 | 500 int v25; // eax@18 |
501 BLVFace *v29; // ebx@32 | |
502 Vec3_short_ *v30; // esi@32 | |
503 int v31; // eax@32 | |
504 int v32; // ST50_4@44 | |
505 int v33; // ST54_4@44 | |
506 int v34; // eax@44 | |
507 signed int v38; // esi@45 | |
2334 | 508 // signed __int64 v40; // qtt@50 |
1615 | 509 __int16 next_sector; // bx@58 |
2334 | 510 // int v43; // [sp-8h] [bp-70h]@11 |
511 // int v44; // [sp-4h] [bp-6Ch]@11 | |
0 | 512 int v47; // [sp+18h] [bp-50h]@20 |
513 int v48; // [sp+1Ch] [bp-4Ch]@20 | |
514 int v49; // [sp+20h] [bp-48h]@20 | |
1615 | 515 int dist_z; // [sp+24h] [bp-44h]@16 |
516 signed int higher_z; // [sp+24h] [bp-44h]@27 | |
517 signed int lower_z; // [sp+28h] [bp-40h]@26 | |
518 signed int higher_y; // [sp+2Ch] [bp-3Ch]@23 | |
519 signed int lower_y; // [sp+30h] [bp-38h]@22 | |
520 signed int higher_x; // [sp+34h] [bp-34h]@21 | |
521 signed int lower_x; // [sp+38h] [bp-30h]@20 | |
522 signed int sectors_visited; // [sp+3Ch] [bp-2Ch]@28 | |
0 | 523 int v58; // [sp+44h] [bp-24h]@50 |
524 int v59; // [sp+48h] [bp-20h]@44 | |
1493 | 525 int obj2_y; // [sp+50h] [bp-18h]@11 |
1615 | 526 int obj1_x; // [sp+58h] [bp-10h]@4 |
527 int obj1_y; // [sp+5Ch] [bp-Ch]@4 | |
528 int obj1_z; // [sp+60h] [bp-8h]@4 | |
529 int current_sector; // [sp+64h] [bp-4h]@7 | |
530 int dist_y; | |
531 int v70; | |
0 | 532 |
848 | 533 v2 = PID_ID(uObjID); |
1615 | 534 switch( PID_TYPE(uObjID) ) |
0 | 535 { |
1615 | 536 case OBJECT_Decoration: |
537 obj1_x = pLevelDecorations[v2].vPosition.x; | |
538 obj1_y = pLevelDecorations[v2].vPosition.y; | |
539 obj1_z = pLevelDecorations[v2].vPosition.z; | |
540 obj1_sector = pIndoor->GetSector(obj1_x, obj1_y, obj1_z); | |
541 break; | |
542 case OBJECT_Actor: | |
543 obj1_x = pActors[v2].vPosition.x; | |
544 obj1_y = pActors[v2].vPosition.y; | |
0 | 545 v8 = (double)pActors[v2].uActorHeight * 0.69999999; |
1493 | 546 //v9 = v8 + 6.7553994e15; |
1615 | 547 //obj1_z = LODWORD(v9) + pActors[v2].vPosition.z; |
548 obj1_z = (int)v8 + pActors[v2].vPosition.z; | |
549 obj1_sector = pActors[v2].uSectorID; | |
550 break; | |
551 case OBJECT_Item: | |
552 obj1_x = pSpriteObjects[v2].vPosition.x; | |
553 obj1_y = pSpriteObjects[v2].vPosition.y; | |
554 obj1_z = pSpriteObjects[v2].vPosition.z; | |
555 obj1_sector = pSpriteObjects[v2].uSectorID; | |
556 break; | |
557 default: | |
558 return 0; | |
0 | 559 } |
1493 | 560 v12 = PID_ID(uObj2ID); |
1615 | 561 switch( PID_TYPE(uObj2ID) ) |
1493 | 562 { |
1615 | 563 case OBJECT_Decoration: |
564 obj2_z = pLevelDecorations[v12].vPosition.z; | |
565 obj2_x = pLevelDecorations[v12].vPosition.x; | |
566 obj2_y = pLevelDecorations[v12].vPosition.y; | |
567 obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); | |
568 break; | |
569 case OBJECT_Player: | |
570 obj2_x = pParty->vPosition.x; | |
571 obj2_z = pParty->sEyelevel + pParty->vPosition.z; | |
572 obj2_y = pParty->vPosition.y; | |
2114 | 573 obj2_sector = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); |
1615 | 574 break; |
575 case OBJECT_Actor: | |
576 obj2_y = pActors[v12].vPosition.y; | |
577 obj2_x = pActors[v12].vPosition.x; | |
578 v20 = (double)pActors[v12].uActorHeight * 0.69999999; | |
579 //v21 = v20 + 6.7553994e15; | |
580 //obj2_z = LODWORD(v21) + pActors[v12].vPosition.z; | |
581 obj2_z = (int)v20 + pActors[v12].vPosition.z; | |
582 obj2_sector = pActors[v12].uSectorID; | |
583 break; | |
584 case OBJECT_Item: | |
585 obj2_x = pSpriteObjects[v12].vPosition.x; | |
586 obj2_z = pSpriteObjects[v12].vPosition.z; | |
587 obj2_y = pSpriteObjects[v12].vPosition.y; | |
588 obj2_sector = pSpriteObjects[v12].uSectorID; | |
589 break; | |
590 default: | |
591 return 0; | |
1493 | 592 } |
1615 | 593 dist_x = obj2_x - obj1_x; |
594 dist_z = obj2_z - obj1_z; | |
595 dist_y = obj2_y - obj1_y; | |
596 dist_3d = integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z); | |
597 //range check | |
598 if ( dist_3d > 5120 ) | |
0 | 599 return 0; |
600 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
601 return 1; | |
602 v25 = 65536; | |
1615 | 603 if ( dist_3d ) |
604 v25 = 65536 / dist_3d; | |
605 v49 = dist_x * v25; | |
606 v47 = dist_z * v25; | |
607 v48 = dist_y * v25; | |
608 if ( obj1_x < obj2_x ) | |
0 | 609 { |
1615 | 610 lower_x = obj1_x; |
611 higher_x = obj2_x; | |
0 | 612 } |
613 else | |
614 { | |
1615 | 615 lower_x = obj2_x; |
616 higher_x = obj1_x; | |
0 | 617 } |
1615 | 618 if ( obj1_y < obj2_y ) |
0 | 619 { |
1615 | 620 lower_y = obj1_y; |
621 higher_y = obj2_y; | |
0 | 622 } |
623 else | |
624 { | |
1615 | 625 lower_y = obj2_y; |
626 higher_y = obj1_y; | |
0 | 627 } |
1615 | 628 if ( obj1_z < obj2_z ) |
0 | 629 { |
1615 | 630 lower_z = obj1_z; |
631 higher_z = obj2_z; | |
0 | 632 } |
633 else | |
634 { | |
1615 | 635 lower_z = obj2_z; |
636 higher_z = obj1_z; | |
0 | 637 } |
1615 | 638 sectors_visited = 0; |
639 //monster in same sector with player | |
640 if ( obj1_sector == obj2_sector ) | |
0 | 641 return 1; |
1615 | 642 //search starts from monster |
643 current_sector = obj1_sector; | |
644 for( int current_portal = 0; current_portal < pIndoor->pSectors[current_sector].uNumPortals; current_portal++ ) | |
645 { | |
646 v29 = &pIndoor->pFaces[pIndoor->pSectors[current_sector].pPortals[current_portal]]; | |
647 v30 = &pIndoor->pVertices[*v29->pVertexIDs]; | |
648 v31 = v29->pFacePlane_old.vNormal.z * (v30->z - obj1_z) | |
649 + v29->pFacePlane_old.vNormal.y * (v30->y - obj1_y) | |
650 + v29->pFacePlane_old.vNormal.x * (v30->x - obj1_x); | |
651 | |
652 if ( current_sector != v29->uSectorID ) | |
653 v31 = -v31; | |
654 | |
655 if ( v31 >= 0 && v30->x != obj1_x && v30->y != obj1_y && v30->z != obj1_z) | |
656 continue; | |
657 | |
658 if( lower_x > v29->pBounding.x2 | |
659 || higher_x < v29->pBounding.x1 | |
660 || lower_y > v29->pBounding.y2 | |
661 || higher_y < v29->pBounding.y1 | |
662 || lower_z > v29->pBounding.z2 | |
663 || higher_z < v29->pBounding.z1 ) | |
664 { | |
665 continue; | |
666 } | |
667 | |
1643 | 668 v32 = fixpoint_mul(v29->pFacePlane_old.vNormal.x,v49); |
669 v33 = fixpoint_mul(v29->pFacePlane_old.vNormal.z,v47); | |
670 v34 = fixpoint_mul(v29->pFacePlane_old.vNormal.y,v48); | |
1615 | 671 v59 = v32 + v33 + v34; |
672 if ( v59 ) | |
1493 | 673 { |
1615 | 674 v70 = v29->pFacePlane_old.dist |
675 + obj1_z * v29->pFacePlane_old.vNormal.z | |
676 + obj1_x * v29->pFacePlane_old.vNormal.x | |
677 + obj1_y * v29->pFacePlane_old.vNormal.y; | |
678 v38 = -v70; | |
679 | |
680 // if ( v59 <= 0 ^ v70 <= 0 ) | |
681 | |
682 /* TEMPORARY | |
683 if ( v59 <= 0 && v70 <= 0 ) | |
684 { | |
685 continue; | |
686 } | |
687 if ( !(v59 <= 0 && v70 <= 0) ) | |
688 { | |
689 continue; | |
690 } | |
691 */ | |
692 | |
693 if( abs(v38) >> 14 > abs(v59) ) | |
694 continue; | |
695 | |
1643 | 696 v58 = fixpoint_div(v38,v59); |
1615 | 697 |
698 if( v58 < 0 ) | |
2114 | 699 continue; |
1493 | 700 |
2114 | 701 if(!sub_4075DB(obj1_x + ((fixpoint_mul(v49,v58) + 32768) >> 16), obj1_y + ((fixpoint_mul(v48,v58) + 32768) >> 16), |
702 obj1_z + ((fixpoint_mul(v47,v58) + 32768) >> 16), v29) ) | |
1615 | 703 { |
1616 | 704 continue; |
1615 | 705 } |
706 | |
707 //if there is no next sector turn back | |
708 if ( v29->uSectorID == current_sector ) | |
709 next_sector = v29->uBackSectorID; | |
710 else | |
711 next_sector = v29->uSectorID; | |
712 | |
713 //no more portals, quit | |
714 if ( next_sector == current_sector ) | |
2114 | 715 break; |
1615 | 716 |
717 ++sectors_visited; | |
718 current_sector = next_sector; | |
719 | |
720 //found player, quit | |
721 if ( next_sector == obj2_sector ) | |
722 return 1; | |
723 | |
724 current_sector = next_sector; | |
725 | |
726 //did we hit limit for portals? | |
727 //does the next room have portals? | |
728 if ( sectors_visited < 30 && pIndoor->pSectors[current_sector].uNumPortals > 0) | |
729 { | |
730 current_portal=-1; | |
731 continue; | |
732 } | |
733 else | |
734 break; | |
735 } | |
736 } | |
737 //did we stop in the sector where player is? | |
738 if ( current_sector != obj2_sector ) | |
0 | 739 return 0; |
740 return 1; | |
741 } | |
742 | |
743 //----- (004075DB) -------------------------------------------------------- | |
2114 | 744 bool __fastcall sub_4075DB(int x, int y, int z, BLVFace *face) |
0 | 745 { |
746 int v8; // edi@2 | |
747 signed int v25; // eax@22 | |
748 bool result; // eax@25 | |
749 signed int a3a; // [sp+24h] [bp+8h]@14 | |
750 int a4a; // [sp+28h] [bp+Ch]@2 | |
751 | |
2000 | 752 std::array<int, 52> dword_4F5CC8_ys; // idb |
753 std::array<int, 52> dword_4F5D98_xs; // idb | |
754 | |
1493 | 755 //__debugbreak(); |
1458 | 756 |
2114 | 757 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 758 { |
1616 | 759 a4a = x; |
760 v8 = y; | |
2114 | 761 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 762 { |
2114 | 763 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].x; |
764 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].y; | |
1471 | 765 } |
0 | 766 } |
767 else | |
768 { | |
1616 | 769 v8 = z; |
2114 | 770 if ( face->uAttributes & FACE_XZ_PLANE ) |
0 | 771 { |
1616 | 772 a4a = x; |
2114 | 773 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 774 { |
2114 | 775 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].x; |
776 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].z; | |
1471 | 777 } |
0 | 778 } |
779 else | |
780 { | |
1616 | 781 a4a = y; |
2114 | 782 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 783 { |
2114 | 784 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].y; |
785 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].z; | |
1471 | 786 } |
0 | 787 } |
788 } | |
789 a3a = 0; | |
2114 | 790 dword_4F5D98_xs[face->uNumVertices] = dword_4F5D98_xs[0]; |
791 dword_4F5CC8_ys[face->uNumVertices] = dword_4F5CC8_ys[0]; | |
792 for(int i = 0; i < face->uNumVertices && a3a < 2; i++) | |
0 | 793 { |
1615 | 794 if ( dword_4F5CC8_ys[i] >= v8 ^ (dword_4F5CC8_ys[i + 1] >= v8) ) |
0 | 795 { |
1615 | 796 //if( dword_4F5D98_xs[i + 1] >= a4a || dword_4F5D98_xs[i] >= a4a) |
797 if( !(dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] < a4a)) | |
0 | 798 { |
1615 | 799 if ( (dword_4F5D98_xs[i + 1] < a4a && dword_4F5D98_xs[i] >= a4a) ) |
800 ++a3a; | |
801 //|| (v25 = dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i],LODWORD(v26) = v25 << 16, HIDWORD(v26) = v25 >> 16, | |
802 //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) | |
803 // + 32768) >> 16) >= a4a) ) | |
804 else | |
805 { | |
1643 | 806 v25 = fixpoint_div(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]); |
2114 | 807 if( dword_4F5D98_xs[i] + (fixpoint_mul(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 0x8000 >> 16) >= a4a) |
1615 | 808 ++a3a; |
809 } | |
0 | 810 } |
811 } | |
812 } | |
813 result = 1; | |
814 if ( a3a != 1 ) | |
815 result = 0; | |
816 return result; | |
817 } | |
818 | |
819 //----- (004077F1) -------------------------------------------------------- | |
2114 | 820 bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *face, BSPVertexBuffer *a5) |
0 | 821 { |
822 int a4a; // [sp+28h] [bp+Ch]@2 | |
823 signed int a5a; // [sp+2Ch] [bp+10h]@14 | |
824 | |
2000 | 825 std::array<int, 52> dword_4F5B24_ys; // idb |
826 std::array<int, 52> dword_4F5BF4_xs; // idb | |
2114 | 827 |
2057 | 828 //__debugbreak(); //срабатывает при нападении стрекозавров с огнём |
1458 | 829 |
2114 | 830 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 831 { |
832 a4a = a1; | |
833 a3 = a2; | |
2114 | 834 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
835 { |
2114 | 836 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].x; |
837 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
|
838 } |
0 | 839 } |
840 else | |
841 { | |
2114 | 842 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 843 { |
844 a4a = a1; | |
2114 | 845 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
846 { |
2114 | 847 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].x; |
848 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
|
849 } |
0 | 850 } |
851 else | |
852 { | |
853 a4a = a2; | |
2114 | 854 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
855 { |
2114 | 856 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].y; |
857 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
|
858 } |
0 | 859 } |
860 } | |
861 a5a = 0; | |
2114 | 862 dword_4F5BF4_xs[face->uNumVertices + 1] = dword_4F5BF4_xs[1]; |
863 dword_4F5B24_ys[face->uNumVertices + 1] = dword_4F5B24_ys[1]; | |
864 for(int i = 0; i < face->uNumVertices; i++) | |
0 | 865 { |
866 if ( a5a >= 2 ) | |
867 break; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
868 if ( dword_4F5B24_ys[i + 1] >= a3 ^ (dword_4F5B24_ys[i + 2] >= a3) ) |
0 | 869 { |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
870 if( dword_4F5BF4_xs[i + 2] >= a4a || dword_4F5BF4_xs[i] >= a4a) |
0 | 871 { |
1545 | 872 if (dword_4F5BF4_xs[i + 2] >= a4a && dword_4F5BF4_xs[i + 1] >= a4a) |
873 ++a5a; | |
874 else | |
875 { | |
2114 | 876 //v23 = (__int64)(dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1]) << 16; |
1545 | 877 __int64 _a = dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1]; |
878 __int64 _b = (__int64)(a3 - dword_4F5B24_ys[i + 1]) << 16; | |
879 | |
2114 | 880 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 | 881 ++a5a; |
882 } | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
883 } |
0 | 884 } |
885 } | |
1545 | 886 |
0 | 887 if ( a5a != 1 ) |
1545 | 888 return false; |
889 return true; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
890 |
0 | 891 } |
892 | |
893 //----- (004088E9) -------------------------------------------------------- | |
1459 | 894 int __fastcall sub_4088E9(int x1, int y1, int x2, int y2, int x3, int y3) |
0 | 895 { |
896 signed int result; // eax@1 | |
897 | |
2114 | 898 result = integer_sqrt(abs(x2 - x1) * abs(x2 - x1) + abs(y2 - y1) * abs(y2 - y1)); |
0 | 899 if ( result ) |
1459 | 900 result = abs(((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / result); |
0 | 901 return result; |
902 } | |
903 | |
904 //----- (0040F82D) -------------------------------------------------------- | |
905 void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue) | |
906 { | |
973 | 907 assert(uTextureId != -1); |
908 ZBuffer_DoFill(pZBuffer, pIcons_LOD->GetTexture(uTextureId), iZValue); | |
0 | 909 } |
910 | |
911 //----- (0040F89C) -------------------------------------------------------- | |
912 void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue) | |
2114 | 913 {//срабатывает при продаже в магазине |
0 | 914 void *v3; // eax@3 |
2114 | 915 //void *v4; // esi@5 |
916 //int *v5; // edi@5 | |
917 //int v6; // eax@5 | |
2334 | 918 // int v7; // ecx@6 |
919 // int v11; // [sp+18h] [bp-8h]@1 | |
2114 | 920 //void *v12; // [sp+1Ch] [bp-4h]@5 |
0 | 921 |
922 if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize ) | |
923 v3 = pTex->UnzipPalette(); | |
924 else | |
710 | 925 v3 = pTex->pLevelOfDetail0_prolly_alpha_mask; |
2114 | 926 //v12 = v3; |
927 //v4 = v3; | |
928 //v5 = pZBuffer; | |
929 //v6 = 0; | |
930 for ( uint i = 0; i < pTex->uTextureHeight; i++ ) | |
0 | 931 { |
2114 | 932 for ( uint j = 0; j < pTex->uTextureWidth; j++ ) |
0 | 933 { |
2114 | 934 //LOBYTE(v6) = *(char *)v4; |
935 //v4 = (char *)v4 + 1; | |
936 //if ( v6 ) | |
937 *pZBuffer = uZValue; | |
938 ++pZBuffer; | |
0 | 939 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
940 pZBuffer += window->GetWidth() - pTex->uTextureWidth; |
0 | 941 } |
942 if ( pIcons_LOD->dword_011BA4 ) | |
943 { | |
2114 | 944 if ( pTex->uDecompressedSize ) |
945 free(v3); | |
0 | 946 } |
947 } | |
948 | |
949 //----- (0040F92A) -------------------------------------------------------- | |
1458 | 950 void __fastcall ZBuffer_DoFill2(int *pZBuffer, Texture *a2, int a3) |
2114 | 951 {//срабатывает в покупке в магазине |
0 | 952 void *v4; // eax@3 |
2114 | 953 //int *v5; // edi@5 |
2334 | 954 // int v6; // ecx@6 |
955 // int v9; // [sp+18h] [bp-4h]@1 | |
0 | 956 |
957 if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize ) | |
958 v4 = a2->UnzipPalette(); | |
959 else | |
710 | 960 v4 = a2->pLevelOfDetail0_prolly_alpha_mask; |
2114 | 961 //v5 = pZBuffer; |
962 for ( uint i = 0; i < a2->uTextureHeight; i++ ) | |
0 | 963 { |
2114 | 964 for ( uint j = 0; j < a2->uTextureWidth; j++ ) |
0 | 965 { |
2114 | 966 *pZBuffer = a3; |
967 ++pZBuffer; | |
0 | 968 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
969 pZBuffer += window->GetWidth() - a2->uTextureWidth; |
0 | 970 } |
971 if ( pIcons_LOD->dword_011BA4 ) | |
972 { | |
2114 | 973 if ( a2->uDecompressedSize ) |
0 | 974 free(v4); |
975 } | |
976 } | |
977 | |
978 | |
979 // 4E28F8: using guessed type int pCurrentScreen; | |
980 | |
981 //----- (00417AD4) -------------------------------------------------------- | |
983 | 982 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) |
1393 | 983 { |
984 switch (uPlayerClass % 4) | |
269 | 985 { |
1393 | 986 case 0: |
269 | 987 { |
1393 | 988 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) |
989 return ui_character_skillinfo_can_learn; | |
990 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level && | |
991 byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) | |
992 { | |
993 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType] < skill_level) | |
994 return ui_character_skillinfo_cant_learn; | |
995 } | |
996 return ui_character_skillinfo_can_learn_gm; | |
0 | 997 } |
1393 | 998 break; |
999 | |
1000 case 1: | |
269 | 1001 { |
1393 | 1002 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) |
1003 return ui_character_skillinfo_can_learn; | |
1004 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level) | |
1005 { | |
1006 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) | |
1007 return ui_character_skillinfo_cant_learn; | |
1008 } | |
1009 return ui_character_skillinfo_can_learn_gm; | |
0 | 1010 } |
1393 | 1011 break; |
1012 | |
1013 case 2: | |
1014 case 3: | |
1015 { | |
1016 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level) | |
1017 return ui_character_skillinfo_cant_learn; | |
1018 return ui_character_skillinfo_can_learn; | |
1019 } | |
1020 break; | |
0 | 1021 } |
1575 | 1022 Error("Invalid player class: %u", uPlayerClass); |
1296 | 1023 } |