2444 return CalcClosestTownFromTile(tile, threshold); |
2444 return CalcClosestTownFromTile(tile, threshold); |
2445 } |
2445 } |
2446 } |
2446 } |
2447 |
2447 |
2448 static bool _town_rating_test = false; |
2448 static bool _town_rating_test = false; |
|
2449 std::map<const Town *, int> _town_test_ratings; |
2449 |
2450 |
2450 void SetTownRatingTestMode(bool mode) |
2451 void SetTownRatingTestMode(bool mode) |
2451 { |
2452 { |
2452 static int ref_count = 0; |
2453 static int ref_count = 0; |
2453 if (mode) { |
2454 if (mode) { |
2454 if (ref_count == 0) { |
2455 if (ref_count == 0) { |
2455 Town *t; |
2456 _town_test_ratings.empty(); |
2456 FOR_ALL_TOWNS(t) t->test_rating = t->ratings[_current_player]; |
|
2457 } |
2457 } |
2458 ref_count++; |
2458 ref_count++; |
2459 } else { |
2459 } else { |
2460 assert(ref_count > 0); |
2460 assert(ref_count > 0); |
2461 ref_count--; |
2461 ref_count--; |
2462 } |
2462 } |
2463 _town_rating_test = !(ref_count == 0); |
2463 _town_rating_test = !(ref_count == 0); |
|
2464 } |
|
2465 |
|
2466 static int GetRating(const Town *t) |
|
2467 { |
|
2468 if (_town_rating_test) { |
|
2469 std::map<const Town *, int>::iterator it = _town_test_ratings.find(t); |
|
2470 if (it != _town_test_ratings.end()) { |
|
2471 return (*it).second; |
|
2472 } |
|
2473 } |
|
2474 return t->ratings[_current_player]; |
2464 } |
2475 } |
2465 |
2476 |
2466 void ChangeTownRating(Town *t, int add, int max) |
2477 void ChangeTownRating(Town *t, int add, int max) |
2467 { |
2478 { |
2468 /* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */ |
2479 /* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */ |
2512 * owned by a town no removal if rating is lower than ... depends now on |
2522 * owned by a town no removal if rating is lower than ... depends now on |
2513 * difficulty setting. Minimum town rating selected by difficulty level |
2523 * difficulty setting. Minimum town rating selected by difficulty level |
2514 */ |
2524 */ |
2515 int modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type]; |
2525 int modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type]; |
2516 |
2526 |
2517 if ((_town_rating_test ? t->test_rating : t->ratings[_current_player]) < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) { |
2527 if (GetRating(t) < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) { |
2518 SetDParam(0, t->index); |
2528 SetDParam(0, t->index); |
2519 _error_message = STR_2009_LOCAL_AUTHORITY_REFUSES; |
2529 _error_message = STR_2009_LOCAL_AUTHORITY_REFUSES; |
2520 return false; |
2530 return false; |
2521 } |
2531 } |
2522 |
2532 |