1.1 --- a/plugins/mapchooser.sp Fri Nov 19 17:37:26 2010 +1300
1.2 +++ b/plugins/mapchooser.sp Fri Nov 19 17:39:53 2010 +1300
1.3 @@ -91,6 +91,7 @@
1.4 new MapChange:g_ChangeTime;
1.5
1.6 new Handle:g_NominationsResetForward = INVALID_HANDLE;
1.7 +new Handle:g_MapVoteStartedForward = INVALID_HANDLE;
1.8
1.9 /* Upper bound of how many team there could be */
1.10 #define MAXTEAMS 10
1.11 @@ -157,6 +158,7 @@
1.12 }
1.13
1.14 g_NominationsResetForward = CreateGlobalForward("OnNominationRemoved", ET_Ignore, Param_String, Param_Cell);
1.15 + g_MapVoteStartedForward = CreateGlobalForward("OnMapVoteStarted", ET_Ignore);
1.16 }
1.17
1.18 public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
1.19 @@ -164,10 +166,13 @@
1.20 RegPluginLibrary("mapchooser");
1.21
1.22 CreateNative("NominateMap", Native_NominateMap);
1.23 + CreateNative("RemoveNominationByMap", Native_RemoveNominationByMap);
1.24 + CreateNative("RemoveNominationByOwner", Native_RemoveNominationByOwner);
1.25 CreateNative("InitiateMapChooserVote", Native_InitiateVote);
1.26 CreateNative("CanMapChooserStartVote", Native_CanVoteStart);
1.27 CreateNative("HasEndOfMapVoteFinished", Native_CheckVoteDone);
1.28 CreateNative("GetExcludeMapList", Native_GetExcludeMapList);
1.29 + CreateNative("GetNominatedMapList", Native_GetNominatedMapList);
1.30 CreateNative("EndOfMapVoteEnabled", Native_EndOfMapVoteEnabled);
1.31
1.32 return APLRes_Success;
1.33 @@ -531,6 +536,10 @@
1.34 g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
1.35 SetMenuTitle(g_VoteMenu, "Vote Nextmap");
1.36 SetVoteResultCallback(g_VoteMenu, Handler_MapVoteFinished);
1.37 +
1.38 + /* Call OnMapVoteStarted() Forward */
1.39 + Call_StartForward(g_MapVoteStartedForward);
1.40 + Call_Finish();
1.41
1.42 /**
1.43 * TODO: Make a proper decision on when to clear the nominations list.
1.44 @@ -961,6 +970,78 @@
1.45 return _:InternalNominateMap(map, GetNativeCell(2), GetNativeCell(3));
1.46 }
1.47
1.48 +bool:InternalRemoveNominationByMap(String:map[])
1.49 +{
1.50 + for (new i = 0; i < GetArraySize(g_NominateList); i++)
1.51 + {
1.52 + new String:oldmap[33];
1.53 + GetArrayString(g_NominateList, i, oldmap, sizeof(oldmap));
1.54 +
1.55 + if(strcmp(map, oldmap, false) == 0)
1.56 + {
1.57 + Call_StartForward(g_NominationsResetForward);
1.58 + Call_PushString(oldmap);
1.59 + Call_PushCell(GetArrayCell(g_NominateOwners, i));
1.60 + Call_Finish();
1.61 +
1.62 + RemoveFromArray(g_NominateList, i);
1.63 + RemoveFromArray(g_NominateOwners, i);
1.64 + g_NominateCount--;
1.65 +
1.66 + return true;
1.67 + }
1.68 + }
1.69 +
1.70 + return false;
1.71 +}
1.72 +
1.73 +/* native bool:RemoveNominationByMap(const String:map[]); */
1.74 +public Native_RemoveNominationByMap(Handle:plugin, numParams)
1.75 +{
1.76 + new len;
1.77 + GetNativeStringLength(1, len);
1.78 +
1.79 + if (len <= 0)
1.80 + {
1.81 + return false;
1.82 + }
1.83 +
1.84 + new String:map[len+1];
1.85 + GetNativeString(1, map, len+1);
1.86 +
1.87 + return _:InternalRemoveNominationByMap(map);
1.88 +}
1.89 +
1.90 +bool:InternalRemoveNominationByOwner(owner)
1.91 +{
1.92 + new index;
1.93 +
1.94 + if (owner && ((index = FindValueInArray(g_NominateOwners, owner)) != -1))
1.95 + {
1.96 + new String:oldmap[33];
1.97 + GetArrayString(g_NominateList, index, oldmap, sizeof(oldmap));
1.98 +
1.99 + Call_StartForward(g_NominationsResetForward);
1.100 + Call_PushString(oldmap);
1.101 + Call_PushCell(owner);
1.102 + Call_Finish();
1.103 +
1.104 + RemoveFromArray(g_NominateList, index);
1.105 + RemoveFromArray(g_NominateOwners, index);
1.106 + g_NominateCount--;
1.107 +
1.108 + return true;
1.109 + }
1.110 +
1.111 + return false;
1.112 +}
1.113 +
1.114 +/* native bool:RemoveNominationByOwner(owner); */
1.115 +public Native_RemoveNominationByOwner(Handle:plugin, numParams)
1.116 +{
1.117 + return _:InternalRemoveNominationByOwner(GetNativeCell(1));
1.118 +}
1.119 +
1.120 /* native InitiateMapChooserVote(); */
1.121 public Native_InitiateVote(Handle:plugin, numParams)
1.122 {
1.123 @@ -994,8 +1075,6 @@
1.124 {
1.125 return;
1.126 }
1.127 -
1.128 -
1.129 new size = GetArraySize(g_OldMapList);
1.130 decl String:map[33];
1.131
1.132 @@ -1007,3 +1086,29 @@
1.133
1.134 return;
1.135 }
1.136 +
1.137 +public Native_GetNominatedMapList(Handle:plugin, numParams)
1.138 +{
1.139 + new Handle:maparray = Handle:GetNativeCell(1);
1.140 + new Handle:ownerarray = Handle:GetNativeCell(2);
1.141 +
1.142 + if (maparray == INVALID_HANDLE)
1.143 + return;
1.144 +
1.145 + decl String:map[33];
1.146 +
1.147 + for (new i = 0; i < GetArraySize(g_NominateList); i++)
1.148 + {
1.149 + GetArrayString(g_NominateList, i, map, sizeof(map));
1.150 + PushArrayString(maparray, map);
1.151 +
1.152 + // If the optional parameter for an owner list was passed, then we need to fill that out as well
1.153 + if(ownerarray != INVALID_HANDLE)
1.154 + {
1.155 + new index = GetArrayCell(g_NominateOwners, i);
1.156 + PushArrayCell(ownerarray, index);
1.157 + }
1.158 + }
1.159 +
1.160 + return;
1.161 +}
1.162 \ No newline at end of file