Back to success stories

Sample of Defect

Project Name CID Checker Category Developer Description
GemRB 1312057 UNUSED_VALUE Incorrect expression Impact is low, just wanted to commend you! It would cause game actors to teleport to the wrong coordinates.
File: /home/kajak/games/gemrb/gemrb/plugins/FXOpcodes/FXOpcodes.cpp
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
        return FX_NOT_APPLIED;
}

// 0x7c DimensionDoor
// iwd2 has several options
int fx_dimension_door (Scriptable* Owner, Actor* target, Effect* fx)
{
        if(0) print("fx_dimension_door(%2d) Type:%d", fx->Opcode, fx->Parameter2);
        Point p;

        switch(fx->Parameter2)
        {
        case 0: //target to point
                p.x=fx->PosX;
                p.y=fx->PosY;
                break;
        case 1: //owner to target
                if (Owner->Type!=ST_ACTOR) {
                        return FX_NOT_APPLIED;
                }
                p=target->Pos;
                target = (Actor *) Owner;
                break;
        case 2: //target to saved location
 <<< CID 1312057: Incorrect expression UNUSED_VALUE
 <<< Assigning value from "target->Modified[236]" to "p.x" here, but that stored value is overwritten before it can be used.
3614
                p.x=STAT_GET(IE_SAVEDXPOS);
 << Overwriting previous write to "p.x" with value from "target->Modified[237]".
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
                p.x=STAT_GET(IE_SAVEDYPOS);
                target->SetOrientation(STAT_GET(IE_SAVEDFACE), false);
                break;
        case 3: //owner swapped with target
                if (Owner->Type!=ST_ACTOR) {
                        return FX_NOT_APPLIED;
                }
                p=target->Pos;
                target->SetPosition(Owner->Pos, true, 0);
                target = (Actor *) Owner;
                break;
        }
        target->SetPosition(p, true, 0 );
        return FX_NOT_APPLIED;
}

// 0x7d Unlock
int fx_knock (Scriptable* Owner, Actor* /*target*/, Effect* fx)
{
        if(0) print("fx_knock(%2d) [%d.%d]", fx->Opcode, fx->PosX, fx->PosY);
        Map *map = Owner->GetCurrentArea();
        if (!map) {
                return FX_NOT_APPLIED;
        }
        Point p(fx->PosX, fx->PosY);

        Door *door = map->TMap->GetDoorByPosition(p);
Events:
value_overwrite FXOpcodes.cpp:3615
assigned_value FXOpcodes.cpp:3614