diff --git a/include/entities.hpp b/include/entities.hpp index 2557c13..1b6d42c 100644 --- a/include/entities.hpp +++ b/include/entities.hpp @@ -187,6 +187,9 @@ struct Projectile: public Entity { void unloadCreatePacket(sf::Packet& packet) override; void loadSyncPacket(sf::Packet& packet) override; void unloadSyncPacket(sf::Packet& packet) override; + + void simSetup() override; + void simReset() override; void onEntityDelete(Entity* d) override; @@ -196,7 +199,8 @@ struct Projectile: public Entity { Entity* owner = nullptr; static double mass, accel, rotateSpeed, maxThrustAngle, easeInFactor, startingFuel; - double fuel; + double fuel, + resFuel; std::unique_ptr shape, warning; }; diff --git a/include/globals.hpp b/include/globals.hpp index 5c5c300..dc15bac 100644 --- a/include/globals.hpp +++ b/include/globals.hpp @@ -52,7 +52,7 @@ inline double delta = 1.0 / 60.0, gen_moonFactor = gen_maxPlanetRadius * 0.24, gen_minMoonDistance = 2.0, gen_maxMoonDistance = 9.0, gen_minMoonRadius = 120.0, gen_maxMoonRadiusFrac = 1.0 / 6.0, shipSpawnDistanceMin = 1.4, shipSpawnDistanceMax = 3.0, - syncCullThreshold = 0.6, syncCullOffset = 100000.0, sweepThreshold = 10e6 * 10e6, + syncCullThreshold = 0.6, syncCullOffset = 100000.0, sweepThreshold = 2.0e7 * 2.0e7, predictSpacing = 0.25, predictDelta = 0.2, extraQuadAllocation = 2.0, quadReallocateThreshold = 0.6, quadtreeShrinkThreshold = 0.2, autorestartSpacing = 30.0 * 60.0 + 1, autorestartNotifSpacing = 5.0 * 60.0, diff --git a/src/entities.cpp b/src/entities.cpp index c32a859..2aff971 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -179,7 +179,7 @@ Projectile::accel = 196.0, Projectile::rotateSpeed = 240.0, Projectile::maxThrustAngle = 45.0 * degToRad, Projectile::easeInFactor = 0.8, -Projectile::startingFuel = 120.0; +Projectile::startingFuel = 80.0; double Triangle::mass = 1.0e6, Triangle::accel = 96.0, @@ -917,10 +917,19 @@ void Projectile::unloadCreatePacket(sf::Packet& packet) { } } void Projectile::loadSyncPacket(sf::Packet& packet) { - packet << id << x << y << velX << velY << rotation; + packet << id << x << y << velX << velY << rotation << fuel; } void Projectile::unloadSyncPacket(sf::Packet& packet) { - packet >> syncX >> syncY >> syncVelX >> syncVelY >> rotation; + packet >> syncX >> syncY >> syncVelX >> syncVelY >> rotation >> fuel; +} + +void Projectile::simSetup() { + Entity::simSetup(); + resFuel = fuel; +} +void Projectile::simReset() { + Entity::simReset(); + fuel = resFuel; } void Projectile::collide(Entity* with, bool specialOnly) { diff --git a/src/main.cpp b/src/main.cpp index 570cd6d..2c1ff00 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -474,7 +474,7 @@ int main(int argc, char** argv) { break; } } - if (closest > sweepThreshold) { + if (closest * e->fuel / e->startingFuel > sweepThreshold) { e->active = false; } }