X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=8f19f435bfa25c3335222094c0ff01342d5066d4;hb=f6f1391a8af068bda8821310fceb762da8c12d67;hp=e6e8b0897ca2394f334e9400a9fc18720013bfbc;hpb=2cbddc6f84967a982c1651b15f924c3c8dd023a7;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index e6e8b08..8f19f43 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,7 @@ */ #include "app/Application.h" +#include "app/Arguments.h" #include "app/Input.h" #include "battle/BattleState.h" #include "battle/Hero.h" @@ -34,13 +35,16 @@ #include "sdl/InitSDL.h" #include +#include #include #include #include +#include #include #include 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::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();