Timer iznogoud.
This commit is contained in:
@@ -137,9 +137,19 @@ Timestamp Connection::Run(World* world) {
|
||||
in.keys.right,
|
||||
in.keys.jump, false, el), world, el);
|
||||
|
||||
if (player->GetPosition().y < -10.) {
|
||||
player->InflictDamage(9000);
|
||||
player->Killer = GetHash(true);
|
||||
}
|
||||
|
||||
out.states.jumping = in.keys.jump;
|
||||
out.states.running = player->GetVelocity().Length() > .3f;
|
||||
out.states.dead = player->AmIDead();
|
||||
|
||||
if (player->AmIDead()) {
|
||||
in.keys.shoot = false;
|
||||
in.keys.block = false;
|
||||
out.states.dead = true;
|
||||
}
|
||||
|
||||
if (in.keys.block) {
|
||||
bool block = false;
|
||||
@@ -152,7 +162,7 @@ Timestamp Connection::Run(World* world) {
|
||||
}
|
||||
|
||||
if (in.keys.shoot && m_shoot_acc <= 0.) {
|
||||
Bullets.push_back(Bullet(player->GetPOV() + player->GetDirection(), player->GetDirection()));
|
||||
Bullets.emplace_back(new Bullet(player->GetPOV() + player->GetDirection(), player->GetDirection(), GetHash(true)));
|
||||
out.states.shooting = true;
|
||||
}
|
||||
|
||||
|
@@ -42,8 +42,8 @@ public:
|
||||
|
||||
bool m_nsync = true;
|
||||
|
||||
std::vector<Bullet> Bullets;
|
||||
std::vector<ChunkMod> ChunkDiffs;
|
||||
std::vector<Bullet*> Bullets;
|
||||
std::vector<ChunkMod*> ChunkDiffs;
|
||||
|
||||
Timestamp GetTStamp() const;
|
||||
|
||||
|
@@ -11,13 +11,20 @@
|
||||
#define ID_LIST_SIZE 127
|
||||
#define SRV_MANUAL_SETUP true
|
||||
|
||||
// @ = Dead guy, $ = Killer.
|
||||
const std::vector<std::string> DEATHMESSAGES = { "@ has gone to meet their maker.",
|
||||
"@ has bit the dust, if you know what I mean.",
|
||||
"@ has ceased to be.",
|
||||
"@ is no more.",
|
||||
"@ is like, super dead.",
|
||||
"RIP, @.",
|
||||
"Requiescat In Pace, @.",
|
||||
"So long, @, and thanks for all the lols!",
|
||||
"@ has a bad case of being dead." };
|
||||
"@ has a bad case of being dead.",
|
||||
"@ has finally seen the light!",
|
||||
"Thought @ was hot; guess what? He's not. He is dead, dead, dead.",
|
||||
"@ did not want to live forever.",
|
||||
"$ made @ die for their country.",
|
||||
"$ has become death, destroyer of @.",
|
||||
"$ did not make @ feel lucky." };
|
||||
|
||||
#endif
|
||||
|
@@ -200,8 +200,8 @@ void Server::Run() {
|
||||
m_world->BuildWorld();
|
||||
|
||||
for (auto& [key, conn] : m_conns) { // Creation des instances de joueurs et premier sync.
|
||||
int x = (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1)) - (CHUNK_SIZE_X * WORLD_SIZE_X / 2),
|
||||
y = (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1)) - (CHUNK_SIZE_Y * WORLD_SIZE_Y / 2);
|
||||
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));
|
||||
m_players[key] = conn->player;
|
||||
Sync sync;
|
||||
@@ -270,8 +270,10 @@ void Server::Run() {
|
||||
if (conn->player->AmIDead()) {
|
||||
Chat chat;
|
||||
chat.dest_id = chat.dest_team_id = chat.src_id = 0;
|
||||
|
||||
std::string killer = m_conns.at(key)->player->GetUsername();
|
||||
|
||||
strcpy(chat.mess, getDeathMessage(conn->player->GetUsername()).c_str());
|
||||
strcpy(chat.mess, getDeathMessage(conn->player->GetUsername(), killer).c_str());
|
||||
|
||||
m_chatlog[tstamp] = chat;
|
||||
|
||||
@@ -285,9 +287,10 @@ void Server::Run() {
|
||||
|
||||
for (auto& bull : conn->Bullets) {
|
||||
bullets.emplace_back(bull);
|
||||
Log("POW!", false, false);
|
||||
BulletAdd* nbul = new BulletAdd();
|
||||
nbul->pos = conn->player->GetPosition();
|
||||
nbul->dir = conn->player->GetDirection();
|
||||
nbul->pos = bull->getPos();
|
||||
nbul->dir = bull->getVel();
|
||||
nbul->id = key;
|
||||
nbul->tstamp = tstamp;
|
||||
|
||||
@@ -300,10 +303,10 @@ void Server::Run() {
|
||||
|
||||
conn->sendPacks(m_sock_udp, m_conns, timer);
|
||||
}
|
||||
if (deadplayers == players - 1 || timer <= 0)
|
||||
endgame = true;
|
||||
//if (/*(deadplayers == players - 1 && deadplayers != 0) || */timer <= 0)
|
||||
//endgame = true;
|
||||
}
|
||||
|
||||
|
||||
for (auto& bull : netbull)
|
||||
for (auto& [key, conn] : m_conns)
|
||||
if (bull->id != conn->GetHash(false)) // Pour pas repitcher au joueur sa propre balle.
|
||||
@@ -319,9 +322,11 @@ void Server::Run() {
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& chat : chatlog)
|
||||
for (auto& [key, conn] : m_conns)
|
||||
for (auto& chat : chatlog) {
|
||||
Log(chat.mess, false, false);
|
||||
for (auto& [key, conn] : m_conns)
|
||||
sendPackTo<Chat>(m_sock_udp, &chat, &m_buf, conn->getAddr());
|
||||
}
|
||||
|
||||
for (auto& chmo : chunkdiffs) {
|
||||
for (auto& [key, conn] : m_conns)
|
||||
@@ -420,13 +425,26 @@ uint64_t Server::getUniqueId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
std::string Server::getDeathMessage(std::string username) const {
|
||||
std::string Server::getDeathMessage(std::string username, std::string killer) const {
|
||||
std::string mess;
|
||||
std::string temp = DEATHMESSAGES.at(rand() % DEATHMESSAGES.size());
|
||||
size_t ind = temp.find('@');
|
||||
mess.append(temp.substr(0, ind));
|
||||
mess.append(username));
|
||||
mess.append(temp.substr(ind + 1));
|
||||
size_t indk = temp.find('$');
|
||||
|
||||
if (ind < indk) {
|
||||
mess.append(temp.substr(0, ind));
|
||||
mess.append(username);
|
||||
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);
|
||||
mess.append(temp.substr(indk + 1, ind));
|
||||
mess.append(username);
|
||||
mess.append(temp.substr(ind + 1));
|
||||
}
|
||||
|
||||
return mess;
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ private:
|
||||
void buildIdList(size_t size);
|
||||
|
||||
uint64_t getUniqueId();
|
||||
std::string getDeathMessage(std::string username) const;
|
||||
std::string getDeathMessage(std::string username, std::string killer) const;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user