Skip to content

Commit 32b9356

Browse files
committed
Add Coplay
1 parent c729c74 commit 32b9356

File tree

119 files changed

+58557
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+58557
-2
lines changed

Diff for: game/tf2vintage/license/TF2V/tf2v-server-thirdpartylegalnotices.txt

+378-1
Large diffs are not rendered by default.

Diff for: src/coplay/.github/ISSUE_TEMPLATE/bug-report.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug Report
3+
about: Found Issue
4+
title: "[BUG] ants?"
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Screenshots**
21+
If applicable, add screenshots to help explain your problem.
22+
23+
**Info**
24+
- OS:
25+
- Played Mod:
26+
- Coplay Version:
27+
28+
**Additional context**
29+
Add any other context about the problem here.

Diff for: src/coplay/.github/ISSUE_TEMPLATE/feature_request.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: "[FEATURE] add ..."
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

Diff for: src/coplay/LICENSE

+373
Large diffs are not rendered by default.

Diff for: src/coplay/README.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<p align="center"> <img width="500" src="https://coaxion.games/res/coplayLogo.svg"/> </p>
2+
3+
Logo made by FLARE145.
4+
5+
# Coplay
6+
A MPL2 licensed Source Engine Multiplayer SDK addon that enables the use of the Steam Datagram Relay for P2P connections with support for Linux and Windows.
7+
8+
If your mod implements Coplay please redirrect issue reports related to it [here](https://github.com/CoaXioN-Games/coplay/issues/new/choose).
9+
10+
## Usage
11+
Mods implementing Coplay can make their own UI if they want to but there are commands and cvars that come standard.
12+
13+
| Command | Description | Usage |
14+
| :-----: | :---------: | :---: |
15+
| `coplay_about` | Reddirects to this Github page and prints the current version | `coplay_about` |
16+
| `coplay_connect` | Connect to a server with a Ipv4 address, User SteamID64 or Lobby SteamID64 * | `coplay_connect (IP or SteamID64)` |
17+
| `coplay_getconnectcommand` | Prints a command for others to use to connect to your server | `coplay_getconnectcommand` |
18+
| `coplay_opensocket` | Allows your game to be joined via Coplay, this is automatically called on server creation if coplay_joinfilter is above -1 | `coplay_opensocket` |
19+
| `coplay_closesocket` | Disables your game from being joined via Coplay, this will also kick currently connected players | `coplay_closesocket` |
20+
| `coplay_listlobbies`* | List joinable lobbies | `coplay_listlobbies` |
21+
| `coplay_invite`* | Brings up the game invite dialog if you're in a game | `coplay_invite` |
22+
23+
24+
| Cvar | Description | Default value |
25+
| :--: | :---------: | :-----------: |
26+
| `coplay_joinfilter` | Sets who is allowed to join the game. -1: Off, 0: Invite Only, 1: Friends only, 2: Anyone(Lobby advertised if available*) | 1 |
27+
| `coplay_timeoutduration` | How long in seconds to keep a connection around that has no game activity | 5 |
28+
| `coplay_portrange_begin` ** | Where to start looking for ports to bind on | 3600 |
29+
| `coplay_portrange_end` ** | Where to stop looking for ports to bind on | 3700 |
30+
| `coplay_connectionthread_hz` | Number of times to service connections per second, it's unlikely you'll need to change this | 300 |
31+
| `coplay_forceloopback` | Uses the loopback interface instead of others, only change this if you have issues | 1 |
32+
33+
\* : Requires Steam Lobbies, Lobbies are only available for mods with an appid on Steam.
34+
\** : Only change this if issues arise, a range of at least 64 is recommended.
35+
36+
# Adding to your mod
37+
38+
## Prerequistes
39+
40+
### Updating the Steamworks SDK
41+
A more updated Steamworks SDK than the one that comes with the Source SDK is required to use Coplay, If you haven't already updated your mod's version you can find the latest download that works with [here](https://partner.steamgames.com/downloads/steamworks_sdk_160.zip).
42+
43+
If your mod still has references to `CSteamAPIContext`/`g_SteamAPIContext`/`steamapicontext` either replace them with the new global accessor equivelent (something like `steamapicontext->SteamFriends()->...` turns to `SteamFriends()->...`) or use the last version of the Steamworks SDK that still provides it, 159, found [here](https://partner.steamgames.com/downloads/steamworks_sdk_159.zip).
44+
45+
Steamworks versions above 157 do not apear to work with the Source SDK by default, if neither of the above versions work for you the download for version 157 is [here](https://partner.steamgames.com/downloads/steamworks_sdk_157.zip). When a fix is confirmed to work this README will include it.
46+
47+
1. Delete the `public/steam` folder of your mod's source tree and replace it with `public/steam` folder inside the downloaded zip, you're safe to delete the contained `lib` folder if you want.
48+
49+
2. Replace the steam_api.lib and libsteam_api.so files found in `lib/public` and `lib/public/linux32` with the ones in the zip under the folder `redistributable_bin`. Make sure to copy the 32 bit versions.
50+
51+
3. Rerun your VPC script and build.
52+
53+
54+
### Fix host_thread_mode
55+
Coplay enables this convar on start. Due to an engine bug, locally hosted servers will sometimes run faster than intended. host_thread_mode 2 fixes this but causes inputs by the host player to be discarded because of a desync.
56+
This can be side-stepped by changing this statement in player.cpp CBasePlayer::IsUserCmdDataValid() from
57+
```
58+
bool bValid = ( pCmd->tick_count >= nMinDelta && pCmd->tick_count < nMaxDelta ) &&
59+
// Prevent clients from sending invalid view angles to try to get leaf server code to crash
60+
( pCmd->viewangles.IsValid() && IsEntityQAngleReasonable( pCmd->viewangles ) ) &&
61+
// Movement ranges
62+
( IsFinite( pCmd->forwardmove ) && IsEntityCoordinateReasonable( pCmd->forwardmove ) ) &&
63+
( IsFinite( pCmd->sidemove ) && IsEntityCoordinateReasonable( pCmd->sidemove ) ) &&
64+
( IsFinite( pCmd->upmove ) && IsEntityCoordinateReasonable( pCmd->upmove ) );
65+
```
66+
to
67+
```
68+
// when using host_thread_mode 1 or 2 on a listen server the client and server tickcount get desynced resulting in none of the hosts usermsgs getting accepted
69+
// this first || fixes that and doesnt seem to do anything else as far as i can tell; Tholp
70+
bool bValid = ((!engine->IsDedicatedServer() && entindex() == 1) || ( pCmd->tick_count >= nMinDelta && pCmd->tick_count < nMaxDelta )) &&
71+
// Prevent clients from sending invalid view angles to try to get leaf server code to crash
72+
( pCmd->viewangles.IsValid() && IsEntityQAngleReasonable( pCmd->viewangles ) ) &&
73+
// Movement ranges
74+
( IsFinite( pCmd->forwardmove ) && IsEntityCoordinateReasonable( pCmd->forwardmove ) ) &&
75+
( IsFinite( pCmd->sidemove ) && IsEntityCoordinateReasonable( pCmd->sidemove ) ) &&
76+
( IsFinite( pCmd->upmove ) && IsEntityCoordinateReasonable( pCmd->upmove ) );
77+
```
78+
79+
## Adding Coplay
80+
81+
1. First Either clone Coplay as a git submodule, or download it as a zip then place it into the root of your mod's source( Where folders such as `devtools`, `game` and `public` are. )
82+
83+
2. Open your mod's client .vpc file, and add the line
84+
`$Include "$SRCDIR\coplay\src\coplay.vpc"`
85+
to it somewhere at the top, if your mod has an appid on Steam you'll probably want to append `COPLAY_USE_LOBBIES` to your `$PreprocessorDefinitions`( Don't add this preprocessor if your mod does not have an appid, otherwise Coplay will be effectively nonfunctional ).
86+
87+
3. Rerun your VPC script and build.
88+
89+
4. If you have linker issues when building on Linux delete the libSDL2.so found in your mod's `src/lib/public/linux32` folder and retry.
90+
91+
5. Add the SDL2_net.dll and libSDL2_net.so (if your mod supports Linux) found in coplay/lib to you mod's /bin folder.
92+
93+
# FAQ
94+
95+
## How?
96+
Coplay is a network relay that maps ports on your local machine to Steam datagram connections, this allows it to not require modifing engine code.
97+
98+
## Whats the difference if Steam's Lobby system is available?
99+
Lobbies allow user hosted games to be advertised and joined akin to the server browser.
100+
101+
## Does custom content work?
102+
Yes, as normal.
103+
104+
## My mod wont launch anymore! "Can't load library client"
105+
Reading the instructions is recomended.
106+
107+
## I Can't move in my own local server!
108+
Reading the instructions is recomended.
109+
110+
## Whats your favorite color?
111+
Green, thanks for asking.

Diff for: src/coplay/include/SDL2/SDL.h

+233
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
/*
2+
Simple DirectMedia Layer
3+
Copyright (C) 1997-2023 Sam Lantinga <[email protected]>
4+
5+
This software is provided 'as-is', without any express or implied
6+
warranty. In no event will the authors be held liable for any damages
7+
arising from the use of this software.
8+
9+
Permission is granted to anyone to use this software for any purpose,
10+
including commercial applications, and to alter it and redistribute it
11+
freely, subject to the following restrictions:
12+
13+
1. The origin of this software must not be misrepresented; you must not
14+
claim that you wrote the original software. If you use this software
15+
in a product, an acknowledgment in the product documentation would be
16+
appreciated but is not required.
17+
2. Altered source versions must be plainly marked as such, and must not be
18+
misrepresented as being the original software.
19+
3. This notice may not be removed or altered from any source distribution.
20+
*/
21+
22+
/**
23+
* \file SDL.h
24+
*
25+
* Main include header for the SDL library
26+
*/
27+
28+
29+
#ifndef SDL_h_
30+
#define SDL_h_
31+
32+
#include "SDL_main.h"
33+
#include "SDL_stdinc.h"
34+
#include "SDL_assert.h"
35+
#include "SDL_atomic.h"
36+
#include "SDL_audio.h"
37+
#include "SDL_clipboard.h"
38+
#include "SDL_cpuinfo.h"
39+
#include "SDL_endian.h"
40+
#include "SDL_error.h"
41+
#include "SDL_events.h"
42+
#include "SDL_filesystem.h"
43+
#include "SDL_gamecontroller.h"
44+
#include "SDL_guid.h"
45+
#include "SDL_haptic.h"
46+
#include "SDL_hidapi.h"
47+
#include "SDL_hints.h"
48+
#include "SDL_joystick.h"
49+
#include "SDL_loadso.h"
50+
#include "SDL_log.h"
51+
#include "SDL_messagebox.h"
52+
#include "SDL_metal.h"
53+
#include "SDL_mutex.h"
54+
#include "SDL_power.h"
55+
#include "SDL_render.h"
56+
#include "SDL_rwops.h"
57+
#include "SDL_sensor.h"
58+
#include "SDL_shape.h"
59+
#include "SDL_system.h"
60+
#include "SDL_thread.h"
61+
#include "SDL_timer.h"
62+
#include "SDL_version.h"
63+
#include "SDL_video.h"
64+
#include "SDL_locale.h"
65+
#include "SDL_misc.h"
66+
67+
#include "begin_code.h"
68+
/* Set up for C function definitions, even when using C++ */
69+
#ifdef __cplusplus
70+
extern "C" {
71+
#endif
72+
73+
/* As of version 0.5, SDL is loaded dynamically into the application */
74+
75+
/**
76+
* \name SDL_INIT_*
77+
*
78+
* These are the flags which may be passed to SDL_Init(). You should
79+
* specify the subsystems which you will be using in your application.
80+
*/
81+
/* @{ */
82+
#define SDL_INIT_TIMER 0x00000001u
83+
#define SDL_INIT_AUDIO 0x00000010u
84+
#define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */
85+
#define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */
86+
#define SDL_INIT_HAPTIC 0x00001000u
87+
#define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
88+
#define SDL_INIT_EVENTS 0x00004000u
89+
#define SDL_INIT_SENSOR 0x00008000u
90+
#define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */
91+
#define SDL_INIT_EVERYTHING ( \
92+
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
93+
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR \
94+
)
95+
/* @} */
96+
97+
/**
98+
* Initialize the SDL library.
99+
*
100+
* SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the
101+
* two may be used interchangeably. Though for readability of your code
102+
* SDL_InitSubSystem() might be preferred.
103+
*
104+
* The file I/O (for example: SDL_RWFromFile) and threading (SDL_CreateThread)
105+
* subsystems are initialized by default. Message boxes
106+
* (SDL_ShowSimpleMessageBox) also attempt to work without initializing the
107+
* video subsystem, in hopes of being useful in showing an error dialog when
108+
* SDL_Init fails. You must specifically initialize other subsystems if you
109+
* use them in your application.
110+
*
111+
* Logging (such as SDL_Log) works without initialization, too.
112+
*
113+
* `flags` may be any of the following OR'd together:
114+
*
115+
* - `SDL_INIT_TIMER`: timer subsystem
116+
* - `SDL_INIT_AUDIO`: audio subsystem
117+
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
118+
* subsystem
119+
* - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the
120+
* events subsystem
121+
* - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem
122+
* - `SDL_INIT_GAMECONTROLLER`: controller subsystem; automatically
123+
* initializes the joystick subsystem
124+
* - `SDL_INIT_EVENTS`: events subsystem
125+
* - `SDL_INIT_EVERYTHING`: all of the above subsystems
126+
* - `SDL_INIT_NOPARACHUTE`: compatibility; this flag is ignored
127+
*
128+
* Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
129+
* for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or
130+
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then
131+
* this call will increase the ref-count and return.
132+
*
133+
* \param flags subsystem initialization flags
134+
* \returns 0 on success or a negative error code on failure; call
135+
* SDL_GetError() for more information.
136+
*
137+
* \since This function is available since SDL 2.0.0.
138+
*
139+
* \sa SDL_InitSubSystem
140+
* \sa SDL_Quit
141+
* \sa SDL_SetMainReady
142+
* \sa SDL_WasInit
143+
*/
144+
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
145+
146+
/**
147+
* Compatibility function to initialize the SDL library.
148+
*
149+
* In SDL2, this function and SDL_Init() are interchangeable.
150+
*
151+
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
152+
* \returns 0 on success or a negative error code on failure; call
153+
* SDL_GetError() for more information.
154+
*
155+
* \since This function is available since SDL 2.0.0.
156+
*
157+
* \sa SDL_Init
158+
* \sa SDL_Quit
159+
* \sa SDL_QuitSubSystem
160+
*/
161+
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
162+
163+
/**
164+
* Shut down specific SDL subsystems.
165+
*
166+
* If you start a subsystem using a call to that subsystem's init function
167+
* (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(),
168+
* SDL_QuitSubSystem() and SDL_WasInit() will not work. You will need to use
169+
* that subsystem's quit function (SDL_VideoQuit()) directly instead. But
170+
* generally, you should not be using those functions directly anyhow; use
171+
* SDL_Init() instead.
172+
*
173+
* You still need to call SDL_Quit() even if you close all open subsystems
174+
* with SDL_QuitSubSystem().
175+
*
176+
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
177+
*
178+
* \since This function is available since SDL 2.0.0.
179+
*
180+
* \sa SDL_InitSubSystem
181+
* \sa SDL_Quit
182+
*/
183+
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
184+
185+
/**
186+
* Get a mask of the specified subsystems which are currently initialized.
187+
*
188+
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
189+
* \returns a mask of all initialized subsystems if `flags` is 0, otherwise it
190+
* returns the initialization status of the specified subsystems.
191+
*
192+
* The return value does not include SDL_INIT_NOPARACHUTE.
193+
*
194+
* \since This function is available since SDL 2.0.0.
195+
*
196+
* \sa SDL_Init
197+
* \sa SDL_InitSubSystem
198+
*/
199+
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
200+
201+
/**
202+
* Clean up all initialized subsystems.
203+
*
204+
* You should call this function even if you have already shutdown each
205+
* initialized subsystem with SDL_QuitSubSystem(). It is safe to call this
206+
* function even in the case of errors in initialization.
207+
*
208+
* If you start a subsystem using a call to that subsystem's init function
209+
* (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(),
210+
* then you must use that subsystem's quit function (SDL_VideoQuit()) to shut
211+
* it down before calling SDL_Quit(). But generally, you should not be using
212+
* those functions directly anyhow; use SDL_Init() instead.
213+
*
214+
* You can use this function with atexit() to ensure that it is run when your
215+
* application is shutdown, but it is not wise to do this from a library or
216+
* other dynamically loaded code.
217+
*
218+
* \since This function is available since SDL 2.0.0.
219+
*
220+
* \sa SDL_Init
221+
* \sa SDL_QuitSubSystem
222+
*/
223+
extern DECLSPEC void SDLCALL SDL_Quit(void);
224+
225+
/* Ends C function definitions when using C++ */
226+
#ifdef __cplusplus
227+
}
228+
#endif
229+
#include "close_code.h"
230+
231+
#endif /* SDL_h_ */
232+
233+
/* vi: set ts=4 sw=4 expandtab: */

0 commit comments

Comments
 (0)