diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-09-23 12:55:09 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-09-23 12:55:09 +0000 |
commit | 5618f4890df5eb9ea91eb73a7a7dd7df745863a6 (patch) | |
tree | 07873952b5f3f7efae06b3045692e2d90bd45a58 /src/game-server/command.cpp | |
parent | 203ed8e40105c17d300b12ee461327cb4416acf2 (diff) | |
download | manaserv-5618f4890df5eb9ea91eb73a7a7dd7df745863a6.tar.gz manaserv-5618f4890df5eb9ea91eb73a7a7dd7df745863a6.tar.bz2 manaserv-5618f4890df5eb9ea91eb73a7a7dd7df745863a6.tar.xz manaserv-5618f4890df5eb9ea91eb73a7a7dd7df745863a6.zip |
Robustified code with respect to insertion failures.
Diffstat (limited to 'src/game-server/command.cpp')
-rw-r--r-- | src/game-server/command.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/game-server/command.cpp b/src/game-server/command.cpp index 55ef4d10..a77c2c02 100644 --- a/src/game-server/command.cpp +++ b/src/game-server/command.cpp @@ -197,7 +197,7 @@ static void drop(Character *from, ItemClass *it, int nb) Item *item = new Item(it, nb); item->setMap(from->getMap()); item->setPosition(from->getPosition()); - GameState::insert(item); + GameState::insertSafe(item); } static void spawn(Character *from, MonsterClass *specy, int nb) @@ -211,7 +211,11 @@ static void spawn(Character *from, MonsterClass *specy, int nb) monster->setMap(map); monster->setPosition(pos); monster->clearDestination(); - GameState::insert(monster); + if (!GameState::insertSafe(monster)) + { + // The map is full. Break out. + break; + } } } |