~ubuntu-branches/ubuntu/raring/mumble/raring

« back to all changes in this revision

Viewing changes to plugins/l4d/l4d.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thorvald Natvig
  • Date: 2010-01-09 19:28:50 UTC
  • mfrom: (9.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100109192850-zs4g5vwrrpd71kob
Tags: 1.2.1-2
Fix upgrade failure when upgrading mumble-server directly from 1.1.x
to 1.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com>
 
2
 
 
3
   All rights reserved.
 
4
 
 
5
   Redistribution and use in source and binary forms, with or without
 
6
   modification, are permitted provided that the following conditions
 
7
   are met:
 
8
 
 
9
   - Redistributions of source code must retain the above copyright notice,
 
10
     this list of conditions and the following disclaimer.
 
11
   - Redistributions in binary form must reproduce the above copyright notice,
 
12
     this list of conditions and the following disclaimer in the documentation
 
13
     and/or other materials provided with the distribution.
 
14
   - Neither the name of the Mumble Developers nor the names of its
 
15
     contributors may be used to endorse or promote products derived from this
 
16
     software without specific prior written permission.
 
17
 
 
18
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
19
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
20
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
21
   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
 
22
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
23
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
24
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
25
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
26
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
27
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
28
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
*/
 
30
 
1
31
#include <stdio.h>
2
32
#include <stdlib.h>
3
33
#include <windows.h>
11
41
HANDLE h;
12
42
BYTE *posptr;
13
43
BYTE *rotptr;
 
44
BYTE *stateptr;
14
45
 
15
46
static DWORD getProcess(const wchar_t *exename) {
16
47
        PROCESSENTRY32 pe;
61
92
}
62
93
 
63
94
static void about(HWND h) {
64
 
        ::MessageBox(h, L"Reads audio position information from Left 4 Dead (Build 3922)", L"Mumble L4D Plugin", MB_OK);
 
95
        ::MessageBox(h, L"Reads audio position information from Left 4 Dead (Build 4023).", L"Mumble L4D Plugin", MB_OK);
65
96
}
66
97
 
67
98
static bool calcout(float *pos, float *rot, float *opos, float *front, float *top) {
114
145
 
115
146
        posptr = mod + 0x580588;
116
147
        rotptr = mod + 0x4FF024;
 
148
        stateptr = mod + 0x4F8E34;
117
149
 
118
150
        float pos[3];
119
151
        float rot[3];
141
173
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) {
142
174
        float ipos[3], rot[3];
143
175
        bool ok;
 
176
        char state;
 
177
 
144
178
        ok = peekProc(posptr, ipos, 12) &&
145
 
             peekProc(rotptr, rot, 12);
 
179
             peekProc(rotptr, rot, 12) &&
 
180
             peekProc(stateptr, &state, 1);
 
181
 
 
182
        if (state == 0)
 
183
                return true; // This results in all vectors beeing zero which tells Mumble to ignore them.
146
184
 
147
185
        if (ok) {
148
186
                int res = calcout(ipos, rot, avatar_pos, avatar_front, avatar_top);
164
202
}
165
203
 
166
204
static const std::wstring longdesc() {
167
 
        return std::wstring(L"Supports L4D version 3986 only. Supports no fancy stuff.");
 
205
        return std::wstring(L"Supports L4D version 4023 only. Supports no fancy stuff.");
168
206
}
169
207
 
170
 
static std::wstring description(L"Left 4 Dead (Build 3986)");
 
208
static std::wstring description(L"Left 4 Dead (Build 4023)");
171
209
static std::wstring shortname(L"Left 4 Dead");
172
210
 
173
211
static MumblePlugin l4dplug = {