mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 20:02:40 +01:00
Remove Logger ownership from GameWorld
This commit is contained in:
parent
b280aac859
commit
b672e41acf
@ -2,6 +2,8 @@
|
|||||||
#ifndef _GAMEDATA_HPP_
|
#ifndef _GAMEDATA_HPP_
|
||||||
#define _GAMEDATA_HPP_
|
#define _GAMEDATA_HPP_
|
||||||
|
|
||||||
|
class Logger;
|
||||||
|
|
||||||
#include <engine/RWTypes.hpp>
|
#include <engine/RWTypes.hpp>
|
||||||
#include <loaders/LoaderIMG.hpp>
|
#include <loaders/LoaderIMG.hpp>
|
||||||
#include <loaders/TextureLoader.hpp>
|
#include <loaders/TextureLoader.hpp>
|
||||||
@ -41,13 +43,15 @@ private:
|
|||||||
std::string datpath;
|
std::string datpath;
|
||||||
std::string splash;
|
std::string splash;
|
||||||
|
|
||||||
|
Logger* logger;
|
||||||
|
|
||||||
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(const std::string& path = "");
|
GameData(Logger* log, const std::string& path = "");
|
||||||
~GameData();
|
~GameData();
|
||||||
|
|
||||||
GameWorld* engine;
|
GameWorld* engine;
|
||||||
@ -273,6 +277,11 @@ public:
|
|||||||
float getWaveHeightAt(const glm::vec3& ws) const;
|
float getWaveHeightAt(const glm::vec3& ws) const;
|
||||||
|
|
||||||
GameTexts texts;
|
GameTexts texts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the given path is a valid game directory.
|
||||||
|
*/
|
||||||
|
static bool isValidGameDirectory(const std::string& path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#ifndef _GAMEWORLD_HPP_
|
#ifndef _GAMEWORLD_HPP_
|
||||||
#define _GAMEWORLD_HPP_
|
#define _GAMEWORLD_HPP_
|
||||||
|
|
||||||
#include <core/Logger.hpp>
|
class Logger;
|
||||||
|
|
||||||
#include <engine/GameData.hpp>
|
#include <engine/GameData.hpp>
|
||||||
#include <engine/GameState.hpp>
|
#include <engine/GameState.hpp>
|
||||||
@ -59,16 +59,11 @@ class GameWorld
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GameWorld(const std::string& gamepath);
|
GameWorld(Logger* log, const std::string& gamepath);
|
||||||
|
|
||||||
~GameWorld();
|
~GameWorld();
|
||||||
|
|
||||||
/**
|
Logger* logger;
|
||||||
* Loads the game data
|
|
||||||
*/
|
|
||||||
bool load();
|
|
||||||
|
|
||||||
Logger logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an IDE into the game
|
* Loads an IDE into the game
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef _GAMERENDERER_HPP_
|
#ifndef _GAMERENDERER_HPP_
|
||||||
#define _GAMERENDERER_HPP_
|
#define _GAMERENDERER_HPP_
|
||||||
|
|
||||||
|
class Logger;
|
||||||
|
|
||||||
#define GLEW_STATIC
|
#define GLEW_STATIC
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -44,6 +46,9 @@ class GameRenderer
|
|||||||
/** Pointer to the world instance */
|
/** Pointer to the world instance */
|
||||||
GameWorld* engine;
|
GameWorld* engine;
|
||||||
|
|
||||||
|
/** Logger to output messages */
|
||||||
|
Logger* logger;
|
||||||
|
|
||||||
/** The low-level drawing interface to use */
|
/** The low-level drawing interface to use */
|
||||||
Renderer* renderer;
|
Renderer* renderer;
|
||||||
|
|
||||||
@ -86,7 +91,7 @@ class GameRenderer
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GameRenderer(GameWorld*);
|
GameRenderer(Logger* log, GameWorld*);
|
||||||
~GameRenderer();
|
~GameRenderer();
|
||||||
|
|
||||||
/** Number of culling events */
|
/** Number of culling events */
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <loaders/GenericDATLoader.hpp>
|
#include <loaders/GenericDATLoader.hpp>
|
||||||
#include <loaders/LoaderGXT.hpp>
|
#include <loaders/LoaderGXT.hpp>
|
||||||
#include <loaders/BackgroundLoader.hpp>
|
#include <loaders/BackgroundLoader.hpp>
|
||||||
|
#include <core/Logger.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -79,10 +80,9 @@ std::string fixPath(std::string path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GameData::GameData(const std::string& path)
|
GameData::GameData(Logger* log, const std::string& path)
|
||||||
: datpath(path), engine(nullptr)
|
: datpath(path), logger(log), engine(nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameData::~GameData()
|
GameData::~GameData()
|
||||||
@ -124,7 +124,7 @@ void GameData::parseDAT(const std::string& path)
|
|||||||
|
|
||||||
if(!datfile.is_open())
|
if(!datfile.is_open())
|
||||||
{
|
{
|
||||||
engine->logger.error("Data", "Failed to open game file " + path);
|
logger->error("Data", "Failed to open game file " + path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -221,12 +221,12 @@ bool GameData::loadZone(const std::string& path)
|
|||||||
for(auto& z : ipll.zones) {
|
for(auto& z : ipll.zones) {
|
||||||
zones.insert({z.name, z});
|
zones.insert({z.name, z});
|
||||||
}
|
}
|
||||||
engine->logger.info("Data", "Loaded " + std::to_string(ipll.zones.size()) + " zones from " + path);
|
logger->info("Data", "Loaded " + std::to_string(ipll.zones.size()) + " zones from " + path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
engine->logger.error("Data", "Failed to load zones from " + path);
|
logger->error("Data", "Failed to load zones from " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -491,7 +491,7 @@ bool GameData::loadAudioClip(const std::string& name)
|
|||||||
|
|
||||||
if ( name.find(".mp3") != name.npos )
|
if ( name.find(".mp3") != name.npos )
|
||||||
{
|
{
|
||||||
engine->logger.error("Data", "MP3 Audio unsupported outside cutscenes");
|
logger->error("Data", "MP3 Audio unsupported outside cutscenes");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ bool GameData::loadAudioClip(const std::string& name)
|
|||||||
|
|
||||||
if (! r )
|
if (! r )
|
||||||
{
|
{
|
||||||
engine->logger.error("Data", "Error loading audio clip " + fname);
|
logger->error("Data", "Error loading audio clip " + fname);
|
||||||
delete engine->missionAudio;
|
delete engine->missionAudio;
|
||||||
engine->missionAudio = nullptr;
|
engine->missionAudio = nullptr;
|
||||||
}
|
}
|
||||||
@ -524,7 +524,7 @@ FileHandle GameData::openFile(const std::string &name)
|
|||||||
auto file = index.openFile(name);
|
auto file = index.openFile(name);
|
||||||
if( file == nullptr )
|
if( file == nullptr )
|
||||||
{
|
{
|
||||||
engine->logger.error("Data", "Unable to open file: " + name);
|
logger->error("Data", "Unable to open file: " + name);
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
@ -559,3 +559,20 @@ float GameData::getWaveHeightAt(const glm::vec3 &ws) const
|
|||||||
{
|
{
|
||||||
return (1+sin(engine->gameTime + (ws.x + ws.y) * WATER_SCALE)) * WATER_HEIGHT;
|
return (1+sin(engine->gameTime + (ws.x + ws.y) * WATER_SCALE)) * WATER_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GameData::isValidGameDirectory(const std::string& path)
|
||||||
|
{
|
||||||
|
if(path.empty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoaderIMG i;
|
||||||
|
if(! i.load(path + "/models/gta3.img") )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#include <engine/GameWorld.hpp>
|
#include <engine/GameWorld.hpp>
|
||||||
|
|
||||||
|
#include <core/Logger.hpp>
|
||||||
|
|
||||||
#include <loaders/LoaderIPL.hpp>
|
#include <loaders/LoaderIPL.hpp>
|
||||||
#include <loaders/LoaderIDE.hpp>
|
#include <loaders/LoaderIDE.hpp>
|
||||||
#include <ai/DefaultAIController.hpp>
|
#include <ai/DefaultAIController.hpp>
|
||||||
@ -75,12 +78,22 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameWorld::GameWorld(const std::string& path)
|
GameWorld::GameWorld(Logger* log, const std::string& path)
|
||||||
: gameTime(0.f), gameData(path), randomEngine(rand()),
|
: logger(log), gameTime(0.f), gameData(log, path), randomEngine(rand()),
|
||||||
_work( new WorkContext( this ) ), script(nullptr), cutsceneAudio(nullptr), missionAudio(nullptr),
|
_work( new WorkContext( this ) ), script(nullptr), cutsceneAudio(nullptr), missionAudio(nullptr),
|
||||||
paused(false)
|
paused(false)
|
||||||
{
|
{
|
||||||
gameData.engine = this;
|
gameData.engine = this;
|
||||||
|
|
||||||
|
collisionConfig = new btDefaultCollisionConfiguration;
|
||||||
|
collisionDispatcher = new WorldCollisionDispatcher(collisionConfig);
|
||||||
|
broadphase = new btDbvtBroadphase();
|
||||||
|
solver = new btSequentialImpulseConstraintSolver;
|
||||||
|
dynamicsWorld = new btDiscreteDynamicsWorld(collisionDispatcher, broadphase, solver, collisionConfig);
|
||||||
|
dynamicsWorld->setGravity(btVector3(0.f, 0.f, -9.81f));
|
||||||
|
broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
|
||||||
|
gContactProcessedCallback = ContactProcessedCallback;
|
||||||
|
dynamicsWorld->setInternalTickCallback(PhysicsTickCallback, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameWorld::~GameWorld()
|
GameWorld::~GameWorld()
|
||||||
@ -100,23 +113,6 @@ GameWorld::~GameWorld()
|
|||||||
/// @todo delete other things.
|
/// @todo delete other things.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameWorld::load()
|
|
||||||
{
|
|
||||||
collisionConfig = new btDefaultCollisionConfiguration;
|
|
||||||
collisionDispatcher = new WorldCollisionDispatcher(collisionConfig);
|
|
||||||
broadphase = new btDbvtBroadphase();
|
|
||||||
solver = new btSequentialImpulseConstraintSolver;
|
|
||||||
dynamicsWorld = new btDiscreteDynamicsWorld(collisionDispatcher, broadphase, solver, collisionConfig);
|
|
||||||
dynamicsWorld->setGravity(btVector3(0.f, 0.f, -9.81f));
|
|
||||||
broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
|
|
||||||
gContactProcessedCallback = ContactProcessedCallback;
|
|
||||||
dynamicsWorld->setInternalTickCallback(PhysicsTickCallback, this);
|
|
||||||
|
|
||||||
gameData.load();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameWorld::defineItems(const std::string& name)
|
bool GameWorld::defineItems(const std::string& name)
|
||||||
{
|
{
|
||||||
auto i = gameData.ideLocations.find(name);
|
auto i = gameData.ideLocations.find(name);
|
||||||
@ -142,7 +138,7 @@ bool GameWorld::defineItems(const std::string& name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.error("Data", "Failed to load IDE " + path);
|
logger->error("Data", "Failed to load IDE " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -162,7 +158,7 @@ void GameWorld::runScript(const std::string &name)
|
|||||||
script = new ScriptMachine(this, f, opcodes);
|
script = new ScriptMachine(this, f, opcodes);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.error("World", "Failed to load SCM: " + name);
|
logger->error("World", "Failed to load SCM: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +175,7 @@ bool GameWorld::placeItems(const std::string& name)
|
|||||||
for( size_t i = 0; i < ipll.m_instances.size(); ++i) {
|
for( size_t i = 0; i < ipll.m_instances.size(); ++i) {
|
||||||
std::shared_ptr<InstanceData> inst = ipll.m_instances[i];
|
std::shared_ptr<InstanceData> inst = ipll.m_instances[i];
|
||||||
if(! createInstance(inst->id, inst->pos, inst->rot)) {
|
if(! createInstance(inst->id, inst->pos, inst->rot)) {
|
||||||
logger.error("World", "No object data for instance " + std::to_string(inst->id) + " in " + path);
|
logger->error("World", "No object data for instance " + std::to_string(inst->id) + " in " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +196,7 @@ bool GameWorld::placeItems(const std::string& name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.error("Data", "Failed to load IPL " + path);
|
logger->error("Data", "Failed to load IPL " + path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +234,7 @@ InstanceObject *GameWorld::createInstance(const uint16_t id, const glm::vec3& po
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( modelname.empty() ) {
|
if( modelname.empty() ) {
|
||||||
logger.warning("World", "Instance with missing model: " + std::to_string(id));
|
logger->warning("World", "Instance with missing model: " + std::to_string(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto instance = new InstanceObject(
|
auto instance = new InstanceObject(
|
||||||
@ -306,6 +302,7 @@ uint16_t GameWorld::findModelDefinition(const std::string model)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include <ai/PlayerController.hpp>
|
#include <ai/PlayerController.hpp>
|
||||||
|
#include <core/Logger.hpp>
|
||||||
CutsceneObject *GameWorld::createCutsceneObject(const uint16_t id, const glm::vec3 &pos, const glm::quat &rot)
|
CutsceneObject *GameWorld::createCutsceneObject(const uint16_t id, const glm::vec3 &pos, const glm::quat &rot)
|
||||||
{
|
{
|
||||||
std::string modelname;
|
std::string modelname;
|
||||||
@ -351,7 +348,7 @@ CutsceneObject *GameWorld::createCutsceneObject(const uint16_t id, const glm::ve
|
|||||||
|
|
||||||
// Ensure the relevant data is loaded.
|
// Ensure the relevant data is loaded.
|
||||||
if( modelname.empty() ) {
|
if( modelname.empty() ) {
|
||||||
logger.error("World", "Cutscene object " + std::to_string(id) + " has no model");
|
logger->error("World", "Cutscene object " + std::to_string(id) + " has no model");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +378,7 @@ VehicleObject *GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos,
|
|||||||
{
|
{
|
||||||
auto vti = findObjectType<VehicleData>(id);
|
auto vti = findObjectType<VehicleData>(id);
|
||||||
if( vti ) {
|
if( vti ) {
|
||||||
logger.info("World", "Creating Vehicle ID " + std::to_string(id) + " (" + vti->gameName + ")");
|
logger->info("World", "Creating Vehicle ID " + std::to_string(id) + " (" + vti->gameName + ")");
|
||||||
|
|
||||||
if(! vti->modelName.empty()) {
|
if(! vti->modelName.empty()) {
|
||||||
gameData.loadDFF(vti->modelName + ".dff");
|
gameData.loadDFF(vti->modelName + ".dff");
|
||||||
@ -399,7 +396,7 @@ VehicleObject *GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos,
|
|||||||
sec = gameData.vehicleColours[palit->second[set].second];
|
sec = gameData.vehicleColours[palit->second[set].second];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.warning("World", "No colour palette for vehicle " + vti->modelName);
|
logger->warning("World", "No colour palette for vehicle " + vti->modelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto wi = findObjectType<ObjectData>(vti->wheelModelID);
|
auto wi = findObjectType<ObjectData>(vti->wheelModelID);
|
||||||
@ -705,7 +702,7 @@ void GameWorld::loadCutscene(const std::string &name)
|
|||||||
|
|
||||||
if ( !cutsceneAudioLoaded )
|
if ( !cutsceneAudioLoaded )
|
||||||
{
|
{
|
||||||
logger.warning("Data", "Failed to load cutscene audio: " + name);
|
logger->warning("Data", "Failed to load cutscene audio: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -714,7 +711,7 @@ void GameWorld::loadCutscene(const std::string &name)
|
|||||||
}
|
}
|
||||||
state.currentCutscene = cutscene;
|
state.currentCutscene = cutscene;
|
||||||
state.currentCutscene->meta.name = name;
|
state.currentCutscene->meta.name = name;
|
||||||
logger.info("World", "Loaded cutscene: " + name);
|
logger->info("World", "Loaded cutscene: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameWorld::startCutscene()
|
void GameWorld::startCutscene()
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <objects/CutsceneObject.hpp>
|
#include <objects/CutsceneObject.hpp>
|
||||||
|
|
||||||
#include <render/GameShaders.hpp>
|
#include <render/GameShaders.hpp>
|
||||||
|
#include <core/Logger.hpp>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -65,11 +66,11 @@ std::vector<VertexP2> sspaceRect = {
|
|||||||
GeometryBuffer ssRectGeom;
|
GeometryBuffer ssRectGeom;
|
||||||
DrawBuffer ssRectDraw;
|
DrawBuffer ssRectDraw;
|
||||||
|
|
||||||
GameRenderer::GameRenderer(GameWorld* engine)
|
GameRenderer::GameRenderer(Logger* log, GameWorld* engine)
|
||||||
: engine(engine), renderer(new OpenGLRenderer), _renderAlpha(0.f),
|
: engine(engine), logger(log), renderer(new OpenGLRenderer), _renderAlpha(0.f),
|
||||||
map(engine, renderer), water(this), text(engine, this)
|
map(engine, renderer), water(this), text(engine, this)
|
||||||
{
|
{
|
||||||
engine->logger.info("Renderer", renderer->getIDString());
|
logger->info("Renderer", renderer->getIDString());
|
||||||
|
|
||||||
worldProg = renderer->createShader(
|
worldProg = renderer->createShader(
|
||||||
GameShaders::WorldObject::VertexShader,
|
GameShaders::WorldObject::VertexShader,
|
||||||
@ -504,7 +505,7 @@ void GameRenderer::renderVehicle(VehicleObject *vehicle)
|
|||||||
{
|
{
|
||||||
if(!vehicle->model)
|
if(!vehicle->model)
|
||||||
{
|
{
|
||||||
engine->logger.warning("Renderer", "Vehicle model " + vehicle->vehicle->modelName + " not loaded!");
|
logger->warning("Renderer", "Vehicle model " + vehicle->vehicle->modelName + " not loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 matrixModel = vehicle->getTimeAdjustedTransform( _renderAlpha );
|
glm::mat4 matrixModel = vehicle->getTimeAdjustedTransform( _renderAlpha );
|
||||||
@ -679,7 +680,7 @@ void GameRenderer::renderPickup(PickupObject *pickup)
|
|||||||
itemModel = weapons->resource->findFrame(odata->modelName + "_l0");
|
itemModel = weapons->resource->findFrame(odata->modelName + "_l0");
|
||||||
if ( ! itemModel )
|
if ( ! itemModel )
|
||||||
{
|
{
|
||||||
engine->logger.error("Renderer", "Weapon frame " + odata->modelName + " not in model");
|
logger->error("Renderer", "Weapon frame " + odata->modelName + " not in model");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -693,7 +694,7 @@ void GameRenderer::renderPickup(PickupObject *pickup)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
engine->logger.error("Renderer", "Pickup model " + odata->modelName + " not loaded");
|
logger->error("Renderer", "Pickup model " + odata->modelName + " not loaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,11 +763,11 @@ void GameRenderer::renderProjectile(ProjectileObject *projectile)
|
|||||||
renderFrame(weapons->resource, itemModel, modelMatrix * matrix, nullptr, 1.f);
|
renderFrame(weapons->resource, itemModel, modelMatrix * matrix, nullptr, 1.f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
engine->logger.error("Renderer", "Weapon frame " + odata->modelName + " not in model");
|
logger->error("Renderer", "Weapon frame " + odata->modelName + " not in model");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
engine->logger.error("Renderer", "Weapon.dff not loaded");
|
logger->error("Renderer", "Weapon.dff not loaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -806,11 +807,11 @@ void GameRenderer::renderItem(InventoryItem *item, const glm::mat4 &modelMatrix)
|
|||||||
renderFrame(weapons->resource, itemModel, modelMatrix * matrix, nullptr, 1.f);
|
renderFrame(weapons->resource, itemModel, modelMatrix * matrix, nullptr, 1.f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
engine->logger.error("Renderer", "Weapon frame " + odata->modelName + " not in model");
|
logger->error("Renderer", "Weapon frame " + odata->modelName + " not in model");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
engine->logger.error("Renderer", "Weapon model not loaded");
|
logger->error("Renderer", "Weapon model not loaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -841,7 +842,7 @@ void GameRenderer::renderGeometry(Model* model, size_t g, const glm::mat4& model
|
|||||||
tex = engine->gameData.findTexture(tC, tA);
|
tex = engine->gameData.findTexture(tC, tA);
|
||||||
if( ! tex )
|
if( ! tex )
|
||||||
{
|
{
|
||||||
//engine->logger.warning("Renderer", "Missing texture: " + tC + " " + tA);
|
//logger->warning("Renderer", "Missing texture: " + tC + " " + tA);
|
||||||
}
|
}
|
||||||
mat.textures[0].texture = tex;
|
mat.textures[0].texture = tex;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <data/Skeleton.hpp>
|
#include <data/Skeleton.hpp>
|
||||||
#include <objects/CutsceneObject.hpp>
|
#include <objects/CutsceneObject.hpp>
|
||||||
#include <objects/PickupObject.hpp>
|
#include <objects/PickupObject.hpp>
|
||||||
|
#include <core/Logger.hpp>
|
||||||
|
|
||||||
#include <glm/gtx/string_cast.hpp>
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ void game_create_vehicle_generator(const ScriptArguments& args)
|
|||||||
|
|
||||||
if(args[4].type == TString)
|
if(args[4].type == TString)
|
||||||
{
|
{
|
||||||
args.getVM()->getWorld()->logger.error("SCM", "Model names not supported for vehicle generator");
|
args.getVM()->getWorld()->logger->error("SCM", "Model names not supported for vehicle generator");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +382,7 @@ void game_create_garage(const ScriptArguments& args)
|
|||||||
int garageType = args[6].integer;
|
int garageType = args[6].integer;
|
||||||
auto garageHandle = args[7].handle;
|
auto garageHandle = args[7].handle;
|
||||||
|
|
||||||
args.getVM()->getWorld()->logger.warning("SCM", "Garages Unimplemented! " + std::to_string(garageType));
|
args.getVM()->getWorld()->logger->warning("SCM", "Garages Unimplemented! " + std::to_string(garageType));
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_disable_ped_paths(const ScriptArguments& args)
|
void game_disable_ped_paths(const ScriptArguments& args)
|
||||||
@ -438,7 +439,7 @@ bool game_model_loaded(const ScriptArguments& args)
|
|||||||
|
|
||||||
void game_restart_critical_mission(const ScriptArguments& args)
|
void game_restart_critical_mission(const ScriptArguments& args)
|
||||||
{
|
{
|
||||||
args.getVM()->getWorld()->logger.info("SCM", "Restarting Critical Mission");
|
args.getVM()->getWorld()->logger->info("SCM", "Restarting Critical Mission");
|
||||||
// Reset player state.
|
// Reset player state.
|
||||||
glm::vec3 position(args[0].real, args[1].real, args[2].real + 1.f);
|
glm::vec3 position(args[0].real, args[1].real, args[2].real + 1.f);
|
||||||
|
|
||||||
@ -553,7 +554,7 @@ void game_create_cutscene_object(const ScriptArguments& args)
|
|||||||
*args[1].handle = object;
|
*args[1].handle = object;
|
||||||
|
|
||||||
if( object == nullptr ) {
|
if( object == nullptr ) {
|
||||||
args.getVM()->getWorld()->logger.error("SCM", "Could not create cutscene object " + std::to_string(id));
|
args.getVM()->getWorld()->logger->error("SCM", "Could not create cutscene object " + std::to_string(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void game_set_cutscene_anim(const ScriptArguments& args)
|
void game_set_cutscene_anim(const ScriptArguments& args)
|
||||||
@ -566,7 +567,7 @@ void game_set_cutscene_anim(const ScriptArguments& args)
|
|||||||
object->animator->setAnimation(anim, false);
|
object->animator->setAnimation(anim, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
args.getVM()->getWorld()->logger.error("SCM", "Failed to load cutscene anim: " + animName);
|
args.getVM()->getWorld()->logger->error("SCM", "Failed to load cutscene anim: " + animName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void game_start_cutscene(const ScriptArguments& args)
|
void game_start_cutscene(const ScriptArguments& args)
|
||||||
@ -632,7 +633,7 @@ void game_set_head_animation(const ScriptArguments& args)
|
|||||||
object->animator->setAnimation(anim, false);
|
object->animator->setAnimation(anim, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
args.getVM()->getWorld()->logger.error("SCM", "Failed to load cutscene anim: " + animName);
|
args.getVM()->getWorld()->logger->error("SCM", "Failed to load cutscene anim: " + animName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,7 +722,7 @@ void game_load_audio(const ScriptArguments& args)
|
|||||||
{
|
{
|
||||||
if(! args.getVM()->getWorld()->gameData.loadAudioClip(name + ".mp3") )
|
if(! args.getVM()->getWorld()->gameData.loadAudioClip(name + ".mp3") )
|
||||||
{
|
{
|
||||||
args.getVM()->getWorld()->logger.error("SCM", "Failed to load audio: " + name);
|
args.getVM()->getWorld()->logger->error("SCM", "Failed to load audio: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -756,7 +757,7 @@ void game_play_music_id(const ScriptArguments& args)
|
|||||||
// TODO play anything other than Miscom.wav
|
// TODO play anything other than Miscom.wav
|
||||||
if(! gw->gameData.loadAudioClip( name + ".wav" ) )
|
if(! gw->gameData.loadAudioClip( name + ".wav" ) )
|
||||||
{
|
{
|
||||||
args.getVM()->getWorld()->logger.error("SCM", "Error loading audio " + name);
|
args.getVM()->getWorld()->logger->error("SCM", "Error loading audio " + name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ( args.getVM()->getWorld()->missionAudio )
|
else if ( args.getVM()->getWorld()->missionAudio )
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <objects/CutsceneObject.hpp>
|
#include <objects/CutsceneObject.hpp>
|
||||||
#include <objects/PickupObject.hpp>
|
#include <objects/PickupObject.hpp>
|
||||||
#include <objects/GenericPickup.hpp>
|
#include <objects/GenericPickup.hpp>
|
||||||
|
#include <core/Logger.hpp>
|
||||||
|
|
||||||
#include <glm/gtx/string_cast.hpp>
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
@ -430,7 +431,7 @@ bool game_vehicle_stopped(const ScriptArguments& args)
|
|||||||
void game_make_object_important(const ScriptArguments& args)
|
void game_make_object_important(const ScriptArguments& args)
|
||||||
{
|
{
|
||||||
auto inst = (InstanceObject*)(*args[0].handle);
|
auto inst = (InstanceObject*)(*args[0].handle);
|
||||||
args.getVM()->getWorld()->logger.warning("SCM", "Object pinning unimplemented!");
|
args.getVM()->getWorld()->logger->warning("SCM", "Object pinning unimplemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_character_in_area_on_foot(const ScriptArguments& args)
|
bool game_character_in_area_on_foot(const ScriptArguments& args)
|
||||||
@ -777,7 +778,7 @@ void game_create_object_world(const ScriptArguments& args)
|
|||||||
auto& modelname = args.getVM()->getFile()->getModels()[-id];
|
auto& modelname = args.getVM()->getFile()->getModels()[-id];
|
||||||
id = args.getVM()->getWorld()->findModelDefinition(modelname);
|
id = args.getVM()->getWorld()->findModelDefinition(modelname);
|
||||||
if( id == (uint16_t)-1 ) {
|
if( id == (uint16_t)-1 ) {
|
||||||
args.getVM()->getWorld()->logger.error("SCM", "Failed to find model " + modelname);
|
args.getVM()->getWorld()->logger->error("SCM", "Failed to find model " + modelname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,24 +65,32 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
|||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
glewInit();
|
glewInit();
|
||||||
|
|
||||||
engine = new GameWorld(gamepath);
|
log.addReciever(&logPrinter);
|
||||||
engine->logger.addReciever(&logPrinter);
|
log.info("Game", "Game directory: " + gamepath);
|
||||||
|
|
||||||
|
if(! GameData::isValidGameDirectory(gamepath) )
|
||||||
|
{
|
||||||
|
std::string envname(ENV_GAME_PATH_NAME);
|
||||||
|
throw std::runtime_error("Invalid game directory path, is " +envname+ " set?");
|
||||||
|
}
|
||||||
|
|
||||||
|
engine = new GameWorld(&log, gamepath);
|
||||||
|
|
||||||
// Initalize all the archives.
|
// Initalize all the archives.
|
||||||
engine->gameData.loadIMG("/models/gta3");
|
engine->gameData.loadIMG("/models/gta3");
|
||||||
//engine->gameData.loadIMG("/models/txd");
|
//engine->gameData.loadIMG("/models/txd");
|
||||||
engine->gameData.loadIMG("/anim/cuts");
|
engine->gameData.loadIMG("/anim/cuts");
|
||||||
|
|
||||||
|
engine->gameData.load();
|
||||||
|
|
||||||
// Initialize renderer
|
// Initialize renderer
|
||||||
renderer = new GameRenderer(engine);
|
renderer = new GameRenderer(&log, engine);
|
||||||
|
|
||||||
// Set up text renderer
|
// Set up text renderer
|
||||||
renderer->text.setFontTexture(0, "pager");
|
renderer->text.setFontTexture(0, "pager");
|
||||||
renderer->text.setFontTexture(1, "font1");
|
renderer->text.setFontTexture(1, "font1");
|
||||||
renderer->text.setFontTexture(2, "font2");
|
renderer->text.setFontTexture(2, "font2");
|
||||||
|
|
||||||
/// @TODO expand this here.
|
|
||||||
engine->load();
|
|
||||||
debug = new DebugDraw;
|
debug = new DebugDraw;
|
||||||
debug->setDebugMode(btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawConstraints | btIDebugDraw::DBG_DrawConstraintLimits);
|
debug->setDebugMode(btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawConstraints | btIDebugDraw::DBG_DrawConstraintLimits);
|
||||||
engine->dynamicsWorld->setDebugDrawer(debug);
|
engine->dynamicsWorld->setDebugDrawer(debug);
|
||||||
@ -113,7 +121,7 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
|||||||
|
|
||||||
StateManager::get().enter(loading);
|
StateManager::get().enter(loading);
|
||||||
|
|
||||||
engine->logger.info("Game", "Started");
|
log.info("Game", "Started");
|
||||||
}
|
}
|
||||||
|
|
||||||
RWGame::~RWGame()
|
RWGame::~RWGame()
|
||||||
@ -244,7 +252,7 @@ void RWGame::tick(float dt)
|
|||||||
}
|
}
|
||||||
catch( SCMException& ex ) {
|
catch( SCMException& ex ) {
|
||||||
std::cerr << ex.what() << std::endl;
|
std::cerr << ex.what() << std::endl;
|
||||||
engine->logger.error( "Script", ex.what() );
|
log.error( "Script", ex.what() );
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#ifndef _RWGAME_HPP_
|
#ifndef _RWGAME_HPP_
|
||||||
#define _RWGAME_HPP_
|
#define _RWGAME_HPP_
|
||||||
|
|
||||||
|
#include <core/Logger.hpp>
|
||||||
#include <engine/GameWorld.hpp>
|
#include <engine/GameWorld.hpp>
|
||||||
#include <render/GameRenderer.hpp>
|
#include <render/GameRenderer.hpp>
|
||||||
#include "game.hpp"
|
#include "game.hpp"
|
||||||
@ -8,6 +10,7 @@
|
|||||||
|
|
||||||
class RWGame
|
class RWGame
|
||||||
{
|
{
|
||||||
|
Logger log;
|
||||||
GameWorld* engine;
|
GameWorld* engine;
|
||||||
// must be allocated after Logger setup.
|
// must be allocated after Logger setup.
|
||||||
GameRenderer* renderer;
|
GameRenderer* renderer;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
#include <engine/GameWorld.hpp>
|
#include <engine/GameWorld.hpp>
|
||||||
|
#include <core/Logger.hpp>
|
||||||
#include <glm/gtx/string_cast.hpp>
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
#define ENV_GAME_PATH_NAME ("OPENRW_GAME_PATH")
|
#define ENV_GAME_PATH_NAME ("OPENRW_GAME_PATH")
|
||||||
@ -39,11 +40,12 @@ public:
|
|||||||
wnd.create(sf::VideoMode(640, 360), "Testing");
|
wnd.create(sf::VideoMode(640, 360), "Testing");
|
||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
glewInit();
|
glewInit();
|
||||||
e = new GameWorld(getGamePath());
|
Logger log;
|
||||||
|
e = new GameWorld(&log, getGamePath());
|
||||||
|
|
||||||
e->gameData.loadIMG("/models/gta3");
|
e->gameData.loadIMG("/models/gta3");
|
||||||
e->gameData.loadIMG("/anim/cuts");
|
e->gameData.loadIMG("/anim/cuts");
|
||||||
e->load();
|
e->gameData.load();
|
||||||
for(std::map<std::string, std::string>::iterator it = e->gameData.ideLocations.begin();
|
for(std::map<std::string, std::string>::iterator it = e->gameData.ideLocations.begin();
|
||||||
it != e->gameData.ideLocations.end();
|
it != e->gameData.ideLocations.end();
|
||||||
++it) {
|
++it) {
|
||||||
|
Loading…
Reference in New Issue
Block a user