Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
SollyBunny committed Nov 21, 2024
1 parent 1b3463f commit 1c1a676
Show file tree
Hide file tree
Showing 29 changed files with 390 additions and 430 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,7 @@ set_src(ENGINE_SHARED GLOB_RECURSE src/engine/shared
storage.cpp
stun.cpp
stun.h
tater_variables.h
teehistorian_ex.cpp
teehistorian_ex.h
teehistorian_ex_chunks.h
Expand Down Expand Up @@ -2171,7 +2172,6 @@ set_src(GAME_SHARED GLOB src/game
mapitems_ex_types.h
prng.cpp
prng.h
tater_variables.h
teamscore.cpp
teamscore.h
tuning.h
Expand Down
8 changes: 4 additions & 4 deletions src/engine/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class IClient : public IInterface
};

/**
* More precise state for @see STATE_LOADING
* Sets what is actually happening in the client right now
*/
* More precise state for @see STATE_LOADING
* Sets what is actually happening in the client right now
*/
enum ELoadingStateDetail
{
LOADING_STATE_DETAIL_INITIAL,
Expand Down Expand Up @@ -268,7 +268,7 @@ class IClient : public IInterface

virtual IGraphics::CTextureHandle GetDebugFont() const = 0; // TODO: remove this function

//DDRace
// DDRace

virtual const char *GetCurrentMap() const = 0;
virtual const char *GetCurrentMapPath() const = 0;
Expand Down
5 changes: 2 additions & 3 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,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(CNetMsg_Cl_Say::ms_MsgId, false);
TOMsgp.Pack(&PackerTO);
SendMsg(Conn, &PackerTO, MSGFLAG_VITAL);

Expand Down Expand Up @@ -3371,8 +3371,7 @@ bool CClient::InitNetworkClient(char *pError, size_t ErrorSize)
BindAddr.type = NETTYPE_ALL;
for(unsigned int i = 0; i < std::size(m_aNetClient); i++)
{
int &PortRef = i == CONN_MAIN ? g_Config.m_ClPort : i == CONN_DUMMY ? g_Config.m_ClDummyPort :
g_Config.m_ClContactPort;
int &PortRef = i == CONN_MAIN ? g_Config.m_ClPort : i == CONN_DUMMY ? g_Config.m_ClDummyPort : g_Config.m_ClContactPort;
if(PortRef < 1024) // Reject users setting ports that we don't want to use
{
PortRef = 0;
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 @@ -507,7 +507,7 @@ class CClient : public IClient, public CDemoPlayer::IListener

IFriends *Foes() override { return &m_Foes; }

void GetSmoothFreezeTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) override;
void GetSmoothFreezeTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) override;
void GetSmoothTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) override;

void AddWarning(const SWarning &Warning) override;
Expand Down
4 changes: 1 addition & 3 deletions src/engine/shared/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ bool CConfigManager::TSave()
WriteLine(aLineBuf); \
}

#include "././game/tater_variables.h"
#include "tater_variables.h"

#undef MACRO_CONFIG_INT
#undef MACRO_CONFIG_COL
Expand All @@ -485,7 +485,6 @@ bool CConfigManager::TSave()
Callback.m_pfnFunc(this, Callback.m_pUserData);
}


if(io_sync(m_ConfigFile) != 0)
{
m_Failed = true;
Expand Down Expand Up @@ -522,7 +521,6 @@ void CConfigManager::RegisterTCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData
m_vTCallbacks.emplace_back(pfnFunc, pUserData);
}


void CConfigManager::WriteLine(const char *pLine)
{
if(!m_ConfigFile ||
Expand Down
1 change: 0 additions & 1 deletion src/engine/shared/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ class CConfigManager : public IConfigManager
static void Con_Toggle(IConsole::IResult *pResult, void *pUserData);
static void Con_ToggleStroke(IConsole::IResult *pResult, void *pUserData);


public:
CConfigManager();

Expand Down
2 changes: 1 addition & 1 deletion src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define MACRO_CONFIG_STR(Name, ScriptName, Len, Def, Save, Desc) ;
#endif

#include "././game/tater_variables.h"
#include "tater_variables.h"

// client
MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Predict client movements")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file can be included several times.

#ifndef MACRO_CONFIG_INT
#error "The config macros must be defined"
Expand Down Expand Up @@ -129,4 +130,4 @@ MACRO_CONFIG_INT(ClRainbowOthers, tc_rainbow_others, 0, 0, 1, CFGFLAG_CLIENT | C
MACRO_CONFIG_INT(ClRainbowMode, tc_rainbow_mode, 1, 1, 4, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Rainbow mode (1: rainbow, 2: pulse, 3: darkness)")

// AAAAAAA
MACRO_CONFIG_INT(ClAmIFrozen, EEEfrz, 0, 0, 1, CFGFLAG_CLIENT, "")
MACRO_CONFIG_INT(ClAmIFrozen, EEEfrz, 0, 0, 1, CFGFLAG_CLIENT, "")
2 changes: 1 addition & 1 deletion src/game/client/components/binds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void CBinds::SetDefaults()
Bind(KEY_MOUSE_1, "+fire");
Bind(KEY_MOUSE_2, "+hook");
Bind(KEY_LSHIFT, "+emote");
Bind(KEY_Q, "+bindwheel");
Bind(KEY_Q, "+bindwheel");
Bind(KEY_RETURN, "+show_chat; chat all");
Bind(KEY_RIGHT, "spectate_next");
Bind(KEY_LEFT, "spectate_previous");
Expand Down
90 changes: 45 additions & 45 deletions src/game/client/components/bindwheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ void CBindWheel::ConBindwheel(IConsole::IResult *pResult, void *pUserData)

void CBindWheel::ConBind(IConsole::IResult *pResult, void *pUserData)
{
int bindpos = pResult->GetInteger(0);
char command[MAX_BINDWHEEL_CMD];
char description[MAX_BINDWHEEL_DESC];
str_format(description, sizeof(description), "%s", pResult->GetString(1));
str_format(command, sizeof(command), "%s", pResult->GetString(2));
int BindPos = pResult->GetInteger(0);
char Command[MAX_BINDWHEEL_CMD];
char Description[MAX_BINDWHEEL_DESC];
str_format(Description, sizeof(Description), "%s", pResult->GetString(1));
str_format(Command, sizeof(Command), "%s", pResult->GetString(2));

CBindWheel *pThis = static_cast<CBindWheel *>(pUserData);
pThis->updateBinds(bindpos, description, command);
pThis->updateBinds(BindPos, Description, Command);
}

void CBindWheel::ConchainBindwheel(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
pfnCallback(pResult, pCallbackUserData);
if(pResult->NumArguments() == 3)
{
int bindpos = pResult->GetInteger(0);
char command[MAX_BINDWHEEL_CMD];
char description[MAX_BINDWHEEL_DESC];
str_format(description, sizeof(description), "%s", pResult->GetString(1));
str_format(command, sizeof(command), "%s", pResult->GetString(2));
int BindPos = pResult->GetInteger(0);
char Command[MAX_BINDWHEEL_CMD];
char Description[MAX_BINDWHEEL_DESC];
str_format(Description, sizeof(Description), "%s", pResult->GetString(1));
str_format(Command, sizeof(Command), "%s", pResult->GetString(2));

CBindWheel *pThis = static_cast<CBindWheel *>(pUserData);
pThis->updateBinds(bindpos, description, command);
pThis->updateBinds(BindPos, Description, Command);
}
}

Expand All @@ -61,19 +61,19 @@ void CBindWheel::OnConsoleInit()
pConfigManager->RegisterTCallback(ConfigSaveCallback, this);

Console()->Register("+bindwheel", "", CFGFLAG_CLIENT, ConBindwheel, this, "Open bindwheel selector");
Console()->Register("bindwheel", "i[bindwheel] s[description:128] s[command:10]", CFGFLAG_CLIENT, ConBind, this, "Edit the command");
Console()->Register("bindwheel", "i[bindwheel] s[Description:128] s[Command:10]", CFGFLAG_CLIENT, ConBind, this, "Edit the Command");
Console()->Chain("bindwheel", ConchainBindwheel, this);

for(int i = 0; i < NUM_BINDWHEEL; i++)
{
if(!(str_comp(m_BindWheelList[i].description, "EMPTY") == 0))
if(!(str_comp(m_BindWheelList[i].Description, "EMPTY") == 0))
{
str_format(m_BindWheelList[i].description, sizeof(m_BindWheelList[i].description), "%s", "EMPTY");
str_format(m_BindWheelList[i].Description, sizeof(m_BindWheelList[i].Description), "%s", "EMPTY");
}

if(str_comp(m_BindWheelList[i].command, "") == 0)
if(str_comp(m_BindWheelList[i].Command, "") == 0)
{
str_format(m_BindWheelList[i].command, sizeof(m_BindWheelList[i].command), "%s", "");
str_format(m_BindWheelList[i].Command, sizeof(m_BindWheelList[i].Command), "%s", "");
}
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ void CBindWheel::OnRender()
if(!m_Active)
{
if(g_Config.m_ClResetBindWheelMouse)
m_SelectorMouse = vec2(0, 0);
m_SelectorMouse = vec2(0.0f, 0.0f);
if(m_WasActive && m_SelectedBind != -1)
Binwheel(m_SelectedBind);
m_WasActive = false;
Expand All @@ -124,13 +124,13 @@ void CBindWheel::OnRender()
if(length(m_SelectorMouse) > 170.0f)
m_SelectorMouse = normalize(m_SelectorMouse) * 170.0f;

float SelectedAngle = angle(m_SelectorMouse) + 2 * pi / 24;
if(SelectedAngle < 0)
SelectedAngle += 2 * pi;
float SelectedAngle = angle(m_SelectorMouse) + 2.0f * pi / 24.0f;
if(SelectedAngle < 0.0f)
SelectedAngle += 2.0f * pi;

m_SelectedBind = -1;
if(length(m_SelectorMouse) > 110.0f)
m_SelectedBind = (int)(SelectedAngle / (2 * pi) * NUM_BINDWHEEL);
m_SelectedBind = (int)(SelectedAngle / (2.0f * pi) * NUM_BINDWHEEL);

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

Expand All @@ -140,32 +140,32 @@ void CBindWheel::OnRender()

Graphics()->TextureClear();
Graphics()->QuadsBegin();
Graphics()->SetColor(0, 0, 0, 0.3f);
DrawCircle(Screen.w / 2, Screen.h / 2, 190.0f, 64);
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.3f);
DrawCircle(Screen.w / 2.0f, Screen.h / 2.0f, 190.0f, 64);
Graphics()->QuadsEnd();

Graphics()->WrapClamp();
for(int i = 0; i < NUM_BINDWHEEL; i++)
{
float Angle = 2 * pi * i / NUM_BINDWHEEL;
float margin = 140.0f;
float Angle = 2.0f * pi * i / NUM_BINDWHEEL;
float Margin = 140.0f;

if(Angle > pi)
{
Angle -= 2 * pi;
Angle -= 2.0f * pi;
}
bool Selected = m_SelectedBind == i;

float Size = Selected ? 14.0 : 12.0f;
float Size = Selected ? 14.0f : 12.0f;

float NudgeX = margin * cosf(Angle);
float NudgeX = Margin * cosf(Angle);
float NudgeY = 150.0f * sinf(Angle);

char aBuf[MAX_BINDWHEEL_DESC];
str_format(aBuf, sizeof(aBuf), "%s", m_BindWheelList[i].description);
str_format(aBuf, sizeof(aBuf), "%s", m_BindWheelList[i].Description);
// str_format(aBuf, sizeof(aBuf), "%d -> %d", inv, orgAngle);
float x = Screen.w / 2 + NudgeX - TextRender()->TextWidth(Size, aBuf, -1, -1.0f) * 0.5;
float y = Screen.h / 2 + NudgeY;
float x = Screen.w / 2.0f + NudgeX - TextRender()->TextWidth(Size, aBuf, -1.0f, -1.0f) * 0.5f;
float y = Screen.h / 2.0f + NudgeY;
float LineWidth = -1.0f;
TextRender()->Text(x, y, Size, aBuf, LineWidth);
}
Expand All @@ -175,33 +175,33 @@ void CBindWheel::OnRender()
{
Graphics()->TextureClear();
Graphics()->QuadsBegin();
Graphics()->SetColor(1.0, 1.0, 1.0, 0.3f);
DrawCircle(Screen.w / 2, Screen.h / 2, 100.0f, 64);
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.3f);
DrawCircle(Screen.w / 2.0f, Screen.h / 2.0f, 100.0f, 64);
Graphics()->QuadsEnd();

Graphics()->TextureClear();
Graphics()->QuadsBegin();
Graphics()->SetColor(0, 0, 0, 0.3f);
DrawCircle(Screen.w / 2, Screen.h / 2, 30.0f, 64);
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.3f);
DrawCircle(Screen.w / 2.0f, Screen.h / 2.0f, 30.0f, 64);
Graphics()->QuadsEnd();
}

RenderTools()->RenderCursor(m_SelectorMouse + vec2(Screen.w, Screen.h) / 2, 24.0f);
RenderTools()->RenderCursor(m_SelectorMouse + vec2(Screen.w, Screen.h) / 2.0f, 24.0f);
}

void CBindWheel::Binwheel(int Bind)
{
// bindwheel 0 "123456789" "say hey"
Console()->ExecuteLine(m_BindWheelList[Bind].command);
Console()->ExecuteLine(m_BindWheelList[Bind].Command);
}

void CBindWheel::updateBinds(int Bindpos, char *Description, char *Command)
void CBindWheel::updateBinds(int BindPos, char *Description, char *Command)
{
str_format(m_BindWheelList[Bindpos].command, sizeof(m_BindWheelList[Bindpos].command), "%s", Command);
str_format(m_BindWheelList[Bindpos].description, sizeof(m_BindWheelList[Bindpos].description), "%s", Description);
str_format(m_BindWheelList[BindPos].Command, sizeof(m_BindWheelList[BindPos].Command), "%s", Command);
str_format(m_BindWheelList[BindPos].Description, sizeof(m_BindWheelList[BindPos].Description), "%s", Description);

char aBuf[512];
str_format(aBuf, sizeof(aBuf), "[%d]: '%s' -> '%s'", Bindpos, m_BindWheelList[Bindpos].description, m_BindWheelList[Bindpos].command);
str_format(aBuf, sizeof(aBuf), "[%d]: '%s' -> '%s'", BindPos, m_BindWheelList[BindPos].Description, m_BindWheelList[BindPos].Command);

Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "updateBinds", aBuf);
}
Expand All @@ -213,9 +213,9 @@ void CBindWheel::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserD
char aBuf[128] = {};
for(int i = 0; i < NUM_BINDWHEEL; ++i)
{
char *command = pSelf->m_BindWheelList[i].command;
char *description = pSelf->m_BindWheelList[i].description;
str_format(aBuf, sizeof(aBuf), "bindwheel %d \"%s\" \"%s\"", i, description, command);
char *Command = pSelf->m_BindWheelList[i].Command;
char *Description = pSelf->m_BindWheelList[i].Description;
str_format(aBuf, sizeof(aBuf), "bindwheel %d \"%s\" \"%s\"", i, Description, Command);

pConfigManager->WriteLine(aBuf);
}
Expand Down
14 changes: 6 additions & 8 deletions src/game/client/components/bindwheel.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#ifndef GAME_CLIENT_COMPONENTS_BIND_WHEEL_H
#define GAME_CLIENT_COMPONENTS_BIND_WHEEL_H
#ifndef GAME_CLIENT_COMPONENTS_BINDWHEEL_H
#define GAME_CLIENT_COMPONENTS_BINDWHEEL_H
#include <game/client/component.h>
class IConfigManager;

Expand All @@ -10,7 +10,7 @@ class IConfigManager;

class CBindWheel : public CComponent
{
void DrawCircle(float x, float y, float r, int Segments);
void DrawCircle(float x, float y, float r, int Segments);

bool m_WasActive;
bool m_Active;
Expand All @@ -25,12 +25,11 @@ class CBindWheel : public CComponent
public:
struct SClientBindWheel
{
char description[MAX_BINDWHEEL_DESC];
char command[MAX_BINDWHEEL_CMD];
char Description[MAX_BINDWHEEL_DESC];
char Command[MAX_BINDWHEEL_CMD];
};
SClientBindWheel m_BindWheelList[NUM_BINDWHEEL];


CBindWheel();
virtual int Sizeof() const override { return sizeof(*this); }

Expand All @@ -40,10 +39,9 @@ class CBindWheel : public CComponent
virtual void OnRelease() override;
virtual bool OnCursorMove(float x, float y, IInput::ECursorType CursorType) override;
static void ConchainBindwheel(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);

void updateBinds(int Bindpos, char *Description, char *Command);
void Binwheel(int Bind);

};

#endif
2 changes: 1 addition & 1 deletion src/game/client/components/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */

#include <engine/editor.h>
#include <engine/external/remimu.h>
#include <engine/graphics.h>
#include <engine/keys.h>
#include <engine/shared/config.h>
Expand All @@ -19,7 +20,6 @@
#include <game/localization.h>

#include "chat.h"
#include "engine/external/remimu.h"

char CChat::ms_aDisplayText[MAX_LINE_LENGTH] = {'\0'};

Expand Down
6 changes: 1 addition & 5 deletions src/game/client/components/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,5 @@ bool CControls::CheckNewInput()

m_FastInput = TestInput;

if (NewInput)
{
return true;
}
return false;
return NewInput;
}
Loading

0 comments on commit 1c1a676

Please sign in to comment.