sv_gametype ctf
let explode s = String.to_seq s |> List.of_seq
let rec reverse_chars s =
match s with [] -> "" | h :: t -> reverse_chars t ^ Char.escaped h
let reverse_string (s : string) : string = explode s |> reverse_chars
let reverse_string2 (s : string) : string =
String.to_seq s |> List.of_seq |> List.rev |> List.to_seq |> String.of_seq
struct Bar {}
struct Baz {}
enum Foo = Bar | Baz;
let foo: Foo = Bar {};
switch foo {
case Bar bar:
// bar contains struct of type Bar
case Baz baz:
// baz contains struct of type Baz
}
Here's one of possible syntaxesT
.(0.0 / 0.0).is_sign_positive()
can produce a different result when executed at compile-time vs at run-time. This is not a bug, and code must not rely on a const fn always producing the exact same result.(0.0 / 0.0).is_sign_positive()
can produce a different result when executed at compile-time vs at run-time. This is not a bug, and code must not rely on a const fn always producing the exact same result.hackneyed
= lacking creativityrapacious
= very greedyscintillating
= impressively clever, amusing or wittyscintillare
= to sparkleCGameClient
instead of in CGhost
, as the value is also used in the gameclient.
Move current race time calculation from CClient
to CGameClient
, as this function is not used in the engine and this allows removing unnecessary virtual functions.
Closes #1720.
return NewInput
) (edited)return NewInput
) (edited)if
fit better?if
fit better? bool CControls::CheckNewInput()
{
CNetObj_PlayerInput TestInput = m_aInputData[g_Config.m_ClDummy];
TestInput.m_Direction = 0;
if(m_aInputDirectionLeft[g_Config.m_ClDummy] && !m_aInputDirectionRight[g_Config.m_ClDummy])
TestInput.m_Direction = -1;
if(!m_aInputDirectionLeft[g_Config.m_ClDummy] && m_aInputDirectionRight[g_Config.m_ClDummy])
TestInput.m_Direction = 1;
bool NewInput = false;
if(m_FastInput.m_Direction != TestInput.m_Direction)
NewInput = true;
if(m_FastInput.m_Hook != TestInput.m_Hook)
NewInput = true;
if(m_FastInput.m_Fire != TestInput.m_Fire)
NewInput = true;
if(m_FastInput.m_Jump != TestInput.m_Jump)
NewInput = true;
if(m_FastInput.m_NextWeapon != TestInput.m_NextWeapon)
NewInput = true;
if(m_FastInput.m_PrevWeapon != TestInput.m_PrevWeapon)
NewInput = true;
if(m_FastInput.m_WantedWeapon != TestInput.m_WantedWeapon)
NewInput = true;
// this is edited btw
if(g_Config.m_ClSubTickAiming)
{
vec2 mouse = m_aMousePos[g_Config.m_ClDummy];
mouse *= (float)g_Config.m_ClMousePositionMultiplier / 100.0f;
if(!g_Config.m_ClOldMouseZoom)
mouse *= m_pClient->m_Camera.m_Zoom;
TestInput.m_TargetX = (int)mouse.x;
TestInput.m_TargetY = (int)mouse.y;
}
m_FastInput = TestInput;
if (NewInput)
{
return true;
}
return false;
}
theres no other early returns, and NewInput is also a flag so theres no cast (edited)bool CControls::CheckNewInput()
{
CNetObj_PlayerInput TestInput = m_aInputData[g_Config.m_ClDummy];
TestInput.m_Direction = 0;
if(m_aInputDirectionLeft[g_Config.m_ClDummy] && !m_aInputDirectionRight[g_Config.m_ClDummy])
TestInput.m_Direction = -1;
if(!m_aInputDirectionLeft[g_Config.m_ClDummy] && m_aInputDirectionRight[g_Config.m_ClDummy])
TestInput.m_Direction = 1;
bool NewInput = false;
if(m_FastInput.m_Direction != TestInput.m_Direction)
NewInput = true;
if(m_FastInput.m_Hook != TestInput.m_Hook)
NewInput = true;
if(m_FastInput.m_Fire != TestInput.m_Fire)
NewInput = true;
if(m_FastInput.m_Jump != TestInput.m_Jump)
NewInput = true;
if(m_FastInput.m_NextWeapon != TestInput.m_NextWeapon)
NewInput = true;
if(m_FastInput.m_PrevWeapon != TestInput.m_PrevWeapon)
NewInput = true;
if(m_FastInput.m_WantedWeapon != TestInput.m_WantedWeapon)
NewInput = true;
// this is edited btw
if(g_Config.m_ClSubTickAiming)
{
vec2 mouse = m_aMousePos[g_Config.m_ClDummy];
mouse *= (float)g_Config.m_ClMousePositionMultiplier / 100.0f;
if(!g_Config.m_ClOldMouseZoom)
mouse *= m_pClient->m_Camera.m_Zoom;
TestInput.m_TargetX = (int)mouse.x;
TestInput.m_TargetY = (int)mouse.y;
}
m_FastInput = TestInput;
if (NewInput)
{
return true;
}
return false;
}
theres no other early returns, and NewInput is also a flag so theres no cast (edited)bool CControls::CheckNewInput()
{
CNetObj_PlayerInput TestInput = m_aInputData[g_Config.m_ClDummy];
TestInput.m_Direction = 0;
if(m_aInputDirectionLeft[g_Config.m_ClDummy] && !m_aInputDirectionRight[g_Config.m_ClDummy])
TestInput.m_Direction = -1;
if(!m_aInputDirectionLeft[g_Config.m_ClDummy] && m_aInputDirectionRight[g_Config.m_ClDummy])
TestInput.m_Direction = 1;
bool NewInput = false;
if(m_FastInput.m_Direction != TestInput.m_Direction)
NewInput = true;
if(m_FastInput.m_Hook != TestInput.m_Hook)
NewInput = true;
if(m_FastInput.m_Fire != TestInput.m_Fire)
NewInput = true;
if(m_FastInput.m_Jump != TestInput.m_Jump)
NewInput = true;
if(m_FastInput.m_NextWeapon != TestInput.m_NextWeapon)
NewInput = true;
if(m_FastInput.m_PrevWeapon != TestInput.m_PrevWeapon)
NewInput = true;
if(m_FastInput.m_WantedWeapon != TestInput.m_WantedWeapon)
NewInput = true;
// this is edited btw
if(g_Config.m_ClSubTickAiming)
{
vec2 mouse = m_aMousePos[g_Config.m_ClDummy];
mouse *= (float)g_Config.m_ClMousePositionMultiplier / 100.0f;
if(!g_Config.m_ClOldMouseZoom)
mouse *= m_pClient->m_Camera.m_Zoom;
TestInput.m_TargetX = (int)mouse.x;
TestInput.m_TargetY = (int)mouse.y;
}
m_FastInput = TestInput;
if (NewInput)
{
return true;
}
return false;
}
theres no other early returns, and NewInput is also a flag so theres no cast (edited)return NewInput;
as you say bool CControls::CheckNewInput()
{
CNetObj_PlayerInput TestInput = m_aInputData[g_Config.m_ClDummy];
TestInput.m_Direction = 0;
if(m_aInputDirectionLeft[g_Config.m_ClDummy] && !m_aInputDirectionRight[g_Config.m_ClDummy])
TestInput.m_Direction = -1;
if(!m_aInputDirectionLeft[g_Config.m_ClDummy] && m_aInputDirectionRight[g_Config.m_ClDummy])
TestInput.m_Direction = 1;
bool NewInput = false;
if(m_FastInput.m_Direction != TestInput.m_Direction)
NewInput = true;
if(m_FastInput.m_Hook != TestInput.m_Hook)
NewInput = true;
if(m_FastInput.m_Fire != TestInput.m_Fire)
NewInput = true;
if(m_FastInput.m_Jump != TestInput.m_Jump)
NewInput = true;
if(m_FastInput.m_NextWeapon != TestInput.m_NextWeapon)
NewInput = true;
if(m_FastInput.m_PrevWeapon != TestInput.m_PrevWeapon)
NewInput = true;
if(m_FastInput.m_WantedWeapon != TestInput.m_WantedWeapon)
NewInput = true;
// this is edited btw
if(g_Config.m_ClSubTickAiming)
{
vec2 mouse = m_aMousePos[g_Config.m_ClDummy];
mouse *= (float)g_Config.m_ClMousePositionMultiplier / 100.0f;
if(!g_Config.m_ClOldMouseZoom)
mouse *= m_pClient->m_Camera.m_Zoom;
TestInput.m_TargetX = (int)mouse.x;
TestInput.m_TargetY = (int)mouse.y;
}
m_FastInput = TestInput;
if (NewInput)
{
return true;
}
return false;
}
theres no other early returns, and NewInput is also a flag so theres no cast (edited)NewInput |= ...
insteadNewInput |= ...
instead chatgpt, the oracle of knoledge first had to be told that im talking about |= and not ||=
but once i get it to first say |= it then says
NewInput |= ...
expands to NewInput = NewInput | ...
which as NewInput is a bool is the same as
NewInput = NewInput || ...
which can short circuit if NewInput is true, which doesnt make much sense
as the short circuit would take 1 instruction (if NewInput is true)
whilst a non short circuit would take 2 instrucitons (if NewInput is false)
(edited)