-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEmulator.cpp
159 lines (121 loc) · 7.86 KB
/
Emulator.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Emulator.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include "stdafx.h"
#include "MD5Hash.h"
#include "aux_function.h"
#include "player_structure.h"
#include "Logging_config.h"
#include <fstream>
#include <regex>
#pragma comment(lib,"ws2_32.lib")
bool init_wsadata() {
WSAData wsaData;
if (WSAStartup(MAKEWORD(2, 1), &wsaData) != 0) {
puts("Winsock falhou");
return false;
}
return true;
}
char my_server[] = "192.168.1.73";
char the_pw[] = "177.54.157.91";
char central[] = "177.54.148.246";
char pw_brasil[] = "189.1.170.142";
//#define PW_PORT 29002
#define PW_PORT 29000
void start(Player_structure* p, Logging_config* lc) {
if (p->config_socket(pw_brasil, PW_PORT)) {
p->set_credentials(*lc);
p->connect();
}
}
std::vector<Logging_config> extract_boot_data() {
std::string line;
std::ifstream myfile("config_bot.txt");
std::regex simple_regex("=\\s+(.+)");
std::smatch s;
std::vector<std::string> data;
if (myfile.is_open()) {
while (std::getline(myfile, line)) {
if (std::regex_search(line, s, simple_regex)) {
//std::cout << s[1] << std::endl;
data.push_back(s[1]);
}
}
myfile.close();
}
else {
std::cout << "Nao foi possivel abrir o arquivo";
exit(1);
}
// as configurações conferem 15 linhas
if (data.empty() || data.size() % 15 != 0) {
std::cout << "Existe algo de errado com o arquivo de dados.. talvez a formatacao" << std::endl;
exit(1);
}
unsigned int number_of_char = data.size() / 15;
std::vector<Logging_config> arr_data;
arr_data.resize(number_of_char);
for (size_t i = 0; i < number_of_char; i++) {
arr_data[i].login = data[0];
arr_data[i].senha = data[1];
arr_data[i].player_name = data[2];
arr_data[i].script = data[3];
arr_data[i].force = std::stoi(data[4]);
arr_data[i].fly_id = std::stoi(data[5]);
arr_data[i].items = data[6].front() - 48;
arr_data[i].inventory = data[7].front() - 48;
arr_data[i].healing = data[8].front() - 48;
arr_data[i].trade = data[9].front() - 48;
arr_data[i].party = data[10].front() - 48;
arr_data[i].movement = data[11].front() - 48;
std::regex get_number("\\d+");
auto parser = std::sregex_iterator(data[12].begin(), data[12].end(), get_number);
std::sregex_iterator rend;
while (parser != rend) {
arr_data[i].party_list_permission.insert(std::stoi(parser->str()));
++parser;
}
parser = std::sregex_iterator(data[13].begin(), data[13].end(), get_number);
while (parser != rend) {
arr_data[i].trade_list_permission.insert(std::stoi(parser->str()));
++parser;
}
parser = std::sregex_iterator(data[14].begin(), data[14].end(), get_number);
while (parser != rend) {
arr_data[i].commands_list_permission.insert(std::stoi(parser->str()));
++parser;
}
data.erase(data.begin(), data.begin() + 15);
}
return arr_data;
}
int main() {
if (!init_wsadata())
return 0;
auto account_data = extract_boot_data();
Player_structure* player_object = new Player_structure[account_data.size()];
Logging_config* logging = new Logging_config[account_data.size()];
std::vector<std::thread> arr_thread;
for (size_t i = 0; i < account_data.size(); i++) {
system("cls");
//std::cout << "Login: ";
////std::cin >> logging[i].login;
//logging->login = "rato0"; //
//std::cout << std::endl;
//std::cout << "Senha: ";
////std::cin >> logging[i].senha;
//logging->senha = "derleyvolt";
//
//logging[i].player_name = "rato_sujo"; // rato00 id = 983408 .. rato0 id = 982656
logging[i] = account_data[i];
arr_thread.push_back(std::thread(start, &player_object[i], &logging[i]));
Sleep(500);
}
//for (auto& k : arr_thread)
// k.join();
Sleep(8888888888);
delete[] player_object;
system("pause");
return 0;
}