diff options
| author | Dominik Geyer <dominik.geyer@gmx.de> | 2008-09-09 15:50:41 +0000 |
|---|---|---|
| committer | Dominik Geyer <dominik.geyer@gmx.de> | 2008-09-09 15:50:41 +0000 |
| commit | 51a9d23dae18ec7a678bdf4215f48d863a720fdc (patch) | |
| tree | a29a599405c5ef1eab9631dc736837b8048e1282 | |
| parent | 3b086d616a9090f714c90c7985f10c5dc4bd5733 (diff) | |
| download | zcatch-51a9d23dae18ec7a678bdf4215f48d863a720fdc.tar.gz zcatch-51a9d23dae18ec7a678bdf4215f48d863a720fdc.zip | |
fixed spectator mode freeview
| -rw-r--r-- | src/game/client/components/camera.cpp | 4 | ||||
| -rw-r--r-- | src/game/client/components/controls.cpp | 4 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 3 | ||||
| -rw-r--r-- | src/game/client/gameclient.hpp | 1 | ||||
| -rw-r--r-- | src/game/server/player.cpp | 5 |
5 files changed, 10 insertions, 7 deletions
diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp index a9727ccf..ba9aed46 100644 --- a/src/game/client/components/camera.cpp +++ b/src/game/client/components/camera.cpp @@ -20,9 +20,7 @@ void CAMERA::on_render() //vec2 center; zoom = 1.0f; - bool spectate = false; - - if(spectate) + if(gameclient.snap.spectate) center = gameclient.controls->mouse_pos; else { diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index 208cad5e..f693eb98 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -157,8 +157,6 @@ bool CONTROLS::on_mousemove(float x, float y) { mouse_pos += vec2(x, y); // TODO: ugly - bool spectate = false; - // float camera_max_distance = 200.0f; float follow_factor = config.cl_mouse_followfactor/100.0f; @@ -167,7 +165,7 @@ bool CONTROLS::on_mousemove(float x, float y) //vec2 camera_offset(0, 0); - if(spectate) + if(gameclient.snap.spectate) { if(mouse_pos.x < 200.0f) mouse_pos.x = 200.0f; if(mouse_pos.y < 200.0f) mouse_pos.y = 200.0f; diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 4f18cf65..9c13c107 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -544,6 +544,9 @@ void GAMECLIENT::on_snapshot() if(p) gameclient.snap.local_prev_character = (NETOBJ_CHARACTER *)p; } + + if (info->team == -1) + gameclient.snap.spectate = true; } // calculate team-balance diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp index 6be67284..dc3532a7 100644 --- a/src/game/client/gameclient.hpp +++ b/src/game/client/gameclient.hpp @@ -58,6 +58,7 @@ public: const NETOBJ_PLAYER_INFO *info_by_score[MAX_CLIENTS]; int num_players; int team_size[2]; + bool spectate; }; SNAPSTATE snap; diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index fb4df781..84efcd81 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -44,7 +44,7 @@ void PLAYER::tick() if(spawning && !get_character()) try_respawn(); - + if(get_character()) view_pos = get_character()->pos; } @@ -98,6 +98,9 @@ void PLAYER::on_direct_input(NETOBJ_PLAYER_INPUT *new_input) spawning = true; dbg_msg("", "I wanna spawn"); } + + if(!chr && team == -1) + view_pos = vec2(new_input->target_x, new_input->target_y); } CHARACTER *PLAYER::get_character() |