コード例 #1
0
//! Upload the last map once more. This does NOT save the world - it can be called without
//! even having a world loaded (e.g., from the main menu, right after startup). It simply
//! packages the files in the map directory and uploads them. This is useful for making
//! fixes to map scripts that crash the server, but can also be used after manually
//! replacing the .ogz file, etc.
void repeat_upload()
{
    std::string lastUploadedMapAsset = last_uploaded_map_asset;

    // Acquire the asset info, so we know its file locations, asset server, etc.
    renderprogress(0.2, "getting map asset info...");
    REFLECT_PYTHON( AssetManager );
    boost::python::object assetInfo = AssetManager.attr("get_info")( lastUploadedMapAsset );

    // Set the map asset ID to the last one uploaded
    REFLECT_PYTHON( set_curr_map_asset_id );
    set_curr_map_asset_id( lastUploadedMapAsset );
    REFLECT_PYTHON( World );
    World.attr("asset_info") = assetInfo;

//    // Make sure the script compiles ok TODO: All scripts, not just the main one
//    renderprogress(0.5, "compiling scripts...");
//    REFLECT_PYTHON( get_map_script_filename );
//    std::string filename = boost::python::extract<std::string>( get_map_script_filename() );
//    if (!checkCompile(filename)) XXX - need engine for this!
//        return;

    // Do the upload
    renderprogress(0.7, "compiling scripts...");
    REFLECT_PYTHON( upload_map );
    upload_map();

    conoutf("Upload complete.");
}
コード例 #2
0
//! The user picks 'upload map' in the GUI.
//! First we save the map. Then we call Python, which packages the map
//! and uploads it to the correct asset server, then notify the instance we
//! are connected to that the map has been updated, which then gets and runs
//! that new map. That process causes it to tell all clients of a new map that
//! they should get, which makes them get the new version. Among those clients is
//! this one, the uploader, which we do not treat differently in that respect.
void do_upload()
{
    renderprogress(0.1, "compiling scripts...");

    // Make sure the script compiles ok TODO: All scripts, not just the main one
    REFLECT_PYTHON( get_map_script_filename );
    std::string filename = boost::python::extract<std::string>( get_map_script_filename() );
    if (!checkCompile(filename))
        return;

    // Save ogz
    renderprogress(0.3, "generating map...");
    save_world(game::getclientmap());

// load_world: ogzname, mname, cname: packages/base/spiral/map.ogz,base/spiral/map,(null)
// save_world ogzname, mname, cname: packages//packages.ogz,/packages

    // Save entities (and backup)
    renderprogress(0.4, "exporting entities...");
    REFLECT_PYTHON( export_entities );
    export_entities("entities.json");

    // Do the upload
    renderprogress(0.5, "uploading map...");
    REFLECT_PYTHON( upload_map );
    upload_map();

    // Remember asset
    REFLECT_PYTHON( get_curr_map_asset_id );
    std::string assetId = boost::python::extract<std::string>( get_curr_map_asset_id() );
    setsvar("last_uploaded_map_asset", assetId.c_str());
}
コード例 #3
0
void connect_to_instance(char *instance_id)
{
    REFLECT_PYTHON( login_to_instance );

    std::string instanceId = instance_id;

    login_to_instance(instanceId);
}
コード例 #4
0
std::string getIntensityLocalAssetPath(const AssetId& id, AssetManager* manager)
{
    // The id is assumed to be the shortpath
    REFLECT_PYTHON_ALTNAME(os.path.join, os_path_join);
    REFLECT_PYTHON(get_asset_dir);

    python::object temp = os_path_join( get_asset_dir(), id );

    return python::extract<std::string>(temp);
}
コード例 #5
0
// Get instance data and create a GUI for it
void show_instances()
{
    REFLECT_PYTHON( get_possible_instances );

    boost::python::object instances = get_possible_instances();

    REFLECT_PYTHON( None );

    if (instances == None)
    {
        setsvar("error_message", "Could not get the list of instances");
        showgui("error");
        return;
    }

    std::string command =
        "newgui instances [\n"
        "    guitext \"Pick an instance to enter:\"\n"
        "    guibar\n";

    int numInstances = boost::python::extract<int>(instances.attr("__len__")());

    for (int i = 0; i < numInstances; i++)
    {
        boost::python::object instance = instances[i];
        std::string instance_id = boost::python::extract<std::string>(instance.attr("__getitem__")("instance_id"));
        std::string event_name = boost::python::extract<std::string>(instance.attr("__getitem__")("event_name"));

        assert( Utility::validateAlphaNumeric(instance_id) );
        assert( Utility::validateAlphaNumeric(event_name, " (),.;") ); // XXX: Allow more than alphanumeric+spaces: ()s, .s, etc.

        command += "    guibutton \"" + event_name + "\" \"connect_to_instance " + instance_id + "\"\n";
    }

    command += "]\n";
    command += "showgui instances\n";

    Logging::log(Logging::DEBUG, "Instances GUI: %s\r\n", command.c_str());

    execute(command.c_str());
}
コード例 #6
0
AssetHash getIntensityLocalAssetHash(const AssetId& id, AssetManager* manager)
{
    std::string path = manager->getLocalAssetPath(id);

    REFLECT_PYTHON( calculate_file_hash );

    std::string hash = python::extract<std::string>( calculate_file_hash(path) );

    Logging::log(Logging::DEBUG, "Calculated IntensityHash: %s ==== %s\r\n", id.c_str(), hash.c_str());

    return hash;
}