/
h_export.cpp
145 lines (127 loc) · 3.32 KB
/
h_export.cpp
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// HPB bot - botman's High Ping Bastard bot
//
// (http://planethalflife.com/botman/)
//
// h_export.cpp
//
#ifndef _WIN32
#include <cstring>
#endif
#include <extdll.h>
#include <dllapi.h>
#include <h_export.h>
#include <meta_api.h>
#include "bot.h"
char g_argv[1024];
DLL_FUNCTIONS gFunctionTable;
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
static FILE *fp;
char z_welcome_msg[] = "HPB bot - http://planethalflife.com/botman";
extern int mod_id;
#ifndef __linux__
// Required DLL entry point
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
return TRUE;
}
#else
#define _strnicmp strncasecmp
#endif
void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{
char game_dir[256];
char mod_name[32];
char game_dll_filename[256];
// get the engine functions from the engine...
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
gpGlobals = pGlobals;
// find the directory name of the currently running MOD...
GetGameDir (game_dir);
strcpy(mod_name, game_dir);
game_dll_filename[0] = 0;
if (_strcmpi(mod_name, "valve") == 0)
{
mod_id = VALVE_DLL;
#ifndef __linux__
strcpy(game_dll_filename, "valve\\dlls\\hl.dll");
#else
strcpy(game_dll_filename, "valve/dlls/hl.so");
#endif
}
else if (_strcmpi(mod_name, "tfc") == 0)
{
mod_id = TFC_DLL;
#ifndef __linux__
strcpy(game_dll_filename, "tfc\\dlls\\tfc.dll");
#else
strcpy(game_dll_filename, "tfc/dlls/tfc.so");
#endif
}
else if (_strcmpi(mod_name, "cstrike") == 0)
{
mod_id = CSTRIKE_DLL;
#ifndef __linux__
strcpy(game_dll_filename, "cstrike\\dlls\\mp.dll");
#else
strcpy(game_dll_filename, "cstrike/dlls/cs.so");
#endif
}
else if (_strcmpi(mod_name, "gearbox") == 0)
{
mod_id = GEARBOX_DLL;
#ifndef __linux__
strcpy(game_dll_filename, "gearbox\\dlls\\opfor.dll");
#else
strcpy(game_dll_filename, "gearbox/dlls/opfor.so");
#endif
}
else if (_strcmpi(mod_name, "frontline") == 0)
{
mod_id = FRONTLINE_DLL;
#ifndef __linux__
strcpy(game_dll_filename, "frontline\\dlls\\frontline.dll");
#else
strcpy(game_dll_filename, "frontline/dlls/front_i386.so");
#endif
}
else if (_strcmpi(mod_name, "holywars") == 0)
{
mod_id = HOLYWARS_DLL;
#ifndef __linux__
strcpy(game_dll_filename, "holywars\\dlls\\holywars.dll");
#else
strcpy(game_dll_filename, "holywars/dlls/holywars_i386.so");
#endif
}
else if (_strcmpi(mod_name, "dmc") == 0)
{
mod_id = DMC_DLL;
#ifndef __linux__
strcpy(game_dll_filename, "dmc\\dlls\\dmc.dll");
#else
strcpy(game_dll_filename, "dmc/dlls/dmc.so");
#endif
}
else if (_strnicmp(mod_name, "wizardwars", 10) == 0)
{
mod_id = WIZARDWARS_DLL;
#ifndef __linux__
sprintf(game_dll_filename, "%s\\dlls\\wizardwars.dll", game_dir);
// strcpy(game_dll_filename, "wizardwars\\dlls\\wizardwars.dll");
#else
sprintf(game_dll_filename, "%s/dlls/wizardwars_i486.so", game_dir);
// strcpy(game_dll_filename, "wizardwars/dlls/wizardwars_i486.so");
#endif
}
else if (_strnicmp(mod_name, "swarm", 5) == 0)
{
mod_id = SWARM_DLL;
#ifndef __linux__
sprintf(game_dll_filename, "%s\\dlls\\swarm.dll", game_dir);
#else
sprintf(game_dll_filename, "%s/dlls/swarm_i486.so", game_dir);
#endif
}
}