Changeset 196

Show
Ignore:
Timestamp:
02/24/08 07:10:49 (4 months ago)
Author:
lordhavoc
Message:

updated ufoai plugin from mattn

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • GtkRadiant/trunk/contrib/ufoaiplug/ufoai.cpp

    r153 r196  
    3333#include <gtk/gtk.h> 
    3434 
    35 #define PLUGIN_VERSION "0.2
     35#define PLUGIN_VERSION "0.4
    3636 
    3737#include "ifilter.h" 
     
    7575        { 
    7676                /*GlobalRadiant().getGameName()*/ 
    77                 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"; 
     77                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"; 
    7878        } 
    7979        const char* getCommandTitleList() 
     
    8787                { 
    8888                        GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_mainwnd), 
    89                                 "UFO:AI Plugin (http://www.ufoai.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n", "About", 
     89                                "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n", "About", 
    9090                                eMB_OK, eMB_ICONDEFAULT); 
    9191                } 
     
    102102                        filter_level(CONTENTS_LEVEL3); 
    103103                } 
    104                 else if(string_equal(command, "Worldspawn (day)")) 
    105                 { 
    106                         assign_default_values_to_worldspawn(false, true, &message); 
    107                 } 
    108                 else if(string_equal(command, "Worldspawn (night)")) 
    109                 { 
    110                         assign_default_values_to_worldspawn(false, false, &message); 
    111                 } 
    112                 else if(string_equal(command, "Worldspawn reset (day)")) 
    113                 { 
    114                         assign_default_values_to_worldspawn(true, true, &message); 
    115                 } 
    116                 else if(string_equal(command, "Worldspawn reset (night)")) 
    117                 { 
    118                         assign_default_values_to_worldspawn(true, false, &message); 
     104                else if(string_equal(command, "Worldspawn")) 
     105                { 
     106                        assign_default_values_to_worldspawn(false, &message); 
     107                } 
     108                else if(string_equal(command, "Worldspawn reset")) 
     109                { 
     110                        assign_default_values_to_worldspawn(true, &message); 
    119111                } 
    120112                else if(string_equal(command, "Perform check")) 
     
    149141                { 
    150142                        filter_actorclip(); 
     143                } 
     144                else if(string_equal(command, "WeaponClip")) 
     145                { 
     146                        filter_weaponclip(); 
     147                } 
     148                else if(string_equal(command, "NoDraw")) 
     149                { 
     150                        filter_nodraw(); 
    151151                } 
    152152 
  • GtkRadiant/trunk/contrib/ufoaiplug/ufoai_filters.cpp

    r153 r196  
    3232bool actorclip_active = false; 
    3333bool stepon_active = false; 
     34bool nodraw_active = false; 
     35bool weaponclip_active = false; 
    3436int level_active = 0; 
    3537 
     
    274276} 
    275277 
     278void filter_nodraw (void) 
     279{ 
     280        if (nodraw_active) { 
     281                nodraw_active = false; 
     282        } else { 
     283                nodraw_active = true; 
     284        } 
     285        brushlist_t brushes; 
     286        GlobalSceneGraph().traverse(BrushGetLevel(brushes, SURF_NODRAW, false, false, nodraw_active)); 
     287 
     288#ifdef _DEBUG 
     289        if (brushes.empty()) 
     290        { 
     291                globalOutputStream() << "UFO:AI: No brushes.\n"; 
     292        } 
     293        else 
     294        { 
     295                globalOutputStream() << "UFO:AI: Hiding " << Unsigned(brushes.size()) << " nodraw brushes.\n"; 
     296        } 
     297#endif 
     298} 
     299 
    276300void filter_actorclip (void) 
    277301{ 
     
    295319#endif 
    296320} 
     321 
     322void filter_weaponclip (void) 
     323{ 
     324        if (weaponclip_active) { 
     325                weaponclip_active = false; 
     326        } else { 
     327                weaponclip_active = true; 
     328        } 
     329        brushlist_t brushes; 
     330        GlobalSceneGraph().traverse(BrushGetLevel(brushes, CONTENTS_WEAPONCLIP, true, false, weaponclip_active)); 
     331 
     332#ifdef _DEBUG 
     333        if (brushes.empty()) 
     334        { 
     335                globalOutputStream() << "UFO:AI: No brushes.\n"; 
     336        } 
     337        else 
     338        { 
     339                globalOutputStream() << "UFO:AI: Hiding " << Unsigned(brushes.size()) << " weaponclip brushes.\n"; 
     340        } 
     341#endif 
     342} 
  • GtkRadiant/trunk/contrib/ufoaiplug/ufoai_filters.h

    r132 r196  
    2323void filter_stepon(void); 
    2424void filter_actorclip(void); 
     25void filter_weaponclip(void); 
     26void filter_nodraw(void); 
     27 
     28#define SURF_NODRAW 0x80 
    2529 
    2630#define CONTENTS_LEVEL8 0x8000 
     
    3337#define CONTENTS_LEVEL1 0x0100 
    3438#define CONTENTS_ACTORCLIP 0x10000 
    35  
     39#define CONTENTS_WEAPONCLIP 0x2000000 
    3640#define CONTENTS_STEPON 0x40000000 
    3741 
  • GtkRadiant/trunk/contrib/ufoaiplug/ufoai_gtk.cpp

    r135 r196  
    6868/* =============================== */ 
    6969 
    70 #define NUM_TOOLBARBUTTONS 10 
     70#define NUM_TOOLBARBUTTONS 12 
    7171 
    7272/** 
     
    106106                case 8: return "ufoai_stepon.bmp"; 
    107107                case 9: return "ufoai_actorclip.bmp"; 
     108                case 10: return "ufoai_weaponclip.bmp"; 
     109                case 11: return "ufoai_nodraw.bmp"; 
    108110                } 
    109111                return NULL; 
     
    116118                case 8: return eToggleButton; 
    117119                case 9: return eToggleButton; 
     120                case 10: return eToggleButton; 
     121                case 11: return eToggleButton; 
    118122                default: return eButton; 
    119123                } 
     
    133137                case 8: return "Stepon"; 
    134138                case 9: return "Actorclip"; 
     139                case 10: return "Weaponclip"; 
     140                case 11: return "Nodraw"; 
    135141                } 
    136142                return NULL; 
     
    150156                case 8: return "Hide stepon brushes"; 
    151157                case 9: return "Hide actorclip brushes"; 
     158                case 10: return "Hide weaponclip brushes"; 
     159                case 11: return "Hide nodraw brushes"; 
    152160                } 
    153161                return NULL; 
     
    168176                case 8: filter_stepon(); break; 
    169177                case 9: filter_actorclip(); break; 
     178                case 10: filter_weaponclip(); break; 
     179                case 11: filter_nodraw(); break; 
    170180                } 
    171181                SceneChangeNotify(); 
  • GtkRadiant/trunk/contrib/ufoaiplug/ufoai_level.cpp

    r153 r196  
    142142 
    143143/** 
    144  * @brief Some default values to worldspawn like maxlevel, maxteams and so on 
    145  */ 
    146 void assign_default_values_to_worldspawn (bool override, bool day, char **returnMsg) 
     144 * @brief Some default values to worldspawn like maxlevel and so on 
     145 */ 
     146void assign_default_values_to_worldspawn (bool override, char **returnMsg) 
    147147{ 
    148148        static char message[1024]; 
     
    163163        *str = '\0'; 
    164164 
    165         get_team_count("info_player_start", &count, &teams); 
    166  
    167         // TODO: Get highest brush - a level has 64 units 
    168         worldspawn->setKeyValue("maxlevel", "5"); 
    169  
    170         if (string_empty(worldspawn->getKeyValue("maxteams")) 
    171          || atoi(worldspawn->getKeyValue("maxteams")) != teams) 
    172         { 
    173                 snprintf(str, sizeof(str) - 1, "%i", teams); 
    174                 worldspawn->setKeyValue("maxteams", str); 
    175                 strncat(message, "Worldspawn: Set maxteams to ", sizeof(message) - 1); 
    176                 strncat(message, str, sizeof(message) - 1); 
    177                 strncat(message, "\n", sizeof(message) - 1); 
    178         } 
    179  
    180         if (day) 
    181         { 
    182                 if (override) 
    183                 { 
    184                         worldspawn->setKeyValue("light", "160"); 
    185                         worldspawn->setKeyValue("_color", "1 0.8 0.8"); 
    186                         worldspawn->setKeyValue("angles", "30 210"); 
    187                         worldspawn->setKeyValue("ambient", "0.4 0.4 0.4"); 
    188                 } 
    189                 else 
    190                 { 
    191                         if (string_empty(worldspawn->getKeyValue("light"))) 
    192                         { 
    193                                 worldspawn->setKeyValue("light", "160"); 
    194                                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient")); 
    195                         } 
    196                         if (string_empty(worldspawn->getKeyValue("_color"))) 
    197                         { 
    198                                 worldspawn->setKeyValue("_color", "1 0.8 0.8"); 
    199                                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient")); 
    200                         } 
    201                         if (string_empty(worldspawn->getKeyValue("angles"))) 
    202                         { 
    203                                 worldspawn->setKeyValue("angles", "30 210"); 
    204                                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient")); 
    205                         } 
    206                         if (string_empty(worldspawn->getKeyValue("ambient"))) 
    207                         { 
    208                                 worldspawn->setKeyValue("ambient", "0.4 0.4 0.4"); 
    209                                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient")); 
    210                         } 
    211                 } 
    212         } 
    213         else 
    214         { 
    215                 if (override) 
    216                 { 
    217                         worldspawn->setKeyValue("light", "60"); 
    218                         worldspawn->setKeyValue("_color", "0.8 0.8 1"); 
    219                         worldspawn->setKeyValue("angles", "15 60"); 
    220                         worldspawn->setKeyValue("ambient", "0.25 0.25 0.275"); 
    221                 } 
    222                 else 
    223                 { 
    224                         if (string_empty(worldspawn->getKeyValue("light"))) 
    225                         { 
    226                                 worldspawn->setKeyValue("light", "60"); 
    227                                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient")); 
    228                         } 
    229                         if (string_empty(worldspawn->getKeyValue("_color"))) 
    230                         { 
    231                                 worldspawn->setKeyValue("_color", "0.8 0.8 1"); 
    232                                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient")); 
    233                         } 
    234                         if (string_empty(worldspawn->getKeyValue("angles"))) 
    235                         { 
    236                                 worldspawn->setKeyValue("angles", "15 60"); 
    237                                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient")); 
    238                         } 
    239                         if (string_empty(worldspawn->getKeyValue("ambient"))) 
    240                         { 
    241                                 worldspawn->setKeyValue("ambient", "0.25 0.25 0.275"); 
    242                                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set ambient to: %s", worldspawn->getKeyValue("ambient")); 
    243                         } 
    244                 } 
    245         } 
    246  
    247         if (override) 
    248         { 
    249                 snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), 
    250                         "Set light to: %s\n" 
    251                         "Set _color to: %s\n" 
    252                         "Set angles to: %s\n" 
    253                         "Set ambient to: %s\n", 
    254                         worldspawn->getKeyValue("light"), 
    255                         worldspawn->getKeyValue("_color"), 
    256                         worldspawn->getKeyValue("angles"), 
    257                         worldspawn->getKeyValue("ambient") 
    258                 ); 
     165        if (override || string_empty(worldspawn->getKeyValue("maxlevel"))) 
     166        { 
     167                // TODO: Get highest brush - a level has 64 units 
     168                worldspawn->setKeyValue("maxlevel", "5"); 
     169                snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set maxlevel to: %s", worldspawn->getKeyValue("maxlevel")); 
     170        } 
     171 
     172        if (override || string_empty(worldspawn->getKeyValue("maxteams"))) 
     173        { 
     174                get_team_count("info_player_start", &count, &teams); 
     175                if (teams) 
     176                { 
     177                        snprintf(str, sizeof(str) - 1, "%i", teams); 
     178                        worldspawn->setKeyValue("maxteams", str); 
     179                        snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Set maxteams to: %s", worldspawn->getKeyValue("maxteams")); 
     180                } 
     181                if (count < 16) 
     182                { 
     183                        snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "You should at least place 16 info_player_start"); 
     184                } 
    259185        } 
    260186 
     
    308234        if (!count) 
    309235                strncat(message, "No multiplayer start positions (info_player_start)\n", sizeof(message) - 1); 
    310         else if (string_empty(worldspawn->getKeyValue("maxteams"))) 
    311         { 
    312                 snprintf(message, sizeof(message) - 1, "Worldspawn: No maxteams defined (#info_player_start) (set to: %i)\n", teams); 
    313                 snprintf(str, sizeof(str) - 1, "%i", teams); 
    314                 worldspawn->setKeyValue("maxteams", str); 
    315         } 
    316         else if (teams != atoi(worldspawn->getKeyValue("maxteams"))) 
    317                 snprintf(message, sizeof(message) - 1, "Worldspawn: Settings for maxteams (%s) doesn't match team count (%i)\n", worldspawn->getKeyValue("maxteams"), teams); 
    318236 
    319237        // singleplayer map? 
     
    322240        if (!count) 
    323241                strncat(message, "No singleplayer start positions (info_human_start)\n", sizeof(message) - 1); 
     242 
     243        // singleplayer map? 
     244        count = 0; 
     245        get_team_count("info_2x2_start", &count, NULL); 
     246        if (!count) 
     247                strncat(message, "No singleplayer start positions for 2x2 units (info_2x2_start)\n", sizeof(message) - 1); 
    324248 
    325249        // search for civilians 
     
    344268        if (ent_flags) 
    345269                snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i func_breakable with no spawnflags\n", ent_flags); 
     270        ent_flags = check_entity_flags("misc_sound", "spawnflags"); 
     271        if (ent_flags) 
     272                snprintf(&message[strlen(message)], sizeof(message) - 1 - strlen(message), "Found %i misc_sound with no spawnflags\n", ent_flags); 
    346273        ent_flags = check_entity_flags("misc_model", "spawnflags"); 
    347274        if (ent_flags) 
  • GtkRadiant/trunk/contrib/ufoaiplug/ufoai_level.h

    r132 r196  
    2020#define INCLUDED_UFOAI_LEVEL_H 
    2121 
    22 void assign_default_values_to_worldspawn (bool override, bool day, char **returnMsg); 
     22void assign_default_values_to_worldspawn (bool override, char **returnMsg); 
    2323void check_map_values (char **returnMsg); 
    2424void get_team_count (const char *classname, int *count, int *team);