Conflicts:
	src/game/collision.cpp
	src/game/collision.h
	src/game/gamecore.cpp
	src/game/server/gamecontext.cpp
This commit is contained in:
GreYFoXGTi 2011-02-13 19:36:53 +02:00
commit 718d697707
15 changed files with 135 additions and 121 deletions

View file

@ -23,7 +23,7 @@
== %i secondes restantes
%s Right click for context menu.
== %s clique droit pour afficher le menu contextuel
== %s Clic-droit pour afficher le menu contextuel.
Abort
== Annuler
@ -50,7 +50,7 @@ Alpha
== Alpha
Alpha value of the envelope
== Valeur d'alpha dans l'arriere-plan
== Composante alpha de l'animation
Always show name plates
== Toujours afficher les pseudonymes
@ -86,7 +86,7 @@ Blue team wins!
== L'équipe bleue gagne !
Blue value of the envelope
== Valeur de bleu dans l'arriere-plan
== Composante bleue de l'animation
Body
== Corps
@ -116,10 +116,10 @@ Color
== Couleur
Color Env
== Couleur Env
== Couleur Anim
Color TO
== Couleur TO
== Décalage Anim
Color+
== Couleur+
@ -143,13 +143,13 @@ Controls
== Contrôles
Creates a new color envelope
== Créer une nouvelle couleur d'arriere-plan
== Crée une nouvelle animation de couleur
Creates a new map
== Crée une nouvelle carte
Creates a new pos envelope
== Créer un nouvel arriere-plan
== Crée une nouvelle animation de position
Current
== Actuellement
@ -179,7 +179,7 @@ Delete layer
== Supprimer la couche
Delete this envelope
== Supprimer l'arriere-plan
== Supprime l'animation
Deletes the layer
== Supprime la couche
@ -227,7 +227,7 @@ Enter
== Démarrer
Envelopes
== Arriere-plans
== Animations
Error
== Erreur
@ -302,7 +302,7 @@ Graphics
== Affichage
Green value of the envelope
== Valeur de vert dans l'arriere-plan
== Composante verte de l'animation
Grenade
== Lance-grenade
@ -380,10 +380,10 @@ Left
== Gauche
Left mouse button to move. Hold shift to move pivot. Hold ctrl to rotate.
== Boutton gauche de la souris pour bouger. Maintenez [shift] pour changer le pivot. Maintenez [ctrl] pour la rotation.
== Bouton gauche de la souris pour déplacer. Maintenez [shift] pour changer le pivot. Maintenez [ctrl] pour tourner.
Left mouse button to move. Hold shift to move the texture.
== Boutton gauche de la souris pour bouger. Maintenez [shift] pour changer la texture.
== Bouton gauche de la souris pour déplacer. Maintenez [shift] pour déplacer la texture.
Lht.
== Lum.
@ -452,7 +452,7 @@ News
== Nouvelles
Next Envelope
== L'arriere-plan suivant
== Animation suivante
Next weapon
== Arme suivante
@ -521,10 +521,10 @@ Please balance teams!
== Équilibrez les équipes !
Pos X
== position X
== Pos X
Pos Y
== position Y
== Pos Y
Pos.+
== Pos.+
@ -536,7 +536,7 @@ Prev. weapon
== Arme précédente
Previous Envelope
== L'arriere-plan précédent
== Animation précédente
Quality Textures
== Textures haute qualité
@ -563,7 +563,7 @@ Red team wins!
== L'équipe rouge gagne !
Red value of the envelope
== Valeur de rouge dans l'arriere-plan
== Composante rouge de l'animation
Refresh
== Rafraîchir
@ -605,7 +605,7 @@ Right
== Droite
Rotation of the envelope
== Rotation de l'arriere-plan
== Rotation de l'animation
Round
== Round
@ -704,7 +704,7 @@ Standard map
== Cartes standards
Stop record
== Stopper l'enregistrement
== Arrêter l'enregistrement
Sudden Death
== Mort Subite
@ -746,10 +746,10 @@ Up
== Haut
Use left mouse button to drag and change the color value. Hold shift to be more precise.
== Maintenez le boutton gauche de la souris et déplacer là pour changer la valeur de la couleur. Maintenez [shift] pour plus de présision
== Maintenez le bouton gauche de la souris et déplacez-là pour changer la couleur. Maintenez [shift] pour plus de précision.
Use left mouse button to drag and change the value. Hold shift to be more precise.
== Maintenez le boutton gauche de la souris et déplacer là pour changer la valeur. Maintenez [shift] pour plus de présision
== Maintenez le bouton gauche de la souris et déplacez-là pour changer la valeur. Maintenez [shift] pour plus de précision.
Use sounds
== Jouer les sons

View file

@ -31,6 +31,6 @@ for filename in sys.argv[1:]:
hash = hashlib.md5(f).hexdigest().lower()[16:]
# TODO: refactor hash that is equal to the 0.5 hash, remove when we
# TODO: remove when we don't need it any more
if hash == "c139dc3e0152dff6":
if hash == "8755162e69711f98":
hash = "b67d1f1a1eea234e"
print('#define GAME_NETVERSION_HASH "%s"' % hash)

View file

@ -1349,12 +1349,14 @@ void gui_messagebox(const char *title, const char *message)
RunStandardAlert(theItem, NULL, &itemIndex);
#elif defined(CONF_FAMILY_UNIX)
static char cmd[1024];
int err;
/* use xmessage which is available on nearly every X11 system */
snprintf(cmd, sizeof(cmd), "xmessage -center -title '%s' '%s'",
title,
message);
int err = system(cmd);
err = system(cmd);
dbg_msg("gui/msgbox", "result = %i", err);
#elif defined(CONF_FAMILY_WINDOWS)
MessageBox(NULL,
message,

View file

@ -1720,6 +1720,15 @@ void CClient::Update()
ActionTaken = Now;
}
}
else
{
if(Now > ActionTaken+time_freq()*(10+g_Config.m_DbgStress))
{
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "stress", "disconnecting!");
Disconnect();
ActionTaken = Now;
}
}
}
// pump the network

View file

@ -219,6 +219,7 @@ public:
{
NETADDR m_Addr;
int m_Expires;
char m_Reason[128];
};
private:

View file

@ -174,6 +174,7 @@ int CNetServer::BanAdd(NETADDR Addr, int Seconds, const char *pReason)
// setup the ban info
pBan->m_Info.m_Expires = Stamp;
pBan->m_Info.m_Addr = Addr;
str_copy(pBan->m_Info.m_Reason, pReason, sizeof(pBan->m_Info.m_Reason));
// add it to the ban hash
MACRO_LIST_LINK_FIRST(pBan, m_aBans[IpHash], m_pHashPrev, m_pHashNext);
@ -215,8 +216,14 @@ int CNetServer::BanAdd(NETADDR Addr, int Seconds, const char *pReason)
char Buf[128];
NETADDR BanAddr;
if(Seconds)
str_format(Buf, sizeof(Buf), "You have been banned for %d minutes (%s)", Seconds/60, pReason);
int Mins = (Seconds + 59) / 60;
if(Mins)
{
if(Mins == 1)
str_format(Buf, sizeof(Buf), "You have been banned for 1 minute (%s)", pReason);
else
str_format(Buf, sizeof(Buf), "You have been banned for %d minutes (%s)", Mins, pReason);
}
else
str_format(Buf, sizeof(Buf), "You have been banned for life (%s)", pReason);
@ -298,12 +305,12 @@ int CNetServer::Recv(CNetChunk *pChunk)
{
int Mins = ((pBan->m_Info.m_Expires - Now)+59)/60;
if(Mins == 1)
str_format(BanStr, sizeof(BanStr), "Banned for 1 minute");
str_format(BanStr, sizeof(BanStr), "Banned for 1 minute (%s)", pBan->m_Info.m_Reason);
else
str_format(BanStr, sizeof(BanStr), "Banned for %d minutes", Mins);
str_format(BanStr, sizeof(BanStr), "Banned for %d minutes (%s)", Mins, pBan->m_Info.m_Reason);
}
else
str_format(BanStr, sizeof(BanStr), "Banned for life");
str_format(BanStr, sizeof(BanStr), "Banned for life (%s)", pBan->m_Info.m_Reason);
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, BanStr, str_length(BanStr)+1);
continue;
}

View file

@ -65,42 +65,39 @@ void CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
}
if(1)
{
int Freq[256] = {0};
int OrgWeight = 0;
int NewWeight = 192;
int Freq[256] = {0};
int OrgWeight = 0;
int NewWeight = 192;
// find most common frequence
for(int y = 0; y < BodySize; y++)
for(int x = 0; x < BodySize; x++)
{
if(d[y*Pitch+x*4+3] > 128)
Freq[d[y*Pitch+x*4]]++;
}
for(int i = 1; i < 256; i++)
// find most common frequence
for(int y = 0; y < BodySize; y++)
for(int x = 0; x < BodySize; x++)
{
if(Freq[OrgWeight] < Freq[i])
OrgWeight = i;
if(d[y*Pitch+x*4+3] > 128)
Freq[d[y*Pitch+x*4]]++;
}
// reorder
int InvOrgWeight = 255-OrgWeight;
int InvNewWeight = 255-NewWeight;
for(int y = 0; y < BodySize; y++)
for(int x = 0; x < BodySize; x++)
{
int v = d[y*Pitch+x*4];
if(v <= OrgWeight)
v = (int)(((v/(float)OrgWeight) * NewWeight));
else
v = (int)(((v-OrgWeight)/(float)InvOrgWeight)*InvNewWeight + NewWeight);
d[y*Pitch+x*4] = v;
d[y*Pitch+x*4+1] = v;
d[y*Pitch+x*4+2] = v;
}
for(int i = 1; i < 256; i++)
{
if(Freq[OrgWeight] < Freq[i])
OrgWeight = i;
}
// reorder
int InvOrgWeight = 255-OrgWeight;
int InvNewWeight = 255-NewWeight;
for(int y = 0; y < BodySize; y++)
for(int x = 0; x < BodySize; x++)
{
int v = d[y*Pitch+x*4];
if(v <= OrgWeight)
v = (int)(((v/(float)OrgWeight) * NewWeight));
else
v = (int)(((v-OrgWeight)/(float)InvOrgWeight)*InvNewWeight + NewWeight);
d[y*Pitch+x*4] = v;
d[y*Pitch+x*4+1] = v;
d[y*Pitch+x*4+2] = v;
}
Skin.m_ColorTexture = pSelf->Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0);
mem_free(Info.m_pData);
@ -113,7 +110,7 @@ void CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
}
void CSkins::Init()
void CSkins::OnInit()
{
// load skins
m_aSkins.clear();

View file

@ -20,7 +20,7 @@ public:
bool operator<(const CSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; }
};
void Init();
void OnInit();
vec3 GetColorV3(int v);
vec4 GetColorV4(int v);

View file

@ -238,6 +238,8 @@ void CGameClient::OnConsoleInit()
void CGameClient::OnInit()
{
int64 Start = time_get();
// set the language
g_Localization.Load(g_Config.m_ClLanguagefile, Storage(), Console());
@ -249,8 +251,6 @@ void CGameClient::OnInit()
for(int i = 0; i < NUM_NETOBJTYPES; i++)
Client()->SnapSetStaticsize(i, m_NetObjHandler.GetObjSize(i));
int64 Start = time_get();
// load default font
static CFont *pDefaultFont = 0;
char aFilename[512];
@ -280,9 +280,6 @@ void CGameClient::OnInit()
gs_LoadCurrent++;
}
// load skins
::gs_Skins.Init();
// TODO: Refactor: fix threaded loading of sounds again
// load sounds
{

View file

@ -165,10 +165,10 @@ 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);
if(!m_pTiles || Ny < 0 || Nx < 0)
{
//dbg_msg("Collision","Something is terribly wrong, !m_pTiles %d, Ny %d, Ny %d", !m_pTiles, Ny, Ny);
@ -187,14 +187,14 @@ int CCollision::GetTile(int X, int Y)
/*
bool CCollision::IsTileSolid(int x, int y)
{
return GetTile(X, Y)&COLFLAG_SOLID;
return GetTile(x, y)&COLFLAG_SOLID;
}
*/
int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough)
{
float D = distance(Pos0, Pos1);
int End(D+1);
float Distance = distance(Pos0, Pos1);
int End(Distance+1);
vec2 Last = Pos0;
int ix = 0, iy = 0; // Temporary position for checking collision
int dx = 0, dy = 0; // Offset for checking the "through" tile
@ -204,8 +204,8 @@ int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *p
}
for(int i = 0; i < End; i++)
{
float A = i/D;
vec2 Pos = mix(Pos0, Pos1, A);
float a = i/Distance;
vec2 Pos = mix(Pos0, Pos1, a);
ix = round(Pos.x);
iy = round(Pos.y);
if(CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy)))

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

@ -44,9 +44,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)
@ -139,16 +139,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)
@ -250,7 +250,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];
@ -264,12 +264,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);
dbg_msg1("GameCore Hooked", "ThisId = %d Id = %d Team = %d", m_Id, i, m_pTeams->Team(i));
}
}
@ -361,29 +361,29 @@ 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 (m_pWorld->m_Tuning.m_PlayerCollision)
{
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;
vec2 Temp = pCharCore->m_Vel;
Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.x, Accel*Dir.x*1.5f);

View file

@ -56,19 +56,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)
@ -107,13 +107,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

@ -103,19 +103,19 @@ class CCharacter *CGameContext::GetPlayerChar(int ClientID)
void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount, int Mask)
{
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), Mask);
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);
}
}
}
@ -171,14 +171,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;
}
}*/

View file

@ -95,6 +95,7 @@ void CGameControllerCTF::Tick()
// flag hits death-tile or left the game layer, reset it
if(GameServer()->Collision()->GetCollisionAt(F->m_Pos.x, F->m_Pos.y)&CCollision::COLFLAG_DEATH || F->GameLayerClipped(F->m_Pos))
{
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", "flag_return");
GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN);
F->Reset();
continue;