1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

Remove usages of WorkContext

This commit is contained in:
Daniel Evans 2016-12-02 00:56:38 +00:00
parent 7ad8ae5e40
commit b65a513bbb
14 changed files with 19 additions and 49 deletions

View File

@ -21,8 +21,8 @@
#include <iostream>
#include <sstream>
GameData::GameData(Logger* log, WorkContext* work, const std::string& path)
: datpath(path), logger(log), workContext(work), engine(nullptr) {
GameData::GameData(Logger* log, const std::string& path)
: datpath(path), logger(log), engine(nullptr) {
}
GameData::~GameData() {

View File

@ -18,7 +18,6 @@ class Logger;
#include <audio/MADStream.hpp>
#include <gl/TextureData.hpp>
#include <platform/FileIndex.hpp>
#include <job/WorkContext.hpp>
#include <memory>
@ -42,14 +41,12 @@ private:
std::string splash;
Logger* logger;
WorkContext* workContext;
public:
/**
* ctor
* @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();
GameWorld* engine;

View File

@ -9,7 +9,6 @@
#include <ai/TrafficDirector.hpp>
#include <data/Model.hpp>
#include <data/WeaponData.hpp>
#include <job/WorkContext.hpp>
#include <loaders/LoaderIDE.hpp>
#include <loaders/LoaderIPL.hpp>
@ -83,8 +82,8 @@ public:
}
};
GameWorld::GameWorld(Logger* log, WorkContext* work, GameData* dat)
: logger(log), data(dat), randomEngine(rand()), _work(work), paused(false) {
GameWorld::GameWorld(Logger* log, GameData* dat)
: logger(log), data(dat), randomEngine(rand()), paused(false) {
data->engine = this;
collisionConfig = std::make_unique<btDefaultCollisionConfiguration>();

View File

@ -13,7 +13,6 @@ class GameState;
#include <audio/SoundManager.hpp>
class CutsceneObject;
class WorkContext;
#include <objects/ObjectTypes.hpp>
class GameObject;
@ -60,7 +59,7 @@ struct AreaIndicatorInfo {
*/
class GameWorld {
public:
GameWorld(Logger* log, WorkContext* work, GameData* dat);
GameWorld(Logger* log, GameData* dat);
~GameWorld();
@ -290,11 +289,6 @@ public:
static void PhysicsTickCallback(btDynamicsWorld* physWorld,
btScalar timeStep);
/**
* Work related
*/
WorkContext* _work;
/**
* @brief Loads and starts the named cutscene.
* @param name

View File

@ -31,7 +31,7 @@ std::map<GameRenderer::SpecialModel, std::string> kSpecialModels = {
RWGame::RWGame(Logger& log, int argc, char* argv[])
: GameBase(log, argc, argv)
, data(&log, &work, config.getGameDataPath())
, data(&log, config.getGameDataPath())
, renderer(&log, &data) {
bool newgame = options.count("newgame");
bool test = options.count("test");
@ -97,9 +97,6 @@ RWGame::RWGame(Logger& log, int argc, char* argv[])
RWGame::~RWGame() {
log.info("Game", "Beginning cleanup");
log.info("Game", "Stopping work queue");
work.stop();
}
void RWGame::newGame() {
@ -107,7 +104,7 @@ void RWGame::newGame() {
state = GameState();
// 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);
// Associate the new world with the new state and vice versa
@ -465,9 +462,6 @@ int RWGame::run() {
}
void RWGame::tick(float dt) {
// Process the Engine's background work.
work.update();
State* currState = StateManager::get().states.back().get();
world->chase.update(dt);

View File

@ -16,7 +16,6 @@
class PlayerController;
class RWGame : public GameBase {
WorkContext work;
GameData data;
GameRenderer renderer;
DebugDraw debug;

View File

@ -15,12 +15,8 @@ void LoadingState::exit() {
void LoadingState::tick(float dt) {
RW_UNUSED(dt);
// If background work is completed, do callback
if (getWorld()->_work->isEmpty()) {
// If we ever get back to this state it should be completed
done();
complete();
}
done();
complete();
}
bool LoadingState::shouldWorldUpdate() {

View File

@ -86,8 +86,6 @@ void ViewerWidget::paintGL() {
dummyObject->skeleton->interpolate(1.f);
}
gworld->_work->update();
r.getRenderer()->invalidate();
glEnable(GL_DEPTH_TEST);

View File

@ -161,9 +161,9 @@ void ViewerWindow::loadGame(const QString& path) {
QDir gameDir(path);
if (gameDir.exists() && path.size() > 0) {
gameData = new GameData(&engineLog, &work,
gameDir.absolutePath().toStdString());
gameWorld = new GameWorld(&engineLog, &work, gameData);
gameData =
new GameData(&engineLog, gameDir.absolutePath().toStdString());
gameWorld = new GameWorld(&engineLog, gameData);
renderer = new GameRenderer(&engineLog, gameData);
gameWorld->state = new GameState;
viewerWidget->setRenderer(renderer);

View File

@ -22,7 +22,6 @@ class ViewerWindow : public QMainWindow {
enum ViewMode { Object = 0, Model = 1, World = 2, _Count };
Logger engineLog;
WorkContext work;
GameData* gameData;
GameWorld* gameWorld;

View File

@ -6,8 +6,8 @@ BOOST_AUTO_TEST_SUITE(GameDataTests)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_object_data) {
GameData gd(&Global::get().log, &Global::get().work, Global::getGamePath());
GameWorld gw(&Global::get().log, &Global::get().work, &gd);
GameData gd(&Global::get().log, Global::getGamePath());
GameWorld gw(&Global::get().log, &gd);
gd.load();

View File

@ -8,7 +8,7 @@ BOOST_AUTO_TEST_SUITE(GameWorldTests)
#if RW_TEST_WITH_DATA
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 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) {
GameWorld gw(&Global::get().log, &Global::get().work, Global::get().d);
GameWorld gw(&Global::get().log, Global::get().d);
gw.state = new GameState();
BOOST_CHECK_EQUAL(0, gw.getHour());

View File

@ -74,7 +74,6 @@ public:
GameWorld* e;
GameState* s;
Logger log;
WorkContext work;
#endif
Global() {
@ -85,19 +84,15 @@ public:
window.hideCursor();
#if RW_TEST_WITH_DATA
d = new GameData(&log, &work, getGamePath());
d = new GameData(&log, getGamePath());
d->load();
e = new GameWorld(&log, &work, d);
e = new GameWorld(&log, d);
s = new GameState;
e->state = s;
e->dynamicsWorld->setGravity(btVector3(0.f, 0.f, 0.f));
while (!e->_work->isEmpty()) {
std::this_thread::yield();
}
#endif
}

View File

@ -1,6 +1,5 @@
#include <boost/test/unit_test.hpp>
#include <data/Model.hpp>
#include <job/WorkContext.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(LoaderDFFTests)