diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2a6275cd35..6071530de0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -393,6 +393,8 @@ add_files(
slope_type.h
smallmap_gui.cpp
smallmap_gui.h
+ social_integration.cpp
+ social_integration.h
sortlist_type.h
sound.cpp
sound_func.h
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 9c72b8fe3e..d47e0cdc5a 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -2141,6 +2141,7 @@ DEF_CONSOLE_CMD(ConListDirs)
{ SAVE_DIR, "save", true },
{ AUTOSAVE_DIR, "autosave", true },
{ SCREENSHOT_DIR, "screenshot", true },
+ { SOCIAL_INTEGRATION_DIR, "social_integration", true },
};
if (argc != 2) {
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 05aa8718b7..26792fa596 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -52,6 +52,7 @@ static const char * const _subdirs[] = {
"game" PATHSEP,
"game" PATHSEP "library" PATHSEP,
"screenshot" PATHSEP,
+ "social_integration" PATHSEP,
};
static_assert(lengthof(_subdirs) == NUM_SUBDIRS);
@@ -1054,7 +1055,7 @@ void DeterminePaths(const char *exe, bool only_local_path)
Debug(misc, 1, "{} found as personal directory", _personal_dir);
static const Subdirectory default_subdirs[] = {
- SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SCREENSHOT_DIR
+ SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SCREENSHOT_DIR, SOCIAL_INTEGRATION_DIR
};
for (uint i = 0; i < lengthof(default_subdirs); i++) {
@@ -1068,7 +1069,7 @@ void DeterminePaths(const char *exe, bool only_local_path)
FillValidSearchPaths(only_local_path);
/* Create the directory for each of the types of content */
- const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR };
+ const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SOCIAL_INTEGRATION_DIR };
for (uint i = 0; i < lengthof(dirs); i++) {
FioCreateDirectory(FioGetDirectory(SP_AUTODOWNLOAD_DIR, dirs[i]));
}
diff --git a/src/fileio_type.h b/src/fileio_type.h
index 66d502d88a..c871c1c14b 100644
--- a/src/fileio_type.h
+++ b/src/fileio_type.h
@@ -121,6 +121,7 @@ enum Subdirectory {
GAME_DIR, ///< Subdirectory for all game scripts
GAME_LIBRARY_DIR, ///< Subdirectory for all GS libraries
SCREENSHOT_DIR, ///< Subdirectory for all screenshots
+ SOCIAL_INTEGRATION_DIR, ///< Subdirectory for all social integration plugins
NUM_SUBDIRS, ///< Number of subdirectories
NO_DIRECTORY, ///< A path without any base directory
};
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 50521ab663..be2d05027a 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -75,6 +75,7 @@
#include "timer/timer_game_economy.h"
#include "timer/timer_game_realtime.h"
#include "timer/timer_game_tick.h"
+#include "social_integration.h"
#include "linkgraph/linkgraphschedule.h"
@@ -752,6 +753,7 @@ int openttd_main(int argc, char *argv[])
/* The video driver is now selected, now initialise GUI zoom */
AdjustGUIZoom(false);
+ SocialIntegration::Initialize();
NetworkStartUp(); // initialize network-core
if (!HandleBootstrap()) {
diff --git a/src/social_integration.cpp b/src/social_integration.cpp
new file mode 100644
index 0000000000..4dd63a1e87
--- /dev/null
+++ b/src/social_integration.cpp
@@ -0,0 +1,50 @@
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see .
+ */
+
+/** @file social_integration.cpp Base implementation of social integration support. */
+
+#include "stdafx.h"
+
+#include "social_integration.h"
+#include "3rdparty/openttd_social_integration_api/openttd_social_integration_api.h"
+
+#include "debug.h"
+#include "fileio_func.h"
+#include "library_loader.h"
+#include "rev.h"
+#include "string_func.h"
+
+#include "safeguards.h"
+
+/** Helper for scanning for files with SocialIntegration as extension */
+class SocialIntegrationFileScanner : FileScanner {
+public:
+ void Scan()
+ {
+#ifdef _WIN32
+ std::string extension = "-social.dll";
+#elif defined(__APPLE__)
+ std::string extension = "-social.dylib";
+#else
+ std::string extension = "-social.so";
+#endif
+
+ this->FileScanner::Scan(extension.c_str(), SOCIAL_INTEGRATION_DIR, false);
+ }
+
+ bool AddFile(const std::string &filename, size_t basepath_length, const std::string &) override
+ {
+ std::string basepath = filename.substr(basepath_length);
+ Debug(misc, 1, "[Social Integration: {}] Loading ...", basepath);
+ }
+};
+
+void SocialIntegration::Initialize()
+{
+ SocialIntegrationFileScanner fs;
+ fs.Scan();
+}
diff --git a/src/social_integration.h b/src/social_integration.h
new file mode 100644
index 0000000000..c03e90d56e
--- /dev/null
+++ b/src/social_integration.h
@@ -0,0 +1,21 @@
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see .
+ */
+
+/** @file social_integration.h Interface definitions for game to report/respond to social integration. */
+
+#ifndef SOCIAL_INTEGRATION_H
+#define SOCIAL_INTEGRATION_H
+
+class SocialIntegration {
+public:
+ /**
+ * Initialize the social integration system, loading any social integration plugins that are available.
+ */
+ static void Initialize();
+};
+
+#endif /* SOCIAL_INTEGRATION_H */