Raised This Month: $12 Target: $400
 3% 

[L4D,L4D2,TF2] BuiltinVotes 0.5.8 (2013-01-29)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-15-2011 , 16:28   [L4D,L4D2,TF2] BuiltinVotes 0.5.8 (2013-01-29)
Reply With Quote #1

Instead of using this extension, help us test NativeVotes!

Any servers running SourceMod 1.4 or 1.5 hg3754 or below need version 0.5.7. Linux TF2 servers running 3754 or below will need the .so file from this post.


Now on Google Code!

Don't forget about the Client Side Transparency mod for TF2!

Common Problems:

I'm seeing an error "[BV] Unknown fatal error while translating a phrase."

These errors are related to the vote progress cvars. One of the SourceMod Core translation phrases has the wrong number of arguments. You can find out which phrase and which language number it's for using a Debug version of the extension. You can then get the language name and code using the plugin in this post.

Please, post the error in this thread and we'll see if we can get the translation phrase fixed in the next SourceMod version.

Currently known translation issues (1.4.1):
  • Dutch (nl): "Voted For", fix expected in 1.4.2
Previous known translation issues (if you see these errors, update your translation files):
  • Swedish (sv) : "Vote Count", fixed in 1.4.1
  • Danish (da): "Vote Count", fixed in 1.4.0
I'm getting a FAILED error for your extension, but I'm not running L4D/L4D2/TF2 or am not [interested in] running your extension!

Assuming you mean this error:

Code:
[4] <FAILED> file "builtinvotes.ext.dll": The specified module could not be found.
This is a known SourceMod issue. Any extension or plugin that you're not running that is listed as an optional dependency for a plugin will show this error.

You'll run into this error if you're using MapChooser Extended 1.8 or newer.

For End Users:

What is BuiltinVotes?

BuiltinVotes is a SourceMod 1.4 Extension that lets plugins use the L4D/L4D2/TF2 built-in vote screens.

Why use it?

The SourceMod vote system uses the 0-9 keys to register votes, which prevent weapon changes while the vote is displayed. This system uses F1-F2 for Yes/No votes and F1-F5 for multiple choice votes (TF2 only).

Better yet, most non-custom votes have their vote message, success message, and failure message translated by Valve for all languages the games support.

What are the Downsides?

/revote and !revote display a failure message and have a 3 second delay before redisplaying the vote. The technical reason for this is explained in the Plugin Developers section.

L4D and L4D2 are limited to Yes/No votes only. TF2 votes are limited to 5 choices.

For votes with more than these, you still need to use the SourceMod voting system.

Settings

BuiltinVotes hooks five SourceMod vote-related cvars for displaying ongoing votes:
  • sm_vote_delay
  • sm_vote_progress_hintbox
  • sm_vote_progress_chat
  • sm_vote_progress_console
  • sm_vote_progress_client_console
These are configured in cfg/sourcemod/sourcemod.cfg and are also used by the SourceMod vote system.


Plugins that currently support BuiltinVotesThe rest of this documentation is for developers, so you probably want to skip down to the builtinvotes.zip link.

For Plugin Developers:

Spoiler


Changelog:
  • 0.5.8 (2013-01-29)
    • Updated for breaking changes in the SourceMod IUserMessages extension interface.
    • This is the FINAL version of BuiltinVotes. Its replacement, the plugin NativeVotes, is nearly ready to begin testing.
  • builtinvotes.inc update #2 (2012-03-20)
    • Added DisplayBuiltinVoteToAllNonSpectators
    • Fixed the previously added team vote functions.
  • builtinvotes.inc update #1 (2012-03-16)
    • Added DisplayBuiltinVoteToTeam, DisplayBuiltinVoteToAllButOne, and DisplayBuiltinVoteToTeamButOne.
  • 0.5.7a (2012-03-06):
    • Modified debugging code to help track down translation issues. Main extension unchanged.
  • 0.5.7 (2012-02-20):
    • Reworked Cancel method to call CancelVoting internally
    • Cancel now properly kills the Display timer, which prevents a crash.
    • Rolled back DecrementPlayerCount change from previous version because it potentially introduced new issues.
    • The Cancel screen is no longer automatically shown when a vote object is disposed. This was necessary to fix the issues with Canceling votes causing errors.
    • Votes that were canceled will no longer be redisplayed if a user uses !revote unless another vote is called first. Hopefully you won't do that, as the vote may have the old vote type or title with the new vote's options.
    • Oh hey, it looks like Cancel is finally working and stable. It only took from 0.5.2 to 0.5.7 to iron out the bugs... now to debug the translations issue.
  • 0.5.4 (2012-02-19):
    • Fixed issue with crashes on map change. Be aware that the Cancel and End callbacks will be called on map start for the vote object.
    • Fixed an issue where disconnecting players were not being removed from the maximum vote count.
  • 0.5.1 (2012-01-19):
    • Fixed two potential memory leaks.
  • 0.5.0 (2011-12-04):
    • The L4D2 Alltalk vote is now present as a vote translation text.
    • Now includes a plugin to enable !revote and /revote for BuiltinVotes. NOTE: Because of the way this plugin is written, any Radio or Valve menus will not have /revote or !revote available when a BuiltinVotes vote is showing.
      • There is a forced 3 second delay between when you type !revote and the revote screen appearing. This is required due to how Valve handles votes in TF2; a vote failed screen is required to re-enable the vote keys. Due to this, !revote isn't allowed within the last 3 seconds of a vote.
      • Only tested on TF2, although it should also work on L4D and L4D2.
    • Fixed an error in the BuiltinVotes revoting logic which would end votes early if people revoted.
    • Fixed a bug in cvar handling that would sometimes cause a crash when the extension was unloaded. Unfortunately, there's still a OnClientDisconnected bug that sometimes causes the extension to crash when unloaded that I haven't been able to track down. (Technically, it's SourceMod that's crashing, but it only happens when the BuiltinVotes extension is reloaded)
    • New function, DisplayBuiltinVotePass2. This allows you to specify the translation constant that the Vote Passed screen should use. This should only be done for game-specific plugins, as the translation phrases for L4D/L4D2 don't work in TF2 (and vice versa).
    • Updated builtinvotes.inc that includes the new function mentioned above plus all the translation constants from the Extension side... including the START translations which aren't actually used for anything on the plugin side... yet...
  • 0.4.1 (2011-11-08)
    • Fixed a bug in L4D/L4D2 were recording votes backwards. Turns out that missing an == 0 is bad. L4D still untested, but L4D2 support appears to work.
    • Fixed a bug where vote counts weren't cleared before the start of a vote in L4D/L4D2.
    • Updated Makefile and Visual C++ projects to SourceMod 1.4 versions. The net result of this is that Linux builds are now slightly smaller and the Makefile will now work in OSX.
  • 0.4.0 (2011-11-07)
    • Preliminary (and untested) support for L4D and L4D2
    • Fixed issues with Yes/No votes in TF2
    • Updated builtinvotes.inc
      • Added two new constants: BUILTINVOTES_VOTE_YES and BUILTINVOTES_VOTE_NO, which are returned as param1 for a Yes/No vote's BuiltinVoteAction_VoteEnd callback.
      • Removed BUILTINVOTES_NO_VOTE, which is from the C++ side and not exposed to the public.
      • Updated documentation for BuiltinVoteAction_Cancel to document that yes, it does return a param1 value.
  • 0.0.3.0 (2011-11-05 (am))
    • Fix bug where players could vote multiple times.
    • Modified when the vote command is hooked. Normal built-in votes should now work when no vote is being displayed. Later versions may also hook callvote to prevent built-in votes from being called while the vote is displayed.
    • OnClientCommand moved to Vote classes from VoteStyle classes. BuiltinVoteHandler now gets passed vote item first and does sanity checks.
    • Fixed dumb mistake in marking users as having pending votes.
  • 0.0.2.0 - Initial Public TF2 Release
Attached Files
File Type: inc builtinvotes.inc (25.2 KB, 1751 views)
File Type: zip builtinvotes 0.5.7.zip (423.9 KB, 2490 views)
File Type: zip builtinvotes debug 0.5.7a.zip (2.30 MB, 897 views)
File Type: zip builtinvotes_src 0.5.7a.zip (68.5 KB, 952 views)
File Type: zip builtinvotes 0.5.8.zip (452.7 KB, 3815 views)
File Type: zip builtinvotes src 0.5.8.zip (69.0 KB, 1433 views)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 02-14-2013 at 11:09. Reason: Updated builtinvotes.inc
Powerlord is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 07-15-2011 , 23:49   Re: [WIP] Builtin Votes
Reply With Quote #2

Oh my gosh you don't have VS2010?! It's so much better.

Also, I can see a possible place where a crash might happen in CreateBuiltinVote: You create a pointer but never check to see that it's valid before making a call to one of its members.
Code:
 IBaseBuiltinVote *vote = g_BuiltinVoteManager.CreateVote(handler, pContext->GetIdentity(), params[4], startTranslation);
might want to add something like

Code:
if (!vote)
    return -1;
after you create the vote, just to make sure it doesn't crash there if you run out of memory or can't create a new vote object for whatever reason.

Last edited by Afronanny; 07-15-2011 at 23:55.
Afronanny is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-16-2011 , 00:06   Re: [WIP] Builtin Votes
Reply With Quote #3

Quote:
Originally Posted by Afronanny View Post
Oh my gosh you don't have VS2010?! It's so much better.
I do at home, but not at work.

Quote:
Originally Posted by Afronanny View Post
Also, I can see a possible place where a crash might happen in CreateBuiltinVote: You create a pointer but never check to see that it's valid before making a call to one of its members.
Code:
 IBaseBuiltinVote *vote = g_BuiltinVoteManager.CreateVote(handler, pContext->GetIdentity(), params[4], startTranslation);
might want to add something like

Code:
if (!vote)
    return -1;
after you create the vote, just to make sure it doesn't crash there if you run out of memory or can't create a new vote object for whatever reason.
I'll probably work on this some tomorrow. I'll keep that in mind.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
FlaminSarge
Veteran Member
Join Date: Jul 2010
Old 07-17-2011 , 01:04   Re: [WIP] Builtin Votes
Reply With Quote #4

I thought you could already access tf2 votes via usermessages? Does this ext plan to allow for more customization of the vote strings?
__________________
Bread EOTL GunMettle Invasion Jungle Inferno will break everything. Don't even ask.

All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions.
Steam is for playing games.
You will be fed to javalia otherwise.
Psyduck likes replays.
FlaminSarge is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 07-17-2011 , 01:10   Re: [WIP] Builtin Votes
Reply With Quote #5

Quote:
Originally Posted by FlaminSarge View Post
I thought you could already access tf2 votes via usermessages? Does this ext plan to allow for more customization of the vote strings?
You can. That's what this extension does, except it acts as a "vote manager" for plugins. If you read the extension's source, you'll see that it does indeed use usermessages.
Afronanny is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-17-2011 , 09:34   Re: [WIP] Builtin Votes
Reply With Quote #6

Quote:
Originally Posted by FlaminSarge View Post
I thought you could already access tf2 votes via usermessages? Does this ext plan to allow for more customization of the vote strings?
The entire point of this extension is to manage that for you. It also supports many commands similar to those

Sadly, I didn't get a chance to work on this yesterday (I was doing a lot of TF2 trading stuffs).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
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
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-21-2011 , 14:06   Re: [WIP] Builtin Votes
Reply With Quote #8

I think I'm going to try simplifying this a bit. The Vote object + Vote Handler object + Vote Manager object + separate natives objects may work for the SourceMod built-in Menu system, but it's overkill for this. I find that every time I make the slightest change, I have to go across 8 different files for fixes.

Sadly, the first thing to get the ax is the interface file. I'm not sure any other extensions would want to use this anyway, though. This won't affect plugins, as they use natives.

Alternatively, I'd love to see if I can add this to the SourceMod built-in menu system (meaning I'd have to create it as a MenuStye). However, some of the things SourceMod does now would end up being no-ops in the new system. Unless I made pagination work in TF2, which would be really sad, as it only supports 5 items.

P.S. If anyone can post the L4D/L4D2 translation strings for votes, plus a translation string that consists of nothing but "%s1" for L4D2, I'd be greatful. I found out the hard way that L4D2 doesn't install its translation file on the dedicated server, and it's like a 16+GB download to install L4D and L4D2.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-21-2011 at 14:30.
Powerlord is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-29-2011 , 22:42   Re: [WIP] Builtin Votes
Reply With Quote #9

I was hoping to complete a new test version this weekend, but it turns out I've run into a problem. Said problem likely stems from my poor C++ skills...

Anyway, I've attached the current source tree. There are some issues with extension.cpp because I need to write some methods yet, and there is still some logic missing from the various vote classes, but that's not what I need help with.

The real problem is the "error C2259: 'L4DVote' : cannot instantiate abstract class" I'm getting from Visual Studio 2010 (note: This happens for TF2Vote, L4DVote, and L4D2Vote classes as I switch configs).

I've tried Go To Definition for every function defined in Votes.h, and every function I can see exists in Votes.cpp. Can anyone see why VC++ thinks they're all abstract classes (BaseVote's the only one that's supposed to be abstract), despite having every method I can see defined?

P.S. Is there any way to get it to tell me which method isn't defined?

P.P.S. Both the msvc9 and msvc10 projects should contain all the files necessary to compile. The msvc8 project needs Votes.h and Votes.cpp added.
Attached Files
File Type: zip builtinvotes-source.zip (38.2 KB, 760 views)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-29-2011 at 22:56.
Powerlord is offline
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 07-30-2011 , 12:32   Re: [WIP] Builtin Votes
Reply With Quote #10

Quote:
Originally Posted by Powerlord View Post
Said problem likely stems from my poor C++ skills...
Sorry if this has already been answered, but couldn't this be done in pawn (still providing natives) since it's based on usermessages?
GoD-Tony is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode