forked from SecretsOTheP/EQMacEmu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_functions.h
178 lines (166 loc) · 4.14 KB
/
basic_functions.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
const char *notin = "~.? ,)=!&|<>\"";
const char * charIn = "`~1234567890-=!@#$%^&*()_+qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP|ASDFGHJKL:ZXCVBNM<>?\"{}";
const char * charIn2 = "`~1234567890-=!@#$%^&*()_+qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP|ASDFGHJKL:ZXCVBNM<>?\" ";
char com_list[512];
/*char * gettok(const char * string, int chara, int pos) {
static char * pch;
static char temp[100];
static char ty[100];
memset(temp, 0, sizeof(temp));
memset(ty, 0, sizeof(ty));
ty[0] = chara;
strn0cpy(temp, string, sizeof(temp));
pch = strtok(temp,ty);
for (int i=0; i < pos; i++) {
if (pos == i) break;
pch = strtok(nullptr,ty);
}
return pch;
}*/
int calc(char * stuff) {
int result = 0;
int i = 0;
int a = 0;
static char temp[100];
int op = 0;
memset(temp,0x0,100);
//char heh[100];
while(*stuff)
{
a++;
if (*stuff >= '0' && *stuff <= '9') {
if (op) {
switch ( op ) {
case 0:
break;
case '+':
result += atoi(stuff);
memset(temp,0x0,100);
i = 0;
break;
case '-':
result -= atoi(stuff);
memset(temp,0x0,100);
i = 0;
break;
case '*':
result *= atoi(stuff);
memset(temp,0x0,100);
i = 0;
break;
case '/':
result /= atoi(stuff);
memset(temp,0x0,100);
i = 0;
break;
}
}
temp[i] = *stuff;
}
else if (*stuff == '+' || *stuff == '-' || *stuff == '/' || *stuff == '*') {
op = *stuff;
if (!result) result = atoi(temp);
memset(temp,0x0,100);
i=0;
}
i++;
stuff++;
}
return result;
}
char * postring (char * string, int pos) {
static char temp[1024];
memset(temp, 0, sizeof(temp));
int p=0;
int tmpStringLen = strlen(string);
for (int i=pos; i < tmpStringLen; i++) {
temp[p] = string[i];
p++;
}
return temp;
}
int g_id ( char * string )
{
char temp[100];
int i=0;
while (*string)
{
if (*string >= '0' && *string <= '9') temp[i++] = *string++;
else string++;
}
return atoi(temp);
}
int GetArgs(char * string)
{
#if 1
char temp[255];
char c_name[255];
int params = 0;
//char *buffer = new char[512]; // this is never deleted, causes zone to crash
char *buffer = com_list;
memset(temp,0x0,255);
//memset(buffer,0x0,512);
//#ifdef WIN32
//strcpy(buffer,com_list);
//#else
//strncpy(buffer,com_list,sizeof(buffer)-1);
//#endif
int i=0;
while (*buffer)
{
if (*buffer != '|' && *buffer != ' ') temp[i++] = *buffer++;
else buffer++;
if (*buffer == '|') {
params = atoi(temp);
if (!strcmp(c_name,string)) {
return params;
}
memset(temp,0x0,255);
i=0;
}
if (*buffer == ' ') {
memset(c_name,0x0,255);
strcpy(c_name,temp);
memset(temp,0x0,255);
i=0;
}
}
return 0;
#else
if (strstr(string,"if")) { return 0; }
if (strstr(string,"sfollow")) { return 0; }
if (strstr(string,"save")) { return 0; }
if (strstr(string,"while")) { return 0; }
if (strstr(string,"break")) { return 1; }
if (strstr(string,"follow")) { return 1; }
if (strstr(string,"setallskill")) { return 1; }
if (strstr(string,"me")) { return 1; }
if (strstr(string,"flagcheck")) { return 1; }
if (strstr(string,"echo")) { return 1; }
if (strstr(string,"summonitem")) { return 1; }
if (strstr(string,"say")) { return 1; }
if (strstr(string,"emote")) { return 1; }
if (strstr(string,"shout")) { return 1; }
if (strstr(string,"depop")) { return 1; }
if (strstr(string,"cumflag")) { return 1; }
if (strstr(string,"exp")) { return 1; }
if (strstr(string,"level")) { return 1; }
if (strstr(string,"safemove")) { return 1; }
if (strstr(string,"rain")) { return 1; }
if (strstr(string,"snow")) { return 1; }
if (strstr(string,"pvp")) { return 1; }
if (strstr(string,"doanim")) { return 1; }
if (strstr(string,"dbspawnadd")) { return 2; }
if (strstr(string,"castspell")) { return 2; }
if (strstr(string,"flagcheck")) { return 2; }
if (strstr(string,"addskill")) { return 2; }
if (strstr(string,"write")) { return 2; }
if (strstr(string,"settarget")) { return 2; }
if (strstr(string,"givecash")) { return 4; }
if (strstr(string,"movepc")) { return 4; }
if (strstr(string,"spawn")) { return 6; }
return 0;
#endif // 0
}
Client* gClient = 0;
uint32 Line_Number = 0;