Skip to content

Commit

Permalink
fix more
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya246 committed Jun 22, 2022
1 parent 433b0f3 commit fff7923
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/entities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct Triangle: public Entity {
void unloadSyncPacket(sf::Packet& packet) override;

uint8_t type() override;
double accel = 6, rotateSpeed = 2.0, boostCooldown = 15.0, boostStrength = 2.0, reload = 6.0, shootPower = 2.0,
double accel = 0.006, rotateSpeed = 2.0, boostCooldown = 15.0, boostStrength = 2.0, reload = 6.0, shootPower = 2.0,
lastBoosted = -boostCooldown, lastShot = -reload;

std::string name = "";
Expand Down
1 change: 1 addition & 0 deletions include/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ inline sf::Font* font = nullptr;
inline obf::Player* sparePlayer = new obf::Player;
inline std::vector<Entity*> updateGroup;
inline std::vector<Player*> playerGroup;
inline std::vector<Entity*> entityDeleteBuffer;
inline std::vector<Attractor*> planets;
inline sf::Vector2i mousePos;
inline sf::Clock deltaClock, globalClock;
Expand Down
8 changes: 4 additions & 4 deletions src/entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Player::~Player() {
for (Player* p : playerGroup) {
p->tcpSocket.send(chatPacket);
}
delete this->entity;
entityDeleteBuffer.push_back(entity);
}

Entity::Entity() {
Expand Down Expand Up @@ -139,7 +139,7 @@ void Entity::update() {
}
}
if (!found) {
delete e;
entityDeleteBuffer.push_back(e);
}
}
}
Expand Down Expand Up @@ -414,12 +414,12 @@ void Projectile::collide(Entity* with, bool collideOther) {
}
}
}
delete this;
entityDeleteBuffer.push_back(this);
} else if (with->type() == Entities::Attractor) {
if (debug) {
printf("of type attractor\n");
}
delete this;
entityDeleteBuffer.push_back(this);
} else {
if (debug) {
printf("of unaccounted type\n");
Expand Down
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ int main(int argc, char** argv) {
for (size_t i = 0; i < updateGroup.size(); i++) {
updateGroup[i]->update();
}
for (Entity* e : entityDeleteBuffer) {
delete e;
}
entityDeleteBuffer.clear();
if (headless) {
int to = playerGroup.size();
for (int i = 0; i < to; i++) {
Expand Down

0 comments on commit fff7923

Please sign in to comment.