You made a mistake structure cannot be inside of function
Here is working code:
Code
- struct RangePickup
- {
- LPCHARACTER ch;
- int iRange;
- RangePickup(LPCHARACTER ch, int iRange)
- {
- ch = ch;
- iRange = iRange;
- }
- void operator()(LPENTITY pEnt)
- {
- if (!ch)
- return;
- if (pEnt->IsType(ENTITY_ITEM))
- {
- LPITEM item = (LPITEM)pEnt;
- if (!item->GetSectree() || !item->IsOwnership(ch))
- return;
- int iDist = DISTANCE_APPROX(item->GetX() - ch->GetX(), ch->GetY() - ch->GetY());
- if (iDist > iRange)
- return;
- ch->PickupItem(item->GetVID());
- }
- }
- };
- void CInputMain::ItemPickup(LPCHARACTER ch, const char * data)
- {
- if (!ch)
- return;
- LPSECTREE sectree = ch->GetSectree();
- if (!sectree)
- return;
- RangePickup f(ch, 1000);
- sectree->ForEachAround(f);
- /*
- // OLD PICKING METHOD
- struct command_item_pickup * pinfo = (struct command_item_pickup*) data;
- if (ch)
- ch->PickupItem(pinfo->vid);
- */
- }