Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "StdAfx.h"
+#include "misc.h"
-#include "gtkr_list.h"
+#include <list>
#include "str.h"
-#include "misc.h"
-
#include "DPoint.h"
#include "DPlane.h"
#include "DBrush.h"
#endif
#include "iundo.h"
-
-#include "refcounted_ptr.h"
+#include "ientity.h"
+#include "iscenegraph.h"
+#include "qerplugin.h"
#include <vector>
#include <list>
void ReadCurrentTexture()
{
- const char* textureName = g_FuncTable.m_pfnGetCurrentTexture();
+ const char* textureName = GlobalRadiant().TextureBrowser_getSelectedShader();
strcpy(g_CurrentTexture, textureName);
}
return buf2;
}
-void Sys_ERROR (char* text, ...)
-{
- va_list argptr;
- char buf[32768];
-
- va_start (argptr,text);
- vsprintf (buf, text,argptr);
- va_end (argptr);
-
- Sys_Printf("BobToolz::ERROR->%s", buf);
-}
-
-/*void Sys_Printf (char *text, ...)
-{
- va_list argptr;
- char buf[32768];
-
- va_start (argptr,text);
- vsprintf (buf, text,argptr);
- va_end (argptr);
-
- g_FuncTable.m_pfnSysMsg ( buf );
-}*/
char* UnixToDosPath(char* path)
{
UnixToDosPath(exename); // do we want this done in linux version?
char mapname[256];
- const char *pn = g_FuncTable.m_pfnReadProjectKey("mapspath");
+ const char *pn = GlobalRadiant().getMapsPath();
strcpy( mapname, pn );
strcat( mapname, "/ac_prt.map" );
Q_Exec( command, TRUE );
}
-void BuildMiniPrt(list<Str>* exclusionList)
+class EntityWriteMiniPrt
+{
+ mutable DEntity world;
+ FILE* pFile;
+ std::list<Str>* exclusionList;
+public:
+ EntityWriteMiniPrt(FILE* pFile, std::list<Str>* exclusionList)
+ : pFile(pFile), exclusionList(exclusionList)
+ {
+ }
+ void operator()(scene::Instance& instance) const
+ {
+ const char* classname = Node_getEntity(instance.path().top())->getKeyValue("classname");
+
+ if(!strcmp(classname, "worldspawn"))
+ {
+ world.LoadFromEntity(instance.path().top(), FALSE);
+ world.RemoveNonCheckBrushes(exclusionList, TRUE);
+ world.SaveToFile(pFile);
+ }
+ else if(strstr(classname, "info_"))
+ {
+ world.ClearBrushes();
+ world.ClearEPairs();
+ world.LoadEPairList(Node_getEntity(instance.path().top()));
+ world.SaveToFile(pFile);
+ }
+ }
+};
+
+void BuildMiniPrt(std::list<Str>* exclusionList)
{
// yes, we could just use -fulldetail option, but, as SPOG said
// it'd be faster without all the hint, donotenter etc textures and
// doors, etc
- DEntity world;
+
char buffer[128];
- const char *pn = g_FuncTable.m_pfnReadProjectKey("mapspath");
+ const char *pn = GlobalRadiant().getMapsPath();
strcpy( buffer, pn );
strcat( buffer, "/ac_prt.map" );
if(!pFile)
return;
-#if 0
- int count = g_FuncTable.m_pfnGetEntityCount();
- for(int i = 0; i < count; i++)
- {
- entity_t* ent = (entity_t*)g_FuncTable.m_pfnGetEntityHandle(i);
-
- epair_t* epl = *g_EntityTable.m_pfnGetEntityKeyValList(ent);
-
- epair_t* ep = epl;
- while(ep)
- {
- if(!strcmp(ep->key, "classname"))
- {
- if(!strcmp(ep->value, "worldspawn"))
- {
- world.LoadFromEntity(i, FALSE);
- world.RemoveNonCheckBrushes(exclusionList, TRUE);
- world.SaveToFile(pFile);
- }
- else if(strstr(ep->value, "info_"))
- {
- world.ClearBrushes();
- world.ClearEPairs();
- world.LoadEPairList(epl);
- world.SaveToFile(pFile);
- }
- break;
- }
-
- ep = ep->next;
- }
- }
-#endif
+ Scene_forEachEntity(EntityWriteMiniPrt(pFile, exclusionList));
fclose(pFile);
StartBSP();
}
-scene::Path* FindEntityFromTargetname(const char* targetname, int* entNum)
+class EntityFindByTargetName
{
-#if 0
- DEntity world;
-
- int count = g_FuncTable.m_pfnGetEntityCount();
- for(int i = 0; i < count; i++)
- {
- world.ClearEPairs();
-
- entity_s* ent = (entity_s*)g_FuncTable.m_pfnGetEntityHandle(i);
-
- world.LoadEPairList(*g_EntityTable.m_pfnGetEntityKeyValList(ent));
-
- DEPair* tn = world.FindEPairByKey("targetname");
- if(tn)
- {
- if(!stricmp(tn->value, targetname)) {
- if(entNum) {
- *entNum = i;
- }
- return ent;
- }
- }
- }
+ const char* targetname;
+public:
+ mutable const scene::Path* result;
+ EntityFindByTargetName(const char* targetname)
+ : targetname(targetname), result(0)
+ {
+ }
+ void operator()(scene::Instance& instance) const
+ {
+ if(result == 0)
+ {
+ const char* value = Node_getEntity(instance.path().top())->getKeyValue("targetname");
-#endif
- return NULL;
+ if(!strcmp(value, targetname))
+ {
+ result = &instance.path();
+ }
+ }
+ }
+};
+
+const scene::Path* FindEntityFromTargetname(const char* targetname)
+{
+ return Scene_forEachEntity(EntityFindByTargetName(targetname)).result;
}
void FillDefaultTexture(_QERFaceData* faceData, vec3_t va, vec3_t vb, vec3_t vc, const char* texture)
faceData->m_texdef.scale[1] = 0.5;
faceData->m_texdef.shift[0] = 0;
faceData->m_texdef.shift[1] = 0;
- faceData->m_texdef.contents = 0;
- faceData->m_texdef.flags = 0;
- faceData->m_texdef.value = 0;
+ faceData->contents = 0;
+ faceData->flags = 0;
+ faceData->value = 0;
if(*texture)
- faceData->m_texdef.SetName(texture);
+ faceData->m_shader = texture;
else
- faceData->m_texdef.SetName("textures/common/caulk");
+ faceData->m_shader = "textures/common/caulk";
VectorCopy(va, faceData->m_p0);
VectorCopy(vb, faceData->m_p1);
VectorCopy(vc, faceData->m_p2);
bool GetEntityCentre(const char* entity, vec3_t centre)
{
- const scene::Path* ent = FindEntityFromTargetname(entity, NULL);
+ const scene::Path* ent = FindEntityFromTargetname(entity);
if(!ent)
return FALSE;
scene::Instance& instance = *GlobalSceneGraph().find(*ent);
- VectorCopy(instance.aabb_world().origin, centre);
+ VectorCopy(instance.worldAABB().origin, centre);
return TRUE;
}
return b;
}
-void MakeNormal( vec_t* va, vec_t* vb, vec_t* vc, vec_t* out ) {
+void MakeNormal( const vec_t* va, const vec_t* vb, const vec_t* vc, vec_t* out ) {
vec3_t v1, v2;
VectorSubtract(va, vb, v1);
VectorSubtract(vc, vb, v2);
CrossProduct(v1, v2, out);
}
+
+char* GetFilename(char* buffer, const char* filename) {
+ strcpy(buffer, GlobalRadiant().getAppPath());
+ strcat(buffer, "plugins/");
+ strcat(buffer, filename);
+ return buffer;
+}
+