-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathquake.h
More file actions
130 lines (107 loc) · 4.3 KB
/
quake.h
File metadata and controls
130 lines (107 loc) · 4.3 KB
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
/*
minqlbot - A Quake Live server administrator bot.
Copyright (C) 2015 Mino <mino@minomino.org>
This file is part of minqlbot.
minqlbot is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
minqlbot is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with minqlbot. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define STRUCT_OFFSET_PSERVERCOMMANDS 0xF7
#define STRUCT_OFFSET_PCLIENTSTATIC 0x2
#define STRUCT_OFFSET_PCONFIGSTRINGS 0x23
#define OFFDIFF_CLC_SERVERCMDS 0x10014 // &servercmds - &clc
#define MAX_RELIABLE_COMMANDS 64
#define MAX_STRING_CHARS 1024
#define MAX_STRING_TOKENS 256
// The bot bottlenecks server commands. This macro defines the delay between each message.
#define DELAY_SEND_COMMAND 600
// The time of the Sleep call in the main loop.
#define DELAY_MAIN_LOOP 20
#include "common.h"
#include "quake_common.h"
#include <string>
#include <vector>
#include <boost/python.hpp>
namespace quake {
enum CONNECTION_STATUS {
CONN_CLOSED = 0,
CONN_DISCONNECTED = 1,
CONN_CONNECTING = 3,
CONN_AWAITING_CHALLENGE = 4,
CONN_AWAITING_GAMESTATE = 5,
CONN_RECEIVING_GAMESTATE = 6,
CONN_AWAITING_SNAPSHOT = 7,
CONN_CONNECTED = 8
};
// Quake Live base pointer.
extern void * qlbase;
// Original functions.
typedef void (__cdecl * ParseServerMessage)(void * msg);
typedef int (__cdecl * ParseCommandString)(void * msg);
typedef int (__cdecl * ParseGamestate)(void * msg);
typedef char * (__cdecl * ReadBigString)(void * msg);
typedef int (__cdecl * ReadShort)(void * msg);
typedef void (__cdecl * AddReliableCommand)(const char * cmd);
typedef void (__cdecl * AddCommand)(const char * cmd, void * func);
typedef void (__cdecl * RemoveCommand)(const char * cmd);
typedef char * (__cdecl * GetArgs)();
typedef void (__cdecl * ConsolePrint)(const char * msg);
typedef cvar_t * (__cdecl * CvarFind)(const char * var_name);
typedef void (__cdecl * ExecuteString)(const char * msg);
// Original function pointers.
extern ParseServerMessage OParseServerMessage;
extern ParseCommandString OParseCommandString;
extern ParseGamestate OParseGamestate;
extern ReadBigString OReadBigString;
extern AddReliableCommand OAddReliableCommand;
extern AddCommand OAddCommand;
extern RemoveCommand ORemoveCommand;
extern GetArgs OGetArgs;
extern ConsolePrint OConsolePrint;
extern CvarFind OCvarFind;
extern ExecuteString OExecuteString;
DWORD WINAPI MainThread(HMODULE hModule);
void CleanUp();
bool Initialize();
bool FindFunctions();
void MainLoop(HANDLE queue_end_event, HANDLE queue_mutex, HANDLE restart_python_event);
bool HookAll();
bool UnhookAll();
void AddConsoleInterface();
void RemoveConsoleInterface();
// Console command handlers.
typedef void (* GenericHandler)(const std::vector<std::string> &args);
void __cdecl HandleConsoleCommands();
void __cdecl HandleHelp(const std::vector<std::string> &args);
void __cdecl HandleRestart(const std::vector<std::string> &args);
void __cdecl HandlePythonCommand(const std::vector<std::string> &args);
void __cdecl HandleExit(const std::vector<std::string> &args);
void __cdecl HandleUnknown(const std::vector<std::string> &args);
void HandleCommandString(size_t index);
void HandleGamestate(int index, const char * configstring);
void HandleConnectionStatus(UINT32 status);
// Function replacements.
void __cdecl HParseServerMessage(void * msg);
int __cdecl HParseCommandString(void * msg);
void __cdecl HParseGamestate(void * msg);
char * __cdecl HReadBigString(void * msg);
int __cdecl HReadShort(void * msg);
void __cdecl HAddReliableCommand(const char * cmd);
void __cdecl HConsolePrint(const char * msg);
// Wrappers.
const char * CvarFindWrapper(const char * var_name);
void ExecuteStringWrapper(const char * cmd);
// Helpers
void AddQueuedCommand(const std::string &cmd);
UINT32 GetConnectionStatus();
const char * GetConfigstring(UINT32 i);
boost::python::dict GetConfigstringRange(UINT32 i, UINT32 j);
} // Namespace quake