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

testclientsnakebite.cpp

00001 /// @cond EXCLUDEDTESTSOURCES
00002 /***************************************************************************
00003  * The contents of this file are subject to the Mozilla Public             *
00004  * License Version 1.1 (the "License"); you may not use this file          *
00005  * except in compliance with the License. You may obtain a copy of         *
00006  * the License at http://www.mozilla.org/MPL/                              *
00007  *                                                                         *
00008  * Software distributed under the License is distributed on an "AS         *
00009  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or              *
00010  * implied. See the License for the specific language governing            *
00011  * rights and limitations under the License.                               *
00012  *                                                                         *
00013  * The Original Code is Game Network Framework (GaNeF).                    *
00014  *                                                                         *
00015  * The Initial Developers of the Original Code are                         *
00016  * Lars Langer and Emanuel Greisen                                         *
00017  * Copyright (C) 2005. Lars Langer & Emanuel Greisen                       *
00018  * All Rights Reserved.                                                    *
00019  *                                                                         *
00020  * Contributor(s):                                                         *
00021  *   none yet....                                                          *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #include "testclientsnakebite.h"
00025 
00026 #include "testclientframework.h"
00027 #include "../Ganef/common/frameworkpacket.h"
00028 
00029 TestClientSnakeBite::TestClientSnakeBite(ClientFramework * f, ClientPacket * packet) : ClientData(f,packet)
00030 {
00031    x = packet->readInt32();
00032    y = packet->readInt32();
00033    angle = packet->readDouble64();
00034    packet->readPtr(this, &nextbite, f);
00035    is_head = packet->readBool8();
00036    m_mybite = false;
00037 }
00038 
00039 
00040 TestClientSnakeBite::~TestClientSnakeBite()
00041 {
00042    TestClientFramework * myframework = static_cast<TestClientFramework *>(client_framework);
00043    myframework->removeSnakeBite(this);
00044 }
00045 
00046 void TestClientSnakeBite::updatePacket( ClientFramework * f, unsigned char updatetype, ClientPacket * packet )
00047 {
00048    switch(updatetype)
00049    {
00050       case 10:
00051          x = packet->readInt32();
00052          y = packet->readInt32();
00053          angle = packet->readDouble64();
00054          break;
00055       case 20:
00056          packet->readPtr(this, &nextbite, f);
00057          break;
00058       case 30:
00059          // Ahh, its our snake bite
00060          m_mybite = true;
00061          break;
00062       case 40:
00063          // Arghh, we lost this snake
00064          m_mybite = false;
00065          break;
00066    }
00067 }
00068 
00069 void TestClientSnakeBite::sendWantedPosition( int _x, int _y )
00070 {
00071    ClientPacket * p = new ClientPacket(this, 10, 12, false);
00072    p->writeInt32(_x);
00073    p->writeInt32(_y);
00074    enqueuePacket(p);
00075 }
00076 
00077 /// @endcond

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