Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

testclient/testclientsnakebite.cpp

/// @cond EXCLUDEDTESTSOURCES
/***************************************************************************
 * The contents of this file are subject to the Mozilla Public             *
 * License Version 1.1 (the "License"); you may not use this file          *
 * except in compliance with the License. You may obtain a copy of         *
 * the License at http://www.mozilla.org/MPL/                              *
 *                                                                         *
 * Software distributed under the License is distributed on an "AS         *
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or              *
 * implied. See the License for the specific language governing            *
 * rights and limitations under the License.                               *
 *                                                                         *
 * The Original Code is Game Network Framework (GaNeF).                    *
 *                                                                         *
 * The Initial Developers of the Original Code are                         *
 * Lars Langer and Emanuel Greisen                                         *
 * Copyright (C) 2005. Lars Langer & Emanuel Greisen                       *
 * All Rights Reserved.                                                    *
 *                                                                         *
 * Contributor(s):                                                         *
 *   none yet....                                                          *
 *                                                                         *
 ***************************************************************************/
#include "testclientsnakebite.h"

#include "testclientframework.h"
#include "../Ganef/common/frameworkpacket.h"

TestClientSnakeBite::TestClientSnakeBite(ClientFramework * f, ClientPacket * packet) : ClientData(f,packet)
{
   x = packet->readInt32();
   y = packet->readInt32();
   angle = packet->readDouble64();
   packet->readPtr(this, &nextbite, f);
   is_head = packet->readBool8();
   m_mybite = false;
}


TestClientSnakeBite::~TestClientSnakeBite()
{
   TestClientFramework * myframework = static_cast<TestClientFramework *>(client_framework);
   myframework->removeSnakeBite(this);
}

void TestClientSnakeBite::updatePacket( ClientFramework * f, unsigned char updatetype, ClientPacket * packet )
{
   switch(updatetype)
   {
      case 10:
         x = packet->readInt32();
         y = packet->readInt32();
         angle = packet->readDouble64();
         break;
      case 20:
         packet->readPtr(this, &nextbite, f);
         break;
      case 30:
         // Ahh, its our snake bite
         m_mybite = true;
         break;
      case 40:
         // Arghh, we lost this snake
         m_mybite = false;
         break;
   }
}

void TestClientSnakeBite::sendWantedPosition( int _x, int _y )
{
   ClientPacket * p = new ClientPacket(this, 10, 12, false);
   p->writeInt32(_x);
   p->writeInt32(_y);
   enqueuePacket(p);
}

/// @endcond

Generated on Mon Feb 6 12:24:50 2006 for Ganef by  doxygen 1.4.4