PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/main.cpp

https://bitbucket.org/voltechs/hexen
C++ | 58 lines | 33 code | 13 blank | 12 comment | 8 complexity | 9ca05adaa6559f0da2a690e089328845 MD5 | raw file
 1#include "main.h"
 2
 3Hexen *client;
 4
 5int main (int argc, char * const argv[])
 6{
 7#ifdef __WIN32__
 8	WSADATA wsaData;
 9	WORD version;
10	int error;
11
12	version = MAKEWORD( 2, 0 );
13
14	error = WSAStartup( version, &wsaData );
15
16	/* check for error */
17	if ( error != 0 )
18	{
19		/* error occured */
20		return FALSE;
21	}
22
23	/* WinSock has been initialized */
24#else
25	
26	signal(SIGWINCH, resize);
27	//signal(SIGKILL, terminate);
28	
29#endif
30
31	if (argc > 1 && !strcmp(argv[1], "server")) {
32
33		Server server = Server(1, argc, argv, false);
34		server.run();
35		printf("Server");
36		system("PAUSE");
37
38	} else {
39		
40		if (argc == 2)
41			client = new Hexen(argv[1]);
42		else client = new Hexen();
43		client->run();
44	}
45	return 0;
46}
47/*
48void terminate(int sig) {
49	// Yes, first ctl-c will end any client,
50	// second ctl-c will end the server.
51	if (client) client.disconnect;
52	else if (server) server.disconnect;
53 }
54*/
55
56void resize(int sig) {
57	client->resize();
58}