Skip to content

Weapons 12 and 13 are not mapped between Python and backend #87

@cetteup

Description

@cetteup

In the Python world, weapon type 12 refers to claymores while 13 represents handgrenades.

WEAPON_TYPE_CLAYMORE = 12
WEAPON_TYPE_HANDGRENADE = 13

In the database, however, the meaning is reversed.

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.

$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;
    }

    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions