From 29bee786ed74fb044f23b8ad9368b77867b31d75 Mon Sep 17 00:00:00 2001 From: namespace Date: Wed, 7 Mar 2007 18:42:05 +0000 Subject: [PATCH] - Updated UFA:Plugin (mattn2) git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/trunk@153 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- CHANGES | 4 ++ contrib/ufoaiplug/ufoai.cpp | 4 +- contrib/ufoaiplug/ufoai_filters.cpp | 6 ++- contrib/ufoaiplug/ufoai_level.cpp | 74 +++++++++++++++++++++++++++-- 4 files changed, 81 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 7a75f3d7..f290b854 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ This is the changelog for developers, != changelog for the end user that we distribute with the binaries. (see changelog) +07/03/2007 +namespace +- Updated UFA:Plugin (mattn2) + 04/03/2007 namespace - Reverted Q3 translucency fix since it randomly made brushes diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index e2372dd0..36caa0b0 100644 --- a/contrib/ufoaiplug/ufoai.cpp +++ b/contrib/ufoaiplug/ufoai.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#define PLUGIN_VERSION "0.1" +#define PLUGIN_VERSION "0.2" #include "ifilter.h" #include "ibrush.h" @@ -86,7 +86,7 @@ namespace UFOAI if(string_equal(command, "About")) { GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_mainwnd), - "UFO:AI Plugin (http://www.ufoai.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\n", "About", + "UFO:AI Plugin (http://www.ufoai.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n", "About", eMB_OK, eMB_ICONDEFAULT); } else if(string_equal(command, "Level 1")) diff --git a/contrib/ufoaiplug/ufoai_filters.cpp b/contrib/ufoaiplug/ufoai_filters.cpp index d7fec320..896f6b37 100644 --- a/contrib/ufoaiplug/ufoai_filters.cpp +++ b/contrib/ufoaiplug/ufoai_filters.cpp @@ -206,8 +206,10 @@ void filter_level(int flag) if (level_active) { GlobalSceneGraph().traverse(BrushGetLevel(brushes, (level_active << 8), true, true, false)); + GlobalSceneGraph().traverse(EntityFindByName("func_door", entities, level_active, false)); GlobalSceneGraph().traverse(EntityFindByName("func_breakable", entities, level_active, false)); GlobalSceneGraph().traverse(EntityFindByName("misc_model", entities, level_active, false)); + GlobalSceneGraph().traverse(EntityFindByName("misc_particle", entities, level_active, false)); entities.erase(entities.begin(), entities.end()); brushes.erase(brushes.begin(), brushes.end()); if (level_active == level) @@ -224,8 +226,10 @@ void filter_level(int flag) GlobalSceneGraph().traverse(BrushGetLevel(brushes, flag, true, true, true)); // now all entities + GlobalSceneGraph().traverse(EntityFindByName("func_door", entities, level, true)); GlobalSceneGraph().traverse(EntityFindByName("func_breakable", entities, level, true)); GlobalSceneGraph().traverse(EntityFindByName("misc_model", entities, level, true)); + GlobalSceneGraph().traverse(EntityFindByName("misc_particle", entities, level, true)); #ifdef _DEBUG if (brushes.empty()) @@ -237,7 +241,7 @@ void filter_level(int flag) globalOutputStream() << "UFO:AI: Found " << Unsigned(brushes.size()) << " brushes.\n"; } - // now let's filter all entities like misc_model and func_breakable that have the spawnflags set + // now let's filter all entities like misc_model, func_breakable and func_door that have the spawnflags set if (entities.empty()) { globalOutputStream() << "UFO:AI: No entities.\n"; diff --git a/contrib/ufoaiplug/ufoai_level.cpp b/contrib/ufoaiplug/ufoai_level.cpp index 71f72a2a..544d0b9e 100644 --- a/contrib/ufoaiplug/ufoai_level.cpp +++ b/contrib/ufoaiplug/ufoai_level.cpp @@ -65,6 +65,36 @@ Entity* Scene_FindEntityByClass(const char* name) return entity; } +/** + * @brief finds start positions + */ +class EntityFindFlags : public scene::Graph::Walker +{ + const char *m_classname; + const char *m_flag; + int *m_count; + + public: + EntityFindFlags(const char *classname, const char *flag, int *count) : m_classname(classname), m_flag(flag), m_count(count) + { + } + bool pre(const scene::Path& path, scene::Instance& instance) const + { + const char *str; + Entity* entity = Node_getEntity(path.top()); + if(entity != 0 && string_equal(m_classname, entity->getKeyValue("classname"))) + { + str = entity->getKeyValue(m_flag); + if (string_empty(str)) + { + (*m_count)++; + } + } + return true; + } +}; + + /** * @brief finds start positions */ @@ -235,9 +265,22 @@ void assign_default_values_to_worldspawn (bool override, bool day, char **return *returnMsg = message; } +/** + * @brief + */ +int check_entity_flags (const char *classname, const char *flag) +{ + int count; + + /* init this with 0 every time we browse the tree */ + count = 0; + + GlobalSceneGraph().traverse(EntityFindFlags(classname, flag, &count)); + return count; +} + /** * @brief Will check e.g. the map entities for valid values - * @todo: Check whether all misc_model and func_breakable have spawnflags * @todo: check for maxlevel */ void check_map_values (char **returnMsg) @@ -245,6 +288,7 @@ void check_map_values (char **returnMsg) static char message[1024]; int count = 0; int teams = 0; + int ent_flags; Entity* worldspawn; char str[64]; @@ -292,9 +336,31 @@ void check_map_values (char **returnMsg) strncat(message, "Worldspawn: Highest maxlevel is 8\n", sizeof(message) - 1); worldspawn->setKeyValue("maxlevel", "8"); } - // no errors - no warnings - if (!strlen(message)) - return; + + ent_flags = check_entity_flags("func_door", "spawnflags"); + if (ent_flags) + snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i func_door with no spawnflags\n", ent_flags); + ent_flags = check_entity_flags("func_breakable", "spawnflags"); + if (ent_flags) + snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i func_breakable with no spawnflags\n", ent_flags); + ent_flags = check_entity_flags("misc_model", "spawnflags"); + if (ent_flags) + snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i misc_model with no spawnflags\n", ent_flags); + ent_flags = check_entity_flags("misc_particle", "spawnflags"); + if (ent_flags) + snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i misc_particle with no spawnflags\n", ent_flags); + ent_flags = check_entity_flags("info_player_start", "team"); + if (ent_flags) + snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i info_player_start with no team assigned\n!!Teamcount may change after you've fixed this\n", ent_flags); + ent_flags = check_entity_flags("light", "color"); + ent_flags = check_entity_flags("light", "_color"); + if (ent_flags) + snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i lights with no color value\n", ent_flags); + + // no errors found + if (!strlen(message)) { + snprintf(message, sizeof(message) - 1, "No errors found - you are ready to compile the map now\n"); + } *returnMsg = message; } -- 2.39.2