00001 /* 00002 SagaEngine library 00003 Copyright (c) 2002-2006 Skalden Studio AS 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any 00007 damages arising from the use of this software. 00008 00009 Permission is granted to distribute the library under the terms of the 00010 Q Public License version 1.0. Be sure to read and understand the license 00011 before using the library. It should be included here, or you may read it 00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl 00013 00014 The original version of this library can be located at: 00015 http://www.sagaengine.com/ 00016 00017 Rune Myrland 00018 rune@skalden.com 00019 */ 00020 00021 00022 #include "PlayerEncoder.hpp" 00023 #include "io/parse/Parser.hpp" 00024 #include "io/stream/OutputStream.hpp" 00025 #include "io/schema/IoSchema.hpp" 00026 #include "client/schema/ClientSchema.hpp" 00027 #include "client/thing/all.hpp" 00028 #include "sim/sim.hpp" 00029 #include "sim/SimEngine.hpp" 00030 #include "sim/schema/SimSchema.hpp" 00031 #include "sim/stat/all.hpp" 00032 #include "sim/area/all.hpp" 00033 #include "sim/thing/all.hpp" 00034 #include "client/thing/all.hpp" 00035 #include "sim/pos/all.hpp" 00036 #include "util/error/Log.hpp" 00037 #include "util/math/CoorT.hpp" 00038 #include "util/type/String.hpp" 00039 #include <cstdio> 00040 #include <cstring> 00041 00042 using namespace se_core; 00043 00044 namespace se_client { 00045 00046 PlayerEncoder 00047 ::PlayerEncoder(EncodeManager& parser) 00048 : Encoder(parser, Parser::ENGINE, Parser::PLAYER, 1) { 00049 } 00050 00051 00052 PlayerEncoder 00053 ::~PlayerEncoder() { 00054 } 00055 00056 00057 void PlayerEncoder 00058 ::encode(OutputStream& out) { 00059 out.writeHeaderCode(headerCode()); 00060 00061 out.writeInfoCode('P'); 00062 out.writeString(ClientSchema::player->owner()->name()); 00063 00064 out.writeInfoCode('A'); 00065 out.writeString(ClientSchema::player->pos().area()->owner()->name()); 00066 00067 ViewPoint vp(ClientSchema::player->pos().world_); 00068 vp.sub(ClientSchema::player->pos().area()->pos().world_); 00069 out.writeInfoCode('T'); 00070 out.writeFloat( vp.coor_.x_); 00071 out.writeFloat( vp.coor_.y_); 00072 out.writeFloat( vp.coor_.z_); 00073 out.writeInfoCode('R'); 00074 out.writeFloat( BrayT::toDeg( vp.face_.yaw_ ) ); 00075 out.writeFloat( BrayT::toDeg( vp.face_.pitch_) ); 00076 out.writeFloat( BrayT::toDeg( vp.face_.roll_) ); 00077 out.writeInfoCode('/'); 00078 00079 out.writeInfoCode('G'); 00080 out.writeInfoCode('/'); 00081 00082 out.writeInfoCode('H'); 00083 out.writeShort(StatComponent::Ptr(*ClientSchema::player)->health().maxHitpoints()); 00084 out.writeShort(StatComponent::Ptr(*ClientSchema::player)->health().currentHitpoints()); 00085 00086 out.writeInfoCode('C'); 00087 out.writeString(ClientSchema::camera->owner()->name()); 00088 00089 vp.setViewPoint(ClientSchema::camera->pos().world_); 00090 vp.sub(ClientSchema::player->pos().area()->pos().world_); 00091 out.writeInfoCode('A'); 00092 out.writeString(ClientSchema::camera->pos().area()->owner()->name()); 00093 out.writeInfoCode('T'); 00094 out.writeFloat( vp.coor_.x_); 00095 out.writeFloat( vp.coor_.y_); 00096 out.writeFloat( vp.coor_.z_); 00097 out.writeInfoCode('R'); 00098 out.writeFloat( BrayT::toDeg( vp.face_.yaw_ ) ); 00099 out.writeFloat( BrayT::toDeg( vp.face_.pitch_) ); 00100 out.writeFloat( BrayT::toDeg( vp.face_.roll_) ); 00101 out.writeInfoCode('/'); 00102 00103 out.writeInfoCode('T'); 00104 out.writeInfoCode('V'); 00105 out.writeInfoCode('/'); 00106 00107 00108 out.writeInfoCode('Q'); 00109 } 00110 00111 } 00112
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:03 2007 by Doxygen version 1.3.9.1.