home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / doom_i / program / dmreject.exe / SOURCE.ZIP / MAIN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-01  |  2.6 KB  |  84 lines

  1. //**********************************************************************************
  2. //    REJECT.EXE - Reject data table builder for DOOM
  3. //    Copyright (C) 1994 L.M.WITEK 
  4. //
  5. //    This program is free software; you can redistribute it and/or modify
  6. //    it under the terms of the GNU General Public License as published by
  7. //    the Free Software Foundation; either version 1, or (at your option)
  8. //    any later version.
  9. //
  10. //    This program is distributed in the hope that it will be useful,
  11. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. //    GNU General Public License for more details.
  14. //
  15. //    You should have received a copy of the GNU General Public License
  16. //    along with this program; if not, write to the Free Software
  17. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. //**********************************************************************************
  19.  
  20. #include <iostream.h>
  21. #include <new.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <fstream.h>
  25.  
  26. #include "pwad.hpp"
  27. #include "reject.hpp"
  28.  
  29. extern char* version_info;
  30.  
  31. int NoMemory (size_t x)
  32. {
  33.      cerr << "\n Out Of Memory" << endl;
  34.      exit(1);
  35.      return (0);
  36. }
  37.  
  38. void main (int argc, char** argv)
  39. {
  40.      _set_new_handler (NoMemory);
  41.  
  42.      cerr << version_info << endl;
  43.      if (argc > 3)
  44.      {
  45.           // -=- Read in PWAD directory -=- 
  46.           CPWad wad (XString(argv[1]) + ".WAD");
  47.  
  48.           // -=- All OK ? -=-
  49.           if (!wad.Valid ())
  50.           {
  51.                cerr << "Failed Reading PWAD " << argv[1] << endl;
  52.                exit (0);
  53.           }
  54.  
  55.           XString map (argv[2]);
  56.           int threshold = atoi (argv[3]);
  57.  
  58.           if ((threshold >= 32) && (threshold <= 4096))
  59.           {
  60.                CReject rej (wad, map);
  61.                if (rej.Valid ())
  62.                {
  63.                     rej.RejectAll ();
  64.                     cout << "Calculating Reject table...." << flush;
  65.                     rej.RejectDefault (threshold);
  66.                     cout << "Done." << endl;
  67.           
  68.                     cout << "Writing Reject table...." << flush;
  69.                     wad.Write (rej.GetRejectData(), map, "REJECT");
  70.                     cout << "Done." << endl;
  71.                }
  72.           }
  73.           else
  74.           {
  75.                cerr << "Treshold must be between 32 and 4096" << endl;
  76.           }
  77.      }
  78.      else
  79.      {
  80.           cerr << "USAGE: REJECT <WADNAME> <MAPNAME> <THRESHOLD>" << endl;
  81.           cerr << "   eg: reject mywad e1m1 600" << endl;
  82.      }
  83. }
  84.