-
Notifications
You must be signed in to change notification settings - Fork 3
/
stdafx.h
362 lines (324 loc) · 8.17 KB
/
stdafx.h
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <stdlib.h>
#include <string>
typedef unsigned char byte;
typedef unsigned short WORD;
#pragma pack(1)
extern "C"
{
#include "lauxlib.h"
#include "lualib.h"
}
extern lua_State *L;
typedef std::string TString;
typedef unsigned char byte;
enum uniPacket_e
{
upVersionRq=1,
upVersionResp,
upWallChanged=5,
upStaticCreated,
upLuaRq,
upLuaResp,
upNewStatic,
upDelStatic,
upMoveStatic,
upUpdateDef, /// ñåðâåð õî÷åò èçìåíèòü ñâîéñòâà unitDef
upTryUnitUse, /// êëèåíò õî÷åò ÈÑÏÎËÜÇÎÂÀÒÜ ïðåäìåò
upNotifyUnitUse,/// ñåðâåð ñîîáùàåò, ÷òî êòî-òî èñïîëüçóåò ïðåäìåò
upSendArchive, /// ñåðâåð ñîîáùàåò, ÷òî âìåñòå ñ êàðòîé ïðèäåò åùå è àðõèâ
upChangeTile, /// ñåðâåð ìåíÿåò òàéë
upSpellStart,/// ñåðâåð ñîîáùàåò ñòàðò ñïåëëà
upSpellSync, /// ñåðâåð ñîîáùàåì âñåì ñâåæèé ñïèñîê ñïåëîâ
upSendBubble,/// ñåðâåð õî÷åò ñîçäàòü ÷àò
upSendPrintToCli,// ñåðâåð ïðèñûëàåò êîíñîëè ñòðîêó
upVersionServerRq, //ñåðâåð çàïðàøèâàåò êëèåíòñêóþ âåðñèþ þíèìîäà
};
// ïðèïèñàòü ê áóôåðó íàø çàãîëîâîê äëÿ îòïðàâêè
void netUniPacket(uniPacket_e Code,BYTE *&Data,int Size);
#define UNIPACKET_HEAD (3)
#define ABIL_TO_SPELL (0x89)
struct noxPoint
{
float X;
float Y;
noxPoint(float x,float y):X(x),Y(y){}
};
struct noxRect
{
float X1;
float Y1;
float X2;
float Y2;
noxRect():X1(0),Y1(0),X2(0),Y2(0){}
noxRect(float x1,float y1, float x2,float y2):X1(x1),Y1(y1),X2(x2),Y2(y2){}
};
struct noxRectInt
{
int X1;
int Y1;
int X2;
int Y2;
noxRectInt(int x1,int y1, int x2,int y2):X1(x1),Y1(y1),X2(x2),Y2(y2){}
};
struct wallRec
{
BYTE Dir;
BYTE tileName;
BYTE variation;
BYTE unk3;
BYTE wallFlags;
BYTE posX;
BYTE posY;
BYTE HP;
BYTE field_8; /// ?
BYTE gap_9[1];/// ?
USHORT wallId;
BYTE gap_c[4]; /// ?
int wallMapPtr; /// óêàçàòåëü íà ñåãìåíò êàðòû - ÍÅ ÒÐÎÃÀÒÜ
int nextWall; /// óêàçàòåëü íà ñëåä ñòåíó - ÍÅ ÒÐÎÃÀÒÜ
int mapYPtr; /// óêàçàòåëü íà ñëåäóþùóþ âåðòèêàëüíóþ ñòåíó - ÍÅ ÒÐÎÃÀÒÜ
int doorPtr; /// ? êàæåòñÿ çäåñü óêàçàòåëü íà ïðèëåïëåíóþ äâåðü
int field_20;
};
struct wallSecret_s
{
int NextWallSecret_s;
int X;
int Y;
int wallRec_Ptr;
int timeToClose;
BYTE timeToOpen;
BYTE bitAuto;
BYTE chetchickOpen;
BYTE field_17;
int ChetchickClose;
int field_1c;
};
struct waypoint_s
{
int Id;
int flag;
float X;
float Y;
char Name[256];
};
struct SpellTargetBlock
{
void *target;
float targX,targY;
};
typedef void * unitBigStructPtr;
struct ServerData
{
char mapName[8];
char gap[1];
char gameName[10];
char gap_13[5];
int field_18[5];
DWORD weaponRestrictions;
DWORD armorRestrictions;
__int16 gameFlags;
unsigned __int16 fragLimit;
unsigned char timeLimitMB;
char isNew;
};
#define ASSIGN(X,Y) *((DWORD*)&(X))=((DWORD)(Y));
DWORD uniCalcJump(DWORD From,void *To);
extern void printI(const char *S);
extern void conSetNextColor(int C); // óñòàíàâëèâàåò öâåò ñëåä. ñîîáùåíèÿ êîíñîëè
extern void conPrintI(const char *S);
extern DWORD *GameFlags;
void netSendAll(void *Buf,int BufSize); /// ïîñûëàåò âñåì êëèåíòàì
void netSendNotOne(void *Buf,int BufSize,void *One); /// ïîñûëàåò âñåì êëèåíòàì êðîìå îäíîãî
void netSendServ(void *Buf,int BufSize);/// ïîñûëàåò ñåðâåðó
USHORT inline toShort(BYTE *X){return *((USHORT*)X);}
void inline fromShort(BYTE *&P,USHORT X){*((USHORT *)P)=X;P+=2;}
struct spellPacket
{
byte Pckt;
DWORD Spells[5];
byte Dir;// 0= îáû÷íûé 1= íà ñåáÿ
};
struct FloatRect
{
float left,top,right,bottom;
FloatRect(float l,float t,float r,float b):left(l),top(t),right(r),bottom(b){}
};
void lua_error_(lua_State *L);
struct ParseAttrib;
/// ôóíêöèÿ äëÿ äîñòóïà ê äàííûì àðõèâîâ - â ïîñëåäñòâèè ÷åðåç íåå íàäî ïðîâåñòè âñå
extern bool fsRead(const char *File,void *&Data, size_t &Size);
/// Ôóíêöèè âûäåëåíèÿ íîêñî-ïàìÿòè
extern void *(__cdecl *noxAlloc)(int Size);
extern void (__cdecl *noxFree)(void *Ptr);
/// Ôóíêöèÿ äëÿ ðåãèñòðàöèè ïàêåòîâ êëèåíòó è ñåðâåðó
typedef void (*netClientFn_s) (BYTE *Packet);
typedef void (*netServFn_s) (BYTE *Packet,BYTE *MyPlayer,BYTE *MyUc);
extern void netRegClientPacket(uniPacket_e Event,netClientFn_s Fn);
extern void netRegServPacket(uniPacket_e Event,netServFn_s Fn);
extern void parseAttr(lua_State *L,int KeyIdx,int ValIdx,void *Struct,const ParseAttrib *Attrs);
inline void registerclient(const char *FnName,lua_CFunction Fn,int UpSize=0)
{
lua_pushcclosure(L, Fn,UpSize);
lua_getfield(L,LUA_REGISTRYINDEX,"client");
lua_pushvalue(L,-2);
lua_setfield(L,-2,FnName);
lua_pop(L,2);// êîïèþ çàìûêàíèÿ è òàáëèöó
}
inline void registerserver(const char *FnName,lua_CFunction Fn,int UpSize=0)
{
lua_pushcclosure(L, Fn,UpSize);
lua_getfield(L,LUA_REGISTRYINDEX,"server");
lua_pushvalue(L,-2);
lua_setfield(L,-2,FnName);
lua_pop(L,2);// êîïèþ çàìûêàíèÿ è òàáëèöó
}
inline void registerServerVar(const char *VarName)
{
lua_getfield(L,LUA_REGISTRYINDEX,"server");
lua_pushvalue(L,-2);
lua_setfield(L,-2,VarName);
lua_pop(L,2);// êîïèþ ïåðåìåííîé è òàáëèöó
}
inline void registerClientVar(const char *VarName)
{
lua_getfield(L,LUA_REGISTRYINDEX,"client");
lua_pushvalue(L,-2);
lua_setfield(L,-2,VarName);
lua_pop(L,2);// êîïèþ ïåðåìåííîé è òàáëèöó
}
inline void getServerVar(const char *VarName)
{
lua_getfield(L,LUA_REGISTRYINDEX,"server");
lua_getfield(L,-1,VarName);
lua_remove(L,-2);
}
inline void getClientVar(const char *VarName)
{
lua_getfield(L,LUA_REGISTRYINDEX,"client");
lua_getfield(L,-1,VarName);
lua_remove(L,-2);
}
struct sprite_s
{
void *x;
};
struct keyState
{
int Spell;
int Direction;
};
struct keyPack
{
keyState Spells[25];
int selectedRow;
keyState *keyRowPtr;
void *someWnd_D0;
void *spellWndItemMB[5];
void *spellIconMB[5];
int field_FC;
};
enum spellFlags
{
sfNeedFly = 4,
sfRemoveShieldEtc = 0x20,
sfCreature=0x0
};
struct tileDef_s
{
char Name[32];
void *ImgPtr;
DWORD Flags;
DWORD doDamage;
short sizeMB;
short param2E;
DWORD colorMB;
byte tileSizeX;
byte tileSizeY;
char More[6];
};
struct polygonAngle_s
{
int numAngle;
float posX;
float posY;
int isCreated;
};
struct polygon_s
{
int filed_0;
char Name[76];
int polygonIdx;
int field_54;
int posX1;
int posY1;
int posX2;
int posY2;
int color;
void *strucCoordinat;
int scriptFunction;
int field_74;
int field_78;
int field_7C;
short kolvoUglov;
short minimapGroup;
int field_84;
int field_88;
};
class SendBuffer /// Ïðåäíàçíà÷åí äëÿ ïåðåäà÷è ïî ñåòè áîëüøèõ êóñêîâ
{
public:
SendBuffer();
byte *RecvComplete(size_t &Len);// Âåðíåò íå NULL åñëè ïðèåõàëè äàííûå
void Write(byte *Data,size_t &Len); // îòïðàâèò áóôåð ïî êóñêàì
void WriteLuaVar(lua_State *L,bool Float=false);
};
struct ParseAttrib /// äëÿ âñÿêèõ ïàðñåðîâ âñÿêèõ ñòðóêòóð
{
const char *name;
int ofs;
int type;
/*
1 int
+2 string
+3 color
+4 wstring
5 bitfield (A=TablePtr)
*/
int argA;
void *argB;
};
struct FxBuffer_t
{
FxBuffer_t *Next;
int Size;
int FreeSize;
int SelIdx;
DWORD Data[];
FxBuffer_t(int Sz):Next(0),Size(Sz){}
~FxBuffer_t(){ if(Next) delete Next; }
void getValues(int First,int Len); /// äëÿ çàïðîñà ïî ñåòè
void addItem(int Val){((int*)Data)[SelIdx++]=Val;}
void addItemD(DWORD Val){Data[SelIdx++]=Val;}
static FxBuffer_t *addBlock(int Size,int *Id); //íà÷èíàåì äîáàâëÿòü ýëåìåíòû, âîçâðàùàåì àéäè
static bool delBlock(int Id); //óäàëÿåì áëîê
static void drawBuffers();
};
extern const int *noxScreenX;
extern const int *noxScreenY;
#include <map>
typedef std::map <BYTE,netClientFn_s> ClientMap_s;
typedef std::map <BYTE,netServFn_s> ServerMap_s;
#define goto wtf þçàòü ãîóòó íåëüçÿ