wasplib: add inv management helpers
[waspsaliva.git] / src / nodedef.h
blob66c21cc0711b43d3e4299322e3afb763814668ee
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include "irrlichttypes_bloated.h"
23 #include <string>
24 #include <iostream>
25 #include <map>
26 #include "mapnode.h"
27 #include "nameidmapping.h"
28 #ifndef SERVER
29 #include "client/tile.h"
30 #include <IMeshManipulator.h>
31 class Client;
32 #endif
33 #include "itemgroup.h"
34 #include "sound.h" // SimpleSoundSpec
35 #include "constants.h" // BS
36 #include "texture_override.h" // TextureOverride
37 #include "tileanimation.h"
39 // PROTOCOL_VERSION >= 37
40 static const u8 CONTENTFEATURES_VERSION = 13;
42 class IItemDefManager;
43 class ITextureSource;
44 class IShaderSource;
45 class IGameDef;
46 class NodeResolver;
48 enum ContentParamType
50 CPT_NONE,
51 CPT_LIGHT,
54 enum ContentParamType2
56 CPT2_NONE,
57 // Need 8-bit param2
58 CPT2_FULL,
59 // Flowing liquid properties
60 CPT2_FLOWINGLIQUID,
61 // Direction for chests and furnaces and such
62 CPT2_FACEDIR,
63 // Direction for signs, torches and such
64 CPT2_WALLMOUNTED,
65 // Block level like FLOWINGLIQUID
66 CPT2_LEVELED,
67 // 2D rotation for things like plants
68 CPT2_DEGROTATE,
69 // Mesh options for plants
70 CPT2_MESHOPTIONS,
71 // Index for palette
72 CPT2_COLOR,
73 // 3 bits of palette index, then facedir
74 CPT2_COLORED_FACEDIR,
75 // 5 bits of palette index, then wallmounted
76 CPT2_COLORED_WALLMOUNTED,
77 // Glasslike framed drawtype internal liquid level, param2 values 0 to 63
78 CPT2_GLASSLIKE_LIQUID_LEVEL,
81 enum LiquidType
83 LIQUID_NONE,
84 LIQUID_FLOWING,
85 LIQUID_SOURCE,
88 enum NodeBoxType
90 NODEBOX_REGULAR, // Regular block; allows buildable_to
91 NODEBOX_FIXED, // Static separately defined box(es)
92 NODEBOX_WALLMOUNTED, // Box for wall mounted nodes; (top, bottom, side)
93 NODEBOX_LEVELED, // Same as fixed, but with dynamic height from param2. for snow, ...
94 NODEBOX_CONNECTED, // optionally draws nodeboxes if a neighbor node attaches
97 struct NodeBox
99 enum NodeBoxType type;
100 // NODEBOX_REGULAR (no parameters)
101 // NODEBOX_FIXED
102 std::vector<aabb3f> fixed;
103 // NODEBOX_WALLMOUNTED
104 aabb3f wall_top;
105 aabb3f wall_bottom;
106 aabb3f wall_side; // being at the -X side
107 // NODEBOX_CONNECTED
108 std::vector<aabb3f> connect_top;
109 std::vector<aabb3f> connect_bottom;
110 std::vector<aabb3f> connect_front;
111 std::vector<aabb3f> connect_left;
112 std::vector<aabb3f> connect_back;
113 std::vector<aabb3f> connect_right;
114 std::vector<aabb3f> disconnected_top;
115 std::vector<aabb3f> disconnected_bottom;
116 std::vector<aabb3f> disconnected_front;
117 std::vector<aabb3f> disconnected_left;
118 std::vector<aabb3f> disconnected_back;
119 std::vector<aabb3f> disconnected_right;
120 std::vector<aabb3f> disconnected;
121 std::vector<aabb3f> disconnected_sides;
123 NodeBox()
124 { reset(); }
126 void reset();
127 void serialize(std::ostream &os, u16 protocol_version) const;
128 void deSerialize(std::istream &is);
131 struct MapNode;
132 class NodeMetadata;
134 enum LeavesStyle {
135 LEAVES_FANCY,
136 LEAVES_SIMPLE,
137 LEAVES_OPAQUE,
140 enum AutoScale : u8 {
141 AUTOSCALE_DISABLE,
142 AUTOSCALE_ENABLE,
143 AUTOSCALE_FORCE,
146 enum WorldAlignMode : u8 {
147 WORLDALIGN_DISABLE,
148 WORLDALIGN_ENABLE,
149 WORLDALIGN_FORCE,
150 WORLDALIGN_FORCE_NODEBOX,
153 class TextureSettings {
154 public:
155 LeavesStyle leaves_style;
156 WorldAlignMode world_aligned_mode;
157 AutoScale autoscale_mode;
158 int node_texture_size;
159 bool opaque_water;
160 bool connected_glass;
161 bool enable_mesh_cache;
162 bool enable_minimap;
164 TextureSettings() = default;
166 void readSettings();
169 enum NodeDrawType
171 // A basic solid block
172 NDT_NORMAL,
173 // Nothing is drawn
174 NDT_AIRLIKE,
175 // Do not draw face towards same kind of flowing/source liquid
176 NDT_LIQUID,
177 // A very special kind of thing
178 NDT_FLOWINGLIQUID,
179 // Glass-like, don't draw faces towards other glass
180 NDT_GLASSLIKE,
181 // Leaves-like, draw all faces no matter what
182 NDT_ALLFACES,
183 // Enabled -> ndt_allfaces, disabled -> ndt_normal
184 NDT_ALLFACES_OPTIONAL,
185 // Single plane perpendicular to a surface
186 NDT_TORCHLIKE,
187 // Single plane parallel to a surface
188 NDT_SIGNLIKE,
189 // 2 vertical planes in a 'X' shape diagonal to XZ axes.
190 // paramtype2 = "meshoptions" allows various forms, sizes and
191 // vertical and horizontal random offsets.
192 NDT_PLANTLIKE,
193 // Fenceposts that connect to neighbouring fenceposts with horizontal bars
194 NDT_FENCELIKE,
195 // Selects appropriate junction texture to connect like rails to
196 // neighbouring raillikes.
197 NDT_RAILLIKE,
198 // Custom Lua-definable structure of multiple cuboids
199 NDT_NODEBOX,
200 // Glass-like, draw connected frames and all visible faces.
201 // param2 > 0 defines 64 levels of internal liquid
202 // Uses 3 textures, one for frames, second for faces,
203 // optional third is a 'special tile' for the liquid.
204 NDT_GLASSLIKE_FRAMED,
205 // Draw faces slightly rotated and only on neighbouring nodes
206 NDT_FIRELIKE,
207 // Enabled -> ndt_glasslike_framed, disabled -> ndt_glasslike
208 NDT_GLASSLIKE_FRAMED_OPTIONAL,
209 // Uses static meshes
210 NDT_MESH,
211 // Combined plantlike-on-solid
212 NDT_PLANTLIKE_ROOTED,
215 // Mesh options for NDT_PLANTLIKE with CPT2_MESHOPTIONS
216 static const u8 MO_MASK_STYLE = 0x07;
217 static const u8 MO_BIT_RANDOM_OFFSET = 0x08;
218 static const u8 MO_BIT_SCALE_SQRT2 = 0x10;
219 static const u8 MO_BIT_RANDOM_OFFSET_Y = 0x20;
220 enum PlantlikeStyle {
221 PLANT_STYLE_CROSS,
222 PLANT_STYLE_CROSS2,
223 PLANT_STYLE_STAR,
224 PLANT_STYLE_HASH,
225 PLANT_STYLE_HASH2,
228 enum AlignStyle : u8 {
229 ALIGN_STYLE_NODE,
230 ALIGN_STYLE_WORLD,
231 ALIGN_STYLE_USER_DEFINED,
235 Stand-alone definition of a TileSpec (basically a server-side TileSpec)
238 struct TileDef
240 std::string name = "";
241 bool backface_culling = true; // Takes effect only in special cases
242 bool tileable_horizontal = true;
243 bool tileable_vertical = true;
244 //! If true, the tile has its own color.
245 bool has_color = false;
246 //! The color of the tile.
247 video::SColor color = video::SColor(0xFFFFFFFF);
248 AlignStyle align_style = ALIGN_STYLE_NODE;
249 u8 scale = 0;
251 struct TileAnimationParams animation;
253 TileDef()
255 animation.type = TAT_NONE;
258 void serialize(std::ostream &os, u16 protocol_version) const;
259 void deSerialize(std::istream &is, u8 contentfeatures_version,
260 NodeDrawType drawtype);
263 // Defines the number of special tiles per nodedef
265 // NOTE: When changing this value, the enum entries of OverrideTarget and
266 // parser in TextureOverrideSource must be updated so that all special
267 // tiles can be overridden.
268 #define CF_SPECIAL_COUNT 6
270 struct ContentFeatures
273 Cached stuff
275 #ifndef SERVER
276 // 0 1 2 3 4 5
277 // up down right left back front
278 TileSpec tiles[6];
279 // Special tiles
280 // - Currently used for flowing liquids
281 TileSpec special_tiles[CF_SPECIAL_COUNT];
282 u8 solidness; // Used when choosing which face is drawn
283 u8 visual_solidness; // When solidness=0, this tells how it looks like
284 bool backface_culling;
285 #endif
287 // Server-side cached callback existence for fast skipping
288 bool has_on_construct;
289 bool has_on_destruct;
290 bool has_after_destruct;
293 Actual data
296 // --- GENERAL PROPERTIES ---
298 std::string name; // "" = undefined node
299 ItemGroupList groups; // Same as in itemdef
300 // Type of MapNode::param1
301 ContentParamType param_type;
302 // Type of MapNode::param2
303 ContentParamType2 param_type_2;
305 // --- VISUAL PROPERTIES ---
307 enum NodeDrawType drawtype;
308 std::string mesh;
309 #ifndef SERVER
310 scene::IMesh *mesh_ptr[24];
311 video::SColor minimap_color;
312 #endif
313 float visual_scale; // Misc. scale parameter
314 TileDef tiledef[6];
315 // These will be drawn over the base tiles.
316 TileDef tiledef_overlay[6];
317 TileDef tiledef_special[CF_SPECIAL_COUNT]; // eg. flowing liquid
318 // If 255, the node is opaque.
319 // Otherwise it uses texture alpha.
320 u8 alpha;
321 // The color of the node.
322 video::SColor color;
323 std::string palette_name;
324 std::vector<video::SColor> *palette;
325 // Used for waving leaves/plants
326 u8 waving;
327 // for NDT_CONNECTED pairing
328 u8 connect_sides;
329 std::vector<std::string> connects_to;
330 std::vector<content_t> connects_to_ids;
331 // Post effect color, drawn when the camera is inside the node.
332 video::SColor post_effect_color;
333 // Flowing liquid or leveled nodebox, value = default level
334 u8 leveled;
335 // Maximum value for leveled nodes
336 u8 leveled_max;
338 // --- LIGHTING-RELATED ---
340 bool light_propagates;
341 bool sunlight_propagates;
342 // Amount of light the node emits
343 u8 light_source;
345 // --- MAP GENERATION ---
347 // True for all ground-like things like stone and mud, false for eg. trees
348 bool is_ground_content;
350 // --- INTERACTION PROPERTIES ---
352 // This is used for collision detection.
353 // Also for general solidness queries.
354 bool walkable;
355 // Player can point to these
356 bool pointable;
357 // Player can dig these
358 bool diggable;
359 // Player can climb these
360 bool climbable;
361 // Player can build on these
362 bool buildable_to;
363 // Player cannot build to these (placement prediction disabled)
364 bool rightclickable;
365 u32 damage_per_second;
366 // client dig prediction
367 std::string node_dig_prediction;
369 // --- LIQUID PROPERTIES ---
371 // Whether the node is non-liquid, source liquid or flowing liquid
372 enum LiquidType liquid_type;
373 // If the content is liquid, this is the flowing version of the liquid.
374 std::string liquid_alternative_flowing;
375 content_t liquid_alternative_flowing_id;
376 // If the content is liquid, this is the source version of the liquid.
377 std::string liquid_alternative_source;
378 content_t liquid_alternative_source_id;
379 // Viscosity for fluid flow, ranging from 1 to 7, with
380 // 1 giving almost instantaneous propagation and 7 being
381 // the slowest possible
382 u8 liquid_viscosity;
383 // Is liquid renewable (new liquid source will be created between 2 existing)
384 bool liquid_renewable;
385 // Number of flowing liquids surrounding source
386 u8 liquid_range;
387 u8 drowning;
388 // Liquids flow into and replace node
389 bool floodable;
391 // --- NODEBOXES ---
393 NodeBox node_box;
394 NodeBox selection_box;
395 NodeBox collision_box;
397 // --- SOUND PROPERTIES ---
399 SimpleSoundSpec sound_footstep;
400 SimpleSoundSpec sound_dig;
401 SimpleSoundSpec sound_dug;
403 // --- LEGACY ---
405 // Compatibility with old maps
406 // Set to true if paramtype used to be 'facedir_simple'
407 bool legacy_facedir_simple;
408 // Set to true if wall_mounted used to be set to true
409 bool legacy_wallmounted;
412 Methods
415 ContentFeatures();
416 ~ContentFeatures();
417 void reset();
418 void serialize(std::ostream &os, u16 protocol_version) const;
419 void deSerialize(std::istream &is);
422 * Since vertex alpha is no longer supported, this method
423 * adds opacity directly to the texture pixels.
425 * \param tiles array of the tile definitions.
426 * \param length length of tiles
428 void correctAlpha(TileDef *tiles, int length);
430 #ifndef SERVER
432 * Checks if any tile texture has any transparent pixels.
433 * Prints a warning and returns true if that is the case, false otherwise.
434 * This is supposed to be used for use_texture_alpha backwards compatibility.
436 bool textureAlphaCheck(ITextureSource *tsrc, const TileDef *tiles,
437 int length);
438 #endif
442 Some handy methods
444 bool needsBackfaceCulling() const
446 switch (drawtype) {
447 case NDT_TORCHLIKE:
448 case NDT_SIGNLIKE:
449 case NDT_FIRELIKE:
450 case NDT_RAILLIKE:
451 case NDT_PLANTLIKE:
452 case NDT_PLANTLIKE_ROOTED:
453 case NDT_MESH:
454 return false;
455 default:
456 return true;
460 bool isLiquid() const{
461 return (liquid_type != LIQUID_NONE);
463 bool sameLiquid(const ContentFeatures &f) const{
464 if(!isLiquid() || !f.isLiquid()) return false;
465 return (liquid_alternative_flowing_id == f.liquid_alternative_flowing_id);
468 int getGroup(const std::string &group) const
470 return itemgroup_get(groups, group);
473 #ifndef SERVER
474 void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
475 scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
476 #endif
480 * @brief This class is for getting the actual properties of nodes from their
481 * content ID.
483 * @details The nodes on the map are represented by three numbers (see MapNode).
484 * The first number (param0) is the type of a node. All node types have own
485 * properties (see ContentFeatures). This class is for storing and getting the
486 * properties of nodes.
487 * The manager is first filled with registered nodes, then as the game begins,
488 * functions only get `const` pointers to it, to prevent modification of
489 * registered nodes.
491 class NodeDefManager {
492 public:
494 * Creates a NodeDefManager, and registers three ContentFeatures:
495 * \ref CONTENT_AIR, \ref CONTENT_UNKNOWN and \ref CONTENT_IGNORE.
497 NodeDefManager();
498 ~NodeDefManager();
501 * Returns the properties for the given content type.
502 * @param c content type of a node
503 * @return properties of the given content type, or \ref CONTENT_UNKNOWN
504 * if the given content type is not registered.
506 inline const ContentFeatures& get(content_t c) const {
507 return
508 c < m_content_features.size() ?
509 m_content_features[c] : m_content_features[CONTENT_UNKNOWN];
513 * Returns the properties of the given node.
514 * @param n a map node
515 * @return properties of the given node or @ref CONTENT_UNKNOWN if the
516 * given content type is not registered.
518 inline const ContentFeatures& get(const MapNode &n) const {
519 return get(n.getContent());
523 * Returns the node properties for a node name.
524 * @param name name of a node
525 * @return properties of the given node or @ref CONTENT_UNKNOWN if
526 * not found
528 const ContentFeatures& get(const std::string &name) const;
531 * Returns the content ID for the given name.
532 * @param name a node name
533 * @param[out] result will contain the content ID if found, otherwise
534 * remains unchanged
535 * @return true if the ID was found, false otherwise
537 bool getId(const std::string &name, content_t &result) const;
540 * Returns the content ID for the given name.
541 * @param name a node name
542 * @return ID of the node or @ref CONTENT_IGNORE if not found
544 content_t getId(const std::string &name) const;
547 * Returns the content IDs of the given node name or node group name.
548 * Group names start with "group:".
549 * @param name a node name or node group name
550 * @param[out] result will be appended with matching IDs
551 * @return true if `name` is a valid node name or a (not necessarily
552 * valid) group name
554 bool getIds(const std::string &name, std::vector<content_t> &result) const;
557 * Returns the smallest box in integer node coordinates that
558 * contains all nodes' selection boxes. The returned box might be larger
559 * than the minimal size if the largest node is removed from the manager.
561 inline core::aabbox3d<s16> getSelectionBoxIntUnion() const {
562 return m_selection_box_int_union;
566 * Checks whether a node connects to an adjacent node.
567 * @param from the node to be checked
568 * @param to the adjacent node
569 * @param connect_face a bit field indicating which face of the node is
570 * adjacent to the other node.
571 * Bits: +y (least significant), -y, -z, -x, +z, +x (most significant).
572 * @return true if the node connects, false otherwise
574 bool nodeboxConnects(MapNode from, MapNode to,
575 u8 connect_face) const;
578 * Registers a NodeResolver to wait for the registration of
579 * ContentFeatures. Once the node registration finishes, all
580 * listeners are notified.
582 void pendNodeResolve(NodeResolver *nr) const;
585 * Stops listening to the NodeDefManager.
586 * @return true if the listener was registered before, false otherwise
588 bool cancelNodeResolveCallback(NodeResolver *nr) const;
591 * Registers a new node type with the given name and allocates a new
592 * content ID.
593 * Should not be called with an already existing name.
594 * @param name name of the node, must match with `def.name`.
595 * @param def definition of the registered node type.
596 * @return ID of the registered node or @ref CONTENT_IGNORE if
597 * the function could not allocate an ID.
599 content_t set(const std::string &name, const ContentFeatures &def);
602 * Allocates a blank node ID for the given name.
603 * @param name name of a node
604 * @return allocated ID or @ref CONTENT_IGNORE if could not allocate
605 * an ID.
607 content_t allocateDummy(const std::string &name);
610 * Removes the given node name from the manager.
611 * The node ID will remain in the manager, but won't be linked to any name.
612 * @param name name to be removed
614 void removeNode(const std::string &name);
617 * Regenerates the alias list (a map from names to node IDs).
618 * @param idef the item definition manager containing alias information
620 void updateAliases(IItemDefManager *idef);
623 * Replaces the textures of registered nodes with the ones specified in
624 * the texturepack's override.txt file
626 * @param overrides the texture overrides
628 void applyTextureOverrides(const std::vector<TextureOverride> &overrides);
631 * Only the client uses this. Loads textures and shaders required for
632 * rendering the nodes.
633 * @param gamedef must be a Client.
634 * @param progress_cbk called each time a node is loaded. Arguments:
635 * `progress_cbk_args`, number of loaded ContentFeatures, number of
636 * total ContentFeatures.
637 * @param progress_cbk_args passed to the callback function
639 void updateTextures(IGameDef *gamedef,
640 void (*progress_cbk)(void *progress_args, u32 progress, u32 max_progress),
641 void *progress_cbk_args);
644 * Writes the content of this manager to the given output stream.
645 * @param protocol_version serialization version of ContentFeatures
647 void serialize(std::ostream &os, u16 protocol_version) const;
650 * Restores the manager from a serialized stream.
651 * This clears the previous state.
652 * @param is input stream containing a serialized NodeDefManager
654 void deSerialize(std::istream &is);
657 * Used to indicate that node registration has finished.
658 * @param completed tells whether registration is complete
660 inline void setNodeRegistrationStatus(bool completed) {
661 m_node_registration_complete = completed;
665 * Notifies the registered NodeResolver instances that node registration
666 * has finished, then unregisters all listeners.
667 * Must be called after node registration has finished!
669 void runNodeResolveCallbacks();
672 * Sets the registration completion flag to false and unregisters all
673 * NodeResolver instances listening to the manager.
675 void resetNodeResolveState();
678 * Resolves (caches the IDs) cross-references between nodes,
679 * like liquid alternatives.
680 * Must be called after node registration has finished!
682 void resolveCrossrefs();
684 private:
686 * Resets the manager to its initial state.
687 * See the documentation of the constructor.
689 void clear();
692 * Allocates a new content ID, and returns it.
693 * @return the allocated ID or \ref CONTENT_IGNORE if could not allocate
695 content_t allocateId();
698 * Binds the given content ID and node name.
699 * Registers them in \ref m_name_id_mapping and
700 * \ref m_name_id_mapping_with_aliases.
701 * @param i a content ID
702 * @param name a node name
704 void addNameIdMapping(content_t i, std::string name);
707 * Removes a content ID from all groups.
708 * Erases content IDs from vectors in \ref m_group_to_items and
709 * removes empty vectors.
710 * @param id Content ID
712 void eraseIdFromGroups(content_t id);
715 * Recalculates m_selection_box_int_union based on
716 * m_selection_box_union.
718 void fixSelectionBoxIntUnion();
720 //! Features indexed by ID.
721 std::vector<ContentFeatures> m_content_features;
723 //! A mapping for fast conversion between names and IDs
724 NameIdMapping m_name_id_mapping;
727 * Like @ref m_name_id_mapping, but maps only from names to IDs, and
728 * includes aliases too. Updated by \ref updateAliases().
729 * Note: Not serialized.
731 std::unordered_map<std::string, content_t> m_name_id_mapping_with_aliases;
734 * A mapping from group names to a vector of content types that belong
735 * to it. Necessary for a direct lookup in \ref getIds().
736 * Note: Not serialized.
738 std::unordered_map<std::string, std::vector<content_t>> m_group_to_items;
741 * The next ID that might be free to allocate.
742 * It can be allocated already, because \ref CONTENT_AIR,
743 * \ref CONTENT_UNKNOWN and \ref CONTENT_IGNORE are registered when the
744 * manager is initialized, and new IDs are allocated from 0.
746 content_t m_next_id;
748 //! True if all nodes have been registered.
749 bool m_node_registration_complete;
752 * The union of all nodes' selection boxes.
753 * Might be larger if big nodes are removed from the manager.
755 aabb3f m_selection_box_union;
758 * The smallest box in integer node coordinates that
759 * contains all nodes' selection boxes.
760 * Might be larger if big nodes are removed from the manager.
762 core::aabbox3d<s16> m_selection_box_int_union;
765 * NodeResolver instances to notify once node registration has finished.
766 * Even constant NodeDefManager instances can register listeners.
768 mutable std::vector<NodeResolver *> m_pending_resolve_callbacks;
771 NodeDefManager *createNodeDefManager();
773 class NodeResolver {
774 public:
775 NodeResolver();
776 virtual ~NodeResolver();
777 virtual void resolveNodeNames() = 0;
779 // required because this class is used as mixin for ObjDef
780 void cloneTo(NodeResolver *res) const;
782 bool getIdFromNrBacklog(content_t *result_out,
783 const std::string &node_alt, content_t c_fallback,
784 bool error_on_fallback = true);
785 bool getIdsFromNrBacklog(std::vector<content_t> *result_out,
786 bool all_required = false, content_t c_fallback = CONTENT_IGNORE);
788 void nodeResolveInternal();
790 u32 m_nodenames_idx = 0;
791 u32 m_nnlistsizes_idx = 0;
792 std::vector<std::string> m_nodenames;
793 std::vector<size_t> m_nnlistsizes;
794 const NodeDefManager *m_ndef = nullptr;
795 bool m_resolve_done = false;