| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ Set(SOURCEPYTHON_LOADER_FILES | |||
| 30 | 30 | # ------------------------------------------------------------------ | |
| 31 | 31 | Set(SOURCEPYTHON_UTIL_HEADERS | |
| 32 | 32 | core/utility/sp_util.h | |
| 33 | + core/utility/shared_utils.h | ||
| 33 | 34 | core/utility/call_python.h | |
| 34 | 35 | core/utility/wrap_macros.h | |
| 35 | 36 | core/utility/ipythongenerator.h | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,8 @@ | |||
| 32 | 32 | #include "eiface.h" | |
| 33 | 33 | #include "strtools.h" | |
| 34 | 34 | ||
| 35 | + #include "utility/shared_utils.h" | ||
| 36 | + | ||
| 35 | 37 | //--------------------------------------------------------------------------------- | |
| 36 | 38 | // External variables we need. | |
| 37 | 39 | //--------------------------------------------------------------------------------- | |
@@ -53,6 +55,7 @@ bool CGamePaths::Initialize( void ) | |||
| 53 | 55 | } | |
| 54 | 56 | ||
| 55 | 57 | engine->GetGameDir(m_szGameDir, MAX_GAME_PATH); | |
| 58 | + GenerateSymlink(m_szGameDir); | ||
| 56 | 59 | V_snprintf(m_szSPDir, MAX_GAME_PATH, "%s%s", m_szGameDir, sp_ADDON_BASE); | |
| 57 | 60 | ||
| 58 | 61 | // Fix slashes | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,89 @@ | |||
| 1 | + /** | ||
| 2 | + * ============================================================================= | ||
| 3 | + * Source Python | ||
| 4 | + * Copyright (C) 2015 Source Python Development Team. All rights reserved. | ||
| 5 | + * ============================================================================= | ||
| 6 | + * | ||
| 7 | + * This program is free software; you can redistribute it and/or modify it under | ||
| 8 | + * the terms of the GNU General Public License, version 3.0, as published by the | ||
| 9 | + * Free Software Foundation. | ||
| 10 | + * | ||
| 11 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 13 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 14 | + * details. | ||
| 15 | + * | ||
| 16 | + * You should have received a copy of the GNU General Public License along with | ||
| 17 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | + * | ||
| 19 | + * As a special exception, the Source Python Team gives you permission | ||
| 20 | + * to link the code of this program (as well as its derivative works) to | ||
| 21 | + * "Half-Life 2," the "Source Engine," and any Game MODs that run on software | ||
| 22 | + * by the Valve Corporation. You must obey the GNU General Public License in | ||
| 23 | + * all respects for all other code used. Additionally, the Source.Python | ||
| 24 | + * Development Team grants this exception to all derivative works. | ||
| 25 | + */ | ||
| 26 | + #ifndef _SHARED_UTILS_H | ||
| 27 | + #define _SHARED_UTILS_H | ||
| 28 | + | ||
| 29 | + //----------------------------------------------------------------------------- | ||
| 30 | + // Includes | ||
| 31 | + //----------------------------------------------------------------------------- | ||
| 32 | + #include "strtools.h" | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + //----------------------------------------------------------------------------- | ||
| 36 | + // Generates a symlink without the colon symbol (":"). | ||
| 37 | + // | ||
| 38 | + // Thanks to Hedgehog for this! | ||
| 39 | + // http://forums.sourcepython.com/showthread.php?581-Server-crash-on-SP-loading&p=2967&viewfull=1#post2967 | ||
| 40 | + //----------------------------------------------------------------------------- | ||
| 41 | + inline void _GenerateSymlink(char* path) | ||
| 42 | + { | ||
| 43 | + #if __linux__ | ||
| 44 | + int pathLen = V_strlen(path) + 1; | ||
| 45 | + char symlinkOrigin[pathLen]; | ||
| 46 | + char symlinkPath[pathLen]; | ||
| 47 | + | ||
| 48 | + V_strncpy(symlinkOrigin, path, pathLen); | ||
| 49 | + V_strncpy(symlinkPath, path, pathLen); | ||
| 50 | + | ||
| 51 | + int i = 0; | ||
| 52 | + bool flag = false; | ||
| 53 | + | ||
| 54 | + for (i = 0; i < pathLen; i++) | ||
| 55 | + { | ||
| 56 | + if (path[i] == ':') | ||
| 57 | + { | ||
| 58 | + path[i] = '-'; | ||
| 59 | + symlinkPath[i] = '-'; | ||
| 60 | + flag = true; | ||
| 61 | + } | ||
| 62 | + if (flag && path[i] == '/') | ||
| 63 | + { | ||
| 64 | + break; | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + symlinkOrigin[i] = '\0'; | ||
| 68 | + symlinkPath[i] = '\0'; | ||
| 69 | + | ||
| 70 | + if (symlink(symlinkOrigin, symlinkPath) != 0 && (errno != EEXIST)) | ||
| 71 | + { | ||
| 72 | + DevMsg(0, MSG_PREFIX "Unable to create a symbolic link (%s).\n", strerror(errno)); | ||
| 73 | + DevMsg(0, MSG_PREFIX "Original path: %s\n", symlinkOrigin); | ||
| 74 | + DevMsg(0, MSG_PREFIX "Symbolic link: %s\n", symlinkPath); | ||
| 75 | + } | ||
| 76 | + #endif | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + inline void GenerateSymlink(char* path) | ||
| 80 | + { | ||
| 81 | + #if __linux__ | ||
| 82 | + while (strchr(path, ':') != NULL) | ||
| 83 | + { | ||
| 84 | + _GenerateSymlink(path); | ||
| 85 | + } | ||
| 86 | + #endif | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + #endif // _SHARED_UTILS_H | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,8 @@ | |||
| 35 | 35 | # include <windows.h> | |
| 36 | 36 | #endif | |
| 37 | 37 | ||
| 38 | + #include "../core/utility/shared_utils.h" | ||
| 39 | + | ||
| 38 | 40 | //--------------------------------------------------------------------------------- | |
| 39 | 41 | // Disable warnings. | |
| 40 | 42 | //--------------------------------------------------------------------------------- | |
@@ -81,6 +83,7 @@ void* SPLoadLibrary( IVEngineServer* engine, const char* libraryPath ) | |||
| 81 | 83 | V_strncpy(szError, "[SP-LOADER] - No error found\n", 1024); | |
| 82 | 84 | ||
| 83 | 85 | engine->GetGameDir(szGamePath, 1024); | |
| 86 | + GenerateSymlink(szGamePath); | ||
| 84 | 87 | ||
| 85 | 88 | V_snprintf(szFullPath, sizeof(szFullPath), "%s/addons/source-python/%s", | |
| 86 | 89 | szGamePath, libraryPath); | |
@@ -172,6 +175,7 @@ bool CSourcePython::Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn | |||
| 172 | 175 | // Get the game directory. | |
| 173 | 176 | // ------------------------------------------------------------------ | |
| 174 | 177 | engine->GetGameDir(szGameDir, 1024); | |
| 178 | + GenerateSymlink(szGameDir); | ||
| 175 | 179 | ||
| 176 | 180 | // ------------------------------------------------------------------ | |
| 177 | 181 | // Load windows dependencies. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments