Y_Less

Complex enum

Dec 1st, 2012
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.48 KB | None | 0 0
  1. // =============================================================================
  2. // =============================================================================
  3. // IMPORTANT NOTE: The order of elements in this enum is INCREDIBLY important.
  4. // Because this is three enums in one, they share some pieces of data that must
  5. // not get overridden.
  6. // =============================================================================
  7. // =============================================================================
  8. enum E_AREA
  9. {
  10.     //union
  11.     //{
  12.     //    struct
  13.     //    {
  14.             #if YSIM_HAS_MASTER
  15.                 E_AREA_MASTER,
  16.             #endif
  17.             Float:E_AREA_POS[4],
  18.             PlayerArray:E_AREA_PLAYERS<MAX_PLAYERS>,
  19.             // This MUST go between "E_AREA_PLAYERS" and "E_AREA_FLAGS" to
  20.             // remain constant in subsequent unions.
  21.             #if defined AREA_VERY_FAST
  22.                 Float:E_AREA_BOUNDING[4],
  23.             #endif
  24.             // As must this.
  25.             #if AREA_WORLDS > 0
  26.                 BitArray:E_AREA_WORLDS<AREA_WORLDS>,
  27.             #endif
  28.             // ALWAYS last (actually used by EVERY type).
  29.             e_AREA_FLAGS:E_AREA_FLAGS,
  30.     //    }
  31.     //    // Start of poly data.
  32.     //    struct
  33.     //    {
  34.             // Reset the enum counter to 0 (on the next item).
  35.             _E_AREA_RESET_@1 = -1,
  36.             // Now restart.
  37.             #if YSIM_HAS_MASTER
  38.                 // Skip the master flag if it exists.
  39.                 _E_AREA_MASTER_@1,
  40.             #endif
  41.             // This is where polys differ from all others.
  42.             Float:E_AREA_POLY_POS[2],
  43.             E_AREA_POLY_COUNT,
  44.             E_AREA_POLY_NEXT,
  45.             // Skip all the array and flag data, they stay the same.
  46.             _E_AREA_ARRAYS_@1[E_AREA_FLAGS - E_AREA_PLAYERS + E_AREA:1],
  47.     //    }
  48.     //    // Start of poly child data.
  49.     //    struct
  50.     //    {
  51.             // Reset the enum counter to 0 (on the next item).
  52.             _E_AREA_RESET_@2 = -1,
  53.             // Now restart.
  54.             #if YSIM_HAS_MASTER
  55.                 // Skip the master flag if it exists.
  56.                 _E_AREA_MASTER_@2,
  57.             #endif
  58.             // Store a link to the parent of this poly child.
  59.             E_AREA_CHILD_PARENT,
  60.             #if _:(E_AREA_FLAGS - E_AREA_CHILD_PARENT) & 1
  61.                 // There are an ODD number of available slots.  We can store an
  62.                 // extra pair iff we don't need to use "NEXT".
  63.                 //_E_AREA_SKIP_@2,
  64.                 E_AREA_CHILD_OPT_X,
  65.             #endif
  66.             // And the next one in VERY rare cases (I hope).
  67.             E_AREA_CHILD_NEXT,
  68.             E_AREA_CHILD_OPT_Y = E_AREA_CHILD_NEXT,
  69.             // Just store a vast number of X/Y pairs in this child.
  70.             E_AREA_CHILD_ELEMS[_:E_AREA_FLAGS - _:E_AREA_CHILD_NEXT - 1],
  71.             // Skip the flags.
  72.             _E_AREA_FLAGS_@2
  73.     //    }
  74. }
  75.  
  76. #define CHILD_AREA_SLOTS ((_:E_AREA_FLAGS - _:E_AREA_CHILD_ELEMS) / 2)
Advertisement
Add Comment
Please, Sign In to add comment