Beispiel #1
0
void  mapStart(tMap* map, tObject* kid, tRoomId *roomId, int level) {
	/* kid->x,y */
	/*static char environments[]=MAP_ENVIRONMENTS;*/
	*roomId=slevel(start)[0];
#if defined DEBUGMAPS
	printf("mapStart: binding kid to map in room %d using the %d environment\n",*roomId,environments[level]);
#endif
	slevel(time)=0;
	roomLoadGfx(/*environments[level]?RES_IMG_ENV_PALACE:*/RES_IMG_ENV_DUNGEON);
}
// Add item to output streamer list
void EvtCollectionStream::addItem(const std::string& descriptor)   {
  MsgStream log(msgSvc(), name());
  int sep = descriptor.rfind("#");
  int level = 0;
  std::string obj_path (descriptor,0,sep);
  std::string slevel   (descriptor,sep+1,descriptor.length());
  if ( slevel == "*" )  {
    level = 9999999;
  }
  else   {
    level = ::atoi(slevel.c_str());
  }
  DataStoreItem* item = new DataStoreItem(obj_path, level);
  log << MSG::INFO << "Adding OutputStream item " << item->path()
      << " with " << item->depth()
      << " level(s)." << endmsg;
  m_itemList.push_back( item );
}
Beispiel #3
0
void
do_10_pack ()
{
  int n;
  long start = get_msec_count (), duration;

  ta_enter (&ten_pack_ta);
  for (n = 0; n < 10; n++)
    {
      new_order ();
#ifndef NO_ONLY
      payment ();
#endif
    }

#ifndef NO_ONLY
  ta_enter (&delivery_ta);
  if (strstr (dbms, "Virtuoso") || strstr (dbms, "SOAP"))
    {
      for (n = 1; n <= 10; n++)
	delivery_1 (local_w_id, n);
    }
  else
    {
      delivery_1 (local_w_id, 0);
    }
  ta_leave (&delivery_ta);
  slevel ();
  ostat ();
#endif

  ta_leave (&ten_pack_ta);
  duration = get_msec_count () - start;
#if defined(GUI)
  log (1, "-- %ld tpmC\n", 600000 / duration);
#else
  printf ("-- %ld tpmC\n\n", 600000 / duration);
  fflush (stdout);
#endif
}
Beispiel #4
0
/* TODO: This is part of the kernel, it needs to be moved */
int   mapMove(tMap* map) {
	int i,refresh=0;
	slevel(time)++;
	if (slevel(time)==1000) slevel(time)=0;

	/* check out and update all the gates in the level */
	for (i=0;i<slevel(totalGates);i++) {
		int maxFrames;
		maxFrames=(map->gates[i].type==eNormalGate)?46:50;
		switch (map->gates[i].action) {
		case eOpenTimer:
			if (map->gates[i].time) {
				map->gates[i].time--;
			} else {
				map->gates[i].action=eClosing;
			}
			break;
		case eOpening:
			map->gates[i].time=12*10;
			if (map->gates[i].frame) {
				map->gates[i].frame--;
			} else {
				map->gates[i].action=eOpenTimer;
			}
			break;
		case eClosing:
			if (map->gates[i].frame!=maxFrames) {
				map->gates[i].frame++;
			} else {
				map->gates[i].action=eClose;
			}
			break;
		case eClosingFast:
			map->gates[i].frame+=30;
			if (map->gates[i].frame>maxFrames) {
				map->gates[i].action=eClose;
				map->gates[i].frame=maxFrames;
			}
			break;
		case eClose:
			map->gates[i].frame=maxFrames;
			break;
		case eOpen:
			map->gates[i].frame=0;
			break;
		}
	}
	
	/* check out and update all the buttons in the level */
	for (i=0;i<slevel(totalPressables);i++) {
		switch (map->pressables[i].action) {
		case eJustPressed:
			map->pressables[i].action=ePressed;
			break;
		case ePressed:
			map->pressables[i].action=eNormal;
			break;
		default:
			break;
		}
	}

	/* check out and update all the spikes and choppers */
#ifdef DEBUGMAPS
	printf("chopper act=%d tim=%d fra=%d\n",map->dangers[i].more.time,map->dangers[i].action,map->dangers[i].frame);
#endif
	for (i=0;i<slevel(totalDangers);i++) { 
		switch (map->dangers[i].action) {
		case eSpiUp:
			map->dangers[i].frame++;
			if (map->dangers[i].frame>4) {
				map->dangers[i].frame=4;
				map->dangers[i].action=eSpiWaitUp;
				map->dangers[i].more.time=30;
			}
			break;
		case eSpiWaitUp:
			map->dangers[i].more.time--;
			if (!map->dangers[i].more.time) {
				map->dangers[i].action=eSpiDown;
			}
			break;
		case eSpiDown:
			if (map->dangers[i].frame) map->dangers[i].frame++;
			if (map->dangers[i].frame==7) map->dangers[i].frame=0;
			break;
		case eChoInactive:
			if (map->dangers[i].frame) map->dangers[i].frame++;
			if (map->dangers[i].frame==6) map->dangers[i].frame=0;
			map->dangers[i].more.time=1;
			break;
		case eChoActive:
			if (map->dangers[i].frame) {
				map->dangers[i].frame++;
			} else {
				map->dangers[i].more.time--;
			}
			if (map->dangers[i].frame==6) {
				map->dangers[i].frame=0;
				map->dangers[i].more.time=10;
			}
			if (!map->dangers[i].more.time) map->dangers[i].frame++;
			break;
		case eLosMoving:
			map->dangers[i].frame++;
			if (map->dangers[i].frame==11) {
				/* Unlink the tile from the map and add it as a falling object */
				tFlying* loose=(tFlying*)malloc(sizeof(tFlying));
				
				map->dangers[i].action=eLosDown; /* Mark it as down in the map */
				loose->next=map->flyingObjects; /* Link the tile to the flying objects list */
				map->flyingObjects=loose;
				
				loose->x=(map->dangers[i].pos%10)*TILE_W;
				loose->y=((map->dangers[i].pos%30)/10+1)*TILE_H;
				loose->speed=0;
				loose->screen=map->dangers[i].pos/30+1;
			}
			break;
		default:
			break;
		}
	}

	/* Now it's time to move the flying objects */
	{
	tFlying* loose=map->flyingObjects;
	while (loose) {
		tRoom room;
		int x=loose->x/TILE_W;
		int y=loose->y/TILE_H;
						
#if defined DEBUGMAPS
		if (loose->screen) printf("Updating tile (x,y)=(%d,%d) s=%d\n",loose->x,loose->y,loose->screen);
#endif
		if (loose->speed<7) loose->speed++;
		if (loose->screen) room=mapGetRoom(map,loose->screen);
		/* calculate if there will be an impact */
		if (loose->screen&&(y!=((loose->y+loose->speed*3)/TILE_H))) { /* tile changed floor and not in screen 0*/
			tTile tile=roomGetTile(&room,x+1,y+1);
#if defined DEBUGMAPS
			printf("Tile changed floor tile=(%d,%d)\n",tile.code,tile.back);
#endif
			if (isIn(tile,TILES_WALKABLE)) {
#if defined DEBUGMAPS
				printf("IMPACT in s%d x%d y%d\n",loose->screen,x,y);
#endif
				map->fore[(loose->screen-1)*30+x+y*10]=TILE_DEBRIS;
				map->back[(loose->screen-1)*30+x+y*10]=0;
				refresh=1;
				loose->screen=0;
			}
		}

		/* if not keep falling */
		loose->y+=loose->speed*3;
		if (loose->y>3*TILE_H) { /* go the the screen bellow */
			if (loose->screen) loose->screen=*(slevel(links)+((loose->screen-1)*4)+eDown);
			loose->y=0;
			/* TODO: if the screen is 0 destroy loose tiles from the falling list */
		}
		loose=loose->next;
	}
	}

	if (map->refresh) {
		map->refresh=0;
		refresh=1;
	}
	return refresh;
}
Beispiel #5
0
tRoom mapGetRoom(tMap* map, tRoomId roomAux) {
	tRoom result;

	/* SET room id*/
	result.id=roomAux;
	result.level=map;
	
	/* SET room links */
	memcpy(result.links,slevel(links)+((roomAux-1)*4),4);
	/* up corners */
	roomAux=result.links[2];
	if (roomAux) {
		result.corners[0]=*(slevel(links)+((roomAux-1)*4)+0);
		result.corners[1]=*(slevel(links)+((roomAux-1)*4)+1);
	} else {
		result.corners[0]=0;
		result.corners[1]=0;
	}
	/* down corners */
	roomAux=result.links[3];
	if (roomAux) {
		result.corners[2]=*(slevel(links)+((roomAux-1)*4)+0);
		result.corners[3]=*(slevel(links)+((roomAux-1)*4)+1);
	} else {
		result.corners[2]=0;
		result.corners[3]=0;
	}
	
	/* SET corner bytes */
	/* left+up */
	if ((roomAux=result.corners[0])) {
		result.fore[0]=*(slevel(fore)+30*(roomAux-1)+29);
		result.back[0]=*(slevel(back)+30*(roomAux-1)+29);
	} else {
		result.fore[0]=MAP_F_WALL;
		result.back[0]=MAP_B_NONE;
	}
	/* right+up */
	if ((roomAux=result.corners[1])) {
		result.fore[11]=*(slevel(fore)+30*(roomAux-1)+20);
		result.back[11]=*(slevel(back)+30*(roomAux-1)+20);
	} else {
		result.fore[11]=MAP_F_FREE;
		result.back[11]=MAP_B_NONE;
	}
	/* left+down */
	if ((roomAux=result.corners[2])) {
		result.fore[48]=*(slevel(fore)+30*(roomAux-1)+9);
		result.back[48]=*(slevel(back)+30*(roomAux-1)+9);
	} else {
		result.fore[48]=MAP_F_WALL;
		result.back[48]=MAP_B_NONE;
	}
	/* right+down */
	if ((roomAux=result.corners[3])) {
		result.fore[59]=*(slevel(fore)+30*(roomAux-1)+0);
		result.back[59]=*(slevel(back)+30*(roomAux-1)+0);
	} else {
		result.fore[59]=MAP_F_WALL;
		result.back[59]=MAP_B_NONE;
	}

	/* Left room */
	if ((roomAux=result.links[0])) {
		result.fore[12]=*(slevel(fore)+30*(roomAux-1)+9);
		result.back[12]=*(slevel(back)+30*(roomAux-1)+9);
		result.fore[24]=*(slevel(fore)+30*(roomAux-1)+19);
		result.back[24]=*(slevel(back)+30*(roomAux-1)+19);
		result.fore[36]=*(slevel(fore)+30*(roomAux-1)+29);
		result.back[36]=*(slevel(back)+30*(roomAux-1)+29);
	} else {
		result.fore[12]=MAP_F_WALL;
		result.back[12]=MAP_B_NONE;
		result.fore[24]=MAP_F_WALL;
		result.back[24]=MAP_B_NONE;
		result.fore[36]=MAP_F_WALL;
		result.back[36]=MAP_B_NONE;	
	}

	/* Right room */
	if ((roomAux=result.links[1])) {
		result.fore[23]=*(slevel(fore)+30*(roomAux-1)+0);
		result.back[23]=*(slevel(back)+30*(roomAux-1)+0);
		result.fore[35]=*(slevel(fore)+30*(roomAux-1)+10);
		result.back[35]=*(slevel(back)+30*(roomAux-1)+10);
		result.fore[47]=*(slevel(fore)+30*(roomAux-1)+20);
		result.back[47]=*(slevel(back)+30*(roomAux-1)+20);
	} else {
		result.fore[23]=MAP_F_WALL;
		result.back[23]=MAP_B_NONE;
		result.fore[35]=MAP_F_WALL;
		result.back[35]=MAP_B_NONE;
		result.fore[47]=MAP_F_WALL;
		result.back[47]=MAP_B_NONE;	
	}

	/* Top room */
	if ((roomAux=result.links[2])) {
		memcpy(result.fore+1,slevel(fore)+30*(roomAux-1)+20,10);
		memcpy(result.back+1,slevel(back)+30*(roomAux-1)+20,10);
	} else {
		memcpy(result.fore+1,"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01",10); /* TODO: use tiles */
		memcpy(result.back+1,"\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01",10); /* TODO: use tiles */
	}

	/* Bottom room */
	if ((roomAux=result.links[3])) {
		memcpy(result.fore+49,slevel(fore)+30*(roomAux-1)+0,10);
		memcpy(result.back+49,slevel(back)+30*(roomAux-1)+0,10);
	} else {
		memcpy(result.fore+49,"\0\0\0\0\0\0\0\0\0\0",10); /* TODO: use tiles */
		memcpy(result.back+49,"\0\0\0\0\0\0\0\0\0\0",10); /* TODO: use tiles */
	}

	/* Main room */
	memcpy(result.fore+13,slevel(fore)+30*(result.id-1)+0,10);
	memcpy(result.back+13,slevel(back)+30*(result.id-1)+0,10);
	memcpy(result.fore+25,slevel(fore)+30*(result.id-1)+10,10);
	memcpy(result.back+25,slevel(back)+30*(result.id-1)+10,10);
	memcpy(result.fore+37,slevel(fore)+30*(result.id-1)+20,10);
	memcpy(result.back+37,slevel(back)+30*(result.id-1)+20,10);

/* This will save a screen map into data.
 * 
 * data is a pre-allocated array with 10x3=30 bytes with the screen map
 * dumped over it in left-to-right/upper-to-lower oreder. 
 *
 * borders is another pre-allocated array with 10 upper bytes, 10 bottom
 * bytes, 3 left-side bytes, 3 right-side bytes and 4 bytes for the
 * corners. This is another 30 bytes. The order has to be determined!
 * In case the screen doesn't exist the 0x00 (free foreground) byte will
 * be returned for the bottom and right sides, the wall foreground for
 * the left side and the simple tile byte for the top side.
 * int levelGetScreenItems(unsigned char* data,unsigned char* borders) {
 * This will save a screen map modifiers into data.
 *
 * data and borders are in the same form as Walls but they contain
 * additional modifiers that must be defined in conf files.
 * e.g. MAPS_ITEMS_DOOROPEN 0x01
 */

	return result;
}