您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Hunk_Alloc函数代码示例

51自学网 2021-06-01 21:26:22
  C++
这篇教程C++ Hunk_Alloc函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中Hunk_Alloc函数的典型用法代码示例。如果您正苦于以下问题:C++ Hunk_Alloc函数的具体用法?C++ Hunk_Alloc怎么用?C++ Hunk_Alloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Hunk_Alloc函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Mod_LoadVertexes

/*=================Mod_LoadVertexes=================*/void Mod_LoadVertexes (lump_t *l){	dvertex_t	*in;	mvertex_t	*out;	int			i, count;	in = (void *)(mod_base + l->fileofs);	if (l->filelen % sizeof(*in))		VID_Printf (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);	count = l->filelen / sizeof(*in);	out = Hunk_Alloc ( count*sizeof(*out));		loadmodel->vertexes = out;	loadmodel->numvertexes = count;	for ( i=0 ; i<count ; i++, in++, out++)	{		out->position[0] = LittleFloat (in->point[0]);		out->position[1] = LittleFloat (in->point[1]);		out->position[2] = LittleFloat (in->point[2]);	}}
开发者ID:mattx86,项目名称:myq2,代码行数:27,


示例2: Mod_LoadVisibility

voidMod_LoadVisibility(lump_t *l){	int i;	if (!l->filelen)	{		loadmodel->vis = NULL;		return;	}	loadmodel->vis = Hunk_Alloc(l->filelen);	memcpy(loadmodel->vis, mod_base + l->fileofs, l->filelen);	loadmodel->vis->numclusters = LittleLong(loadmodel->vis->numclusters);	for (i = 0; i < loadmodel->vis->numclusters; i++)	{		loadmodel->vis->bitofs[i][0] = LittleLong(loadmodel->vis->bitofs[i][0]);		loadmodel->vis->bitofs[i][1] = LittleLong(loadmodel->vis->bitofs[i][1]);	}}
开发者ID:DrItanium,项目名称:yquake2,代码行数:22,


示例3: LoadSP2

voidLoadSP2 ( model_t *mod, void *buffer ){	dsprite_t   *sprin, *sprout;	int i;	sprin = (dsprite_t *) buffer;	sprout = Hunk_Alloc( modfilelen );	sprout->ident = LittleLong( sprin->ident );	sprout->version = LittleLong( sprin->version );	sprout->numframes = LittleLong( sprin->numframes );	if ( sprout->version != SPRITE_VERSION )	{		ri.Sys_Error( ERR_DROP, "%s has wrong version number (%i should be %i)",				mod->name, sprout->version, SPRITE_VERSION );	}	if ( sprout->numframes > MAX_MD2SKINS )	{		ri.Sys_Error( ERR_DROP, "%s has too many frames (%i > %i)",				mod->name, sprout->numframes, MAX_MD2SKINS );	}	/* byte swap everything */	for ( i = 0; i < sprout->numframes; i++ )	{		sprout->frames [ i ].width = LittleLong( sprin->frames [ i ].width );		sprout->frames [ i ].height = LittleLong( sprin->frames [ i ].height );		sprout->frames [ i ].origin_x = LittleLong( sprin->frames [ i ].origin_x );		sprout->frames [ i ].origin_y = LittleLong( sprin->frames [ i ].origin_y );		memcpy( sprout->frames [ i ].name, sprin->frames [ i ].name, MAX_SKINNAME );		mod->skins [ i ] = R_FindImage( sprout->frames [ i ].name,				it_sprite );	}	mod->type = mod_sprite;}
开发者ID:Nekrofage,项目名称:Quake2RPi,代码行数:39,


示例4: Mod_LoadSurfedges

/*=================Mod_LoadSurfedges=================*/void Mod_LoadSurfedges (lump_t *l, FILE *file, long base){		int		i, count;	int		*out;		Com_DPrintf("%s/n", __FUNCTION__);	fseek(file, base + l->fileofs, SEEK_SET);	if (l->filelen % sizeof(int))		ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);	count = l->filelen / sizeof(int);	out = Hunk_Alloc (&hunk_ref, l->filelen);		loadmodel->surfedges = out;	loadmodel->numsurfedges = count;	ri.FS_Read(out, l->filelen, file);		Com_DPrintf("%s OK/n", __FUNCTION__);}
开发者ID:petmac,项目名称:quake2-lite,代码行数:27,


示例5: Mod_LoadSubmodels

/*=================Mod_LoadSubmodels=================*/void Mod_LoadSubmodels (lump_t *l, FILE *file, long base){	dmodel_t	in[MAX_MAP_MODELS];	mmodel_t	*out;	int			i, j, count;		Com_DPrintf("%s/n", __FUNCTION__);	fseek(file, base + l->fileofs, SEEK_SET);	if (l->filelen % sizeof(dmodel_t))		ri.Sys_Error (ERR_DROP, "Mod_LoadSubmodels: funny lump size in %s",loadmodel->name);	count = l->filelen / sizeof(dmodel_t);	if (count > MAX_MAP_MODELS)		ri.Sys_Error(ERR_DROP, "%s: Too many (%d) in %s", __FUNCTION__, count, loadmodel->name);	out = Hunk_Alloc (&hunk_ref, count*sizeof(*out));		loadmodel->submodels = out;	loadmodel->numsubmodels = count;	ri.FS_Read(in, l->filelen, file);	for ( i=0 ; i<count ; i++, out++)	{		for (j=0 ; j<3 ; j++)		{	// spread the mins / maxs by a pixel			out->mins[j] = LittleFloat (in[i].mins[j]) - 1;			out->maxs[j] = LittleFloat (in[i].maxs[j]) + 1;			out->origin[j] = LittleFloat (in[i].origin[j]);		}		out->radius = RadiusFromBounds (out->mins, out->maxs);		out->headnode = LittleLong (in[i].headnode);		out->firstface = LittleLong (in[i].firstface);		out->numfaces = LittleLong (in[i].numfaces);	}		Com_DPrintf("%s OK/n", __FUNCTION__);}
开发者ID:petmac,项目名称:quake2-lite,代码行数:43,


示例6: Mod_LoadSurfedges

/*=================Mod_LoadSurfedges=================*/void Mod_LoadSurfedges (lump_t *l, FILE *file, long base){		int		i, count;	int		in, *out;	fseek(file, base + l->fileofs, SEEK_SET);		if (l->filelen % sizeof(in))		ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);	count = l->filelen / sizeof(in);	out = Hunk_Alloc (&hunk_ref, count*sizeof(*out));		loadmodel->surfedges = out;	loadmodel->numsurfedges = count;	for ( i=0 ; i<count ; i++)	{		ri.FS_Read(&in, sizeof(in), file);		out[i] = LittleLong (in);	}}
开发者ID:petmac,项目名称:quake2-lite,代码行数:28,


示例7: Mod_LoadLighting

/*=================Mod_LoadLightingConverts the 24 bit lighting down to 8 bitby taking the brightest component=================*/void Mod_LoadLighting (lump_t *l){	int		i, size;	byte	*in;	if (!l->filelen)	{		loadmodel->lightdata = NULL;		return;	}	size = l->filelen/3;	loadmodel->lightdata = Hunk_Alloc (size);	in = (void *)(mod_base + l->fileofs);	for (i=0 ; i<size ; i++, in+=3)	{		if (in[0] > in[1] && in[0] > in[2])			loadmodel->lightdata[i] = in[0];		else if (in[1] > in[0] && in[1] > in[2])			loadmodel->lightdata[i] = in[1];		else			loadmodel->lightdata[i] = in[2];	}}
开发者ID:AJenbo,项目名称:Quake-2,代码行数:31,


示例8: Mod_LoadMarksurfaces

/*=================Mod_LoadMarksurfaces=================*/void Mod_LoadMarksurfaces (lump_t *l){		int		i, j, count;	short		*in;	msurface_t **out;		in = (void *)(mod_base + l->fileofs);	if (l->filelen % sizeof(*in))		ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);	count = l->filelen / sizeof(*in);	out = Hunk_Alloc ( count*sizeof(*out));		loadmodel->marksurfaces = out;	loadmodel->nummarksurfaces = count;	for ( i=0 ; i<count ; i++)	{		j = LittleShort(in[i]);		if (j < 0 ||  j >= loadmodel->numsurfaces)			ri.Sys_Error (ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");		out[i] = loadmodel->surfaces + j;	}}
开发者ID:dschimmer,项目名称:omega-q2-engine,代码行数:28,


示例9: Mod_LoadSubmodels

voidMod_LoadSubmodels(lump_t *l){	dmodel_t *in;	mmodel_t *out;	int i, j, count;	in = (void *)(mod_base + l->fileofs);	if (l->filelen % sizeof(*in))	{		ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",				loadmodel->name);	}	count = l->filelen / sizeof(*in);	out = Hunk_Alloc(count * sizeof(*out));	loadmodel->submodels = out;	loadmodel->numsubmodels = count;	for (i = 0; i < count; i++, in++, out++)	{		for (j = 0; j < 3; j++)		{			/* spread the mins / maxs by a pixel */			out->mins[j] = LittleFloat(in->mins[j]) - 1;			out->maxs[j] = LittleFloat(in->maxs[j]) + 1;			out->origin[j] = LittleFloat(in->origin[j]);		}		out->radius = Mod_RadiusFromBounds(out->mins, out->maxs);		out->headnode = LittleLong(in->headnode);		out->firstface = LittleLong(in->firstface);		out->numfaces = LittleLong(in->numfaces);	}}
开发者ID:DrItanium,项目名称:yquake2,代码行数:37,


示例10: Mod_LoadEdges

/*=================Mod_LoadEdges=================*/void Mod_LoadEdges (lump_t *l, FILE *file, long base){	dedge_t in;	medge_t *out;	int 	i, count;	fseek(file, base + l->fileofs, SEEK_SET);	if (l->filelen % sizeof(in))		ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);	count = l->filelen / sizeof(in);	out = Hunk_Alloc (&hunk_ref, (count + 1) * sizeof(*out));		loadmodel->edges = out;	loadmodel->numedges = count;	for ( i=0 ; i<count ; i++, out++)	{		ri.FS_Read(&in, sizeof(in), file);		out->v[0] = (unsigned short)LittleShort(in.v[0]);		out->v[1] = (unsigned short)LittleShort(in.v[1]);	}}
开发者ID:petmac,项目名称:quake2-lite,代码行数:29,


示例11: Mod_LoadSpriteModel

/*=================Mod_LoadSpriteModel=================*/void Mod_LoadSpriteModel (model_t *mod, FILE *file, long base){	dsprite_t	*sprout;	int			i;	sprout = Hunk_Alloc (&hunk_ref, modfilelen);	ri.FS_Read(sprout, modfilelen, file);	mod->sprite = sprout;	sprout->ident = LittleLong (sprout->ident);	sprout->version = LittleLong (sprout->version);	sprout->numframes = LittleLong (sprout->numframes);	if (sprout->version != SPRITE_VERSION)		ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",				 mod->name, sprout->version, SPRITE_VERSION);	if (sprout->numframes > MAX_MD2SKINS)		ri.Sys_Error (ERR_DROP, "%s has too many frames (%i > %i)",				 mod->name, sprout->numframes, MAX_MD2SKINS);	// byte swap everything and load the images.	for (i=0 ; i<sprout->numframes ; i++)	{		sprout->frames[i].width = LittleLong (sprout->frames[i].width);		sprout->frames[i].height = LittleLong (sprout->frames[i].height);		sprout->frames[i].origin_x = LittleLong (sprout->frames[i].origin_x);		sprout->frames[i].origin_y = LittleLong (sprout->frames[i].origin_y);		mod->skins[i] = GL_FindImage (sprout->frames[i].name,			it_sprite);	}	mod->type = mod_sprite;}
开发者ID:petmac,项目名称:quake2-lite,代码行数:41,


示例12: Cmd_AddCommand

/*============Cmd_AddCommand============*/void Cmd_AddCommand (char *cmd_name, xcommand_t function){	cmd_function_t	*cmd;	int	key;		if (host_initialized)	// because hunk allocation would get stomped		assert(!"Cmd_AddCommand after host_initialized");#if 0// fail if the command is a variable name	if (Cvar_FindVar(cmd_name)) {		Com_Printf ("Cmd_AddCommand: %s already defined as a var/n", cmd_name);		return;	}#endif	key = Com_HashKey (cmd_name);// fail if the command already exists	for (cmd=cmd_hash_array[key] ; cmd ; cmd=cmd->hash_next)	{		if (!Q_stricmp (cmd_name, cmd->name))		{			Com_Printf ("Cmd_AddCommand: %s already defined/n", cmd_name);			return;		}	}	cmd = Hunk_Alloc (sizeof(cmd_function_t));	cmd->name = cmd_name;	cmd->function = function;	cmd->next = cmd_functions;	cmd_functions = cmd;	cmd->hash_next = cmd_hash_array[key];	cmd_hash_array[key] = cmd;}
开发者ID:matatk,项目名称:agrip,代码行数:41,


示例13: GL_MakeAliasModelDisplayLists_VBO

/*================GL_MakeAliasModelDisplayLists_VBOSaves data needed to build the VBO for this model on the hunk. Afterwards thisis copied to Mod_Extradata.Original code by MH from RMQEngine================*/void GL_MakeAliasModelDisplayLists_VBO (void){	int i, j;	int maxverts_vbo;	trivertx_t *verts;	unsigned short *indexes;	aliasmesh_t *desc;	// first, copy the verts onto the hunk	verts = (trivertx_t *) Hunk_Alloc (paliashdr->numposes * paliashdr->numverts * sizeof(trivertx_t));	paliashdr->vertexes = (byte *)verts - (byte *)paliashdr;	for (i=0 ; i<paliashdr->numposes ; i++)		for (j=0 ; j<paliashdr->numverts ; j++)			verts[i*paliashdr->numverts + j] = poseverts[i][j];	// there can never be more than this number of verts and we just put them all on the hunk	maxverts_vbo = pheader->numtris * 3;	desc = (aliasmesh_t *) Hunk_Alloc (sizeof (aliasmesh_t) * maxverts_vbo);	// there will always be this number of indexes	indexes = (unsigned short *) Hunk_Alloc (sizeof (unsigned short) * maxverts_vbo);	pheader->indexes = (intptr_t) indexes - (intptr_t) pheader;	pheader->meshdesc = (intptr_t) desc - (intptr_t) pheader;	pheader->numindexes = 0;	pheader->numverts_vbo = 0;	for (i = 0; i < pheader->numtris; i++)	{		for (j = 0; j < 3; j++)		{			int v;			// index into hdr->vertexes			unsigned short vertindex = triangles[i].vertindex[j];			// basic s/t coords			int s = stverts[vertindex].s;			int t = stverts[vertindex].t;			// check for back side and adjust texcoord s			if (!triangles[i].facesfront && stverts[vertindex].onseam) s += pheader->skinwidth / 2;			// see does this vert already exist			for (v = 0; v < pheader->numverts_vbo; v++)			{				// it could use the same xyz but have different s and t				if (desc[v].vertindex == vertindex && (int) desc[v].st[0] == s && (int) desc[v].st[1] == t)				{					// exists; emit an index for it					indexes[pheader->numindexes++] = v;					// no need to check any more					break;				}			}			if (v == pheader->numverts_vbo)			{				// doesn't exist; emit a new vert and index				indexes[pheader->numindexes++] = pheader->numverts_vbo;				desc[pheader->numverts_vbo].vertindex = vertindex;				desc[pheader->numverts_vbo].st[0] = s;				desc[pheader->numverts_vbo++].st[1] = t;			}		}	}		// upload immediately	GLMesh_LoadVertexBuffer (aliasmodel, pheader);}
开发者ID:aonorin,项目名称:vkQuake,代码行数:82,


示例14: R_Init

void R_Init( void ) {		int i;	byte *ptr;//	Com_Printf ("----- R_Init -----/n" );	// clear all our internal state	Com_Memset( &tr, 0, sizeof( tr ) );	Com_Memset( &backEnd, 0, sizeof( backEnd ) );#ifndef DEDICATED	Com_Memset( &tess, 0, sizeof( tess ) );#endif//	Swap_Init();#ifndef DEDICATED#ifndef FINAL_BUILD	if ( (int)tess.xyz & 15 ) {		Com_Printf( "WARNING: tess.xyz not 16 byte aligned (%x)/n",(int)tess.xyz & 15 );	}#endif#endif	//	// init function tables	//	for ( i = 0; i < FUNCTABLE_SIZE; i++ )	{		tr.sinTable[i]		= sin( DEG2RAD( i * 360.0f / ( ( float ) ( FUNCTABLE_SIZE - 1 ) ) ) );		tr.squareTable[i]	= ( i < FUNCTABLE_SIZE/2 ) ? 1.0f : -1.0f;		tr.sawToothTable[i] = (float)i / FUNCTABLE_SIZE;		tr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i];		if ( i < FUNCTABLE_SIZE / 2 )		{			if ( i < FUNCTABLE_SIZE / 4 )			{				tr.triangleTable[i] = ( float ) i / ( FUNCTABLE_SIZE / 4 );			}			else			{				tr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4];			}		}		else		{			tr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2];		}	}#ifndef DEDICATED	R_InitFogTable();	R_NoiseInit();#endif	R_Register();	max_polys = r_maxpolys->integer;	if (max_polys < MAX_POLYS)		max_polys = MAX_POLYS;	max_polyverts = r_maxpolyverts->integer;	if (max_polyverts < MAX_POLYVERTS)		max_polyverts = MAX_POLYVERTS;	ptr = (byte *)Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low);	backEndData = (backEndData_t *) ptr;	backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData ));	backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys);#ifndef DEDICATED	R_ToggleSmpFrame();	for(i = 0; i < MAX_LIGHT_STYLES; i++)	{		RE_SetLightStyle(i, -1);	}	InitOpenGL();	R_InitImages();	R_InitShaders(qfalse);	R_InitSkins();	R_TerrainInit(); //rwwRMG - added	R_InitFonts();#endif	R_ModelInit();	G2VertSpaceServer = &CMiniHeap_singleton;#ifndef DEDICATED	R_InitDecals ( );	R_InitWorldEffects();	int	err = qglGetError();	if ( err != GL_NO_ERROR )		Com_Printf ( "glGetError() = 0x%x/n", err);#endif//	Com_Printf ("----- finished R_Init -----/n" );}
开发者ID:Camron,项目名称:OpenJK,代码行数:96,


示例15: SV_SpawnServer

/*================SV_SpawnServerChange the server to a new map, taking all connectedclients along with it.This is NOT called for map_restart================*/void SV_SpawnServer( char *server, qboolean killBots ){	int        i;	int        checksum;	qboolean   isBot;	const char *p;	// shut down the existing game if it is running	SV_ShutdownGameProgs();	Com_Printf( "------ Server Initialization ------/n" );	Com_Printf( "Server: %s/n", server );	// if not running a dedicated server CL_MapLoading will connect the client to the server	// also print some status stuff	CL_MapLoading();	// make sure all the client stuff is unloaded	CL_ShutdownAll();	// clear the whole hunk because we're (re)loading the server	Hunk_Clear();	// clear collision map data     // (SA) NOTE: TODO: used in missionpack	CM_ClearMap();	// wipe the entire per-level structure	SV_ClearServer();	// MrE: main zone should be pretty much emtpy at this point	// except for file system data and cached renderer data	Z_LogHeap();	// allocate empty config strings	for ( i = 0; i < MAX_CONFIGSTRINGS; i++ )	{		sv.configstrings[ i ] = CopyString( "" );		sv.configstringsmodified[ i ] = qfalse;	}	// init client structures and svs.numSnapshotEntities	if ( !Cvar_VariableValue( "sv_running" ) )	{		SV_Startup();	}	else	{		// check for maxclients change		if ( sv_maxclients->modified )		{			SV_ChangeMaxClients();		}#ifdef USE_HUB_SERVER		// if sv_owHubHost was changed, resolve the address again		if ( sv_owHubHost->modified )		{			sv_owHubHost->modified = qfalse;			SV_ResolveowHubHost();		}#endif	}	// clear pak references	FS_ClearPakReferences( 0 );	// allocate the snapshot entities on the hunk	svs.snapshotEntities = Hunk_Alloc( sizeof( entityState_t ) * svs.numSnapshotEntities, h_high );	svs.nextSnapshotEntities = 0;	// toggle the server bit so clients can detect that a	// server has changed	svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;	// set nextmap to the same map, but it may be overriden	// by the game startup or another console command	Cvar_Set( "nextmap", "map_restart 0" );//  Cvar_Set( "nextmap", va("map %s", server) );	// Ridah	// DHM - Nerve :: We want to use the completion bar in multiplayer as well	// Arnout: just always use it//  if( !SV_GameIsSinglePlayer() ) {	SV_SetExpectedHunkUsage( va( "maps/%s.bsp", server ) );//  } else {	// just set it to a negative number,so the cgame knows not to draw the percent bar//      Cvar_Set( "com_expectedhunkusage", "-1" );//  }//.........这里部分代码省略.........
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:101,


示例16: Com_Error

/*=================BotImport_HunkAlloc=================*/static void *BotImport_HunkAlloc( int size ) {	if( Hunk_CheckMark() ) {		Com_Error( ERR_DROP, "SV_Bot_HunkAlloc: Alloc with marks already set" );	}	return Hunk_Alloc( size, h_high );}
开发者ID:baseas,项目名称:aftershock,代码行数:11,


示例17: gl_Mod_MakeAliasModelDisplayLists

//.........这里部分代码省略.........					struct mdfour md;					int         vers = 1;					int         len = numcommands + numorder;					mdfour_begin (&md);					mdfour_update (&md, (unsigned char *) &vers, sizeof (int));					mdfour_update (&md, (unsigned char *) &len, sizeof (int));					mdfour_update (&md, (unsigned char *) &numcommands,								   sizeof (int));					mdfour_update (&md, (unsigned char *) &numorder, sizeof (int));					mdfour_update (&md, (unsigned char *) commands,								   numcommands * sizeof (commands[0]));					mdfour_update (&md, (unsigned char *) vertexorder,								   numorder * sizeof (vertexorder[0]));					mdfour_update (&md, model_digest, MDFOUR_DIGEST_BYTES);					mdfour_result (&md, mesh_digest);					Qwrite (f, &vers, sizeof (int));					Qwrite (f, &len, sizeof (int));					Qwrite (f, &numcommands, sizeof (int));					Qwrite (f, &numorder, sizeof (int));					Qwrite (f, commands, numcommands * sizeof (commands[0]));					Qwrite (f, vertexorder, numorder * sizeof (vertexorder[0]));					Qwrite (f, model_digest, MDFOUR_DIGEST_BYTES);					Qwrite (f, mesh_digest, MDFOUR_DIGEST_BYTES);					Qclose (f);				}			}		}		// save the data out		paliashdr->poseverts = numorder;		cmds = Hunk_Alloc (numcommands * sizeof (int));		paliashdr->commands = (byte *) cmds - (byte *) paliashdr;		memcpy (cmds, commands, numcommands * sizeof (int));	} else {		tex_coord_t *tex_coord;		numorder = 0;		for (i=0; i < pheader->mdl.numtris; i++) {			add_vertex(triangles[i].vertindex[0]);			add_vertex(triangles[i].vertindex[1]);			add_vertex(triangles[i].vertindex[2]);		}		paliashdr->poseverts = numorder;		tex_coord = Hunk_Alloc (numorder * sizeof(tex_coord_t));		paliashdr->tex_coord = (byte *) tex_coord - (byte *) paliashdr;		for (i=0; i < numorder; i++) {			float s, t;			int k;			k = vertexorder[i];			s = stverts[k].s;			t = stverts[k].t;			if (!triangles[i/3].facesfront && stverts[k].onseam)				s += pheader->mdl.skinwidth / 2;	// on back side			s = (s + 0.5) / pheader->mdl.skinwidth;			t = (t + 0.5) / pheader->mdl.skinheight;			tex_coord[i].st[0] = s;			tex_coord[i].st[1] = t;		}	}	if (extra) {
开发者ID:EIREXE,项目名称:Quakeforge-gcw0,代码行数:67,


示例18: VM_Compile

//.........这里部分代码省略.........		case OP_MULF:			EmitCommand(LAST_COMMAND_SUB_DI_4);		// sub edi, 4			EmitString( "D9 07" );		// fld dword ptr [edi]			EmitString( "D8 4f 04" );	// fmul dword ptr [edi+4]			EmitString( "D9 1F" );		// fstp dword ptr [edi]			break;		case OP_CVIF:			EmitString( "DB 07" );		// fild dword ptr [edi]			EmitString( "D9 1F" );		// fstp dword ptr [edi]			break;		case OP_CVFI:#ifndef FTOL_PTR // WHENHELLISFROZENOVER  // bk001213 - was used in 1.17			// not IEEE complient, but simple and fast		  EmitString( "D9 07" );		// fld dword ptr [edi]			EmitString( "DB 1F" );		// fistp dword ptr [edi]#else // FTOL_PTR			// call the library conversion function			EmitString( "D9 07" );		// fld dword ptr [edi]			EmitString( "FF 15" );		// call ftolPtr			Emit4( (int)&ftolPtr );			EmitCommand(LAST_COMMAND_MOV_EDI_EAX);		// mov dword ptr [edi], eax#endif			break;		case OP_SEX8:			EmitString( "0F BE 07" );	// movsx eax, byte ptr [edi]			EmitCommand(LAST_COMMAND_MOV_EDI_EAX);		// mov dword ptr [edi], eax			break;		case OP_SEX16:			EmitString( "0F BF 07" );	// movsx eax, word ptr [edi]			EmitCommand(LAST_COMMAND_MOV_EDI_EAX);		// mov dword ptr [edi], eax			break;		case OP_BLOCK_COPY:			// FIXME: range check			EmitString( "56" );			// push esi			EmitString( "57" );			// push edi			EmitString( "8B 37" );		// mov esi,[edi] 			EmitString( "8B 7F FC" );	// mov edi,[edi-4] 			EmitString( "B9" );			// mov ecx,0x12345678			Emit4( Constant4() >> 2 );			EmitString( "B8" );			// mov eax, datamask			Emit4( vm->dataMask );			EmitString( "BB" );			// mov ebx, database			Emit4( (int)vm->dataBase );			EmitString( "23 F0" );		// and esi, eax			EmitString( "03 F3" );		// add esi, ebx			EmitString( "23 F8" );		// and edi, eax			EmitString( "03 FB" );		// add edi, ebx			EmitString( "F3 A5" );		// rep movsd			EmitString( "5F" );			// pop edi			EmitString( "5E" );			// pop esi			EmitCommand(LAST_COMMAND_SUB_DI_8);		// sub edi, 8			break;		case OP_JUMP:			EmitCommand(LAST_COMMAND_SUB_DI_4);		// sub edi, 4			EmitString( "8B 47 04" );	// mov eax,dword ptr [edi+4]			// FIXME: range check			EmitString( "FF 24 85" );	// jmp dword ptr [instructionPointers + eax * 4]			Emit4( (int)vm->instructionPointers );			break;		default:			Com_Error( ERR_DROP, "VM_CompileX86: bad opcode %i at offset %i", op, pc );		}		pop0 = pop1;		pop1 = op;	}	}	// copy to an exact size buffer on the hunk	vm->codeLength = compiledOfs;	vm->codeBase = (unsigned char *)Hunk_Alloc( compiledOfs, h_low );	Com_Memcpy( vm->codeBase, buf, compiledOfs );	Z_Free( buf );	Z_Free( jused );	Com_Printf( "VM file %s compiled to %i bytes of code/n", vm->name, compiledOfs);	// offset all the instruction pointers for the new location	for ( i = 0 ; i < header->instructionCount ; i++ ) {		vm->instructionPointers[i] += (int)vm->codeBase;	}#if 0 // ndef _WIN32	// Must make the newly generated code executable	{		int r;		unsigned long addr;		int psize = getpagesize();		addr = ((int)vm->codeBase & ~(psize-1)) - psize;		r = mprotect((char*)addr, vm->codeLength + (int)vm->codeBase - addr + psize, 			PROT_READ | PROT_WRITE | PROT_EXEC );		if (r < 0)			Com_Error( ERR_FATAL, "mprotect failed to change PROT_EXEC" );	}#endif}
开发者ID:Boothand,项目名称:jk2mp,代码行数:101,


示例19: Com_sprintf

/*=================VM_LoadQVMLoad a .qvm file=================*/vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {	int					length;	int					dataLength;	int					i;	char				filename[MAX_QPATH];	vmHeader_t	*header;	// load the image	Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", vm->name );	Com_Printf( "Loading vm file %s.../n", filename );	length = FS_ReadFile( filename, (void **)&header );	if ( !header ) {		Com_Printf( "Failed./n" );		VM_Free( vm );		return NULL;	}	if( LittleLong( header->vmMagic ) == VM_MAGIC_VER2 ) {		Com_Printf( "...which has vmMagic VM_MAGIC_VER2/n" );		// byte swap the header		for ( i = 0 ; i < sizeof( vmHeader_t ) / 4 ; i++ ) {			((int *)header)[i] = LittleLong( ((int *)header)[i] );		}		// validate		if ( header->jtrgLength < 0			|| header->bssLength < 0			|| header->dataLength < 0			|| header->litLength < 0			|| header->codeLength <= 0 ) {			VM_Free( vm );			Com_Error( ERR_FATAL, "%s has bad header", filename );		}	} else if( LittleLong( header->vmMagic ) == VM_MAGIC ) {		// byte swap the header		// sizeof( vmHeader_t ) - sizeof( int ) is the 1.32b vm header size		for ( i = 0 ; i < ( sizeof( vmHeader_t ) - sizeof( int ) ) / 4 ; i++ ) {			((int *)header)[i] = LittleLong( ((int *)header)[i] );		}		// validate		if ( header->bssLength < 0			|| header->dataLength < 0			|| header->litLength < 0			|| header->codeLength <= 0 ) {			VM_Free( vm );			Com_Error( ERR_FATAL, "%s has bad header", filename );		}	} else {		VM_Free( vm );		Com_Error( ERR_FATAL, "%s does not have a recognisable "				"magic number in its header", filename );	}	// round up to next power of 2 so all data operations can	// be mask protected	dataLength = header->dataLength + header->litLength + header->bssLength;	for ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) {	}	dataLength = 1 << i;	if( alloc ) {		// allocate zero filled space for initialized and uninitialized data		vm->dataBase = Hunk_Alloc( dataLength, h_high );		vm->dataMask = dataLength - 1;	} else {		// clear the data		Com_Memset( vm->dataBase, 0, dataLength );	}	// copy the intialized data	Com_Memcpy( vm->dataBase, (byte *)header + header->dataOffset, header->dataLength + header->litLength );	// byte swap the longs	for ( i = 0 ; i < header->dataLength ; i += 4 ) {		*(int *)(vm->dataBase + i) = LittleLong( *(int *)(vm->dataBase + i ) );	}	if( header->vmMagic == VM_MAGIC_VER2 ) {		vm->numJumpTableTargets = header->jtrgLength >> 2;		Com_Printf( "Loading %d jump table targets/n", vm->numJumpTableTargets );		if( alloc ) {			vm->jumpTableTargets = Hunk_Alloc( header->jtrgLength, h_high );		} else {			Com_Memset( vm->jumpTableTargets, 0, header->jtrgLength );		}		Com_Memcpy( vm->jumpTableTargets, (byte *)header + header->dataOffset +				header->dataLength + header->litLength, header->jtrgLength );//.........这里部分代码省略.........
开发者ID:AlienHoboken,项目名称:Tremulous-Z-Server,代码行数:101,


示例20: CM_PatchCollideFromGrid

//.........这里部分代码省略.........				borders[EN_LEFT] = gridPlanes[grid->width - 2][j][0];			}			noAdjust[EN_LEFT] = ( borders[EN_LEFT] == gridPlanes[i][j][1] );			if ( borders[EN_LEFT] == -1 || noAdjust[EN_LEFT] ) {				borders[EN_LEFT] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 3 );			}			borders[EN_RIGHT] = -1;			if ( i < grid->width - 2 ) {				borders[EN_RIGHT] = gridPlanes[i + 1][j][1];			} else if ( grid->wrapWidth ) {				borders[EN_RIGHT] = gridPlanes[0][j][1];			}			noAdjust[EN_RIGHT] = ( borders[EN_RIGHT] == gridPlanes[i][j][0] );			if ( borders[EN_RIGHT] == -1 || noAdjust[EN_RIGHT] ) {				borders[EN_RIGHT] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 1 );			}			if ( numFacets == MAX_FACETS ) {				Com_Error( ERR_DROP, "MAX_FACETS" );			}			facet = &facets[numFacets];			memset( facet, 0, sizeof( *facet ) );			if ( gridPlanes[i][j][0] == gridPlanes[i][j][1] ) {				if ( gridPlanes[i][j][0] == -1 ) {					continue;       // degenrate				}				facet->surfacePlane = gridPlanes[i][j][0];				facet->numBorders = 4;				facet->borderPlanes[0] = borders[EN_TOP];				facet->borderNoAdjust[0] = noAdjust[EN_TOP];				facet->borderPlanes[1] = borders[EN_RIGHT];				facet->borderNoAdjust[1] = noAdjust[EN_RIGHT];				facet->borderPlanes[2] = borders[EN_BOTTOM];				facet->borderNoAdjust[2] = noAdjust[EN_BOTTOM];				facet->borderPlanes[3] = borders[EN_LEFT];				facet->borderNoAdjust[3] = noAdjust[EN_LEFT];				CM_SetBorderInward( facet, grid, gridPlanes, i, j, -1 );				if ( CM_ValidateFacet( facet ) ) {					CM_AddFacetBevels( facet );					numFacets++;				}			} else {				// two seperate triangles				facet->surfacePlane = gridPlanes[i][j][0];				facet->numBorders = 3;				facet->borderPlanes[0] = borders[EN_TOP];				facet->borderNoAdjust[0] = noAdjust[EN_TOP];				facet->borderPlanes[1] = borders[EN_RIGHT];				facet->borderNoAdjust[1] = noAdjust[EN_RIGHT];				facet->borderPlanes[2] = gridPlanes[i][j][1];				if ( facet->borderPlanes[2] == -1 ) {					facet->borderPlanes[2] = borders[EN_BOTTOM];					if ( facet->borderPlanes[2] == -1 ) {						facet->borderPlanes[2] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 4 );					}				}				CM_SetBorderInward( facet, grid, gridPlanes, i, j, 0 );				if ( CM_ValidateFacet( facet ) ) {					CM_AddFacetBevels( facet );					numFacets++;				}				if ( numFacets == MAX_FACETS ) {					Com_Error( ERR_DROP, "MAX_FACETS" );				}				facet = &facets[numFacets];				memset( facet, 0, sizeof( *facet ) );				facet->surfacePlane = gridPlanes[i][j][1];				facet->numBorders = 3;				facet->borderPlanes[0] = borders[EN_BOTTOM];				facet->borderNoAdjust[0] = noAdjust[EN_BOTTOM];				facet->borderPlanes[1] = borders[EN_LEFT];				facet->borderNoAdjust[1] = noAdjust[EN_LEFT];				facet->borderPlanes[2] = gridPlanes[i][j][0];				if ( facet->borderPlanes[2] == -1 ) {					facet->borderPlanes[2] = borders[EN_TOP];					if ( facet->borderPlanes[2] == -1 ) {						facet->borderPlanes[2] = CM_EdgePlaneNum( grid, gridPlanes, i, j, 5 );					}				}				CM_SetBorderInward( facet, grid, gridPlanes, i, j, 1 );				if ( CM_ValidateFacet( facet ) ) {					CM_AddFacetBevels( facet );					numFacets++;				}			}		}	}	// copy the results out	pf->numPlanes = numPlanes;	pf->numFacets = numFacets;	pf->facets = Hunk_Alloc( numFacets * sizeof( *pf->facets ), h_high );	memcpy( pf->facets, facets, numFacets * sizeof( *pf->facets ) );	pf->planes = Hunk_Alloc( numPlanes * sizeof( *pf->planes ), h_high );	memcpy( pf->planes, planes, numPlanes * sizeof( *pf->planes ) );}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,


示例21: int

vm_t *VM_Create( const char *module, int (*systemCalls)(int *), 				vmInterpret_t interpret ) {	vm_t		*vm;	vmHeader_t	*header;	int			length;	int			dataLength;	int			i, remaining;	char		filename[MAX_QPATH];	if ( !module || !module[0] || !systemCalls ) {		Com_Error( ERR_FATAL, "VM_Create: bad parms" );	}	remaining = Hunk_MemoryRemaining();	// see if we already have the VM	for ( i = 0 ; i < MAX_VM ; i++ ) {		if (!Q_stricmp(vmTable[i].name, module)) {			vm = &vmTable[i];			return vm;		}	}	// find a free vm	for ( i = 0 ; i < MAX_VM ; i++ ) {		if ( !vmTable[i].name[0] ) {			break;		}	}	if ( i == MAX_VM ) {		Com_Error( ERR_FATAL, "VM_Create: no free vm_t" );	}	vm = &vmTable[i];	Q_strncpyz( vm->name, module, sizeof( vm->name ) );	vm->systemCall = systemCalls;	// never allow dll loading with a demo	if ( interpret == VMI_NATIVE ) {		if ( Cvar_VariableValue( "fs_restrict" ) ) {			interpret = VMI_COMPILED;		}	}	if ( interpret == VMI_NATIVE ) {		// try to load as a system dll		Com_Printf( "Loading dll file %s./n", vm->name );		vm->dllHandle = Sys_LoadDll( module, vm->fqpath , &vm->entryPoint, VM_DllSyscall );		if ( vm->dllHandle ) {			return vm;		}		Com_Printf( "Failed to load dll, looking for qvm./n" );		interpret = VMI_COMPILED;	}	// load the image	Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", vm->name );	Com_Printf( "Loading vm file %s./n", filename );	length = FS_ReadFile( filename, (void **)&header );	if ( !header ) {		Com_Printf( "Failed./n" );		VM_Free( vm );		return NULL;	}	// byte swap the header	for ( i = 0 ; i < sizeof( *header ) / 4 ; i++ ) {		((int *)header)[i] = LittleLong( ((int *)header)[i] );	}	// validate	if ( header->vmMagic != VM_MAGIC		|| header->bssLength < 0 		|| header->dataLength < 0 		|| header->litLength < 0 		|| header->codeLength <= 0 ) {		VM_Free( vm );		Com_Error( ERR_FATAL, "%s has bad header", filename );	}	// round up to next power of 2 so all data operations can	// be mask protected	dataLength = header->dataLength + header->litLength + header->bssLength;	for ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) {	}	dataLength = 1 << i;	// allocate zero filled space for initialized and uninitialized data	vm->dataBase = Hunk_Alloc( dataLength, h_high );	vm->dataMask = dataLength - 1;	// copy the intialized data	Com_Memcpy( vm->dataBase, (byte *)header + header->dataOffset, header->dataLength + header->litLength );	// byte swap the longs	for ( i = 0 ; i < header->dataLength ; i += 4 ) {		*(int *)(vm->dataBase + i) = LittleLong( *(int *)(vm->dataBase + i ) );//.........这里部分代码省略.........
开发者ID:LoudHoward,项目名称:Quake3,代码行数:101,


示例22: Com_sprintf

/*=================VM_LoadQVMLoad a .qvm file=================*/vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc, qboolean unpure){	int					dataLength;	int					i;	char				filename[MAX_QPATH];	union {		vmHeader_t	*h;		void				*v;	} header;	// load the image	Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", vm->name );	Com_Printf( "Loading vm file %s.../n", filename );	FS_ReadFileDir(filename, vm->searchPath, unpure, &header.v);	if ( !header.h ) {		Com_Printf( "Failed./n" );		VM_Free( vm );		Com_Printf(S_COLOR_YELLOW "Warning: Couldn't open VM file %s/n", filename);		return NULL;	}	// show where the qvm was loaded from	FS_Which(filename, vm->searchPath);	if( LittleLong( header.h->vmMagic ) == VM_MAGIC_VER2 ) {		Com_Printf( "...which has vmMagic VM_MAGIC_VER2/n" );		// byte swap the header		for ( i = 0 ; i < sizeof( vmHeader_t ) / 4 ; i++ ) {			((int *)header.h)[i] = LittleLong( ((int *)header.h)[i] );		}		// validate		if ( header.h->jtrgLength < 0			|| header.h->bssLength < 0			|| header.h->dataLength < 0			|| header.h->litLength < 0			|| header.h->codeLength <= 0 )		{			VM_Free(vm);			FS_FreeFile(header.v);						Com_Printf(S_COLOR_YELLOW "Warning: %s has bad header/n", filename);			return NULL;		}	} else if( LittleLong( header.h->vmMagic ) == VM_MAGIC ) {		// byte swap the header		// sizeof( vmHeader_t ) - sizeof( int ) is the 1.32b vm header size		for ( i = 0 ; i < ( sizeof( vmHeader_t ) - sizeof( int ) ) / 4 ; i++ ) {			((int *)header.h)[i] = LittleLong( ((int *)header.h)[i] );		}		// validate		if ( header.h->bssLength < 0			|| header.h->dataLength < 0			|| header.h->litLength < 0			|| header.h->codeLength <= 0 )		{			VM_Free(vm);			FS_FreeFile(header.v);			Com_Printf(S_COLOR_YELLOW "Warning: %s has bad header/n", filename);			return NULL;		}	} else {		VM_Free( vm );		FS_FreeFile(header.v);		Com_Printf(S_COLOR_YELLOW "Warning: %s does not have a recognisable "				"magic number in its header/n", filename);		return NULL;	}	// round up to next power of 2 so all data operations can	// be mask protected	dataLength = header.h->dataLength + header.h->litLength +		header.h->bssLength;	for ( i = 0 ; dataLength > ( 1 << i ) ; i++ ) {	}	dataLength = 1 << i;	if(alloc)	{		// allocate zero filled space for initialized and uninitialized data		vm->dataBase = Hunk_Alloc(dataLength, h_high);		vm->dataMask = dataLength - 1;	}	else	{//.........这里部分代码省略.........
开发者ID:entdark,项目名称:q3mme,代码行数:101,


示例23: SV_SpawnServer

/*================SV_SpawnServerChange the server to a new map, taking all connectedclients along with it.This is NOT called for map_restart================*/void SV_SpawnServer( char *server, qboolean killBots ) {    int			i;    int			checksum;    qboolean	isBot;    char		systemInfo[16384];    const char	*p;    // shut down the existing game if it is running    SV_ShutdownGameProgs();    Com_Printf ("------ Server Initialization ------/n");    Com_Printf ("Server: %s/n",server);    // if not running a dedicated server CL_MapLoading will connect the client to the server    // also print some status stuff    CL_MapLoading();    // make sure all the client stuff is unloaded    CL_ShutdownAll();    // clear the whole hunk because we're (re)loading the server    Hunk_Clear();    // clear collision map data    CM_ClearMap();    // init client structures and svs.numSnapshotEntities    if ( !Cvar_VariableValue("sv_running") ) {        SV_Startup();    } else {        // check for maxclients change        if ( sv_maxclients->modified ) {            SV_ChangeMaxClients();        }    }    // clear pak references    FS_ClearPakReferences(0);    // allocate the snapshot entities on the hunk    svs.snapshotEntities = Hunk_Alloc( sizeof(entityState_t)*svs.numSnapshotEntities, h_high );    svs.nextSnapshotEntities = 0;    // toggle the server bit so clients can detect that a    // server has changed    svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;    // set nextmap to the same map, but it may be overriden    // by the game startup or another console command    Cvar_Set( "nextmap", "map_restart 0");//	Cvar_Set( "nextmap", va("map %s", server) );    // wipe the entire per-level structure    SV_ClearServer();    for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) {        sv.configstrings[i] = CopyString("");    }    // make sure we are not paused    Cvar_Set("cl_paused", "0");    // get a new checksum feed and restart the file system    srand(Com_Milliseconds());    sv.checksumFeed = ( ((int) rand() << 16) ^ rand() ) ^ Com_Milliseconds();    FS_Restart( sv.checksumFeed );    CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum );    // set serverinfo visible name    Cvar_Set( "mapname", server );    Cvar_Set( "sv_mapChecksum", va("%i",checksum) );    // serverid should be different each time    sv.serverId = com_frameTime;    sv.restartedServerId = sv.serverId; // I suppose the init here is just to be safe    sv.checksumFeedServerId = sv.serverId;    Cvar_Set( "sv_serverid", va("%i", sv.serverId ) );    // clear physics interaction links    SV_ClearWorld ();    // media configstring setting should be done during    // the loading stage, so connected clients don't have    // to load during actual gameplay    sv.state = SS_LOADING;    // load and spawn all other entities    SV_InitGameProgs();    // don't allow a map_restart if game is modified//.........这里部分代码省略.........
开发者ID:Avatarchik,项目名称:Quake-III-Arena-D3D11,代码行数:101,


示例24: Mod_LoadAliasModel

/*=================Mod_LoadAliasModel=================*/void Mod_LoadAliasModel (model_t *mod, void *buffer){	int					i, j;	dmdl_t				*pinmodel, *pheader;	dstvert_t			*pinst, *poutst;	dtriangle_t			*pintri, *pouttri;	daliasframe_t		*pinframe, *poutframe;	int					*pincmd, *poutcmd;	int					version;	pinmodel = (dmdl_t *)buffer;	version = LittleLong (pinmodel->version);	if (version != ALIAS_VERSION)		ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",				 mod->name, version, ALIAS_VERSION);	pheader = Hunk_Alloc (LittleLong(pinmodel->ofs_end));		// byte swap the header fields and sanity check	for (i=0 ; i<sizeof(dmdl_t)/4 ; i++)		((int *)pheader)[i] = LittleLong (((int *)buffer)[i]);	if (pheader->skinheight > MAX_LBM_HEIGHT)		ri.Sys_Error (ERR_DROP, "model %s has a skin taller than %d", mod->name,				   MAX_LBM_HEIGHT);	if (pheader->num_xyz <= 0)		ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);	if (pheader->num_xyz > MAX_VERTS)		ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);	if (pheader->num_st <= 0)		ri.Sys_Error (ERR_DROP, "model %s has no st vertices", mod->name);	if (pheader->num_tris <= 0)		ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);	if (pheader->num_frames <= 0)		ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);//// load base s and t vertices (not used in gl version)//	pinst = (dstvert_t *) ((byte *)pinmodel + pheader->ofs_st);	poutst = (dstvert_t *) ((byte *)pheader + pheader->ofs_st);	for (i=0 ; i<pheader->num_st ; i++)	{		poutst[i].s = LittleShort (pinst[i].s);		poutst[i].t = LittleShort (pinst[i].t);	}//// load triangle lists//	pintri = (dtriangle_t *) ((byte *)pinmodel + pheader->ofs_tris);	pouttri = (dtriangle_t *) ((byte *)pheader + pheader->ofs_tris);	for (i=0 ; i<pheader->num_tris ; i++)	{		for (j=0 ; j<3 ; j++)		{			pouttri[i].index_xyz[j] = LittleShort (pintri[i].index_xyz[j]);			pouttri[i].index_st[j] = LittleShort (pintri[i].index_st[j]);		}	}//// load the frames//	for (i=0 ; i<pheader->num_frames ; i++)	{		pinframe = (daliasframe_t *) ((byte *)pinmodel 			+ pheader->ofs_frames + i * pheader->framesize);		poutframe = (daliasframe_t *) ((byte *)pheader 			+ pheader->ofs_frames + i * pheader->framesize);		memcpy (poutframe->name, pinframe->name, sizeof(poutframe->name));		for (j=0 ; j<3 ; j++)		{			poutframe->scale[j] = LittleFloat (pinframe->scale[j]);			poutframe->translate[j] = LittleFloat (pinframe->translate[j]);		}		// verts are all 8 bit, so no swapping needed		memcpy (poutframe->verts, pinframe->verts, 			pheader->num_xyz*sizeof(dtrivertx_t));	}	mod->type = mod_alias;	//	// load the glcmds//.........这里部分代码省略.........
开发者ID:dschimmer,项目名称:omega-q2-engine,代码行数:101,


示例25: VM_LoadSymbols

/*===============VM_LoadSymbols===============*/void VM_LoadSymbols( vm_t *vm ) {	int		len;	char	*mapfile, *text_p, *token;	char	name[MAX_QPATH];	char	symbols[MAX_QPATH];	vmSymbol_t	**prev, *sym;	int		count;	int		value;	int		chars;	int		segment;	int		numInstructions;	// don't load symbols if not developer	if ( !com_developer->integer ) {		return;	}	COM_StripExtension( vm->name, name );	Com_sprintf( symbols, sizeof( symbols ), "vm/%s.map", name );	len = FS_ReadFile( symbols, (void **)&mapfile );	if ( !mapfile ) {		Com_Printf( "Couldn't load symbol file: %s/n", symbols );		return;	}	numInstructions = vm->instructionPointersLength >> 2;	// parse the symbols	text_p = mapfile;	prev = &vm->symbols;	count = 0;	while ( 1 ) {		token = COM_Parse( &text_p );		if ( !token[0] ) {			break;		}		segment = ParseHex( token );		if ( segment ) {			COM_Parse( &text_p );			COM_Parse( &text_p );			continue;		// only load code segment values		}		token = COM_Parse( &text_p );		if ( !token[0] ) {			Com_Printf( "WARNING: incomplete line at end of file/n" );			break;		}		value = ParseHex( token );		token = COM_Parse( &text_p );		if ( !token[0] ) {			Com_Printf( "WARNING: incomplete line at end of file/n" );			break;		}		chars = strlen( token );		sym = Hunk_Alloc( sizeof( *sym ) + chars, h_high );		*prev = sym;		prev = &sym->next;		sym->next = NULL;		// convert value from an instruction number to a code offset		if ( value >= 0 && value < numInstructions ) {			value = vm->instructionPointers[value];		}		sym->symValue = value;		Q_strncpyz( sym->symName, token, chars + 1 );		count++;	}	vm->numSymbols = count;	Com_Printf( "%i symbols parsed from %s/n", count, symbols );	FS_FreeFile( mapfile );}
开发者ID:LoudHoward,项目名称:Quake3,代码行数:82,


示例26: SubdividePolygon

void SubdividePolygon (int numverts, float *verts){	int		i, j, k;	vec3_t	mins, maxs;	float	m;	float	*v;	vec3_t	front[64], back[64];	int		f, b;	float	dist[64];	float	frac;	glpoly_t	*poly;	float	s, t;	vec3_t	total;	float	total_s, total_t;	if (numverts > 60)		ri.Sys_Error (ERR_DROP, "numverts = %i", numverts);	BoundPoly (numverts, verts, mins, maxs);	for (i=0 ; i<3 ; i++)	{		m = (mins[i] + maxs[i]) * 0.5;		m = SUBDIVIDE_SIZE * floor (m/SUBDIVIDE_SIZE + 0.5);		if (maxs[i] - m < 8)			continue;		if (m - mins[i] < 8)			continue;		// cut it		v = verts + i;		for (j=0 ; j<numverts ; j++, v+= 3)			dist[j] = *v - m;		// wrap cases		dist[j] = dist[0];		v-=i;		VectorCopy (verts, v);		f = b = 0;		v = verts;		for (j=0 ; j<numverts ; j++, v+= 3)		{			if (dist[j] >= 0)			{				VectorCopy (v, front[f]);				f++;			}			if (dist[j] <= 0)			{				VectorCopy (v, back[b]);				b++;			}			if (dist[j] == 0 || dist[j+1] == 0)				continue;			if ( (dist[j] > 0) != (dist[j+1] > 0) )			{				// clip point				frac = dist[j] / (dist[j] - dist[j+1]);				for (k=0 ; k<3 ; k++)					front[f][k] = back[b][k] = v[k] + frac*(v[3+k] - v[k]);				f++;				b++;			}		}		SubdividePolygon (f, front[0]);		SubdividePolygon (b, back[0]);		return;	}	// add a point in the center to help keep warp valid	poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float));	poly->next = warpface->polys;	warpface->polys = poly;	poly->numverts = numverts+2;	VectorClear (total);	total_s = 0;	total_t = 0;	for (i=0 ; i<numverts ; i++, verts+= 3)	{		VectorCopy (verts, poly->verts[i+1]);		s = DotProduct (verts, warpface->texinfo->vecs[0]);		t = DotProduct (verts, warpface->texinfo->vecs[1]);		total_s += s;		total_t += t;		VectorAdd (total, verts, total);		poly->verts[i+1][3] = s;		poly->verts[i+1][4] = t;	}	VectorScale (total, (1.0/numverts), poly->verts[0]);	poly->verts[0][3] = total_s/numverts;	poly->verts[0][4] = total_t/numverts;	// copy first vertex to last	memcpy (poly->verts[i+1], poly->verts[1], sizeof(poly->verts[0]));}
开发者ID:Izhido,项目名称:qrevpak,代码行数:100,


示例27: SV_LoadGame_f

void SV_LoadGame_f (void) {	char name[MAX_OSPATH], mapname[MAX_QPATH], str[32 * 1024], *start;	FILE *f;	float time, tfloat, spawn_parms[NUM_SPAWN_PARMS];	edict_t *ent;	int entnum, version, r;	unsigned int i;	if (Cmd_Argc() != 2) {		Com_Printf ("Usage: %s <savename> : load a game/n", Cmd_Argv(0));		return;	}	snprintf (name, sizeof (name), "%s/save/%s", com_gamedir, Cmd_Argv(1));	COM_DefaultExtension (name, ".sav");	Com_Printf ("Loading game from %s.../n", name);	if (!(f = fopen (name, "rb"))) {		Com_Printf ("ERROR: couldn't open./n");		return;	}	fscanf (f, "%i/n", &version);	if (version != SAVEGAME_VERSION) {		fclose (f);		Com_Printf ("Savegame is version %i, not %i/n", version, SAVEGAME_VERSION);		return;	}	fscanf (f, "%s/n", str);	for (i = 0; i < NUM_SPAWN_PARMS; i++)		fscanf (f, "%f/n", &spawn_parms[i]);	// this silliness is so we can load 1.06 save files, which have float skill values	fscanf (f, "%f/n", &tfloat);	current_skill = (int)(tfloat + 0.1);	Cvar_Set (&skill, va("%i", current_skill));	Cvar_SetValue (&deathmatch, 0);	Cvar_SetValue (&coop, 0);	Cvar_SetValue (&teamplay, 0);	Cvar_SetValue (&maxclients, 1);	fscanf (f, "%s/n", mapname);	fscanf (f, "%f/n", &time);	Host_EndGame();	CL_BeginLocalConnection ();	SV_SpawnServer (mapname, false);	if (sv.state != ss_active) {		Com_Printf ("Couldn't load map/n");		return;	}	Cvar_ForceSet (&sv_paused, "1"); // pause until all clients connect	sv.loadgame = true;	// load the light styles	for (i = 0; i < MAX_LIGHTSTYLES; i++) {		fscanf (f, "%s/n", str);		sv.lightstyles[i] = (char *) Hunk_Alloc (strlen(str) + 1);		strlcpy (sv.lightstyles[i], str, strlen(str) + 1);	}	// load the edicts out of the savegame file	entnum = -1;		// -1 is the globals	while (!feof(f)) {		for (i = 0; i < sizeof(str) - 1; i++) {			r = fgetc (f);			if (r == EOF || !r)				break;			str[i] = r;			if (r == '}') {				i++;				break;			}		}		if (i == sizeof(str)-1)			Host_Error ("Loadgame buffer overflow");		str[i] = 0;		start = str;		start = COM_Parse(str);		if (!com_token[0])			break;		// end of file		if (strcmp(com_token,"{"))			Host_Error ("First token isn't a brace");		if (entnum == -1) {				// parse the global vars			ED_ParseGlobals (start);		} else {				// parse an edict			ent = EDICT_NUM(entnum);			memset (&ent->v, 0, progs->entityfields * 4);			ent->free = false;			ED_ParseEdict (start, ent);	//.........这里部分代码省略.........
开发者ID:jogi1,项目名称:camquake,代码行数:101,


示例28: LoadGamestate

int LoadGamestate(char *level, char *startspot){	char	name[MAX_OSPATH];	FILE	*f;	char	mapname[MAX_QPATH];	float	time, sk;	char	str[32768], *start;	int		i, r;	edict_t	*ent;	int		entnum;	int		version;//	float	spawn_parms[NUM_SPAWN_PARMS];	sprintf (name, "%s/%s.gip", com_gamedir, level);		Con_Printf ("Loading game from %s.../n", name);	f = fopen (name, "r");	if (!f)	{		Con_Printf ("ERROR: couldn't open./n");		return -1;	}	fscanf (f, "%i/n", &version);	if (version != SAVEGAME_VERSION)	{		fclose (f);		Con_Printf ("Savegame is version %i, not %i/n", version, SAVEGAME_VERSION);		return -1;	}	fscanf (f, "%s/n", str);//	for (i=0 ; i<NUM_SPAWN_PARMS ; i++)//		fscanf (f, "%f/n", &spawn_parms[i]);	fscanf (f, "%f/n", &sk);	Cvar_SetValue ("skill", sk);	fscanf (f, "%s/n",mapname);	fscanf (f, "%f/n",&time);	SV_SpawnServer (mapname, startspot);	if (!sv.active)	{		Con_Printf ("Couldn't load map/n");		return -1;	}// load the light styles	for (i=0 ; i<MAX_LIGHTSTYLES ; i++)	{		fscanf (f, "%s/n", str);		sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);		strcpy (sv.lightstyles[i], str);	}// load the edicts out of the savegame file	while (!feof(f))	{		fscanf (f, "%i/n",&entnum);		for (i=0 ; i<sizeof(str)-1 ; i++)		{			r = fgetc (f);			if (r == EOF || !r)				break;			str[i] = r;			if (r == '}')			{				i++;				break;			}		}		if (i == sizeof(str)-1)			Sys_Error ("Loadgame buffer overflow");		str[i] = 0;		start = str;		start = COM_Parse(str);		if (!com_token[0])			break;		// end of file		if (strcmp(com_token,"{"))			Sys_Error ("First token isn't a brace");					// parse an edict		ent = EDICT_NUM(entnum);		memset (&ent->v, 0, progs->entityfields * 4);		ent->free = false;		ED_ParseEdict (start, ent);			// link it into the bsp tree		if (!ent->free)			SV_LinkEdict (ent, false);	}	//	sv.num_edicts = entnum;	sv.time = time;	fclose (f);//	for (i=0 ; i<NUM_SPAWN_PARMS ; i++)//		svs.clients->spawn_parms[i] = spawn_parms[i];//.........这里部分代码省略.........
开发者ID:DrLabman,项目名称:Vengeance-r2,代码行数:101,


示例29: Com_Error

/*===================CM_GeneratePatchCollideCreates an internal structure that will be used to performcollision detection with a patch mesh.Points is packed as concatenated rows.===================*/struct patchCollide_s   *CM_GeneratePatchCollide( int width, int height, vec3_t *points ) {	patchCollide_t  *pf;	cGrid_t grid;	int i, j;	if ( width <= 2 || height <= 2 || !points ) {		Com_Error( ERR_DROP, "CM_GeneratePatchFacets: bad parameters: (%i, %i, %p)",				   width, height, (void *)points );	}	if ( !( width & 1 ) || !( height & 1 ) ) {		Com_Error( ERR_DROP, "CM_GeneratePatchFacets: even sizes are invalid for quadratic meshes" );	}	if ( width > MAX_GRID_SIZE || height > MAX_GRID_SIZE ) {		Com_Error( ERR_DROP, "CM_GeneratePatchFacets: source is > MAX_GRID_SIZE" );	}	// build a grid	grid.width = width;	grid.height = height;	grid.wrapWidth = qfalse;	grid.wrapHeight = qfalse;	for ( i = 0 ; i < width ; i++ ) {		for ( j = 0 ; j < height ; j++ ) {			VectorCopy( points[j * width + i], grid.points[i][j] );		}	}	// subdivide the grid	CM_SetGridWrapWidth( &grid );	CM_SubdivideGridColumns( &grid );	CM_RemoveDegenerateColumns( &grid );	CM_TransposeGrid( &grid );	CM_SetGridWrapWidth( &grid );	CM_SubdivideGridColumns( &grid );	CM_RemoveDegenerateColumns( &grid );	// we now have a grid of points exactly on the curve	// the aproximate surface defined by these points will be	// collided against	pf = Hunk_Alloc( sizeof( *pf ), h_high );	ClearBounds( pf->bounds[0], pf->bounds[1] );	for ( i = 0 ; i < grid.width ; i++ ) {		for ( j = 0 ; j < grid.height ; j++ ) {			AddPointToBounds( grid.points[i][j], pf->bounds[0], pf->bounds[1] );		}	}	c_totalPatchBlocks += ( grid.width - 1 ) * ( grid.height - 1 );	// generate a bsp tree for the surface	CM_PatchCollideFromGrid( &grid, pf );	// expand by one unit for epsilon purposes	pf->bounds[0][0] -= 1;	pf->bounds[0][1] -= 1;	pf->bounds[0][2] -= 1;	pf->bounds[1][0] += 1;	pf->bounds[1][1] += 1;	pf->bounds[1][2] += 1;	return pf;}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:77,


示例30: GL_MakeAliasModelDisplayLists

/*================GL_MakeAliasModelDisplayLists================*/void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr){	int		i, j;	maliasgroup_t	*paliasgroup;	int			*cmds;	trivertx_t	*verts;	char	cache[MAX_QPATH], fullpath[MAX_OSPATH], *c;	FILE	*f;	int		len;	byte	*data;	aliasmodel = m;	paliashdr = hdr;	// (aliashdr_t *)Mod_Extradata (m);	//	// look for a cached version	//	strcpy (cache, "glquake/");	COM_StripExtension (m->name+strlen("progs/"), cache+strlen("glquake/"));	strcat (cache, ".ms2");	COM_FOpenFile (cache, &f, NULL);	// 2001-09-12 Returning from which searchpath a file was loaded by Maddes	if (f)	{		fread (&numcommands, 4, 1, f);		fread (&numorder, 4, 1, f);		fread (&commands, numcommands * sizeof(commands[0]), 1, f);		fread (&vertexorder, numorder * sizeof(vertexorder[0]), 1, f);		fclose (f);	}	else	{		//		// build it from scratch		//		Con_Printf ("meshing %s.../n",m->name);		BuildTris ();		// trifans or lists		//		// save out the cached version		//		sprintf (fullpath, "%s/%s", com_gamedir, cache);		f = fopen (fullpath, "wb");		if (f)		{			fwrite (&numcommands, 4, 1, f);			fwrite (&numorder, 4, 1, f);			fwrite (&commands, numcommands * sizeof(commands[0]), 1, f);			fwrite (&vertexorder, numorder * sizeof(vertexorder[0]), 1, f);			fclose (f);		}	}	// save the data out	paliashdr->poseverts = numorder;	cmds = Hunk_Alloc (numcommands * 4);	paliashdr->commands = (byte *)cmds - (byte *)paliashdr;	memcpy (cmds, commands, numcommands * 4);	verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts		* sizeof(trivertx_t) );	paliashdr->posedata = (byte *)verts - (byte *)paliashdr;	for (i=0 ; i<paliashdr->numposes ; i++)		for (j=0 ; j<numorder ; j++)			*verts++ = poseverts[i][vertexorder[j]];}
开发者ID:Blzut3,项目名称:Engoo,代码行数:75,



注:本文中的Hunk_Alloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ Hunk_AllocName函数代码示例
C++ HttpSendRequest函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。