-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHMSC_Server.cpp
76 lines (57 loc) · 1.59 KB
/
HMSC_Server.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<iostream>
#include<windows.h>
#include<io.h>
#include<fcntl.h>
#include <sys/stat.h>
using namespace std;
int a=0,total=0;
DWORD WINAPI Fun1(LPVOID lpParamter)
{
Sleep(15000);
system("python rcon_instruction_1.py");
}
DWORD WINAPI Fun2(LPVOID lpParamter)
{
Sleep(15000);
system("python rcon_instruction_2.py");
}
inline bool exists_test (const std::string& name) {
struct stat buffer;
return (stat (name.c_str(), &buffer) == 0);
}
int main()
{
system("title HMSC_Server");
char cmd[256],name[256]="server.jar"; //a: total commond b:read file,starting server-core name
int handle=open("core-name.ini",O_TEXT|O_CREAT|O_RDWR);
if(read(handle,name,256)==0)
{
write(handle,name,strlen(name));
}
close(handle);
sprintf(cmd,"java -jar %s nogui",name);
char rcon_type[13];
if(exists_test("rcon.py")){sprintf(rcon_type,"Have Found");}else{sprintf(rcon_type,"Not Found");};
printf("Rcon :%s\n",rcon_type);
if(exists_test(name)!=TRUE){printf("Server core %s Not Found,You can set in core_name.ini\n",name);system("PAUSE");return 0;}
printf("boot commond :%s\n",cmd);
printf("Warn:This is an endless loop, once the startup fails, will use a lot of system resources!!\n");
printf("Would you want to continue?[press enter]\n");
getchar();
while(1)
{
system(cmd);
a++;
total++;
Sleep(1000);
if(a>=5)
{
HANDLE hThread=CreateThread(NULL,0,Fun1,NULL,0,NULL);
a=0;
}
if((total%10)==0)
{
HANDLE hThread=CreateThread(NULL,0,Fun2,NULL,0,NULL);
}
}
}