Bonne idée.

This commit is contained in:
MarcEricMartel 2023-12-06 13:23:33 -05:00
parent 3b0f9650d4
commit 1762043757
4 changed files with 32 additions and 20 deletions

View File

@ -40,6 +40,7 @@ public:
int getScore() const;
void addPoint();
uint64_t Killer = 0;
std::string m_username;
private:
uint64_t getId() const;
@ -49,7 +50,6 @@ protected:
Vector3f m_velocity;
Vector3f m_direction;
std::string m_username;
uint64_t id = 0;
int m_score = 0;

View File

@ -118,6 +118,11 @@ Timestamp Connection::Run(World* world) {
if (m_input_manifest.size() < 2)
return tstamp;
if (player->AmIDead()) {
m_input_manifest.clear();
return tstamp;
}
while (m_last_in < m_input_vector.size() - 1) {
in = m_input_vector.at(m_last_in + 1);
last = m_input_vector.at(m_last_in);

View File

@ -203,6 +203,7 @@ void Server::Run() {
int x = 0,// (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1)),// -(CHUNK_SIZE_X * WORLD_SIZE_X / 2),
y = 0;// (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1));// -(CHUNK_SIZE_Y * WORLD_SIZE_Y / 2);
conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f));
conn->player->m_username = conn->GetName();
m_players[key] = conn->player;
Sync sync;
sync.position = conn->player->GetPositionAbs();
@ -230,6 +231,7 @@ void Server::Run() {
last = tstamp;
sync_acc += tstamp - last;
if (sync_acc >= 1000) {
while (sync_acc >= 1000)
sync_acc -= 1000;
--timer;
std::string str = "Timer: ";
@ -269,7 +271,7 @@ void Server::Run() {
if (conn->m_nsync) {
Timestamp tstamp = conn->Run(m_world);
if (conn->player->AmIDead()) {
if (conn->player->AmIDead() && tstamp) {
Chat chat;
chat.dest_id = chat.dest_team_id = chat.src_id = 0;
@ -277,10 +279,10 @@ void Server::Run() {
std::string mess = getDeathMessage(conn->player->GetUsername(), killer);
strcpy(chat.mess, mess.c_str());
strcpy(chat.mess, 140, mess.c_str());
Log("You is dead", false, false);
m_chatlog[tstamp] = chat;
++deadplayers;
conn->m_nsync == false;
}
@ -434,14 +436,20 @@ std::string Server::getDeathMessage(std::string username, std::string killer) co
std::string temp = DEATHMESSAGES.at(rand() % DEATHMESSAGES.size());
size_t ind = temp.find('@');
size_t indk = temp.find('$');
bool bypass = false;
if (ind < indk) {
if (indk == std::string::npos)
bypass = true;
if (ind < indk || bypass) {
mess.append(temp.substr(0, ind));
mess.append(username);
if (!bypass) {
mess.append(temp.substr(ind + 1, indk));
mess.append(killer);
mess.append(temp.substr(indk + 1));
}
}
else {
mess.append(temp.substr(0, indk));
mess.append(killer);

View File

@ -431,6 +431,8 @@ void Engine::DisplayHud(int timer) {
// HP Bar
float playerHp = m_player.GetHP();
if (playerHp < 0.)
playerHp == 0;
float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f;
float hpBarWidthProportion = 0.25f;
@ -720,11 +722,11 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
ss.str("");
fPosY -= charSize;
ss << " Block : ";
if (bloc == BTYPE_LAST)
ss << "Weapon";
else
ss << (int)bloc;
//ss << " Block : ";
//if (bloc == BTYPE_LAST)
// ss << "Weapon";
//else
// ss << (int)bloc;
PrintText(fPosX, fPosYJump, ss.str());
}
@ -1341,10 +1343,6 @@ void Engine::Render(float elapsedTime) {
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f);
fell = true;
}
else if (m_player.GetPosition().y < -20.f) {
m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); // Respawn si le bonho- joueur tombe en bas du monde.
fell = false;
}
if (m_networkgame) { // Pour se gerer le paquet.
static bool has_synced = false;
@ -1381,6 +1379,7 @@ void Engine::Render(float elapsedTime) {
}
if (cmod_acc >= 1000) {
while (cmod_acc >= 1000)
cmod_acc -= 1000;
if (!m_chunkmod_manifest.empty()) {
ChunkMod* cmod = m_chunkmod_manifest.front();