Example #1
0
File: game.cpp Project: erik/blocks
void Game::CreateMenu() {

    // Create the scene

    context->scene->Init(context);

    // Create the GUI

    sf::Color invis(0, 0, 0, 0);
    sf::Color gray(0x22, 0x22, 0x22, 128);

    sf::Rect<int> rect(200, 200, 600, 250);
    sf::Rect<int> rect2(200, 275, 600, 325);
    sf::Rect<int> rect3(200, 350, 600, 400);

    GUIButton *but =  new GUIButton("START GAME", rect, gray, invis);
    GUIButton *but2 = new GUIButton("OPTIONS",    rect2, gray, invis);
    GUIButton *but3 = new GUIButton("EXIT",       rect3, gray, invis);

    but3->SetOnClick(exitOnClick);
    but->SetOnClick(startGameOnClick);

    but->SetFontSize(20.0f);
    but2->SetFontSize(20.0f);
    but3->SetFontSize(20.0f);

    gui->AddElement(but);
    gui->AddElement(but2);
    gui->AddElement(but3);
}
Example #2
0
int main(int argc, char* argv[])
{
	int     uid;
	set_max_load(argv[0]);

	uid = getuid();

	if (uid == BBSUID)
	{	/* bbs uid */

#ifdef USE_UTMP
		struct utmp *whee;
#endif
#ifdef USE_UTMPX

		struct utmpx *whee;
#endif

		char    hid[17];
		/* load control for BBS */
		/*#ifdef LOAD_LIMIT */
		{
			double  cpu_load[3];
			int     load;
			get_load(cpu_load);
			load = cpu_load[0];
			printf("BBS ×î½ü (1,10,15) ·ÖÖÓµÄƽ¾ù¸ººÉ·Ö±ðΪ %.2f, %.2f, %.2f (Ä¿Ç°ÉÏÏÞ = %d).\n\n",
			       cpu_load[0], cpu_load[1], cpu_load[2], max_load);

			if (load < 0 || load > max_load)
			{
				printf("ºÜ±§Ç¸,Ŀǰϵͳ¸ººÉ¹ýÖØ, ÇëÉÔááÔÙÀ´\n");
				sleep(load);
				exit(-1);
			}
		}
		/*#endif*/
		/* ppfoong */
		{
			char    buf[256];
			FILE   *fp;
			if ((fp = fopen("NOLOGIN", "r")) != NULL)
			{
				while (fgets(buf, 256, fp) != NULL)
					printf(buf);
				fclose(fp);
				sleep(3);
				exit(-1);
			}
		}
		RF_DEBUG("Before invis....");
		whee = invis();

		RF_DEBUG("Before Chroot....");

#ifdef BBSRF_CHROOT

		sprintf(bbs_prog_path, "/bin/bbs", BBSHOME);
		if (chroot(BBSHOME) != 0)
		{
			printf("Cannot chroot, exit!\n");
			exit(-1);
		}
#else
		sprintf(bbs_prog_path, "%s/bin/bbs", BBSHOME);
#endif

		RF_DEBUG("Before setuid....");
		setuid(uid);

		if (whee)
		{
			char    ttybuf[16];
			char   *tp;
			RF_DEBUG("Before ttyname (whee)....");
			tp = ttyname(0);
			strcpy(ttybuf, (tp == NULL) ? "/dev/ttyp0" : tp);

			if (whee->ut_host[0])
				strncpy(hid, whee->ut_host, 16);
			else
#ifdef SYSV

			{
				struct utsname name;
				if (uname(&name) >= 0)
					strcpy(hid, name.nodename);
				else
					strcpy(hid, "localhost");
			}
#else
				gethostname(hid, 16);
#endif

			hid[16] = '\0';

			if (check_ban_site(hid))
				exit(-1);
			RF_DEBUG("Before execl (whee)....");

			execl(bbs_prog_path, "bbs", "h", hid, ttybuf, NULL);
		}
		else
		{
			RF_DEBUG("Before execl (not whee)....");
			execl(bbs_prog_path, "bbs", "h", "unknown", "notty", NULL);
		}

		printf("execl failed\n");
		exit(-1);
	}
	setuid(uid);
	printf("UID DOES NOT MATCH\n");
	exit(-1);
	return -1;
}