X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=8f19f435bfa25c3335222094c0ff01342d5066d4;hb=f6f1391a8af068bda8821310fceb762da8c12d67;hp=2ac04233370a496f7cf469ceb5963a9f33578a25;hpb=d04fc494f1a140c20941d0d871f2b6a074068b44;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index 2ac0423..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" @@ -25,7 +26,6 @@ #include "graphics/Menu.h" #include "graphics/SimpleAnimation.h" #include "graphics/Sprite.h" -#include "loader/Compiler.h" #include "loader/Interpreter.h" #include "loader/ParsedSource.h" #include "loader/Parser.h" @@ -35,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; @@ -60,7 +63,6 @@ using graphics::Gauge; using graphics::Menu; using graphics::SimpleAnimation; using graphics::Sprite; -using loader::Compiler; using loader::Interpreter; using loader::ParsedSource; using loader::Parser; @@ -73,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; @@ -102,19 +106,42 @@ 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(); -// std::ofstream testOut("test-data/test.l2o"); -// Compiler(intp).Write(testOut); -// return 0; - int battleResId(TypeDescription::GetTypeId("BattleResources")); int heroId(TypeDescription::GetTypeId("Hero")); int itemId(TypeDescription::GetTypeId("Item"));