diff --git a/.gitignore b/.gitignore index 91c00b3a0..34e8a2dbd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ config.lua teeworlds_d teeworlds_srv_d +bam.exe +build server.bat +buildlog.txt \ No newline at end of file diff --git a/DDRace_Trunk.exe b/DDRace_Trunk.exe new file mode 100644 index 000000000..371d06864 Binary files /dev/null and b/DDRace_Trunk.exe differ diff --git a/src/base/system.c b/src/base/system.c index 457b761a9..f5cf86074 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -10,6 +10,8 @@ #include "system.h" /*#include "e_console.h"*/ +#include "errno.h" + #if defined(CONF_FAMILY_UNIX) #include #include @@ -687,23 +689,29 @@ NETSOCKET net_udp_create(NETADDR bindaddr) int net_udp_send(NETSOCKET sock, const NETADDR *addr, const void *data, int size) { struct sockaddr sa; - int d; + int32_t d; mem_zero(&sa, sizeof(sa)); netaddr_to_sockaddr(addr, &sa); - d = sendto((int)sock, (const char*)data, size, 0, &sa, sizeof(sa)); - /*if(d < 0) + if((d = sendto((int)sock, (const char*)data, size, 0, &sa, sizeof(sa))) < 0) { + int32_t err_num = errno; + char char_buffer[256]; char addrstr[256]; net_addr_str(addr, addrstr, sizeof(addrstr)); dbg_msg("net", "sendto error %d %x", d, d); dbg_msg("net", "\tsock = %d %x", sock, sock); dbg_msg("net", "\tsize = %d %x", size, size); - dbg_msg("net", "\taddr = %s", addrstr); - }*/ - network_stats.sent_bytes += size; - network_stats.sent_packets++; + net_addr_str( addr, char_buffer, sizeof( char_buffer ) ); + dbg_msg( "net", "\taddr = %s", char_buffer ); + + dbg_msg( "net", "\terr = '%d:%s'", err_num, strerror( + err_num ) ); + } else { + network_stats.sent_bytes += size; + network_stats.sent_packets++; + } return d; } diff --git a/src/base/system.h b/src/base/system.h index 0850a08b3..f814193b6 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -9,6 +9,26 @@ #include "detect.h" +#if defined(CONF_FAMILY_WINDOWS) + #include "stdint.h" +#endif +#if defined(CONF_FAMILY_UNIX) + #include +#endif +#if defined(CONF_PLATFORM_MACOSX) +#include + +typedef SInt8 int8_t; +typedef UInt8 uint8_t; +typedef SInt16 int16_t; +typedef UInt16 uint16_t; +typedef SInt32 int32_t; +typedef UInt32 uint32_t; +typedef SInt64 int64_t; +typedef UInt64 uint64_t; +typedef unsigned long uintptr_t; +#endif + #ifdef __cplusplus extern "C" { #endif @@ -530,7 +550,7 @@ NETSOCKET net_udp_create(NETADDR bindaddr); On success it returns the number of bytes sent. Returns -1 on error. */ -int net_udp_send(NETSOCKET sock, const NETADDR *addr, const void *data, int size); +int32_t net_udp_send(NETSOCKET sock, const NETADDR *addr, const void *data, int size); /* Function: net_udp_recv diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 34f6f3dbc..93217c384 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -297,7 +297,7 @@ int CServer::Init() bool CServer::IsAuthed(int ClientID) { - return m_aClients[ClientID].m_Authed; + return m_aClients[ClientID].m_Authed; //TODO: return int } int CServer::GetClientInfo(int ClientID, CClientInfo *pInfo) @@ -543,7 +543,7 @@ int CServer::NewClientCallback(int ClientId, void *pUser) pThis->m_aClients[ClientId].m_Authed = 0; pThis->m_aClients[ClientId].m_PwTries = 0; // init pw tries memset(&pThis->m_aClients[ClientId].m_Addr, 0, sizeof(NETADDR)); // init that too - pThis->m_aClients[ClientId].m_CommandTriesTimer= 0; + pThis->m_aClients[ClientId].m_CmdTriesTimer= 0; pThis->m_aClients[ClientId].m_CmdTries = 0; //Floff init cmd tries pThis->m_aClients[ClientId].m_Resistent = 0; pThis->m_aClients[ClientId].Reset(); @@ -564,7 +564,7 @@ int CServer::DelClientCallback(int ClientId, void *pUser) pThis->m_aClients[ClientId].m_Authed = 0; pThis->m_aClients[ClientId].m_PwTries = 0; // init pw tries memset(&pThis->m_aClients[ClientId].m_Addr, 0, sizeof(NETADDR)); // init that too - pThis->m_aClients[ClientId].m_CommandTriesTimer= 0; + pThis->m_aClients[ClientId].m_CmdTriesTimer= 0; pThis->m_aClients[ClientId].m_CmdTries = 0; //Floff init cmd tries pThis->m_aClients[ClientId].m_Resistent = 0; pThis->m_aClients[ClientId].m_Snapshots.PurgeAll(); @@ -707,10 +707,10 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) else { if(m_aClients[ClientId].m_Authed == 0 && Msg != NETMSG_INPUT && Msg != NETMSG_REQUEST_MAP_DATA) { - if(time_get() > m_aClients[ClientId].m_CommandTriesTimer + time_freq()) + if(time_get() > m_aClients[ClientId].m_CmdTriesTimer + time_freq()) { m_aClients[ClientId].m_CmdTries = 0; - m_aClients[ClientId].m_CommandTriesTimer = time_get(); + m_aClients[ClientId].m_CmdTriesTimer = time_get(); } m_aClients[ClientId].m_CmdTries++; //dbg_msg("server","client_counter: %d", clients[cid].command_tries); @@ -732,15 +732,15 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) if(Msg != NETMSG_INPUT && Msg != NETMSG_REQUEST_MAP_DATA) { m_aClients[ClientId].m_CmdTries++; - if(time_get() < m_aClients[ClientId].m_LastCommand + time_freq()/* * 1*/) + if(time_get() < m_aClients[ClientId].m_CmdTriesTimer + time_freq()/* * 1*/) { - if(m_aClients[ClientId].m_CmdTries > g_Config.m_SvRconCmdTries) + if(m_aClients[ClientId].m_CmdTries > g_Config.m_SvNetmsgLimit && g_Config.m_SvNetmsgLimit != 0) { dbg_msg("server", "client trying to flood the server (%d tries), ban. cid=%x ip=%d.%d.%d.%d", m_aClients[ClientId].m_CmdTries, ClientId, m_aClients[ClientId].m_Addr.ip[0], m_aClients[ClientId].m_Addr.ip[1], m_aClients[ClientId].m_Addr.ip[2], m_aClients[ClientId].m_Addr.ip[3] ); - BanAdd(m_aClients[ClientId].m_Addr, g_Config.m_SvRconBanTime); // bye + BanAdd(m_aClients[ClientId].m_Addr, g_Config.m_SvNetmsgBanTime, "exceeding netmsg_limit, Bye"); // bye return; } } @@ -748,7 +748,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) { m_aClients[ClientId].m_CmdTries = 0; } - m_aClients[ClientId].m_LastCommand = time_get(); + m_aClients[ClientId].m_CmdTriesTimer = time_get(); } // system message if(Msg == NETMSG_REQUEST_MAP_DATA) @@ -948,7 +948,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) SendRconLine(ClientId, "Wrong password."); if(++m_aClients[ClientId].m_PwTries > g_Config.m_SvRconTries) { // rcon Kottizen LemonFace - BanAdd(m_NetServer.ClientAddr(ClientId), g_Config.m_SvRconTriesBantime); // bye + BanAdd(m_NetServer.ClientAddr(ClientId), g_Config.m_SvRconTriesBantime, "exceeding rcon password tries, Bye"); // bye dbg_msg("server", "cid=%d banned, wrong rcon pw", ClientId); } } @@ -992,8 +992,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) if(m_aClients[ClientId].m_State >= CClient::STATE_READY) GameServer()->OnMessage(Msg, &Unpacker, ClientId); } - } } + void CServer::SendServerInfo(NETADDR *pAddr, int Token) { diff --git a/src/engine/server/server.h b/src/engine/server/server.h index e0c138bc0..6a9c32af7 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -103,7 +103,7 @@ public: NETADDR m_Addr; // for storing address int m_PwTries; // a players rcon pw tries int m_CmdTries; //Floff players rcon command tries, to prevent command flood server crash - int64 m_CommandTriesTimer; // time + int64 m_CmdTriesTimer; // time void Reset(); }; diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 9e12e5501..80b70dda4 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -8,6 +8,7 @@ //=============================== MACRO_CONFIG_INT(SvReconnectTime,sv_reconnect_time,5,0,9999,CFGFLAG_SERVER,"how much time between leaves and joins") MACRO_CONFIG_INT(SvVoteKickTimeDelay,sv_vote_kick_delay,0,0,9999,CFGFLAG_SERVER,"how much time between kick votes") +MACRO_CONFIG_INT(SvVoteKickBanTime,sv_vote_kick_bantime, 300, 0, 9999, CFGFLAG_SERVER," ") MACRO_CONFIG_INT(SvVoteMapTimeDelay,sv_vote_map_delay,0,0,9999,CFGFLAG_SERVER,"how much time between map votes") //MACRO_CONFIG_INT(SvMaxConnections,sv_max_connections, 2, 1, 16, CFGFLAG_SERVER, "Maximum count of connection from one IP server can accept") depricated MACRO_CONFIG_INT(SvMaxAfkTime,sv_max_afk_time, 0, 0, 9999, CFGFLAG_SERVER, "How many seconds a player is allowed to be afk, 0=disabled") @@ -26,7 +27,10 @@ MACRO_CONFIG_INT(SvRconTriesBantime, sv_rcon_tries_bantime, 300, 0, 9999, CFGFLA MACRO_CONFIG_STR(SvRconPasswordAdmin, sv_rcon_password_admin, 32, "", CFGFLAG_SERVER, "Remote console administrator password") MACRO_CONFIG_STR(SvRconPasswordModer, sv_rcon_password_moder, 32, "", CFGFLAG_SERVER, "Remote console moderator password") MACRO_CONFIG_STR(SvRconPasswordHelper, sv_rcon_password_helper, 32, "", CFGFLAG_SERVER, "Remote console helper password") - + +MACRO_CONFIG_INT(SvNetmsgLimit, sv_netmsg_limit, 0, 0, 100, CFGFLAG_SERVER, "How Many unauthed Command Tries Before ban") +MACRO_CONFIG_INT(SvNetmsgBanTime, sv_netmsg_bantime, 300, 0, 9999, CFGFLAG_SERVER, "How Much time will the unauthed rcon command spammer will be banned") + //=============================== */ MACRO_CONFIG_STR(PlayerName, player_name, 24, "nameless tee", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Name of the player") diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 735ceb4fb..d641eeead 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -1,6 +1,7 @@ #include #include "config.h" #include "network.h" +#include #define MACRO_LIST_LINK_FIRST(Object, First, Prev, Next) \ { if(First) First->Prev = Object; \ @@ -164,7 +165,7 @@ int CNetServer::BanAdd(NETADDR Addr, int Seconds, const char * Reason) return 0; pBan->m_Info.m_Expires = Stamp; - strcpy(pBan->m_Info.m_Reason, m_Reason); + strcpy(pBan->m_Info.m_Reason, Reason); return 0; } @@ -263,7 +264,7 @@ int CNetServer::BanAddNoDrop(NETADDR Addr, int Seconds, const char *Reason) return 0; pBan->m_Info.m_Expires = Stamp; - strcpy(pBan->m_Info.m_Reason, m_Reason); + strcpy(pBan->m_Info.m_Reason, Reason); return 0; } @@ -277,7 +278,7 @@ int CNetServer::BanAddNoDrop(NETADDR Addr, int Seconds, const char *Reason) // setup the ban info pBan->m_Info.m_Expires = Stamp; pBan->m_Info.m_Addr = Addr; - strcpy(pBan->m_Info.m_Reason, m_Reason); + strcpy(pBan->m_Info.m_Reason, Reason); // add it to the ban hash MACRO_LIST_LINK_FIRST(pBan, m_aBans[IpHash], m_pHashPrev, m_pHashNext); diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 054e51f1f..e981d5719 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -72,8 +72,8 @@ void CCollision::Init(class CLayers *pLayers) int FIndex = 0; if(!isOneLayer) FIndex = m_pFTiles[i].m_Index; - if (FIndex!=0) - dbg_msg ("flayer", "tile found at (%d, %d)",(i - (i/ m_Width) * m_Width) ,(i / m_Width)); + //if (FIndex!=0) + // dbg_msg ("flayer", "tile found at (%d, %d)",(i - (i/ m_Width) * m_Width) ,(i / m_Width)); if(Index > 190) continue; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index ed5ca373a..0bf91010e 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -563,7 +563,8 @@ void CCharacter::Tick() m_Input.m_Direction = 0; m_Input.m_Jump = 0; m_Input.m_Hook = 0; - m_Input.m_Fire = 0; + m_Input.m_Fire = 0; + m_Core.m_Jumped = 0; ResetPos(); } diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 85c5654aa..24d98d09c 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -454,7 +454,7 @@ void CGameContext::OnTick() //Console()->ExecuteLine(m_aVoteCommand, 4, -1); //EndVote(); //SendChat(-1, CGameContext::CHAT_ALL, "Vote passed"); - if(vote_enforce == VOTE_ENFORCE_YES) + if(m_VoteEnforce == VOTE_ENFORCE_YES) { Console()->ExecuteLine(m_aVoteCommand, 3,-1); SendChat(-1, CGameContext::CHAT_ALL, "Vote passed (enforced by Admin)"); @@ -621,6 +621,10 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) if(g_Config.m_SvSpamprotection && p->m_Last_Chat && p->m_Last_Chat+Server()->TickSpeed() > Server()->Tick()) return; + if(str_length(pMsg->m_pMessage)>370) { + SendChatTarget(ClientId, "Your Message is too long"); + return; + } p->m_Last_Chat = Server()->Tick(); @@ -777,10 +781,10 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) { if(str_comp_nocase(pMsg->m_Value, pOption->m_aCommand) == 0) { - if(m_apPlayers[ClientId]->m_Authed == 0 && strncmp(pOption->m_aCommand, "sv_map ", 7) == 0 && time_get() < last_mapvote + (time_freq() * g_Config.m_SvVoteMapDelay)) + if(m_apPlayers[ClientId]->m_Authed == 0 && strncmp(pOption->m_aCommand, "sv_map ", 7) == 0 && time_get() < last_mapvote + (time_freq() * g_Config.m_SvVoteMapTimeDelay)) { char chatmsg[512] = {0}; - str_format(chatmsg, sizeof(chatmsg), "There's a %d second delay between map-votes,Please wait %d Second(s)", g_Config.m_SvVoteMapDelay,((last_mapvote+(g_Config.m_SvVoteMapDelay * time_freq()))/time_freq())-(time_get()/time_freq())); + str_format(chatmsg, sizeof(chatmsg), "There's a %d second delay between map-votes,Please wait %d Second(s)", g_Config.m_SvVoteMapTimeDelay,((last_mapvote+(g_Config.m_SvVoteMapTimeDelay * time_freq()))/time_freq())-(time_get()/time_freq())); SendChatTarget(ClientId, chatmsg); return; @@ -805,22 +809,23 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) } else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) { - if(m_apPlayers[ClientId]->m_Authed == 0 && time_get() < m_apPlayers[ClientId]->m_LastKickVote + (time_freq() * 5)) + if(m_apPlayers[ClientId]->m_Authed == 0 && time_get() < m_apPlayers[ClientId]->m_Last_KickVote + (time_freq() * 5)) return; - else if(m_apPlayers[ClientId]->m_Authed == 0 && time_get() < m_apPlayers[ClientId]->m_LastKickVote + (time_freq() * g_Config.m_SvVoteKickDelay)) + else if(m_apPlayers[ClientId]->m_Authed == 0 && time_get() < m_apPlayers[ClientId]->m_Last_KickVote + (time_freq() * g_Config.m_SvVoteKickTimeDelay)) { char chatmsg[512] = {0}; str_format(chatmsg, sizeof(chatmsg), "There's a %d second waittime between kickvotes for each player please wait %d second(s)", - g_Config.m_SvVoteKickDelay, - ((m_apPlayers[ClientId]->m_LastKickVote + (m_apPlayers[ClientId]->m_LastKickVote*time_freq()))/time_freq())-(time_get()/time_freq()) + g_Config.m_SvVoteKickTimeDelay, + ((m_apPlayers[ClientId]->m_Last_KickVote + (m_apPlayers[ClientId]->m_Last_KickVote*time_freq()))/time_freq())-(time_get()/time_freq()) ); - SendChatTarget(client_id, chatmsg); - m_apPlayers[ClientId]->m_LastKickVote = time_get(); + SendChatTarget(ClientId, chatmsg); + m_apPlayers[ClientId]->m_Last_KickVote = time_get(); return; } else if(!g_Config.m_SvVoteKick) { SendChatTarget(ClientId, "Server does not allow voting to kick players"); + m_apPlayers[ClientId]->m_Last_KickVote = time_get(); return; } @@ -828,6 +833,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) if(KickId < 0 || KickId >= MAX_CLIENTS || !m_apPlayers[KickId]) { SendChatTarget(ClientId, "Invalid client id to kick"); + m_apPlayers[ClientId]->m_Last_KickVote = time_get(); return; } if(KickId == ClientId) @@ -838,6 +844,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) if(Server()->IsAuthed(KickId)) { SendChatTarget(ClientId, "You cant kick admins"); + m_apPlayers[ClientId]->m_Last_KickVote = time_get(); char aBufKick[128]; str_format(aBufKick, sizeof(aBufKick), "%s called for vote to kick you", Server()->ClientName(ClientId)); SendChatTarget(KickId, aBufKick); @@ -846,7 +853,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) str_format(aChatmsg, sizeof(aChatmsg), "%s called for vote to kick '%s'", Server()->ClientName(ClientId), Server()->ClientName(KickId)); str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId)); - if (!g_Config.m_SvVoteKickBantime) + if (!g_Config.m_SvVoteKickBanTime) str_format(aCmd, sizeof(aCmd), "kick %d", KickId); else { @@ -854,6 +861,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) Server()->GetClientIP(KickId, aBuf, sizeof(aBuf)); str_format(aCmd, sizeof(aCmd), "ban %s %d", aBuf, g_Config.m_SvVoteKickBantime); } + m_apPlayers[ClientId]->m_Last_KickVote = time_get(); } if(aCmd[0]) diff --git a/src/game/server/gamemodes/mod.cpp b/src/game/server/gamemodes/mod.cpp index be3eb3402..3055b094a 100644 --- a/src/game/server/gamemodes/mod.cpp +++ b/src/game/server/gamemodes/mod.cpp @@ -1,22 +1,22 @@ /* // copyright (c) 2007 magnus auvinen, see licence.txt for more info -#include "mod.h" - -CGameControllerMOD::CGameControllerMOD(class CGameContext *pGameServer) -: IGameController(pGameServer) -{ - // Exchange this to a string that identifies your game mode. - // DM, TDM and CTF are reserved for teeworlds original modes. - m_pGameType = "MOD"; - - //m_GameFlags = GAMEFLAG_TEAMS; // GAMEFLAG_TEAMS makes it a two-team gamemode -} - -void CGameControllerMOD::Tick() -{ - // this is the main part of the gamemode, this function is run every tick - DoPlayerScoreWincheck(); // checks for winners, no teams version - //DoTeamScoreWincheck(); // checks for winners, two teams version - - IGameController::Tick(); -} +#include "mod.h" + +CGameControllerMOD::CGameControllerMOD(class CGameContext *pGameServer) +: IGameController(pGameServer) +{ + // Exchange this to a string that identifies your game mode. + // DM, TDM and CTF are reserved for teeworlds original modes. + m_pGameType = "MOD"; + + //m_GameFlags = GAMEFLAG_TEAMS; // GAMEFLAG_TEAMS makes it a two-team gamemode +} + +void CGameControllerMOD::Tick() +{ + // this is the main part of the gamemode, this function is run every tick + DoPlayerScoreWincheck(); // checks for winners, no teams version + //DoTeamScoreWincheck(); // checks for winners, two teams version + + IGameController::Tick(); +} */ \ No newline at end of file diff --git a/src/game/server/gamemodes/mod.h b/src/game/server/gamemodes/mod.h index 86dff78bb..2c4b4b0d1 100644 --- a/src/game/server/gamemodes/mod.h +++ b/src/game/server/gamemodes/mod.h @@ -1,14 +1,14 @@ #ifndef GAME_SERVER_GAMEMODES_MOD_H #define GAME_SERVER_GAMEMODES_MOD_H -#include - -// you can subclass GAMECONTROLLER_CTF, GAMECONTROLLER_TDM etc if you want -// todo a modification with their base as well. -class CGameControllerMOD : public IGameController -{ -public: - CGameControllerMOD(class CGameContext *pGameServer); - virtual void Tick(); - // add more virtual functions here if you wish -}; +#include + +// you can subclass GAMECONTROLLER_CTF, GAMECONTROLLER_TDM etc if you want +// todo a modification with their base as well. +class CGameControllerMOD : public IGameController +{ +public: + CGameControllerMOD(class CGameContext *pGameServer); + virtual void Tick(); + // add more virtual functions here if you wish +}; #endif diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 55ab5a37e..ba12f582a 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include "player.h" @@ -229,7 +231,7 @@ void CPlayer::AfkTimer(int new_target_x, int new_target_y) if(m_Authed) return; // don't kick admins if(g_Config.m_SvMaxAfkTime == 0) return; // 0 = disabled - if(new_target_x != last_target_x || new_target_y != last_target_y) + if(new_target_x != m_LastTarget_x || new_target_y != m_LastTarget_y) { m_LastPlaytime = time_get(); m_LastTarget_x = new_target_x; @@ -249,7 +251,7 @@ void CPlayer::AfkTimer(int new_target_x, int new_target_y) (int)(g_Config.m_SvMaxAfkTime*0.5), g_Config.m_SvMaxAfkTime ); - m_pGameServer->SendChatTarget(client_id, m_pAfkMsg); + m_pGameServer->SendChatTarget(m_ClientID, m_pAfkMsg); m_SentAfkWarning = 1; } else if(m_SentAfkWarning2 == 0 && m_LastPlaytime < time_get()-time_freq()*(int)(g_Config.m_SvMaxAfkTime*0.9)) { @@ -259,11 +261,12 @@ void CPlayer::AfkTimer(int new_target_x, int new_target_y) (int)(g_Config.m_SvMaxAfkTime*0.9), g_Config.m_SvMaxAfkTime ); - m_pGameServer->SendChatTarget(client_id, m_pAfkMsg); + m_pGameServer->SendChatTarget(m_ClientID, m_pAfkMsg); m_SentAfkWarning = 1; - } else if(last_playtime < time_get()-time_freq()*g_Config.m_SvMaxAfkTime) + } else if(m_LastPlaytime < time_get()-time_freq()*g_Config.m_SvMaxAfkTime) { - m_pGameServer->Server()->Kick(client_id,"Away from keyboard"); + CServer* serv = (CServer*)m_pGameServer->Server(); + serv->Kick(m_ClientID,"Away from keyboard"); } } } \ No newline at end of file diff --git a/src/versionsrv/versionsrv.cpp b/src/versionsrv/versionsrv.cpp index 8c0801e73..83e1a9d18 100644 --- a/src/versionsrv/versionsrv.cpp +++ b/src/versionsrv/versionsrv.cpp @@ -1,60 +1,60 @@ // copyright (c) 2007 magnus auvinen, see licence.txt for more info -#include - -#include - -#include "versionsrv.h" - -static CNetClient g_NetOp; // main - -void SendVer(NETADDR *pAddr) -{ - CNetChunk p; - unsigned char aData[sizeof(VERSIONSRV_VERSION) + sizeof(VERSION_DATA)]; - - mem_copy(aData, VERSIONSRV_VERSION, sizeof(VERSIONSRV_VERSION)); - mem_copy(aData + sizeof(VERSIONSRV_VERSION), VERSION_DATA, sizeof(VERSION_DATA)); - - p.m_ClientID = -1; - p.m_Address = *pAddr; - p.m_Flags = NETSENDFLAG_CONNLESS; - p.m_pData = aData; - p.m_DataSize = sizeof(aData); - - g_NetOp.Send(&p); -} - -int main(int argc, char **argv) // ignore_convention -{ - NETADDR BindAddr; - - dbg_logger_stdout(); - net_init(); - - mem_zero(&BindAddr, sizeof(BindAddr)); - BindAddr.port = VERSIONSRV_PORT; - g_NetOp.Open(BindAddr, 0); - - dbg_msg("versionsrv", "started"); - - while(1) - { - g_NetOp.Update(); - - // process packets - CNetChunk Packet; - while(g_NetOp.Recv(&Packet)) - { - if(Packet.m_DataSize == sizeof(VERSIONSRV_GETVERSION) && - mem_comp(Packet.m_pData, VERSIONSRV_GETVERSION, sizeof(VERSIONSRV_GETVERSION)) == 0) - { - SendVer(&Packet.m_Address); - } - } - - // be nice to the CPU - thread_sleep(1); - } - - return 0; -} +#include + +#include + +#include "versionsrv.h" + +static CNetClient g_NetOp; // main + +void SendVer(NETADDR *pAddr) +{ + CNetChunk p; + unsigned char aData[sizeof(VERSIONSRV_VERSION) + sizeof(VERSION_DATA)]; + + mem_copy(aData, VERSIONSRV_VERSION, sizeof(VERSIONSRV_VERSION)); + mem_copy(aData + sizeof(VERSIONSRV_VERSION), VERSION_DATA, sizeof(VERSION_DATA)); + + p.m_ClientID = -1; + p.m_Address = *pAddr; + p.m_Flags = NETSENDFLAG_CONNLESS; + p.m_pData = aData; + p.m_DataSize = sizeof(aData); + + g_NetOp.Send(&p); +} + +int main(int argc, char **argv) // ignore_convention +{ + NETADDR BindAddr; + + dbg_logger_stdout(); + net_init(); + + mem_zero(&BindAddr, sizeof(BindAddr)); + BindAddr.port = VERSIONSRV_PORT; + g_NetOp.Open(BindAddr, 0); + + dbg_msg("versionsrv", "started"); + + while(1) + { + g_NetOp.Update(); + + // process packets + CNetChunk Packet; + while(g_NetOp.Recv(&Packet)) + { + if(Packet.m_DataSize == sizeof(VERSIONSRV_GETVERSION) && + mem_comp(Packet.m_pData, VERSIONSRV_GETVERSION, sizeof(VERSIONSRV_GETVERSION)) == 0) + { + SendVer(&Packet.m_Address); + } + } + + // be nice to the CPU + thread_sleep(1); + } + + return 0; +} diff --git a/src/versionsrv/versionsrv.h b/src/versionsrv/versionsrv.h index d458a54c7..e771bd3c1 100644 --- a/src/versionsrv/versionsrv.h +++ b/src/versionsrv/versionsrv.h @@ -1,9 +1,9 @@ #ifndef VERSIONSRV_VERSIONSRV_H #define VERSIONSRV_VERSIONSRV_H -static const int VERSIONSRV_PORT = 8302; - -static const unsigned char VERSION_DATA[] = {0x00, 0, 5, 1}; - -static const unsigned char VERSIONSRV_GETVERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 'g'}; -static const unsigned char VERSIONSRV_VERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 's'}; +static const int VERSIONSRV_PORT = 8302; + +static const unsigned char VERSION_DATA[] = {0x00, 0, 5, 1}; + +static const unsigned char VERSIONSRV_GETVERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 'g'}; +static const unsigned char VERSIONSRV_VERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 's'}; #endif