mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Increasing the Readability on primitive editors of DDRace Specific files (All files that does not exist in oy/teeworlds)
This commit is contained in:
parent
ee115b5346
commit
cdab951296
|
@ -2,7 +2,6 @@
|
|||
#ifndef GAME_SERVER_DDRACECOMMANDS_H
|
||||
#define GAME_SERVER_DDRACECOMMANDS_H
|
||||
#undef GAME_SERVER_DDRACECOMMANDS_H // this file can be included several times
|
||||
|
||||
#ifndef CONSOLE_COMMAND
|
||||
#define CONSOLE_COMMAND(name, params, flags, callback, userdata, help)
|
||||
#endif
|
||||
|
|
|
@ -7,67 +7,96 @@
|
|||
#include <game/version.h>
|
||||
#include <game/generated/nethash.cpp>
|
||||
#if defined(CONF_SQL)
|
||||
#include <game/server/score/sql_score.h>
|
||||
#include <game/server/score/sql_score.h>
|
||||
#endif
|
||||
|
||||
bool CheckClientID(int ClientID);
|
||||
|
||||
void CGameContext::ConCredits(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Teeworlds Team takes most of the credits also");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "This mod was originally created by \'3DA\'");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Now it is maintained & re-coded by:");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "\'[Egypt]GreYFoX@GTi\' and \'[BlackTee]den\'");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Others Helping on the code: \'heinrich5991\', \'ravomavain\', \'Trust o_0 Aeeeh ?!\', \'noother\', \'<3 fisted <3\' & \'LemonFace\'");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Documentation: Zeta-Hoernchen & Learath2, Entities: Fisico");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Code (in the past): \'3DA\' and \'Fluxid\'");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Please check the changelog on DDRace.info.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Also the commit log on github.com/GreYFoX/teeworlds .");
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit",
|
||||
"Teeworlds Team takes most of the credits also");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit",
|
||||
"This mod was originally created by \'3DA\'");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit",
|
||||
"Now it is maintained & re-coded by:");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit",
|
||||
"\'[Egypt]GreYFoX@GTi\' and \'[BlackTee]den\'");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"credit",
|
||||
"Others Helping on the code: \'heinrich5991\', \'ravomavain\', \'Trust o_0 Aeeeh ?!\', \'noother\', \'<3 fisted <3\' & \'LemonFace\'");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit",
|
||||
"Documentation: Zeta-Hoernchen & Learath2, Entities: Fisico");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit",
|
||||
"Code (in the past): \'3DA\' and \'Fluxid\'");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit",
|
||||
"Please check the changelog on DDRace.info.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit",
|
||||
"Also the commit log on github.com/GreYFoX/teeworlds .");
|
||||
}
|
||||
|
||||
void CGameContext::ConInfo(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "DDRace Mod. Version: " GAME_VERSION);
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
||||
"DDRace Mod. Version: " GAME_VERSION);
|
||||
#if defined( GIT_SHORTREV_HASH )
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "Git revision hash: " GIT_SHORTREV_HASH);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
||||
"Git revision hash: " GIT_SHORTREV_HASH);
|
||||
#endif
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "Official site: DDRace.info");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "For more Info /cmdlist");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "Or visit DDRace.info");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
||||
"Official site: DDRace.info");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
||||
"For more Info /cmdlist");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
||||
"Or visit DDRace.info");
|
||||
}
|
||||
|
||||
void CGameContext::ConHelp(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
|
||||
if(pResult->NumArguments() == 0)
|
||||
if (pResult->NumArguments() == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", "/cmdlist will show a list of all chat commands");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", "/help + any command will show you the help for this command");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", "Example /help settings will display the help about ");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help",
|
||||
"/cmdlist will show a list of all chat commands");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help",
|
||||
"/help + any command will show you the help for this command");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help",
|
||||
"Example /help settings will display the help about ");
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *pArg = pResult->GetString(0);
|
||||
const IConsole::CCommandInfo *pCmdInfo = pSelf->Console()->GetCommandInfo(pArg, CFGFLAG_SERVER, false);
|
||||
if(pCmdInfo && pCmdInfo->m_pHelp)
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", pCmdInfo->m_pHelp);
|
||||
const IConsole::CCommandInfo *pCmdInfo =
|
||||
pSelf->Console()->GetCommandInfo(pArg, CFGFLAG_SERVER, false);
|
||||
if (pCmdInfo && pCmdInfo->m_pHelp)
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help",
|
||||
pCmdInfo->m_pHelp);
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", "Command is either unknown or you have given a blank command without any parameters.");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"help",
|
||||
"Command is either unknown or you have given a blank command without any parameters.");
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConSettings(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
|
||||
if(pResult->NumArguments() == 0)
|
||||
if (pResult->NumArguments() == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "setting", "to check a server setting say /settings and setting's name, setting names are:");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "setting", "teams, cheats, collision, hooking, endlesshooking, me, ");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "setting", "hitting, oldlaser, timeout, votes, pause and scores");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"setting",
|
||||
"to check a server setting say /settings and setting's name, setting names are:");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "setting",
|
||||
"teams, cheats, collision, hooking, endlesshooking, me, ");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "setting",
|
||||
"hitting, oldlaser, timeout, votes, pause and scores");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -77,198 +106,308 @@ void CGameContext::ConSettings(IConsole::IResult *pResult, void *pUserData)
|
|||
float HookTemp;
|
||||
pSelf->m_Tuning.Get("player_collision", &ColTemp);
|
||||
pSelf->m_Tuning.Get("player_hooking", &HookTemp);
|
||||
if(str_comp(pArg, "teams") == 0)
|
||||
if (str_comp(pArg, "teams") == 0)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%s %s", g_Config.m_SvTeam == 1 ? "Teams are available on this server" : !g_Config.m_SvTeam ? "Teams are not available on this server" : "You have to be in a team to play on this server", /*g_Config.m_SvTeamStrict ? "and if you die in a team all of you die" : */"and if you die in a team only you die");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", aBuf);
|
||||
str_format(
|
||||
aBuf,
|
||||
sizeof(aBuf),
|
||||
"%s %s",
|
||||
g_Config.m_SvTeam == 1 ?
|
||||
"Teams are available on this server" :
|
||||
!g_Config.m_SvTeam ?
|
||||
"Teams are not available on this server" :
|
||||
"You have to be in a team to play on this server", /*g_Config.m_SvTeamStrict ? "and if you die in a team all of you die" : */
|
||||
"and if you die in a team only you die");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings",
|
||||
aBuf);
|
||||
}
|
||||
else if(str_comp(pArg, "collision") == 0)
|
||||
else if (str_comp(pArg, "collision") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", ColTemp?"Players can collide on this server":"Players Can't collide on this server");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
ColTemp ?
|
||||
"Players can collide on this server" :
|
||||
"Players Can't collide on this server");
|
||||
}
|
||||
else if(str_comp(pArg, "hooking") == 0)
|
||||
else if (str_comp(pArg, "hooking") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", HookTemp?"Players can hook each other on this server":"Players Can't hook each other on this server");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
HookTemp ?
|
||||
"Players can hook each other on this server" :
|
||||
"Players Can't hook each other on this server");
|
||||
}
|
||||
else if(str_comp(pArg, "endlesshooking") == 0)
|
||||
else if (str_comp(pArg, "endlesshooking") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvEndlessDrag?"Players can hook time is unlimited":"Players can hook time is limited");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
g_Config.m_SvEndlessDrag ?
|
||||
"Players can hook time is unlimited" :
|
||||
"Players can hook time is limited");
|
||||
}
|
||||
else if(str_comp(pArg, "hitting") == 0)
|
||||
else if (str_comp(pArg, "hitting") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvHit?"Player's weapons affect each other":"Player's weapons has no affect on each other");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
g_Config.m_SvHit ?
|
||||
"Player's weapons affect each other" :
|
||||
"Player's weapons has no affect on each other");
|
||||
}
|
||||
else if(str_comp(pArg, "oldlaser") == 0)
|
||||
else if (str_comp(pArg, "oldlaser") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvOldLaser?"Lasers can hit you if you shot them and that they pull you towards the bounce origin (Like DDRace Beta)":"Lasers can't hit you if you shot them, and they pull others towards the shooter");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
g_Config.m_SvOldLaser ?
|
||||
"Lasers can hit you if you shot them and that they pull you towards the bounce origin (Like DDRace Beta)" :
|
||||
"Lasers can't hit you if you shot them, and they pull others towards the shooter");
|
||||
}
|
||||
else if(str_comp(pArg, "me") == 0)
|
||||
else if (str_comp(pArg, "me") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvSlashMe?"Players can use /me commands the famous IRC Command":"Players Can't use the /me command");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
g_Config.m_SvSlashMe ?
|
||||
"Players can use /me commands the famous IRC Command" :
|
||||
"Players Can't use the /me command");
|
||||
}
|
||||
else if(str_comp(pArg, "timeout") == 0)
|
||||
else if (str_comp(pArg, "timeout") == 0)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "The Server Timeout is currently set to %d", g_Config.m_ConnTimeout);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", aBuf);
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"The Server Timeout is currently set to %d",
|
||||
g_Config.m_ConnTimeout);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings",
|
||||
aBuf);
|
||||
}
|
||||
else if(str_comp(pArg, "votes") == 0)
|
||||
else if (str_comp(pArg, "votes") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvVoteKick?"Players can use Callvote menu tab to kick offenders":"Players Can't use the Callvote menu tab to kick offenders");
|
||||
if(g_Config.m_SvVoteKick)
|
||||
str_format(aBuf, sizeof(aBuf), "Players are banned for %d second(s) if they get voted off", g_Config.m_SvVoteKickBantime);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvVoteKickBantime?aBuf:"Players are just kicked and not banned if they get voted off");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
g_Config.m_SvVoteKick ?
|
||||
"Players can use Callvote menu tab to kick offenders" :
|
||||
"Players Can't use the Callvote menu tab to kick offenders");
|
||||
if (g_Config.m_SvVoteKick)
|
||||
str_format(
|
||||
aBuf,
|
||||
sizeof(aBuf),
|
||||
"Players are banned for %d second(s) if they get voted off",
|
||||
g_Config.m_SvVoteKickBantime);
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
g_Config.m_SvVoteKickBantime ?
|
||||
aBuf :
|
||||
"Players are just kicked and not banned if they get voted off");
|
||||
}
|
||||
else if(str_comp(pArg, "pause") == 0)
|
||||
else if (str_comp(pArg, "pause") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvPauseable?g_Config.m_SvPauseTime?"/pause is available on this server and it pauses your time too":"/pause is available on this server but it doesn't pause your time":"/pause is NOT available on this server");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
g_Config.m_SvPauseable ?
|
||||
g_Config.m_SvPauseTime ?
|
||||
"/pause is available on this server and it pauses your time too" :
|
||||
"/pause is available on this server but it doesn't pause your time"
|
||||
:"/pause is NOT available on this server");
|
||||
}
|
||||
else if(str_comp(pArg, "scores") == 0)
|
||||
else if (str_comp(pArg, "scores") == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvHideScore?"Scores are private on this server":"Scores are public on this server");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"settings",
|
||||
g_Config.m_SvHideScore ?
|
||||
"Scores are private on this server" :
|
||||
"Scores are public on this server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConRules(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
bool Printed = false;
|
||||
if(g_Config.m_SvDDRaceRules)
|
||||
if (g_Config.m_SvDDRaceRules)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No blocking.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No insulting / spamming.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No fun voting / vote spamming.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "Breaking any of these rules will result in a penalty, decided by server admins.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
"No blocking.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
"No insulting / spamming.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
"No fun voting / vote spamming.");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"rules",
|
||||
"Breaking any of these rules will result in a penalty, decided by server admins.");
|
||||
Printed = true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine1[0])
|
||||
if (g_Config.m_SvRulesLine1[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine1);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine1);
|
||||
Printed = true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine2[0])
|
||||
if (g_Config.m_SvRulesLine2[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine2);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine2);
|
||||
Printed = true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine3[0])
|
||||
if (g_Config.m_SvRulesLine3[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine3);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine3);
|
||||
Printed = true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine4[0])
|
||||
if (g_Config.m_SvRulesLine4[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine4);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine4);
|
||||
Printed = true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine5[0])
|
||||
if (g_Config.m_SvRulesLine5[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine5);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine5);
|
||||
Printed = true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine6[0])
|
||||
if (g_Config.m_SvRulesLine6[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine6);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine6);
|
||||
Printed = true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine7[0])
|
||||
if (g_Config.m_SvRulesLine7[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine7);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine7);
|
||||
Printed = true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine8[0])
|
||||
if (g_Config.m_SvRulesLine8[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine8);
|
||||
Printed=true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine9[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine9);
|
||||
Printed=true;
|
||||
}
|
||||
if(g_Config.m_SvRulesLine10[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine10);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine8);
|
||||
Printed = true;
|
||||
}
|
||||
if(!Printed)
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No Rules Defined, Kill em all!!");
|
||||
if (g_Config.m_SvRulesLine9[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine9);
|
||||
Printed = true;
|
||||
}
|
||||
if (g_Config.m_SvRulesLine10[0])
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
g_Config.m_SvRulesLine10);
|
||||
Printed = true;
|
||||
}
|
||||
if (!Printed)
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules",
|
||||
"No Rules Defined, Kill em all!!");
|
||||
}
|
||||
|
||||
void CGameContext::ConTogglePause(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
char aBuf[128];
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
if(!pPlayer)
|
||||
if (!pPlayer)
|
||||
return;
|
||||
|
||||
if(g_Config.m_SvPauseable)
|
||||
if (g_Config.m_SvPauseable)
|
||||
{
|
||||
CCharacter* pChr = pPlayer->GetCharacter();
|
||||
if(!pPlayer->GetTeam() && pChr && (!pChr->GetWeaponGot(WEAPON_NINJA) || pChr->m_FreezeTime) && pChr->IsGrounded() && pChr->m_Pos==pChr->m_PrevPos && !pPlayer->m_InfoSaved)
|
||||
if (!pPlayer->GetTeam() && pChr
|
||||
&& (!pChr->GetWeaponGot(WEAPON_NINJA) || pChr->m_FreezeTime)
|
||||
&& pChr->IsGrounded() && pChr->m_Pos == pChr->m_PrevPos
|
||||
&& !pPlayer->m_InfoSaved)
|
||||
{
|
||||
if(pPlayer->m_LastSetTeam + pSelf->Server()->TickSpeed() * g_Config.m_SvPauseFrequency <= pSelf->Server()->Tick())
|
||||
if (pPlayer->m_LastSetTeam
|
||||
+ pSelf->Server()->TickSpeed() * g_Config.m_SvPauseFrequency
|
||||
<= pSelf->Server()->Tick())
|
||||
{
|
||||
pPlayer->SaveCharacter();
|
||||
pPlayer->m_InfoSaved = true;
|
||||
pPlayer->SetTeam(TEAM_SPECTATORS);
|
||||
}
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause", "You can\'t pause that often.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"pause", "You can\'t pause that often.");
|
||||
}
|
||||
else if(pPlayer->GetTeam()==TEAM_SPECTATORS && pPlayer->m_InfoSaved && pPlayer->m_ForcePauseTime == 0)
|
||||
else if (pPlayer->GetTeam() == TEAM_SPECTATORS && pPlayer->m_InfoSaved
|
||||
&& pPlayer->m_ForcePauseTime == 0)
|
||||
{
|
||||
pPlayer->m_PauseInfo.m_Respawn = true;
|
||||
pPlayer->SetTeam(TEAM_RED);
|
||||
pPlayer->m_InfoSaved = false;
|
||||
//pPlayer->LoadCharacter();//TODO:Check if this system Works
|
||||
}
|
||||
else if(pChr)
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause", pChr->GetWeaponGot(WEAPON_NINJA)?"You can't use /pause while you are a ninja":(!pChr->IsGrounded())?"You can't use /pause while you are a in air":"You can't use /pause while you are moving");
|
||||
else if(pPlayer->m_ForcePauseTime > 0)
|
||||
else if (pChr)
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"pause",
|
||||
pChr->GetWeaponGot(WEAPON_NINJA) ?
|
||||
"You can't use /pause while you are a ninja" :
|
||||
(!pChr->IsGrounded()) ?
|
||||
"You can't use /pause while you are a in air" :
|
||||
"You can't use /pause while you are moving");
|
||||
else if (pPlayer->m_ForcePauseTime > 0)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "You have been force-paused. %ds left.", pPlayer->m_ForcePauseTime/pSelf->Server()->TickSpeed());
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause", aBuf);
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"You have been force-paused. %ds left.",
|
||||
pPlayer->m_ForcePauseTime / pSelf->Server()->TickSpeed());
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause",
|
||||
aBuf);
|
||||
}
|
||||
else if(pPlayer->m_ForcePauseTime < 0)
|
||||
else if (pPlayer->m_ForcePauseTime < 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause", "You have been force-paused.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause",
|
||||
"You have been force-paused.");
|
||||
}
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause", "No pause data saved.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause",
|
||||
"No pause data saved.");
|
||||
}
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause", "Pause isn't allowed on this server.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause",
|
||||
"Pause isn't allowed on this server.");
|
||||
}
|
||||
|
||||
void CGameContext::ConTop5(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
#if defined(CONF_SQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
|
||||
return;
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
|
||||
return;
|
||||
#endif
|
||||
|
||||
if(g_Config.m_SvHideScore)
|
||||
if (g_Config.m_SvHideScore)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "top5", "Showing the top 5 is not allowed on this server.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "top5",
|
||||
"Showing the top 5 is not allowed on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(pResult->NumArguments() > 0)
|
||||
pSelf->Score()->ShowTop5(pResult, pResult->m_ClientID, pUserData, pResult->GetInteger(0));
|
||||
else
|
||||
pSelf->Score()->ShowTop5(pResult, pResult->m_ClientID, pUserData);
|
||||
if (pResult->NumArguments() > 0)
|
||||
pSelf->Score()->ShowTop5(pResult, pResult->m_ClientID, pUserData,
|
||||
pResult->GetInteger(0));
|
||||
else
|
||||
pSelf->Score()->ShowTop5(pResult, pResult->m_ClientID, pUserData);
|
||||
|
||||
#if defined(CONF_SQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery = pSelf->Server()->Tick();
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery = pSelf->Server()->Tick();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -279,9 +418,9 @@ void CGameContext::ConTimes(IConsole::IResult *pResult, void *pUserData)
|
|||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
|
||||
#if defined(CONF_SQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
|
||||
return;
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
|
||||
return;
|
||||
#endif
|
||||
|
||||
if(g_Config.m_SvUseSQL)
|
||||
|
@ -313,7 +452,7 @@ void CGameContext::ConTimes(IConsole::IResult *pResult, void *pUserData)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "times", "/times needs 0, 1 or 2 parameter. 1. = name, 2. = start number");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "times", "Example: /times, /times me, /times Hans, /times \"Papa Smurf\" 5");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "times", "Bad: /times Papa Smurf 5 # Good: /times \"Papa Smurf\" 5 ");
|
||||
|
@ -322,151 +461,205 @@ void CGameContext::ConTimes(IConsole::IResult *pResult, void *pUserData)
|
|||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery = pSelf->Server()->Tick();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CGameContext::ConRank(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
#if defined(CONF_SQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
|
||||
return;
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
|
||||
return;
|
||||
#endif
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
if(!pPlayer)
|
||||
if (!pPlayer)
|
||||
return;
|
||||
|
||||
if(pResult->NumArguments() > 0)
|
||||
if(!g_Config.m_SvHideScore)
|
||||
pSelf->Score()->ShowRank(pResult->m_ClientID, pResult->GetString(0), true);
|
||||
if (pResult->NumArguments() > 0)
|
||||
if (!g_Config.m_SvHideScore)
|
||||
pSelf->Score()->ShowRank(pResult->m_ClientID, pResult->GetString(0),
|
||||
true);
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rank", "Showing the rank of other players is not allowed on this server.");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"rank",
|
||||
"Showing the rank of other players is not allowed on this server.");
|
||||
else
|
||||
pSelf->Score()->ShowRank(pResult->m_ClientID, pSelf->Server()->ClientName(pResult->m_ClientID));
|
||||
pSelf->Score()->ShowRank(pResult->m_ClientID,
|
||||
pSelf->Server()->ClientName(pResult->m_ClientID));
|
||||
|
||||
#if defined(CONF_SQL)
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery = pSelf->Server()->Tick();
|
||||
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
|
||||
pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery = pSelf->Server()->Tick();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CGameContext::ConJoinTeam(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
if(pSelf->m_VoteCloseTime && pSelf->m_VoteCreator == pResult->m_ClientID)
|
||||
if (pSelf->m_VoteCloseTime && pSelf->m_VoteCreator == pResult->m_ClientID)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You are running a vote please try again after the vote is done!");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"join",
|
||||
"You are running a vote please try again after the vote is done!");
|
||||
return;
|
||||
}
|
||||
else if(g_Config.m_SvTeam == 0)
|
||||
else if (g_Config.m_SvTeam == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "Admin has disabled teams");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join",
|
||||
"Admin has disabled teams");
|
||||
return;
|
||||
}
|
||||
else if (g_Config.m_SvTeam == 2)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You must join to any team and play with anybody or you will not play");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"join",
|
||||
"You must join to any team and play with anybody or you will not play");
|
||||
}
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
|
||||
if(pResult->NumArguments() > 0)
|
||||
if (pResult->NumArguments() > 0)
|
||||
{
|
||||
if(pPlayer->GetCharacter() == 0)
|
||||
if (pPlayer->GetCharacter() == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can't change teams while you are dead/a spectator.");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join",
|
||||
"You can't change teams while you are dead/a spectator.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pPlayer->m_Last_Team + pSelf->Server()->TickSpeed() * g_Config.m_SvTeamChangeDelay > pSelf->Server()->Tick())
|
||||
if (pPlayer->m_Last_Team
|
||||
+ pSelf->Server()->TickSpeed()
|
||||
* g_Config.m_SvTeamChangeDelay
|
||||
> pSelf->Server()->Tick())
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can\'t join teams that fast!");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join",
|
||||
"You can\'t join teams that fast!");
|
||||
}
|
||||
else if(((CGameControllerDDRace*)pSelf->m_pController)->m_Teams.SetCharacterTeam(pPlayer->GetCID(), pResult->GetInteger(0)))
|
||||
else if (((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.SetCharacterTeam(
|
||||
pPlayer->GetCID(), pResult->GetInteger(0)))
|
||||
{
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "%s joined team %d", pSelf->Server()->ClientName(pPlayer->GetCID()), pResult->GetInteger(0));
|
||||
str_format(aBuf, sizeof(aBuf), "%s joined team %d",
|
||||
pSelf->Server()->ClientName(pPlayer->GetCID()),
|
||||
pResult->GetInteger(0));
|
||||
pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
pPlayer->m_Last_Team = pSelf->Server()->Tick();
|
||||
}
|
||||
else
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You cannot join this team at this time");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join",
|
||||
"You cannot join this team at this time");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char aBuf[512];
|
||||
if(!pPlayer->IsPlaying())
|
||||
if (!pPlayer->IsPlaying())
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can't check your team while you are dead/a spectator.");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"join",
|
||||
"You can't check your team while you are dead/a spectator.");
|
||||
}
|
||||
else
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "You are in team %d", ((CGameControllerDDRace*)pSelf->m_pController)->m_Teams.m_Core.Team(pResult->m_ClientID));
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", aBuf);
|
||||
str_format(
|
||||
aBuf,
|
||||
sizeof(aBuf),
|
||||
"You are in team %d",
|
||||
((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(
|
||||
pResult->m_ClientID));
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join",
|
||||
aBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConMe(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
char aBuf[256 + 24];
|
||||
|
||||
str_format(aBuf, 256 + 24, "'%s' %s", pSelf->Server()->ClientName(pResult->m_ClientID), pResult->GetString(0));
|
||||
if(g_Config.m_SvSlashMe)
|
||||
str_format(aBuf, 256 + 24, "'%s' %s",
|
||||
pSelf->Server()->ClientName(pResult->m_ClientID),
|
||||
pResult->GetString(0));
|
||||
if (g_Config.m_SvSlashMe)
|
||||
pSelf->SendChat(-2, CGameContext::CHAT_ALL, aBuf, pResult->m_ClientID);
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "me", "/me is disabled on this server, admin can enable it by using sv_slash_me");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"me",
|
||||
"/me is disabled on this server, admin can enable it by using sv_slash_me");
|
||||
}
|
||||
|
||||
void CGameContext::ConToggleEyeEmote(IConsole::IResult *pResult, void *pUserData)
|
||||
void CGameContext::ConToggleEyeEmote(IConsole::IResult *pResult,
|
||||
void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
if(!pPlayer)
|
||||
if (!pPlayer)
|
||||
return;
|
||||
CCharacter* pChr = pPlayer->GetCharacter();
|
||||
if(!pChr)
|
||||
if (!pChr)
|
||||
return;
|
||||
|
||||
pChr->m_EyeEmote = !pChr->m_EyeEmote;
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "emote", (pChr->m_EyeEmote) ? "You can now use the preset eye emotes." : "You don't have any eye emotes, remember to bind some. (until you die)");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"emote",
|
||||
(pChr->m_EyeEmote) ?
|
||||
"You can now use the preset eye emotes." :
|
||||
"You don't have any eye emotes, remember to bind some. (until you die)");
|
||||
}
|
||||
|
||||
void CGameContext::ConEyeEmote(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(g_Config.m_SvEmotionalTees == -1) {
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "emote", "Server admin disabled emotes.");
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (g_Config.m_SvEmotionalTees == -1)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "emote",
|
||||
"Server admin disabled emotes.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
if(!pPlayer)
|
||||
if (!pPlayer)
|
||||
return;
|
||||
CCharacter* pChr = pPlayer->GetCharacter();
|
||||
if(!pChr)
|
||||
if (!pChr)
|
||||
return;
|
||||
|
||||
if (pResult->NumArguments() == 0)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "emote", "Emote commands are: /emote surprise /emote blink /emote close /emote angry /emote happy /emote pain");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "emote", "Example: /emote surprise 10 for 10 seconds or /emote surprise (default 1 second)");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"emote",
|
||||
"Emote commands are: /emote surprise /emote blink /emote close /emote angry /emote happy /emote pain");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"emote",
|
||||
"Example: /emote surprise 10 for 10 seconds or /emote surprise (default 1 second)");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -487,44 +680,55 @@ void CGameContext::ConEyeEmote(IConsole::IResult *pResult, void *pUserData)
|
|||
else if (!str_comp(pResult->GetString(0), "normal"))
|
||||
pChr->m_DefEmote = EMOTE_NORMAL;
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "emote", "Unknown emote... Say /emote");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"emote", "Unknown emote... Say /emote");
|
||||
|
||||
int Duration = 1;
|
||||
if (pResult->NumArguments() > 1)
|
||||
Duration = pResult->GetInteger(1);
|
||||
|
||||
pChr->m_DefEmoteReset = pSelf->Server()->Tick() + Duration * pSelf->Server()->TickSpeed();
|
||||
pChr->m_DefEmoteReset = pSelf->Server()->Tick()
|
||||
+ Duration * pSelf->Server()->TickSpeed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConShowOthers(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
if(!pPlayer)
|
||||
if (!pPlayer)
|
||||
return;
|
||||
if(g_Config.m_SvShowOthers)
|
||||
if (g_Config.m_SvShowOthers)
|
||||
{
|
||||
if(pPlayer->m_IsUsingDDRaceClient)
|
||||
if (pPlayer->m_IsUsingDDRaceClient)
|
||||
{
|
||||
if(pResult->NumArguments())
|
||||
if (pResult->NumArguments())
|
||||
pPlayer->m_ShowOthers = pResult->GetInteger(0);
|
||||
else
|
||||
pPlayer->m_ShowOthers = !pPlayer->m_ShowOthers;
|
||||
}
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "showotherschat", "Showing players from other teams is only available with DDRace Client, http://DDRace.info");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"showotherschat",
|
||||
"Showing players from other teams is only available with DDRace Client, http://DDRace.info");
|
||||
}
|
||||
else
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "showotherschat", "Showing players from other teams is disabled by the server admin");
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"showotherschat",
|
||||
"Showing players from other teams is disabled by the server admin");
|
||||
}
|
||||
|
||||
bool CheckClientID(int ClientID)
|
||||
{
|
||||
dbg_assert(ClientID >= 0 || ClientID < MAX_CLIENTS, "The Client ID is wrong");
|
||||
if(ClientID < 0 || ClientID >= MAX_CLIENTS) return false;
|
||||
dbg_assert(ClientID >= 0 || ClientID < MAX_CLIENTS,
|
||||
"The Client ID is wrong");
|
||||
if (ClientID < 0 || ClientID >= MAX_CLIENTS)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#ifndef GAME_SERVER_DDRACECOMMANDS_H
|
||||
#define GAME_SERVER_DDRACECOMMANDS_H
|
||||
#undef GAME_SERVER_DDRACECOMMANDS_H // this file can be included several times
|
||||
|
||||
#ifndef CHAT_COMMAND
|
||||
#define CHAT_COMMAND(name, params, flags, callback, userdata, help)
|
||||
#endif
|
||||
|
|
|
@ -7,58 +7,66 @@
|
|||
#include <game/version.h>
|
||||
#include <game/generated/nethash.cpp>
|
||||
#if defined(CONF_SQL)
|
||||
#include <game/server/score/sql_score.h>
|
||||
#include <game/server/score/sql_score.h>
|
||||
#endif
|
||||
|
||||
bool CheckClientID(int ClientID);
|
||||
|
||||
void CGameContext::ConGoLeft(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
pSelf->MoveCharacter(pResult->m_ClientID, -1, 0);
|
||||
}
|
||||
|
||||
void CGameContext::ConGoRight(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
pSelf->MoveCharacter(pResult->m_ClientID, 1, 0);
|
||||
}
|
||||
|
||||
void CGameContext::ConGoDown(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
pSelf->MoveCharacter(pResult->m_ClientID, 0, 1);
|
||||
}
|
||||
|
||||
void CGameContext::ConGoUp(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
pSelf->MoveCharacter(pResult->m_ClientID, 0, -1);
|
||||
}
|
||||
|
||||
void CGameContext::ConMove(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
pSelf->MoveCharacter(pResult->m_ClientID, pResult->GetInteger(0), pResult->GetInteger(1));
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
pSelf->MoveCharacter(pResult->m_ClientID, pResult->GetInteger(0),
|
||||
pResult->GetInteger(1));
|
||||
}
|
||||
|
||||
void CGameContext::ConMoveRaw(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
pSelf->MoveCharacter(pResult->m_ClientID, pResult->GetInteger(0), pResult->GetInteger(1), true);
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
pSelf->MoveCharacter(pResult->m_ClientID, pResult->GetInteger(0),
|
||||
pResult->GetInteger(1), true);
|
||||
}
|
||||
|
||||
void CGameContext::MoveCharacter(int ClientID, int X, int Y, bool Raw)
|
||||
{
|
||||
CCharacter* pChr = GetPlayerChar(ClientID);
|
||||
|
||||
if(!pChr)
|
||||
if (!pChr)
|
||||
return;
|
||||
|
||||
pChr->Core()->m_Pos.x += ((Raw) ? 1 : 32) * X;
|
||||
|
@ -66,34 +74,37 @@ void CGameContext::MoveCharacter(int ClientID, int X, int Y, bool Raw)
|
|||
pChr->m_DDRaceState = DDRACE_CHEAT;
|
||||
}
|
||||
|
||||
|
||||
void CGameContext::ConKillPlayer(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
int Victim = pResult->GetVictim();
|
||||
|
||||
if(pSelf->m_apPlayers[Victim])
|
||||
if (pSelf->m_apPlayers[Victim])
|
||||
{
|
||||
pSelf->m_apPlayers[Victim]->KillCharacter(WEAPON_GAME);
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "%s was killed by %s", pSelf->Server()->ClientName(Victim), pSelf->Server()->ClientName(pResult->m_ClientID));
|
||||
str_format(aBuf, sizeof(aBuf), "%s was killed by %s",
|
||||
pSelf->Server()->ClientName(Victim),
|
||||
pSelf->Server()->ClientName(pResult->m_ClientID));
|
||||
pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConNinja(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_NINJA, false);
|
||||
}
|
||||
|
||||
void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
||||
if(pChr && !pChr->m_Super)
|
||||
if (pChr && !pChr->m_Super)
|
||||
{
|
||||
pChr->m_Super = true;
|
||||
pChr->UnFreeze();
|
||||
|
@ -105,97 +116,105 @@ void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
void CGameContext::ConUnSuper(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
||||
if(pChr && pChr->m_Super)
|
||||
if (pChr && pChr->m_Super)
|
||||
{
|
||||
pChr->m_Super = false;
|
||||
pChr->Teams()->SetForceCharacterTeam(pResult->m_ClientID, pChr->m_TeamBeforeSuper);
|
||||
pChr->Teams()->SetForceCharacterTeam(pResult->m_ClientID,
|
||||
pChr->m_TeamBeforeSuper);
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::ConShotgun(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_SHOTGUN, false);
|
||||
}
|
||||
|
||||
void CGameContext::ConGrenade(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_GRENADE, false);
|
||||
}
|
||||
|
||||
void CGameContext::ConRifle(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_RIFLE, false);
|
||||
}
|
||||
|
||||
void CGameContext::ConWeapons(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, -1, false);
|
||||
}
|
||||
|
||||
void CGameContext::ConUnShotgun(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_SHOTGUN, true);
|
||||
}
|
||||
|
||||
void CGameContext::ConUnGrenade(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_GRENADE, true);
|
||||
}
|
||||
|
||||
void CGameContext::ConUnRifle(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_RIFLE, true);
|
||||
}
|
||||
|
||||
void CGameContext::ConUnWeapons(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, -1, true);
|
||||
}
|
||||
|
||||
void CGameContext::ConAddWeapon(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, pResult->GetInteger(0), false);
|
||||
}
|
||||
|
||||
void CGameContext::ConRemoveWeapon(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->ModifyWeapons(pResult, pUserData, pResult->GetInteger(0), true);
|
||||
}
|
||||
|
||||
void CGameContext::ModifyWeapons(IConsole::IResult *pResult, void *pUserData, int Weapon, bool Remove)
|
||||
void CGameContext::ModifyWeapons(IConsole::IResult *pResult, void *pUserData,
|
||||
int Weapon, bool Remove)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
int ClientID = pResult->m_ClientID;
|
||||
if(clamp(Weapon, -1, NUM_WEAPONS - 1) != Weapon)
|
||||
if (clamp(Weapon, -1, NUM_WEAPONS - 1) != Weapon)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "invalid weapon id");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
||||
"invalid weapon id");
|
||||
return;
|
||||
}
|
||||
|
||||
CCharacter* pChr = GetPlayerChar(ClientID);
|
||||
if(!pChr)
|
||||
if (!pChr)
|
||||
return;
|
||||
|
||||
if(Weapon == -1)
|
||||
if (Weapon == -1)
|
||||
{
|
||||
if(Remove && (pChr->GetActiveWeapon() == WEAPON_SHOTGUN || pChr->GetActiveWeapon() == WEAPON_GRENADE || pChr->GetActiveWeapon() == WEAPON_RIFLE))
|
||||
if (Remove
|
||||
&& (pChr->GetActiveWeapon() == WEAPON_SHOTGUN
|
||||
|| pChr->GetActiveWeapon() == WEAPON_GRENADE
|
||||
|| pChr->GetActiveWeapon() == WEAPON_RIFLE))
|
||||
pChr->SetActiveWeapon(WEAPON_GUN);
|
||||
|
||||
if(Remove)
|
||||
if (Remove)
|
||||
{
|
||||
pChr->SetWeaponGot(WEAPON_SHOTGUN, false);
|
||||
pChr->SetWeaponGot(WEAPON_GRENADE, false);
|
||||
|
@ -204,21 +223,22 @@ void CGameContext::ModifyWeapons(IConsole::IResult *pResult, void *pUserData, in
|
|||
else
|
||||
pChr->GiveAllWeapons();
|
||||
}
|
||||
else if(Weapon != WEAPON_NINJA)
|
||||
else if (Weapon != WEAPON_NINJA)
|
||||
{
|
||||
if(Remove && pChr->GetActiveWeapon() == Weapon)
|
||||
if (Remove && pChr->GetActiveWeapon() == Weapon)
|
||||
pChr->SetActiveWeapon(WEAPON_GUN);
|
||||
|
||||
if(Remove)
|
||||
if (Remove)
|
||||
pChr->SetWeaponGot(Weapon, false);
|
||||
else
|
||||
pChr->GiveWeapon(Weapon, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Remove)
|
||||
if (Remove)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "you can't remove ninja");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
||||
"you can't remove ninja");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -230,13 +250,14 @@ void CGameContext::ModifyWeapons(IConsole::IResult *pResult, void *pUserData, in
|
|||
|
||||
void CGameContext::ConTeleport(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->GetVictim())) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->GetVictim()))
|
||||
return;
|
||||
int TeleTo = pResult->GetVictim();
|
||||
if(pSelf->m_apPlayers[TeleTo])
|
||||
if (pSelf->m_apPlayers[TeleTo])
|
||||
{
|
||||
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
||||
if(pChr)
|
||||
if (pChr)
|
||||
{
|
||||
pChr->Core()->m_Pos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
|
||||
pChr->m_DDRaceState = DDRACE_CHEAT;
|
||||
|
@ -246,11 +267,17 @@ void CGameContext::ConTeleport(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
void CGameContext::ConKill(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
|
||||
if(!pPlayer || (pPlayer->m_LastKill && pPlayer->m_LastKill + pSelf->Server()->TickSpeed() * g_Config.m_SvKillDelay > pSelf->Server()->Tick()))
|
||||
if (!pPlayer
|
||||
|| (pPlayer->m_LastKill
|
||||
&& pPlayer->m_LastKill
|
||||
+ pSelf->Server()->TickSpeed()
|
||||
* g_Config.m_SvKillDelay
|
||||
> pSelf->Server()->Tick()))
|
||||
return;
|
||||
|
||||
pPlayer->m_LastKill = pSelf->Server()->Tick();
|
||||
|
@ -260,71 +287,81 @@ void CGameContext::ConKill(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
void CGameContext::ConForcePause(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
// if(!CheckClientID(pResult->m_ClientID)) return;
|
||||
CServer* pServ = (CServer*)pSelf->Server();
|
||||
CServer* pServ = (CServer*) pSelf->Server();
|
||||
int Victim = pResult->GetVictim();
|
||||
int Seconds = 0;
|
||||
char aBuf[128];
|
||||
|
||||
if(pResult->NumArguments() > 0 && pResult->m_ClientID < 0)
|
||||
if (pResult->NumArguments() > 0 && pResult->m_ClientID < 0)
|
||||
Seconds = clamp(pResult->GetInteger(0), 0, 15);
|
||||
//else if(pResult->NumArguments() > 0 && CheckClientID(pResult->m_ClientID))
|
||||
//Seconds = clamp(pResult->GetInteger(1), 0, 360);
|
||||
//Seconds = clamp(pResult->GetInteger(1), 0, 360);
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
|
||||
if(!pPlayer || (!Seconds && pResult->m_ClientID >= 0))
|
||||
if (!pPlayer || (!Seconds && pResult->m_ClientID >= 0))
|
||||
return;
|
||||
|
||||
CCharacter* pChr = pPlayer->GetCharacter();
|
||||
if(!pPlayer->GetTeam() && pChr && !pPlayer->m_InfoSaved && pResult->m_ClientID < 0)
|
||||
if (!pPlayer->GetTeam() && pChr && !pPlayer->m_InfoSaved
|
||||
&& pResult->m_ClientID < 0)
|
||||
{
|
||||
pPlayer->SaveCharacter();
|
||||
pPlayer->m_InfoSaved = true;
|
||||
pPlayer->SetTeam(TEAM_SPECTATORS);
|
||||
pPlayer->m_ForcePauseTime = Seconds*pServ->TickSpeed();
|
||||
pPlayer->m_ForcePauseTime = Seconds * pServ->TickSpeed();
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->m_ForcePauseTime = Seconds*pServ->TickSpeed();
|
||||
pPlayer->m_ForcePauseTime = Seconds * pServ->TickSpeed();
|
||||
}
|
||||
if(pResult->m_ClientID < 0)
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' has been force-paused for %d seconds", pServ->ClientName(Victim), Seconds);
|
||||
if (pResult->m_ClientID < 0)
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"'%s' has been force-paused for %d seconds",
|
||||
pServ->ClientName(Victim), Seconds);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "Force-pause of '%s' have been removed by '%s'", pServ->ClientName(Victim), pServ->ClientName(pResult->m_ClientID));
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"Force-pause of '%s' have been removed by '%s'",
|
||||
pServ->ClientName(Victim),
|
||||
pServ->ClientName(pResult->m_ClientID));
|
||||
pSelf->SendChat(-1, CHAT_ALL, aBuf);
|
||||
}
|
||||
|
||||
void CGameContext::Mute(IConsole::IResult *pResult, NETADDR *Addr, int Secs, const char *pDisplayName)
|
||||
void CGameContext::Mute(IConsole::IResult *pResult, NETADDR *Addr, int Secs,
|
||||
const char *pDisplayName)
|
||||
{
|
||||
char aBuf[128];
|
||||
int Found = 0;
|
||||
// find a matching mute for this ip, update expiration time if found
|
||||
for(int i = 0; i < m_NumMutes; i++)
|
||||
for (int i = 0; i < m_NumMutes; i++)
|
||||
{
|
||||
if(net_addr_comp(&m_aMutes[i].m_Addr, Addr) == 0)
|
||||
if (net_addr_comp(&m_aMutes[i].m_Addr, Addr) == 0)
|
||||
{
|
||||
m_aMutes[i].m_Expire = Server()->Tick() + Secs * Server()->TickSpeed();
|
||||
m_aMutes[i].m_Expire = Server()->Tick()
|
||||
+ Secs * Server()->TickSpeed();
|
||||
Found = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!Found) // nothing found so far, find a free slot..
|
||||
if (!Found) // nothing found so far, find a free slot..
|
||||
{
|
||||
if(m_NumMutes < MAX_MUTES)
|
||||
if (m_NumMutes < MAX_MUTES)
|
||||
{
|
||||
m_aMutes[m_NumMutes].m_Addr = *Addr;
|
||||
m_aMutes[m_NumMutes].m_Expire = Server()->Tick() + Secs * Server()->TickSpeed();
|
||||
m_aMutes[m_NumMutes].m_Expire = Server()->Tick()
|
||||
+ Secs * Server()->TickSpeed();
|
||||
m_NumMutes++;
|
||||
Found = 1;
|
||||
}
|
||||
}
|
||||
if(Found)
|
||||
if (Found)
|
||||
{
|
||||
str_format(aBuf, sizeof aBuf, "'%s' has been muted for %d seconds.", pDisplayName, Secs);
|
||||
str_format(aBuf, sizeof aBuf, "'%s' has been muted for %d seconds.",
|
||||
pDisplayName, Secs);
|
||||
SendChat(-1, CHAT_ALL, aBuf);
|
||||
}
|
||||
else if(pResult)// no free slot found
|
||||
else if (pResult) // no free slot found
|
||||
// pResult->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", "mute array is full");
|
||||
// Todo(Shereef Marzouk: Fix this
|
||||
dbg_msg("mutes", "mute array is full");
|
||||
|
@ -332,64 +369,78 @@ void CGameContext::Mute(IConsole::IResult *pResult, NETADDR *Addr, int Secs, con
|
|||
|
||||
void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", "Use either 'muteid <client_id> <seconds>' or 'muteip <ip> <seconds>'");
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
"mutes",
|
||||
"Use either 'muteid <client_id> <seconds>' or 'muteip <ip> <seconds>'");
|
||||
}
|
||||
|
||||
// mute through client id
|
||||
void CGameContext::ConMuteID(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
int Victim = pResult->GetVictim();
|
||||
|
||||
NETADDR Addr;
|
||||
pSelf->Server()->GetClientAddr(Victim, &Addr);
|
||||
|
||||
pSelf->Mute(pResult, &Addr, clamp(pResult->GetInteger(0), 1, 86400), pSelf->Server()->ClientName(Victim));
|
||||
pSelf->Mute(pResult, &Addr, clamp(pResult->GetInteger(0), 1, 86400),
|
||||
pSelf->Server()->ClientName(Victim));
|
||||
}
|
||||
|
||||
// mute through ip, arguments reversed to workaround parsing
|
||||
void CGameContext::ConMuteIP(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
NETADDR Addr;
|
||||
if(net_addr_from_str(&Addr, pResult->GetString(0)))
|
||||
if (net_addr_from_str(&Addr, pResult->GetString(0)))
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", "Invalid network address to mute");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes",
|
||||
"Invalid network address to mute");
|
||||
}
|
||||
pSelf->Mute(pResult, &Addr, clamp(pResult->GetInteger(1), 1, 86400), pResult->GetString(0));
|
||||
pSelf->Mute(pResult, &Addr, clamp(pResult->GetInteger(1), 1, 86400),
|
||||
pResult->GetString(0));
|
||||
}
|
||||
|
||||
// unmute by mute list index
|
||||
void CGameContext::ConUnmute(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
char aIpBuf[64];
|
||||
char aBuf[64];
|
||||
int Victim = pResult->GetVictim();
|
||||
|
||||
if(Victim < 0 || Victim >= pSelf->m_NumMutes)
|
||||
if (Victim < 0 || Victim >= pSelf->m_NumMutes)
|
||||
return;
|
||||
|
||||
|
||||
pSelf->m_NumMutes--;
|
||||
pSelf->m_aMutes[Victim] = pSelf->m_aMutes[pSelf->m_NumMutes];
|
||||
|
||||
net_addr_str(&pSelf->m_aMutes[Victim].m_Addr, aIpBuf, sizeof(aIpBuf));
|
||||
str_format(aBuf, sizeof(aBuf), "Unmuted %s" , aIpBuf);
|
||||
str_format(aBuf, sizeof(aBuf), "Unmuted %s", aIpBuf);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf);
|
||||
}
|
||||
|
||||
// list mutes
|
||||
void CGameContext::ConMutes(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
char aIpBuf[64];
|
||||
char aBuf[128];
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", "Active mutes:");
|
||||
for(int i = 0; i < pSelf->m_NumMutes; i++)
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes",
|
||||
"Active mutes:");
|
||||
for (int i = 0; i < pSelf->m_NumMutes; i++)
|
||||
{
|
||||
net_addr_str(&pSelf->m_aMutes[i].m_Addr, aIpBuf, sizeof(aIpBuf));
|
||||
str_format(aBuf, sizeof aBuf, "%d: \"%s\", %d seconds left", i, aIpBuf, (pSelf->m_aMutes[i].m_Expire - pSelf->Server()->Tick()) / pSelf->Server()->TickSpeed());
|
||||
str_format(
|
||||
aBuf,
|
||||
sizeof aBuf,
|
||||
"%d: \"%s\", %d seconds left",
|
||||
i,
|
||||
aIpBuf,
|
||||
(pSelf->m_aMutes[i].m_Expire - pSelf->Server()->Tick())
|
||||
/ pSelf->Server()->TickSpeed());
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,16 @@
|
|||
|
||||
#include "door.h"
|
||||
|
||||
CDoor::CDoor(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length, int Number)
|
||||
: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
CDoor::CDoor(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length,
|
||||
int Number) :
|
||||
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
{
|
||||
m_Number = Number;
|
||||
m_Pos = Pos;
|
||||
|
||||
m_Length = Length;
|
||||
|
||||
m_Direction = vec2(sin(Rotation), cos(Rotation));
|
||||
vec2 To = Pos + normalize(m_Direction) * m_Length;
|
||||
|
||||
|
||||
GameServer()->Collision()->IntersectNoLaser(Pos, To, &this->m_To, 0);
|
||||
ResetCollision();
|
||||
GameWorld()->InsertEntity(this);
|
||||
|
@ -24,18 +23,24 @@ CDoor::CDoor(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length, int N
|
|||
|
||||
void CDoor::Open(int Tick, bool ActivatedTeam[])
|
||||
{
|
||||
m_EvalTick=Server()->Tick();
|
||||
m_EvalTick = Server()->Tick();
|
||||
}
|
||||
|
||||
void CDoor::ResetCollision()
|
||||
{
|
||||
for(int i=0;i<m_Length-1;i++)
|
||||
for (int i = 0; i < m_Length - 1; i++)
|
||||
{
|
||||
vec2 CurrentPos(m_Pos.x + (m_Direction.x * i), m_Pos.y + (m_Direction.y * i));
|
||||
if(GameServer()->Collision()->CheckPoint(CurrentPos) || GameServer()->Collision()->GetTile(m_Pos.x, m_Pos.y) || GameServer()->Collision()->GetFTile(m_Pos.x, m_Pos.y))
|
||||
vec2 CurrentPos(m_Pos.x + (m_Direction.x * i),
|
||||
m_Pos.y + (m_Direction.y * i));
|
||||
if (GameServer()->Collision()->CheckPoint(CurrentPos)
|
||||
|| GameServer()->Collision()->GetTile(m_Pos.x, m_Pos.y)
|
||||
|| GameServer()->Collision()->GetFTile(m_Pos.x, m_Pos.y))
|
||||
break;
|
||||
else
|
||||
GameServer()->Collision()->SetDCollisionAt(m_Pos.x + (m_Direction.x * i), m_Pos.y + (m_Direction.y * i), TILE_STOPA, 0/*Flags*/, m_Number);
|
||||
GameServer()->Collision()->SetDCollisionAt(
|
||||
m_Pos.x + (m_Direction.x * i),
|
||||
m_Pos.y + (m_Direction.y * i), TILE_STOPA, 0/*Flags*/,
|
||||
m_Number);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,32 +66,38 @@ void CDoor::Tick()
|
|||
|
||||
void CDoor::Snap(int SnappingClient)
|
||||
{
|
||||
if(NetworkClipped(SnappingClient, m_Pos) && NetworkClipped(SnappingClient, m_To))
|
||||
if (NetworkClipped(SnappingClient, m_Pos)
|
||||
&& NetworkClipped(SnappingClient, m_To))
|
||||
return;
|
||||
|
||||
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
||||
pObj->m_X = (int)m_Pos.x;
|
||||
pObj->m_Y = (int)m_Pos.y;
|
||||
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
|
||||
NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
||||
pObj->m_X = (int) m_Pos.x;
|
||||
pObj->m_Y = (int) m_Pos.y;
|
||||
|
||||
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
|
||||
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
|
||||
if(Char == 0) return;
|
||||
if(Char->IsAlive() && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()] && (!Tick)) return;
|
||||
int Tick = (Server()->Tick() % Server()->TickSpeed()) % 11;
|
||||
if (Char == 0)
|
||||
return;
|
||||
if (Char->IsAlive()
|
||||
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]
|
||||
&& (!Tick))
|
||||
return;
|
||||
|
||||
if(Char->Team() == TEAM_SUPER)
|
||||
if (Char->Team() == TEAM_SUPER)
|
||||
{
|
||||
pObj->m_FromX = (int)m_Pos.x;
|
||||
pObj->m_FromY = (int)m_Pos.y;
|
||||
pObj->m_FromX = (int) m_Pos.x;
|
||||
pObj->m_FromY = (int) m_Pos.y;
|
||||
}
|
||||
else if (GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()])
|
||||
{
|
||||
pObj->m_FromX = (int)m_To.x;
|
||||
pObj->m_FromY = (int)m_To.y;
|
||||
pObj->m_FromX = (int) m_To.x;
|
||||
pObj->m_FromY = (int) m_To.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_FromX = (int)m_Pos.x;
|
||||
pObj->m_FromY = (int)m_Pos.y;
|
||||
pObj->m_FromX = (int) m_Pos.x;
|
||||
pObj->m_FromY = (int) m_Pos.y;
|
||||
}
|
||||
pObj->m_StartTick = Server()->Tick();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
class CTrigger;
|
||||
|
||||
class CDoor : public CEntity
|
||||
class CDoor: public CEntity
|
||||
{
|
||||
vec2 m_To;
|
||||
int m_EvalTick;
|
||||
|
@ -14,13 +14,14 @@ class CDoor : public CEntity
|
|||
int m_Length;
|
||||
vec2 m_Direction;
|
||||
int m_Angle;
|
||||
|
||||
|
||||
public:
|
||||
void Open(int Tick, bool ActivatedTeam[]);
|
||||
void Open(int Team);
|
||||
void Close(int Team);
|
||||
CDoor(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length, int Number);
|
||||
|
||||
CDoor(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length,
|
||||
int Number);
|
||||
|
||||
virtual void Reset();
|
||||
virtual void Tick();
|
||||
virtual void Snap(int SnappingClient);
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
#include <game/server/gamemodes/DDRace.h>
|
||||
#include "dragger.h"
|
||||
|
||||
const int LENGTH=700;
|
||||
const int LENGTH = 700;
|
||||
|
||||
CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, int CatchedTeam, int Layer, int Number)
|
||||
: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW,
|
||||
int CatchedTeam, int Layer, int Number) :
|
||||
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
{
|
||||
m_Layer = Layer;
|
||||
m_Number = Number;
|
||||
|
@ -24,29 +25,39 @@ CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, in
|
|||
|
||||
void CDragger::Move()
|
||||
{
|
||||
if(m_Target && m_Target->IsAlive() && (m_Target->m_Super || (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[m_Target->Team()])))
|
||||
if (m_Target && m_Target->IsAlive()
|
||||
&& (m_Target->m_Super
|
||||
|| (m_Layer == LAYER_SWITCH
|
||||
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[m_Target->Team()])))
|
||||
m_Target = 0;
|
||||
if(m_Target)
|
||||
if (m_Target)
|
||||
return;
|
||||
CCharacter *Ents[16];
|
||||
int Num = GameServer()->m_World.FindEntities(m_Pos,LENGTH, (CEntity**)Ents, 16, CGameWorld::ENTTYPE_CHARACTER);
|
||||
int Id=-1;
|
||||
int MinLen=0;
|
||||
int Num = GameServer()->m_World.FindEntities(m_Pos, LENGTH,
|
||||
(CEntity**) Ents, 16, CGameWorld::ENTTYPE_CHARACTER);
|
||||
int Id = -1;
|
||||
int MinLen = 0;
|
||||
for (int i = 0; i < Num; i++)
|
||||
{
|
||||
m_Target = Ents[i];
|
||||
if(m_Target->Team() != m_CatchedTeam) continue;
|
||||
if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[m_Target->Team()]) continue;
|
||||
int Res = m_NW ? GameServer()->Collision()->IntersectNoLaserNW(m_Pos, m_Target->m_Pos, 0, 0) :
|
||||
GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Target->m_Pos, 0, 0);
|
||||
if (m_Target->Team() != m_CatchedTeam)
|
||||
continue;
|
||||
if (m_Layer == LAYER_SWITCH
|
||||
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[m_Target->Team()])
|
||||
continue;
|
||||
int Res =
|
||||
m_NW ? GameServer()->Collision()->IntersectNoLaserNW(m_Pos,
|
||||
m_Target->m_Pos, 0, 0) :
|
||||
GameServer()->Collision()->IntersectNoLaser(m_Pos,
|
||||
m_Target->m_Pos, 0, 0);
|
||||
|
||||
if (Res==0)
|
||||
if (Res == 0)
|
||||
{
|
||||
int Len=length(m_Target->m_Pos - m_Pos);
|
||||
if (MinLen==0 || MinLen>Len)
|
||||
int Len = length(m_Target->m_Pos - m_Pos);
|
||||
if (MinLen == 0 || MinLen > Len)
|
||||
{
|
||||
MinLen=Len;
|
||||
Id=i;
|
||||
MinLen = Len;
|
||||
Id = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,27 +71,137 @@ void CDragger::Drag()
|
|||
|
||||
int Res = 0;
|
||||
if (!m_NW)
|
||||
Res = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Target->m_Pos, 0, 0);
|
||||
Res = GameServer()->Collision()->IntersectNoLaser(m_Pos,
|
||||
m_Target->m_Pos, 0, 0);
|
||||
else
|
||||
Res = GameServer()->Collision()->IntersectNoLaserNW(m_Pos, m_Target->m_Pos, 0, 0);
|
||||
if (Res || length(m_Pos-m_Target->m_Pos)>700)
|
||||
Res = GameServer()->Collision()->IntersectNoLaserNW(m_Pos,
|
||||
m_Target->m_Pos, 0, 0);
|
||||
if (Res || length(m_Pos - m_Target->m_Pos) > 700)
|
||||
{
|
||||
m_Target=0;
|
||||
m_Target = 0;
|
||||
}
|
||||
else if (length(m_Pos - m_Target->m_Pos) > 28)
|
||||
{
|
||||
vec2 Temp = m_Target->Core()->m_Vel
|
||||
+ (normalize(m_Pos - m_Target->m_Pos) * m_Strength);
|
||||
if (Temp.x > 0
|
||||
&& ((m_Target->m_TileIndex == TILE_STOP
|
||||
&& m_Target->m_TileFlags == ROTATION_270)
|
||||
|| (m_Target->m_TileIndexL == TILE_STOP
|
||||
&& m_Target->m_TileFlagsL == ROTATION_270)
|
||||
|| (m_Target->m_TileIndexL == TILE_STOPS
|
||||
&& (m_Target->m_TileFlagsL == ROTATION_90
|
||||
|| m_Target->m_TileFlagsL
|
||||
== ROTATION_270))
|
||||
|| (m_Target->m_TileIndexL == TILE_STOPA)
|
||||
|| (m_Target->m_TileFIndex == TILE_STOP
|
||||
&& m_Target->m_TileFFlags == ROTATION_270)
|
||||
|| (m_Target->m_TileFIndexL == TILE_STOP
|
||||
&& m_Target->m_TileFFlagsL == ROTATION_270)
|
||||
|| (m_Target->m_TileFIndexL == TILE_STOPS
|
||||
&& (m_Target->m_TileFFlagsL == ROTATION_90
|
||||
|| m_Target->m_TileFFlagsL
|
||||
== ROTATION_270))
|
||||
|| (m_Target->m_TileFIndexL == TILE_STOPA)
|
||||
|| (m_Target->m_TileSIndex == TILE_STOP
|
||||
&& m_Target->m_TileSFlags == ROTATION_270)
|
||||
|| (m_Target->m_TileSIndexL == TILE_STOP
|
||||
&& m_Target->m_TileSFlagsL == ROTATION_270)
|
||||
|| (m_Target->m_TileSIndexL == TILE_STOPS
|
||||
&& (m_Target->m_TileSFlagsL == ROTATION_90
|
||||
|| m_Target->m_TileSFlagsL
|
||||
== ROTATION_270))
|
||||
|| (m_Target->m_TileSIndexL == TILE_STOPA)))
|
||||
Temp.x = 0;
|
||||
if (Temp.x < 0
|
||||
&& ((m_Target->m_TileIndex == TILE_STOP
|
||||
&& m_Target->m_TileFlags == ROTATION_90)
|
||||
|| (m_Target->m_TileIndexR == TILE_STOP
|
||||
&& m_Target->m_TileFlagsR == ROTATION_90)
|
||||
|| (m_Target->m_TileIndexR == TILE_STOPS
|
||||
&& (m_Target->m_TileFlagsR == ROTATION_90
|
||||
|| m_Target->m_TileFlagsR
|
||||
== ROTATION_270))
|
||||
|| (m_Target->m_TileIndexR == TILE_STOPA)
|
||||
|| (m_Target->m_TileFIndex == TILE_STOP
|
||||
&& m_Target->m_TileFFlags == ROTATION_90)
|
||||
|| (m_Target->m_TileFIndexR == TILE_STOP
|
||||
&& m_Target->m_TileFFlagsR == ROTATION_90)
|
||||
|| (m_Target->m_TileFIndexR == TILE_STOPS
|
||||
&& (m_Target->m_TileFFlagsR == ROTATION_90
|
||||
|| m_Target->m_TileFFlagsR
|
||||
== ROTATION_270))
|
||||
|| (m_Target->m_TileFIndexR == TILE_STOPA)
|
||||
|| (m_Target->m_TileSIndex == TILE_STOP
|
||||
&& m_Target->m_TileSFlags == ROTATION_90)
|
||||
|| (m_Target->m_TileSIndexR == TILE_STOP
|
||||
&& m_Target->m_TileSFlagsR == ROTATION_90)
|
||||
|| (m_Target->m_TileSIndexR == TILE_STOPS
|
||||
&& (m_Target->m_TileSFlagsR == ROTATION_90
|
||||
|| m_Target->m_TileSFlagsR
|
||||
== ROTATION_270))
|
||||
|| (m_Target->m_TileSIndexR == TILE_STOPA)))
|
||||
Temp.x = 0;
|
||||
if (Temp.y < 0
|
||||
&& ((m_Target->m_TileIndex == TILE_STOP
|
||||
&& m_Target->m_TileFlags == ROTATION_180)
|
||||
|| (m_Target->m_TileIndexB == TILE_STOP
|
||||
&& m_Target->m_TileFlagsB == ROTATION_180)
|
||||
|| (m_Target->m_TileIndexB == TILE_STOPS
|
||||
&& (m_Target->m_TileFlagsB == ROTATION_0
|
||||
|| m_Target->m_TileFlagsB
|
||||
== ROTATION_180))
|
||||
|| (m_Target->m_TileIndexB == TILE_STOPA)
|
||||
|| (m_Target->m_TileFIndex == TILE_STOP
|
||||
&& m_Target->m_TileFFlags == ROTATION_180)
|
||||
|| (m_Target->m_TileFIndexB == TILE_STOP
|
||||
&& m_Target->m_TileFFlagsB == ROTATION_180)
|
||||
|| (m_Target->m_TileFIndexB == TILE_STOPS
|
||||
&& (m_Target->m_TileFFlagsB == ROTATION_0
|
||||
|| m_Target->m_TileFFlagsB
|
||||
== ROTATION_180))
|
||||
|| (m_Target->m_TileFIndexB == TILE_STOPA)
|
||||
|| (m_Target->m_TileSIndex == TILE_STOP
|
||||
&& m_Target->m_TileSFlags == ROTATION_180)
|
||||
|| (m_Target->m_TileSIndexB == TILE_STOP
|
||||
&& m_Target->m_TileSFlagsB == ROTATION_180)
|
||||
|| (m_Target->m_TileSIndexB == TILE_STOPS
|
||||
&& (m_Target->m_TileSFlagsB == ROTATION_0
|
||||
|| m_Target->m_TileSFlagsB
|
||||
== ROTATION_180))
|
||||
|| (m_Target->m_TileSIndexB == TILE_STOPA)))
|
||||
Temp.y = 0;
|
||||
if (Temp.y > 0
|
||||
&& ((m_Target->m_TileIndex == TILE_STOP
|
||||
&& m_Target->m_TileFlags == ROTATION_0)
|
||||
|| (m_Target->m_TileIndexT == TILE_STOP
|
||||
&& m_Target->m_TileFlagsT == ROTATION_0)
|
||||
|| (m_Target->m_TileIndexT == TILE_STOPS
|
||||
&& (m_Target->m_TileFlagsT == ROTATION_0
|
||||
|| m_Target->m_TileFlagsT
|
||||
== ROTATION_180))
|
||||
|| (m_Target->m_TileIndexT == TILE_STOPA)
|
||||
|| (m_Target->m_TileFIndex == TILE_STOP
|
||||
&& m_Target->m_TileFFlags == ROTATION_0)
|
||||
|| (m_Target->m_TileFIndexT == TILE_STOP
|
||||
&& m_Target->m_TileFFlagsT == ROTATION_0)
|
||||
|| (m_Target->m_TileFIndexT == TILE_STOPS
|
||||
&& (m_Target->m_TileFFlagsT == ROTATION_0
|
||||
|| m_Target->m_TileFFlagsT
|
||||
== ROTATION_180))
|
||||
|| (m_Target->m_TileFIndexT == TILE_STOPA)
|
||||
|| (m_Target->m_TileSIndex == TILE_STOP
|
||||
&& m_Target->m_TileSFlags == ROTATION_0)
|
||||
|| (m_Target->m_TileSIndexT == TILE_STOP
|
||||
&& m_Target->m_TileSFlagsT == ROTATION_0)
|
||||
|| (m_Target->m_TileSIndexT == TILE_STOPS
|
||||
&& (m_Target->m_TileSFlagsT == ROTATION_0
|
||||
|| m_Target->m_TileSFlagsT
|
||||
== ROTATION_180))
|
||||
|| (m_Target->m_TileSIndexT == TILE_STOPA)))
|
||||
Temp.y = 0;
|
||||
m_Target->Core()->m_Vel = Temp;
|
||||
}
|
||||
else
|
||||
if (length(m_Pos-m_Target->m_Pos)>28)
|
||||
{
|
||||
vec2 Temp = m_Target->Core()->m_Vel +(normalize(m_Pos-m_Target->m_Pos)*m_Strength);
|
||||
if(Temp.x > 0 && ((m_Target->m_TileIndex == TILE_STOP && m_Target->m_TileFlags == ROTATION_270) || (m_Target->m_TileIndexL == TILE_STOP && m_Target->m_TileFlagsL == ROTATION_270) || (m_Target->m_TileIndexL == TILE_STOPS && (m_Target->m_TileFlagsL == ROTATION_90 || m_Target->m_TileFlagsL ==ROTATION_270)) || (m_Target->m_TileIndexL == TILE_STOPA) || (m_Target->m_TileFIndex == TILE_STOP && m_Target->m_TileFFlags == ROTATION_270) || (m_Target->m_TileFIndexL == TILE_STOP && m_Target->m_TileFFlagsL == ROTATION_270) || (m_Target->m_TileFIndexL == TILE_STOPS && (m_Target->m_TileFFlagsL == ROTATION_90 || m_Target->m_TileFFlagsL == ROTATION_270)) || (m_Target->m_TileFIndexL == TILE_STOPA) || (m_Target->m_TileSIndex == TILE_STOP && m_Target->m_TileSFlags == ROTATION_270) || (m_Target->m_TileSIndexL == TILE_STOP && m_Target->m_TileSFlagsL == ROTATION_270) || (m_Target->m_TileSIndexL == TILE_STOPS && (m_Target->m_TileSFlagsL == ROTATION_90 || m_Target->m_TileSFlagsL == ROTATION_270)) || (m_Target->m_TileSIndexL == TILE_STOPA)))
|
||||
Temp.x = 0;
|
||||
if(Temp.x < 0 && ((m_Target->m_TileIndex == TILE_STOP && m_Target->m_TileFlags == ROTATION_90) || (m_Target->m_TileIndexR == TILE_STOP && m_Target->m_TileFlagsR == ROTATION_90) || (m_Target->m_TileIndexR == TILE_STOPS && (m_Target->m_TileFlagsR == ROTATION_90 || m_Target->m_TileFlagsR == ROTATION_270)) || (m_Target->m_TileIndexR == TILE_STOPA) || (m_Target->m_TileFIndex == TILE_STOP && m_Target->m_TileFFlags == ROTATION_90) || (m_Target->m_TileFIndexR == TILE_STOP && m_Target->m_TileFFlagsR == ROTATION_90) || (m_Target->m_TileFIndexR == TILE_STOPS && (m_Target->m_TileFFlagsR == ROTATION_90 || m_Target->m_TileFFlagsR == ROTATION_270)) || (m_Target->m_TileFIndexR == TILE_STOPA) || (m_Target->m_TileSIndex == TILE_STOP && m_Target->m_TileSFlags == ROTATION_90) || (m_Target->m_TileSIndexR == TILE_STOP && m_Target->m_TileSFlagsR == ROTATION_90) || (m_Target->m_TileSIndexR == TILE_STOPS && (m_Target->m_TileSFlagsR == ROTATION_90 || m_Target->m_TileSFlagsR == ROTATION_270)) || (m_Target->m_TileSIndexR == TILE_STOPA)))
|
||||
Temp.x = 0;
|
||||
if(Temp.y < 0 && ((m_Target->m_TileIndex == TILE_STOP && m_Target->m_TileFlags == ROTATION_180) || (m_Target->m_TileIndexB == TILE_STOP && m_Target->m_TileFlagsB == ROTATION_180) || (m_Target->m_TileIndexB == TILE_STOPS && (m_Target->m_TileFlagsB == ROTATION_0 || m_Target->m_TileFlagsB == ROTATION_180)) || (m_Target->m_TileIndexB == TILE_STOPA) || (m_Target->m_TileFIndex == TILE_STOP && m_Target->m_TileFFlags == ROTATION_180) || (m_Target->m_TileFIndexB == TILE_STOP && m_Target->m_TileFFlagsB == ROTATION_180) || (m_Target->m_TileFIndexB == TILE_STOPS && (m_Target->m_TileFFlagsB == ROTATION_0 || m_Target->m_TileFFlagsB == ROTATION_180)) || (m_Target->m_TileFIndexB == TILE_STOPA) || (m_Target->m_TileSIndex == TILE_STOP && m_Target->m_TileSFlags == ROTATION_180) || (m_Target->m_TileSIndexB == TILE_STOP && m_Target->m_TileSFlagsB == ROTATION_180) || (m_Target->m_TileSIndexB == TILE_STOPS && (m_Target->m_TileSFlagsB == ROTATION_0 || m_Target->m_TileSFlagsB == ROTATION_180)) || (m_Target->m_TileSIndexB == TILE_STOPA)))
|
||||
Temp.y = 0;
|
||||
if(Temp.y > 0 && ((m_Target->m_TileIndex == TILE_STOP && m_Target->m_TileFlags == ROTATION_0) || (m_Target->m_TileIndexT == TILE_STOP && m_Target->m_TileFlagsT == ROTATION_0) || (m_Target->m_TileIndexT == TILE_STOPS && (m_Target->m_TileFlagsT == ROTATION_0 || m_Target->m_TileFlagsT == ROTATION_180)) || (m_Target->m_TileIndexT == TILE_STOPA) || (m_Target->m_TileFIndex == TILE_STOP && m_Target->m_TileFFlags == ROTATION_0) || (m_Target->m_TileFIndexT == TILE_STOP && m_Target->m_TileFFlagsT == ROTATION_0) || (m_Target->m_TileFIndexT == TILE_STOPS && (m_Target->m_TileFFlagsT == ROTATION_0 || m_Target->m_TileFFlagsT == ROTATION_180)) || (m_Target->m_TileFIndexT == TILE_STOPA) || (m_Target->m_TileSIndex == TILE_STOP && m_Target->m_TileSFlags == ROTATION_0) || (m_Target->m_TileSIndexT == TILE_STOP && m_Target->m_TileSFlagsT == ROTATION_0) || (m_Target->m_TileSIndexT == TILE_STOPS && (m_Target->m_TileSFlagsT == ROTATION_0 || m_Target->m_TileSFlagsT == ROTATION_180)) || (m_Target->m_TileSIndexT == TILE_STOPA)))
|
||||
Temp.y = 0;
|
||||
m_Target->Core()->m_Vel = Temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,85 +212,97 @@ void CDragger::Reset()
|
|||
|
||||
void CDragger::Tick()
|
||||
{
|
||||
if (((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.GetTeamState(m_CatchedTeam) == CGameTeams::TEAMSTATE_EMPTY)
|
||||
if (((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.GetTeamState(
|
||||
m_CatchedTeam) == CGameTeams::TEAMSTATE_EMPTY)
|
||||
return;
|
||||
if (Server()->Tick()%int(Server()->TickSpeed()*0.15f)==0)
|
||||
if (Server()->Tick() % int(Server()->TickSpeed() * 0.15f) == 0)
|
||||
{
|
||||
int Flags;
|
||||
m_EvalTick=Server()->Tick();
|
||||
int index = GameServer()->Collision()->IsMover(m_Pos.x,m_Pos.y, &Flags);
|
||||
m_EvalTick = Server()->Tick();
|
||||
int index = GameServer()->Collision()->IsMover(m_Pos.x, m_Pos.y,
|
||||
&Flags);
|
||||
if (index)
|
||||
{
|
||||
m_Core=GameServer()->Collision()->CpSpeed(index, Flags);
|
||||
m_Core = GameServer()->Collision()->CpSpeed(index, Flags);
|
||||
}
|
||||
m_Pos+=m_Core;
|
||||
m_Pos += m_Core;
|
||||
Move();
|
||||
}
|
||||
Drag();
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDragger::Snap(int SnappingClient)
|
||||
{
|
||||
if (((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.GetTeamState(m_CatchedTeam) == CGameTeams::TEAMSTATE_EMPTY)
|
||||
if (((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.GetTeamState(
|
||||
m_CatchedTeam) == CGameTeams::TEAMSTATE_EMPTY)
|
||||
return;
|
||||
if (m_Target)
|
||||
{
|
||||
if(NetworkClipped(SnappingClient, m_Pos) && NetworkClipped(SnappingClient,m_Target->m_Pos))
|
||||
if (NetworkClipped(SnappingClient, m_Pos)
|
||||
&& NetworkClipped(SnappingClient, m_Target->m_Pos))
|
||||
return;
|
||||
}
|
||||
else
|
||||
if(NetworkClipped(SnappingClient,m_Pos))
|
||||
return;
|
||||
else if (NetworkClipped(SnappingClient, m_Pos))
|
||||
return;
|
||||
|
||||
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
|
||||
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
|
||||
if (Char && Char->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()] && (!Tick))) return;
|
||||
int Tick = (Server()->Tick() % Server()->TickSpeed()) % 11;
|
||||
if (Char && Char->IsAlive()
|
||||
&& (m_Layer == LAYER_SWITCH
|
||||
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]
|
||||
&& (!Tick)))
|
||||
return;
|
||||
if (Char && Char->IsAlive())
|
||||
{
|
||||
if (Char->Team() != m_CatchedTeam) return;
|
||||
if (Char->Team() != m_CatchedTeam)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// send to spectators only active draggers and some inactive from team 0
|
||||
if (!((m_Target && m_Target->IsAlive()) || m_CatchedTeam == 0)) return;
|
||||
if (!((m_Target && m_Target->IsAlive()) || m_CatchedTeam == 0))
|
||||
return;
|
||||
}
|
||||
|
||||
CNetObj_Laser *obj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
||||
if(!obj)
|
||||
CNetObj_Laser *obj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
|
||||
NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
||||
if (!obj)
|
||||
return;
|
||||
obj->m_X = (int)m_Pos.x;
|
||||
obj->m_Y = (int)m_Pos.y;
|
||||
obj->m_X = (int) m_Pos.x;
|
||||
obj->m_Y = (int) m_Pos.y;
|
||||
if (m_Target)
|
||||
{
|
||||
obj->m_FromX = (int)m_Target->m_Pos.x;
|
||||
obj->m_FromY = (int)m_Target->m_Pos.y;
|
||||
obj->m_FromX = (int) m_Target->m_Pos.x;
|
||||
obj->m_FromY = (int) m_Target->m_Pos.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->m_FromX = (int)m_Pos.x;
|
||||
obj->m_FromY = (int)m_Pos.y;
|
||||
obj->m_FromX = (int) m_Pos.x;
|
||||
obj->m_FromY = (int) m_Pos.y;
|
||||
}
|
||||
|
||||
|
||||
int StartTick = m_EvalTick;
|
||||
if (StartTick < Server()->Tick() - 4)
|
||||
StartTick = Server()->Tick() - 4;
|
||||
else if (StartTick>Server()->Tick())
|
||||
else if (StartTick > Server()->Tick())
|
||||
StartTick = Server()->Tick();
|
||||
obj->m_StartTick = StartTick;
|
||||
}
|
||||
|
||||
CDraggerTeam::CDraggerTeam(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, int Layer, int Number){
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
m_Draggers[i] = new CDragger(pGameWorld, Pos, Strength, NW, i, Layer, Number);
|
||||
CDraggerTeam::CDraggerTeam(CGameWorld *pGameWorld, vec2 Pos, float Strength,
|
||||
bool NW, int Layer, int Number)
|
||||
{
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
m_Draggers[i] = new CDragger(pGameWorld, Pos, Strength, NW, i, Layer,
|
||||
Number);
|
||||
}
|
||||
}
|
||||
|
||||
//CDraggerTeam::~CDraggerTeam() {
|
||||
//for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
// delete m_Draggers[i];
|
||||
//}
|
||||
//for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
// delete m_Draggers[i];
|
||||
//}
|
||||
//}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <game/server/entity.h>
|
||||
class CCharacter;
|
||||
|
||||
class CDragger : public CEntity
|
||||
class CDragger: public CEntity
|
||||
{
|
||||
vec2 m_Core;
|
||||
float m_Strength;
|
||||
|
@ -17,20 +17,22 @@ class CDragger : public CEntity
|
|||
int m_CatchedTeam;
|
||||
public:
|
||||
|
||||
|
||||
CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, int CatchedTeam, int Layer = 0, int Number = 0);
|
||||
CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW,
|
||||
int CatchedTeam, int Layer = 0, int Number = 0);
|
||||
|
||||
virtual void Reset();
|
||||
virtual void Tick();
|
||||
virtual void Snap(int snapping_client);
|
||||
};
|
||||
|
||||
class CDraggerTeam {
|
||||
class CDraggerTeam
|
||||
{
|
||||
CDragger * m_Draggers[MAX_CLIENTS];
|
||||
|
||||
public:
|
||||
|
||||
CDraggerTeam(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW=false, int Layer = 0, int Number = 0);
|
||||
CDraggerTeam(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW =
|
||||
false, int Layer = 0, int Number = 0);
|
||||
//~CDraggerTeam();
|
||||
};
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
#include "light.h"
|
||||
#include <game/mapitems.h>
|
||||
|
||||
CLight::CLight(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length, int Layer, int Number)
|
||||
: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
CLight::CLight(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length,
|
||||
int Layer, int Number) :
|
||||
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
{
|
||||
m_Layer = Layer;
|
||||
m_Number = Number;
|
||||
m_Tick=(Server()->TickSpeed()*0.15f);
|
||||
m_Tick = (Server()->TickSpeed() * 0.15f);
|
||||
m_Pos = Pos;
|
||||
m_Rotation = Rotation;
|
||||
m_Length = Length;
|
||||
|
@ -20,14 +21,19 @@ CLight::CLight(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length, int
|
|||
Step();
|
||||
}
|
||||
|
||||
|
||||
bool CLight::HitCharacter()
|
||||
{
|
||||
std::list < CCharacter * > HitCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 0.0f, 0);
|
||||
if(HitCharacters.empty()) return false;
|
||||
for(std::list < CCharacter * >::iterator i = HitCharacters.begin(); i != HitCharacters.end(); i++) {
|
||||
std::list<CCharacter *> HitCharacters =
|
||||
GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 0.0f, 0);
|
||||
if (HitCharacters.empty())
|
||||
return false;
|
||||
for (std::list<CCharacter *>::iterator i = HitCharacters.begin();
|
||||
i != HitCharacters.end(); i++)
|
||||
{
|
||||
CCharacter * Char = *i;
|
||||
if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]) continue;
|
||||
if (m_Layer == LAYER_SWITCH
|
||||
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()])
|
||||
continue;
|
||||
Char->Freeze();
|
||||
}
|
||||
return true;
|
||||
|
@ -37,37 +43,38 @@ void CLight::Move()
|
|||
{
|
||||
if (m_Speed != 0)
|
||||
{
|
||||
if ((m_CurveLength>=m_Length && m_Speed>0) || (m_CurveLength<=0 && m_Speed<0))
|
||||
m_Speed=-m_Speed;
|
||||
m_CurveLength+=m_Speed*m_Tick + m_LengthL;
|
||||
m_LengthL=0;
|
||||
if (m_CurveLength>m_Length)
|
||||
if ((m_CurveLength >= m_Length && m_Speed > 0)
|
||||
|| (m_CurveLength <= 0 && m_Speed < 0))
|
||||
m_Speed = -m_Speed;
|
||||
m_CurveLength += m_Speed * m_Tick + m_LengthL;
|
||||
m_LengthL = 0;
|
||||
if (m_CurveLength > m_Length)
|
||||
{
|
||||
m_LengthL=m_CurveLength-m_Length;
|
||||
m_CurveLength=m_Length;
|
||||
m_LengthL = m_CurveLength - m_Length;
|
||||
m_CurveLength = m_Length;
|
||||
}
|
||||
else if(m_CurveLength<0)
|
||||
else if (m_CurveLength < 0)
|
||||
{
|
||||
m_LengthL=0+m_CurveLength;
|
||||
m_CurveLength=0;
|
||||
m_LengthL = 0 + m_CurveLength;
|
||||
m_CurveLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
m_Rotation+=m_AngularSpeed*m_Tick;
|
||||
if (m_Rotation>pi*2)
|
||||
m_Rotation-=pi*2;
|
||||
else if(m_Rotation<0)
|
||||
m_Rotation+=pi*2;
|
||||
m_Rotation += m_AngularSpeed * m_Tick;
|
||||
if (m_Rotation > pi * 2)
|
||||
m_Rotation -= pi * 2;
|
||||
else if (m_Rotation < 0)
|
||||
m_Rotation += pi * 2;
|
||||
}
|
||||
|
||||
void CLight::Step()
|
||||
{
|
||||
Move();
|
||||
vec2 dir(sin(m_Rotation), cos(m_Rotation));
|
||||
vec2 to2 = m_Pos + normalize(dir)*m_CurveLength;
|
||||
GameServer()->Collision()->IntersectNoLaser(m_Pos, to2, &m_To,0 );
|
||||
vec2 to2 = m_Pos + normalize(dir) * m_CurveLength;
|
||||
GameServer()->Collision()->IntersectNoLaser(m_Pos, to2, &m_To, 0);
|
||||
}
|
||||
|
||||
|
||||
void CLight::Reset()
|
||||
{
|
||||
GameServer()->m_World.DestroyEntity(this);
|
||||
|
@ -75,70 +82,73 @@ void CLight::Reset()
|
|||
|
||||
void CLight::Tick()
|
||||
{
|
||||
|
||||
if (Server()->Tick()%int(Server()->TickSpeed()*0.15f)==0)
|
||||
|
||||
if (Server()->Tick() % int(Server()->TickSpeed() * 0.15f) == 0)
|
||||
{
|
||||
int Flags;
|
||||
m_EvalTick=Server()->Tick();
|
||||
int index = GameServer()->Collision()->IsMover(m_Pos.x,m_Pos.y, &Flags);
|
||||
m_EvalTick = Server()->Tick();
|
||||
int index = GameServer()->Collision()->IsMover(m_Pos.x, m_Pos.y,
|
||||
&Flags);
|
||||
if (index)
|
||||
{
|
||||
m_Core=GameServer()->Collision()->CpSpeed(index, Flags);
|
||||
m_Core = GameServer()->Collision()->CpSpeed(index, Flags);
|
||||
}
|
||||
m_Pos+=m_Core;
|
||||
m_Pos += m_Core;
|
||||
Step();
|
||||
}
|
||||
|
||||
HitCharacter();
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CLight::Snap(int SnappingClient)
|
||||
{
|
||||
if(NetworkClipped(SnappingClient,m_Pos) && NetworkClipped(SnappingClient,m_To))
|
||||
if (NetworkClipped(SnappingClient, m_Pos)
|
||||
&& NetworkClipped(SnappingClient, m_To))
|
||||
return;
|
||||
|
||||
CCharacter * pSnappingCharacter = GameServer()->GetPlayerChar(SnappingClient);
|
||||
int Tick = (Server()->Tick()%Server()->TickSpeed())%6;
|
||||
CCharacter * pSnappingCharacter = GameServer()->GetPlayerChar(
|
||||
SnappingClient);
|
||||
int Tick = (Server()->Tick() % Server()->TickSpeed()) % 6;
|
||||
|
||||
if(pSnappingCharacter && pSnappingCharacter->IsAlive() && m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pSnappingCharacter->Team()] && (Tick))
|
||||
if (pSnappingCharacter && pSnappingCharacter->IsAlive()
|
||||
&& m_Layer == LAYER_SWITCH
|
||||
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pSnappingCharacter->Team()]
|
||||
&& (Tick))
|
||||
return;
|
||||
|
||||
|
||||
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
||||
pObj->m_X = (int)m_Pos.x;
|
||||
pObj->m_Y = (int)m_Pos.y;
|
||||
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
|
||||
NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
||||
pObj->m_X = (int) m_Pos.x;
|
||||
pObj->m_Y = (int) m_Pos.y;
|
||||
|
||||
|
||||
|
||||
if(pSnappingCharacter && pSnappingCharacter->Team() == TEAM_SUPER)
|
||||
if (pSnappingCharacter && pSnappingCharacter->Team() == TEAM_SUPER)
|
||||
{
|
||||
pObj->m_FromX = (int)m_Pos.x;
|
||||
pObj->m_FromY = (int)m_Pos.y;
|
||||
pObj->m_FromX = (int) m_Pos.x;
|
||||
pObj->m_FromY = (int) m_Pos.y;
|
||||
}
|
||||
else if(pSnappingCharacter && m_Layer == LAYER_SWITCH && GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pSnappingCharacter->Team()])
|
||||
else if (pSnappingCharacter && m_Layer == LAYER_SWITCH
|
||||
&& GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pSnappingCharacter->Team()])
|
||||
{
|
||||
pObj->m_FromX = (int)m_To.x;
|
||||
pObj->m_FromY = (int)m_To.y;
|
||||
pObj->m_FromX = (int) m_To.x;
|
||||
pObj->m_FromY = (int) m_To.y;
|
||||
}
|
||||
else if(m_Layer != LAYER_SWITCH)
|
||||
else if (m_Layer != LAYER_SWITCH)
|
||||
{
|
||||
pObj->m_FromX = (int)m_To.x;
|
||||
pObj->m_FromY = (int)m_To.y;
|
||||
pObj->m_FromX = (int) m_To.x;
|
||||
pObj->m_FromY = (int) m_To.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_FromX = (int)m_Pos.x;
|
||||
pObj->m_FromY = (int)m_Pos.y;
|
||||
pObj->m_FromX = (int) m_Pos.x;
|
||||
pObj->m_FromY = (int) m_Pos.y;
|
||||
}
|
||||
|
||||
|
||||
int StartTick = m_EvalTick;
|
||||
if (StartTick<Server()->Tick()-4)
|
||||
StartTick=Server()->Tick()-4;
|
||||
else if (StartTick>Server()->Tick())
|
||||
StartTick=Server()->Tick();
|
||||
if (StartTick < Server()->Tick() - 4)
|
||||
StartTick = Server()->Tick() - 4;
|
||||
else if (StartTick > Server()->Tick())
|
||||
StartTick = Server()->Tick();
|
||||
pObj->m_StartTick = StartTick;
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
#include <game/server/entity.h>
|
||||
|
||||
class CLight : public CEntity
|
||||
class CLight: public CEntity
|
||||
{
|
||||
float m_Rotation;
|
||||
vec2 m_To;
|
||||
vec2 m_Core;
|
||||
|
||||
int m_EvalTick;
|
||||
|
||||
|
||||
int m_Tick;
|
||||
|
||||
bool HitCharacter();
|
||||
|
@ -23,10 +23,10 @@ public:
|
|||
float m_AngularSpeed;
|
||||
int m_Speed;
|
||||
int m_Length;
|
||||
|
||||
|
||||
CLight(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length, int Layer = 0, int Number = 0);
|
||||
|
||||
CLight(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length,
|
||||
int Layer = 0, int Number = 0);
|
||||
|
||||
virtual void Reset();
|
||||
virtual void Tick();
|
||||
virtual void Snap(int SnappingClient);
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
#include <game/server/gamemodes/DDRace.h>
|
||||
#include "plasma.h"
|
||||
|
||||
const float ACCEL=1.1f;
|
||||
const float ACCEL = 1.1f;
|
||||
|
||||
CPlasma::CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze, bool Explosive, int ResponsibleTeam)
|
||||
: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
CPlasma::CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze,
|
||||
bool Explosive, int ResponsibleTeam) :
|
||||
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
{
|
||||
m_Pos = Pos;
|
||||
m_Core = Dir;
|
||||
|
@ -25,14 +26,17 @@ CPlasma::CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze, bool E
|
|||
bool CPlasma::HitCharacter()
|
||||
{
|
||||
vec2 To2;
|
||||
CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, m_Pos+m_Core, 0.0f,To2);
|
||||
if(!Hit)
|
||||
CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos,
|
||||
m_Pos + m_Core, 0.0f, To2);
|
||||
if (!Hit)
|
||||
return false;
|
||||
|
||||
if(Hit->Team() != m_ResponsibleTeam) return false;
|
||||
if (Hit->Team() != m_ResponsibleTeam)
|
||||
return false;
|
||||
m_Freeze ? Hit->Freeze() : Hit->UnFreeze();
|
||||
if(m_Explosive)
|
||||
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, true, m_ResponsibleTeam, Hit->Teams()->TeamMask(m_ResponsibleTeam));
|
||||
if (m_Explosive)
|
||||
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, true,
|
||||
m_ResponsibleTeam, Hit->Teams()->TeamMask(m_ResponsibleTeam));
|
||||
GameServer()->m_World.DestroyEntity(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +46,7 @@ void CPlasma::Move()
|
|||
m_Pos += m_Core;
|
||||
m_Core *= ACCEL;
|
||||
}
|
||||
|
||||
|
||||
void CPlasma::Reset()
|
||||
{
|
||||
GameServer()->m_World.DestroyEntity(this);
|
||||
|
@ -50,7 +54,7 @@ void CPlasma::Reset()
|
|||
|
||||
void CPlasma::Tick()
|
||||
{
|
||||
if (m_LifeTime==0)
|
||||
if (m_LifeTime == 0)
|
||||
{
|
||||
Reset();
|
||||
return;
|
||||
|
@ -59,37 +63,47 @@ void CPlasma::Tick()
|
|||
Move();
|
||||
HitCharacter();
|
||||
|
||||
int Res=0;
|
||||
Res = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Pos+m_Core,0, 0);
|
||||
if(Res)
|
||||
int Res = 0;
|
||||
Res = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Pos + m_Core, 0,
|
||||
0);
|
||||
if (Res)
|
||||
{
|
||||
if(m_Explosive)
|
||||
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, true, m_ResponsibleTeam, ((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.TeamMask(m_ResponsibleTeam));
|
||||
if (m_Explosive)
|
||||
GameServer()->CreateExplosion(
|
||||
m_Pos,
|
||||
-1,
|
||||
WEAPON_GRENADE,
|
||||
true,
|
||||
m_ResponsibleTeam,
|
||||
((CGameControllerDDRace*) GameServer()->m_pController)->m_Teams.TeamMask(
|
||||
m_ResponsibleTeam));
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CPlasma::Snap(int SnappingClient)
|
||||
{
|
||||
if(NetworkClipped(SnappingClient))
|
||||
{
|
||||
if (NetworkClipped(SnappingClient))
|
||||
return;
|
||||
CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient);
|
||||
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
|
||||
int Tick = (Server()->Tick() % Server()->TickSpeed()) % 11;
|
||||
|
||||
if(SnapChar &&
|
||||
SnapChar->IsAlive() &&
|
||||
(
|
||||
m_Layer == LAYER_SWITCH &&
|
||||
!GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) &&
|
||||
(!Tick))
|
||||
if (SnapChar && SnapChar->IsAlive()
|
||||
&& (m_Layer == LAYER_SWITCH
|
||||
&& !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()])
|
||||
&& (!Tick))
|
||||
return;
|
||||
if(SnapChar && (SnapChar->Team() != m_ResponsibleTeam) && (!SnapChar->GetPlayer()->m_IsUsingDDRaceClient || (GameServer()->m_apPlayers[SnappingClient]->m_IsUsingDDRaceClient && !GameServer()->m_apPlayers[SnappingClient]->m_ShowOthers)))
|
||||
if (SnapChar && (SnapChar->Team() != m_ResponsibleTeam)
|
||||
&& (!SnapChar->GetPlayer()->m_IsUsingDDRaceClient
|
||||
|| (GameServer()->m_apPlayers[SnappingClient]->m_IsUsingDDRaceClient
|
||||
&& !GameServer()->m_apPlayers[SnappingClient]->m_ShowOthers)))
|
||||
return;
|
||||
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
||||
pObj->m_X = (int)m_Pos.x;
|
||||
pObj->m_Y = (int)m_Pos.y;
|
||||
pObj->m_FromX = (int)m_Pos.x;
|
||||
pObj->m_FromY = (int)m_Pos.y;
|
||||
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(
|
||||
NETOBJTYPE_LASER, m_ID, sizeof(CNetObj_Laser)));
|
||||
pObj->m_X = (int) m_Pos.x;
|
||||
pObj->m_Y = (int) m_Pos.y;
|
||||
pObj->m_FromX = (int) m_Pos.x;
|
||||
pObj->m_FromY = (int) m_Pos.y;
|
||||
pObj->m_StartTick = m_EvalTick;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
class CGun;
|
||||
|
||||
class CPlasma : public CEntity
|
||||
class CPlasma: public CEntity
|
||||
{
|
||||
vec2 m_Core;
|
||||
int m_EvalTick;
|
||||
|
@ -20,13 +20,12 @@ class CPlasma : public CEntity
|
|||
void Move();
|
||||
public:
|
||||
|
||||
CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze, bool Explosive, int ResponsibleTeam);
|
||||
|
||||
CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze,
|
||||
bool Explosive, int ResponsibleTeam);
|
||||
|
||||
virtual void Reset();
|
||||
virtual void Tick();
|
||||
virtual void Snap(int SnappingClient);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#include "DDRace.h"
|
||||
#include "gamemode.h"
|
||||
|
||||
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) : IGameController(pGameServer), m_Teams(pGameServer)
|
||||
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
|
||||
IGameController(pGameServer), m_Teams(pGameServer)
|
||||
{
|
||||
m_pGameType = GAME_NAME;
|
||||
|
||||
|
@ -27,21 +28,28 @@ void CGameControllerDDRace::Tick()
|
|||
|
||||
void CGameControllerDDRace::InitTeleporter()
|
||||
{
|
||||
if(!GameServer()->Collision()->Layers()->TeleLayer()) return;
|
||||
if (!GameServer()->Collision()->Layers()->TeleLayer())
|
||||
return;
|
||||
int Width = GameServer()->Collision()->Layers()->TeleLayer()->m_Width;
|
||||
int Height = GameServer()->Collision()->Layers()->TeleLayer()->m_Height;
|
||||
|
||||
for(int i = 0; i < Width*Height; i++)
|
||||
for (int i = 0; i < Width * Height; i++)
|
||||
{
|
||||
if(GameServer()->Collision()->TeleLayer()[i].m_Number > 0)
|
||||
if (GameServer()->Collision()->TeleLayer()[i].m_Number > 0)
|
||||
{
|
||||
if(GameServer()->Collision()->TeleLayer()[i].m_Type == TILE_TELEOUT)
|
||||
if (GameServer()->Collision()->TeleLayer()[i].m_Type
|
||||
== TILE_TELEOUT)
|
||||
{
|
||||
m_TeleOuts[GameServer()->Collision()->TeleLayer()[i].m_Number-1].push_back(vec2(i % Width*32+16, i/Width*32+16));
|
||||
m_TeleOuts[GameServer()->Collision()->TeleLayer()[i].m_Number
|
||||
- 1].push_back(
|
||||
vec2(i % Width * 32 + 16, i / Width * 32 + 16));
|
||||
}
|
||||
else if(GameServer()->Collision()->TeleLayer()[i].m_Type == TILE_TELECHECKOUT)
|
||||
else if (GameServer()->Collision()->TeleLayer()[i].m_Type
|
||||
== TILE_TELECHECKOUT)
|
||||
{
|
||||
m_TeleCheckOuts[GameServer()->Collision()->TeleLayer()[i].m_Number-1].push_back(vec2(i % Width*32+16, i/Width*32+16));
|
||||
m_TeleCheckOuts[GameServer()->Collision()->TeleLayer()[i].m_Number
|
||||
- 1].push_back(
|
||||
vec2(i % Width * 32 + 16, i / Width * 32 + 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
||||
class CGameControllerDDRace : public IGameController
|
||||
class CGameControllerDDRace: public IGameController
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -18,8 +17,8 @@ public:
|
|||
|
||||
CGameTeams m_Teams;
|
||||
|
||||
std::map < int , std::vector < vec2 > > m_TeleOuts;
|
||||
std::map < int , std::vector < vec2 > > m_TeleCheckOuts;
|
||||
std::map<int, std::vector<vec2> > m_TeleOuts;
|
||||
std::map<int, std::vector<vec2> > m_TeleCheckOuts;
|
||||
|
||||
void InitTeleporter();
|
||||
virtual void Tick();
|
||||
|
|
|
@ -13,17 +13,19 @@
|
|||
|
||||
static LOCK gs_ScoreLock = 0;
|
||||
|
||||
CFileScore::CPlayerScore::CPlayerScore(const char *pName, float Score, float aCpTime[NUM_CHECKPOINTS])
|
||||
CFileScore::CPlayerScore::CPlayerScore(const char *pName, float Score,
|
||||
float aCpTime[NUM_CHECKPOINTS])
|
||||
{
|
||||
str_copy(m_aName, pName, sizeof(m_aName));
|
||||
m_Score = Score;
|
||||
for(int i = 0; i < NUM_CHECKPOINTS; i++)
|
||||
for (int i = 0; i < NUM_CHECKPOINTS; i++)
|
||||
m_aCpTime[i] = aCpTime[i];
|
||||
}
|
||||
|
||||
CFileScore::CFileScore(CGameContext *pGameServer) : m_pGameServer(pGameServer), m_pServer(pGameServer->Server())
|
||||
CFileScore::CFileScore(CGameContext *pGameServer) :
|
||||
m_pGameServer(pGameServer), m_pServer(pGameServer->Server())
|
||||
{
|
||||
if(gs_ScoreLock == 0)
|
||||
if (gs_ScoreLock == 0)
|
||||
gs_ScoreLock = lock_create();
|
||||
|
||||
Init();
|
||||
|
@ -42,8 +44,9 @@ CFileScore::~CFileScore()
|
|||
std::string SaveFile()
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if(g_Config.m_SvScoreFolder[0])
|
||||
oss << g_Config.m_SvScoreFolder << "/" << g_Config.m_SvMap << "_record.dtb";
|
||||
if (g_Config.m_SvScoreFolder[0])
|
||||
oss << g_Config.m_SvScoreFolder << "/" << g_Config.m_SvMap
|
||||
<< "_record.dtb";
|
||||
else
|
||||
oss << g_Config.m_SvMap << "_record.dtb";
|
||||
return oss.str();
|
||||
|
@ -51,24 +54,26 @@ std::string SaveFile()
|
|||
|
||||
void CFileScore::SaveScoreThread(void *pUser)
|
||||
{
|
||||
CFileScore *pSelf = (CFileScore *)pUser;
|
||||
CFileScore *pSelf = (CFileScore *) pUser;
|
||||
lock_wait(gs_ScoreLock);
|
||||
std::fstream f;
|
||||
f.open(SaveFile().c_str(), std::ios::out);
|
||||
if(!f.fail())
|
||||
if (!f.fail())
|
||||
{
|
||||
int t = 0;
|
||||
for(sorted_array<CPlayerScore>::range r = pSelf->m_Top.all(); !r.empty(); r.pop_front())
|
||||
for (sorted_array<CPlayerScore>::range r = pSelf->m_Top.all();
|
||||
!r.empty(); r.pop_front())
|
||||
{
|
||||
f << r.front().m_aName << std::endl << r.front().m_Score << std::endl;
|
||||
if(g_Config.m_SvCheckpointSave)
|
||||
f << r.front().m_aName << std::endl << r.front().m_Score
|
||||
<< std::endl;
|
||||
if (g_Config.m_SvCheckpointSave)
|
||||
{
|
||||
for(int c = 0; c < NUM_CHECKPOINTS; c++)
|
||||
for (int c = 0; c < NUM_CHECKPOINTS; c++)
|
||||
f << r.front().m_aCpTime[c] << " ";
|
||||
f << std::endl;
|
||||
}
|
||||
t++;
|
||||
if(t%50 == 0)
|
||||
if (t % 50 == 0)
|
||||
thread_sleep(1);
|
||||
}
|
||||
}
|
||||
|
@ -89,84 +94,91 @@ void CFileScore::Init()
|
|||
lock_wait(gs_ScoreLock);
|
||||
|
||||
// create folder if not exist
|
||||
if(g_Config.m_SvScoreFolder[0])
|
||||
if (g_Config.m_SvScoreFolder[0])
|
||||
fs_makedir(g_Config.m_SvScoreFolder);
|
||||
|
||||
std::fstream f;
|
||||
f.open(SaveFile().c_str(), std::ios::in);
|
||||
|
||||
while(!f.eof() && !f.fail())
|
||||
while (!f.eof() && !f.fail())
|
||||
{
|
||||
std::string TmpName, TmpScore, TmpCpLine;
|
||||
std::getline(f, TmpName);
|
||||
if(!f.eof() && TmpName != "")
|
||||
if (!f.eof() && TmpName != "")
|
||||
{
|
||||
std::getline(f, TmpScore);
|
||||
float aTmpCpTime[NUM_CHECKPOINTS] = {0};
|
||||
if(g_Config.m_SvCheckpointSave)
|
||||
float aTmpCpTime[NUM_CHECKPOINTS] =
|
||||
{ 0 };
|
||||
if (g_Config.m_SvCheckpointSave)
|
||||
{
|
||||
std::getline(f, TmpCpLine);
|
||||
char *pTime = strtok((char*)TmpCpLine.c_str(), " ");
|
||||
char *pTime = strtok((char*) TmpCpLine.c_str(), " ");
|
||||
int i = 0;
|
||||
while(pTime != NULL && i < NUM_CHECKPOINTS)
|
||||
while (pTime != NULL && i < NUM_CHECKPOINTS)
|
||||
{
|
||||
aTmpCpTime[i] = atof(pTime);
|
||||
pTime = strtok(NULL, " ");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
m_Top.add(*new CPlayerScore(TmpName.c_str(), atof(TmpScore.c_str()), aTmpCpTime));
|
||||
m_Top.add(
|
||||
*new CPlayerScore(TmpName.c_str(), atof(TmpScore.c_str()),
|
||||
aTmpCpTime));
|
||||
}
|
||||
}
|
||||
f.close();
|
||||
lock_release(gs_ScoreLock);
|
||||
|
||||
// save the current best score
|
||||
if(m_Top.size())
|
||||
((CGameControllerDDRace*)GameServer()->m_pController)->m_CurrentRecord = m_Top[0].m_Score;
|
||||
if (m_Top.size())
|
||||
((CGameControllerDDRace*) GameServer()->m_pController)->m_CurrentRecord =
|
||||
m_Top[0].m_Score;
|
||||
}
|
||||
|
||||
CFileScore::CPlayerScore *CFileScore::SearchName(const char *pName, int *pPosition, bool NoCase)
|
||||
CFileScore::CPlayerScore *CFileScore::SearchName(const char *pName,
|
||||
int *pPosition, bool NoCase)
|
||||
{
|
||||
CPlayerScore *pPlayer = 0;
|
||||
int Pos = 1;
|
||||
int Found = 0;
|
||||
for(sorted_array<CPlayerScore>::range r = m_Top.all(); !r.empty(); r.pop_front())
|
||||
for (sorted_array<CPlayerScore>::range r = m_Top.all(); !r.empty();
|
||||
r.pop_front())
|
||||
{
|
||||
if(str_find_nocase(r.front().m_aName, pName))
|
||||
if (str_find_nocase(r.front().m_aName, pName))
|
||||
{
|
||||
if(pPosition)
|
||||
if (pPosition)
|
||||
*pPosition = Pos;
|
||||
if(NoCase)
|
||||
if (NoCase)
|
||||
{
|
||||
Found++;
|
||||
pPlayer = &r.front();
|
||||
}
|
||||
if(!strcmp(r.front().m_aName, pName))
|
||||
if (!strcmp(r.front().m_aName, pName))
|
||||
return &r.front();
|
||||
}
|
||||
Pos++;
|
||||
}
|
||||
if(Found > 1)
|
||||
if (Found > 1)
|
||||
{
|
||||
if(pPosition)
|
||||
if (pPosition)
|
||||
*pPosition = -1;
|
||||
return 0;
|
||||
}
|
||||
return pPlayer;
|
||||
}
|
||||
|
||||
void CFileScore::UpdatePlayer(int ID, float Score, float aCpTime[NUM_CHECKPOINTS])
|
||||
void CFileScore::UpdatePlayer(int ID, float Score,
|
||||
float aCpTime[NUM_CHECKPOINTS])
|
||||
{
|
||||
const char *pName = Server()->ClientName(ID);
|
||||
|
||||
lock_wait(gs_ScoreLock);
|
||||
CPlayerScore *pPlayer = SearchScore(ID, 0);
|
||||
|
||||
if(pPlayer)
|
||||
if (pPlayer)
|
||||
{
|
||||
for(int c = 0; c < NUM_CHECKPOINTS; c++)
|
||||
pPlayer->m_aCpTime[c] = aCpTime[c];
|
||||
for (int c = 0; c < NUM_CHECKPOINTS; c++)
|
||||
pPlayer->m_aCpTime[c] = aCpTime[c];
|
||||
|
||||
pPlayer->m_Score = Score;
|
||||
str_copy(pPlayer->m_aName, pName, sizeof(pPlayer->m_aName));
|
||||
|
@ -183,7 +195,7 @@ void CFileScore::UpdatePlayer(int ID, float Score, float aCpTime[NUM_CHECKPOINTS
|
|||
void CFileScore::LoadScore(int ClientID)
|
||||
{
|
||||
CPlayerScore *pPlayer = SearchScore(ClientID, 0);
|
||||
if(pPlayer)
|
||||
if (pPlayer)
|
||||
{
|
||||
lock_wait(gs_ScoreLock);
|
||||
lock_release(gs_ScoreLock);
|
||||
|
@ -191,29 +203,33 @@ void CFileScore::LoadScore(int ClientID)
|
|||
}
|
||||
|
||||
// set score
|
||||
if(pPlayer)
|
||||
if (pPlayer)
|
||||
PlayerData(ClientID)->Set(pPlayer->m_Score, pPlayer->m_aCpTime);
|
||||
}
|
||||
|
||||
void CFileScore::SaveScore(int ClientID, float Time, float CpTime[NUM_CHECKPOINTS])
|
||||
void CFileScore::SaveScore(int ClientID, float Time,
|
||||
float CpTime[NUM_CHECKPOINTS])
|
||||
{
|
||||
CConsole* pCon = (CConsole*)GameServer()->Console();
|
||||
if(!pCon->m_Cheated)
|
||||
CConsole* pCon = (CConsole*) GameServer()->Console();
|
||||
if (!pCon->m_Cheated)
|
||||
UpdatePlayer(ClientID, Time, CpTime);
|
||||
}
|
||||
|
||||
void CFileScore::ShowTop5(IConsole::IResult *pResult, int ClientID, void *pUserData, int Debut)
|
||||
void CFileScore::ShowTop5(IConsole::IResult *pResult, int ClientID,
|
||||
void *pUserData, int Debut)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||
char aBuf[512];
|
||||
pSelf->SendChatTarget(ClientID, "----------- Top 5 -----------");
|
||||
for(int i = 0; i < 5; i++)
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if(i+Debut > m_Top.size())
|
||||
if (i + Debut > m_Top.size())
|
||||
break;
|
||||
CPlayerScore *r = &m_Top[i+Debut-1];
|
||||
str_format(aBuf, sizeof(aBuf), "%d. %s Time: %d minute(s) %5.2f second(s)",
|
||||
i+Debut, r->m_aName, (int) r->m_Score/60, r->m_Score-((int)r->m_Score/60*60));
|
||||
CPlayerScore *r = &m_Top[i + Debut - 1];
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"%d. %s Time: %d minute(s) %5.2f second(s)", i + Debut,
|
||||
r->m_aName, (int) r->m_Score / 60,
|
||||
r->m_Score - ((int) r->m_Score / 60 * 60));
|
||||
pSelf->SendChatTarget(ClientID, aBuf);
|
||||
}
|
||||
pSelf->SendChatTarget(ClientID, "------------------------------");
|
||||
|
@ -225,30 +241,37 @@ void CFileScore::ShowRank(int ClientID, const char* pName, bool Search)
|
|||
int Pos;
|
||||
char aBuf[512];
|
||||
|
||||
if(!Search)
|
||||
if (!Search)
|
||||
pScore = SearchScore(ClientID, &Pos);
|
||||
else
|
||||
pScore = SearchName(pName, &Pos, 1);
|
||||
|
||||
if(pScore && Pos > -1)
|
||||
if (pScore && Pos > -1)
|
||||
{
|
||||
float Time = pScore->m_Score;
|
||||
char aClientName[128];
|
||||
str_format(aClientName, sizeof(aClientName), " (%s)", Server()->ClientName(ClientID));
|
||||
if(g_Config.m_SvHideScore)
|
||||
str_format(aBuf, sizeof(aBuf), "Your time: %d minute(s) %5.2f second(s)", (int)Time/60, Time-((int)Time/60*60));
|
||||
str_format(aClientName, sizeof(aClientName), " (%s)",
|
||||
Server()->ClientName(ClientID));
|
||||
if (g_Config.m_SvHideScore)
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"Your time: %d minute(s) %5.2f second(s)", (int) Time / 60,
|
||||
Time - ((int) Time / 60 * 60));
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%d. %s Time: %d minute(s) %5.2f second(s)", Pos, pScore->m_aName, (int)Time/60, Time-((int)Time/60*60));
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"%d. %s Time: %d minute(s) %5.2f second(s)", Pos,
|
||||
pScore->m_aName, (int) Time / 60,
|
||||
Time - ((int) Time / 60 * 60));
|
||||
if (!Search)
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, ClientID);
|
||||
else
|
||||
GameServer()->SendChatTarget(ClientID, aBuf);
|
||||
return;
|
||||
}
|
||||
else if(Pos == -1)
|
||||
else if (Pos == -1)
|
||||
str_format(aBuf, sizeof(aBuf), "Several players were found.");
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%s is not ranked", Search?pName:Server()->ClientName(ClientID));
|
||||
str_format(aBuf, sizeof(aBuf), "%s is not ranked",
|
||||
Search ? pName : Server()->ClientName(ClientID));
|
||||
|
||||
GameServer()->SendChatTarget(ClientID, aBuf);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "../score.h"
|
||||
|
||||
class CFileScore : public IScore
|
||||
class CFileScore: public IScore
|
||||
{
|
||||
CGameContext *m_pGameServer;
|
||||
IServer *m_pServer;
|
||||
|
@ -20,18 +20,35 @@ class CFileScore : public IScore
|
|||
float m_Score;
|
||||
float m_aCpTime[NUM_CHECKPOINTS];
|
||||
|
||||
CPlayerScore() {};
|
||||
CPlayerScore(const char *pName, float Score, float aCpTime[NUM_CHECKPOINTS]);
|
||||
CPlayerScore()
|
||||
{
|
||||
}
|
||||
;
|
||||
CPlayerScore(const char *pName, float Score,
|
||||
float aCpTime[NUM_CHECKPOINTS]);
|
||||
|
||||
bool operator<(const CPlayerScore& other) { return (this->m_Score < other.m_Score); }
|
||||
bool operator<(const CPlayerScore& other)
|
||||
{
|
||||
return (this->m_Score < other.m_Score);
|
||||
}
|
||||
};
|
||||
|
||||
sorted_array<CPlayerScore> m_Top;
|
||||
|
||||
CGameContext *GameServer() { return m_pGameServer; }
|
||||
IServer *Server() { return m_pServer; }
|
||||
CGameContext *GameServer()
|
||||
{
|
||||
return m_pGameServer;
|
||||
}
|
||||
IServer *Server()
|
||||
{
|
||||
return m_pServer;
|
||||
}
|
||||
|
||||
CPlayerScore *SearchScore(int ID, int *pPosition){ return SearchName(Server()->ClientName(ID), pPosition, 0 );};
|
||||
CPlayerScore *SearchScore(int ID, int *pPosition)
|
||||
{
|
||||
return SearchName(Server()->ClientName(ID), pPosition, 0);
|
||||
}
|
||||
;
|
||||
|
||||
CPlayerScore *SearchName(const char *pName, int *pPosition, bool MatchCase);
|
||||
void UpdatePlayer(int ID, float Score, float aCpTime[NUM_CHECKPOINTS]);
|
||||
|
@ -46,10 +63,12 @@ public:
|
|||
~CFileScore();
|
||||
|
||||
virtual void LoadScore(int ClientID);
|
||||
virtual void SaveScore(int ClientID, float Time, float CpTime[NUM_CHECKPOINTS]);
|
||||
virtual void SaveScore(int ClientID, float Time,
|
||||
float CpTime[NUM_CHECKPOINTS]);
|
||||
|
||||
virtual void ShowTop5(IConsole::IResult *pResult, int ClientID, void *pUserData, int Debut=1);
|
||||
virtual void ShowRank(int ClientID, const char* pName, bool Search=false);
|
||||
virtual void ShowTop5(IConsole::IResult *pResult, int ClientID,
|
||||
void *pUserData, int Debut = 1);
|
||||
virtual void ShowRank(int ClientID, const char* pName, bool Search = false);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
static LOCK gs_SqlLock = 0;
|
||||
|
||||
CSqlScore::CSqlScore(CGameContext *pGameServer) : m_pGameServer(pGameServer),
|
||||
m_pServer(pGameServer->Server()),
|
||||
m_pDatabase(g_Config.m_SvSqlDatabase),
|
||||
m_pPrefix(g_Config.m_SvSqlPrefix),
|
||||
m_pUser(g_Config.m_SvSqlUser),
|
||||
m_pPass(g_Config.m_SvSqlPw),
|
||||
m_pIp(g_Config.m_SvSqlIp),
|
||||
m_Port(g_Config.m_SvSqlPort)
|
||||
m_pServer(pGameServer->Server()),
|
||||
m_pDatabase(g_Config.m_SvSqlDatabase),
|
||||
m_pPrefix(g_Config.m_SvSqlPrefix),
|
||||
m_pUser(g_Config.m_SvSqlUser),
|
||||
m_pPass(g_Config.m_SvSqlPw),
|
||||
m_pIp(g_Config.m_SvSqlIp),
|
||||
m_Port(g_Config.m_SvSqlPort)
|
||||
{
|
||||
str_copy(m_aMap, g_Config.m_SvMap, sizeof(m_aMap));
|
||||
NormalizeMapname(m_aMap);
|
||||
|
@ -67,31 +67,34 @@ bool CSqlScore::Connect()
|
|||
dbg_msg("SQL", "ERROR: SQL connection failed");
|
||||
return false;
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
// ...
|
||||
dbg_msg("SQL", "1 %s",ex.what());
|
||||
|
||||
} catch (const std::string& ex) {
|
||||
}
|
||||
catch (const std::string& ex)
|
||||
{
|
||||
// ...
|
||||
dbg_msg("SQL", "2 %s",ex.c_str());
|
||||
}
|
||||
catch( int )
|
||||
{
|
||||
dbg_msg("SQL", "3 %s");
|
||||
dbg_msg("SQL", "3 %s");
|
||||
}
|
||||
catch( float )
|
||||
{
|
||||
dbg_msg("SQL", "4 %s");
|
||||
dbg_msg("SQL", "4 %s");
|
||||
}
|
||||
|
||||
catch( char[] )
|
||||
{
|
||||
dbg_msg("SQL", "5 %s");
|
||||
dbg_msg("SQL", "5 %s");
|
||||
}
|
||||
|
||||
catch( char )
|
||||
{
|
||||
dbg_msg("SQL", "6 %s");
|
||||
dbg_msg("SQL", "6 %s");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -126,7 +129,7 @@ void CSqlScore::Init()
|
|||
{
|
||||
// create tables
|
||||
char aBuf[768];
|
||||
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_%s_race (Name VARCHAR(%d) NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , Time FLOAT DEFAULT 0, cp1 FLOAT DEFAULT 0, cp2 FLOAT DEFAULT 0, cp3 FLOAT DEFAULT 0, cp4 FLOAT DEFAULT 0, cp5 FLOAT DEFAULT 0, cp6 FLOAT DEFAULT 0, cp7 FLOAT DEFAULT 0, cp8 FLOAT DEFAULT 0, cp9 FLOAT DEFAULT 0, cp10 FLOAT DEFAULT 0, cp11 FLOAT DEFAULT 0, cp12 FLOAT DEFAULT 0, cp13 FLOAT DEFAULT 0, cp14 FLOAT DEFAULT 0, cp15 FLOAT DEFAULT 0, cp16 FLOAT DEFAULT 0, cp17 FLOAT DEFAULT 0, cp18 FLOAT DEFAULT 0, cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, cp25 FLOAT DEFAULT 0, KEY Name (Name)) CHARACTER SET utf8 ;", m_pPrefix, m_aMap, MAX_NAME_LENGTH);
|
||||
m_pStatement->execute(aBuf);
|
||||
|
||||
|
@ -134,12 +137,13 @@ void CSqlScore::Init()
|
|||
str_format(aBuf, sizeof(aBuf), "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '%s_%s_race' AND column_name = 'Timestamp'",m_pPrefix, m_aMap);
|
||||
m_pResults = m_pStatement->executeQuery(aBuf);
|
||||
|
||||
if(m_pResults->rowsCount() < 1){
|
||||
if(m_pResults->rowsCount() < 1)
|
||||
{
|
||||
// If not... add the column
|
||||
str_format(aBuf, sizeof(aBuf), "ALTER TABLE %s_%s_race ADD Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER Name, ADD INDEX(Name);",m_pPrefix, m_aMap);
|
||||
m_pStatement->execute(aBuf);
|
||||
}
|
||||
|
||||
|
||||
dbg_msg("SQL", "Tables were created successfully");
|
||||
|
||||
// get the best time
|
||||
|
@ -189,7 +193,6 @@ void CSqlScore::LoadScoreThread(void *pUser)
|
|||
|
||||
char aBuf[512];
|
||||
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT * FROM %s_%s_race WHERE Name='%s' ORDER BY time ASC LIMIT 1;", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName);
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
if(pData->m_pSqlData->m_pResults->next())
|
||||
|
@ -277,7 +280,7 @@ void CSqlScore::SaveScoreThread(void *pUser)
|
|||
}
|
||||
|
||||
// disconnect from database
|
||||
pData->m_pSqlData->Disconnect(); //TODO:Check if an exception is caught will this still execute ?
|
||||
pData->m_pSqlData->Disconnect();//TODO:Check if an exception is caught will this still execute ?
|
||||
}
|
||||
|
||||
delete pData;
|
||||
|
@ -324,21 +327,21 @@ void CSqlScore::ShowRankThread(void *pUser)
|
|||
char aBuf[600];
|
||||
|
||||
pData->m_pSqlData->m_pStatement->execute("SET @rownum := 0;");
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT Rank, one_rank.Name, one_rank.Time, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(r.Timestamp) as Ago, UNIX_TIMESTAMP(r.Timestamp) as stamp "
|
||||
"FROM ("
|
||||
"SELECT * FROM ("
|
||||
"SELECT @rownum := @rownum + 1 AS RANK, Name, Time "
|
||||
"FROM ("
|
||||
"SELECT Name, min(Time) as Time "
|
||||
"FROM %s_%s_race "
|
||||
"Group By Name) as all_top_times "
|
||||
"ORDER BY Time ASC) as all_ranks "
|
||||
"WHERE all_ranks.Name = '%s') as one_rank "
|
||||
"LEFT JOIN %s_%s_race as r "
|
||||
"ON one_rank.Name = r.Name && one_rank.Time = r.Time "
|
||||
"ORDER BY Ago ASC "
|
||||
"LIMIT 0,1"
|
||||
";", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap,pData->m_aName, pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap);
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT Rank, one_rank.Name, one_rank.Time, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(r.Timestamp) as Ago, UNIX_TIMESTAMP(r.Timestamp) as stamp "
|
||||
"FROM ("
|
||||
"SELECT * FROM ("
|
||||
"SELECT @rownum := @rownum + 1 AS RANK, Name, Time "
|
||||
"FROM ("
|
||||
"SELECT Name, min(Time) as Time "
|
||||
"FROM %s_%s_race "
|
||||
"Group By Name) as all_top_times "
|
||||
"ORDER BY Time ASC) as all_ranks "
|
||||
"WHERE all_ranks.Name = '%s') as one_rank "
|
||||
"LEFT JOIN %s_%s_race as r "
|
||||
"ON one_rank.Name = r.Name && one_rank.Time = r.Time "
|
||||
"ORDER BY Ago ASC "
|
||||
"LIMIT 0,1"
|
||||
";", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap,pData->m_aName, pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap);
|
||||
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
|
||||
|
@ -362,7 +365,8 @@ void CSqlScore::ShowRankThread(void *pUser)
|
|||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%d. %s Time: %d minute(s) %5.2f second(s)", Rank, pData->m_pSqlData->m_pResults->getString("Name").c_str(), (int)(Time/60), Time-((int)Time/60*60), agoString);
|
||||
|
||||
if(pData->m_pSqlData->m_pResults->getInt("stamp") != 0){
|
||||
if(pData->m_pSqlData->m_pResults->getInt("stamp") != 0)
|
||||
{
|
||||
pData->m_pSqlData->GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, pData->m_ClientID);
|
||||
str_format(aBuf, sizeof(aBuf), "Finished: %s ago", agoString);
|
||||
}
|
||||
|
@ -476,22 +480,23 @@ void CSqlScore::ShowTimesThread(void *pUser)
|
|||
char originalName[MAX_NAME_LENGTH];
|
||||
strcpy(originalName,pData->m_aName);
|
||||
pData->m_pSqlData->ClearString(pData->m_aName);
|
||||
|
||||
|
||||
char aBuf[512];
|
||||
|
||||
if(pData->m_Search) // last 5 times of a player
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT Time, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(Timestamp) as Ago, UNIX_TIMESTAMP(Timestamp) as Stamp FROM %s_%s_race WHERE Name = '%s' ORDER BY Ago ASC LIMIT %d, 5;", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName, pData->m_Num-1);
|
||||
else // last 5 times of server
|
||||
else// last 5 times of server
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT Name, Time, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(Timestamp) as Ago, UNIX_TIMESTAMP(Timestamp) as Stamp FROM %s_%s_race ORDER BY Ago ASC LIMIT %d, 5;", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_Num-1);
|
||||
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
|
||||
// show top5
|
||||
if(pData->m_pSqlData->m_pResults->rowsCount() == 0){
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, "There are no times in the specified range");
|
||||
if(pData->m_pSqlData->m_pResults->rowsCount() == 0)
|
||||
{
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, "There are no times in the specified range");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "------------ Last Times No %d - %d ------------",pData->m_Num,pData->m_Num + pData->m_pSqlData->m_pResults->rowsCount() - 1);
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
|
||||
|
||||
|
@ -506,20 +511,20 @@ void CSqlScore::ShowTimesThread(void *pUser)
|
|||
pStamp = (int)pData->m_pSqlData->m_pResults->getInt("Stamp");
|
||||
pTime = (float)pData->m_pSqlData->m_pResults->getDouble("Time");
|
||||
|
||||
agoTimeToString(pSince,pAgoString);
|
||||
|
||||
agoTimeToString(pSince,pAgoString);
|
||||
|
||||
if(pData->m_Search) // last 5 times of a player
|
||||
{
|
||||
if(pStamp == 0) // stamp is 00:00:00 cause it's an old entry from old times where there where no stamps yet
|
||||
str_format(aBuf, sizeof(aBuf), "%d min %.2f sec, don't know how long ago", (int)(pTime/60), pTime-((int)pTime/60*60));
|
||||
else
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%s ago, %d min %.2f sec", pAgoString,(int)(pTime/60), pTime-((int)pTime/60*60));
|
||||
}
|
||||
else // last 5 times of the server
|
||||
{
|
||||
if(pStamp == 0) // stamp is 00:00:00 cause it's an old entry from old times where there where no stamps yet
|
||||
str_format(aBuf, sizeof(aBuf), "%s, %d m %.2f s, don't know when", pData->m_pSqlData->m_pResults->getString("Name").c_str(), (int)(pTime/60), pTime-((int)pTime/60*60));
|
||||
else
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%s, %s ago, %d m %.2f s", pData->m_pSqlData->m_pResults->getString("Name").c_str(), pAgoString, (int)(pTime/60), pTime-((int)pTime/60*60));
|
||||
}
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
|
||||
|
@ -539,7 +544,7 @@ void CSqlScore::ShowTimesThread(void *pUser)
|
|||
dbg_msg("SQL", aBuf);
|
||||
dbg_msg("SQL", "ERROR: Could not show times");
|
||||
}
|
||||
end:
|
||||
end:
|
||||
// disconnect from database
|
||||
pData->m_pSqlData->Disconnect();
|
||||
}
|
||||
|
@ -561,7 +566,6 @@ void CSqlScore::ShowTop5(IConsole::IResult *pResult, int ClientID, void *pUserDa
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
void CSqlScore::ShowTimes(int ClientID, int Debut)
|
||||
{
|
||||
CSqlScoreData *Tmp = new CSqlScoreData();
|
||||
|
@ -571,9 +575,9 @@ void CSqlScore::ShowTimes(int ClientID, int Debut)
|
|||
Tmp->m_Search = false;
|
||||
|
||||
void *TimesThread = thread_create(ShowTimesThread, Tmp);
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)TimesThread);
|
||||
#endif
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)TimesThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSqlScore::ShowTimes(int ClientID, const char* pName, int Debut)
|
||||
|
@ -584,11 +588,11 @@ void CSqlScore::ShowTimes(int ClientID, const char* pName, int Debut)
|
|||
str_copy(Tmp->m_aName, pName, sizeof(Tmp->m_aName));
|
||||
Tmp->m_pSqlData = this;
|
||||
Tmp->m_Search = true;
|
||||
|
||||
|
||||
void *TimesThread = thread_create(ShowTimesThread, Tmp);
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)TimesThread);
|
||||
#endif
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)TimesThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
// anti SQL injection
|
||||
|
@ -598,17 +602,25 @@ void CSqlScore::ClearString(char *pString)
|
|||
char newString[MAX_NAME_LENGTH*2-1];
|
||||
int pos = 0;
|
||||
|
||||
for(int i=0;i<str_length(pString);i++) {
|
||||
if(pString[i] == '\\') {
|
||||
for(int i=0;i<str_length(pString);i++)
|
||||
{
|
||||
if(pString[i] == '\\')
|
||||
{
|
||||
newString[pos++] = '\\';
|
||||
newString[pos++] = '\\';
|
||||
} else if(pString[i] == '\'') {
|
||||
}
|
||||
else if(pString[i] == '\'')
|
||||
{
|
||||
newString[pos++] = '\\';
|
||||
newString[pos++] = '\'';
|
||||
} else if(pString[i] == '"') {
|
||||
}
|
||||
else if(pString[i] == '"')
|
||||
{
|
||||
newString[pos++] = '\\';
|
||||
newString[pos++] = '"';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
newString[pos++] = pString[i];
|
||||
}
|
||||
}
|
||||
|
@ -618,35 +630,41 @@ void CSqlScore::ClearString(char *pString)
|
|||
strcpy(pString,newString);
|
||||
}
|
||||
|
||||
void CSqlScore::NormalizeMapname(char *pString) {
|
||||
void CSqlScore::NormalizeMapname(char *pString)
|
||||
{
|
||||
std::string validChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
|
||||
|
||||
for(int i=0;i<str_length(pString);i++) {
|
||||
if(validChars.find(pString[i]) == std::string::npos) {
|
||||
for(int i=0;i<str_length(pString);i++)
|
||||
{
|
||||
if(validChars.find(pString[i]) == std::string::npos)
|
||||
{
|
||||
pString[i] = '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSqlScore::agoTimeToString(int agoTime, char agoString[]){
|
||||
void CSqlScore::agoTimeToString(int agoTime, char agoString[])
|
||||
{
|
||||
char aBuf[20];
|
||||
int times[7] = {
|
||||
60 * 60 * 24 * 365 ,
|
||||
60 * 60 * 24 * 30 ,
|
||||
60 * 60 * 24 * 7,
|
||||
60 * 60 * 24 ,
|
||||
60 * 60 ,
|
||||
60 ,
|
||||
1
|
||||
int times[7] =
|
||||
{
|
||||
60 * 60 * 24 * 365 ,
|
||||
60 * 60 * 24 * 30 ,
|
||||
60 * 60 * 24 * 7,
|
||||
60 * 60 * 24 ,
|
||||
60 * 60 ,
|
||||
60 ,
|
||||
1
|
||||
};
|
||||
char names[7][6] = {
|
||||
"year",
|
||||
"month",
|
||||
"week",
|
||||
"day",
|
||||
"hour",
|
||||
"min",
|
||||
"sec"
|
||||
char names[7][6] =
|
||||
{
|
||||
"year",
|
||||
"month",
|
||||
"week",
|
||||
"day",
|
||||
"hour",
|
||||
"min",
|
||||
"sec"
|
||||
};
|
||||
|
||||
int seconds = 0;
|
||||
|
@ -655,24 +673,30 @@ void CSqlScore::agoTimeToString(int agoTime, char agoString[]){
|
|||
int i = 0;
|
||||
|
||||
// finding biggest match
|
||||
for(i = 0; i<7; i++){
|
||||
for(i = 0; i<7; i++)
|
||||
{
|
||||
seconds = times[i];
|
||||
strcpy(name,names[i]);
|
||||
|
||||
count = floor((float)agoTime/(float)seconds);
|
||||
if(count != 0){
|
||||
if(count != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(count == 1){
|
||||
if(count == 1)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%d %s", 1 , name);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%d %ss", count , name);
|
||||
}
|
||||
strcat(agoString,aBuf);
|
||||
|
||||
if (i + 1 < 7) {
|
||||
if (i + 1 < 7)
|
||||
{
|
||||
// getting second piece now
|
||||
int seconds2 = times[i+1];
|
||||
char name2[6];
|
||||
|
@ -681,10 +705,14 @@ void CSqlScore::agoTimeToString(int agoTime, char agoString[]){
|
|||
// add second piece if it's greater than 0
|
||||
int count2 = floor((float)(agoTime - (seconds * count)) / (float)seconds2);
|
||||
|
||||
if (count2 != 0) {
|
||||
if(count2 == 1){
|
||||
if (count2 != 0)
|
||||
{
|
||||
if(count2 == 1)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), " and %d %s", 1 , name2);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), " and %d %ss", count2 , name2);
|
||||
}
|
||||
strcat(agoString,aBuf);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "../score.h"
|
||||
|
||||
class CSqlScore : public IScore
|
||||
class CSqlScore: public IScore
|
||||
{
|
||||
CGameContext *m_pGameServer;
|
||||
IServer *m_pServer;
|
||||
|
@ -32,14 +32,20 @@ class CSqlScore : public IScore
|
|||
char m_aMap[64];
|
||||
int m_Port;
|
||||
|
||||
CGameContext *GameServer() { return m_pGameServer; }
|
||||
IServer *Server() { return m_pServer; }
|
||||
CGameContext *GameServer()
|
||||
{
|
||||
return m_pGameServer;
|
||||
}
|
||||
IServer *Server()
|
||||
{
|
||||
return m_pServer;
|
||||
}
|
||||
|
||||
static void LoadScoreThread(void *pUser);
|
||||
static void SaveScoreThread(void *pUser);
|
||||
static void ShowRankThread(void *pUser);
|
||||
static void ShowTop5Thread(void *pUser);
|
||||
static void ShowTimesThread(void *pUser);
|
||||
static void ShowTimesThread(void *pUser);
|
||||
|
||||
void Init();
|
||||
|
||||
|
@ -57,12 +63,14 @@ public:
|
|||
~CSqlScore();
|
||||
|
||||
virtual void LoadScore(int ClientID);
|
||||
virtual void SaveScore(int ClientID, float Time, float CpTime[NUM_CHECKPOINTS]);
|
||||
virtual void ShowRank(int ClientID, const char* pName, bool Search=false);
|
||||
virtual void ShowTimes(int ClientID, const char* pName, int Debut=1);
|
||||
virtual void ShowTimes(int ClientID, int Debut=1);
|
||||
virtual void ShowTop5(IConsole::IResult *pResult, int ClientID, void *pUserData, int Debut=1);
|
||||
static void agoTimeToString(int agoTime, char agoStrign[]);
|
||||
virtual void SaveScore(int ClientID, float Time,
|
||||
float CpTime[NUM_CHECKPOINTS]);
|
||||
virtual void ShowRank(int ClientID, const char* pName, bool Search = false);
|
||||
virtual void ShowTimes(int ClientID, const char* pName, int Debut = 1);
|
||||
virtual void ShowTimes(int ClientID, int Debut = 1);
|
||||
virtual void ShowTop5(IConsole::IResult *pResult, int ClientID,
|
||||
void *pUserData, int Debut = 1);
|
||||
static void agoTimeToString(int agoTime, char agoStrign[]);
|
||||
};
|
||||
|
||||
struct CSqlScoreData
|
||||
|
@ -72,7 +80,7 @@ struct CSqlScoreData
|
|||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
char m_aName[16]; // Don't edit this, or all your teeth will fall http://bugs.mysql.com/bug.php?id=50046
|
||||
#else
|
||||
char m_aName[MAX_NAME_LENGTH*2-1];
|
||||
char m_aName[MAX_NAME_LENGTH * 2 - 1];
|
||||
#endif
|
||||
|
||||
float m_Time;
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#include "teams.h"
|
||||
#include <engine/shared/config.h>
|
||||
|
||||
CGameTeams::CGameTeams(CGameContext *pGameContext) : m_pGameContext(pGameContext)
|
||||
CGameTeams::CGameTeams(CGameContext *pGameContext) :
|
||||
m_pGameContext(pGameContext)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
@ -10,7 +11,7 @@ CGameTeams::CGameTeams(CGameContext *pGameContext) : m_pGameContext(pGameContext
|
|||
void CGameTeams::Reset()
|
||||
{
|
||||
m_Core.Reset();
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
m_TeamState[i] = TEAMSTATE_EMPTY;
|
||||
m_TeeFinished[i] = false;
|
||||
|
@ -23,11 +24,12 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
{
|
||||
int Tick = Server()->Tick();
|
||||
CCharacter* pStartingChar = Character(ClientID);
|
||||
if(!pStartingChar)
|
||||
if (!pStartingChar)
|
||||
return;
|
||||
if(pStartingChar->m_DDRaceState == DDRACE_FINISHED)
|
||||
if (pStartingChar->m_DDRaceState == DDRACE_FINISHED)
|
||||
pStartingChar->m_DDRaceState = DDRACE_NONE;
|
||||
if(m_Core.Team(ClientID) == TEAM_FLOCK || m_Core.Team(ClientID) == TEAM_SUPER)
|
||||
if (m_Core.Team(ClientID) == TEAM_FLOCK
|
||||
|| m_Core.Team(ClientID) == TEAM_SUPER)
|
||||
{
|
||||
pStartingChar->m_DDRaceState = DDRACE_STARTED;
|
||||
pStartingChar->m_StartTime = Tick;
|
||||
|
@ -36,26 +38,37 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
else
|
||||
{
|
||||
bool Waiting = false;
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
if (m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
{
|
||||
CPlayer* pPlayer = GetPlayer(i);
|
||||
if(pPlayer && pPlayer->IsPlaying() && GetDDRaceState(pPlayer) == DDRACE_FINISHED)
|
||||
if (pPlayer && pPlayer->IsPlaying()
|
||||
&& GetDDRaceState(pPlayer) == DDRACE_FINISHED)
|
||||
{
|
||||
Waiting = true;
|
||||
pStartingChar->m_DDRaceState = DDRACE_NONE;
|
||||
if(m_LastChat[ClientID] + Server()->TickSpeed() + g_Config.m_SvChatDelay < Tick)
|
||||
if (m_LastChat[ClientID] + Server()->TickSpeed()
|
||||
+ g_Config.m_SvChatDelay < Tick)
|
||||
{
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "%s has finished and didn't go through start yet, wait for him or join another team.", Server()->ClientName(i));
|
||||
str_format(
|
||||
aBuf,
|
||||
sizeof(aBuf),
|
||||
"%s has finished and didn't go through start yet, wait for him or join another team.",
|
||||
Server()->ClientName(i));
|
||||
GameServer()->SendChatTarget(ClientID, aBuf);
|
||||
m_LastChat[ClientID] = Tick;
|
||||
}
|
||||
if(m_LastChat[i] + Server()->TickSpeed() + g_Config.m_SvChatDelay < Tick)
|
||||
if (m_LastChat[i] + Server()->TickSpeed()
|
||||
+ g_Config.m_SvChatDelay < Tick)
|
||||
{
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "%s wants to start a new round, kill or walk to start.", Server()->ClientName(ClientID));
|
||||
str_format(
|
||||
aBuf,
|
||||
sizeof(aBuf),
|
||||
"%s wants to start a new round, kill or walk to start.",
|
||||
Server()->ClientName(ClientID));
|
||||
GameServer()->SendChatTarget(i, aBuf);
|
||||
m_LastChat[i] = Tick;
|
||||
}
|
||||
|
@ -63,15 +76,15 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
}
|
||||
}
|
||||
|
||||
if(m_TeamState[m_Core.Team(ClientID)] < TEAMSTATE_STARTED && !Waiting)
|
||||
if (m_TeamState[m_Core.Team(ClientID)] < TEAMSTATE_STARTED && !Waiting)
|
||||
{
|
||||
ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_STARTED);
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
if (m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
{
|
||||
CPlayer* pPlayer = GetPlayer(i);
|
||||
if(pPlayer && pPlayer->IsPlaying())
|
||||
if (pPlayer && pPlayer->IsPlaying())
|
||||
{
|
||||
SetDDRaceState(pPlayer, DDRACE_STARTED);
|
||||
SetStartTime(pPlayer, Tick);
|
||||
|
@ -85,32 +98,33 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
|
||||
void CGameTeams::OnCharacterFinish(int ClientID)
|
||||
{
|
||||
if(m_Core.Team(ClientID) == TEAM_FLOCK || m_Core.Team(ClientID) == TEAM_SUPER)
|
||||
if (m_Core.Team(ClientID) == TEAM_FLOCK
|
||||
|| m_Core.Team(ClientID) == TEAM_SUPER)
|
||||
{
|
||||
CPlayer* pPlayer = GetPlayer(ClientID);
|
||||
if(pPlayer && pPlayer->IsPlaying())
|
||||
if (pPlayer && pPlayer->IsPlaying())
|
||||
OnFinish(pPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TeeFinished[ClientID] = true;
|
||||
if(TeamFinished(m_Core.Team(ClientID)))
|
||||
if (TeamFinished(m_Core.Team(ClientID)))
|
||||
{
|
||||
ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_FINISHED);//TODO: Make it better
|
||||
ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_FINISHED); //TODO: Make it better
|
||||
//ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_OPEN);
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
if (m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
{
|
||||
CPlayer* pPlayer = GetPlayer(i);
|
||||
if(pPlayer && pPlayer->IsPlaying())
|
||||
if (pPlayer && pPlayer->IsPlaying())
|
||||
{
|
||||
OnFinish(pPlayer);
|
||||
m_TeeFinished[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,28 +132,29 @@ void CGameTeams::OnCharacterFinish(int ClientID)
|
|||
bool CGameTeams::SetCharacterTeam(int ClientID, int Team)
|
||||
{
|
||||
//Check on wrong parameters. +1 for TEAM_SUPER
|
||||
if(ClientID < 0 || ClientID >= MAX_CLIENTS || Team < 0 || Team >= MAX_CLIENTS + 1)
|
||||
if (ClientID < 0 || ClientID >= MAX_CLIENTS || Team < 0
|
||||
|| Team >= MAX_CLIENTS + 1)
|
||||
return false;
|
||||
//You can join to TEAM_SUPER at any time, but any other group you cannot if it started
|
||||
if(Team != TEAM_SUPER && m_TeamState[Team] > TEAMSTATE_OPEN)
|
||||
if (Team != TEAM_SUPER && m_TeamState[Team] > TEAMSTATE_OPEN)
|
||||
return false;
|
||||
//No need to switch team if you there
|
||||
if(m_Core.Team(ClientID) == Team)
|
||||
if (m_Core.Team(ClientID) == Team)
|
||||
return false;
|
||||
//You cannot be in TEAM_SUPER if you not super
|
||||
if(Team == TEAM_SUPER && !Character(ClientID)->m_Super) return false;
|
||||
if (Team == TEAM_SUPER && !Character(ClientID)->m_Super)
|
||||
return false;
|
||||
//if you begin race
|
||||
if(Character(ClientID)->m_DDRaceState != DDRACE_NONE)
|
||||
if (Character(ClientID)->m_DDRaceState != DDRACE_NONE)
|
||||
{
|
||||
//you will be killed if you try to join FLOCK
|
||||
if(Team == TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_FLOCK)
|
||||
if (Team == TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_FLOCK)
|
||||
GetPlayer(ClientID)->KillCharacter(WEAPON_GAME);
|
||||
else if(Team != TEAM_SUPER)
|
||||
else if (Team != TEAM_SUPER)
|
||||
return false;
|
||||
}
|
||||
SetForceCharacterTeam(ClientID, Team);
|
||||
|
||||
|
||||
|
||||
//GameServer()->CreatePlayerSpawn(Character(id)->m_Core.m_Pos, TeamMask());
|
||||
return true;
|
||||
}
|
||||
|
@ -147,36 +162,39 @@ bool CGameTeams::SetCharacterTeam(int ClientID, int Team)
|
|||
void CGameTeams::SetForceCharacterTeam(int ClientID, int Team)
|
||||
{
|
||||
m_TeeFinished[ClientID] = false;
|
||||
if(m_Core.Team(ClientID) != TEAM_FLOCK
|
||||
&& m_Core.Team(ClientID) != TEAM_SUPER
|
||||
&& m_TeamState[m_Core.Team(ClientID)] != TEAMSTATE_EMPTY)
|
||||
if (m_Core.Team(ClientID) != TEAM_FLOCK
|
||||
&& m_Core.Team(ClientID) != TEAM_SUPER
|
||||
&& m_TeamState[m_Core.Team(ClientID)] != TEAMSTATE_EMPTY)
|
||||
{
|
||||
bool NoOneInOldTeam = true;
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
if(i != ClientID && m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
if (i != ClientID && m_Core.Team(ClientID) == m_Core.Team(i))
|
||||
{
|
||||
NoOneInOldTeam = false;//all good exists someone in old team
|
||||
NoOneInOldTeam = false; //all good exists someone in old team
|
||||
break;
|
||||
}
|
||||
if(NoOneInOldTeam)
|
||||
if (NoOneInOldTeam)
|
||||
m_TeamState[m_Core.Team(ClientID)] = TEAMSTATE_EMPTY;
|
||||
}
|
||||
if(Count(m_Core.Team(ClientID)) > 0) m_MembersCount[m_Core.Team(ClientID)]--;
|
||||
if (Count(m_Core.Team(ClientID)) > 0)
|
||||
m_MembersCount[m_Core.Team(ClientID)]--;
|
||||
m_Core.Team(ClientID, Team);
|
||||
if(m_Core.Team(ClientID) != TEAM_SUPER) m_MembersCount[m_Core.Team(ClientID)]++;
|
||||
if(Team != TEAM_SUPER && m_TeamState[Team] == TEAMSTATE_EMPTY)
|
||||
if (m_Core.Team(ClientID) != TEAM_SUPER)
|
||||
m_MembersCount[m_Core.Team(ClientID)]++;
|
||||
if (Team != TEAM_SUPER && m_TeamState[Team] == TEAMSTATE_EMPTY)
|
||||
ChangeTeamState(Team, TEAMSTATE_OPEN);
|
||||
|
||||
|
||||
for (int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
|
||||
{
|
||||
if(GetPlayer(LoopClientID) && GetPlayer(LoopClientID)->m_IsUsingDDRaceClient)
|
||||
if (GetPlayer(LoopClientID)
|
||||
&& GetPlayer(LoopClientID)->m_IsUsingDDRaceClient)
|
||||
SendTeamsState(LoopClientID);
|
||||
}
|
||||
}
|
||||
|
||||
int CGameTeams::Count(int Team) const
|
||||
{
|
||||
if(Team == TEAM_SUPER)
|
||||
if (Team == TEAM_SUPER)
|
||||
return -1;
|
||||
return m_MembersCount[Team];
|
||||
}
|
||||
|
@ -190,11 +208,11 @@ void CGameTeams::ChangeTeamState(int Team, int State)
|
|||
|
||||
void CGameTeams::onChangeTeamState(int Team, int State, int OldState)
|
||||
{
|
||||
if(OldState != State && State == TEAMSTATE_STARTED)
|
||||
if (OldState != State && State == TEAMSTATE_STARTED)
|
||||
{
|
||||
// OnTeamStateStarting
|
||||
}
|
||||
if(OldState != State && State == TEAMSTATE_FINISHED)
|
||||
if (OldState != State && State == TEAMSTATE_FINISHED)
|
||||
{
|
||||
// OnTeamStateFinishing
|
||||
}
|
||||
|
@ -202,24 +220,28 @@ void CGameTeams::onChangeTeamState(int Team, int State, int OldState)
|
|||
|
||||
bool CGameTeams::TeamFinished(int Team)
|
||||
{
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
if(m_Core.Team(i) == Team && !m_TeeFinished[i])
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
if (m_Core.Team(i) == Team && !m_TeeFinished[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int CGameTeams::TeamMask(int Team, int ExceptID, int Asker)
|
||||
{
|
||||
if(Team == TEAM_SUPER) return -1;
|
||||
if(m_Core.GetSolo(Asker) && ExceptID == Asker)
|
||||
if (Team == TEAM_SUPER)
|
||||
return -1;
|
||||
if (m_Core.GetSolo(Asker) && ExceptID == Asker)
|
||||
return 0;
|
||||
if(m_Core.GetSolo(Asker))
|
||||
if (m_Core.GetSolo(Asker))
|
||||
return 1 << Asker;
|
||||
int Mask = 0;
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
if(i != ExceptID)
|
||||
if((Asker == i || !m_Core.GetSolo(i)) && ((Character(i) && (m_Core.Team(i) == Team || m_Core.Team(i) == TEAM_SUPER))
|
||||
|| (GetPlayer(i) && GetPlayer(i)->GetTeam() == -1)))
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
if (i != ExceptID)
|
||||
if ((Asker == i || !m_Core.GetSolo(i))
|
||||
&& ((Character(i)
|
||||
&& (m_Core.Team(i) == Team
|
||||
|| m_Core.Team(i) == TEAM_SUPER))
|
||||
|| (GetPlayer(i) && GetPlayer(i)->GetTeam() == -1)))
|
||||
Mask |= 1 << i;
|
||||
return Mask;
|
||||
}
|
||||
|
@ -243,212 +265,229 @@ void CGameTeams::SendTeamsState(int ClientID)
|
|||
Msg.m_Tee13 = m_Core.Team(13);
|
||||
Msg.m_Tee14 = m_Core.Team(14);
|
||||
Msg.m_Tee15 = m_Core.Team(15);
|
||||
|
||||
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID);
|
||||
|
||||
|
||||
}
|
||||
|
||||
int CGameTeams::GetDDRaceState(CPlayer* Player)
|
||||
{
|
||||
if(!Player)
|
||||
if (!Player)
|
||||
return DDRACE_NONE;
|
||||
|
||||
CCharacter* pChar = Player->GetCharacter();
|
||||
if(pChar)
|
||||
if (pChar)
|
||||
return pChar->m_DDRaceState;
|
||||
else if(Player->m_InfoSaved)
|
||||
else if (Player->m_InfoSaved)
|
||||
return Player->m_PauseInfo.m_DDRaceState;
|
||||
return DDRACE_NONE;
|
||||
}
|
||||
|
||||
void CGameTeams::SetDDRaceState(CPlayer* Player, int DDRaceState)
|
||||
{
|
||||
if(!Player)
|
||||
if (!Player)
|
||||
return;
|
||||
|
||||
CCharacter* pChar = Player->GetCharacter();
|
||||
if(pChar)
|
||||
if (pChar)
|
||||
pChar->m_DDRaceState = DDRaceState;
|
||||
else if(Player->m_InfoSaved)
|
||||
else if (Player->m_InfoSaved)
|
||||
Player->m_PauseInfo.m_DDRaceState = DDRaceState;
|
||||
}
|
||||
|
||||
int CGameTeams::GetStartTime(CPlayer* Player)
|
||||
{
|
||||
if(!Player)
|
||||
if (!Player)
|
||||
return 0;
|
||||
|
||||
CCharacter* pChar = Player->GetCharacter();
|
||||
if(pChar)
|
||||
if (pChar)
|
||||
return pChar->m_StartTime;
|
||||
else if(Player->m_InfoSaved)
|
||||
else if (Player->m_InfoSaved)
|
||||
return Player->m_PauseInfo.m_StartTime;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CGameTeams::SetStartTime(CPlayer* Player, int StartTime)
|
||||
{
|
||||
if(!Player)
|
||||
if (!Player)
|
||||
return;
|
||||
|
||||
CCharacter* pChar = Player->GetCharacter();
|
||||
if(pChar)
|
||||
if (pChar)
|
||||
pChar->m_StartTime = StartTime;
|
||||
else if(Player->m_InfoSaved)
|
||||
else if (Player->m_InfoSaved)
|
||||
Player->m_PauseInfo.m_StartTime = StartTime;
|
||||
}
|
||||
|
||||
void CGameTeams::SetRefreshTime(CPlayer* Player, int RefreshTime)
|
||||
{
|
||||
if(!Player)
|
||||
if (!Player)
|
||||
return;
|
||||
|
||||
CCharacter* pChar = Player->GetCharacter();
|
||||
if(pChar)
|
||||
if (pChar)
|
||||
pChar->m_RefreshTime = RefreshTime;
|
||||
/*else if(Player->m_InfoSaved)
|
||||
Player->m_PauseInfo.m_RefreshTime = RefreshTime;*/
|
||||
Player->m_PauseInfo.m_RefreshTime = RefreshTime;*/
|
||||
}
|
||||
|
||||
void CGameTeams::SetCpActive(CPlayer* Player, int CpActive)
|
||||
{
|
||||
if(!Player)
|
||||
if (!Player)
|
||||
return;
|
||||
|
||||
CCharacter* pChar = Player->GetCharacter();
|
||||
if(pChar)
|
||||
if (pChar)
|
||||
pChar->m_CpActive = CpActive;
|
||||
else if(Player->m_InfoSaved)
|
||||
else if (Player->m_InfoSaved)
|
||||
Player->m_PauseInfo.m_CpActive = CpActive;
|
||||
}
|
||||
|
||||
float *CGameTeams::GetCpCurrent(CPlayer* Player)
|
||||
{
|
||||
if(!Player)
|
||||
if (!Player)
|
||||
return NULL;
|
||||
|
||||
CCharacter* pChar = Player->GetCharacter();
|
||||
if(pChar)
|
||||
if (pChar)
|
||||
return pChar->m_CpCurrent;
|
||||
else if(Player->m_InfoSaved)
|
||||
else if (Player->m_InfoSaved)
|
||||
return Player->m_PauseInfo.m_CpCurrent;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CGameTeams::OnFinish(CPlayer* Player)
|
||||
{
|
||||
if(!Player || !Player->IsPlaying())
|
||||
if (!Player || !Player->IsPlaying())
|
||||
return;
|
||||
//TODO:DDRace:btd: this ugly
|
||||
float time = (float)(Server()->Tick() - GetStartTime(Player)) / ((float)Server()->TickSpeed());
|
||||
if(time < 0.000001f) return;
|
||||
float time = (float) (Server()->Tick() - GetStartTime(Player))
|
||||
/ ((float) Server()->TickSpeed());
|
||||
if (time < 0.000001f)
|
||||
return;
|
||||
CPlayerData *pData = GameServer()->Score()->PlayerData(Player->GetCID());
|
||||
char aBuf[128];
|
||||
SetCpActive(Player, -2);
|
||||
str_format(aBuf, sizeof(aBuf), "%s finished in: %d minute(s) %5.2f second(s)", Server()->ClientName(Player->GetCID()), (int)time/60, time-((int)time/60*60));
|
||||
if(g_Config.m_SvHideScore)
|
||||
SetCpActive(Player, -2);
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"%s finished in: %d minute(s) %5.2f second(s)",
|
||||
Server()->ClientName(Player->GetCID()), (int) time / 60,
|
||||
time - ((int) time / 60 * 60));
|
||||
if (g_Config.m_SvHideScore)
|
||||
GameServer()->SendChatTarget(Player->GetCID(), aBuf);
|
||||
else
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
|
||||
if (time - pData->m_BestTime < 0)
|
||||
{
|
||||
// new record \o/
|
||||
str_format(aBuf, sizeof(aBuf), "New record: %5.2f second(s) better.",
|
||||
fabs(time - pData->m_BestTime));
|
||||
if (g_Config.m_SvHideScore)
|
||||
GameServer()->SendChatTarget(Player->GetCID(), aBuf);
|
||||
else
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
|
||||
if(time - pData->m_BestTime < 0)
|
||||
}
|
||||
else if (pData->m_BestTime != 0) // tee has already finished?
|
||||
{
|
||||
if (fabs(time - pData->m_BestTime) <= 0.005)
|
||||
{
|
||||
// new record \o/
|
||||
str_format(aBuf, sizeof(aBuf), "New record: %5.2f second(s) better.", fabs(time - pData->m_BestTime));
|
||||
if(g_Config.m_SvHideScore)
|
||||
GameServer()->SendChatTarget(Player->GetCID(), aBuf);
|
||||
else
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
GameServer()->SendChatTarget(Player->GetCID(),
|
||||
"You finished with your best time.");
|
||||
}
|
||||
else if(pData->m_BestTime != 0) // tee has already finished?
|
||||
else
|
||||
{
|
||||
if(fabs(time - pData->m_BestTime) <= 0.005)
|
||||
{
|
||||
GameServer()->SendChatTarget(Player->GetCID(), "You finished with your best time.");
|
||||
}
|
||||
else
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%5.2f second(s) worse, better luck next time.", fabs(pData->m_BestTime - time));
|
||||
GameServer()->SendChatTarget(Player->GetCID(), aBuf);//this is private, sent only to the tee
|
||||
}
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"%5.2f second(s) worse, better luck next time.",
|
||||
fabs(pData->m_BestTime - time));
|
||||
GameServer()->SendChatTarget(Player->GetCID(), aBuf); //this is private, sent only to the tee
|
||||
}
|
||||
}
|
||||
|
||||
bool CallSaveScore = false;
|
||||
#if defined(CONF_SQL)
|
||||
CallSaveScore = g_Config.m_SvUseSQL;
|
||||
#endif
|
||||
bool CallSaveScore = false;
|
||||
#if defined(CONF_SQL)
|
||||
CallSaveScore = g_Config.m_SvUseSQL;
|
||||
#endif
|
||||
|
||||
if(!pData->m_BestTime || time < pData->m_BestTime)
|
||||
if (!pData->m_BestTime || time < pData->m_BestTime)
|
||||
{
|
||||
// update the score
|
||||
pData->Set(time, GetCpCurrent(Player));
|
||||
CallSaveScore = true;
|
||||
}
|
||||
|
||||
if (CallSaveScore)
|
||||
if (str_comp_num(Server()->ClientName(Player->GetCID()), "nameless tee",
|
||||
12) != 0)
|
||||
GameServer()->Score()->SaveScore(Player->GetCID(), time,
|
||||
GetCpCurrent(Player));
|
||||
|
||||
bool NeedToSendNewRecord = false;
|
||||
// update server best time
|
||||
if (GameServer()->m_pController->m_CurrentRecord == 0
|
||||
|| time < GameServer()->m_pController->m_CurrentRecord)
|
||||
{
|
||||
// check for nameless
|
||||
if (str_comp_num(Server()->ClientName(Player->GetCID()), "nameless tee",
|
||||
12) != 0)
|
||||
{
|
||||
// update the score
|
||||
pData->Set(time, GetCpCurrent(Player));
|
||||
CallSaveScore = true;
|
||||
}
|
||||
|
||||
if(CallSaveScore)
|
||||
if(str_comp_num(Server()->ClientName(Player->GetCID()), "nameless tee", 12) != 0)
|
||||
GameServer()->Score()->SaveScore(Player->GetCID(), time, GetCpCurrent(Player));
|
||||
|
||||
bool NeedToSendNewRecord = false;
|
||||
// update server best time
|
||||
if(GameServer()->m_pController->m_CurrentRecord == 0 || time < GameServer()->m_pController->m_CurrentRecord)
|
||||
{
|
||||
// check for nameless
|
||||
if(str_comp_num(Server()->ClientName(Player->GetCID()), "nameless tee", 12) != 0) {
|
||||
GameServer()->m_pController->m_CurrentRecord = time;
|
||||
//dbg_msg("character", "Finish");
|
||||
NeedToSendNewRecord = true;
|
||||
}
|
||||
}
|
||||
|
||||
SetDDRaceState(Player, DDRACE_FINISHED);
|
||||
// set player score
|
||||
if(!pData->m_CurrentTime || pData->m_CurrentTime > time)
|
||||
{
|
||||
pData->m_CurrentTime = time;
|
||||
GameServer()->m_pController->m_CurrentRecord = time;
|
||||
//dbg_msg("character", "Finish");
|
||||
NeedToSendNewRecord = true;
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
}
|
||||
}
|
||||
|
||||
SetDDRaceState(Player, DDRACE_FINISHED);
|
||||
// set player score
|
||||
if (!pData->m_CurrentTime || pData->m_CurrentTime > time)
|
||||
{
|
||||
pData->m_CurrentTime = time;
|
||||
NeedToSendNewRecord = true;
|
||||
for (int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if (GetPlayer(i) && GetPlayer(i)->m_IsUsingDDRaceClient)
|
||||
{
|
||||
if(GetPlayer(i) && GetPlayer(i)->m_IsUsingDDRaceClient)
|
||||
if (!g_Config.m_SvHideScore || i == Player->GetCID())
|
||||
{
|
||||
if(!g_Config.m_SvHideScore || i == Player->GetCID())
|
||||
{
|
||||
CNetMsg_Sv_PlayerTime Msg;
|
||||
Msg.m_Time = time * 100.0;
|
||||
Msg.m_ClientID = Player->GetCID();
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i);
|
||||
}
|
||||
CNetMsg_Sv_PlayerTime Msg;
|
||||
Msg.m_Time = time * 100.0;
|
||||
Msg.m_ClientID = Player->GetCID();
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(NeedToSendNewRecord && Player->m_IsUsingDDRaceClient) {
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
if (NeedToSendNewRecord && Player->m_IsUsingDDRaceClient)
|
||||
{
|
||||
for (int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if (GameServer()->m_apPlayers[i]
|
||||
&& GameServer()->m_apPlayers[i]->m_IsUsingDDRaceClient)
|
||||
{
|
||||
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_IsUsingDDRaceClient)
|
||||
{
|
||||
GameServer()->SendRecord(i);
|
||||
}
|
||||
GameServer()->SendRecord(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Player->m_IsUsingDDRaceClient) {
|
||||
CNetMsg_Sv_DDRaceTime Msg;
|
||||
Msg.m_Time = (int)(time * 100.0f);
|
||||
Msg.m_Check = 0;
|
||||
Msg.m_Finish = 1;
|
||||
if (Player->m_IsUsingDDRaceClient)
|
||||
{
|
||||
CNetMsg_Sv_DDRaceTime Msg;
|
||||
Msg.m_Time = (int) (time * 100.0f);
|
||||
Msg.m_Check = 0;
|
||||
Msg.m_Finish = 1;
|
||||
|
||||
if(pData->m_BestTime)
|
||||
{
|
||||
float Diff = (time - pData->m_BestTime)*100;
|
||||
Msg.m_Check = (int)Diff;
|
||||
}
|
||||
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, Player->GetCID());
|
||||
if (pData->m_BestTime)
|
||||
{
|
||||
float Diff = (time - pData->m_BestTime) * 100;
|
||||
Msg.m_Check = (int) Diff;
|
||||
}
|
||||
|
||||
int TTime = 0-(int)time;
|
||||
if(Player->m_Score < TTime)
|
||||
Player->m_Score = TTime;
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, Player->GetCID());
|
||||
}
|
||||
|
||||
int TTime = 0 - (int) time;
|
||||
if (Player->m_Score < TTime)
|
||||
Player->m_Score = TTime;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,49 +10,57 @@ class CGameTeams
|
|||
int m_TeamState[MAX_CLIENTS];
|
||||
int m_MembersCount[MAX_CLIENTS];
|
||||
bool m_TeeFinished[MAX_CLIENTS];
|
||||
|
||||
|
||||
class CGameContext * m_pGameContext;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
TEAMSTATE_EMPTY,
|
||||
TEAMSTATE_OPEN,
|
||||
TEAMSTATE_STARTED,
|
||||
TEAMSTATE_FINISHED
|
||||
TEAMSTATE_EMPTY, TEAMSTATE_OPEN, TEAMSTATE_STARTED, TEAMSTATE_FINISHED
|
||||
};
|
||||
|
||||
CTeamsCore m_Core;
|
||||
|
||||
CGameTeams(CGameContext *pGameContext);
|
||||
|
||||
//helper methods
|
||||
CCharacter* Character(int ClientID) { return GameServer()->GetPlayerChar(ClientID); }
|
||||
CPlayer* GetPlayer(int ClientID) { return GameServer()->m_apPlayers[ClientID]; }
|
||||
|
||||
class CGameContext *GameServer() { return m_pGameContext; }
|
||||
class IServer *Server() { return m_pGameContext->Server(); }
|
||||
|
||||
CTeamsCore m_Core;
|
||||
|
||||
CGameTeams(CGameContext *pGameContext);
|
||||
|
||||
//helper methods
|
||||
CCharacter* Character(int ClientID)
|
||||
{
|
||||
return GameServer()->GetPlayerChar(ClientID);
|
||||
}
|
||||
CPlayer* GetPlayer(int ClientID)
|
||||
{
|
||||
return GameServer()->m_apPlayers[ClientID];
|
||||
}
|
||||
|
||||
class CGameContext *GameServer()
|
||||
{
|
||||
return m_pGameContext;
|
||||
}
|
||||
class IServer *Server()
|
||||
{
|
||||
return m_pGameContext->Server();
|
||||
}
|
||||
|
||||
void OnCharacterStart(int ClientID);
|
||||
void OnCharacterFinish(int ClientID);
|
||||
|
||||
|
||||
bool SetCharacterTeam(int ClientID, int Team);
|
||||
|
||||
|
||||
void ChangeTeamState(int Team, int State);
|
||||
void onChangeTeamState(int Team, int State, int OldState);
|
||||
|
||||
|
||||
bool TeamFinished(int Team);
|
||||
|
||||
int TeamMask(int Team, int ExceptID = -1, int Asker = -1);
|
||||
|
||||
|
||||
int Count(int Team) const;
|
||||
|
||||
|
||||
//need to be very carefull using this method
|
||||
void SetForceCharacterTeam(int id, int Team);
|
||||
|
||||
|
||||
void Reset();
|
||||
|
||||
|
||||
void SendTeamsState(int Cid);
|
||||
|
||||
int m_LastChat[MAX_CLIENTS];
|
||||
|
@ -65,8 +73,16 @@ public:
|
|||
void SetRefreshTime(CPlayer* Player, int RefreshTime);
|
||||
void SetCpActive(CPlayer* Player, int CpActive);
|
||||
void OnFinish(CPlayer* Player);
|
||||
bool TeeFinished(int ClientID) { return m_TeeFinished[ClientID]; };
|
||||
int GetTeamState(int Team) { return m_TeamState[Team]; };
|
||||
bool TeeFinished(int ClientID)
|
||||
{
|
||||
return m_TeeFinished[ClientID];
|
||||
}
|
||||
;
|
||||
int GetTeamState(int Team)
|
||||
{
|
||||
return m_TeamState[Team];
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,7 @@ bool CTeamsCore::SameTeam(int ClientID1, int ClientID2)
|
|||
{
|
||||
return m_Team[ClientID1] == m_Team[ClientID2];
|
||||
}
|
||||
|
||||
|
||||
int CTeamsCore::Team(int ClientID)
|
||||
{
|
||||
return m_Team[ClientID];
|
||||
|
@ -23,16 +23,17 @@ void CTeamsCore::Team(int ClientID, int Team)
|
|||
|
||||
bool CTeamsCore::CanCollide(int ClientID1, int ClientID2)
|
||||
{
|
||||
if(m_Team[ClientID1] == TEAM_SUPER || m_Team[ClientID2] == TEAM_SUPER || ClientID1 == ClientID2)
|
||||
if (m_Team[ClientID1] == TEAM_SUPER || m_Team[ClientID2] == TEAM_SUPER
|
||||
|| ClientID1 == ClientID2)
|
||||
return true;
|
||||
if(m_IsSolo[ClientID1] || m_IsSolo[ClientID2])
|
||||
if (m_IsSolo[ClientID1] || m_IsSolo[ClientID2])
|
||||
return false;
|
||||
return m_Team[ClientID1] == m_Team[ClientID2];
|
||||
}
|
||||
|
||||
void CTeamsCore::Reset()
|
||||
{
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
m_Team[i] = TEAM_FLOCK;
|
||||
m_IsSolo[i] = false;
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
enum
|
||||
{
|
||||
TEAM_FLOCK = 0,
|
||||
TEAM_SUPER = 16
|
||||
TEAM_FLOCK = 0, TEAM_SUPER = 16
|
||||
};
|
||||
|
||||
class CTeamsCore
|
||||
|
@ -16,19 +15,27 @@ class CTeamsCore
|
|||
int m_Team[MAX_CLIENTS];
|
||||
bool m_IsSolo[MAX_CLIENTS];
|
||||
public:
|
||||
|
||||
|
||||
CTeamsCore(void);
|
||||
|
||||
|
||||
bool SameTeam(int ClientID1, int ClientID2);
|
||||
|
||||
bool CanCollide(int ClientID1, int ClientID2);
|
||||
|
||||
|
||||
int Team(int ClientID);
|
||||
void Team(int ClientID, int Team);
|
||||
|
||||
void Reset();
|
||||
void SetSolo(int ClientID, bool Value) { m_IsSolo[ClientID] = Value; };
|
||||
bool GetSolo(int ClientID) { return m_IsSolo[ClientID]; };
|
||||
void SetSolo(int ClientID, bool Value)
|
||||
{
|
||||
m_IsSolo[ClientID] = Value;
|
||||
}
|
||||
;
|
||||
bool GetSolo(int ClientID)
|
||||
{
|
||||
return m_IsSolo[ClientID];
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue