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) {
|
for (auto& [key, player] : mapPlayer) {
|
||||||
bool hit = false;
|
bool hit = false;
|
||||||
if ((m_currentpos - player->GetPosition()).Length() < .6f) {
|
if ((m_currentpos - player->GetPosition()).Length() < .6f) {
|
||||||
std::cout << "hit" << std::endl;
|
|
||||||
hit = true;
|
hit = true;
|
||||||
}
|
}
|
||||||
if ((m_currentpos - player->GetPOV()).Length() < .2f) {
|
if ((m_currentpos - player->GetPOV()).Length() < .2f) {
|
||||||
std::cout << "headshot" << std::endl;
|
|
||||||
damage *= 2; // HEADSHOT!
|
damage *= 2; // HEADSHOT!
|
||||||
hit = true;
|
hit = true;
|
||||||
}
|
}
|
||||||
|
@ -200,6 +200,10 @@ void Server::Run() {
|
|||||||
m_world->BuildWorld();
|
m_world->BuildWorld();
|
||||||
|
|
||||||
for (auto& [key, conn] : m_conns) { // Creation des instances de joueurs et premier sync.
|
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),
|
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);
|
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 = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f));
|
||||||
@ -247,7 +251,8 @@ void Server::Run() {
|
|||||||
}
|
}
|
||||||
last = tstamp;
|
last = tstamp;
|
||||||
|
|
||||||
for (auto& [key, conn] : m_conns) {
|
|
||||||
|
for (auto& [key, conn] : m_conns) {
|
||||||
|
|
||||||
/* In */
|
/* In */
|
||||||
|
|
||||||
@ -260,8 +265,10 @@ void Server::Run() {
|
|||||||
switch (netprot::getType(pck, 1)) {
|
switch (netprot::getType(pck, 1)) {
|
||||||
using enum netprot::PACKET_TYPE;
|
using enum netprot::PACKET_TYPE;
|
||||||
case INPUT:
|
case INPUT:
|
||||||
if (Deserialize(&in, pck, &bsize))
|
if (Deserialize(&in, pck, &bsize)) {
|
||||||
m_conns[in.sid]->AddInput(in);
|
if (m_conns.count(in.sid))
|
||||||
|
m_conns[in.sid]->AddInput(in);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SYNC:
|
case SYNC:
|
||||||
if (Deserialize(&sync, pck, &bsize)) {}
|
if (Deserialize(&sync, pck, &bsize)) {}
|
||||||
@ -298,6 +305,9 @@ void Server::Run() {
|
|||||||
chunkdiffs.emplace_back(std::move(chmo));
|
chunkdiffs.emplace_back(std::move(chmo));
|
||||||
conn->ChunkDiffs.clear();
|
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) {
|
for (auto& bull : conn->Bullets) {
|
||||||
bullets.emplace_back(bull);
|
bullets.emplace_back(bull);
|
||||||
Log("POW!", false, false);
|
Log("POW!", false, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user