Reverted 1 Letter Refactoring or Edited it to a full name.

This commit is contained in:
GreYFoXGTi 2011-02-13 08:47:51 +02:00 committed by oy
parent 7bfbe24a1c
commit 68a1a29db8
6 changed files with 62 additions and 62 deletions

View file

@ -51,30 +51,30 @@ void CCollision::Init(class CLayers *pLayers)
}
}
int CCollision::GetTile(int X, int Y)
int CCollision::GetTile(int x, int y)
{
int Nx = clamp(X/32, 0, m_Width-1);
int Ny = clamp(Y/32, 0, m_Height-1);
int Nx = clamp(x/32, 0, m_Width-1);
int Ny = clamp(y/32, 0, m_Height-1);
return m_pTiles[Ny*m_Width+Nx].m_Index > 128 ? 0 : m_pTiles[Ny*m_Width+Nx].m_Index;
}
bool CCollision::IsTileSolid(int X, int Y)
bool CCollision::IsTileSolid(int x, int y)
{
return GetTile(X, Y)&COLFLAG_SOLID;
return GetTile(x, y)&COLFLAG_SOLID;
}
// TODO: rewrite this smarter!
int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
{
float D = distance(Pos0, Pos1);
int End(D+1);
float Distance = distance(Pos0, Pos1);
int End(Distance+1);
vec2 Last = Pos0;
for(int i = 0; i < End; i++)
{
float A = i/D;
vec2 Pos = mix(Pos0, Pos1, A);
float PointOnLine = i/Distance;
vec2 Pos = mix(Pos0, Pos1, PointOnLine);
if(CheckPoint(Pos.x, Pos.y))
{
if(pOutCollision)

View file

@ -25,9 +25,9 @@ public:
CCollision();
void Init(class CLayers *pLayers);
bool CheckPoint(float X, float Y) { return IsTileSolid(round(X), round(Y)); }
bool CheckPoint(vec2 P) { return CheckPoint(P.x, P.y); }
int GetCollisionAt(float X, float Y) { return GetTile(round(X), round(Y)); }
bool CheckPoint(float x, float y) { return IsTileSolid(round(x), round(y)); }
bool CheckPoint(vec2 Pos) { return CheckPoint(Pos.x, Pos.y); }
int GetCollisionAt(float x, float y) { return GetTile(round(x), round(y)); }
int GetWidth() { return m_Width; };
int GetHeight() { return m_Height; };
int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);

View file

@ -20,19 +20,19 @@ static struct
static int g_UiNumPopups = 0;
void CEditor::UiInvokePopupMenu(void *pID, int Flags, float X, float Y, float W, float H, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect), void *pExtra)
void CEditor::UiInvokePopupMenu(void *pID, int Flags, float x, float y, float Width, float Height, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect), void *pExtra)
{
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "editor", "invoked");
if(X + W > UI()->Screen()->w)
X -= W;
if(Y + H > UI()->Screen()->h)
Y -= H;
if(x + Width > UI()->Screen()->w)
x -= Width;
if(y + Height > UI()->Screen()->h)
y -= Height;
s_UiPopups[g_UiNumPopups].m_pId = pID;
s_UiPopups[g_UiNumPopups].m_IsMenu = Flags;
s_UiPopups[g_UiNumPopups].m_Rect.x = X;
s_UiPopups[g_UiNumPopups].m_Rect.y = Y;
s_UiPopups[g_UiNumPopups].m_Rect.w = W;
s_UiPopups[g_UiNumPopups].m_Rect.h = H;
s_UiPopups[g_UiNumPopups].m_Rect.x = x;
s_UiPopups[g_UiNumPopups].m_Rect.y = y;
s_UiPopups[g_UiNumPopups].m_Rect.w = Width;
s_UiPopups[g_UiNumPopups].m_Rect.h = Height;
s_UiPopups[g_UiNumPopups].m_pfnFunc = pfnFunc;
s_UiPopups[g_UiNumPopups].m_pExtra = pExtra;
g_UiNumPopups++;

View file

@ -43,9 +43,9 @@ bool CTuningParams::Get(const char *pName, float *pValue)
return false;
}
float HermiteBasis1(float V)
float HermiteBasis1(float v)
{
return 2*V*V*V - 3*V*V+1;
return 2*v*v*v - 3*v*v+1;
}
float VelocityRamp(float Value, float Start, float Range, float Curvature)
@ -100,16 +100,16 @@ void CCharacterCore::Tick(bool UseInput)
m_Direction = m_Input.m_Direction;
// setup angle
float A = 0;
float a = 0;
if(m_Input.m_TargetX == 0)
A = atanf((float)m_Input.m_TargetY);
a = atanf((float)m_Input.m_TargetY);
else
A = atanf((float)m_Input.m_TargetY/(float)m_Input.m_TargetX);
a = atanf((float)m_Input.m_TargetY/(float)m_Input.m_TargetX);
if(m_Input.m_TargetX < 0)
A = A+pi;
a = a+pi;
m_Angle = (int)(A*256.0f);
m_Angle = (int)(a*256.0f);
// handle jump
if(m_Input.m_Jump)
@ -209,7 +209,7 @@ void CCharacterCore::Tick(bool UseInput)
// Check against other players first
if(m_pWorld && m_pWorld->m_Tuning.m_PlayerHooking)
{
float Dist = 0.0f;
float Distance = 0.0f;
for(int i = 0; i < MAX_CLIENTS; i++)
{
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[i];
@ -219,12 +219,12 @@ void CCharacterCore::Tick(bool UseInput)
vec2 ClosestPoint = closest_point_on_line(m_HookPos, NewPos, pCharCore->m_Pos);
if(distance(pCharCore->m_Pos, ClosestPoint) < PhysSize+2.0f)
{
if (m_HookedPlayer == -1 || distance(m_HookPos, pCharCore->m_Pos) < Dist)
if (m_HookedPlayer == -1 || distance(m_HookPos, pCharCore->m_Pos) < Distance)
{
m_TriggeredEvents |= COREEVENT_HOOK_ATTACH_PLAYER;
m_HookState = HOOK_GRABBED;
m_HookedPlayer = i;
Dist = distance(m_HookPos, pCharCore->m_Pos);
Distance = distance(m_HookPos, pCharCore->m_Pos);
}
}
}
@ -315,28 +315,28 @@ void CCharacterCore::Tick(bool UseInput)
continue; // make sure that we don't nudge our self
// handle player <-> player collision
float D = distance(m_Pos, pCharCore->m_Pos);
float Distance = distance(m_Pos, pCharCore->m_Pos);
vec2 Dir = normalize(m_Pos - pCharCore->m_Pos);
if(D < PhysSize*1.25f && D > 1.0f)
if(Distance < PhysSize*1.25f && Distance > 1.0f)
{
float A = (PhysSize*1.45f - D);
float V = 0.5f;
float a = (PhysSize*1.45f - Distance);
float Velocity = 0.5f;
// make sure that we don't add excess force by checking the
// direction against the current velocity. if not zero.
if (length(m_Vel) > 0.0001)
V = 1-(dot(normalize(m_Vel), Dir)+1)/2;
Velocity = 1-(dot(normalize(m_Vel), Dir)+1)/2;
m_Vel += Dir*A*(V*0.75f);
m_Vel += Dir*a*(Velocity*0.75f);
m_Vel *= 0.85f;
}
// handle hook influence
if(m_HookedPlayer == i)
{
if(D > PhysSize*1.50f) // TODO: fix tweakable variable
if(Distance > PhysSize*1.50f) // TODO: fix tweakable variable
{
float Accel = m_pWorld->m_Tuning.m_HookDragAccel * (D/m_pWorld->m_Tuning.m_HookLength);
float Accel = m_pWorld->m_Tuning.m_HookDragAccel * (Distance/m_pWorld->m_Tuning.m_HookLength);
float DragSpeed = m_pWorld->m_Tuning.m_HookDragSpeed;
// add force to the hooked player

View file

@ -54,19 +54,19 @@ inline vec2 GetDirection(int Angle)
return vec2(cosf(a), sinf(a));
}
inline vec2 GetDir(float A)
inline vec2 GetDir(float Angle)
{
return vec2(cosf(A), sinf(A));
return vec2(cosf(Angle), sinf(Angle));
}
inline float GetAngle(vec2 Dir)
{
if(Dir.x == 0 && Dir.y == 0)
return 0.0f;
float A = atanf(Dir.y/Dir.x);
float a = atanf(Dir.y/Dir.x);
if(Dir.x < 0)
A = A+pi;
return A;
a = a+pi;
return a;
}
inline void StrToInts(int *pInts, int Num, const char *pStr)
@ -105,13 +105,13 @@ inline void IntsToStr(const int *pInts, int Num, char *pStr)
inline vec2 CalcPos(vec2 P, vec2 V, float Curvature, float Speed, float T)
inline vec2 CalcPos(vec2 Pos, vec2 Velocity, float Curvature, float Speed, float Time)
{
vec2 N;
T *= Speed;
N.x = P.x + V.x*T;
N.y = P.y + V.y*T + Curvature/10000*(T*T);
return N;
vec2 n;
Time *= Speed;
n.x = Pos.x + Velocity.x*Time;
n.y = Pos.y + Velocity.y*Time + Curvature/10000*(Time*Time);
return n;
}

View file

@ -83,19 +83,19 @@ class CCharacter *CGameContext::GetPlayerChar(int ClientID)
void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount)
{
float A = 3 * 3.14159f / 2 + Angle;
float a = 3 * 3.14159f / 2 + Angle;
//float a = get_angle(dir);
float S = A-pi/3;
float E = A+pi/3;
float s = a-pi/3;
float e = a+pi/3;
for(int i = 0; i < Amount; i++)
{
float F = mix(S, E, float(i+1)/float(Amount+2));
float f = mix(s, e, float(i+1)/float(Amount+2));
NETEVENT_DAMAGEIND *pEvent = (NETEVENT_DAMAGEIND *)m_Events.Create(NETEVENTTYPE_DAMAGEIND, sizeof(NETEVENT_DAMAGEIND));
if(pEvent)
{
pEvent->m_X = (int)Pos.x;
pEvent->m_Y = (int)Pos.y;
pEvent->m_Angle = (int)(F*256.0f);
pEvent->m_Angle = (int)(f*256.0f);
}
}
}
@ -145,14 +145,14 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag
}
/*
void create_smoke(vec2 P)
void create_smoke(vec2 Pos)
{
// create the event
EV_EXPLOSION *pEvent = (EV_EXPLOSION *)events.create(EVENT_SMOKE, sizeof(EV_EXPLOSION));
if(pEvent)
{
pEvent->x = (int)P.x;
pEvent->y = (int)P.y;
pEvent->x = (int)Pos.x;
pEvent->y = (int)Pos.y;
}
}*/
@ -853,9 +853,9 @@ void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData)
char aBuf[256];
for(int i = 0; i < pSelf->Tuning()->Num(); i++)
{
float V;
pSelf->Tuning()->Get(i, &V);
str_format(aBuf, sizeof(aBuf), "%s %.2f", pSelf->Tuning()->m_apNames[i], V);
float v;
pSelf->Tuning()->Get(i, &v);
str_format(aBuf, sizeof(aBuf), "%s %.2f", pSelf->Tuning()->m_apNames[i], v);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", aBuf);
}
}
@ -1133,4 +1133,4 @@ void CGameContext::OnPostSnap()
const char *CGameContext::Version() { return GAME_VERSION; }
const char *CGameContext::NetVersion() { return GAME_NETVERSION; }
IGameServer *CreateGameServer() { return new CGameContext; }
IGameServer *CreateGameServer() { return new CGameContext; }