Skip to content

Commit

Permalink
Move addWall out of WorldInfo. Fixes #341.
Browse files Browse the repository at this point in the history
  • Loading branch information
blast007 committed Dec 9, 2024
1 parent 2e52264 commit 6089084
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
10 changes: 0 additions & 10 deletions src/bzfs/WorldInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "BaseBuilding.h"
#include "TetraBuilding.h"
#include "Teleporter.h"
#include "WallObstacle.h"
#include "MeshObstacle.h"
#include "ArcObstacle.h"
#include "ConeObstacle.h"
Expand Down Expand Up @@ -76,15 +75,6 @@ WorldInfo::~WorldInfo()
finished = false;
}


void WorldInfo::addWall(float x, float y, float z, float r, float w, float h)
{
const float pos[3] = {x, y, z};
WallObstacle* wall = new WallObstacle(pos, r, w, h, false);
OBSTACLEMGR.addWorldObstacle(wall);
}


void WorldInfo::addLink(int src, int dst)
{
links.addLink(src, dst);
Expand Down
18 changes: 13 additions & 5 deletions src/bzfs/bzfs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
// common implementation headers
#include "Obstacle.h"
#include "ObstacleMgr.h"
#include "WallObstacle.h"
#include "CollisionManager.h"
#include "BaseBuilding.h"
#include "AnsiCodes.h"
Expand Down Expand Up @@ -1050,6 +1051,13 @@ static void relayPlayerPacket(int index, uint16_t len, const void *rawbuf, uint1
}
}

void addWall(float x, float y, float z, float r, float w, float h)
{
const float pos[3] = { x, y, z };
WallObstacle* wall = new WallObstacle(pos, r, w, h, false);
OBSTACLEMGR.addWorldObstacle(wall);
}

void makeWalls ( void )
{
float worldSize = BZDBCache::worldSize;
Expand Down Expand Up @@ -1079,16 +1087,16 @@ void makeWalls ( void )
float x = sinf(midpointAngle*degToRad)*midpointRad;
float y = cosf(midpointAngle*degToRad)*midpointRad;

world->addWall(x, y, 0.0f, (270.0f-midpointAngle)*degToRad, (float)segmentLen, wallHeight);
addWall(x, y, 0.0f, (270.0f-midpointAngle)*degToRad, (float)segmentLen, wallHeight);

}
}
else
{
world->addWall(0.0f, 0.5f * worldSize, 0.0f, (float)(1.5 * M_PI), 0.5f * worldSize, wallHeight);
world->addWall(0.5f * worldSize, 0.0f, 0.0f, (float)M_PI, 0.5f * worldSize, wallHeight);
world->addWall(0.0f, -0.5f * worldSize, 0.0f, (float)(0.5 * M_PI), 0.5f * worldSize, wallHeight);
world->addWall(-0.5f * worldSize, 0.0f, 0.0f, 0.0f, 0.5f * worldSize, wallHeight);
addWall(0.0f, 0.5f * worldSize, 0.0f, (float)(1.5 * M_PI), 0.5f * worldSize, wallHeight);
addWall(0.5f * worldSize, 0.0f, 0.0f, (float)M_PI, 0.5f * worldSize, wallHeight);
addWall(0.0f, -0.5f * worldSize, 0.0f, (float)(0.5 * M_PI), 0.5f * worldSize, wallHeight);
addWall(-0.5f * worldSize, 0.0f, 0.0f, 0.0f, 0.5f * worldSize, wallHeight);
}
}

Expand Down

0 comments on commit 6089084

Please sign in to comment.