OpenTTD Source  13.2.1
company_cmd.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "company_base.h"
12 #include "company_func.h"
13 #include "company_gui.h"
14 #include "core/backup_type.hpp"
15 #include "town.h"
16 #include "news_func.h"
17 #include "command_func.h"
18 #include "network/network.h"
19 #include "network/network_func.h"
20 #include "network/network_base.h"
21 #include "network/network_admin.h"
22 #include "ai/ai.hpp"
23 #include "company_manager_face.h"
24 #include "window_func.h"
25 #include "strings_func.h"
26 #include "date_func.h"
27 #include "sound_func.h"
28 #include "rail.h"
29 #include "core/pool_func.hpp"
30 #include "settings_func.h"
31 #include "vehicle_base.h"
32 #include "vehicle_func.h"
33 #include "smallmap_gui.h"
34 #include "game/game.hpp"
35 #include "goal_base.h"
36 #include "story_base.h"
38 #include "company_cmd.h"
39 
40 #include "table/strings.h"
41 
42 #include "safeguards.h"
43 
45 
52 
53 CompanyPool _company_pool("Company");
55 
56 
61 Company::Company(uint16 name_1, bool is_ai)
62 {
63  this->name_1 = name_1;
64  this->location_of_HQ = INVALID_TILE;
65  this->is_ai = is_ai;
66  this->terraform_limit = (uint32)_settings_game.construction.terraform_frame_burst << 16;
67  this->clear_limit = (uint32)_settings_game.construction.clear_frame_burst << 16;
68  this->tree_limit = (uint32)_settings_game.construction.tree_frame_burst << 16;
69  this->build_object_limit = (uint32)_settings_game.construction.build_object_frame_burst << 16;
70 
71  std::fill(this->share_owners.begin(), this->share_owners.end(), INVALID_OWNER);
73 }
74 
77 {
78  if (CleaningPool()) return;
79 
81 }
82 
87 void Company::PostDestructor(size_t index)
88 {
93  /* If the currently shown error message has this company in it, then close it. */
95 }
96 
103 void SetLocalCompany(CompanyID new_company)
104 {
105  /* company could also be COMPANY_SPECTATOR or OWNER_NONE */
106  assert(Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
107 
108  /* If actually changing to another company, several windows need closing */
109  bool switching_company = _local_company != new_company;
110 
111  /* Delete the chat window, if you were team chatting. */
113 
114  assert(IsLocalCompany());
115 
116  _current_company = _local_company = new_company;
117 
118  if (switching_company) {
120  /* Delete any construction windows... */
122  }
123 
124  /* ... and redraw the whole screen. */
128 }
129 
136 {
137  if (!Company::IsValidID(company)) return (TextColour)_colour_gradient[COLOUR_WHITE][4] | TC_IS_PALETTE_COLOUR;
139 }
140 
147 void DrawCompanyIcon(CompanyID c, int x, int y)
148 {
149  DrawSprite(SPR_COMPANY_ICON, COMPANY_SPRITE_COLOUR(c), x, y);
150 }
151 
159 {
160  if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_GEN_ETHN, GE_WM)) return false;
161 
163  bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0;
164  bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
165  bool has_glasses = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
166 
167  if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_EYE_COLOUR, ge)) return false;
168  for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
169  switch (cmfv) {
170  case CMFV_MOUSTACHE: if (!has_moustache) continue; break;
171  case CMFV_LIPS:
172  case CMFV_NOSE: if (has_moustache) continue; break;
173  case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
174  case CMFV_GLASSES: if (!has_glasses) continue; break;
175  default: break;
176  }
177  if (!AreCompanyManagerFaceBitsValid(cmf, cmfv, ge)) return false;
178  }
179 
180  return true;
181 }
182 
187 void InvalidateCompanyWindows(const Company *company)
188 {
189  CompanyID cid = company->index;
190 
193 }
194 
201 {
202  if (cost.GetCost() > 0) {
204  if (c != nullptr && cost.GetCost() > c->money) {
205  SetDParam(0, cost.GetCost());
206  cost.MakeError(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY);
207  return false;
208  }
209  }
210  return true;
211 }
212 
218 static void SubtractMoneyFromAnyCompany(Company *c, const CommandCost &cost)
219 {
220  if (cost.GetCost() == 0) return;
221  assert(cost.GetExpensesType() != INVALID_EXPENSES);
222 
223  c->money -= cost.GetCost();
224  c->yearly_expenses[0][cost.GetExpensesType()] += cost.GetCost();
225 
226  if (HasBit(1 << EXPENSES_TRAIN_REVENUE |
229  1 << EXPENSES_SHIP_REVENUE, cost.GetExpensesType())) {
230  c->cur_economy.income -= cost.GetCost();
231  } else if (HasBit(1 << EXPENSES_TRAIN_RUN |
232  1 << EXPENSES_ROADVEH_RUN |
233  1 << EXPENSES_AIRCRAFT_RUN |
234  1 << EXPENSES_SHIP_RUN |
235  1 << EXPENSES_PROPERTY |
236  1 << EXPENSES_LOAN_INTEREST, cost.GetExpensesType())) {
237  c->cur_economy.expenses -= cost.GetCost();
238  }
239 
241 }
242 
248 {
250  if (c != nullptr) SubtractMoneyFromAnyCompany(c, cost);
251 }
252 
259 {
260  Company *c = Company::Get(company);
261  byte m = c->money_fraction;
262  Money cost = cst.GetCost();
263 
264  c->money_fraction = m - (byte)cost;
265  cost >>= 8;
266  if (c->money_fraction > m) cost++;
267  if (cost != 0) SubtractMoneyFromAnyCompany(c, CommandCost(cst.GetExpensesType(), cost));
268 }
269 
272 {
273  for (Company *c : Company::Iterate()) {
274  c->terraform_limit = std::min<uint64>((uint64)c->terraform_limit + _settings_game.construction.terraform_per_64k_frames, (uint64)_settings_game.construction.terraform_frame_burst << 16);
275  c->clear_limit = std::min<uint64>((uint64)c->clear_limit + _settings_game.construction.clear_per_64k_frames, (uint64)_settings_game.construction.clear_frame_burst << 16);
276  c->tree_limit = std::min<uint64>((uint64)c->tree_limit + _settings_game.construction.tree_per_64k_frames, (uint64)_settings_game.construction.tree_frame_burst << 16);
277  c->build_object_limit = std::min<uint64>((uint64)c->build_object_limit + _settings_game.construction.build_object_per_64k_frames, (uint64)_settings_game.construction.build_object_frame_burst << 16);
278  }
279 }
280 
287 void GetNameOfOwner(Owner owner, TileIndex tile)
288 {
289  SetDParam(2, owner);
290 
291  if (owner != OWNER_TOWN) {
292  if (!Company::IsValidID(owner)) {
293  SetDParam(0, STR_COMPANY_SOMEONE);
294  } else {
295  SetDParam(0, STR_COMPANY_NAME);
296  SetDParam(1, owner);
297  }
298  } else {
299  assert(tile != 0);
300  const Town *t = ClosestTownFromTile(tile, UINT_MAX);
301 
302  SetDParam(0, STR_TOWN_NAME);
303  SetDParam(1, t->index);
304  }
305 }
306 
307 
317 {
318  assert(owner < OWNER_END);
319  assert(owner != OWNER_TOWN || tile != 0);
320 
321  if (owner == _current_company) return CommandCost();
322 
323  GetNameOfOwner(owner, tile);
324  return_cmd_error(STR_ERROR_OWNED_BY);
325 }
326 
335 {
336  Owner owner = GetTileOwner(tile);
337 
338  assert(owner < OWNER_END);
339 
340  if (owner == _current_company) return CommandCost();
341 
342  /* no need to get the name of the owner unless we're the local company (saves some time) */
343  if (IsLocalCompany()) GetNameOfOwner(owner, tile);
344  return_cmd_error(STR_ERROR_OWNED_BY);
345 }
346 
352 {
353  /* Reserve space for extra unicode character. We need to do this to be able
354  * to detect too long company name. */
355  char buffer[(MAX_LENGTH_COMPANY_NAME_CHARS + 1) * MAX_CHAR_LENGTH];
356 
357  if (c->name_1 != STR_SV_UNNAMED) return;
358  if (c->last_build_coordinate == 0) return;
359 
361 
362  StringID str;
363  uint32 strp;
364  if (t->name.empty() && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) {
365  str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_COMPANY_NAME_START;
366  strp = t->townnameparts;
367 
368 verify_name:;
369  /* No companies must have this name already */
370  for (const Company *cc : Company::Iterate()) {
371  if (cc->name_1 == str && cc->name_2 == strp) goto bad_town_name;
372  }
373 
374  GetString(buffer, str, lastof(buffer));
375  if (Utf8StringLength(buffer) >= MAX_LENGTH_COMPANY_NAME_CHARS) goto bad_town_name;
376 
377 set_name:;
378  c->name_1 = str;
379  c->name_2 = strp;
380 
382 
383  if (c->is_ai) {
385  SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
386  SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
387  SetDParamStr(2, cni->company_name);
388  SetDParam(3, t->index);
389  AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NT_COMPANY_INFO, NF_COMPANY, NR_TILE, c->last_build_coordinate, NR_NONE, UINT32_MAX, cni);
390  }
391  return;
392  }
393 bad_town_name:;
394 
395  if (c->president_name_1 == SPECSTR_PRESIDENT_NAME) {
396  str = SPECSTR_ANDCO_NAME;
397  strp = c->president_name_2;
398  goto set_name;
399  } else {
400  str = SPECSTR_ANDCO_NAME;
401  strp = Random();
402  goto verify_name;
403  }
404 }
405 
407 static const byte _colour_sort[COLOUR_END] = {2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 1, 1, 1};
409 static const Colours _similar_colour[COLOUR_END][2] = {
410  { COLOUR_BLUE, COLOUR_LIGHT_BLUE }, // COLOUR_DARK_BLUE
411  { COLOUR_GREEN, COLOUR_DARK_GREEN }, // COLOUR_PALE_GREEN
412  { INVALID_COLOUR, INVALID_COLOUR }, // COLOUR_PINK
413  { COLOUR_ORANGE, INVALID_COLOUR }, // COLOUR_YELLOW
414  { INVALID_COLOUR, INVALID_COLOUR }, // COLOUR_RED
415  { COLOUR_DARK_BLUE, COLOUR_BLUE }, // COLOUR_LIGHT_BLUE
416  { COLOUR_PALE_GREEN, COLOUR_DARK_GREEN }, // COLOUR_GREEN
417  { COLOUR_PALE_GREEN, COLOUR_GREEN }, // COLOUR_DARK_GREEN
418  { COLOUR_DARK_BLUE, COLOUR_LIGHT_BLUE }, // COLOUR_BLUE
419  { COLOUR_BROWN, COLOUR_ORANGE }, // COLOUR_CREAM
420  { COLOUR_PURPLE, INVALID_COLOUR }, // COLOUR_MAUVE
421  { COLOUR_MAUVE, INVALID_COLOUR }, // COLOUR_PURPLE
422  { COLOUR_YELLOW, COLOUR_CREAM }, // COLOUR_ORANGE
423  { COLOUR_CREAM, INVALID_COLOUR }, // COLOUR_BROWN
424  { COLOUR_WHITE, INVALID_COLOUR }, // COLOUR_GREY
425  { COLOUR_GREY, INVALID_COLOUR }, // COLOUR_WHITE
426 };
427 
432 static Colours GenerateCompanyColour()
433 {
434  Colours colours[COLOUR_END];
435 
436  /* Initialize array */
437  for (uint i = 0; i < COLOUR_END; i++) colours[i] = (Colours)i;
438 
439  /* And randomize it */
440  for (uint i = 0; i < 100; i++) {
441  uint r = Random();
442  Swap(colours[GB(r, 0, 4)], colours[GB(r, 4, 4)]);
443  }
444 
445  /* Bubble sort it according to the values in table 1 */
446  for (uint i = 0; i < COLOUR_END; i++) {
447  for (uint j = 1; j < COLOUR_END; j++) {
448  if (_colour_sort[colours[j - 1]] < _colour_sort[colours[j]]) {
449  Swap(colours[j - 1], colours[j]);
450  }
451  }
452  }
453 
454  /* Move the colours that look similar to each company's colour to the side */
455  for (const Company *c : Company::Iterate()) {
456  Colours pcolour = (Colours)c->colour;
457 
458  for (uint i = 0; i < COLOUR_END; i++) {
459  if (colours[i] == pcolour) {
460  colours[i] = INVALID_COLOUR;
461  break;
462  }
463  }
464 
465  for (uint j = 0; j < 2; j++) {
466  Colours similar = _similar_colour[pcolour][j];
467  if (similar == INVALID_COLOUR) break;
468 
469  for (uint i = 1; i < COLOUR_END; i++) {
470  if (colours[i - 1] == similar) Swap(colours[i - 1], colours[i]);
471  }
472  }
473  }
474 
475  /* Return the first available colour */
476  for (uint i = 0; i < COLOUR_END; i++) {
477  if (colours[i] != INVALID_COLOUR) return colours[i];
478  }
479 
480  NOT_REACHED();
481 }
482 
488 {
489  for (;;) {
490 restart:;
491  c->president_name_2 = Random();
492  c->president_name_1 = SPECSTR_PRESIDENT_NAME;
493 
494  /* Reserve space for extra unicode character. We need to do this to be able
495  * to detect too long president name. */
497  SetDParam(0, c->index);
498  GetString(buffer, STR_PRESIDENT_NAME, lastof(buffer));
499  if (Utf8StringLength(buffer) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) continue;
500 
501  for (const Company *cc : Company::Iterate()) {
502  if (c != cc) {
503  /* Reserve extra space so even overlength president names can be compared. */
504  char buffer2[(MAX_LENGTH_PRESIDENT_NAME_CHARS + 1) * MAX_CHAR_LENGTH];
505  SetDParam(0, cc->index);
506  GetString(buffer2, STR_PRESIDENT_NAME, lastof(buffer2));
507  if (strcmp(buffer2, buffer) == 0) goto restart;
508  }
509  }
510  return;
511  }
512 }
513 
520 {
521  for (LiveryScheme scheme = LS_BEGIN; scheme < LS_END; scheme++) {
522  c->livery[scheme].in_use = 0;
523  c->livery[scheme].colour1 = c->colour;
524  c->livery[scheme].colour2 = c->colour;
525  }
526 
527  for (Group *g : Group::Iterate()) {
528  if (g->owner == c->index) {
529  g->livery.in_use = 0;
530  g->livery.colour1 = c->colour;
531  g->livery.colour2 = c->colour;
532  }
533  }
534 }
535 
544 {
545  if (!Company::CanAllocateItem()) return nullptr;
546 
547  /* we have to generate colour before this company is valid */
548  Colours colour = GenerateCompanyColour();
549 
550  Company *c;
551  if (company == INVALID_COMPANY) {
552  c = new Company(STR_SV_UNNAMED, is_ai);
553  } else {
554  if (Company::IsValidID(company)) return nullptr;
555  c = new (company) Company(STR_SV_UNNAMED, is_ai);
556  }
557 
558  c->colour = colour;
559 
561  _company_colours[c->index] = (Colours)c->colour;
562 
563  /* Scale the initial loan based on the inflation rounded down to the loan interval. The maximum loan has already been inflation adjusted. */
564  c->money = c->current_loan = std::min<int64>((INITIAL_LOAN * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL, _economy.max_loan);
565 
566  std::fill(c->share_owners.begin(), c->share_owners.end(), INVALID_OWNER);
567 
571 
572  /* If starting a player company in singleplayer and a favorite company manager face is selected, choose it. Otherwise, use a random face.
573  * In a network game, we'll choose the favorite face later in CmdCompanyCtrl to sync it to all clients. */
574  if (_company_manager_face != 0 && !is_ai && !_networking) {
576  } else {
577  RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false, false);
578  }
579 
582 
584 
590 
591  if (is_ai && (!_networking || _network_server)) AI::StartNew(c->index);
592 
593  AI::BroadcastNewEvent(new ScriptEventCompanyNew(c->index), c->index);
594  Game::NewEvent(new ScriptEventCompanyNew(c->index));
595 
596  return c;
597 }
598 
601 {
603 }
604 
606 static bool MaybeStartNewCompany()
607 {
609 
610  /* count number of competitors */
611  uint n = 0;
612  for (const Company *c : Company::Iterate()) {
613  if (c->is_ai) n++;
614  }
615 
617  /* Send a command to all clients to start up a new AI.
618  * Works fine for Multiplayer and Singleplayer */
620  }
621 
622  return false;
623 }
624 
627 {
629 }
630 
638 {
639  const Company *c1 = Company::Get(cbig);
640  const Company *c2 = Company::Get(csmall);
641 
642  /* Do the combined vehicle counts stay within the limits? */
647 }
648 
659 {
660  /* Amount of time out for each company to take over a company;
661  * Timeout is a quarter (3 months of 30 days) divided over the
662  * number of companies. The minimum number of days in a quarter
663  * is 90: 31 in January, 28 in February and 31 in March.
664  * Note that the company going bankrupt can't buy itself. */
665  static const int TAKE_OVER_TIMEOUT = 3 * 30 * DAY_TICKS / (MAX_COMPANIES - 1);
666 
667  assert(c->bankrupt_asked != 0);
668 
669  /* We're currently asking some company to buy 'us' */
670  if (c->bankrupt_timeout != 0) {
672  if (c->bankrupt_timeout > 0) return;
673  c->bankrupt_timeout = 0;
674 
675  return;
676  }
677 
678  /* Did we ask everyone for bankruptcy? If so, bail out. */
679  if (c->bankrupt_asked == MAX_UVALUE(CompanyMask)) return;
680 
681  Company *best = nullptr;
682  int32 best_performance = -1;
683 
684  /* Ask the company with the highest performance history first */
685  for (Company *c2 : Company::Iterate()) {
686  if (c2->bankrupt_asked == 0 && // Don't ask companies going bankrupt themselves
687  !HasBit(c->bankrupt_asked, c2->index) &&
688  best_performance < c2->old_economy[1].performance_history &&
689  MayCompanyTakeOver(c2->index, c->index)) {
690  best_performance = c2->old_economy[1].performance_history;
691  best = c2;
692  }
693  }
694 
695  /* Asked all companies? */
696  if (best_performance == -1) {
697  c->bankrupt_asked = MAX_UVALUE(CompanyMask);
698  return;
699  }
700 
701  SetBit(c->bankrupt_asked, best->index);
702 
703  c->bankrupt_timeout = TAKE_OVER_TIMEOUT;
704  if (best->is_ai) {
705  AI::NewEvent(best->index, new ScriptEventCompanyAskMerger(c->index, ClampToI32(c->bankrupt_value)));
706  } else if (IsInteractiveCompany(best->index)) {
708  }
709 }
710 
713 {
714  if (_game_mode == GM_EDITOR) return;
715 
717  if (c != nullptr) {
718  if (c->name_1 != 0) GenerateCompanyName(c);
720  }
721 
722  if (_next_competitor_start == 0) {
723  /* AI::GetStartNextTime() can return 0. */
725  }
726 
727  if (_game_mode != GM_MENU && AI::CanStartNew() && --_next_competitor_start == 0) {
728  /* Allow multiple AIs to possibly start in the same tick. */
729  do {
730  if (!MaybeStartNewCompany()) break;
731 
732  /* In networking mode, we can only send a command to start but it
733  * didn't execute yet, so we cannot loop. */
734  if (_networking) break;
735  } while (AI::GetStartNextTime() == 0);
736  }
737 
739 }
740 
746 {
747  /* Copy statistics */
748  for (Company *c : Company::Iterate()) {
749  memmove(&c->yearly_expenses[1], &c->yearly_expenses[0], sizeof(c->yearly_expenses) - sizeof(c->yearly_expenses[0]));
750  memset(&c->yearly_expenses[0], 0, sizeof(c->yearly_expenses[0]));
751  SetWindowDirty(WC_FINANCES, c->index);
752  }
753 
759  } else {
761  }
762  }
763 }
764 
771 {
772  SetDParam(0, c->index);
773  this->company_name = GetString(STR_COMPANY_NAME);
774 
775  if (other != nullptr) {
776  SetDParam(0, other->index);
777  this->other_company_name = GetString(STR_COMPANY_NAME);
778  c = other;
779  }
780 
781  SetDParam(0, c->index);
782  this->president_name = GetString(STR_PRESIDENT_NAME_MANAGER);
783 
784  this->colour = c->colour;
785  this->face = c->face;
786 
787 }
788 
793 void CompanyAdminUpdate(const Company *company)
794 {
796 }
797 
804 {
806 }
807 
817 {
819 
820  switch (cca) {
821  case CCA_NEW: { // Create a new company
822  /* This command is only executed in a multiplayer game */
823  if (!_networking) return CMD_ERROR;
824 
825  /* Has the network client a correct ClientIndex? */
826  if (!(flags & DC_EXEC)) return CommandCost();
827 
829 
830  /* Delete multiplayer progress bar */
832 
833  Company *c = DoStartupNewCompany(false);
834 
835  /* A new company could not be created, revert to being a spectator */
836  if (c == nullptr) {
837  /* We check for "ci != nullptr" as a client could have left by
838  * the time we execute this command. */
839  if (_network_server && ci != nullptr) {
842  }
843  break;
844  }
845 
846  /* This is the client (or non-dedicated server) who wants a new company */
847  if (client_id == _network_own_client_id) {
852  }
853 
854  /* In network games, we need to try setting the company manager face here to sync it to all clients.
855  * If a favorite company manager face is selected, choose it. Otherwise, use a random face. */
857 
858  /* Now that we have a new company, broadcast our company settings to
859  * all clients so everything is in sync */
861 
863  }
864 
866  break;
867  }
868 
869  case CCA_NEW_AI: { // Make a new AI company
870  if (company_id != INVALID_COMPANY && company_id >= MAX_COMPANIES) return CMD_ERROR;
871 
872  /* For network games, company deletion is delayed. */
873  if (!_networking && company_id != INVALID_COMPANY && Company::IsValidID(company_id)) return CMD_ERROR;
874 
875  if (!(flags & DC_EXEC)) return CommandCost();
876 
877  /* For network game, just assume deletion happened. */
878  assert(company_id == INVALID_COMPANY || !Company::IsValidID(company_id));
879 
880  Company *c = DoStartupNewCompany(true, company_id);
881  if (c != nullptr) NetworkServerNewCompany(c, nullptr);
882  break;
883  }
884 
885  case CCA_DELETE: { // Delete a company
886  if (reason >= CRR_END) return CMD_ERROR;
887 
888  /* We can't delete the last existing company in singleplayer mode. */
889  if (!_networking && Company::GetNumItems() == 1) return CMD_ERROR;
890 
891  Company *c = Company::GetIfValid(company_id);
892  if (c == nullptr) return CMD_ERROR;
893 
894  if (!(flags & DC_EXEC)) return CommandCost();
895 
897 
898  /* Show the bankrupt news */
899  SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
900  SetDParam(1, STR_NEWS_COMPANY_BANKRUPT_DESCRIPTION);
901  SetDParamStr(2, cni->company_name);
902  AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
903 
904  /* Remove the company */
906  if (c->is_ai) AI::Stop(c->index);
907 
908  CompanyID c_index = c->index;
909  delete c;
910  AI::BroadcastNewEvent(new ScriptEventCompanyBankrupt(c_index));
911  Game::NewEvent(new ScriptEventCompanyBankrupt(c_index));
912  CompanyAdminRemove(c_index, (CompanyRemoveReason)reason);
913 
916 
917  break;
918  }
919 
920  default: return CMD_ERROR;
921  }
922 
926 
927  return CommandCost();
928 }
929 
937 {
938  if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
939 
940  if (flags & DC_EXEC) {
941  Company::Get(_current_company)->face = cmf;
943  }
944  return CommandCost();
945 }
946 
955 CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool primary, Colours colour)
956 {
957  if (scheme >= LS_END || (colour >= COLOUR_END && colour != INVALID_COLOUR)) return CMD_ERROR;
958 
959  /* Default scheme can't be reset to invalid. */
960  if (scheme == LS_DEFAULT && colour == INVALID_COLOUR) return CMD_ERROR;
961 
963 
964  /* Ensure no two companies have the same primary colour */
965  if (scheme == LS_DEFAULT && primary) {
966  for (const Company *cc : Company::Iterate()) {
967  if (cc != c && cc->colour == colour) return CMD_ERROR;
968  }
969  }
970 
971  if (flags & DC_EXEC) {
972  if (primary) {
973  if (scheme != LS_DEFAULT) SB(c->livery[scheme].in_use, 0, 1, colour != INVALID_COLOUR);
974  if (colour == INVALID_COLOUR) colour = (Colours)c->livery[LS_DEFAULT].colour1;
975  c->livery[scheme].colour1 = colour;
976 
977  /* If setting the first colour of the default scheme, adjust the
978  * original and cached company colours too. */
979  if (scheme == LS_DEFAULT) {
980  for (int i = 1; i < LS_END; i++) {
981  if (!HasBit(c->livery[i].in_use, 0)) c->livery[i].colour1 = colour;
982  }
984  c->colour = colour;
986  }
987  } else {
988  if (scheme != LS_DEFAULT) SB(c->livery[scheme].in_use, 1, 1, colour != INVALID_COLOUR);
989  if (colour == INVALID_COLOUR) colour = (Colours)c->livery[LS_DEFAULT].colour2;
990  c->livery[scheme].colour2 = colour;
991 
992  if (scheme == LS_DEFAULT) {
993  for (int i = 1; i < LS_END; i++) {
994  if (!HasBit(c->livery[i].in_use, 1)) c->livery[i].colour2 = colour;
995  }
996  }
997  }
998 
999  if (c->livery[scheme].in_use != 0) {
1000  /* If enabling a scheme, set the default scheme to be in use too */
1001  c->livery[LS_DEFAULT].in_use = 1;
1002  } else {
1003  /* Else loop through all schemes to see if any are left enabled.
1004  * If not, disable the default scheme too. */
1005  c->livery[LS_DEFAULT].in_use = 0;
1006  for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
1007  if (c->livery[scheme].in_use != 0) {
1008  c->livery[LS_DEFAULT].in_use = 1;
1009  break;
1010  }
1011  }
1012  }
1013 
1014  ResetVehicleColourMap();
1016 
1017  /* All graph related to companies use the company colour. */
1024  /* The smallmap owner view also stores the company colours. */
1025  BuildOwnerLegend();
1027 
1028  /* Company colour data is indirectly cached. */
1029  for (Vehicle *v : Vehicle::Iterate()) {
1030  if (v->owner == _current_company) v->InvalidateNewGRFCache();
1031  }
1032 
1033  extern void UpdateObjectColours(const Company *c);
1035  }
1036  return CommandCost();
1037 }
1038 
1044 static bool IsUniqueCompanyName(const std::string &name)
1045 {
1046  for (const Company *c : Company::Iterate()) {
1047  if (!c->name.empty() && c->name == name) return false;
1048  }
1049 
1050  return true;
1051 }
1052 
1059 CommandCost CmdRenameCompany(DoCommandFlag flags, const std::string &text)
1060 {
1061  bool reset = text.empty();
1062 
1063  if (!reset) {
1065  if (!IsUniqueCompanyName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
1066  }
1067 
1068  if (flags & DC_EXEC) {
1070  if (reset) {
1071  c->name.clear();
1072  } else {
1073  c->name = text;
1074  }
1076  CompanyAdminUpdate(c);
1077  }
1078 
1079  return CommandCost();
1080 }
1081 
1087 static bool IsUniquePresidentName(const std::string &name)
1088 {
1089  for (const Company *c : Company::Iterate()) {
1090  if (!c->president_name.empty() && c->president_name == name) return false;
1091  }
1092 
1093  return true;
1094 }
1095 
1102 CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
1103 {
1104  bool reset = text.empty();
1105 
1106  if (!reset) {
1108  if (!IsUniquePresidentName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
1109  }
1110 
1111  if (flags & DC_EXEC) {
1113 
1114  if (reset) {
1115  c->president_name.clear();
1116  } else {
1117  c->president_name = text;
1118 
1119  if (c->name_1 == STR_SV_UNNAMED && c->name.empty()) {
1120  Command<CMD_RENAME_COMPANY>::Do(DC_EXEC, text + " Transport");
1121  }
1122  }
1123 
1125  CompanyAdminUpdate(c);
1126  }
1127 
1128  return CommandCost();
1129 }
1130 
1138 {
1139  const VehicleDefaultSettings *vds = (c == nullptr) ? &_settings_client.company.vehicle : &c->settings.vehicle;
1140  switch (type) {
1141  default: NOT_REACHED();
1142  case VEH_TRAIN: return vds->servint_trains;
1143  case VEH_ROAD: return vds->servint_roadveh;
1144  case VEH_AIRCRAFT: return vds->servint_aircraft;
1145  case VEH_SHIP: return vds->servint_ships;
1146  }
1147 }
1148 
1154 {
1155  uint32 total = 0;
1156  for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
1157  if (RoadTypeIsRoad(rt)) total += this->road[rt];
1158  }
1159  return total;
1160 }
1161 
1167 {
1168  uint32 total = 0;
1169  for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
1170  if (RoadTypeIsTram(rt)) total += this->road[rt];
1171  }
1172  return total;
1173 }
1174 
1185 CommandCost CmdGiveMoney(DoCommandFlag flags, uint32 money, CompanyID dest_company)
1186 {
1188 
1190  CommandCost amount(EXPENSES_OTHER, std::min<Money>(money, 20000000LL));
1191 
1192  /* You can only transfer funds that is in excess of your loan */
1193  if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() < 0) return_cmd_error(STR_ERROR_INSUFFICIENT_FUNDS);
1194  if (!Company::IsValidID(dest_company)) return CMD_ERROR;
1195 
1196  if (flags & DC_EXEC) {
1197  /* Add money to company */
1198  Backup<CompanyID> cur_company(_current_company, dest_company, FILE_LINE);
1200  cur_company.Restore();
1201 
1202  if (_networking) {
1203  SetDParam(0, dest_company);
1204  std::string dest_company_name = GetString(STR_COMPANY_NAME);
1205 
1207  std::string from_company_name = GetString(STR_COMPANY_NAME);
1208 
1209  NetworkTextMessage(NETWORK_ACTION_GIVE_MONEY, GetDrawStringCompanyColour(_current_company), false, from_company_name, dest_company_name, amount.GetCost());
1210  }
1211  }
1212 
1213  /* Subtract money from local-company */
1214  return amount;
1215 }
1216 
1227 {
1228  for (Company *c : Company::Iterate()) {
1229  if (Company::IsHumanID(c->index)) {
1230  return c->index;
1231  }
1232  }
1233 
1234  if (Company::CanAllocateItem()) {
1235  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
1236  if (!Company::IsValidID(c)) {
1237  return c;
1238  }
1239  }
1240  }
1241 
1242  return COMPANY_FIRST;
1243 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
EconomySettings::give_money
bool give_money
allow giving other companies money
Definition: settings_type.h:520
game.hpp
HandleBankruptcyTakeover
static void HandleBankruptcyTakeover(Company *c)
Handle the bankruptcy take over of a company.
Definition: company_cmd.cpp:658
BuildOwnerLegend
void BuildOwnerLegend()
Completes the array for the owned property legend.
Definition: smallmap_gui.cpp:326
CompanyProperties::is_ai
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Definition: company_base.h:96
VehicleSettings::max_aircraft
UnitID max_aircraft
max planes in game per company
Definition: settings_type.h:497
CompanyCtrlAction
CompanyCtrlAction
The action to do with CMD_COMPANY_CTRL.
Definition: company_type.h:67
Economy::inflation_prices
uint64 inflation_prices
Cumulated inflation of prices since game start; 16 bit fractional part.
Definition: economy_type.h:36
InvalidateWindowData
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition: window.cpp:3254
IsInsideMM
static constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:230
sound_func.h
ClampToI32
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
Definition: math_func.hpp:167
EXPENSES_ROADVEH_RUN
@ EXPENSES_ROADVEH_RUN
Running costs road vehicles.
Definition: economy_type.h:161
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
INVALID_EXPENSES
@ INVALID_EXPENSES
Invalid expense type.
Definition: economy_type.h:172
CommandCost::MakeError
void MakeError(StringID message)
Makes this CommandCost behave like an error command.
Definition: command_type.h:101
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
CRR_NONE
@ CRR_NONE
Dummy reason for actions that don't need one.
Definition: company_type.h:63
CompanyNewsInformation::colour
byte colour
The colour related to the company.
Definition: news_type.h:164
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3156
NR_TILE
@ NR_TILE
Reference tile. Scroll to tile when clicking on the news.
Definition: news_type.h:52
INVALID_CLIENT_ID
@ INVALID_CLIENT_ID
Client is not part of anything.
Definition: network_type.h:48
Company::group_all
GroupStatistics group_all[VEH_COMPANY_END]
NOSAVE: Statistics for the ALL_GROUP group.
Definition: company_base.h:127
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
CompanyAdminUpdate
void CompanyAdminUpdate(const Company *company)
Called whenever company related information changes in order to notify admins.
Definition: company_cmd.cpp:793
command_func.h
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:348
CMD_ERROR
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Definition: command_func.h:28
statusbar_widget.h
Company::avail_railtypes
RailTypes avail_railtypes
Rail types available to this company.
Definition: company_base.h:121
ClosestTownFromTile
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Definition: town_cmd.cpp:3594
smallmap_gui.h
GenerateCompanyName
static void GenerateCompanyName(Company *c)
Generate the name of a company from the last build coordinate.
Definition: company_cmd.cpp:351
Backup
Class to backup a specific variable and restore it later.
Definition: backup_type.hpp:21
CompanyManagerFace
uint32 CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
Definition: company_type.h:52
SetDefaultCompanySettings
void SetDefaultCompanySettings(CompanyID cid)
Set the company settings for a new company to their default values.
Definition: settings.cpp:1587
Company::avail_roadtypes
RoadTypes avail_roadtypes
Road types available to this company.
Definition: company_base.h:122
_similar_colour
static const Colours _similar_colour[COLOUR_END][2]
Similar colours, so we can try to prevent same coloured companies.
Definition: company_cmd.cpp:409
company_base.h
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
CCA_DELETE
@ CCA_DELETE
Delete a company.
Definition: company_type.h:70
EXPENSES_OTHER
@ EXPENSES_OTHER
Other expenses.
Definition: economy_type.h:170
CompanyNewsInformation::president_name
std::string president_name
The name of the president.
Definition: news_type.h:160
NetworkClientInfo::client_playas
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition: network_base.h:27
LOAN_INTERVAL
static const int LOAN_INTERVAL
The "steps" in loan size, in British Pounds!
Definition: economy_type.h:198
CompanyProperties::inaugurated_year
Year inaugurated_year
Year of starting the company.
Definition: company_base.h:80
company_gui.h
NetworkSettings::default_company_pass
std::string default_company_pass
default password for new companies in encrypted form
Definition: settings_type.h:293
_network_server
bool _network_server
network-server is active
Definition: network.cpp:59
EXPENSES_TRAIN_REVENUE
@ EXPENSES_TRAIN_REVENUE
Revenue from trains.
Definition: economy_type.h:165
INITIAL_LOAN
static const int64 INITIAL_LOAN
The size of loan for a new company, in British Pounds!
Definition: economy_type.h:200
ConstructionSettings::clear_per_64k_frames
uint32 clear_per_64k_frames
how many tiles may, over a long period, be cleared per 65536 frames?
Definition: settings_type.h:360
CmdGiveMoney
CommandCost CmdGiveMoney(DoCommandFlag flags, uint32 money, CompanyID dest_company)
Transfer funds (money) from one company to another.
Definition: company_cmd.cpp:1185
WC_CLIENT_LIST
@ WC_CLIENT_LIST
Client list; Window numbers:
Definition: window_type.h:471
company_manager_face.h
GenderEthnicity
GenderEthnicity
The gender/race combinations that we have faces for.
Definition: company_manager_face.h:19
Pool::PoolItem<&_company_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
CompanyProperties::money_fraction
byte money_fraction
Fraction of money of the company, too small to represent in money.
Definition: company_base.h:68
NetworkUpdateClientInfo
void NetworkUpdateClientInfo(ClientID client_id)
Send updated client info of a particular client.
Definition: network_server.cpp:1473
Company::PostDestructor
static void PostDestructor(size_t index)
Invalidating some stuff after removing item from the pool.
Definition: company_cmd.cpp:87
AI::GetStartNextTime
static int GetStartNextTime()
Get the number of days before the next AI should start.
Definition: ai_core.cpp:294
WC_PERFORMANCE_HISTORY
@ WC_PERFORMANCE_HISTORY
Performance history graph; Window numbers:
Definition: window_type.h:539
WID_S_RIGHT
@ WID_S_RIGHT
Right part; bank balance.
Definition: statusbar_widget.h:17
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition: settings_type.h:586
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
INVALID_TILE
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:108
AddNewsItem
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32 ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32 ref2=UINT32_MAX, const NewsAllocatedData *data=nullptr)
Add a new newsitem to be shown.
Definition: news_gui.cpp:827
WC_SIGN_LIST
@ WC_SIGN_LIST
Sign list; Window numbers:
Definition: window_type.h:271
CompanySettings::vehicle
VehicleDefaultSettings vehicle
default settings for vehicles
Definition: settings_type.h:581
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
SetLocalCompany
void SetLocalCompany(CompanyID new_company)
Sets the local company and updates the settings that are set on a per-company basis to reflect the co...
Definition: company_cmd.cpp:103
AI::CanStartNew
static bool CanStartNew()
Is it possible to start a new AI company?
Definition: ai_core.cpp:30
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:253
vehicle_base.h
EXPENSES_AIRCRAFT_RUN
@ EXPENSES_AIRCRAFT_RUN
Running costs aircraft.
Definition: economy_type.h:162
CmdCompanyCtrl
CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id)
Control the companies: add, delete, etc.
Definition: company_cmd.cpp:816
CompanyProperties::name
std::string name
Name of the company if the user changed it.
Definition: company_base.h:59
goal_base.h
Economy::max_loan
Money max_loan
NOSAVE: Maximum possible loan.
Definition: economy_type.h:29
DESTTYPE_TEAM
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
Definition: network_type.h:91
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
LiveryScheme
LiveryScheme
List of different livery schemes.
Definition: livery.h:20
GetCompanyRoadTypes
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Definition: road.cpp:188
town.h
CloseCompanyWindows
void CloseCompanyWindows(CompanyID company)
Close all windows of a company.
Definition: window.cpp:1219
WC_COMPANY
@ WC_COMPANY
Company view; Window numbers:
Definition: window_type.h:362
SoundSettings::new_year
bool new_year
Play sound on new year, summarising the performance during the last year.
Definition: settings_type.h:215
CompanyProperties::last_build_coordinate
TileIndex last_build_coordinate
Coordinate of the last build thing by this company.
Definition: company_base.h:76
CompanyProperties::face
CompanyManagerFace face
Face description of the president.
Definition: company_base.h:65
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:224
WC_GOALS_LIST
@ WC_GOALS_LIST
Goals list; Window numbers:
Definition: window_type.h:283
VehicleDefaultSettings::servint_ships
uint16 servint_ships
service interval for ships
Definition: settings_type.h:572
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
DC_EXEC
@ DC_EXEC
execute the given command
Definition: command_type.h:357
CmdSetCompanyColour
CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool primary, Colours colour)
Change the company's company-colour.
Definition: company_cmd.cpp:955
WC_COMPANY_LEAGUE
@ WC_COMPANY_LEAGUE
Company league window; Window numbers:
Definition: window_type.h:551
_colour_gradient
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:55
IsLocalCompany
static bool IsLocalCompany()
Is the current company the local company?
Definition: company_func.h:43
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:355
CompanyProperties::current_loan
Money current_loan
Amount of money borrowed from the bank.
Definition: company_base.h:69
_cur_company_tick_index
uint _cur_company_tick_index
used to generate a name for one company that doesn't have a name yet per tick
Definition: company_cmd.cpp:51
InitializeCompanies
void InitializeCompanies()
Initialize the pool of companies.
Definition: company_cmd.cpp:626
ClearEnginesHiddenFlagOfCompany
void ClearEnginesHiddenFlagOfCompany(CompanyID cid)
Clear the 'hidden' flag for all engines of a new company.
Definition: engine.cpp:924
MayCompanyTakeOver
bool MayCompanyTakeOver(CompanyID cbig, CompanyID csmall)
May company cbig buy company csmall?
Definition: company_cmd.cpp:637
CompanyInfrastructure::GetRoadTotal
uint32 GetRoadTotal() const
Get total sum of all owned road bits.
Definition: company_cmd.cpp:1153
CompanyProperties::name_2
uint32 name_2
Parameter of name_1.
Definition: company_base.h:57
GroupStatistics::num_vehicle
uint16 num_vehicle
Number of vehicles.
Definition: group.h:29
network_base.h
MAX_CHAR_LENGTH
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
Definition: strings_type.h:18
MAX_LENGTH_COMPANY_NAME_CHARS
static const uint MAX_LENGTH_COMPANY_NAME_CHARS
The maximum length of a company name in characters including '\0'.
Definition: company_type.h:40
CmdSetCompanyManagerFace
CommandCost CmdSetCompanyManagerFace(DoCommandFlag flags, CompanyManagerFace cmf)
Change the company manager's face.
Definition: company_cmd.cpp:936
ai.hpp
NR_NONE
@ NR_NONE
Empty reference.
Definition: news_type.h:51
GENDER_FEMALE
@ GENDER_FEMALE
This bit set means a female, otherwise male.
Definition: company_manager_face.h:20
NetworkChangeCompanyPassword
std::string NetworkChangeCompanyPassword(CompanyID company_id, std::string password)
Change the company password of a given company.
Definition: network.cpp:157
GetCompanyManagerFaceBits
static uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Make sure the table's size is right.
Definition: company_manager_face.h:96
WC_DELIVERED_CARGO
@ WC_DELIVERED_CARGO
Delivered cargo graph; Window numbers:
Definition: window_type.h:533
ConstructionSettings::build_object_frame_burst
uint16 build_object_frame_burst
how many tiles may, over a short period, be purchased or have objects built on them?
Definition: settings_type.h:365
COMPANY_FIRST
@ COMPANY_FIRST
First company, same as owner.
Definition: company_type.h:22
Group
Group data.
Definition: group.h:74
SetWindowWidgetDirty
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
Definition: window.cpp:3169
WC_GRAPH_LEGEND
@ WC_GRAPH_LEGEND
Legend for graphs; Window numbers:
Definition: window_type.h:509
NetworkClientInfo::GetByClientID
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition: network.cpp:114
company_cmd.h
CompanyNewsInformation::other_company_name
std::string other_company_name
The name of the company taking over this one.
Definition: news_type.h:161
Utf8StringLength
size_t Utf8StringLength(const char *s)
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes th...
Definition: string.cpp:435
ShowCompanyFinances
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
Definition: company_gui.cpp:548
_company_colours
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
Definition: company_cmd.cpp:48
ConstructionSettings::terraform_frame_burst
uint16 terraform_frame_burst
how many tile heights may, over a short period, be terraformed?
Definition: settings_type.h:359
CompanyNewsInformation::company_name
std::string company_name
The name of the company.
Definition: news_type.h:159
CompanyInfrastructure::GetTramTotal
uint32 GetTramTotal() const
Get total sum of all owned tram bits.
Definition: company_cmd.cpp:1166
CheckOwnership
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
Definition: company_cmd.cpp:316
return_cmd_error
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
Definition: command_func.h:38
StartupCompanies
void StartupCompanies()
Start the next competitor now.
Definition: company_cmd.cpp:600
AI::NewEvent
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Definition: ai_core.cpp:236
CompanyProperties::colour
byte colour
Company colour.
Definition: company_base.h:71
CommandCost
Common return value for all commands.
Definition: command_type.h:24
CompanyEconomyEntry::performance_history
int32 performance_history
Company score (scale 0-1000)
Definition: company_base.h:27
MAX_LENGTH_PRESIDENT_NAME_CHARS
static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS
The maximum length of a president name in characters including '\0'.
Definition: company_type.h:39
settings_func.h
CompanyProperties::num_valid_stat_ent
byte num_valid_stat_ent
Number of valid statistical entries in old_economy.
Definition: company_base.h:101
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:607
CommandCost::GetExpensesType
ExpensesType GetExpensesType() const
The expense type of the cost.
Definition: command_type.h:92
VehicleSettings::max_ships
UnitID max_ships
max ships in game per company
Definition: settings_type.h:498
SubtractMoneyFromCompanyFract
void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cst)
Subtract money from a company, including the money fraction.
Definition: company_cmd.cpp:258
ConstructionSettings::tree_frame_burst
uint16 tree_frame_burst
how many trees may, over a short period, be planted?
Definition: settings_type.h:363
GeneratePresidentName
static void GeneratePresidentName(Company *c)
Generate a random president name of a company.
Definition: company_cmd.cpp:487
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:47
INVALID_OWNER
@ INVALID_OWNER
An invalid owner.
Definition: company_type.h:29
CompanyProperties::money
Money money
Money owned by the company.
Definition: company_base.h:67
InvalidateCompanyWindows
void InvalidateCompanyWindows(const Company *company)
Refresh all windows owned by a company.
Definition: company_cmd.cpp:187
AI::StartNew
static void StartNew(CompanyID company, bool rerandomise_ai=true)
Start a new AI company.
Definition: ai_core.cpp:36
ConstructionSettings::terraform_per_64k_frames
uint32 terraform_per_64k_frames
how many tile heights may, over a long period, be terraformed per 65536 frames?
Definition: settings_type.h:358
GetNameOfOwner
void GetNameOfOwner(Owner owner, TileIndex tile)
Set the right DParams to get the name of an owner.
Definition: company_cmd.cpp:287
AreCompanyManagerFaceBitsValid
static bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Checks whether the company manager's face bits have a valid range.
Definition: company_manager_face.h:151
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
TC_IS_PALETTE_COLOUR
@ TC_IS_PALETTE_COLOUR
Colour value is already a real palette colour index, not an index of a StringColour.
Definition: gfx_type.h:276
Livery::in_use
byte in_use
Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour...
Definition: livery.h:79
CompanyProperties::settings
CompanySettings settings
settings specific for each company
Definition: company_base.h:106
Game::NewEvent
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition: game_core.cpp:146
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:596
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
SyncCompanySettings
void SyncCompanySettings()
Sync all company settings in a multiplayer game.
Definition: settings.cpp:1599
AI::BroadcastNewEvent
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
Definition: ai_core.cpp:261
safeguards.h
CommandCost::GetCost
Money GetCost() const
The costs as made up to this moment.
Definition: command_type.h:83
IsInteractiveCompany
static bool IsInteractiveCompany(CompanyID company)
Is the user representing company?
Definition: company_func.h:53
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:58
rail.h
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1058
CompanyProperties::president_name
std::string president_name
Name of the president if the user changed it.
Definition: company_base.h:63
IsValidCompanyManagerFace
static bool IsValidCompanyManagerFace(CompanyManagerFace cmf)
Checks whether a company manager's face is a valid encoding.
Definition: company_cmd.cpp:158
VehicleDefaultSettings
Default settings for vehicles.
Definition: settings_type.h:567
CompanyInfrastructure::road
uint32 road[ROADTYPE_END]
Count of company owned track bits for each road type.
Definition: company_base.h:32
CompanyProperties::yearly_expenses
Money yearly_expenses[3][EXPENSES_END]
Expenses of the company for the last three years, in every ExpensesType category.
Definition: company_base.h:98
ConstructionSettings::tree_per_64k_frames
uint32 tree_per_64k_frames
how many trees may, over a long period, be planted per 65536 frames?
Definition: settings_type.h:362
AdminCompanyRemoveReason
AdminCompanyRemoveReason
Reasons for removing a company - communicated to admins.
Definition: tcp_admin.h:103
date_func.h
WC_INCOME_GRAPH
@ WC_INCOME_GRAPH
Income graph; Window numbers:
Definition: window_type.h:521
stdafx.h
Company::IsHumanID
static bool IsHumanID(size_t index)
Is this company a company not controlled by a NoAI program?
Definition: company_base.h:162
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
NetworkAdminCompanyRemove
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr)
Notify the admin network of a company to be removed (including the reason why).
Definition: network_admin.cpp:912
CompaniesYearlyLoop
void CompaniesYearlyLoop()
A year has passed, update the economic data of all companies, and perhaps show the financial overview...
Definition: company_cmd.cpp:745
WC_LINKGRAPH_LEGEND
@ WC_LINKGRAPH_LEGEND
Linkgraph legend; Window numbers:
Definition: window_type.h:674
CheckCompanyHasMoney
bool CheckCompanyHasMoney(CommandCost &cost)
Verify whether the company can pay the bill.
Definition: company_cmd.cpp:200
CompanyAdminRemove
void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
Called whenever a company is removed in order to notify admins.
Definition: company_cmd.cpp:803
CompanyProperties::bankrupt_asked
CompanyMask bankrupt_asked
which companies were asked about buying it?
Definition: company_base.h:83
NetworkClientInfo::client_id
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition: network_base.h:25
CCA_NEW_AI
@ CCA_NEW_AI
Create a new AI company.
Definition: company_type.h:69
CompanyProperties::president_name_2
uint32 president_name_2
Parameter of president_name_1.
Definition: company_base.h:62
GetTileOwner
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:178
DrawCompanyIcon
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
Definition: company_cmd.cpp:147
_network_own_client_id
ClientID _network_own_client_id
Our client identifier.
Definition: network.cpp:64
_colour_sort
static const byte _colour_sort[COLOUR_END]
Sorting weights for the company colours.
Definition: company_cmd.cpp:407
NetworkAdminCompanyUpdate
void NetworkAdminCompanyUpdate(const Company *company)
Notify the admin network of company updates.
Definition: network_admin.cpp:896
_company_pool
CompanyPool _company_pool("Company")
Pool of companies.
WC_COMPANY_VALUE
@ WC_COMPANY_VALUE
Company value graph; Window numbers:
Definition: window_type.h:545
IsUniqueCompanyName
static bool IsUniqueCompanyName(const std::string &name)
Is the given name in use as name of a company?
Definition: company_cmd.cpp:1044
ShowBuyCompanyDialog
void ShowBuyCompanyDialog(CompanyID company)
Show the query to buy another company.
Definition: company_gui.cpp:2875
CompanyEconomyEntry::expenses
Money expenses
The amount of expenses.
Definition: company_base.h:25
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
vehicle_func.h
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:606
CompanyProperties::share_owners
std::array< Owner, MAX_COMPANY_SHARE_OWNERS > share_owners
Owners of the shares of the company. INVALID_OWNER if nobody has bought them yet.
Definition: company_base.h:78
Pool::PoolItem<&_company_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:386
CompanyNewsInformation
Data that needs to be stored for company news messages.
Definition: news_type.h:158
strings_func.h
Pool
Base class for all pools.
Definition: pool_type.hpp:81
CompanyProperties::cur_economy
CompanyEconomyEntry cur_economy
Economic data of the company of this quarter.
Definition: company_base.h:99
WC_PERFORMANCE_DETAIL
@ WC_PERFORMANCE_DETAIL
Performance detail window; Window numbers:
Definition: window_type.h:563
VehicleDefaultSettings::servint_trains
uint16 servint_trains
service interval for trains
Definition: settings_type.h:569
VehicleSettings::max_trains
UnitID max_trains
max trains in game per company
Definition: settings_type.h:495
Pool::PoolItem<&_company_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:367
Backup::Restore
void Restore()
Restore the variable.
Definition: backup_type.hpp:112
MaybeStartNewCompany
static bool MaybeStartNewCompany()
Start a new competitor company if possible.
Definition: company_cmd.cpp:606
WC_AI_LIST
@ WC_AI_LIST
AI list; Window numbers:
Definition: window_type.h:277
GUISettings::show_finances
bool show_finances
show finances at end of year
Definition: settings_type.h:112
GetDrawStringCompanyColour
TextColour GetDrawStringCompanyColour(CompanyID company)
Get the colour for DrawString-subroutines which matches the colour of the company.
Definition: company_cmd.cpp:135
_company_manager_face
CompanyManagerFace _company_manager_face
for company manager face storage in openttd.cfg
Definition: company_cmd.cpp:49
NF_COMPANY
@ NF_COMPANY
Company news item. (Newspaper with face)
Definition: news_type.h:81
COMPANY_SPECTATOR
@ COMPANY_SPECTATOR
The client is spectating.
Definition: company_type.h:35
CompanyServiceInterval
int CompanyServiceInterval(const Company *c, VehicleType type)
Get the service interval for the given company and vehicle type.
Definition: company_cmd.cpp:1137
NetworkServerNewCompany
void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci)
Perform all the server specific administration of a new company.
Definition: network_server.cpp:2070
InvalidateWindowClassesData
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition: window.cpp:3271
WC_NETWORK_STATUS_WINDOW
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
Definition: window_type.h:478
Pool::PoolItem<&_company_pool >::CleaningPool
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
Definition: pool_type.hpp:316
WC_AI_SETTINGS
@ WC_AI_SETTINGS
AI settings; Window numbers:
Definition: window_type.h:168
OWNER_NONE
@ OWNER_NONE
The tile has no ownership.
Definition: company_type.h:25
CompanyNewsInformation::face
uint32 face
The face of the president.
Definition: news_type.h:163
GetCompanyRailtypes
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
Definition: rail.cpp:251
VehicleDefaultSettings::servint_aircraft
uint16 servint_aircraft
service interval for aircraft
Definition: settings_type.h:571
Pool::PoolItem<&_company_pool >::CanAllocateItem
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:307
GetFirstPlayableCompanyID
CompanyID GetFirstPlayableCompanyID()
Get the index of the first available company.
Definition: company_cmd.cpp:1226
MAX_UVALUE
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
Definition: stdafx.h:479
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
SubtractMoneyFromAnyCompany
static void SubtractMoneyFromAnyCompany(Company *c, const CommandCost &cost)
Deduct costs of a command from the money of a company.
Definition: company_cmd.cpp:218
EXPENSES_PROPERTY
@ EXPENSES_PROPERTY
Property costs.
Definition: economy_type.h:164
DoStartupNewCompany
Company * DoStartupNewCompany(bool is_ai, CompanyID company=INVALID_COMPANY)
Create a new company and sets all company variables default values.
Definition: company_cmd.cpp:543
DifficultySettings::max_no_competitors
byte max_no_competitors
the number of competitors (AIs)
Definition: settings_type.h:78
company_func.h
VehicleSettings::max_roadveh
UnitID max_roadveh
max trucks in game per company
Definition: settings_type.h:496
ConstructionSettings::clear_frame_burst
uint16 clear_frame_burst
how many tiles may, over a short period, be cleared?
Definition: settings_type.h:361
ConstructionSettings::build_object_per_64k_frames
uint32 build_object_per_64k_frames
how many tiles may, over a long period, be purchased or have objects built on them per 65536 frames?
Definition: settings_type.h:364
CompanyNewsInformation::CompanyNewsInformation
CompanyNewsInformation(const struct Company *c, const struct Company *other=nullptr)
Fill the CompanyNewsInformation struct with the required data.
Definition: company_cmd.cpp:770
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Definition: pool_func.hpp:224
CompanyEconomyEntry::income
Money income
The amount of income.
Definition: company_base.h:24
network.h
CompanyProperties::president_name_1
StringID president_name_1
Name of the president if the user did not change it.
Definition: company_base.h:61
CheckTileOwnership
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
Definition: company_cmd.cpp:334
CommandHelper
Definition: command_func.h:94
WC_SEND_NETWORK_MSG
@ WC_SEND_NETWORK_MSG
Chatbox; Window numbers:
Definition: window_type.h:490
Company::~Company
~Company()
Destructor.
Definition: company_cmd.cpp:76
SND_01_BAD_YEAR
@ SND_01_BAD_YEAR
40 == 0x28 New year: performance declined
Definition: sound_type.h:79
window_func.h
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
Town
Town data structure.
Definition: town.h:50
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1767
ClientSettings::network
NetworkSettings network
settings related to the network
Definition: settings_type.h:605
EXPENSES_TRAIN_RUN
@ EXPENSES_TRAIN_RUN
Running costs trains.
Definition: economy_type.h:160
OverflowSafeInt< int64 >
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1191
VehicleDefaultSettings::servint_roadveh
uint16 servint_roadveh
service interval for road vehicles
Definition: settings_type.h:570
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
SND_00_GOOD_YEAR
@ SND_00_GOOD_YEAR
39 == 0x27 New year: performance improved
Definition: sound_type.h:78
OWNER_END
@ OWNER_END
Last + 1 owner.
Definition: company_type.h:28
CRR_END
@ CRR_END
Sentinel for end.
Definition: company_type.h:61
ClientSettings::company
CompanySettings company
default values for per-company settings
Definition: settings_type.h:606
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:588
GameSettings::vehicle
VehicleSettings vehicle
options for vehicles
Definition: settings_type.h:595
IsUniquePresidentName
static bool IsUniquePresidentName(const std::string &name)
Is the given name in use as president name of a company?
Definition: company_cmd.cpp:1087
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
WC_STATUS_BAR
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
Definition: window_type.h:57
GE_WM
@ GE_WM
A male of Caucasian origin (white)
Definition: company_manager_face.h:23
SubtractMoneyFromCompany
void SubtractMoneyFromCompany(const CommandCost &cost)
Subtract money from the _current_company, if the company is valid.
Definition: company_cmd.cpp:247
CloseConstructionWindows
void CloseConstructionWindows()
Close all windows that are used for construction of vehicle etc.
Definition: window.cpp:3347
AI::Stop
static void Stop(CompanyID company)
Stop a company to be controlled by an AI.
Definition: ai_core.cpp:104
CCA_NEW
@ CCA_NEW
Create a new company.
Definition: company_type.h:68
WC_FINANCES
@ WC_FINANCES
Finances of a company; Window numbers:
Definition: window_type.h:515
network_admin.h
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:241
OnTick_Companies
void OnTick_Companies()
Called every tick for updating some company info.
Definition: company_cmd.cpp:712
WN_NETWORK_STATUS_WINDOW_JOIN
@ WN_NETWORK_STATUS_WINDOW_JOIN
Network join status.
Definition: window_type.h:32
pool_func.hpp
ScriptInfo::name
const char * name
Full name of the script.
Definition: script_info.hpp:156
GenerateCompanyColour
static Colours GenerateCompanyColour()
Generate a company colour.
Definition: company_cmd.cpp:432
WC_ERRMSG
@ WC_ERRMSG
Error message; Window numbers:
Definition: window_type.h:103
WC_OPERATING_PROFIT
@ WC_OPERATING_PROFIT
Operating profit graph; Window numbers:
Definition: window_type.h:527
story_base.h
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
Company
Definition: company_base.h:117
ChangeOwnershipOfCompanyItems
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
Definition: economy.cpp:299
Town::name
std::string name
Custom town name. If empty, the town was not renamed and uses the generated name.
Definition: town.h:59
WC_MAIN_TOOLBAR
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
Definition: window_type.h:51
CompanyProperties::old_economy
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
Definition: company_base.h:100
CompanyProperties::bankrupt_timeout
int16 bankrupt_timeout
If bigger than 0, amount of time to wait for an answer on an offer to buy this company.
Definition: company_base.h:84
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:402
EXPENSES_ROADVEH_REVENUE
@ EXPENSES_ROADVEH_REVENUE
Revenue from road vehicles.
Definition: economy_type.h:166
ROADTYPE_BEGIN
@ ROADTYPE_BEGIN
Used for iterations.
Definition: road_type.h:23
NT_COMPANY_INFO
@ NT_COMPANY_INFO
Company info (new companies, bankruptcy messages)
Definition: news_type.h:26
WC_SMALLMAP
@ WC_SMALLMAP
Small map; Window numbers:
Definition: window_type.h:97
_next_competitor_start
uint _next_competitor_start
the number of ticks before the next AI is started
Definition: company_cmd.cpp:50
UpdateLandscapingLimits
void UpdateLandscapingLimits()
Update the landscaping limits per company.
Definition: company_cmd.cpp:271
EXPENSES_AIRCRAFT_REVENUE
@ EXPENSES_AIRCRAFT_REVENUE
Revenue from aircraft.
Definition: economy_type.h:167
network_func.h
DAY_TICKS
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
Definition: date_type.h:28
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:24
EXPENSES_SHIP_RUN
@ EXPENSES_SHIP_RUN
Running costs ships.
Definition: economy_type.h:163
EXPENSES_LOAN_INTEREST
@ EXPENSES_LOAN_INTEREST
Interest payments over the loan.
Definition: economy_type.h:169
CompanyRemoveReason
CompanyRemoveReason
The reason why the company was removed.
Definition: company_type.h:56
OWNER_TOWN
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
Definition: company_type.h:24
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:297
UpdateObjectColours
void UpdateObjectColours(const Company *c)
Updates the colour of the object whenever a company changes.
Definition: object_cmd.cpp:179
RandomCompanyManagerFaceBits
static void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, bool interactive=true)
Make a random new face.
Definition: company_manager_face.h:206
ResetCompanyLivery
void ResetCompanyLivery(Company *c)
Reset the livery schemes to the company's primary colour.
Definition: company_cmd.cpp:519
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:604
CmdRenameCompany
CommandCost CmdRenameCompany(DoCommandFlag flags, const std::string &text)
Change the name of the company.
Definition: company_cmd.cpp:1059
CompanyProperties::name_1
StringID name_1
Name of the company if the user did not change it.
Definition: company_base.h:58
EXPENSES_SHIP_REVENUE
@ EXPENSES_SHIP_REVENUE
Revenue from ships.
Definition: economy_type.h:168
NetworkSettings::max_companies
uint8 max_companies
maximum amount of companies
Definition: settings_type.h:300
news_func.h
CmdRenamePresident
CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
Change the name of the president.
Definition: company_cmd.cpp:1102
Livery::colour2
byte colour2
Second colour, for vehicles with 2CC support.
Definition: livery.h:81
Livery::colour1
byte colour1
First colour, for all vehicles.
Definition: livery.h:80
backup_type.hpp