示例#1
0
void LoadStatics( byte * buffer, int size)
{saved_stat_type dummy;
 int stcount,i;
 statobj_t*temp;

 stcount = size/sizeof(saved_stat_type);
 InitStaticList();

 for(i=0;i<stcount;i++)
	{
	temp = (statobj_t*)Z_LevelMalloc(sizeof(statobj_t),PU_LEVELSTRUCT,NULL);
	if (!temp)
		Error("LoadStatics: Failed on allocation of static %d of %d",i,stcount);
	memset(temp,0,sizeof(*temp));
	memcpy(&(dummy.x),buffer,sizeof(saved_stat_type));
	temp->whichstat = statcount++;
	temp->x = dummy.x;
	temp->y = dummy.y;
	temp->z = dummy.z;
	temp->flags = dummy.flags;
	temp->ticcount = dummy.ticcount;
	temp->hitpoints = dummy.hitpoints;
	temp->shapenum = dummy.shapenum;
	temp->ammo = dummy.ammo;
	temp->count = dummy.count;
	temp->numanims = dummy.numanims;
	temp->itemnumber = dummy.itemnumber;
	temp->areanumber = dummy.areanumber;
	temp->linked_to = dummy.linked_to;

	temp->which = SPRITE;
	temp->tilex = temp->x >> TILESHIFT;
	temp->tiley = temp->y >> TILESHIFT;
	temp->flags &= ~FL_ABP;
	temp->visspot = &spotvis[temp->tilex][temp->tiley];

	if ((temp->itemnumber >= stat_touch1) &&
		 (temp->itemnumber <= stat_touch4))
	  {touchindices[temp->tilex][temp->tiley] = lasttouch + 1;
		lasttouch ++;
		SD_PreCacheSoundGroup(SD_TOUCHPLATESND,SD_BADTOUCHSND);
	  }

	AddStatic(temp);
	if (temp->shapenum != -1)
	  {
     if (temp->itemnumber == stat_bullethole)
		  {
		  SetupBulletHoleLink(temp->linked_to,temp);
		  }

	  else if (temp->flags & FL_DEADBODY)
		  {
        if ( actorat[temp->tilex][temp->tiley] == NULL )
           actorat[temp->tilex][temp->tiley] = temp;
		  }

	  else if (!(temp->flags & FL_NONMARK))
		  {
		  sprites[temp->tilex][temp->tiley] = temp;
		  }

     PreCacheStaticFrames(temp);


	  }
	PreCacheStaticSounds(temp->itemnumber);

	buffer += sizeof(saved_stat_type);
  }
}
示例#2
0
void SetupGameLevel (void)
{
	int	x,y,i;
	unsigned	far *map,tile,spot;


	if (!loadedgame)
	{
	 gamestate.TimeCount=
	 gamestate.secrettotal=
	 gamestate.killtotal=
	 gamestate.treasuretotal=
	 gamestate.secretcount=
	 gamestate.killcount=
	 gamestate.treasurecount=0;
	}

	if (demoplayback || demorecord)
		US_InitRndT (false);
	else
		US_InitRndT (true);

//
// load the level
//
	CA_CacheMap (gamestate.mapon+10*gamestate.episode);
	mapon-=gamestate.episode*10;

	mapwidth = mapheaderseg[mapon]->width;
	mapheight = mapheaderseg[mapon]->height;

	if (mapwidth != 64 || mapheight != 64)
		Quit ("Map not 64*64!");


//
// copy the wall data to a data segment array
//
	memset (tilemap,0,sizeof(tilemap));
	memset (actorat,0,sizeof(actorat));
	map = mapsegs[0];
	for (y=0;y<mapheight;y++)
		for (x=0;x<mapwidth;x++)
		{
			tile = *map++;
			if (tile<AREATILE)
			{
			// solid wall
				tilemap[x][y] = tile;
				(unsigned)actorat[x][y] = tile;
			}
			else
			{
			// area floor
				tilemap[x][y] = 0;
				(unsigned)actorat[x][y] = 0;
			}
		}

//
// spawn doors
//
	InitActorList ();			// start spawning things with a clean slate
	InitDoorList ();
	InitStaticList ();

	map = mapsegs[0];
	for (y=0;y<mapheight;y++)
		for (x=0;x<mapwidth;x++)
		{
			tile = *map++;
			if (tile >= 90 && tile <= 101)
			{
			// door
				switch (tile)
				{
				case 90:
				case 92:
				case 94:
				case 96:
				case 98:
				case 100:
					SpawnDoor (x,y,1,(tile-90)/2);
					break;
				case 91:
				case 93:
				case 95:
				case 97:
				case 99:
				case 101:
					SpawnDoor (x,y,0,(tile-91)/2);
					break;
				}
			}
		}

//
// spawn actors
//
	ScanInfoPlane ();

//
// take out the ambush markers
//
	map = mapsegs[0];
	for (y=0;y<mapheight;y++)
		for (x=0;x<mapwidth;x++)
		{
			tile = *map++;
			if (tile == AMBUSHTILE)
			{
				tilemap[x][y] = 0;
				if ( (unsigned)actorat[x][y] == AMBUSHTILE)
					actorat[x][y] = NULL;

				if (*map >= AREATILE)
					tile = *map;
				if (*(map-1-mapwidth) >= AREATILE)
					tile = *(map-1-mapwidth);
				if (*(map-1+mapwidth) >= AREATILE)
					tile = *(map-1+mapwidth);
				if ( *(map-2) >= AREATILE)
					tile = *(map-2);

				*(map-1) = tile;
			}
		}



//
// have the caching manager load and purge stuff to make sure all marks
// are in memory
//
	CA_LoadAllSounds ();

}