示例#1
0
void	prepare_client(t_data *data)
{
  prepare_players(data);
  prepare_window(data);
  prepare_network(data);
  prepare_pseudo(data);
}
示例#2
0
文件: hotreboot.c 项目: borlak/umgw
void do_hotreboot(CHAR_DATA * ch, char *argument)
{
	FILE *fp;
	DESCRIPTOR_DATA *d, *d_next;
	char buf[100], buf2[100], buf3[100];

	fp = fopen(HOTREBOOT_FILE, "w");

	if(!fp)
	{
		send_to_char("hotreboot file not writeable, aborted.\n\r", ch);
		fpReserve = fopen(NULL_FILE, "r");
		perror("do_hotreboot:fopen");
		return;
	}

	if(argument && !str_cmp(argument,"INFINITE LOOP!"))
	{
		sprintf(buf, "[HotReboot by Godwars - Infinite Loop!]\n\r");
	}
	if(argument && argument[0] != '\0')
	{
		sprintf(buf, "[HotReboot by Godwars - Crash!]\n\r");
	}
	else
	{
		do_restore(ch, "all");
		prepare_players();
		write_kingdoms();
		sprintf(buf, "[HotReboot by %s - You will automatically reconnect]\n\r", ch->name);
	}

	/* For each playing descriptor, save its state */
	for(d = descriptor_list; d; d = d_next)
	{
		CHAR_DATA *och = CH(d);

		d_next = d->next;	/* We delete from the list , so need to save this */

		if(!d->character || d->connected != CON_PLAYING || och->level == 1)	/* drop those logging on */
		{
			write_to_descriptor(d->descriptor, "\n\rSorry, we are rebooting. Come back in a few minutes.\n\r",
					    0);
			close_socket2(d, FALSE);	/* throw'em out */
		}
		else
		{
			fprintf(fp, "%li %s %s\n", d->descriptor, och->name, d->host);
			save_char_obj(och);
			write_to_descriptor(d->descriptor, buf, 0);
		}
	}

	fprintf(fp, "-1\n\n");
	fclose(fp);

	if((fp = fopen(OLDUPTIME_FILE, "w")) != 0)
	{
		fprintf(fp, "%.0f\n", get_uptime());
		fclose(fp);
	}
	else
	{
		unlink(OLDUPTIME_FILE);
	}

	fclose(fpReserve);

	/* exec - descriptors are inherited */

	sprintf(buf, "%li", port);
	sprintf(buf2, "%li", control);
	sprintf(buf3, "%li", rebootnum);
#ifndef WIN32
	execl(EXE_FILE, "Merc", buf, "hotreboot", buf2, buf3, (char *) 0);
#endif
	/* Failed - sucessful exec will not return */

	perror("do_hotreboot: execl");
	send_to_char("hotreboot FAILED!\n\r", ch);

	/* Here you might want to reopen fpReserve */
	fpReserve = fopen(NULL_FILE, "r");
}