:>
This commit is contained in:
parent
1762043757
commit
c47b36726b
@ -284,6 +284,9 @@ bool Player::AmIDead()
|
|||||||
|
|
||||||
void Player::InflictDamage(float hitPoints) {
|
void Player::InflictDamage(float hitPoints) {
|
||||||
m_hp -= hitPoints;
|
m_hp -= hitPoints;
|
||||||
|
|
||||||
|
if (m_hp < 0)
|
||||||
|
m_hp == 0;
|
||||||
//if (AmIDead())
|
//if (AmIDead())
|
||||||
//{ // Quand le joueur est mort.
|
//{ // Quand le joueur est mort.
|
||||||
//}
|
//}
|
||||||
|
@ -218,7 +218,7 @@ void Server::Run() {
|
|||||||
int timer = m_game.countdown, sync_acc = 0, deadplayers = 0;
|
int timer = m_game.countdown, sync_acc = 0, deadplayers = 0;
|
||||||
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
|
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
|
||||||
Timestamp last = 0;
|
Timestamp last = 0;
|
||||||
std::vector<Chat> chatlog;
|
std::vector<Chat*> chatlog;
|
||||||
std::vector<ChunkMod*> chunkdiffs;
|
std::vector<ChunkMod*> chunkdiffs;
|
||||||
std::vector<Bullet*> bullets, outbox_bullets;
|
std::vector<Bullet*> bullets, outbox_bullets;
|
||||||
std::vector<BulletAdd*> netbull;
|
std::vector<BulletAdd*> netbull;
|
||||||
@ -237,6 +237,7 @@ void Server::Run() {
|
|||||||
std::string str = "Timer: ";
|
std::string str = "Timer: ";
|
||||||
Log(str.append(std::to_string(timer).append(" SyncAcc: ").append(std::to_string(sync_acc))), false, false);
|
Log(str.append(std::to_string(timer).append(" SyncAcc: ").append(std::to_string(sync_acc))), false, false);
|
||||||
}
|
}
|
||||||
|
last = tstamp;
|
||||||
|
|
||||||
for (auto& [key, conn] : m_conns) {
|
for (auto& [key, conn] : m_conns) {
|
||||||
|
|
||||||
@ -258,8 +259,8 @@ void Server::Run() {
|
|||||||
if (Deserialize(&sync, pck, &bsize)) {}
|
if (Deserialize(&sync, pck, &bsize)) {}
|
||||||
break;
|
break;
|
||||||
case CHAT:
|
case CHAT:
|
||||||
if (Deserialize(&chat, pck, &bsize))
|
//if (Deserialize(&chat, pck, &bsize))
|
||||||
chatlog.push_back(chat);
|
//chatlog.push_back(chat);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@ -272,17 +273,17 @@ void Server::Run() {
|
|||||||
Timestamp tstamp = conn->Run(m_world);
|
Timestamp tstamp = conn->Run(m_world);
|
||||||
|
|
||||||
if (conn->player->AmIDead() && tstamp) {
|
if (conn->player->AmIDead() && tstamp) {
|
||||||
Chat chat;
|
Chat* chat = new Chat();
|
||||||
chat.dest_id = chat.dest_team_id = chat.src_id = 0;
|
chat->dest_id = chat->dest_team_id = chat->src_id = 0;
|
||||||
|
|
||||||
std::string killer = m_conns.at(key)->player->GetUsername();
|
std::string killer = m_conns.at(key)->player->GetUsername();
|
||||||
|
|
||||||
std::string mess = getDeathMessage(conn->player->GetUsername(), killer);
|
std::string mess = getDeathMessage(conn->player->GetUsername(), killer);
|
||||||
|
|
||||||
strcpy(chat.mess, 140, mess.c_str());
|
strcpy(chat->mess, 140, mess.c_str());
|
||||||
Log("You is dead", false, false);
|
Log(mess, false, false);
|
||||||
|
|
||||||
m_chatlog[tstamp] = chat;
|
chatlog.emplace_back(chat);
|
||||||
++deadplayers;
|
++deadplayers;
|
||||||
conn->m_nsync == false;
|
conn->m_nsync == false;
|
||||||
}
|
}
|
||||||
@ -329,9 +330,10 @@ void Server::Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto& chat : chatlog) {
|
for (auto& chat : chatlog) {
|
||||||
Log(chat.mess, false, false);
|
Log(chat->mess, false, false);
|
||||||
for (auto& [key, conn] : m_conns)
|
for (auto& [key, conn] : m_conns)
|
||||||
sendPackTo<Chat>(m_sock_udp, &chat, &m_buf, conn->getAddr());
|
sendPackTo<Chat>(m_sock_udp, chat, &m_buf, conn->getAddr());
|
||||||
|
delete chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& chmo : chunkdiffs) {
|
for (auto& chmo : chunkdiffs) {
|
||||||
|
@ -1422,6 +1422,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
Sync comp = m_syncs[sync.timestamp];
|
Sync comp = m_syncs[sync.timestamp];
|
||||||
m_player.InflictDamage(sync.hp - comp.hp);
|
m_player.InflictDamage(sync.hp - comp.hp);
|
||||||
|
|
||||||
|
|
||||||
Vector3f diff = sync.position - comp.position;
|
Vector3f diff = sync.position - comp.position;
|
||||||
|
|
||||||
if (diff.y < 1.)
|
if (diff.y < 1.)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user