Reported part of 601c10cadf that was causing a crash

Need to investigate this further but we want the game playable in the meantime...
This commit is contained in:
Charles Dang 2021-01-21 09:56:16 +11:00
parent 780a08016e
commit 939f2b3c8a
2 changed files with 10 additions and 7 deletions

View file

@ -54,7 +54,7 @@ config& replay_recorder_base::get_command_at(int pos)
config& replay_recorder_base::add_child()
{
assert(pos_ <= size());
commands_.insert(commands_.begin() + pos_, config());
commands_.insert(commands_.begin() + pos_, new config());
++pos_;
return commands_[pos_ - 1];
}
@ -89,7 +89,7 @@ config& replay_recorder_base::insert_command(int index)
{
++pos_;
}
return *commands_.insert(commands_.begin() + index, config());
return *commands_.insert(commands_.begin() + index, new config());
}
@ -101,7 +101,7 @@ void replay_recorder_base::append_config(const config& data)
}
for(const config& command : data.child_range("command"))
{
commands_.push_back(command);
commands_.push_back(new config(command));
}
}
@ -113,9 +113,11 @@ void replay_recorder_base::append_config(config& data)
}
for(config& command : data.child_range("command"))
{
config new_config {};
new_config.swap(command);
commands_.push_back(std::move(new_config));
config* new_config = new config();
new_config->swap(command);
commands_.push_back(new_config);
}
}

View file

@ -13,6 +13,7 @@
#pragma once
#include <cassert>
#include <boost/ptr_container/ptr_vector.hpp>
#include "config.hpp"
@ -54,7 +55,7 @@ public:
void delete_upcoming_commands();
protected:
config upload_log_;
std::vector<config> commands_;
boost::ptr_vector<config> commands_;
int pos_;
};