~ubuntu-branches/ubuntu/saucy/mumble/saucy

« back to all changes in this revision

Viewing changes to plugins/l4d2/l4d2.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2012-05-24 20:32:56 UTC
  • mfrom: (1.4.8)
  • Revision ID: package-import@ubuntu.com-20120524203256-b7ax994zjba4gft5
Tags: 1.2.3-348-g317f5a0-1
* New upstream snapshot from 20.05.2012.
* Build with now available libpulse on hurd-i386.
* Overwrite false positive hardening-no-stackprotector lintian warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2005-2011, Thorvald Natvig <thorvald@natvig.com>
 
1
/* Copyright (C) 2005-2012, Thorvald Natvig <thorvald@natvig.com>
 
2
   Copyright (C) 2012, dark_skeleton (d-rez) <dark.skeleton@gmail.com>
2
3
 
3
4
   All rights reserved.
4
5
 
30
31
 
31
32
#include "../mumble_plugin_win32.h"
32
33
 
33
 
BYTE *posptr;
34
 
BYTE *rotptr;
35
 
// BYTE *stateptr;
 
34
static BYTE *posptr;
 
35
static BYTE *rotptr;
 
36
static BYTE *stateptr;
 
37
static BYTE *contextptr;
36
38
 
37
39
static bool calcout(float *pos, float *rot, float *opos, float *front, float *top) {
38
40
        float h = rot[0];
67
69
}
68
70
 
69
71
static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
70
 
        posptr = rotptr = NULL;
 
72
        posptr = rotptr = stateptr = contextptr = NULL;
71
73
 
72
74
        if (! initialize(pids, L"left4dead2.exe", L"client.dll"))
73
75
                return false;
74
76
 
75
 
        posptr = pModule + 0x6F9250;
 
77
        posptr = pModule + 0x641A4C;
76
78
        rotptr = pModule + 0x641A08;
77
 
        // stateptr = pModule + 0x690A3C;
78
 
 
 
79
        stateptr = pModule + 0x6A1AF4;
 
80
        contextptr = pModule + 0x6f487c;
 
81
        
79
82
        float pos[3];
80
83
        float rot[3];
81
84
        float opos[3], top[3], front[3];
82
 
 
 
85
        char state, _context[21];
83
86
        bool ok = peekProc(posptr, pos, 12) &&
84
 
                  peekProc(rotptr, rot, 12);
 
87
                  peekProc(rotptr, rot, 12) &&
 
88
                          peekProc(stateptr, &state, 1) &&
 
89
                          peekProc(contextptr, _context);
85
90
 
86
91
        if (ok)
87
92
                return calcout(pos, rot, opos, top, front);
91
96
        return false;
92
97
}
93
98
 
94
 
static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &identity) {
 
99
static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &/*identity*/) {
95
100
        for (int i=0;i<3;i++)
96
101
                avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;
97
102
 
98
103
        float ipos[3], rot[3];
99
104
        bool ok;
100
 
        // char state;
 
105
        char state;
 
106
        char _context[21];
101
107
 
102
108
        // stateptr returns byte values: 0 when map is not loaded; 8 when loaded
103
109
        ok = peekProc(posptr, ipos, 12) &&
104
 
             peekProc(rotptr, rot, 12);
105
 
        // peekProc(stateptr, &state, 1);
 
110
             peekProc(rotptr, rot, 12) &&
 
111
                 peekProc(stateptr, &state, 1) &&
 
112
                 peekProc(contextptr, _context);
106
113
 
107
 
        // if (state == 0)
108
 
        //      return true; // This results in all vectors beeing zero which tells Mumble to ignore them.
 
114
        if (state == 0) {
 
115
                context = std::string(""); // clear context
 
116
                return true; // This results in all vectors beeing zero which tells Mumble to ignore them.
 
117
        }
109
118
 
110
119
        if (ok) {
111
120
                int res = calcout(ipos, rot, avatar_pos, avatar_front, avatar_top);
116
125
                                camera_top[i] = avatar_top[i];
117
126
 
118
127
                                // Example only -- only set these when you have sane values, and make sure they're pretty constant (every change causes a sever message).
119
 
                                context = std::string("server/map/blah");
120
 
                                identity = std::wstring(L"STEAM_1:2:3456789");
 
128
                                //context = std::string("server/map/blah");
 
129
                                //identity = std::wstring(L"STEAM_1:2:3456789");
 
130
                        }
 
131
                        std::string sHost(_context);
 
132
                        // This string can be either "xxx.xxx.xxx.xxx:yyyyy" (or shorter), "loopback:0" or "" (empty) when in menus. Hence 21 size for char.
 
133
                        if (!sHost.empty())
 
134
                        {
 
135
                                if (sHost.find("loopback") == std::string::npos)
 
136
                                {
 
137
                                        std::ostringstream newcontext;
 
138
                                        newcontext << "{\"ipport\": \"" << sHost << "\"}";
 
139
                                        context = newcontext.str();
 
140
                                }
 
141
                                                
121
142
                        }
122
143
                        return res;
123
144
                }
127
148
}
128
149
 
129
150
static const std::wstring longdesc() {
130
 
        return std::wstring(L"Supports L4D2 build 4490. No identity or context support yet.");
 
151
        return std::wstring(L"Supports L4D2 build 4777 with context support. No identity support yet.");
131
152
}
132
153
 
133
 
static std::wstring description(L"Left 4 Dead 2 (Build 4490)");
 
154
static std::wstring description(L"Left 4 Dead 2 (Build 4777)");
134
155
static std::wstring shortname(L"Left 4 Dead 2");
135
156
 
136
157
static int trylock1() {