@ -1935,41 +1935,41 @@ static bool IsUniqueTownName(const std::string &name)
* @ param text Custom name for the town . If empty , the town name parts will be used .
* @ param text Custom name for the town . If empty , the town name parts will be used .
* @ return the cost of this operation or an error
* @ return the cost of this operation or an error
*/
*/
std : : tuple < CommandCost , TownID> CmdFoundTown ( DoCommandFlag flags , TileIndex tile , TownSize size , bool city , TownLayout layout , bool random_location , uint32 townnameparts , const std : : string & text )
std : : tuple < CommandCost , Money, TownID> CmdFoundTown ( DoCommandFlag flags , TileIndex tile , TownSize size , bool city , TownLayout layout , bool random_location , uint32 townnameparts , const std : : string & text )
{
{
TownNameParams par ( _settings_game . game_creation . town_name ) ;
TownNameParams par ( _settings_game . game_creation . town_name ) ;
if ( size > = TSZ_END ) return { CMD_ERROR , INVALID_TOWN } ;
if ( size > = TSZ_END ) return { CMD_ERROR , 0 , INVALID_TOWN } ;
if ( layout > = NUM_TLS ) return { CMD_ERROR , INVALID_TOWN } ;
if ( layout > = NUM_TLS ) return { CMD_ERROR , 0 , INVALID_TOWN } ;
/* Some things are allowed only in the scenario editor and for game scripts. */
/* Some things are allowed only in the scenario editor and for game scripts. */
if ( _game_mode ! = GM_EDITOR & & _current_company ! = OWNER_DEITY ) {
if ( _game_mode ! = GM_EDITOR & & _current_company ! = OWNER_DEITY ) {
if ( _settings_game . economy . found_town = = TF_FORBIDDEN ) return { CMD_ERROR , INVALID_TOWN } ;
if ( _settings_game . economy . found_town = = TF_FORBIDDEN ) return { CMD_ERROR , 0 , INVALID_TOWN } ;
if ( size = = TSZ_LARGE ) return { CMD_ERROR , INVALID_TOWN } ;
if ( size = = TSZ_LARGE ) return { CMD_ERROR , 0 , INVALID_TOWN } ;
if ( random_location ) return { CMD_ERROR , INVALID_TOWN } ;
if ( random_location ) return { CMD_ERROR , 0 , INVALID_TOWN } ;
if ( _settings_game . economy . found_town ! = TF_CUSTOM_LAYOUT & & layout ! = _settings_game . economy . town_layout ) {
if ( _settings_game . economy . found_town ! = TF_CUSTOM_LAYOUT & & layout ! = _settings_game . economy . town_layout ) {
return { CMD_ERROR , INVALID_TOWN } ;
return { CMD_ERROR , 0 , INVALID_TOWN } ;
}
}
} else if ( _current_company = = OWNER_DEITY & & random_location ) {
} else if ( _current_company = = OWNER_DEITY & & random_location ) {
/* Random parameter is not allowed for Game Scripts. */
/* Random parameter is not allowed for Game Scripts. */
return { CMD_ERROR , INVALID_TOWN } ;
return { CMD_ERROR , 0 , INVALID_TOWN } ;
}
}
if ( text . empty ( ) ) {
if ( text . empty ( ) ) {
/* If supplied name is empty, townnameparts has to generate unique automatic name */
/* If supplied name is empty, townnameparts has to generate unique automatic name */
if ( ! VerifyTownName ( townnameparts , & par ) ) return { CommandCost ( STR_ERROR_NAME_MUST_BE_UNIQUE ) , INVALID_TOWN } ;
if ( ! VerifyTownName ( townnameparts , & par ) ) return { CommandCost ( STR_ERROR_NAME_MUST_BE_UNIQUE ) , 0 , INVALID_TOWN } ;
} else {
} else {
/* If name is not empty, it has to be unique custom name */
/* If name is not empty, it has to be unique custom name */
if ( Utf8StringLength ( text ) > = MAX_LENGTH_TOWN_NAME_CHARS ) return { CMD_ERROR , INVALID_TOWN } ;
if ( Utf8StringLength ( text ) > = MAX_LENGTH_TOWN_NAME_CHARS ) return { CMD_ERROR , 0 , INVALID_TOWN } ;
if ( ! IsUniqueTownName ( text ) ) return { CommandCost ( STR_ERROR_NAME_MUST_BE_UNIQUE ) , INVALID_TOWN } ;
if ( ! IsUniqueTownName ( text ) ) return { CommandCost ( STR_ERROR_NAME_MUST_BE_UNIQUE ) , 0 , INVALID_TOWN } ;
}
}
/* Allocate town struct */
/* Allocate town struct */
if ( ! Town : : CanAllocateItem ( ) ) return { CommandCost ( STR_ERROR_TOO_MANY_TOWNS ) , INVALID_TOWN } ;
if ( ! Town : : CanAllocateItem ( ) ) return { CommandCost ( STR_ERROR_TOO_MANY_TOWNS ) , 0 , INVALID_TOWN } ;
if ( ! random_location ) {
if ( ! random_location ) {
CommandCost ret = TownCanBePlacedHere ( tile ) ;
CommandCost ret = TownCanBePlacedHere ( tile ) ;
if ( ret . Failed ( ) ) return { ret , INVALID_TOWN } ;
if ( ret . Failed ( ) ) return { ret , 0 , INVALID_TOWN } ;
}
}
static const byte price_mult [ ] [ TSZ_RANDOM + 1 ] = { { 15 , 25 , 40 , 25 } , { 20 , 35 , 55 , 35 } } ;
static const byte price_mult [ ] [ TSZ_RANDOM + 1 ] = { { 15 , 25 , 40 , 25 } , { 20 , 35 , 55 , 35 } } ;
@ -1985,8 +1985,7 @@ std::tuple<CommandCost, TownID> CmdFoundTown(DoCommandFlag flags, TileIndex tile
TownID new_town = INVALID_TOWN ;
TownID new_town = INVALID_TOWN ;
if ( flags & DC_EXEC ) {
if ( flags & DC_EXEC ) {
if ( cost . GetCost ( ) > GetAvailableMoneyForCommand ( ) ) {
if ( cost . GetCost ( ) > GetAvailableMoneyForCommand ( ) ) {
_additional_cash_required = cost . GetCost ( ) ;
return { CommandCost ( EXPENSES_OTHER ) , cost . GetCost ( ) , INVALID_TOWN } ;
return { CommandCost ( EXPENSES_OTHER ) , INVALID_TOWN } ;
}
}
Backup < bool > old_generating_world ( _generating_world , true , FILE_LINE ) ;
Backup < bool > old_generating_world ( _generating_world , true , FILE_LINE ) ;
@ -2031,7 +2030,7 @@ std::tuple<CommandCost, TownID> CmdFoundTown(DoCommandFlag flags, TileIndex tile
Game : : NewEvent ( new ScriptEventTownFounded ( t - > index ) ) ;
Game : : NewEvent ( new ScriptEventTownFounded ( t - > index ) ) ;
}
}
}
}
return { cost , new_town } ;
return { cost , 0 , new_town } ;
}
}
/**
/**