mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
2763: Allow joining and inviting others via Steam friend list r=def- a=heinrich5991 Fixes #2642. 2768: Clamp kill border count r=def- a=Jupeyy fixes #2766 Appearently the center of the camera can even go outside of the kill border(like even left from it) I also notice that sometimes when zooming out, and then in again the zoom level gets negative(since the new smooth zoom)(atleast i see everything upside down for few frames) These numerical unstableness makes me sweat a bit xd Co-authored-by: heinrich5991 <heinrich5991@gmail.com> Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
commit
d6a353f618
|
@ -2588,18 +2588,17 @@ void CClient::Update()
|
|||
{
|
||||
|
||||
#if defined(CONF_VIDEORECORDER)
|
||||
if (m_DemoPlayer.IsPlaying() && IVideo::Current())
|
||||
{
|
||||
if (IVideo::Current()->FrameRendered())
|
||||
IVideo::Current()->NextVideoFrame();
|
||||
if (IVideo::Current()->AudioFrameRendered())
|
||||
IVideo::Current()->NextAudioFrameTimeline();
|
||||
}
|
||||
else if(m_ButtonRender)
|
||||
Disconnect();
|
||||
if (m_DemoPlayer.IsPlaying() && IVideo::Current())
|
||||
{
|
||||
if (IVideo::Current()->FrameRendered())
|
||||
IVideo::Current()->NextVideoFrame();
|
||||
if (IVideo::Current()->AudioFrameRendered())
|
||||
IVideo::Current()->NextAudioFrameTimeline();
|
||||
}
|
||||
else if(m_ButtonRender)
|
||||
Disconnect();
|
||||
#endif
|
||||
|
||||
|
||||
m_DemoPlayer.Update();
|
||||
|
||||
if(m_DemoPlayer.IsPlaying())
|
||||
|
@ -2845,6 +2844,15 @@ void CClient::Update()
|
|||
if(!m_EditorActive)
|
||||
GameClient()->OnUpdate();
|
||||
|
||||
Steam()->Update();
|
||||
if(Steam()->GetConnectAddress())
|
||||
{
|
||||
char aAddress[NETADDR_MAXSTRSIZE];
|
||||
net_addr_str(Steam()->GetConnectAddress(), aAddress, sizeof(aAddress), true);
|
||||
Connect(aAddress);
|
||||
Steam()->ClearConnectAddress();
|
||||
}
|
||||
|
||||
if(m_ReconnectTime > 0 && time_get() > m_ReconnectTime)
|
||||
{
|
||||
Connect(m_aServerAddressStr);
|
||||
|
@ -4048,6 +4056,11 @@ static CClient *CreateClient()
|
|||
return new(pClient) CClient;
|
||||
}
|
||||
|
||||
void CClient::HandleConnectAddress(const NETADDR *pAddr)
|
||||
{
|
||||
net_addr_str(pAddr, m_aCmdConnect, sizeof(m_aCmdConnect), true);
|
||||
}
|
||||
|
||||
void CClient::HandleConnectLink(const char *pLink)
|
||||
{
|
||||
str_copy(m_aCmdConnect, pLink + sizeof(CONNECTLINK) - 1, sizeof(m_aCmdConnect));
|
||||
|
@ -4118,6 +4131,7 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
IEngineTextRender *pEngineTextRender = CreateEngineTextRender();
|
||||
IEngineMap *pEngineMap = CreateEngineMap();
|
||||
IEngineMasterServer *pEngineMasterServer = CreateEngineMasterServer();
|
||||
ISteam *pSteam = CreateSteam();
|
||||
|
||||
if(RandInitFailed)
|
||||
{
|
||||
|
@ -4150,7 +4164,7 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(CreateEditor(), false);
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(CreateGameClient(), false);
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(pStorage);
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(CreateSteam());
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(pSteam);
|
||||
|
||||
if(RegisterFail)
|
||||
{
|
||||
|
@ -4215,6 +4229,12 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
else if(argc > 1) // ignore_convention
|
||||
pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention
|
||||
|
||||
if(pSteam->GetConnectAddress())
|
||||
{
|
||||
pClient->HandleConnectAddress(pSteam->GetConnectAddress());
|
||||
pSteam->ClearConnectAddress();
|
||||
}
|
||||
|
||||
pClient->Engine()->InitLogfile();
|
||||
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
|
|
|
@ -427,6 +427,7 @@ public:
|
|||
|
||||
void ServerBrowserUpdate();
|
||||
|
||||
void HandleConnectAddress(const NETADDR *pAddr);
|
||||
void HandleConnectLink(const char *pLink);
|
||||
void HandleDemoPath(const char *pPath);
|
||||
void HandleMapPath(const char *pPath);
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
#include <engine/steam.h>
|
||||
|
||||
#include <engine/shared/config.h>
|
||||
|
||||
#include <steam/steam_api_flat.h>
|
||||
|
||||
class CSteam : public ISteam
|
||||
{
|
||||
HSteamPipe m_SteamPipe;
|
||||
ISteamApps *m_pSteamApps;
|
||||
ISteamFriends *m_pSteamFriends;
|
||||
char m_aPlayerName[16];
|
||||
bool m_GotConnectAddr;
|
||||
NETADDR m_ConnectAddr;
|
||||
|
||||
public:
|
||||
CSteam()
|
||||
{
|
||||
SteamAPI_ManualDispatch_Init();
|
||||
m_SteamPipe = SteamAPI_GetHSteamPipe();
|
||||
m_pSteamApps = SteamAPI_SteamApps_v008();
|
||||
m_pSteamFriends = SteamAPI_SteamFriends_v017();
|
||||
|
||||
char aCmdLine[128];
|
||||
int CmdLineSize = SteamAPI_ISteamApps_GetLaunchCommandLine(m_pSteamApps, aCmdLine, sizeof(aCmdLine));
|
||||
if(CmdLineSize >= 128)
|
||||
{
|
||||
CmdLineSize = 127;
|
||||
}
|
||||
aCmdLine[CmdLineSize] = 0;
|
||||
dbg_msg("steam", "cmdline='%s' param_connect='%s'", aCmdLine, SteamAPI_ISteamApps_GetLaunchQueryParam(m_pSteamApps, "connect"));
|
||||
ReadLaunchCommandLine();
|
||||
str_copy(m_aPlayerName, SteamAPI_ISteamFriends_GetPersonaName(m_pSteamFriends), sizeof(m_aPlayerName));
|
||||
}
|
||||
~CSteam()
|
||||
|
@ -29,26 +29,108 @@ public:
|
|||
SteamAPI_Shutdown();
|
||||
}
|
||||
|
||||
void ParseConnectString(const char *pConnect)
|
||||
{
|
||||
if(pConnect[0])
|
||||
{
|
||||
NETADDR Connect;
|
||||
if(net_addr_from_str(&Connect, pConnect) == 0)
|
||||
{
|
||||
m_ConnectAddr = Connect;
|
||||
m_GotConnectAddr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_msg("steam", "got unparsable connect string: '%s'", pConnect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReadLaunchCommandLine()
|
||||
{
|
||||
char aConnect[NETADDR_MAXSTRSIZE];
|
||||
int ConnectSize = SteamAPI_ISteamApps_GetLaunchCommandLine(m_pSteamApps, aConnect, sizeof(aConnect));
|
||||
if(ConnectSize >= NETADDR_MAXSTRSIZE)
|
||||
{
|
||||
ConnectSize = NETADDR_MAXSTRSIZE - 1;
|
||||
}
|
||||
aConnect[ConnectSize] = 0;
|
||||
m_GotConnectAddr = false;
|
||||
ParseConnectString(aConnect);
|
||||
}
|
||||
|
||||
void OnGameRichPresenceJoinRequested(GameRichPresenceJoinRequested_t *pEvent)
|
||||
{
|
||||
ParseConnectString(pEvent->m_rgchConnect);
|
||||
}
|
||||
|
||||
const char *GetPlayerName()
|
||||
{
|
||||
return m_aPlayerName;
|
||||
}
|
||||
|
||||
const NETADDR *GetConnectAddress()
|
||||
{
|
||||
if(m_GotConnectAddr)
|
||||
{
|
||||
return &m_ConnectAddr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
void ClearConnectAddress()
|
||||
{
|
||||
m_GotConnectAddr = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
SteamAPI_ManualDispatch_RunFrame(m_SteamPipe);
|
||||
CallbackMsg_t Callback;
|
||||
while(SteamAPI_ManualDispatch_GetNextCallback(m_SteamPipe, &Callback))
|
||||
{
|
||||
switch(Callback.m_iCallback)
|
||||
{
|
||||
case NewUrlLaunchParameters_t::k_iCallback:
|
||||
ReadLaunchCommandLine();
|
||||
break;
|
||||
case GameRichPresenceJoinRequested_t::k_iCallback:
|
||||
OnGameRichPresenceJoinRequested((GameRichPresenceJoinRequested_t *)Callback.m_pubParam);
|
||||
break;
|
||||
default:
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
dbg_msg("steam/dbg", "unhandled callback id=%d", Callback.m_iCallback);
|
||||
}
|
||||
}
|
||||
SteamAPI_ManualDispatch_FreeLastCallback(m_SteamPipe);
|
||||
}
|
||||
}
|
||||
void ClearGameInfo()
|
||||
{
|
||||
SteamAPI_ISteamFriends_ClearRichPresence(m_pSteamFriends);
|
||||
}
|
||||
void SetGameInfo(NETADDR ServerAddr, const char *pMapName)
|
||||
{
|
||||
char aServerAddr[NETADDR_MAXSTRSIZE];
|
||||
net_addr_str(&ServerAddr, aServerAddr, sizeof(aServerAddr), true);
|
||||
|
||||
SteamAPI_ISteamFriends_SetRichPresence(m_pSteamFriends, "connect", aServerAddr);
|
||||
SteamAPI_ISteamFriends_SetRichPresence(m_pSteamFriends, "map", pMapName);
|
||||
SteamAPI_ISteamFriends_SetRichPresence(m_pSteamFriends, "status", pMapName);
|
||||
SteamAPI_ISteamFriends_SetRichPresence(m_pSteamFriends, "steam_display", "#Status");
|
||||
SteamAPI_ISteamFriends_SetRichPresence(m_pSteamFriends, "map", pMapName);
|
||||
SteamAPI_ISteamFriends_SetRichPresence(m_pSteamFriends, "steam_player_group", aServerAddr);
|
||||
}
|
||||
};
|
||||
|
||||
class CSteamStub : public ISteam
|
||||
{
|
||||
const char *GetPlayerName() { return 0; }
|
||||
const NETADDR *GetConnectAddress() { return 0; }
|
||||
void ClearConnectAddress() { }
|
||||
void Update() { }
|
||||
void ClearGameInfo() { }
|
||||
void SetGameInfo(NETADDR ServerAddr, const char *pMapName) { }
|
||||
};
|
||||
|
|
|
@ -10,6 +10,13 @@ public:
|
|||
// Returns NULL if the name cannot be determined.
|
||||
virtual const char *GetPlayerName() = 0;
|
||||
|
||||
// Returns NULL if the no server needs to be joined.
|
||||
// Can change while the game is running.
|
||||
virtual const NETADDR *GetConnectAddress() = 0;
|
||||
virtual void ClearConnectAddress() = 0;
|
||||
|
||||
virtual void Update() = 0;
|
||||
|
||||
virtual void ClearGameInfo() = 0;
|
||||
virtual void SetGameInfo(NETADDR ServerAddr, const char *pMapName) = 0;
|
||||
};
|
||||
|
|
|
@ -36,9 +36,19 @@ void CCamera::ScaleZoom(float Factor)
|
|||
ChangeZoom(CurrentTarget * Factor);
|
||||
}
|
||||
|
||||
float CCamera::MaxZoomLevel()
|
||||
{
|
||||
return (Graphics()->IsTileBufferingEnabled()? 60 : 30);
|
||||
}
|
||||
|
||||
float CCamera::MinZoomLevel()
|
||||
{
|
||||
return 0.01f;
|
||||
}
|
||||
|
||||
void CCamera::ChangeZoom(float Target)
|
||||
{
|
||||
if(Target >= (Graphics()->IsTileBufferingEnabled()? 60 : 30))
|
||||
if(Target > MaxZoomLevel() || Target < MinZoomLevel())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -75,6 +85,7 @@ void CCamera::OnRender()
|
|||
{
|
||||
m_Zoom = m_ZoomSmoothing.Evaluate(ZoomProgress(Time));
|
||||
}
|
||||
m_Zoom = clamp(m_Zoom, MinZoomLevel(), MaxZoomLevel());
|
||||
}
|
||||
|
||||
if(!(m_pClient->m_Snap.m_SpecInfo.m_Active || GameClient()->m_GameInfo.m_AllowZoom || Client()->State() == IClient::STATE_DEMOPLAYBACK))
|
||||
|
|
|
@ -28,6 +28,8 @@ class CCamera : public CComponent
|
|||
void ChangeZoom(float Target);
|
||||
float ZoomProgress(float CurrentTime) const;
|
||||
|
||||
float MinZoomLevel();
|
||||
float MaxZoomLevel();
|
||||
public:
|
||||
vec2 m_Center;
|
||||
bool m_ZoomSet;
|
||||
|
|
|
@ -1293,6 +1293,8 @@ void CMapLayers::RenderKillTileBorder(int LayerIndex, ColorRGBA* pColor, CMapIte
|
|||
vec2 Offset;
|
||||
int OffX0 = (BorderX0 < -201 ? -201 : BorderX0);
|
||||
int OffX1 = (BorderX1 >= pTileLayer->m_Width + 201 ? pTileLayer->m_Width + 201 : BorderX1);
|
||||
OffX0 = clamp(OffX0, -201, (int)pTileLayer->m_Width + 201);
|
||||
OffX1 = clamp(OffX1, -201, (int)pTileLayer->m_Width + 201);
|
||||
Offset.x = OffX0 * 32.f;
|
||||
Offset.y = BorderY0 * 32.f;
|
||||
vec2 Dir;
|
||||
|
@ -1321,6 +1323,8 @@ void CMapLayers::RenderKillTileBorder(int LayerIndex, ColorRGBA* pColor, CMapIte
|
|||
vec2 Offset;
|
||||
int OffX0 = (BorderX0 < -201 ? -201 : BorderX0);
|
||||
int OffX1 = (BorderX1 >= pTileLayer->m_Width + 201 ? pTileLayer->m_Width + 201 : BorderX1);
|
||||
OffX0 = clamp(OffX0, -201, (int)pTileLayer->m_Width + 201);
|
||||
OffX1 = clamp(OffX1, -201, (int)pTileLayer->m_Width + 201);
|
||||
Offset.x = OffX0 * 32.f;
|
||||
Offset.y = (pTileLayer->m_Height + 201) * 32.f;
|
||||
vec2 Dir;
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <base/dynamic.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef STEAMAPI
|
||||
#define STEAMAPI DYNAMIC_IMPORT
|
||||
#endif
|
||||
|
@ -10,12 +12,43 @@
|
|||
extern "C"
|
||||
{
|
||||
|
||||
typedef uint64_t CSteamID;
|
||||
typedef int32_t HSteamPipe;
|
||||
typedef int32_t HSteamUser;
|
||||
|
||||
struct CallbackMsg_t
|
||||
{
|
||||
HSteamUser m_hSteamUser;
|
||||
int m_iCallback;
|
||||
unsigned char *m_pubParam;
|
||||
int m_cubParam;
|
||||
};
|
||||
|
||||
struct GameRichPresenceJoinRequested_t
|
||||
{
|
||||
enum { k_iCallback = 337 };
|
||||
CSteamID m_steamIDFriend;
|
||||
char m_rgchConnect[256];
|
||||
};
|
||||
|
||||
struct NewUrlLaunchParameters_t
|
||||
{
|
||||
enum { k_iCallback = 1014 };
|
||||
unsigned char m_EmptyStructDontUse;
|
||||
};
|
||||
|
||||
struct ISteamApps;
|
||||
struct ISteamFriends;
|
||||
|
||||
STEAMAPI bool SteamAPI_Init(); // Returns true on success.
|
||||
STEAMAPI HSteamPipe SteamAPI_GetHSteamPipe();
|
||||
STEAMAPI void SteamAPI_Shutdown();
|
||||
|
||||
STEAMAPI void SteamAPI_ManualDispatch_Init();
|
||||
STEAMAPI void SteamAPI_ManualDispatch_FreeLastCallback(HSteamPipe SteamPipe);
|
||||
STEAMAPI bool SteamAPI_ManualDispatch_GetNextCallback(HSteamPipe SteamPipe, CallbackMsg_t *pCallbackMsg);
|
||||
STEAMAPI void SteamAPI_ManualDispatch_RunFrame(HSteamPipe SteamPipe);
|
||||
|
||||
STEAMAPI ISteamApps *SteamAPI_SteamApps_v008();
|
||||
STEAMAPI int SteamAPI_ISteamApps_GetLaunchCommandLine(ISteamApps *pSelf, char *pBuffer, int BufferSize);
|
||||
STEAMAPI const char *SteamAPI_ISteamApps_GetLaunchQueryParam(ISteamApps *pSelf, const char *pKey);
|
||||
|
|
|
@ -8,7 +8,12 @@ extern "C"
|
|||
{
|
||||
|
||||
bool SteamAPI_Init() { return false; }
|
||||
HSteamPipe SteamAPI_GetHSteamPipe() { abort(); }
|
||||
void SteamAPI_Shutdown() { abort(); }
|
||||
void SteamAPI_ManualDispatch_Init() { abort(); }
|
||||
void SteamAPI_ManualDispatch_FreeLastCallback(HSteamPipe SteamPipe) { abort(); }
|
||||
bool SteamAPI_ManualDispatch_GetNextCallback(HSteamPipe SteamPipe, CallbackMsg_t *pCallbackMsg) { abort(); }
|
||||
void SteamAPI_ManualDispatch_RunFrame(HSteamPipe SteamPipe) { abort(); }
|
||||
ISteamApps *SteamAPI_SteamApps_v008() { abort(); }
|
||||
int SteamAPI_ISteamApps_GetLaunchCommandLine(ISteamApps *pSelf, char *pBuffer, int BufferSize) { abort(); }
|
||||
const char *SteamAPI_ISteamApps_GetLaunchQueryParam(ISteamApps *pSelf, const char *pKey) { abort(); }
|
||||
|
|
Loading…
Reference in a new issue