remove_detached_inventory: Fix segfault during mod load
[oweals/minetest.git] / src / nodedef.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #pragma once
21
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 "tileanimation.h"
37
38 // PROTOCOL_VERSION >= 37
39 static const u8 CONTENTFEATURES_VERSION = 13;
40
41 class IItemDefManager;
42 class ITextureSource;
43 class IShaderSource;
44 class IGameDef;
45 class NodeResolver;
46
47 enum ContentParamType
48 {
49         CPT_NONE,
50         CPT_LIGHT,
51 };
52
53 enum ContentParamType2
54 {
55         CPT2_NONE,
56         // Need 8-bit param2
57         CPT2_FULL,
58         // Flowing liquid properties
59         CPT2_FLOWINGLIQUID,
60         // Direction for chests and furnaces and such
61         CPT2_FACEDIR,
62         // Direction for signs, torches and such
63         CPT2_WALLMOUNTED,
64         // Block level like FLOWINGLIQUID
65         CPT2_LEVELED,
66         // 2D rotation for things like plants
67         CPT2_DEGROTATE,
68         // Mesh options for plants
69         CPT2_MESHOPTIONS,
70         // Index for palette
71         CPT2_COLOR,
72         // 3 bits of palette index, then facedir
73         CPT2_COLORED_FACEDIR,
74         // 5 bits of palette index, then wallmounted
75         CPT2_COLORED_WALLMOUNTED,
76         // Glasslike framed drawtype internal liquid level, param2 values 0 to 63
77         CPT2_GLASSLIKE_LIQUID_LEVEL,
78 };
79
80 enum LiquidType
81 {
82         LIQUID_NONE,
83         LIQUID_FLOWING,
84         LIQUID_SOURCE,
85 };
86
87 enum NodeBoxType
88 {
89         NODEBOX_REGULAR, // Regular block; allows buildable_to
90         NODEBOX_FIXED, // Static separately defined box(es)
91         NODEBOX_WALLMOUNTED, // Box for wall mounted nodes; (top, bottom, side)
92         NODEBOX_LEVELED, // Same as fixed, but with dynamic height from param2. for snow, ...
93         NODEBOX_CONNECTED, // optionally draws nodeboxes if a neighbor node attaches
94 };
95
96 struct NodeBox
97 {
98         enum NodeBoxType type;
99         // NODEBOX_REGULAR (no parameters)
100         // NODEBOX_FIXED
101         std::vector<aabb3f> fixed;
102         // NODEBOX_WALLMOUNTED
103         aabb3f wall_top;
104         aabb3f wall_bottom;
105         aabb3f wall_side; // being at the -X side
106         // NODEBOX_CONNECTED
107         std::vector<aabb3f> connect_top;
108         std::vector<aabb3f> connect_bottom;
109         std::vector<aabb3f> connect_front;
110         std::vector<aabb3f> connect_left;
111         std::vector<aabb3f> connect_back;
112         std::vector<aabb3f> connect_right;
113         std::vector<aabb3f> disconnected_top;
114         std::vector<aabb3f> disconnected_bottom;
115         std::vector<aabb3f> disconnected_front;
116         std::vector<aabb3f> disconnected_left;
117         std::vector<aabb3f> disconnected_back;
118         std::vector<aabb3f> disconnected_right;
119         std::vector<aabb3f> disconnected;
120         std::vector<aabb3f> disconnected_sides;
121
122         NodeBox()
123         { reset(); }
124
125         void reset();
126         void serialize(std::ostream &os, u16 protocol_version) const;
127         void deSerialize(std::istream &is);
128 };
129
130 struct MapNode;
131 class NodeMetadata;
132
133 enum LeavesStyle {
134         LEAVES_FANCY,
135         LEAVES_SIMPLE,
136         LEAVES_OPAQUE,
137 };
138
139 enum AutoScale : u8 {
140         AUTOSCALE_DISABLE,
141         AUTOSCALE_ENABLE,
142         AUTOSCALE_FORCE,
143 };
144
145 enum WorldAlignMode : u8 {
146         WORLDALIGN_DISABLE,
147         WORLDALIGN_ENABLE,
148         WORLDALIGN_FORCE,
149         WORLDALIGN_FORCE_NODEBOX,
150 };
151
152 class TextureSettings {
153 public:
154         LeavesStyle leaves_style;
155         WorldAlignMode world_aligned_mode;
156         AutoScale autoscale_mode;
157         int node_texture_size;
158         bool opaque_water;
159         bool connected_glass;
160         bool use_normal_texture;
161         bool enable_mesh_cache;
162         bool enable_minimap;
163
164         TextureSettings() = default;
165
166         void readSettings();
167 };
168
169 enum NodeDrawType
170 {
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,
213 };
214
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,
226 };
227
228 enum AlignStyle : u8 {
229         ALIGN_STYLE_NODE,
230         ALIGN_STYLE_WORLD,
231         ALIGN_STYLE_USER_DEFINED,
232 };
233
234 /*
235         Stand-alone definition of a TileSpec (basically a server-side TileSpec)
236 */
237
238 struct TileDef
239 {
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;
250
251         struct TileAnimationParams animation;
252
253         TileDef()
254         {
255                 animation.type = TAT_NONE;
256         }
257
258         void serialize(std::ostream &os, u16 protocol_version) const;
259         void deSerialize(std::istream &is, u8 contentfeatures_version,
260                 NodeDrawType drawtype);
261 };
262
263 #define CF_SPECIAL_COUNT 6
264
265 struct ContentFeatures
266 {
267         /*
268                 Cached stuff
269          */
270 #ifndef SERVER
271         // 0     1     2     3     4     5
272         // up    down  right left  back  front
273         TileSpec tiles[6];
274         // Special tiles
275         // - Currently used for flowing liquids
276         TileSpec special_tiles[CF_SPECIAL_COUNT];
277         u8 solidness; // Used when choosing which face is drawn
278         u8 visual_solidness; // When solidness=0, this tells how it looks like
279         bool backface_culling;
280 #endif
281
282         // Server-side cached callback existence for fast skipping
283         bool has_on_construct;
284         bool has_on_destruct;
285         bool has_after_destruct;
286
287         /*
288                 Actual data
289          */
290
291         // --- GENERAL PROPERTIES ---
292
293         std::string name; // "" = undefined node
294         ItemGroupList groups; // Same as in itemdef
295         // Type of MapNode::param1
296         ContentParamType param_type;
297         // Type of MapNode::param2
298         ContentParamType2 param_type_2;
299
300         // --- VISUAL PROPERTIES ---
301
302         enum NodeDrawType drawtype;
303         std::string mesh;
304 #ifndef SERVER
305         scene::IMesh *mesh_ptr[24];
306         video::SColor minimap_color;
307 #endif
308         float visual_scale; // Misc. scale parameter
309         TileDef tiledef[6];
310         // These will be drawn over the base tiles.
311         TileDef tiledef_overlay[6];
312         TileDef tiledef_special[CF_SPECIAL_COUNT]; // eg. flowing liquid
313         // If 255, the node is opaque.
314         // Otherwise it uses texture alpha.
315         u8 alpha;
316         // The color of the node.
317         video::SColor color;
318         std::string palette_name;
319         std::vector<video::SColor> *palette;
320         // Used for waving leaves/plants
321         u8 waving;
322         // for NDT_CONNECTED pairing
323         u8 connect_sides;
324         std::vector<std::string> connects_to;
325         std::vector<content_t> connects_to_ids;
326         // Post effect color, drawn when the camera is inside the node.
327         video::SColor post_effect_color;
328         // Flowing liquid or snow, value = default level
329         u8 leveled;
330
331         // --- LIGHTING-RELATED ---
332
333         bool light_propagates;
334         bool sunlight_propagates;
335         // Amount of light the node emits
336         u8 light_source;
337
338         // --- MAP GENERATION ---
339
340         // True for all ground-like things like stone and mud, false for eg. trees
341         bool is_ground_content;
342
343         // --- INTERACTION PROPERTIES ---
344
345         // This is used for collision detection.
346         // Also for general solidness queries.
347         bool walkable;
348         // Player can point to these
349         bool pointable;
350         // Player can dig these
351         bool diggable;
352         // Player can climb these
353         bool climbable;
354         // Player can build on these
355         bool buildable_to;
356         // Player cannot build to these (placement prediction disabled)
357         bool rightclickable;
358         u32 damage_per_second;
359         // client dig prediction
360         std::string node_dig_prediction;
361
362         // --- LIQUID PROPERTIES ---
363
364         // Whether the node is non-liquid, source liquid or flowing liquid
365         enum LiquidType liquid_type;
366         // If the content is liquid, this is the flowing version of the liquid.
367         std::string liquid_alternative_flowing;
368         // If the content is liquid, this is the source version of the liquid.
369         std::string liquid_alternative_source;
370         // Viscosity for fluid flow, ranging from 1 to 7, with
371         // 1 giving almost instantaneous propagation and 7 being
372         // the slowest possible
373         u8 liquid_viscosity;
374         // Is liquid renewable (new liquid source will be created between 2 existing)
375         bool liquid_renewable;
376         // Number of flowing liquids surrounding source
377         u8 liquid_range;
378         u8 drowning;
379         // Liquids flow into and replace node
380         bool floodable;
381
382         // --- NODEBOXES ---
383
384         NodeBox node_box;
385         NodeBox selection_box;
386         NodeBox collision_box;
387
388         // --- SOUND PROPERTIES ---
389
390         SimpleSoundSpec sound_footstep;
391         SimpleSoundSpec sound_dig;
392         SimpleSoundSpec sound_dug;
393
394         // --- LEGACY ---
395
396         // Compatibility with old maps
397         // Set to true if paramtype used to be 'facedir_simple'
398         bool legacy_facedir_simple;
399         // Set to true if wall_mounted used to be set to true
400         bool legacy_wallmounted;
401
402         /*
403                 Methods
404         */
405
406         ContentFeatures();
407         ~ContentFeatures() = default;
408         void reset();
409         void serialize(std::ostream &os, u16 protocol_version) const;
410         void deSerialize(std::istream &is);
411         /*!
412          * Since vertex alpha is no longer supported, this method
413          * adds opacity directly to the texture pixels.
414          *
415          * \param tiles array of the tile definitions.
416          * \param length length of tiles
417          */
418         void correctAlpha(TileDef *tiles, int length);
419
420         /*
421                 Some handy methods
422         */
423         bool isLiquid() const{
424                 return (liquid_type != LIQUID_NONE);
425         }
426         bool sameLiquid(const ContentFeatures &f) const{
427                 if(!isLiquid() || !f.isLiquid()) return false;
428                 return (liquid_alternative_flowing == f.liquid_alternative_flowing);
429         }
430
431         int getGroup(const std::string &group) const
432         {
433                 return itemgroup_get(groups, group);
434         }
435
436 #ifndef SERVER
437         void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
438                 scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
439 #endif
440 };
441
442 /*!
443  * @brief This class is for getting the actual properties of nodes from their
444  * content ID.
445  *
446  * @details The nodes on the map are represented by three numbers (see MapNode).
447  * The first number (param0) is the type of a node. All node types have own
448  * properties (see ContentFeatures). This class is for storing and getting the
449  * properties of nodes.
450  * The manager is first filled with registered nodes, then as the game begins,
451  * functions only get `const` pointers to it, to prevent modification of
452  * registered nodes.
453  */
454 class NodeDefManager {
455 public:
456         /*!
457          * Creates a NodeDefManager, and registers three ContentFeatures:
458          * \ref CONTENT_AIR, \ref CONTENT_UNKNOWN and \ref CONTENT_IGNORE.
459          */
460         NodeDefManager();
461         ~NodeDefManager();
462
463         /*!
464          * Returns the properties for the given content type.
465          * @param c content type of a node
466          * @return properties of the given content type, or \ref CONTENT_UNKNOWN
467          * if the given content type is not registered.
468          */
469         inline const ContentFeatures& get(content_t c) const {
470                 return
471                         c < m_content_features.size() ?
472                                 m_content_features[c] : m_content_features[CONTENT_UNKNOWN];
473         }
474
475         /*!
476          * Returns the properties of the given node.
477          * @param n a map node
478          * @return properties of the given node or @ref CONTENT_UNKNOWN if the
479          * given content type is not registered.
480          */
481         inline const ContentFeatures& get(const MapNode &n) const {
482                 return get(n.getContent());
483         }
484
485         /*!
486          * Returns the node properties for a node name.
487          * @param name name of a node
488          * @return properties of the given node or @ref CONTENT_UNKNOWN if
489          * not found
490          */
491         const ContentFeatures& get(const std::string &name) const;
492
493         /*!
494          * Returns the content ID for the given name.
495          * @param name a node name
496          * @param[out] result will contain the content ID if found, otherwise
497          * remains unchanged
498          * @return true if the ID was found, false otherwise
499          */
500         bool getId(const std::string &name, content_t &result) const;
501
502         /*!
503          * Returns the content ID for the given name.
504          * @param name a node name
505          * @return ID of the node or @ref CONTENT_IGNORE if not found
506          */
507         content_t getId(const std::string &name) const;
508
509         /*!
510          * Returns the content IDs of the given node name or node group name.
511          * Group names start with "group:".
512          * @param name a node name or node group name
513          * @param[out] result will be appended with matching IDs
514          * @return true if `name` is a valid node name or a (not necessarily
515          * valid) group name
516          */
517         bool getIds(const std::string &name, std::vector<content_t> &result) const;
518
519         /*!
520          * Returns the smallest box in integer node coordinates that
521          * contains all nodes' selection boxes. The returned box might be larger
522          * than the minimal size if the largest node is removed from the manager.
523          */
524         inline core::aabbox3d<s16> getSelectionBoxIntUnion() const {
525                 return m_selection_box_int_union;
526         }
527
528         /*!
529          * Checks whether a node connects to an adjacent node.
530          * @param from the node to be checked
531          * @param to the adjacent node
532          * @param connect_face a bit field indicating which face of the node is
533          * adjacent to the other node.
534          * Bits: +y (least significant), -y, -z, -x, +z, +x (most significant).
535          * @return true if the node connects, false otherwise
536          */
537         bool nodeboxConnects(MapNode from, MapNode to,
538                         u8 connect_face) const;
539
540         /*!
541          * Registers a NodeResolver to wait for the registration of
542          * ContentFeatures. Once the node registration finishes, all
543          * listeners are notified.
544          */
545         void pendNodeResolve(NodeResolver *nr) const;
546
547         /*!
548          * Stops listening to the NodeDefManager.
549          * @return true if the listener was registered before, false otherwise
550          */
551         bool cancelNodeResolveCallback(NodeResolver *nr) const;
552
553         /*!
554          * Registers a new node type with the given name and allocates a new
555          * content ID.
556          * Should not be called with an already existing name.
557          * @param name name of the node, must match with `def.name`.
558          * @param def definition of the registered node type.
559          * @return ID of the registered node or @ref CONTENT_IGNORE if
560          * the function could not allocate an ID.
561          */
562         content_t set(const std::string &name, const ContentFeatures &def);
563
564         /*!
565          * Allocates a blank node ID for the given name.
566          * @param name name of a node
567          * @return allocated ID or @ref CONTENT_IGNORE if could not allocate
568          * an ID.
569          */
570         content_t allocateDummy(const std::string &name);
571
572         /*!
573          * Removes the given node name from the manager.
574          * The node ID will remain in the manager, but won't be linked to any name.
575          * @param name name to be removed
576          */
577         void removeNode(const std::string &name);
578
579         /*!
580          * Regenerates the alias list (a map from names to node IDs).
581          * @param idef the item definition manager containing alias information
582          */
583         void updateAliases(IItemDefManager *idef);
584
585         /*!
586          * Reads the used texture pack's override.txt, and replaces the textures
587          * of registered nodes with the ones specified there.
588          *
589          * Format of the input file: in each line
590          * `node_name top|bottom|right|left|front|back|all|*|sides texture_name.png`
591          *
592          * @param override_filepath path to 'texturepack/override.txt'
593          */
594         void applyTextureOverrides(const std::string &override_filepath);
595
596         /*!
597          * Only the client uses this. Loads textures and shaders required for
598          * rendering the nodes.
599          * @param gamedef must be a Client.
600          * @param progress_cbk called each time a node is loaded. Arguments:
601          * `progress_cbk_args`, number of loaded ContentFeatures, number of
602          * total ContentFeatures.
603          * @param progress_cbk_args passed to the callback function
604          */
605         void updateTextures(IGameDef *gamedef,
606                 void (*progress_cbk)(void *progress_args, u32 progress, u32 max_progress),
607                 void *progress_cbk_args);
608
609         /*!
610          * Writes the content of this manager to the given output stream.
611          * @param protocol_version serialization version of ContentFeatures
612          */
613         void serialize(std::ostream &os, u16 protocol_version) const;
614
615         /*!
616          * Restores the manager from a serialized stream.
617          * This clears the previous state.
618          * @param is input stream containing a serialized NodeDefManager
619          */
620         void deSerialize(std::istream &is);
621
622         /*!
623          * Used to indicate that node registration has finished.
624          * @param completed tells whether registration is complete
625          */
626         inline void setNodeRegistrationStatus(bool completed) {
627                 m_node_registration_complete = completed;
628         }
629
630         /*!
631          * Notifies the registered NodeResolver instances that node registration
632          * has finished, then unregisters all listeners.
633          * Must be called after node registration has finished!
634          */
635         void runNodeResolveCallbacks();
636
637         /*!
638          * Sets the registration completion flag to false and unregisters all
639          * NodeResolver instances listening to the manager.
640          */
641         void resetNodeResolveState();
642
643         /*!
644          * Resolves the IDs to which connecting nodes connect from names.
645          * Must be called after node registration has finished!
646          */
647         void mapNodeboxConnections();
648
649 private:
650         /*!
651          * Resets the manager to its initial state.
652          * See the documentation of the constructor.
653          */
654         void clear();
655
656         /*!
657          * Allocates a new content ID, and returns it.
658          * @return the allocated ID or \ref CONTENT_IGNORE if could not allocate
659          */
660         content_t allocateId();
661
662         /*!
663          * Binds the given content ID and node name.
664          * Registers them in \ref m_name_id_mapping and
665          * \ref m_name_id_mapping_with_aliases.
666          * @param i a content ID
667          * @param name a node name
668          */
669         void addNameIdMapping(content_t i, std::string name);
670
671         /*!
672          * Removes a content ID from all groups.
673          * Erases content IDs from vectors in \ref m_group_to_items and
674          * removes empty vectors.
675          * @param id Content ID
676          */
677         void eraseIdFromGroups(content_t id);
678
679         /*!
680          * Recalculates m_selection_box_int_union based on
681          * m_selection_box_union.
682          */
683         void fixSelectionBoxIntUnion();
684
685         //! Features indexed by ID.
686         std::vector<ContentFeatures> m_content_features;
687
688         //! A mapping for fast conversion between names and IDs
689         NameIdMapping m_name_id_mapping;
690
691         /*!
692          * Like @ref m_name_id_mapping, but maps only from names to IDs, and
693          * includes aliases too. Updated by \ref updateAliases().
694          * Note: Not serialized.
695          */
696         std::unordered_map<std::string, content_t> m_name_id_mapping_with_aliases;
697
698         /*!
699          * A mapping from group names to a vector of content types that belong
700          * to it. Necessary for a direct lookup in \ref getIds().
701          * Note: Not serialized.
702          */
703         std::unordered_map<std::string, std::vector<content_t>> m_group_to_items;
704
705         /*!
706          * The next ID that might be free to allocate.
707          * It can be allocated already, because \ref CONTENT_AIR,
708          * \ref CONTENT_UNKNOWN and \ref CONTENT_IGNORE are registered when the
709          * manager is initialized, and new IDs are allocated from 0.
710          */
711         content_t m_next_id;
712
713         //! True if all nodes have been registered.
714         bool m_node_registration_complete;
715
716         /*!
717          * The union of all nodes' selection boxes.
718          * Might be larger if big nodes are removed from the manager.
719          */
720         aabb3f m_selection_box_union;
721
722         /*!
723          * The smallest box in integer node coordinates that
724          * contains all nodes' selection boxes.
725          * Might be larger if big nodes are removed from the manager.
726          */
727         core::aabbox3d<s16> m_selection_box_int_union;
728
729         /*!
730          * NodeResolver instances to notify once node registration has finished.
731          * Even constant NodeDefManager instances can register listeners.
732          */
733         mutable std::vector<NodeResolver *> m_pending_resolve_callbacks;
734 };
735
736 NodeDefManager *createNodeDefManager();
737
738 class NodeResolver {
739 public:
740         NodeResolver();
741         virtual ~NodeResolver();
742         virtual void resolveNodeNames() = 0;
743
744         bool getIdFromNrBacklog(content_t *result_out,
745                 const std::string &node_alt, content_t c_fallback,
746                 bool error_on_fallback = true);
747         bool getIdsFromNrBacklog(std::vector<content_t> *result_out,
748                 bool all_required = false, content_t c_fallback = CONTENT_IGNORE);
749
750         void nodeResolveInternal();
751
752         u32 m_nodenames_idx = 0;
753         u32 m_nnlistsizes_idx = 0;
754         std::vector<std::string> m_nodenames;
755         std::vector<size_t> m_nnlistsizes;
756         const NodeDefManager *m_ndef = nullptr;
757         bool m_resolve_done = false;
758 };