main_gui.c
changeset 2430 b8bb9d74253b
parent 2429 5e5b66fb8420
child 2432 c48585a8b05f
equal deleted inserted replaced
2429:5e5b66fb8420 2430:b8bb9d74253b
    40 static byte _terraform_size = 1;
    40 static byte _terraform_size = 1;
    41 static byte _last_built_railtype;
    41 static byte _last_built_railtype;
    42 extern void GenerateWorld(int mode, uint size_x, uint size_y);
    42 extern void GenerateWorld(int mode, uint size_x, uint size_y);
    43 
    43 
    44 extern void GenerateIndustries(void);
    44 extern void GenerateIndustries(void);
    45 extern void GenerateTowns(void);
    45 extern bool GenerateTowns(void);
    46 
    46 
    47 void HandleOnEditTextCancel(void)
    47 void HandleOnEditTextCancel(void)
    48 {
    48 {
    49 	switch(_rename_what) {
    49 	switch(_rename_what) {
    50 #ifdef ENABLE_NETWORK
    50 #ifdef ENABLE_NETWORK
  1503 
  1503 
  1504 			HandleButtonClick(w, 5);
  1504 			HandleButtonClick(w, 5);
  1505 			_generating_world = true;
  1505 			_generating_world = true;
  1506 			t = CreateRandomTown(20);
  1506 			t = CreateRandomTown(20);
  1507 			_generating_world = false;
  1507 			_generating_world = false;
  1508 			if (t != NULL)
  1508 
       
  1509 			if (t == NULL) {
       
  1510 				ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
       
  1511 			} else
  1509 				ScrollMainWindowToTile(t->xy);
  1512 				ScrollMainWindowToTile(t->xy);
       
  1513 
  1510 			break;
  1514 			break;
  1511 		}
  1515 		}
  1512 		case 6: {/* many random towns */
  1516 		case 6: {/* many random towns */
  1513 			HandleButtonClick(w, 6);
  1517 			HandleButtonClick(w, 6);
       
  1518 
  1514 			_generating_world = true;
  1519 			_generating_world = true;
  1515 			_game_mode = GM_NORMAL; // little hack to avoid towns of the same size
  1520 			_game_mode = GM_NORMAL; // little hack to avoid towns of the same size
  1516 			GenerateTowns();
  1521 			if (!GenerateTowns())
       
  1522 					ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
  1517 			_generating_world = false;
  1523 			_generating_world = false;
       
  1524 
  1518 			_game_mode = GM_EDITOR;
  1525 			_game_mode = GM_EDITOR;
  1519 			break;
  1526 			break;
  1520 		}
  1527 		}
  1521 
  1528 
  1522 		case 7: case 8: case 9:
  1529 		case 7: case 8: case 9: