这篇教程C++ GetClearedMemory函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetClearedMemory函数的典型用法代码示例。如果您正苦于以下问题:C++ GetClearedMemory函数的具体用法?C++ GetClearedMemory怎么用?C++ GetClearedMemory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetClearedMemory函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:59,
示例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
开发者ID:0culus,项目名称:ioq3,代码行数:36,
示例3: AAS_FloodAreasvoid 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);}
开发者ID:Razish,项目名称:QtZ,代码行数:8,
示例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
开发者ID:gfx0,项目名称:Unvanquished,代码行数:64,
示例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
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:63,
示例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
开发者ID:ArtanAhmeti,项目名称:lab,代码行数:62,
示例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
开发者ID:Justasic,项目名称:RTCW-MP,代码行数:18,
示例8: GetClearedMemoryint *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;}
开发者ID:Razish,项目名称:QtZ,代码行数:12,
示例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));}
开发者ID:KuehnhammerTobias,项目名称:ioqw,代码行数:23,
示例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
开发者ID:ArtanAhmeti,项目名称:lab,代码行数:19,
示例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
开发者ID:chegestar,项目名称:omni-bot,代码行数:19,
示例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
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:19,
示例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
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:22,
示例14: Com_sprintfscript_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
开发者ID:Mailaender,项目名称:etlegacy,代码行数:48,
示例15: Q3_CreatePlanarSurfacePlanesvoid 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
开发者ID:tkmorris,项目名称:OpenMOHAA,代码行数:18,
示例16: AAS_RemoveNonReachabilityAlloc//===========================================================================//// Parameter: -// Returns: -// Changes Globals: -//===========================================================================void AAS_RemoveNonReachabilityAlloc(optimized_t * optimized){ optimized->areas = (aas_area_t *) GetClearedMemory((*aasworld).numareas * sizeof(aas_area_t)); // optimized->areasettings = (aas_areasettings_t *) GetClearedMemory((*aasworld).numareas * sizeof(aas_areasettings_t)); // optimized->reachability = (aas_reachability_t *) GetClearedMemory((*aasworld).reachabilitysize * sizeof(aas_reachability_t)); optimized->reachabilitysize = (*aasworld).reachabilitysize;/* // optimized->nodes = (aas_node_t *) GetClearedMemory((*aasworld).numnodes * sizeof(aas_node_t)); optimized->numnodes = (*aasworld).numnodes; // optimized->portals = (aas_portals_t *) GetClearedMemory((*aasworld).numportals * sizeof(aas_portal_t)); optimized->numportals = (*aasworld).numportals; // optimized->clusters = (aas_cluster_t *) GetClearedMemory((*aasworld).numclusters * sizeof(aas_cluster_t)); optimized->numclusters = (*aasworld).numclusters;*/// optimized->areakeep = (int *)GetClearedMemory((*aasworld).numareas * sizeof(int)); optimized->arearemap = (int *)GetClearedMemory((*aasworld).numareas * sizeof(int)); optimized->removedareas = (int *)GetClearedMemory((*aasworld).numareas * sizeof(int)); optimized->reachabilityremap = (int *)GetClearedMemory((*aasworld).reachabilitysize * sizeof(int));} //end of the function AAS_OptimizeAlloc
开发者ID:DerSaidin,项目名称:OpenWolf,代码行数:29,
示例17: defined//.........这里部分代码省略......... strcat( pakfile, filedata.cFileName ); _stat( pakfile, &statbuf );#else glob( pakfilter, 0, NULL, &globbuf ); for ( j = 0; j < globbuf.gl_pathc; j++ ) { strcpy( pakfile, globbuf.gl_pathv[j] ); stat( pakfile, &statbuf );#endif //if the file with .pak or .pk3 is a folder if ( statbuf.st_mode & S_IFDIR ) { strcpy( filename, pakfilter ); AppendPathSeperator( filename, _MAX_PATH ); strcat( filename, filter ); qf = FindQuakeFilesWithPakFilter( NULL, filename ); if ( lastqf ) { lastqf->next = qf; } else { qfiles = qf;} lastqf = qf; while ( lastqf->next ) lastqf = lastqf->next; } //end if else {#if defined( WIN32 ) | defined( _WIN32 ) str = StringContains( pakfile, ".pk3", false );#else str = StringContains( pakfile, ".pk3", true );#endif if ( str && str == pakfile + strlen( pakfile ) - strlen( ".pk3" ) ) { qf = FindQuakeFilesInZip( pakfile, filter ); } //end if else { qf = FindQuakeFilesInPak( pakfile, filter ); } //end else // if ( qf ) { if ( lastqf ) { lastqf->next = qf; } else { qfiles = qf;} lastqf = qf; while ( lastqf->next ) lastqf = lastqf->next; } //end if } //end else //#if defined( WIN32 ) | defined( _WIN32 ) //find the next file done = !FindNextFile( handle, &filedata ); } //end while#else } //end for globfree( &globbuf );#endif } //end if else {#if defined( WIN32 ) | defined( _WIN32 ) handle = FindFirstFile( filter, &filedata ); done = ( handle == INVALID_HANDLE_VALUE ); while ( !done ) { _splitpath( filter, filename, NULL, NULL, NULL ); _splitpath( filter, NULL, &filename[strlen( filename )], NULL, NULL ); AppendPathSeperator( filename, _MAX_PATH ); strcat( filename, filedata.cFileName );#else glob( filter, 0, NULL, &globbuf ); for ( j = 0; j < globbuf.gl_pathc; j++ ) { strcpy( filename, globbuf.gl_pathv[j] );#endif // qf = GetClearedMemory( sizeof( quakefile_t ) ); if ( !qf ) { Error( "out of memory" ); } memset( qf, 0, sizeof( quakefile_t ) ); strcpy( qf->pakfile, "" ); strcpy( qf->filename, filename ); strcpy( qf->origname, filename ); qf->offset = 0; qf->length = 0; qf->type = QuakeFileType( filename ); //add the file ot the list qf->next = NULL; if ( lastqf ) { lastqf->next = qf; } else { qfiles = qf;} lastqf = qf;#if defined( WIN32 ) | defined( _WIN32 ) //find the next file done = !FindNextFile( handle, &filedata ); } //end while#else } //end for globfree( &globbuf );#endif } //end else return qfiles;} //end of the function FindQuakeFilesWithPakFilter
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:101,
示例18: AAS_AllocMaxAAS//===========================================================================//// Parameter: -// Returns: -// Changes Globals: -//===========================================================================void AAS_AllocMaxAAS( void ) { int i; AAS_InitMaxAAS(); //bounding boxes ( *aasworld ).numbboxes = 0; ( *aasworld ).bboxes = (aas_bbox_t *) GetClearedMemory( max_aas.max_bboxes * sizeof( aas_bbox_t ) ); allocatedaasmem += max_aas.max_bboxes * sizeof( aas_bbox_t ); //vertexes ( *aasworld ).numvertexes = 0; ( *aasworld ).vertexes = (aas_vertex_t *) GetClearedMemory( max_aas.max_vertexes * sizeof( aas_vertex_t ) ); allocatedaasmem += max_aas.max_vertexes * sizeof( aas_vertex_t ); //planes ( *aasworld ).numplanes = 0; ( *aasworld ).planes = (aas_plane_t *) GetClearedMemory( max_aas.max_planes * sizeof( aas_plane_t ) ); allocatedaasmem += max_aas.max_planes * sizeof( aas_plane_t ); //edges ( *aasworld ).numedges = 0; ( *aasworld ).edges = (aas_edge_t *) GetClearedMemory( max_aas.max_edges * sizeof( aas_edge_t ) ); allocatedaasmem += max_aas.max_edges * sizeof( aas_edge_t ); //edge index ( *aasworld ).edgeindexsize = 0; ( *aasworld ).edgeindex = (aas_edgeindex_t *) GetClearedMemory( max_aas.max_edgeindexsize * sizeof( aas_edgeindex_t ) ); allocatedaasmem += max_aas.max_edgeindexsize * sizeof( aas_edgeindex_t ); //faces ( *aasworld ).numfaces = 0; ( *aasworld ).faces = (aas_face_t *) GetClearedMemory( max_aas.max_faces * sizeof( aas_face_t ) ); allocatedaasmem += max_aas.max_faces * sizeof( aas_face_t ); //face index ( *aasworld ).faceindexsize = 0; ( *aasworld ).faceindex = (aas_faceindex_t *) GetClearedMemory( max_aas.max_faceindexsize * sizeof( aas_faceindex_t ) ); allocatedaasmem += max_aas.max_faceindexsize * sizeof( aas_faceindex_t ); //convex areas ( *aasworld ).numareas = 0; ( *aasworld ).areas = (aas_area_t *) GetClearedMemory( max_aas.max_areas * sizeof( aas_area_t ) ); allocatedaasmem += max_aas.max_areas * sizeof( aas_area_t ); //convex area settings ( *aasworld ).numareasettings = 0; ( *aasworld ).areasettings = (aas_areasettings_t *) GetClearedMemory( max_aas.max_areasettings * sizeof( aas_areasettings_t ) ); allocatedaasmem += max_aas.max_areasettings * sizeof( aas_areasettings_t ); //reachablity list ( *aasworld ).reachabilitysize = 0; ( *aasworld ).reachability = (aas_reachability_t *) GetClearedMemory( max_aas.max_reachabilitysize * sizeof( aas_reachability_t ) ); allocatedaasmem += max_aas.max_reachabilitysize * sizeof( aas_reachability_t ); //nodes of the bsp tree ( *aasworld ).numnodes = 0; ( *aasworld ).nodes = (aas_node_t *) GetClearedMemory( max_aas.max_nodes * sizeof( aas_node_t ) ); allocatedaasmem += max_aas.max_nodes * sizeof( aas_node_t ); //cluster portals ( *aasworld ).numportals = 0; ( *aasworld ).portals = (aas_portal_t *) GetClearedMemory( max_aas.max_portals * sizeof( aas_portal_t ) ); allocatedaasmem += max_aas.max_portals * sizeof( aas_portal_t ); //cluster portal index ( *aasworld ).portalindexsize = 0; ( *aasworld ).portalindex = (aas_portalindex_t *) GetClearedMemory( max_aas.max_portalindexsize * sizeof( aas_portalindex_t ) ); allocatedaasmem += max_aas.max_portalindexsize * sizeof( aas_portalindex_t ); //cluster ( *aasworld ).numclusters = 0; ( *aasworld ).clusters = (aas_cluster_t *) GetClearedMemory( max_aas.max_clusters * sizeof( aas_cluster_t ) ); allocatedaasmem += max_aas.max_clusters * sizeof( aas_cluster_t ); // Log_Print( "allocated " ); PrintMemorySize( allocatedaasmem ); Log_Print( " of AAS memory/n" ); //reset the has stuff aas_vertexchain = (int *) GetClearedMemory( max_aas.max_vertexes * sizeof( int ) ); aas_planechain = (int *) GetClearedMemory( max_aas.max_planes * sizeof( int ) ); aas_edgechain = (int *) GetClearedMemory( max_aas.max_edges * sizeof( int ) ); // for ( i = 0; i < max_aas.max_vertexes; i++ ) aas_vertexchain[i] = -1; for ( i = 0; i < VERTEX_HASH_SIZE * VERTEX_HASH_SIZE; i++ ) aas_hashverts[i] = -1; // for ( i = 0; i < max_aas.max_planes; i++ ) aas_planechain[i] = -1; for ( i = 0; i < PLANE_HASH_SIZE; i++ ) aas_hashplanes[i] = -1; // for ( i = 0; i < max_aas.max_edges; i++ ) aas_edgechain[i] = -1; for ( i = 0; i < EDGE_HASH_SIZE; i++ ) aas_hashedges[i] = -1;} //end of the function AAS_AllocMaxAAS
开发者ID:D4edalus,项目名称:CoD4x_Server,代码行数:84,
示例19: AAS_InitClustering//===========================================================================//// Parameter: -// Returns: -// Changes Globals: -//===========================================================================void AAS_InitClustering(void){ int i, removedPortalAreas; int n, total, numreachabilityareas; if (!aasworld.loaded) return; //if there are clusters if (aasworld.numclusters >= 1) {#ifndef BSPC //if clustering isn't forced if (!((int)LibVarGetValue("forceclustering")) && !((int)LibVarGetValue("forcereachability"))) return;#endif } //end if //set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach) AAS_SetViewPortalsAsClusterPortals(); //count the number of forced cluster portals AAS_CountForcedClusterPortals(); //remove all area cluster marks AAS_RemoveClusterAreas(); //find possible cluster portals AAS_FindPossiblePortals(); //craete portals to for the bot view AAS_CreateViewPortals(); //remove all portals that are not closing a cluster //AAS_RemoveNotClusterClosingPortals(); //initialize portal memory if (aasworld.portals) FreeMemory(aasworld.portals); aasworld.portals = (aas_portal_t *) GetClearedMemory(AAS_MAX_PORTALS * sizeof(aas_portal_t)); //initialize portal index memory if (aasworld.portalindex) FreeMemory(aasworld.portalindex); aasworld.portalindex = (aas_portalindex_t *) GetClearedMemory(AAS_MAX_PORTALINDEXSIZE * sizeof(aas_portalindex_t)); //initialize cluster memory if (aasworld.clusters) FreeMemory(aasworld.clusters); aasworld.clusters = (aas_cluster_t *) GetClearedMemory(AAS_MAX_CLUSTERS * sizeof(aas_cluster_t)); // removedPortalAreas = 0; botimport.Print(PRT_MESSAGE, "/r%6d removed portal areas", removedPortalAreas); while(1) { botimport.Print(PRT_MESSAGE, "/r%6d", removedPortalAreas); //initialize the number of portals and clusters aasworld.numportals = 1; //portal 0 is a dummy aasworld.portalindexsize = 0; aasworld.numclusters = 1; //cluster 0 is a dummy //create the portals from the portal areas AAS_CreatePortals(); // removedPortalAreas++; //find the clusters if (!AAS_FindClusters()) continue; //test the portals if (!AAS_TestPortals()) continue; // break; } //end while botimport.Print(PRT_MESSAGE, "/n"); //the AAS file should be saved aasworld.savefile = qtrue; //write the portal areas to the log file for (i = 1; i < aasworld.numportals; i++) { Log_Write("portal %d: area %d/r/n", i, aasworld.portals[i].areanum); } //end for // report cluster info botimport.Print(PRT_MESSAGE, "%6d portals created/n", aasworld.numportals); botimport.Print(PRT_MESSAGE, "%6d clusters created/n", aasworld.numclusters); for (i = 1; i < aasworld.numclusters; i++) { botimport.Print(PRT_MESSAGE, "cluster %d has %d reachability areas/n", i, aasworld.clusters[i].numreachabilityareas); } //end for // report AAS file efficiency numreachabilityareas = 0; total = 0; for (i = 0; i < aasworld.numclusters; i++) { n = aasworld.clusters[i].numreachabilityareas; numreachabilityareas += n; total += n * n; } total += numreachabilityareas * aasworld.numportals; // botimport.Print(PRT_MESSAGE, "%6i total reachability areas/n", numreachabilityareas); botimport.Print(PRT_MESSAGE, "%6i AAS memory/CPU usage (the lower the better)/n", total * 3);} //end of the function AAS_InitClustering
开发者ID:OADoctor,项目名称:SmokinGuns,代码行数:94,
示例20: Q2_AllocMaxBSPvoid Q2_AllocMaxBSP(void){ //models nummodels = 0; dmodels = (dmodel_t *) GetClearedMemory(MAX_MAP_MODELS * sizeof(dmodel_t)); allocatedbspmem += MAX_MAP_MODELS * sizeof(dmodel_t); //vis data visdatasize = 0; dvisdata = (byte *) GetClearedMemory(MAX_MAP_VISIBILITY * sizeof(byte)); dvis = (dvis_t *) dvisdata; allocatedbspmem += MAX_MAP_VISIBILITY * sizeof(byte); //light data lightdatasize = 0; dlightdata = (byte *) GetClearedMemory(MAX_MAP_LIGHTING * sizeof(byte)); allocatedbspmem += MAX_MAP_LIGHTING * sizeof(byte); //entity data entdatasize = 0; dentdata = (char *) GetClearedMemory(MAX_MAP_ENTSTRING * sizeof(char)); allocatedbspmem += MAX_MAP_ENTSTRING * sizeof(char); //leafs numleafs = 0; dleafs = (dleaf_t *) GetClearedMemory(MAX_MAP_LEAFS * sizeof(dleaf_t)); allocatedbspmem += MAX_MAP_LEAFS * sizeof(dleaf_t); //planes numplanes = 0; dplanes = (dplane_t *) GetClearedMemory(MAX_MAP_PLANES * sizeof(dplane_t)); allocatedbspmem += MAX_MAP_PLANES * sizeof(dplane_t); //vertexes numvertexes = 0; dvertexes = (dvertex_t *) GetClearedMemory(MAX_MAP_VERTS * sizeof(dvertex_t)); allocatedbspmem += MAX_MAP_VERTS * sizeof(dvertex_t); //nodes numnodes = 0; dnodes = (dnode_t *) GetClearedMemory(MAX_MAP_NODES * sizeof(dnode_t)); allocatedbspmem += MAX_MAP_NODES * sizeof(dnode_t); /* //texture info numtexinfo = 0; texinfo = (texinfo_t *) GetClearedMemory(MAX_MAP_TEXINFO * sizeof(texinfo_t)); allocatedbspmem += MAX_MAP_TEXINFO * sizeof(texinfo_t); //*/ //faces numfaces = 0; dfaces = (dface_t *) GetClearedMemory(MAX_MAP_FACES * sizeof(dface_t)); allocatedbspmem += MAX_MAP_FACES * sizeof(dface_t); //edges numedges = 0; dedges = (dedge_t *) GetClearedMemory(MAX_MAP_EDGES * sizeof(dedge_t)); allocatedbspmem += MAX_MAP_EDGES * sizeof(dedge_t); //leaf faces numleaffaces = 0; dleaffaces = (unsigned short *) GetClearedMemory(MAX_MAP_LEAFFACES * sizeof(unsigned short)); allocatedbspmem += MAX_MAP_LEAFFACES * sizeof(unsigned short); //leaf brushes numleafbrushes = 0; dleafbrushes = (unsigned short *) GetClearedMemory(MAX_MAP_LEAFBRUSHES * sizeof(unsigned short)); allocatedbspmem += MAX_MAP_LEAFBRUSHES * sizeof(unsigned short); //surface edges numsurfedges = 0; dsurfedges = (int *) GetClearedMemory(MAX_MAP_SURFEDGES * sizeof(int)); allocatedbspmem += MAX_MAP_SURFEDGES * sizeof(int); //brushes numbrushes = 0; dbrushes = (dbrush_t *) GetClearedMemory(MAX_MAP_BRUSHES * sizeof(dbrush_t)); allocatedbspmem += MAX_MAP_BRUSHES * sizeof(dbrush_t); //brushsides numbrushsides = 0; dbrushsides = (dbrushside_t *) GetClearedMemory(MAX_MAP_BRUSHSIDES * sizeof(dbrushside_t)); allocatedbspmem += MAX_MAP_BRUSHSIDES * sizeof(dbrushside_t); //areas numareas = 0; dareas = (darea_t *) GetClearedMemory(MAX_MAP_AREAS * sizeof(darea_t)); allocatedbspmem += MAX_MAP_AREAS * sizeof(darea_t); //area portals numareaportals = 0; dareaportals = (dareaportal_t *) GetClearedMemory(MAX_MAP_AREAPORTALS * sizeof(dareaportal_t)); allocatedbspmem += MAX_MAP_AREAPORTALS * sizeof(dareaportal_t); //print allocated memory Log_Print("allocated "); PrintMemorySize(allocatedbspmem); Log_Print(" of BSP memory/n");} //end of the function Q2_AllocMaxBSP
开发者ID:ArtanAhmeti,项目名称:lab,代码行数:82,
示例21: PS_SetBaseFolder//===========================================================================//// Parameter: -// Returns: -// Changes Globals: -//===========================================================================bot_character_t *BotLoadCharacterFromFile( char *charfile, int skill ){ int indent, index, foundcharacter; bot_character_t *ch; source_t *source; token_t token; foundcharacter = qfalse; //a bot character is parsed in two phases PS_SetBaseFolder( "botfiles" ); source = LoadSourceFile( charfile ); PS_SetBaseFolder( "" ); if ( !source ) { botimport.Print( PRT_ERROR, "counldn't load %s/n", charfile ); return NULL; } //end if ch = ( bot_character_t * ) GetClearedMemory( sizeof( bot_character_t ) + MAX_CHARACTERISTICS * sizeof( bot_characteristic_t ) ); strcpy( ch->filename, charfile ); while ( PC_ReadToken( source, &token ) ) { if ( !strcmp( token.string, "skill" ) ) { if ( !PC_ExpectTokenType( source, TT_NUMBER, 0, &token ) ) { FreeSource( source ); BotFreeCharacterStrings( ch ); FreeMemory( ch ); return NULL; } //end if if ( !PC_ExpectTokenString( source, "{" ) ) { FreeSource( source ); BotFreeCharacterStrings( ch ); FreeMemory( ch ); return NULL; } //end if //if it's the correct skill if ( skill < 0 || token.intvalue == skill ) { foundcharacter = qtrue; ch->skill = token.intvalue; while ( PC_ExpectAnyToken( source, &token ) ) { if ( !strcmp( token.string, "}" ) ) { break; } if ( token.type != TT_NUMBER || !( token.subtype & TT_INTEGER ) ) { SourceError( source, "expected integer index, found %s/n", token.string ); FreeSource( source ); BotFreeCharacterStrings( ch ); FreeMemory( ch ); return NULL; } //end if index = token.intvalue; if ( index < 0 || index > MAX_CHARACTERISTICS ) { SourceError( source, "characteristic index out of range [0, %d]/n", MAX_CHARACTERISTICS ); FreeSource( source ); BotFreeCharacterStrings( ch ); FreeMemory( ch ); return NULL; } //end if if ( ch->c[ index ].type ) { SourceError( source, "characteristic %d already initialized/n", index ); FreeSource( source ); BotFreeCharacterStrings( ch ); FreeMemory( ch ); return NULL; } //end if if ( !PC_ExpectAnyToken( source, &token ) ) { FreeSource( source ); BotFreeCharacterStrings( ch ); FreeMemory( ch ); return NULL; } //end if if ( token.type == TT_NUMBER ) {//.........这里部分代码省略.........
开发者ID:gfx0,项目名称:Unvanquished,代码行数:101,
示例22: fopen//===========================================================================//// Parameter: -// Returns: -// Changes Globals: -//===========================================================================quakefile_t *FindQuakeFilesInPak( char *pakfile, char *filter ) { FILE *fp; dpackheader_t packheader; dsinpackfile_t *packfiles; dpackfile_t *idpackfiles; quakefile_t *qfiles, *lastqf, *qf; int numpackdirs, i; qfiles = NULL; lastqf = NULL; //open the pak file fp = fopen( pakfile, "rb" ); if ( !fp ) { Warning( "can't open pak file %s", pakfile ); return NULL; } //end if //read pak header, check for valid pak id and seek to the dir entries if ( ( fread( &packheader, 1, sizeof( dpackheader_t ), fp ) != sizeof( dpackheader_t ) ) || ( packheader.ident != IDPAKHEADER && packheader.ident != SINPAKHEADER ) || ( fseek( fp, LittleLong( packheader.dirofs ), SEEK_SET ) ) ) { fclose( fp ); Warning( "invalid pak file %s", pakfile ); return NULL; } //end if //if it is a pak file from id software if ( packheader.ident == IDPAKHEADER ) { //number of dir entries in the pak file numpackdirs = LittleLong( packheader.dirlen ) / sizeof( dpackfile_t ); idpackfiles = (dpackfile_t *) GetClearedMemory( numpackdirs * sizeof( dpackfile_t ) ); if ( !idpackfiles ) { Error( "out of memory" ); } //read the dir entry if ( fread( idpackfiles, sizeof( dpackfile_t ), numpackdirs, fp ) != numpackdirs ) { fclose( fp ); FreeMemory( idpackfiles ); Warning( "can't read the Quake pak file dir entries from %s", pakfile ); return NULL; } //end if fclose( fp ); //convert to sin pack files packfiles = (dsinpackfile_t *) GetClearedMemory( numpackdirs * sizeof( dsinpackfile_t ) ); if ( !packfiles ) { Error( "out of memory" ); } for ( i = 0; i < numpackdirs; i++ ) { strcpy( packfiles[i].name, idpackfiles[i].name ); packfiles[i].filepos = LittleLong( idpackfiles[i].filepos ); packfiles[i].filelen = LittleLong( idpackfiles[i].filelen ); } //end for FreeMemory( idpackfiles ); } //end if else //its a Sin pack file { //number of dir entries in the pak file numpackdirs = LittleLong( packheader.dirlen ) / sizeof( dsinpackfile_t ); packfiles = (dsinpackfile_t *) GetClearedMemory( numpackdirs * sizeof( dsinpackfile_t ) ); if ( !packfiles ) { Error( "out of memory" ); } //read the dir entry if ( fread( packfiles, sizeof( dsinpackfile_t ), numpackdirs, fp ) != numpackdirs ) { fclose( fp ); FreeMemory( packfiles ); Warning( "can't read the Sin pak file dir entries from %s", pakfile ); return NULL; } //end if fclose( fp ); for ( i = 0; i < numpackdirs; i++ ) { packfiles[i].filepos = LittleLong( packfiles[i].filepos ); packfiles[i].filelen = LittleLong( packfiles[i].filelen ); } //end for } //end else // for ( i = 0; i < numpackdirs; i++ ) { ConvertPath( packfiles[i].name ); if ( FileFilter( filter, packfiles[i].name, false ) ) { qf = GetClearedMemory( sizeof( quakefile_t ) ); if ( !qf ) { Error( "out of memory" ); } memset( qf, 0, sizeof( quakefile_t ) ); strcpy( qf->pakfile, pakfile ); strcpy( qf->filename, pakfile ); strcpy( qf->origname, packfiles[i].name ); qf->zipfile = false; qf->offset = packfiles[i].filepos; qf->length = packfiles[i].filelen; qf->type = QuakeFileType( packfiles[i].name ); //add the file ot the list//.........这里部分代码省略.........
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:101,
示例23: GetClearedMemory//===========================================================================//// Parameter: -// Returns: -// Changes Globals: -//===========================================================================fuzzyseperator_t *ReadFuzzySeperators_r( source_t *source ) { int newindent, index, def, founddefault; token_t token; fuzzyseperator_t *fs, *lastfs, *firstfs; founddefault = qfalse; firstfs = NULL; lastfs = NULL; if ( !PC_ExpectTokenString( source, "(" ) ) { return NULL; } if ( !PC_ExpectTokenType( source, TT_NUMBER, TT_INTEGER, &token ) ) { return NULL; } index = token.intvalue; if ( !PC_ExpectTokenString( source, ")" ) ) { return NULL; } if ( !PC_ExpectTokenString( source, "{" ) ) { return NULL; } if ( !PC_ExpectAnyToken( source, &token ) ) { return NULL; } do { def = !strcmp( token.string, "default" ); if ( def || !strcmp( token.string, "case" ) ) { fs = (fuzzyseperator_t *) GetClearedMemory( sizeof( fuzzyseperator_t ) ); fs->index = index; if ( lastfs ) { lastfs->next = fs; } else { firstfs = fs;} lastfs = fs; if ( def ) { if ( founddefault ) { SourceError( source, "switch already has a default" ); FreeFuzzySeperators_r( firstfs ); return NULL; } //end if fs->value = MAX_INVENTORYVALUE; founddefault = qtrue; } //end if else { if ( !PC_ExpectTokenType( source, TT_NUMBER, TT_INTEGER, &token ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if fs->value = token.intvalue; } //end else if ( !PC_ExpectTokenString( source, ":" ) || !PC_ExpectAnyToken( source, &token ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if newindent = qfalse; if ( !strcmp( token.string, "{" ) ) { newindent = qtrue; if ( !PC_ExpectAnyToken( source, &token ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } //end if if ( !strcmp( token.string, "return" ) ) { if ( !ReadFuzzyWeight( source, fs ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } //end if else if ( !strcmp( token.string, "switch" ) ) { fs->child = ReadFuzzySeperators_r( source ); if ( !fs->child ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } //end else if else { SourceError( source, "invalid name %s", token.string ); return NULL; } //end else if ( newindent ) { if ( !PC_ExpectTokenString( source, "}" ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } //end if } //end if else { FreeFuzzySeperators_r( firstfs ); SourceError( source, "invalid name %s", token.string ); return NULL; } //end else//.........这里部分代码省略.........
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,
示例24: GetClearedMemory//===========================================================================//// Parameter: -// Returns: -// Changes Globals: -//===========================================================================void *GetClearedHunkMemory(unsigned long size){ return GetClearedMemory(size);} //end of the function GetClearedHunkMemory
开发者ID:Cpasjuste,项目名称:quake3_pandora_gles,代码行数:10,
示例25: Sys_MilliSeconds//===========================================================================//// Parameter: -// Returns: -// Changes Globals: -//===========================================================================weightconfig_t *ReadWeightConfig( char *filename ) { int newindent, avail = 0, n; token_t token; source_t *source; fuzzyseperator_t *fs; weightconfig_t *config = NULL;#ifdef DEBUG int starttime; starttime = Sys_MilliSeconds();#endif //DEBUG if ( !LibVarGetValue( "bot_reloadcharacters" ) ) { avail = -1; for ( n = 0; n < MAX_WEIGHT_FILES; n++ ) { config = weightFileList[n]; if ( !config ) { if ( avail == -1 ) { avail = n; } //end if continue; } //end if if ( strcmp( filename, config->filename ) == 0 ) { //botimport.Print( PRT_MESSAGE, "retained %s/n", filename ); return config; } //end if } //end for if ( avail == -1 ) { botimport.Print( PRT_ERROR, "weightFileList was full trying to load %s/n", filename ); return NULL; } //end if } //end if source = LoadSourceFile( filename ); if ( !source ) { botimport.Print( PRT_ERROR, "counldn't load %s/n", filename ); return NULL; } //end if // config = (weightconfig_t *) GetClearedMemory( sizeof( weightconfig_t ) ); config->numweights = 0; Q_strncpyz( config->filename, filename, sizeof( config->filename ) ); //parse the item config file while ( PC_ReadToken( source, &token ) ) { if ( !strcmp( token.string, "weight" ) ) { if ( config->numweights >= MAX_WEIGHTS ) { SourceWarning( source, "too many fuzzy weights" ); break; } //end if if ( !PC_ExpectTokenType( source, TT_STRING, 0, &token ) ) { FreeWeightConfig( config ); FreeSource( source ); return NULL; } //end if StripDoubleQuotes( token.string ); config->weights[config->numweights].name = (char *) GetClearedMemory( strlen( token.string ) + 1 ); strcpy( config->weights[config->numweights].name, token.string ); if ( !PC_ExpectAnyToken( source, &token ) ) { FreeWeightConfig( config ); FreeSource( source ); return NULL; } //end if newindent = qfalse; if ( !strcmp( token.string, "{" ) ) { newindent = qtrue; if ( !PC_ExpectAnyToken( source, &token ) ) { FreeWeightConfig( config ); FreeSource( source ); return NULL; } //end if } //end if if ( !strcmp( token.string, "switch" ) ) { fs = ReadFuzzySeperators_r( source ); if ( !fs ) { FreeWeightConfig( config ); FreeSource( source ); return NULL; } //end if config->weights[config->numweights].firstseperator = fs; } //end if else if ( !strcmp( token.string, "return" ) ) { fs = (fuzzyseperator_t *) GetClearedMemory( sizeof( fuzzyseperator_t ) ); fs->index = 0; fs->value = MAX_INVENTORYVALUE; fs->next = NULL; fs->child = NULL; if ( !ReadFuzzyWeight( source, fs ) ) { FreeMemory( fs ); FreeWeightConfig( config ); FreeSource( source ); return NULL;//.........这里部分代码省略.........
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,
示例26: Com_sprintfscript_t *LoadScriptFile(const char *filename) { fileHandle_t h_up, h_patch; char pathname[MAX_QPATH], pathpatch[MAX_QPATH]; unsigned long inhash = 0; int inlength, outlength, plength; char *inbuffer, *outbuffer, *pbuffer; script_t *script; if (strlen(basefolder)) { Com_sprintf(pathname, sizeof(pathname), "%s/%s", basefolder, filename); Com_sprintf(pathpatch, sizeof(pathpatch), "%s/%s_patch", basefolder, filename); } else { Com_sprintf(pathname, sizeof(pathname), "%s", filename); Com_sprintf(pathpatch, sizeof(pathpatch), "%s_patch", filename); } inlength = botimport.FS_FOpenFileHash(pathname, &h_up, FS_READ, &inhash); if (!h_up) return NULL; plength = botimport.FS_FOpenFile(pathpatch, &h_patch, FS_READ); inbuffer = (char *)GetClearedMemory(inlength + 1); botimport.FS_Read(inbuffer, inlength, h_up); botimport.FS_FCloseFile(h_up); if (h_patch) { pbuffer = (char *)GetClearedMemory(plength + 1); botimport.FS_Read(pbuffer, plength, h_patch); botimport.FS_FCloseFile(h_patch); Com_Printf("patching menu file %s.../n", pathname); outlength = MV_MenuPatchFile(inbuffer, inhash, pbuffer, &outbuffer); if (outlength < 0) { if (outlength == ERROR_SYNTAX) { Com_Printf("patching failed: syntax error in patchfile/n"); } else if (outlength == ERROR_HASH) { Com_Printf("patching skipped: hash mismatch/n"); } outbuffer = inbuffer; outlength = inlength; } FreeMemory(pbuffer); // uncomment to dump patched file with _patched suffix; menu_patch /* char patchedName[MAX_QPATH]; fileHandle_t patchedFile; Com_sprintf(patchedName, sizeof(patchedName), "%s_patched", pathname); botimport.FS_FOpenFile(patchedName, &patchedFile, FS_WRITE); botimport.FS_Write(outbuffer, outlength, patchedFile); botimport.FS_FCloseFile(patchedFile); */ } else { outbuffer = inbuffer; outlength = inlength; } script = (script_t *)GetClearedMemory(sizeof(script_t) + outlength + 1); Com_Memset(script, 0, sizeof(script_t)); strcpy(script->filename, filename); script->buffer = (char *)script + sizeof(script_t); script->buffer[outlength] = 0; script->length = outlength; script->script_p = script->buffer; script->lastscript_p = script->buffer; script->end_p = &script->buffer[outlength]; script->tokenavailable = 0; script->line = 1; script->lastline = 1; SetScriptPunctuations(script, NULL); Com_Memcpy(script->buffer, outbuffer, outlength); FreeMemory(outbuffer); if (outbuffer != inbuffer) FreeMemory(inbuffer); script->length = COM_Compress(script->buffer); return script;} //end of the function LoadScriptFile
开发者ID:ataceyhun,项目名称:jk2mv,代码行数:81,
注:本文中的GetClearedMemory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetClientName函数代码示例 C++ GetClassPtr函数代码示例 |