/**
* Join multiple players onto the same side of a Battleground
* @param name: Battleground name
* @param sd: Player who requested to join the battlegrounds
* @param list: Contains all players including the player who requested to join
*/
void bg_queue_join_multi(const char *name, map_session_data *sd, std::vector <map_session_data *> list)
{
if (!sd) {
ShowError("bg_queue_join_multi: Tried to join non-existent player\n.");
return;
}
std::shared_ptr<s_battleground_type> bg = bg_search_name(name);
if (!bg) {
ShowWarning("bq_queue_join_multi: Could not find battleground \"%s\" requested by %s (AID: %d / CID: %d)\n", name, sd->status.name, sd->status.account_id, sd->status.char_id);
return;
}
if (!bg_queue_check_joinable(bg, sd, name)){
return;
}
for (const auto &queue : bg_queues) {
if (queue->id != bg->id || queue->state == QUEUE_STATE_SETUP_DELAY || queue->state == QUEUE_STATE_ENDED)
continue;
// Make sure there's enough space on one side to join as a party/guild in this queue
if (queue->teama_members.size() + list.size() > bg->max_players && queue->teamb_members.size() + list.size() > bg->max_players) {
break;
}
bool r = rnd() % 2 != 0;
std::vector<map_session_data *> *team = r ? &queue->teamb_members : &queue->teama_members;
if (queue->state == QUEUE_STATE_ACTIVE) {
// If one team has lesser members try to balance (on an active BG)
if (r && queue->teama_members.size() < queue->teamb_members.size())
team = &queue->teama_members;
else if (!r && queue->teamb_members.size() < queue->teama_members.size())
team = &queue->teamb_members;
} else {
// If the designated team is full, put the player into the other team
if (team->size() + list.size() > bg->required_players)
team = r ? &queue->teama_members : &queue->teamb_members;
}
while (!list.empty() && team->size() < bg->max_players) {
map_session_data *sd2 = list.back();
list.pop_back();
if (!sd2 || sd2->bg_queue_id > 0)
continue;
if (!bg_queue_check_joinable(bg, sd2, name))
continue;
sd2->bg_queue_id = queue->queue_id;
team->push_back(sd2);
clif_bg_queue_apply_result(BG_APPLY_ACCEPT, name, sd2);
clif_bg_queue_apply_notify(name, sd2);
}
if (queue->state == QUEUE_STATE_ACTIVE) { // Battleground is already active
for (auto &pl_sd : *team) {
if (queue->map->mapindex == pl_sd->mapindex)
continue;
pc_set_bg_queue_timer(pl_sd);
clif_bg_queue_lobby_notify(name, pl_sd);
}
} else if (queue->state == QUEUE_STATE_SETUP && queue->teamb_members.size() >= bg->required_players && queue->teama_members.size() >= bg->required_players) // Enough players have joined
bg_queue_on_ready(name, queue);
return;
}
// Something went wrong, sends reconnect and then reapply message to client.
clif_bg_queue_apply_result(BG_APPLY_RECONNECT, name, sd);
}
/**
* Send packets to all clients in queue to notify them that the battleground is ready to be joined
* @param name: Battleground name
* @param queue: Battleground queue
* @return True on success or false otherwise
*/
bool bg_queue_on_ready(const char *name, std::shared_ptr<s_battleground_queue> queue)
{
std::shared_ptr<s_battleground_type> bg = battleground_db.find(queue->id);
if (!bg) {
ShowError("bg_queue_on_ready: Couldn't find battleground ID %d in battlegrounds database.\n", queue->id);
return false;
}
if (queue->teama_members.size() < queue->required_players || queue->teamb_members.size() < queue->required_players)
return false; // Return players to the queue and stop reapplying the timer
bool map_reserved = false;
for (auto &map : bg->maps) {
if (!map.isReserved) {
map.isReserved = true;
map_reserved = true;
queue->map = ↦
break;
}
}
if (!map_reserved) { // All the battleground maps are reserved. Set a timer to check for an open battleground every 10 seconds.
queue->tid_requeue = add_timer(gettick() + 10000, bg_on_ready_loopback, 0, (intptr_t)queue->queue_id);
return false;
}
queue->state = QUEUE_STATE_SETUP_DELAY;
queue->tid_expire = add_timer(gettick() + 20000, bg_on_ready_expire, 0, (intptr_t)queue->queue_id);
for (const auto &sd : queue->teama_members)
clif_bg_queue_lobby_notify(name, sd);
for (const auto &sd : queue->teamb_members)
clif_bg_queue_lobby_notify(name, sd);
return true;
}
Question
Angeluz
Hi,
Is it possible to remove the following window?
I want to make it so that when all people are found they don't have to confirm, but enter automatically.
I have tried to get my hands on these functions but I have not been able to get it to work, any ideas?
https://github.com/rathena/rathena/blob/master/src/map/battleground.cpp#L1213
https://github.com/rathena/rathena/blob/master/src/map/battleground.cpp#L1370
https://github.com/rathena/rathena/blob/master/src/map/clif.cpp#L18550
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.