Exemple #1
0
void BuyChipLayer::click_btn_sub(Ref* sender)
{
    if(amount_ <= 0){
        return;
    }
    auto user = static_pointer_cast<user_texas>( GetRoom()->get_user(GDM->get_user_id()));
    
    int buyin_min = GetRoom()->get_buyin_min();
    int buyin_max = GetRoom()->get_buyin_max();
    
    bool need_credit = false;//permission_.needcredit();
    if (need_credit)
    {
        uint32_t credit = permission_.credit();
        if (credit < buyin_max)
            buyin_max = credit;
    }
    
    int min_chip = buyin_min - user->get_properties()->chips();
    int max_chip = buyin_max - user->get_properties()->chips();
    
    uint32_t unit = GetRoom()->get_buy_min_unit();
    
    uint32_t sub = max_chip - std::max(min_chip, 0);
    int32_t value = amount_ - unit;
    if(value >= min_chip && value <= max_chip) {
        float percent = (value - std::max(0, min_chip)) * 100.0f / sub;
        slider_chip_->setPercent(percent);
        amount_ = value;
        text_buy_number_->setString(tools::to_string(amount_));
    }
}
Exemple #2
0
void LayerMahjongMenu::click_btn_chat(cocos2d::Ref *sender)
{
    ChatMessageManager::getInstance()->clear_unreal_message_by(GetRoom()->get_group_id(), ChatMessageManager::MESSAGETYPE::GROUPCHAT);
    handle_receive_chat(nullptr);//接收信息
    
    gcl = LayerGameChat::createByGroup(GetRoom()->get_group_id());
    this->addChild(gcl, 0,"LayerGameChat");
}
Exemple #3
0
void BuyChipLayer::Refresh()
{
    if (GetRoom()->get_group_id() == 0)
    {
        handle_get_permission(nullptr);
    }else
    {
        auto processor = PM->GetUserPermission_up(GetRoom()->get_group_id(), GDM->get_user_id());
        send_data(processor,REQ_GET_PERMISSION);
    }
}
Exemple #4
0
int
GetVisited (int x, int y)
{
  /* Not a valid room. */
  if (x < 0 
      || y < 0
      || x >= map.w
      || y >= map.h
      || GetRoom (x, y) == -1)
    return 0;

  return map.rooms[GetRoom (x, y)].visited;
}
Exemple #5
0
void SaveLevel()
{
  int x, y, i;
  SDL_Surface *map_surf;
  char cs[2] = ".";
  char rnum[5] = "0000";
  unsigned char ch;
  unsigned char *map_p;
  SDL_Color cpalette[4];
  Uint8 cl;
	
  map_surf = SDL_CreateRGBSurface(0, 4096, 4096, 8, 0, 0, 0, 0);
	
  map_p = map.m;
	
  cpalette[0].r = cpalette[0].g = cpalette[0].b = 0;
  cpalette[1].r = cpalette[1].g = cpalette[1].b = 255;
  cpalette[2].r = 255; cpalette[2].g = 0; cpalette[2].b = 255;
  cpalette[3].r = 0; cpalette[3].g = 255; cpalette[3].b = 128;
	
  SDL_SetPalette(map_surf, SDL_LOGPAL | SDL_PHYSPAL, cpalette, 0, 4);
	
  for (y = 0; y < map.h; y++) {
    for (x = 0; x < map.w; x++) {
      ch = *(map_p++);
			
      if (IsSolid(ch))
        *cs = 4;
      else
        *cs = 5;
				
      if (ch == 17)
        *cs = 0;
				
      cl = 1;
      if (map.rooms[GetRoom(x, y)].room_type == 2) cl = 2;
      if (map.rooms[GetRoom(x, y)].room_type == 3) cl = 3;
			
      draw_map_text (x * 8, y * 8, cs, cl, map_surf);
    }
  }
  for (i = 0; i < NUM_ROOMS; i++) {
    sprintf(rnum, "%d", i);
    draw_map_text (map.rooms[i].x * 8, map.rooms[i].y * 8, rnum, 0, map_surf);
  }
	
  SDL_SaveBMP(map_surf, "map.bmp");
}
void CLimitDungeonManager::AddPlayer(CPlayer& player)
{
	const LimitDungeonScript& script = g_CGameResourceManager.GetLimitDungeonScript(
		mMapType,
		player.GetChannelID());

	if(0 == script.mMapType)
	{
		return;
	}

	Room& room = GetRoom(
		script.mMapType,
		script.mChannel);
	room.mPlayerIndexSet.insert(
		player.GetID());
	mPlayerQueue.push(
		player.GetID());

	// 091106 LUJ, 돌아갈 곳을 미리 설정해놓는다
	const LimitDungeonScript::Home& home = script.mHome;
	player.SetMapMoveInfo(
		home.mMapType,
		DWORD(home.mPosition.x),
		DWORD(home.mPosition.z));
	__time64_t todayTime = 0;
	_time64(&todayTime);
	MSG_DWORDEX2 message;
	ZeroMemory(&message, sizeof(message));
	message.Category = MP_LIMITDUNGEON;
	message.Protocol = MP_LIMITDUNGEON_JOIN_ACK;
	message.dweData1 = DWORDEX(g_pServerSystem->GetMonsterCount(script.mChannel));
	message.dweData2 = room.mCloseTime - todayTime;
	player.SendMsg(
		&message,
		sizeof(message));

	TCHAR text[MAX_PATH] = {0};
	_sntprintf(
		text,
		_countof(text),
		"%map:%d(%d)",
		script.mMapType,
		script.mChannel);
	LogItemMoney(
		player.GetID(),
		player.GetObjectName(),
		0,
		text,
		eLog_LimitDungeonBegin,
		player.GetMoney(),
		0,
		0,
		0,
		0,
		0,
		0,
		0,
		0);
}
Exemple #7
0
void CTaxasPokerPeer::OnWaitActionTimeOut()
{
	if ( GetPlayer()->GetState() == CPlayer::ePlayerState_WillLeavingRoom )
	{
		LeaveRoom();
		return ;
	}

	++m_nContinueNoneAct;

	stMsgTaxasPokerPeerAction msg ;
	msg.ePeerAct = eRoomPeerAction_GiveUp ;
	CRoomTexasPoker*pRoom = (CRoomTexasPoker*)GetRoom() ;
	if ( pRoom->GetCurMostBetCoinThisRound() == GetBetCoinThisRound() )
	{
		msg.ePeerAct = eRoomPeerAction_Pass ;
	}
	
	if ( m_nContinueNoneAct > MAX_NONE_ACT_TIMES )
	{
		msg.ePeerAct = eRoomPeerAction_StandUp ;
		m_nContinueNoneAct = 0 ;
	}
	unsigned nNoneActTimes = m_nContinueNoneAct ;
	OnMessage( &msg ) ;
	m_nContinueNoneAct = nNoneActTimes;
}
QStringList MucExtension::GetParticipants(QString roomJid)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return QStringList();

    return room->participants();
}
bool MucExtension::Invite(QString roomJid, QString peerJid, QString reason)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return false;

    return room->sendInvitation(peerJid, reason);
}
QString MucExtension::GetRoomSubject(QString roomJid)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return QString("unknown");

    return room->subject();
}
bool MucExtension::SendMessage(QString roomJid, QString message)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return false;

    return room->sendMessage(message);
}
bool MucExtension::LeaveRoom(QString roomJid)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return false;

    return room->leave("Bye!");
}
void CLimitDungeonManager::UpdatePlayer()
{
	if(mPlayerQueue.empty())
	{
		return;
	}

	const DWORD playerIndex = mPlayerQueue.front();
	mPlayerQueue.pop();

	CPlayer* const player = (CPlayer*)g_pUserTable->FindUser(playerIndex);

	if(0 == player)
	{
		return;
	}
	else if(eObjectKind_Player != player->GetObjectKind())
	{
		return;
	}

	const Room& room = GetRoom(mMapType, player->GetChannelID());
	const BOOL isClosedRoom(0 == room.mCloseTime);

	if(isClosedRoom)
	{
		const LimitDungeonScript& script = g_CGameResourceManager.GetLimitDungeonScript(
			mMapType,
			player->GetChannelID());				
		player->UpdateLogoutToDB(FALSE);

		MSG_WORD2 message;
		ZeroMemory(&message, sizeof(message));
		message.Category = MP_USERCONN;
		message.Protocol = MP_USERCONN_MAP_OUT_WITHMAPNUM;
		message.dwObjectID = playerIndex;
		message.wData1 = script.mHome.mMapType;
		message.wData2 = WORD(-1);
		g_Network.Broadcast2AgentServer(
			LPTSTR(&message),
			sizeof(message));
		g_pServerSystem->RemovePlayer(playerIndex);
		return;
	}

	// 091106 LUJ, 다시 순차적으로 업데이트할 수 있도록 큐에 넣어둔다
	mPlayerQueue.push(playerIndex);

	MSG_DWORD message;
	ZeroMemory(&message, sizeof(message));
	message.Category = MP_LIMITDUNGEON;
	message.Protocol = MP_LIMITDUNGEON_SET_STATUS_ACK;
	message.dwData = g_pServerSystem->GetMonsterCount(player->GetChannelID());
	player->SendMsg(
		&message,
		sizeof(message));
}
Exemple #14
0
int GetVisited(int x, int y)
{
	if (x < 0) return 0;
	if (y < 0) return 0;
	if (x >= map.w) return 0;
	if (y >= map.h) return 0;
	
	return rooms[GetRoom(x, y)].visited;
}
Exemple #15
0
void BuyChipLayer::click_btn_confirm(Ref* sender)
{
    //    int amount = PDM->get_room()->get_buyin_max() - PDM->get_room()->get_buyin_min();
    //    int buy_count = PDM->get_room()->get_buyin_min() + amount * slider_chip_->getPercent() / 100.0f;
    PDM->send_poker_add_chips(amount_, GetRoom()->get_id());
    
    auto user = static_pointer_cast<user_texas>(GetRoom()->get_user( GDM->get_user_id()));
    if(user->get_status() == msg::SittingStatus::PLAYING)
    {
        PokerRoomLayer * prl = dynamic_cast<PokerRoomLayer *>(getParent()->getParent());
        if(prl&&prl->get_is_playing())
        {
            TipView::showAlertView(tools::local_string("offer_chip","这手牌打完后会给筹码。"));
        }
        
    }
    removeFromParent();
}
Exemple #16
0
CRoom* CMapLayout::GetRoom( const Vector &vecPos )
{
	int nX = ( vecPos.x / ASW_TILE_SIZE ) + MAP_LAYOUT_TILES_WIDE * 0.5f;
	int nY = ( vecPos.y / ASW_TILE_SIZE ) + MAP_LAYOUT_TILES_WIDE * 0.5f;
	if ( nX >= 0 && nX < MAP_LAYOUT_TILES_WIDE && nY >= 0 && nY < MAP_LAYOUT_TILES_WIDE )
	{
		return GetRoom( nX, nY );
	}
	return NULL;
}
void GetName()
{
	cout << "Full Name: ";
	getline(cin, patient_name);
	if (patient_name == "")
  	{
		GiveError();
		GetName();
	}
    	else
    	GetRoom();
}
Exemple #18
0
void CMapLayout::MarkEncounterRooms()
{
	// mark all rooms with alien encounters
	for ( int i = 0; i < m_Encounters.Count(); i++ )
	{
		CRoom *pRoom = GetRoom( m_Encounters[i]->GetEncounterPosition() );
		if ( pRoom )
		{
			pRoom->SetHasAlienEncounter( true );
		}
	}
}
Exemple #19
0
void Paint(int xp, int yp, int w, int h, char *fname)
{
  FILE *fp;
  int x, y;
  fp = fopen(fname, "rb");
	
  for (y = 0; y < h; y++) {
    for (x = 0; x < w; x++) {
      Put(x+xp, y+yp, fgetc(fp), GetRoom (x + xp, y + yp));
    }
  }
  fclose(fp);
}
Exemple #20
0
void olterrain::ReceiveDamage(character* Villain, int Damage, int)
{
  if(CanBeDestroyed() && Damage > GetStrengthValue())
  {
    EditHP(GetStrengthValue() - Damage);

    if(HP <= 0)
    {
      room* Room = GetRoom();
      Break();

      if(Room)
        Room->DestroyTerrain(Villain);
    }
  }
}
void CNPC::DoSwampMohrAI() {
   //if swamp ai is on !=0
   //and vnum is that of a swamp mohrai
   if (SWAMP_MOHR_STATUS != 0
	   && this->GetVnum() >= 14028
	   && this->GetVnum() <= 14031) {
	if (GetVnum() == 14028 && GetRoom()->GetVnum() != 14003) {
	   SWAMP_MOHR_STATUS = 0;
	}
	if (SWAMP_MOHR_STATUS == 1 && this->GetVnum() >= 14028 && this->GetVnum() <= 14031) {
	   this->AddCommand(MOHR_TO_ORC);
	} else if (SWAMP_MOHR_STATUS == 2 && this->GetVnum() >= 14028 && this->GetVnum() <= 14031) {
	   this->TogPreference(SENTINEL);
	} else if (SWAMP_MOHR_STATUS == 3 && this->GetVnum() >= 14028 && this->GetVnum() <= 14031) {
	   this->AddCommand(MOHR_TO_GNOLL);
	}
   }
}
void GetRoom()
{
	cout << "\n\nRoom Types: \n";
	cout << "(1) Private\n(2) Semi-Private\n(3) Ward\n"
	 << "Enter Your Room Type(1,2,3): ";
	cin >> patient_room;
	if (patient_room == "1")
		GetPhone();
	else if (patient_room == "2")
		GetPhone();
	else if (patient_room == "3")
		GetPhone();
	else
  	{
		GiveError();
		GetRoom();
	}
}
Exemple #23
0
NeighbourRooms_t GeneratorData::GetNeighbourRooms( int32_t roomIndex )
{
    NeighbourRooms_t r;
    auto& roomDesc = mGRoomDescs[roomIndex];
    for (auto& n : GetRoom( roomIndex )->GetNeighbourCells())
    {
        glm::vec2 pos = GetRoomCoord(roomIndex) + n;
        if (IsInBounds( pos ))
        {
            int32_t roomIndex = GetGCell( pos ).mGRoomDescIndex;
            if (std::find( r.begin(), r.end(), roomIndex ) == r.end())
            {
                r.push_back( roomIndex );
            }
        }
    }
    return r;
}
Exemple #24
0
void olterrain::BeKicked(character* Kicker, int Damage, int)
{
  if(CanBeDestroyed() && Damage > GetMainMaterial()->GetStrengthValue() >> 1)
  {
    EditHP((GetMainMaterial()->GetStrengthValue() >> 1) - Damage);

    if(HP <= 0)
    {
      room* Room = GetRoom();

      if(CanBeSeenByPlayer())
        ADD_MESSAGE("%s is shattered.", CHAR_NAME(DEFINITE));

      Break();

      if(Room)
        Room->DestroyTerrain(Kicker);
    }
  }
  else if(Kicker->IsPlayer())
Exemple #25
0
void BuyChipLayer::slider_slider_chip(Ref* sender, Slider::EventType event)
{
    
    auto user = static_pointer_cast<user_texas>(GetRoom()->get_user(GDM->get_user_id()));
    //    int min = PDM->get_room()->get_buyin_min() - user->get_chip_amount();
    //    int max = PDM->get_room()->get_buyin_max() - user->get_chip_amount();
    //    int amount = max - min;
    //    int buy_count = min + amount * slider_chip_->getPercent() / 100.0f;
    //    text_buy_number_->setString(tools::to_string(buy_count));
    
    int buyin_min = GetRoom()->get_buyin_min();
    int buyin_max = GetRoom()->get_buyin_max();
    

    if (need_credit_)
    {
        uint32_t credit = permission_.credit();
        if (credit < buyin_max)
            buyin_max = credit;
    }
    
    int min_chip = buyin_min - user->get_properties()->chips();
    int max_chip = buyin_max - user->get_properties()->chips();
    
    
    if (min_chip < 0) {
        min_chip = 0;
    }
    
    int count = (max_chip - min_chip) * slider_chip_->getPercent() / 100.0f + min_chip;
    
    if(count % GetRoom()->get_buy_min_unit() != 0) {
        count = count / GetRoom()->get_buy_min_unit() * GetRoom()->get_buy_min_unit() + GetRoom()->get_buy_min_unit();
    }
    
    if(count <= min_chip) {
        count = min_chip;
    }
    if(count >= max_chip) {
        count = max_chip;
    }
    amount_ = count;
    text_buy_number_->setString(tools::to_string(count));
    //cocos2d::log("BuyChipLayer:slider_chip min:%d,max:%d,count:%d", min_chip, max_chip, count);
}
Exemple #26
0
void BuyChipLayer::handle_get_permission(cmd_data_pointer data)
{
    if (GetRoom()->get_group_id() == 0)
    {
        need_credit_ = false;
    }else
    {
        std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
        if (!check_request(rec)) return;
        auto processor = PM->GetUserPermission_down(rec);
        need_credit_ = true;
        if (processor.has_permission())
        {
            permission_.CopyFrom(processor.permission());
        }else{
            need_credit_ = false;
        }
    }

    auto user = static_pointer_cast<user_texas>(GetRoom()->get_user( GDM->get_user_id()));
    if(user) {
        int buyin_min = GetRoom()->get_buyin_min();
        int buyin_max = GetRoom()->get_buyin_max();
        
        ;//permission_.needcredit();
        if (need_credit_)
        {
            uint32_t credit = permission_.credit();
            
            if (credit < buyin_max)
            {
                buyin_max = credit;
            }
        }
        
        int min_chip = buyin_min - user->get_properties()->chips();
        int max_chip = buyin_max - user->get_properties()->chips();
        
        if (need_credit_ && permission_.credit() < min_chip)
        {
            TipView::showAlertView(tools::local_string("no_credit","信用值不足"));
            this->removeFromParent();
            return;
        }
        
        if (max_chip <= 0)
        {
            TipView::showAlertView(tools::local_string("max_chip", "您的计分牌已经达到极限,不能添加"));
            this->removeFromParent();
            return;
        }
        
        min_chip = std::max(0, min_chip);
        
        text_min_number_->setString(tools::to_string(min_chip));
        text_max_number_->setString(tools::to_string(max_chip));
        text_buy_number_->setString(tools::to_string(min_chip));
    }
    slider_slider_chip(slider_chip_, Slider::EventType::ON_PERCENTAGE_CHANGED);
    this->setVisible(true);
}
BOOL CLimitDungeonManager::IsNoRoom(MAPTYPE mapType, DWORD channelIndex)
{
	const Room& room = GetRoom(mapType, channelIndex);

	return 0 == room.mCloseTime;
}
Exemple #28
0
void MakeConnect(int x, int y, int type)
{
  int nx, ny;
  int d1, d2;
  int room_1, room_2;
  struct RoomConnection *rconnect;
	
  switch (type) {
  case 0:
    nx = x;
    ny = y - 1;
    d1 = 14;
    d2 = 13;
    break;
  case 1:
    nx = x;
    ny = y + 1;
    d1 = 13;
    d2 = 14;
    break;
  case 2:
    nx = x - 1;
    ny = y;
    d1 = 16;
    d2 = 15;
    break;
  case 3:
    nx = x + 1;
    ny = y;
    d1 = 15;
    d2 = 16;
    break;
  default:
    nx = 0;
    ny = 0;
    d1 = 0;
    d2 = 0;
    break;
  }
	
  room_1 = GetRoom(x, y);
  room_2 = GetRoom(nx, ny);
  if ((room_1 % (NUM_ROOMS / 3)) == ((NUM_ROOMS / 3) - 1)) {
    d1 = d1 - 13 + 21;
    d2 = d2 - 13 + 38;
  } else {
    if ((room_2 % (NUM_ROOMS / 3)) == ((NUM_ROOMS / 3) - 1)) {
      d1 = d1 - 13 + 38;
      d2 = d2 - 13 + 21;
    }
  }
  Put(x, y, d1, GetRoom(x, y));
  Put(nx, ny, d2, GetRoom(nx, ny));

  map.rooms[room_1].connections++;
  rconnect = map.rooms[room_1].con;
  map.rooms[room_1].con = malloc(sizeof(struct RoomConnection));
  map.rooms[room_1].con->n = rconnect;
  map.rooms[room_1].con->x = x;
  map.rooms[room_1].con->y = y;
  map.rooms[room_1].con->x2 = nx;
  map.rooms[room_1].con->y2 = ny;
  map.rooms[room_1].con->c = room_2;
	
  map.rooms[room_2].connections++;
  rconnect = map.rooms[room_2].con;
  map.rooms[room_2].con = malloc(sizeof(struct RoomConnection));
  map.rooms[room_2].con->n = rconnect;
  map.rooms[room_2].con->x = nx;
  map.rooms[room_2].con->y = ny;
  map.rooms[room_2].con->x2 = x;
  map.rooms[room_2].con->y2 = y;
  map.rooms[room_2].con->c = room_1;

}
Exemple #29
0
void MakeSpecialRooms()
{
  int i, j;
  int c_tier;
  int c_room;
  int biggest_room_sz = 0;
  int biggest_room_n = -1;
  int rtyp[8] = {0};
  int ctyp;
  int x, y;
	
  /* Special rooms are:
   *
   * - Boss rooms, every 1/(number of bosses)th of the total rooms.
   *
   * - PSI key rooms, every 1/2(number of bosses)th of the total
   *   rooms that isn't a boss room.
   *
   * (By default, eg with 3000 rooms and 3 bosses, this will generate a 
   *  boss room in rooms 1000, 2000 and 3000 and a PSI key room in rooms 
   *  500, 1500 and 2500. TODO: test for other numbers)
   *
   * - Artifact rooms (biggest non-boss room of a given distance tier)
   *		Tiers: 5-9  10-14  15-19  20-24  25-29  30-34  35-39  40-44
   */
	
  /* boss rooms */
  for (i = 0; i < NUM_REGULAR_BOSSES; i++) {
    c_room = (((i + 1) * (NUM_ROOMS / NUM_REGULAR_BOSSES)) - 1);
    map.rooms[c_room].room_type = ROOM_BOSS;
    map.rooms[c_room].room_param = i;
  }
  /* power object rooms */
  for (i = 0; i < NUM_REGULAR_BOSSES; i++) {
    c_room = (((i + 1) * (NUM_ROOMS / NUM_REGULAR_BOSSES)) - 
              (NUM_ROOMS / NUM_REGULAR_BOSSES / 2) - 1);
    map.rooms[c_room].room_type = ROOM_PSI_KEY;
    map.rooms[c_room].room_param = i;
  }
	
  /* artifact rooms */
  for (c_tier = 0; c_tier < 8; c_tier++) {
    biggest_room_sz = 0;
    for (c_room = 0; c_room < NUM_ROOMS; c_room++) {
      if (map.rooms[c_room].room_type == 0) {
        if (map.rooms[c_room].s_dist >= (c_tier*5+5)) {
          if (map.rooms[c_room].s_dist <= (c_tier*5+9)) {
            if (RoomSize(c_room) > biggest_room_sz) {
              biggest_room_sz = RoomSize(c_room);
              biggest_room_n = c_room;
            }
          }
        }
      }
    }
    map.rooms[biggest_room_n].room_type = ROOM_ART_CHALLENGE;
		
    /* pick a # */
    for (;;) {
      ctyp = rand()%8;
      if (rtyp[ctyp] == 0) {
        rtyp[ctyp] = 1;
        break;
      }
    }
		
    map.rooms[biggest_room_n].room_param = ctyp;
		
    /*printf("Artifact room for tier %d is room %d (size %d), with artifact %d\n", c_tier, biggest_room_n, biggest_room_sz, ctyp); */
  }
	
  /* place of power
   * The room with the highest s_dist that is not of any other type */
	
  for (i = 0; i < NUM_ROOMS; i++) {
    if (map.rooms[i].s_dist > map.rooms[place_of_power].s_dist) {
      if (map.rooms[i].room_type == 0) {
        place_of_power = i;
      }
    }
  }

  map.rooms[place_of_power].room_type = ROOM_PLACE_OF_POWER;
	
  /* Now place some checkpoints in the remaining rooms
   * Normally, we would have a checkpoint for every 30
   * rooms, BUT since we aren't using that method any
   * more, we will simply use an equivalent--namely, to
   * divide the map into an 8x8 grid and place one
   * checkpoint per square.
   */

  for (y = 0; y < 8; y++) {
    for (x = 0; x < 8; x++) {
      j = -1;
      for (i = 0; i < 20; i++) {
        j = GetRoom(rand() % 64 + x * 64, rand() % 64 + y * 64);
                
        if (j >= 0) {
          if (map.rooms[j].room_type == 0) {
            Put(map.rooms[j].x + map.rooms[j].w / 2, map.rooms[j].y + map.rooms[j].h / 2, 25, j);
            map.rooms[j].checkpoint = 1;
            break;
          }
        }
      }
    }
  }
	
  next_check--;
}
Exemple #30
0
void NewRoom(int place_x, int place_y, int room_w, int room_h, int creator)
{
  int connect_points = 0;
  int cplist_x[100], cplist_y[100], cplist_r[100], cplist_t[100];
	
  int sr_cps = 0;
  int sr_cp[100];
	
  int sr_nps = 0;
  int sr_np[100];
	
  int i;
	
  /* Draw this room */
  map.rooms[total_rooms].checkpoint = 0;
  DrawRoom(place_x, place_y, room_w, room_h, total_rooms);
	
  map.rooms[total_rooms].x = place_x;
  map.rooms[total_rooms].y = place_y;
	
  map.rooms[total_rooms].w = room_w;
  map.rooms[total_rooms].h = room_h;
	
  map.rooms[total_rooms].room_type = 0;
  map.rooms[total_rooms].room_param = 0;
	
  map.rooms[total_rooms].creator = creator;
	
  map.rooms[total_rooms].connections = 0;
  map.rooms[total_rooms].con = NULL;
  map.rooms[total_rooms].enemies = 0;
	
  map.rooms[total_rooms].visited = 0;

  map.rooms[total_rooms].s_dist = -1;
	
  if (total_rooms == 0) {
    map.rooms[total_rooms].checkpoint = 1;
  }
	
	
	
  total_rooms++;

  if (creator == -1) return;
	
  /* Find connection points */
	
  for (i = 0; i < room_w - 2; i++) {
    if (SuitableConnection(Get(place_x + 1 + i, place_y - 1))) {
      cplist_x[connect_points] = place_x + 1 + i;
      cplist_y[connect_points] = place_y;
      cplist_r[connect_points] = GetRoom(place_x + 1 + i, place_y - 1);
      cplist_t[connect_points] = 0;
      connect_points++;
    }
		
    if (SuitableConnection(Get(place_x + 1 + i, place_y + room_h))) {
      cplist_x[connect_points] = place_x + 1 + i;
      cplist_y[connect_points] = place_y + room_h - 1;
      cplist_r[connect_points] = GetRoom(place_x + 1 + i, place_y + room_h);
      cplist_t[connect_points] = 1;
      connect_points++;
    }
  }
  for (i = 0; i < room_h - 2; i++) {
    if (SuitableConnection(Get(place_x - 1, place_y + 1 + i))) {
      cplist_x[connect_points] = place_x;
      cplist_y[connect_points] = place_y + 1 + i;
      cplist_r[connect_points] = GetRoom(place_x - 1, place_y + 1 + i);
      cplist_t[connect_points] = 2;
      connect_points++;
    }
		
    if (SuitableConnection(Get(place_x + room_w, place_y + 1 + i))) {
      cplist_x[connect_points] = place_x + room_w - 1;
      cplist_y[connect_points] = place_y + 1 + i;
      cplist_r[connect_points] = GetRoom(place_x + room_w, place_y + 1 + i);
      cplist_t[connect_points] = 3;
      connect_points++;
    }
  }
	
  for (i = 0; i < connect_points; i++) {
    if (cplist_r[i] == creator) {
      sr_cp[sr_cps++] = i;
    } else {
      sr_np[sr_nps++] = i;
    }
  }
	
  /* printf("cps: %d      room: %d\n", sr_cps, total_rooms); */

  assert(sr_cps > 0);
	
  i = rndval(0, sr_cps-1);
  MakeConnect(cplist_x[sr_cp[i]], cplist_y[sr_cp[i]], cplist_t[sr_cp[i]]);
	
  /* one other connection (if we can) */
  if (sr_nps > 0) {
    i = rndval(0, sr_nps-1);
    MakeConnect(cplist_x[sr_np[i]], cplist_y[sr_np[i]], cplist_t[sr_np[i]]);
  }

}