From 79d5023db9bfd64ae693f4255a997cc182455c93 Mon Sep 17 00:00:00 2001 From: Forest Hale Date: Sun, 24 Feb 2008 13:10:49 +0000 Subject: [PATCH] updated ufoai plugin from mattn git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@196 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- contrib/ufoaiplug/bitmaps/ufoai_actorclip.bmp | Bin 774 -> 1014 bytes contrib/ufoaiplug/bitmaps/ufoai_nodraw.bmp | Bin 0 -> 1014 bytes contrib/ufoaiplug/bitmaps/ufoai_stepon.bmp | Bin 774 -> 1014 bytes .../ufoaiplug/bitmaps/ufoai_weaponclip.bmp | Bin 0 -> 1014 bytes contrib/ufoaiplug/ufoai.cpp | 30 ++--- contrib/ufoaiplug/ufoai_filters.cpp | 46 +++++++ contrib/ufoaiplug/ufoai_filters.h | 6 +- contrib/ufoaiplug/ufoai_gtk.cpp | 12 +- contrib/ufoaiplug/ufoai_level.cpp | 119 ++++-------------- contrib/ufoaiplug/ufoai_level.h | 2 +- 10 files changed, 101 insertions(+), 114 deletions(-) create mode 100644 contrib/ufoaiplug/bitmaps/ufoai_nodraw.bmp create mode 100644 contrib/ufoaiplug/bitmaps/ufoai_weaponclip.bmp diff --git a/contrib/ufoaiplug/bitmaps/ufoai_actorclip.bmp b/contrib/ufoaiplug/bitmaps/ufoai_actorclip.bmp index 5fbba7f986f3d421dd3376a85f40c1b702bf696f..43bdf933ef5cc94894002cf993526f9e78802b68 100644 GIT binary patch literal 1014 zcmZ?r{l?4y24+A~1BeBHm>-B485Dpd1H%EJybw18g9X6E|NjgOxN$?n|NrOk~XAnpR<79gGr#Hjj{l8*dOPCoj-wDc9&{?yb{|NZ=C1Jzvu;ypmT35Y>< suLNRH7@_KixdWYssl!F1t4HVK(gzbqSC7tzsl!F1t4HVK(gza<0AuYzS^xk5 literal 774 ycmZ?rWn*Rl12Z700mK48%n!tj3=%++f#CuZ1A`DZ1cL=YMB4vRG#UcKCIkQrKT!Gr diff --git a/contrib/ufoaiplug/bitmaps/ufoai_nodraw.bmp b/contrib/ufoaiplug/bitmaps/ufoai_nodraw.bmp new file mode 100644 index 0000000000000000000000000000000000000000..b994856271f932edcdf077b4ab806cddf3d8c122 GIT binary patch literal 1014 zcmZ?r{l?4y24+A~1BeBHm>-B485Dpd1H%EJybw18g9U)Ze}?-1cyYu2|NrsfVWR&I zL*D=O4B`I|G9>)p$q@7ZAw$9c!wiZ4_r~{u@v6}J|Ch7o{h#ES`~OeHbd_J0*hcE4*6eg8}q-_Dfxerq38cosnap^gVe5L2>X8k zXvTJi=>Kbh?6(YM{|_fl`hPfS(*Lc|?f=(?H~xQGyc*1h$BD!I|Nkk$SmJhjOy~b^ zH9P*#@hkm*nj!W7R)(nmPZ$cZrxPst8yph;&+sYyUuGQv3=8}JUm2?YcQLpUt$$~1 h_y23z3;u)XvkYlq`=2os5v?B{HXyeRlk|zp9{{z5lzjjI literal 0 HcmV?d00001 diff --git a/contrib/ufoaiplug/bitmaps/ufoai_stepon.bmp b/contrib/ufoaiplug/bitmaps/ufoai_stepon.bmp index c494c8dd99603a1cee32d08a9d6064099bc13f79..828449efa53df7b96b9fd81427b686e52a89f5b7 100644 GIT binary patch literal 1014 zcmZ?r{l?4y24+A~1BeBHm>-B485Dpd1H%EJybw18g9SiD!h-+!aNV9~|M6jbdO>pd z^n&C@y#9c;{|qjL{}~*z{xf*hK(I;pe+JL0{|v50|NTn)|Cg=5{y(T{>i?L|6=2#m zz3zW_)BOJ+S~0TzzhO}3f4kZh|Mjycfw6*n(trDkdH?lOJOAsXcK?@mjsFi8>pcXf z#Oc-M}`?*Qiy0PGP{y8r+H literal 774 zcmbV|Np3k9m@9Vah`ace(nQf&DBn6^LX-P5eY2E-{{e?iE* z;WM4zuSM^B`ASEXOM)*Le8@kmK3#qUkk7f|@F}JR{{kPfR)pCO8sx;mFl;1y3;h}W zuHTRV!be3sO#ZsBc{Ic=PGOIb@(7~ppY!A5-n}4^4@XJ<8U#Z^LXWV^*93{h2qgCh l7tHw}!FL)6xL1fgjBZQ04+VceYRZqN1I$bRd@BF0egOy(zykmP diff --git a/contrib/ufoaiplug/bitmaps/ufoai_weaponclip.bmp b/contrib/ufoaiplug/bitmaps/ufoai_weaponclip.bmp new file mode 100644 index 0000000000000000000000000000000000000000..fe6b3485852ca68332315bc63597fea01b897579 GIT binary patch literal 1014 zcmZ?r{l?4y24+A~1BeBHm>-B485Dpd1H%EJybw18g9Si@{r~^?aKrrn|M6jbdO>pd z^n&CDoqppB{~5G5{%0_~@t;Ay?tf13v;TWWPyAms{WFGtFx;;)`9Fi@i~kI^ z-~KZwG=SAR1T_3NbI$p1hu0H=%y&tUZ$$i4{-pX(Umfu7zl;s-6gqpL^f4|e?k)Tv>r literal 0 HcmV?d00001 diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index 36caa0b0..e371e833 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.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) { diff --git a/contrib/ufoaiplug/ufoai_filters.cpp b/contrib/ufoaiplug/ufoai_filters.cpp index 896f6b37..869c4eb8 100644 --- a/contrib/ufoaiplug/ufoai_filters.cpp +++ b/contrib/ufoaiplug/ufoai_filters.cpp @@ -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 +} diff --git a/contrib/ufoaiplug/ufoai_filters.h b/contrib/ufoaiplug/ufoai_filters.h index bdc40fc5..7d581140 100644 --- a/contrib/ufoaiplug/ufoai_filters.h +++ b/contrib/ufoaiplug/ufoai_filters.h @@ -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 diff --git a/contrib/ufoaiplug/ufoai_gtk.cpp b/contrib/ufoaiplug/ufoai_gtk.cpp index 34685ee0..afadc7ad 100644 --- a/contrib/ufoaiplug/ufoai_gtk.cpp +++ b/contrib/ufoaiplug/ufoai_gtk.cpp @@ -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(); } diff --git a/contrib/ufoaiplug/ufoai_level.cpp b/contrib/ufoaiplug/ufoai_level.cpp index 544d0b9e..3a36b258 100644 --- a/contrib/ufoaiplug/ufoai_level.cpp +++ b/contrib/ufoaiplug/ufoai_level.cpp @@ -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,101 +162,27 @@ 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")); - } + snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "You should at least place 16 info_player_start"); } } - 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")); - } - } - } - - 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)) @@ -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); diff --git a/contrib/ufoaiplug/ufoai_level.h b/contrib/ufoaiplug/ufoai_level.h index b545c207..ba75bd45 100644 --- a/contrib/ufoaiplug/ufoai_level.h +++ b/contrib/ufoaiplug/ufoai_level.h @@ -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);