Guest User

map2stl.diff, add gcc support

a guest
Oct 31st, 2014
176
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *** map2stl.c   2009-05-15 20:53:30.000000000 +0400
  2. --- my_map2stl.c    2014-10-31 13:14:47.469190278 +0400
  3. ***************
  4. *** 24,36 ****
  5.   typedef struct
  6.   {
  7.      short wallptr, wallnum;
  8. !    long z[2]; short stat[2]; build7surf_t surf[2];
  9.      char visibility, filler;
  10.      short lotag, hitag, extra;
  11.   } build7sect_t;
  12.   typedef struct
  13.   {
  14. !    long x, y;
  15.      short point2, nextwall, nextsect, cstat, picnum, overpicnum;
  16.      signed char shade;
  17.      char pal, xrepeat, yrepeat, xpanning, ypanning;
  18. --- 24,36 ----
  19.   typedef struct
  20.   {
  21.      short wallptr, wallnum;
  22. !    int  z[2]; short stat[2]; build7surf_t surf[2];
  23.      char visibility, filler;
  24.      short lotag, hitag, extra;
  25.   } build7sect_t;
  26.   typedef struct
  27.   {
  28. !    int x, y;
  29.      short point2, nextwall, nextsect, cstat, picnum, overpicnum;
  30.      signed char shade;
  31.      char pal, xrepeat, yrepeat, xpanning, ypanning;
  32. ***************
  33. *** 349,368 ****
  34.   static long loadmap (char *filnam)
  35.   {
  36.      float f, fx, fy;
  37. !    long i, j, k;
  38.      short s;
  39.      FILE *fil;
  40. !
  41. !    fil = fopen(filnam,"rb"); if (!fil) return(0);
  42. !    fread(&i,4,1,fil); if (i != 0x00000007) return(0); //not Build1 .MAP format 7
  43.      fseek(fil,20,SEEK_SET);
  44.  
  45. !    fread(&s,2,1,fil); numsects = (long)s;
  46.      sec = (sect_t *)malloc(numsects*sizeof(sect_t));
  47.      memset(sec,0,numsects*sizeof(sect_t));
  48.      for(i=0;i<numsects;i++)
  49.      {
  50. !       fread(&b7sec,sizeof(b7sec),1,fil);
  51.         sec[i].n = b7sec.wallnum;
  52.         sec[i].wall = (wall_t *)realloc(sec[i].wall,sec[i].n*sizeof(wall_t));
  53.         memset(sec[i].wall,0L,sec[i].n*sizeof(wall_t));
  54. --- 349,379 ----
  55.   static long loadmap (char *filnam)
  56.   {
  57.      float f, fx, fy;
  58. !    int i;
  59. !    long  j, k;
  60.      short s;
  61.      FILE *fil;
  62. !    fil = fopen(filnam,"rb");
  63. !    if (fil == NULL)
  64. !   return(0);
  65. !    if (fread(&i,1, sizeof(i),fil) != 4)
  66. !   return(0);
  67. !  
  68. !    if (i != 7 && i !=9)
  69. !   return(0); //not Build1 .MAP format 7
  70.      fseek(fil,20,SEEK_SET);
  71.  
  72. !    if (fread(&s,1,sizeof(s),fil) != 2)
  73. !   return(0);
  74. !
  75. !    numsects = (long)s;
  76.      sec = (sect_t *)malloc(numsects*sizeof(sect_t));
  77.      memset(sec,0,numsects*sizeof(sect_t));
  78.      for(i=0;i<numsects;i++)
  79.      {
  80. !       if (fread(&b7sec,1,sizeof(b7sec),fil) != 40) // read sectors
  81. !   return(0);
  82. !
  83.         sec[i].n = b7sec.wallnum;
  84.         sec[i].wall = (wall_t *)realloc(sec[i].wall,sec[i].n*sizeof(wall_t));
  85.         memset(sec[i].wall,0L,sec[i].n*sizeof(wall_t));
  86. ***************
  87. *** 375,394 ****
  88.         }
  89.      }
  90.  
  91. !    fread(&s,2,1,fil); //numwalls
  92.      for(i=k=0;i<numsects;i++)
  93.      {
  94.         for(j=0;j<sec[i].n;j++,k++)
  95.         {
  96. !          fread(&b7wal,sizeof(b7wal),1,fil);
  97.            sec[i].wall[j].x = ((float)b7wal.x)*(1.f/512.f);
  98.            sec[i].wall[j].y = ((float)b7wal.y)*(1.f/512.f);
  99.            sec[i].wall[j].n = b7wal.point2-k;
  100.         }
  101. !
  102.         fx = sec[i].wall[1].y-sec[i].wall[0].y;
  103.         fy = sec[i].wall[0].x-sec[i].wall[1].x;
  104. !       f = fx*fx + fy*fy; if (f > 0.f) f = 1.f/(float)sqrt(f); fx *= f; fy *= f;
  105.         for(j=0;j<2;j++)
  106.         {
  107.            sec[i].grad[j].x = fx*sec[i].grad[j].y;
  108. --- 386,414 ----
  109.         }
  110.      }
  111.  
  112. !    if (fread(&s,1,2,fil) != 2)
  113. !   return(0); // walls  count
  114. !
  115.      for(i=k=0;i<numsects;i++)
  116.      {
  117.         for(j=0;j<sec[i].n;j++,k++)
  118.         {
  119. !          if (fread(&b7wal,1, sizeof(b7wal),fil) != 32) //read walls
  120. !       return(0);
  121. !
  122.            sec[i].wall[j].x = ((float)b7wal.x)*(1.f/512.f);
  123.            sec[i].wall[j].y = ((float)b7wal.y)*(1.f/512.f);
  124.            sec[i].wall[j].n = b7wal.point2-k;
  125.         }
  126. !  
  127.         fx = sec[i].wall[1].y-sec[i].wall[0].y;
  128.         fy = sec[i].wall[0].x-sec[i].wall[1].x;
  129. !
  130. !       f = fx*fx + fy*fy;
  131. !       if (f > 0.f)
  132. !   f = 1.f/(float)sqrt(f);
  133. !       fx *= f; fy *= f;
  134. !
  135.         for(j=0;j<2;j++)
  136.         {
  137.            sec[i].grad[j].x = fx*sec[i].grad[j].y;
RAW Paste Data