Reorganized, expanded pickup file to include other entities, now .ent

This commit is contained in:
suhrke 2017-08-19 19:30:14 -07:00
parent 40f9432321
commit 3d6896e6ff
28 changed files with 110 additions and 61 deletions

View File

@ -14,6 +14,5 @@
# executables # executables
reflex2q3 reflex2q3
test/catch runtests
test/test-parser

8
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "ReflexToQ3/includes/cxxopts"] [submodule "includes/cxxopts"]
path = ReflexToQ3/includes/cxxopts path = includes/cxxopts
url = https://github.com/jarro2783/cxxopts.git url = https://github.com/jarro2783/cxxopts.git
[submodule "ReflexToQ3/includes/Catch"] [submodule "includes/Catch"]
path = ReflexToQ3/includes/Catch path = includes/Catch
url = https://github.com/philsquared/Catch.git url = https://github.com/philsquared/Catch.git

32
Makefile Normal file
View File

@ -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)

View File

@ -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)

@ -1 +0,0 @@
Subproject commit 6f32db35af06b30701d159b9e16a21e76d82aada

@ -1 +0,0 @@
Subproject commit 11faadeba77d05a80c751e97142875c4b296fa87

1
includes/Catch Submodule

@ -0,0 +1 @@
Subproject commit 27640a5a968a0981eeab5f354aa52459641b2e91

1
includes/cxxopts Submodule

@ -0,0 +1 @@
Subproject commit c2c2262626b20c75d1bebbab5e35d3f9282d7f63

25
r2cpma.ent Normal file
View File

@ -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

25
r2q3.ent Normal file
View File

@ -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

View File

@ -12,7 +12,7 @@
4 weapon_rocketlauncher 4 weapon_rocketlauncher
5 weapon_electro 5 weapon_electro
6 weapon_nex 6 weapon_nex
20 burst 20 item_shells
21 item_shells 21 item_shells
22 item_rockets 22 item_rockets
23 item_cells 23 item_cells

View File

@ -243,7 +243,7 @@ EntityConverter::convertPickup(const std::vector<std::string> &lines) const
std::vector<std::string> convertedLines; std::vector<std::string> convertedLines;
//can ignore angle of pickups in xonotic format //can ignore angle of pickups in xonotic format
std::string coords[3] = {"0.0", "0.0", "0.0"}; std::string coords[3] = {"0.0", "0.0", "0.0"};
int pickupID; std::string pickupID;
std::string trash; std::string trash;
bool havePickupID = false; bool havePickupID = false;
@ -275,8 +275,8 @@ EntityConverter::convertPickup(const std::vector<std::string> &lines) const
} }
if ( havePickupID ) { if ( havePickupID ) {
auto pickupIter = pickupMap_.find(pickupID); auto pickupIter = entityMap_.find(pickupID);
if ( pickupIter == pickupMap_.end() ) { if ( pickupIter == entityMap_.end() ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Pickup ID is invalid", lines )); makeErrorMessage( "error: Pickup ID is invalid", lines ));
} }
@ -681,12 +681,12 @@ EntityConverter::mapEntities(const std::string &mapFile)
while (std::getline(fin, line)) { while (std::getline(fin, line)) {
std::istringstream iss(line); std::istringstream iss(line);
// Reflex ID corresponds to xonotic pickup name // Reflex ID corresponds to xonotic pickup name
int id; std::string id;
std::string pickup; std::string pickup;
if ( ! (iss >> id >> pickup)) { if ( ! (iss >> id >> pickup)) {
throw std::runtime_error( "format error in Pickup .pck file " + mapFile ); throw std::runtime_error( "format error in Pickup .pck file " + mapFile );
} }
pickupMap_.insert ( std::pair<int, std::string>(id, pickup) ); entityMap_.insert ( std::pair<std::string, std::string>(id, pickup) );
} }
} }
else { else {
@ -816,8 +816,8 @@ void
EntityConverter::printMapping() const EntityConverter::printMapping() const
{ {
std::cout << std::endl << "Reflex pickup ID mapped to Xonotic pickup names: " << std::endl; std::cout << std::endl << "Reflex pickup ID mapped to Xonotic pickup names: " << std::endl;
std::map<int, std::string>::const_iterator it; std::map<std::string, std::string>::const_iterator it;
for ( it=pickupMap_.begin(); it!=pickupMap_.end(); ++it ) for ( it=entityMap_.begin(); it!=entityMap_.end(); ++it )
std::cout << it->first << " => " << it->second << std::endl; std::cout << it->first << " => " << it->second << std::endl;
} }

View File

@ -219,7 +219,7 @@ class EntityConverter
// Map Reflex pickup IDs to Xonotic pickup identifiers // Map Reflex pickup IDs to Xonotic pickup identifiers
std::map<int, std::string> pickupMap_; std::map<std::string, std::string> entityMap_;
// Map targets (by name) to their source type // Map targets (by name) to their source type
std::map<std::string, std::string> targetMap_; std::map<std::string, std::string> targetMap_;
// Related entities must be matched prior to entity conversion // Related entities must be matched prior to entity conversion

View File

@ -21,7 +21,7 @@
#include "EntityConverter.hpp" #include "EntityConverter.hpp"
#define PICKUP_FILENAME "ReflexToQ3/r2x.pck" #define ENTITY_FILENAME "r2xonotic.ent"
#define DELTA 0.00001 #define DELTA 0.00001
@ -29,7 +29,7 @@
TEST_CASE( "r2x: Unsupported entity types cause return of empty vector", "[EntityConverter]" ) { TEST_CASE( "r2x: Unsupported entity types cause return of empty vector", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up entity // Mock up entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: a single Pickup entity can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up entity // Mock up entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: a single PlayerSpawn (race) entity can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up WorldSpawn entity // Mock up WorldSpawn entity
// (needed for mode info) // (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]" ) { TEST_CASE( "r2x: a single PlayerSpawn (teamA) entity can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up entity // Mock up entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: a single PlayerSpawn (non-team) entity can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up entity // Mock up entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: a single RaceStart entity can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up entity // Mock up entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: a single RaceFinish entity can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up entity // Mock up entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: a single Teleporter and related Target can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up Teleporter entity // Mock up Teleporter entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: a single JumpPad and related Target can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up JumpPad entity // Mock up JumpPad entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: a single PointLight entity can be converted", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up entity // Mock up entity
std::vector<std::string> entity; std::vector<std::string> 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]" ) { TEST_CASE( "r2x: PointLight defaults to white light of typical intensity", "[EntityConverter]" ) {
// Instantiate object // Instantiate object
EntityConverter ec (PICKUP_FILENAME); EntityConverter ec (ENTITY_FILENAME);
// Mock up entity // Mock up entity
std::vector<std::string> entity; std::vector<std::string> entity;