예제 #1
0
파일: loop.c 프로젝트: jsyk/Talking_Clock
message_t *loop_put_msg_begin(void)
{
    int8_t next_wp = iwrap(g_message_buffer.wrpos+1);
    if (next_wp == g_message_buffer.rdpos) {
        /* Buffer full! */
        usart_sendstr_P(PSTR("[loop_put_msg_begin FULL]\n"));
        return NULL;
    }
    return &g_message_buffer.msg_buf[g_message_buffer.wrpos];
}
예제 #2
0
파일: main.c 프로젝트: bsurmanski/SDLDemos
static void *techtonics_start(void *args)
{
    SDL_Surface *back = args; 

    vec2 *velocity = alloca(sizeof(vec2) * N_PLATES);

    int i,j;
    for(i = 0; i < N_PLATES; i++)
    {
        vec2_rand(velocity[i]);
    }

    for(j = 0; j < HEIGHT; j++)
    {
        for(i = 0; i < WIDTH; i++)
        {
            int val = unpackid(getpixel(s, i, j));
            int dstx = iwrap(i + velocity[val][X] * 5, WIDTH - 1);
            int dsty = iwrap(j + velocity[val][Y] * 5, HEIGHT - 1);
            setpixel(back, dstx, dsty, val); 
        }
    }
}
예제 #3
0
파일: loop.c 프로젝트: jsyk/Talking_Clock
/**
 * Main message (infinite) loop.
 */
void loop_loop(int8_t once)
{
    do {
        message_t lmsg;
        if (g_message_buffer.rdpos == g_message_buffer.wrpos) {
            /* no message in the buffer: Run NOP message */
            lmsg.cmd = Cmd_Nop;
            lmsg.arg1i = 0;
        } else {
            /* a message in the buffer: retrieve and process */
            lmsg = g_message_buffer.msg_buf[g_message_buffer.rdpos];
            g_message_buffer.rdpos = iwrap(g_message_buffer.rdpos + 1);

            if (lmsg.cmd != Cmd_ClockTick) {
                usart_sendstr_P(PSTR("[Msg:0x"));
                usart_sendhexb(lmsg.cmd);
                usart_sendstr_P(PSTR("]"));
            }
        }

        int8_t used = 0;
        used |= voice_process(&lmsg);
        used |= vfs_process(&lmsg);
        used |= sound_process(&lmsg);
        used |= ir_process(&lmsg);
        used |= debug_process(&lmsg);
        used |= btn_process(&lmsg);
        used |= clock_process(&lmsg);

        if (!used && (lmsg.cmd != Cmd_Nop)) {
            usart_sendstr_P(PSTR("[Msg not recognized!]\n"));
        }

        /* reset watchdog timer */
        wdt_reset();
    } while (!once);
}
예제 #4
0
파일: loop.c 프로젝트: jsyk/Talking_Clock
void loop_put_msg_end(message_t *msg)
{
    int8_t next_wp = iwrap(g_message_buffer.wrpos+1);
    g_message_buffer.wrpos = next_wp;
}
예제 #5
0
string finger_user(string who) {
    object link, body;
    mixed tmp1, tmp2, tmp3, tmp4, tmp5;
    string msg;
    mapping mail_stat;
    int hibernate;

    link = restore_data(who);
    if (link) body = restore_body(who);

    if (!link || !body) {
	if (sscanf(who, "(%s)", who))
	    return finger_group(who);
	return "Finger: There is no such user.\n";
    }

    msg = LINE1;

    // Line 1: Fingerguy the Utter Novice (Chaotic Neutral)
    if (link->query("wizard")) {
	string al, title = body->getenv( "TITLE" );
	al = body->query("al_title");
	if (!al || al=="") {
	    msg += body->query_title() + "\n";
	} else {
	    if (!title) title = "$N the New Wizard ($A)";
	    title = replace_string(title, "$N", body->query("cap_name"));
	    title = replace_string(title, "$A", al);
	    msg += title + "\n";
	}
    } else
	msg += body->query_title() + "\n";

    // Line 2: Male Human Mage [Level 5]
    // or:    Male Human Necromancer [Lesser Power of Prime]
    msg += capitalize(body->query("gender"));
    msg += " "+capitalize(body->query("race"));

    mail_stat = link->query("Class");
    if (mail_stat) {
	tmp1 = (values(mail_stat))[0];
	msg += ( " " +  capitalize(tmp1) );
    }

    if (wizardp(TP)) {
	if (link->query("wizard")) {
	    if (member_group(body->query("name"), "ambassador")) {
		tmp1 = "Ambassador";
		tmp2 = body->query("ambassador");
		if ((tmp2 != 0) && (tmp2 != ""))
		    tmp1 = tmp1 + " of " + capitalize(tmp2);
	    } else {
		tmp1 = DOMAIN_D->query_domain(link);
		tmp2 = DOMAIN_D->query_domain_level(link);
		if ((tmp1 == 0) || (tmp1 == ""))
		    tmp1 = "Domainless "+tmp2;
		else
		    tmp1 = tmp2 + " of " + tmp1 + " Domain";
	    }
	} else {
	    tmp1 = "Level " + link->query("level");
	}
	tmp1 = " [" + tmp1 + "]\n";
	msg += tmp1;
    } else msg += "\n";

    // Line 3: Gang allegience: The Machiavellian Menagerie
    // or: The Admin (Leader)
    
	tmp1 = "Gang allegience: ";
	tmp2 = body->query("gang");

	if (tmp2) {
	    mail_stat = GANG_D->get_list_map();
	    if (mail_stat[tmp2] == body->query("name"))
	        tmp1 += "Leader of "+cap_all_words(tmp2);
	    else
	        tmp1 += "Member of "+cap_all_words(tmp2);
	       
	} else {
	    tmp1 += "none";
	}
	
   	msg += tmp1 + "\n";

    // Line 4 : Married to Whoever
    tmp1 = body->query("spouse");
    if (tmp1) {
	tmp1 = capitalize(tmp1);
	msg += "Married to "+tmp1+"\n";
    }

    // Line 5 : A cool line to make it all very pretty.
    msg += LINE2;

    // Line 6: In Real Life: Matthew A. Titmus
    // or: In Real Life: ?
    tmp2 = "In Real Life: ";
    if (tmp3 = (string)link->RNAME)
	tmp2 += extract(tmp3, 0, 22);
    else
	tmp2 += "?";

    msg += "Status: ";
    if (member_group(body->query("name"), "root"))
	msg += "Administrator\n";
    else if (member_group(body->query("name"), "adminaccess"))
	msg += "Elder\n";
    else if (member_group(body->query("name"), "ambassador"))
	msg += "Ambassador\n";
    else if (link->query("wizard"))
	msg += "Immortal\n";
    else
	msg += "Player\n";

    if (body->query("email_visible"))
	tmp1 = "[Public]";
    else
	tmp1 = "[Private]";

    if (adminp(TP) || 
      body->query("name")==TP->query("name")) {
	tmp1 = (string)link->query("email")+" "+tmp1;
    } else {
	if (body->query("email_visible")) {
	    tmp1 = (string)link->query("email");
	} else {
	    tmp1 = "[Private]";
	}
    }

    if (tmp1) msg += "Email address: " + tmp1 + "\n";

    tmp1 = (string)link->query("URL");
    if (tmp1) msg += "URL: " + tmp1 + "\n";

    hibernate = (int)link->query("hibernate");

    if (hibernate && time() < hibernate)
	msg += "\n\t[In hibernation until " + ctime(hibernate) + "]\n\n";

    tmp1 = find_player(who);
    if (tmp1) {
	if (!filter_users(tmp1))
	    tmp1 = 0;
    }

    if (!link->query("last_on"))
	msg += (tmp1 ? "On since: " : "Last on: ") + "Unavailable";
    else
	msg += ((tmp1 && !tmp1->query("npc")) ? "On since: " : "Last on: ") +
	ctime((int)link->query("last_on")) ;

    if (wizardp(TP)) 
	msg += ( " from " + (string)link->query("ip") + " \n" );
    else
	msg += "\n";

    if (tmp1) {
	tmp1 = query_idle_string(tmp1, 1);
	if (strlen(tmp1) > 0)
	    msg += tmp1 + "\n";
    }

    mail_stat = (mapping)MAILBOX_D->mail_status(who);
    if (mail_stat["unread"])
	msg += sprintf("%s has not read %d of their %d piece%s of mail.\n",
	  capitalize(who), mail_stat["unread"], mail_stat["total"],
	  (mail_stat["total"] == 1 ? "" : "s"));
    else {
	msg += "No unread mail" ;
	if(this_player()) {
	    if (adminp(getuid(this_player()))) {
		//  msg += " ("+mail_stat["total"]+" pieces)" ;
		msg += sprintf(" (%d piece%s)", mail_stat["total"], (mail_stat["total"] == 1 ? "" : "s"));
	    }
	}
	msg += ".\n" ;
    }

    if (link->query("wizard")) {
	tmp1 = user_path(who) + ".project";
	if (file_size(tmp1) >= 0)
	    msg += "Project: " + read_file(tmp1);

	tmp1 = user_path(who) + ".plan";
	if (file_size(tmp1) >= 0) {
	    msg += "Plan:\n" + read_file(tmp1);
	} else {
	    msg += "No Plan.\n";
	}
    } else {
	if (body->query("session"))
	    tmp1 = iwrap("Session: "+body->query("session"));
	else
	    tmp1 = "No Session.\n";

	msg += tmp1;
    }

    msg += LINE1;

    if (!find_player(who) || !interactive(find_player(who))) {
	link->remove();
	// Some names like .foo weren't getting away.
	if(link) destruct(link);
	if(link) log_file("fingerdest",sprintf("Connection of %s not "+
		"dested by finger daemon, on %s.\n", link->query("name"), 
		ctime(time())));

	if(body) destruct(body);
	if(body) log_file("fingerdest",sprintf("Connection of %s not "+
		"dested by finger daemon, on %s.\n", body->query("name"), 
		ctime(time())));
    }

    return "\n" + msg + "\n";
}
예제 #6
0
int cmd_shout (string str) {

    mapping languages ;
    string *roomnames, p_language, ostr ;
    object ob, *users, *rooms;
    int i, p_chance, flag, success, loop, shoutblock;
    string nstr, how, what ;

    if (!str) {
	notify_fail("Shout what?\n");
	return 0;
    }

    /*
       if (TP->query_level() < 2) {
	  write("Sorry - due to abuse, you cannot shout until you reach\n"+
	    "level 2. If you REALLY need help, use the 'wizcall' command.\n");
	  return 1;
       }
    */

    if (TP->query("shoutblock")) {
	write("Sorry - your shoublock is on.\n");
	return 1;
    }

    nstr = str;

#ifdef LANGUAGES

    // Fetch the languages X speaks.

    languages=previous_object()->query("languages");
    if (!languages) languages = LANGUAGE_D->get_mapping() ;


    // filter out which language to use

    flag = 0 ;

    ostr = str;

    if ( sscanf (str, "in %s %s", how, what)==2) {
	p_language = lower_case(how) ;
	str = what ;
    } else {
	how = previous_object()->query("default_language") ;
	if (!how) how="common" ;
	p_language = lower_case(how) ;
    }

    if (languages[lower_case(how)] > 0 )
    {
	flag=1 ;
	p_language=lower_case(how);
	p_chance=languages[p_language];
    }

    if (flag==0)
    {
	p_language = "common";
	p_chance = languages[p_language];
	how = "common";
	str = ostr;
    }


    // Now we want to determine success or not, in speaking the language

    success=0;

    if ( random (100) < p_chance )
	success=1;

    if ( ! success ) 
	write ("You stumble out some words, "+
	  "unfamiliar with the tongue.\n");

    //   Now fetch the garbled versions of the string 
    //   from the language daemon.

    g_string=(string)LANGUAGE_D->garble_string(str, p_language);
    g_lang=(string)LANGUAGE_D->transform_string(str, p_language);


    ostr = "in " + capitalize(p_language) + ": " + str;
    str = ostr;

#endif
#ifndef LANGUAGES
    ostr =": " + str;
    str = ostr;
#endif

    write(iwrap("You shout "+str));
    ob = environment(this_player());
    if (!ob) {
	notify_fail("Your shouts go unheard in the void.\n");
	return 0;
    }

    do_shout (environment(previous_object()),nstr, p_language, success) ;

    users = users();
    rooms = ({});