halflife icon indicating copy to clipboard operation
halflife copied to clipboard

Provide access to the engine for community support

Open SamVanheer opened this issue 10 years ago • 228 comments

As suggested by @Stenudd, this is a new issue to cover discussion about engine access and upgrades.

Original discussion here: #1685

So far, the following users have shown interest in providing support for engine access: @tschumann @johnstt @Stenudd @SamVanheer

To summarize: we would like to request access to the engine so we can provide support to the GoldSource community. This would involve both bug fixes and new features to improve functionality.

I can speak from experience here, given that i used to have access when i was on the Sven Co-op team. Valve requires the engine to be stored in a secure manner, so if access were given it would require a secure repository. They also require the signing of an NDA, meaning no information found in the engine can be disclosed publicly.

Personally i'd like to see the following issues dealt with:

  • Increase engine limits (max entities/models/sounds/events/etc)
  • Bulk data transfer support (similar to Source's network string tables and entity networking, would solve large map cycle issues, late precaching, etc)
  • Elimination of sys_error and host_error causes (e.g. missing files, late precache, host_error triggers a longjmp which can corrupt and leak memory)
  • Fix known issues (e.g. resource lists too large to send all at once cause overflows)
  • Provide features previously limited to Valve games to mods ( e.g. VGUI2, chrome HTML renderer, GameUI)
  • Improved graphical performance (immediate mode support is pretty poor in some driver implementations)
  • New game interfaces to allow the server and client to be notified of events (e.g. map started loading on client and server, changing map, etc)
  • Improved string pool (currently allocates new block of memory for each call to enginefuncs_t::pfnAllocString, can run out easily for larger mods)
  • Unified memory allocator so everything uses the same memory pool (currently malloc/new don't use the engine's heap set by the -heapsize parameter)

There's more, but i can't think of it right now.

If you support this endeavor, and/or want to assist in the event that access is provided, please post your thoughts. If you have any ideas as to what could be done to improve the engine, please post them as well.

SamVanheer avatar Jun 22 '16 15:06 SamVanheer

As the current lead maintainer of Science & Industry, I have a strong interest in this.

  • I have (many times) settled for unsatisfactory solutions to problems because I cannot change the engine or HLDS source code used by my mod

For example, I recently spent a lot of time trying to improve the shotgun in our game, which involved a few performance bottlenecks and engine limits. As far as I can tell, many of these are simple #defines in the engine source code which ought to be reconsidered almost 20 years after Half-Life was developed and released.

In that same thread, I pointed out how the Half-Life engine and HLDS have open-source competition. However, I would prefer the official Half-Life binaries be kept up-to-date and transparent by the people contributing fixes on this Github repo. I cannot in good conscience ask my players to use an 'alternative engine' when the official engine is a closed-source paid product on Steam.

I also tried to learn how sv_clienttrace works as part of some investigation into hit registration and netcode issues in my mod. Unfortunately, I could not find much information in the official channels. Which brings me to my next point..

  • I often look at the Xash3D and reHLDS code to get ideas when debugging these issues, even though I do not use (or trust) those projects.

If the engine and HLDS code were available as open source, I could make better decisions for my mod and contribute improvements to the code powering the official Steam distribution of Half-Life. For example, I investigated and fixed a very strange bug with tripmines (documented here ). My fix applies to the SDK code, but I would be just as willing to share fixes I make to the other components if I had access to them.

There are many more stories like mine, but all the improvements being made are limited to the mods under which they are developed (since this repository is inactive and the Steam distribution of Half-Life is not being regularly updated).

  • I have seen how beneficial a complete open source ecosystem can be with games such as Quakeworld and Quake 3 Arena.

As I explained here, the Quake games are fully available as open source (client, server and engine code). These games are still sold on Steam and elsewhere, but the people purchasing them today are able to benefit from improvements made by open source developers in the many years since their original release. Many successful arena FPS game projects have grown out of the Quake 2/3 source code (OpenArena, ioquake3, Warsow etc) and the most commonly used Quakeworld client/server distributions are all in active development on Github.

I believe that, with only a small investment of management and support from Valve, the people posting on this repo could contribute positively to an open source Half-Life (including access to the engine and HLDS source code).

ghost avatar Jun 23 '16 20:06 ghost

I'm quite interested too. I made and continue to develop Sandpit: http://www.moddb.com/mods/sandpit/ The biggest hassle is the model precache limit of course, but also the inconsistency of it crashing when developer is 1 but silently failing when developer is 0. The engine's selective ability to load Blue Shift maps is also a bit annoying - it only seems to do it if the game is Blue Shift, otherwise the game freezes. GameUI being closed source is something I can live with but the inconvenience of not being able to filter what maps show for multiplayer remains - it seems like filters for Half-Life and Opposing Force are hard-coded, and the only alternative is the mp_filter key in liblist.gam which is quite limited. There is also the bug-based alternative of putting single-player maps a .pak file because GameUI doesn't look in .pak files but it's not the best. Another thing I'd like to do is add support for Dreamcast and PlayStation 2 models, which may be possible but difficult just from client.dll Also, better community access to the engine would be nice just to see how some things actually work. It's great that with the Linux update for Half-Life a whole lot more of the SDK got documented and released, but as almost none of it is used by vanilla Half-Life it's not entirely clear how to properly use some of the new features. I've been tinkering with IFileSystem009 but some of it doesn't work like you think it should. The ability to better debug some crashes would be nice too - unitialized sizebuf_t doesn't tell me what I'm doing wrong in my mod.

tschumann avatar Jun 24 '16 23:06 tschumann

The engine is full of checks that see if the game/mod dir is a particular one, like czero or cstrike, bshift, etc. That's why it's so inconsistent. The filesystem is actually somewhat buggy. I used it in a separate project to load content and it crashed after removing search paths. I should report that one when i've reproduced it.

SamVanheer avatar Jun 24 '16 23:06 SamVanheer

Do you know to use AddSearchPath properly? I'm trying to load Opposing Force content and I can't figure it out. I can get it to work but I don't want to change all the models paths to gearbox/models/whatever.mdl when models/whatever.mdl should work.

tschumann avatar Jun 25 '16 00:06 tschumann

AddSearchPath takes 2 parameters: the relative directory and a path ID. The directory is used to form file paths, while the path ID is used to determine which operations the path is used in.

The path is formed like this: "<search path/><filename>"

Assuming you're using the file system in a mod, adding the path "gearbox" will work.

The path ID will have to match one used in the engine for it to be used though.

The following path IDs are in use from what i can tell: ROOT: Half-Life/ BASE: Half-Life/ DEFAULT: a bunch of default paths, not really used directly PLATFORM: <game dir>/platform GAME: Game directories, including localization and _addon GAMECONFIG: Contains game configurations, meaning <mod dir> GAMEDOWNLOAD: The <mod dir>_downloads directory

It will use the "valve" directory as well to fall back to original content, unless a -basedir command line parameter is specified, in which case the given parameter is used. The mod dir is determined by using the value for -game. If none is given, it uses -basedir or valve.

If "fallback_dir" is defined in liblist.gam, it also defines GAME_FALLBACK.

If you want to add the Opposing Force directory, you'll have to add its search path. Ideally, adding it to "GAME" should be done since that's where it gets everything else from.

Note that you'll be adding it to the end of the list, so the mod dir and game dir are checked first. Worst case scenario you'll have to wipe all paths and add them again. That's difficult to do given that some are added conditionally based on things like low violence settings and command line parameters.

The engine will search for files by either passing null as the path ID, meaning all paths are searched, or by specifying a specific path ID, in which case only paths with that ID are considered. Whenever you're dealing with content that can be in _downloads, the null path ID should be used, since searching each path ID separately is a major hassle.

Because it searches every path when using null, it will produce duplicate results. That's why the map command and the Options menu models list have duplicates. The same paths are searched multiple times because they're defined in multiple path IDs.

Avoid calling RemoveSearchPath. That's the method that caused crashes for me. I don't know why, but i'm sure that if ran using a debug build or using pdbs the problem should be discovered easily.

Disclaimer: all of this information was determined through reverse engineering. No official documentation exists, so there's no alternative.

SamVanheer avatar Jun 25 '16 08:06 SamVanheer

Hm, I'll try "GAME" - I think I was using "MOD" based on a VDC article...

Also, to add to the list - crashing due to missing .wad files probably shouldn't happen - the engine can certainly handle missing textures; r_shadows could be exposed again (even if only when cheats are enabled) and if you want to print to the console from from some engine callbacks in client.dll then it won't work unless you use GameConsole003.

tschumann avatar Jun 25 '16 11:06 tschumann

I made the same mistake at first. GoldSource and Source use different path IDs for some reason.

I agree with those issues.

SamVanheer avatar Jun 25 '16 13:06 SamVanheer

Another reason to provide access: i've built a prototype shader based BSP renderer. It's not complete yet, but it can load and display maps. Because it uses VBOs and shaders, its performance is much better than the engine's immediate mode based renderer.

Repository can be found here: https://github.com/SamVanheer/BSPViewer

If this were integrated into the engine, it could boost graphics performance by a considerable amount. Further improvements in the future could lead to complete support for all rendered objects, including studio models, sprites and particles. This should eliminate any performance issues caused by poor driver support (e.g. AMD drivers). It shouldn't be too difficult to provide a shader based OpenGL renderer alongside the immediate mode version, though the codebase would be an even bigger mess than it is now.

SamVanheer avatar Jun 29 '16 15:06 SamVanheer

I've created a VDC page for GoldSource's IFileSystem interface. You can find it here.

SamVanheer avatar Jul 02 '16 19:07 SamVanheer

+1

einfacharthur avatar Jul 05 '16 20:07 einfacharthur

I am strongly in favor of open sourcing Goldsource. The fact this engine powers some of the best games of all time and that modders are still working with it 20 years after its release are proves of the quality of the gaming and development experience with it. The only reason why I'm reluctant to work more with the Goldsource engine is because it is closed source.

Loulimi avatar Jul 13 '16 19:07 Loulimi

+1 for open-sourcing the engine, a lot of wonderful enhancements, bug-fixes while keeping the legacy of Half-Life is something I wish to see in the future. I agree with the ideas of @Loulimi @tschumann @johnstt and @SamVanheer.

JoelTroch avatar Jul 19 '16 16:07 JoelTroch

+1 I support this idea.

peon501 avatar Jul 22 '16 17:07 peon501

This will be a great step forward for GoldSrc mods if it happens. It's really about time this happens.

lcarst avatar Jul 25 '16 05:07 lcarst

+1, this idea is great. It would help us, modders, and people who would like to help to improve the game (since the game is a bit too old now and needs some serious tweaks) and increase its lifespan a bit more :) :+1:

ssone95 avatar Jul 25 '16 11:07 ssone95

+1

InfcBear avatar Jul 25 '16 13:07 InfcBear

+1

milutinke avatar Jul 26 '16 21:07 milutinke

+1

Eraviperoor avatar Jul 26 '16 22:07 Eraviperoor

FYI, you can now thumbs up OP message. That way we aren't annoyed by a ton of notifications for all that +1...

dannycolin avatar Jul 26 '16 23:07 dannycolin

+1, It would help us develope the servers we always wanted to create, and decrease limitations in the engine, fix bugs and performance issues. Even add features such as map instead of radar, HD water and more.

Hope they listen this time, even though in reality i doubt it.

Skumek avatar Jul 28 '16 17:07 Skumek