// // ACS_thingCount // static int32_t ACS_thingCount(mobjtype_t type, int32_t tid) { Mobj *mo = NULL; int count = 0; if(tid) { while((mo = P_FindMobjFromTID(tid, mo, NULL))) { if(type == 0 || mo->type == type) { // don't count killable things that are dead if(((mo->flags & MF_COUNTKILL) || (mo->flags3 & MF3_KILLABLE)) && mo->health <= 0) continue; ++count; } } } else { while((mo = P_NextThinker(mo))) { if(type == 0 || mo->type == type) { // don't count killable things that are dead if(((mo->flags & MF_COUNTKILL) || (mo->flags3 & MF3_KILLABLE)) && mo->health <= 0) continue; ++count; } } } return count; }
// // TELEPORTATION // int EV_Teleport ( line_t* line, int side, mobj_t* thing ) { int i; int tag; mobj_t* m; mobj_t* fog; unsigned an; thinker_t* thinker; sector_t* sector; fixed_t oldx; fixed_t oldy; fixed_t oldz; // don't teleport missiles if (thing->flags & MF_MISSILE) return 0; // Don't teleport if hit back of line, // so you can get out of teleporter. if (side == 1) return 0; tag = line->tag; for (i = 0; i < P_CountSectors(); i++) { if (P_GetSector(i)->tag == tag ) { for (thinker = P_FirstThinker(); thinker; thinker = P_NextThinker(thinker)) { // not a mobj if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) continue; m = (mobj_t *)thinker; // not a teleportman if (m->type != MT_TELEPORTMAN ) continue; sector = m->subsector->sector; // wrong sector if (P_UngetSector(sector) != i ) continue; oldx = thing->x; oldy = thing->y; oldz = thing->z; if (!P_TeleportMove (thing, m->x, m->y)) return 0; if (!B_CheckCompat(COMPAT_TELEPORTZ)) { thing->z = thing->floorz; //fixme: not needed? } if (thing->player) thing->player->viewz = thing->z+thing->player->viewheight; // spawn teleport fog at source and destination fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); S_StartSound (fog, sfx_telept); an = m->angle >> ANGLETOFINESHIFT; fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an] , thing->z, MT_TFOG); // emit sound, where? S_StartSound (fog, sfx_telept); // don't move for a bit if (thing->player) thing->reactiontime = 18; thing->angle = m->angle; thing->momx = thing->momy = thing->momz = 0; return 1; } } } return 0; }
void R_PrecacheLevel (void) { char* texturepresent; char* spritepresent; int i; int j; int k; int lump; texture_t* texture; thinker_t* th; spriteframe_t* sf; if (demoplayback) return; // Precache flats. for (i=0 ; i<P_CountSectors() ; i++) { sector_t *sector = P_GetSector(i); W_CacheLumpNum(sector->floorpic,PU_CACHE); W_CacheLumpNum(sector->ceilingpic,PU_CACHE); } // Precache textures. texturepresent = _alloca(numtextures); memset (texturepresent,0, numtextures); for (i=0 ; i<P_CountSideDefs() ; i++) { side_t *side = P_GetSideDef(i); texturepresent[side->toptexture] = 1; texturepresent[side->midtexture] = 1; texturepresent[side->bottomtexture] = 1; } // Sky texture is always present. // Note that F_SKY1 is the name used to // indicate a sky floor/ceiling as a flat, // while the sky texture is stored like // a wall texture, with an episode dependend // name. texturepresent[skytexture] = 1; texturememory = 0; for (i=0 ; i<numtextures ; i++) { if (!texturepresent[i]) continue; texture = textures[i]; for (j=0 ; j<texture->patchcount ; j++) { lump = texture->patches[j].patch; texturememory += W_LumpLength(lump); W_CacheLumpNum(lump , PU_CACHE); } } // Precache sprites. spritepresent = _alloca(numsprites); memset (spritepresent,0, numsprites); for (th = P_FirstThinker() ; th ; th=P_NextThinker(th)) { if (th->function.acp1 == (actionf_p1)P_MobjThinker) spritepresent[((mobj_t *)th)->sprite] = 1; } spritememory = 0; for (i=0 ; i<numsprites ; i++) { if (!spritepresent[i]) continue; for (j=0 ; j<sprites[i].numframes ; j++) { sf = &sprites[i].spriteframes[j]; for (k=0 ; k<8 ; k++) { lump = sf->lump[k]; spritememory += W_LumpLength(lump); W_CacheLumpNum(lump , PU_CACHE); } } } }
void R_PrecacheLevel(void) { register int i; register byte *hitlist; if (timingdemo) return; { int size = numflats > numsprites ? numflats : numsprites; hitlist = malloc(numtextures > size ? numtextures : size); } // Precache flats. memset(hitlist, 0, numflats); for (i = numsectors; --i >= 0; ) hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1; for (i = numflats; --i >= 0; ) if (hitlist[i]) precache_lump(firstflat + i); // Precache textures. memset(hitlist, 0, numtextures); for (i = numsides; --i >= 0;) hitlist[sides[i].bottomtexture] = hitlist[sides[i].toptexture] = hitlist[sides[i].midtexture] = 1; // Sky texture is always present. // Note that F_SKY1 is the name used to // indicate a sky floor/ceiling as a flat, // while the sky texture is stored like // a wall texture, with an episode dependend // name. hitlist[skytexture] = 1; for (i = numtextures; --i >= 0; ) if (hitlist[i]) { texture_t *texture = textures[i]; int j = texture->patchcount; while (--j >= 0) precache_lump(texture->patches[j].patch); } // Precache sprites. memset(hitlist, 0, numsprites); { thinker_t *th = NULL; while ((th = P_NextThinker(th,th_all)) != NULL) if (th->function == P_MobjThinker) hitlist[((mobj_t *)th)->sprite] = 1; } for (i=numsprites; --i >= 0;) if (hitlist[i]) { int j = sprites[i].numframes; while (--j >= 0) { short *sflump = sprites[i].spriteframes[j].lump; int k = 7; do precache_lump(firstspritelump + sflump[k]); while (--k >= 0); } } free(hitlist); }