diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-24 09:03:49 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-24 09:03:49 +0000 |
| commit | eb21e9d6bb772c6fba533bfe4b421dc7efe181b1 (patch) | |
| tree | 0d94fb38f7244e2495527d66d8e5ae2c9e155da2 /src/game/server/player.cpp | |
| parent | d9d37b945ee5796553794ef33249c22490494391 (diff) | |
| download | zcatch-eb21e9d6bb772c6fba533bfe4b421dc7efe181b1.tar.gz zcatch-eb21e9d6bb772c6fba533bfe4b421dc7efe181b1.zip | |
cleaned up the code a bit more. pooling of character and player objects with reusable macros. fixed crashing when changing maps and a couple of other bugs
Diffstat (limited to 'src/game/server/player.cpp')
| -rw-r--r-- | src/game/server/player.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index a31cf21c..252e23e3 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -5,12 +5,20 @@ #include "player.hpp" #include "gamecontext.hpp" +MACRO_ALLOC_POOL_ID_IMPL(PLAYER, MAX_CLIENTS) + PLAYER::PLAYER(int client_id) { character = 0; this->client_id = client_id; } +PLAYER::~PLAYER() +{ + delete character; + character = 0; +} + /* void PLAYER::init(int client_id) { @@ -168,7 +176,7 @@ void PLAYER::try_respawn() if(num_ents == 0) { spawning = false; - character = new CHARACTER(); + character = new(client_id) CHARACTER(); character->spawn(this, spawnpos, team); } } |