Commit c0ad717d authored by Mikleo's avatar Mikleo

fix scenariovote, add Temple koth scenario.

parent c4160af4
Pipeline #10184 passed with stages
in 18 seconds
......@@ -10,7 +10,7 @@
#include <SteamWorks>
#define PluginVersion "1.15"
#define PluginVersion "1.17"
float pVersion;
// note linearmap field is unstable
......@@ -28,6 +28,7 @@ int lastMinorEditTime = 0;
Handle ScenarioVoteTimer = INVALID_HANDLE;
Menu ScenarioVoteMenu = null;
int currentHammerID = BASEHAMMERID;
......@@ -260,11 +261,7 @@ public void OnAllPluginsLoaded()
public OnMapEnd()
{
if(ScenarioVoteTimer != INVALID_HANDLE)
{
KillTimer(ScenarioVoteTimer);
ScenarioVoteTimer = INVALID_HANDLE;
}
CancelScenarioVote();
// make sure baseswap is turned off for the next round.
ef_baseswap.IntValue = 0;
......@@ -392,8 +389,7 @@ public OnMapStart()
Funcs_OnMapStart();
ScenarioVoteMenu = null;
}
......@@ -465,12 +461,7 @@ public Action Timer_StartDefaultScenarioVote(Handle timer,int entity)
{
// make sure handle is empty so we dont attempt to kill a bad timer.
ScenarioVoteTimer = INVALID_HANDLE;
if(EU_GetWaitTime() < 20)
return Plugin_Handled;
if(EU_GetWaitTime() < ef_scenario_vote_min_timeleft.IntValue)
{
EU_SetWaitTime(ef_scenario_vote_min_timeleft.IntValue);
}
StartDefaultScenarioVote();
return Plugin_Handled;
......@@ -500,14 +491,22 @@ public bool StartScenarioVote(KeyValues kv)
return;
}
if(EU_GetWaitTime() < 20)
return;
if(EU_GetWaitTime() < ef_scenario_vote_min_timeleft.IntValue)
{
EU_SetWaitTime(ef_scenario_vote_min_timeleft.IntValue);
}
char path[128];
Menu menu = new Menu(Handle_VoteMenu);
menu.SetTitle("Vote For a Scenario\n");
menu.AddItem("", "Default \nThe Current Scenario");
ScenarioVoteMenu = new Menu(Handle_VoteMenu);
ScenarioVoteMenu.SetTitle("Vote For a Scenario\n");
ScenarioVoteMenu.AddItem("", "Default \nThe Current Scenario");
KeyValues kv_scenario;
......@@ -580,7 +579,7 @@ public bool StartScenarioVote(KeyValues kv)
Format(optionText,sizeof(optionText),"%s\n%s",optionText,displayBuffer);
}
Format(optionText,sizeof(optionText),"%s ",optionText);
menu.AddItem(nameBuffer, optionText);
ScenarioVoteMenu.AddItem(nameBuffer, optionText);
numOptions ++;
}
delete kv_scenario;
......@@ -589,14 +588,15 @@ public bool StartScenarioVote(KeyValues kv)
if(numOptions > 0)
{
menu.ExitButton = false;
menu.VoteResultCallback = Handle_VoteResults;
menu.DisplayVoteToAll(ef_scenario_vote_duration.IntValue);
ScenarioVoteMenu.ExitButton = false;
ScenarioVoteMenu.VoteResultCallback = Handle_VoteResults;
ScenarioVoteMenu.DisplayVoteToAll(ef_scenario_vote_duration.IntValue);
ScenarioVoteTimer = CreateTimer(ef_scenario_vote_duration.FloatValue - 5.0, Timer_VoteWarnTimer);
}
else
{
delete menu;
delete ScenarioVoteMenu;
ScenarioVoteMenu = null;
}
......@@ -615,6 +615,7 @@ public int Handle_VoteMenu(Menu menu, MenuAction action, int param1, int param2)
ScenarioVoteTimer = INVALID_HANDLE;
}
delete menu;
ScenarioVoteMenu = null;
}
}
......@@ -686,6 +687,28 @@ public void Handle_VoteResults(Menu menu, int num_votes, int num_clients, const
}
public bool IsInScenarioVote()
{
return ScenarioVoteMenu != null;
}
// returns true if there was an active vote which was cancelled
public bool CancelScenarioVote()
{
if(ScenarioVoteTimer != INVALID_HANDLE)
{
KillTimer(ScenarioVoteTimer);
ScenarioVoteTimer = INVALID_HANDLE;
}
if(ScenarioVoteMenu != null)
{
CancelVote();
ScenarioVoteMenu = null;
return true;
}
return false;
}
// make sure that valid refinery points are available. hack for now
public Action Timer_RunoffVote(Handle timer,Menu menu)
{
......@@ -3690,42 +3713,37 @@ public Action Command_Scenario_Var(int client, int args)
// maybe an option to specify later.
public Action Command_Scenario_Vote(int client, int args)
{
if(ScenarioVoteTimer != INVALID_HANDLE)
{
PrintToChat(client,"Scenario vote already begun");
return Plugin_Handled;
}
// just cancel the existing vote.
CancelScenarioVote();
if(EU_GetWaitTime() > ef_scenario_vote_min_timeleft.IntValue)
if(args == 0)
{
if(args == 0)
{
StartDefaultScenarioVote();
}
else
{
KeyValues kv = new KeyValues("VoteData");
char arg[32];
for(int i = 0; i <= GetCmdArgs(); i++)
{
GetCmdArg(i, arg, sizeof(arg));
kv.JumpToKey(arg,true);
kv.GoBack();
}
StartScenarioVote(kv);
delete kv;
}
char clientName[128];
GetClientName(client,clientName,sizeof(clientName));
PrintToChatAll("%s started a scenario vote",clientName);
StartDefaultScenarioVote();
}
else
{
PrintToChat(client, "Too late to start scenario vote");
KeyValues kv = new KeyValues("VoteData");
char arg[32];
for(int i = 0; i <= GetCmdArgs(); i++)
{
GetCmdArg(i, arg, sizeof(arg));
kv.JumpToKey(arg,true);
kv.GoBack();
}
StartScenarioVote(kv);
delete kv;
}
char clientName[128];
GetClientName(client,clientName,sizeof(clientName));
PrintToChatAll("%s started a scenario vote",clientName);
return Plugin_Handled;
}
......@@ -3920,15 +3938,9 @@ public Action Command_Load_Scenario(int client, int args)
}
if(LoadScenario(client,arg1))
{
if(ScenarioVoteTimer != INVALID_HANDLE)
if(CancelScenarioVote())
{
KillTimer(ScenarioVoteTimer);
ScenarioVoteTimer = INVALID_HANDLE;
if(IsVoteInProgress())
{
PrintToChatAll("Scenario already loaded, vote canceled");
CancelVote();
}
PrintToChatAll("Cancelling Scenario Vote...");
}
}
return Plugin_Handled;
......
This diff is collapsed.
......@@ -4,7 +4,7 @@
{
"Version"
{
"Latest" "1.15"
"Latest" "1.17"
}
}
......@@ -31,6 +31,9 @@
"Plugin" "Path_Mod/scenarios/emp_duststorm/mik_kingofthehill.snr"
"Plugin" "Path_Mod/scenarios/emp_duststorm/votelist_base.txt"
"Plugin" "Path_Mod/scenarios/emp_temple/mik_kingofthehill.snr"
"Plugin" "Path_Mod/scenarios/emp_palmbay/mik_boats.snr"
"Plugin" "Path_Mod/scenarios/emp_palmbay/votelist_base.txt"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment