- Updated UFA:Plugin (mattn2)

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@153 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
namespace 2007-03-07 18:42:05 +00:00
parent 5dd408d91d
commit 0e5bc042fe
4 changed files with 81 additions and 7 deletions

View File

@ -1,6 +1,10 @@
This is the changelog for developers, != changelog for the end user This is the changelog for developers, != changelog for the end user
that we distribute with the binaries. (see changelog) that we distribute with the binaries. (see changelog)
07/03/2007
namespace
- Updated UFA:Plugin (mattn2)
04/03/2007 04/03/2007
namespace namespace
- Reverted Q3 translucency fix since it randomly made brushes - Reverted Q3 translucency fix since it randomly made brushes

View File

@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <gtk/gtk.h> #include <gtk/gtk.h>
#define PLUGIN_VERSION "0.1" #define PLUGIN_VERSION "0.2"
#include "ifilter.h" #include "ifilter.h"
#include "ibrush.h" #include "ibrush.h"
@ -86,7 +86,7 @@ namespace UFOAI
if(string_equal(command, "About")) if(string_equal(command, "About"))
{ {
GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(g_mainwnd), 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); eMB_OK, eMB_ICONDEFAULT);
} }
else if(string_equal(command, "Level 1")) else if(string_equal(command, "Level 1"))

View File

@ -206,8 +206,10 @@ void filter_level(int flag)
if (level_active) if (level_active)
{ {
GlobalSceneGraph().traverse(BrushGetLevel(brushes, (level_active << 8), true, true, false)); 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("func_breakable", entities, level_active, false));
GlobalSceneGraph().traverse(EntityFindByName("misc_model", 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()); entities.erase(entities.begin(), entities.end());
brushes.erase(brushes.begin(), brushes.end()); brushes.erase(brushes.begin(), brushes.end());
if (level_active == level) if (level_active == level)
@ -224,8 +226,10 @@ void filter_level(int flag)
GlobalSceneGraph().traverse(BrushGetLevel(brushes, flag, true, true, true)); GlobalSceneGraph().traverse(BrushGetLevel(brushes, flag, true, true, true));
// now all entities // now all entities
GlobalSceneGraph().traverse(EntityFindByName("func_door", entities, level, true));
GlobalSceneGraph().traverse(EntityFindByName("func_breakable", entities, level, true)); GlobalSceneGraph().traverse(EntityFindByName("func_breakable", entities, level, true));
GlobalSceneGraph().traverse(EntityFindByName("misc_model", entities, level, true)); GlobalSceneGraph().traverse(EntityFindByName("misc_model", entities, level, true));
GlobalSceneGraph().traverse(EntityFindByName("misc_particle", entities, level, true));
#ifdef _DEBUG #ifdef _DEBUG
if (brushes.empty()) if (brushes.empty())
@ -237,7 +241,7 @@ void filter_level(int flag)
globalOutputStream() << "UFO:AI: Found " << Unsigned(brushes.size()) << " brushes.\n"; 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()) if (entities.empty())
{ {
globalOutputStream() << "UFO:AI: No entities.\n"; globalOutputStream() << "UFO:AI: No entities.\n";

View File

@ -65,6 +65,36 @@ Entity* Scene_FindEntityByClass(const char* name)
return entity; 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 * @brief finds start positions
*/ */
@ -235,9 +265,22 @@ void assign_default_values_to_worldspawn (bool override, bool day, char **return
*returnMsg = message; *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 * @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 * @todo: check for maxlevel
*/ */
void check_map_values (char **returnMsg) void check_map_values (char **returnMsg)
@ -245,6 +288,7 @@ void check_map_values (char **returnMsg)
static char message[1024]; static char message[1024];
int count = 0; int count = 0;
int teams = 0; int teams = 0;
int ent_flags;
Entity* worldspawn; Entity* worldspawn;
char str[64]; char str[64];
@ -292,9 +336,31 @@ void check_map_values (char **returnMsg)
strncat(message, "Worldspawn: Highest maxlevel is 8\n", sizeof(message) - 1); strncat(message, "Worldspawn: Highest maxlevel is 8\n", sizeof(message) - 1);
worldspawn->setKeyValue("maxlevel", "8"); worldspawn->setKeyValue("maxlevel", "8");
} }
// no errors - no warnings
if (!strlen(message)) ent_flags = check_entity_flags("func_door", "spawnflags");
return; 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; *returnMsg = message;
} }