ZoriaRPG

Mapdata Setter Macros (sanity checks)

Oct 23rd, 2018
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //mapdata m-> Variables
  2.     #define SET_MAPDATA_VAR_INT32(member, str) \
  3.     { \
  4.         if ( ri->mapsref == 0 ) \
  5.         { \
  6.             Z_scripterrlog("Script attempted to use a mapdata->%s pointer that is uninitialised\n",str); \
  7.             break; \
  8.         } \
  9.         else if ( ri->mapsref == LONG_MAX ) \
  10.         { \
  11.             Z_scripterrlog("Script attempted to use a mapdata->%s on a pointer that is uninitialised\n",str); \
  12.             break; \
  13.         } \
  14.         else \
  15.         { \
  16.             mapscr *m = &TheMaps[ri->mapsref]; \
  17.             m->member = vbound((value / 10000),-214747,214747); \
  18.         } \
  19.     } \
  20.    
  21.     #define SET_MAPDATA_VAR_INT16(member, str) \
  22.     { \
  23.         if ( ri->mapsref == 0 ) \
  24.         { \
  25.             Z_scripterrlog("Script attempted to use a mapdata->%s pointer that is uninitialised\n",str); \
  26.             break; \
  27.         } \
  28.         else if ( ri->mapsref == LONG_MAX ) \
  29.         { \
  30.             Z_scripterrlog("Script attempted to use a mapdata->%s on a pointer that is uninitialised\n",str); \
  31.             break; \
  32.         } \
  33.         else \
  34.         { \
  35.             mapscr *m = &TheMaps[ri->mapsref]; \
  36.             m->member = vbound((value / 10000),0,32767); \
  37.         } \
  38.     } \
  39.  
  40.     #define SET_MAPDATA_VAR_BYTE(member, str) \
  41.     { \
  42.         if ( ri->mapsref == 0 ) \
  43.         { \
  44.             Z_scripterrlog("Script attempted to use a mapdata->%s pointer that is uninitialised\n",str); \
  45.             break; \
  46.         } \
  47.         else if ( ri->mapsref == LONG_MAX ) \
  48.         { \
  49.             Z_scripterrlog("Script attempted to use a mapdata->%s on a pointer that is uninitialised\n",str); \
  50.             break; \
  51.         } \
  52.         else \
  53.         { \
  54.             mapscr *m = &TheMaps[ri->mapsref]; \
  55.             m->member = vbound((value / 10000),0,255); \
  56.         } \
  57.     } \
  58.    
  59.     #define SET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
  60.     { \
  61.         int indx = ri->d[0] / 10000; \
  62.         if(indx < 0 || indx > indexbound ) \
  63.         { \
  64.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx), str); \
  65.             break; \
  66.         } \
  67.         if ( ri->mapsref == 0 ) \
  68.         { \
  69.             Z_scripterrlog("Script attempted to use a mapdata->%s pointer that is uninitialised\n",str); \
  70.             break; \
  71.         } \
  72.         else if ( ri->mapsref == LONG_MAX ) \
  73.         { \
  74.             Z_scripterrlog("Script attempted to use a mapdata->%s on a pointer that is uninitialised\n",str); \
  75.             break; \
  76.         } \
  77.         else \
  78.         { \
  79.             mapscr *m = &TheMaps[ri->mapsref]; \
  80.             m->member[indx] = vbound((value / 10000),-214747,214747); \
  81.         } \
  82.     } \
  83.    
  84.     #define SET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
  85.     { \
  86.         int indx = ri->d[0] / 10000; \
  87.         if(indx < 0 || indx > indexbound ) \
  88.         { \
  89.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx), str); \
  90.             break; \
  91.         } \
  92.         if ( ri->mapsref == 0 ) \
  93.         { \
  94.             Z_scripterrlog("Script attempted to use a mapdata->%s pointer that is uninitialised\n",str); \
  95.             break; \
  96.         } \
  97.         else if ( ri->mapsref == LONG_MAX ) \
  98.         { \
  99.             Z_scripterrlog("Script attempted to use a mapdata->%s on a pointer that is uninitialised\n",str); \
  100.             break; \
  101.         } \
  102.         else \
  103.         { \
  104.             mapscr *m = &TheMaps[ri->mapsref]; \
  105.             m->member[indx] = vbound((value / 10000),-32767,32767); \
  106.         } \
  107.     } \
  108.  
  109.     #define SET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
  110.     { \
  111.         int indx = ri->d[0] / 10000; \
  112.         if(indx < 0 || indx > indexbound ) \
  113.         { \
  114.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx), str); \
  115.             break; \
  116.         } \
  117.         if ( ri->mapsref == 0 ) \
  118.         { \
  119.             Z_scripterrlog("Script attempted to use a mapdata->%s pointer that is uninitialised\n",str); \
  120.             break; \
  121.         } \
  122.         else if ( ri->mapsref == LONG_MAX ) \
  123.         { \
  124.             Z_scripterrlog("Script attempted to use a mapdata->%s on a pointer that is uninitialised\n",str); \
  125.             break; \
  126.         } \
  127.         else \
  128.         { \
  129.             mapscr *m = &TheMaps[ri->mapsref]; \
  130.             m->member[indx] = vbound((value / 10000),0,255); \
  131.         } \
  132.     }\
  133.    
  134.     #define SET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
  135.     { \
  136.         int indx = ri->d[0] / 10000; \
  137.         if(indx < 0 || indx > indexbound ) \
  138.         { \
  139.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx), str); \
  140.             break; \
  141.         } \
  142.         if ( ri->mapsref == 0 ) \
  143.         { \
  144.             Z_scripterrlog("Script attempted to use a mapdata->%s pointer that is uninitialised\n",str); \
  145.             break; \
  146.         } \
  147.         else if ( ri->mapsref == LONG_MAX ) \
  148.         { \
  149.             Z_scripterrlog("Script attempted to use a mapdata->%s on a pointer that is uninitialised\n",str); \
  150.             break; \
  151.         } \
  152.         else \
  153.         { \
  154.             mapscr *m = &TheMaps[ri->mapsref]; \
  155.             m->member[indx] =( (value/10000) ? 1 : 0 ); \
  156.         } \
  157.     } \
  158.    
  159.     #define SET_MAPDATA_FLAG(member, str) \
  160.     { \
  161.         long flag =  (value/10000);  \
  162.         if ( ri->mapsref == 0 ) \
  163.         { \
  164.             Z_scripterrlog("Script attempted to use a mapdata->%s pointer that is uninitialised\n",str); \
  165.             break; \
  166.         } \
  167.         else if ( ri->mapsref == LONG_MAX ) \
  168.         { \
  169.             Z_scripterrlog("Script attempted to use a mapdata->%s on a pointer that is uninitialised\n",str); \
  170.             break; \
  171.         } \
  172.         else \
  173.         { \
  174.             mapscr *m = &TheMaps[ri->mapsref]; \
  175.             if ( flag != 0 ) \
  176.             { \
  177.                 m->member|=flag; \
  178.             } \
  179.             else m->.member|= ~flag; \
  180.         } \
  181.     } \
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×