From b87f051b3f4e5dead4d7aad31ec2bea42859b281 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 13 Jul 2020 00:07:39 +0200 Subject: [PATCH] fixed a weird crash in guided tour --- multigame.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/multigame.cpp b/multigame.cpp index 5b54c823..e1fc9935 100644 --- a/multigame.cpp +++ b/multigame.cpp @@ -36,6 +36,18 @@ struct gamedata { } index += ssize; } + template void store_ptr(T& x) { + T* copy; + if(mode == 0) { + copy = new T; + *copy = move(x); + } + store(copy); + if(mode != 0) { + x = move(*copy); + delete copy; + } + } }; #endif @@ -49,7 +61,7 @@ void gamedata_all(gamedata& gd) { gd.store(chaosmode); gd.store(*current_display); gd.store(cgip); - gd.store(vid); + gd.store_ptr(vid); gd.store(sightrange_bonus); gd.store(genrange_bonus); gd.store(gamerange_bonus);