From 6800761863dd45b6055768febc6ace6a20120dc7 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sun, 19 Oct 2014 22:22:08 -0700 Subject: New ast module for for npc parsing Will eventually put most/all parsers there. --- src/ast/npc.hpp | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 src/ast/npc.hpp (limited to 'src/ast/npc.hpp') diff --git a/src/ast/npc.hpp b/src/ast/npc.hpp new file mode 100644 index 0000000..e39a704 --- /dev/null +++ b/src/ast/npc.hpp @@ -0,0 +1,135 @@ +#pragma once +// ast/npc.hpp - Structure of non-player characters (including mobs). +// +// Copyright © 2014 Ben Longbons +// +// This file is part of The Mana World (Athena server) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "fwd.hpp" + +#include "../compat/result.hpp" + +#include "../mmo/ids.hpp" +#include "../mmo/strs.hpp" + +#include "../map/map.hpp" + +#include "script.hpp" + + +namespace tmwa +{ +namespace npc +{ +namespace parse +{ + using io::Spanned; + + struct TopLevel + { + io::LineSpan span; + + virtual ~TopLevel(); + }; + struct Comment : TopLevel + { + RString comment; + }; + struct Warp : TopLevel + { + Spanned m; + Spanned x, y; + io::LineSpan key_span; + Spanned name; + Spanned xs, ys; + Spanned to_m; + Spanned to_x, to_y; + }; + struct ShopItem + { + Spanned name; + Spanned value; + }; + struct Shop : TopLevel + { + Spanned m; + Spanned x, y; + Spanned d; + io::LineSpan key_span; + Spanned name; + Spanned npc_class; + Spanned>> items; + }; + struct Monster : TopLevel + { + Spanned m; + Spanned x, y; + Spanned xs, ys; + io::LineSpan key_span; + Spanned name; + Spanned mob_class; + Spanned num; + Spanned delay1, delay2; + Spanned event; + }; + struct MapFlag : TopLevel + { + Spanned m; + io::LineSpan key_span; + // TODO should this extract all the way? + Spanned name; + Spanned opt_extra; + }; + struct Script : TopLevel + { + io::LineSpan key_span; + // see src/script/parser.hpp + script::parse::ScriptBody body; + }; + struct ScriptFunction : Script + { + io::LineSpan key1_span; + Spanned name; + }; + struct ScriptNone : Script + { + io::LineSpan key1_span; + Spanned name; + io::LineSpan key4_span; + }; + struct ScriptMapNone : Script + { + Spanned m; + Spanned x, y; + Spanned d; + Spanned name; + io::LineSpan key4_span; + }; + struct ScriptMap : Script + { + Spanned m; + Spanned x, y; + Spanned d; + Spanned name; + Spanned npc_class; + Spanned xs, ys; + }; + // other Script subclasses elsewhere? (for item and magic scripts) + + Result> parse_top(io::LineCharReader& in); +} // namespace parse +} // namespace npc +} // namespace tmwa -- cgit v1.2.3-60-g2f50