Advertisement
hoosier18

vote system

Sep 29th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 38.91 KB | None | 0 0
  1. class avaVoteSystem extends Info;
  2.    
  3.  
  4. var float   VoteTime;
  5.  
  6. enum EVoteSubjectType
  7. {
  8.     VOTESUBJECT_KickPlayer,
  9. };
  10.  
  11. struct VoteInfo
  12. {
  13.     var avaPlayerReplicationInfo        proposer;       // 발의자의 PRI 이다.
  14.     var avaPlayerReplicationInfo        target;         // 대상자의 PRI 이다.
  15.     var int                             targetID;       // 나간 사람에 대해서도 Vote 를 진행 해야만 한다....
  16.     var int                             proposerID;     //
  17.     var bool                            bVoting;        // treu 이면 Vote 가 진행중이다...
  18.     var float                           LeftTime;       // Vote 의 남은 시간
  19.     var EVoteSubjectType                Type;           // 현재 진행되고 있는 Vote 의 Type 이다.
  20.     var int                             Subject;        // 부차 항목
  21.     var array<PlayerReplicationInfo>    Voters;         // 입후보 당시의 유권자들
  22.     var array<PlayerReplicationInfo>    Accept;         // 찬성한 사람들
  23.     var array<PlayerReplicationInfo>    Deny;           // 반대한 사람들
  24. };
  25.  
  26. var VoteInfo    TeamVoteInfo[2];
  27.  
  28. function bool StartVote(EVoteSubjectType Subject,avaPlayerController proposer, avaPlayerReplicationInfo target, int nSubject )
  29. {
  30.     local int                   proposerTeam;
  31.     local avaPlayerController   avaPC;
  32.     local int                   i;
  33.    
  34.     proposerTeam = proposer.GetTeamNum();
  35.  
  36.     // TeamGame 인 경우에 발의자의 Team 이 Valid 하지 않음...
  37.     if ( WorldInfo.Game.bTeamGame )
  38.     {
  39.         proposerTeam = proposer.GetTeamNum();
  40.         if ( proposerTeam < 0 || proposerTeam > 1 )
  41.             return true;
  42.     }
  43.     else
  44.     {
  45.         proposerTeam = 0;
  46.     }
  47.  
  48.     if ( TeamVoteInfo[proposerTeam].bVoting == true )  
  49.         return false;   // 발의자의 Team이 현재 Voting 을 진행중임
  50.  
  51.     TeamVoteInfo[proposerTeam].proposer     = avaPlayerReplicationInfo( proposer.PlayerReplicationInfo );
  52.     TeamVoteInfo[proposerTeam].target       = target;
  53.     TeamVoteInfo[proposerTeam].proposerID   = avaPlayerReplicationInfo( proposer.PlayerReplicationInfo ).AccountID;
  54.     TeamVoteInfo[proposerTeam].targetID     = target.AccountID;
  55.     TeamVoteInfo[proposerTeam].bVoting      = true;
  56.     TeamVoteInfo[proposerTeam].LeftTime     = VoteTime;
  57.     TeamVoteInfo[proposerTeam].Type         = Subject;
  58.     TeamVoteInfo[proposerTeam].Subject      = nSubject;
  59.  
  60.     TeamVoteInfo[proposerTeam].Voters.length = 0;
  61.     TeamVoteInfo[proposerTeam].Accept.length = 0;
  62.     TeamVoteInfo[proposerTeam].Deny.length = 0;
  63.  
  64.     foreach WorldInfo.AllControllers( class'avaPlayerController', avaPC )
  65.     {
  66.         // TeamGame 인 경우에 발의자와 팀이 같지 않다면 무시한다.
  67.         if ( WorldInfo.Game.bTeamGame && avaPC.GetTeamNum() != proposerTeam )
  68.             continue;
  69.  
  70.         // Spectator 로 들어온 경우에는 투표에 참여할 수 없다.
  71.         if ( avaPC.PlayerReplicationInfo.bOnlySpectator == true )
  72.             continue;
  73.        
  74.         if ( avaPC.PlayerReplicationInfo == target )   
  75.             continue;   // 투표 대상자는 유권자에서 제외한다..
  76.         i = TeamVoteInfo[proposerTeam].Voters.length;
  77.         TeamVoteInfo[proposerTeam].Voters[i] = avaPC.PlayerReplicationInfo;
  78.     }
  79.  
  80.     if ( proposerTeam == 0 )    SetTimer( VoteTime, false, 'VoteTimeOver_EU' );
  81.     else                        SetTimer( VoteTime, false, 'VoteTimeOver_NRF' );
  82.  
  83.     // 투표 시작을 유권자에게 알린다....
  84.     ReportStartVote( TeamVoteInfo[proposerTeam] );
  85.  
  86.     // 발의자는 찬성으로 시작한다...
  87.     PlayerVote( proposer, true );
  88.     return true;
  89. }
  90.  
  91. function VoteTimeOver_EU()
  92. {
  93.     CheckVoteOver( 0, true );
  94. }
  95.  
  96. function VoteTimeOver_NRF()
  97. {
  98.     CheckVoteOver( 1, true );
  99. }
  100.  
  101. function bool IsAvailableVote( int TeamIdx, avaPlayerController voter )
  102. {
  103.     local int   i;
  104.  
  105.     // 투표자의 Team 이 Valid 한지 Check 한다. TeamGame 인 경우에만 Check 하도록 한다...
  106.     if ( WorldInfo.Game.bTeamGame && TeamIdx < 0 || TeamIdx > 1 )                  
  107.         return false;  
  108.  
  109.     if ( TeamVoteInfo[TeamIdx].bVoting == false )       return false;   // 투표가 진행중이 아님
  110.     for ( i = 0 ; i < TeamVoteInfo[TeamIdx].Accept.length ; ++ i )      // 투표자가 이미 찬성했는지 Check 한다.
  111.     {
  112.         if ( TeamVoteInfo[TeamIdx].Accept[i] == voter.PlayerReplicationInfo )   return false;
  113.     }
  114.     for ( i = 0 ; i < TeamVoteInfo[TeamIdx].Deny.length ; ++ i )        // 투표자가 이미 반대했는지 Check 한다.
  115.     {
  116.         if ( TeamVoteInfo[TeamIdx].Deny[i] == voter.PlayerReplicationInfo ) return false;
  117.     }
  118.     for ( i = 0 ; i < TeamVoteInfo[TeamIdx].Voters.length ; ++ i )      // 투표자가 유권자중에 있는지 Check 한다.
  119.     {
  120.         if ( TeamVoteInfo[TeamIdx].Voters[i] == voter.PlayerReplicationInfo )
  121.             return true;
  122.     }
  123.     return false;
  124. }
  125.  
  126. // 투표를 받는다....
  127. function PlayerVote( avaPlayerController voter, bool bResult )
  128. {
  129.     // 투표가 가능한지 Check 한다...
  130.     local int   TeamIdx;
  131.     local int   i;
  132.  
  133.     if ( WorldInfo.Game.bTeamGame )
  134.         TeamIdx = voter.GetTeamNum();
  135.     else
  136.         TeamIdx = 0;
  137.  
  138.     if ( IsAvailableVote( TeamIdx, voter ) == false )   return;
  139.     if ( bResult == true )  TeamVoteInfo[TeamIdx].Accept[TeamVoteInfo[TeamIdx].Accept.length]   = avaPlayerReplicationInfo( voter.PlayerReplicationInfo );
  140.     else                    TeamVoteInfo[TeamIdx].Deny[TeamVoteInfo[TeamIdx].Deny.length]       = avaPlayerReplicationInfo( voter.PlayerReplicationInfo );
  141.  
  142.     `log( "Playervote" @voter @bResult @TeamVoteInfo[TeamIdx].Voters.length @TeamVoteInfo[TeamIdx].Accept.length @TeamVoteInfo[TeamIdx].Deny.length );
  143.  
  144.     for ( i = 0 ; i < TeamVoteInfo[TeamIdx].Voters.length ; ++ i )
  145.     {
  146.         avaPlayerController( TeamVoteInfo[TeamIdx].Voters[i].Owner ).Client_VoteAccepted( avaPlayerReplicationInfo( voter.PlayerReplicationInfo ), bResult );
  147.     }
  148.     // 투표가 종료 되었는지 Check 한다.
  149.     CheckVoteOver( TeamIdx );
  150. }
  151.  
  152. function CheckVoteOver( int TeamIdx, optional bool bTimeOver = false )
  153. {
  154.     local int VotersCnt, AcceptCnt, DenyCnt;
  155.     if ( TeamVoteInfo[TeamIdx].bVoting == false )   return;
  156.     VotersCnt = TeamVoteInfo[TeamIdx].Voters.length;
  157.     AcceptCnt = TeamVoteInfo[TeamIdx].Accept.length;
  158.     DenyCnt   = TeamVoteInfo[TeamIdx].Deny.length;
  159.     if ( bTimeOver == true )
  160.     {
  161.         // 찬성이 유권자의 50% 이상이므로 가결됨
  162.         if ( VotersCnt > 0 && AcceptCnt == VotersCnt )      ReportVoteOver( TeamIdx, true );
  163.         else                                                ReportVoteOver( TeamIdx, false );                              
  164.     }
  165.     else
  166.     {
  167.         // 찬성이나 반대가 과반수를 넘으면 Vote 를 종료한다....
  168.         if ( VotersCnt > 0 && AcceptCnt == VotersCnt )      ReportVoteOver( TeamIdx, true );   
  169.         else if ( DenyCnt > 0 )                             ReportVoteOver( TeamIdx, false );
  170.     }
  171. }
  172.  
  173. // 중간에 나간 사람은 반대표를 던진 것으로 간주한다...
  174. function DisconnectEvent( Controller Exiting )
  175. {
  176.     PlayerVote( avaPlayerController( Exiting ), false );   
  177. }
  178.  
  179. // Vote 가 시작되었음을 유권자들에게 알려준다...
  180. function ReportStartVote( VoteInfo info )
  181. {
  182.     local int i;
  183.     for ( i = 0 ; i < info.Voters.length ; ++ i )
  184.     {
  185.         avaPlayerController( info.Voters[i].Owner ).Client_StartVote( info.Type, info.proposer, info.target, info.LeftTime, info.Subject );
  186.     }
  187. }
  188.  
  189. function ReportVoteOver( int TeamIdx, bool bResult )
  190. {
  191.     local int           i;
  192.     local array< int >  VoterList;
  193.     for ( i = 0 ; i < TeamVoteInfo[TeamIdx].Voters.length ; ++ i )
  194.     {
  195.         avaPlayerController( TeamVoteInfo[TeamIdx].Voters[i].Owner ).Client_EndVote( bResult );
  196.     }
  197.  
  198.     if ( bResult )
  199.     {
  200.         for ( i = 0 ; i < TeamVoteInfo[TeamIdx].Accept.length ; ++ i )
  201.         {
  202.             if ( TeamVoteInfo[TeamIdx].proposerID != avaPlayerReplicationInfo( TeamVoteInfo[TeamIdx].Accept[i] ).AccountID )
  203.             {
  204.                 VoterList.length =  VoterList.length + 1;
  205.                 VoterList[i]    =   avaPlayerReplicationInfo( TeamVoteInfo[TeamIdx].Accept[i] ).AccountID;
  206.             }
  207.         }
  208.  
  209.         class'avaNetHandler'.static.GetAvaNetHandler().ReportVoteNew(
  210.             EVC_Kick,
  211.             TeamVoteInfo[TeamIdx].proposerID,
  212.             VoterList,
  213.             TeamVoteInfo[TeamIdx].targetID,
  214.             TeamVoteInfo[TeamIdx].Subject );
  215.  
  216.         // vote kick --> ReportVote(EVC_Kick, Caller_Account_ID, Victim_Account_ID, EVoteKickReason)
  217.         //class'avaNetHandler'.static.GetAvaNetHandler().ReportVote(
  218.         //  EVC_Kick,
  219.         //  TeamVoteInfo[TeamIdx].proposerID,
  220.         //  TeamVoteInfo[TeamIdx].targetID,
  221.         //  TeamVoteInfo[TeamIdx].Subject );
  222.         //`log( "ReportVoteOver!!!" );
  223.     }
  224.  
  225.     // Vote Info 초기화....
  226.     TeamVoteInfo[TeamIdx].bVoting       = false;
  227.     TeamVoteInfo[TeamIdx].Voters.length = 0;
  228.     TeamVoteInfo[TeamIdx].Accept.length = 0;
  229.     TeamVoteInfo[TeamIdx].Deny.length   = 0;
  230.  
  231.     if ( TeamIdx == 0 )         ClearTimer( 'VoteTimeOver_EU' );
  232.     else if ( TeamIdx == 1 )    ClearTimer( 'VoteTimeOVer_NRF' );
  233. }
  234.  
  235. defaultproperties
  236. {
  237.     RemoteRole  =   ROLE_None
  238.     VoteTime    =   30.0
  239. }
  240.  
  241.  
  242. //enum EVoteSubjectType
  243. //{
  244. //  VOTESUBJECT_SquadLeader_EU,
  245. //  VOTESUBJECT_SquadLeader_USSR,
  246. //  VOTESUBJECT_MapSelection,
  247. //  VOTESUBJECT_KickPlayer,
  248. //  VOTESUBJECT_DrawGame,
  249. //};
  250. //
  251. //enum EVoteProgressType
  252. //{
  253. //  // Drawing Progress
  254. //  VOTEPROGRESS_Invalid,
  255. //  VOTEPROGRESS_Insufficient,
  256. //  VOTEPROGRESS_Another,
  257. //  VOTEPROGRESS_Timeout,
  258. //  VOTEPROGRESS_Already,
  259. //  VOTEPROGRESS_Freeze,
  260. //  VOTEPROGRESS_Elected,
  261. //  VOTEPROGRESS_Rejected,
  262. //  VOTEPROGRESS_Vote,
  263. //  VOTEPROGRESS_Cancel,
  264. //  VOTEPROGRESS_Retire,
  265. //  VOTEPROGRESS_Submit,
  266. //  VOTEPROGRESS_Logout,
  267. //
  268. //  // One chance Event (Sound, Notify Msg, ...)
  269. //  VOTEPROGRESS_EventStart,
  270. //  VOTEPROGRESS_EventCancel,
  271. //  VOTEPROGRESS_EventEnd,
  272. //  VOTEPROGRESS_EventAccept,
  273. //  VOTEPROGRESS_EventDeny,
  274. //};
  275. //
  276. //enum EVoteRangeType
  277. //{
  278. //  VOTERANGE_Team,
  279. //  VOTERANGE_All,
  280. //};
  281. //
  282. //enum EShowFlagType
  283. //{
  284. //  VOTEMSG_Show,
  285. //  VOTEMSG_Hide,
  286. //};
  287. //
  288. //struct native FreezeInfo
  289. //{
  290. //  var PlayerReplicationInfo               FreezePRI;
  291. //  var float                               fTimeleft;
  292. //};
  293. //
  294. //struct native VoteInfo
  295. //{
  296. //  /* Vote SubjectInfo*/
  297. //  var Name                Name;       // "MapSelection", "SquadLeader", "KickPlayer" 
  298. //  var EVoteRangeType      Range;              // Team - 팀만 투표, All - 모두 투표
  299. //  var float               Duration;       // 투표의 지속 시간. ex) KickPlayer는 20초 투표등등
  300. //  var int                 nMinJoinNum;        // 투표시작 최소인원.      
  301. //  var float               fMinVoteRate;       // 몇 퍼센트이상 투표했을때, 투표 결과를 확정할 것인가
  302. //                                              // ex) 20%이하 투표시에는 투표 결과 취소.
  303. //  var float               fAcceptRate;        // 과반수(다수결) - 0.5
  304. //
  305. //  /* Vote Internal Logic ( State, Condition , etc ...)*/
  306. //  var bool                                    bVoting;            // 투표중 ...
  307. //  var array<PlayerReplicationInfo>            Voters;             // 입후보 당시의 유권자들
  308. //  var array<PlayerReplicationInfo>            Accept;             // 찬성한 사람들
  309. //  var array<PlayerReplicationInfo>            Deny;               // 반대한 사람들
  310. //  var array<PlayerReplicationInfo>            Left;               // 투표 안한 사람들
  311. //  var array<PlayerReplicationInfo>            Submit;             // 투표한 사람들
  312. //  var float                                   fTimeLeft;          // 투표 남은시간
  313. //
  314. //  var array<int>                              TeamVoterCount;     // 팀당 유권자수 (ex. EU - 3명, NRF - 4명 )
  315. //  var array<int>                              TeamAcceptCount;    // 팀당 찬성수 (ex. EU - 1명, NRF - 0명)
  316. //  var array<int>                              TeamDenyCount;      // 팀당 반대수 (ex. EU - 1명, NRF - 1명)
  317. // 
  318. //  var array<FreezeInfo>                       Freeze;
  319. //  var PlayerReplicationInfo                   CandidatePRI;
  320. //  var PlayerReplicationInfo                   ElectedPRI;
  321. //}
  322. //
  323. //var array<VoteInfo>               Vote;
  324. //var const float                   fUpdatePeriod;
  325. //var const float                   fMsgDuration;
  326. //var const float                   fFreezePeriod;
  327. //
  328. //var PlayerReplicationInfo                     TempPRI;
  329. //
  330. //
  331. //static native function string ParsePlayerName(coerce string PlayerName, string Message);
  332. //static native function string ParseTimeLeft(coerce string fTimeLeft, string Message);
  333. //static native function string ParseVoteCount(coerce string accepts, coerce string denies, string Message);
  334. //
  335. //
  336. //function NotifyInvalid(EVoteSubjectType Subject)
  337. //{
  338. //  SendToCandidate(Subject, VOTEPROGRESS_Invalid, true);
  339. //}
  340. //
  341. //function NotifyAnother(EVoteSubjectType Subject, EVoteSubjectType AnotherSubject)
  342. //{
  343. //  SendToCandidate(Subject, VOTEPROGRESS_Another, true, Vote[AnotherSubject].fTimeLeft);
  344. //}
  345. //
  346. //function NotifyInsufficient(EVoteSubjectType Subject)
  347. //{
  348. //  SendToCandidate(Subject, VOTEPROGRESS_Insufficient, true);
  349. //}
  350. //
  351. //function NotifyTimeout(EVoteSubjectType Subject)
  352. //{
  353. //  Local string ElectedName;
  354. //  ElectedName = Vote[Subject].ElectedPRI != None ? Vote[Subject].ElectedPRI.PlayerName : "";
  355. //  SendToCandidate(Subject, VOTEPROGRESS_Rejected, true, , Vote[Subject].CandidatePRI.PlayerName,ElectedNAme ,Vote[Subject].Accept.Length, Vote[Subject].Deny.Length);
  356. //  SendToVoters(Subject, VOTEPROGRESS_Rejected, false, , Vote[Subject].CandidatePRI.PlayerName,ElectedName ,Vote[Subject].Accept.Length, Vote[Subject].Deny.Length);
  357. //}
  358. //
  359. //function NotifyAlready(EVoteSubjectType Subject)
  360. //{
  361. //  SendToCandidate(Subject, VOTEPROGRESS_Already, true);
  362. //}
  363. //
  364. //function NotifyCancel(EVoteSubjectType Subject)
  365. //{
  366. //  SendToCandidate(Subject, VOTEPROGRESS_Cancel, true, , Vote[Subject].CandidatePRI.PlayerName);
  367. //  SendToVoters(Subject, VOTEPROGRESS_Cancel, false, , Vote[Subject].CandidatePRI.PlayerName);
  368. //}
  369. //
  370. //function NotifyRetire(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  371. //{
  372. ////    SendToElected(Subject, VOTEPROGRESS_Retire, true, , PRI.PlayerName);
  373. //  SendToTeam(Subject, VOTEPROGRESS_Retire, false, , PRI.PlayerName);
  374. //}
  375. //
  376. //function NotifyLogout(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  377. //{
  378. //  SendToCandidate(Subject, VOTEPROGRESS_Logout, Vote[Subject].CandidatePRI == PRI , ,PRI.PlayerName);
  379. //  SendToVoters(Subject, VOTEPROGRESS_Logout, Vote[Subject].CandidatePRI == PRI , ,PRI.PlayerName);
  380. //}
  381. //
  382. ///* ElectedPRI = CandidatePRI 하기 전에 불림. 따라서 ElectedPRI 는 이전 선출자, CandidatePRI 이번 입후보자*/
  383. //function NotifyElected(EVoteSubjectType Subject)
  384. //{
  385. //  Local string ElectedName;
  386. //  Local int n1, n2;
  387. //
  388. //  switch(Subject)
  389. //  {
  390. //  case VOTESUBJECT_SquadLeader_EU:   
  391. //  case VOTESUBJECT_SquadLeader_USSR:      n1 = Vote[Subject].Accept.Length; n2 = Vote[Subject].Deny.Length;   break;
  392. //  case VOTESUBJECT_DrawGame:  n1 = (CheckEachTeamAccept(Subject, TEAM_EU) ? 1 : 0);
  393. //                              n2 = (CheckEachTeamAccept(Subject, TEAM_USSR) ? 1 : 0);
  394. //                                  break;
  395. //  }
  396. //  // Elected 는 이전 후보자, Candidate는 차기 후보자
  397. //  ElectedName = Vote[Subject].ElectedPRI != None ? Vote[Subject].ElectedPRI.PlayerName : "";
  398. //  SendToCandidate(Subject, VOTEPROGRESS_Elected, true, , Vote[Subject].CandidatePRI.PlayerName,ElectedName ,n1, n2);
  399. //  SendToVoters(Subject, VOTEPROGRESS_Elected, false, , Vote[Subject].CandidatePRI.PlayerName,ElectedName ,n1, n2);
  400. //
  401. //  SendToVoters(Subject, VOTEPROGRESS_EventEnd);
  402. //}
  403. //
  404. //function NotifyRejected(EVoteSubjectType Subject)
  405. //{
  406. //  Local string ElectedName;
  407. //  Local int n1, n2;
  408. //
  409. //  switch(Subject)
  410. //  {
  411. //  case VOTESUBJECT_SquadLeader_EU:   
  412. //  case VOTESUBJECT_SquadLeader_USSR:      n1 = Vote[Subject].Accept.Length; n2 = Vote[Subject].Deny.Length;   break;
  413. //  case VOTESUBJECT_DrawGame:  n1 = (CheckEachTeamAccept(Subject, TEAM_EU) ? 1 : 0);
  414. //                              n2 = (CheckEachTeamAccept(Subject, TEAM_USSR) ? 1 : 0);
  415. //                                  break;
  416. //  }
  417. //
  418. //  ElectedName = Vote[Subject].ElectedPRI != None ? Vote[Subject].ElectedPRI.PlayerName : "";
  419. //  SendToCandidate(Subject, VOTEPROGRESS_Rejected, true, , Vote[Subject].CandidatePRI.PlayerName,ElectedNAme , n1, n2);
  420. //  SendToVoters(Subject, VOTEPROGRESS_Rejected, false, , Vote[Subject].CandidatePRI.PlayerName,ElectedName , n1, n2);
  421. //
  422. //  SendToVoters(Subject, VOTEPROGRESS_EventEnd);
  423. //}
  424. //
  425. //function NotifyVote(EVoteSubjectType Subject)
  426. //{
  427. //  Local string ElectedName;
  428. //  Local int n1, n2, TeamIndex, i;
  429. //
  430. //  TeamIndex = Vote[Subject].CandidatePRI.Team.TeamIndex;
  431. //  ElectedName = Vote[Subject].ElectedPRI != None ? Vote[Subject].ElectedPRI.PlayerName : "";
  432. // 
  433. //  switch(Subject)
  434. //  {
  435. //  case VOTESUBJECT_SquadLeader_EU:   
  436. //  case VOTESUBJECT_SquadLeader_USSR:     
  437. //      n1 = Vote[Subject].Accept.Length; n2 = Vote[Subject].Deny.Length;      
  438. //      SendToCandidate(Subject, VOTEPROGRESS_Vote, true, Vote[Subject].fTimeLeft, Vote[Subject].CandidatePRI.PlayerName,ElectedName, n1, n2);
  439. //      SendToLeft(Subject, VOTEPROGRESS_Vote, false,Vote[Subject].fTimeLeft, Vote[Subject].CandidatePRI.PlayerName,ElectedName, n1, n2);
  440. //          break;
  441. //  case VOTESUBJECT_DrawGame: 
  442. //      n1 = Vote[Subject].TeamAcceptCount[TeamIndex];
  443. //      n2 = Vote[Subject].TeamDenyCount[TeamIndex];
  444. //      SendToCandidate(Subject, VOTEPROGRESS_Vote, true, Vote[Subject].fTimeLeft, Vote[Subject].CandidatePRI.PlayerName,ElectedName, n1, n2);
  445. //      for( i = 0 ; i < Vote[Subject].Left.Length ; i++)
  446. //      {
  447. //          TeamIndex = Vote[Subject].Left[i].Team.TeamIndex;
  448. //          n1 = Vote[Subject].TeamAcceptCount[TeamIndex];
  449. //          n2 = Vote[Subject].TeamDenyCount[TeamIndex];
  450. //          SendToSinglePRI(Vote[Subject].Left[i],Subject, VOTEPROGRESS_Vote, false, Vote[Subject].fTimeLeft, Vote[Subject].CandidatePRI.PlayerName,ElectedName, n1, n2);
  451. //      }
  452. //      break;
  453. //  }
  454. //}
  455. //
  456. //function NotifySubmit(EVoteSubjectType Subject)
  457. //{
  458. //  Local int n1, n2, i, TeamIndex;
  459. //
  460. //  switch(Subject)
  461. //  {
  462. //  case VOTESUBJECT_SquadLeader_EU:   
  463. //  case VOTESUBJECT_SquadLeader_USSR:     
  464. //      n1 = Vote[Subject].Accept.Length; n2 = Vote[Subject].Deny.Length;      
  465. //      SendToSubmit(Subject, VOTEPROGRESS_Submit, false,Vote[Subject].fTimeLeft, , , n1, n2);
  466. //          break;
  467. //  case VOTESUBJECT_DrawGame: 
  468. //      for( i = 0 ; i < Vote[Subject].Submit.Length ; i++)
  469. //      {
  470. //          TeamIndex = Vote[Subject].Submit[i].Team.TeamIndex;
  471. //          n1 = Vote[Subject].TeamAcceptCount[TeamIndex];
  472. //          n2 = Vote[Subject].TeamDenyCount[TeamIndex];
  473. //          SendToSinglePRI(Vote[Subject].Submit[i],Subject, VOTEPROGRESS_Submit, false, Vote[Subject].fTimeLeft, , , n1, n2);
  474. //      }
  475. //      break;
  476. //  }
  477. //
  478. //}
  479. //
  480. //function NotifyFreeze(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  481. //{
  482. //  Local int Index;
  483. //
  484. //  Index = Vote[Subject].Freeze.find('FreezePRI', PRI);
  485. //  Assert(Index >= 0);
  486. //  SendToCandidate(Subject, VOTEPROGRESS_Freeze, true, Vote[Subject].Freeze[index].fTimeLeft);
  487. //}
  488. //
  489. //// Call from Start() only
  490. //function NotifyEventStart(EVoteSubjectType Subject)
  491. //{
  492. //  SendToCandidate(Subject, VOTEPROGRESS_EventStart);
  493. //  SendToVoters(Subject, VOTEPROGRESS_EventStart);
  494. //}
  495. //
  496. //// Call from NotifyRejected, NotifyElected
  497. //function NotifyEventEnd(EVoteSubjectType Subject)
  498. //{
  499. //  SendToCandidate(Subject, VOTEPROGRESS_EventEnd);
  500. //  SendToVoters(Subject, VOTEPROGRESS_EventEnd);
  501. //}
  502. //
  503. //// Call from Cancel() only
  504. //function NotifyEventCancel(EVoteSubjectType Subject)
  505. //{
  506. //  SendToCandidate(Subject, VOTEPROGRESS_EventCancel);
  507. //  SendToVoters(Subject, VOTEPROGRESS_EventCancel);
  508. //}
  509. //
  510. //function NotifyEventAccept(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  511. //{
  512. //  SendToSinglePRI(PRI, Subject, VOTEPROGRESS_EventAccept);
  513. //}
  514. //
  515. //function NotifyEventDeny(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  516. //{
  517. //  SendToSinglePRI(PRI, Subject, VOTEPROGRESS_EventDeny);
  518. //}
  519. //
  520. //
  521. ///* SendMsg functions to Voters, Candidate, All, and so on */
  522. //
  523. ///* PRIArray에 있는 대상에게 Msg를 보냄 */
  524. //
  525. //function SendToSinglePRI(PlayerReplicationInfo PRI,
  526. //                 EVoteSubjectType Subject, EVoteProgressType Progress,
  527. //                 optional bool bCandidate, optional float Timeleft,
  528. //                 optional string PlayerName, optional string AnotherName,
  529. //                 optional int n1, optional int n2)
  530. //{
  531. //  AvaPlayerController(PRI.Owner).ClientReceiveVoteMsg(Subject, Progress, bCandidate, Timeleft, PlayerName, AnotherName,n1,n2);
  532. //}
  533. //
  534. //function SendToPRI(array<PlayerReplicationInfo> PRI,
  535. //                 EVoteSubjectType Subject, EVoteProgressType Progress,
  536. //                 optional bool bCandidate, optional float Timeleft,
  537. //                 optional string PlayerName, optional string AnotherName,
  538. //                 optional int n1, optional int n2)
  539. //{
  540. //  Local int i;
  541. //  for( i = 0 ; i < PRI.Length ; i++)
  542. //      AvaPlayerController(PRI[i].Owner).ClientReceiveVoteMsg(Subject, Progress, bCandidate, Timeleft, PlayerName, AnotherName,n1,n2);
  543. //}
  544. //
  545.  
  546. //
  547. //function SendToLeft(EVoteSubjectType Subject, EVoteProgressType Progress,
  548. //                 optional bool bCandidate, optional float Timeleft,
  549. //                 optional string PlayerName, optional string AnotherName,
  550. //                 optional int n1, optional int n2)
  551. //{
  552. //  SendToPRI(Vote[Subject].Left,  Subject, Progress, bCandidate, Timeleft, PlayerName, AnotherName,n1, n2);
  553. //}
  554. //
  555. //function SendToSubmit(EVoteSubjectType Subject, EVoteProgressType Progress,
  556. //                 optional bool bCandidate, optional float Timeleft,
  557. //                 optional string PlayerName, optional string AnotherName,
  558. //                 optional int n1, optional int n2)
  559. //{
  560. //  SendToPRI(Vote[Subject].Submit,  Subject, Progress, bCandidate, Timeleft, PlayerName, AnotherName,n1, n2);
  561. //}
  562. //
  563. //
  564. //function SendToCandidate(EVoteSubjectType Subject, EVoteProgressType Progress,
  565. //                 optional bool bCandidate, optional float Timeleft,
  566. //                 optional string PlayerName, optional string AnotherName,
  567. //                 optional int n1, optional int n2)
  568. //{
  569. //  Local PlayerReplicationInfo PRI;
  570. //  PRI = Vote[Subject].bVoting ? Vote[Subject].CandidatePRI : TempPRI;
  571. //
  572. //  avaPlayerController(PRI.Owner).ClientReceiveVoteMsg(Subject, Progress, bCandidate, Timeleft, PlayerName,AnotherName, n1,n2);
  573. //}
  574. //
  575. //function SendToElected(EVoteSubjectType Subject, EVoteProgressType Progress,
  576. //                 optional bool bCandidate, optional float Timeleft,
  577. //                 optional string PlayerName, optional string AnotherName,
  578. //                 optional int n1, optional int n2)
  579. //{
  580. //  Local PlayerReplicationInfo PRI;
  581. //  PRI = Vote[Subject].ElectedPRI;
  582. //
  583. //  if(PRI != None);
  584. //  avaPlayerController(PRI.Owner).ClientReceiveVoteMsg(Subject, Progress, bCandidate, Timeleft, PlayerName,AnotherName, n1,n2);
  585. //}
  586. //
  587. //function SendToTeam(EVoteSubjectType Subject, EVoteProgressType Progress,
  588. //                 optional bool bCandidate, optional float Timeleft,
  589. //                 optional string PlayerName, optional string AnotherName,
  590. //                 optional int n1, optional int n2)
  591. //{
  592. //  Local PlayerController PC;
  593. //  foreach WorldInfo.AllControllers(class'PlayerController' , PC)
  594. //      if(PC.PlayerReplicationInfo.Team.TeamIndex == Vote[Subject].CandidatePRI.Team.TeamIndex)
  595. //          avaPlayerController(PC).ClientReceiveVoteMsg(Subject, Progress, bCandidate, Timeleft, PlayerName, AnotherName,n1,n2);
  596. //}
  597. //
  598. //function SendToAll(EVoteSubjectType Subject, EVoteProgressType Progress,
  599. //                 optional bool bCandidate, optional float Timeleft,
  600. //                 optional string PlayerName, optional string AnotherName,
  601. //                 optional int n1, optional int n2)
  602. //{
  603. //  Local PlayerController PC;
  604. //  foreach WorldInfo.AllControllers(class'PlayerController' , PC)
  605. //      avaPlayerController(PC).ClientReceiveVoteMsg(Subject, Progress, bCandidate, Timeleft, PlayerName, AnotherName,n1,n2);
  606. //}
  607. //
  608. //function HidePRI(PlayerReplicationInfo PRI)
  609. //{
  610. //  //  avaPlayerController(PRI.Owner).ClientReceiveHideVoteMsg(V);
  611. //}
  612. //
  613. //
  614. ///* VoteLogic 관련, 현재 Vote의 진행상황 조작, 인출  */
  615. //
  616. //function bool IsAcceptable(EVoteSubjectType Subject,PlayerReplicationInfo PRI)
  617. //{
  618. //  switch(Subject)
  619. //  {
  620. //  case VOTESUBJECT_MapSelection:  return true;
  621. //  case VOTESUBJECT_SquadLeader_EU:
  622. //  case VOTESUBJECT_SquadLeader_USSR:
  623. //                                  return true;
  624. //  case VOTESUBJECT_KickPlayer:    return true;
  625. //  case VOTESUBJECT_DrawGame:      return true;
  626. //  default:
  627. //      Assert(false); return false;
  628. //  }
  629. //  return true;
  630. //}
  631. //
  632. //function bool CheckVote(EVoteSubjectType Subject)
  633. //{
  634. //  return Vote[Subject].bVoting;
  635. //}
  636. //
  637. //function bool CheckRange(EVoteSubjectType Subject, PlayerReplicationInfo PRI, out EVoteSubjectType AnotherSubject)
  638. //{
  639. //  Local int i , v;
  640. //
  641. //  for( i = 0 ; i < Vote.Length ; i++ )
  642. //  {
  643. //      if(Vote[i].bVoting && i != Subject)
  644. //      {
  645. //          // All Members are Voting on
  646. //          if(Vote[i].Range == VOTERANGE_ALL)
  647. //          {
  648. //              AnotherSubject = EVoteSubjectType(i);
  649. //              return false;
  650. //          }
  651. //
  652. //          // Assume that Vote[i].Range == VOTERANGE_TEAM
  653. //          // because there's no other type in Range at the moment
  654. //          for( v = 0 ; v < Vote[i].Voters.Length ; v++)
  655. //          {
  656. //              if( Vote[i].Voters[v].Team.TeamIndex == PRI.Team.TeamIndex)
  657. //              {
  658. //                  AnotherSubject = EVoteSubjectType(i);
  659. //                  return false;
  660. //              }
  661. //          }
  662. //      }
  663. //  }
  664. //  return true;
  665. //}
  666. //
  667. //function bool CheckSufficient(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  668. //{
  669. //  Local int i;
  670. //  Local int WholeVoters;
  671. //  if(Vote[Subject].Range == VOTERANGE_Team)
  672. //  {
  673. //      if(Vote[Subject].Voters.Length < Vote[Subject].nMinJoinNum)
  674. //          return false;
  675. //  }
  676. //  else if(Vote[Subject].Range == VOTERANGE_ALL)
  677. //  {
  678. //      if(Vote[Subject].TeamVoterCount.Length != TEAM_MAX - 1)
  679. //          return false;
  680. //     
  681. //      for( i = 0 ; i < Vote[Subject].TeamVoterCount.Length ; i++)
  682. //      {
  683. //          WholeVoters = Vote[Subject].TeamVoterCount[i] + (i == PRI.Team.TeamIndex ? 1 : 0);
  684. ////            `log("WholeVoters["$i$"] = "$WholeVoters);
  685. //          if(WholeVoters <= 0)
  686. //              return false;
  687. //      }
  688. //  }
  689. // 
  690. //  return true;
  691. //}
  692. //
  693. //
  694. //function StartVote(EVoteSubjectType Subject,PlayerReplicationInfo PRI, optional Object VoteObject)
  695. //{
  696. //  Local EVoteSubjectType AnotherSubject;
  697. // 
  698. //  /* TempPRI Scope Begins*/
  699. //  TempPRI = PRI;
  700. // 
  701. //  /* '계급이 하사이상'과 같은 적합한 플레이어인지의 조건*/
  702. //  if(!IsAcceptable(Subject, PRI))
  703. //  {
  704. ////        `log("Invalid");
  705. //      NotifyInvalid(Subject);
  706. //      return;
  707. //  }
  708. //
  709. //  /* 선출된 플레이어가 다시 투표를 시도할때*/
  710. //  if( Vote[Subject].ElectedPRI == PRI)
  711. //  {
  712. ////        `log("Already");
  713. //      NotifyAlready(Subject);
  714. //      return;
  715. //  }
  716. //
  717. //  /* 낙선해 FreezeTime이 적용중인 플레이어가 다시 재선을 시도*/
  718. //  if( Vote[Subject].Freeze.find('FreezePRI', PRI) >= 0)
  719. //  {
  720. ////        `log("Freeze");
  721. //      NotifyFreeze(Subject, PRI);
  722. //      return;
  723. //  }
  724. //
  725. //  /* 같은 주제의 투표를 2개이상 만들 수 없음*/
  726. //  if( CheckVote(Subject) )
  727. //  {
  728. ////        `log("Multiple Not Allowed");
  729. //      return;
  730. //  }
  731. //
  732. //  /* 투표가 필요로 하는 인원중에 다른 투표에 참여하고 있는 인원이 있는가 ?*/
  733. //  if(!CheckRange(Subject, PRI, AnotherSubject))
  734. //  {
  735. ////        `log("Another");
  736. //      NotifyAnother(Subject, AnotherSubject);
  737. //      return;
  738. //  }
  739. //
  740. //  /* 최소 투표인원을 만족하는가 ? */
  741. //  GetCurrentVoters(Subject);
  742. //  if(!CheckSufficient(Subject, TempPRI))
  743. //  {
  744. ////        `log("Insufficient");
  745. //      NotifyInsufficient(Subject);
  746. //      return;
  747. //  }
  748. //  /* TempPRI Scope End*/
  749. //
  750. //  /* Check all conditions, Process Next*/
  751. //
  752. //  `log("Ready to Vote");
  753. //
  754. //  Vote[Subject].CandidatePRI = PRI;
  755. //  Vote[Subject].bVoting = true;
  756. //  Vote[Subject].fTimeLeft = Vote[Subject].Duration;
  757. //  Vote[Subject].Accept[ Vote[Subject].Accept.Length ] = PRI;
  758. //  Vote[Subject].TeamAcceptCount[ PRI.Team.TeamIndex ] = 1;    // 팀에서 Accept한 숫자 1 (자기자신은 팀에서 찬성이므로)
  759. //  if(!IsTimerActive())
  760. //  {
  761. ////        `log("SetTimer");
  762. //      SetTimer(fUpdatePeriod, true);
  763. //  }
  764. //  NotifyVote(Subject);
  765. //  NotifyEventStart(Subject);
  766. //}
  767. //
  768. //function Timer()
  769. //{
  770. //  Local int i,k;
  771. //  Local int VoteCount;
  772. //  Local int FreezeCount;
  773. //
  774. //  VoteCount = 0;
  775. //  FreezeCount = 0;
  776. //  for( i = 0 ; i < Vote.Length ; i++)
  777. //  {
  778. //
  779. //      /* Manipulate Vote Status (Left-Time Update, Notify Timeout)  */
  780. //      if(Vote[i].bVoting)
  781. //      {
  782. //          if(Vote[i].fTimeLeft <= 0.0)
  783. //          {
  784. //              NotifyRejected(EVoteSubjectType(i));
  785. //              ResetVoteParam(EVoteSubjectType(i));
  786. //          }
  787. //          else
  788. //          {
  789. //              NotifyVote(EVoteSubjectType(i));
  790. //              NotifySubmit(EVoteSubjectType(i));
  791. //              Vote[i].fTimeLeft -= fUpdatePeriod;
  792. //          }
  793. //          VoteCount++;
  794. //      }
  795. //
  796. //      /* Manipulate Cooltime (Left-Time Update, Melt Player when time is gone)*/
  797. //      for(k = Vote[i].Freeze.Length-1 ; k >= 0 ; k--)
  798. //      {
  799. //          if( Vote[i].Freeze[k].fTimeLeft <= 0.0)
  800. //          {
  801. //              Vote[i].Freeze.Remove(k,1);
  802. //          }
  803. //          else
  804. //          {
  805. //              Vote[i].Freeze[k].fTimeLeft -= fUpdatePeriod;
  806. ////                `log("fTimeLeft = "$Vote[i].Freeze[k].fTimeLeft);
  807. //          }
  808. //          FreezeCount++;
  809. //      }
  810. //  }
  811. //
  812. //  if(VoteCount == 0 && FreezeCount == 0)
  813. //  {
  814. ////        `log("ClearTimer");
  815. //      ClearTimer();
  816. //  }
  817. //}
  818. //
  819. //function ResetVoteParam(EVoteSubjectType Subject)
  820. //{
  821. //
  822. //  Vote[Subject].bVoting = false;
  823. //  Vote[Subject].fTimeLeft = 0.0;
  824. //  Vote[Subject].Voters.Length = 0;
  825. //  Vote[Subject].Accept.Length = 0;
  826. //  Vote[Subject].Deny.Length = 0;
  827. //  Vote[Subject].Left.Length = 0;
  828. //  Vote[Subject].Submit.Length = 0;
  829. //  Vote[Subject].TeamVoterCount.Length = 0;
  830. //  Vote[Subject].TeamAcceptCount.Length = 0;
  831. //  Vote[Subject].TeamDenyCount.Length = 0;
  832. //
  833. //}
  834. //
  835. //function bool CheckEachTeamAccept(EVoteSubjectType Subject, int TeamIndex)
  836. //{
  837. //  Local int left, right;
  838. //
  839. //  left = Vote[Subject].TeamVoterCount[TeamIndex];
  840. //  right = Vote[Subject].TeamAcceptCount[TeamIndex];
  841. //
  842. //  if( Vote[Subject].CandidatePRI.Team.TeamIndex == TeamIndex)
  843. //      left = left + 1;
  844. //
  845. //  left = left * Vote[Subject].fAcceptRate;
  846. //
  847. //  return left < right;
  848. //}
  849. //
  850. //function bool CheckAccept(EVoteSubjectType Subject)
  851. //{
  852. //  Local int left, right, i;
  853. //  Local int count;
  854. // 
  855. //  switch(Subject)
  856. //  {
  857. //  case VOTESUBJECT_SquadLeader_EU:
  858. //  case VOTESUBJECT_SquadLeader_USSR:      left = Vote[Subject].fAcceptRate * (Vote[Subject].Voters.Length + 1);
  859. //                                          right = Vote[Subject].Accept.Length;                   
  860. //                                          return left < right;
  861. //  case VOTESUBJECT_DrawGame:                                                 
  862. //                                      count = 0;
  863. //                                      for( i = 0 ; i < Vote[Subject].TeamVoterCount.Length ; i++)
  864. //                                      {
  865. //                                          if( CheckEachTeamAccept(Subject, i) )
  866. //                                              count++;
  867. //                                      }
  868. ////                                        `log("Count = "$count$", TeamVoterCount.Length = "$Vote[Subject].TeamVoterCount.Length);
  869. //                                      return count == (Vote[Subject].TeamVoterCount.Length );
  870. //
  871. //  default:    Assert(false);      break;
  872. //
  873. //  }
  874. //  // Vote[Subject].Accept.Length + 1 = (찬성한 사람) + (자기자신)
  875. //  return left < right;
  876. //}
  877. //
  878. //
  879. //function Submit(EVoteSubjectType Subject, bool bAgree, PlayerReplicationInfo PRI)
  880. //{
  881. //  Local int Index;
  882. //  Local int TeamIndex;
  883. //
  884. //
  885. //  Index = Vote[Subject].Left.find(PRI);
  886. //  /* 현재 유권자들 중에 없음 (투표 초기에 유권자 범위에 포함되지 않거나, 투표 중간에 들어왔음) */
  887. //  if(Index < 0)
  888. //      return;
  889. //
  890. //  Vote[Subject].Left.Remove(Index, 1);
  891. //  Vote[Subject].Submit[ Vote[Subject].Submit.Length ] = PRI;
  892. //
  893. //  TeamIndex = PRI.Team.TeamIndex;
  894. //  if( bAgree)
  895. //  {
  896. //      Vote[Subject].Accept[ Vote[Subject].Accept.Length ] = PRI;
  897. //      Vote[Subject].TeamAcceptCount[TeamIndex] = Vote[Subject].TeamAcceptCount[TeamIndex] + 1;
  898. //      NotifyEventAccept(Subject, PRI);
  899. //  }
  900. //  else
  901. //  {
  902. //      Vote[Subject].Deny[ Vote[Subject].Deny.Length ] = PRI;
  903. //      Vote[Subject].TeamDenyCount[TeamIndex] = Vote[Subject].TeamDenyCount[TeamIndex] + 1;
  904. //      NotifyEventDeny(Subject, PRI);
  905. //  }
  906. // 
  907. //
  908. //  if(CheckAccept(Subject))
  909. //  {
  910. //      /* Elected */
  911. //      NotifyElected(Subject);
  912. //      ProcessElected(Subject);       
  913. //      ResetVoteParam(Subject);
  914. //      return;
  915. //  }else if(Vote[Subject].Accept.Length + Vote[Subject].Deny.Length >= Vote[Subject].Voters.Length + 1)    // +1(자기자신)
  916. //  {
  917. //      /* Rejected */
  918. //      AddFreezePRI(Subject, Vote[Subject].CandidatePRI);
  919. //      NotifyRejected(Subject);
  920. //      ResetVoteParam(Subject);
  921. //      return;
  922. //  }
  923. //}
  924. //
  925. //function ProcessElected(EVoteSubjectType Subject, optional PlayerReplicationInfo PRI)
  926. //{
  927. //  switch(Subject)
  928. //  {
  929. //  case VOTESUBJECT_SquadLeader_EU:               
  930. //  case VOTESUBJECT_SquadLeader_USSR:             
  931. //      if(Vote[Subject].ElectedPRI != None)
  932. //      {
  933. //          ProcessChanged(Subject, Vote[Subject].ElectedPRI);
  934. //      }
  935. //      Vote[Subject].ElectedPRI = Vote[Subject].CandidatePRI;
  936. //      avaPlayerReplicationInfo(Vote[Subject].ElectedPRI).bSquadLeader = true;        
  937. ////        avaGameReplicationInfo(WorldInfo.GRI).ClearTeamWaypoint(Vote[Subject].ElectedPRI.Team.TeamIndex);
  938. //
  939. //      break;
  940. //  case VOTESUBJECT_DrawGame:
  941. //      /* Game 비기기 게임종료 Sequece*/                                                break;
  942. //  default:    Assert(false);  break;
  943. //  }
  944. //
  945. //}
  946. //
  947. //function ProcessChanged(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  948. //{
  949. //  switch(Subject)
  950. //  {
  951. //  case VOTESUBJECT_SquadLeader_EU:               
  952. //  case VOTESUBJECT_SquadLeader_USSR:
  953. //      if(PRI != None)
  954. //      {
  955. //          avaPlayerReplicationInfo(PRI).bSquadLeader = false;
  956. //          avaGameReplicationInfo(WorldInfo.GRI).ClearTeamWaypoint(PRI.Team.TeamIndex);
  957. //      }
  958. //      break;
  959. //  case VOTESUBJECT_DrawGame:
  960. //      break;
  961. //  default:    Assert(false);  break;
  962. //  }
  963. //}
  964. //
  965. //function Cancel(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  966. //{
  967. //  if(Vote[Subject].bVoting && Vote[Subject].CandidatePRI == PRI)
  968. //  {
  969. //      AddFreezePRI(Subject, Vote[Subject].CandidatePRI);
  970. //      NotifyCancel(Subject);
  971. //      NotifyEventCancel(Subject);
  972. //      ResetVoteParam(Subject);
  973. //      return;
  974. //  }
  975. //}
  976. //
  977. //function Retire(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  978. //{
  979. //  Local avaPlayerReplicationInfo ElectedPRI;
  980. //
  981. //  if(!Vote[Subject].bVoting && Vote[Subject].ElectedPRI == PRI)
  982. //  {
  983. //      ElectedPRI = avaPlayerReplicationInfo(Vote[Subject].ElectedPRI);
  984. //      NotifyRetire(Subject, ElectedPRI);
  985. //      ProcessChanged(Subject, ElectedPRI);
  986. //      ElectedPRI.bSquadLeader = false;
  987. //      Vote[Subject].ElectedPRI = None;
  988. //      ResetVoteParam(Subject);
  989. //      return;
  990. //  }
  991. //}
  992. //
  993. //function AddFreezePRI(EVoteSubjectType Subject, PlayerReplicationInfo PRI)
  994. //{
  995. //  Vote[Subject].Freeze.Length = Vote[Subject].Freeze.Length + 1;
  996. //  Vote[Subject].Freeze[ Vote[Subject].Freeze.Length - 1].FreezePRI = PRI;
  997. //  Vote[Subject].Freeze[ Vote[Subject].Freeze.Length - 1].fTimeLeft = fFreezePeriod;
  998. //}
  999. //
  1000. //function DisconnectEvent(Controller Exiting)
  1001. //{
  1002. //  Local PlayerReplicationInfo PRI;
  1003. //  Local EVoteSubjectType Subject;
  1004. //  Local int Index, TeamIndex;
  1005. //
  1006. //  PRI = PlayerController(Exiting).PlayerReplicationInfo;
  1007. // 
  1008. //  Index = EVoteSubjectType(GetCurrentSubject(PRI));
  1009. //  if( Index < 0 || Index >= Vote.Length)
  1010. //      return;
  1011. //
  1012. //  Subject = EVoteSubjectType(Index);
  1013. //  if(Vote[Subject].bVoting)
  1014. //  {
  1015. //      /* 입후보자가 나갔을 경우, 투표중단*/
  1016. //      if(Vote[Subject].CandidatePRI == PRI)
  1017. //      {
  1018. //          NotifyLogout(Subject, PRI);
  1019. //          ResetVoteParam(Subject);
  1020. //          return;
  1021. //      }
  1022. //      else
  1023. //      {
  1024. //          TeamIndex = PRI.Team.TeamIndex;
  1025. //
  1026. //          Index = Vote[Subject].Voters.find(PRI);
  1027. //          if( Index < 0 )
  1028. //              return;
  1029. //
  1030. //          Vote[Subject].TeamVoterCount[TeamIndex] = Vote[Subject].TeamVoterCount[TeamIndex] - 1;
  1031. //          Vote[Subject].Voters.Remove(Index, 1);
  1032. //         
  1033. //          Index = Vote[Subject].Submit.Find(PRI);
  1034. //          if( Index >= 0 )
  1035. //          {
  1036. //              Vote[Subject].Submit.Remove(Index,1);
  1037. //              Index = Vote[Subject].Accept.find(PRI);
  1038. //              if(Index >= 0)
  1039. //              {
  1040. //                  Vote[Subject].Accept.Remove(Index,1);
  1041. //                  Vote[Subject].TeamAcceptCount[TeamIndex] = Vote[Subject].TeamAcceptCount[TeamIndex] - 1;
  1042. //              }
  1043. //              Index = Vote[Subject].Deny.find(PRI);
  1044. //              if(Index >= 0)
  1045. //              {
  1046. //                  Vote[Subject].Deny.Remove(Index,1);
  1047. //                  Vote[Subject].TeamDenyCount[TeamIndex] = Vote[Subject].TeamDenyCount[TeamIndex] - 1;
  1048. //
  1049. //              }
  1050. //          }
  1051. //         
  1052. //         
  1053. //          Index = Vote[Subject].Left.Find(PRI);
  1054. //          if( Index >= 0 )
  1055. //              Vote[Subject].Left.Remove(Index,1);
  1056. //         
  1057. //          if( !CheckSufficient(Subject, Vote[Subject].CandidatePRI) )
  1058. //          {
  1059. //              NotifyLogout(Subject, PRI);
  1060. //              ResetVoteParam(Subject);
  1061. //              return;
  1062. //          }
  1063. //         
  1064. //          if( CheckAccept(Subject) )
  1065. //          {
  1066. //              NotifyElected(Subject);
  1067. //              ProcessElected(Subject);
  1068. //              ResetVoteParam(Subject);
  1069. //              return;
  1070. //          }
  1071. //      }
  1072. //  }
  1073. //  /* 투표중이 아닌데 당선된 사람이 나갔을 경우  */
  1074. //  else if( PRI == Vote[Subject].ElectedPRI )
  1075. //  {
  1076. //      ProcessChanged(Subject, PRI);
  1077. //      Vote[Subject].ElectedPRI = None;
  1078. //  }
  1079. //}
  1080. //
  1081. ///* Some Getters for (Role == Authority) */
  1082. //
  1083. //function array<PlayerReplicationInfo> GetPRIArray()
  1084. //{
  1085. //  return WorldInfo.GRI.PRIArray;
  1086. //}
  1087. //
  1088. ///* 전체 투표인원을 가지고 있는 Voters배열을 채움.
  1089. //단, 투표하고 남은 사람을 가지고 있기 위한 Left배열도 같이 채움*/
  1090. //function int GetCurrentVoters(EVoteSubjectType Subject)
  1091. //{
  1092. //  Local int i, TeamIndex;
  1093. //  Local array<PlayerReplicationInfo> PRI;
  1094. //
  1095. //  PRI = GetPRIArray();
  1096. //
  1097. //  for( i = 0 ; i < PRI.Length ; i++)
  1098. //  {
  1099. //      if( Vote[Subject].Range == VOTERANGE_ALL ||
  1100. //          (Vote[Subject].Range == VOTERANGE_TEAM && TempPRI.Team.TeamIndex == PRI[i].Team.TeamIndex) )
  1101. //      {
  1102. //          TeamIndex = PRI[i].Team.TeamIndex;
  1103. //          if(TeamIndex >= Vote[Subject].TeamVoterCount.Length)
  1104. //          {
  1105. //              Vote[Subject].TeamVoterCount.Length = TeamIndex + 1;
  1106. //              Vote[Subject].TeamAcceptCount.Length = TeamIndex + 1;
  1107. //              Vote[Subject].TeamDenyCount.Length = TeamIndex + 1;
  1108. //          }
  1109. //          if(PRI[i] != TempPRI)
  1110. //          {
  1111. //             
  1112. ////                `log("CandidatePRI.PlayerName = "$TempPRI.PlayerName);
  1113. //              Vote[Subject].Voters[Vote[Subject].Voters.Length] = PRI[i];
  1114. //              Vote[Subject].Left[ Vote[Subject].Left.Length ] = PRI[i];
  1115. //              Vote[Subject].TeamVoterCount[TeamIndex] = Vote[Subject].TeamVoterCount[TeamIndex] + 1;
  1116. //          }
  1117. //      }
  1118. //  }
  1119. //
  1120. ////    `log("return Length = "$Vote[Subject].Voters.Length);
  1121. //  return Vote[Subject].Voters.Length;
  1122. //}
  1123. //
  1124. //function PlayerReplicationInfo GetPRIByID(int PlayerID)
  1125. //{
  1126. //  return WorldInfo.GRI.FindPlayerByID(PlayerID);
  1127. //}
  1128. //
  1129. //function int GetCurrentSubject(PlayerReplicationInfo PRI)
  1130. //{
  1131. //  Local int i;
  1132. //
  1133. //  for( i = 0 ; i < Vote.Length ; i++)
  1134. //  {
  1135. //      if( Vote[i].bVoting)
  1136. //      {  
  1137. //          if( (Vote[i].CandidatePRI == PRI) || (Vote[i].Voters.find(PRI) >= 0) )
  1138. //              return i;
  1139. //      }
  1140. //  }
  1141. //
  1142. //  return -1;
  1143. //}
  1144. //
  1145. //function Request(int VoteRange, PlayerReplicationInfo PRI)
  1146. //{
  1147. //  Local bool bAvail, bOtherTeam, bInvolved;
  1148. //  Local float TimeLeft;
  1149. //  Local int  i;
  1150. //  Local string Candidate;
  1151. //
  1152. //  bAvail = true;
  1153. //  bOtherTeam = false;
  1154. //  for( i = 0 ; i < Vote.Length ; i ++)
  1155. //  {
  1156. //      if(Vote[i].bVoting)
  1157. //      {
  1158. //          if(Vote[i].Range == VOTERANGE_ALL)
  1159. //          {
  1160. //              bAvail = false;
  1161. //              bOtherTeam = true;
  1162. //              TimeLeft = FMAX(TimeLeft,Vote[i].fTimeLeft);
  1163. //          }
  1164. //          else if(Vote[i].Range == VOTERANGE_TEAM)
  1165. //          {
  1166. //              if(PRI.Team.TeamIndex == Vote[i].CandidatePRI.Team.TeamIndex)
  1167. //              {
  1168. //                  TimeLeft = FMAX(TimeLeft, Vote[i].fTimeLeft);
  1169. //                  bAvail = false;
  1170. //              }
  1171. //              else if(VoteRange == VOTERANGE_ALL)
  1172. //              {
  1173. //                  TimeLeft = FMAX(TimeLeft, Vote[i].fTimeLeft);
  1174. //                  bOtherTeam = true;
  1175. //              }
  1176. //          }
  1177. //      }
  1178. //  }
  1179. //
  1180. //  i = GetCurrentSubject(PRI);
  1181. //  if( i >= 0)
  1182. //  {
  1183. //      bInvolved  = true;
  1184. //      Candidate = Vote[i].CandidatePRI.PlayerName;
  1185. //  }
  1186. //
  1187. //  avaPlayerController(PRI.Owner).ResponseVote(VoteRange, bAvail, bOtherTeam, bInvolved, TimeLeft, Candidate);
  1188. //}
  1189. //
  1190. //defaultproperties
  1191. //{
  1192. //  // [테스트수정] fAcceptRate = 0.5 -> fAcceptRate = 0.2
  1193. //  Vote(VOTESUBJECT_SquadLeader_EU)=(Name="SquadLeader", Range=VOTERANGE_TEAM, Duration=20.0, nMinJoinNum=1, fMinVoteRate=0.2, fAcceptRate = 0.2)
  1194. //  Vote(VOTESUBJECT_SquadLeader_USSR)=(Name="SquadLeader", Range=VOTERANGE_TEAM, Duration=20.0, nMinJoinNum=1, fMinVoteRate=0.2, fAcceptRate = 0.2)
  1195. //  Vote(VOTESUBJECT_KickPlayer)=(Name="SquadLeader", Range=VOTERANGE_TEAM, Duration=10.0, nMinJoinNum=1, fMinVoteRate=0.2, fAcceptRate = 0.5)
  1196. //  Vote(VOTESUBJECT_MapSelection)=(Name="MapSelection", Range=VOTERANGE_ALL, Duration=20.0, nMinJoinNum=1, fMinVoteRate=0.5, fAcceptRate = 0.5)
  1197. //  Vote(VOTESUBJECT_DrawGame)=(Name="DrawGame", Range=VOTERANGE_ALL, Duration=30.0, nMinJoinNum=1, fMinVoteRate=0.5, fAcceptRate = 0.5)
  1198. // 
  1199. //  fUpdatePeriod = 1.0
  1200. //  fMsgDuration = 3.0
  1201. //  fFreezePeriod = 30.0
  1202. //
  1203. //  TickGroup=TG_DuringAsyncWork
  1204. //  RemoteRole=ROLE_SimulatedProxy
  1205. //  bAlwaysRelevant=true
  1206. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement