Esempio n. 1
0
void pop_tick(void)
{
	static int last_reset = 0;
	int nr;

	if (globs->ticker - last_reset>=RESETTICKER)      // reset one character per minute
	{
		nr = (globs->ticker / RESETTICKER) % MAXTCHARS;
		if (nr>0 && nr<MAXTCHARS)               // yes, we're paranoid :)
		{
			reset_char(nr);
		}
		last_reset = globs->ticker;
	}

	if (globs->reset_char)
	{
		reset_char(globs->reset_char);
		globs->reset_char = 0;
	}
	if (globs->reset_item)
	{
		reset_item(globs->reset_item);
		globs->reset_item = 0;
	}
}
Esempio n. 2
0
void pop_reset_all(void)
{
	int n;

	for (n = 1; n<MAXTCHARS; n++)
	{
		if (ch_temp[n].used!=USE_EMPTY)
		{
			reset_char(n);
		}
	}
	for (n = 1; n<MAXTITEM; n++)
	{
		if (it_temp[n].used!=USE_EMPTY && it_temp[n].driver!=36 && it_temp[n].driver!=38)
		{
			reset_item(n);
		}
	}
}
Esempio n. 3
0
void populate(void)
{
	int n, m;

	xlog("Started Populate");

	/*xlog("Load");

	   pop_load();*/

	xlog("Creating NPCs from Templates");

	for (n = 1; n<MAXTCHARS; n++)
	{
		if (ch_temp[n].used!=USE_EMPTY)
		{
			for (m = 1; m<MAXCHARS; m++)
			{
				if (ch[m].used!=USE_ACTIVE)
				{
					continue;
				}
				if (ch[m].flags & CF_BODY)
				{
					continue;
				}
				if (ch[m].temp==n)
				{
					break;
				}
			}
			if (m==MAXCHARS)
			{
				reset_char(n);
			}
		}
	}
}
Esempio n. 4
0
/**
 * 加载配置文件
 */
void init_conf(){
	buffer_t *rbuf=alloc_buffer(CONF_READ_BUF);
	int fd=open_conf_file();
	enum PARSE_STATE status=RAW;
	config_module_t *current_module;
	command_t *current_command;
	char_t *module_name=init_char();
	char_t *command_key=init_char();
	char_t *command_value=init_char();
	while(1){
		if(has_space(rbuf)){
			intptr_t count=read(fd,rbuf->data+rbuf->limit,rbuf->size-rbuf->limit);
			if(count<=0){
				goto CONFIG_END;
			}
			rbuf->limit+=count;
		}
		while(has_remaining(rbuf)){
    		char c=*(rbuf->data+rbuf->current);
    		rbuf->current+=1;
    		if(status==RAW&&c==brace_start){
    			status=MODULE_START;
    		}else if(status==MODULE_START&&!char_is_special(c)){
    			if(c==brace_start){
    				add_terminal(module_name);
    				current_module=find_config_module(module_name);
    				if(current_module==NULL){
    					my_log(ERROR,"config error,please check\n");
    					goto CONFIG_END;
    				}else{
    					status=FIND_COMMAND_KEY;
    				}
    			}else if(c==brace_end){
    				goto CONFIG_END;
    			}else{
    				add_char(module_name,c);
    			}
    		}else if(status==FIND_COMMAND_KEY&&!char_is_special(c)){
    			if(c==brace_end){
    				current_module=NULL;
    				reset_char(module_name);
    				status=MODULE_START;
    			}else{
    				add_char(command_key,c);
    				status=COMMAND_KEY_START;
    			}
    		}else if(status==COMMAND_KEY_START){
    			if(!char_is_special(c)){
    				add_char(command_key,c);
    			}else{
    				add_terminal(command_key);
    				current_command=find_config_command(command_key,current_module);
    				if(current_command==NULL){
    					my_log(ERROR,"config error,please check\n");
    					goto CONFIG_END;
    				}
    				status=COMMAND_VALUE_START;
    			}
				
    		}else if(status==COMMAND_VALUE_START&&!char_is_special(c)){
    			if(c!=semicolon){
    				add_char(command_value,c);
    			}else{
    				add_terminal(command_value);
    				current_command->set_value(command_value);
    				current_command=NULL;
    				reset_char(command_value);
    				reset_char(command_key);
    				status=FIND_COMMAND_KEY;
    			}
    		}
    	}
	}
CONFIG_END:
	destroy_buffer(rbuf);
}
Esempio n. 5
0
/*
 * Reset the terminal mode bits to a sensible state.  Very useful after
 * a child program dies in raw mode.
 */
void
reset_tty_settings(int fd, TTY * tty_settings)
{
    GET_TTY(fd, tty_settings);

#ifdef TERMIOS
#if defined(VDISCARD) && defined(CDISCARD)
    reset_char(VDISCARD, CDISCARD);
#endif
    reset_char(VEOF, CEOF);
    reset_char(VERASE, CERASE);
#if defined(VFLUSH) && defined(CFLUSH)
    reset_char(VFLUSH, CFLUSH);
#endif
    reset_char(VINTR, CINTR);
    reset_char(VKILL, CKILL);
#if defined(VLNEXT) && defined(CLNEXT)
    reset_char(VLNEXT, CLNEXT);
#endif
    reset_char(VQUIT, CQUIT);
#if defined(VREPRINT) && defined(CRPRNT)
    reset_char(VREPRINT, CRPRNT);
#endif
#if defined(VSTART) && defined(CSTART)
    reset_char(VSTART, CSTART);
#endif
#if defined(VSTOP) && defined(CSTOP)
    reset_char(VSTOP, CSTOP);
#endif
#if defined(VSUSP) && defined(CSUSP)
    reset_char(VSUSP, CSUSP);
#endif
#if defined(VWERASE) && defined(CWERASE)
    reset_char(VWERASE, CWERASE);
#endif

    tty_settings->c_iflag &= ~((unsigned) (IGNBRK
					   | PARMRK
					   | INPCK
					   | ISTRIP
					   | INLCR
					   | IGNCR
#ifdef IUCLC
					   | IUCLC
#endif
#ifdef IXANY
					   | IXANY
#endif
					   | IXOFF));

    tty_settings->c_iflag |= (BRKINT
			      | IGNPAR
			      | ICRNL
			      | IXON
#ifdef IMAXBEL
			      | IMAXBEL
#endif
	);

    tty_settings->c_oflag &= ~((unsigned) (0
#ifdef OLCUC
					   | OLCUC
#endif
#ifdef OCRNL
					   | OCRNL
#endif
#ifdef ONOCR
					   | ONOCR
#endif
#ifdef ONLRET
					   | ONLRET
#endif
#ifdef OFILL
					   | OFILL
#endif
#ifdef OFDEL
					   | OFDEL
#endif
#ifdef NLDLY
					   | NLDLY
#endif
#ifdef CRDLY
					   | CRDLY
#endif
#ifdef TABDLY
					   | TABDLY
#endif
#ifdef BSDLY
					   | BSDLY
#endif
#ifdef VTDLY
					   | VTDLY
#endif
#ifdef FFDLY
					   | FFDLY
#endif
			       ));

    tty_settings->c_oflag |= (OPOST
#ifdef ONLCR
			      | ONLCR
#endif
	);

    tty_settings->c_cflag &= ~((unsigned) (CSIZE
					   | CSTOPB
					   | PARENB
					   | PARODD
					   | CLOCAL));
    tty_settings->c_cflag |= (CS8 | CREAD);
    tty_settings->c_lflag &= ~((unsigned) (ECHONL
					   | NOFLSH
#ifdef TOSTOP
					   | TOSTOP
#endif
#ifdef ECHOPTR
					   | ECHOPRT
#endif
#ifdef XCASE
					   | XCASE
#endif
			       ));

    tty_settings->c_lflag |= (ISIG
			      | ICANON
			      | ECHO
			      | ECHOE
			      | ECHOK
#ifdef ECHOCTL
			      | ECHOCTL
#endif
#ifdef ECHOKE
			      | ECHOKE
#endif
	);
#endif

    SET_TTY(fd, tty_settings);
}