Bonne idée.
This commit is contained in:
@@ -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);
|
||||
|
@@ -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,7 +231,8 @@ void Server::Run() {
|
||||
last = tstamp;
|
||||
sync_acc += tstamp - last;
|
||||
if (sync_acc >= 1000) {
|
||||
sync_acc -= 1000;
|
||||
while (sync_acc >= 1000)
|
||||
sync_acc -= 1000;
|
||||
--timer;
|
||||
std::string str = "Timer: ";
|
||||
Log(str.append(std::to_string(timer).append(" SyncAcc: ").append(std::to_string(sync_acc))), false, false);
|
||||
@@ -269,18 +271,18 @@ 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;
|
||||
|
||||
std::string killer = m_conns.at(key)->player->GetUsername();
|
||||
|
||||
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,13 +436,19 @@ 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);
|
||||
mess.append(temp.substr(ind + 1, indk));
|
||||
mess.append(killer);
|
||||
mess.append(temp.substr(indk + 1));
|
||||
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));
|
||||
|
Reference in New Issue
Block a user