Mercurial > mm7
comparison mm7_3.cpp @ 82:1faa29fd4c2d
many type, memory, boundary fixes
author | zipi |
---|---|
date | Sun, 03 Feb 2013 23:37:17 +0000 |
parents | 377535d6e366 |
children | 170259c8c71f |
comparison
equal
deleted
inserted
replaced
81:377535d6e366 | 82:1faa29fd4c2d |
---|---|
18364 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle) | 18364 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle) |
18365 { | 18365 { |
18366 unsigned int v3; // ebx@1 | 18366 unsigned int v3; // ebx@1 |
18367 unsigned int v4; // ebp@1 | 18367 unsigned int v4; // ebp@1 |
18368 signed int v5; // edi@1 | 18368 signed int v5; // edi@1 |
18369 char *v6; // esi@4 | 18369 Actor *v6; // esi@4 |
18370 size_t v7; // ecx@10 | 18370 size_t v7; // ecx@10 |
18371 char *v8; // eax@11 | 18371 Actor *v8; // eax@11 |
18372 unsigned __int16 v9; // dx@14 | 18372 unsigned __int16 v9; // dx@14 |
18373 | 18373 |
18374 v4 = uGroupID; | 18374 v4 = uGroupID; |
18375 v5 = Standing; | 18375 v5 = Standing; |
18376 v3 = uFlag; | 18376 v3 = uFlag; |
18378 { | 18378 { |
18379 if ( bToggle ) | 18379 if ( bToggle ) |
18380 { | 18380 { |
18381 if ( (signed int)uNumActors > Standing ) | 18381 if ( (signed int)uNumActors > Standing ) |
18382 { | 18382 { |
18383 v6 = (char *)&pActors[0].uAttributes; | 18383 v6 = pActors;//[0].uAttributes; |
18384 do | 18384 do |
18385 { | 18385 { |
18386 if ( *((_DWORD *)v6 + 168) == v4 ) | 18386 if ( v6->uGroup == v4 ) |
18387 { | 18387 { |
18388 *(_DWORD *)v6 |= v3; | 18388 v6->uAttributes |= v3; |
18389 if ( v3 == 0x10000 ) | 18389 if ( v3 == 0x10000 ) |
18390 { | 18390 { |
18391 *((_WORD *)v6 + 70) = Disabled; | 18391 v6->uAIState = Disabled; |
18392 ((Actor *)(v6 - 36))->UpdateAnimation(); | 18392 v6->UpdateAnimation(); |
18393 } | 18393 } |
18394 } | 18394 } |
18395 ++v5; | 18395 ++v5; |
18396 v6 += 836; | 18396 ++v6; |
18397 } | 18397 } |
18398 while ( v5 < (signed int)uNumActors ); | 18398 while ( v5 < (signed int)uNumActors ); |
18399 } | 18399 } |
18400 } | 18400 } |
18401 else | 18401 else |
18402 { | 18402 { |
18403 v7 = uNumActors; | 18403 v7 = uNumActors; |
18404 if ( (signed int)uNumActors > Standing ) | 18404 if ( (signed int)uNumActors > Standing ) |
18405 { | 18405 { |
18406 v8 = (char *)&pActors[0].uAIState; | 18406 v8 = pActors;//[0].uAIState; |
18407 do | 18407 do |
18408 { | 18408 { |
18409 if ( *((_DWORD *)v8 + 133) == v4 ) | 18409 if ( v8->uGroup == v4 ) |
18410 { | 18410 { |
18411 if ( v3 == 0x10000 ) | 18411 if ( v3 == 0x10000 ) |
18412 { | 18412 { |
18413 v9 = *(_WORD *)v8; | 18413 v9 = v8->uAIState; |
18414 if ( *(_WORD *)v8 != Dead ) | 18414 if ( v8->uAIState != Dead ) |
18415 { | 18415 { |
18416 if ( v9 != 4 && v9 != 11 ) | 18416 if ( v9 != 4 && v9 != 11 ) |
18417 *(_WORD *)v8 = Standing; | 18417 v8->uAIState = Standing; |
18418 } | 18418 } |
18419 } | 18419 } |
18420 *((_DWORD *)v8 - 35) &= ~v3; | 18420 LODWORD(v8->uAttributes) &= ~v3; |
18421 } | 18421 } |
18422 v8 += 836; | 18422 ++v8; |
18423 --v7; | 18423 --v7; |
18424 } | 18424 } |
18425 while ( v7 ); | 18425 while ( v7 ); |
18426 } | 18426 } |
18427 } | 18427 } |
19903 // 4F75D8: using guessed type int ai_arrays_size; | 19903 // 4F75D8: using guessed type int ai_arrays_size; |
19904 | 19904 |
19905 //----- (004016FA) -------------------------------------------------------- | 19905 //----- (004016FA) -------------------------------------------------------- |
19906 int __cdecl BLV_4016FA_AI() | 19906 int __cdecl BLV_4016FA_AI() |
19907 { | 19907 { |
19908 char *v0; // esi@2 | 19908 Actor *v0; // esi@2 |
19909 int v1; // eax@4 | 19909 int v1; // eax@4 |
19910 int v2; // ebx@4 | 19910 int v2; // ebx@4 |
19911 unsigned int v3; // ecx@4 | 19911 unsigned int v3; // ecx@4 |
19912 int v4; // edx@5 | 19912 int v4; // edx@5 |
19913 int v5; // edx@7 | 19913 int v5; // edx@7 |
19927 signed int v19; // edi@31 | 19927 signed int v19; // edi@31 |
19928 Actor *v20; // esi@32 | 19928 Actor *v20; // esi@32 |
19929 bool v21; // eax@33 | 19929 bool v21; // eax@33 |
19930 int v22; // eax@34 | 19930 int v22; // eax@34 |
19931 signed int v23; // ebx@36 | 19931 signed int v23; // ebx@36 |
19932 char *v24; // esi@37 | 19932 Actor *v24; // esi@37 |
19933 signed int v25; // eax@40 | 19933 signed int v25; // eax@40 |
19934 int v26; // eax@43 | 19934 int v26; // eax@43 |
19935 int v27; // ebx@45 | 19935 int v27; // ebx@45 |
19936 int j; // edi@45 | 19936 int j; // edi@45 |
19937 unsigned int v29; // eax@46 | 19937 unsigned int v29; // eax@46 |
19955 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | 19955 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
19956 v45 = 0; | 19956 v45 = 0; |
19957 v43 = 0; | 19957 v43 = 0; |
19958 if ( (signed int)uNumActors > 0 ) | 19958 if ( (signed int)uNumActors > 0 ) |
19959 { | 19959 { |
19960 v0 = (char *)&pActors[0].uAttributes; | 19960 v0 = pActors;//[0].uAttributes; |
19961 do | 19961 do |
19962 { | 19962 { |
19963 v0[1] &= 0xFBu; | 19963 BYTE1(v0->uAttributes) &= 0xFBu; |
19964 if ( ! ((Actor *)(v0 - 36))->CanAct() ) | 19964 if ( ! v0->CanAct() ) |
19965 goto LABEL_60; | 19965 goto LABEL_60; |
19966 v39 = abs(pParty->vPosition.z - *((short *)v0 + 55)); | 19966 v39 = abs(pParty->vPosition.z - v0->vPosition.z); |
19967 v38 = abs(pParty->vPosition.y - *((short *)v0 + 54)); | 19967 v38 = abs(pParty->vPosition.y - v0->vPosition.y); |
19968 v1 = abs(pParty->vPosition.x - *((short *)v0 + 53)); | 19968 v1 = abs(pParty->vPosition.x - v0->vPosition.x); |
19969 v2 = v38; | 19969 v2 = v38; |
19970 v3 = v39; | 19970 v3 = v39; |
19971 if ( v1 < v38 ) | 19971 if ( v1 < v38 ) |
19972 { | 19972 { |
19973 v4 = v1; | 19973 v4 = v1; |
19985 v6 = v3; | 19985 v6 = v3; |
19986 v3 = v2; | 19986 v3 = v2; |
19987 v2 = v6; | 19987 v2 = v6; |
19988 } | 19988 } |
19989 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; | 19989 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; |
19990 v8 = *((short *)v0 + 50); | 19990 v8 = v0->uActorRadius; |
19991 v9 = v7 - v8; | 19991 v9 = v7 - v8; |
19992 v40 = v7 - v8; | 19992 v40 = v7 - v8; |
19993 if ( v40 < 0 ) | 19993 if ( v40 < 0 ) |
19994 { | 19994 { |
19995 v9 = 0; | 19995 v9 = 0; |
19996 v40 = 0; | 19996 v40 = 0; |
19997 } | 19997 } |
19998 if ( v9 < 10240 ) | 19998 if ( v9 < 10240 ) |
19999 { | 19999 { |
20000 v10 = *(int *)v0 & 0xFEFFFFFF; | 20000 v10 = v0->uAttributes & 0xFEFFFFFF; |
20001 *(int *)v0 = v10; | 20001 v0->uAttributes = v10; |
20002 if ( v10 & 0x80000 || ((Actor *)(v0 - 36))->GetActorsRelation(0) ) | 20002 if ( v10 & 0x80000 || v0->GetActorsRelation(0) ) |
20003 { | 20003 { |
20004 v11 = (pParty->uFlags & 0x10) == 0; | 20004 v11 = (pParty->uFlags & 0x10) == 0; |
20005 *(int *)v0 = v10 | 0x1000000; | 20005 v0->uAttributes = v10 | 0x1000000; |
20006 if ( v11 && (double)v40 < 307.2 ) | 20006 if ( v11 && (double)v40 < 307.2 ) |
20007 pParty->uFlags |= 0x10u; | 20007 pParty->uFlags |= 0x10u; |
20008 if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) | 20008 if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) |
20009 pParty->uFlags |= 0x20u; | 20009 pParty->uFlags |= 0x20u; |
20010 } | 20010 } |
20013 ai_array_4F7DB0_actor_ids[v12] = v43; | 20013 ai_array_4F7DB0_actor_ids[v12] = v43; |
20014 } | 20014 } |
20015 else | 20015 else |
20016 { | 20016 { |
20017 LABEL_60: | 20017 LABEL_60: |
20018 v0[1] &= 0xBFu; | 20018 BYTE1(v0->uAttributes) &= 0xBFu; |
20019 } | 20019 } |
20020 ++v43; | 20020 ++v43; |
20021 v0 += 836; | 20021 ++v0; |
20022 } | 20022 } |
20023 while ( v43 < (signed int)uNumActors ); | 20023 while ( v43 < (signed int)uNumActors ); |
20024 } | 20024 } |
20025 v13 = 0; | 20025 v13 = 0; |
20026 if ( v45 > 0 ) | 20026 if ( v45 > 0 ) |
20072 } | 20072 } |
20073 v23 = 0; | 20073 v23 = 0; |
20074 ai_arrays_size = v19; | 20074 ai_arrays_size = v19; |
20075 if ( (signed int)uNumActors > 0 ) | 20075 if ( (signed int)uNumActors > 0 ) |
20076 { | 20076 { |
20077 v24 = (char *)&pActors[0].uAttributes; | 20077 v24 = pActors;//[0].uAttributes; |
20078 do | 20078 do |
20079 { | 20079 { |
20080 if ( ((Actor *)(v24 - 36))->CanAct() && *((short *)v24 + 61) == v37 ) | 20080 if ( v24->CanAct() && v24->uSectorID == v37 ) |
20081 { | 20081 { |
20082 v25 = 0; | 20082 v25 = 0; |
20083 if ( v19 <= 0 ) | 20083 if ( v19 <= 0 ) |
20084 { | 20084 { |
20085 LABEL_43: | 20085 LABEL_43: |
20086 v26 = ai_arrays_size; | 20086 v26 = ai_arrays_size; |
20087 v24[1] |= 0x40u; | 20087 BYTE1(v24->uAttributes) |= 0x40u; |
20088 ++ai_arrays_size; | 20088 ++ai_arrays_size; |
20089 ai_array_4F6638_actor_ids[v26] = v23; | 20089 ai_array_4F6638_actor_ids[v26] = v23; |
20090 } | 20090 } |
20091 else | 20091 else |
20092 { | 20092 { |
20097 goto LABEL_43; | 20097 goto LABEL_43; |
20098 } | 20098 } |
20099 } | 20099 } |
20100 } | 20100 } |
20101 ++v23; | 20101 ++v23; |
20102 v24 += 836; | 20102 ++v24; |
20103 } | 20103 } |
20104 while ( v23 < (signed int)uNumActors ); | 20104 while ( v23 < (signed int)uNumActors ); |
20105 } | 20105 } |
20106 v27 = ai_arrays_size; | 20106 v27 = ai_arrays_size; |
20107 for ( j = 0; j < v45; ++j ) | 20107 for ( j = 0; j < v45; ++j ) |
20158 unsigned int v0; // esi@4 | 20158 unsigned int v0; // esi@4 |
20159 int v1; // eax@7 | 20159 int v1; // eax@7 |
20160 int v2; // ecx@7 | 20160 int v2; // ecx@7 |
20161 int v3; // eax@7 | 20161 int v3; // eax@7 |
20162 signed int v4; // edi@10 | 20162 signed int v4; // edi@10 |
20163 char *v5; // esi@12 | 20163 Actor *v5; // esi@12 |
20164 signed int v6; // eax@14 | 20164 signed int v6; // eax@14 |
20165 __int16 v7; // cx@14 | 20165 __int16 v7; // cx@14 |
20166 Player **v8; // esi@20 | 20166 Player **v8; // esi@20 |
20167 Player *pPlayer; // ecx@21 | 20167 Player *pPlayer; // ecx@21 |
20168 Actor *pActor; // esi@34 | 20168 Actor *pActor; // esi@34 |
20269 { | 20269 { |
20270 pParty->field_1613C = 0; | 20270 pParty->field_1613C = 0; |
20271 v84 = 0; | 20271 v84 = 0; |
20272 if ( (signed int)uNumActors > 0 ) | 20272 if ( (signed int)uNumActors > 0 ) |
20273 { | 20273 { |
20274 v5 = (char *)&pActors[0].sCurrentHP; | 20274 v5 = pActors;//[0].sCurrentHP; |
20275 do | 20275 do |
20276 { | 20276 { |
20277 if ( ((Actor *)(v5 - 40))->CanAct() ) | 20277 if ( v5->CanAct() ) |
20278 { | 20278 { |
20279 v6 = stru_50C198.CalcMagicalDamageToActor((Actor *)(v5 - 40), 5, v4); | 20279 v6 = stru_50C198.CalcMagicalDamageToActor(v5, 5, v4); |
20280 v7 = *(short *)v5 - v6; | 20280 v7 = v5->sCurrentHP - v6; |
20281 *(short *)v5 = v7; | 20281 v5->sCurrentHP = v7; |
20282 if ( v6 ) | 20282 if ( v6 ) |
20283 { | 20283 { |
20284 if ( v7 >= 0 ) | 20284 if ( v7 >= 0 ) |
20285 { | 20285 { |
20286 Actor::_4030AD(v84, 4, 0); | 20286 Actor::_4030AD(v84, 4, 0); |
20287 } | 20287 } |
20288 else | 20288 else |
20289 { | 20289 { |
20290 Actor::Die(v84); | 20290 Actor::Die(v84); |
20291 if ( *((int *)v5 + 19) ) | 20291 if ( v5->pMonsterInfo.uExp ) |
20292 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[*((short *)v5 + 28)].uExp); | 20292 sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp); |
20293 } | 20293 } |
20294 } | 20294 } |
20295 } | 20295 } |
20296 ++v84; | 20296 ++v84; |
20297 v5 += 836; | 20297 ++v5; |
20298 } | 20298 } |
20299 while ( (signed int)v84 < (signed int)uNumActors ); | 20299 while ( (signed int)v84 < (signed int)uNumActors ); |
20300 } | 20300 } |
20301 v8 = &pPlayers[1]; | 20301 v8 = &pPlayers[1]; |
20302 do | 20302 do |