//! 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()); }
//! 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."); }
void trigger_received_entity() { num_received_entities++; if (num_expected_entities > 0) { float val = clamp(float(num_received_entities) / float(num_expected_entities), 0.0f, 1.0f); if (loading) { defformatstring(buf)("received entity %d ...", num_received_entities); renderprogress(val, buf); } } }
void trigger_received_entity() { num_received_entities++; if (num_expected_entities > 0) { float val = clamp(float(num_received_entities) / float(num_expected_entities), 0.0f, 1.0f); if (loading) renderprogress(val, types::String().format( "received entity %i ...", num_received_entities ).get_buf()); } }