Exemplo n.º 1
0
//--------------------------------------------------------------------------------------------
bool wawalite_weather_t::write(vfs_FILE *filewrite, const wawalite_weather_t *profile)
{
    if (NULL == filewrite || NULL == profile) return false;

    // weather data
    vfs_printf(filewrite,   "Weather particle effect ( NONE, LAVA, RAIN or SNOW ): %s", profile->weather_name.c_str());
    vfs_put_bool(filewrite, "Weather particles only over water ( TRUE or FALSE ) :", profile->over_water);
    vfs_put_int(filewrite,  "Weather particle spawn rate ( 0 to 100, 0 is none ) :", profile->timer_reset);

    return true;
}
Exemplo n.º 2
0
//--------------------------------------------------------------------------------------------
void module_add_idsz_vfs( const char *szModName, IDSZ idsz, size_t buffer_len, const char * buffer )
{
    /// @details ZZ@> This function appends an IDSZ to the module's menu.txt file
    vfs_FILE *filewrite;

    // Only add if there isn't one already
    if ( !module_has_idsz_vfs( szModName, idsz, 0, NULL ) )
    {
        STRING src_file, dst_file;

        // make sure that the file exists in the user data directory since we are WRITING to it
        snprintf( src_file, SDL_arraysize( src_file ), "mp_modules/%s/gamedat/menu.txt", szModName );
        snprintf( dst_file, SDL_arraysize( dst_file ), "/modules/%s/gamedat/menu.txt", szModName );
        vfs_copyFile( src_file, dst_file );

        // Try to open the file in append mode
        filewrite = vfs_openAppend( dst_file );
        if ( filewrite )
        {
            // output the expansion IDSZ
            vfs_printf( filewrite, "\n:[%s]", undo_idsz( idsz ) );

            // output an optional parameter
            if ( NULL != buffer && buffer_len > 1 )
            {
                vfs_printf( filewrite, " %s", undo_idsz( idsz ) );
            }

            // end the line
            vfs_printf( filewrite, "\n" );

            // invalidate any module list so that we will reload them
            module_list_valid = bfalse;

            // close the file
            vfs_close( filewrite );
        }
    }
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------------------------
bool wawalite_data_write(const std::string& filename,const wawalite_data_t *profile)
{
    if (!profile)
    {
        throw std::invalid_argument("nullptr == profile");
    }
    auto filewrite = std::shared_ptr<vfs_FILE>(vfs_openWrite(filename),
                                               [](vfs_FILE *file) {
                                                   if (file) {
                                                       vfs_close(file);
                                                   }
                                               });
    if (!filewrite)
    {
		Log::get().warn("%s:%d: unable to write file `%s`\n", __FILE__, __LINE__, filename.c_str());
        return false;
    }

    // Add file verison number
    vfs_put_version( filewrite.get(), WAWALITE_FILE_VERSION );

    // file header
    vfs_printf(filewrite.get(), "// This file tells the game how to model lighting and water...\n");
    vfs_printf(filewrite.get(), "// Please fill in all of the data even if you only use one layer of\n");
    vfs_printf(filewrite.get(), "// water. 2 is the maximum number of layers.\n");
    vfs_printf(filewrite.get(), "// This file also gives information regarding damage tiles and\n");
    vfs_printf(filewrite.get(), "// friction for the module.\n");
    vfs_printf(filewrite.get(), "\n\n");

    // random map
    vfs_put_int(filewrite.get(), "Random map ( TRUE or FALSE ) ( doesn't work )           :", profile->seed);

    wawalite_water_t::write(filewrite.get(), &(profile->water));
    wawalite_light_t::write(filewrite.get(), &(profile->light));
    wawalite_physics_t::write(filewrite.get(), &(profile->phys));
    wawalite_animtile_t::write(filewrite.get(), &(profile->animtile));
    wawalite_damagetile_t::write(filewrite.get(), &(profile->damagetile));
    wawalite_weather_t::write(filewrite.get(), &(profile->weather));
    wawalite_graphics_t::write(filewrite.get(), &(profile->graphics));
    wawalite_camera_t::write(filewrite.get(), &(profile->camera));
    wawalite_fog_t::write(filewrite.get(), &(profile->fog));

    if (profile->fog.found)
    {
        vfs_printf(filewrite.get(), "\n\n// Damage tile expansion...  Must have fog first...\n");
        vfs_put_local_particle_profile_ref(filewrite.get(), "Weather particle to spawn ( 4 or 5, 6 is splash )  :", profile->damagetile.part_gpip);
        vfs_put_int(filewrite.get(), "Particle timing AND ( 1, 3, 7, 15, etc. )          :", profile->damagetile.partand);
        vfs_put_int(filewrite.get(), "Damage sound ( 0 to 4 )                            :", profile->damagetile.sound_index);
    }

    return true;
}
Exemplo n.º 4
0
//--------------------------------------------------------------------------------------------
bool wawalite_fog_t::write(vfs_FILE *filewrite, const wawalite_fog_t *profile)
{
    if (NULL == filewrite || NULL == profile) return false;

    // write optional data...  Only read if it exists...
    if (!profile->found) return true;

    vfs_printf( filewrite, "\n\n// Fog Expansion...  Leave this out for no fog...\n" );
    vfs_put_float(filewrite, "Fog top z ( 0 to 100 )                           :", profile->top);
    vfs_put_float(filewrite, "Fog bottom z ( 0 )                               :", profile->bottom);
    vfs_put_float(filewrite, "Fog Red ( 0.0 to 1.0 )                           :", profile->red);
    vfs_put_float(filewrite, "Fog Green ( 0.0 to 1.0 )                         :", profile->grn);
    vfs_put_float(filewrite, "Fog Blue ( 0.0 to 1.0 )                          :", profile->blu);
    vfs_put_bool(filewrite, "Fog affects water ( TRUE or FALSE )               :", profile->affects_water);

    return true;
}