ryzom / ryzomcore

Ryzom Core is the open-source project related to the Ryzom game. This community repository is synchronized with the Ryzom Forge repository, based on the Core branch.
https://wiki.ryzom.dev
GNU Affero General Public License v3.0
341 stars 90 forks source link

PushTarget in CNetworkConnection has a check that does not do anything #678

Closed bierdosenhalter closed 1 year ago

bierdosenhalter commented 1 year ago

assignment in the switch and after the switch (also the slot assignment could be done in the action factory i guess)

void    CNetworkConnection::pushTarget(TCLEntityId slot, LHSTATE::TLHState targetOrPickup )
{
    CActionTargetSlot *ats = (CActionTargetSlot*)CActionFactory::getInstance ()->create (INVALID_SLOT, ACTION_TARGET_SLOT_CODE);
    nlassert (ats != NULL);
    ats->Slot = slot;
    switch ( targetOrPickup ) // ensure the value is good for the FE
    {
        case LHSTATE::NONE: ats->TargetOrPickup = 0; break;
        case LHSTATE::LOOTABLE: ats->TargetOrPickup = 1; break;
        case LHSTATE::HARVESTABLE: ats->TargetOrPickup = 2; break;
    }

    ats->TargetOrPickup = (uint32)targetOrPickup;
    push(ats);
}
kaetemi commented 1 year ago

Ahah. Weird. Is this broken or dead code?

bierdosenhalter commented 1 year ago

i assume someone wanted to make sure targetOrPickup is a valid TLHState, but afterwards it is assigned anyway

kaetemi commented 1 year ago

It uses the same enum on the server, it's serialized as 2 bits, and there's also a value 3 now, so looks like dead code to me. Can safely remove that ugly switch with ugly numbers. :)

kaetemi commented 1 year ago

Feel free to send a PR.