Writing entity brushes overwrites brush texture with common/trigger

This commit is contained in:
2017-07-07 23:08:58 -07:00
parent 5f0343a88d
commit 24d011a289
2 changed files with 17 additions and 3 deletions

View File

@ -5,7 +5,7 @@
#include <iterator> #include <iterator>
using namespace std; using namespace std;
bool is_ebrush(std::vector<std::string> input) { bool is_ebrush(const std::vector<std::string> &input) {
#define KEYWORD_ENTBRUSH1 "type Teleporter" #define KEYWORD_ENTBRUSH1 "type Teleporter"
#define KEYWORD_ENTBRUSH2 "type JumpPad" #define KEYWORD_ENTBRUSH2 "type JumpPad"
for (const string &str : input) { for (const string &str : input) {
@ -36,6 +36,18 @@ bool write(const struct TBrush &geometry,
return ok; return ok;
} }
// currently for the specific case to specify trigger to brush entities
struct TBrush override_textures(struct TBrush x, const char *texture) {
struct TBrush output = x;
for (struct TFace &z : output.m_Faces) {
// prevent appending color infomation to texture file path
// may need re-ordering on when to append that.
z.hex = string();
z.m_Material = texture;
}
return output;
}
void write(const vector<string> &entity, void write(const vector<string> &entity,
ofstream &fo, ofstream &fo,
void (*b) (stringstream &, const vector<TPlanePoints> &), void (*b) (stringstream &, const vector<TPlanePoints> &),
@ -73,7 +85,7 @@ void write(const vector<string> &entity,
string line; string line;
copy(brush.begin(), brush.end(), ostream_iterator<string>(ss, "\n")); copy(brush.begin(), brush.end(), ostream_iterator<string>(ss, "\n"));
getline(ss, line); // this both discards the brush keyboard and prevents a crash getline(ss, line); // this both discards the brush keyboard and prevents a crash
write(parse_brush<stringstream>(ss), fo, b); write(override_textures(parse_brush<stringstream>(ss), "common/trigger"), fo, b);
} }
fo << "}" << endl; fo << "}" << endl;
} }

View File

@ -10,7 +10,9 @@
#include <queue> #include <queue>
#include "EntityConverter.hpp" #include "EntityConverter.hpp"
bool is_ebrush(std::vector<std::string>); bool is_ebrush(const std::vector<std::string>&);
struct TBrush override_textures(struct TBrush, const char*);
bool write(const struct TBrush &, bool write(const struct TBrush &,
std::ofstream &, std::ofstream &,