* Updates the score. * @param score The base score. * @param harvestedAllied Pointer to the total amount of spice harvested by allies. * @param harvestedEnemy Pointer to the total amount of spice harvested by enemies. * @param houseID The houseID of the player. */
| 1422 | * @param houseID The houseID of the player. |
| 1423 | */ |
| 1424 | static uint16 Update_Score(int16 score, uint16 *harvestedAllied, uint16 *harvestedEnemy, uint8 houseID) |
| 1425 | { |
| 1426 | PoolFindStruct find; |
| 1427 | uint16 targetTime; |
| 1428 | uint16 sumHarvestedAllied = 0; |
| 1429 | uint16 sumHarvestedEnnemy = 0; |
| 1430 | uint32 tmp; |
| 1431 | |
| 1432 | if (score < 0) score = 0; |
| 1433 | |
| 1434 | find.houseID = houseID; |
| 1435 | find.type = 0xFFFF; |
| 1436 | find.index = 0xFFFF; |
| 1437 | |
| 1438 | while (true) { |
| 1439 | Structure *s; |
| 1440 | |
| 1441 | s = Structure_Find(&find); |
| 1442 | if (s == NULL) break; |
| 1443 | if (s->o.type == STRUCTURE_SLAB_1x1 || s->o.type == STRUCTURE_SLAB_2x2 || s->o.type == STRUCTURE_WALL) continue; |
| 1444 | |
| 1445 | score += g_table_structureInfo[s->o.type].o.buildCredits / 100; |
| 1446 | } |
| 1447 | |
| 1448 | g_validateStrictIfZero++; |
| 1449 | |
| 1450 | find.houseID = HOUSE_INVALID; |
| 1451 | find.type = UNIT_HARVESTER; |
| 1452 | find.index = 0xFFFF; |
| 1453 | |
| 1454 | while (true) { |
| 1455 | Unit *u; |
| 1456 | |
| 1457 | u = Unit_Find(&find); |
| 1458 | if (u == NULL) break; |
| 1459 | |
| 1460 | if (House_AreAllied(Unit_GetHouseID(u), g_playerHouseID)) { |
| 1461 | sumHarvestedAllied += u->amount * 7; |
| 1462 | } else { |
| 1463 | sumHarvestedEnnemy += u->amount * 7; |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | g_validateStrictIfZero--; |
| 1468 | |
| 1469 | tmp = *harvestedEnemy + sumHarvestedEnnemy; |
| 1470 | *harvestedEnemy = (tmp > 65000) ? 65000 : (tmp & 0xFFFF); |
| 1471 | |
| 1472 | tmp = *harvestedAllied + sumHarvestedAllied; |
| 1473 | *harvestedAllied = (tmp > 65000) ? 65000 : (tmp & 0xFFFF); |
| 1474 | |
| 1475 | score += House_Get_ByIndex(houseID)->credits / 100; |
| 1476 | |
| 1477 | if (score < 0) score = 0; |
| 1478 | |
| 1479 | targetTime = g_campaignID * 45; |
| 1480 | |
| 1481 | if (s_ticksPlayed < targetTime) { |
no test coverage detected