mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #2066
2066: Implement dry saves r=def- a=Learath2 I'm not sure how much I like this but it should be helpful Co-authored-by: Learath2 <learath2@gmail.com>
This commit is contained in:
commit
7691227f24
|
@ -52,6 +52,7 @@ CONSOLE_COMMAND("unmute", "v[id]", CFGFLAG_SERVER, ConUnmute, this, "")
|
|||
CONSOLE_COMMAND("mutes", "", CFGFLAG_SERVER, ConMutes, this, "")
|
||||
CONSOLE_COMMAND("moderate", "", CFGFLAG_SERVER, ConModerate, this, "Enables/disables active moderator mode for the player")
|
||||
CONSOLE_COMMAND("vote_no", "", CFGFLAG_SERVER, ConVoteNo, this, "Same as \"vote no\"")
|
||||
CONSOLE_COMMAND("save_dry", "", CFGFLAG_SERVER, ConDrySave, this, "Dump the current savestring")
|
||||
|
||||
CONSOLE_COMMAND("freezehammer", "v[id]", CFGFLAG_SERVER|CMDFLAG_TEST, ConFreezeHammer, this, "Gives a player Freeze Hammer")
|
||||
CONSOLE_COMMAND("unfreezehammer", "v[id]", CFGFLAG_SERVER|CMDFLAG_TEST, ConUnFreezeHammer, this, "Removes Freeze Hammer from a player")
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <engine/shared/config.h>
|
||||
#include <game/server/teams.h>
|
||||
#include <game/server/gamemodes/DDRace.h>
|
||||
#include <game/server/save.h>
|
||||
#include <game/version.h>
|
||||
#if defined(CONF_SQL)
|
||||
#include <game/server/score/sql_score.h>
|
||||
|
@ -705,3 +706,28 @@ void CGameContext::ConVoteNo(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
pSelf->ForceVote(pResult->m_ClientID, false);
|
||||
}
|
||||
|
||||
void CGameContext::ConDrySave(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
|
||||
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
||||
|
||||
if(!pPlayer || pSelf->Server()->GetAuthedState(pResult->m_ClientID) != AUTHED_ADMIN)
|
||||
return;
|
||||
|
||||
CSaveTeam SavedTeam(pSelf->m_pController);
|
||||
int Result = SavedTeam.save(pPlayer->GetTeam());
|
||||
if(CSaveTeam::HandleSaveError(Result, pResult->m_ClientID, pSelf))
|
||||
return;
|
||||
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "%s-%lld-%s.save", pSelf->Server()->GetMapName(), time_get(), pSelf->Server()->GetAuthName(pResult->m_ClientID));
|
||||
IOHANDLE File = pSelf->Storage()->OpenFile(aBuf, IOFLAG_WRITE, IStorage::TYPE_ALL);
|
||||
if(!File)
|
||||
return;
|
||||
|
||||
int Len = str_length(SavedTeam.GetString());
|
||||
io_write(File, SavedTeam.GetString(), Len);
|
||||
io_close(File);
|
||||
}
|
||||
|
|
|
@ -111,6 +111,7 @@ class CGameContext : public IGameServer
|
|||
static void ConClearVotes(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConVote(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConVoteNo(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConDrySave(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
|
||||
CGameContext(int Resetting);
|
||||
|
|
|
@ -279,6 +279,29 @@ int CSaveTeam::save(int Team)
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool CSaveTeam::HandleSaveError(int Result, int ClientID, CGameContext *pGameContext)
|
||||
{
|
||||
switch(Result)
|
||||
{
|
||||
case 1:
|
||||
pGameContext->SendChatTarget(ClientID, "You have to be in a team (from 1-63)");
|
||||
break;
|
||||
case 2:
|
||||
pGameContext->SendChatTarget(ClientID, "Could not find your Team");
|
||||
break;
|
||||
case 3:
|
||||
pGameContext->SendChatTarget(ClientID, "Unable to find all Characters");
|
||||
break;
|
||||
case 4:
|
||||
pGameContext->SendChatTarget(ClientID, "Your team is not started yet");
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CSaveTeam::load(int Team)
|
||||
{
|
||||
if(Team <= 0 || Team >= MAX_CLIENTS)
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
int load(int Team);
|
||||
CSaveTee* SavedTees;
|
||||
|
||||
static bool HandleSaveError(int Result, int ClientID, CGameContext *pGameContext);
|
||||
private:
|
||||
int MatchPlayer(char name[16]);
|
||||
CCharacter* MatchCharacter(char name[16], int SaveID);
|
||||
|
|
|
@ -1409,21 +1409,9 @@ bool CSqlScore::SaveTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData
|
|||
{
|
||||
CSaveTeam SavedTeam(pData->GameServer()->m_pController);
|
||||
Num = SavedTeam.save(Team);
|
||||
switch (Num)
|
||||
{
|
||||
case 1:
|
||||
pData->GameServer()->SendChatTarget(pData->m_ClientID, "You have to be in a team (from 1-63)");
|
||||
break;
|
||||
case 2:
|
||||
pData->GameServer()->SendChatTarget(pData->m_ClientID, "Could not find your Team");
|
||||
break;
|
||||
case 3:
|
||||
pData->GameServer()->SendChatTarget(pData->m_ClientID, "Unable to find all Characters");
|
||||
break;
|
||||
case 4:
|
||||
pData->GameServer()->SendChatTarget(pData->m_ClientID, "Your team is not started yet");
|
||||
break;
|
||||
}
|
||||
if(CSaveTeam::HandleSaveError(Num, pData->m_ClientID, pData->GameServer()))
|
||||
return true;
|
||||
|
||||
if(!Num)
|
||||
{
|
||||
str_copy(TeamString, SavedTeam.GetString(), sizeof(TeamString));
|
||||
|
|
Loading…
Reference in a new issue