Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

messages.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           messages.cpp  -  description
00003                              -------------------
00004     begin                : Thu Feb 21 2002
00005     copyright            : (C) 2002 by Martin Bickel
00006     email                : bickel@asc-hq.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "global.h"
00019 #include "messages.h"
00020 // #include "gamedlg.h"
00021 #include "gamemap.h"
00022 #include "spfst.h"
00023 
00024 Message :: Message ( GameMap* spfld  )  : cc(0)
00025 {
00026    from = 1 << spfld->actplayer;
00027          
00028    gametime = spfld->time;
00029    time = ::time( NULL );
00030    to = 0;
00031    spfld->messageid++;
00032    id = spfld->messageid;
00033    reminder = false;
00034 
00035    spfld->messages.push_back ( this );
00036 }
00037 
00038 
00039 Message :: Message ( const ASCString& msg, GameMap* gamemap, int rec, int _from ) : cc(0)  // f?r Meldungen vom System
00040 {
00041    from = _from;
00042    gametime = gamemap->time;
00043    time = ::time( NULL );
00044    to = rec;
00045    text = msg;
00046    gamemap->messageid++;
00047    id = gamemap->messageid;
00048    reminder = false;
00049 
00050    gamemap->messages.push_back ( this );
00051 
00052    for ( int i = 0; i < 8; i++ )
00053       if ( to & ( 1 << i ))
00054          gamemap->player[i].unreadmessage.push_back ( this );
00055   
00056 }
00057 
00058 
00059 ASCString Message::bitMap2PlayerName( int p, const GameMap* gamemap  ) const
00060 {
00061    ASCString s;
00062    for ( int i = 0; i < gamemap->getPlayerCount(); ++i )
00063       if ( p & ( 1 << i)) {
00064          if ( !s.empty() )
00065             s += ", ";
00066          s += gamemap->getPlayer(i).getName();
00067       }
00068    return s;
00069 }
00070 
00071 
00072 ASCString Message::getFromText( const GameMap* gamemap ) const
00073 {
00074    if ( from <= 0 )
00075       return "";
00076    
00077    if ( from == (1<<9))
00078       return "system";
00079    
00080    return gamemap->player[log2(from)].getName();
00081 }
00082 
00083 
00084 // #endif
00085 
00086 
00087 

Generated on Tue Jun 24 01:27:45 2008 for Advanced Strategic Command by  doxygen 1.4.2