Skip to content

Commit

Permalink
Merge pull request #37 from AssassinTee/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AssassinTee authored May 4, 2019
2 parents 824b450 + a0bad72 commit c3f3ff8
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 11 deletions.
18 changes: 16 additions & 2 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_EmoteStop = -1;
m_LastAction = -1;
m_LastNoAmmoSound = -1;
m_ActiveWeapon = (int)g_Config.m_SvStartWeapon;
m_LastWeapon = (int)g_Config.m_SvStartWeapon;
m_ActiveWeapon = (int)GameServer()->m_pController->GetStartWeapon();
m_LastWeapon = (int)GameServer()->m_pController->GetStartWeapon();
m_QueuedWeapon = -1;

m_pPlayer = pPlayer;
Expand Down Expand Up @@ -104,6 +104,20 @@ void CCharacter::SetWeapon(int W)
m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart = -1;
}

void CCharacter::SetActiveWeapon(int W)
{
if(m_ActiveWeapon < 0 || m_ActiveWeapon >= NUM_WEAPONS)
return;
m_LastWeapon = W;
m_ActiveWeapon = W;
GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SWITCH);
for(int i = 0; i < NUM_WEAPONS; ++i)
m_aWeapons[i].m_Got = false;
m_aWeapons[W].m_Got = true;
m_aWeapons[W].m_Ammo = -1;
m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart = -1;
}

bool CCharacter::IsGrounded()
{
if(GameServer()->Collision()->CheckPoint(m_Pos.x+GetProximityRadius()/2, m_Pos.y+GetProximityRadius()/2+5))
Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CCharacter : public CEntity
bool IsGrounded();

void SetWeapon(int W);
void SetActiveWeapon(int W);
void HandleWeaponSwitch();
void DoWeaponSwitch();

Expand Down
21 changes: 21 additions & 0 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,25 @@ void CGameContext::ConchainGameinfoUpdate(IConsole::IResult *pResult, void *pUse
}
}

void CGameContext::ConStartWeapon(IConsole::IResult *pResult, void* pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
int StartWeapon = pResult->GetInteger(0);
if(StartWeapon < 0 || StartWeapon > 4)
StartWeapon = 0;
pSelf->SetStartWeapon(StartWeapon);

for(int i = 0; i < MAX_CLIENTS; ++i)
if(pSelf->m_apPlayers[i] && pSelf->m_apPlayers[i]->GetCharacter())
pSelf->m_apPlayers[i]->GetCharacter()->SetActiveWeapon(StartWeapon);
}

void CGameContext::SetStartWeapon(int StartWeapon)
{
if(m_pController)
m_pController->SetStartWeapon(StartWeapon);
}

void CGameContext::OnConsoleInit()
{
m_pServer = Kernel()->RequestInterface<IServer>();
Expand All @@ -1758,6 +1777,8 @@ void CGameContext::OnConsoleInit()
Console()->Register("remove_vote", "s", CFGFLAG_SERVER, ConRemoveVote, this, "remove a voting option");
Console()->Register("clear_votes", "", CFGFLAG_SERVER, ConClearVotes, this, "Clears the voting options");
Console()->Register("vote", "r", CFGFLAG_SERVER, ConVote, this, "Force a vote to yes/no");

Console()->Register("start_weapon", "i", CFGFLAG_SERVER, ConStartWeapon, this, "Set start weapon");
}

void CGameContext::OnInit()
Expand Down
3 changes: 3 additions & 0 deletions src/game/server/gamecontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class CGameContext : public IGameServer
static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainSettingUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainGameinfoUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConStartWeapon(IConsole::IResult *pResult, void* pUserData);

void SetStartWeapon(int StartWeapon);

CGameContext(int Resetting);
void Construct(int Resetting);
Expand Down
15 changes: 8 additions & 7 deletions src/game/server/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ IGameController::IGameController(CGameContext *pGameServer)
m_aNumSpawnPoints[2] = 0;

m_TopTeam = -1;
m_StartWeapon = 4;//Weapon laser;
}

//activity
Expand Down Expand Up @@ -251,7 +252,7 @@ void IGameController::OnCharacterSpawn(CCharacter *pChr)
// default health
pChr->IncreaseHealth(10);

int Weapon = g_Config.m_SvStartWeapon;
int Weapon = m_StartWeapon;
pChr->GiveWeapon(Weapon, -1);
}

Expand Down Expand Up @@ -402,11 +403,11 @@ void IGameController::OnReset()
GameServer()->m_apPlayers[i]->m_RespawnDisabled = false;
GameServer()->m_apPlayers[i]->Respawn();
GameServer()->m_apPlayers[i]->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
/*if(m_RoundCount == 0)
if(m_TopscoreCount == 1)
{
GameServer()->m_apPlayers[i]->m_Score = 0;
GameServer()->m_apPlayers[i]->m_ScoreStartTick = Server()->Tick();
}*/
}
GameServer()->m_apPlayers[i]->m_IsReadyToPlay = true;
GameServer()->ResetSkin(i);
}
Expand Down Expand Up @@ -435,7 +436,7 @@ bool IGameController::DoWincheckMatch()
{
// gather some stats
int Topscore = 0;
int TopscoreCount = 0;
m_TopscoreCount = 0;
int TopTeam = -1;
int TopTeamCount = 0;
bool AllInOneTeam=true;
Expand All @@ -446,10 +447,10 @@ bool IGameController::DoWincheckMatch()
if(GameServer()->m_apPlayers[i]->m_Score > Topscore)
{
Topscore = GameServer()->m_apPlayers[i]->m_Score;
TopscoreCount = 1;
m_TopscoreCount = 1;
}
else if(GameServer()->m_apPlayers[i]->m_Score == Topscore)
TopscoreCount++;
m_TopscoreCount++;

//calc if all players are in one Team
if(GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS && AllInOneTeam)
Expand All @@ -470,7 +471,7 @@ bool IGameController::DoWincheckMatch()
{
if(m_GameState == IGS_GAME_RUNNING)
m_TopTeam = TopTeam;
if(TopscoreCount == 1 || AllInOneTeam)
if(m_TopscoreCount == 1 || AllInOneTeam)
{
EndMatch();
return true;
Expand Down
6 changes: 6 additions & 0 deletions src/game/server/gamecontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class IGameController

//colorcatch winner
int m_TopTeam;
int m_StartWeapon;

int m_TopscoreCount;

public:
IGameController(class CGameContext *pGameServer);
Expand Down Expand Up @@ -217,6 +220,9 @@ class IGameController

int GetRealPlayerNum() const { return m_aTeamSize[TEAM_RED]+m_aTeamSize[TEAM_BLUE]; }
int GetStartTeam();

void SetStartWeapon(int W){ m_StartWeapon = W;}
int GetStartWeapon(){ return m_StartWeapon;}
};

#endif
1 change: 0 additions & 1 deletion src/game/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ MACRO_CONFIG_INT(SvVoteKick, sv_vote_kick, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_SERVER,
MACRO_CONFIG_INT(SvVoteKickMin, sv_vote_kick_min, 0, 0, MAX_CLIENTS, CFGFLAG_SAVE|CFGFLAG_SERVER, "Minimum number of players required to start a kick vote")
MACRO_CONFIG_INT(SvVoteKickBantime, sv_vote_kick_bantime, 5, 0, 1440, CFGFLAG_SAVE|CFGFLAG_SERVER, "The time to ban a player if kicked by vote. 0 makes it just use kick")

MACRO_CONFIG_INT(SvStartWeapon, sv_start_weapon, 4, 0, 4, CFGFLAG_SAVE|CFGFLAG_SERVER, "0: Hammer, 1: Gun, 2: Shotgun, 3: Grenade, 4: Laser")
MACRO_CONFIG_INT(SvAllowPickups, sv_allow_pickups, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_SERVER, "Spawn pickups")
MACRO_CONFIG_INT(SvAllowWeaponPickups, sv_allow_weapon_pickups, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_SERVER, "Spawn weapons")

Expand Down
2 changes: 1 addition & 1 deletion src/game/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
#define GAME_NETVERSION "0.7 802f1be60a05665f"
#define CLIENT_VERSION 0x0703
static const char GAME_RELEASE_VERSION[8] = "0.7.3.1";
#define CATCH_VERSION "1.0.7"
#define CATCH_VERSION "1.0.8"
#endif

0 comments on commit c3f3ff8

Please sign in to comment.