コード例 #1
0
int main (int argc, char **argv)
{
	int			i;
	double		time, oldtime;

	PrintVersion();

	if (argc > 1)
	{
		for (i = 1; i < argc; i++)
		{
			if ( !(strcmp(argv[i], "-v")) || !(strcmp(argv[i], "-version" )) ||
				  !(strcmp(argv[i], "--version")) )
			{
				exit(0);
			}
			else if ( !(strcmp(argv[i], "-h")) || !(strcmp(argv[i], "-help" )) ||
				  !(strcmp(argv[i], "--help")) || !(strcmp(argv[i], "-?")) )
			{
				PrintHelp(argv[0]);
				exit (0);
			}
		}
	}

	memset (cwd, 0, sizeof(cwd));
	if (Sys_GetBasedir(argv[0], cwd, sizeof(cwd)) != 0)
		Sys_Error ("Couldn't determine current directory");

	/* initialize the host params */
	memset (&parms, 0, sizeof(parms));
	parms.basedir = cwd;
	parms.userdir = cwd;	/* no userdir on win32 */
	parms.argc = argc;
	parms.argv = argv;
	host_parms = &parms;

	LOG_Init (&parms);

	Sys_Printf("basedir is: %s\n", parms.basedir);
	Sys_Printf("userdir is: %s\n", parms.userdir);

	COM_ValidateByteorder ();

	parms.memsize = STD_MEM_ALLOC;

	i = COM_CheckParm ("-heapsize");
	if (i && i < com_argc-1)
	{
		parms.memsize = atoi (com_argv[i+1]) * 1024;

		if ((parms.memsize > MAX_MEM_ALLOC) && !(COM_CheckParm ("-forcemem")))
		{
			Sys_Printf ("Requested memory (%d Mb) too large, using the default maximum.\n", parms.memsize/(1024*1024));
			Sys_Printf ("If you are sure, use the -forcemem switch.\n");
			parms.memsize = MAX_MEM_ALLOC;
		}
		else if ((parms.memsize < MIN_MEM_ALLOC) && !(COM_CheckParm ("-forcemem")))
		{
			Sys_Printf ("Requested memory (%d Mb) too little, using the default minimum.\n", parms.memsize/(1024*1024));
			Sys_Printf ("If you are sure, use the -forcemem switch.\n");
			parms.memsize = MIN_MEM_ALLOC;
		}
	}

	parms.membase = malloc (parms.memsize);

	if (!parms.membase)
		Sys_Error ("Insufficient memory.\n");

	timeBeginPeriod (1);	/* 1 ms timer precision */
	starttime = timeGetTime ();

	Host_Init();

	oldtime = Sys_DoubleTime ();

	/* main window message loop */
	while (1)
	{
		time = Sys_DoubleTime ();

		if (time - oldtime < sys_ticrate.value )
		{
			Sleep (1);
			continue;
		}

		Host_Frame (time - oldtime);
		oldtime = time;
	}

	return 0;
}
コード例 #2
0
ファイル: prtview.cpp プロジェクト: thewolfteam/GtkRadiant
extern "C" void QERPlug_Dispatch( const char* p, vec3_t vMin, vec3_t vMax, bool bSingleBrush ){
	Sys_Printf( MSG_PREFIX "Command \"%s\"\n",p );

	if ( !strcmp( p,Q3R_CMD_ABOUT ) ) {
		DoAboutDlg( GTK_WIDGET( g_pMainWidget ) );
	}
	else if ( !strcmp( p,Q3R_CMD_LOAD ) ) {
		CheckInterfaces();

		if ( interfaces_started ) {
			if ( DoLoadPortalFileDialog( GTK_WIDGET( g_pMainWidget ) ) == IDOK ) {
				portals.Load();
				g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
			}
			else
			{
				Sys_Printf( MSG_PREFIX "Portal file load aborted.\n", portals.fn );
			}
		}
	}
	else if ( !strcmp( p,Q3R_CMD_RELEASE ) ) {
		portals.Purge();

		if ( interfaces_started ) {
			g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
		}

		Sys_Printf( MSG_PREFIX "Portals unloaded.\n" );
	}
	else if ( !strcmp( p,Q3R_CMD_SHOW_2D ) ) {
		portals.show_2d = !portals.show_2d;

		if ( interfaces_started ) {
			g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
		}
		SaveConfig();

		if ( portals.show_2d ) {
			Sys_Printf( MSG_PREFIX "Portals will be rendered in 2D view.\n" );
		}
		else{
			Sys_Printf( MSG_PREFIX "Portals will NOT be rendered in 2D view.\n" );
		}
	}
	else if ( !strcmp( p,Q3R_CMD_SHOW_3D ) ) {
		portals.show_3d = !portals.show_3d;
		SaveConfig();

		if ( interfaces_started ) {
			g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
		}

		if ( portals.show_3d ) {
			Sys_Printf( MSG_PREFIX "Portals will be rendered in 3D view.\n" );
		}
		else{
			Sys_Printf( MSG_PREFIX "Portals will NOT be rendered in 3D view.\n" );
		}
	}
	else if ( !strcmp( p,Q3R_CMD_OPTIONS ) ) {
		DoConfigDialog( GTK_WIDGET( g_pMainWidget ) );
		SaveConfig();

		if ( interfaces_started ) {
			g_FuncTable.m_pfnSysUpdateWindows( UPDATE_ALL );
		}
	}
}
コード例 #3
0
ファイル: host_cmd.c プロジェクト: EIREXE/Quakeforge-gcw0
static void
Host_Loadgame_f (void)
{
	dstring_t  *name = 0;
	QFile      *f;
	char       *mapname = 0;
	script_t   *script = 0;
	plitem_t   *game = 0;
	plitem_t   *list;
	plitem_t   *item;
	char       *script_data = 0;
	int         i;
	int         entnum;
	int         count;
	int         version;
	float       spawn_parms[NUM_SPAWN_PARMS];

	if (cmd_source != src_command)
		goto end;

	if (Cmd_Argc () != 2) {
		Sys_Printf ("load <savename> : load a game\n");
		goto end;
	}

	cls.demonum = -1;					// stop demo loop in case this fails

	name = dstring_newstr ();
	dsprintf (name, "%s/%s", qfs_gamedir->dir.def, Cmd_Argv (1));
	QFS_DefaultExtension (name, ".sav");

	cl.loading = true;
	CL_UpdateScreen (cl.time);

	Sys_Printf ("Loading game from %s...\n", name->str);
	f = QFS_Open (name->str, "rz");
	if (!f) {
		Sys_Printf ("ERROR: couldn't open.\n");
		goto end;
	}
	script_data = malloc (Qfilesize (f) + 1);
	i = Qread (f, script_data, Qfilesize (f));
	script_data[i] = 0;
	Qclose (f);

	script = Script_New ();
	script->single = "";		// disable {}()': lexing
	Script_Start (script, name->str, script_data);

	Script_GetToken (script, 1);
	if (strequal (script->token->str, PACKAGE_NAME)) {
		if (!Script_TokenAvailable (script, 1)) {
			Sys_Printf ("Unexpected EOF reading %s\n", name->str);
			goto end;
		}
		game = PL_GetPropertyList (script->p);
	} else {
		sscanf (script->token->str, "%i", &version);
		if (version != SAVEGAME_VERSION) {
			Sys_Printf ("Savegame is version %i, not %i\n", version,
						SAVEGAME_VERSION);
			goto end;
		}
		game = convert_to_game_dict (script);
	}

	item = PL_ObjectForKey (game, "spawn_parms");
	for (i = 0; i < NUM_SPAWN_PARMS; i++) {
		if (i >= PL_A_NumObjects (item))
			break;
		spawn_parms[i] = atof (PL_String (PL_ObjectAtIndex (item, i)));
	}
	current_skill = atoi (PL_String (PL_ObjectForKey (game, "current_skill")));
	Cvar_SetValue (skill, current_skill);
	mapname = strdup (PL_String (PL_ObjectForKey (game, "name")));

	CL_Disconnect_f ();

	SV_SpawnServer (mapname);
	if (!sv.active) {
		Sys_Printf ("Couldn't load map %s\n", mapname);
		goto end;
	}
	sv.paused = true;					// pause until all clients connect
	sv.loadgame = true;

	list = PL_ObjectForKey (game, "lightstyles");
	for (i = 0; i < MAX_LIGHTSTYLES; i++) {
		const char *style;
		char       *str;
		if (i >= PL_A_NumObjects (list))
			break;
		item = PL_ObjectAtIndex (list, i);
		style = PL_String (item);
		sv.lightstyles[i] = str = Hunk_Alloc (strlen (style) + 1);
		strcpy (str, style);
	}

	ED_InitGlobals (&sv_pr_state, PL_ObjectForKey (game, "globals"));

	list = PL_ObjectForKey (game, "entities");
	entnum = 0;
	count = PL_A_NumObjects (list);
	if (count > sv.max_edicts)
		Host_Error ("too many entities in saved game. adjust max_edicts\n");
	for (entnum = 0; entnum < count; entnum++) {
		plitem_t   *entity = PL_ObjectAtIndex (list, entnum);
		edict_t    *ent = EDICT_NUM (&sv_pr_state, entnum);

		memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
		ent->free = false;
		ED_InitEntity (&sv_pr_state, entity, ent);

		// link it into the bsp tree
		if (!ent->free)
			SV_LinkEdict (ent, false);
	}

	sv.num_edicts = entnum;
	sv.time = atof (PL_String (PL_ObjectForKey (game, "time")));

	for (i = 0; i < NUM_SPAWN_PARMS; i++)
		svs.clients->spawn_parms[i] = spawn_parms[i];

	if (cls.state != ca_dedicated) {
		CL_EstablishConnection ("local");
		Host_Reconnect_f ();
	}
end:
	if (game)
		PL_Free (game);
	if (mapname)
		free (mapname);
	if (script)
		Script_Delete (script);
	if (script_data)
		free (script_data);
	if (name)
		dstring_delete (name);
}
コード例 #4
0
ファイル: conproc.cpp プロジェクト: jlecorre/hlinvasion
/*
==============
InitConProc

==============
*/   
void InitConProc ( void )
{
	unsigned	threadAddr;
	HANDLE		hFile			= (HANDLE)0;
	HANDLE		heventParent	= (HANDLE)0;
	HANDLE		heventChild		= (HANDLE)0;
	int			WantHeight = 50;
	char		*p;

	// give external front ends a chance to hook into the console
	if ( CheckParm ( "-HFILE", &p ) && p )
	{
		hFile = (HANDLE)atoi ( p );
	}

	if ( CheckParm ( "-HPARENT", &p ) && p )
	{
		heventParent = (HANDLE)atoi ( p );
	}

	if ( CheckParm ( "-HCHILD", &p ) && p )
	{
		heventChild = (HANDLE)atoi ( p );
	}

	// ignore if we don't have all the events.
	if ( !hFile || !heventParent || !heventChild )
	{
		//Sys_Printf ("\n\nNo external front end present.\n" );
		return;
	}

	Sys_Printf( "\n\nInitConProc:  Setting up external control.\n" );

	hfileBuffer			= hFile;
	heventParentSend	= heventParent;
	heventChildSend		= heventChild;

	// So we'll know when to go away.
	heventDone = CreateEvent (NULL, FALSE, FALSE, NULL);
	if (!heventDone)
	{
		Sys_Printf ("InitConProc:  Couldn't create heventDone\n");
		return;
	}

	if (!_beginthreadex (NULL, 0, RequestProc, NULL, 0, &threadAddr))
	{
		CloseHandle (heventDone);
		Sys_Printf ("InitConProc:  Couldn't create third party thread\n");
		return;
	}

	// save off the input/output handles.
	hStdout	= GetStdHandle (STD_OUTPUT_HANDLE);
	hStdin	= GetStdHandle (STD_INPUT_HANDLE);

	if ( CheckParm( "-conheight", &p ) && p )
	{
		WantHeight = atoi( p );
	}

	// Force 80 character width, at least 25 character height
	SetConsoleCXCY( hStdout, 80, WantHeight );
}
コード例 #5
0
ファイル: vis.c プロジェクト: Teivaz/nebula2
/*
===========
VisMain
===========
*/
int VisMain (int argc, char **argv)
{
    char        portalfile[1024];
    int            i;
    
    
    /* note it */
    Sys_Printf( "--- Vis ---\n" );
    
    /* process arguments */
    for (i=1 ; i < (argc - 1) ; i++)
    {
        if (!strcmp(argv[i], "-fast")) {
            Sys_Printf ("fastvis = true\n");
            fastvis = qtrue;
        } else if (!strcmp(argv[i], "-merge")) {
            Sys_Printf ("merge = true\n");
            mergevis = qtrue;
        } else if (!strcmp(argv[i], "-nopassage")) {
            Sys_Printf ("nopassage = true\n");
            noPassageVis = qtrue;
        } else if (!strcmp(argv[i], "-passageOnly")) {
            Sys_Printf ("passageOnly = true\n");
            passageVisOnly = qtrue;
        } else if (!strcmp (argv[i],"-nosort")) {
            Sys_Printf ("nosort = true\n");
            nosort = qtrue;
        } else if (!strcmp (argv[i],"-saveprt")) {
            Sys_Printf ("saveprt = true\n");
            saveprt = qtrue;
        } else if (!strcmp (argv[i],"-tmpin")) {
            strcpy (inbase, "/tmp");
        } else if (!strcmp (argv[i],"-tmpout")) {
            strcpy (outbase, "/tmp");
        }
        
    
        /* ydnar: -hint to merge all but hint portals */
        else if( !strcmp( argv[ i ], "-hint" ) )
        {
            Sys_Printf( "hint = true\n" );
            hint = qtrue;
            mergevis = qtrue;
        }
        
        else
            Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
    }

    if( i != argc - 1 )
        Error( "usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile" );
    

    /* load the bsp */
    sprintf( source, "%s%s", inbase, ExpandArg( argv[ i ] ) );
    StripExtension( source );
    strcat( source, ".bsp" );
    Sys_Printf( "Loading %s\n", source );
    LoadBSPFile( source );
    
    /* load the portal file */
    sprintf( portalfile, "%s%s", inbase, ExpandArg( argv[ i ] ) );
    StripExtension( portalfile );
    strcat( portalfile, ".prt" );
    Sys_Printf( "Loading %s\n", portalfile );
    LoadPortals( portalfile );
    
    /* ydnar: exit if no portals, hence no vis */
    if( numportals == 0 )
    {
        Sys_Printf( "No portals means no vis, exiting.\n" );
        return 0;
    }
    
    /* ydnar: for getting far plane */
    ParseEntities();
    
    if( mergevis )
    {
        MergeLeaves();
        MergeLeafPortals();
    }
    
    CountActivePortals();
    /* WritePortals( "maps/hints.prs" );*/
    
    Sys_Printf( "visdatasize:%i\n", numBSPVisBytes );
    
    CalcVis();
    
    /* delete the prt file */
    if( !saveprt )
        remove( portalfile );

    /* write the bsp file */
    Sys_Printf( "Writing %s\n", source );
    WriteBSPFile( source );

    return 0;
}
コード例 #6
0
ファイル: fog.c プロジェクト: kimsama/minimangalore
void SplitMeshByPlane( mesh_t *in, vec3_t normal, float dist, mesh_t **front, mesh_t **back )
{
    int        w, h, split;
    float    d[MAX_PATCH_SIZE][MAX_PATCH_SIZE];
    bspDrawVert_t    *dv, *v1, *v2;
    int        c_front, c_back, c_on;
    mesh_t    *f, *b;
    int        i;
    float    frac;
    int        frontAprox, backAprox;

    for ( i = 0 ; i < 2 ; i++ ) {
        dv = in->verts;
        c_front = 0;
        c_back = 0;
        c_on = 0;
        for ( h = 0 ; h < in->height ; h++ ) {
            for ( w = 0 ; w < in->width ; w++, dv++ ) {
                d[h][w] = DotProduct( dv->xyz, normal ) - dist;
                if ( d[h][w] > ON_EPSILON ) {
                    c_front++;
                } else if ( d[h][w] < -ON_EPSILON ) {
                    c_back++;
                } else {
                    c_on++;
                }
            }
        }

        *front = NULL;
        *back = NULL;

        if ( !c_front ) {
            *back = in;
            return;
        }
        if ( !c_back ) {
            *front = in;
            return;
        }

        // find a split point
        split = -1;
        for ( w = 0 ; w < in->width -1 ; w++ ) {
            if ( ( d[0][w] < 0 ) != ( d[0][w+1] < 0 ) ) {
                if ( split == -1 ) {
                    split = w;
                    break;
                }
            }
        }

        if ( split == -1 ) {
            if ( i == 1 ) {
                Sys_FPrintf (SYS_VRB, "No crossing points in patch\n");
                *front = in;
                return;
            }

            in = TransposeMesh( in );
            InvertMesh( in );
            continue;
        }

        // make sure the split point stays the same for all other rows
        for ( h = 1 ; h < in->height ; h++ ) {
            for ( w = 0 ; w < in->width -1 ; w++ ) {
                if ( ( d[h][w] < 0 ) != ( d[h][w+1] < 0 ) ) {
                    if ( w != split ) {
                        Sys_Printf( "multiple crossing points for patch -- can't clip\n");
                        *front = in;
                        return;
                    }
                }
            }
            if ( ( d[h][split] < 0 ) == ( d[h][split+1] < 0 ) ) {
                Sys_Printf( "differing crossing points for patch -- can't clip\n");
                *front = in;
                return;
            }
        }

        break;
    }


    // create two new meshes
    f = safe_malloc( sizeof( *f ) );
    f->width = split + 2;
    if ( ! (f->width & 1) ) {
        f->width++;
        frontAprox = 1;
    } else {
        frontAprox = 0;
    }
    if ( f->width > MAX_PATCH_SIZE ) {
        Error( "MAX_PATCH_SIZE after split");
    }
    f->height = in->height;
    f->verts = safe_malloc( sizeof(f->verts[0]) * f->width * f->height );

    b = safe_malloc( sizeof( *b ) );
    b->width = in->width - split;
    if ( ! (b->width & 1) ) {
        b->width++;
        backAprox = 1;
    } else {
        backAprox = 0;
    }
    if ( b->width > MAX_PATCH_SIZE ) {
        Error( "MAX_PATCH_SIZE after split");
    }
    b->height = in->height;
    b->verts = safe_malloc( sizeof(b->verts[0]) * b->width * b->height );

    if ( d[0][0] > 0 ) {
        *front = f;
        *back = b;
    } else {
        *front = b;
        *back = f;
    }

    // distribute the points
    for ( w = 0 ; w < in->width ; w++ ) {
        for ( h = 0 ; h < in->height ; h++ ) {
            if ( w <= split ) {
                f->verts[ h * f->width + w ] = in->verts[ h * in->width + w ];
            } else {
                b->verts[ h * b->width + w - split + backAprox ] = in->verts[ h * in->width + w ];
            }
        }
    }

    // clip the crossing line
    for ( h = 0; h < in->height; h++ )
    {
        dv = &f->verts[ h * f->width + split + 1 ];
        v1 = &in->verts[ h * in->width + split ];
        v2 = &in->verts[ h * in->width + split + 1 ];

        frac = d[h][split] / ( d[h][split] - d[h][split+1] );
        
        /* interpolate */
        //%    for( i = 0; i < 10; i++ )
        //%        dv->xyz[ i ] = v1->xyz[ i ] + frac * (v2->xyz[ i ] - v1->xyz[ i ]);
        //%    dv->xyz[10] = 0;    // set all 4 colors to 0 
        LerpDrawVertAmount( v1, v2, frac, dv );
        
        if ( frontAprox ) {
            f->verts[ h * f->width + split + 2 ] = *dv;
        }
        b->verts[ h * b->width ] = *dv;
        if ( backAprox ) {
            b->verts[ h * b->width + 1 ] = *dv;
        }
    }

    /*
PrintMesh( in );
Sys_Printf("\n");
PrintMesh( f );
Sys_Printf("\n");
PrintMesh( b );
Sys_Printf("\n");
    */

    FreeMesh( in );
}
コード例 #7
0
ファイル: bsp_scale.c プロジェクト: Elzair/q3map2
static void ExtrapolateTexcoords( const float *axyz, const float *ast, const float *bxyz, const float *bst, const float *cxyz, const float *cst, const float *axyz_new, float *ast_out, const float *bxyz_new, float *bst_out, const float *cxyz_new, float *cst_out ){
	vec4_t scoeffs, tcoeffs;
	float md;
	m4x4_t solvematrix;

	vec3_t norm;
	vec3_t dab, dac;
	VectorSubtract( bxyz, axyz, dab );
	VectorSubtract( cxyz, axyz, dac );
	CrossProduct( dab, dac, norm );

	// assume:
	//   s = f(x, y, z)
	//   s(v + norm) = s(v) when n ortho xyz

	// s(v) = DotProduct(v, scoeffs) + scoeffs[3]

	// solve:
	//   scoeffs * (axyz, 1) == ast[0]
	//   scoeffs * (bxyz, 1) == bst[0]
	//   scoeffs * (cxyz, 1) == cst[0]
	//   scoeffs * (norm, 0) == 0
	// scoeffs * [axyz, 1 | bxyz, 1 | cxyz, 1 | norm, 0] = [ast[0], bst[0], cst[0], 0]
	solvematrix[0] = axyz[0];
	solvematrix[4] = axyz[1];
	solvematrix[8] = axyz[2];
	solvematrix[12] = 1;
	solvematrix[1] = bxyz[0];
	solvematrix[5] = bxyz[1];
	solvematrix[9] = bxyz[2];
	solvematrix[13] = 1;
	solvematrix[2] = cxyz[0];
	solvematrix[6] = cxyz[1];
	solvematrix[10] = cxyz[2];
	solvematrix[14] = 1;
	solvematrix[3] = norm[0];
	solvematrix[7] = norm[1];
	solvematrix[11] = norm[2];
	solvematrix[15] = 0;

	md = m4_det( solvematrix );
	if ( md * md < 1e-10 ) {
		Sys_Printf( "Cannot invert some matrix, some texcoords aren't extrapolated!" );
		return;
	}

	m4x4_invert( solvematrix );

	scoeffs[0] = ast[0];
	scoeffs[1] = bst[0];
	scoeffs[2] = cst[0];
	scoeffs[3] = 0;
	m4x4_transform_vec4( solvematrix, scoeffs );
	tcoeffs[0] = ast[1];
	tcoeffs[1] = bst[1];
	tcoeffs[2] = cst[1];
	tcoeffs[3] = 0;
	m4x4_transform_vec4( solvematrix, tcoeffs );

	ast_out[0] = scoeffs[0] * axyz_new[0] + scoeffs[1] * axyz_new[1] + scoeffs[2] * axyz_new[2] + scoeffs[3];
	ast_out[1] = tcoeffs[0] * axyz_new[0] + tcoeffs[1] * axyz_new[1] + tcoeffs[2] * axyz_new[2] + tcoeffs[3];
	bst_out[0] = scoeffs[0] * bxyz_new[0] + scoeffs[1] * bxyz_new[1] + scoeffs[2] * bxyz_new[2] + scoeffs[3];
	bst_out[1] = tcoeffs[0] * bxyz_new[0] + tcoeffs[1] * bxyz_new[1] + tcoeffs[2] * bxyz_new[2] + tcoeffs[3];
	cst_out[0] = scoeffs[0] * cxyz_new[0] + scoeffs[1] * cxyz_new[1] + scoeffs[2] * cxyz_new[2] + scoeffs[3];
	cst_out[1] = tcoeffs[0] * cxyz_new[0] + tcoeffs[1] * cxyz_new[1] + tcoeffs[2] * cxyz_new[2] + tcoeffs[3];
}
コード例 #8
0
ファイル: threads.c プロジェクト: paulvortex/BloodMap
void ThreadStats (void)
{
	if( numthreads <= 0 )
		ThreadSetDefault();
	Sys_Printf (" %i threads\n", numthreads);
}
コード例 #9
0
ファイル: convert_map.c プロジェクト: otty/cake3
int ConvertMapToMap(int argc, char **argv)
{
	int             i;
	double          start, end;
	char            source[1024];
	char            name[1024];
	char            save[1024];

	Sys_Printf("---- convert map to map ----\n");

	for(i = 1; i < argc; i++)
	{
		if(!strcmp(argv[i], "-threads"))
		{
			numthreads = atoi(argv[i + 1]);
			i++;
		}
		else if(!strcmp(argv[i], "-v"))
		{
			Sys_Printf("verbose = true\n");
			verbose = qtrue;
		}
		else if(!strcmp(argv[i], "-quake3"))
		{
			convertType = CONVERT_QUAKE3;
			Sys_Printf("converting from Quake3 to XreaL\n");
		}
		else if(!strcmp(argv[i], "-quake4"))
		{
			convertType = CONVERT_QUAKE4;
			Sys_Printf("converting from Quake4 to XreaL\n");
		}
		else if(!strcmp(argv[i], "-connect"))
		{
			Broadcast_Setup(argv[++i]);
		}
		else if(argv[i][0] == '-')
			Error("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if(i != argc - 1)
	{
		Error("usage: xmap -map2map [-<switch> [-<switch> ...]] <mapname.map>\n"
			  "\n" "Switches:\n" "   v              = verbose output\n"
			  //"   quake1       = convert from QuakeWorld to XreaL\n"
			  //"   quake2       = convert from Quake2 to XreaL\n"
			  "   quake3         = convert from Quake3 to XreaL\n" "   quake4         = convert from Quake4 to XreaL\n");
	}

	start = I_FloatTime();

	ThreadSetDefault();

	SetQdirFromPath(argv[i]);

	strcpy(source, ExpandArg(argv[i]));
	StripExtension(source);

	strcpy(name, ExpandArg(argv[i]));
	DefaultExtension(name, ".map");

	// start from scratch
	LoadShaderInfo();

	LoadMapFile(name);

	//
	strcpy(save, ExpandArg(argv[i]));
	StripExtension(save);
	strcat(save, "_converted");
	DefaultExtension(save, ".map");

	WriteMapFile(save);

	end = I_FloatTime();
	Sys_Printf("%5.0f seconds elapsed\n", end - start);

	// shut down connection
	Broadcast_Shutdown();

	return 0;
}
コード例 #10
0
ファイル: sv_login.c プロジェクト: ashabada/mvdsv
void SV_ParseLogin(client_t *cl)
{
	extern cvar_t sv_forcenick;
	char *log1, *pass;

	if (Cmd_Argc() > 2)
	{
		log1 = Cmd_Argv(1);
		pass = Cmd_Argv(2);
	}
	else
	{ // bah usually whole text in 'say' is put into ""
		log1 = pass = Cmd_Argv(1);
		while (*pass && *pass != ' ')
			pass++;

		if (*pass)
			*pass++ = 0;

		while (*pass == ' ')
			pass++;
	}

	// if login is parsed, we read just a password
	if (cl->login[0])
	{
		pass = log1;
		log1 = cl->login;
	}
	else
	{
		strlcpy(cl->login, log1, CLIENT_LOGIN_LEN);
	}

	if (!*pass)
	{
		strlcpy(cl->login, log1, CLIENT_LOGIN_LEN);
		MSG_WriteByte (&cl->netchan.message, svc_print);
		MSG_WriteByte (&cl->netchan.message, PRINT_HIGH);
		MSG_WriteString (&cl->netchan.message, va("Password for %s:\n", cl->login));

		return;
	}

	cl->logged = checklogin(log1, pass, cl - svs.clients + 1, use_log);

	switch (cl->logged)
	{
	case -2:
		MSG_WriteByte (&cl->netchan.message, svc_print);
		MSG_WriteByte (&cl->netchan.message, PRINT_HIGH);
		MSG_WriteString (&cl->netchan.message, "Login blocked\n");
		cl->logged = 0;
		cl->login[0] = 0;
		break;
	case -1:
		MSG_WriteByte (&cl->netchan.message, svc_print);
		MSG_WriteByte (&cl->netchan.message, PRINT_HIGH);
		MSG_WriteString (&cl->netchan.message, "Login in use!\ntry again:\n");
		cl->logged = 0;
		cl->login[0] = 0;
		break;
	case 0:
		MSG_WriteByte (&cl->netchan.message, svc_print);
		MSG_WriteByte (&cl->netchan.message, PRINT_HIGH);
		MSG_WriteString (&cl->netchan.message, va("Access denied\nPassword for %s:\n", cl->login));
		break;
	default:
		Sys_Printf("%s logged in as %s\n", cl->name, cl->login);
		MSG_WriteByte (&cl->netchan.message, svc_print);
		MSG_WriteByte (&cl->netchan.message, PRINT_HIGH);
		MSG_WriteString (&cl->netchan.message, va("Welcome %s\n", log1));

		//VVD: forcenick ->
		if ((int)sv_forcenick.value && cl->login)
		{
			char oldval[MAX_EXT_INFO_STRING];
			strlcpy (oldval, cl->name, MAX_EXT_INFO_STRING);

			Info_Set (&cl->_userinfo_ctx_, "name", cl->login);

			ProcessUserInfoChange (cl, "name", oldval);

			// Change name cvar in client
			MSG_WriteByte (&cl->netchan.message, svc_stufftext);
			MSG_WriteString (&cl->netchan.message, va("name %s\n", cl->login));
		}
		//<-

		MSG_WriteByte (&cl->netchan.message, svc_stufftext);
		MSG_WriteString (&cl->netchan.message, "cmd new\n");
	}
}
コード例 #11
0
ファイル: sv_user.c プロジェクト: twinaphex/fxquake
/*
===================
SV_ReadClientMessage

Returns false if the client should be killed
===================
*/
qboolean SV_ReadClientMessage (void)
{
	int		ret;
	int		cmd;
	char		*s;
	
	do
	{
nextmsg:
		ret = NET_GetMessage (host_client->netconnection);
		if (ret == -1)
		{
			Sys_Printf ("SV_ReadClientMessage: NET_GetMessage failed\n");
			return false;
		}
		if (!ret)
			return true;
					
		MSG_BeginReading (net_message);
		
		while (1)
		{
			if (!host_client->active)
				return false;	// a command caused an error

			if (net_message->badread)
			{
				Sys_Printf ("SV_ReadClientMessage: badread\n");
				return false;
			}	
	
			cmd = MSG_ReadChar (net_message);
			
			switch (cmd)
			{
			case -1:
				goto nextmsg;		// end of message
				
			default:
				Sys_Printf ("SV_ReadClientMessage: unknown command char\n");
				return false;
							
			case clc_nop:
//				Sys_Printf ("SV_ReadClientMessage: clc_nop\n");
				break;
				
			case clc_stringcmd:	
				s = MSG_ReadString (net_message);

				ret = 0;

				if (nehahra)
				{
					if (strncasecmp(s, "max", 3) == 0)
						ret = 1;
					else if (strncasecmp(s, "monster", 7) == 0)
						ret = 1;
					else if (strncasecmp(s, "scrag", 5) == 0)
						ret = 1;
					else if (strncasecmp(s, "wraith", 6) == 0)
						ret = 1;
					else if (strncasecmp(s, "gimme", 5) == 0)
						ret = 1;
				}
				else
				{
					if (strncasecmp(s, "god", 3) == 0)
						ret = 1;
					else if (strncasecmp(s, "notarget", 8) == 0)
						ret = 1;
					else if (strncasecmp(s, "fly", 3) == 0)
						ret = 1;
					else if (strncasecmp(s, "noclip", 6) == 0)
						ret = 1;
					else if (strncasecmp(s, "give", 4) == 0)
						ret = 1;
				}

				if (strncasecmp(s, "status", 6) == 0)
					ret = 1;
				else if (strncasecmp(s, "freezeall", 9) == 0)
					ret = 1;
				else if (strncasecmp(s, "name", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "say", 3) == 0)
					ret = 1;
				else if (strncasecmp(s, "say_team", 8) == 0)
					ret = 1;
				else if (strncasecmp(s, "tell", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "color", 5) == 0)
					ret = 1;
				else if (strncasecmp(s, "kill", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "pause", 5) == 0)
					ret = 1;
				else if (strncasecmp(s, "spawn", 5) == 0)
					ret = 1;
				else if (strncasecmp(s, "begin", 5) == 0)
					ret = 1;
				else if (strncasecmp(s, "prespawn", 8) == 0)
					ret = 1;
				else if (strncasecmp(s, "kick", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "ping", 4) == 0)
					ret = 1;
				else if (strncasecmp(s, "ban", 3) == 0)
					ret = 1;
				else if (strncasecmp(s, "qcexec", 6) == 0)
					ret = 1; // qcexec command for qc testing

				if (ret == 1)
					Cmd_ExecuteString (s, src_client);
				else
					Con_DPrintf("%s tried to %s\n", host_client->name, s);
				break;
				
			case clc_disconnect:
//				Sys_Printf ("SV_ReadClientMessage: client disconnected\n");
				return false;
			
			case clc_move:
				SV_ReadClientMove (&host_client->cmd);
				break;
			}
		}
	} while (ret == 1);
	
	return true;
}
コード例 #12
0
ファイル: eclass.cpp プロジェクト: thewolfteam/GtkRadiant
void Eclass_Init(){
	GSList *pFiles;

	// start by creating the default unknown eclass
	eclass_bad = EClass_Create( "UNKNOWN_CLASS", 0, 0.5, 0,NULL,NULL,NULL );

	// now scan the definitions
	_EClassTable *pTable = &g_EClassDefTable;
	while ( pTable )
	{
		// read in all scripts/*.<extension>
		pFiles = vfsGetFileList( "scripts", pTable->m_pfnGetExtension() );
		if ( pFiles ) {
			GSList *pFile = pFiles;
			while ( pFile )
			{
				/*!
				   \todo the MP/SP filtering rules need to be CLEANED UP and SANITIZED
				 */
				// HACK
				// JKII SP/MP mapping mode
				if ( g_pGameDescription->mGameFile == "jk2.game" || g_pGameDescription->mGameFile == "ja.game" ) {
					if ( !strcmp( ValueForKey( g_qeglobals.d_project_entity, "gamemode" ), "sp" ) ) {
						// SP mapping, ignore mp_*.def
						char *name = (char *)pFile->data;
						if ( name[0] == 'm' && name[1] == 'p' && name[2] == '_' ) {
							Sys_Printf( "Single Player mapping mode. Ignoring '%s'\n", name );
							pFile = pFile->next;
							continue;
						}
					}
					else
					{
						// MP mapping, ignore sp_*.def
						char *name = (char *)pFile->data;
						if ( name[0] == 's' && name[1] == 'p' && name[2] == '_' ) {
							Sys_Printf( "Multiplayer mapping mode. Ignoring '%s'\n", name );
							pFile = pFile->next;
							continue;
						}
					}
				}
				// RIANT
				// STVEF SP/MP mapping mode
				else if ( g_pGameDescription->mGameFile == "stvef.game" ) {
					if ( !strcmp( ValueForKey( g_qeglobals.d_project_entity, "gamemode" ), "sp" ) ) {
						// SP mapping, ignore mp_*.def
						char *name = (char *)pFile->data;
						if ( ( name[0] == 'm' && name[1] == 'p' && name[2] == '_' )
							|| ( name[0] == 'h' && name[1] == 'm' && name[2] == '_' ) ) {
							Sys_Printf( "Single Player mapping mode. Ignoring '%s'\n", name );
							pFile = pFile->next;
							continue;
						}
					}
					else
					{
						// HM mapping, ignore sp_*.def
						char *name = (char *)pFile->data;
						if ( name[0] == 's' && name[1] == 'p' && name[2] == '_' ) {
							Sys_Printf( "HoloMatch mapping mode. Ignoring '%s'\n", name );
							pFile = pFile->next;
							continue;
						}
					}
				}
				// for a given name, we grab the first .def in the vfs
				// this allows to override baseq3/scripts/entities.def for instance
				char relPath[PATH_MAX];
				strcpy( relPath, "scripts/" );
				strcat( relPath, (char*)pFile->data );
				char *fullpath = vfsGetFullPath( relPath, 0, 0 );
				if ( !fullpath ) {
					Sys_FPrintf( SYS_ERR, "Failed to find the full path for \"%s\" in the VFS\n", relPath );
				}
				else{
					pTable->m_pfnScanFile( fullpath );
				}
				if ( g_pGameDescription->mEClassSingleLoad ) {
					break;
				}
				pFile = pFile->next;
			}
			vfsClearFileDirList( &pFiles );
			pFiles = NULL;
		}
		else{
			Sys_FPrintf( SYS_ERR, "Didn't find any scripts/*.%s files to load EClass information\n", pTable->m_pfnGetExtension() );
		}

		// we deal with two formats max, if the other table exists, loop again
		if ( g_bHaveEClassExt && pTable == &g_EClassDefTable ) {
			pTable = &g_EClassExtTable;
		}
		else{
			pTable = NULL; // done, exit
		}
	}
	Eclass_CreateSpriteModelPaths();
}
コード例 #13
0
ファイル: eclass.cpp プロジェクト: thewolfteam/GtkRadiant
/*!
   This looks at each eclass_t, if it has a "modelpath" set then it leaves it alone
   if it's not set it checks to see if a file called "sprites/<eclassname>.*" exists, and
   if it does exist then it sets the "modelpath" to "sprites/<eclassname>.spr"
 */
void Eclass_CreateSpriteModelPaths(){
	int Counts[4] = { 0, 0, 0, 0 };
	char filename[512]; // should be big enough, ExtractFileBase doesn't take a buffer size...
	eclass_t *e;

	// get a list of all sprite/*>* files in all sprite/ directories
	Sys_Printf( "Searching VFS for files in sprites/*.* that match entity names...\n" );
	GSList *pFiles = vfsGetFileList( "sprites", NULL );
	GSList *pFile;

	if ( pFiles ) {

		// find an eclass without a modelpath.
		for ( e = eclass ; e ; e = e->next )
		{
			Counts[0]++;
			if ( e->modelpath ) {
#ifdef _DEBUG
				Sys_Printf( "Ignoring sprite for entity %s (modelpath: \"%s\")\n",e->name,e->modelpath );
#endif
				Counts[1]++;
				continue; // ignore this eclass, it's already got a model
			}

			// TODO: remove this check when we can have sprites for non-fixed size entities.
			if ( !e->fixedsize ) {
#ifdef _DEBUG
				Sys_Printf( "Ignoring sprite for non-fixed-size entity %s\n",e->name );
#endif
				Counts[2]++;
				continue; // can't have sprites for non-fixed size entities (yet!)
			}


			Sys_Printf( "Searching for sprite for fixed-size entity %s...",e->name );

			pFile = pFiles; // point to start of list

			// look for a file that has the same name, with any extension.
			bool Found = FALSE;
			while ( pFile )
			{

				// strip the path/ and the .extension.
				ExtractFileBase( (char *)pFile->data,filename );

				// does the eclass name match the filename?
				if ( stricmp( e->name,filename ) == 0 ) {
					// yes, so generate a sprite filename using the all-encompasing .spr extension
					// so that the model wrapper knows the sprite model plugin will be the model
					// plugin used to render it.
					CString strSpriteName;
					strSpriteName.Format( "sprites/%s.spr",e->name );
					e->modelpath = strdup( strSpriteName.GetBuffer() );
					Sys_Printf( "Found! (\"%s\")\n",(char *)pFile->data );
					Counts[3]++;
					Found = TRUE;
				}
				pFile = pFile->next;
			}

			if ( !Found ) {
				Sys_Printf( "not found\n" );
			}

		}

		vfsClearFileDirList( &pFiles );
	}
	Sys_Printf( "%d entities were scanned\n"
				"%d entities that already had models/sprites were ignored\n"
				"%d non-fixed-size entities were ignored\n"
				"%d entities did not have matching sprite files\n"
				"%d entities had sprite files and have been attached\n",
				Counts[0],Counts[1],Counts[2],Counts[0] - Counts[3],Counts[3] );

}
コード例 #14
0
void MIDI_Play (const char *Name)
{
	FILE		*midiFile;
	char	midiName[MAX_OSPATH], tempName[MAX_QPATH];
	OSErr	err;
	FSSpec	midiSpec;
	FSRef	midiRef;
	short	midiRefNum;

	if (!bMidiInited)	//don't try to play if there is no midi
		return;

	MIDI_Stop();

	if (!Name || !*Name)
	{
		Sys_Printf("no midi music to play\n");
		return;
	}

	q_snprintf (tempName, sizeof(tempName), "%s.%s", Name, "mid");
	FS_OpenFile (va("%s/%s", "midi", tempName), &midiFile, false);
	if (!midiFile)
	{
		Con_Printf("music file %s not found\n", tempName);
		return;
	}
	else
	{
		if (file_from_pak)
		{
			int		ret;

			Con_Printf("Extracting %s from pakfile\n", tempName);
			q_snprintf (midiName, sizeof(midiName), "%s/%s.%s", host_parms->userdir, TEMP_MUSICNAME, "mid");
			ret = FS_CopyFromFile (midiFile, midiName, fs_filesize);
			fclose (midiFile);
			if (ret != 0)
			{
				Con_Printf("Error while extracting from pak\n");
				return;
			}
		}
		else	/* use the file directly */
		{
			fclose (midiFile);
			q_snprintf (midiName, sizeof(midiName), "%s/%s/%s", fs_filepath, "midi", tempName);
		}
	}

	// converting path to FSSpec. found in CarbonCocoaIntegration.pdf:
	// page 27, Obtaining an FSSpec Structure
	err = FSPathMakeRef ((UInt8*)midiName, &midiRef, NULL);
	if (err != noErr)
	{
		Con_Printf ("MIDI: FSPathMakeRef: error while opening %s\n", midiName);
		return;
	}

	err = FSGetCatalogInfo (&midiRef, kFSCatInfoNone, NULL, NULL, &midiSpec, NULL);
	if (err != noErr)
	{
		Con_Printf ("MIDI: FSGetCatalogInfo: error while opening %s\n", midiName);
		return;
	}

	err = OpenMovieFile (&midiSpec, &midiRefNum, fsRdPerm);
	if (err != noErr)
	{
		Con_Printf ("MIDI: OpenMovieStream: error opening midi file\n");
		return;
	}

	err = NewMovieFromFile (&midiTrack, midiRefNum, NULL, NULL, newMovieActive, NULL);
	if (err != noErr || !midiTrack)
	{
		Con_Printf ("MIDI: QuickTime error in creating stream.\n");
		return;
	}

	GoToBeginningOfMovie (midiTrack);
	PrerollMovie (midiTrack, 0, 0);

	// pOx - set initial volume
	MIDI_SetVolume (&bgmvolume);

	StartMovie (midiTrack);
	Con_Printf ("Started midi music %s\n", tempName);
}
コード例 #15
0
ファイル: patches.c プロジェクト: Garux/netradiant-custom
/*
   ======================
   CalcTextureReflectivity_Heretic2
   ======================
 */
void CalcTextureReflectivity_Heretic2( void ){
	int i;
	int j, texels;
	int color[3];
	int texel;
	char path[1024];
	float r;
	miptex_m8_t     *mt;
	miptex_m32_t        *mt32;
	byte            *pos;


	// allways set index 0 even if no textures
	texture_reflectivity[0][0] = 0.5;
	texture_reflectivity[0][1] = 0.5;
	texture_reflectivity[0][2] = 0.5;

	for ( i = 0 ; i < numtexinfo ; i++ )
	{
		// see if an earlier texinfo allready got the value
		for ( j = 0 ; j < i ; j++ )
		{
			if ( !strcmp( texinfo[i].texture, texinfo[j].texture ) ) {
				VectorCopy( texture_reflectivity[j], texture_reflectivity[i] );
				break;
			}
		}
		if ( j != i ) {
			continue;
		}

		// load the wal file

		sprintf( path, "%stextures/%s.m32", gamedir, texinfo[i].texture );
		if ( TryLoadFile( path, (void **)&mt32 ) == -1 ) {
			sprintf( path, "%stextures/%s.m8", gamedir, texinfo[i].texture );
			if ( TryLoadFile( path, (void **)&mt ) == -1 ) {
				Sys_Printf( "Couldn't load %s\n", path );
				texture_reflectivity[i][0] = 0.5;
				texture_reflectivity[i][1] = 0.5;
				texture_reflectivity[i][2] = 0.5;
				continue;
			}
			texels = LittleLong( mt->width[0] ) * LittleLong( mt->height[0] );
			color[0] = color[1] = color[2] = 0;

			for ( j = 0 ; j < texels ; j++ )
			{
				texel = ( (byte *)mt )[LittleLong( mt->offsets[0] ) + j];
				color[0] += mt->palette[texel].r;
				color[1] += mt->palette[texel].g;
				color[2] += mt->palette[texel].b;
			}

			free( mt );
		}
		else
		{
			texels = LittleLong( mt32->width[0] ) * LittleLong( mt32->height[0] );
			color[0] = color[1] = color[2] = 0;

			for ( j = 0 ; j < texels ; j++ )
			{
				pos = (byte *)mt32 + mt32->offsets[0] + ( j << 2 );
				color[0] += *pos++; // r
				color[1] += *pos++; // g
				color[2] += *pos++; // b
			}

			free( mt32 );
		}


		for ( j = 0 ; j < 3 ; j++ )
		{
			r = color[j] / ( (float) texels * 255.0 );
			texture_reflectivity[i][j] = r;
		}
	}
}
コード例 #16
0
ファイル: convert_map.c プロジェクト: otty/cake3
/*
==================
WriteMapFile
==================
*/
static void WriteMapFile(char *filename)
{
	FILE           *f;
	int             i, j, k, l;
	entity_t       *entity;
	epair_t        *ep;
	bspBrush_t     *brush;
	side_t         *side;
	plane_t        *plane;
	parseMesh_t    *pm;

//  winding_t      *w;
	shaderInfo_t   *si;

	Sys_Printf("writing %s\n", filename);
	f = fopen(filename, "wb");
	if(!f)
		Error("Can't write %s\b", filename);

	fprintf(f, "Version 2\n");

	for(i = 0; i < numEntities; i++)
	{
		entity = &entities[i];

		// write entity header
		fprintf(f, "// entity %i\n", i);
		fprintf(f, "{\n");

		// write epairs
		for(ep = entity->epairs; ep; ep = ep->next)
		{
			fprintf(f, "\"%s\" \"%s\"\n", ep->key, ep->value);
		}

		// write brush list
		for(j = 0, brush = entity->brushes; brush; j++, brush = brush->next)
		{
			fprintf(f, "// brush %i\n", j);
			fprintf(f, "{\n");
			fprintf(f, "brushDef3\n");
			fprintf(f, "{\n");
			for(k = 0, side = brush->sides; k < brush->numsides; k++, side++)
			{
				// write plane equation
				plane = &mapPlanes[side->planenum];

				fprintf(f, "( %f %f %f %f ) ", plane->normal[0], plane->normal[1], plane->normal[2], -plane->dist);

				// write texture matrix
				Write2DMatrix(f, 2, 3, (float *)side->texMat);

				si = side->shaderInfo;
				fprintf(f, " \"%s\"", si->shader);

				// support detail flags
				if(side->contents & CONTENTS_DETAIL)
					fprintf(f, " %i 0 0\n", CONTENTS_DETAIL);
				else
					fprintf(f, " 0 0 0\n");

			}
			fprintf(f, "}\n");
			fprintf(f, "}\n");
		}

		// write patch list
		for(j = 0, pm = entity->patches; pm; j++, pm = pm->next)
		{

			fprintf(f, "// patch %i\n", j);
			fprintf(f, "{\n");

			if(pm->patchDef3)
				fprintf(f, "patchDef3\n");
			else
				fprintf(f, "patchDef2\n");

			fprintf(f, "{\n");

			// write shader
			si = pm->shaderInfo;
			fprintf(f, "\"%s\"\n", si->shader);

			// write patch dimensions
			if(pm->patchDef3)
				fprintf(f, "( %i %i %i %i %i %i %i )\n", (int)pm->info[0], (int)pm->info[1], (int)pm->info[2], (int)pm->info[3],
						(int)pm->info[4], (int)pm->info[5], (int)pm->info[6]);
			else

				fprintf(f, "( %i %i %i %i %i )\n", (int)pm->info[0], (int)pm->info[1], (int)pm->info[2], (int)pm->info[3],
						(int)pm->info[4]);

			fprintf(f, "(\n");
			for(k = 0; k < pm->mesh.width; k++)
			{
				fprintf(f, "(");
				for(l = 0; l < pm->mesh.height; l++)
				{
					// write drawVert_t::xyz + st
					Write1DMatrix(f, 5, pm->mesh.verts[l * pm->mesh.width + k].xyz);
				}
				fprintf(f, ")\n");
			}
			fprintf(f, ")\n");

			fprintf(f, "}\n");
			fprintf(f, "}\n");
		}

		fprintf(f, "}\n");
	}

	fclose(f);
}
コード例 #17
0
ファイル: patches.c プロジェクト: Garux/netradiant-custom
/*
   ======================
   CalcTextureReflectivity_Quake2
   ======================
 */
void CalcTextureReflectivity_Quake2( void ){
	int i;
	int j, k, texels;
	int color[3];
	int texel;
	byte            *palette;
	char path[1024];
	float r, scale;
	miptex_t        *mt;

	sprintf( path, "%spics/colormap.pcx", gamedir );

	// get the game palette
	Load256Image( path, NULL, &palette, NULL, NULL );

	// allways set index 0 even if no textures
	texture_reflectivity[0][0] = 0.5;
	texture_reflectivity[0][1] = 0.5;
	texture_reflectivity[0][2] = 0.5;

	for ( i = 0 ; i < numtexinfo ; i++ )
	{
		// see if an earlier texinfo allready got the value
		for ( j = 0 ; j < i ; j++ )
		{
			if ( !strcmp( texinfo[i].texture, texinfo[j].texture ) ) {
				VectorCopy( texture_reflectivity[j], texture_reflectivity[i] );
				break;
			}
		}
		if ( j != i ) {
			continue;
		}

		// load the wal file
		sprintf( path, "%stextures/%s.wal", gamedir, texinfo[i].texture );
		if ( TryLoadFile( path, (void **)&mt ) == -1 ) {
			Sys_Printf( "Couldn't load %s\n", path );
			texture_reflectivity[i][0] = 0.5;
			texture_reflectivity[i][1] = 0.5;
			texture_reflectivity[i][2] = 0.5;
			continue;
		}
		texels = LittleLong( mt->width ) * LittleLong( mt->height );
		color[0] = color[1] = color[2] = 0;

		for ( j = 0 ; j < texels ; j++ )
		{
			texel = ( (byte *)mt )[LittleLong( mt->offsets[0] ) + j];
			for ( k = 0 ; k < 3 ; k++ )
				color[k] += palette[texel * 3 + k];
		}

		for ( j = 0 ; j < 3 ; j++ )
		{
			r = color[j] / texels / 255.0;
			texture_reflectivity[i][j] = r;
		}
		// scale the reflectivity up, because the textures are
		// so dim
		scale = ColorNormalize( texture_reflectivity[i],
								texture_reflectivity[i] );
		if ( scale < 0.5 ) {
			scale *= 2;
			VectorScale( texture_reflectivity[i], scale, texture_reflectivity[i] );
		}
#if 0
		texture_reflectivity[i][0] = 0.5;
		texture_reflectivity[i][1] = 0.5;
		texture_reflectivity[i][2] = 0.5;
#endif
	}
}
コード例 #18
0
// experimental stuff, work directly on BP
static void OnTest( GtkWidget *widget, gpointer data ){
	if ( !g_qeglobals.m_bBrushPrimitMode ) {
		Sys_FPrintf( SYS_WRN, "BP mode required\n" );
		return;
	}
	if ( g_ptrSelectedFaces.GetSize() != 1 ) {
		Sys_FPrintf( SYS_WRN, "Expected single face selection\n" );
		return;
	}
	//brush_t *b = reinterpret_cast<brush_t*>( g_ptrSelectedFaceBrushes.GetAt( 0 ) );
	face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
	// get the ST axis base for the face
	vec3_t texS,texT;
	ComputeAxisBase( selFace->plane.normal, texS, texT );
	// find ST coordinates for the center of the face
	float Os = 0,Ot = 0;
	int i;
	for ( i = 0; i < selFace->face_winding->numpoints; i++ )
	{
		Os += DotProduct( selFace->face_winding->points[i],texS );
		Ot += DotProduct( selFace->face_winding->points[i],texT );
	}
	Os /= selFace->face_winding->numpoints;
	Ot /= selFace->face_winding->numpoints;
	brushprimit_texdef_t *pBP = &selFace->brushprimit_texdef;

	// (FIXME: initial version, before axis base change optimize)

	// we need to compute our BP matrix in this new axis base (O,texS,texT)
	// the general case if BPO = M * BP * M^-1
	//   where BPO is transformation expressed in (O,texS,texT)
	//         M is the axis base change from (origin,texS,texT) to (O,texS,texT)
	// here we have a special case, M is a translation and it's inverse is easy
	vec_t BPO[2][3];
	vec_t aux[2][3];
	vec_t m[2][3];
	memset( &m, 0, sizeof( vec_t ) * 6 );
	m[0][0] = 1; m[1][1] = 1; m[0][2] = -Os; m[1][2] = -Ot;
	BPMatMul( m, pBP->coords, aux );
	m[0][2] = Os; m[1][2] = Ot; // now M^-1
	BPMatMul( aux, m, BPO );

#if 0
	// apply a scaling
	// scale factors against S and T axis, we apply on top of the existing matrix
	// <1 will decrease the texel/world resolution, >1 will increase
	float sS = 1.025,sT = 1.025;
	BPMatScale( BPO,sS,sT );
#endif
#if 0
	// apply a rotation
	float theta = 5;
	BPMatRotate( BPO,theta );
#endif
#if 0
	// read the scale
	ConvertTexMatWithQTexture( BPO, selFace->d_texture, aux, NULL );
	// reset the scale (normalize the matrix)
	vec_t v1,v2;
	v1 = sqrt( aux[0][0] * aux[0][0] + aux[1][0] * aux[1][0] );
	v2 = sqrt( aux[0][1] * aux[0][1] + aux[1][1] * aux[1][1] );
	// if reading the scale values, we have them here:
	Sys_Printf( "Current Scale: S: %g T: %g\n", v1, v2 );
	return;
#endif
#if 1
	// apply a given scale (on S and T)
	ConvertTexMatWithQTexture( BPO, selFace->d_texture, aux, NULL );
	// reset the scale (normalize the matrix)
	vec_t v1,v2;
	v1 = sqrt( aux[0][0] * aux[0][0] + aux[1][0] * aux[1][0] );
	v2 = sqrt( aux[0][1] * aux[0][1] + aux[1][1] * aux[1][1] );
	vec_t sS,sT;
	// put the values for scale on S and T here:
	sS = 1.2 / v1;
	sT = 0.8 / v2;
	aux[0][0] *= sS; aux[1][0] *= sS;
	aux[0][1] *= sT; aux[1][1] *= sT;
	ConvertTexMatWithQTexture( aux, NULL, BPO, selFace->d_texture );
#endif

	// now BPO must be expressed back in (origin,texS,texT) axis base BP = M^-1 * BPO * M
	BPMatMul( m, BPO, aux ); // m is M^-1
	m[0][2] = -Os; m[1][2] = -Ot;
	BPMatMul( aux, m, pBP->coords );

	// now emit the coordinates on the winding
	EmitBrushPrimitTextureCoordinates( selFace, selFace->face_winding );
	Sys_UpdateWindows( W_CAMERA );
}
コード例 #19
0
ファイル: bsp_scale.c プロジェクト: Elzair/q3map2
int ScaleBSPMain( int argc, char **argv ){
	int i, j;
	float f, a;
	vec3_t scale;
	vec3_t vec;
	char str[ 1024 ];
	int uniform, axis;
	qboolean texscale;
	float *old_xyzst = NULL;
	float spawn_ref = 0;


	/* arg checking */
	if ( argc < 3 ) {
		Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
		return 0;
	}

	texscale = qfalse;
	for ( i = 1; i < argc - 2; ++i )
	{
		if ( !strcmp( argv[i], "-tex" ) ) {
			texscale = qtrue;
		}
		else if ( !strcmp( argv[i], "-spawn_ref" ) ) {
			spawn_ref = atof( argv[i + 1] );
			++i;
		}
		else{
			break;
		}
	}

	/* get scale */
	// if(argc-2 >= i) // always true
	scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
	if ( argc - 3 >= i ) {
		scale[1] = scale[0] = atof( argv[ argc - 3 ] );
	}
	if ( argc - 4 >= i ) {
		scale[0] = atof( argv[ argc - 4 ] );
	}

	uniform = ( ( scale[0] == scale[1] ) && ( scale[1] == scale[2] ) );

	if ( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f ) {
		Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
		Sys_Printf( "Non-zero scale value required.\n" );
		return 0;
	}

	/* do some path mangling */
	strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
	StripExtension( source );
	DefaultExtension( source, ".bsp" );

	/* load the bsp */
	Sys_Printf( "Loading %s\n", source );
	LoadBSPFile( source );
	ParseEntities();

	/* note it */
	Sys_Printf( "--- ScaleBSP ---\n" );
	Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );

	/* scale entity keys */
	for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
	{
		/* scale origin */
		GetVectorForKey( &entities[ i ], "origin", vec );
		if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
			if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
				vec[2] += spawn_ref;
			}
			vec[0] *= scale[0];
			vec[1] *= scale[1];
			vec[2] *= scale[2];
			if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
				vec[2] -= spawn_ref;
			}
			sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
			SetKeyValue( &entities[ i ], "origin", str );
		}

		a = FloatForKey( &entities[ i ], "angle" );
		if ( a == -1 || a == -2 ) { // z scale
			axis = 2;
		}
		else if ( fabs( sin( DEG2RAD( a ) ) ) < 0.707 ) {
			axis = 0;
		}
		else{
			axis = 1;
		}

		/* scale door lip */
		f = FloatForKey( &entities[ i ], "lip" );
		if ( f ) {
			f *= scale[axis];
			sprintf( str, "%f", f );
			SetKeyValue( &entities[ i ], "lip", str );
		}

		/* scale plat height */
		f = FloatForKey( &entities[ i ], "height" );
		if ( f ) {
			f *= scale[2];
			sprintf( str, "%f", f );
			SetKeyValue( &entities[ i ], "height", str );
		}

		// TODO maybe allow a definition file for entities to specify which values are scaled how?
	}

	/* scale models */
	for ( i = 0; i < numBSPModels; i++ )
	{
		bspModels[ i ].mins[0] *= scale[0];
		bspModels[ i ].mins[1] *= scale[1];
		bspModels[ i ].mins[2] *= scale[2];
		bspModels[ i ].maxs[0] *= scale[0];
		bspModels[ i ].maxs[1] *= scale[1];
		bspModels[ i ].maxs[2] *= scale[2];
	}

	/* scale nodes */
	for ( i = 0; i < numBSPNodes; i++ )
	{
		bspNodes[ i ].mins[0] *= scale[0];
		bspNodes[ i ].mins[1] *= scale[1];
		bspNodes[ i ].mins[2] *= scale[2];
		bspNodes[ i ].maxs[0] *= scale[0];
		bspNodes[ i ].maxs[1] *= scale[1];
		bspNodes[ i ].maxs[2] *= scale[2];
	}

	/* scale leafs */
	for ( i = 0; i < numBSPLeafs; i++ )
	{
		bspLeafs[ i ].mins[0] *= scale[0];
		bspLeafs[ i ].mins[1] *= scale[1];
		bspLeafs[ i ].mins[2] *= scale[2];
		bspLeafs[ i ].maxs[0] *= scale[0];
		bspLeafs[ i ].maxs[1] *= scale[1];
		bspLeafs[ i ].maxs[2] *= scale[2];
	}

	if ( texscale ) {
		Sys_Printf( "Using texture unlocking (and probably breaking texture alignment a lot)\n" );
		old_xyzst = safe_malloc( sizeof( *old_xyzst ) * numBSPDrawVerts * 5 );
		for ( i = 0; i < numBSPDrawVerts; i++ )
		{
			old_xyzst[5 * i + 0] = bspDrawVerts[i].xyz[0];
			old_xyzst[5 * i + 1] = bspDrawVerts[i].xyz[1];
			old_xyzst[5 * i + 2] = bspDrawVerts[i].xyz[2];
			old_xyzst[5 * i + 3] = bspDrawVerts[i].st[0];
			old_xyzst[5 * i + 4] = bspDrawVerts[i].st[1];
		}
	}

	/* scale drawverts */
	for ( i = 0; i < numBSPDrawVerts; i++ )
	{
		bspDrawVerts[i].xyz[0] *= scale[0];
		bspDrawVerts[i].xyz[1] *= scale[1];
		bspDrawVerts[i].xyz[2] *= scale[2];
		bspDrawVerts[i].normal[0] /= scale[0];
		bspDrawVerts[i].normal[1] /= scale[1];
		bspDrawVerts[i].normal[2] /= scale[2];
		VectorNormalize( bspDrawVerts[i].normal, bspDrawVerts[i].normal );
	}

	if ( texscale ) {
		for ( i = 0; i < numBSPDrawSurfaces; i++ )
		{
			switch ( bspDrawSurfaces[i].surfaceType )
			{
			case SURFACE_FACE:
			case SURFACE_META:
				if ( bspDrawSurfaces[i].numIndexes % 3 ) {
					Error( "Not a triangulation!" );
				}
				for ( j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3 )
				{
					int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j + 1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j + 2] + bspDrawSurfaces[i].firstVert;
					bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
					float *oa = &old_xyzst[ia * 5], *ob = &old_xyzst[ib * 5], *oc = &old_xyzst[ic * 5];
					// extrapolate:
					//   a->xyz -> oa
					//   b->xyz -> ob
					//   c->xyz -> oc
					ExtrapolateTexcoords(
						&oa[0], &oa[3],
						&ob[0], &ob[3],
						&oc[0], &oc[3],
						a->xyz, a->st,
						b->xyz, b->st,
						c->xyz, c->st );
				}
				break;
			}
		}
	}

	/* scale planes */
	if ( uniform ) {
		for ( i = 0; i < numBSPPlanes; i++ )
		{
			bspPlanes[ i ].dist *= scale[0];
		}
	}
	else
	{
		for ( i = 0; i < numBSPPlanes; i++ )
		{
			bspPlanes[ i ].normal[0] /= scale[0];
			bspPlanes[ i ].normal[1] /= scale[1];
			bspPlanes[ i ].normal[2] /= scale[2];
			f = 1 / VectorLength( bspPlanes[i].normal );
			VectorScale( bspPlanes[i].normal, f, bspPlanes[i].normal );
			bspPlanes[ i ].dist *= f;
		}
	}

	/* scale gridsize */
	GetVectorForKey( &entities[ 0 ], "gridsize", vec );
	if ( ( vec[ 0 ] + vec[ 1 ] + vec[ 2 ] ) == 0.0f ) {
		VectorCopy( gridSize, vec );
	}
	vec[0] *= scale[0];
	vec[1] *= scale[1];
	vec[2] *= scale[2];
	sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
	SetKeyValue( &entities[ 0 ], "gridsize", str );

	/* inject command line parameters */
	InjectCommandLine( argv, 0, argc - 1 );

	/* write the bsp */
	UnparseEntities();
	StripExtension( source );
	DefaultExtension( source, "_s.bsp" );
	Sys_Printf( "Writing %s\n", source );
	WriteBSPFile( source );

	/* return to sender */
	return 0;
}
コード例 #20
0
void SurfaceDlg::SetTexMods(){
	texdef_t *pt;
	brushprimit_texdef_t  *bpt;
	// local copy if a width=2 height=2 qtetxture_t is needed
	brushprimit_texdef_t local_bp;

#ifdef DBG_SI
	Sys_Printf( "SurfaceDlg::SetTexMods\n" );
#endif

	if ( !g_surfwin ) {
		return;
	}

	if ( g_ptrSelectedFaces.GetSize() > 0 ) {
		face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
		pt = &selFace->texdef;
		if ( g_qeglobals.m_bBrushPrimitMode ) {
			// compute a texture matrix related to the default matrix width=2 height=2
			ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &local_bp, NULL );
			bpt = &local_bp;
		}
	}
	else
	{
		pt = &g_qeglobals.d_texturewin.texdef;
		if ( g_qeglobals.m_bBrushPrimitMode ) {
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
		}
	}
	// brush primitive mode : compute fake shift scale rot representation
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		TexMatToFakeTexCoords( bpt->coords, m_shift, &m_rotate, m_scale );
	}

	g_bListenChanged = false;

	if ( strncmp( pt->GetName(), "textures/", 9 ) != 0 ) {
		pt->SetName( SHADER_NOT_FOUND );
	}
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "texture" ) ), pt->GetName() + 9 );

	GtkSpinButton *spin;
	spin = GTK_SPIN_BUTTON( GetDlgWidget( "hshift" ) );
	gtk_spin_button_set_digits( spin, 2 );
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		gtk_spin_button_set_value( spin, m_shift[0] );
	}
	else{
		gtk_spin_button_set_value( spin, pt->shift[0] );
	}
	GtkAdjustment *adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->shift[0];
	char buf[10]; // got into snprintf paranoia after BoundChecker detected a stack overrun
#ifdef _WIN32
	// TTimo: THIS IS UGLY
#define snprintf _snprintf
#endif
	snprintf( buf, 10, "%g", l_pIncrement->shift[0] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hshift_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) );
	gtk_spin_button_set_digits( spin, 2 );
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		gtk_spin_button_set_value( spin, m_shift[1] );
	}
	else{
		gtk_spin_button_set_value( spin, pt->shift[1] );
	}
	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->shift[1];
	snprintf( buf, 10, "%g", l_pIncrement->shift[1] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vshift_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) );
	gtk_spin_button_set_digits( spin, 5 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->scale[0];
	snprintf( buf, 10, "%g", l_pIncrement->scale[0] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hscale_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) );
	gtk_spin_button_set_digits( spin, 5 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->scale[1];
	snprintf( buf, 10, "%g", l_pIncrement->scale[1] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vscale_inc" ) ), buf );

	//++timo compute BProtate as int ..
	spin = GTK_SPIN_BUTTON( GetDlgWidget( "rotate" ) );
	gtk_spin_button_set_digits( spin, 2 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->rotate;
	snprintf( buf, 10, "%g", l_pIncrement->rotate );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "rotate_inc" ) ), buf );

	g_bListenChanged = true;

	// undo tricks: set the undo id to zero so we don't attempt to undo something that does not belong to us
	m_nUndoId = 0;
	// store the current texdef as our escape route if user hits OnCancel
	g_old_texdef = g_qeglobals.d_texturewin.texdef;
	// reset the Enter key behaviour flag
	m_bEditingTextureWidget = false;
}
コード例 #21
0
ファイル: conproc.cpp プロジェクト: jlecorre/hlinvasion
/*
==============
RequestProc

==============
*/
unsigned _stdcall RequestProc (void *arg)
{
	int		*pBuffer;
	DWORD	dwRet;
	HANDLE	heventWait[2];
	int		iBeginLine, iEndLine;
	
	heventWait[0] = heventParentSend;
	heventWait[1] = heventDone;

	while (1)
	{
		dwRet = WaitForMultipleObjects (2, heventWait, FALSE, INFINITE);

	// heventDone fired, so we're exiting.
		if (dwRet == WAIT_OBJECT_0 + 1)	
			break;

		pBuffer = (int *) GetMappedBuffer (hfileBuffer);
		
	// hfileBuffer is invalid.  Just leave.
		if (!pBuffer)
		{
			Sys_Printf ("Request Proc:  Invalid -HFILE handle\n");
			break;
		}

		switch (pBuffer[0])
		{
			case CCOM_WRITE_TEXT:
			// Param1 : Text
				pBuffer[0] = WriteText ((LPCTSTR) (pBuffer + 1));
				break;

			case CCOM_GET_TEXT:
			// Param1 : Begin line
			// Param2 : End line
				iBeginLine = pBuffer[1];
				iEndLine = pBuffer[2];
				pBuffer[0] = ReadText ((LPTSTR) (pBuffer + 1), iBeginLine, 
									   iEndLine);
				break;

			case CCOM_GET_SCR_LINES:
			// No params
				pBuffer[0] = GetScreenBufferLines (&pBuffer[1]);
				break;

			case CCOM_SET_SCR_LINES:
			// Param1 : Number of lines
				pBuffer[0] = SetScreenBufferLines (pBuffer[1]);
				break;
		}

		ReleaseMappedBuffer (pBuffer);
		SetEvent (heventChildSend);
	}

	_endthreadex (0);
	return 0;
}
コード例 #22
0
/*
   ==============
   GetTexMods

   Reads the fields to get the current texdef (i.e. widgets -> MAP)
   in brush primitive mode, grab the fake shift scale rot and compute a new texture matrix
   ===============
 */
void SurfaceDlg::GetTexMods(){
	char buffer[1024];
	texdef_t *pt;

#ifdef DBG_SI
	Sys_Printf( "SurfaceDlg::GetTexMods\n" );
#endif

	if ( g_ptrSelectedFaces.GetSize() > 0 ) {
		//++timo just a test, we disable the undo when working on selected faces
		m_nUndoId = 0;
		face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
		g_qeglobals.d_texturewin.texdef = selFace->texdef;
#ifdef DBG_SI
		Sys_Printf( "g_qeglobals.d_texturewin.texdef = selFace->texdef\n" );
#endif
	}
//  else
//  {
	pt = &g_qeglobals.d_texturewin.texdef;
#ifdef DBG_SI
	Sys_Printf( "pt = &g_qeglobals.d_texturewin.texdef\n" );
#endif
//  }

	const char* text = gtk_entry_get_text( GTK_ENTRY( GetDlgWidget( "texture" ) ) );

#ifdef DBG_SI
	Sys_Printf( "pt->SetName(%s)\n", text );
#endif

	// TTimo: detect and refuse invalid texture names (at least the ones with spaces)
	if ( text[0] <= ' ' || strchr( text, ' ' ) ) {
		Sys_FPrintf( SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text );
		pt->SetName( SHADER_NOT_FOUND );
		gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "texture" ) ), pt->GetName() );
	}
	else
	{
		strcpy( buffer, "textures/" );
		strcpy( buffer + 9, text );
		pt->SetName( buffer );
	}


	( g_qeglobals.m_bBrushPrimitMode ? m_shift[0] : pt->shift[0] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "hshift" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_shift[1] : pt->shift[1] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "rotate" ) ) );

	// a local copy of the texture matrix, given for a qtexture_t with width=2 height=2
	brushprimit_texdef_t local_bp;
	brushprimit_texdef_t  *bpt;
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		face_t *selFace = NULL;
		if ( g_ptrSelectedFaces.GetSize() > 0 ) {
			selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
			bpt = &selFace->brushprimit_texdef;
		}
		else
		{
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
		}
		// compute texture matrix
		// the matrix returned must be understood as a qtexture_t with width=2 height=2
		FakeTexCoordsToTexMat( m_shift, m_rotate, m_scale, local_bp.coords );
		// copy the texture matrix in the global struct
		// fit the qtexture if we have a face selected, otherwise g_qeglobals.d_texturewin.brushprimit_texdef uses the basic qtexture_t with width=2 height=2

		ConvertTexMatWithQTexture( &local_bp, NULL, bpt, ( ( selFace ) ? selFace->d_texture : NULL ) );
	}
	// we are gonna do stuff, if we own the last do we undo it first
	if ( m_nUndoId != 0 ) {
		// check the do we're about to undo is the one we pushed earlier
		if ( m_nUndoId == Undo_GetUndoId() ) {
#ifdef DBG_SI
			Sys_Printf( "GetTexMods calling Undo_Undo (silent)\n" );
#endif
			g_bListenUpdate = false;
			Undo_Undo( true );
			g_bListenUpdate = true;
		}
	}
	Select_SetTexture( pt,&local_bp );
	m_nUndoId = Undo_GetUndoId();
}
コード例 #23
0
ファイル: sv_user.c プロジェクト: atphalix/PSPCube
/*
===================
SV_ReadClientMessage

Returns false if the client should be killed
===================
*/
qboolean SV_ReadClientMessage (void)
{
	int		ret;
	int		cmd;
	char		*s;
	
	do
	{
nextmsg:
		ret = NET_GetMessage (host_client->netconnection);
		if (ret == -1)
		{
			Sys_Printf ("SV_ReadClientMessage: NET_GetMessage failed\n");
			return false;
		}
		if (!ret)
			return true;
					
		MSG_BeginReading ();
		
		while (1)
		{
			if (!host_client->active)
				return false;	// a command caused an error

			if (msg_badread)
			{
				Sys_Printf ("SV_ReadClientMessage: badread\n");
				return false;
			}	
	
			cmd = MSG_ReadChar ();
			
			switch (cmd)
			{
			case -1:
				goto nextmsg;		// end of message
				
			default:
				Sys_Printf ("SV_ReadClientMessage: unknown command char\n");
				return false;
							
			case clc_nop:
//				Sys_Printf ("clc_nop\n");
				break;
				
			case clc_stringcmd:	
				s = MSG_ReadString ();
				if (host_client->privileged)
					ret = 2;
				else
					ret = 0;
				if (Q_strncasecmp(s, "status", 6) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "god", 3) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "notarget", 8) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "fly", 3) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "name", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "noclip", 6) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "say", 3) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "say_team", 8) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "tell", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "color", 5) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "kill", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "pause", 5) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "spawn", 5) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "begin", 5) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "prespawn", 8) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "kick", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "ping", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "give", 4) == 0)
					ret = 1;
				else if (Q_strncasecmp(s, "ban", 3) == 0)
					ret = 1;
				if (ret == 2)
					Cbuf_InsertText (s);
				else if (ret == 1)
					Cmd_ExecuteString (s, src_client);
				else
					Con_DPrintf("%s tried to %s\n", host_client->name, s);
				break;
				
			case clc_disconnect:
//				Sys_Printf ("SV_ReadClientMessage: client disconnected\n");
				return false;
			
			case clc_move:
				SV_ReadClientMove (&host_client->cmd);
				break;
			}
		}
	} while (ret == 1);
	
	return true;
}
コード例 #24
0
ファイル: vis.c プロジェクト: Asvarox/Unvanquished
/*
==================
CalcVis
==================
*/
void CalcVis(void)
{
	int             i, minvis, maxvis;
	const char     *value;
	double          mu, sigma, totalvis, totalvis2;


	/* ydnar: rr2do2's farplane code */
	farPlaneDist = 0.0f;
	value = ValueForKey(&entities[0], "_farplanedist");	/* proper '_' prefixed key */
	if(value[0] == '\0')
		value = ValueForKey(&entities[0], "fogclip");	/* wolf compatibility */
	if(value[0] == '\0')
		value = ValueForKey(&entities[0], "distancecull");	/* sof2 compatibility */
	if(value[0] != '\0')
	{
		farPlaneDist = atof(value);
		if(farPlaneDist > 0.0f)
			Sys_Printf("farplane distance = %.1f\n", farPlaneDist);
		else
			farPlaneDist = 0.0f;
	}



	Sys_Printf("\n--- BasePortalVis (%d) ---\n", numportals * 2);
	RunThreadsOnIndividual(numportals * 2, qtrue, BasePortalVis);

//  RunThreadsOnIndividual (numportals*2, qtrue, BetterPortalVis);

	SortPortals();

	if(fastvis)
	{
		CalcFastVis();
	}
	else if(noPassageVis)
	{
		CalcPortalVis();
	}
	else if(passageVisOnly)
	{
		CalcPassageVis();
	}
	else
	{
		CalcPassagePortalVis();
	}
	//
	// assemble the leaf vis lists by oring and compressing the portal lists
	//
	Sys_Printf("creating leaf vis...\n");
	for(i = 0; i < portalclusters; i++)
		ClusterMerge(i);

	totalvis = 0;
	totalvis2 = 0;
	minvis = -1;
	maxvis = -1;
	for(i = 0; i < MAX_MAP_LEAFS; ++i)
		if(clustersizehistogram[i])
		{
			if(debugCluster)
				Sys_FPrintf(SYS_VRB, "%4i clusters have exactly %4i visible clusters\n", clustersizehistogram[i], i);
			/* cast is to prevent integer overflow */
			totalvis += ((double)i) * ((double)clustersizehistogram[i]);
			totalvis2 += ((double)i) * ((double)i) * ((double)clustersizehistogram[i]);

			if(minvis < 0)
				minvis = i;
			maxvis = i;
		}

	mu = totalvis / portalclusters;
	sigma = sqrt(totalvis2 / portalclusters - mu * mu);

	Sys_Printf("Total clusters: %i\n", portalclusters);
	Sys_Printf("Total visible clusters: %.0f\n", totalvis);
	Sys_Printf("Average clusters visible: %.2f (%.3f%%/total)\n", mu, mu / portalclusters * 100.0);
	Sys_Printf("  Standard deviation: %.2f (%.3f%%/total, %.3f%%/avg)\n", sigma, sigma / portalclusters * 100.0,
			   sigma / mu * 100.0);
	Sys_Printf("  Minimum: %i (%.3f%%/total, %.3f%%/avg)\n", minvis, minvis / (double)portalclusters * 100.0,
			   minvis / mu * 100.0);
	Sys_Printf("  Maximum: %i (%.3f%%/total, %.3f%%/avg)\n", maxvis, maxvis / (double)portalclusters * 100.0,
			   maxvis / mu * 100.0);
}
コード例 #25
0
ファイル: vis.c プロジェクト: Teivaz/nebula2
/*
============
LoadPortals
============
*/
void LoadPortals (char *name)
{
    int            i, j, hint;
    vportal_t    *p;
    leaf_t        *l;
    char        magic[80];
    FILE        *f;
    int            numpoints;
    fixedWinding_t    *w;
    int            leafnums[2];
    visPlane_t    plane;
    
    if (!strcmp(name,"-"))
        f = stdin;
    else
    {
        f = fopen(name, "r");
        if (!f)
            Error ("LoadPortals: couldn't read %s\n",name);
    }

    if (fscanf (f,"%79s\n%i\n%i\n%i\n",magic, &portalclusters, &numportals, &numfaces) != 4)
        Error ("LoadPortals: failed to read header");
    if (strcmp(magic,PORTALFILE))
        Error ("LoadPortals: not a portal file");

    Sys_Printf ("%6i portalclusters\n", portalclusters);
    Sys_Printf ("%6i numportals\n", numportals);
    Sys_Printf ("%6i numfaces\n", numfaces);
    
    // these counts should take advantage of 64 bit systems automatically
    leafbytes = ((portalclusters+63)&~63)>>3;
    leaflongs = leafbytes/sizeof(long);
    
    portalbytes = ((numportals*2+63)&~63)>>3;
    portallongs = portalbytes/sizeof(long);

    // each file portal is split into two memory portals
    portals = safe_malloc(2*numportals*sizeof(vportal_t));
    memset (portals, 0, 2*numportals*sizeof(vportal_t));
    
    leafs = safe_malloc(portalclusters*sizeof(leaf_t));
    memset (leafs, 0, portalclusters*sizeof(leaf_t));

    for (i = 0; i < portalclusters; i++)
        leafs[i].merged = -1;

    numBSPVisBytes = VIS_HEADER_SIZE + portalclusters*leafbytes;

    if (numBSPVisBytes > MAX_MAP_VISIBILITY)
      Error("MAX_MAP_VISIBILITY exceeded");

    ((int *)bspVisBytes)[0] = portalclusters;
    ((int *)bspVisBytes)[1] = leafbytes;
        
    for (i=0, p=portals ; i<numportals ; i++)
    {
        if (fscanf (f, "%i %i %i ", &numpoints, &leafnums[0], &leafnums[1]) != 3)
            Error ("LoadPortals: reading portal %i", i);
        if (numpoints > MAX_POINTS_ON_WINDING)
            Error ("LoadPortals: portal %i has too many points", i);
        if ( (unsigned)leafnums[0] > portalclusters
        || (unsigned)leafnums[1] > portalclusters)
            Error ("LoadPortals: reading portal %i", i);
        if (fscanf (f, "%i ", &hint) != 1)
            Error ("LoadPortals: reading hint state");
        
        w = p->winding = NewFixedWinding (numpoints);
        w->numpoints = numpoints;
        
        for (j=0 ; j<numpoints ; j++)
        {
            double    v[3];
            int        k;

            // scanf into double, then assign to vec_t
            // so we don't care what size vec_t is
            if (fscanf (f, "(%lf %lf %lf ) "
            , &v[0], &v[1], &v[2]) != 3)
                Error ("LoadPortals: reading portal %i", i);
            for (k=0 ; k<3 ; k++)
                w->points[j][k] = v[k];
        }
        fscanf (f, "\n");
        
        // calc plane
        PlaneFromWinding (w, &plane);

        // create forward portal
        l = &leafs[leafnums[0]];
        if (l->numportals == MAX_PORTALS_ON_LEAF)
            Error ("Leaf with too many portals");
        l->portals[l->numportals] = p;
        l->numportals++;
        
        p->num = i+1;
        p->hint = hint;
        p->winding = w;
        VectorSubtract (vec3_origin, plane.normal, p->plane.normal);
        p->plane.dist = -plane.dist;
        p->leaf = leafnums[1];
        SetPortalSphere (p);
        p++;
        
        // create backwards portal
        l = &leafs[leafnums[1]];
        if (l->numportals == MAX_PORTALS_ON_LEAF)
            Error ("Leaf with too many portals");
        l->portals[l->numportals] = p;
        l->numportals++;
        
        p->num = i+1;
        p->hint = hint;
        p->winding = NewFixedWinding(w->numpoints);
        p->winding->numpoints = w->numpoints;
        for (j=0 ; j<w->numpoints ; j++)
        {
            VectorCopy (w->points[w->numpoints-1-j], p->winding->points[j]);
        }

        p->plane = plane;
        p->leaf = leafnums[0];
        SetPortalSphere (p);
        p++;

    }

    faces = safe_malloc(2*numfaces*sizeof(vportal_t));
    memset (faces, 0, 2*numfaces*sizeof(vportal_t));

    faceleafs = safe_malloc(portalclusters*sizeof(leaf_t));
    memset(faceleafs, 0, portalclusters*sizeof(leaf_t));

    for (i = 0, p = faces; i < numfaces; i++)
    {
        if (fscanf (f, "%i %i ", &numpoints, &leafnums[0]) != 2)
            Error ("LoadPortals: reading portal %i", i);

        w = p->winding = NewFixedWinding (numpoints);
        w->numpoints = numpoints;
        
        for (j=0 ; j<numpoints ; j++)
        {
            double    v[3];
            int        k;

            // scanf into double, then assign to vec_t
            // so we don't care what size vec_t is
            if (fscanf (f, "(%lf %lf %lf ) "
            , &v[0], &v[1], &v[2]) != 3)
                Error ("LoadPortals: reading portal %i", i);
            for (k=0 ; k<3 ; k++)
                w->points[j][k] = v[k];
        }
        fscanf (f, "\n");
        
        // calc plane
        PlaneFromWinding (w, &plane);

        l = &faceleafs[leafnums[0]];
        l->merged = -1;
        if (l->numportals == MAX_PORTALS_ON_LEAF)
            Error ("Leaf with too many faces");
        l->portals[l->numportals] = p;
        l->numportals++;
        
        p->num = i+1;
        p->winding = w;
        // normal pointing out of the leaf
        VectorSubtract (vec3_origin, plane.normal, p->plane.normal);
        p->plane.dist = -plane.dist;
        p->leaf = -1;
        SetPortalSphere (p);
        p++;
    }
    
    fclose (f);
}
コード例 #26
0
ファイル: bsp.c プロジェクト: otty/cake3
/*
============
ProcessWorldModel
============
*/
void ProcessWorldModel(void)
{
	int             s;
	entity_t       *e;
	tree_t         *tree;
	bspFace_t      *faces;
	qboolean        leaked;
	xmlNodePtr      polyline, leaknode;
	char            level[2];
	const char     *value;

	e = &entities[0];
	e->firstDrawSurf = 0;		//numMapDrawSurfs;

	// sets integer blockSize from worldspawn "_blocksize" key if it exists
	value = ValueForKey(e, "_blocksize");
	if(value[0] == '\0')
		value = ValueForKey(e, "blocksize");
	if(value[0] == '\0')
		value = ValueForKey(e, "chopsize");	// sof2
	if(value[0] != '\0')
	{
		// scan 3 numbers
		s = sscanf(value, "%d %d %d", &blockSize[0], &blockSize[1], &blockSize[2]);

		// handle legacy case
		if(s == 1)
		{
			blockSize[1] = blockSize[0];
			blockSize[2] = blockSize[0];
		}
	}
	Sys_Printf("block size = { %d %d %d }\n", blockSize[0], blockSize[1], blockSize[2]);

	BeginModel(e);

	// check for patches with adjacent edges that need to LOD together
	PatchMapDrawSurfs(e);

	// build an initial bsp tree using all of the sides
	// of all of the structural brushes
	faces = MakeStructuralBspFaceList(entities[0].brushes);
	tree = FaceBSP(faces);
	MakeTreePortals(tree);
	FilterStructuralBrushesIntoTree(e, tree);

	if(drawFlag)
	{
		// draw unoptimized portals in new window
		drawTree = tree;
		Draw_Scene(DrawTree);
	}

	// see if the bsp is completely enclosed
	if(FloodEntities(tree))
	{
		// rebuild a better bsp tree using only the
		// sides that are visible from the inside
		FillOutside(tree->headnode);

		// chop the sides to the convex hull of
		// their visible fragments, giving us the smallest
		// polygons 
		ClipSidesIntoTree(e, tree);

		faces = MakeVisibleBspFaceList(entities[0].brushes);
		FreeTree(tree);
		tree = FaceBSP(faces);
		MakeTreePortals(tree);
		FilterStructuralBrushesIntoTree(e, tree);
		leaked = qfalse;
	}
	else
	{
		Sys_FPrintf(SYS_NOXML, "**********************\n");
		Sys_FPrintf(SYS_NOXML, "******* leaked *******\n");
		Sys_FPrintf(SYS_NOXML, "**********************\n");

		polyline = LeakFile(tree);
		leaknode = xmlNewNode(NULL, "message");
		xmlNodeSetContent(leaknode, "MAP LEAKED\n");
		xmlAddChild(leaknode, polyline);
		level[0] = (int)'0' + SYS_ERR;
		level[1] = 0;
		xmlSetProp(leaknode, "level", (char *)&level);
		xml_SendNode(leaknode);

		if(leaktest)
		{
			Sys_Printf("--- MAP LEAKED, ABORTING LEAKTEST ---\n");
			exit(0);
		}
		leaked = qtrue;

		// chop the sides to the convex hull of
		// their visible fragments, giving us the smallest
		// polygons 
		ClipSidesIntoTree(e, tree);
	}

	// save out information for visibility processing
	NumberClusters(tree);

	if(!leaked)
	{
		WritePortalFile(tree);
	}

	if(glview)
	{
		// dump the portals for debugging
		WriteGLView(tree, source);
	}

	FloodAreas(tree);

	if(drawFlag)
	{
		// draw optimized portals in new window
		drawTree = tree;
		Draw_Scene(DrawTree);
	}

	// add references to the detail brushes
	FilterDetailBrushesIntoTree(e, tree);

	// create drawsurfs for triangle models
	AddTriangleModels();

	// drawsurfs that cross fog boundaries will need to
	// be split along the bound
	if(!nofog)
	{
		FogDrawSurfs();			// may fragment drawsurfs
	}

	// subdivide each drawsurf as required by shader tesselation
	if(!nosubdivide)
	{
		SubdivideDrawSurfs(e, tree);
	}

	// merge together all common shaders on the same plane and remove 
	// all colinear points, so extra tjunctions won't be generated
	if(!nomerge)
	{
		MergeSides(e, tree);	// !@# testing
	}

	// add in any vertexes required to fix tjunctions
	if(!notjunc)
	{
		FixTJunctions(e);
	}

	// allocate lightmaps for faces and patches
	AllocateLightmaps(e);

	// add references to the final drawsurfs in the apropriate clusters
	FilterDrawsurfsIntoTree(e, tree);

	EndModel(e, tree->headnode);

	FreeTree(tree);
}
コード例 #27
0
ファイル: host_cmd.c プロジェクト: EIREXE/Quakeforge-gcw0
static void
Host_Savegame_f (void)
{
	dstring_t  *name;
	const char *save_name;
	char       *save_text;
	QFile      *f;
	int         i;
	char       *bup1, *bup2 = 0;


	if (cmd_source != src_command)
		return;

	if (!sv.active) {
		Sys_Printf ("Not playing a local game.\n");
		return;
	}

	if (cl.intermission) {
		Sys_Printf ("Can't save in intermission.\n");
		return;
	}

	if (svs.maxclients != 1) {
		Sys_Printf ("Can't save multiplayer games.\n");
		return;
	}

	if (Cmd_Argc () != 2) {
		Sys_Printf ("save <savename> : save a game\n");
		return;
	}

	if (strstr (Cmd_Argv (1), "..")) {
		Sys_Printf ("Relative pathnames are not allowed.\n");
		return;
	}

	for (i = 0; i < svs.maxclients; i++) {
		if (svs.clients[i].active && (SVfloat (svs.clients[i].edict, health)
									  <= 0)) {
			Sys_Printf ("Can't savegame with a dead player\n");
			return;
		}
	}

	save_name = Cmd_Argv (1);
	name = dstring_newstr ();
	if (strcmp  (save_name, "quick") == 0) {
		bup2 = nva ("%s/%s%d.sav", qfs_gamedir->dir.def, save_name, MAX_QUICK);
		QFS_Remove (bup2);
		for (i = MAX_QUICK - 1; i > 0; i--) {
			bup1 = nva ("%s/%s%d.sav", qfs_gamedir->dir.def, save_name, i);
			QFS_Rename (bup1, bup2);
			free (bup2);
			bup2 = bup1;
		}
	}
	dsprintf (name, "%s/%s", qfs_gamedir->dir.def, save_name);
	QFS_DefaultExtension (name, ".sav");

	if (bup2) {
		QFS_Rename (name->str, bup2);
		free (bup2);
	}
	Sys_Printf ("Saving game to %s...\n", name->str);
	f = QFS_WOpen (name->str, 0);
	dstring_delete (name);
	if (!f) {
		Sys_Printf ("ERROR: couldn't open.\n");
		return;
	}

	save_text = PL_WritePropertyList (game_dict ());
	Qprintf (f, "%s\n%s", PACKAGE_NAME, save_text);
	free (save_text);

	Qclose (f);
	Sys_Printf ("done.\n");
}
コード例 #28
0
ファイル: bsp.c プロジェクト: otty/cake3
int BspMain(int argc, char **argv)
{
	int             i;
	double          start, end;
	char            path[1024];

	Sys_Printf("---- bsp ----\n");

	for(i = 1; i < argc; i++)
	{
		if(!strcmp(argv[i], "-threads"))
		{
			numthreads = atoi(argv[i + 1]);
			i++;
		}
		else if(!strcmp(argv[i], "-glview"))
		{
			glview = qtrue;
		}
		else if(!strcmp(argv[i], "-v"))
		{
			Sys_Printf("verbose = true\n");
			verbose = qtrue;
		}
		else if(!strcmp(argv[i], "-draw"))
		{
			Sys_Printf("drawflag = true\n");
			drawFlag = qtrue;
		}
		else if(!strcmp(argv[i], "-debugsurfaces"))
		{
			Sys_Printf("emitting debug surfaces\n");
			debugSurfaces = qtrue;
		}
		else if(!strcmp(argv[i], "-nowater"))
		{
			Sys_Printf("nowater = true\n");
			noliquids = qtrue;
		}
		else if(!strcmp(argv[i], "-nodetail"))
		{
			Sys_Printf("nodetail = true\n");
			nodetail = qtrue;
		}
		else if(!strcmp(argv[i], "-fulldetail"))
		{
			Sys_Printf("fulldetail = true\n");
			fulldetail = qtrue;
		}
		else if(!strcmp(argv[i], "-onlyents"))
		{
			Sys_Printf("onlyents = true\n");
			onlyents = qtrue;
		}
		else if(!strcmp(argv[i], "-onlytextures"))
		{
			Sys_Printf("onlytextures = true\n");	// FIXME: make work again!
			onlytextures = qtrue;
		}
		else if(!strcmp(argv[i], "-micro"))
		{
			microvolume = atof(argv[i + 1]);
			Sys_Printf("microvolume = %f\n", microvolume);
			i++;
		}
		else if(!strcmp(argv[i], "-nofog"))
		{
			Sys_Printf("nofog = true\n");
			nofog = qtrue;
		}
		else if(!strcmp(argv[i], "-nosubdivide"))
		{
			Sys_Printf("nosubdivide = true\n");
			nosubdivide = qtrue;
		}
		else if(!strcmp(argv[i], "-leaktest"))
		{
			Sys_Printf("leaktest = true\n");
			leaktest = qtrue;
		}
		else if(!strcmp(argv[i], "-nocurves"))
		{
			nocurves = qtrue;
			Sys_Printf("no curve brushes\n");
		}
		else if(!strcmp(argv[i], "-nodoors"))
		{
			nodoors = qtrue;
			Sys_Printf("no door entities\n");
		}
		else if(!strcmp(argv[i], "-notjunc"))
		{
			notjunc = qtrue;
			Sys_Printf("no tjunction fixing\n");
		}
		else if(!strcmp(argv[i], "-expand"))
		{
			testExpand = qtrue;
			Sys_Printf("Writing expanded.map.\n");
		}
		else if(!strcmp(argv[i], "-showseams"))
		{
			showseams = qtrue;
			Sys_Printf("Showing seams on terrain.\n");
		}
		else if(!strcmp(argv[i], "-tmpout"))
		{
			strcpy(outbase, "/tmp");
		}
		else if(!strcmp(argv[i], "-fakemap"))
		{
			fakemap = qtrue;
			Sys_Printf("will generate fakemap.map\n");
		}
		else if(!strcmp(argv[i], "-samplesize"))
		{
			samplesize = atoi(argv[i + 1]);
			if(samplesize < 1)
				samplesize = 1;
			i++;
			Sys_Printf("lightmap sample size is %dx%d units\n", samplesize, samplesize);
		}
		else if(!strcmp(argv[i], "-connect"))
		{
			Broadcast_Setup(argv[++i]);
		}
		else if(argv[i][0] == '-')
			Error("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if(i != argc - 1)
	{
		Error("usage: xmap -map2bsp [-<switch> [-<switch> ...]] <mapname.map>\n"
			  "\n"
			  "Switches:\n"
			  "   v              = verbose output\n"
			  "   threads <X>    = set number of threads to X\n"
			  "   nocurves       = don't emit bezier surfaces\n" "   nodoors        = disable door entities\n"
			  //"   breadthfirst   = breadth first bsp building\n"
			  //"   nobrushmerge   = don't merge brushes\n"
			  "   noliquids      = don't write liquids to map\n"
			  //"   nocsg                                = disables brush chopping\n"
			  //"   glview     = output a GL view\n"
			  "   draw           = enables mini BSP viewer\n"
			  //"   noweld     = disables weld\n"
			  //"   noshare    = disables sharing\n"
			  "   notjunc        = disables juncs\n" "   nowater        = disables water brushes\n"
			  //"   noprune    = disables node prunes\n"
			  //"   nomerge    = disables face merging\n"
			  "   nofog          = disables fogs\n"
			  "   nosubdivide    = disables subdivision of draw surfaces\n"
			  "   nodetail       = disables detail brushes\n"
			  "   fulldetail     = enables full detail\n"
			  "   onlyents       = only compile entities with bsp\n"
			  "   micro <volume>\n"
			  "                  = sets the micro volume to the given float\n" "   leaktest       = perform a leak test\n"
			  //"   chop <subdivide_size>\n"
			  //"              = sets the subdivide size to the given float\n"
			  "   samplesize <N> = set the lightmap pixel size to NxN units\n");
	}

	start = I_FloatTime();

	ThreadSetDefault();

	SetQdirFromPath(argv[i]);

	strcpy(source, ExpandArg(argv[i]));
	StripExtension(source);

	// delete portal and line files
	sprintf(path, "%s.prt", source);
	remove(path);
	sprintf(path, "%s.lin", source);
	remove(path);

	strcpy(name, ExpandArg(argv[i]));
	if(strcmp(name + strlen(name) - 4, ".reg"))
	{
		// if we are doing a full map, delete the last saved region map
		sprintf(path, "%s.reg", source);
		remove(path);

		DefaultExtension(name, ".map");	// might be .reg
	}

	// if onlyents, just grab the entites and resave
	if(onlyents)
	{
		OnlyEnts();

		// shut down connection
		Broadcast_Shutdown();

		return 0;
	}

	// if onlytextures, just grab the textures and resave
	if(onlytextures)
	{
		OnlyTextures();

		// shut down connection
		Broadcast_Shutdown();

		return 0;
	}

	// start from scratch
	LoadShaderInfo();

	LoadMapFile(name);

	ProcessModels();

	SetModelNumbers();

	EndBSPFile();

	end = I_FloatTime();
	Sys_Printf("%5.0f seconds elapsed\n", end - start);

	// shut down connection
	Broadcast_Shutdown();

	return 0;
}
コード例 #29
0
ファイル: host_cmd.c プロジェクト: EIREXE/Quakeforge-gcw0
static void
Host_Version_f (void)
{
	Sys_Printf ("Version %s\n", PACKAGE_VERSION);
	Sys_Printf ("Exe: " __TIME__ " " __DATE__ "\n");
}
コード例 #30
0
ファイル: threads.c プロジェクト: TTimo/GtkRadiant
/*
   =============
   RunThreadsOn
   =============
 */
void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
	int i;
	pthread_t work_threads[MAX_THREADS];
	pthread_addr_t status;
	pthread_attr_t attrib;
	pthread_mutexattr_t mattrib;
	int start, end;

	start = I_FloatTime();
	dispatch = 0;
	workcount = workcnt;
	oldf = -1;
	pacifier = showpacifier;
	threaded = true;

	if ( pacifier ) {
		setbuf( stdout, NULL );
	}

	if ( !my_mutex ) {
		my_mutex = safe_malloc( sizeof( *my_mutex ) );
		if ( pthread_mutexattr_create( &mattrib ) == -1 ) {
			Error( "pthread_mutex_attr_create failed" );
		}
		if ( pthread_mutexattr_setkind_np( &mattrib, MUTEX_FAST_NP ) == -1 ) {
			Error( "pthread_mutexattr_setkind_np failed" );
		}
		if ( pthread_mutex_init( my_mutex, mattrib ) == -1 ) {
			Error( "pthread_mutex_init failed" );
		}
	}

	if ( pthread_attr_create( &attrib ) == -1 ) {
		Error( "pthread_attr_create failed" );
	}
	if ( pthread_attr_setstacksize( &attrib, 0x100000 ) == -1 ) {
		Error( "pthread_attr_setstacksize failed" );
	}

	for ( i = 0 ; i < numthreads ; i++ )
	{
		if ( pthread_create( &work_threads[i], attrib
							 , (pthread_startroutine_t)func, (pthread_addr_t)i ) == -1 ) {
			Error( "pthread_create failed" );
		}
	}

	for ( i = 0 ; i < numthreads ; i++ )
	{
		if ( pthread_join( work_threads[i], &status ) == -1 ) {
			Error( "pthread_join failed" );
		}
	}

	threaded = false;

	end = I_FloatTime();
	if ( pacifier ) {
		Sys_Printf( " (%i)\n", end - start );
	}
}