/** Loads the specified definitions file. @param filename The name of the file @param boundsManager Used to return the various bounds for objects @param componentPropertyTypes Used to return the types of the properties in the various object components @param archetypes Used to return the object archetypes */ void DefinitionsFile::load(const std::string& filename, BoundsManager_Ptr& boundsManager, ComponentPropertyTypeMap& componentPropertyTypes, std::map<std::string,ObjectSpecification>& archetypes) { XMLLexer_Ptr lexer(new XMLLexer(filename)); XMLParser parser(lexer); XMLElement_CPtr root = parser.parse(); XMLElement_CPtr definitionsElt = root->find_unique_child("definitions"); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Process the objects subtree. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { XMLElement_CPtr objectsElt = definitionsElt->find_unique_child("objects"); // Load the object bounds. XMLElement_CPtr boundsElt = objectsElt->find_unique_child("bounds"); boundsManager = load_bounds(boundsElt); // Load the component property types. XMLElement_CPtr componentsElt = objectsElt->find_unique_child("components"); load_component_property_types(componentsElt, componentPropertyTypes); // Load the object archetypes. XMLElement_CPtr archetypesElt = objectsElt->find_unique_child("archetypes"); load_archetypes(archetypesElt, archetypes, componentPropertyTypes); } }
/** Loads the bounds from the specified definitions file. @param filename The name of the file from which to load the bounds @return The bounds */ BoundsManager_Ptr DefinitionsFile::load_bounds_only(const std::string& filename) { XMLLexer_Ptr lexer(new XMLLexer(filename)); XMLParser parser(lexer); XMLElement_CPtr root = parser.parse(); XMLElement_CPtr definitionsElt = root->find_unique_child("definitions"); XMLElement_CPtr objectsElt = definitionsElt->find_unique_child("objects"); XMLElement_CPtr boundsElt = objectsElt->find_unique_child("bounds"); return load_bounds(boundsElt); }
static int xdf_write(Stream_t *Stream, char *buf, mt_off_t where, size_t len) { off_t begin, end; size_t len2; DeclareThis(Xdf_t); decompose(This, truncBytes32(where), len, &begin, &end, 0); len2 = load_bounds(This, begin, end); if(len2 < 0) return len2; maximize(end, len2); len2 -= begin; maximize(len, len2); memcpy(This->buffer + begin, buf, len); mark_dirty(This, begin, end); return end - begin; }
int load_s_map(s_map *sm, PACKFILE *f) { sm->map_no = pack_getc(f); sm->zero_zone = pack_getc(f); sm->map_mode = pack_getc(f); sm->can_save = pack_getc(f); sm->tileset = pack_getc(f); sm->use_sstone = pack_getc(f); sm->can_warp = pack_getc(f); sm->extra_byte = pack_getc(f); sm->xsize = pack_igetl(f); sm->ysize = pack_igetl(f); sm->pmult = pack_igetl(f); sm->pdiv = pack_igetl(f); sm->stx = pack_igetl(f); sm->sty = pack_igetl(f); sm->warpx = pack_igetl(f); sm->warpy = pack_igetl(f); sm->revision = pack_igetl(f); sm->extra_sdword2 = pack_igetl(f); pack_fread(sm->song_file, sizeof(sm->song_file), f); pack_fread(sm->map_desc, sizeof(sm->map_desc), f); if (sm->revision >= 1) { /* Markers stuff */ load_markers(&sm->markers, f); if (sm->revision >= 2) { /* Bounding boxes stuff */ load_bounds(&sm->bounds, f); } else { sm->bounds.size = 0; } } else { sm->markers.size = 0; sm->bounds.size = 0; } return 0; }