SYNC_ACC CMOD_ACC GLOBALS
This commit is contained in:
parent
2dbaf84844
commit
fd1fe66d13
@ -37,6 +37,9 @@
|
||||
#define STRENGTH_SPEED_BOOST 10 //Pourcentage
|
||||
#define BULLET_TIME .1
|
||||
|
||||
#define SYNC_ACC 200
|
||||
#define CMOD_ACC 1500
|
||||
|
||||
typedef uint8_t BlockType;
|
||||
enum BLOCK_TYPE { BTYPE_AIR, BTYPE_DIRT, BTYPE_GRASS, BTYPE_METAL, BTYPE_ICE, BTYPE_GREENGRASS, BTYPE_LAST };
|
||||
typedef uint8_t BoostType;
|
||||
|
@ -91,8 +91,8 @@ void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*
|
||||
|
||||
outs += out.timestamp + last;
|
||||
|
||||
if (outs >= 200) {
|
||||
outs -= 200;
|
||||
if (outs >= 50) {
|
||||
outs -= 50;
|
||||
Sync sync;
|
||||
sync.hp = player->GetHP();
|
||||
sync.timestamp = out.timestamp;
|
||||
@ -117,15 +117,15 @@ 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);
|
||||
|
||||
if (in.timestamp <= m_tstamp) {
|
||||
++m_last_in;
|
||||
continue;
|
||||
}
|
||||
|
||||
el = (double)(in.timestamp - last.timestamp) / 1000.;
|
||||
|
||||
if (m_shoot_acc > 0.) {
|
||||
@ -190,7 +190,7 @@ Timestamp Connection::Run(World* world) {
|
||||
out.id = m_playinfo.id;
|
||||
m_output_manifest[out.timestamp] = out;
|
||||
m_output_vector.push_back(out);
|
||||
tstamp = out.timestamp;
|
||||
m_tstamp = tstamp = out.timestamp;
|
||||
|
||||
++m_last_in;
|
||||
}
|
||||
|
@ -242,9 +242,9 @@ void Server::Run() {
|
||||
if (last == 0)
|
||||
last = tstamp;
|
||||
sync_acc += tstamp - last;
|
||||
if (sync_acc >= 1000) {
|
||||
while (sync_acc >= 1000)
|
||||
sync_acc -= 1000;
|
||||
if (sync_acc >= SYNC_ACC) {
|
||||
while (sync_acc >= SYNC_ACC)
|
||||
sync_acc -= SYNC_ACC;
|
||||
--timer;
|
||||
std::string str = "Timer: ";
|
||||
Log(str.append(std::to_string(timer)), false, false);
|
||||
@ -304,7 +304,6 @@ void Server::Run() {
|
||||
|
||||
for (auto& bull : conn->Bullets) {
|
||||
bullets.emplace_back(bull);
|
||||
//Log("POW!", false, false);
|
||||
BulletAdd* nbul = new BulletAdd();
|
||||
nbul->pos = bull->getPos();
|
||||
nbul->dir = bull->getVel();
|
||||
@ -315,12 +314,11 @@ void Server::Run() {
|
||||
}
|
||||
conn->Bullets.clear();
|
||||
}
|
||||
|
||||
/* Out */
|
||||
|
||||
conn->sendPacks(m_sock_udp, m_conns, timer);
|
||||
}
|
||||
if ((deadplayers == players - 1 && deadplayers != 0) || timer <= 0)
|
||||
/* Out */
|
||||
conn->sendPacks(m_sock_udp, m_conns, timer);
|
||||
|
||||
if ((deadplayers == players - 1 && deadplayers != 0) || timer < 0)
|
||||
endgame = true;
|
||||
}
|
||||
|
||||
|
@ -1454,8 +1454,8 @@ void Engine::Render(float elapsedTime) {
|
||||
cmod_acc += tstamp - last;
|
||||
last = tstamp;
|
||||
|
||||
if (sync_acc >= 200) {
|
||||
sync_acc -= 200;
|
||||
if (sync_acc >= SYNC_ACC) {
|
||||
sync_acc -= SYNC_ACC;
|
||||
sync.sid = id;
|
||||
sync.timestamp = tstamp;
|
||||
sync.position = m_player.GetPositionAbs();
|
||||
@ -1467,9 +1467,9 @@ void Engine::Render(float elapsedTime) {
|
||||
m_syncs[sync.timestamp] = sync;
|
||||
}
|
||||
|
||||
if (cmod_acc >= 2000) {
|
||||
while (cmod_acc >= 2000)
|
||||
cmod_acc -= 2000;
|
||||
if (cmod_acc >= CMOD_ACC) {
|
||||
while (cmod_acc >= CMOD_ACC)
|
||||
cmod_acc -= CMOD_ACC;
|
||||
if (!m_chunkmod_manifest.empty()) {
|
||||
ChunkMod* cmod = m_chunkmod_manifest.front();
|
||||
m_chunkmod_manifest.pop_front();
|
||||
|
Loading…
x
Reference in New Issue
Block a user