home *** CD-ROM | disk | FTP | other *** search
/ Superpower (Alt) / SUPERPOWER.iso / q / editoren / mbq311 / qck2map.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-07-12  |  3.9 KB  |  130 lines

  1. program quack2map;
  2.  
  3. type cube = record
  4.     x,y,z,xl,yl,zl:integer;
  5.     texture:string[9];
  6. end;
  7.  
  8.  
  9. type ent = record
  10.     class:string;
  11.     ox,oy,oz:integer;
  12.     angle:integer;
  13. end;
  14.  
  15.  
  16. var brush:array[0..255] of cube;
  17.     entity:array[0..63] of ent;
  18.     numbrushes:byte;
  19.     numentities:byte;
  20.  
  21. procedure load;
  22. var
  23.     f:file of cube;
  24.     e:file of ent;
  25.     l:string;
  26.     t:string;
  27.  
  28.     i:byte;
  29.     c:cube;
  30.     en:ent;
  31. begin
  32.     write('Name of brush and entity data files with out extention:');
  33.     readln(t);
  34.     assign(f,t+'.qck');
  35.     reset(f);
  36.         numbrushes:=0;
  37.         repeat
  38.             inc(numbrushes);
  39.             read(f,c);
  40.             brush[numbrushes-1]:=c;
  41.         until eof(f);
  42.     close(f);
  43.     str(numbrushes,l);
  44.     writeln('Loaded '+l+' brushes.');
  45.  
  46.     assign(e,t+'.ent');
  47.     reset(e);
  48.         numentities:=0;
  49.         repeat
  50.             inc(numentities);
  51.             read(e,en);
  52.             entity[numentities-1]:=en;
  53.         until eof(e);
  54.     close(e);
  55.     str(numentities,l);
  56.     writeln('Loaded '+l+' entities.');
  57. end;
  58.  
  59. function i2s(i:integer):string;
  60. var s:string;
  61. begin
  62.     str(i,s);
  63.     i2s:=s;
  64. end;
  65.  
  66. procedure savemap;
  67. var l:string;
  68.     f:text;
  69.     b:byte;
  70. begin
  71.     write('write map to:'); readln(l);
  72.     assign(f,l);
  73.     rewrite(f);
  74.         writeln(f,'{');
  75.         writeln(f,'"classname" "worldspawn"');
  76.     for b:=0 to numbrushes-1 do begin
  77.         writeln(f,'{');
  78.         {begin work on side 1}
  79.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].y)+' '+i2s(brush[b].z)+' ) ');
  80.             write(f,'( '+i2s(brush[b].xl)+' '+i2s(brush[b].y)+' '+i2s(brush[b].z)+' ) ');
  81.             write(f,'( '+i2s(brush[b].xl)+' '+i2s(brush[b].yl)+' '+i2s(brush[b].z)+' ) ');
  82.             writeln(f,brush[b].texture+' 0 0 0 1.0 1.0');
  83.         {begin work on side 2}
  84.             write(f,'( '+i2s(brush[b].xl)+' '+i2s(brush[b].y)+' '+i2s(brush[b].zl)+' ) ');
  85.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].y)+' '+i2s(brush[b].zl)+' ) ');
  86.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].yl)+' '+i2s(brush[b].zl)+' ) ');
  87.             writeln(f,brush[b].texture+' 0 0 0 1.0 1.0');
  88.         {begin work on side 3}
  89.             write(f,'( '+i2s(brush[b].xl)+' '+i2s(brush[b].y)+' '+i2s(brush[b].z)+' ) ');
  90.             write(f,'( '+i2s(brush[b].xl)+' '+i2s(brush[b].y)+' '+i2s(brush[b].zl)+' ) ');
  91.             write(f,'( '+i2s(brush[b].xl)+' '+i2s(brush[b].yl)+' '+i2s(brush[b].zl)+' ) ');
  92.             writeln(f,brush[b].texture+' 0 0 0 1.0 1.0');
  93.         {begin work on side 4}
  94.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].y)+' '+i2s(brush[b].zl)+' ) ');
  95.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].y)+' '+i2s(brush[b].z)+' ) ');
  96.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].yl)+' '+i2s(brush[b].z)+' ) ');
  97.             writeln(f,brush[b].texture+' 0 0 0 1.0 1.0');
  98.         {begin work on side 5}
  99.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].y)+' '+i2s(brush[b].z)+' ) ');
  100.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].y)+' '+i2s(brush[b].zl)+' ) ');
  101.             write(f,'( '+i2s(brush[b].xl)+' '+i2s(brush[b].y)+' '+i2s(brush[b].zl)+' ) ');
  102.             writeln(f,brush[b].texture+' 0 0 0 1.0 1.0');
  103.         {begin work on side 6}
  104.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].yl)+' '+i2s(brush[b].zl)+' ) ');
  105.             write(f,'( '+i2s(brush[b].x)+' '+i2s(brush[b].yl)+' '+i2s(brush[b].z)+' ) ');
  106.             write(f,'( '+i2s(brush[b].xl)+' '+i2s(brush[b].yl)+' '+i2s(brush[b].z)+' ) ');
  107.             writeln(f,brush[b].texture+' 0 0 0 1.0 1.0');
  108.         writeln(f,'}');
  109.     end;
  110.     writeln(f,'}');
  111.     for b:=0 to numentities-1 do begin
  112.         writeln(f,'{');
  113.         writeln(f,'"classname" '+entity[b].class);
  114.         writeln(f,'"origin" "'+i2s(entity[b].ox)+' '+i2s(entity[b].oy)+' '+i2s(entity[b].oz)+'"');
  115.         writeln(f,'"angle" "'+i2s(entity[b].angle)+'"');
  116.         writeln(f,'}');
  117.     end;
  118.  
  119.     close(f);
  120.  
  121. end;
  122.  
  123.  
  124.  
  125.  
  126. begin
  127.     load;
  128.     savemap;
  129. end.
  130.