]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
- Updated UFA:Plugin (mattn2)
authornamespace <namespace>
Wed, 7 Mar 2007 18:42:05 +0000 (18:42 +0000)
committernamespace <namespace>
Wed, 7 Mar 2007 18:42:05 +0000 (18:42 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@153 8a3a26a2-13c4-0310-b231-cf6edde360e5

CHANGES
contrib/ufoaiplug/ufoai.cpp
contrib/ufoaiplug/ufoai_filters.cpp
contrib/ufoaiplug/ufoai_level.cpp

diff --git a/CHANGES b/CHANGES
index 7a75f3d741715a23d0aaf86e0792532877f83cd1..f290b854dc192d25d01f77c9d22613f101179920 100644 (file)
--- 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
index e2372dd0e0d44fece0d8942cee0a25e387414b56..36caa0b06ab6810bd19821a76f37cbd6d851ea96 100644 (file)
@@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <gtk/gtk.h>
 
-#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"))
index d7fec320b27f62b07ef2fa3c1edd0c81de8b0192..896f6b370b1b7a42ced7eb1f5095f8c452e5148e 100644 (file)
@@ -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";
index 71f72a2a95afcc2d9af6284437db4f1914533e83..544d0b9e569042d7b22747733bcf46a4ba8973e7 100644 (file)
@@ -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;
 }