Skip to content

Commit

Permalink
Merged release/0.5.6 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
thesupremecommander committed Dec 23, 2016
2 parents 770b3d3 + 40f32d6 commit 93a0f6e
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 76 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -15,6 +15,10 @@ Installation
Changelog
---------

### 0.5.6
* general
* update for interface changes

### 0.5.5
* general
* update gamedata
Expand Down
2 changes: 1 addition & 1 deletion extension/extension.cpp
Expand Up @@ -80,7 +80,7 @@ void CompCtrl::SDK_OnAllLoaded() {
g_BetweenRoundsEndForward = forwards->CreateForward("CompCtrl_OnBetweenRoundsEnd", ET_Hook, 0, NULL);
g_BetweenRoundsThinkForward = forwards->CreateForward("CompCtrl_OnBetweenRoundsThink", ET_Hook, 0, NULL);
g_RestartTournamentForward = forwards->CreateForward("CompCtrl_OnRestartTournament", ET_Hook, 0, NULL);
g_CheckWinLimitForward = forwards->CreateForward("CompCtrl_OnCheckWinLimit", ET_Hook, 2, NULL, Param_CellByRef, Param_CellByRef);
g_CheckWinLimitForward = forwards->CreateForward("CompCtrl_OnCheckWinLimit", ET_Hook, 3, NULL, Param_CellByRef, Param_CellByRef, Param_CellByRef);
g_RespawnForward = forwards->CreateForward("CompCtrl_OnRespawn", ET_Hook, 1, NULL, Param_Cell);
g_ResetTeamScoresForward = forwards->CreateForward("CompCtrl_OnResetTeamScores", ET_Hook, 1, NULL, Param_Cell);

Expand Down
11 changes: 8 additions & 3 deletions extension/gamerules.cpp
Expand Up @@ -10,7 +10,7 @@ SH_DECL_MANUALHOOK0_void(CTFGameRules_BetweenRounds_Start, 0, 0, 0);
SH_DECL_MANUALHOOK0_void(CTFGameRules_BetweenRounds_End, 0, 0, 0);
SH_DECL_MANUALHOOK0_void(CTFGameRules_BetweenRounds_Think, 0, 0, 0);
SH_DECL_MANUALHOOK0_void(CTFGameRules_RestartTournament, 0, 0, 0);
SH_DECL_MANUALHOOK1(CTFGameRules_CheckWinLimit, 0, 0, 0, bool, bool);
SH_DECL_MANUALHOOK2(CTFGameRules_CheckWinLimit, 0, 0, 0, bool, bool, int);

void GameRulesManager::Enable() {
if (!m_hooksSetup) {
Expand Down Expand Up @@ -245,11 +245,13 @@ void GameRulesManager::Hook_CTFGameRules_RestartTournament() {
}
}

bool GameRulesManager::Hook_CTFGameRules_CheckWinLimit(bool bAllowEnd) {
bool GameRulesManager::Hook_CTFGameRules_CheckWinLimit(bool bAllowEnd, int iIncrementScores) {
cell_t allowEndCell = bAllowEnd;
cell_t returnValue = SH_MCALL(g_pSDKTools->GetGameRules(), CTFGameRules_CheckWinLimit)(false);
cell_t incrementScoresCell = iIncrementScores;
cell_t returnValue = SH_MCALL(g_pSDKTools->GetGameRules(), CTFGameRules_CheckWinLimit)(false, iIncrementScores);

g_CheckWinLimitForward->PushCellByRef(&allowEndCell);
g_CheckWinLimitForward->PushCellByRef(&incrementScoresCell);
g_CheckWinLimitForward->PushCellByRef(&returnValue);

cell_t result = 0;
Expand All @@ -259,6 +261,9 @@ bool GameRulesManager::Hook_CTFGameRules_CheckWinLimit(bool bAllowEnd) {
if (result > Pl_Continue) {
RETURN_META_VALUE(MRES_SUPERCEDE, (bool)returnValue);
}
else if (result == Pl_Changed) {
RETURN_META_VALUE_MNEWPARAMS(MRES_HANDLED, (bool)returnValue, CTFGameRules_CheckWinLimit, ((bool)allowEndCell, (int)incrementScoresCell));
}
else {
RETURN_META_VALUE(MRES_IGNORED, false);
}
Expand Down
2 changes: 1 addition & 1 deletion extension/gamerules.h
Expand Up @@ -26,7 +26,7 @@ class GameRulesManager
void Hook_CTFGameRules_BetweenRounds_End();
void Hook_CTFGameRules_BetweenRounds_Think();
void Hook_CTFGameRules_RestartTournament();
bool Hook_CTFGameRules_CheckWinLimit(bool bAllowEnd = true);
bool Hook_CTFGameRules_CheckWinLimit(bool bAllowEnd = true, int iIncrementScores = 0);

private:
bool m_hooksSetup;
Expand Down
28 changes: 14 additions & 14 deletions gamedata/compctrl.txt
Expand Up @@ -20,39 +20,39 @@
"linux" "165"
}
"CTFGameRules::BetweenRounds_Start"
{
"windows" "199"
"linux" "201"
}
"CTFGameRules::BetweenRounds_End"
{
"windows" "200"
"linux" "202"
}
"CTFGameRules::BetweenRounds_Think"
"CTFGameRules::BetweenRounds_End"
{
"windows" "201"
"linux" "203"
}
"CTFGameRules::BetweenRounds_Think"
{
"windows" "202"
"linux" "204"
}
"CTFGameRules::RestartTournament"
{
"windows" "206"
"linux" "208"
"windows" "207"
"linux" "209"
}
"CTFGameRules::CheckWinLimit"
{
"windows" "218"
"linux" "220"
"windows" "219"
"linux" "221"
}
"CTFGameRules::RoundRespawn"
{
"windows" "223"
"linux" "225"
"windows" "224"
"linux" "226"
}
"CTFGameRules::CleanUpMap"
{
"windows" "224"
"linux" "226"
"windows" "225"
"linux" "227"
}
"CTFPlayer::ForceRespawn"
{
Expand Down
6 changes: 3 additions & 3 deletions plugins/compctrl-matches.sp
Expand Up @@ -437,16 +437,16 @@ public Action CompCtrl_OnRestartTournament() {
return Plugin_Continue;
}

public Action CompCtrl_OnCheckWinLimit(bool &allowEnd, bool &returnValue) {
public Action CompCtrl_OnCheckWinLimit(bool &allowEnd, int &incrementScores, bool &returnValue) {
if (g_InMatch) {
GetCurrentRoundConfig();

if (g_MatchConfig.GetNum("manual-scoring", 0)) {
EndCondition endCondition;
TFTeam cause;

returnValue = CheckEndConditions(GetScore(TFTeam_Red), GetScore(TFTeam_Blue), endCondition, cause);
return Plugin_Changed;
returnValue = CheckEndConditions(GetScore(TFTeam_Red) + incrementScores, GetScore(TFTeam_Blue) + incrementScores, endCondition, cause);
return Plugin_Handled;
}
}

Expand Down
108 changes: 55 additions & 53 deletions plugins/include/compctrl_extension.inc
Expand Up @@ -38,37 +38,37 @@ enum StalemateReason {
};

/**
* @brief Calls SetWinningTeam in CTFGameRules.
*
* @param team The team that has won.
* @param reason The reason why the team is winning.
* @param forceMapReset Whether to reset the map (usually after a full round is completed).
* @param switchTeams Whether to switch teams.
* @param dontAddScore Whether to not score this round.
* @param final Whether this is the final round.
* @brief Calls SetWinningTeam in CTFGameRules.
*
* @param team The team that has won.
* @param reason The reason why the team is winning.
* @param forceMapReset Whether to reset the map (usually after a full round is completed).
* @param switchTeams Whether to switch teams.
* @param dontAddScore Whether to not score this round.
* @param final Whether this is the final round.
* @noreturn
*/
native void CompCtrl_SetWinningTeam(TFTeam team, WinReason reason, bool forceMapReset, bool switchTeams, bool dontAddScore, bool final);

/**
* @brief Calls SetStalemate in CTFGameRules.
* @brief Calls SetStalemate in CTFGameRules.
*
* @param reason The reason why the team is winning.
* @param forceMapReset Whether to reset the map (usually after a full round is completed).
* @param switchTeams Whether to switch teams.
* @param reason The reason why the team is winning.
* @param forceMapReset Whether to reset the map (usually after a full round is completed).
* @param switchTeams Whether to switch teams.
* @noreturn
*/
native void CompCtrl_SetStalemate(StalemateReason reason, bool forceMapReset, bool switchTeams);

/**
* @brief Calls HandleSwitchTeams in CTFGameRules.
* @brief Calls HandleSwitchTeams in CTFGameRules.
*
* @noreturn
*/
native void CompCtrl_SwitchTeams();

/*
* @brief Calls CleanUpMap in CTFGameRules.
* @brief Calls CleanUpMap in CTFGameRules.
*
* @noreturn
*/
Expand All @@ -87,8 +87,9 @@ stock void CompCtrl_CleanUpMap() {
}

/*
* @brief Calls State_Transition in CTFGameRules.
* @brief Calls State_Transition in CTFGameRules.
*
* @param state The state to transition to.
* @noreturn
*/
stock void CompCtrl_StateTransition(RoundState state) {
Expand All @@ -107,101 +108,102 @@ stock void CompCtrl_StateTransition(RoundState state) {
}

/**
* @brief When a SourceTV demo has started to record.
* @brief When a SourceTV demo has started to record.
*
* @param file The path to the demo file.
* @param file The path to the demo file.
* @noreturn
*/
forward void CompCtrl_OnStartRecording(const char[] file);

/**
* @brief When a SourceTV demo has finished recording.
* @brief When a SourceTV demo has finished recording.
*
* @param file The path to the demo file.
* @param file The path to the demo file.
* @noreturn
*/
forward void CompCtrl_OnStopRecording(const char[] file);

/**
* @brief When SetWinningTeam in CTFGameRules is called by the game.
* @brief When SetWinningTeam in CTFGameRules is called by the game.
*
* @param team The team that has won.
* @param reason The reason why the team is winning.
* @param forceMapReset Whether to reset the map (usually after a full round is completed).
* @param switchTeams Whether to switch teams.
* @param dontAddScore Whether to not score this round.
* @param final Whether this is the final round.
* @return Plugin_Continue to continue with original values, Plugin_Changed to use new values, Plugin_Handled or Plugin_Stop to stop the game call.
* @param team The team that has won.
* @param reason The reason why the team is winning.
* @param forceMapReset Whether to reset the map (usually after a full round is completed).
* @param switchTeams Whether to switch teams.
* @param dontAddScore Whether to not score this round.
* @param final Whether this is the final round.
* @return Plugin_Continue to continue with original values, Plugin_Changed to use new values, Plugin_Handled or Plugin_Stop to stop the game call.
*/
forward Action CompCtrl_OnSetWinningTeam(TFTeam &team, WinReason &reason, bool &forceMapReset, bool &switchTeams, bool &dontAddScore, bool &final);

/**
* @brief When SetStalemate in CTFGameRules is called by the game.
* @brief When SetStalemate in CTFGameRules is called by the game.
*
* @param reason The reason why the team is winning.
* @param forceMapReset Whether to reset the map (usually after a full round is completed).
* @param switchTeams Whether to switch teams.
* @return Plugin_Continue to continue with original values, Plugin_Changed to use new values, Plugin_Handled or Plugin_Stop to stop the game call.
* @param reason The reason why the team is winning.
* @param forceMapReset Whether to reset the map (usually after a full round is completed).
* @param switchTeams Whether to switch teams.
* @return Plugin_Continue to continue with original values, Plugin_Changed to use new values, Plugin_Handled or Plugin_Stop to stop the game call.
*/
forward Action CompCtrl_OnSetStalemate(StalemateReason &reason, bool &forceMapReset, bool &switchTeams);

/**
* @brief When HandleSwitchTeams in CTFGameRules is called by the game.
* @brief When HandleSwitchTeams in CTFGameRules is called by the game.
*
* @return Plugin_Continue to allow the team switch, Plugin_Changed or above to prevent the team switch.
* @return Plugin_Continue to allow the team switch, Plugin_Changed or above to prevent the team switch.
*/
forward Action CompCtrl_OnSwitchTeams();

/**
* @brief When BetweenRounds_Start in CTFGameRules is called by the game.
* @brief When BetweenRounds_Start in CTFGameRules is called by the game.
*
* @return Plugin_Continue to allow the function to execute, Plugin_Changed or above to prevent the function from executing.
* @return Plugin_Continue to allow the function to execute, Plugin_Changed or above to prevent the function from executing.
*/
forward Action CompCtrl_OnBetweenRoundsStart();

/**
* @brief When BetweenRounds_End in CTFGameRules is called by the game.
* @brief When BetweenRounds_End in CTFGameRules is called by the game.
*
* @return Plugin_Continue to allow the function to execute, Plugin_Changed or above to prevent the function from executing.
* @return Plugin_Continue to allow the function to execute, Plugin_Changed or above to prevent the function from executing.
*/
forward Action CompCtrl_OnBetweenRoundsEnd();

/**
* @brief When BetweenRounds_Think in CTFGameRules is called by the game.
* @brief When BetweenRounds_Think in CTFGameRules is called by the game.
*
* @return Plugin_Continue to allow the function to execute, Plugin_Changed or above to prevent the function from executing.
* @return Plugin_Continue to allow the function to execute, Plugin_Changed or above to prevent the function from executing.
*/
forward Action CompCtrl_OnBetweenRoundsThink();

/**
* @brief When RestartTournament in CTFGameRules is called by the game.
* @brief When RestartTournament in CTFGameRules is called by the game.
*
* @return Plugin_Continue to allow the restart, Plugin_Changed or above to prevent the restart.
* @return Plugin_Continue to allow the restart, Plugin_Changed or above to prevent the restart.
*/
forward Action CompCtrl_OnRestartTournament();

/**
* @brief When CheckWinLimit in CTFGameRules is called by the game.
* @brief When CheckWinLimit in CTFGameRules is called by the game.
*
* @param allowEnd Whether to allow the map to end upon checking this.
* @param returnValue The return value for the function (true for win limit reached, false for not).
* @return Plugin_Continue to return the original value, Plugin_Changed or above to use the new value.
* @param allowEnd Whether to allow the map to end upon checking this.
* @param incrementScores How much to increment the scores by when checking if a win limit was reached.
* @param returnValue The return value for the function (true for win limit reached, false for not).
* @return Plugin_Continue to return the original value, Plugin_Changed or above to use the new value.
*/
forward Action CompCtrl_OnCheckWinLimit(bool &allowEnd, bool &returnValue);
forward Action CompCtrl_OnCheckWinLimit(bool &allowEnd, int &incrementScores, bool &returnValue);

/**
* @brief When ForceRespawn in CTFPlayer is called by the game.
* @brief When ForceRespawn in CTFPlayer is called by the game.
*
* @param client The player that is being respawned.
* @return Plugin_Continue to allow the respawn, Plugin_Changed or above to prevent the respawn.
* @param client The player that is being respawned.
* @return Plugin_Continue to allow the respawn, Plugin_Changed or above to prevent the respawn.
*/
forward Action CompCtrl_OnRespawn(int client);

/**
* @brief When ResetScores in CTFTeam is called by the game.
* @brief When ResetScores in CTFTeam is called by the game.
*
* @param team The team that is having its scores reset.
* @return Plugin_Continue to allow the reset, Plugin_Changed or above to prevent the reset.
* @param team The team that is having its scores reset.
* @return Plugin_Continue to allow the reset, Plugin_Changed or above to prevent the reset.
*/
forward Action CompCtrl_OnResetTeamScores(TFTeam team);

Expand Down
2 changes: 1 addition & 1 deletion product.version
@@ -1 +1 @@
0.5.5
0.5.6

0 comments on commit 93a0f6e

Please sign in to comment.