Guest User

blud2e/io.coo

a guest
Oct 11th, 2014
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. int  Map::write(char *filename) {
  2.  
  3.     int hd1[4];short hd2[2];
  4.     hd1[0]=9; hd1[1]=posX; hd1[2]=posY; hd1[3]=posZ;
  5.     hd2[0]=angle; hd2[1]=secNum;
  6.     unsigned short sz=(unsigned short)s.size();
  7.  
  8.     std::ofstream out(filename, std::ofstream::binary);
  9.     out.write(reinterpret_cast<char*>(hd1), sizeof(hd1));
  10.     out.write(reinterpret_cast<char*>(hd2), sizeof(hd2));
  11.     // sectors
  12.     out.write((char*)(&sz), sizeof(sz));
  13.     for ( auto T: s)
  14.     {
  15.         T.extra=-1;
  16.         out.write((char*)(&T), size_sector);
  17.     };
  18.     // walls
  19.     sz=(unsigned short)w.size();
  20.     out.write((char*)(&sz), sizeof(sz));
  21.     for ( auto T: w)
  22.     {
  23.         T.extra=-1;
  24.         out.write((char*)(&T), size_wall);
  25.     };
  26.     // sprites
  27.     sz=(unsigned short)sp.size();
  28.     out.write((char*)(&sz), sizeof(sz));
  29.     for ( auto T: sp)
  30.     {
  31.         T.extra=-1;
  32.         out.write((char*)(&T), size_sprite);
  33.     };
  34.  
  35.     out.close();
  36.  
  37.     return 0;
  38. };
Advertisement
Add Comment
Please, Sign In to add comment