Mercurial > mm7
annotate mm7_5.cpp @ 2403:069018761f96
Слияние
author | Ritor1 |
---|---|
date | Mon, 14 Jul 2014 10:04:14 +0600 |
parents | c631b1877204 |
children | f4af3b203f65 |
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; | |
2390
c631b1877204
area_of_effect_damage_evaluate - fixed spells radius problem
zipi
parents:
2348
diff
changeset
|
117 v19 = AttackerInfo.field_324[attacker_id] + pActors[target_id].uActorRadius; |
2059 | 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]; |
2390
c631b1877204
area_of_effect_damage_evaluate - fixed spells radius problem
zipi
parents:
2348
diff
changeset
|
170 v33 = pActors[actorID].uActorRadius + AttackerInfo.field_324[attacker_id]; |
2059 | 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 | |
481 //----- (004075DB) -------------------------------------------------------- | |
2114 | 482 bool __fastcall sub_4075DB(int x, int y, int z, BLVFace *face) |
0 | 483 { |
484 int v8; // edi@2 | |
485 signed int v25; // eax@22 | |
486 bool result; // eax@25 | |
487 signed int a3a; // [sp+24h] [bp+8h]@14 | |
488 int a4a; // [sp+28h] [bp+Ch]@2 | |
489 | |
2000 | 490 std::array<int, 52> dword_4F5CC8_ys; // idb |
491 std::array<int, 52> dword_4F5D98_xs; // idb | |
492 | |
1493 | 493 //__debugbreak(); |
1458 | 494 |
2114 | 495 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 496 { |
1616 | 497 a4a = x; |
498 v8 = y; | |
2114 | 499 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 500 { |
2114 | 501 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].x; |
502 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].y; | |
1471 | 503 } |
0 | 504 } |
505 else | |
506 { | |
1616 | 507 v8 = z; |
2114 | 508 if ( face->uAttributes & FACE_XZ_PLANE ) |
0 | 509 { |
1616 | 510 a4a = x; |
2114 | 511 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 512 { |
2114 | 513 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].x; |
514 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].z; | |
1471 | 515 } |
0 | 516 } |
517 else | |
518 { | |
1616 | 519 a4a = y; |
2114 | 520 for(int i = 0; i < face->uNumVertices; i++) |
1471 | 521 { |
2114 | 522 dword_4F5D98_xs[i] = pIndoor->pVertices[face->pVertexIDs[i]].y; |
523 dword_4F5CC8_ys[i] = pIndoor->pVertices[face->pVertexIDs[i]].z; | |
1471 | 524 } |
0 | 525 } |
526 } | |
527 a3a = 0; | |
2114 | 528 dword_4F5D98_xs[face->uNumVertices] = dword_4F5D98_xs[0]; |
529 dword_4F5CC8_ys[face->uNumVertices] = dword_4F5CC8_ys[0]; | |
530 for(int i = 0; i < face->uNumVertices && a3a < 2; i++) | |
0 | 531 { |
1615 | 532 if ( dword_4F5CC8_ys[i] >= v8 ^ (dword_4F5CC8_ys[i + 1] >= v8) ) |
0 | 533 { |
1615 | 534 //if( dword_4F5D98_xs[i + 1] >= a4a || dword_4F5D98_xs[i] >= a4a) |
535 if( !(dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] < a4a)) | |
0 | 536 { |
1615 | 537 if ( (dword_4F5D98_xs[i + 1] < a4a && dword_4F5D98_xs[i] >= a4a) ) |
538 ++a3a; | |
539 //|| (v25 = dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i],LODWORD(v26) = v25 << 16, HIDWORD(v26) = v25 >> 16, | |
540 //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) | |
541 // + 32768) >> 16) >= a4a) ) | |
542 else | |
543 { | |
1643 | 544 v25 = fixpoint_div(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]); |
2114 | 545 if( dword_4F5D98_xs[i] + (fixpoint_mul(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 0x8000 >> 16) >= a4a) |
1615 | 546 ++a3a; |
547 } | |
0 | 548 } |
549 } | |
550 } | |
551 result = 1; | |
552 if ( a3a != 1 ) | |
553 result = 0; | |
554 return result; | |
555 } | |
556 | |
557 //----- (004077F1) -------------------------------------------------------- | |
2114 | 558 bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *face, BSPVertexBuffer *a5) |
0 | 559 { |
560 int a4a; // [sp+28h] [bp+Ch]@2 | |
561 signed int a5a; // [sp+2Ch] [bp+10h]@14 | |
562 | |
2000 | 563 std::array<int, 52> dword_4F5B24_ys; // idb |
564 std::array<int, 52> dword_4F5BF4_xs; // idb | |
2114 | 565 |
2057 | 566 //__debugbreak(); // |
1458 | 567 |
2114 | 568 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 569 { |
570 a4a = a1; | |
571 a3 = a2; | |
2114 | 572 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
573 { |
2114 | 574 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].x; |
575 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
|
576 } |
0 | 577 } |
578 else | |
579 { | |
2114 | 580 if ( face->uAttributes & FACE_XY_PLANE ) |
0 | 581 { |
582 a4a = a1; | |
2114 | 583 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
584 { |
2114 | 585 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].x; |
586 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
|
587 } |
0 | 588 } |
589 else | |
590 { | |
591 a4a = a2; | |
2114 | 592 for(int i = 0; i < face->uNumVertices; i++) |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
593 { |
2114 | 594 dword_4F5BF4_xs[i+1] = a5->pVertices[face->pVertexIDs[i]].y; |
595 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
|
596 } |
0 | 597 } |
598 } | |
599 a5a = 0; | |
2114 | 600 dword_4F5BF4_xs[face->uNumVertices + 1] = dword_4F5BF4_xs[1]; |
601 dword_4F5B24_ys[face->uNumVertices + 1] = dword_4F5B24_ys[1]; | |
602 for(int i = 0; i < face->uNumVertices; i++) | |
0 | 603 { |
604 if ( a5a >= 2 ) | |
605 break; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
606 if ( dword_4F5B24_ys[i + 1] >= a3 ^ (dword_4F5B24_ys[i + 2] >= a3) ) |
0 | 607 { |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
608 if( dword_4F5BF4_xs[i + 2] >= a4a || dword_4F5BF4_xs[i] >= a4a) |
0 | 609 { |
1545 | 610 if (dword_4F5BF4_xs[i + 2] >= a4a && dword_4F5BF4_xs[i + 1] >= a4a) |
611 ++a5a; | |
612 else | |
613 { | |
2114 | 614 //v23 = (__int64)(dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1]) << 16; |
1545 | 615 __int64 _a = dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1]; |
616 __int64 _b = (__int64)(a3 - dword_4F5B24_ys[i + 1]) << 16; | |
617 | |
2114 | 618 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 | 619 ++a5a; |
620 } | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
621 } |
0 | 622 } |
623 } | |
1545 | 624 |
0 | 625 if ( a5a != 1 ) |
1545 | 626 return false; |
627 return true; | |
1472
2395e99b89d0
sub_4077F1 cleaned, and fixed previous mistake in cleaning
zipi
parents:
1471
diff
changeset
|
628 |
0 | 629 } |
630 | |
631 | |
632 //----- (0040F82D) -------------------------------------------------------- | |
633 void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue) | |
634 { | |
973 | 635 assert(uTextureId != -1); |
636 ZBuffer_DoFill(pZBuffer, pIcons_LOD->GetTexture(uTextureId), iZValue); | |
0 | 637 } |
638 | |
639 //----- (0040F89C) -------------------------------------------------------- | |
640 void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue) | |
2114 | 641 {// |
0 | 642 void *v3; // eax@3 |
2114 | 643 //void *v4; // esi@5 |
644 //int *v5; // edi@5 | |
645 //int v6; // eax@5 | |
2334 | 646 // int v7; // ecx@6 |
647 // int v11; // [sp+18h] [bp-8h]@1 | |
2114 | 648 //void *v12; // [sp+1Ch] [bp-4h]@5 |
0 | 649 |
650 if ( pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize ) | |
651 v3 = pTex->UnzipPalette(); | |
652 else | |
710 | 653 v3 = pTex->pLevelOfDetail0_prolly_alpha_mask; |
2114 | 654 //v12 = v3; |
655 //v4 = v3; | |
656 //v5 = pZBuffer; | |
657 //v6 = 0; | |
658 for ( uint i = 0; i < pTex->uTextureHeight; i++ ) | |
0 | 659 { |
2114 | 660 for ( uint j = 0; j < pTex->uTextureWidth; j++ ) |
0 | 661 { |
2114 | 662 //LOBYTE(v6) = *(char *)v4; |
663 //v4 = (char *)v4 + 1; | |
664 //if ( v6 ) | |
665 *pZBuffer = uZValue; | |
666 ++pZBuffer; | |
0 | 667 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
668 pZBuffer += window->GetWidth() - pTex->uTextureWidth; |
0 | 669 } |
670 if ( pIcons_LOD->dword_011BA4 ) | |
671 { | |
2114 | 672 if ( pTex->uDecompressedSize ) |
673 free(v3); | |
0 | 674 } |
675 } | |
676 | |
677 //----- (0040F92A) -------------------------------------------------------- | |
1458 | 678 void __fastcall ZBuffer_DoFill2(int *pZBuffer, Texture *a2, int a3) |
2114 | 679 {// |
0 | 680 void *v4; // eax@3 |
2114 | 681 //int *v5; // edi@5 |
2334 | 682 // int v6; // ecx@6 |
683 // int v9; // [sp+18h] [bp-4h]@1 | |
0 | 684 |
685 if ( pIcons_LOD->dword_011BA4 && a2->uDecompressedSize ) | |
686 v4 = a2->UnzipPalette(); | |
687 else | |
710 | 688 v4 = a2->pLevelOfDetail0_prolly_alpha_mask; |
2114 | 689 //v5 = pZBuffer; |
690 for ( uint i = 0; i < a2->uTextureHeight; i++ ) | |
0 | 691 { |
2114 | 692 for ( uint j = 0; j < a2->uTextureWidth; j++ ) |
0 | 693 { |
2114 | 694 *pZBuffer = a3; |
695 ++pZBuffer; | |
0 | 696 } |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2207
diff
changeset
|
697 pZBuffer += window->GetWidth() - a2->uTextureWidth; |
0 | 698 } |
699 if ( pIcons_LOD->dword_011BA4 ) | |
700 { | |
2114 | 701 if ( a2->uDecompressedSize ) |
0 | 702 free(v4); |
703 } | |
704 } | |
705 | |
706 | |
707 // 4E28F8: using guessed type int pCurrentScreen; | |
708 | |
709 //----- (00417AD4) -------------------------------------------------------- | |
983 | 710 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) |
1393 | 711 { |
712 switch (uPlayerClass % 4) | |
269 | 713 { |
1393 | 714 case 0: |
269 | 715 { |
1393 | 716 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) |
717 return ui_character_skillinfo_can_learn; | |
718 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level && | |
719 byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) | |
720 { | |
721 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType] < skill_level) | |
722 return ui_character_skillinfo_cant_learn; | |
723 } | |
724 return ui_character_skillinfo_can_learn_gm; | |
0 | 725 } |
1393 | 726 break; |
727 | |
728 case 1: | |
269 | 729 { |
1393 | 730 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) |
731 return ui_character_skillinfo_can_learn; | |
732 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level) | |
733 { | |
734 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) | |
735 return ui_character_skillinfo_cant_learn; | |
736 } | |
737 return ui_character_skillinfo_can_learn_gm; | |
0 | 738 } |
1393 | 739 break; |
740 | |
741 case 2: | |
742 case 3: | |
743 { | |
744 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level) | |
745 return ui_character_skillinfo_cant_learn; | |
746 return ui_character_skillinfo_can_learn; | |
747 } | |
748 break; | |
0 | 749 } |
1575 | 750 Error("Invalid player class: %u", uPlayerClass); |
1296 | 751 } |