Advanced Strategic Command
pbpeditor.cpp
Go to the documentation of this file.
2 
4 
5 void k_savemap(bool saveas)
6 {
7  ASCString filename;
8 
9  int nameavail = 0;
10  if ( !actmap->preferredFileNames.mapname[0].empty() ) {
11  nameavail = 1;
12  filename = actmap->preferredFileNames.mapname[0];;
13  }
14 
15  if ( saveas || !nameavail ) {
16  filename = selectFile(ASCString("*") + tournamentextension, false);
17  }
18  if ( !filename.empty() ) {
19 
20  FileTransfer ft;
21  ft.setup( filename );
22  ft.send ( actmap, -1, -1 );
23  mapsaved = true;
24  }
25 }
26 
27 
28 void k_loadmap(void)
29 {
30  ASCString s1 = selectFile( ASCString("*") + tournamentextension + ";*.asc", true );
31  if ( !s1.empty() ) {
32  StatusMessageWindowHolder smw = MessagingHub::Instance().infoMessageWindow( "loading map " + s1 );
33  FileTransfer ft;
35  if ( !mp )
36  return;
37 
38  auto_ptr<GameMap> oldMap ( actmap );
39  actmap = mp;
40 
41  Password pwd;
42  for ( int i = 0; i < actmap->getPlayerCount(); ++i )
44  if ( !actmap->getPlayer(i).passwordcrc.empty() ) {
45  pwd = actmap->getPlayer(i).passwordcrc;
46  break;
47  }
48 
49  if ( pwd.empty() )
51 
53  tlockdispspfld ldsf;
54  if ( !enterpassword ( pwd )) {
55  delete actmap;
56  actmap = oldMap.release();
57  return;
58  }
59  ASCfilename = s1;
60  } else {
61  displaymessage("Sorry, you can't load this file because no supervisor was defined ",1);
62  delete actmap;
63  actmap = NULL;
64  throw NoMapLoaded();
65  }
66 
67  displaymap();
68  mapsaved = true;
70  }
71 }
72 
void send(const GameMap *map, int lastPlayer, int lastturn)
void displaymap()
Definition: spfst.cpp:58
Player & getPlayer(PlayerID p)
Definition: gamemap.h:257
GameMap * loadPBEMFile(const ASCString &filename)
void k_savemap(bool saveas)
Definition: pbpeditor.cpp:5
Loki::Functor< GameMap *, LOKI_TYPELIST_1(const ASCString &) > MapLoadingFunction
Definition: loaders.h:57
bool enterpassword(Password &pwd, bool firstTime, bool cancelAllowed, bool defaultAllowed, const ASCString &username)
Definition: pwd_dlg.cpp:158
if(!yyg->yy_init)
Definition: scanner.cpp:695
A class that hols a MessageWindow. This class ensures that the window is removed if the last copy of ...
Definition: messaginghub.h:34
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
static ASCString ASCfilename
Definition: pbpeditor.cpp:1
struct GameMap::PreferredFilenames preferredFileNames
bool mapsaved
Definition: edmisc.cpp:66
bool empty() const
Definition: password.cpp:89
GameMap * mapLoadingExceptionChecker(const ASCString &filename, MapLoadingFunction loader)
Definition: loaders.cpp:1539
enum Player::PlayerStatus stat
void displaymessage(const char *formatstring, int num,...)
displays a dialog box with a message
Definition: dlg_box.cpp:1849
ASCString selectFile(const ASCString &ext, bool load, bool overwriteMessage)
int getgameparameter(GameParameter num) const
Definition: gamemap.cpp:1047
Password supervisorpasswordcrc
Definition: gamemap.h:368
GameMap * actmap
Definition: spfst.cpp:64
Password passwordcrc
the Password required for playing this player
Definition: player.h:160
int getPlayerCount() const
Definition: gamemap.h:255
const char * tournamentextension
Definition: loaders.cpp:80
void k_loadmap(void)
Definition: pbpeditor.cpp:28
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182