home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the DOOM Programming Gurus / Tricks_of_the_Doom_Programming_Gurus.iso / bonus / editors / deth / source / things2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-02  |  2.4 KB  |  140 lines

  1. /*
  2.    Doom Editor Utility, by Brendon Wyber and RaphaĆ«l Quinet.
  3.    
  4.    You are allowed to use any parts of this code in another program, as
  5.    long as you give credits to the authors in the documentation and in
  6.    the program itself.  Read the file README.1ST for more information.
  7.    
  8.    This program comes with absolutely no warranty.
  9.    
  10.    THINGS.C - Thing name and type routines.
  11.    */
  12.  
  13. /* the includes */
  14. #include "deu.h"
  15.  
  16. #define _WHITE    15
  17.  
  18. thing_class *Thing_classes;
  19.  
  20. /*
  21.    get the colour of a thing
  22.    */
  23.  
  24. BCINT GetThingColour( BCINT type)
  25. {
  26.     thing_class *c;
  27.     thing_type *t;
  28.     BCINT col;
  29.  
  30.     for(c = Thing_classes; c; c = c->next)
  31.         for(t = c->types; t; t = t->next)
  32.             if(t->type == type) {
  33.                 col = t->col1;
  34.                 goto found_it;
  35.             }
  36.     
  37.     /* fall through */
  38.     col = _WHITE;
  39.     
  40.  found_it:
  41.     return((col == _WHITE) ? WHITE : col);
  42. }
  43.  
  44.  
  45.  
  46. /*
  47.    get the name of a thing
  48.    */
  49.  
  50. char *GetThingName( BCINT type)
  51. {
  52.     thing_class *c;
  53.     thing_type *t;
  54.  
  55.     for(c = Thing_classes; c; c = c->next)
  56.         for(t = c->types; t; t = t->next)
  57.             if(t->type == type)
  58.                 return t->name;
  59.     
  60.     /* fall through */
  61.     return("Unknown Thing Type");
  62. }
  63.  
  64.  
  65.  
  66. /*
  67.    get the size of a thing
  68.    */
  69.  
  70. BCINT GetThingRadius( BCINT type)
  71. {
  72.     thing_class *c;
  73.     thing_type *t;
  74.  
  75.     for(c = Thing_classes; c; c = c->next)
  76.         for(t = c->types; t; t = t->next)
  77.             if(t->type == type)
  78.                 return t->radius;
  79.     
  80.     /* fall through */
  81.     return(16);
  82. }
  83.  
  84.  
  85. /*
  86.    get the name of the angle
  87.    */
  88.  
  89. char *GetAngleName( BCINT angle)
  90. {
  91.     switch (angle) {
  92.     case 0:
  93.     return "East";
  94.     case 45:
  95.     return "NorthEast";
  96.     case 90:
  97.     return "North";
  98.     case 135:
  99.     return "NorthWest";
  100.     case 180:
  101.     return "West";
  102.     case 225:
  103.     return "SouthWest";
  104.     case 270:
  105.     return "South";
  106.     case 315:
  107.     return "SouthEast";
  108.     }
  109.     return "<ILLEGAL ANGLE>";
  110. }
  111.  
  112.  
  113.  
  114. /*
  115.    get string of when something will appear
  116.    */
  117.  
  118. char *GetWhenName( BCINT when)
  119. {
  120.     static char temp[ 40];
  121.     
  122.     temp[ 0] = '\0';
  123.     if (when & 0x01)
  124.     strcat( temp, "Easy ");
  125.     if (when & 0x02)
  126.     strcat( temp, "Medium ");
  127.     if (when & 0x04)
  128.     strcat( temp, "Hard ");
  129.     if (when & 0x08)
  130.     strcat( temp, "Deaf ");
  131.     if (when & 0x10)
  132.     strcat( temp, "Multi ");
  133.     return temp;
  134. }
  135.  
  136.  
  137.  
  138. /* end of file */
  139.  
  140.