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

networksupervisor.cpp

Go to the documentation of this file.
00001 
00008 /*
00009     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00010     Copyright (C) 1994-2005  Martin Bickel  and  Marc Schellenberger
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; see the file COPYING. If not, write to the 
00024     Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
00025     Boston, MA  02111-1307  USA
00026 */
00027 
00028 #include <stdio.h>                    
00029 #include <stdlib.h>
00030 #include <cstring>
00031 
00032 #include "global.h"
00033 #include "misc.h"
00034 #include "typen.h"
00035 #include "network/simple_file_transfer.h"
00036 #include "dlg_box.h"
00037 #include "dialog.h"
00038 #include "sgstream.h"
00039 #include "loadpcx.h"
00040 #include "dialogs/pwd_dlg.h"
00041 #include "loaders.h"
00042 #include "gamemap.h"
00043 #include "turncontrol.h"
00044 #include "dialogs/fileselector.h"
00045 #include "dialogs/admingame.h"
00046 
00047 
00048 void networksupervisor ()
00049 {
00050    ASCString filename = selectFile( ASCString("*") + tournamentextension + ";*.asc", true );
00051    if ( filename.empty() )
00052       return;
00053 
00054    StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "loading " + filename );
00055    FileTransfer ft;
00056    auto_ptr<GameMap> newMap ( mapLoadingExceptionChecker( filename, MapLoadingFunction( &ft, &FileTransfer::loadPBEMFile )));
00057    if ( !newMap.get() )
00058       return;
00059 
00060    Password pwd;
00061 
00062    for ( int i = 0; i < newMap->getPlayerCount(); ++i )
00063       if ( newMap->getPlayer(i).stat == Player::supervisor ) {
00064          pwd = newMap->getPlayer(i).passwordcrc;
00065          break;
00066       }
00067 
00068 
00069    if ( pwd.empty() )
00070       pwd = newMap->supervisorpasswordcrc;
00071 
00072    if ( pwd.empty() ) {
00073       errorMessage ("no supervisor setup in this game!" );
00074       return;
00075    }
00076 
00077    smw.close();
00078   
00079 
00080    try {
00081       bool ok = enterpassword ( pwd );
00082       if ( !ok ) {
00083          errorMessage ("invalid password!" );
00084          return;
00085       }
00086    }
00087    catch ( ... ) {
00088       return;
00089    }
00090 
00091    TurnSkipper ts ( &skipTurn );
00092    
00093    if ( adminGame( newMap.get(), &ts  ) ) {
00094       if ( !newMap->network ) {
00095          errorMessage("no network set up for game");
00096          return;
00097       }
00098       newMap->network->send( newMap.get(), -1, -1 );
00099    }
00100 
00101 }
00102 
00103 

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