Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/network/packet/Welcome.cc @ 9870

Last change on this file since 9870 was 8858, checked in by landauf, 13 years ago

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

  • orxout levelname message
  • orxout_context levelname context message
  • shortcuts: log message, error message, warning message, status message, info message, debug message
  • Property svn:eol-style set to native
File size: 2.3 KB
RevLine 
[1711]1
2
3/*
4 *   ORXONOX - the hottest 3D action shooter ever to exist
5 *                    > www.orxonox.net <
6 *
7 *
8 *   License notice:
9 *
10 *   This program is free software; you can redistribute it and/or
11 *   modify it under the terms of the GNU General Public License
12 *   as published by the Free Software Foundation; either version 2
13 *   of the License, or (at your option) any later version.
14 *
15 *   This program is distributed in the hope that it will be useful,
16 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 *   GNU General Public License for more details.
19 *
20 *   You should have received a copy of the GNU General Public License
21 *   along with this program; if not, write to the Free Software
22 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
23 *
24 *   Author:
25 *      Oliver Scheuss, (C) 2008
26 *   Co-authors:
27 *      ...
28 *
29 */
30
[3214]31#include "Welcome.h"
[1711]32
[2773]33#include <cassert>
[8858]34#include "util/Output.h"
[1711]35#include "network/Host.h"
[2662]36#include "network/synchronisable/Synchronisable.h"
[1705]37
[2171]38namespace orxonox {
[1705]39namespace packet {
40
[3214]41#define PACKET_FLAGS_CLASSID  PacketFlag::Reliable
[1705]42#define _PACKETID             0
[3280]43#define _CLIENTID             _PACKETID + sizeof(Type::Value)
[2662]44#define _ENDIANTEST           _CLIENTID + sizeof(uint32_t)
45
[8706]46  Welcome::Welcome( uint32_t clientID )
[1711]47 : Packet()
[1705]48{
49  flags_ = flags_ | PACKET_FLAGS_CLASSID;
[1709]50  assert(getSize());
[1907]51  data_=new uint8_t[ getSize() ];
[1709]52  assert(data_);
[3280]53  *(packet::Type::Value *)(data_ + _PACKETID ) = packet::Type::Welcome;
[2662]54  *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID);
55  *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321;
[1705]56}
57
[2662]58Welcome::Welcome( uint8_t* data, uint32_t clientID )
[1711]59  : Packet(data, clientID)
[1705]60{
61}
62
63Welcome::~Welcome()
64{
65}
66
[1907]67uint8_t *Welcome::getData(){
[1705]68  return data_;
69}
70
71unsigned int Welcome::getSize() const{
[3280]72  return sizeof(packet::Type::Value) + 2*sizeof(uint32_t);
[1705]73}
74
[7801]75bool Welcome::process(orxonox::Host* host){
[2662]76  uint32_t clientID;
77  clientID = *(uint32_t *)(data_ + _CLIENTID );
78  assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321);
[7801]79  host->setClientID(clientID);
[8858]80  orxout(internal_info, context::packets) << "Welcome set clientId: " << clientID << endl;
[1751]81  Synchronisable::setClient(true);
[1711]82  delete this;
[1705]83  return true;
84}
85
86
87} //namespace packet
[2171]88}//namespace orxonox
Note: See TracBrowser for help on using the repository browser.