OH
This commit is contained in:
parent
8bfee4a9ff
commit
486c823da1
@ -16,11 +16,9 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere
|
||||
for (auto& [key, player] : mapPlayer) {
|
||||
bool hit = false;
|
||||
if ((m_currentpos - player->GetPosition()).Length() < .6f) {
|
||||
std::cout << "hit" << std::endl;
|
||||
hit = true;
|
||||
}
|
||||
if ((m_currentpos - player->GetPOV()).Length() < .2f) {
|
||||
std::cout << "headshot" << std::endl;
|
||||
damage *= 2; // HEADSHOT!
|
||||
hit = true;
|
||||
}
|
||||
|
@ -200,6 +200,10 @@ void Server::Run() {
|
||||
m_world->BuildWorld();
|
||||
|
||||
for (auto& [key, conn] : m_conns) { // Creation des instances de joueurs et premier sync.
|
||||
if (!conn) {
|
||||
m_conns.erase(key);
|
||||
continue;
|
||||
}
|
||||
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));
|
||||
@ -247,7 +251,8 @@ void Server::Run() {
|
||||
}
|
||||
last = tstamp;
|
||||
|
||||
for (auto& [key, conn] : m_conns) {
|
||||
|
||||
for (auto& [key, conn] : m_conns) {
|
||||
|
||||
/* In */
|
||||
|
||||
@ -260,8 +265,10 @@ void Server::Run() {
|
||||
switch (netprot::getType(pck, 1)) {
|
||||
using enum netprot::PACKET_TYPE;
|
||||
case INPUT:
|
||||
if (Deserialize(&in, pck, &bsize))
|
||||
m_conns[in.sid]->AddInput(in);
|
||||
if (Deserialize(&in, pck, &bsize)) {
|
||||
if (m_conns.count(in.sid))
|
||||
m_conns[in.sid]->AddInput(in);
|
||||
}
|
||||
break;
|
||||
case SYNC:
|
||||
if (Deserialize(&sync, pck, &bsize)) {}
|
||||
@ -298,6 +305,9 @@ void Server::Run() {
|
||||
chunkdiffs.emplace_back(std::move(chmo));
|
||||
conn->ChunkDiffs.clear();
|
||||
|
||||
std::string str = conn->player->GetUsername();
|
||||
Log(str.append(" ").append(std::to_string(conn->player->GetHP())), false, false);
|
||||
|
||||
for (auto& bull : conn->Bullets) {
|
||||
bullets.emplace_back(bull);
|
||||
Log("POW!", false, false);
|
||||
|
Loading…
Reference in New Issue
Block a user