This commit is contained in:
aozhiwei 2023-08-17 14:18:02 +08:00
parent a4f826ec22
commit 0f3c154067
2 changed files with 25 additions and 0 deletions

View File

@ -99,6 +99,7 @@ class Human : public Creature
a8::XTimerWp revive_timer;
long long dead_frameno = 0;
long long real_dead_frameno = 0;
int sort_id = 0;
Weapon default_weapon;

View File

@ -564,12 +564,15 @@ void Incubator::Rearrangement()
std::vector<int> teams4;
{
std::map<int, int> team_num_hash;
int i = 0;
for (auto hum : hold_humans_) {
if (team_num_hash.find(hum->team_id) != team_num_hash.end()) {
++team_num_hash[hum->team_id];
} else {
team_num_hash[hum->team_id];
}
hum->sort_id = i;
++i;
}
for (auto& pair : team_num_hash) {
if (pair.second > 1) {
@ -597,4 +600,25 @@ void Incubator::Rearrangement()
} else if (!teams2.empty()) {
team_id = teams2.at(rand() % teams2.size());
}
if (team_id) {
for (auto hum : hold_humans_) {
if (hum->team_id == team_id) {
hum->sort_id = 999999;
}
}
std::sort(hold_humans_.begin(), hold_humans_.end(),
[] (Human* a, Human* b) -> bool
{
return a->sort_id < b->sort_id;
});
}
#ifdef DEBUG
{
std::string data = "Rearrangement ";
for (auto hum : hold_humans_) {
data += a8::XValue(hum->team_id) + ",";
}
a8::XPrintf("%s\n", {data});
}
#endif
}