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

TF2 Vote Usermessages


Post New Thread Reply   
 
Thread Tools Display Modes
Monkeys
Veteran Member
Join Date: Jan 2010
Old 05-26-2011 , 04:31   Re: TF2 Vote Usermessages
Reply With Quote #11

I'm thinking the m_nVoteOptionCount subclass is the options it's giving. No clue why it's an integer, won't know 'till you read them.


As you said you don't have any experience working with netprops, here's how you could read it:
PHP Code:
ReadEntityData(Entity)
{
    new 
offs FindSendPropOffs("CVoteController""m_nVoteOptionCount");
    if(
offs > -1)
    {
        new 
data;
        for(new 
0;5;i++) // 5 members, 0 -> 4
        
{
            
data GetEntData(Entityoffs + (i*4), 1); //size 1, because it's only 8 bits
            
PrintToChatAll("m_nVoteOptionCount: Member: %d, Offset: %d, Content: %d"ioffs + (i*4), data);
        } else
            
PrintToChatAll("Could not find offset");
    }

where Entity's the CVoteController entity you find. (There could be several, but highly unlikely)
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-26-2011 , 08:35   Re: TF2 Vote Usermessages
Reply With Quote #12

Quote:
Originally Posted by Monkeys View Post
I'm thinking the m_nVoteOptionCount subclass is the options it's giving. No clue why it's an integer, won't know 'till you read them.
My theory is that each map has its own number. It'd be nice if they mapped to the way the default maplist.txt is ordered, but I'll have to find out the hard way after work today. The down side of this would mean it's impossible to add custom maps to this list.

Also, thanks for the example code.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-26-2011 at 08:46.
Powerlord is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 05-26-2011 , 13:13   Re: TF2 Vote Usermessages
Reply With Quote #13

It could be in reference to the server's mapcycle. That means you can add custom maps to it, but they'll need to be in the cycle.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-26-2011 , 13:36   Re: TF2 Vote Usermessages
Reply With Quote #14

Quote:
Originally Posted by Monkeys View Post
It could be in reference to the server's mapcycle. That means you can add custom maps to it, but they'll need to be in the cycle.
It could be, but then the server would have to transfer its map cycle to the client at some point, which I didn't see.

I'll have to test this... in fact, I'll try it tonight. My testing server uses the same directory as my event server does, so I should have a bunch of custom maps on it I can throw into the mapcycle.

Incidentally, I know it's not the server's maplist, as my server uses maplist.txt as the source of its nominations list, so it's been... adjusted.

Yeah, kind of dumb on my part, but I haven't gotten around to switching to a different file. You think I would have the first time a game update wiped out my maplist.txt file.

Incidentally, the usermessages are likely useless to us. What we need is the signatures for the functions inside CVoteController. Otherwise, the server doesn't send updates to the clients machine with the current vote numbers or update the vote's pass/fail status.

While we can emulate the latter, the former appears to be updated through some other mechanism... I'm not sure what. That is, unless it rebroadcasts every vote to every user, which I didn't see.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-26-2011 at 13:49.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-26-2011 , 13:40   Re: TF2 Vote Usermessages
Reply With Quote #15

Quote:
Originally Posted by Powerlord View Post
It could be, but then the server would have to transfer its map cycle to the client at some point, which I didn't see.
I think there's a stringtable for it.

Edit: indeed, Table ServerMapCycle

Last edited by psychonic; 05-26-2011 at 13:43.
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-26-2011 , 14:06   Re: TF2 Vote Usermessages
Reply With Quote #16

Quote:
Originally Posted by psychonic View Post
I think there's a stringtable for it.

Edit: indeed, Table ServerMapCycle
Ooh, interesting. I'll have to look into that as well.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-26-2011 , 15:43   Re: TF2 Vote Usermessages
Reply With Quote #17

I never realized exactly how much was going on in server.so.

I've found a few interesting functions while looking through an objdump of server.so.

Specifically:

_ZN15CVoteController9SetupVoteEi
_ZN15CVoteController21SendVoteFailedMessageE2 0vote_create_failed_tP11CBasePlayeri
_ZN15CVoteController10CreateVoteEiPKcS1_
_ZN15CVoteController20GetWinningVoteOptionEv

At a guess, SetupVote takes an issue object (i.e. CNextLevelIssue) as an input.
At a guess, SendVoteFailedMessage takes a vote_create_failed_t (numerical value?) and a CBasePlayer as arguments.

Unfortunately, I'm not that familiar with assembly code (yes, I admitted it!), so I'm not sure what arguments most of those take. Presumably, if we can get CreateVote working, the others will be fairly automatic.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-26-2011 at 15:48.
Powerlord is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-26-2011 , 16:54   Re: TF2 Vote Usermessages
Reply With Quote #18

objdump apparently has this neat -C option that cleans up the calling conventions.

I now know some of the arguments the functions take, but not what they mean:

CVoteController::SetupVote(int)
CVoteController::CreateVote(int, char const*, char const*)

I'm assuming the character pointers are actually strings.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-26-2011 , 20:32   Re: TF2 Vote Usermessages
Reply With Quote #19

By the way, while this isn't relevant for starting a vote (I think), hl2/resource/gameevents.res now defines the following events for Orange Box games:
Code:
        // Client side VoteController talking to HUD
        "vote_ended"
        {
        }
        "vote_started"
        {
                "issue"                 "string"
                "param1"                "string"
                "team"                  "byte"
                "initiator"             "long" // entity id of the player who in
itiated the vote
        }
        "vote_changed"
        {
                "vote_option1"          "byte"
                "vote_option2"          "byte"
                "vote_option3"          "byte"
                "vote_option4"          "byte"
                "vote_option5"          "byte"
                "potentialVotes"        "byte"
        }
        "vote_passed"
        {
                "details"               "string"
                "param1"                "string"
                "team"                  "byte"
        }
        "vote_failed"
        {
                "team"                  "byte"
        }
        "vote_cast"
        {
                "vote_option"   "byte"  // which option the player voted on
                "team"                  "short"
                "entityid"              "long"  // entity id of the voter
        }
        "vote_options"
        {
                "count"                 "byte"  // Number of options - up to MAX
_VOTE_OPTIONS
                "option1"               "string"
                "option2"               "string"
                "option3"               "string"
                "option4"               "string"
                "option5"               "string"
        }
In other words, rather than trying to hook commands in CVoteController, we could just fake it.

These events could also help us figure out what data the CVoteController commands take.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-26-2011 at 20:39.
Powerlord is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-26-2011 , 22:11   Re: TF2 Vote Usermessages
Reply With Quote #20

After hooking all 6 events, I found out that the map vote doesn't trigger all of them.

Specifically:
L 05/26/2011 - 22:06:07: [vote_test.smx] Vote options. Count: 5, Option 1: ctf_well, Option 2: koth_sawmill, Option 3: koth_nucleus, Option 4: ctf_well, Option 5 Extend current Map
L 05/26/2011 - 22:06:10: [vote_test.smx] Vote cast. Option: 3, Team: -1, Entity ID: 1
L 05/26/2011 - 22:06:10: Vote succeeded "NextLevel ctf_well"
L 05/26/2011 - 22:06:13: server_cvar: "nextlevel" "ctf_well"

You'll notice that vote_start, vote_passed, and vote_end were never triggered. "Vote succeeded" is a message from the TF2 vote system itself (it logs whenever a player starts a vote, too).

Also, the vote_cast was for the second ctf_well... the fourth option in the list... it appears to be zero-based.

So, from the sounds of it, you need a mix of usermessages and events in order to fake the vote system. I'm still wondering what will happen if I send the events instead, and that will likely be what I try next.

Side note: This is the messages that appear when you try a NextLevel vote from the menu:
L 05/26/2011 - 22:10:49: [vote_test.smx] Vote options. Count: 2, Option 1: cp_badlands, Option 2: Extend current Map, Option 3: , Option 4: , Option 5
L 05/26/2011 - 22:10:49: [vote_test.smx] Vote cast. Option: 0, Team: -1, Entity ID: 1
L 05/26/2011 - 22:11:04: Vote succeeded "NextLevel cp_well"
L 05/26/2011 - 22:11:07: server_cvar: "nextlevel" "cp_well"

Note that vote options is... completely wrong to say the least, as this was a Yes/No vote.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-26-2011 at 22:15.
Powerlord is offline
Reply



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 00:34.


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