Ejemplo n.º 1
0
void str_map_iter_next(str_map_iter_ptr iter)
{
    assert(str_map_iter_is_valid(iter));

    iter->node = iter->node->next;
    if (!iter->node)
    {
        int prime = _primes[iter->map->prime_idx];
        int i;

        for (i = iter->bucket + 1; i < prime; i++)
        {
            iter->bucket = i;
            iter->node = iter->map->buckets[i];
            if (iter->node)
                break;
        }
    }
}
Ejemplo n.º 2
0
void spell_stats_on_save(savefile_ptr file)
{
    str_map_ptr      map = _spell_stats_map();
    str_map_iter_ptr iter;
    
    savefile_write_s32b(file, str_map_count(map));

    for (iter = str_map_iter_alloc(map); 
            str_map_iter_is_valid(iter); 
            str_map_iter_next(iter))
    {
        spell_stats_ptr stats = str_map_iter_current(iter);

        savefile_write_cptr(file, str_map_iter_current_key(iter));
        savefile_write_u32b(file, stats->flags);
        savefile_write_s32b(file, stats->ct_cast);
        savefile_write_s32b(file, stats->ct_fail);
        savefile_write_s32b(file, stats->skill);
        savefile_write_s32b(file, stats->max_skill);
        savefile_write_s32b(file, stats->last_turn);
    }
    str_map_iter_free(iter);
}
Ejemplo n.º 3
0
void skills_on_save(savefile_ptr file)
{
    str_map_ptr         map = _innate_map();
    str_map_iter_ptr    iter;

    savefile_write_s32b(file, str_map_count(map));

    for (iter = str_map_iter_alloc(map);
            str_map_iter_is_valid(iter);
            str_map_iter_next(iter))
    {
        cptr            name = str_map_iter_current_key(iter);
        _skill_info_ptr info = (_skill_info_ptr)str_map_iter_current(iter);

        savefile_write_cptr(file, name);
        savefile_write_s32b(file, info->current);
        savefile_write_s32b(file, info->max);
    }
    str_map_iter_free(iter);

    /* TODO: Spell Skills for Bookless Casters */
    savefile_write_s32b(file, 0);
}
Ejemplo n.º 4
0
const char * str_map_iter_current_key(str_map_iter_ptr iter)
{
    assert(str_map_iter_is_valid(iter));
    return iter->node->key;
}
Ejemplo n.º 5
0
void * str_map_iter_current(str_map_iter_ptr iter)
{
    assert(str_map_iter_is_valid(iter));
    return iter->node->val;
}