//========================================= // Free allocated resources for next search //========================================= void FreeStack(node_t *PathNode) { unsigned long NumFreed=0;//GHz - for debugging node_t *tNode; stack_t *STK; //GHz NOTE: numfreed is not consistent with numcount // it looks like the OPEN list has a broken forward link // or perhaps the child nodes are not being accounted for? // are we counting nodes for NodeCount properly? // maybe make a ListNodes() func for debugging to see what all the lists contain and where they are pointing? while (PathNode) { tNode=PathNode; PathNode=PathNode->PrevNode; V_Free(tNode); //free(tNode); NumFreed++; } while (CLOSED) { tNode=CLOSED; CLOSED=CLOSED->NextNode; V_Free(tNode); //free(tNode); NumFreed++; } while (OPEN) { tNode=OPEN; OPEN=OPEN->NextNode; V_Free(tNode); //free(tNode); NumFreed++; } while (Stack) { STK=Stack; Stack=Stack->StackPtr; V_Free(STK); //free(STK); NumFreed++; } //gi.dprintf("freed %d/%d nodes\n", NumFreed, NodeCount); }
//========================================= // Pop Node from front of the linked list //========================================= node_t *Pop(void) { node_t *tNode; stack_t *STK; STK=Stack; // Start of Stack tNode=Stack->NodePtr; // Grab this Node. Stack=Stack->StackPtr; // Move Stack Pointer V_Free(STK); // Free this node return (tNode); }
// tex and mask should already be created. we'll re-read in each of their // file's data, and then create another image and GL compile it, storing // all of the new info to ip. Only supports textures that have an equal // width and height value, and that value must be a powerof 2. int IMG_CombineTextureMaskPow2( image_t *tex, image_t *mask, image_t **ipp ) { int i; if ( !( tex && mask && ipp ) ) return -1; if ( tex->h != tex->w || mask->h != mask->w ) return -2; if ( !ISPOWEROF2( tex->h ) ) return -3; // alloc the image image_t *ip = (image_t *) V_Malloc( sizeof(image_t) ); image_t *m_ip = (image_t*) V_Malloc( sizeof(image_t) ); memset( ip, 0, sizeof(image_t) ); memset( m_ip, 0, sizeof(image_t) ); char path[ 512 ]; snprintf( path, 512, "%s\\%s", fs_gamepath->string(), tex->syspath ); // read the TEX file switch ( tex->type ) { case IMG_TGA: IMG_readfileTGA( path, ip ); break; case IMG_BMP: IMG_readfileBMP( path, ip ); break; case IMG_GIF: case IMG_JPG: case IMG_PCX: case IMG_PPM: case IMG_PNG: default: Com_Printf( "image type: %s not supported\n", IMG_Error(tex->type) ); V_Free(ip); V_Free(m_ip); return -6; } // save path info of the texture image ip->name[0] = 0; ip->syspath[0] = 0; strcpy( ip->name, strip_path( &path[0] ) ); strcpy( ip->syspath, strip_gamepath( &path[0] ) ); // read in the MASK file snprintf( path, 512, "%s\\%s", fs_gamepath->string(), mask->syspath ); switch ( mask->type ) { case IMG_TGA: IMG_readfileTGA( path, m_ip ); break; case IMG_BMP: IMG_readfileBMP( path, m_ip ); break; case IMG_GIF: case IMG_JPG: case IMG_PCX: case IMG_PPM: case IMG_PNG: default: Com_Printf( "image type: %s not supported\n", IMG_Error(mask->type) ); if ( ip->data ) V_Free( ip->data ); V_Free(ip); V_Free(m_ip); return -7; } int err_cond = 0; // allocates compiled array & formats data into it if ( IMG_compileGLImage( ip ) ) err_cond = 1; if ( IMG_compileGLImage( m_ip ) ) err_cond = 1; byte *rsmp = NULL; if ( !err_cond ) { int scale = ip->w / m_ip->w; // difference between scales // single channel greyscale mask int r_sz = ip->h * ip->w; // 1 byte for each pixel rsmp = (byte *) V_Malloc( ip->h * ip->w ); memset( rsmp, 0, r_sz ); // convert mask from it's resident format to be the same dimension // as the texture image int h, i, j, k, rsmp_i, rsmp_j, pix; /// foreach Row in Mask // for each row in m_ip ==> j for ( j = 0; j < m_ip->h; j++ ) { /// foreach col in Mask // for each col in m_ip ==> i for ( i = 0; i < m_ip->w; i++ ) { /// extrapolate Mask Pixel to Cover all of it's corresponding pixels /// in the new re-sampled mask // ROWS: ( j * scale ) to ( j * scale + scale ) for ( k = 0; k < scale; k++ ) { rsmp_j = j * scale + k; // COLS: set i to i + scale pixels to value of m_ip->compiled[ i ] for ( h = 0; h < scale; h++ ) { rsmp_i = i * scale + h; // index into new mask pix = rsmp_j * ip->w + rsmp_i; if ( pix < r_sz ) { rsmp[ pix ] = m_ip->compiled[ j * m_ip->w + i ]; } } } } } if ( ip->bpp == 1 ) { for ( i = 0; i < (int)ip->numbytes; i += 1 ) { if ( rsmp[ i ] == 0 ) { ip->compiled[ i + 0 ] = 0; } } } else if ( 0 ) { // set to zero any texels that didn't pass for ( i = 0; i < (int)r_sz; i++ ) { if ( rsmp[ i ] == 0 ) { ip->compiled[ i * 4 + 0 ] = 0; ip->compiled[ i * 4 + 1 ] = 0; ip->compiled[ i * 4 + 2 ] = 0; ip->compiled[ i * 4 + 3 ] = 255; } } } // if bpp == 4 IMG_MakeGLTexture( ip ); } if ( ip->data ) { V_Free( ip->data ); ip->data = NULL; } if ( ip->compiled ) { V_Free( ip->compiled ); ip->compiled = NULL; } if ( m_ip->data ) { V_Free( m_ip->data ); m_ip->data = NULL; } if ( m_ip->compiled ) { V_Free( m_ip->compiled ); m_ip->compiled = NULL; } V_Free( m_ip ); if ( rsmp ) V_Free( rsmp ); *ipp = NULL; if ( err_cond ) return -4; *ipp = ip; return 0; }
void boss_spawn_tank (edict_t *ent) { char userinfo[MAX_INFO_STRING], *message; //edict_t *tank; //gi.dprintf("boss_spawn_tank()\n"); if (G_EntExists(ent->owner) && (ent->owner->mtype == BOSS_TANK)) { message = HiPrint(va("%s got bored and left the game.", ent->client->pers.netname)); gi.bprintf(PRINT_HIGH, "%s\n", message); V_Free(message); BecomeTE(ent->owner); ent->svflags &= ~SVF_NOCLIENT; ent->viewheight = 22; ent->movetype = MOVETYPE_WALK; ent->solid = SOLID_BBOX; ent->takedamage = DAMAGE_AIM; // recover player info memcpy(userinfo, ent->client->pers.userinfo, sizeof(userinfo)); InitClientPersistant(ent->client); ClientUserinfoChanged(ent, userinfo); modify_max(ent); Pick_respawnweapon(ent); ent->owner = NULL; return; } CreateBoss(ent); /* message = HiPrint(va("A level %d boss known as %s has spawned!", average_player_level, ent->client->pers.netname)); gi.bprintf(PRINT_HIGH, "%s\n", message); // create the tank entity that the player will pilot tank = G_Spawn(); tank->classname = "boss"; tank->solid = SOLID_BBOX; tank->takedamage = DAMAGE_YES; tank->movetype = MOVETYPE_STEP; tank->clipmask = MASK_MONSTERSOLID; tank->svflags |= SVF_MONSTER; tank->activator = ent; tank->die = boss_tank_die; tank->think = boss_tank_think; tank->mass = 500; tank->monsterinfo.level = average_player_level; tank->health = TANK_INITIAL_HEALTH+TANK_ADDON_HEALTH*tank->monsterinfo.level; tank->max_health = tank->health; tank->mtype = BOSS_TANK; tank->pain = boss_pain; tank->flags |= FL_CHASEABLE; // 3.65 indicates entity can be chase cammed // set up pointers tank->owner = ent; ent->owner = tank; tank->s.modelindex = gi.modelindex ("models/monsters/tank/tris.md2"); VectorSet (tank->mins, -24, -24, -16); VectorSet (tank->maxs, 24, 24, 64); tank->s.skinnum = 2; // commander skin VectorCopy(ent->s.angles, tank->s.angles); tank->s.angles[PITCH] = 0; // monsters don't use pitch tank->nextthink = level.time + FRAMETIME; VectorCopy(ent->s.origin, tank->s.origin); VectorCopy(ent->s.old_origin, tank->s.old_origin); // link up entities gi.linkentity(tank); gi.linkentity(ent); // make the player into a ghost ent->svflags |= SVF_NOCLIENT; ent->viewheight = 0; ent->movetype = MOVETYPE_NOCLIP; ent->solid = SOLID_NOT; ent->takedamage = DAMAGE_NO; ent->client->ps.gunindex = 0; memset (ent->client->pers.inventory, 0, sizeof(ent->client->pers.inventory)); ent->client->pers.weapon = NULL; */ }
void IMG_compileImageFile ( const char *path, image_t **ip ) { int type; int i; *ip = (image_t *) V_Malloc( sizeof(image_t) ); // get type from filename extension for (i = 0; path[i] != '\0'; i++) ; do { --i; } while ( path[i] != '.' ); ++i; type = IMG_NONE; if ( !C_strncasecmp( &path[i], "BMP", 3 ) ) type = IMG_BMP; else if ( !C_strncasecmp( &path[i], "TGA", 3 ) ) type = IMG_TGA; // switch(type) { case IMG_TGA: IMG_readfileTGA( path, *ip ); break; case IMG_BMP: IMG_readfileBMP( path, *ip ); break; case IMG_GIF: case IMG_JPG: case IMG_PCX: case IMG_PPM: case IMG_PNG: default: Com_Printf( "image type: %s not supported\n", IMG_Error(type) ); V_Free(*ip); (*ip)=NULL; return; } (*ip)->name[0] = 0; (*ip)->syspath[0] = 0; // get basename strcpy( (*ip)->name, strip_path( &path[0] ) ); // get relative name strcpy( (*ip)->syspath, strip_gamepath( &path[0] ) ); int err_cond = 0; if ( IMG_compileGLImage( *ip ) ) err_cond = 1; V_Free( (*ip)->data ); (*ip)->data = NULL; if ( !err_cond ) { IMG_MakeGLTexture( *ip ); V_Free( (*ip)->compiled ); (*ip)->compiled = NULL; } }