2000Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev] [adv&#45;mud] Spellbound Hierarchy and Keys (fwd) -->
<!--X-From-R13: X Q Znjerapr <pynjNxnatn.ah> -->
<!--X-Date: Sat, 29 Jan 2000 12:46:20 &#45;0800 -->
<!--X-Message-Id: E12Eel5&#45;0002fy&#45;00#dingo,kanga.nu -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: E12BVr7&#45;0003oB&#45;00#dingo,kanga.nu -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Re: [MUD-Dev] [adv-mud] Spellbound Hierarchy and Keys (fwd)</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:claw#kanga,nu">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00230.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00233.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00201.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00187.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00231">Author</A>
&nbsp;|&nbsp;<A HREF="#00231">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00231">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev] [adv-mud] Spellbound Hierarchy and Keys (fwd)</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: Re: [MUD-Dev] [adv-mud] Spellbound Hierarchy and Keys (fwd) </LI>
<LI><em>From</em>: J C Lawrence &lt;<A HREF="mailto:claw#kanga,nu">claw#kanga,nu</A>&gt;</LI>
<LI><em>Date</em>: Sat, 29 Jan 2000 12:46:15 -0800</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Sender</em>: <A HREF="mailto:mud-dev-admin#kanga,nu">mud-dev-admin#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
&gt; From: "phlUID" &lt;phluid#mindless,com&gt; 

&gt; On Spellbound, every object in the game is given it's own database
&gt; number. Help files, races, spells, objects, rooms, mobiles, exits,
&gt; worlds, areas, classes, populations, etc.  There are generically
&gt; two types of database numbers: Pure, which is just a simple unique
&gt; number given to every object, and Hybrid, which is used in the
&gt; case of Object's and Mobs. For example, a room is object #43,
&gt; while the sword in my inventory is #45:1 and the same type of
&gt; sword in my friend's inventory is #45:2. The second number is
&gt; referred to as an Entity ID because they refer to specific
&gt; Entity's instead of Entries. There is an Entry class for #45
&gt; called ObjectEntry, and there is an associated Entity class for
&gt; ObjectEntry called Object. This concept is the same as DIKU's use
&gt; of OBJ_INDEX_DATA and OBJ_DATA.

Translation:

  You have ObjectIDs which are synonymous with their (single)
instance, and you have InstanceIDs which are synonymous with an
instance of a referenced ObjectID.  An ObjectID may have multiple
InstanceIDs referring to it as each one marks a duplicate object.

&gt; Currently, Spellbound uses pointers directly to objects like
&gt; normal DIKU mud.
...various complaints about pointer tracking...
&gt; This is made worse by the object orientness of C++, so I began to
&gt; think of alternate ways of storing pointers.

My first thought is using either an auto_ptr or some sort of simple
reference counting scheme.

&gt; The first thing that I wanted to be able to do is validate
&gt; pointers. 

Reference counting with a flag would work fine.  Put a reference
count on your object class, and add an internal object_deleted flag
that is checked on every reference.  That way you just delete the
object, the flag gets set, and at that point when its reference
count falls to zero you call the destructor.

There's actually a rather nicely written grim_reaper class floating
about the net that handles this elegantly as a base class.

&gt; This started my thinking into the idea that it would be possible
&gt; to replicate this system to make sure that what I am referencing
&gt; is actually there. My database uses a regular array to return
&gt; pointer's to DB numbers, so there is no CPU time involved looking
&gt; through tables or linked lists. If I want object #43, I just call
&gt; Database.getEntry( 43 ) and it returns a pointer to that entry.

You might like to hit the archives for discussion of my ObjectID
format, and how it supports re-use and collision detection.

&gt; This identifier consists of a count of exactly how many nano or
&gt; milliseconds from the epoch. 

Remember that the high resolution timer on non-hard realtime systems
(and not even most of those) is _not_ reliable or accurate.
Furhter, you are relying on general clock accuracy.  Consider the
simple case where you have something like an NTP client or a SysAdm
resetting the system clock: there is a definite chance for two timer
calls to return the same value as the system clock passes the same
value twice.

&gt; Assuming that no two object's can be created at the exact same
&gt; time, this gives each object ever created a unique identifier.

Object A created at time X.

System clock set back by NTP client to time X-Y.

Y time later Object B created at time X.

Both get the same ID.

&gt; If the database couldn't find #23, entity 0, or the time
&gt; identifier was wrong, I would end up with a NULL pointer, which
&gt; will just stop my action and inform Fred that Bob is no longer
&gt; there. Simple, effecient error control.

I tend to be a big fan of exceptions (you might notice that my
initial internal language used exceptions for all call returns, with
a normal non-error return merely being a flavour of exception that
defaulted to always being caught by the caller).

Why use exceptions here?  With your scheme ever piece of code that
has to reference an object has to be prepared to find it
non-existent.  This is both a lot of duplication of effort and puts
the load on the programmer for a task that the system can generally
take care of instead (in the general case you just want events to
fail that reference deleted objects, not try to manage the error).

&gt; The only real question that I had is if anyone can see ways to
&gt; improve this process. 

As above.  For what you're doing (runtime checks only with no
storage collision requirements) a refernece count etc seems cheaper
and simpler.

&gt; On the technical side, I need a way of grabbing the time() in an
&gt; extremely precise manner...

The syscall required tends to vary by OS: setitimer()/getitimer()
are typical.

-- 
J C Lawrence                                 Home: claw#kanga,nu
----------(*)                              Other: coder#kanga,nu
--=| A man is as sane as he is dangerous to his environment |=--


_______________________________________________
MUD-Dev maillist  -  MUD-Dev#kanga,nu
<A  HREF="http://www.kanga.nu/lists/listinfo/mud-dev">http://www.kanga.nu/lists/listinfo/mud-dev</A>

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00201" HREF="msg00201.html">[MUD-Dev] [adv-mud] Spellbound Hierarchy and Keys (fwd)</A></STRONG>
<UL><LI><EM>From:</EM> J C Lawrence &lt;claw#kanga,nu&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00230.html">RE: [MUD-Dev] Community Relations</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00233.html">RE: [MUD-Dev] Community Relations</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00201.html">[MUD-Dev] [adv-mud] Spellbound Hierarchy and Keys (fwd)</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00187.html">[MUD-Dev] [adv-mud] Re: Topic list repost (fwd)</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00231"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00231"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><strong><A NAME="00202" HREF="msg00202.html">[MUD-Dev] Re: [adv-mud] Better Grammer Detection</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Fri 21 Jan 2000, 04:49 GMT
<UL>
<LI><strong><A NAME="00206" HREF="msg00206.html">[MUD-Dev] MUD-Dev vs. adv-mud</A></strong>, 
phlUID <a href="mailto:phluid#mindless,com">phluid#mindless,com</a>, Fri 21 Jan 2000, 06:37 GMT
<UL>
<LI><strong><A NAME="00204" HREF="msg00204.html">[MUD-Dev] Re: [adv-mud] MUD-Dev vs. adv-mud</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Fri 21 Jan 2000, 06:34 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
<LI><strong><A NAME="00201" HREF="msg00201.html">[MUD-Dev] [adv-mud] Spellbound Hierarchy and Keys (fwd)</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Fri 21 Jan 2000, 04:39 GMT
<UL>
<LI><strong><A NAME="00231" HREF="msg00231.html">Re: [MUD-Dev] [adv-mud] Spellbound Hierarchy and Keys (fwd)</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Sat 29 Jan 2000, 20:46 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00187" HREF="msg00187.html">[MUD-Dev] [adv-mud] Re: Topic list repost (fwd)</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Thu 20 Jan 2000, 23:41 GMT
<LI><strong><A NAME="00186" HREF="msg00186.html">[MUD-Dev] Re: [adv-mud] What good is a hero when nobody knows?</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Thu 20 Jan 2000, 23:34 GMT
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00207" HREF="msg00207.html">[MUD-Dev] RE: [adv-mud] What good is a hero when nobody knows?</A></strong>, 
phlUID <a href="mailto:phluid#mindless,com">phluid#mindless,com</a>, Fri 21 Jan 2000, 06:37 GMT
<UL>
<LI><strong><A NAME="00235" HREF="msg00235.html">Re: [MUD-Dev] RE: [adv-mud] What good is a hero when nobody knows?</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Sun 30 Jan 2000, 05:13 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>