From 3d6896e6ff12e8ff01f15e3a2bcfb26ec647af64 Mon Sep 17 00:00:00 2001 From: suhrke Date: Sat, 19 Aug 2017 19:30:14 -0700 Subject: [PATCH] Reorganized, expanded pickup file to include other entities, now .ent --- ReflexToQ3/.gitignore => .gitignore | 3 +- .gitmodules | 8 ++--- Makefile | 32 +++++++++++++++++++ ReflexToQ3/Makefile | 32 ------------------- ReflexToQ3/includes/Catch | 1 - ReflexToQ3/includes/cxxopts | 1 - includes/Catch | 1 + includes/cxxopts | 1 + r2cpma.ent | 25 +++++++++++++++ r2q3.ent | 25 +++++++++++++++ ReflexToQ3/r2x.pck => r2xonotic.ent | 2 +- .../includes => src}/EntityConverter.cpp | 14 ++++---- .../includes => src}/EntityConverter.hpp | 2 +- {ReflexToQ3/includes => src}/brushdef.cpp | 0 {ReflexToQ3/includes => src}/brushdef.hpp | 0 {ReflexToQ3 => src}/main.cpp | 0 .../includes => src}/oopless-parser.cpp | 0 .../includes => src}/oopless-parser.hpp | 0 {ReflexToQ3/includes => src}/planes.cpp | 0 {ReflexToQ3/includes => src}/planes.h | 0 {ReflexToQ3/includes => src}/worldspawn.h | 0 .../cases-face/parser-face-3indices.txt | 0 .../cases-face/parser-face-4indices.txt | 0 .../cases-face/parser-face-5indices.txt | 0 .../cases-face/parser-face-nomaterial-0.txt | 0 .../test => test}/catch-entityconverter.cpp | 24 +++++++------- {ReflexToQ3/test => test}/catch-parser.cpp | 0 {ReflexToQ3/test => test}/catch.cpp | 0 28 files changed, 110 insertions(+), 61 deletions(-) rename ReflexToQ3/.gitignore => .gitignore (83%) create mode 100644 Makefile delete mode 100644 ReflexToQ3/Makefile delete mode 160000 ReflexToQ3/includes/Catch delete mode 160000 ReflexToQ3/includes/cxxopts create mode 160000 includes/Catch create mode 160000 includes/cxxopts create mode 100644 r2cpma.ent create mode 100644 r2q3.ent rename ReflexToQ3/r2x.pck => r2xonotic.ent (96%) rename {ReflexToQ3/includes => src}/EntityConverter.cpp (98%) rename {ReflexToQ3/includes => src}/EntityConverter.hpp (99%) rename {ReflexToQ3/includes => src}/brushdef.cpp (100%) rename {ReflexToQ3/includes => src}/brushdef.hpp (100%) rename {ReflexToQ3 => src}/main.cpp (100%) rename {ReflexToQ3/includes => src}/oopless-parser.cpp (100%) rename {ReflexToQ3/includes => src}/oopless-parser.hpp (100%) rename {ReflexToQ3/includes => src}/planes.cpp (100%) rename {ReflexToQ3/includes => src}/planes.h (100%) rename {ReflexToQ3/includes => src}/worldspawn.h (100%) rename {ReflexToQ3/test => test}/cases-face/parser-face-3indices.txt (100%) rename {ReflexToQ3/test => test}/cases-face/parser-face-4indices.txt (100%) rename {ReflexToQ3/test => test}/cases-face/parser-face-5indices.txt (100%) rename {ReflexToQ3/test => test}/cases-face/parser-face-nomaterial-0.txt (100%) rename {ReflexToQ3/test => test}/catch-entityconverter.cpp (96%) rename {ReflexToQ3/test => test}/catch-parser.cpp (100%) rename {ReflexToQ3/test => test}/catch.cpp (100%) diff --git a/ReflexToQ3/.gitignore b/.gitignore similarity index 83% rename from ReflexToQ3/.gitignore rename to .gitignore index 1f243d5..eca3467 100644 --- a/ReflexToQ3/.gitignore +++ b/.gitignore @@ -14,6 +14,5 @@ # executables reflex2q3 -test/catch -test/test-parser +runtests diff --git a/.gitmodules b/.gitmodules index b4d4ce2..7c5b405 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule "ReflexToQ3/includes/cxxopts"] - path = ReflexToQ3/includes/cxxopts +[submodule "includes/cxxopts"] + path = includes/cxxopts url = https://github.com/jarro2783/cxxopts.git -[submodule "ReflexToQ3/includes/Catch"] - path = ReflexToQ3/includes/Catch +[submodule "includes/Catch"] + path = includes/Catch url = https://github.com/philsquared/Catch.git diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..683a326 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +EX=reflex2q3 +CC=g++ +CFLAGS=-std=c++11 -I"./src" -I"./includes" -I"./includes/Catch/single_include" -I"./includes/cxxopts/include" -I"/usr/include/eigen3" +TESTEX=runtests + +all: main test + +main: planes.o brushdef.o oopless-parser.o EntityConverter.o + $(CC) $^ src/main.cpp $(CFLAGS) -o $(EX) #2>error8.log + +test: planes.o brushdef.o oopless-parser.o EntityConverter.o catch.o + $(CC) $^ $(CFLAGS) -o $(TESTEX) + cp runtests .git/hooks/pre-commit + +catch.o: test/catch.cpp + $(CC) -c $^ $(CFLAGS) + +oopless-parser.o: src/oopless-parser.cpp + $(CC) -c $^ $(CFLAGS) + +brushdef.o: src/brushdef.cpp + $(CC) -c $^ $(CFLAGS) + +planes.o: src/planes.cpp + $(CC) -c $^ $(CFLAGS) + +EntityConverter.o: src/EntityConverter.cpp + $(CC) -c $^ $(CFLAGS) + +clean: + rm *.o *.log $(EX) + diff --git a/ReflexToQ3/Makefile b/ReflexToQ3/Makefile deleted file mode 100644 index 535cb9f..0000000 --- a/ReflexToQ3/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -EX=reflex2q3 -CC=g++ -CFLAGS=-std=c++11 -I"./includes" -I"./includes/Catch/single_include" -I"./includes/cxxopts/include" -I"/usr/include/eigen3" -TESTEX=test/catch - -all: main test - -main: planes.o brushdef.o oopless-parser.o EntityConverter.o - $(CC) $^ main.cpp $(CFLAGS) -o $(EX) 2>error8.log - -test: planes.o brushdef.o oopless-parser.o EntityConverter.o catch.o - $(CC) $^ $(CFLAGS) -o $(TESTEX) - mv test/catch ../.git/hooks/pre-commit - -catch.o: test/catch.cpp - $(CC) -c $^ $(CFLAGS) - -oopless-parser.o: includes/oopless-parser.cpp - $(CC) -c $^ $(CFLAGS) - -brushdef.o: includes/brushdef.cpp - $(CC) -c $^ $(CFLAGS) - -planes.o: includes/planes.cpp - $(CC) -c $^ $(CFLAGS) - -EntityConverter.o: includes/EntityConverter.cpp - $(CC) -c $^ $(CFLAGS) - -clean: - rm *.o *.log $(EX) - diff --git a/ReflexToQ3/includes/Catch b/ReflexToQ3/includes/Catch deleted file mode 160000 index 6f32db3..0000000 --- a/ReflexToQ3/includes/Catch +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6f32db35af06b30701d159b9e16a21e76d82aada diff --git a/ReflexToQ3/includes/cxxopts b/ReflexToQ3/includes/cxxopts deleted file mode 160000 index 11faade..0000000 --- a/ReflexToQ3/includes/cxxopts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 11faadeba77d05a80c751e97142875c4b296fa87 diff --git a/includes/Catch b/includes/Catch new file mode 160000 index 0000000..27640a5 --- /dev/null +++ b/includes/Catch @@ -0,0 +1 @@ +Subproject commit 27640a5a968a0981eeab5f354aa52459641b2e91 diff --git a/includes/cxxopts b/includes/cxxopts new file mode 160000 index 0000000..c2c2262 --- /dev/null +++ b/includes/cxxopts @@ -0,0 +1 @@ +Subproject commit c2c2262626b20c75d1bebbab5e35d3f9282d7f63 diff --git a/r2cpma.ent b/r2cpma.ent new file mode 100644 index 0000000..b2072eb --- /dev/null +++ b/r2cpma.ent @@ -0,0 +1,25 @@ +40 item_health_small +41 item_health +42 item_health_large +43 item_health_mega +50 item_armor_shard +51 item_armor_jacket +52 item_armor_combat +53 item_armor_body +1 weapon_shotgun +2 weapon_grenadelauncher +3 weapon_plasmagun +4 weapon_rocketlauncher +5 weapon_lightning +6 weapon_railgun +20 ammo_bullets +21 ammo_shells +22 ammo_rockets +23 ammo_lightning +24 ammo_rockets +25 ammo_bullets +26 ammo_lightning +60 item_quad +62 item_enviro +70 team_CTF_redflag +71 team_CTF_blueflag diff --git a/r2q3.ent b/r2q3.ent new file mode 100644 index 0000000..76e36cd --- /dev/null +++ b/r2q3.ent @@ -0,0 +1,25 @@ +40 item_health_small +41 item_health +42 item_health_large +43 item_health_mega +50 item_armor_shard +51 item_armor_small +52 item_armor_big +53 item_armor_mega +1 weapon_shotgun +2 weapon_grenadelauncher +3 weapon_plasmagun +4 weapon_rocketlauncher +5 weapon_lightning +6 weapon_railgun +20 item_bullets +21 item_shells +22 item_rockets +23 item_lightning +24 item_rockets +25 item_bullets +26 item_lightning +60 item_quad +62 item_shield? +70 item_flag_team1 +71 item_flag_team2 diff --git a/ReflexToQ3/r2x.pck b/r2xonotic.ent similarity index 96% rename from ReflexToQ3/r2x.pck rename to r2xonotic.ent index 2edc648..a396f18 100644 --- a/ReflexToQ3/r2x.pck +++ b/r2xonotic.ent @@ -12,7 +12,7 @@ 4 weapon_rocketlauncher 5 weapon_electro 6 weapon_nex -20 burst +20 item_shells 21 item_shells 22 item_rockets 23 item_cells diff --git a/ReflexToQ3/includes/EntityConverter.cpp b/src/EntityConverter.cpp similarity index 98% rename from ReflexToQ3/includes/EntityConverter.cpp rename to src/EntityConverter.cpp index 1d1a912..0771b2f 100644 --- a/ReflexToQ3/includes/EntityConverter.cpp +++ b/src/EntityConverter.cpp @@ -243,7 +243,7 @@ EntityConverter::convertPickup(const std::vector &lines) const std::vector convertedLines; //can ignore angle of pickups in xonotic format std::string coords[3] = {"0.0", "0.0", "0.0"}; - int pickupID; + std::string pickupID; std::string trash; bool havePickupID = false; @@ -275,8 +275,8 @@ EntityConverter::convertPickup(const std::vector &lines) const } if ( havePickupID ) { - auto pickupIter = pickupMap_.find(pickupID); - if ( pickupIter == pickupMap_.end() ) { + auto pickupIter = entityMap_.find(pickupID); + if ( pickupIter == entityMap_.end() ) { throw std::runtime_error( makeErrorMessage( "error: Pickup ID is invalid", lines )); } @@ -681,12 +681,12 @@ EntityConverter::mapEntities(const std::string &mapFile) while (std::getline(fin, line)) { std::istringstream iss(line); // Reflex ID corresponds to xonotic pickup name - int id; + std::string id; std::string pickup; if ( ! (iss >> id >> pickup)) { throw std::runtime_error( "format error in Pickup .pck file " + mapFile ); } - pickupMap_.insert ( std::pair(id, pickup) ); + entityMap_.insert ( std::pair(id, pickup) ); } } else { @@ -816,8 +816,8 @@ void EntityConverter::printMapping() const { std::cout << std::endl << "Reflex pickup ID mapped to Xonotic pickup names: " << std::endl; - std::map::const_iterator it; - for ( it=pickupMap_.begin(); it!=pickupMap_.end(); ++it ) + std::map::const_iterator it; + for ( it=entityMap_.begin(); it!=entityMap_.end(); ++it ) std::cout << it->first << " => " << it->second << std::endl; } diff --git a/ReflexToQ3/includes/EntityConverter.hpp b/src/EntityConverter.hpp similarity index 99% rename from ReflexToQ3/includes/EntityConverter.hpp rename to src/EntityConverter.hpp index 96b07f3..04181db 100644 --- a/ReflexToQ3/includes/EntityConverter.hpp +++ b/src/EntityConverter.hpp @@ -219,7 +219,7 @@ class EntityConverter // Map Reflex pickup IDs to Xonotic pickup identifiers - std::map pickupMap_; + std::map entityMap_; // Map targets (by name) to their source type std::map targetMap_; // Related entities must be matched prior to entity conversion diff --git a/ReflexToQ3/includes/brushdef.cpp b/src/brushdef.cpp similarity index 100% rename from ReflexToQ3/includes/brushdef.cpp rename to src/brushdef.cpp diff --git a/ReflexToQ3/includes/brushdef.hpp b/src/brushdef.hpp similarity index 100% rename from ReflexToQ3/includes/brushdef.hpp rename to src/brushdef.hpp diff --git a/ReflexToQ3/main.cpp b/src/main.cpp similarity index 100% rename from ReflexToQ3/main.cpp rename to src/main.cpp diff --git a/ReflexToQ3/includes/oopless-parser.cpp b/src/oopless-parser.cpp similarity index 100% rename from ReflexToQ3/includes/oopless-parser.cpp rename to src/oopless-parser.cpp diff --git a/ReflexToQ3/includes/oopless-parser.hpp b/src/oopless-parser.hpp similarity index 100% rename from ReflexToQ3/includes/oopless-parser.hpp rename to src/oopless-parser.hpp diff --git a/ReflexToQ3/includes/planes.cpp b/src/planes.cpp similarity index 100% rename from ReflexToQ3/includes/planes.cpp rename to src/planes.cpp diff --git a/ReflexToQ3/includes/planes.h b/src/planes.h similarity index 100% rename from ReflexToQ3/includes/planes.h rename to src/planes.h diff --git a/ReflexToQ3/includes/worldspawn.h b/src/worldspawn.h similarity index 100% rename from ReflexToQ3/includes/worldspawn.h rename to src/worldspawn.h diff --git a/ReflexToQ3/test/cases-face/parser-face-3indices.txt b/test/cases-face/parser-face-3indices.txt similarity index 100% rename from ReflexToQ3/test/cases-face/parser-face-3indices.txt rename to test/cases-face/parser-face-3indices.txt diff --git a/ReflexToQ3/test/cases-face/parser-face-4indices.txt b/test/cases-face/parser-face-4indices.txt similarity index 100% rename from ReflexToQ3/test/cases-face/parser-face-4indices.txt rename to test/cases-face/parser-face-4indices.txt diff --git a/ReflexToQ3/test/cases-face/parser-face-5indices.txt b/test/cases-face/parser-face-5indices.txt similarity index 100% rename from ReflexToQ3/test/cases-face/parser-face-5indices.txt rename to test/cases-face/parser-face-5indices.txt diff --git a/ReflexToQ3/test/cases-face/parser-face-nomaterial-0.txt b/test/cases-face/parser-face-nomaterial-0.txt similarity index 100% rename from ReflexToQ3/test/cases-face/parser-face-nomaterial-0.txt rename to test/cases-face/parser-face-nomaterial-0.txt diff --git a/ReflexToQ3/test/catch-entityconverter.cpp b/test/catch-entityconverter.cpp similarity index 96% rename from ReflexToQ3/test/catch-entityconverter.cpp rename to test/catch-entityconverter.cpp index 778bce8..783c4cf 100644 --- a/ReflexToQ3/test/catch-entityconverter.cpp +++ b/test/catch-entityconverter.cpp @@ -21,7 +21,7 @@ #include "EntityConverter.hpp" -#define PICKUP_FILENAME "ReflexToQ3/r2x.pck" +#define ENTITY_FILENAME "r2xonotic.ent" #define DELTA 0.00001 @@ -29,7 +29,7 @@ TEST_CASE( "r2x: Unsupported entity types cause return of empty vector", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up entity std::vector entity; @@ -53,7 +53,7 @@ TEST_CASE( "r2x: Unsupported entity types cause return of empty vector", "[Entit TEST_CASE( "r2x: a single Pickup entity can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up entity std::vector entity; @@ -92,7 +92,7 @@ TEST_CASE( "r2x: a single Pickup entity can be converted", "[EntityConverter]" ) TEST_CASE( "r2x: a single PlayerSpawn (race) entity can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up WorldSpawn entity // (needed for mode info) @@ -182,7 +182,7 @@ TEST_CASE( "r2x: a single PlayerSpawn (race) entity can be converted", "[EntityC TEST_CASE( "r2x: a single PlayerSpawn (teamA) entity can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up entity std::vector entity; @@ -222,7 +222,7 @@ TEST_CASE( "r2x: a single PlayerSpawn (teamA) entity can be converted", "[Entity TEST_CASE( "r2x: a single PlayerSpawn (non-team) entity can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up entity std::vector entity; @@ -261,7 +261,7 @@ TEST_CASE( "r2x: a single PlayerSpawn (non-team) entity can be converted", "[Ent TEST_CASE( "r2x: a single RaceStart entity can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up entity std::vector entity; @@ -287,7 +287,7 @@ TEST_CASE( "r2x: a single RaceStart entity can be converted", "[EntityConverter] TEST_CASE( "r2x: a single RaceFinish entity can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up entity std::vector entity; @@ -313,7 +313,7 @@ TEST_CASE( "r2x: a single RaceFinish entity can be converted", "[EntityConverter TEST_CASE( "r2x: a single Teleporter and related Target can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up Teleporter entity std::vector entity; @@ -376,7 +376,7 @@ TEST_CASE( "r2x: a single Teleporter and related Target can be converted", "[Ent TEST_CASE( "r2x: a single JumpPad and related Target can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up JumpPad entity std::vector entity; @@ -413,7 +413,7 @@ TEST_CASE( "r2x: a single JumpPad and related Target can be converted", "[Entity TEST_CASE( "r2x: a single PointLight entity can be converted", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up entity std::vector entity; @@ -461,7 +461,7 @@ TEST_CASE( "r2x: a single PointLight entity can be converted", "[EntityConverter TEST_CASE( "r2x: PointLight defaults to white light of typical intensity", "[EntityConverter]" ) { // Instantiate object - EntityConverter ec (PICKUP_FILENAME); + EntityConverter ec (ENTITY_FILENAME); // Mock up entity std::vector entity; diff --git a/ReflexToQ3/test/catch-parser.cpp b/test/catch-parser.cpp similarity index 100% rename from ReflexToQ3/test/catch-parser.cpp rename to test/catch-parser.cpp diff --git a/ReflexToQ3/test/catch.cpp b/test/catch.cpp similarity index 100% rename from ReflexToQ3/test/catch.cpp rename to test/catch.cpp