Skip to content

Commit

Permalink
fixes, changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya246 committed Apr 24, 2023
1 parent b281126 commit 4bf9c95
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion include/entities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<sf::CircleShape> shape, warning;
};
Expand Down
2 changes: 1 addition & 1 deletion include/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 12 additions & 3 deletions src/entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ int main(int argc, char** argv) {
break;
}
}
if (closest > sweepThreshold) {
if (closest * e->fuel / e->startingFuel > sweepThreshold) {
e->active = false;
}
}
Expand Down

0 comments on commit 4bf9c95

Please sign in to comment.