--- a/rust/lib-hedgewars-engine/src/lib.rs Fri Dec 07 13:56:45 2018 +0100
+++ b/rust/lib-hedgewars-engine/src/lib.rs Fri Dec 07 14:30:35 2018 +0100
@@ -42,14 +42,19 @@
(*engine_state).world.generate_preview();
- let land_preview = (*engine_state).world.preview();
+ if let Some(land_preview) = (*engine_state).world.preview() {
+ *preview = PreviewInfo {
+ width: land_preview.width() as u32,
+ height: land_preview.height() as u32,
+ hedgehogs_number: 0,
+ land: land_preview.raw_pixels().as_ptr(),
+ };
+ }
+}
- *preview = PreviewInfo {
- width: land_preview.width() as u32,
- height: land_preview.height() as u32,
- hedgehogs_number: 0,
- land: land_preview.raw_pixels().as_ptr(),
- };
+#[no_mangle]
+pub extern "C" fn dispose_preview(engine_state: &mut EngineInstance, preview: &mut PreviewInfo) {
+ (*engine_state).world.dispose_preview();
}
#[no_mangle]