Пример #1
0
void print_inventory(struct Message *message) {
    int i = get_pindex(message->sender_nick);
    int j;
    char out[MAX_MESSAGE_BUFFER];
    char temp[100];

    sprintf(out, "PRIVMSG %s :", message->receiver);

    for (j = 0; j < (MAX_INVENTORY_SLOTS - dawn->players[i].available_slots); j++) {
        if (j % 9 == 0) {
            strcat(out, "\r\n");
            add_msg(out, strlen(out));
            sprintf(out, "PRIVMSG %s :", message->receiver);
        }
        temp[0] = '\0';

        sprintf(temp, "[%s%d%s%s] - %s%s%s ", 
                is_equipped(i, j) ? IRC_GREEN : IRC_RED,
                j,
                IRC_NORMAL,
                is_favorite(i, j) ? IRC_PURPLE"*"IRC_NORMAL : "",
                is_new(i, j) ? IRC_RED"["IRC_NORMAL : "",
                dawn->players[i].inventory[j].name,
                is_new(i, j) ? IRC_RED"]"IRC_NORMAL : "");
        strcat(out, temp);
    }
    sprintf(temp, " - Available slots: %d", dawn->players[i].available_slots);
    strcat(out, temp);
    strcat(out, "\r\n");
    add_msg(out, strlen(out));
}
Пример #2
0
int mutt_open_append_compressed (CONTEXT * ctx)
{
    FILE *fh;
    COMPRESS_INFO *ci = set_compress_info (ctx);

    if (!get_append_command (ctx->path, ctx)) {
        if (ci->open && ci->close)
            return (mutt_open_read_compressed (ctx));

        ctx->magic = 0;
        mem_free (&ctx->compressinfo);
        return (-1);
    }

    set_path (ctx);

    ctx->magic = DefaultMagic;

    if (!is_new (ctx->realpath))
        if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
            if ((fh = safe_fopen (ctx->path, "w")))
                fclose (fh);
    /* No error checking - the parent function will catch it */

    return (0);
}
Пример #3
0
void state_projectiont::new_states(queuet &queue, bool use_cache)
{
  // iterate over all states in queue

  #if 0  
  if(queue.new_threads_queue.empty()) return;
  
  for(state_listt::iterator it=queue.new_threads_queue.begin();
      it!=queue.new_threads_queue.end();
      it++)
  {
    if(is_new(*it, use_cache))
    {
      queue.main_queue.push_back(statet());
      queue.main_queue.back().swap(*it);
    }
  }
  
  queue.new_threads_queue.clear();
  
  if(queue.main_queue.empty())
    std::cout << "Thread fixed-point reached" << std::endl;
  else
    std::cout << "Increasing number of threads" << std::endl;
  #endif
}
Пример #4
0
static InStream *ram_open_input(Store *store, const char *filename)
{
    RAMFile *rf = (RAMFile *)h_get(store->dir.ht, filename);
    InStream *is = NULL;

    if (rf == NULL) {
        /*
        Hash *ht = store->dir.ht;
        int i;
        printf("\nlooking for %s, %ld\n", filename, str_hash(filename));
        for (i = 0; i <= ht->mask; i++) {
            if (ht->table[i].value)
                printf("%s, %ld  --  %ld\n", (char *)ht->table[i].key,
                       str_hash(ht->table[i].key), ht->table[i].hash);
        }
        */
        RAISE(FILE_NOT_FOUND_ERROR,
              "tried to open \"%s\" but it doesn't exist", filename);
    }
    REF(rf);
    is = is_new();
    is->file.rf = rf;
    is->d.pointer = 0;
    is->m = &RAM_IN_STREAM_METHODS;

    return is;
}
Пример #5
0
int ts_cm_t::realloc(uint32 & outer_id, uint32 & id)
{
    if(is_new(outer_id))
    {
        return -1;
    }

    return _alloc(outer_id, id);
}
Пример #6
0
static InStream *cmpd_create_input(InStream *sub_is, off_t offset, off_t length)
{
    InStream *is = is_new();
    CompoundInStream *cis = ALLOC(CompoundInStream);

    cis->sub = sub_is;
    cis->offset = offset;
    cis->length = length;
    is->d.cis = cis;
    is->m = &CMPD_IN_STREAM_METHODS;

    return is;
}
Пример #7
0
int mutt_can_append_compressed (const char *path)
{
    int magic;

    if (is_new (path))
        return (find_compress_hook (M_CLOSEHOOK, path) ? 1 : 0);

    magic = mx_get_magic (path);

    if (magic != 0 && magic != M_COMPRESSED)
        return 0;

    return (find_compress_hook (M_APPENDHOOK, path)
            || (find_compress_hook (M_OPENHOOK, path)
                && find_compress_hook (M_CLOSEHOOK, path))) ? 1 : 0;
}
Пример #8
0
static InStream *fs_open_input(Store *store, const char *filename)
{
    InStream *is;
    char path[MAX_FILE_PATH];
    int fd = open(join_path(path, store->dir.path, filename), O_RDONLY | O_BINARY);
    if (fd < 0) {
        RAISE(FILE_NOT_FOUND_ERROR,
              "tried to open \"%s\" but it doesn't exist: <%s>",
              path, strerror(errno));
    }
    is = is_new();
    is->file.fd = fd;
    is->d.path = estrdup(path);
    is->m = &FS_IN_STREAM_METHODS;
    return is;
}
Пример #9
0
inline bool newGeneration::is_new(oop p, char *boundary) {
    return p->is_mem() && is_new(memOop(p), boundary);
}
Пример #10
0
/* if the file is new, we really do not append, but create, and so use
 * close-hook, and not append-hook
 */
static const char *get_append_command (const char *path, const CONTEXT * ctx)
{
    COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;

    return (is_new (path)) ? ci->close : ci->append;
}
Пример #11
0
Surface_mesh::Face
Surface_mesh::
add_face(const std::vector<Vertex>& vertices)
{
    Vertex                   v;
    unsigned int             i, ii, n((int)vertices.size()), id;
    std::vector<Halfedge>    halfedges(n);
    std::vector<bool>        is_new(n), needs_adjust(n, false);
    Halfedge                 inner_next, inner_prev,
    outer_next, outer_prev,
    boundary_next, boundary_prev,
    patch_start, patch_end;

    // cache for set_next_halfedge and vertex' set_halfedge
    typedef std::pair<Halfedge, Halfedge>  NextCacheEntry;
    typedef std::vector<NextCacheEntry>    NextCache;

    NextCache    next_cache;
    next_cache.reserve(3*n);


    // don't allow degenerated faces
    assert (n > 2);


    // test for topological errors
    for (i=0, ii=1; i<n; ++i, ++ii, ii%=n)
    {
        if ( !is_boundary(vertices[i]) )
        {
            std::cerr << "Surface_meshT::add_face: complex vertex\n";
            return Face();
        }

        halfedges[i] = find_halfedge(vertices[i], vertices[ii]);
        is_new[i]    = !halfedges[i].is_valid();

        if (!is_new[i] && !is_boundary(halfedges[i]))
        {
            std::cerr << "Surface_meshT::add_face: complex edge\n";
            return Face();
        }
    }


    // re-link patches if necessary
    for (i=0, ii=1; i<n; ++i, ++ii, ii%=n)
    {
        if (!is_new[i] && !is_new[ii])
        {
            inner_prev = halfedges[i];
            inner_next = halfedges[ii];

            if (next_halfedge(inner_prev) != inner_next)
            {
                // here comes the ugly part... we have to relink a whole patch

                // search a free gap
                // free gap will be between boundary_prev and boundary_next
                outer_prev = opposite_halfedge(inner_next);
                outer_next = opposite_halfedge(inner_prev);
                boundary_prev = outer_prev;
                do
                    boundary_prev = opposite_halfedge(next_halfedge(boundary_prev));
                while (!is_boundary(boundary_prev) || boundary_prev==inner_prev);
                boundary_next = next_halfedge(boundary_prev);
                assert(is_boundary(boundary_prev));
                assert(is_boundary(boundary_next));


                // ok ?
                if (boundary_next == inner_next)
                {
                    std::cerr << "Surface_meshT::add_face: patch re-linking failed\n";
                    return Face();
                }

                // other halfedges' handles
                patch_start = next_halfedge(inner_prev);
                patch_end   = prev_halfedge(inner_next);

                // relink
                next_cache.push_back(NextCacheEntry(boundary_prev, patch_start));
                next_cache.push_back(NextCacheEntry(patch_end, boundary_next));
                next_cache.push_back(NextCacheEntry(inner_prev, inner_next));
            }
        }
    }



    // create missing edges
    for (i=0, ii=1; i<n; ++i, ++ii, ii%=n)
        if (is_new[i])
            halfedges[i] = new_edge(vertices[i], vertices[ii]);



    // create the face
    Face f(new_face());
    set_halfedge(f, halfedges[n-1]);



    // setup halfedges
    for (i=0, ii=1; i<n; ++i, ++ii, ii%=n)
    {
        v          = vertices[ii];
        inner_prev = halfedges[i];
        inner_next = halfedges[ii];

        id = 0;
        if (is_new[i])  id |= 1;
        if (is_new[ii]) id |= 2;

        if (id)
        {
            outer_prev = opposite_halfedge(inner_next);
            outer_next = opposite_halfedge(inner_prev);

            // set outer links
            switch (id)
            {
                case 1: // prev is new, next is old
                    boundary_prev = prev_halfedge(inner_next);
                    next_cache.push_back(NextCacheEntry(boundary_prev, outer_next));
                    set_halfedge(v, outer_next);
                    break;

                case 2: // next is new, prev is old
                    boundary_next = next_halfedge(inner_prev);
                    next_cache.push_back(NextCacheEntry(outer_prev, boundary_next));
                    set_halfedge(v, boundary_next);
                    break;

                case 3: // both are new
                    if (!halfedge(v).is_valid())
                    {
                        set_halfedge(v, outer_next);
                        next_cache.push_back(NextCacheEntry(outer_prev, outer_next));
                    }
                    else
                    {
                        boundary_next = halfedge(v);
                        boundary_prev = prev_halfedge(boundary_next);
                        next_cache.push_back(NextCacheEntry(boundary_prev, outer_next));
                        next_cache.push_back(NextCacheEntry(outer_prev, boundary_next));
                    }
                    break;
            }

            // set inner link
            next_cache.push_back(NextCacheEntry(inner_prev, inner_next));
        }
        else needs_adjust[ii] = (halfedge(v) == inner_next);


        // set face handle
        set_face(halfedges[i], f);
    }



    // process next halfedge cache
    NextCache::const_iterator ncIt(next_cache.begin()), ncEnd(next_cache.end());
    for (; ncIt != ncEnd; ++ncIt)
        set_next_halfedge(ncIt->first, ncIt->second);



    // adjust vertices' halfedge handle
    for (i=0; i<n; ++i)
        if (needs_adjust[i])
            adjust_outgoing_halfedge(vertices[i]);


    return f;
}