-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathL.cc
212 lines (211 loc) · 5.6 KB
/
L.cc
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#include <windows.h>
//
#include <gl/GLU.h>
#include <filesystem>
#include <fstream>
#include <map>
#define MSAA_0X 9
#define MSAA_2X 25
#define MSAA_4X 41
#define MSAA_8X 57
#define MSAA_16X 73
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_PNG
#include "stb_image.h"
extern "C" {
_declspec(dllexport) int NvOptimusEnablement = 1;
_declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
std::string P(std::string p = "") {
char _[MAX_PATH];
GetModuleFileNameA(0, _, MAX_PATH);
auto s = std::string(_);
return s.substr(0, s.find_last_of('\\') + 1) + p;
}
std::map<std::string, int> s;
void S() {
std::string p = P(std::string(getenv("USERNAME")) + ".ini");
if (s.empty()) {
std::ifstream f(p, std::ios::binary);
for (std::string i; getline(f, i);) {
auto _ = i.find(',');
s.emplace(i.substr(0, _), stoi(i.substr(_ + 1)));
}
return;
}
std::ofstream f(p, std::ios::binary);
for (auto &[k, v] : s) f << k << ',' << v << '\n';
}
int &S(std::string k, int v = 0) {
if (s.find(k) == s.end()) s.emplace(k, v);
return s[k];
}
void RP() {
if (P().substr(P().size() - 8) != "Release\\") return;
std::ostringstream ss;
for (auto &i : std::filesystem::directory_iterator("D\\T")) {
stbi_set_flip_vertically_on_load(1);
int x, y, n;
auto *_ = stbi_load(i.path().string().c_str(), &x, &y, &n, 0);
auto l = x * y * n;
ss << "T_" << i.path().filename().replace_extension().string() << '\n'
<< x << '\n'
<< y << '\n'
<< n << '\n';
ss.write((char *)_, l);
ss << '\n';
stbi_image_free(_);
}
auto MPos = ss.tellp();
for (auto &i : std::filesystem::directory_iterator("D\\M")) {
}
auto APos = ss.tellp();
for (auto &i : std::filesystem::directory_iterator("D\\A")) {
}
std::ofstream(P("D.exe"), std::ios::binary) << MPos << '\n'
<< APos << '\n'
<< ss.str();
}
struct Txtr {
int x, y, n;
std::unique_ptr<unsigned char[]> d;
};
Txtr *RU(std::string r) {
std::ifstream f(P("D.exe"), std::ios::binary);
int MPos, APos;
f >> MPos >> APos;
switch (r.front()) {
case 'T':
for (std::string i; getline(f, i);) {
if (i.find(r) != std::string::npos) {
auto t = new Txtr;
f >> t->x >> t->y >> t->n;
auto l = t->x * t->y * t->n;
t->d = std::make_unique<unsigned char[]>(l);
f.read((char *)t->d.get(), l);
return t;
}
}
break;
case 'M':
f.seekg(MPos);
break;
case 'A':
f.seekg(APos);
break;
}
}
struct Entt;
struct Op;
struct Tr;
struct Li;
struct Ui;
std::vector<Entt *> Entts, Kills;
std::vector<Op *> Ops;
std::vector<Tr *> Trs;
std::vector<Li *> Lis;
std::vector<Ui *> Uis;
struct Entt {
bool IsOn = 1;
void Enbl(bool b) {
IsOn = b;
OEnbl(b);
}
virtual void OEnbl(bool b) {}
virtual void Tick() {}
virtual void OSpwn() { Entts.push_back(this); }
virtual void OKill() {
Entts.erase(std::find(Entts.begin(), Entts.end(), this));
}
virtual ~Entt() {}
};
struct Op : Entt {
void OSpwn() { Ops.push_back(this); }
void OKill() { Ops.erase(std::find(Ops.begin(), Ops.end(), this)); }
};
struct Tr : Entt {};
struct Li : Entt {};
struct Ui : Entt {};
template <typename T>
T *Spwn() {
auto _ = new T;
_->OSpwn();
return _;
}
void Kill(Entt *e) { Kills.push_back(e); }
void Exit() {
for (auto &i : Entts) delete i;
S();
}
struct L : Entt {
L();
~L();
void Tick();
};
float CC[] = {0, 0, 0, 0};
float TDelt, TScal = 1;
MSG M;
int WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PSTR, _In_ INT) {
if (SetForegroundWindow(FindWindowA(0, " "))) return 0;
RP();
S();
auto W = CreateWindowExA(SetProcessDPIAware(), "Static", " ",
WS_POPUP | WS_SIZEBOX | SS_NOTIFY, 0, 0, 0, 0, 0, 0,
0, 0);
auto H = GetDC(W);
ShowWindow(W, 3);
SetPixelFormat(H, S("V_MSAA", MSAA_4X), new PIXELFORMATDESCRIPTOR{});
wglMakeCurrent(H, wglCreateContext(H));
wglUseFontBitmapsA(H, 0, 255, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
((GLUtessBeginProc)wglGetProcAddress("wglSwapIntervalEXT"))(S("V_VSYNC", 1));
int _[] = {0, GL_DEPTH_TEST, GL_COLOR_MATERIAL, GL_TEXTURE_2D};
for (auto &i : _) glEnable(i);
Spwn<L>();
while (SwapBuffers(H)) {
Sleep(!SetForegroundWindow(W));
if (PeekMessageA(&M, 0, 0, 0, 1)) DispatchMessageA(&M);
TDelt = (clock() - *_) * TScal / 1000;
*_ = clock();
for (auto &i : Entts)
if (i->IsOn) i->Tick();
glClearColor(CC[0], CC[1], CC[2], CC[3]);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(S("V_FOV", 60),
float(GetSystemMetrics(0)) / GetSystemMetrics(1), .01, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
for (auto &i : Ops)
if (i->IsOn) i->Tick();
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
for (auto &i : Trs)
if (i->IsOn) i->Tick();
glEnable(GL_DEPTH_TEST);
for (auto &i : Lis)
if (i->IsOn) i->Tick();
glDisable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(GetSystemMetrics(0) / -2, GetSystemMetrics(0) / 2,
GetSystemMetrics(1) / -2, GetSystemMetrics(1) / 2);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
for (auto &i : Uis)
if (i->IsOn) i->Tick();
glDisable(GL_BLEND);
for (auto &i : Kills) {
i->OKill();
delete i;
}
Kills.clear();
}
Exit();
return 0;
}
L::L() { auto t = RU("RGB"); }
L::~L() {}
void L::Tick() {}