MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / EndVoting

Method EndVoting

core/MenuVoting.cpp:399–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399void VoteMenuHandler::EndVoting()
400{
401 /* Set when the next delay ends. We ignore cancellation because a menu
402 * was, at one point, displayed, which is all that counts. However, we
403 * do re-calculate the time just in case the menu had no time limit.
404 */
405 float fVoteDelay = sm_vote_delay.GetFloat();
406 if (fVoteDelay < 1.0)
407 {
408 g_next_vote = 0.0;
409 }
410 else
411 {
412 g_next_vote = gpGlobals->curtime + fVoteDelay;
413 }
414
415 if (m_displayTimer)
416 {
417 g_Timers.KillTimer(m_displayTimer);
418 }
419
420 if (m_bCancelled)
421 {
422 /* If we were cancelled, don't bother tabulating anything.
423 * Reset just in case someone tries to redraw, which means
424 * we need to save our states.
425 */
426 IBaseMenu *menu = m_pCurMenu;
427 IMenuHandler *handler = m_pHandler;
428 InternalReset();
429 handler->OnMenuVoteCancel(menu, VoteCancel_Generic);
430 handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
431 return;
432 }
433
434 menu_vote_result_t vote;
435 menu_vote_result_t::menu_client_vote_t client_vote[256];
436 menu_vote_result_t::menu_item_vote_t item_vote[256];
437
438 memset(&vote, 0, sizeof(vote));
439
440 /* Build the item list */
441 for (unsigned int i=0; i<m_Items; i++)
442 {
443 if (m_Votes[i] > 0)
444 {
445 item_vote[vote.num_items].count = m_Votes[i];
446 item_vote[vote.num_items].item = i;
447 vote.num_votes += m_Votes[i];
448 vote.num_items++;
449 }
450 }
451 vote.item_list = item_vote;
452
453 if (!vote.num_votes)
454 {
455 IBaseMenu *menu = m_pCurMenu;
456 IMenuHandler *handler = m_pHandler;

Callers

nothing calls this directly

Calls 5

KillTimerMethod · 0.80
GetFloatMethod · 0.45
OnMenuVoteCancelMethod · 0.45
OnMenuEndMethod · 0.45
OnMenuVoteResultsMethod · 0.45

Tested by

no test coverage detected