-
Notifications
You must be signed in to change notification settings - Fork 6
Description
In the Python world, weapon type 12 refers to claymores while 13 represents handgrenades.
asp/src/python/bf2/stats/constants.py
Lines 51 to 52 in df86f71
| WEAPON_TYPE_CLAYMORE = 12 | |
| WEAPON_TYPE_HANDGRENADE = 13 |
In the database, however, the meaning is reversed.
asp/src/ASP/system/sql/data.sql
Lines 219 to 220 in df86f71
| INSERT INTO `weapon` VALUES (12, 'Hand Grenade', 0, 1); | |
| INSERT INTO `weapon` VALUES (13, 'Claymore', 1, 1); |
Yet the mismatch is not resolved when processing snaphots, the weapon ids are used as-is.
asp/src/ASP/system/framework/Snapshot.php
Lines 738 to 746 in df86f71
| $query->set('time', '+', $object->time); | |
| $query->set('score', '+', $object->score); | |
| $query->set('kills', '+', $object->kills); | |
| $query->set('deaths', '+', $object->deaths); | |
| $query->set('fired', '+', $object->fired); | |
| $query->set('hits', '+', $object->hits); | |
| $query->set('deployed', '+', $object->deployed); | |
| $query->where('weapon_id', '=', $object->id); | |
| $query->execute(); |
Meaning the data is stored incorrectly and the in-game BFHQ will show the reversed data. To fix this, the mismatch should be addressed when processing snapshots. Note that this will only fix future data, existing data will need to be migrated.
foreach ($player->weaponData as $object) {
// Claymore (12/13) and hand grenade (13/12) are swapped in ASP/database compared to the Python constants
switch ($object->id) {
case 12:
$weaponId = 13;
break;
case 13:
$weaponId = 12;
break;
default:
$weaponId = $object->id;
}
// ...
}