Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Fixes for Windows #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ogre/EmberOgreFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ DataStreamPtr FileSystemArchive::open(const String& filename, bool readOnly) con

// Always open in binary mode
auto* origStream = OGRE_NEW_T(std::ifstream, MEMCATEGORY_GENERAL)();
origStream->open(full_path.c_str(), std::ios::in | std::ios::binary);
origStream->open(full_path.string().c_str(), std::ios::in | std::ios::binary);

// Should check ensure open succeeded, in case fail for some reason.
if (origStream->fail()) {
Expand Down
12 changes: 12 additions & 0 deletions src/components/ogre/OgrePluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ OgrePluginLoader::OgrePluginLoader() {
//on windows we'll bundle the dll files in the same directory as the executable
mPluginDirs.push_back(".");
mPluginExtension = ".dll";
mPluginDirs.push_back("bin");// Prefix + "bin", or alternatives:
mPluginDirs.push_back("lib64");
mPluginDirs.push_back("lib");
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX

//If any prefix is set (for example for AppImage builds), check for the plugins in directories relative to the prefix first.
Expand Down Expand Up @@ -143,6 +146,12 @@ bool OgrePluginLoader::loadDynPlugin(const std::string& pluginName) {
//#else
pluginPath = dir + "/" + pluginName + mPluginExtension;
//#endif
if (!std::ifstream(pluginPath).good()) {
pluginPath = pluginName + mPluginExtension;// if absent, use plugin in current directory
}
if (!std::ifstream(pluginPath).good()) {
pluginPath = dir + "/" + pluginName + "_d" + mPluginExtension;
}
if (std::ifstream(pluginPath).good()) {
S_LOG_INFO("Trying to load the plugin '" << pluginPath << "'.");
try {
Expand All @@ -151,6 +160,9 @@ bool OgrePluginLoader::loadDynPlugin(const std::string& pluginName) {
} catch (...) {
}
}
else{
printf("\nUnable to load:%s", pluginPath.c_str());
}
}
S_LOG_FAILURE("Failed to load the plugin '" << pluginName << "'!");
#else
Expand Down
23 changes: 22 additions & 1 deletion src/components/ogre/OgreSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,37 @@ void OgreSetup::createOgreSystem() {
mPluginLoader.loadPlugin("Codec_FreeImage");
mPluginLoader.loadPlugin("Plugin_ParticleFX");
mPluginLoader.loadPlugin("RenderSystem_GL3Plus"); //We'll use OpenGL on Windows too, to make it easier to develop
mPluginLoader.loadPlugin("RenderSystem_Direct3D11");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you getting errors without these? Normally Ember should run without having to load the DirectX-plugins.

mPluginLoader.loadPlugin("RenderSystem_Direct3D10");
mPluginLoader.loadPlugin("RenderSystem_Direct3D9");
#endif

auto renderSystem = mRoot->getAvailableRenderers().front();
//auto renderSystem = mRoot->getAvailableRenderers().front();
const auto& renderers = mRoot->getAvailableRenderers();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to support both DirectX and OpenGL, but in the end it just became a huge hassle since it meant I had to provide shaders for both GLSL and HLSL. So in the end we decided on only supporting OpenGL.
In the long run we want to move to a PBS based rendering flow, in which we hopefully won't need to write any shaders. And in the even longer run we want to see Vulkan support in Ogre, making away with both DirectX and OpenGL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn’t come here for a long time. Yes, I wanted to make the game work on DirectX. But as I understand it, this is not worth doing. You can apply changes without this code.

if (renderers.size() == 0){
S_LOG_WARNING("\nFatal error: Empty renderer list!\n");
exit(1);
}
const char* envRenderName = getenv("OGRE_RENDER_SYSTEM");
if (envRenderName!= NULL)
{
auto renderSystem = mRoot->getRenderSystemByName(envRenderName);
if (renderSystem == NULL){
S_LOG_WARNING("\nmRoot->getRenderSystemByName() return NULL!Render name:\n");
S_LOG_WARNING(envRenderName);
renderSystem = renderers.front();
}
mRoot->setRenderSystem(renderSystem);
}else{
auto renderSystem = renderers.front();
try {
//Set the default resolution to 1280 x 720 unless overridden by the user.
renderSystem->setConfigOption("Video Mode", "1280 x 720"); //OGRE stores the value with two spaces after "x".
} catch (const std::exception& ex) {
S_LOG_WARNING("Could not set default resolution." << ex);
}
mRoot->setRenderSystem(renderSystem);
}

if (chdir(configSrv.getEmberDataDirectory().generic_string().c_str())) {
S_LOG_WARNING("Failed to change to the data directory '" << configSrv.getEmberDataDirectory().string() << "'.");
Expand Down
2 changes: 1 addition & 1 deletion src/components/ogre/model/ModelDefinitionAtlasComposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ std::string ModelDefinitionAtlasComposer::composeToFile(Model* model, const std:


auto fileName = dir / (typeName + ".xml");
std::fstream exportFile(fileName.c_str(), std::fstream::out);
std::fstream exportFile(fileName.string().c_str(), std::fstream::out);

S_LOG_INFO("Creating atlas type " << fileName.string());
composeToStream(exportFile, model, typeName, parentTypeName, scale, collisionType);
Expand Down
8 changes: 7 additions & 1 deletion src/components/ogre/widgets/IngameChatWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,13 @@ void IngameChatWidget::Label::objectRendering(const Ogre::Camera* camera) {
auto model = Model::ModelRepresentation::getModelForEntity(*mEntity);
if (model) {

Ogre::Node* node = model->getNodeProvider()->getNode();
auto provider = model->getNodeProvider();
if (provider == nullptr) // avoid "Pick up" person bug with null provider
{
S_LOG_WARNING("model->getNodeProvider() returned NULL!");
return;
}
Ogre::Node* node = provider->getNode();
Ogre::Vector3 diff = node->_getDerivedPosition() - camera->getDerivedPosition();

//remove the window if it's either too far away
Expand Down
2 changes: 1 addition & 1 deletion src/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Application::Application(std::string prefix, std::string homeDir, ConfigMap conf
auto userConfigFilePath = mConfigService.getHomeDirectory(BaseDirType_CONFIG) / "ember.conf";
if (!boost::filesystem::exists(userConfigFilePath)) {
//Create empty template file.
std::ofstream outstream(userConfigFilePath.c_str());
std::ofstream outstream(userConfigFilePath.string().c_str());
outstream << "#This is a user specific settings file. Settings here override those found in the application installed ember.conf file." << std::endl << std::flush;
S_LOG_INFO("Created empty user specific settings file at '" << userConfigFilePath.string() << "'.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/config/ConfigService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ bool ConfigService::loadSavedConfig(const std::string& filename, const StringCon
S_LOG_INFO ("Loading shared config file from " << path.string() << ".");
bool success = mGlobalConfig->readFromFile(path.string(), varconf::GLOBAL);
auto userConfigPath = getHomeDirectory(BaseDirType_CONFIG) / filename;
std::ifstream file(userConfigPath.c_str());
std::ifstream file(userConfigPath.string().c_str());
if (!file.fail()) {
S_LOG_INFO ("Loading user config file from " << userConfigPath.string() << ".");
try {
Expand Down
10 changes: 5 additions & 5 deletions src/services/server/LoggedInState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ LoggedInState::~LoggedInState() {
void LoggedInState::checkTransfer() {
TransferInfoStringSerializer serializer;
auto teleportFilePath = EmberServices::getSingleton().getConfigService().getHomeDirectory(BaseDirType_DATA) / "teleports";
std::fstream teleportsFile(teleportFilePath.c_str(), std::ios_base::in);
std::fstream teleportsFile(teleportFilePath.string().c_str(), std::ios_base::in);
TransferInfoStringSerializer::TransferInfoStore transferObjects;
if (teleportsFile.good()) {
serializer.deserialize(transferObjects, teleportsFile);
Expand Down Expand Up @@ -178,7 +178,7 @@ void LoggedInState::gotAvatarSuccess(Eris::Avatar* avatar) {
void LoggedInState::removeTransferInfo(const AvatarTransferInfo& transferInfo) {
TransferInfoStringSerializer serializer;
auto teleportFilePath = EmberServices::getSingleton().getConfigService().getHomeDirectory(BaseDirType_DATA) / "teleports";
std::fstream teleportsFile(teleportFilePath.c_str(), std::ios_base::in);
std::fstream teleportsFile(teleportFilePath.string().c_str(), std::ios_base::in);
TransferInfoStringSerializer::TransferInfoStore transferObjects;
if (teleportsFile.good()) {
serializer.deserialize(transferObjects, teleportsFile);
Expand All @@ -196,7 +196,7 @@ void LoggedInState::removeTransferInfo(const AvatarTransferInfo& transferInfo) {
}
}

std::fstream teleportsOutputFile(teleportFilePath.c_str(), std::ios_base::out);
std::fstream teleportsOutputFile(teleportFilePath.string().c_str(), std::ios_base::out);
if (teleportsOutputFile.good()) {
serializer.serialize(transferObjects, teleportsOutputFile);
} else {
Expand All @@ -209,7 +209,7 @@ void LoggedInState::removeTransferInfo(const AvatarTransferInfo& transferInfo) {
void LoggedInState::avatar_transferRequest(const Eris::TransferInfo& transferInfo, const Eris::Avatar* avatar) {
TransferInfoStringSerializer serializer;
auto teleportFilePath = EmberServices::getSingleton().getConfigService().getHomeDirectory(BaseDirType_DATA) / "teleports";
std::fstream teleportsFile(teleportFilePath.c_str(), std::ios_base::in);
std::fstream teleportsFile(teleportFilePath.string().c_str(), std::ios_base::in);
TransferInfoStringSerializer::TransferInfoStore transferObjects;
if (teleportsFile.good()) {
serializer.deserialize(transferObjects, teleportsFile);
Expand All @@ -218,7 +218,7 @@ void LoggedInState::avatar_transferRequest(const Eris::TransferInfo& transferInf
AvatarTransferInfo avatarTransferInfo(avatar->getEntity()->getName(), WFMath::TimeStamp::now(), transferInfo);
transferObjects.push_back(avatarTransferInfo);

std::fstream teleportsOutputFile(teleportFilePath.c_str(), std::ios_base::out);
std::fstream teleportsOutputFile(teleportFilePath.string().c_str(), std::ios_base::out);
if (teleportsOutputFile.good()) {
serializer.serialize(transferObjects, teleportsOutputFile);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/services/serversettings/ServerSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void ServerSettings::writeToDisk() {
void ServerSettings::readFromDisk() {
auto filePath = getFullConfigFilePath();

std::ifstream file(filePath.c_str());
std::ifstream file(filePath.string().c_str());

// If an existing server settings is present, then read it in.
if (!file.fail()) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/sound/SoundService.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <list>
#include <unordered_map>

#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(WIN32)
#include <alc.h>
#endif
namespace Ember {
Expand Down Expand Up @@ -170,7 +170,7 @@ class SoundService : public Service, public ConsoleObject {
*/
std::unordered_map<std::string, std::unique_ptr<BaseSoundSample>> mBaseSamples;

#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(WIN32)
/**
* @brief The main OpenAL context.
*/
Expand Down