void gamedetect(){
// if we're inside a Nexuiz install
// default to nexuiz.game (unless the user used an option to inhibit this)
- bool nogamedetect = false;
+ //bool nogamedetect = false;
+ bool nogamedetect = true;
int i;
for ( i = 1; i < g_argc - 1; ++i )
if ( g_argv[i][0] == '-' ) {
PathsDialog g_PathsDialog;
+bool g_strEnginePath_was_empty_1st_start = false;
+
void EnginePath_verify(){
- if ( !file_exists( g_strEnginePath.c_str() ) ) {
+ if ( !file_exists( g_strEnginePath.c_str() ) || g_strEnginePath_was_empty_1st_start ) {
g_PathsDialog.Create();
g_PathsDialog.DoModal();
g_PathsDialog.Destroy();
GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) );
GlobalPreferenceSystem().registerPreference( "XZWnd", WindowPositionTrackerImportStringCaller( g_posXZWnd ), WindowPositionTrackerExportStringCaller( g_posXZWnd ) );
+ GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
+ if ( g_strEnginePath.empty() )
{
+ g_strEnginePath_was_empty_1st_start = true;
const char* ENGINEPATH_ATTRIBUTE =
#if defined( WIN32 )
"enginepath_win32"
StringOutputStream path( 256 );
path << DirectoryCleaned( g_pGameDescription->getRequiredKeyValue( ENGINEPATH_ATTRIBUTE ) );
g_strEnginePath = path.c_str();
+ GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
}
- GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
+
g_Layout_viewStyle.useLatched();
g_Layout_enableDetachableMenus.useLatched();
return MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse_Selected, filename );
}
-
class ParentSelectedBrushesToEntityWalker : public scene::Graph::Walker
{
-scene::Node& m_parent;
+ scene::Node& m_parent;
+ mutable bool m_emptyOldParent;
+
public:
-ParentSelectedBrushesToEntityWalker( scene::Node& parent ) : m_parent( parent ){
+ParentSelectedBrushesToEntityWalker( scene::Node& parent ) : m_parent( parent ), m_emptyOldParent( false ){
}
bool pre( const scene::Path& path, scene::Instance& instance ) const {
- if ( path.top().get_pointer() != &m_parent
- && Node_isPrimitive( path.top() ) ) {
+ if ( path.top().get_pointer() != &m_parent && ( Node_isPrimitive( path.top() ) || m_emptyOldParent ) ) {
Selectable* selectable = Instance_getSelectable( instance );
- if ( selectable != 0
- && selectable->isSelected()
- && path.size() > 1 ) {
+ if ( selectable && selectable->isSelected() && path.size() > 1 ) {
return false;
}
}
return true;
}
void post( const scene::Path& path, scene::Instance& instance ) const {
- if ( path.top().get_pointer() != &m_parent
- && Node_isPrimitive( path.top() ) ) {
+ if ( path.top().get_pointer() == &m_parent )
+ return;
+
+ if ( Node_isPrimitive( path.top() ) ){
+ m_emptyOldParent = false;
Selectable* selectable = Instance_getSelectable( instance );
- if ( selectable != 0
- && selectable->isSelected()
- && path.size() > 1 ) {
+
+ if ( selectable && selectable->isSelected() && path.size() > 1 ){
scene::Node& parent = path.parent();
- if ( &parent != &m_parent ) {
+ if ( &parent != &m_parent ){
NodeSmartReference node( path.top().get() );
- Node_getTraversable( parent )->erase( node );
+ scene::Traversable* traversable_parent = Node_getTraversable( parent );
+ traversable_parent->erase( node );
Node_getTraversable( m_parent )->insert( node );
+ if ( traversable_parent->empty() )
+ m_emptyOldParent = true;
}
}
}
+ else if ( m_emptyOldParent ){
+ m_emptyOldParent = false;
+ // delete empty entities
+ Entity* entity = Node_getEntity( path.top() );
+ if ( entity != 0 && path.top().get_pointer() != Map_FindWorldspawn( g_map ) && Node_getTraversable( path.top() )->empty() ) {
+ Path_deleteTop( path );
+ }
+ }
}
};
}
}
*/
-void getTextureWH( qtexture_t* tex, int *width, int *height ){
+void getTextureWH( qtexture_t* tex, int &W, int &H ){
// Don't use uniform size
- *width = (int)( tex->width * ( (float)m_textureScale / 100 ) );
- *height = (int)( tex->height * ( (float)m_textureScale / 100 ) );
+ W = (int)( tex->width * ( (float)m_textureScale / 100 ) );
+ H = (int)( tex->height * ( (float)m_textureScale / 100 ) );
if ( g_TextureBrowser_fixedSize ){
- int W = *width;
- int H = *height;
if ( W >= H ) {
// Texture is square, or wider than it is tall
if ( W >= m_uniformTextureSize ){
- *width = m_uniformTextureSize;
- *height = m_uniformTextureSize * H / W;
+ H = m_uniformTextureSize * H / W;
+ W = m_uniformTextureSize;
}
else if ( W <= m_uniformTextureMinSize ){
- *width = m_uniformTextureMinSize;
- *height = m_uniformTextureMinSize * H / W;
+ H = m_uniformTextureMinSize * H / W;
+ W = m_uniformTextureMinSize;
}
}
else {
// Texture taller than it is wide
if ( H >= m_uniformTextureSize ){
- *height = m_uniformTextureSize;
- *width = m_uniformTextureSize * W / H;
+ W = m_uniformTextureSize * W / H;
+ H = m_uniformTextureSize;
}
else if ( H <= m_uniformTextureMinSize ){
- *height = m_uniformTextureMinSize;
- *width = m_uniformTextureMinSize * W / H;
+ W = m_uniformTextureMinSize * W / H;
+ H = m_uniformTextureMinSize;
}
}
}
qtexture_t* q = current_texture;
int nWidth, nHeight;
- textureBrowser.getTextureWH( q, &nWidth, &nHeight );
+ textureBrowser.getTextureWH( q, nWidth, nHeight );
if ( layout.current_x + nWidth > textureBrowser.width - 8 && layout.current_row ) { // go to the next row unless the texture is the first on the row
layout.current_x = 8;
layout.current_y -= layout.current_row + TextureBrowser_fontHeight( textureBrowser ) + 4;
int x, y;
Texture_NextPos( textureBrowser, layout, shader->getTexture(), &x, &y );
int nWidth, nHeight;
- textureBrowser.getTextureWH( shader->getTexture(), &nWidth, &nHeight );
+ textureBrowser.getTextureWH( shader->getTexture(), nWidth, nHeight );
textureBrowser.m_nTotalHeight = std::max( textureBrowser.m_nTotalHeight, abs( layout.current_y ) + TextureBrowser_fontHeight( textureBrowser ) + nHeight + 4 );
}
}
}
int nWidth, nHeight;
- textureBrowser.getTextureWH( q, &nWidth, &nHeight );
+ textureBrowser.getTextureWH( q, nWidth, nHeight );
if ( mx > x && mx - x < nWidth
&& my < y && y - my < nHeight + TextureBrowser_fontHeight( textureBrowser ) ) {
return shader;
}
int nWidth, nHeight;
- textureBrowser.getTextureWH( q, &nWidth, &nHeight );
+ textureBrowser.getTextureWH( q, nWidth, nHeight );
if ( y != last_y ) {
last_y = y;
}
else if ( numBSPDrawVerts > numBSPDrawVertsBuffer ) {
+ bspDrawVert_t *newBspDrawVerts;
+
numBSPDrawVertsBuffer *= 3; // multiply by 1.5
numBSPDrawVertsBuffer /= 2;
- bspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer );
+ newBspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer );
- if ( !bspDrawVerts ) {
+ if ( !newBspDrawVerts ) {
+ free (bspDrawVerts);
Error( "realloc() failed (IncDrawVerts)" );
}
+
+ bspDrawVerts = newBspDrawVerts;
}
memset( bspDrawVerts + ( numBSPDrawVerts - 1 ), 0, sizeof( bspDrawVert_t ) );
}
/* error check */
- if ( front->numVerts > maxPoints || front->numVerts > maxPoints ) {
+ if ( front->numVerts > maxPoints ) {
Error( "RadClipWindingEpsilon: points exceeded estimate" );
}
- if ( front->numVerts > MAX_POINTS_ON_WINDING || front->numVerts > MAX_POINTS_ON_WINDING ) {
+ if ( front->numVerts > MAX_POINTS_ON_WINDING ) {
Error( "RadClipWindingEpsilon: MAX_POINTS_ON_WINDING" );
}
}
/* multiply by texture color */
if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, rw->verts[ samples ].st, textureColor ) ) {
VectorCopy( si->averageColor, textureColor );
- textureColor[ 4 ] = 255.0f;
+ textureColor[ 3 ] = 255.0f;
}
avgcolor = ( textureColor[ 0 ] + textureColor[ 1 ] + textureColor[ 2 ] ) / 3;
for ( i = 0; i < 3; i++ )
/* multiply by texture color */
if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, st, textureColor ) ) {
VectorCopy( si->averageColor, textureColor );
- textureColor[ 4 ] = 255;
+ textureColor[ 3 ] = 255;
}
avgcolor = ( textureColor[ 0 ] + textureColor[ 1 ] + textureColor[ 2 ] ) / 3;
for ( l = 0; l < 3; l++ ){
/* allocate LIGHTMAP_RESERVE_COUNT new output lightmaps */
numOutLightmaps += LIGHTMAP_RESERVE_COUNT;
olm = safe_malloc( numOutLightmaps * sizeof( outLightmap_t ) );
+ if ( !olm ){
+ Error( "FindOutLightmaps: Failed to allocate memory.\n" );
+ }
+
if ( outLightmaps != NULL && numOutLightmaps > LIGHTMAP_RESERVE_COUNT ) {
memcpy( olm, outLightmaps, ( numOutLightmaps - LIGHTMAP_RESERVE_COUNT ) * sizeof( outLightmap_t ) );
free( outLightmaps );
sun_t *sun; /* ydnar */
vec3_t color; /* normalized color */
- vec3_t averageColor;
+ vec4_t averageColor;
byte lightStyle;
/* vortex: per-surface floodlight */
if ( VectorLength( si->color ) <= 0.0f ) {
ColorNormalize( color, si->color );
VectorScale( color, ( 1.0f / count ), si->averageColor );
+ si->averageColor[ 3 ] = color[ 3 ] / count;
}
else
{
VectorCopy( si->color, si->averageColor );
+ si->averageColor[ 3 ] = 1.0f;
}
}
typedef struct edge_s
{
- vec3_t origin, edge;
+ vec3_t origin;
+ vec4_t edge;
vec_t length, kingpinLength;
int kingpin;
vec4_t plane;