attempt to fix server crash
This commit is contained in:
parent
cc7eea96e3
commit
028b742395
3 changed files with 5 additions and 7 deletions
|
@ -692,7 +692,7 @@ void config::clear_children(const std::string& key)
|
|||
children.erase(key);
|
||||
}
|
||||
|
||||
void config::remove_child(const std::string& key, size_t index)
|
||||
config* config::remove_child(const std::string& key, size_t index)
|
||||
{
|
||||
//remove from the ordering
|
||||
const child_pos pos(children.find(key),index);
|
||||
|
@ -709,7 +709,9 @@ void config::remove_child(const std::string& key, size_t index)
|
|||
//remove from the child map
|
||||
child_list& v = children[key];
|
||||
assert(index < v.size());
|
||||
config* const res = v[index];
|
||||
v.erase(v.begin()+index);
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string& config::operator[](const std::string& key)
|
||||
|
|
|
@ -120,7 +120,7 @@ struct config
|
|||
const std::string& value) const;
|
||||
|
||||
void clear_children(const std::string& key);
|
||||
void remove_child(const std::string& key, size_t index);
|
||||
config* remove_child(const std::string& key, size_t index);
|
||||
|
||||
static std::vector<std::string> split(const std::string& val, char c=',');
|
||||
static std::string& strip(std::string& str);
|
||||
|
|
|
@ -66,9 +66,6 @@ void server::run()
|
|||
config data;
|
||||
while((sock = network::receive_data(data)) != NULL) {
|
||||
|
||||
std::cerr << "from " << (int)sock << " received: "
|
||||
<< data.write() << "\n-----\n";
|
||||
|
||||
//if someone who is not yet logged in is sending
|
||||
//login details
|
||||
if(not_logged_in_.is_member(sock)) {
|
||||
|
@ -247,8 +244,7 @@ void server::run()
|
|||
|
||||
const config::child_iterator desc = std::find(vg.first,vg.second,g->description());
|
||||
if(desc != vg.second) {
|
||||
gamelist->remove_child("game",desc - vg.first);
|
||||
delete *desc;
|
||||
delete gamelist->remove_child("game",desc - vg.first);
|
||||
}
|
||||
|
||||
//put the players back in the lobby and send
|
||||
|
|
Loading…
Add table
Reference in a new issue