X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=contrib%2Fbobtoolz%2Fmisc.cpp;h=b1929f3858a3eab93c0339947240dde475eac76a;hb=48410b113dd2036e69dbf723a39ec9af02fc9b12;hp=f793bcc426e52b22f12d05d0a88e07e4601fb569;hpb=12b372f89ce109a4db9d510884fbe7d05af79870;p=xonotic%2Fnetradiant.git diff --git a/contrib/bobtoolz/misc.cpp b/contrib/bobtoolz/misc.cpp index f793bcc4..b1929f38 100644 --- a/contrib/bobtoolz/misc.cpp +++ b/contrib/bobtoolz/misc.cpp @@ -19,18 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "StdAfx.h" -#include "gtkr_list.h" -#include "str.h" - -#include "misc.h" - -#include "DPoint.h" -#include "DPlane.h" -#include "DBrush.h" -#include "DEPair.h" -#include "DPatch.h" #include "DEntity.h" - #include "funchandlers.h" #ifdef __linux__ @@ -38,17 +27,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #endif -#include "iundo.h" - -#include "refcounted_ptr.h" - -#include -#include -#include -#include - -#include "scenelib.h" - /*========================== Global Vars ==========================*/ @@ -71,6 +49,16 @@ const char* GetCurrentTexture() return g_CurrentTexture; } +epair_t* GetNextChainItem(epair_t* lastItem, const char* key, const char* value) +{ + epair_t* nextEPair = g_FuncTable.m_pfnAllocateEpair(key, value); + + if(lastItem != NULL) + lastItem->next = nextEPair; + + return nextEPair; +} + void MoveBlock(int dir, vec3_t min, vec3_t max, float dist) { switch(dir) @@ -129,7 +117,7 @@ void SetInitialStairPos(int dir, vec3_t min, vec3_t max, float width) } } -char* TranslateString (char *buf) +char* TranslateString (const char *buf) { static char buf2[32768]; int i, l; @@ -152,7 +140,7 @@ char* TranslateString (char *buf) return buf2; } -void Sys_ERROR (char* text, ...) +void Sys_ERROR (const char* text, ...) { va_list argptr; char buf[32768]; @@ -178,7 +166,7 @@ void Sys_ERROR (char* text, ...) char* UnixToDosPath(char* path) { -#ifndef WIN32 +#ifndef _WIN32 return path; #else for(char* p = path; *p; p++) @@ -192,7 +180,7 @@ char* UnixToDosPath(char* path) const char* ExtractFilename(const char* path) { - char* p = strrchr(path, '/'); + const char* p = strrchr(path, '/'); if(!p) { p = strrchr(path, '\\'); @@ -203,7 +191,7 @@ const char* ExtractFilename(const char* path) return ++p; } -extern char* PLUGIN_NAME; +extern const char* PLUGIN_NAME; /*char* GetGameFilename(char* buffer, const char* filename) { strcpy(buffer, g_FuncTable.m_pfnGetGamePath()); @@ -241,12 +229,7 @@ bool Q_Exec( const char *pCmd, bool bCreateConsole ) } #endif -#include - -#ifdef WIN32 - -#include - +#ifdef _WIN32 bool Q_Exec( const char *pCmd, bool bCreateConsole ) { // G_DeWan: Don't know if this is needed for linux version @@ -276,9 +259,9 @@ void StartBSP() GetFilename(exename, "q3map"); UnixToDosPath(exename); // do we want this done in linux version? - char mapname[256]; + char mapname[256]; const char *pn = g_FuncTable.m_pfnReadProjectKey("mapspath"); - + strcpy( mapname, pn ); strcat( mapname, "/ac_prt.map" ); UnixToDosPath(mapname); @@ -296,7 +279,7 @@ void BuildMiniPrt(list* exclusionList) // doors, etc DEntity world; - + char buffer[128]; const char *pn = g_FuncTable.m_pfnReadProjectKey("mapspath"); @@ -308,8 +291,7 @@ void BuildMiniPrt(list* exclusionList) if(!pFile) return; -#if 0 - int count = g_FuncTable.m_pfnGetEntityCount(); + int count = g_FuncTable.m_pfnGetEntityCount(); for(int i = 0; i < count; i++) { entity_t* ent = (entity_t*)g_FuncTable.m_pfnGetEntityHandle(i); @@ -340,16 +322,14 @@ void BuildMiniPrt(list* exclusionList) ep = ep->next; } } -#endif fclose(pFile); StartBSP(); } -scene::Path* FindEntityFromTargetname(const char* targetname, int* entNum) +entity_s* FindEntityFromTargetname(const char* targetname, int* entNum) { -#if 0 DEntity world; int count = g_FuncTable.m_pfnGetEntityCount(); @@ -372,28 +352,27 @@ scene::Path* FindEntityFromTargetname(const char* targetname, int* entNum) } } } - -#endif return NULL; } void FillDefaultTexture(_QERFaceData* faceData, vec3_t va, vec3_t vb, vec3_t vc, const char* texture) { - faceData->m_texdef.rotate = 0; - faceData->m_texdef.scale[0] = 0.5; - 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->m_bBPrimit = FALSE; + faceData->m_fRotate = 0; + faceData->m_fScale[0] = 0.5; + faceData->m_fScale[1] = 0.5; + faceData->m_fShift[0] = 0; + faceData->m_fShift[1] = 0; + faceData->m_nContents = 0; + faceData->m_nFlags = 0; + faceData->m_nValue = 0; if(*texture) - faceData->m_texdef.SetName(texture); + strcpy(faceData->m_TextureName, texture); else - faceData->m_texdef.SetName("textures/common/caulk"); - VectorCopy(va, faceData->m_p0); - VectorCopy(vb, faceData->m_p1); - VectorCopy(vc, faceData->m_p2); + strcpy(faceData->m_TextureName, "textures/common/caulk"); + VectorCopy(va, faceData->m_v1); + VectorCopy(vb, faceData->m_v2); + VectorCopy(vc, faceData->m_v3); } float Determinant3x3(float a1, float a2, float a3, @@ -405,13 +384,28 @@ float Determinant3x3(float a1, float a2, float a3, bool GetEntityCentre(const char* entity, vec3_t centre) { - const scene::Path* ent = FindEntityFromTargetname(entity, NULL); + entity_s* ent = FindEntityFromTargetname(entity, NULL); if(!ent) return FALSE; - scene::Instance& instance = *GlobalSceneGraph().find(*ent); - VectorCopy(instance.aabb_world().origin, centre); + int cnt = g_FuncTable.m_pfnAllocateEntityBrushHandles(ent); + if(cnt == 0) + { + g_FuncTable.m_pfnReleaseEntityBrushHandles(); + return FALSE; + } + + brush_t* brush = (brush_t*)g_FuncTable.m_pfnGetEntityBrushHandle(0); + DBrush cBrush; + cBrush.LoadFromBrush_t(brush, FALSE); + + vec3_t min, max; + cBrush.GetBounds(min, max); + + VectorAdd(min, max, centre); + VectorScale(centre, 0.5f, centre); + g_FuncTable.m_pfnReleaseEntityBrushHandles(); return TRUE; }