-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcheat_global.m
128 lines (101 loc) · 3.74 KB
/
cheat_global.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* The Cheat - The legendary universal game trainer for Mac OS X.
* http://www.brokenzipper.com/trac/wiki/TheCheat
*
* Copyright (c) 2003-2011, Charles McGarvey et al.
*
* Distributable under the terms and conditions of the 2-clause BSD
* license; see the file COPYING for the legal text of the license.
*/
#import "cheat_global.h"
#import <Carbon/Carbon.h>
// globals
float gFadeAnimationDuration = TCDefaultFadeAnimation;
// user default constants
NSString *TCFirstLaunchPref = nil;
NSString *TCWindowsOnTopPref = @"TCWindowsOnTopPref";
NSString *TCUpdateCheckPref = @"TCUpdateCheckPref";
NSString *TCDisplayValuesPref = @"TCDisplayValuesPref";
NSString *TCValueUpdatePref = @"TCValueUpdatePref";
NSString *TCHitsDisplayedPref = @"TCHitsDisplayedPref";
NSString *TCRunServerPref = @"TCRunServerPref";
NSString *TCBroadcastNamePref = @"TCBroadcastNamePref";
NSString *TCListenPortPref = @"TCListenPortPref";
NSString *TCFadeAnimationPref = @"TCFadeAnimationPref";
NSString *TCAskForSavePref = @"TCAskForSavePref";
NSString *TCSwitchVariablesPref = @"TCSwitchVariablesPref";
NSString *TCAutoStartEditingVarsPref = @"TCAutoStartEditingVarsPref";
// notification constants
NSString *TCServiceFoundNote = @"TCServiceFoundNote";
NSString *TCServiceRemovedNote = @"TCServiceRemovedNote";
NSString *TCServerStartedNote = @"TCServerStartedNote";
NSString *TCServerStoppedNote = @"TCServerStoppedNote";
NSString *TCServerConnectionsChangedNote = @"TCServerConnectionsChangedNote";
NSString *TCWindowsOnTopChangedNote = @"TCWindowsOnTopChangedNote";
NSString *TCDisplayValuesChangedNote = @"TCDisplayValuesChangedNote";
NSString *TCHitsDisplayedChangedNote = @"TCHitsDisplayedChangedNote";
void LaunchWebsite()
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.brokenzipper.com/"]];
}
void LaunchEmail()
{
//[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"mailto:[email protected]?subject=The%20Cheat%20Feedback"]];
/* Ed Palma will act as a contact person for The Cheat. */
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.brokenzipper.com/contact.html"]];
}
int MacOSXVersion()
{
SInt32 static version = -1;
if ( version != -1 ) {
return (int)version;
}
// get the version
if ( Gestalt( gestaltSystemVersion, &version ) != noErr ) {
return -1;
}
return (int)version;
}
NSString *ApplicationVersion( NSString *appPath )
{
NSString *tVersion = nil;
NSBundle *tBundle = [NSBundle bundleWithPath:appPath];
if ( tBundle ) {
NSDictionary *tInfoDictionary;
tInfoDictionary = [tBundle infoDictionary];
if ( tInfoDictionary ) {
tVersion = [tInfoDictionary objectForKey:@"CFBundleShortVersionString"];
if ( !tVersion ) {
tVersion = [tInfoDictionary objectForKey:@"CFBundleVersion"];
}
}
}
else {
CFBundleRef tBundleRef;
short resNum = 0;
tBundleRef = CFBundleCreate( NULL, (CFURLRef)[NSURL fileURLWithPath:appPath] );
if ( tBundleRef ) {
resNum = CFBundleOpenBundleResourceMap( tBundleRef );
}
if ( resNum != 0 ) {
VersRecHndl tVersionHandle;
unsigned long tNumVersion;
tVersionHandle = (VersRecHndl)Get1IndResource( 'vers', 1 );
if ( tVersionHandle ) {
tNumVersion = *((unsigned long *) &((*tVersionHandle)->numericVersion));
if ( (tNumVersion & 0x00040000) != 0 ) {
tVersion = [NSString stringWithFormat:@"%d.%d.%d", (tNumVersion & 0xFF000000)>>24, (tNumVersion & 0x00F00000)>>20, (tNumVersion & 0x000F0000)>>16];
}
else {
tVersion = [NSString stringWithFormat:@"%d.%d", (tNumVersion & 0xFF000000)>>24, (tNumVersion & 0x00F00000)>>20];
}
}
}
if ( tBundleRef ) {
CFBundleCloseBundleResourceMap( tBundleRef, resNum );
// Release Memory
CFRelease( tBundleRef );
}
}
return tVersion;
}