Implement dry saves

This commit is contained in:
Learath2 2020-02-13 16:16:35 +01:00
parent 72fcf9caa8
commit 27d9ac54b0
3 changed files with 44 additions and 0 deletions

View file

@ -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("dry_save", "", 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")

View file

@ -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,44 @@ 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 Num = SavedTeam.save(pPlayer->GetTeam());
switch (Num)
{
case 1:
pSelf->SendChatTarget(pResult->m_ClientID, "You have to be in a team (from 1-63)");
break;
case 2:
pSelf->SendChatTarget(pResult->m_ClientID, "Could not find your Team");
break;
case 3:
pSelf->SendChatTarget(pResult->m_ClientID, "Unable to find all Characters");
break;
case 4:
pSelf->SendChatTarget(pResult->m_ClientID, "Your team is not started yet");
break;
}
if(!Num)
{
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);
}
}

View 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);