View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-18-2011 , 16:39   Re: [WIP] Builtin Votes
Reply With Quote #7

I need to do more testing in TF2 to make sure the vote_changed event really isn't used. Hopefully I'll get some friends together tonight to test it on my plugin test server. I only tested with 2 people before, and I have a feeling it won't show a vote_changed event until at least 3 people are present due to the first vote automatically being placed and the second vote ending the vote with only 2.

As for vote objects, I hate doing this because it seems messy, but I've replaced

PHP Code:
BuiltinVoteHandler s_BuiltinVoteHandler
with
PHP Code:
#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
TF2VoteHandler s_BuiltinVoteHandler;
#elif SOURCE_ENGINE == SE_LEFT4DEAD
L4DVoteHandler s_BuiltinVoteHandler;
#elif SOURCE_ENGINE == SE_LEFT4DEAD2
L4D2VoteHandler s_BuiltinVoteHandler;
#endif 
It was either that or convert it to a pointer and change all the calls it made... which, upon further consideration, I will likely do instead.

I'm also in the middle of creating those classes. The TF2 version was easy, as it's essentially the behavior that's already going on. I'm working on L4D's now, as it's fairly well documented on the Wiki. I'm going to turn to Mr. Zero's documentation in the L4D Vote Manager 2 plugin thread for the L4D2 handling when I finish the L4D handling.

So, far, I've declared BuildinVoteHandler an abstract class by marking 7 functions as pure virtual functions:
PHP Code:
public:
    
void Hook_ClientCommand(edict_t *pEntity, const CCommand &args) = 0;
    
void DisplayVotePass(const char *passTranslation, const char *winner) = 0;
    
void DisplayVoteFail(BuiltinVoteFailReason reason) = 0;
protected:
    
void ShowVote(IBaseBuiltinVote *votecell_t clients[], unsigned int playersNum, const char *voteArgument "") = 0;
    
void ShowVoteCast(int entityIdint item) = 0;
    
bool SendOptions(IBaseBuiltinVote *vote) = 0;
    
void DisplayAllVotes() = 0;
}; 
All formerly-private functions and variables are now marked as protected. I'm not sure if that's necessary, but I'm a Java coder, and it is necessary there.

DisplayAllVotes is new, in order to display L4D(/L4D2?)'s vote_changed event post-vote tally... and TF2's event of the same name, should it be used.

SendOptions returns a bool now. It returns false for L4D and L4D2, as well as if the TF2 vote has no vote options listed, which indicates an error if it's a multiple choice vote.

As a side note, there will be some new code going on in CreateVote... or possibly in CBuildinVote's constructor... to add Yes and No votes to the vote item list in order to make vote processing consistent among the 3 handlers. I'm thinking the constructor is the best place to do this, as it has access to which type of vote is going on and I can make the Add/Insert/Remove item functions return an error should it be marked as a Yes/No vote.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-18-2011 at 17:04.
Powerlord is offline