Exemplo n.º 1
0
Character *new_char()
{
    Character *ch = (Character *) alloc_mem(1, sizeof(Character));
    ch->flags = new_flag();
    ch->affectedBy = new_flag();
    ch->next = 0;
    ch->next_in_area = 0;
    ch->name = str_empty;
    ch->position = POS_STANDING;
    ch->sex = SEX_NEUTRAL;
    ch->description = str_empty;
    ch->hit = ch->maxHit = 100;
    ch->mana = ch->maxMana = 100;
    ch->move = ch->maxMove = 100;
    ch->writelnf = writef_line_to_char;
    ch->writef = writef_to_char;
    ch->writeln = write_line_to_char;
    ch->write = write_to_char;
    ch->page = page_to_char;
    ch->title = title_to_char;
    ch->titlef = titlef_to_char;
    ch->classes = alloc_mem(1, sizeof(int));
    ch->classes[0] = -1;
    ch->size = SIZE_AVERAGE;

    for (int i = 0; i < MAX_DAM; i++) {
        ch->resists[i] = 100;
    }
    return ch;
}
Exemplo n.º 2
0
 Argument_helper::Argument_helper(){
   author_="a programmer";
   description_= "This program produces output.";
   date_= "some day a long, long time ago.";
   version_=-1;
   extra_arguments_=NULL;
   seen_end_named_=false;
   new_flag('v', "verbose", "Whether to print extra information", verbose);
   new_flag('V', "VERBOSE", "Whether to print lots of extra information", VERBOSE);
 }
Exemplo n.º 3
0
Player *new_player(Connection *conn)
{
    Player *p = (Player *) alloc_mem(1, sizeof(Player));
    p->title = str_empty;
    p->prompt = str_dup("[~R%h~x/~R%H~rhp ~M%m~x/~M%M~mm ~B%v/~B%V~bmv~x]");
    p->battlePrompt =
        str_dup("[~R%h~x/~R%H~rhp ~M%m~x/~M%M~mm ~B%v/~B%V~bmv~x] %E");
    p->conn = conn;
    p->account = conn->account;
    p->explored = new_flag();
    p->channels = new_flag();
    p->permHit = 100;
    p->permMana = 100;
    p->permMove = 100;
    return p;

}
static void *curl_func(void * share_file)
{
    //read music from music box

    CURL *curl;
    CURLcode res;

    const char * file_name;

    if (share_file == NULL) {
        fprintf(stderr, "Fatal Error: share file not initialized in curl_func().\n");
    }

    file_t curl_fd = (file_t)share_file;

    curl_buffer_t cbuf = new_curl_buffer(curl_fd);

    curl_flag = new_flag();
    curl_global_init(CURL_GLOBAL_ALL);

    while (1) {
        // get the music file name and create it if it haven't already exist.
        pthread_mutex_lock(&curl_start_lock);

        cbuf->offset = 0;
        cbuf->file->eof = 0;
        cbuf->file->size = 0;
        set_flag(curl_flag, '\0');

        file_name = get_music_url();
        printf("file name = %s\n", file_name);

        curl = curl_easy_init();
        curl_easy_setopt (curl, CURLOPT_URL, file_name);
        curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data);
        curl_easy_setopt (curl, CURLOPT_WRITEDATA, cbuf);
        //  curl_easy_setopt(curl, CURLOPT_TIMEOUT, 9);
        res = curl_easy_perform(curl);
        if(CURLE_OK != res) {
            printf("curl error...\n");
        }

        cbuf->file->eof = 1;

        curl_easy_cleanup(curl);

        if (is_going_to_close(curl_flag)) {
            goto quit;
        }
    }

quit:
    destroy_curl_buffer(cbuf);
    destroy_flag(curl_flag);
    return (void*)0;
}