TargetState.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <target/TargetState.h>
00022 #include <net/NetBuffer.h>
00023 
00024 TargetStateMovement::TargetStateMovement()
00025 {
00026 }
00027 
00028 TargetStateMovement::~TargetStateMovement()
00029 {
00030 }
00031 
00032 TargetState::TargetState() :
00033         falling_(0),
00034         displayDamage_(true), displayShadow_(true),
00035         noDamageBurn_(false), noCollision_(false), noFalling_(false),
00036         movement_(0), noFallingDamage_(false), 
00037         driveOverToDestroy_(false), flattenDestroy_(false),
00038         displayHardwareShadow_(true)
00039 {
00040 }
00041 
00042 TargetState::~TargetState()
00043 {
00044         delete movement_;
00045 }
00046 
00047 bool TargetState::writeMessage(NetBuffer &buffer)
00048 {
00049         unsigned int value =
00050                 (displayDamage_?1:0) |
00051                 (displayShadow_?2:0) |
00052                 (noDamageBurn_?4:0) |
00053                 (noCollision_?8:0) |
00054                 (noFalling_?16:0) |
00055                 //(movement_?32:0) |
00056                 (noFallingDamage_?64:0) |
00057                 (driveOverToDestroy_?128:0) |
00058                 (flattenDestroy_?256:0);
00059         buffer.addToBuffer(value);
00060         return true;
00061 }
00062 
00063 bool TargetState::readMessage(NetBufferReader &reader)
00064 {
00065         unsigned int value = 0;
00066         if (!reader.getFromBuffer(value)) return false;
00067 
00068         displayDamage_ = (value & 1) != 0;
00069         displayShadow_ = (value & 2) != 0;
00070         noDamageBurn_ = (value & 4) != 0;
00071         noCollision_ = (value & 8) != 0;
00072         noFalling_ = (value & 16) != 0;
00073         //movement_ = (value & 32) != 0;
00074         noFallingDamage_ = (value & 64) != 0;
00075         driveOverToDestroy_ = (value & 128) != 0;
00076         flattenDestroy_ = (value & 256) != 0;
00077 
00078         return true;
00079 }
00080 

Generated on Mon Feb 16 15:14:52 2009 for Scorched3D by  doxygen 1.5.3