Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register


This is a discussion on "hex numbers" in the Top Mud Sites MUD Coding forum :

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?...



You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our MUD community today!

If you have any problems with the registration process or your account login, please contact us.

If you are a registered member of the old TMS forums, please click here
Reply
 
LinkBack Thread Tools
Old 09-25-2002, 12:45 PM   #1
Emit
New Member
 
Join Date: May 2002
Location: Kentucky
Posts: 14
Emit is on a distinguished road
Send a message via AIM to Emit
Unhappy

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?
Emit is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2002, 08:53 AM   #2
welcor
Member
 
Join Date: Apr 2002
Location: Aarhus, Denmark, Europe
Posts: 59
welcor is on a distinguished road
Send a message via ICQ to welcor
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.
Quote:
Originally Posted by
ie : get 0x2458fe3a
would bring the object to me
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.
welcor is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2002, 12:05 PM   #3
Cogline
New Member
 
Join Date: Apr 2002
Posts: 2
Cogline is on a distinguished road
Unhappy

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.
Cogline is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Thread Tools


hex numbers - Similar Threads
Thread Thread Starter Forum Replies Last Post
longer numbers? Enziet MUD Coding 14 09-14-2003 10:53 AM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -4. The time now is 08:57 PM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Style based on a design by Essilor
Copyright Top Mud Sites.com 2007