本文整理匯總了C++中GetClearedMemory函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetClearedMemory函數的具體用法?C++ GetClearedMemory怎麽用?C++ GetClearedMemory使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetClearedMemory函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: BotInitInfoEntities
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void BotInitInfoEntities( void ) {
char classname[MAX_EPAIRKEY];
maplocation_t *ml;
campspot_t *cs;
int ent, numlocations, numcampspots;
BotFreeInfoEntities();
//
numlocations = 0;
numcampspots = 0;
for ( ent = AAS_NextBSPEntity( 0 ); ent; ent = AAS_NextBSPEntity( ent ) )
{
if ( !AAS_ValueForBSPEpairKey( ent, "classname", classname, MAX_EPAIRKEY ) ) {
continue;
}
//map locations
if ( !strcmp( classname, "target_location" ) ) {
ml = (maplocation_t *) GetClearedMemory( sizeof( maplocation_t ) );
AAS_VectorForBSPEpairKey( ent, "origin", ml->origin );
AAS_ValueForBSPEpairKey( ent, "message", ml->name, sizeof( ml->name ) );
ml->areanum = AAS_PointAreaNum( ml->origin );
ml->next = maplocations;
maplocations = ml;
numlocations++;
} //end if
//camp spots
else if ( !strcmp( classname, "info_camp" ) ) {
cs = (campspot_t *) GetClearedMemory( sizeof( campspot_t ) );
AAS_VectorForBSPEpairKey( ent, "origin", cs->origin );
//cs->origin[2] += 16;
AAS_ValueForBSPEpairKey( ent, "message", cs->name, sizeof( cs->name ) );
AAS_FloatForBSPEpairKey( ent, "range", &cs->range );
AAS_FloatForBSPEpairKey( ent, "weight", &cs->weight );
AAS_FloatForBSPEpairKey( ent, "wait", &cs->wait );
AAS_FloatForBSPEpairKey( ent, "random", &cs->random );
cs->areanum = AAS_PointAreaNum( cs->origin );
if ( !cs->areanum ) {
botimport.Print( PRT_MESSAGE, "camp spot at %1.1f %1.1f %1.1f in solid\n", cs->origin[0], cs->origin[1], cs->origin[2] );
FreeMemory( cs );
continue;
} //end if
cs->next = campspots;
campspots = cs;
//AAS_DrawPermanentCross(cs->origin, 4, LINECOLOR_YELLOW);
numcampspots++;
} //end else if
} //end for
if ( bot_developer ) {
botimport.Print( PRT_MESSAGE, "%d map locations\n", numlocations );
botimport.Print( PRT_MESSAGE, "%d camp spots\n", numcampspots );
} //end if
} //end of the function BotInitInfoEntities
示例2: GetClearedMemory
//============================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//============================================================================
script_t *LoadScriptMemory(char *ptr, int length, char *name)
{
void *buffer;
script_t *script;
buffer = GetClearedMemory(sizeof(script_t) + length + 1);
script = (script_t *) buffer;
Com_Memset(script, 0, sizeof(script_t));
Q_strncpyz(script->filename, name, sizeof(script->filename));
script->buffer = (char *) buffer + sizeof(script_t);
script->buffer[length] = 0;
script->length = length;
//pointer in script buffer
script->script_p = script->buffer;
//pointer in script buffer before reading token
script->lastscript_p = script->buffer;
//pointer to end of script buffer
script->end_p = &script->buffer[length];
//set if there's a token available in script->token
script->tokenavailable = 0;
//
script->line = 1;
script->lastline = 1;
//
SetScriptPunctuations(script, NULL);
//
Com_Memcpy(script->buffer, ptr, length);
//
return script;
} //end of the function LoadScriptMemory
示例3: AAS_FloodAreas
void AAS_FloodAreas(vector3 *origin) {
int areanum, cluster, *done;
done = (int *) GetClearedMemory(aasworld.numareas * sizeof(int));
areanum = AAS_PointAreaNum(origin);
cluster = AAS_AreaCluster(areanum);
AAS_FloodAreas_r(areanum, cluster, done);
}
示例4: BotInterpolateCharacters
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int BotInterpolateCharacters( int handle1, int handle2, int desiredskill )
{
bot_character_t *ch1, *ch2, *out;
int i, handle;
float scale;
ch1 = BotCharacterFromHandle( handle1 );
ch2 = BotCharacterFromHandle( handle2 );
if ( !ch1 || !ch2 )
{
return 0;
}
//find a free spot for a character
for ( handle = 1; handle <= MAX_CLIENTS; handle++ )
{
if ( !botcharacters[ handle ] )
{
break;
}
} //end for
if ( handle > MAX_CLIENTS )
{
return 0;
}
out = ( bot_character_t * ) GetClearedMemory( sizeof( bot_character_t ) + MAX_CHARACTERISTICS * sizeof( bot_characteristic_t ) );
out->skill = desiredskill;
strcpy( out->filename, ch1->filename );
botcharacters[ handle ] = out;
scale = ( float )( desiredskill - 1 ) / ( ch2->skill - ch1->skill );
for ( i = 0; i < MAX_CHARACTERISTICS; i++ )
{
//
if ( ch1->c[ i ].type == CT_FLOAT && ch2->c[ i ].type == CT_FLOAT )
{
out->c[ i ].type = CT_FLOAT;
out->c[ i ].value._float = ch1->c[ i ].value._float + ( ch2->c[ i ].value._float - ch1->c[ i ].value._float ) * scale;
} //end if
else if ( ch1->c[ i ].type == CT_INTEGER )
{
out->c[ i ].type = CT_INTEGER;
out->c[ i ].value.integer = ch1->c[ i ].value.integer;
} //end else if
else if ( ch1->c[ i ].type == CT_STRING )
{
out->c[ i ].type = CT_STRING;
out->c[ i ].value.string = ( char * ) GetMemory( strlen( ch1->c[ i ].value.string ) + 1 );
strcpy( out->c[ i ].value.string, ch1->c[ i ].value.string );
} //end else if
} //end for
return handle;
} //end of the function BotInterpolateCharacters
示例5: unzOpen
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
quakefile_t *FindQuakeFilesInZip( char *zipfile, char *filter ) {
unzFile uf;
int err;
unz_global_info gi;
char filename_inzip[MAX_PATH];
unz_file_info file_info;
int i;
quakefile_t *qfiles, *lastqf, *qf;
uf = unzOpen( zipfile );
err = unzGetGlobalInfo( uf, &gi );
if ( err != UNZ_OK ) {
return NULL;
}
unzGoToFirstFile( uf );
qfiles = NULL;
lastqf = NULL;
for ( i = 0; i < gi.number_entry; i++ )
{
err = unzGetCurrentFileInfo( uf, &file_info, filename_inzip, sizeof( filename_inzip ), NULL,0,NULL,0 );
if ( err != UNZ_OK ) {
break;
}
ConvertPath( filename_inzip );
if ( FileFilter( filter, filename_inzip, false ) ) {
qf = GetClearedMemory( sizeof( quakefile_t ) );
if ( !qf ) {
Error( "out of memory" );
}
memset( qf, 0, sizeof( quakefile_t ) );
strcpy( qf->pakfile, zipfile );
strcpy( qf->filename, zipfile );
strcpy( qf->origname, filename_inzip );
qf->zipfile = true;
//memcpy( &buildBuffer[i].zipfileinfo, (unz_s*)uf, sizeof(unz_s));
memcpy( &qf->zipinfo, (unz_s*)uf, sizeof( unz_s ) );
qf->offset = 0;
qf->length = file_info.uncompressed_size;
qf->type = QuakeFileType( filename_inzip );
//add the file ot the list
qf->next = NULL;
if ( lastqf ) {
lastqf->next = qf;
} else { qfiles = qf;}
lastqf = qf;
} //end if
unzGoToNextFile( uf );
} //end for
unzClose( uf );
return qfiles;
} //end of the function FindQuakeFilesInZip
示例6: AAS_CreateAreaSettings
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AAS_CreateAreaSettings(void)
{
int i, flags, side, numgrounded, numladderareas, numliquidareas;
tmp_face_t *face;
tmp_area_t *tmparea;
numgrounded = 0;
numladderareas = 0;
numliquidareas = 0;
Log_Write("AAS_CreateAreaSettings\r\n");
i = 0;
qprintf("%6d areas provided with settings", i);
for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
{
//if the area is invalid there no need to create settings for it
if (tmparea->invalid) continue;
tmparea->settings = (tmp_areasettings_t *) GetClearedMemory(sizeof(tmp_areasettings_t));
tmparea->settings->contents = tmparea->contents;
tmparea->settings->modelnum = tmparea->modelnum;
flags = 0;
for (face = tmparea->tmpfaces; face; face = face->next[side])
{
side = face->frontarea != tmparea;
flags |= face->faceflags;
} //end for
tmparea->settings->areaflags = 0;
if (flags & FACE_GROUND)
{
tmparea->settings->areaflags |= AREA_GROUNDED;
numgrounded++;
} //end if
if (flags & FACE_LADDER)
{
tmparea->settings->areaflags |= AREA_LADDER;
numladderareas++;
} //end if
if (tmparea->contents & (AREACONTENTS_WATER |
AREACONTENTS_SLIME |
AREACONTENTS_LAVA))
{
tmparea->settings->areaflags |= AREA_LIQUID;
numliquidareas++;
} //end if
//presence type of the area
tmparea->settings->presencetype = tmparea->presencetype;
//
qprintf("\r%6d", ++i);
} //end for
qprintf("\n");
#ifdef AASINFO
Log_Print("%6d grounded areas\n", numgrounded);
Log_Print("%6d ladder areas\n", numladderareas);
Log_Print("%6d liquid areas\n", numliquidareas);
#endif //AASINFO
} //end of the function AAS_CreateAreaSettings
示例7: BotAllocWeaponState
//========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//========================================================================
int BotAllocWeaponState( void ) {
int i;
for ( i = 1; i <= MAX_CLIENTS; i++ )
{
if ( !botweaponstates[i] ) {
botweaponstates[i] = GetClearedMemory( sizeof( bot_weaponstate_t ) );
return i;
} //end if
} //end for
return 0;
} //end of the function BotAllocWeaponState
示例8: GetClearedMemory
int *WeaponWeightIndex(weightconfig_t *wwc, weaponconfig_t *wc) {
int *index, i;
//initialize item weight index
index = (int *) GetClearedMemory(sizeof(int) * wc->numweapons);
for (i = 0; i < wc->numweapons; i++)
{
index[i] = FindFuzzyWeight(wwc, wc->weaponinfo[i].name);
}
return index;
}
示例9: AAS_OptimizeAlloc
/*
=======================================================================================================================================
AAS_OptimizeAlloc
=======================================================================================================================================
*/
void AAS_OptimizeAlloc(optimized_t *optimized) {
optimized->vertexes = (aas_vertex_t *)GetClearedMemory(aasworld.numvertexes * sizeof(aas_vertex_t));
optimized->numvertexes = 0;
optimized->edges = (aas_edge_t *)GetClearedMemory(aasworld.numedges * sizeof(aas_edge_t));
optimized->numedges = 1; // edge zero is a dummy
optimized->edgeindex = (aas_edgeindex_t *)GetClearedMemory(aasworld.edgeindexsize * sizeof(aas_edgeindex_t));
optimized->edgeindexsize = 0;
optimized->faces = (aas_face_t *)GetClearedMemory(aasworld.numfaces * sizeof(aas_face_t));
optimized->numfaces = 1; // face zero is a dummy
optimized->faceindex = (aas_faceindex_t *)GetClearedMemory(aasworld.faceindexsize * sizeof(aas_faceindex_t));
optimized->faceindexsize = 0;
optimized->areas = (aas_area_t *)GetClearedMemory(aasworld.numareas * sizeof(aas_area_t));
optimized->numareas = aasworld.numareas;
optimized->vertexoptimizeindex = (int *)GetClearedMemory(aasworld.numvertexes * sizeof(int));
optimized->edgeoptimizeindex = (int *)GetClearedMemory(aasworld.numedges * sizeof(int));
optimized->faceoptimizeindex = (int *)GetClearedMemory(aasworld.numfaces * sizeof(int));
}
示例10: GetClearedMemory
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
tmp_face_t *AAS_AllocTmpFace(void)
{
tmp_face_t *tmpface;
tmpface = (tmp_face_t *) GetClearedMemory(sizeof(tmp_face_t));
tmpface->num = tmpaasworld.facenum++;
tmpface->l_prev = NULL;
tmpface->l_next = tmpaasworld.faces;
if (tmpaasworld.faces) tmpaasworld.faces->l_prev = tmpface;
tmpaasworld.faces = tmpface;
tmpaasworld.numfaces++;
return tmpface;
} //end of the function AAS_AllocTmpFace
示例11: GetClearedMemory
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
tmp_node_t *AAS_AllocTmpNode( void ) {
tmp_nodebuf_t *nodebuf;
if ( !tmpaasworld.nodebuffer ||
tmpaasworld.nodebuffer->numnodes >= NODEBUF_SIZE ) {
nodebuf = (tmp_nodebuf_t *) GetClearedMemory( sizeof( tmp_nodebuf_t ) );
nodebuf->next = tmpaasworld.nodebuffer;
nodebuf->numnodes = 0;
tmpaasworld.nodebuffer = nodebuf;
} //end if
tmpaasworld.numnodes++;
return &tmpaasworld.nodebuffer->nodes[tmpaasworld.nodebuffer->numnodes++];
} //end of the function AAS_AllocTmpNode
示例12: BotAllocGoalState
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int BotAllocGoalState( int client ) {
int i;
for ( i = 1; i <= MAX_CLIENTS; i++ )
{
if ( !botgoalstates[i] ) {
botgoalstates[i] = GetClearedMemory( sizeof( bot_goalstate_t ) );
botgoalstates[i]->client = client;
return i;
} //end if
} //end for
return 0;
} //end of the function BotAllocGoalState
示例13: GetClearedMemory
//===========================================================================
// index to find the weight function of an iteminfo
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int *ItemWeightIndex( weightconfig_t *iwc, itemconfig_t *ic ) {
int *index, i;
//initialize item weight index
index = (int *) GetClearedMemory( sizeof( int ) * ic->numiteminfo );
for ( i = 0; i < ic->numiteminfo; i++ )
{
index[i] = FindFuzzyWeight( iwc, ic->iteminfo[i].classname );
if ( index[i] < 0 ) {
Log_Write( "item info %d \"%s\" has no fuzzy weight\r\n", i, ic->iteminfo[i].classname );
} //end if
} //end for
return index;
} //end of the function ItemWeightIndex
示例14: Com_sprintf
script_t *LoadScriptFile(const char *filename)
{
fileHandle_t fp;
char pathname[MAX_QPATH];
int length;
void *buffer;
script_t *script;
if (strlen(basefolder))
{
Com_sprintf(pathname, sizeof(pathname), "%s/%s", basefolder, filename);
}
else
{
Com_sprintf(pathname, sizeof(pathname), "%s", filename);
}
length = botimport.FS_FOpenFile(pathname, &fp, FS_READ);
if (!fp)
{
return NULL;
}
buffer = GetClearedMemory(sizeof(script_t) + length + 1);
script = (script_t *) buffer;
memset(script, 0, sizeof(script_t));
strcpy(script->filename, filename);
script->buffer = (char *) buffer + sizeof(script_t);
script->buffer[length] = 0;
script->length = length;
//pointer in script buffer
script->script_p = script->buffer;
//pointer in script buffer before reading token
script->lastscript_p = script->buffer;
//pointer to end of script buffer
script->end_p = &script->buffer[length];
//set if there's a token available in script->token
script->tokenavailable = 0;
script->line = 1;
script->lastline = 1;
SetScriptPunctuations(script, NULL);
botimport.FS_Read(script->buffer, length, fp);
botimport.FS_FCloseFile(fp);
return script;
} //end of the function LoadScriptFile
示例15: Q3_CreatePlanarSurfacePlanes
void Q3_CreatePlanarSurfacePlanes(void)
{
int i;
dsurface_t *surface;
Log_Print("creating planar surface planes...\n");
q3_surfaceplanes = (dplane_t *) GetClearedMemory(q3_numDrawSurfaces * sizeof(dplane_t));
for (i = 0; i < q3_numDrawSurfaces; i++)
{
surface = &drawSurfaces[i];
if (surface->surfaceType != MST_PLANAR) continue;
Q3_SurfacePlane(surface, q3_surfaceplanes[i].normal, &q3_surfaceplanes[i].dist);
//Log_Print("normal = %f %f %f, dist = %f\n", q3_surfaceplanes[i].normal[0],
// q3_surfaceplanes[i].normal[1],
// q3_surfaceplanes[i].normal[2], q3_surfaceplanes[i].dist);
} //end for
} //end of the function Q3_CreatePlanarSurfacePlanes