Source Python for GMod?
Source Python for GMod?
Have you guys ever considered adding support for Garry's Mod to Source Python?
I've tried to build a SP branch for GMod a while ago, ran into issues, got busy with other stuff and never really revisited the idea.
It's a fairly active game and a popular game to write addons for (obviously). I'm aware GMod includes LUA as a scripting language, but I don't find LUA particularly powerful for starters and I find the implementation to be rather poor in GMod. It just doesn't feel intuitive at all.
Afaik it should be adding just another engine version and data to SP, or are there any particular issues in getting a build for GMod that I'm unaware of?
I've tried to build a SP branch for GMod a while ago, ran into issues, got busy with other stuff and never really revisited the idea.
It's a fairly active game and a popular game to write addons for (obviously). I'm aware GMod includes LUA as a scripting language, but I don't find LUA particularly powerful for starters and I find the implementation to be rather poor in GMod. It just doesn't feel intuitive at all.
Afaik it should be adding just another engine version and data to SP, or are there any particular issues in getting a build for GMod that I'm unaware of?
Re: Source Python for GMod?
There is a decent amount you have to do to get it to work with a new engine. Specifically, you have to add the engine specific logic in several of the src/core/modules/ directories, any patches, and possibly some defined checks in the loader and sp_main. I have been attempting to add a few new engines to our support, but had not worked on GMod. However, after seeing your post, I did make a new branch locally and start on adding GMod support. Right now, I am only seeing one error when building, though that error appears about 60 times.
It seems that GMod's memalloc.h does not include a MemAlloc_Alloc function, which is causing this error. I will commit what I have, so far, and anyone can feel free to continue the work on it.
*Edit:
https://github.com/Source-Python-Dev-Te ... ngine_gmod
Code: Select all
2>e:\projects\source.python\src\core\modules\memory\memory_alloc.h(65): error C3861: 'MemAlloc_Alloc': identifier not found
It seems that GMod's memalloc.h does not include a MemAlloc_Alloc function, which is causing this error. I will commit what I have, so far, and anyone can feel free to continue the work on it.
*Edit:
https://github.com/Source-Python-Dev-Te ... ngine_gmod
Re: Source Python for GMod?
It seems that you're not supposed to use it, so setting NO_MALLOC_OVERRIDE should do the trick.
I updated gmod.makec to
Now I get an error from the sdk:
I updated gmod.makec to
Code: Select all
# ------------------------------------------------------------------
# File: src/makefiles/branch/gmod.cmake
# Purpose: This is the CMake file for the gmod branch.
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# Set the engine version.
# ------------------------------------------------------------------
Set(SOURCE_ENGINE "gmod")
add_definitions(-DENGINE_GMOD)
# ------------------------------------------------------------------
# Don't use MemAlloc_Alloc
# ------------------------------------------------------------------
add_definitions(-DNO_MALLOC_OVERRIDE)
Now I get an error from the sdk:
Code: Select all
1>..\..\..\hl2sdk\gmod\tier1\KeyValues.cpp(2352): error C3861: 'MemAlloc_PushAllocDbgInfo': identifier not found
1>..\..\..\hl2sdk\gmod\tier1\KeyValues.cpp(2354): error C3861: 'MemAlloc_PopAllocDbgInfo': identifier not found
Re: Source Python for GMod?
I haven't taken a look at it, but instead of defining NO_MALLOC_OVERRIDE on Windows, i would rather add -DMemAlloc_Alloc=malloc. However, maybe it's just missing include. But again: i haven't taken a look at it yet, but I will do that when I get home today.
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Source Python for GMod?
Seems like memalloc.h on GMod branch has not been updated for the lastest version. Added a patch for it and it now compile fine for me (on windows).
Re: Source Python for GMod?
Yep, compiles for me, as well, thank you! I will attempt to build it on Linux tonight and download the servers to get the binaries.
Re: Source Python for GMod?
Any luck? On Windows it ran into this and unloaded.
Thanks for the support so far!
Code: Select all
[Source.Python] Could not retrieve interface FileSystem019
Thanks for the support so far!
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Source Python for GMod?
L'In20Cible wrote:https://github.com/Source-Python-Dev-Team/Source.Python/commit/0c3294c847fc550505f21bffa2a4ca070febd045#commitcomment-18732172
Cool, I understand if it ends up being to much work to implement, or lower on the list of priorities.
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Source Python for GMod?
Psychonic pushed updates for the Gmod branch! When you get the time to, could you try again and see if it loads? It will still raise on load due to missing data/global pointers that we still have to add but if the SDK is fully updated, you should at least see this message.
Re: Source Python for GMod?
I just tested the new version, and I am getting this error 37 times:
Also, I think we can now remove the memalloc.h patch, as that file was updated.
Code: Select all
E:\Projects\Source.Python\src\hl2sdk\gmod\game/server/baseentity.h(1570): error C2259: 'CBaseEntity
::NetworkVar_m_Collision' : cannot instantiate abstract class [E:\Projects\Source.Python\src\Builds
\WINDOWS\gmod\core.vcxproj]
due to following members:
'const Vector &ICollideable::OBBMinsPreScaled(void) const' : is abstract
e:\projects\source.python\src\hl2sdk\gmod\public\engine/ICollideable.h(35) : see declarat
ion of 'ICollideable::OBBMinsPreScaled'
'const Vector &ICollideable::OBBMaxsPreScaled(void) const' : is abstract
e:\projects\source.python\src\hl2sdk\gmod\public\engine/ICollideable.h(36) : see declarat
ion of 'ICollideable::OBBMaxsPreScaled'
Also, I think we can now remove the memalloc.h patch, as that file was updated.
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Source Python for GMod?
I removed the memalloc patch. As for this error, I will see if I can find the cause. Seeing NetworkVar I'm assuming we need to update networkvar.h with our patch for the current version. Doing some testings right now and will push the required fixes.
Re: Source Python for GMod?
I didn't realize you were going to be so fast I had a fix for EmitSound that I hadn't committed locally. But, since you are making fixes, I'll let you handle that, too.
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Source Python for GMod?
Fixed the compile error, the file collisionproperty.h need to be updated. I will add it as a fix in our repo for now, and PR it on their once it is fully tested on both platform. The EmitSound is the one I need to fix, now. :P
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Source Python for GMod?
Pushed. I'm now getting:
But I think I screwed it on my side pulling while compiling. Unless you get the same?
Code: Select all
1>mathlib.lib(mathlib_base.obj) : error LNK2019: unresolved external symbol ___vdecl_sin2 referenced in function "void __cdecl InitSinCosTable(void)" (?InitSinCosTable@@YAXXZ)
1>mathlib.lib(color_conversion.obj) : error LNK2019: unresolved external symbol ___vdecl_pow2 referenced in function "void __cdecl BuildGammaTable(float,float,float,int)" (?BuildGammaTable@@YAXMMMH@Z)
1>mathlib.lib(color_conversion.obj) : error LNK2019: unresolved external symbol ___vdecl_powf4 referenced in function "void __cdecl BuildGammaTable(float,float,float,int)" (?BuildGammaTable@@YAXMMMH@Z)
But I think I screwed it on my side pulling while compiling. Unless you get the same?
Re: Source Python for GMod?
I get the same. Heading to bed, so I won't be able to do any more till tomorrow evening.
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Source Python for GMod?
Seems like mathlib.lib will have to be recompiled with updated color_conversion.cpp file. I will start an issue on their repo for this.
EDIT: Patched mathlib.lib on our repo for now. It now compile fine for me, the compiled binaries are loading perfectly on my test server (still unloading itself due to missing data but the builds are fine).
EDIT: Patched mathlib.lib on our repo for now. It now compile fine for me, the compiled binaries are loading perfectly on my test server (still unloading itself due to missing data but the builds are fine).
Re: Source Python for GMod?
Wouldn't it be better if Source Python was more vocal when loading with missing data? All it outputs is "Loading main module" and then "failed to load main module", then begins to unload everything.
Re: Source Python for GMod?
I would agree. I think the best idea, though, is to not require the data. If the data is missing, that functionality should just not work, but the plugin should still load. I'm not sure how feasible that will be at this time. I know the OnEntityOutput listener could easily be implemented this way. Other objects that utilize data to get objects in memory might be far more engrained into Source.Python itself to not allow for this.
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Source Python for GMod?
On my side I replaced the load function into __init__.py with:
Syntax: Select all
def load():
"""Load Source.Python's Python side."""
def try_to_setup(func):
try:
func()
except:
import sys
exc_type, exc_value, exc_traceback = sys.exc_info()
print('Unable to {} due to an {}:'.format(func.__name__.replace('_', ' '), exc_type.__name__))
print('\t', exc_value)
try_to_setup(setup_core_settings)
try_to_setup(setup_logging)
try_to_setup(setup_hooks)
try_to_setup(setup_translations)
try_to_setup(setup_global_pointers)
try_to_setup(setup_sp_command)
try_to_setup(setup_auth)
try_to_setup(setup_user_settings)
try_to_setup(setup_entities_listener)
try_to_setup(setup_versioning)
try_to_setup(setup_sqlite)
Code: Select all
Unable to setup core settings due to an AttributeError:
type object 'BaseEntityOutput' has no attribute 'fire_output'
Unable to setup global pointers due to an NameError:
No global pointer found for "Server".
Unable to setup sp command due to an AttributeError:
type object 'BaseEntityOutput' has no attribute 'fire_output'
Unable to setup user settings due to an AttributeError:
type object 'BaseEntityOutput' has no attribute 'fire_output'
Unable to setup entities listener due to an NameError:
No global pointer found for "GlobalEntityList".
Return to “General Discussion”
Who is online
Users browsing this forum: No registered users and 27 guests