updated ufoai plugin from mattn
authorForest Hale <lordhavoc>
Sun, 24 Feb 2008 13:10:49 +0000 (13:10 +0000)
committerForest Hale <lordhavoc>
Sun, 24 Feb 2008 13:10:49 +0000 (13:10 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@196 8a3a26a2-13c4-0310-b231-cf6edde360e5

contrib/ufoaiplug/bitmaps/ufoai_actorclip.bmp
contrib/ufoaiplug/bitmaps/ufoai_nodraw.bmp [new file with mode: 0644]
contrib/ufoaiplug/bitmaps/ufoai_stepon.bmp
contrib/ufoaiplug/bitmaps/ufoai_weaponclip.bmp [new file with mode: 0644]
contrib/ufoaiplug/ufoai.cpp
contrib/ufoaiplug/ufoai_filters.cpp
contrib/ufoaiplug/ufoai_filters.h
contrib/ufoaiplug/ufoai_gtk.cpp
contrib/ufoaiplug/ufoai_level.cpp
contrib/ufoaiplug/ufoai_level.h

index 5fbba7f..43bdf93 100644 (file)
Binary files a/contrib/ufoaiplug/bitmaps/ufoai_actorclip.bmp and b/contrib/ufoaiplug/bitmaps/ufoai_actorclip.bmp differ
diff --git a/contrib/ufoaiplug/bitmaps/ufoai_nodraw.bmp b/contrib/ufoaiplug/bitmaps/ufoai_nodraw.bmp
new file mode 100644 (file)
index 0000000..b994856
Binary files /dev/null and b/contrib/ufoaiplug/bitmaps/ufoai_nodraw.bmp differ
index c494c8d..828449e 100644 (file)
Binary files a/contrib/ufoaiplug/bitmaps/ufoai_stepon.bmp and b/contrib/ufoaiplug/bitmaps/ufoai_stepon.bmp differ
diff --git a/contrib/ufoaiplug/bitmaps/ufoai_weaponclip.bmp b/contrib/ufoaiplug/bitmaps/ufoai_weaponclip.bmp
new file mode 100644 (file)
index 0000000..fe6b348
Binary files /dev/null and b/contrib/ufoaiplug/bitmaps/ufoai_weaponclip.bmp differ
index 36caa0b..e371e83 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.2"
+#define PLUGIN_VERSION "0.4"
 
 #include "ifilter.h"
 #include "ibrush.h"
@@ -74,7 +74,7 @@ namespace UFOAI
        const char* getCommandList()
        {
                /*GlobalRadiant().getGameName()*/
-               return "About;-;Worldspawn reset (day);Worldspawn reset (night);Worldspawn (day);Worldspawn (night);Perform check;-;Level 1;Level 2;Level 3;Level 4;Level 5;Level 6;Level 7;Level 8;-;StepOn;ActorClip";
+               return "About;-;Worldspawn reset;Worldspawn;Perform check;-;Level 1;Level 2;Level 3;Level 4;Level 5;Level 6;Level 7;Level 8;-;StepOn;ActorClip;WeaponClip;Nodraw";
        }
        const char* getCommandTitleList()
        {
@@ -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 "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n", "About",
+                               "UFO:AI Plugin (http://ufoai.sf.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"))
@@ -101,21 +101,13 @@ namespace UFOAI
                {
                        filter_level(CONTENTS_LEVEL3);
                }
-               else if(string_equal(command, "Worldspawn (day)"))
+               else if(string_equal(command, "Worldspawn"))
                {
-                       assign_default_values_to_worldspawn(false, true, &message);
+                       assign_default_values_to_worldspawn(false, &message);
                }
-               else if(string_equal(command, "Worldspawn (night)"))
+               else if(string_equal(command, "Worldspawn reset"))
                {
-                       assign_default_values_to_worldspawn(false, false, &message);
-               }
-               else if(string_equal(command, "Worldspawn reset (day)"))
-               {
-                       assign_default_values_to_worldspawn(true, true, &message);
-               }
-               else if(string_equal(command, "Worldspawn reset (night)"))
-               {
-                       assign_default_values_to_worldspawn(true, false, &message);
+                       assign_default_values_to_worldspawn(true, &message);
                }
                else if(string_equal(command, "Perform check"))
                {
@@ -149,6 +141,14 @@ namespace UFOAI
                {
                        filter_actorclip();
                }
+               else if(string_equal(command, "WeaponClip"))
+               {
+                       filter_weaponclip();
+               }
+               else if(string_equal(command, "NoDraw"))
+               {
+                       filter_nodraw();
+               }
 
                if (message != NULL)
                {
index 896f6b3..869c4eb 100644 (file)
@@ -31,6 +31,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 bool actorclip_active = false;
 bool stepon_active = false;
+bool nodraw_active = false;
+bool weaponclip_active = false;
 int level_active = 0;
 
 // TODO: This should be added to ibrush.h
@@ -273,6 +275,28 @@ void filter_stepon (void)
        }
 }
 
+void filter_nodraw (void)
+{
+       if (nodraw_active) {
+               nodraw_active = false;
+       } else {
+               nodraw_active = true;
+       }
+       brushlist_t brushes;
+       GlobalSceneGraph().traverse(BrushGetLevel(brushes, SURF_NODRAW, false, false, nodraw_active));
+
+#ifdef _DEBUG
+       if (brushes.empty())
+       {
+               globalOutputStream() << "UFO:AI: No brushes.\n";
+       }
+       else
+       {
+               globalOutputStream() << "UFO:AI: Hiding " << Unsigned(brushes.size()) << " nodraw brushes.\n";
+       }
+#endif
+}
+
 void filter_actorclip (void)
 {
        if (actorclip_active) {
@@ -294,3 +318,25 @@ void filter_actorclip (void)
        }
 #endif
 }
+
+void filter_weaponclip (void)
+{
+       if (weaponclip_active) {
+               weaponclip_active = false;
+       } else {
+               weaponclip_active = true;
+       }
+       brushlist_t brushes;
+       GlobalSceneGraph().traverse(BrushGetLevel(brushes, CONTENTS_WEAPONCLIP, true, false, weaponclip_active));
+
+#ifdef _DEBUG
+       if (brushes.empty())
+       {
+               globalOutputStream() << "UFO:AI: No brushes.\n";
+       }
+       else
+       {
+               globalOutputStream() << "UFO:AI: Hiding " << Unsigned(brushes.size()) << " weaponclip brushes.\n";
+       }
+#endif
+}
index bdc40fc..7d58114 100644 (file)
@@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 void filter_level(int flag);
 void filter_stepon(void);
 void filter_actorclip(void);
+void filter_weaponclip(void);
+void filter_nodraw(void);
+
+#define SURF_NODRAW 0x80
 
 #define CONTENTS_LEVEL8 0x8000
 #define CONTENTS_LEVEL7 0x4000
@@ -32,7 +36,7 @@ void filter_actorclip(void);
 #define CONTENTS_LEVEL2 0x0200
 #define CONTENTS_LEVEL1 0x0100
 #define CONTENTS_ACTORCLIP 0x10000
-
+#define CONTENTS_WEAPONCLIP 0x2000000
 #define CONTENTS_STEPON 0x40000000
 
 #endif
index 34685ee..afadc7a 100644 (file)
@@ -67,7 +67,7 @@ static void close_window(GtkWidget *widget, gpointer data)
 
 /* =============================== */
 
-#define NUM_TOOLBARBUTTONS 10
+#define NUM_TOOLBARBUTTONS 12
 
 /**
  * @brief
@@ -105,6 +105,8 @@ public:
                case 7: return "ufoai_level8.bmp";
                case 8: return "ufoai_stepon.bmp";
                case 9: return "ufoai_actorclip.bmp";
+               case 10: return "ufoai_weaponclip.bmp";
+               case 11: return "ufoai_nodraw.bmp";
                }
                return NULL;
        }
@@ -115,6 +117,8 @@ public:
 /*             case 3: return eButton;*/
                case 8: return eToggleButton;
                case 9: return eToggleButton;
+               case 10: return eToggleButton;
+               case 11: return eToggleButton;
                default: return eButton;
                }
        }
@@ -132,6 +136,8 @@ public:
                case 7: return "Level 8";
                case 8: return "Stepon";
                case 9: return "Actorclip";
+               case 10: return "Weaponclip";
+               case 11: return "Nodraw";
                }
                return NULL;
        }
@@ -149,6 +155,8 @@ public:
                case 7: return "Show only level 8";
                case 8: return "Hide stepon brushes";
                case 9: return "Hide actorclip brushes";
+               case 10: return "Hide weaponclip brushes";
+               case 11: return "Hide nodraw brushes";
                }
                return NULL;
        }
@@ -167,6 +175,8 @@ public:
                case 7: filter_level(CONTENTS_LEVEL8); break;
                case 8: filter_stepon(); break;
                case 9: filter_actorclip(); break;
+               case 10: filter_weaponclip(); break;
+               case 11: filter_nodraw(); break;
                }
                SceneChangeNotify();
        }
index 544d0b9..3a36b25 100644 (file)
@@ -141,9 +141,9 @@ void get_team_count (const char *classname, int *count, int *team)
 }
 
 /**
- * @brief Some default values to worldspawn like maxlevel, maxteams and so on
+ * @brief Some default values to worldspawn like maxlevel and so on
  */
-void assign_default_values_to_worldspawn (bool override, bool day, char **returnMsg)
+void assign_default_values_to_worldspawn (bool override, char **returnMsg)
 {
        static char message[1024];
        Entity* worldspawn;
@@ -162,102 +162,28 @@ void assign_default_values_to_worldspawn (bool override, bool day, char **return
        *message = '\0';
        *str = '\0';
 
-       get_team_count("info_player_start", &count, &teams);
-
-       // TODO: Get highest brush - a level has 64 units
-       worldspawn->setKeyValue("maxlevel", "5");
-
-       if (string_empty(worldspawn->getKeyValue("maxteams"))
-        || atoi(worldspawn->getKeyValue("maxteams")) != teams)
+       if (override || string_empty(worldspawn->getKeyValue("maxlevel")))
        {
-               snprintf(str, sizeof(str) - 1, "%i", teams);
-               worldspawn->setKeyValue("maxteams", str);
-               strncat(message, "Worldspawn: Set maxteams to ", sizeof(message) - 1);
-               strncat(message, str, sizeof(message) - 1);
-               strncat(message, "\n", sizeof(message) - 1);
+               // TODO: Get highest brush - a level has 64 units
+               worldspawn->setKeyValue("maxlevel", "5");
+               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set maxlevel to: %s", worldspawn->getKeyValue("maxlevel"));
        }
 
-       if (day)
+       if (override || string_empty(worldspawn->getKeyValue("maxteams")))
        {
-               if (override)
+               get_team_count("info_player_start", &count, &teams);
+               if (teams)
                {
-                       worldspawn->setKeyValue("light", "160");
-                       worldspawn->setKeyValue("_color", "1 0.8 0.8");
-                       worldspawn->setKeyValue("angles", "30 210");
-                       worldspawn->setKeyValue("ambient", "0.4 0.4 0.4");
+                       snprintf(str, sizeof(str) - 1, "%i", teams);
+                       worldspawn->setKeyValue("maxteams", str);
+                       snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set maxteams to: %s", worldspawn->getKeyValue("maxteams"));
                }
-               else
+               if (count < 16)
                {
-                       if (string_empty(worldspawn->getKeyValue("light")))
-                       {
-                               worldspawn->setKeyValue("light", "160");
-                               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient"));
-                       }
-                       if (string_empty(worldspawn->getKeyValue("_color")))
-                       {
-                               worldspawn->setKeyValue("_color", "1 0.8 0.8");
-                               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient"));
-                       }
-                       if (string_empty(worldspawn->getKeyValue("angles")))
-                       {
-                               worldspawn->setKeyValue("angles", "30 210");
-                               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient"));
-                       }
-                       if (string_empty(worldspawn->getKeyValue("ambient")))
-                       {
-                               worldspawn->setKeyValue("ambient", "0.4 0.4 0.4");
-                               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient"));
-                       }
-               }
-       }
-       else
-       {
-               if (override)
-               {
-                       worldspawn->setKeyValue("light", "60");
-                       worldspawn->setKeyValue("_color", "0.8 0.8 1");
-                       worldspawn->setKeyValue("angles", "15 60");
-                       worldspawn->setKeyValue("ambient", "0.25 0.25 0.275");
-               }
-               else
-               {
-                       if (string_empty(worldspawn->getKeyValue("light")))
-                       {
-                               worldspawn->setKeyValue("light", "60");
-                               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient"));
-                       }
-                       if (string_empty(worldspawn->getKeyValue("_color")))
-                       {
-                               worldspawn->setKeyValue("_color", "0.8 0.8 1");
-                               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient"));
-                       }
-                       if (string_empty(worldspawn->getKeyValue("angles")))
-                       {
-                               worldspawn->setKeyValue("angles", "15 60");
-                               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient"));
-                       }
-                       if (string_empty(worldspawn->getKeyValue("ambient")))
-                       {
-                               worldspawn->setKeyValue("ambient", "0.25 0.25 0.275");
-                               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient"));
-                       }
+                       snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "You should at least place 16 info_player_start");
                }
        }
 
-       if (override)
-       {
-               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message),
-                       "Set light to: %s\n"
-                       "Set _color to: %s\n"
-                       "Set angles to: %s\n"
-                       "Set ambient to: %s\n",
-                       worldspawn->getKeyValue("light"),
-                       worldspawn->getKeyValue("_color"),
-                       worldspawn->getKeyValue("angles"),
-                       worldspawn->getKeyValue("ambient")
-               );
-       }
-
        // no errors - no warnings
        if (!strlen(message))
                return;
@@ -307,14 +233,6 @@ void check_map_values (char **returnMsg)
        get_team_count("info_player_start", &count, &teams);
        if (!count)
                strncat(message, "No multiplayer start positions (info_player_start)\n", sizeof(message) - 1);
-       else if (string_empty(worldspawn->getKeyValue("maxteams")))
-       {
-               snprintf(message, sizeof(message) - 1, "Worldspawn: No maxteams defined (#info_player_start) (set to: %i)\n", teams);
-               snprintf(str, sizeof(str) - 1, "%i", teams);
-               worldspawn->setKeyValue("maxteams", str);
-       }
-       else if (teams != atoi(worldspawn->getKeyValue("maxteams")))
-               snprintf(message, sizeof(message) - 1, "Worldspawn: Settings for maxteams (%s) doesn't match team count (%i)\n", worldspawn->getKeyValue("maxteams"), teams);
 
        // singleplayer map?
        count = 0;
@@ -322,6 +240,12 @@ void check_map_values (char **returnMsg)
        if (!count)
                strncat(message, "No singleplayer start positions (info_human_start)\n", sizeof(message) - 1);
 
+       // singleplayer map?
+       count = 0;
+       get_team_count("info_2x2_start", &count, NULL);
+       if (!count)
+               strncat(message, "No singleplayer start positions for 2x2 units (info_2x2_start)\n", sizeof(message) - 1);
+
        // search for civilians
        count = 0;
        get_team_count("info_civilian_start", &count, NULL);
@@ -343,6 +267,9 @@ void check_map_values (char **returnMsg)
        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_sound", "spawnflags");
+       if (ent_flags)
+               snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i misc_sound 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);
index b545c20..ba75bd4 100644 (file)
@@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #if !defined(INCLUDED_UFOAI_LEVEL_H)
 #define INCLUDED_UFOAI_LEVEL_H
 
-void assign_default_values_to_worldspawn (bool override, bool day, char **returnMsg);
+void assign_default_values_to_worldspawn (bool override, char **returnMsg);
 void check_map_values (char **returnMsg);
 void get_team_count (const char *classname, int *count, int *team);