Skip to content

Commit

Permalink
Fix ddnet changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Apr 25, 2024
1 parent a3b3205 commit 7cfadf6
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 208 deletions.
12 changes: 6 additions & 6 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ void CClient::EnterGame(int Conn)
if(State() == IClient::STATE_DEMOPLAYBACK)
return;

m_CodeRunAfterJoin[Conn] = false;
m_CodeRunAfterJoinConsole[Conn] = false;
m_aCodeRunAfterJoin[Conn] = false;
m_aCodeRunAfterJoinConsole[Conn] = false;

// now we will wait for two snapshots
// to finish the connection
Expand Down Expand Up @@ -1896,10 +1896,10 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
int64_t TimeLeft = (TickStart - Now) * 1000 / time_freq();
m_aGameTime[Conn].Update(&m_GametimeMarginGraph, (GameTick - 1) * time_freq() / GameTickSpeed(), TimeLeft, CSmoothTime::ADJUSTDIRECTION_DOWN);
}
if(g_Config.m_ClRunOnJoinConsole && m_aReceivedSnapshots[Conn] > g_Config.m_ClRunOnJoinDelay && !m_CodeRunAfterJoinConsole[Conn])
if(g_Config.m_ClRunOnJoinConsole && m_aReceivedSnapshots[Conn] > g_Config.m_ClRunOnJoinDelay && !m_aCodeRunAfterJoinConsole[Conn])
{
m_pConsole->ExecuteLine(g_Config.m_ClRunOnJoin);
m_CodeRunAfterJoinConsole[Conn] = true;
m_aCodeRunAfterJoinConsole[Conn] = true;
}

if(m_aReceivedSnapshots[Conn] > GameTickSpeed() && !m_aCodeRunAfterJoin[Conn])
Expand All @@ -1911,7 +1911,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
char aBufTO[256];
str_format(aBufTO, sizeof(aBufTO), "/timeout %s", m_aTimeoutCodes[Conn]);
TOMsgp.m_pMessage = aBufTO;
CMsgPacker PackerTO(TOMsgp.ms_MsgID, false);
CMsgPacker PackerTO(TOMsgp.ms_MsgId, false);
TOMsgp.Pack(&PackerTO);
SendMsg(Conn, &PackerTO, MSGFLAG_VITAL);

Expand Down Expand Up @@ -1967,7 +1967,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
if(g_Config.m_ClRunOnJoin[0] || g_Config.m_ClDummyDefaultEyes || g_Config.m_ClPlayerDefaultEyes)
SendMsg(Conn, &PackerTimeout, MSGFLAG_VITAL);
}
m_CodeRunAfterJoin[Conn] = true;
m_aCodeRunAfterJoin[Conn] = true;
}

// ack snapshot
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CClient : public IClient, public CDemoPlayer::IListener

char m_aTimeoutCodes[NUM_DUMMIES][32] = {"", ""};
bool m_aCodeRunAfterJoin[NUM_DUMMIES] = {false, false};
bool m_CodeRunAfterJoinConsole[NUM_DUMMIES] = {false, false};
bool m_aCodeRunAfterJoinConsole[NUM_DUMMIES] = {false, false};
bool m_GenerateTimeoutSeed = true;

char m_aCmdConnect[256] = "";
Expand Down
12 changes: 5 additions & 7 deletions src/engine/shared/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ CConfigManager::CConfigManager()
m_pConsole = nullptr;
m_pStorage = nullptr;
m_ConfigFile = 0;
m_NumTCallbacks = 0;
m_Failed = false;
}

Expand Down Expand Up @@ -476,8 +475,10 @@ bool CConfigManager::TSave()
#undef MACRO_CONFIG_COL
#undef MACRO_CONFIG_STR

for(int i = 0; i < m_NumTCallbacks; i++)
m_aTCallbacks[i].m_pfnFunc(this, m_aTCallbacks[i].m_pUserData);
for(const auto &Callback : m_vTCallbacks)
{
Callback.m_pfnFunc(this, Callback.m_pUserData);
}


if(io_sync(m_ConfigFile) != 0)
Expand Down Expand Up @@ -513,10 +514,7 @@ void CConfigManager::RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData)

void CConfigManager::RegisterTCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData)
{
dbg_assert(m_NumTCallbacks < MAX_CALLBACKS, "too many tater config callbacks");
m_aTCallbacks[m_NumTCallbacks].m_pfnFunc = pfnFunc;
m_aTCallbacks[m_NumTCallbacks].m_pUserData = pUserData;
m_NumTCallbacks++;
m_vTCallbacks.emplace_back(pfnFunc, pUserData);
}


Expand Down
4 changes: 2 additions & 2 deletions src/engine/shared/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define AUTOEXEC_CLIENT_FILE "autoexec_client.cfg"
#define AUTOEXEC_SERVER_FILE "autoexec_server.cfg"
#define TCONFIG_FILE "settings_tclient.cfg"
#define MAX_CALLBACKS 64;

class CConfig
{
Expand Down Expand Up @@ -201,6 +202,7 @@ class CConfigManager : public IConfigManager
}
};
std::vector<SCallback> m_vCallbacks;
std::vector<SCallback> m_vTCallbacks;

std::vector<SConfigVariable *> m_vpAllVariables;
std::vector<SConfigVariable *> m_vpGameVariables;
Expand All @@ -211,8 +213,6 @@ class CConfigManager : public IConfigManager
static void Con_Toggle(IConsole::IResult *pResult, void *pUserData);
static void Con_ToggleStroke(IConsole::IResult *pResult, void *pUserData);

CCallback m_aTCallbacks[MAX_CALLBACKS];
int m_NumTCallbacks;

public:
CConfigManager();
Expand Down
1 change: 0 additions & 1 deletion src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ MACRO_CONFIG_INT(ClShowChatFriends, cl_show_chat_friends, 0, 0, 1, CFGFLAG_CLIEN
MACRO_CONFIG_INT(ClShowChatSystem, cl_show_chat_system, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show chat messages from the server")
MACRO_CONFIG_INT(ClShowKillMessages, cl_showkillmessages, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show kill messages")
MACRO_CONFIG_INT(ClShowFinishMessages, cl_show_finish_messages, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show finish messages")
MACRO_CONFIG_INT(ClShowVotesAfterVoting, cl_show_votes_after_voting, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show votes window after voting")
MACRO_CONFIG_INT(ClShowLocalTimeAlways, cl_show_local_time_always, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Always show local time")
MACRO_CONFIG_INT(ClShowfps, cl_showfps, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show ingame FPS counter")
MACRO_CONFIG_INT(ClShowpred, cl_showpred, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show ingame prediction time in milliseconds")
Expand Down
10 changes: 6 additions & 4 deletions src/game/client/components/bindwheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void CBindWheel::ConchainBindwheel(IConsole::IResult *pResult, void *pUserData,
pThis->updateBinds(bindpos, description, command);
}
}

void CBindWheel::OnConsoleInit()
{
IConfigManager *pConfigManager = Kernel()->RequestInterface<IConfigManager>();
Expand Down Expand Up @@ -96,7 +97,7 @@ bool CBindWheel::OnCursorMove(float x, float y, IInput::ECursorType CursorType)
return false;
}

UI()->ConvertMouseMove(&x, &y, CursorType);
Ui()->ConvertMouseMove(&x, &y, CursorType);
m_SelectorMouse += vec2(x, y);
return true;
}
Expand Down Expand Up @@ -131,9 +132,9 @@ void CBindWheel::OnRender()
if(length(m_SelectorMouse) > 110.0f)
m_SelectedBind = (int)(SelectedAngle / (2 * pi) * NUM_BINDWHEEL);

CUIRect Screen = *UI()->Screen();
CUIRect Screen = *Ui()->Screen();

UI()->MapScreen();
Ui()->MapScreen();

Graphics()->BlendNormal();

Expand Down Expand Up @@ -218,4 +219,5 @@ void CBindWheel::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserD

pConfigManager->WriteLine(aBuf);
}
}
}

24 changes: 12 additions & 12 deletions src/game/client/components/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,17 +562,17 @@ void CHud::RenderTextInfo()
char aBuf[64];
float yOff = 3;

int PlayerId = m_pClient->m_Snap.m_LocalClientID;
int PlayerId = m_pClient->m_Snap.m_LocalClientId;
if(m_pClient->m_Snap.m_SpecInfo.m_Active)
PlayerId = m_pClient->m_Snap.m_SpecInfo.m_SpectatorID;
PlayerId = m_pClient->m_Snap.m_SpecInfo.m_SpectatorId;

if(g_Config.m_ClShowhudDDRace && m_pClient->m_Snap.m_aCharacters[PlayerId].m_HasExtendedData && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW)
if(g_Config.m_ClShowhudDDRace && m_pClient->m_Snap.m_aCharacters[PlayerId].m_HasExtendedData && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW)
yOff += 50;
else if(g_Config.m_ClShowhudHealthAmmo && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW)
else if(g_Config.m_ClShowhudHealthAmmo && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW)
yOff += 27;

vec2 Pos;
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW)
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorId == SPEC_FREEVIEW)
Pos = vec2(GameClient()->m_Controls.m_aMousePos[g_Config.m_ClDummy].x, GameClient()->m_Controls.m_aMousePos[g_Config.m_ClDummy].y);
else
Pos = m_pClient->m_aClients[PlayerId].m_RenderPos;
Expand All @@ -583,7 +583,7 @@ void CHud::RenderTextInfo()
yOff += TextHeight;
str_format(aBuf, sizeof(aBuf), "Y: %.2f", Pos.y / 32.0f);
TextRender()->Text(4, yOff, FontSize, aBuf, -1.0f);
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW)
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW)
{
yOff += TextHeight;
str_format(aBuf, sizeof(aBuf), "Angle: %d", m_pClient->m_aClients[PlayerId].m_RenderCur.m_Angle);
Expand All @@ -605,9 +605,9 @@ void CHud::RenderTextInfo()
{
int NumInTeam = 0;
int NumFrozen = 0;
int LocalTeamID = m_pClient->m_Snap.m_SpecInfo.m_Active == 1 && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != -1 ?
m_pClient->m_Teams.Team(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID) :
m_pClient->m_Teams.Team(m_pClient->m_Snap.m_LocalClientID);
int LocalTeamID = m_pClient->m_Snap.m_SpecInfo.m_Active == 1 && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != -1 ?
m_pClient->m_Teams.Team(m_pClient->m_Snap.m_SpecInfo.m_SpectatorId) :
m_pClient->m_Teams.Team(m_pClient->m_Snap.m_LocalClientId);

for(int i = 0; i < MAX_CLIENTS; i++)
{
Expand Down Expand Up @@ -643,7 +643,7 @@ void CHud::RenderTextInfo()
if(g_Config.m_ClShowFrozenText > 0)
TextRender()->Text(m_Width / 2 - TextRender()->TextWidth(10, aBuf, -1, -1.0f) / 2, 12, 10, aBuf, -1.0f);

//str_format(aBuf, sizeof(aBuf), "%d", m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_PrevPredicted.m_FreezeEnd);
//str_format(aBuf, sizeof(aBuf), "%d", m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId].m_PrevPredicted.m_FreezeEnd);
//str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_ClWhatsMyPing);
//TextRender()->Text(0, m_Width / 2 - TextRender()->TextWidth(0, 10, aBuf, -1, -1.0f) / 2, 20, 10, aBuf, -1.0f);

Expand Down Expand Up @@ -773,14 +773,14 @@ void CHud::RenderTeambalanceWarning()

void CHud::RenderCursor()
{
if((!m_pClient->m_Snap.m_pLocalCharacter && !(g_Config.m_ClRenderCursorSpec && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW)) || Client()->State() == IClient::STATE_DEMOPLAYBACK)
if((!m_pClient->m_Snap.m_pLocalCharacter && !(g_Config.m_ClRenderCursorSpec && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId == SPEC_FREEVIEW)) || Client()->State() == IClient::STATE_DEMOPLAYBACK)
return;

int CurWeapon = 1;
RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);

// render cursor
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW)
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW)
CurWeapon = m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS;
Graphics()->SetColor(1.f, 1.f, 1.f, 1.f);
Graphics()->TextureSet(m_pClient->m_GameSkin.m_aSpriteWeaponCursors[CurWeapon]);
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/components/menus_browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers());
else
str_format(aBuf, sizeof(aBuf), Localize("%d of %d server"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers());
UI()->DoLabel(&ServersOnline, aBuf, 12.0f, TEXTALIGN_MR);
Ui()->DoLabel(&ServersOnline, aBuf, 12.0f, TEXTALIGN_MR);

int NumPlayers = 0;
for(int i = 0; i < ServerBrowser()->NumSortedServers(); i++)
Expand All @@ -576,7 +576,7 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
str_format(aBuf, sizeof(aBuf), Localize("%d players"), NumPlayers);
else
str_format(aBuf, sizeof(aBuf), Localize("%d player"), NumPlayers);
UI()->DoLabel(&PlayersOnline, aBuf, 12.0f, TEXTALIGN_MR);
Ui()->DoLabel(&PlayersOnline, aBuf, 12.0f, TEXTALIGN_MR);
}

// address info
Expand Down
Loading

0 comments on commit 7cfadf6

Please sign in to comment.