Subversion Repositories WoWGM

Rev

Rev 32 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
19 tristanc 1
#include "pch.h"
2
#pragma hdrstop
3
 
4
#include "Player_C.h"
5
 
6
#include <WowSvcs/ClientServices.h>
7
#include <Console/ConsoleClient.h>
8
 
32 tristanc 9
 
36 tristanc 10
/******************************************************************************
31 tristanc 11
*
12
*   Client memory addresses
13
*
14
***/
15
 
32 tristanc 16
#define  PLAYERCLIENTINITIALIZE 0x006E8EE0
17
#define  PLAYERCLIENTSHUTDOWN   0x006E0300
31 tristanc 18
 
19
 
36 tristanc 20
/******************************************************************************
31 tristanc 21
*
22
*   Client function pointers
23
*
24
***/
25
 
19 tristanc 26
void (*PlayerClientInitializePtr)()	= *(void(*)())PLAYERCLIENTINITIALIZE;
27
void (*PlayerClientShutdownPtr)()	= *(void(*)())PLAYERCLIENTSHUTDOWN;
28
 
31 tristanc 29
 
36 tristanc 30
/******************************************************************************
31 tristanc 31
*
32
*   Detours setup
33
*
34
***/
35
 
36 tristanc 36
//=============================================================================
31 tristanc 37
void WowGM::PlayerClientInitialize () {
19 tristanc 38
	DETOUR_INIT;
39
	DETOUR_ATTACH(PlayerClientInitializePtr,::PlayerClientInitialize);
40
	DETOUR_ATTACH(PlayerClientShutdownPtr,::PlayerClientShutdown);
41
	DETOUR_COMMIT;
42
}
43
 
36 tristanc 44
//=============================================================================
31 tristanc 45
void WowGM::PlayerClientShutdown () {
19 tristanc 46
	DETOUR_INIT;
47
	DETOUR_DETACH(PlayerClientInitializePtr,::PlayerClientInitialize);
48
	DETOUR_DETACH(PlayerClientShutdownPtr,::PlayerClientShutdown);
49
	DETOUR_COMMIT;
50
}
51
 
31 tristanc 52
 
36 tristanc 53
/******************************************************************************
31 tristanc 54
*
55
*   Private
56
*
57
***/
58
 
36 tristanc 59
//=============================================================================
31 tristanc 60
BOOL GmResurrectFailedHandler (void*        formal,
61
                               NETMESSAGE   msgId,
62
                               unsigned int eventTime,
63
                               CDataStore*  msg) {
64
 
19 tristanc 65
	BOOL failed;
66
	msg->Get(failed);
31 tristanc 67
 
68
	if (!failed)
19 tristanc 69
		ConsoleWrite("Player resurrected", DEFAULT_COLOR);
31 tristanc 70
	else
19 tristanc 71
		ConsoleWrite("resurrect failed", DEFAULT_COLOR);
31 tristanc 72
 
19 tristanc 73
	return TRUE;
74
}
75
 
36 tristanc 76
//=============================================================================
31 tristanc 77
void PlayerClientInitialize () {
19 tristanc 78
	PlayerClientInitializePtr();
79
	ClientServices_SetMessageHandler(SMSG_RESURRECT_FAILED,GmResurrectFailedHandler,0);
80
}
81
 
36 tristanc 82
//=============================================================================
31 tristanc 83
void PlayerClientShutdown () {
19 tristanc 84
	PlayerClientShutdownPtr();
85
	ClientServices_ClearMessageHandler(SMSG_RESURRECT_FAILED);
86
}
32 tristanc 87