-
Notifications
You must be signed in to change notification settings - Fork 3
/
sprite.cpp
76 lines (69 loc) · 1.79 KB
/
sprite.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
#include "stdafx.h"
sprite_s *(__cdecl *spriteLoadAdd) (int thingType,int coordX,int coordY);
void (__cdecl *spriteDeleteStatic)(sprite_s *Sprite);
void (__cdecl *drawImage)(void *ImgH,int X,int Y);
extern int (__cdecl *noxDrawGetStringSize) (int FontPtr, wchar_t *String,int *Width,int,int);
extern void (__cdecl *drawString)(void *FontPtr,const wchar_t*String,int X,int Y);
extern tileDef_s *tileDefs;
namespace
{
/*
íàäî ïðîäóìàòü ñïîñîá îòðèñîâêè ñïðàéòîâ ñ êàñòîìíûìè ïåðåìåííûìè
*/
void customSpriteDraw(void *DrawData,void *Sprite)
{
}
int drawTileImage(lua_State *L)
{
lua_settop(L,4);
int i=1;
if (
(lua_type(L,i++)!=LUA_TNUMBER)||
(lua_type(L,i++)!=LUA_TNUMBER)||
(lua_type(L,i++)!=LUA_TNUMBER)||
(lua_type(L,i++)!=LUA_TNUMBER)
)
{
lua_pushstring(L,"wrong args!");
lua_error_(L);
}
void **imageH=0;/// òóò áû ïðîâåðîê
imageH=(void **)tileDefs[lua_tointeger(L,1)].ImgPtr;
if (imageH==NULL)
return 0;
if ((imageH[lua_tointeger(L,2)])==NULL)
return 0;
drawImage(imageH,lua_tointeger(L,3),lua_tointeger(L,4));
return 0;
}
int tileGetImage(lua_State *L)
{
lua_settop(L,2);
int i=1;
if (
(lua_type(L,i++)!=LUA_TNUMBER)||
(lua_type(L,i++)!=LUA_TNUMBER)
)
{
lua_pushstring(L,"wrong args!");
lua_error_(L);
}
void **imageH=0;/// òóò áû ïðîâåðîê
imageH=(void **)tileDefs[lua_tointeger(L,1)].ImgPtr;
if (imageH==NULL)
return 0;
void *Ret=imageH[lua_tointeger(L,2)];
if (Ret==NULL)
return 0;
lua_pushlightuserdata(L,Ret);
return 1;
}
}
void spriteInit()
{
ASSIGN(spriteLoadAdd,0x0045A360);
ASSIGN(spriteDeleteStatic,0x0045A4E0);
ASSIGN(drawImage,0x0047D2C0);
registerclient("tileDraw",&drawTileImage);
registerclient("tileImage",&tileGetImage);
}