Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   MUD Coding (http://www.topmudsites.com/forums/forumdisplay.php?f=9)
-   -   hex numbers (http://www.topmudsites.com/forums/showthread.php?t=276)

Emit 09-25-2002 12:45 PM

i want to grap a pointer to an obj by specifying its address in memory in the argument to a command.
ie : get 0x2458fe3a
would bring the object to me

question is, how to convert a string to a hex number?

welcor 10-01-2002 08:53 AM

void *ptr;
struct obj_data *obj;

sscanf(txt, "%p", &ptr);
obj = (struct obj_data *)ptr;

Beware, though. This is a sure way to crash your game. There is no check for validity involved. If you happen to
put in a wrong number, the 'obj' pointer may cause all sorts of troubles.
You should consider other ways of getting to the object. Whether you wish to have some sort of internal numbering or recognize it by name is your choice, but typing in memory values is asking for trouble.

Cogline 10-01-2002 12:05 PM

Is it the case that you are debugging your MUD using a debugger like GDB and you are trying to figure out to which object a pointer is pointing? If so, just dereference the pointer from gdb, like:

print *obj

It would be much safer that way.


All times are GMT -4. The time now is 10:21 AM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022