本文整理汇总了C++中Sys_Printf函数的典型用法代码示例。如果您正苦于以下问题:C++ Sys_Printf函数的具体用法?C++ Sys_Printf怎么用?C++ Sys_Printf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sys_Printf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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: QERPlug_Dispatch
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: Host_Loadgame_f
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"));
//.........这里部分代码省略.........
示例4: InitConProc
/*
==============
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: VisMain
/*
===========
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 */
//.........这里部分代码省略.........
示例6: SplitMeshByPlane
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 );
//.........这里部分代码省略.........
示例7: ExtrapolateTexcoords
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: ThreadStats
void ThreadStats (void)
{
if( numthreads <= 0 )
ThreadSetDefault();
Sys_Printf (" %i threads\n", numthreads);
}
示例9: ConvertMapToMap
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: SV_ParseLogin
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: SV_ReadClientMessage
/*
===================
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)
//.........这里部分代码省略.........
示例12: Eclass_Init
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: Eclass_CreateSpriteModelPaths
/*!
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: MIDI_Play
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: CalcTextureReflectivity_Heretic2
/*
======================
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;
}
}
}