Pointer-Based Type-Safe DMU

edited 2006 Jan 21 in Developers
<i>This post was originally made by <b>skyjake</b> on the dengDevs blog. It was posted under the category: Blog.</i>

I've been thinking about the pointer-based DMU functions. If there was a way to quickly and easily determine the type of the map object that a pointer refers to, there would be no need to pass the type as a parameter to the DMU pointer-based functions. This would make life much easier and safer.

Example (before):
<pre>
P_SetFixedp(DMU_SECTOR, sector, DMU_FLOOR_HEIGHT, newHeight);
</pre>

After:
<pre>
P_SetFixedp(sector, DMU_FLOOR_HEIGHT, newHeight);
</pre>

Although, something has to be done with the special DMU_LINE_OF_SECTOR and that kind of stuff.

Comments

  • Well, it gets my vote :)

    What do you have in mind?
  • It might be possible to define DMU_LINE_OF_SECTOR, DMU_SECTOR_OF_SUBSECTOR, and DMU_SEG_OF_POLYOBJ as flags, i.e., make them 0x80000000, 0x40000000, and 0x20000000 (respectively). Then it would be possible to use them like this:

    <pre>
    P_SetFixedp(subsector, DMU_SECTOR_OF_SUBSECTOR | DMU_FLOOR_HEIGHT,
    newHeight);
    P_GetPtrp(sector, DMU_LINE_OF_SECTOR | index);
    </pre>

    Might be nice.
  • It gets better and better.

    If the above is possible I would definetly prefer it as its obvious in the above syntax that <tt>DMU_LINE_OF_SECTOR</tt> is a property of the sector and that we are asking for a ptr to line <tt>index</tt>.
  • OK, I think I'll go ahead with this.
  • It's now in the CVS. Games need to be updated. It should be quite a straightforward Search & Replace All, though. With the exception of the SOMETHING_OF_OTHER -cases.

    It does look much better now, though. You can also do a <tt>P_GetIntp(subsector, DMU_SECTOR)</tt> and get the index of the sector. (<tt>P_ToIndex(DMU_SECTOR_OF_SUBSECTOR, subsector)</tt> is no longer available.)
  • Hold on, I'll run a regular expression and replace most of the current Get/Set<i>Type</i>p's.
  • You caught me just in time :)

    This syntax _is_ much easier to read.
  • Updated <tt>Src/Common/*.c</tt> in line with improved type-safe DMU. Now in CVS.

    Theres a few places in the games the expression hasn't picked up, mainly:
    <tt>P_ToIndex(DMU_TYPE, object)</tt>
  • I'll take care of those ToIndex()s.
Sign In or Register to comment.