Skip to content

Commit

Permalink
fix player model assignment not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Lentz committed Jun 6, 2024
1 parent d9cb5ce commit 380c648
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions src/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,34 +302,31 @@ std::chrono::milliseconds Server::doTick() {
sendUpdateToAllClients(Event(this->world_eid, EventType::LoadGameState, LoadGameStateEvent(partial_update)));
}

std::cout << "Assigned player " + std::to_string(index) + " to be the DM" << std::endl;
}

int player_idx = 0; // only increment when assigning a model

auto players = this->state.objects.getPlayers();
for (int i = 0; i < players.size(); i++) {
auto player = players.get(i);
if (player == nullptr) continue;

if (player_idx == 0) {
std::cout << "assigning player " << i << " to fire\n";
player->modelType = ModelType::PlayerFire;
} else if (player_idx == 1) {
std::cout << "assigning player " << i << " to lightning\n";
player->modelType = ModelType::PlayerLightning;
} else if (player_idx == 2) {
std::cout << "assigning player " << i << " to water\n";
player->modelType = ModelType::PlayerWater;
}
int player_idx = 0; // only increment when assigning a model

player_idx++;
auto players = this->state.objects.getPlayers();
for (int i = 0; i < players.size(); i++) {
auto player = players.get(i);
if (player == nullptr) continue;

if (player_idx > 2) {
player_idx = 0;
}
if (player_idx == 0) {
player->modelType = ModelType::PlayerFire;
}
else if (player_idx == 1) {
player->modelType = ModelType::PlayerLightning;
}
else if (player_idx == 2) {
player->modelType = ModelType::PlayerWater;
}

std::cout << "Assigned player " + std::to_string(index) + " to be the DM" << std::endl;
std::cout << "Starting game!" << std::endl;
player_idx++;

if (player_idx > 2) {
player_idx = 0;
}
}

if (this->config.server.skip_intro) {
Expand Down

0 comments on commit 380c648

Please sign in to comment.