Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** map2stl.c 2009-05-15 20:53:30.000000000 +0400
- --- my_map2stl.c 2014-10-31 13:14:47.469190278 +0400
- ***************
- *** 24,36 ****
- typedef struct
- {
- short wallptr, wallnum;
- ! long z[2]; short stat[2]; build7surf_t surf[2];
- char visibility, filler;
- short lotag, hitag, extra;
- } build7sect_t;
- typedef struct
- {
- ! long x, y;
- short point2, nextwall, nextsect, cstat, picnum, overpicnum;
- signed char shade;
- char pal, xrepeat, yrepeat, xpanning, ypanning;
- --- 24,36 ----
- typedef struct
- {
- short wallptr, wallnum;
- ! int z[2]; short stat[2]; build7surf_t surf[2];
- char visibility, filler;
- short lotag, hitag, extra;
- } build7sect_t;
- typedef struct
- {
- ! int x, y;
- short point2, nextwall, nextsect, cstat, picnum, overpicnum;
- signed char shade;
- char pal, xrepeat, yrepeat, xpanning, ypanning;
- ***************
- *** 349,368 ****
- static long loadmap (char *filnam)
- {
- float f, fx, fy;
- ! long i, j, k;
- short s;
- FILE *fil;
- !
- ! fil = fopen(filnam,"rb"); if (!fil) return(0);
- ! fread(&i,4,1,fil); if (i != 0x00000007) return(0); //not Build1 .MAP format 7
- fseek(fil,20,SEEK_SET);
- ! fread(&s,2,1,fil); numsects = (long)s;
- sec = (sect_t *)malloc(numsects*sizeof(sect_t));
- memset(sec,0,numsects*sizeof(sect_t));
- for(i=0;i<numsects;i++)
- {
- ! fread(&b7sec,sizeof(b7sec),1,fil);
- sec[i].n = b7sec.wallnum;
- sec[i].wall = (wall_t *)realloc(sec[i].wall,sec[i].n*sizeof(wall_t));
- memset(sec[i].wall,0L,sec[i].n*sizeof(wall_t));
- --- 349,379 ----
- static long loadmap (char *filnam)
- {
- float f, fx, fy;
- ! int i;
- ! long j, k;
- short s;
- FILE *fil;
- ! fil = fopen(filnam,"rb");
- ! if (fil == NULL)
- ! return(0);
- ! if (fread(&i,1, sizeof(i),fil) != 4)
- ! return(0);
- !
- ! if (i != 7 && i !=9)
- ! return(0); //not Build1 .MAP format 7
- fseek(fil,20,SEEK_SET);
- ! if (fread(&s,1,sizeof(s),fil) != 2)
- ! return(0);
- !
- ! numsects = (long)s;
- sec = (sect_t *)malloc(numsects*sizeof(sect_t));
- memset(sec,0,numsects*sizeof(sect_t));
- for(i=0;i<numsects;i++)
- {
- ! if (fread(&b7sec,1,sizeof(b7sec),fil) != 40) // read sectors
- ! return(0);
- !
- sec[i].n = b7sec.wallnum;
- sec[i].wall = (wall_t *)realloc(sec[i].wall,sec[i].n*sizeof(wall_t));
- memset(sec[i].wall,0L,sec[i].n*sizeof(wall_t));
- ***************
- *** 375,394 ****
- }
- }
- ! fread(&s,2,1,fil); //numwalls
- for(i=k=0;i<numsects;i++)
- {
- for(j=0;j<sec[i].n;j++,k++)
- {
- ! fread(&b7wal,sizeof(b7wal),1,fil);
- sec[i].wall[j].x = ((float)b7wal.x)*(1.f/512.f);
- sec[i].wall[j].y = ((float)b7wal.y)*(1.f/512.f);
- sec[i].wall[j].n = b7wal.point2-k;
- }
- !
- fx = sec[i].wall[1].y-sec[i].wall[0].y;
- fy = sec[i].wall[0].x-sec[i].wall[1].x;
- ! f = fx*fx + fy*fy; if (f > 0.f) f = 1.f/(float)sqrt(f); fx *= f; fy *= f;
- for(j=0;j<2;j++)
- {
- sec[i].grad[j].x = fx*sec[i].grad[j].y;
- --- 386,414 ----
- }
- }
- ! if (fread(&s,1,2,fil) != 2)
- ! return(0); // walls count
- !
- for(i=k=0;i<numsects;i++)
- {
- for(j=0;j<sec[i].n;j++,k++)
- {
- ! if (fread(&b7wal,1, sizeof(b7wal),fil) != 32) //read walls
- ! return(0);
- !
- sec[i].wall[j].x = ((float)b7wal.x)*(1.f/512.f);
- sec[i].wall[j].y = ((float)b7wal.y)*(1.f/512.f);
- sec[i].wall[j].n = b7wal.point2-k;
- }
- !
- fx = sec[i].wall[1].y-sec[i].wall[0].y;
- fy = sec[i].wall[0].x-sec[i].wall[1].x;
- !
- ! f = fx*fx + fy*fy;
- ! if (f > 0.f)
- ! f = 1.f/(float)sqrt(f);
- ! fx *= f; fy *= f;
- !
- for(j=0;j<2;j++)
- {
- sec[i].grad[j].x = fx*sec[i].grad[j].y;
RAW Paste Data