Commit 09bcf351 authored by NTAuthority's avatar NTAuthority

some autoformatting stuff

parent 869bcae5
Pipeline #44 skipped
......@@ -6,7 +6,7 @@ namespace krt
{
class FileLoader
{
public:
public:
// loads an IDE/IPL file without assigning to any universe
inline static void LoadIDEFile(const std::string& absPath)
{
......@@ -24,7 +24,7 @@ public:
static void ScanIMG(const vfs::DevicePtr& device, const std::string& pathPrefix, const GameUniversePtr& universe);
private:
private:
// static class only
FileLoader();
};
......
......@@ -2,13 +2,13 @@
// Game things go here!
#define GAME_NUM_STREAMING_CHANNELS 4
#define GAME_NUM_STREAMING_CHANNELS 4
#include "vfs\Device.h"
#include "ModelInfo.h"
#include "Streaming.h"
#include "TexDict.h"
#include "ModelInfo.h"
#include "World.h"
#include "Console.Commands.h"
......@@ -19,43 +19,44 @@ namespace krt
class Game
{
friend struct Entity;
public:
Game( void );
~Game( void );
friend struct Entity;
std::string GetGamePath( std::string relPath );
public:
Game(void);
~Game(void);
inline streaming::StreamMan& GetStreaming( void ) { return this->streaming; }
inline TextureManager& GetTextureManager( void ) { return this->texManager; }
inline ModelManager& GetModelManager( void ) { return this->modelManager; }
std::string GetGamePath(std::string relPath);
inline World* GetWorld( void ) { return &theWorld; }
inline streaming::StreamMan& GetStreaming(void) { return this->streaming; }
inline TextureManager& GetTextureManager(void) { return this->texManager; }
inline ModelManager& GetModelManager(void) { return this->modelManager; }
std::string GetDevicePathPrefix( void ) { return "gta3:/"; }
inline World* GetWorld(void) { return &theWorld; }
std::string GetDevicePathPrefix(void) { return "gta3:/"; }
GameUniversePtr AddUniverse(const GameConfiguration& configuration);
GameUniversePtr GetUniverse(const std::string& name);
private:
std::string gameDir;
private:
std::string gameDir;
streaming::StreamMan streaming;
streaming::StreamMan streaming;
TextureManager texManager;
ModelManager modelManager;
TextureManager texManager;
ModelManager modelManager;
World theWorld;
World theWorld;
NestedList <Entity> activeEntities;
NestedList<Entity> activeEntities;
std::vector<GameUniversePtr> universes;
};
extern Game *theGame;
extern Game* theGame;
template<>
template <>
struct ConsoleArgumentType<GameUniversePtr>
{
static bool Parse(const std::string& input, GameUniversePtr* out)
......@@ -64,5 +65,4 @@ struct ConsoleArgumentType<GameUniversePtr>
return true;
}
};
};
\ No newline at end of file
......@@ -24,7 +24,7 @@ struct GameConfiguration
// a game universe represents a single game's asset configuration
class GameUniverse
{
public:
public:
GameUniverse(const GameConfiguration& configuration);
~GameUniverse();
......@@ -47,7 +47,7 @@ public:
inline void RegisterModelIndexMapping(streaming::ident_t from, streaming::ident_t to)
{
m_modelIndexMapping.insert({ from, to });
m_modelIndexMapping.insert({from, to});
}
inline streaming::ident_t GetModelIndexMapping(streaming::ident_t localId)
......@@ -59,12 +59,12 @@ public:
return it->second;
}
private:
private:
void AddImage(const std::string& relativePath);
void LoadConfiguration(const std::string& relativePath);
private:
private:
struct ImageFile
{
vfs::DevicePtr cdimage;
......@@ -74,7 +74,7 @@ private:
std::string primaryMount;
};
private:
private:
GameConfiguration m_configuration;
std::vector<ImageFile> m_imageFiles;
......
This diff is collapsed.
......@@ -2,60 +2,60 @@
#include "Game.h"
#include <cstdio>
#include <iostream>
#include <fstream>
#include <iostream>
#include "Console.h"
#include "Console.CommandHelpers.h"
#include "Console.h"
#include "CdImageDevice.h"
#include "vfs/Manager.h"
#include <src/rwgta.h>
#pragma warning(disable:4996)
#pragma warning(disable : 4996)
namespace krt
{
Game *theGame = NULL;
Game* theGame = NULL;
Game::Game( void ) : streaming( GAME_NUM_STREAMING_CHANNELS ), texManager( streaming ), modelManager( streaming, texManager )
Game::Game(void) : streaming(GAME_NUM_STREAMING_CHANNELS), texManager(streaming), modelManager(streaming, texManager)
{
assert( theGame == NULL );
assert(theGame == NULL);
// We can only have one game :)
theGame = this;
// We can only have one game :)
theGame = this;
// Initialize RW.
rw::platform = rw::PLATFORM_D3D9;
rw::loadTextures = false;
// Initialize RW.
rw::platform = rw::PLATFORM_D3D9;
rw::loadTextures = false;
gta::attachPlugins();
gta::attachPlugins();
// Detect where the game is installed.
// For now, I guess we do it manually.
// Detect where the game is installed.
// For now, I guess we do it manually.
const char *computerName = getenv( "COMPUTERNAME" );
const char* computerName = getenv("COMPUTERNAME");
if ( stricmp( computerName, "FALLARBOR" ) == 0 )
{
// Bas' thing.
//this->gameDir = "S:\\Games\\CleanSA\\GTA San Andreas\\";
if (stricmp(computerName, "FALLARBOR") == 0)
{
// Bas' thing.
//this->gameDir = "S:\\Games\\CleanSA\\GTA San Andreas\\";
this->gameDir = "S:\\Games\\Steam\\steamapps\\common\\Grand Theft Auto 3\\";
}
else if ( stricmp( computerName, "DESKTOP" ) == 0 )
{
// Martin's thing.
this->gameDir = "D:\\gtaiso\\unpack\\gta3\\";
}
else
{
// Add your own, meow.
}
// Set up game related things.
LIST_CLEAR( this->activeEntities.root );
}
else if (stricmp(computerName, "DESKTOP") == 0)
{
// Martin's thing.
this->gameDir = "D:\\gtaiso\\unpack\\gta3\\";
}
else
{
// Add your own, meow.
}
// Set up game related things.
LIST_CLEAR(this->activeEntities.root);
// Create the game universe.
GameConfiguration configuration;
......@@ -70,25 +70,25 @@ Game::Game( void ) : streaming( GAME_NUM_STREAMING_CHANNELS ), texManager( strea
GameUniversePtr universe = AddUniverse(configuration);
universe->Load();
// Do a test that loads all game models.
modelManager.LoadAllModels();
// Do a test that loads all game models.
modelManager.LoadAllModels();
}
Game::~Game( void )
Game::~Game(void)
{
// Delete all our entities.
{
while ( !LIST_EMPTY( this->activeEntities.root ) )
{
Entity *entity = LIST_GETITEM( Entity, this->activeEntities.root.next, gameNode );
// It will remove itself from the list.
delete entity;
}
}
// There is no more game.
theGame = NULL;
// Delete all our entities.
{
while (!LIST_EMPTY(this->activeEntities.root))
{
Entity* entity = LIST_GETITEM(Entity, this->activeEntities.root.next, gameNode);
// It will remove itself from the list.
delete entity;
}
}
// There is no more game.
theGame = NULL;
}
GameUniversePtr Game::AddUniverse(const GameConfiguration& configuration)
......@@ -112,11 +112,10 @@ GameUniversePtr Game::GetUniverse(const std::string& name)
return nullptr;
}
std::string Game::GetGamePath( std::string relPath )
std::string Game::GetGamePath(std::string relPath)
{
// Get some sort of relative directory from the game directory.
// Note that we want the gameDir to have a slash at the end!
return ( this->gameDir + relPath );
// Get some sort of relative directory from the game directory.
// Note that we want the gameDir to have a slash at the end!
return (this->gameDir + relPath);
}
};
\ No newline at end of file
......@@ -11,18 +11,15 @@
namespace krt
{
ConsoleCommand loadIdeCommand("load_ide", [] (const GameUniversePtr& universe, const std::string& idePath)
{
ConsoleCommand loadIdeCommand("load_ide", [](const GameUniversePtr& universe, const std::string& idePath) {
FileLoader::LoadIDEFile(idePath, universe);
});
ConsoleCommand loadIplCommand("load_ipl", [] (const GameUniversePtr& universe, const std::string& iplPath)
{
ConsoleCommand loadIplCommand("load_ipl", [](const GameUniversePtr& universe, const std::string& iplPath) {
FileLoader::LoadIPLFile(iplPath, universe);
});
ConsoleCommand loadImgCommand("load_cdimage", [] (const GameUniversePtr& universe, const std::string& mainMount)
{
ConsoleCommand loadImgCommand("load_cdimage", [](const GameUniversePtr& universe, const std::string& mainMount) {
FileLoader::ScanIMG(vfs::GetDevice(mainMount), mainMount, universe);
});
}
\ No newline at end of file
......@@ -3,20 +3,19 @@
#include <Game.h>
#include <GameUniverse.h>
#include <vfs/RelativeDevice.h>
#include <vfs/Manager.h>
#include <vfs/RelativeDevice.h>
#include <CdImageDevice.h>
#include <Console.h>
#include <Console.CommandHelpers.h>
#include <Console.h>
namespace krt
{
GameUniverse::GameUniverse(const GameConfiguration& configuration)
: m_configuration(configuration)
: m_configuration(configuration)
{
}
GameUniverse::~GameUniverse()
......@@ -32,7 +31,7 @@ void GameUniverse::Load()
// mount a relative device pointing at the root
vfs::DevicePtr device = std::make_shared<vfs::RelativeDevice>(m_configuration.rootPath);
vfs::Mount(device, GetMountPoint());
// enqueue pre-cached IMG files
for (const auto& imageFile : m_configuration.imageFiles)
{
......@@ -55,29 +54,26 @@ void GameUniverse::Load()
void GameUniverse::LoadConfiguration(const std::string& relativePath)
{
vfs::StreamPtr stream = vfs::OpenRead(GetMountPoint() + relativePath);
vfs::StreamPtr stream = vfs::OpenRead(GetMountPoint() + relativePath);
std::vector<uint8_t> string = stream->ReadToEnd();
console::Context localConsole;
// add commands to the context
ConsoleCommand ideLoadCmd(&localConsole, "IDE",
[&] (const std::string& fileName)
{
localConsole.ExecuteSingleCommand(ProgramArguments{ "load_ide", m_configuration.gameName, GetMountPoint() + fileName });
});
[&](const std::string& fileName) {
localConsole.ExecuteSingleCommand(ProgramArguments{"load_ide", m_configuration.gameName, GetMountPoint() + fileName});
});
ConsoleCommand iplLoadCmd(&localConsole, "IPL",
[&] (const std::string& fileName)
{
localConsole.ExecuteSingleCommand(ProgramArguments{ "load_ipl", m_configuration.gameName, GetMountPoint() + fileName });
});
[&](const std::string& fileName) {
localConsole.ExecuteSingleCommand(ProgramArguments{"load_ipl", m_configuration.gameName, GetMountPoint() + fileName});
});
ConsoleCommand imgMountCmd(&localConsole, "IMG",
[&] (const std::string& path)
{
localConsole.ExecuteSingleCommand(ProgramArguments{ "add_cdimage", m_configuration.gameName, path });
});
[&](const std::string& path) {
localConsole.ExecuteSingleCommand(ProgramArguments{"add_cdimage", m_configuration.gameName, path});
});
// run the configuration file
localConsole.AddToBuffer(std::string(reinterpret_cast<char*>(string.data()), string.size()));
......@@ -101,14 +97,14 @@ void GameUniverse::AddImage(const std::string& relativePath)
// and add an entry to the list
ImageFile entry;
entry.cdimage = cdImage;
entry.cdimage = cdImage;
entry.relativeMount = relative;
entry.primaryMount = mountPath;
entry.primaryMount = mountPath;
m_imageFiles.push_back(entry);
// pass the image file to be loaded immediately
console::ExecuteSingleCommand(ProgramArguments{ "load_cdimage", m_configuration.gameName, entry.primaryMount });
console::ExecuteSingleCommand(ProgramArguments{"load_cdimage", m_configuration.gameName, entry.primaryMount});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment