comparison mm7_6.cpp @ 82:1faa29fd4c2d

many type, memory, boundary fixes
author zipi
date Sun, 03 Feb 2013 23:37:17 +0000
parents 377535d6e366
children 98cd93e14777
comparison
equal deleted inserted replaced
81:377535d6e366 82:1faa29fd4c2d
1294 //----- (004269A2) -------------------------------------------------------- 1294 //----- (004269A2) --------------------------------------------------------
1295 int __fastcall sub_4269A2_GivePartyExp(unsigned int a1) 1295 int __fastcall sub_4269A2_GivePartyExp(unsigned int a1)
1296 { 1296 {
1297 unsigned __int64 v1; // qax@1 1297 unsigned __int64 v1; // qax@1
1298 signed int v2; // ecx@1 1298 signed int v2; // ecx@1
1299 char *v3; // esi@1 1299 int *v3; // esi@1
1300 bool v4; // edi@6 1300 bool v4; // edi@6
1301 char *v5; // edi@10 1301 int *v5; // edi@10
1302 char *v6; // esi@10 1302 Player *v6; // esi@10
1303 int v7; // eax@13 1303 int v7; // eax@13
1304 unsigned __int8 v8; // cf@13 1304 unsigned __int8 v8; // cf@13
1305 char v10; // [sp+Ch] [bp-14h]@1 1305 int v10; // [sp+Ch] [bp-14h]@1
1306 int v11; // [sp+1Ch] [bp-4h]@10 1306 int v11; // [sp+1Ch] [bp-4h]@10
1307 1307
1308 v1 = __PAIR__((int)((char *)&pParty + 2620), a1); 1308 v1 = __PAIR__((int)((char *)&pParty + 2620), a1);
1309 v2 = 0; 1309 v2 = 0;
1310 v3 = &v10; 1310 v3 = &v10;
1312 { 1312 {
1313 v4 = !(*(int *)(HIDWORD(v1) - 4) | *(int *)(HIDWORD(v1) - 8)) 1313 v4 = !(*(int *)(HIDWORD(v1) - 4) | *(int *)(HIDWORD(v1) - 8))
1314 && !*(int *)HIDWORD(v1) 1314 && !*(int *)HIDWORD(v1)
1315 && !*(_QWORD *)(HIDWORD(v1) + 8) 1315 && !*(_QWORD *)(HIDWORD(v1) + 8)
1316 && !*(_QWORD *)(HIDWORD(v1) + 16); 1316 && !*(_QWORD *)(HIDWORD(v1) + 16);
1317 *(int *)v3 = v4; 1317 *v3 = v4;
1318 HIDWORD(v1) += 6972; 1318 HIDWORD(v1) += 6972;
1319 v2 += v4; 1319 v2 += v4;
1320 v3 += 4; 1320 ++v3;
1321 } 1321 }
1322 while ( SHIDWORD(v1) < (signed int)&pParty->pHirelings[1].field_24 ); 1322 while ( SHIDWORD(v1) < (signed int)&pParty->pHirelings[1].field_24 );
1323 if ( v2 ) 1323 if ( v2 )
1324 { 1324 {
1325 LODWORD(v1) = (signed int)v1 / v2; 1325 LODWORD(v1) = (signed int)v1 / v2;
1326 v5 = &v10; 1326 v5 = &v10;
1327 v6 = (char *)&pParty->pPlayers[0].uExperience; 1327 v6 = pParty->pPlayers;//[0].uExperience;
1328 v11 = v1; 1328 v11 = v1;
1329 do 1329 do
1330 { 1330 {
1331 if ( *(int *)v5 ) 1331 if ( *v5 )
1332 { 1332 {
1333 if ( v11 ) 1333 if ( v11 )
1334 { 1334 {
1335 LOBYTE(v7) = ((Player *)(v6 - 160))->GetLearningPercent(); 1335 LOBYTE(v7) = v6->GetLearningPercent();
1336 v1 = v11 + v11 * v7 / 100; 1336 v1 = v11 + v11 * v7 / 100;
1337 v8 = __CFADD__((int)v1, *(int *)v6); 1337 v8 = __CFADD__((int)v1, LODWORD(v6->uExperience));
1338 *(int *)v6 += v1; 1338 LODWORD(v6->uExperience) += v1;
1339 *((int *)v6 + 1) += HIDWORD(v1) + v8; 1339 HIDWORD(v6->uExperience) += HIDWORD(v1) + v8;
1340 if ( *(_QWORD *)v6 > 4000000000i64 ) 1340 if ( v6->uExperience > 4000000000i64 )
1341 { 1341 {
1342 *((int *)v6 + 1) = 0; 1342 HIDWORD(v6->uExperience) = 0;
1343 *(int *)v6 = -294967296; 1343 LODWORD(v6->uExperience) = -294967296;
1344 } 1344 }
1345 } 1345 }
1346 } 1346 }
1347 v6 += 6972; 1347 ++v6;
1348 v5 += 4; 1348 ++v5;
1349 } 1349 }
1350 while ( (signed int)v6 < (signed int)&pParty->pPickedItem._bonus_strength ); 1350 while ( v6 <= &pParty->pPlayers[3] );
1351 } 1351 }
1352 return v1; 1352 return v1;
1353 } 1353 }
1354 1354
1355 //----- (00426A5A) -------------------------------------------------------- 1355 //----- (00426A5A) --------------------------------------------------------
8290 8290
8291 //----- (0042F4DA) -------------------------------------------------------- 8291 //----- (0042F4DA) --------------------------------------------------------
8292 signed int __cdecl sub_42F4DA() 8292 signed int __cdecl sub_42F4DA()
8293 { 8293 {
8294 signed int v0; // edi@1 8294 signed int v0; // edi@1
8295 char *v1; // esi@4 8295 Actor *v1; // esi@4
8296 int v2; // ebx@5 8296 int v2; // ebx@5
8297 int v3; // eax@5 8297 int v3; // eax@5
8298 int v4; // ebx@5 8298 int v4; // ebx@5
8299 unsigned int v5; // ecx@5 8299 unsigned int v5; // ecx@5
8300 int v6; // edx@6 8300 int v6; // edx@6
8315 LABEL_20: 8315 LABEL_20:
8316 result = 0; 8316 result = 0;
8317 } 8317 }
8318 else 8318 else
8319 { 8319 {
8320 v1 = (char *)&pActors[0].uAIState; 8320 v1 = pActors;
8321 while ( 1 ) 8321 while ( 1 )
8322 { 8322 {
8323 v2 = abs(*((short *)v1 - 17) - pParty->vPosition.x); 8323 v2 = abs(v1->vInitialPosition.x - pParty->vPosition.x);
8324 v11 = abs(*((short *)v1 - 16) - pParty->vPosition.y); 8324 v11 = abs(v1->vInitialPosition.y - pParty->vPosition.y);
8325 v12 = abs(*((short *)v1 - 15) - pParty->vPosition.z); 8325 v12 = abs(v1->vInitialPosition.z - pParty->vPosition.z);
8326 v3 = v2; 8326 v3 = v2;
8327 v4 = v11; 8327 v4 = v11;
8328 v5 = v12; 8328 v5 = v12;
8329 if ( v3 < v11 ) 8329 if ( v3 < v11 )
8330 { 8330 {
8344 v5 = v4; 8344 v5 = v4;
8345 v4 = v8; 8345 v4 = v8;
8346 } 8346 }
8347 if ( (signed int)(((unsigned int)(11 * v4) >> 5) + (v5 >> 2) + v3) < v0 ) 8347 if ( (signed int)(((unsigned int)(11 * v4) >> 5) + (v5 >> 2) + v3) < v0 )
8348 { 8348 {
8349 v9 = *(short *)v1; 8349 v9 = v1->uAIState;
8350 if ( *(short *)v1 != 5 ) 8350 if ( v1->uAIState != 5 )
8351 { 8351 {
8352 if ( v9 != 4 8352 if ( v9 != 4
8353 && v9 != 11 8353 && v9 != 11
8354 && v9 != 19 8354 && v9 != 19
8355 && v9 != 17 8355 && v9 != 17
8356 && (*(v1 - 138) & 8 || ((Actor *)nullptr)->GetActorsRelation( (Actor *)(v1 - 176))) ) 8356 && (BYTE2(v1->uAttributes) & 8 || ((Actor *)nullptr)->GetActorsRelation( v1)) )
8357 break; 8357 break;
8358 } 8358 }
8359 } 8359 }
8360 ++v13; 8360 ++v13;
8361 v1 += 836; 8361 ++v1;
8362 if ( v13 >= (signed int)uNumActors ) 8362 if ( v13 >= (signed int)uNumActors )
8363 goto LABEL_20; 8363 goto LABEL_20;
8364 } 8364 }
8365 result = 1; 8365 result = 1;
8366 } 8366 }