BUG: Could not claim controller after unclaim



  • Requirements: GCL 2. Owner only one room.

    Step for reproduce:

    1. Claim second controller.
    2. Unclaim this controller from Game menu.
    3. Try claim controller again.

    Result: ERR_GCL_NOT_ENOUGH

    Expected result: Controller claimed, user owns two rooms.

    I reproduce this issue on the latest server code from github.

    In DB (W7N3 - problem room):

    storage.db['users'].find({username: 'Ufo'});
    [
        {
            steam: { id: '76561198335008629' },
            cpu: 100,
            cpuAvailable: 10000,
            registeredDate: '2019-06-15T13:01:48.873Z',
            credits: 0,
            gcl: 2952517,
            _id: 'aae5b3acdcaa3e6',
            meta: {
            revision: 1652367,
            created: 1560603708874,
            version: 0,
            updated: 1560870813412
            },
            '$loki': 8,
            active: 10000,
            username: 'Ufo',
            usernameLower: 'ufo',
            badge: {
            type: 12,
            color1: '#ebade7',
            color2: '#d9cf26',
            color3: '#808080',
            param: 24,
            flip: false
            },
            rooms: [ 'W8N3', 'W7N3' ],
            lastUsedCpu: 2,
            lastUsedDirtyTime: 4,
            lastNotifyDate: 1560870034799
        }
    ]
    
    storage.db['rooms.objects'].find({type: 'controller'});
    {
        room: 'W8N3',
        type: 'controller',
        x: 23,
        y: 42,
        level: 6,
        _id: '1bc30772347c388',
        meta: {
        revision: 608019,
        created: 1477476557639,
        version: 0,
        updated: 1560871483268
        },
        '$loki': 42,
        user: 'aae5b3acdcaa3e6',
        progress: 1174475,
        downgradeTime: 1005116,
        safeMode: 20146,
        safeModeAvailable: 5
    },
    
    {
        room: 'W7N3',
        type: 'controller',
        x: 36,
        y: 18,
        level: 0,
        _id: 'a2db077296e87b8',
        meta: {
        revision: 2,
        created: 1477476559214,
        version: 0,
        updated: 1560865943559
        },
        '$loki': 66,
        user: null,
        progress: 0,
        downgradeTime: null,
        reservation: null,
        safeMode: null,
        safeModeAvailable: 0,
        safeModeCooldown: 907427,
        isPowerEnabled: false
    },
    // many records cut's