RedcrowProd
Member
|
General Pointer to class ?
Hey, so i was trying something and ended up with a small wall.
i'm trying to do a dynamic target system passing the Sockaddr of the neighbor, into the actor.user, and getting it back, so i can do a find into my map of neighbor to avoid repa.
so i got my actor/addr:
Actor A_Torso;
SockAddr addr;
and i give him an user info of the address of my addr:
A_Torso.user(&addr);
up to here, no issues.
now i want to get it back to get my mouseover info.
and do a find with it.
so i do something like that:
if(Physics.ray(start, end-start, &phys_hit, actor_groups )) // if ray hit something
{
// CAST(SockAddr, phy_hit.user);
SockAddr &test = phys_hit.user;
Neighbor *n=NeighborClients.find (test);
}
but i must have a wrong idea of what is this General Ptr, because nothing is working saying Ptr cannot be converted to SockAddr
anybody could clear up this grey area please ? =)
|
|
07-18-2015 07:22 AM |
|
rstralberg
Member
|
RE: General Pointer to class ?
This will do the trick
Code:
SockAddr* test = reinterpret_cast<SockAddr*>(phys_hit.user);
or for the lazy one
Code:
SockAddr* test = (SockAddr*)phys_hit.user;
(This post was last modified: 07-18-2015 10:47 AM by rstralberg.)
|
|
07-18-2015 09:58 AM |
|
RedcrowProd
Member
|
RE: General Pointer to class ?
perfect thanks
|
|
07-18-2015 04:52 PM |
|