Skip to content

Commit

Permalink
Delete after fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
klingbolt committed Aug 17, 2024
1 parent d6485cc commit e8b73f8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 41 deletions.
15 changes: 8 additions & 7 deletions Spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,17 @@ func decode_context_packet(spb: StreamPeerBuffer):
if self.map_id != old_map_id:
print("New Map")
var old_textue_path: String = ""
if self.next_texture_id != 0:
old_textue_path = self.waypoint_data.get_textures()[self.next_texture_id].get_filepath()
if old_map_id != 0 and not read_hash(old_map_id) == make_hash(self.waypoint_data.to_bytes()):
print("Saving Old Map")
old_textue_path = self.waypoint_data.get_textures()[self.next_texture_id].get_filepath()
save_map_data(old_map_id)
print("Loading New Map")
load_waypoint_markers(self.map_id)
if old_textue_path != "":
self.next_texture_id = get_texture_index(old_textue_path)
if self.next_texture_id == -1:
self.waypoint_data.add_textures().set_filepath(old_textue_path)
self.next_texture_id = self.waypoint_data.get_textures().size() - 1
self.next_texture_id = get_texture_index(old_textue_path)
if self.next_texture_id == -1:
self.waypoint_data.add_textures().set_filepath(old_textue_path)
self.next_texture_id = self.waypoint_data.get_textures().size() - 1


reset_minimap_masks()
Expand Down Expand Up @@ -620,6 +620,7 @@ func gen_new_trail(waypoint_trail: Waypoint.Trail, category_item: TreeItem) -> A
func gen_new_icon(waypoint_icon: Waypoint.Icon, category_item: TreeItem):
var texture_id: int = waypoint_icon.get_texture_id()
if texture_id == null:
print(texture_id)
var category_data = category_item.get_metadata(0)
print("Warning: No texture found in " , category_data.waypoint_category.get_name())
var texture_path: String = self.unsaved_markers_dir + self.waypoint_data.get_textures()[texture_id].get_filepath()
Expand Down Expand Up @@ -1101,7 +1102,7 @@ func _on_ImportPackDialog_dir_selected(dir):
"--input-taco-path", dir,
# TODO: This line is not working as intended and needs to be investigated
# "--input-waypoint-path", user_data_dir.plus_file("protobin"),
"--output-waypoint-path", user_data_dir.plus_file("protobin"),
#"--output-waypoint-path", user_data_dir.plus_file("protobin"),
"--output-split-waypoint-path", ProjectSettings.globalize_path(self.unsaved_markers_dir)
]
FileHandler.call_xml_converter(args)
Expand Down
4 changes: 2 additions & 2 deletions Spatial.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ margin_bottom = 534.0
window_title = "Open a Directory"
mode = 2
access = 2
current_dir = ""
current_path = ""
current_dir = "/home/steph/Code/Projects/Burrito"
current_path = "/home/steph/Code/Projects/Burrito/"
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<OverlayData>
<MarkerCategory Name="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83"></MarkerCategory>

<MarkerCategory Name="NestedLevel1" XPos="000" MapID="999">
<MarkerCategory Name="NestedLevel2" YPos="222">
<MarkerCategory Name="nestedlevel1" XPos="000" MapID="999">
<MarkerCategory Name="nestedlevel2" YPos="222">
<MarkerCategory Name="NestedLevel3" ZPos="333"></MarkerCategory>
</MarkerCategory>
</MarkerCategory>

<MarkerCategory Name="NestedLevel1" XPos="111"></MarkerCategory>
<MarkerCategory Name="nestedlevel1" XPos="111"></MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" />
Expand Down
3 changes: 2 additions & 1 deletion xml_converter/src/attribute/marker_category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "../rapid_helpers.hpp"
#include "../rapidxml-1.13/rapidxml.hpp"
#include "../string_helper.hpp"
#include "waypoint.pb.h"

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -18,7 +19,7 @@ void xml_attribute_to_marker_category(
XMLReaderState*,
MarkerCategory* value,
bool* is_set) {
value->category = get_attribute_value(input);
value->category = lowercase(get_attribute_value(input));
*is_set = true;
}

Expand Down
24 changes: 11 additions & 13 deletions xml_converter/src/packaging_protobin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void parse_waypoint_categories(
map<string, Category>* marker_categories,
vector<Parseable*>* parsed_pois,
ProtoReaderState* state) {
full_category_name += proto_category.name();
full_category_name += lowercase(proto_category.name());
Category* this_category = &(*marker_categories)[full_category_name];

this_category->parse_protobuf(proto_category, state);
Expand All @@ -40,6 +40,7 @@ void parse_waypoint_categories(
// TODO: The field category in Icon is being deprciated
// This overwrites any icon.category with its position in the heirarchy
icon->category.category = full_category_name;
icon->category_is_set = true;
parsed_pois->push_back(icon);
}
for (int i = 0; i < proto_category.trail_size(); i++) {
Expand All @@ -48,6 +49,7 @@ void parse_waypoint_categories(
// TODO: The field category in Trail is being deprciated
// This overwrites any trail.category with its position in the heirarchy
trail->category.category = full_category_name;
trail->category_is_set = true;
parsed_pois->push_back(trail);
}

Expand Down Expand Up @@ -93,7 +95,7 @@ MaybeCategory build_category_objects(
const Category* category,
const StringHierarchy& category_filter,
const std::map<string, std::vector<Parseable*>>& category_to_pois,
vector<string>* category_vector,
string category_name,
ProtoWriterState* state) {
waypoint::Category category_proto = category->as_protobuf(state);
bool has_valid_contents = false;
Expand All @@ -102,27 +104,24 @@ MaybeCategory build_category_objects(

for (map<string, Category>::const_iterator it = category->children.begin(); it != category->children.end(); it++) {
// This is currently a copy operation which is kind expensive
category_vector->push_back(it->first);

if (category_filter.in_hierarchy(*category_vector)) {
cout << category_name << endl;
if (category_filter.in_hierarchy(split(category_name, "."))) {
MaybeCategory child_category = build_category_objects(
&it->second,
category_filter,
category_to_pois,
category_vector,
it->first,
state);

if (child_category.is_category) {
has_valid_contents = true;
category_proto.add_children()->MergeFrom(child_category.category);
}
}
category_vector->pop_back();
}

// This is a pretty expensive operation
string full_category_name = join(*category_vector, ".");
auto iterator = category_to_pois.find(full_category_name);
auto iterator = category_to_pois.find(category_name);
if (iterator != category_to_pois.end()) {
for (size_t i = 0; i < iterator->second.size(); i++) {
Parseable* parsed_poi = iterator->second[i];
Expand Down Expand Up @@ -184,12 +183,11 @@ void _write_protobuf_file(
string category_name = it->first;
const Category* category_object = &it->second;

vector<string> category_vector = {it->first};
MaybeCategory maybe_category = build_category_objects(
category_object,
category_filter,
category_to_pois,
&category_vector,
category_name,
state);

if (maybe_category.is_category) {
Expand All @@ -216,11 +214,11 @@ void write_protobuf_file(
Parseable* parsed_poi = (*parsed_pois)[i];
if (parsed_poi->classname() == "POI") {
Icon* icon = dynamic_cast<Icon*>(parsed_poi);
category_to_pois[lowercase(icon->category.category)].push_back(parsed_poi);
category_to_pois[icon->category.category].push_back(parsed_poi);
}
else if (parsed_poi->classname() == "Trail") {
Trail* trail = dynamic_cast<Trail*>(parsed_poi);
category_to_pois[lowercase(trail->category.category)].push_back(parsed_poi);
category_to_pois[trail->category.category].push_back(parsed_poi);
}
else {
std::cout << "Unknown type" << std::endl;
Expand Down
16 changes: 1 addition & 15 deletions xml_converter/src/xml_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "attribute/marker_category.hpp"
#include "category_gen.hpp"
#include "file_helper.hpp"
#include "function_timers.hpp"
#include "icon_gen.hpp"
#include "packaging_protobin.hpp"
#include "packaging_xml.hpp"
Expand Down Expand Up @@ -150,7 +151,6 @@ void process_data(
map<string, Category> marker_categories;

// Read in all the xml taco markerpacks
auto begin = chrono::high_resolution_clock::now();
for (size_t i = 0; i < input_taco_paths.size(); i++) {
cout << "Loading taco pack " << input_taco_paths[i] << endl;

Expand All @@ -159,10 +159,6 @@ void process_data(
&marker_categories,
&parsed_pois);
}
auto end = chrono::high_resolution_clock::now();
auto dur = end - begin;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
cout << "The taco parse function took " << ms << " milliseconds to run" << endl;

// Read in all the protobin waypoint markerpacks
for (size_t i = 0; i < input_waypoint_paths.size(); i++) {
Expand All @@ -175,31 +171,21 @@ void process_data(
}

// Write all of the xml taco paths
begin = chrono::high_resolution_clock::now();
for (size_t i = 0; i < output_taco_paths.size(); i++) {
write_taco_directory(output_taco_paths[i], &marker_categories, &parsed_pois);
}
end = chrono::high_resolution_clock::now();
dur = end - begin;
ms = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
cout << "The xml write function took " << ms << " milliseconds to run" << endl;

// Write all of the protobin waypoint paths
for (size_t i = 0; i < output_waypoint_paths.size(); i++) {
write_burrito_directory(output_waypoint_paths[i], &marker_categories, &parsed_pois);
}

// Write the special map-split protbin waypoint file
begin = chrono::high_resolution_clock::now();
if (output_split_waypoint_dir != "") {
StringHierarchy category_filter;
category_filter.add_path({}, true);
write_protobuf_file_per_map_id(output_split_waypoint_dir, category_filter, &marker_categories, &parsed_pois);
}
end = chrono::high_resolution_clock::now();
dur = end - begin;
ms = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
cout << "The protobuf write function took " << ms << " milliseconds to run" << endl;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit e8b73f8

Please sign in to comment.