Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line parser #378

Open
wants to merge 12 commits into
base: xml_converter
Choose a base branch
from
20 changes: 9 additions & 11 deletions xml_converter/integration_tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@


def run_xml_converter(
allow_duplicates: Optional[bool] = None,
input_xml: Optional[List[str]] = None,
output_xml: Optional[List[str]] = None,
input_proto: Optional[List[str]] = None,
output_proto: Optional[List[str]] = None,
split_output_proto: Optional[str] = None,
allow_duplicates: Optional[bool] = None,
split_by_map_id: Optional[bool] = None
) -> Tuple[str, str, int]:

# Build the command to execute the C++ program with the desired function and arguments
cmd: List[str] = [xml_converter_binary_path]

if allow_duplicates:
cmd += ["--allow-duplicates"]
if input_xml:
cmd += ["--input-taco-path"] + input_xml
if output_xml:
Expand All @@ -34,10 +36,8 @@ def run_xml_converter(
cmd += ["--input-guildpoint-path"] + input_proto
if output_proto:
cmd += ["--output-guildpoint-path"] + output_proto
if split_output_proto:
cmd += ["--output-split-guildpoint-path"] + [split_output_proto]
if allow_duplicates:
cmd += ["--allow-duplicates"]
if split_by_map_id:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the ordering, does this mean that if split-by-map-id is specified then only the proto will be split by map id? If so that's fine for now but you should make a new issue detailing the problems that arise from this and how one might fix them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct for now. This would be the next step in adjusting the test harness so that each input and output can be configured. My thought was to make a dictionary of adjustments so that they can be processed as a group for each type.

example:

configurations: 
    "xml" : "split_by_category"
   "proto" : "split_by_map_id"

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good first thought, but assumes that all xml inputs want one argument, and the same argument. Instead just transform the inputs field from a Dict[str,str] to a Dict[str, ConfigData] where ConfigData is something like {"type": "xml", "split_by_category": true}. This will allow the inputs to be specified in an intuitive manner to anyone reading the test config, and will also allow for test inputs to nearly mirror the new cli flags.

cmd += ["--split-by-map-id"]

# Run the C++ program and capture its output
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
Expand Down Expand Up @@ -122,10 +122,7 @@ def rebuild_xml_converter_binary() -> None:
line_patterns_to_ignore = [
r"^Loading taco pack .*$",
r"^Loading guildpoint pack .*$",
r"^The taco parse function took [0-9]+ milliseconds to run$",
r"^The xml write function took [0-9]+ milliseconds to run$",
r"^The protobuf read function took [0-9]+ milliseconds to run$",
r"^The protobuf write function took [0-9]+ milliseconds to run$",
r"^The .+? function took [0-9]+ milliseconds to run$",
r"^$"
]

Expand Down Expand Up @@ -180,11 +177,12 @@ def main() -> bool:
output_proto_paths = [proto_output_dir_path]

rawstdout, rawstderr, returncode = run_xml_converter(
allow_duplicates=testcase.allow_duplicates,
input_xml=testcase.xml_input_paths,
input_proto=testcase.proto_input_paths,
output_xml=output_xml_paths,
output_proto=output_proto_paths,
allow_duplicates=testcase.allow_duplicates
split_by_map_id=testcase.split_by_map_id
)

# Sanitize and denoise the lines
Expand Down
12 changes: 11 additions & 1 deletion xml_converter/integration_tests/src/testcase_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Testcase:
expected_stderr: List[str]
expected_returncode: int
allow_duplicates: bool
split_by_map_id: bool


################################################################################
Expand Down Expand Up @@ -60,6 +61,7 @@ def load_testcase(path: str) -> Optional[Testcase]:
xml_input_paths: List[str] = []
proto_input_paths: List[str] = []
allow_duplicates: bool = False
split_by_map_id: bool = False
for pack_name, pack_type in data["input_paths"].items():
if not isinstance(pack_name, str):
print(f"Invalid pack name, expecting a string but got {pack_name}")
Expand Down Expand Up @@ -126,6 +128,13 @@ def load_testcase(path: str) -> Optional[Testcase]:
else:
allow_duplicates = data["allow_duplicates"]

if "split_by_map_id" in data:
if not isinstance(data["split_by_map_id"], bool):
print(f"Invalid Test, expecting bool value for 'split_by_map_id' in {path}")
return None
else:
split_by_map_id = data["split_by_map_id"]

return Testcase(
name=os.path.basename(path),
xml_input_paths=xml_input_paths,
Expand All @@ -135,7 +144,8 @@ def load_testcase(path: str) -> Optional[Testcase]:
expected_stdout=to_lines(data["expected_stdout"]),
expected_stderr=to_lines(data["expected_stderr"]),
expected_returncode=data["expected_returncode"],
allow_duplicates=allow_duplicates
allow_duplicates=allow_duplicates,
split_by_map_id=split_by_map_id
)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" Name="mycategory">
</MarkerCategory>

<POIs>
<POI Type="mycategory" XPos="100" YPos="200" ZPos="300" MapID="0" />
<POI Type="mycategory" XPos="110" YPos="210" ZPos="310" MapID="1" />
<POI Type="mycategory" XPos="120" YPos="220" ZPos="320" MapID="5" />
<POI Type="mycategory" XPos="130" YPos="230" ZPos="330" MapID="2147483647" />
<POI Type="mycategory" XPos="140" YPos="240" ZPos="340" MapID="50" />
</POIs>
</OverlayData>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._old	2025-01-19 03:52:55.356172701 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._new	2025-01-19 03:52:55.364172747 +0000
@@ -0,0 +1,11 @@
+category {
+  name: "My Category"
+  icon {
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._old	2025-01-19 04:50:55.013852956 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._new	2025-01-19 04:50:55.020852949 +0000
@@ -0,0 +1,11 @@
+category {
+  name: "My Category"
+  icon {
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._old	2025-01-25 01:36:59.638725166 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._new	2025-01-25 01:36:59.645725208 +0000
@@ -0,0 +1,11 @@
+category {
+  name: "My Category"
+  icon {
+    position {
+      x: 100
+      y: 200
+      z: 300
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._old	2025-01-25 01:42:07.598797894 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._new	2025-01-25 01:42:07.605797863 +0000
@@ -0,0 +1,11 @@
+category {
+  name: "My Category"
+  icon {
+    position {
+      x: 100
+      y: 200
+      z: 300
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._old	2025-01-25 02:29:39.884471992 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._new	2025-01-25 02:29:39.891471986 +0000
@@ -0,0 +1,11 @@
+category {
+  name: "My Category"
+  icon {
+    position {
+      x: 100
+      y: 200
+      z: 300
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._old	2025-01-25 02:40:57.137576986 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._new	2025-01-25 02:40:57.144576951 +0000
@@ -0,0 +1,11 @@
+category {
+  name: "My Category"
+  icon {
+    position {
+      x: 100
+      y: 200
+      z: 300
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._old	2025-01-27 01:21:12.708476357 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._new	2025-01-27 01:21:12.715476460 +0000
@@ -0,0 +1,11 @@
+category {
+  name: "My Category"
+  icon {
+    position {
+      x: 100
+      y: 200
+      z: 300
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._old	2025-01-27 01:27:17.508703275 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/0.guildpoint.textproto._new	2025-01-27 01:27:17.516703358 +0000
@@ -0,0 +1,11 @@
+category {
+  name: "My Category"
+  icon {
+    position {
+      x: 100
+      y: 200
+      z: 300
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Binary file not shown.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._old	2025-01-19 03:52:55.372172793 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._new	2025-01-19 03:52:55.378172827 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 1
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._old	2025-01-19 04:50:55.028852940 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._new	2025-01-19 04:50:55.035852932 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 1
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._old	2025-01-25 01:36:59.653725255 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._new	2025-01-25 01:36:59.660725297 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 1
+    position {
+      x: 110
+      y: 210
+      z: 310
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._old	2025-01-25 01:42:07.617797809 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._new	2025-01-25 01:42:07.624797777 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 1
+    position {
+      x: 110
+      y: 210
+      z: 310
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._old	2025-01-25 02:29:39.899471980 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._new	2025-01-25 02:29:39.907471973 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 1
+    position {
+      x: 110
+      y: 210
+      z: 310
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._old	2025-01-25 02:40:57.152576911 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._new	2025-01-25 02:40:57.159576876 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 1
+    position {
+      x: 110
+      y: 210
+      z: 310
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._old	2025-01-27 01:21:12.723476577 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._new	2025-01-27 01:21:12.730476680 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 1
+    position {
+      x: 110
+      y: 210
+      z: 310
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._old	2025-01-27 01:27:17.523703430 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/1.guildpoint.textproto._new	2025-01-27 01:27:17.531703513 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 1
+    position {
+      x: 110
+      y: 210
+      z: 310
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Binary file not shown.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._old	2025-01-19 03:52:55.385172867 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._new	2025-01-19 03:52:55.392172907 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 2147483647
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._old	2025-01-19 04:50:55.042852924 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._new	2025-01-19 04:50:55.049852917 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 2147483647
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._old	2025-01-25 01:36:59.666725332 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._new	2025-01-25 01:36:59.673725374 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 2147483647
+    position {
+      x: 130
+      y: 230
+      z: 330
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._old	2025-01-25 01:42:07.631797746 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._new	2025-01-25 01:42:07.638797714 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 2147483647
+    position {
+      x: 130
+      y: 230
+      z: 330
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._old	2025-01-25 02:29:39.914471968 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._new	2025-01-25 02:29:39.921471962 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 2147483647
+    position {
+      x: 130
+      y: 230
+      z: 330
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._old	2025-01-25 02:40:57.165576846 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._new	2025-01-25 02:40:57.172576811 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 2147483647
+    position {
+      x: 130
+      y: 230
+      z: 330
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._old	2025-01-27 01:21:12.737476783 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._new	2025-01-27 01:21:12.744476886 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 2147483647
+    position {
+      x: 130
+      y: 230
+      z: 330
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._old	2025-01-27 01:27:17.538703586 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/2147483647.guildpoint.textproto._new	2025-01-27 01:27:17.545703659 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 2147483647
+    position {
+      x: 130
+      y: 230
+      z: 330
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Binary file not shown.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._old	2025-01-19 03:52:55.399172948 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._new	2025-01-19 03:52:55.406172988 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 5
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._old	2025-01-19 04:50:55.055852910 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._new	2025-01-19 04:50:55.062852902 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 5
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._old	2025-01-25 01:36:59.681725422 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._new	2025-01-25 01:36:59.688725463 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 5
+    position {
+      x: 120
+      y: 220
+      z: 320
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._old	2025-01-25 01:42:07.644797687 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._new	2025-01-25 01:42:07.651797656 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 5
+    position {
+      x: 120
+      y: 220
+      z: 320
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._old	2025-01-25 02:29:39.928471957 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._new	2025-01-25 02:29:39.935471951 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 5
+    position {
+      x: 120
+      y: 220
+      z: 320
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._old	2025-01-25 02:40:57.179576776 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._new	2025-01-25 02:40:57.186576741 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 5
+    position {
+      x: 120
+      y: 220
+      z: 320
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._old	2025-01-27 01:21:12.751476989 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._new	2025-01-27 01:21:12.758477091 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 5
+    position {
+      x: 120
+      y: 220
+      z: 320
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._old	2025-01-27 01:27:17.552703731 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/5.guildpoint.textproto._new	2025-01-27 01:27:17.558703794 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 5
+    position {
+      x: 120
+      y: 220
+      z: 320
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Binary file not shown.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._old	2025-01-19 03:52:55.412173023 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._new	2025-01-19 03:52:55.419173063 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._old	2025-01-19 04:50:55.069852895 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._new	2025-01-19 04:50:55.076852887 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._old	2025-01-25 01:36:59.695725505 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._new	2025-01-25 01:36:59.701725540 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 140
+      y: 240
+      z: 340
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._old	2025-01-25 01:42:07.658797624 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._new	2025-01-25 01:42:07.665797593 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 140
+      y: 240
+      z: 340
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._old	2025-01-25 02:29:39.942471945 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._new	2025-01-25 02:29:39.949471940 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 140
+      y: 240
+      z: 340
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._old	2025-01-25 02:40:57.193576706 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._new	2025-01-25 02:40:57.199576676 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 140
+      y: 240
+      z: 340
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._old	2025-01-27 01:21:12.764477179 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._new	2025-01-27 01:21:12.771477282 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 140
+      y: 240
+      z: 340
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._old	2025-01-27 01:27:17.565703866 +0000
+++ xml_converter/integration_tests/test_cases/xml_split_by_map_id/output_proto/50.guildpoint.textproto._new	2025-01-27 01:27:17.572703939 +0000
@@ -0,0 +1,12 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 140
+      y: 240
+      z: 340
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}

Binary file not shown.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the new xml output is merged in this test is probably going to fail because it is not formatted correctly. Lets leave it as-is for now to prevent you from having to rebase this branch. But your very next PR should be fixing all of the remaining issues in these tests, such as the .guildpoint changes. Ideally that could include a change to the CI to have these tests run automatically so that their failures dont go unnoticed in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI Type="mycategory" MapID="0" XPos="100.000000" YPos="200.000000" ZPos="300.000000"/>
<POI Type="mycategory" MapID="1" XPos="110.000000" YPos="210.000000" ZPos="310.000000"/>
<POI Type="mycategory" MapID="5" XPos="120.000000" YPos="220.000000" ZPos="320.000000"/>
<POI Type="mycategory" MapID="2147483647" XPos="130.000000" YPos="230.000000" ZPos="330.000000"/>
<POI Type="mycategory" MapID="50" XPos="140.000000" YPos="240.000000" ZPos="340.000000"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
input_paths:
"pack": "xml"
expected_stdout: |
expected_stderr: |
expected_returncode: 0
split_by_map_id: True
88 changes: 88 additions & 0 deletions xml_converter/src/argument_parser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include "argument_parser.hpp"

#include <cstring>
#include <iostream>
#include <map>

using namespace std;

// Default constructor for the class
PathConfig::PathConfig()
: type(BehaviorType::NONE),
format(MarkerFormat::NONE),
path("DEFAULT"),
split_by_map_id(false) {
}

PathConfig::PathConfig(BehaviorType type, MarkerFormat format, std::string path, bool split_by_map_id)
: type(type), format(format), path(path), split_by_map_id(split_by_map_id) {
}

ArgumentConfig::ArgumentConfig(BehaviorType type, MarkerFormat format)
: type(type), format(format) {
}

////////////////////////////////////////////////////////////////////////////////
// parse_arguments
//
// Processes all of the command line data into a format the internal functions
// want to receive.
////////////////////////////////////////////////////////////////////////////////
ParsedArguments parse_arguments(int argc, char* argv[]) {
vector<PathConfig> path_configs;
map<string, ArgumentConfig> arg_map = {
{"--input-taco-path", ArgumentConfig(BehaviorType::IMPORT, MarkerFormat::XML)},
{"--output-taco-path", ArgumentConfig(BehaviorType::EXPORT, MarkerFormat::XML)},
{"--input-guildpoint-path", ArgumentConfig(BehaviorType::IMPORT, MarkerFormat::GUILDPOINT)},
{"--output-guildpoint-path", ArgumentConfig(BehaviorType::EXPORT, MarkerFormat::GUILDPOINT)}};
ParsedArguments parsed_arguments;
BehaviorType type = BehaviorType::NONE;
MarkerFormat format = MarkerFormat::NONE;
bool split_by_map_id = false;
string current_argument;
vector<string> current_paths;

for (int i = 1; i < argc; i++) {
auto it = arg_map.find(argv[i]);
if (it != arg_map.end()) {
if (!current_paths.empty()) {
for (const string& path : current_paths) {
path_configs.emplace_back(type, format, path, split_by_map_id);
}
current_paths.clear();
}
else if (type != BehaviorType::NONE) {
cerr << "Error: Expected a path to a directory after " << current_argument << endl;
return {};
}
current_argument = argv[i];
type = it->second.type;
format = it->second.format;
// All flags must be set to default value
split_by_map_id = false;
}
else if (!strcmp(argv[i], "--allow-duplicates")) {
current_argument = argv[i];
parsed_arguments.allow_duplicates = true;
}
else if (!strcmp(argv[i], "--split-by-map-id")) {
current_argument = argv[i];
if (type == BehaviorType::IMPORT) {
cerr << "Error: --split-by-map-id cannot be used after an input argument" << endl;
return {};
}
split_by_map_id = true;
}
else {
current_paths.push_back(argv[i]);
}
}

if (!current_paths.empty()) {
for (const auto& path : current_paths) {
path_configs.emplace_back(type, format, path, split_by_map_id);
}
}
parsed_arguments.path_configs = path_configs;
return parsed_arguments;
}
46 changes: 46 additions & 0 deletions xml_converter/src/argument_parser.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include <string>
#include <vector>

// Defines what behavior is expected i.e. (Read/Import or Write/Export)
enum class BehaviorType {
IMPORT,
EXPORT,
NONE,
};

// Defines what format the data is expected to be in
enum class MarkerFormat {
XML,
GUILDPOINT,
NONE,
};

class PathConfig {
public:
BehaviorType type;
MarkerFormat format;
std::string path;
bool split_by_map_id = false;

PathConfig();

PathConfig(BehaviorType type, MarkerFormat format, std::string path, bool split_by_map_id = false);
};

class ArgumentConfig {
public:
BehaviorType type;
MarkerFormat format;

ArgumentConfig(BehaviorType type, MarkerFormat format);
};

class ParsedArguments {
public:
std::vector<PathConfig> path_configs;
bool allow_duplicates = false;
};

ParsedArguments parse_arguments(int argc, char* argv[]);
Loading
Loading