Remove the dead code.

This commit is contained in:
MarcEricMartel 2023-12-16 16:13:20 -05:00
parent 4df53a5f9b
commit 678776d6e6
4 changed files with 5 additions and 112 deletions

View File

@ -17,6 +17,9 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere
m_currentpos += m_velocity * elapsedtime; m_currentpos += m_velocity * elapsedtime;
for (auto& [key, player] : mapPlayer) { for (auto& [key, player] : mapPlayer) {
if (key == m_shooter_id)
continue;
bool hit = false; bool hit = false;
if ((m_currentpos - player->GetPosition()).Length() < 1.5f) { if ((m_currentpos - player->GetPosition()).Length() < 1.5f) {
hit = true; hit = true;

View File

@ -205,11 +205,7 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const { void Player::ApplyTransformation(Transformation& transformation, bool rel, bool rot) const {
transformation.ApplyRotation(-m_rotX, 1, 0, 0); transformation.ApplyRotation(-m_rotX, 1, 0, 0);
transformation.ApplyRotation(-m_rotY, 0, 1, 0); transformation.ApplyRotation(-m_rotY, 0, 1, 0);
if (rel) transformation.ApplyTranslation(-GetPOV()); if (rel) transformation.ApplyTranslation(-GetPOV());
} }
void Player::GetBooster(Booster boosttype) void Player::GetBooster(Booster boosttype)
@ -302,9 +298,6 @@ void Player::InflictDamage(float hitPoints) {
if (m_hp < 0) if (m_hp < 0)
m_hp == 0; m_hp == 0;
//if (AmIDead())
//{ // Quand le joueur est mort.
//}
} }
int Player::getScore() const { return m_score; } int Player::getScore() const { return m_score; }

View File

@ -49,8 +49,6 @@ void World::RemoveChunk(int nbReduit)
if (x > WORLD_SIZE_X - nbReduit) if (x > WORLD_SIZE_X - nbReduit)
chk = m_chunks.Remove(x, y); chk = m_chunks.Remove(x, y);
// TODO: MakeDirty() les voisins pour qu'ils se redessinent.
if (!chk) if (!chk)
continue; continue;
@ -167,7 +165,6 @@ void World::GetScope(unsigned int& x, unsigned int& y) {
void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) { void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
UpdateWorld(player_pos, blockinfo); UpdateWorld(player_pos, blockinfo);
//TransposeWorld(player_pos, bullets);
} }
netprot::ChunkMod* World::ChangeBlockAtCursor(BlockType blockType, const Vector3f& player_pos, const Vector3f& player_dir, bool& block, bool net) { netprot::ChunkMod* World::ChangeBlockAtCursor(BlockType blockType, const Vector3f& player_pos, const Vector3f& player_dir, bool& block, bool net) {
@ -258,7 +255,6 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]
int side = 0; int side = 0;
int threads = 0; int threads = 0;
std::future<Chunk*> genThList[THREADS_GENERATE_CHUNKS]; std::future<Chunk*> genThList[THREADS_GENERATE_CHUNKS];
//std::future<void> delThList[THREADS_DELETE_CHUNKS];
if (frameGenerate > 0) --frameGenerate; if (frameGenerate > 0) --frameGenerate;
if (frameUpdate > 0) --frameUpdate; if (frameUpdate > 0) --frameUpdate;
@ -349,101 +345,6 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]
side = 0; side = 0;
threads = 0; threads = 0;
//if (!frameUpdate)
// while (side * CHUNK_SIZE_X <= VIEW_DISTANCE * 2) {
// int tx = -side, ty = -side;
// for (; tx <= side; ++tx) {
// if (frameUpdate)
// break;
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
// if (ChunkAt(chx, 1, chy) &&
// ChunkAt(chx, 1, chy)->IsDirty()) {
// updateThList[threads++] =
// std::async(std::launch::async,
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
// }
// }
// for (; ty <= side; ++ty) {
// if (frameUpdate)
// break;
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
// if (ChunkAt(chx, 1, chy) &&
// ChunkAt(chx, 1, chy)->IsDirty()) {
// updateThList[threads++] =
// std::async(std::launch::async,
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
// }
// }
// for (; tx >= -side; --tx) {
// if (frameUpdate)
// break;
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
// if (ChunkAt(chx, 1, chy) &&
// ChunkAt(chx, 1, chy)->IsDirty()) {
// updateThList[threads++] =
// std::async(std::launch::async,
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
// }
// }
// for (; ty >= -side; --ty) {
// if (frameUpdate)
// break;
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
// if (ChunkAt(chx, 1, chy) &&
// ChunkAt(chx, 1, chy)->IsDirty()) {
// updateThList[threads++] =
// std::async(std::launch::async,
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
// }
// }
// if (frameUpdate)
// break;
// ++side;
// }
//if (threads > 0) {
// for (int i = 0; i < threads; ++i) {
// updateThList[i].wait();
// Chunk* chunk = updateThList[i].get();
// chunk->FlushMeshToVBO();
// }
//}
threads = 0;
//int del = THREADS_DELETE_CHUNKS;
//while (!m_tbDeleted.empty() && del--) { // Moins rapide que le bout en dessous, mais -beaucoup- plus stable.
// m_tbDeleted.back()->FlushVBO();
// m_tbDeleted.back()->~Chunk();
// m_tbDeleted.pop_back();
//}
/*while (!m_tbDeleted.empty() && !frameDelete) {
if (m_tbDeleted.back()) {
m_tbDeleted.back()->FlushVBO();
delThList[threads] =
std::async(std::launch::async,
[](Chunk* chunk) { delete chunk; }, m_tbDeleted.back());
m_tbDeleted.pop_back();
if (++threads > THREADS_DELETE_CHUNKS) frameDelete = FRAMES_DELETE_CHUNKS;
}
else m_tbDeleted.pop_back();
}*/
/*for (int x = 0; x < threads; ++x) {
delThList[x].wait();
delThList[x].get();
}*/
} }
int World::GettbDeleted() const { return m_tbDeleted.size(); } int World::GettbDeleted() const { return m_tbDeleted.size(); }

View File

@ -282,11 +282,6 @@ void Server::Run() {
/* Process */ /* Process */
if (conn->m_nsync) { if (conn->m_nsync) {
/*if (conn->player->m_hit) {
std::string str = conn->player->GetUsername();
str = str.append(" has been hit: ").append(std::to_string(conn->player->GetHP()));
Log(str, false, false);
}*/
Timestamp tstamp = conn->Run(m_world); Timestamp tstamp = conn->Run(m_world);
@ -308,6 +303,7 @@ void Server::Run() {
++deadplayers; ++deadplayers;
conn->player->Eulogy = true; conn->player->Eulogy = true;
conn->m_nsync = false;
} }
else { else {
for (auto& chmo : conn->ChunkDiffs) for (auto& chmo : conn->ChunkDiffs)
@ -383,7 +379,7 @@ void Server::Run() {
for (auto bull = bullets.begin(); bull != bullets.end(); ++bull) { for (auto bull = bullets.begin(); bull != bullets.end(); ++bull) {
ChunkMod* cmod = nullptr; ChunkMod* cmod = nullptr;
Bullet* bullet = *bull; Bullet* bullet = *bull;
if (bullet->Update(m_world, (1. / 60.), 1, m_players, &cmod)) { if (bullet->Update(m_world, (1. / 60.), 50, m_players, &cmod)) {
if (cmod) if (cmod)
chunkdiffs.emplace_back(cmod); chunkdiffs.emplace_back(cmod);
bullit.push_back(bull); bullit.push_back(bull);