]> git.localhorst.tv Git - l2e.git/blobdiff - src/main.cpp
removed some leftover lines from linker branch
[l2e.git] / src / main.cpp
index e6e8b0897ca2394f334e9400a9fc18720013bfbc..8f19f435bfa25c3335222094c0ff01342d5066d4 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "app/Application.h"
+#include "app/Arguments.h"
 #include "app/Input.h"
 #include "battle/BattleState.h"
 #include "battle/Hero.h"
 #include "sdl/InitSDL.h"
 
 #include <cstdlib>
+#include <cstring>
 #include <ctime>
 #include <exception>
 #include <iostream>
+#include <string>
 #include <SDL.h>
 #include <SDL_image.h>
 
 using app::Application;
+using app::Arguments;
 using app::Input;
 using battle::BattleState;
 using battle::Hero;
@@ -71,6 +75,8 @@ using std::cerr;
 using std::cout;
 using std::endl;
 using std::exception;
+using std::string;
+using std::vector;
 
 int main(int argc, char **argv) {
        const int width = 800;
@@ -100,12 +106,39 @@ int main(int argc, char **argv) {
                Stats::CreateTypeDescription();
                common::TargetingMode::CreateTypeDescription();
 
+               Arguments args;
+               args.Read(argc, argv);
+
                ParsedSource source;
-               Parser("test-data/test.l2s", source).Parse();
-               Parser("test-data/ikaris.l2s", source).Parse();
-               Parser("test-data/items.l2s", source).Parse();
-               Parser("test-data/spells.l2s", source).Parse();
-               Parser("test-data/constants.l2s", source).Parse();
+
+               for (vector<char *>::const_iterator i(args.Infiles().begin()), end(args.Infiles().end()); i != end; ++i) {
+                       Parser(*i, source).Parse();
+               }
+
+               switch (args.DetectRunLevel()) {
+                       case Arguments::WRITE:
+                       {
+                               int length(std::strlen(args.OutfilePath()));
+                               switch (args.OutfilePath()[length - 1]) {
+                                       case 'h': {
+                                               std::ofstream outstream(args.OutfilePath());
+                                               source.WriteHeader(outstream);
+                                               break;
+                                       }
+                                       default: {
+                                               throw std::runtime_error(string("don't know how to write file ") + args.OutfilePath());
+                                       }
+                               }
+                               return 0;
+                       }
+                       case Arguments::DUMP: {
+                               std::cout << source << std::endl;
+                               return 0;
+                       }
+                       case Arguments::PLAY:
+                               break;
+               }
+
                Interpreter intp(source);
                intp.ReadSource();