nMessage Class Reference

#include <nNetwork.h>

Inheritance diagram for nMessage:

Inheritance graph
[legend]
Collaboration diagram for nMessage:

Collaboration graph
[legend]

List of all members.

Public Member Functions

unsigned short Descriptor () const
unsigned short SenderID () const
unsigned short MessageID () const
unsigned long MessageIDBig () const
unsigned short DataLen () const
unsigned short Data (unsigned short n)
void ClearMessageID ()
 nMessage (const nDescriptor &)
 nMessage (unsigned short *&buffer, short sn_myNetID, int lenLeft)
void SendImmediately (int peer, bool ack=true)
void BroadCast (bool ack=true)
void Send (int peer, REAL priority=0, bool ack=true)
void Write (const unsigned short &x)
nMessageoperator<< (const REAL &x)
nMessageoperator>> (REAL &x)
nMessageoperator<< (const unsigned short &x)
nMessageoperator>> (unsigned short &x)
nMessageoperator<< (const double &x)
nMessageoperator>> (double &x)
nMessageReadRaw (tString &s)
nMessageoperator>> (tString &s)
nMessageoperator>> (tColoredString &s)
nMessageoperator<< (const tString &s)
nMessageoperator<< (const tColoredString &s)
nMessageoperator<< (const tOutput &o)
template<class T>
void BinWrite (const T &x)
bool End ()
void Reset ()
int ReadSoFar ()
void Read (unsigned short &x)
template<class T>
void BinRead (const T &x)
nMessageoperator<< (const short &x)
nMessageoperator>> (short &x)
nMessageoperator<< (const int &x)
nMessageoperator>> (int &x)
nMessageoperator<< (const unsigned int &x)
nMessageoperator>> (unsigned int &x)
nMessageoperator<< (const bool &x)
nMessageoperator>> (bool &x)
template<class T>
nMessageoperator<< (const tArray< T > &a)
template<class T>
nMessageoperator>> (tArray< T > &a)
template<class T>
nMessageoperator<< (const T *p)
template<class T>
nMessageoperator<< (const tControlledPTR< T > p)

Static Public Member Functions

static void SendCollected (int peer)
static void BroadcastCollected (int peer, unsigned int port)

Protected Member Functions

 ~nMessage ()

Protected Attributes

unsigned short descriptor
unsigned long messageIDBig_
short senderID
tArray< unsigned short > data
unsigned int readOut

Friends

class tControlledPTR< nMessage >
class tReferencable< nMessage >
class nDescriptor
class nNetObject
class nWaitForAck


Detailed Description

Definition at line 414 of file nNetwork.h.


Constructor & Destructor Documentation

nMessage::~nMessage (  )  [protected]

Definition at line 975 of file nNetwork.cpp.

References con, descriptor, and tCHECK_DEST.

00977                    {
00978 #ifdef NET_DEBUG
00979     nMessages--;
00980     if (nMessages>max_nMessages){
00981         max_nMessages=nMessages;
00982         con << "MN=" << max_nMessages <<'\n';
00983     }
00984 #endif
00985 
00986 #ifdef DEBUG_X
00987     if (descriptor>1)
00988         con << "DMT " << descriptor << "\n";
00989 #endif
00990 

nMessage::nMessage ( const nDescriptor d  ) 

Definition at line 953 of file nNetwork.cpp.

Referenced by nAckMessage::nAckMessage().

00956         :descriptor(d.id),
00957 senderID(::sn_myNetID), readOut(0){
00958 #ifdef NET_DEBUG
00959     nMessages++;
00960 #endif
00961 
00962     current_id++;
00963     if (current_id <= IDS_RESERVED)
00964         current_id = IDS_RESERVED + 1;
00965 
00966     messageIDBig_ = current_id;
00967 
00968 #ifdef DEBUG
00969     BreakOnMessageID( messageIDBig_ );
00970 #endif
00971 
00972     tRecorderSync< unsigned long >::Archive( "_MESSAGE_ID_OUT", 3, messageIDBig_ );

Here is the caller graph for this function:

nMessage::nMessage ( unsigned short *&  buffer,
short  sn_myNetID,
int  lenLeft 
)

Definition at line 926 of file nNetwork.cpp.

References tRecorderSync< DATA >::Archive().

00929         :descriptor(ntohs(*(buffer++))),messageIDBig_(sn_ExpandMessageID(ntohs(*(buffer++)),sender)),
00930 senderID(sender),readOut(0){
00931 #ifdef NET_DEBUG
00932     nMessages++;
00933 #endif
00934 
00935     tRecorderSync< unsigned long >::Archive( "_MESSAGE_ID_IN", 3, messageIDBig_ );
00936     tRecorderSync< unsigned short >::Archive( "_MESSAGE_DECL_IN", 3, descriptor );
00937 
00938     unsigned short len=ntohs(*(buffer++));
00939     lenLeft--;
00940     if ( len > lenLeft )
00941     {
00942         len = lenLeft;
00943 #ifndef NOEXCEPT
00944         throw nKillHim();
00945 #endif
00946     }
00947     for(int i=0;i<len;i++)
00948         data[i]=ntohs(*(buffer++));
00949 
00950 #ifdef DEBUG
00951     BreakOnMessageID( messageIDBig_ );

Here is the call graph for this function:


Member Function Documentation

unsigned short nMessage::Descriptor (  )  const [inline]

Definition at line 437 of file nNetwork.h.

References descriptor.

Referenced by nSendBuffer::AddMessage(), nDescriptor::HandleMessage(), rec_peer(), and Send().

00437                                      {
00438         return descriptor;
00439     }

Here is the caller graph for this function:

unsigned short nMessage::SenderID (  )  const [inline]

Definition at line 441 of file nNetwork.h.

References senderID.

Referenced by eVoteItem::AcceptNewVote(), ack_handler(), client_gamestate_handler(), eVoteItem::DoFillFromMessage(), ePlayerNetID::ePlayerNetID(), eVoteItem::FillFromMessage(), FloodProtection(), eVoteItem::GetControlMessage(), GetSenderData(), nServerInfo::GiveBigServerInfo(), nServerInfo::GiveBigServerInfoCommon(), nServerInfo::GiveSmallServerInfo(), nDescriptor::HandleMessage(), nAuthentication::HandlePasswordAnswer(), nAuthentication::HandlePasswordRequest(), id_req_handler(), nNOInitialisator< T >::Init(), login_accept_handler(), logout_handler(), net_control_handler(), net_destroy_handler(), net_sync_handler(), nServerInfoBase::NetReadThis(), new_destination_handler(), nNetObject::nNetObject(), nNetObject::ReadSync(), eTimer::ReadSync(), ready_handler(), req_id_handler(), req_info_handler(), se_GetVoter(), se_LoginWanted(), sync_ack_handler(), and sync_msg_handler().

00441                                    {
00442         return senderID;
00443     }

Here is the caller graph for this function:

unsigned short nMessage::MessageID (  )  const [inline]

Definition at line 445 of file nNetwork.h.

References messageIDBig_.

Referenced by nSendBuffer::AddMessage(), gDestination::gDestination(), nServerInfo::GetBigServerInfoCommon(), rec_peer(), req_id_handler(), and gDestination::WriteCreate().

00445                                     {
00446         return messageIDBig_ & 0xFFFF;
00447     }

Here is the caller graph for this function:

unsigned long nMessage::MessageIDBig (  )  const [inline]

Definition at line 449 of file nNetwork.h.

References messageIDBig_.

Referenced by nConfItemBase::s_GetConfigMessage(), and nNetObject::SyncIsNew().

00449                                       {
00450         return messageIDBig_;
00451     }

Here is the caller graph for this function:

unsigned short nMessage::DataLen (  )  const [inline]

Definition at line 453 of file nNetwork.h.

References data, and GrowingArrayBase::Len().

Referenced by nSendBuffer::AddMessage(), nNOInitialisator< T >::Init(), and nNetObject::WriteAll().

00453                                   {
00454         return data.Len();
00455     }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short nMessage::Data ( unsigned short  n  )  [inline]

Definition at line 457 of file nNetwork.h.

References data.

Referenced by nSendBuffer::AddMessage(), and nNOInitialisator< T >::Init().

00457                                          {
00458         return data(n);
00459     }

Here is the caller graph for this function:

void nMessage::ClearMessageID (  )  [inline]

Definition at line 461 of file nNetwork.h.

References messageIDBig_.

Referenced by nServerInfo::GetFromLAN(), nServerInfo::GetFromLANContinuously(), and nServerInfo::GiveBigServerInfoCommon().

00461                          { // clear the message ID so no acks are sent for it
00462         messageIDBig_ = 0;
00463     }

Here is the caller graph for this function:

void nMessage::SendImmediately ( int  peer,
bool  ack = true 
)

Definition at line 2046 of file nNetwork.cpp.

References nSendBuffer::AddMessage(), con, data, descriptor, nDescriptor::id, GrowingArrayBase::Len(), MAX_MESS_LEN, messageIDBig_, nSERVER, nWaitForAck, s_Acknowledge, nConnectionInfo::sendBuffer_, SendCollected(), sn_GetNetState(), st_Breakpoint(), and tASSERT.

Referenced by nServerInfo::GetFromLAN(), nServerInfo::GetFromLANContinuously(), and nServerInfo::GiveBigServerInfoCommon().

02048                                                {
02049     if (ack)
02050     {
02051 #ifdef NO_ACK
02052         tASSERT(messageIDBig_);
02053 #endif
02054         new nWaitForAck(this,peer);
02055     }
02056 
02057     // server: messages to yourself are a bit strange...
02058     if ( sn_GetNetState() == nSERVER && peer == 0 && ack )
02059     {
02060         st_Breakpoint();
02061         tJUST_CONTROLLED_PTR< nMessage > bounce(this);
02062         return;
02063     }
02064 
02065 #ifdef DEBUG
02066     /*
02067     if (descriptor>1)
02068       con << "SMT " << descriptor << "\n";
02069     */
02070 
02071     /*
02072       #ifdef DEBUG
02073       if (sn_Connections[].rate_control[peer]<-2000)
02074          tERR_ERROR("Heavy network overflow.");
02075       #endif
02076     */
02077 
02078     // if (peer==0 && sn_GetNetState()==nSERVER)
02079     //      tERR_ERROR("talking to yourself, eh?");
02080 
02081     if (peer==MAXCLIENTS+1){
02082 #ifdef DEBUG
02083         if(descriptor==s_Acknowledge.id)
02084             con << "Sending ack to login slot.\n";
02085 #endif
02086         //      else if (descriptor
02087         //      tERR_ERROR("the last user only should receive denials or acks.");
02088     }
02089 #endif
02090 
02091     if (sn_Connections[peer].sendBuffer_.Len()+data.Len()+3 > MAX_MESS_LEN/2){
02092         SendCollected(peer);
02093         //con << "Overflow packets sent to " << peer << '\n';
02094     }
02095 
02096 
02097     if (sn_Connections[peer].socket)
02098     {
02099         sn_Connections[peer].sendBuffer_.AddMessage( *this, &sn_Connections[peer].bandwidthControl_ );
02100 
02101         /*
02102           if (sn_Connections[].rate_control[peer]>0)
02103           send_collected(peer);
02104 
02105           unsigned short *b=new (unsigned short)[data.Len()+3];
02106 
02107           b[0]=htons(descriptor);
02108           b[1]=htons(messageID);
02109           b[2]=htons(data.Len());
02110           int len=data.Len();
02111           for(int i=0;i<len;i++)
02112           b[3+i]=htons(data(i));
02113 
02114 
02115           ANET_Write(sn_Connections[].socket[peer],(int8 *)b,
02116           2*(data.Len()+3),&peers[peer]);
02117 
02118           //std::cerr << "Sent " << 2*len+6 << " bytes.\n";
02119           sn_Connections[].rate_control[peer]-=2*(len+3)+OVERHEAD;
02120 
02121           delete b;
02122         */
02123 
02124         if (deb_net)
02125             con << "Sent " <<descriptor << ':' << messageIDBig_ << ":"
02126             << peer << '\n';
02127     }
02128 

Here is the call graph for this function:

Here is the caller graph for this function:

void nMessage::SendCollected ( int  peer  )  [static]

Definition at line 2023 of file nNetwork.cpp.

Referenced by nServerInfo::GiveBigServerInfoCommon(), nServerInfo::GiveSmallServerInfo(), nServerInfo::NetReadThis(), nServerInfo::QueryServer(), and SendImmediately().

02026 {
02027     //if ( peer == 7 && sn_Connections[peer].sendBuffer_.Len() > 0 )
02028     //    con << tSysTimeFloat() << "\n";
02029 
02030     sn_OrderPriority = 0;
02031 
02032     if (peer<0 || peer > MAXCLIENTS+1 || !sn_Connections[peer].socket)
02033         tERR_ERROR("Invalid peer!");
02034 

Here is the caller graph for this function:

void nMessage::BroadcastCollected ( int  peer,
unsigned int  port 
) [static]

Definition at line 2037 of file nNetwork.cpp.

References nSendBuffer::Broadcast(), nConnectionInfo::sendBuffer_, and tERR_ERROR.

Referenced by nServerInfo::GetFromLAN(), and nServerInfo::GetFromLANContinuously().

02039                                                             {
02040     if (peer<0 || peer > MAXCLIENTS+1 || !sn_Connections[peer].socket)
02041         tERR_ERROR("Invalid peer!");
02042 

Here is the call graph for this function:

Here is the caller graph for this function:

void nMessage::BroadCast ( bool  ack = true  ) 

Definition at line 995 of file nNetwork.cpp.

References nCLIENT, nSERVER, Send(), and sn_GetNetState().

Referenced by BroadCastNewDestination(), client(), ePlayerNetID::CreateNewTeamWish(), nServerInfo::GetFromMaster(), nConfItemBase::SendConfig(), floattest::SendControl(), eNetGameObject::SendControl(), eVoteItem::SendMessage(), ePlayerNetID::SetTeamWish(), and nServerInfo::TellMasterAboutMe().

00997                                 {
00998     tControlledPTR< nMessage > keep( this );
00999     if (sn_GetNetState()==nCLIENT)
01000         Send(0,ack);
01001 
01002     if (sn_GetNetState()==nSERVER){
01003         for(int i=MAXCLIENTS;i>0;i--){
01004             if (sn_Connections[i].socket)
01005                 Send(i,ack);
01006         }

Here is the call graph for this function:

Here is the caller graph for this function:

void nMessage::Send ( int  peer,
REAL  priority = 0,
bool  ack = true 
)

Definition at line 2132 of file nNetwork.cpp.

References con, data, Descriptor(), descriptor, nDescriptor::ID(), nDescriptor::id, GrowingArrayBase::Len(), messageIDBig_, nSERVER, s_Acknowledge, sn_GetNetState(), st_Breakpoint(), and tASSERT.

Referenced by BroadCast(), FinishHandlePasswordRequest(), nServerLag::Report(), nServerInfo::RunMaster(), se_Cleanup(), se_sendEventNotification(), se_SendPrivateMessage(), se_SendTeamMessage(), se_WantLogin(), nConfItemBase::SendConfig(), and gGame::StateUpdate().

02134                                                   {
02135 #ifdef NO_ACK
02136     if (!ack)
02137         messageIDBig_ = 0;
02138 #endif
02139 
02140     // messages to yourself are a bit strange...
02141     if ( sn_GetNetState() == nSERVER && peer == 0 && ack )
02142     {
02143         st_Breakpoint();
02144         tJUST_CONTROLLED_PTR< nMessage > bounce(this);
02145         return;
02146     }
02147 
02148 #ifdef DEBUG
02149 
02150     if (peer==MAXCLIENTS+1){
02151         if(descriptor==s_Acknowledge.id)
02152             con << "Sending ack to login slot.\n";
02153         //      else if (descriptor
02154         //      tERR_ERROR("the last user only should receive denials or acks.");
02155     }
02156 #endif
02157 
02158 #ifdef DEBUG_X
02159     if (descriptor>1)
02160         con << "PMT " << descriptor << "\n";
02161 #endif
02162 
02163     // the next line was redundant; the send buffer handles that part of accounting.
02164     //sn_Connections[peer].bandwidthControl_.Use( nBandwidthControl::Usage_Planning, 2*(data.Len()+3) );
02165 
02166     sent_per_messid[descriptor]+=2*(data.Len()+3);
02167 
02168     tASSERT(Descriptor()!=s_Acknowledge.ID() || !ack);
02169 
02170     new nMessage_planned_send(this,priority+sn_OrderPriority,ack,peer);

Here is the call graph for this function:

Here is the caller graph for this function:

void nMessage::Write ( const unsigned short &  x  )  [inline]

Definition at line 485 of file nNetwork.h.

References data, and GrowingArrayBase::Len().

Referenced by BinWrite(), eVoteItemHarm::DoFillToMessage(), eVoteItem::DoFillToMessage(), nNetObject::NewControlMessage(), operator<<(), operator<<(), se_NewChatMessage(), se_ServerControlledChatMessageConsole(), eNetGameObject::SendControl(), gGame::StateUpdate(), gFloatCompressor::Write(), gNetPlayerWall::WriteCreate(), gDestination::WriteCreate(), nNetObject::WriteCreate(), deptest::WriteCreate(), eNetGameObject::WriteCreate(), nKrawall::WriteScrambledPassword(), gNetPlayerWall::WriteSync(), gGame::WriteSync(), and gCycle::WriteSync().

00485                                        {
00486         data[data.Len()]=x;
00487     }

Here is the call graph for this function:

Here is the caller graph for this function:

nMessage & nMessage::operator<< ( const REAL x  ) 

Definition at line 1118 of file nNetwork.cpp.

References EXP, exp(), MANT, MS, REAL, tERR_ERROR_INT, and z.

Referenced by operator<<().

01120                                            {
01121 
01122 
01123 #ifdef DEBUG
01124     // con << "write x= " << x;
01125 
01126 
01127     if(sizeof(myfloat)!=sizeof(int))
01128         tERR_ERROR_INT("floating ePoint format does not work!");
01129 #endif
01130     /*
01131       REAL nachkomma=x-floor(x);
01132       Write(short(x-nachkomma));
01133       Write(60000*nachkomma);
01134     */
01135     // no fuss. Read and write floats in binary format.
01136     // will likely cause problems for systems other than i386.
01137 
01138     //Write(((short *)&x)[0]);
01139     //Write(((short *)&x)[1]);
01140 
01141     // right. Caused severe problems with the AIX port.
01142 
01143     // new way: own floating ePoint format that is not good with small numbers
01144     // (we do not need them anyway)
01145     REAL y=x;
01146 
01147     unsigned int negative=0;
01148     if (y<0){
01149         y=-y;
01150         negative=1;
01151     }
01152 
01153     unsigned int exp=0;
01154     while ( fabs(y)>=64 && exp < (1<<EXP)-6 )
01155     {
01156         exp +=6;
01157         y/=64;
01158     }
01159     while ( fabs(y)>=1 && exp < (1<<EXP)-1 )
01160     {
01161         exp++;
01162         y/=2;
01163     }
01164     // now x=y*2^exp
01165     unsigned int mant=int(y*(1<<MS));
01166     // now x=mant*2^exp * (1/ (1<<MANT))
01167 
01168     // cutoffs:
01169     if (mant>((1<<MS))-1)
01170         mant=(1<<MS)-1;
01171 
01172     if (exp>(1<<EXP)-1){
01173         exp=(1<<EXP)-1;
01174         if (mant>0)
01175             mant=(1<<MS)-1;
01176     }
01177 
01178     // put them together:
01179 
01180     unsigned int trans=(mant & ((1<<MS)-1)) | (negative << MS) | (exp << MANT);
01181     /*
01182       myfloat trans;
01183       trans.exp=exp;
01184       trans.mant=mant;
01185     */
01186 
01187     operator<<(reinterpret_cast<int &>(trans));
01188 
01189 #ifdef DEBUG
01190     /*
01191       con << "mant: " << mant
01192       << ", exp: " << exp
01193       << ", negative: " << negative;
01194     */
01195 
01196     unsigned int mant2=trans & ((1 << MS)-1);
01197     unsigned int negative2=(trans >> MS) & 1;
01198     unsigned int nt=trans-mant-(negative << MS);
01199     unsigned int exp2=nt >> MANT;
01200 
01201     if (mant2!=mant || negative2!=negative || exp2!=exp)
01202         tERR_ERROR_INT("Floating ePoint tranfer failure!");
01203 
01204     /*
01205       con << ", x: " << x;
01206 
01207       con << ", mant: " << mant
01208       << ", exp: " << exp
01209       << ", negative: " << negative;
01210     */
01211 
01212     // check:
01213 
01214     REAL z=REAL(mant)/(1<<MS);
01215     if (negative)
01216         z=-z;
01217 
01218     while (exp>=6){
01219         exp-=6;
01220         z*=64;
01221     }
01222     while (exp>0){
01223         exp--;
01224         z*=2;
01225     }
01226 
01227     if (fabs(z-x)>(fabs(x)+1)*.001)
01228         tERR_ERROR_INT("Floating ePoint tranfer failure!");
01229 
01230     //con << ", z: " << z << '\n';
01231 #endif
01232 

Here is the call graph for this function:

Here is the caller graph for this function:

nMessage & nMessage::operator>> ( REAL x  ) 

Definition at line 1234 of file nNetwork.cpp.

Referenced by operator>>().

01236                                      {
01237     /*
01238       short vorkomma;
01239       unsigned short nachkomma;
01240       Read((unsigned short &)vorkomma);
01241       Read(nachkomma);
01242       x=vorkomma+nachkomma/60000.0;
01243 
01244       Read(((unsigned short *)&x)[0]);
01245       Read(((unsigned short *)&x)[1]);
01246      */
01247 
01248     unsigned int trans;
01249     operator>>(reinterpret_cast<int &>(trans));
01250 
01251     int mant=trans & ((1 << MS)-1);
01252     unsigned int negative=(trans >> MS) & 1;
01253     unsigned int exp=(trans-mant-(negative << MS)) >> MANT;
01254 
01255     x=REAL(mant)/(1<<MS);
01256     if (negative)
01257         x=-x;
01258 
01259 #ifdef DEBUG
01260     //  con << "read mant: " <<mant << ", exp: " << exp;
01261 #endif
01262 
01263     while (exp>=6){
01264         exp-=6;
01265         x*=64;
01266     }
01267     while (exp>0){
01268         exp--;
01269         x*=2;
01270     }
01271 
01272 #ifdef DEBUG
01273 #ifndef WIN32
01274     if (!finite(x))
01275         st_Breakpoint();
01276     // con << " , x= " << x << '\n';
01277 #endif
01278 #endif

Here is the caller graph for this function:

nMessage& nMessage::operator<< ( const unsigned short &  x  )  [inline]

Definition at line 492 of file nNetwork.h.

References Write().

00492                                                   {
00493         Write(x);
00494         return *this;
00495     }

Here is the call graph for this function:

nMessage& nMessage::operator>> ( unsigned short &  x  )  [inline]

Definition at line 496 of file nNetwork.h.

References Read().

00496                                             {
00497         Read(x);
00498         return *this;
00499     }

Here is the call graph for this function:

nMessage& nMessage::operator<< ( const double &  x  )  [inline]

Definition at line 501 of file nNetwork.h.

References operator<<(), and REAL.

00501                                           {
00502         return operator<<(REAL(x));
00503     }

Here is the call graph for this function:

nMessage& nMessage::operator>> ( double &  x  )  [inline]

Definition at line 505 of file nNetwork.h.

References operator>>(), and REAL.

00505                                     {
00506         REAL y;
00507         operator>>(y);
00508         x=y;
00509 
00510         return *this;
00511     }

Here is the call graph for this function:

nMessage & nMessage::ReadRaw ( tString s  ) 

Definition at line 1058 of file nNetwork.cpp.

Referenced by nAuthentication::HandlePasswordRequest().

01061 {
01062     s.Clear();
01063     unsigned short w,len;
01064     Read(len);
01065     if ( len > 0 )
01066     {
01067         s.reserve(len);
01068         for(int i=0;i<len;i+=2){
01069             Read(w);
01070             tString::CHAR c1 = w & 255;
01071             sn_AddToString( s, c1 );
01072             if (i+1<len)
01073                 sn_AddToString( s, (w-c1) >> 8 );
01074         }
01075     }
01076 

Here is the caller graph for this function:

nMessage & nMessage::operator>> ( tString s  ) 

Definition at line 1097 of file nNetwork.cpp.

01100 {
01101     tColoredString safe;
01102     operator>>( safe );
01103     s = safe;
01104 

nMessage & nMessage::operator>> ( tColoredString s  ) 

Definition at line 1078 of file nNetwork.cpp.

01081 {
01082     // read the raw data
01083     ReadRaw( s );
01084 
01085     // filter client string messages
01086     if ( sn_GetNetState() == nSERVER )
01087     {
01088         s.NetFilter();
01089         s.RemoveTrailingColor();
01090     }
01091 
01092     // filter color codes away
01093     if ( sn_filterColorStrings )
01094         s = tColoredString::RemoveColors( s );
01095 

nMessage & nMessage::operator<< ( const tString s  ) 

Definition at line 1011 of file nNetwork.cpp.

01013                                                 {
01014     if ( !sn_ZeroMessageCrashfix.Supported() && s.Len() <= 0 )
01015     {
01016         return this->operator<<( s + " " );
01017     }
01018 
01019     unsigned short len=s.Size()+1;
01020 
01021     // clamp away excess zeroes
01022     while(len > 1 && s(len-2)==0)
01023     {
01024         --len;
01025     }
01026 
01027     Write(len);
01028     int i;
01029 
01030     char const * sRaw = s;
01031 
01032     // write first pairs of bytes
01033     for(i=0;i+1<len;i+=2)
01034         Write(sRaw[i]+(sRaw[i+1] << 8));
01035 
01036     // write last byte
01037     if (i<len)
01038         Write(sRaw[i]);
01039 

nMessage & nMessage::operator<< ( const tColoredString s  ) 

Definition at line 1041 of file nNetwork.cpp.

01043                                                        {

nMessage & nMessage::operator<< ( const tOutput o  ) 

Definition at line 1045 of file nNetwork.cpp.

01047                                                   {

template<class T>
void nMessage::BinWrite ( const T &  x  )  [inline]

Definition at line 522 of file nNetwork.h.

References Write().

00522                                                 {
00523         for (unsigned int i=0;i<sizeof(T)/2;i++)
00524             Write((reinterpret_cast<const unsigned short *>(&x))[i]);
00525         return *this;
00526     }

Here is the call graph for this function:

bool nMessage::End (  )  [inline]

Definition at line 528 of file nNetwork.h.

References data, GrowingArrayBase::Len(), and readOut.

Referenced by ack_handler(), gDestination::gDestination(), nServerInfo::GetSmallServerInfo(), nServerInfo::GiveSmallServerInfo(), nAuthentication::HandlePasswordRequest(), id_req_handler(), login_accept_handler(), net_destroy_handler(), nServerInfo::NetReadThis(), Read(), zZone::ReadSync(), gZone::ReadSync(), gNetPlayerWall::ReadSync(), gCycle::ReadSync(), req_id_handler(), sample_message_handler(), sample_message_handler2(), and zShapePolygon::zShapePolygon().

00528               {
00529         return readOut>=static_cast<unsigned int>(data.Len());
00530     }

Here is the call graph for this function:

Here is the caller graph for this function:

void nMessage::Reset ( void   )  [inline]

Definition at line 532 of file nNetwork.h.

References readOut.

Referenced by net_sync_handler().

00532                 {
00533         readOut=0;
00534     }

Here is the caller graph for this function:

int nMessage::ReadSoFar (  )  [inline]

Definition at line 536 of file nNetwork.h.

References readOut.

Referenced by nNetObject::ReadAll().

00536                    {
00537         return readOut;
00538     }

Here is the caller graph for this function:

void nMessage::Read ( unsigned short &  x  ) 

Definition at line 1332 of file nNetwork.cpp.

References con, data, End(), nReadError(), readOut, senderID, tOutput::SetTemplateParameter(), and st_Breakpoint().

Referenced by ack_handler(), BinRead(), client_gamestate_handler(), deptest::deptest(), eVoteItemHarm::DoFillFromMessage(), eVoteItem::DoFillFromMessage(), eNetGameObject::eNetGameObject(), gDestination::gDestination(), eVoteItem::GetControlMessage(), gNetPlayerWall::gNetPlayerWall(), handle_chat_client(), eVoteItemServerControlled::HandleChanged(), id_req_handler(), login_accept_handler(), net_control_handler(), net_destroy_handler(), net_sync_handler(), nNetObject::nNetObject(), operator>>(), operator>>(), gFloatCompressor::Read(), nKrawall::ReadScrambledPassword(), gNetPlayerWall::ReadSync(), gGame::ReadSync(), gCycle::ReadSync(), eNetGameObject::ReceiveControlNet(), req_id_handler(), eVoteItemServerControlled::s_HandleChanged(), sync_ack_handler(), sync_msg_handler(), and gCycle::SyncIsNew().

01334                                     {
01335     if (End()){
01336         tOutput o;
01337         st_Breakpoint();
01338         o.SetTemplateParameter(1, senderID);
01339         o << "$network_error_shortmessage";
01340         con << o;
01341         // sn_DisconnectUser(senderID, "$network_kill_error");
01342         nReadError( false );
01343     }
01344     else

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T>
void nMessage::BinRead ( const T &  x  )  [inline]

Definition at line 542 of file nNetwork.h.

References Read().

00542                                                {
00543         for (unsigned int i=0;i<sizeof(T)/2;i++)
00544             Read(reinterpret_cast<unsigned short *>(&x)[i]);
00545         return *this;
00546     }

Here is the call graph for this function:

nMessage & nMessage::operator<< ( const short &  x  ) 

Definition at line 1280 of file nNetwork.cpp.

01282                                              {
01283     Write((reinterpret_cast<const short *>(&x))[0]);
01284 

nMessage & nMessage::operator>> ( short &  x  ) 

Definition at line 1286 of file nNetwork.cpp.

01288                                        {
01289     Read(reinterpret_cast<unsigned short *>(&x)[0]);
01290 

nMessage & nMessage::operator<< ( const int &  x  ) 

Definition at line 1292 of file nNetwork.cpp.

01294                                            {
01295     unsigned short a=x & (0xFFFF);
01296     short b=(x-a) >> 16;
01297 
01298     Write(a);
01299     operator<<(b);
01300 

nMessage & nMessage::operator>> ( int &  x  ) 

Definition at line 1302 of file nNetwork.cpp.

01304                                      {
01305     unsigned short a;
01306     short b;
01307 
01308     Read(a);
01309     operator>>(b);
01310 
01311     x=(b << 16)+a;
01312 

nMessage& nMessage::operator<< ( const unsigned int &  x  )  [inline]

Definition at line 555 of file nNetwork.h.

00555                                                 {
00556         operator<<(reinterpret_cast<const int&>(x));
00557         return *this;
00558     }

nMessage& nMessage::operator>> ( unsigned int &  x  )  [inline]

Definition at line 559 of file nNetwork.h.

References operator>>().

00559                                           {
00560         operator>>(reinterpret_cast<int&>(x));
00561         return *this;
00562     }

Here is the call graph for this function:

nMessage & nMessage::operator<< ( const bool &  x  ) 

Definition at line 1314 of file nNetwork.cpp.

01316                                             {
01317     if (x)
01318         Write(1);
01319     else
01320         Write(0);
01321 

nMessage & nMessage::operator>> ( bool &  x  ) 

Definition at line 1323 of file nNetwork.cpp.

01325                                       {
01326     unsigned short y;
01327     Read(y);
01328     x= (y!=0);
01329 

template<class T>
nMessage& nMessage::operator<< ( const tArray< T > &  a  )  [inline]

Definition at line 567 of file nNetwork.h.

References a, and Write().

00568     {
00569         unsigned short len = a.Len();
00570         Write(len);
00571         for (int i=a.Len()-1; i>=0; i--)
00572             operator<< (a(i));
00573 
00574         return *this;
00575     }

Here is the call graph for this function:

template<class T>
nMessage& nMessage::operator>> ( tArray< T > &  a  )  [inline]

Definition at line 577 of file nNetwork.h.

References a, GrowingArrayBase::Len(), Read(), and tArray< T, MALLOC >::SetLen().

00578     {
00579         unsigned short len;
00580         Read(len);
00581         a.SetLen(len);
00582         for (int i=a.Len()-1; i>=0; i--)
00583             operator >> (a(i));
00584 
00585         return *this;
00586     }

Here is the call graph for this function:

template<class T>
nMessage& nMessage::operator<< ( const T *  p  )  [inline]

Definition at line 588 of file nNetwork.h.

References Write().

00589     {
00590         if (p)
00591             Write( p->ID() );
00592         else
00593             Write(0);
00594 
00595         return *this;
00596     }

Here is the call graph for this function:

template<class T>
nMessage& nMessage::operator<< ( const tControlledPTR< T >  p  )  [inline]

Definition at line 600 of file nNetwork.h.

References Write().

00601     {
00602         if (p)
00603             Write( p->ID() );
00604         else
00605             Write(0);
00606 
00607         return *this;
00608     }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class tControlledPTR< nMessage > [friend]

Definition at line 416 of file nNetwork.h.

friend class tReferencable< nMessage > [friend]

Definition at line 417 of file nNetwork.h.

friend class nDescriptor [friend]

Definition at line 419 of file nNetwork.h.

friend class nNetObject [friend]

Definition at line 420 of file nNetwork.h.

friend class nWaitForAck [friend]

Definition at line 421 of file nNetwork.h.

Referenced by SendImmediately().


Member Data Documentation

unsigned short nMessage::descriptor [protected]

Definition at line 427 of file nNetwork.h.

Referenced by Descriptor(), nDescriptor::HandleMessage(), Send(), SendImmediately(), and ~nMessage().

unsigned long nMessage::messageIDBig_ [protected]

Definition at line 429 of file nNetwork.h.

Referenced by ClearMessageID(), MessageID(), MessageIDBig(), nAckMessage::nAckMessage(), Send(), and SendImmediately().

short nMessage::senderID [protected]

Definition at line 430 of file nNetwork.h.

Referenced by Read(), and SenderID().

tArray<unsigned short> nMessage::data [protected]

Definition at line 431 of file nNetwork.h.

Referenced by Data(), DataLen(), End(), Read(), Send(), SendImmediately(), and Write().

unsigned int nMessage::readOut [protected]

Definition at line 433 of file nNetwork.h.

Referenced by End(), Read(), ReadSoFar(), and Reset().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:48:10 2008 for Armagetron Advanced by  doxygen 1.5.4