mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
Remove usages of WorkContext
This commit is contained in:
parent
7ad8ae5e40
commit
b65a513bbb
@ -21,8 +21,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
GameData::GameData(Logger* log, WorkContext* work, const std::string& path)
|
GameData::GameData(Logger* log, const std::string& path)
|
||||||
: datpath(path), logger(log), workContext(work), engine(nullptr) {
|
: datpath(path), logger(log), engine(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GameData::~GameData() {
|
GameData::~GameData() {
|
||||||
|
@ -18,7 +18,6 @@ class Logger;
|
|||||||
#include <audio/MADStream.hpp>
|
#include <audio/MADStream.hpp>
|
||||||
#include <gl/TextureData.hpp>
|
#include <gl/TextureData.hpp>
|
||||||
#include <platform/FileIndex.hpp>
|
#include <platform/FileIndex.hpp>
|
||||||
#include <job/WorkContext.hpp>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -42,14 +41,12 @@ private:
|
|||||||
std::string splash;
|
std::string splash;
|
||||||
|
|
||||||
Logger* logger;
|
Logger* logger;
|
||||||
WorkContext* workContext;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* ctor
|
* ctor
|
||||||
* @param path Path to the root of the game data.
|
* @param path Path to the root of the game data.
|
||||||
*/
|
*/
|
||||||
GameData(Logger* log, WorkContext* work, const std::string& path = "");
|
GameData(Logger* log, const std::string& path = "");
|
||||||
~GameData();
|
~GameData();
|
||||||
|
|
||||||
GameWorld* engine;
|
GameWorld* engine;
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <ai/TrafficDirector.hpp>
|
#include <ai/TrafficDirector.hpp>
|
||||||
#include <data/Model.hpp>
|
#include <data/Model.hpp>
|
||||||
#include <data/WeaponData.hpp>
|
#include <data/WeaponData.hpp>
|
||||||
#include <job/WorkContext.hpp>
|
|
||||||
#include <loaders/LoaderIDE.hpp>
|
#include <loaders/LoaderIDE.hpp>
|
||||||
#include <loaders/LoaderIPL.hpp>
|
#include <loaders/LoaderIPL.hpp>
|
||||||
|
|
||||||
@ -83,8 +82,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameWorld::GameWorld(Logger* log, WorkContext* work, GameData* dat)
|
GameWorld::GameWorld(Logger* log, GameData* dat)
|
||||||
: logger(log), data(dat), randomEngine(rand()), _work(work), paused(false) {
|
: logger(log), data(dat), randomEngine(rand()), paused(false) {
|
||||||
data->engine = this;
|
data->engine = this;
|
||||||
|
|
||||||
collisionConfig = std::make_unique<btDefaultCollisionConfiguration>();
|
collisionConfig = std::make_unique<btDefaultCollisionConfiguration>();
|
||||||
|
@ -13,7 +13,6 @@ class GameState;
|
|||||||
#include <audio/SoundManager.hpp>
|
#include <audio/SoundManager.hpp>
|
||||||
|
|
||||||
class CutsceneObject;
|
class CutsceneObject;
|
||||||
class WorkContext;
|
|
||||||
#include <objects/ObjectTypes.hpp>
|
#include <objects/ObjectTypes.hpp>
|
||||||
|
|
||||||
class GameObject;
|
class GameObject;
|
||||||
@ -60,7 +59,7 @@ struct AreaIndicatorInfo {
|
|||||||
*/
|
*/
|
||||||
class GameWorld {
|
class GameWorld {
|
||||||
public:
|
public:
|
||||||
GameWorld(Logger* log, WorkContext* work, GameData* dat);
|
GameWorld(Logger* log, GameData* dat);
|
||||||
|
|
||||||
~GameWorld();
|
~GameWorld();
|
||||||
|
|
||||||
@ -290,11 +289,6 @@ public:
|
|||||||
static void PhysicsTickCallback(btDynamicsWorld* physWorld,
|
static void PhysicsTickCallback(btDynamicsWorld* physWorld,
|
||||||
btScalar timeStep);
|
btScalar timeStep);
|
||||||
|
|
||||||
/**
|
|
||||||
* Work related
|
|
||||||
*/
|
|
||||||
WorkContext* _work;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Loads and starts the named cutscene.
|
* @brief Loads and starts the named cutscene.
|
||||||
* @param name
|
* @param name
|
||||||
|
@ -31,7 +31,7 @@ std::map<GameRenderer::SpecialModel, std::string> kSpecialModels = {
|
|||||||
|
|
||||||
RWGame::RWGame(Logger& log, int argc, char* argv[])
|
RWGame::RWGame(Logger& log, int argc, char* argv[])
|
||||||
: GameBase(log, argc, argv)
|
: GameBase(log, argc, argv)
|
||||||
, data(&log, &work, config.getGameDataPath())
|
, data(&log, config.getGameDataPath())
|
||||||
, renderer(&log, &data) {
|
, renderer(&log, &data) {
|
||||||
bool newgame = options.count("newgame");
|
bool newgame = options.count("newgame");
|
||||||
bool test = options.count("test");
|
bool test = options.count("test");
|
||||||
@ -97,9 +97,6 @@ RWGame::RWGame(Logger& log, int argc, char* argv[])
|
|||||||
|
|
||||||
RWGame::~RWGame() {
|
RWGame::~RWGame() {
|
||||||
log.info("Game", "Beginning cleanup");
|
log.info("Game", "Beginning cleanup");
|
||||||
|
|
||||||
log.info("Game", "Stopping work queue");
|
|
||||||
work.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RWGame::newGame() {
|
void RWGame::newGame() {
|
||||||
@ -107,7 +104,7 @@ void RWGame::newGame() {
|
|||||||
state = GameState();
|
state = GameState();
|
||||||
|
|
||||||
// Destroy the current world and start over
|
// Destroy the current world and start over
|
||||||
world = std::make_unique<GameWorld>(&log, &work, &data);
|
world = std::make_unique<GameWorld>(&log, &data);
|
||||||
world->dynamicsWorld->setDebugDrawer(&debug);
|
world->dynamicsWorld->setDebugDrawer(&debug);
|
||||||
|
|
||||||
// Associate the new world with the new state and vice versa
|
// Associate the new world with the new state and vice versa
|
||||||
@ -465,9 +462,6 @@ int RWGame::run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RWGame::tick(float dt) {
|
void RWGame::tick(float dt) {
|
||||||
// Process the Engine's background work.
|
|
||||||
work.update();
|
|
||||||
|
|
||||||
State* currState = StateManager::get().states.back().get();
|
State* currState = StateManager::get().states.back().get();
|
||||||
|
|
||||||
world->chase.update(dt);
|
world->chase.update(dt);
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
class PlayerController;
|
class PlayerController;
|
||||||
|
|
||||||
class RWGame : public GameBase {
|
class RWGame : public GameBase {
|
||||||
WorkContext work;
|
|
||||||
GameData data;
|
GameData data;
|
||||||
GameRenderer renderer;
|
GameRenderer renderer;
|
||||||
DebugDraw debug;
|
DebugDraw debug;
|
||||||
|
@ -15,12 +15,8 @@ void LoadingState::exit() {
|
|||||||
void LoadingState::tick(float dt) {
|
void LoadingState::tick(float dt) {
|
||||||
RW_UNUSED(dt);
|
RW_UNUSED(dt);
|
||||||
|
|
||||||
// If background work is completed, do callback
|
done();
|
||||||
if (getWorld()->_work->isEmpty()) {
|
complete();
|
||||||
// If we ever get back to this state it should be completed
|
|
||||||
done();
|
|
||||||
complete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadingState::shouldWorldUpdate() {
|
bool LoadingState::shouldWorldUpdate() {
|
||||||
|
@ -86,8 +86,6 @@ void ViewerWidget::paintGL() {
|
|||||||
dummyObject->skeleton->interpolate(1.f);
|
dummyObject->skeleton->interpolate(1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
gworld->_work->update();
|
|
||||||
|
|
||||||
r.getRenderer()->invalidate();
|
r.getRenderer()->invalidate();
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
@ -161,9 +161,9 @@ void ViewerWindow::loadGame(const QString& path) {
|
|||||||
QDir gameDir(path);
|
QDir gameDir(path);
|
||||||
|
|
||||||
if (gameDir.exists() && path.size() > 0) {
|
if (gameDir.exists() && path.size() > 0) {
|
||||||
gameData = new GameData(&engineLog, &work,
|
gameData =
|
||||||
gameDir.absolutePath().toStdString());
|
new GameData(&engineLog, gameDir.absolutePath().toStdString());
|
||||||
gameWorld = new GameWorld(&engineLog, &work, gameData);
|
gameWorld = new GameWorld(&engineLog, gameData);
|
||||||
renderer = new GameRenderer(&engineLog, gameData);
|
renderer = new GameRenderer(&engineLog, gameData);
|
||||||
gameWorld->state = new GameState;
|
gameWorld->state = new GameState;
|
||||||
viewerWidget->setRenderer(renderer);
|
viewerWidget->setRenderer(renderer);
|
||||||
|
@ -22,7 +22,6 @@ class ViewerWindow : public QMainWindow {
|
|||||||
enum ViewMode { Object = 0, Model = 1, World = 2, _Count };
|
enum ViewMode { Object = 0, Model = 1, World = 2, _Count };
|
||||||
|
|
||||||
Logger engineLog;
|
Logger engineLog;
|
||||||
WorkContext work;
|
|
||||||
|
|
||||||
GameData* gameData;
|
GameData* gameData;
|
||||||
GameWorld* gameWorld;
|
GameWorld* gameWorld;
|
||||||
|
@ -6,8 +6,8 @@ BOOST_AUTO_TEST_SUITE(GameDataTests)
|
|||||||
|
|
||||||
#if RW_TEST_WITH_DATA
|
#if RW_TEST_WITH_DATA
|
||||||
BOOST_AUTO_TEST_CASE(test_object_data) {
|
BOOST_AUTO_TEST_CASE(test_object_data) {
|
||||||
GameData gd(&Global::get().log, &Global::get().work, Global::getGamePath());
|
GameData gd(&Global::get().log, Global::getGamePath());
|
||||||
GameWorld gw(&Global::get().log, &Global::get().work, &gd);
|
GameWorld gw(&Global::get().log, &gd);
|
||||||
|
|
||||||
gd.load();
|
gd.load();
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ BOOST_AUTO_TEST_SUITE(GameWorldTests)
|
|||||||
|
|
||||||
#if RW_TEST_WITH_DATA
|
#if RW_TEST_WITH_DATA
|
||||||
BOOST_AUTO_TEST_CASE(test_gameobject_id) {
|
BOOST_AUTO_TEST_CASE(test_gameobject_id) {
|
||||||
GameWorld gw(&Global::get().log, &Global::get().work, Global::get().d);
|
GameWorld gw(&Global::get().log, Global::get().d);
|
||||||
|
|
||||||
auto object1 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 0.f));
|
auto object1 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 0.f));
|
||||||
auto object2 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 100.f));
|
auto object2 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 100.f));
|
||||||
@ -17,7 +17,7 @@ BOOST_AUTO_TEST_CASE(test_gameobject_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_offsetgametime) {
|
BOOST_AUTO_TEST_CASE(test_offsetgametime) {
|
||||||
GameWorld gw(&Global::get().log, &Global::get().work, Global::get().d);
|
GameWorld gw(&Global::get().log, Global::get().d);
|
||||||
gw.state = new GameState();
|
gw.state = new GameState();
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(0, gw.getHour());
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
||||||
|
@ -74,7 +74,6 @@ public:
|
|||||||
GameWorld* e;
|
GameWorld* e;
|
||||||
GameState* s;
|
GameState* s;
|
||||||
Logger log;
|
Logger log;
|
||||||
WorkContext work;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Global() {
|
Global() {
|
||||||
@ -85,19 +84,15 @@ public:
|
|||||||
window.hideCursor();
|
window.hideCursor();
|
||||||
|
|
||||||
#if RW_TEST_WITH_DATA
|
#if RW_TEST_WITH_DATA
|
||||||
d = new GameData(&log, &work, getGamePath());
|
d = new GameData(&log, getGamePath());
|
||||||
|
|
||||||
d->load();
|
d->load();
|
||||||
|
|
||||||
e = new GameWorld(&log, &work, d);
|
e = new GameWorld(&log, d);
|
||||||
s = new GameState;
|
s = new GameState;
|
||||||
e->state = s;
|
e->state = s;
|
||||||
|
|
||||||
e->dynamicsWorld->setGravity(btVector3(0.f, 0.f, 0.f));
|
e->dynamicsWorld->setGravity(btVector3(0.f, 0.f, 0.f));
|
||||||
|
|
||||||
while (!e->_work->isEmpty()) {
|
|
||||||
std::this_thread::yield();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <data/Model.hpp>
|
#include <data/Model.hpp>
|
||||||
#include <job/WorkContext.hpp>
|
|
||||||
#include "test_globals.hpp"
|
#include "test_globals.hpp"
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(LoaderDFFTests)
|
BOOST_AUTO_TEST_SUITE(LoaderDFFTests)
|
||||||
|
Loading…
Reference in New Issue
Block a user