mergend stuff

This commit is contained in:
SushiTee 2010-06-03 15:21:12 +02:00
commit 0115161463
16 changed files with 216 additions and 29 deletions

View file

@ -274,8 +274,8 @@ Prev. weapon
Quality Textures Quality Textures
== Kvalitní textury == Kvalitní textury
Quick search Quick search:
== Rychlé hledání == Rychlé hledání:
Quit Quit
== Ukončit == Ukončit
@ -438,5 +438,23 @@ Your skin
Show chat Show chat
== Show chat == Show chat
Password incorrect
== Password incorrect
Please balance teams!
== Please balance teams!
Connection Problems...
== Connection Problems...
Warmup
== Warmup
Sudden Death
== Sudden Death
%ds left
== %ds left
##### old translations #### ##### old translations ####

View file

@ -273,8 +273,8 @@ Prev. weapon
Quality Textures Quality Textures
== Kwalteit Textures == Kwalteit Textures
Quick search Quick search:
== Snel Zoken == Snel Zoken:
Quit Quit
== Stoppen == Stoppen
@ -437,4 +437,22 @@ Show chat
Your skin Your skin
== Your skin == Your skin
Password incorrect
== Password incorrect
Please balance teams!
== Please balance teams!
Connection Problems...
== Connection Problems...
Warmup
== Warmup
Sudden Death
== Sudden Death
%ds left
== %ds left
##### old translations #### ##### old translations ####

View file

@ -274,8 +274,8 @@ Prev. weapon
Quality Textures Quality Textures
== Textures haute qualité == Textures haute qualité
Quick search Quick search:
== Recherche rapide == Recherche rapide:
Quit Quit
== Quitter == Quitter
@ -438,5 +438,23 @@ Your skin
##### needs translation #### ##### needs translation ####
Password incorrect
== Password incorrect
Please balance teams!
== Please balance teams!
Connection Problems...
== Connection Problems...
Warmup
== Warmup
Sudden Death
== Sudden Death
%ds left
== %ds left
##### old translations #### ##### old translations ####

View file

@ -274,8 +274,8 @@ Prev. weapon
Quality Textures Quality Textures
== Hochaufgelöste Texturen == Hochaufgelöste Texturen
Quick search Quick search:
== Schnelle Suche == Schnellsuche:
Quit Quit
== Beenden == Beenden
@ -436,6 +436,24 @@ You must restart the game for all settings to take effect.
Your skin Your skin
== Dein Skin == Dein Skin
Password incorrect
== Passwort falsch
Please balance teams!
== Bitte Teams ausgleichen!
Connection Problems...
== Verbindungsprobleme...
Warmup
== Aufwärmen
Sudden Death
== Sudden Death
%ds left
== Noch %ds
##### needs translation #### ##### needs translation ####

View file

@ -271,8 +271,8 @@ Prev. weapon
Quality Textures Quality Textures
== Textures di qualità == Textures di qualità
Quick search Quick search:
== Ricerca rapida == Ricerca rapida:
Quit Quit
== Esci == Esci
@ -438,5 +438,23 @@ Show chat
Your skin Your skin
== Your skin == Your skin
Password incorrect
== Password incorrect
Please balance teams!
== Please balance teams!
Connection Problems...
== Connection Problems...
Warmup
== Warmup
Sudden Death
== Sudden Death
%ds left
== %ds left
##### old translations #### ##### old translations ####

View file

@ -274,8 +274,8 @@ Prev. weapon
Quality Textures Quality Textures
== Texturas de Qualidade == Texturas de Qualidade
Quick search Quick search:
== Pesquisa Rápida == Pesquisa Rápida:
Quit Quit
== Sair == Sair
@ -438,6 +438,23 @@ Your skin
##### needs translation #### ##### needs translation ####
Password incorrect
== Password incorrect
Please balance teams!
== Please balance teams!
Connection Problems...
== Connection Problems...
Warmup
== Warmup
Sudden Death
== Sudden Death
%ds left
== %ds left
##### old translations #### ##### old translations ####

View file

@ -271,8 +271,8 @@ Prev. weapon
Quality Textures Quality Textures
== Kvalitetstexturer == Kvalitetstexturer
Quick search Quick search:
== Snabbsök == Snabbsök:
Quit Quit
== Avsluta == Avsluta
@ -438,5 +438,23 @@ Show chat
Your skin Your skin
== Your skin == Your skin
Password incorrect
== Password incorrect
Please balance teams!
== Please balance teams!
Connection Problems...
== Connection Problems...
Warmup
== Warmup
Sudden Death
== Sudden Death
%ds left
== %ds left
##### old translations #### ##### old translations ####

View file

@ -1016,7 +1016,7 @@ int CServer::Run()
} }
if(!m_NetServer.Open(BindAddr, g_Config.m_SvMaxClients, 0)) if(!m_NetServer.Open(BindAddr, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0))
{ {
dbg_msg("server", "couldn't open socket. port might already be in use"); dbg_msg("server", "couldn't open socket. port might already be in use");
return -1; return -1;
@ -1248,12 +1248,16 @@ void CServer::ConStatus(IConsole::IResult *pResult, void *pUser)
for(i = 0; i < MAX_CLIENTS; i++) for(i = 0; i < MAX_CLIENTS; i++)
{ {
if(pServer->m_aClients[i].m_State == CClient::STATE_INGAME) if(pServer->m_aClients[i].m_State != CClient::STATE_EMPTY)
{ {
Addr = pServer->m_NetServer.ClientAddr(i); Addr = pServer->m_NetServer.ClientAddr(i);
str_format(aBuf, sizeof(aBuf), "id=%d addr=%d.%d.%d.%d:%d name='%s' score=%d", if(pServer->m_aClients[i].m_State == CClient::STATE_INGAME)
i, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port, str_format(aBuf, sizeof(aBuf), "id=%d addr=%d.%d.%d.%d:%d name='%s' score=%d",
pServer->m_aClients[i].m_aName, pServer->m_aClients[i].m_Score); i, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port,
pServer->m_aClients[i].m_aName, pServer->m_aClients[i].m_Score);
else
str_format(aBuf, sizeof(aBuf), "id=%d addr=%d.%d.%d.%d:%d connecting",
i, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port);
pServer->Console()->Print(aBuf); pServer->Console()->Print(aBuf);
dbg_msg("server", "%s", aBuf); dbg_msg("server", "%s", aBuf);
} }
@ -1289,6 +1293,13 @@ void CServer::ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserD
((CServer *)pUserData)->UpdateServerInfo(); ((CServer *)pUserData)->UpdateServerInfo();
} }
void CServer::ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
pfnCallback(pResult, pCallbackUserData);
if(pResult->NumArguments())
((CServer *)pUserData)->m_NetServer.SetMaxClientsPerIP(pResult->GetInteger(0));
}
void CServer::RegisterCommands() void CServer::RegisterCommands()
{ {
m_pConsole = Kernel()->RequestInterface<IConsole>(); m_pConsole = Kernel()->RequestInterface<IConsole>();
@ -1307,6 +1318,8 @@ void CServer::RegisterCommands()
Console()->Chain("sv_name", ConchainSpecialInfoupdate, this); Console()->Chain("sv_name", ConchainSpecialInfoupdate, this);
Console()->Chain("password", ConchainSpecialInfoupdate, this); Console()->Chain("password", ConchainSpecialInfoupdate, this);
Console()->Chain("sv_max_clients_per_ip", ConchainMaxclientsperipUpdate, this);
} }

View file

@ -185,6 +185,7 @@ public:
static void ConStopRecord(IConsole::IResult *pResult, void *pUser); static void ConStopRecord(IConsole::IResult *pResult, void *pUser);
static void ConMapReload(IConsole::IResult *pResult, void *pUser); static void ConMapReload(IConsole::IResult *pResult, void *pUser);
static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
void RegisterCommands(); void RegisterCommands();

View file

@ -64,6 +64,7 @@ MACRO_CONFIG_INT(SvPort, sv_port, 8303, 0, 0, CFGFLAG_SERVER, "Port to use for t
MACRO_CONFIG_INT(SvExternalPort, sv_external_port, 0, 0, 0, CFGFLAG_SERVER, "External port to report to the master servers") MACRO_CONFIG_INT(SvExternalPort, sv_external_port, 0, 0, 0, CFGFLAG_SERVER, "External port to report to the master servers")
MACRO_CONFIG_STR(SvMap, sv_map, 128, "dm1", CFGFLAG_SERVER, "Map to use on the server") MACRO_CONFIG_STR(SvMap, sv_map, 128, "dm1", CFGFLAG_SERVER, "Map to use on the server")
MACRO_CONFIG_INT(SvMaxClients, sv_max_clients, 8, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients that are allowed on a server") MACRO_CONFIG_INT(SvMaxClients, sv_max_clients, 8, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients that are allowed on a server")
MACRO_CONFIG_INT(SvMaxClientsPerIP, sv_max_clients_per_ip, 8, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients with the same IP that can connect to the server")
MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only") MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only")
MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register server with master server for public listing") MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register server with master server for public listing")
MACRO_CONFIG_STR(SvRconPassword, sv_rcon_password, 32, "", CFGFLAG_SERVER, "Remote console password") MACRO_CONFIG_STR(SvRconPassword, sv_rcon_password, 32, "", CFGFLAG_SERVER, "Remote console password")

View file

@ -244,6 +244,7 @@ private:
NETSOCKET m_Socket; NETSOCKET m_Socket;
CSlot m_aSlots[NET_MAX_CLIENTS]; CSlot m_aSlots[NET_MAX_CLIENTS];
int m_MaxClients; int m_MaxClients;
int m_MaxClientsPerIP;
CBan *m_aBans[256]; CBan *m_aBans[256];
CBan m_BanPool[NET_SERVER_MAXBANS]; CBan m_BanPool[NET_SERVER_MAXBANS];
@ -262,7 +263,7 @@ public:
int SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_DELCLIENT pfnDelClient, void *pUser); int SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_DELCLIENT pfnDelClient, void *pUser);
// //
bool Open(NETADDR BindAddr, int MaxClients, int Flags); bool Open(NETADDR BindAddr, int MaxClients, int MaxClientsPerIP, int Flags);
int Close(); int Close();
// //
@ -283,6 +284,9 @@ public:
NETADDR ClientAddr(int ClientID) const { return m_aSlots[ClientID].m_Connection.PeerAddress(); } NETADDR ClientAddr(int ClientID) const { return m_aSlots[ClientID].m_Connection.PeerAddress(); }
NETSOCKET Socket() const { return m_Socket; } NETSOCKET Socket() const { return m_Socket; }
int MaxClients() const { return m_MaxClients; } int MaxClients() const { return m_MaxClients; }
//
void SetMaxClientsPerIP(int Max);
}; };

View file

@ -24,7 +24,7 @@
#define MACRO_LIST_FIND(Start, Next, Expression) \ #define MACRO_LIST_FIND(Start, Next, Expression) \
{ while(Start && !(Expression)) Start = Start->Next; } { while(Start && !(Expression)) Start = Start->Next; }
bool CNetServer::Open(NETADDR BindAddr, int MaxClients, int Flags) bool CNetServer::Open(NETADDR BindAddr, int MaxClients, int MaxClientsPerIP, int Flags)
{ {
// zero out the whole structure // zero out the whole structure
mem_zero(this, sizeof(*this)); mem_zero(this, sizeof(*this));
@ -40,6 +40,8 @@ bool CNetServer::Open(NETADDR BindAddr, int MaxClients, int Flags)
m_MaxClients = NET_MAX_CLIENTS; m_MaxClients = NET_MAX_CLIENTS;
if(m_MaxClients < 1) if(m_MaxClients < 1)
m_MaxClients = 1; m_MaxClients = 1;
m_MaxClientsPerIP = MaxClientsPerIP;
for(int i = 0; i < NET_MAX_CLIENTS; i++) for(int i = 0; i < NET_MAX_CLIENTS; i++)
m_aSlots[i].m_Connection.Init(m_Socket); m_aSlots[i].m_Connection.Init(m_Socket);
@ -335,6 +337,29 @@ int CNetServer::Recv(CNetChunk *pChunk)
// client that wants to connect // client that wants to connect
if(!Found) if(!Found)
{ {
// only allow a specific number of players with the same ip
NETADDR ThisAddr = Addr, OtherAddr;
int FoundAddr = 1;
ThisAddr.port = 0;
for(int i = 0; i < MaxClients(); ++i)
{
if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_OFFLINE)
continue;
OtherAddr = m_aSlots[i].m_Connection.PeerAddress();
OtherAddr.port = 0;
if(!net_addr_comp(&ThisAddr, &OtherAddr))
{
if(FoundAddr++ >= m_MaxClientsPerIP)
{
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "only %i players with same ip allowed", m_MaxClientsPerIP);
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, aBuf, sizeof(aBuf));
return 0;
}
}
}
for(int i = 0; i < MaxClients(); i++) for(int i = 0; i < MaxClients(); i++)
{ {
if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_OFFLINE) if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_OFFLINE)
@ -411,3 +436,13 @@ int CNetServer::Send(CNetChunk *pChunk)
return 0; return 0;
} }
void CNetServer::SetMaxClientsPerIP(int Max)
{
// clamp
if(Max < 1)
Max = 1;
else if(Max > NET_MAX_CLIENTS)
Max = NET_MAX_CLIENTS;
m_MaxClientsPerIP = Max;
}

View file

@ -56,7 +56,7 @@ void CHud::RenderSuddenDeath()
if(m_pClient->m_Snap.m_pGameobj->m_SuddenDeath) if(m_pClient->m_Snap.m_pGameobj->m_SuddenDeath)
{ {
float Half = 300.0f*Graphics()->ScreenAspect()/2.0f; float Half = 300.0f*Graphics()->ScreenAspect()/2.0f;
const char *pText = "Sudden Death"; const char *pText = Localize("Sudden Death");
float FontSize = 12.0f; float FontSize = 12.0f;
float w = TextRender()->TextWidth(0, FontSize, pText, -1); float w = TextRender()->TextWidth(0, FontSize, pText, -1);
TextRender()->Text(0, Half-w/2, 2, FontSize, pText, -1); TextRender()->Text(0, Half-w/2, 2, FontSize, pText, -1);
@ -133,8 +133,8 @@ void CHud::RenderWarmupTimer()
{ {
char Buf[256]; char Buf[256];
float FontSize = 20.0f; float FontSize = 20.0f;
float w = TextRender()->TextWidth(0, FontSize, "Warmup", -1); float w = TextRender()->TextWidth(0, FontSize, Localize("Warmup"), -1);
TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 50, FontSize, "Warmup", -1); TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 50, FontSize, Localize("Warmup"), -1);
int Seconds = m_pClient->m_Snap.m_pGameobj->m_Warmup/SERVER_TICK_SPEED; int Seconds = m_pClient->m_Snap.m_pGameobj->m_Warmup/SERVER_TICK_SPEED;
if(Seconds < 5) if(Seconds < 5)
@ -171,7 +171,7 @@ void CHud::RenderConnectionWarning()
{ {
if(Client()->ConnectionProblems()) if(Client()->ConnectionProblems())
{ {
const char *pText = "Connection Problems..."; const char *pText = Localize("Connection Problems...");
float w = TextRender()->TextWidth(0, 24, pText, -1); float w = TextRender()->TextWidth(0, 24, pText, -1);
TextRender()->Text(0, 150*Graphics()->ScreenAspect()-w/2, 50, 24, pText, -1); TextRender()->Text(0, 150*Graphics()->ScreenAspect()-w/2, 50, 24, pText, -1);
} }
@ -186,7 +186,7 @@ void CHud::RenderTeambalanceWarning()
int TeamDiff = m_pClient->m_Snap.m_aTeamSize[0]-m_pClient->m_Snap.m_aTeamSize[1]; int TeamDiff = m_pClient->m_Snap.m_aTeamSize[0]-m_pClient->m_Snap.m_aTeamSize[1];
if (g_Config.m_ClWarningTeambalance && (TeamDiff >= 2 || TeamDiff <= -2)) if (g_Config.m_ClWarningTeambalance && (TeamDiff >= 2 || TeamDiff <= -2))
{ {
const char *pText = "Please balance teams!"; const char *pText = Localize("Please balance teams!");
if(Flash) if(Flash)
TextRender()->TextColor(1,1,0.5f,1); TextRender()->TextColor(1,1,0.5f,1);
else else
@ -214,7 +214,7 @@ void CHud::RenderVoting()
char Buf[512]; char Buf[512];
TextRender()->Text(0x0, 5, 60, 6, m_pClient->m_pVoting->VoteDescription(), -1); TextRender()->Text(0x0, 5, 60, 6, m_pClient->m_pVoting->VoteDescription(), -1);
str_format(Buf, sizeof(Buf), "%ds left", m_pClient->m_pVoting->SecondsLeft()); str_format(Buf, sizeof(Buf), Localize("%ds left"), m_pClient->m_pVoting->SecondsLeft());
float tw = TextRender()->TextWidth(0x0, 6, Buf, -1); float tw = TextRender()->TextWidth(0x0, 6, Buf, -1);
TextRender()->Text(0x0, 5+100-tw, 60, 6, Buf, -1); TextRender()->Text(0x0, 5+100-tw, 60, 6, Buf, -1);

View file

@ -840,7 +840,7 @@ int CMenus::Render()
} }
else if(m_Popup == POPUP_PASSWORD) else if(m_Popup == POPUP_PASSWORD)
{ {
pTitle = Localize("Password Incorrect"); pTitle = Localize("Password incorrect");
pExtraText = Client()->ErrorString(); pExtraText = Client()->ErrorString();
pButtonText = Localize("Try again"); pButtonText = Localize("Try again");
} }

View file

@ -1029,6 +1029,14 @@ void CEditor::DoQuadPoint(CQuad *q, int QuadIndex, int v)
s_Operation = OP_CONTEXT_MENU; s_Operation = OP_CONTEXT_MENU;
m_SelectedQuad = QuadIndex; m_SelectedQuad = QuadIndex;
UI()->SetActiveItem(pId); UI()->SetActiveItem(pId);
if(!(m_SelectedPoints&(1<<v)))
{
if(Input()->KeyPressed(KEY_LSHIFT) || Input()->KeyPressed(KEY_RSHIFT))
m_SelectedPoints |= 1<<v;
else
m_SelectedPoints = 1<<v;
s_Moved = true;
}
} }
} }
else else

View file

@ -111,7 +111,7 @@ static int Run()
int64 NextHeartBeat = 0; int64 NextHeartBeat = 0;
NETADDR BindAddr = {NETTYPE_IPV4, {0},0}; NETADDR BindAddr = {NETTYPE_IPV4, {0},0};
if(!pNet->Open(BindAddr, 0, 0)) if(!pNet->Open(BindAddr, 0, 0, 0))
return 0; return 0;
while(1) while(1)