Advertisement
ZoriaRPG

Maqpdata FFC Functions Fix

Oct 26th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.31 KB | None | 0 0
  1. #define GET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
  2.     { \
  3.         int indx = (ri->d[0] / 10000)-1; \
  4.         if(indx < 0 || indx > indexbound ) \
  5.         { \
  6.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
  7.             ret = -10000; \
  8.         } \
  9.         else if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 ) \
  10.         { \
  11.             Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
  12.             ret = -10000; \
  13.         } \
  14.         else \
  15.         { \
  16.             mapscr *m = &TheMaps[ri->mapsref]; \
  17.             ret = (m->member[indx]); \
  18.         } \
  19.     } \
  20.    
  21.     #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
  22.     { \
  23.         int indx = (ri->d[0] / 10000)-1; \
  24.         if(indx < 0 || indx > indexbound ) \
  25.         { \
  26.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
  27.             ret = -10000; \
  28.         } \
  29.         else if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 ) \
  30.         { \
  31.             Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
  32.             ret = -10000; \
  33.         } \
  34.         else \
  35.         { \
  36.             mapscr *m = &TheMaps[ri->mapsref]; \
  37.             ret = (m->member[indx])*10000; \
  38.         } \
  39.     } \
  40.     #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
  41.     { \
  42.         int indx = (ri->d[0] / 10000)-1; \
  43.         if(indx < 0 || indx > indexbound ) \
  44.         { \
  45.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
  46.             ret = -10000; \
  47.         } \
  48.         else if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 ) \
  49.         { \
  50.             Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
  51.             ret = -10000; \
  52.         } \
  53.         else \
  54.         { \
  55.             mapscr *m = &TheMaps[ri->mapsref]; \
  56.             ret = (m->member[indx])*10000; \
  57.         } \
  58.     } \
  59.  
  60. case MAPDATAFFDATA:         GET_MAPDATA_FFC_INDEX32(ffdata, "FFCData", 31); break;  //W, 32 OF THESE
  61. case MAPDATAFFCSET:         GET_MAPDATA_FFC_INDEX32(ffcset, "FFCCSet", 31); break;  //B, 32
  62. case MAPDATAFFDELAY:        GET_MAPDATA_FFC_INDEX32(ffdelay, "FFCDelay", 31); break;    //W, 32
  63. case MAPDATAFFX:        GET_MAPDATA_FFCPOS_INDEX32(ffx, "FFCX", 31); break; //INT32, 32 OF THESE
  64. case MAPDATAFFY:        GET_MAPDATA_FFCPOS_INDEX32(ffy, "FFCY", 31); break; //..
  65. case MAPDATAFFXDELTA:       GET_MAPDATA_FFCPOS_INDEX32(ffxdelta, "FFCVx", 31); break;   //..
  66. case MAPDATAFFYDELTA:       GET_MAPDATA_FFCPOS_INDEX32(ffydelta, "FFCVy", 31); break;   //..
  67. case MAPDATAFFXDELTA2:      GET_MAPDATA_FFCPOS_INDEX32(ffxdelta2, "FFCAx", 31); break;  //..
  68. case MAPDATAFFYDELTA2:      GET_MAPDATA_FFCPOS_INDEX32(ffydelta2, "FFCAy", 31); break;  //..
  69. case MAPDATAFFFLAGS:        GET_MAPDATA_FFC_INDEX32(ffflags, "FFCFlags", 31); break;    //INT16, 32 OF THESE
  70.  
  71. case MAPDATAFFWIDTH:       
  72. {
  73.     if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 )
  74.     {
  75.         Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
  76.         ret = -10000;
  77.     }
  78.     else
  79.     {
  80.         mapscr *m = &TheMaps[ri->mapsref];
  81.         int indx = (ri->d[0] / 10000)-1;
  82.         if ( indx < 0 || indx > 32 )
  83.         {
  84.             Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
  85.             ret = -10000;
  86.             break;
  87.         }
  88.         ret = ((m->ffwidth[indx]&0x3F)+1)*10000;
  89.         break;
  90.     }
  91. }  
  92.  
  93.  
  94. //GET_MAPDATA_BYTE_INDEX(ffwidth, "FFCTileWidth");  //B, 32 OF THESE
  95. case MAPDATAFFHEIGHT:      
  96. {
  97.     if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 )
  98.     {
  99.         Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
  100.         ret = -10000;
  101.     }
  102.     else
  103.     {
  104.         mapscr *m = &TheMaps[ri->mapsref];
  105.         int indx = (ri->d[0] / 10000)-1;
  106.         if ( indx < 0 || indx > 32 )
  107.         {
  108.             Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
  109.             ret = -10000;
  110.             break;
  111.         }
  112.         ret=((m->ffheight[indx]&0x3F)+1)*10000;
  113.         break;
  114.     }
  115.    
  116. }
  117.  
  118. //EffectWidth tmpscr->ffwidth[ri->ffcref]= (tmpscr->ffwidth[ri->ffcref]&63) | ((((value/10000)-1)&3)<<6);
  119.  
  120. //GET_MAPDATA_BYTE_INDEX(ffheight, "FFCTileHeight"  //B, 32 OF THESE
  121. case MAPDATAFFEFFECTWIDTH:     
  122. {
  123.     if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 )
  124.     {
  125.         Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
  126.         ret = -10000;
  127.     }
  128.     else
  129.     {
  130.         mapscr *m = &TheMaps[ri->mapsref];
  131.         int indx = (ri->d[0] / 10000)-1;
  132.         if ( indx < 0 || indx > 32 )
  133.         {
  134.             Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
  135.             ret = -10000;
  136.             break;
  137.         }
  138.         ret=((m->ffwidth[indx]>>6)+1)*10000;
  139.         break;
  140.     }
  141. }
  142.  
  143.  
  144. //GET_MAPDATA_BYTE_INDEX(ffwidth, "FFCEffectWidth");    //B, 32 OF THESE
  145. case MAPDATAFFEFFECTHEIGHT:
  146. {
  147.     if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 )
  148.     {
  149.         Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
  150.         ret = -10000;
  151.     }
  152.     else
  153.     {
  154.         mapscr *m = &TheMaps[ri->mapsref];
  155.         int indx = (ri->d[0] / 10000)-1;
  156.         if ( indx < 0 || indx > 32 )
  157.         {
  158.             Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
  159.             ret = -10000;
  160.             break;
  161.         }
  162.         ret=((m->ffheight[indx]>>6)+1)*10000;
  163.         break;
  164.     }
  165. }  
  166.    
  167. //GET_MAPDATA_BYTE_INDEX(ffheight, "FFCEffectHeight"    //B, 32 OF THESE   
  168.  
  169. case MAPDATAFFLINK:         GET_MAPDATA_FFC_INDEX32(fflink, "FFCLink", 31); break;  //B, 32 OF THESE
  170. case MAPDATAFFSCRIPT:       GET_MAPDATA_FFC_INDEX32(ffscript, "FFCScript", 31); break;  //W, 32 OF THESE
  171.  
  172.  
  173. //Setters
  174.  
  175.  
  176.     #define SET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
  177.     { \
  178.         int indx = (ri->d[0] / 10000)-1; \
  179.         if(indx < 0 || indx > indexbound ) \
  180.         { \
  181.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
  182.             break; \
  183.         } \
  184.         else if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 ) \
  185.         { \
  186.             Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
  187.             break\
  188.         } \
  189.         else \
  190.         { \
  191.             mapscr *m = &TheMaps[ri->mapsref]; \
  192.             m->member[indx] = value; \
  193.         } \
  194.     } \
  195.    
  196.     #define SET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
  197.     { \
  198.         int indx = (ri->d[0] / 10000)-1; \
  199.         if(indx < 0 || indx > indexbound ) \
  200.         { \
  201.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
  202.             break; \
  203.         } \
  204.         else if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 ) \
  205.         { \
  206.             Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
  207.             break\
  208.         } \
  209.         else \
  210.         { \
  211.             mapscr *m = &TheMaps[ri->mapsref]; \
  212.             m->member[indx] = value/10000; \
  213.         } \
  214.     } \
  215.    
  216.     #define SET_MAPDATA_FFC_INDEX_VBOUND(member, str, indexbound, min, max) \
  217.     { \
  218.         int v = value/10000; \
  219.         int indx = (ri->d[0] / 10000)-1; \
  220.         if(indx < 0 || indx > indexbound ) \
  221.         { \
  222.             Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
  223.             break; \
  224.         } \
  225.         if(v < min || v > max ) \
  226.         { \
  227.             Z_scripterrlog("Invalid value assigned to mapdata->%s[]: %d\n", (indx+1), str); \
  228.             break; \
  229.         } \
  230.         else if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 ) \
  231.         { \
  232.             Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
  233.             break\
  234.         } \
  235.         else \
  236.         { \
  237.             mapscr *m = &TheMaps[ri->mapsref]; \
  238.             m->member[indx] = v; \
  239.         } \
  240.     } \
  241.    
  242.    
  243. case MAPDATAFFDATA:         SET_MAPDATA_FFC_INDEX32(ffdata, "FFCData", 31); break;  //W, 32 OF THESE
  244. case MAPDATAFFCSET:         SET_MAPDATA_FFC_INDEX32(ffcset, "FFCCSet", 31); break;  //B, 32
  245. case MAPDATAFFDELAY:        SET_MAPDATA_FFC_INDEX32(ffdelay, "FFCDelay", 31); break;    //W, 32
  246. case MAPDATAFFX:        SET_MAPDATA_FFCPOS_INDEX32(ffx, "FFCX", 31); break; //INT32, 32 OF THESE
  247. case MAPDATAFFY:        SET_MAPDATA_FFCPOS_INDEX32(ffy, "FFCY", 31); break; //..
  248. case MAPDATAFFXDELTA:       SET_MAPDATA_FFCPOS_INDEX32(ffxdelta, "FFCVx", 31); break;   //..
  249. case MAPDATAFFYDELTA:       SET_MAPDATA_FFCPOS_INDEX32(ffydelta, "FFCVy", 31); break;   //..
  250. case MAPDATAFFXDELTA2:      SET_MAPDATA_FFCPOS_INDEX32(ffxdelta2, "FFCAx", 31); break;  //..
  251. case MAPDATAFFYDELTA2:      SET_MAPDATA_FFCPOS_INDEX32(ffydelta2, "FFCAy", 31); break;  //..
  252. case MAPDATAFFFLAGS:        SET_MAPDATA_FFC_INDEX32(ffflags, "FFCFlags", 31); break;    //INT16, 32 OF THESE
  253. //Height and With are Or'd together, and need to be separate:
  254. /*
  255.  //TileWidth ffwidth[ri->ffcref]= (tmpscr->ffwidth[ri->ffcref] & ~63) | (((value/10000)-1)&63);
  256. */
  257. case MAPDATAFFWIDTH:       
  258. {
  259.     if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 )
  260.     {
  261.         Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
  262.         break;
  263.     }
  264.     else
  265.     {
  266.     mapscr *m = &TheMaps[ri->mapsref];
  267.     int indx = (ri->d[0] / 10000)-1;
  268.         if ( indx < 0 || indx > 32 )
  269.         {
  270.             Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
  271.             break;
  272.         }
  273.         if ( (value/10000) < 0 || (value/10000) > 4 )
  274.         {
  275.             Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileWidth[]: %d\n", value/10000);
  276.             break;
  277.         }
  278.         m->ffwidth[indx] = ( m->ffwidth[indx]&~63) | vbound( (((value/10000)-1)&63), (0&63), (214747&63) );
  279.         break;
  280.     }
  281. }  
  282.  
  283.  
  284. //SET_MAPDATA_BYTE_INDEX(ffwidth, "FFCTileWidth");  //B, 32 OF THESE
  285. case MAPDATAFFHEIGHT:      
  286. {
  287.     if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 )
  288.     {
  289.         Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
  290.         break;
  291.     }
  292.     else
  293.     {
  294.         mapscr *m = &TheMaps[ri->mapsref];
  295.         int (ri->d[0] / 10000)-1;
  296.         if ( indx < 0 || indx > 31 )
  297.         {
  298.             Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
  299.             break;
  300.         }
  301.         if ( (value/10000) < 0 || (value/10000) > 4 )
  302.         {
  303.             Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileHeight[]: %d\n", value/10000);
  304.             break;
  305.         }
  306.         m->ffheight[indx] = ( m->ffheight[indx]&~63) | vbound( (((value/10000)-1)&63), (0&63), (4&63) );
  307.         break;
  308.     }
  309.    
  310. }
  311.  
  312. //EffectWidth tmpscr->ffwidth[ri->ffcref]= (tmpscr->ffwidth[ri->ffcref]&63) | ((((value/10000)-1)&3)<<6);
  313.  
  314. //SET_MAPDATA_BYTE_INDEX(ffheight, "FFCTileHeight"  //B, 32 OF THESE
  315. case MAPDATAFFEFFECTWIDTH:     
  316. {
  317.     if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 )
  318.     {
  319.         Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
  320.         break;
  321.     }
  322.     else
  323.     {
  324.         mapscr *m = &TheMaps[ri->mapsref];
  325.         int (ri->d[0] / 10000)-1;
  326.         if ( indx < 0 || indx > 31 )
  327.         {
  328.             Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
  329.             break;
  330.         }
  331.         if ( (value/10000) < 0 )
  332.         {
  333.             Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCEffectWidth[]: %d\n", value/10000);
  334.             break;
  335.         }
  336.         m->ffwidth[indx] = ( m->ffwidth[indx]&63) | vbound( ((((value/10000)-1)&3)<<6), ((((0)-1)&3)<<6), ((((214747)&3)<<6)) );
  337.         break;
  338.     }
  339. }
  340.  
  341.  
  342. //SET_MAPDATA_BYTE_INDEX(ffwidth, "FFCEffectWidth");    //B, 32 OF THESE
  343. case MAPDATAFFEFFECTHEIGHT:
  344. {
  345.     if ( ri->mapsref == LONG_MAX || ri->mapsref == 0 )
  346.     {
  347.         Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
  348.         break;
  349.     }
  350.     else
  351.     {
  352.         mapscr *m = &TheMaps[ri->mapsref];
  353.         int indx = (ri->d[0] / 10000)-1;
  354.         if ( indx < 0 || indx > 31 )
  355.         {
  356.             Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
  357.             break;
  358.         }
  359.         if ( (value/10000) < 0 )
  360.         {
  361.             Z_scripterrlog("Invalid HEIGHT value passed to MapData->FFCEffectHeight[]: %d\n", value/10000);
  362.             break;
  363.         }
  364.         m->ffheight[indx] = ( m->ffheight[indx]&63) | vbound( ((((value/10000)-1)&3)<<6), ((((0)-1)&3)<<6), ((((214747)&3)<<6)) );
  365.         break;
  366.     }
  367. }  
  368.    
  369. //SET_MAPDATA_BYTE_INDEX(ffheight, "FFCEffectHeight"    //B, 32 OF THESE   
  370.  
  371. case MAPDATAFFLINK:         SET_MAPDATA_FFC_INDEX_VBOUND(fflink, "FFCLink", 31, 0, 32); break;  //B, 32 OF THESE
  372. case MAPDATAFFSCRIPT:       SET_MAPDATA_FFC_INDEX_VBOUND(ffscript, "FFCScript", 31, 0, 255); break; //W, 32 OF THESE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement