OpenTTD Source  1.11.0-beta2
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 "cmd_helper.h"
18 #include "command_func.h"
19 #include "network/network.h"
20 #include "network/network_func.h"
21 #include "network/network_base.h"
22 #include "network/network_admin.h"
23 #include "ai/ai.hpp"
24 #include "company_manager_face.h"
25 #include "window_func.h"
26 #include "strings_func.h"
27 #include "date_func.h"
28 #include "sound_func.h"
29 #include "rail.h"
30 #include "core/pool_func.hpp"
31 #include "settings_func.h"
32 #include "vehicle_base.h"
33 #include "vehicle_func.h"
34 #include "smallmap_gui.h"
35 #include "game/game.hpp"
36 #include "goal_base.h"
37 #include "story_base.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 = _settings_game.construction.terraform_frame_burst << 16;
67  this->clear_limit = _settings_game.construction.clear_frame_burst << 16;
68  this->tree_limit = _settings_game.construction.tree_frame_burst << 16;
69 
70  for (uint j = 0; j < 4; j++) this->share_owners[j] = COMPANY_SPECTATOR;
72 }
73 
76 {
77  if (CleaningPool()) return;
78 
80 }
81 
86 void Company::PostDestructor(size_t index)
87 {
92  /* If the currently shown error message has this company in it, then close it. */
94 }
95 
102 void SetLocalCompany(CompanyID new_company)
103 {
104  /* company could also be COMPANY_SPECTATOR or OWNER_NONE */
105  assert(Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
106 
107  /* If actually changing to another company, several windows need closing */
108  bool switching_company = _local_company != new_company;
109 
110  /* Delete the chat window, if you were team chatting. */
112 
113  assert(IsLocalCompany());
114 
115  _current_company = _local_company = new_company;
116 
117  /* Delete any construction windows... */
118  if (switching_company) DeleteConstructionWindows();
119 
120  /* ... and redraw the whole screen. */
123 }
124 
131 {
132  if (!Company::IsValidID(company)) return (TextColour)_colour_gradient[COLOUR_WHITE][4] | TC_IS_PALETTE_COLOUR;
134 }
135 
142 void DrawCompanyIcon(CompanyID c, int x, int y)
143 {
144  DrawSprite(SPR_COMPANY_ICON, COMPANY_SPRITE_COLOUR(c), x, y);
145 }
146 
154 {
155  if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_GEN_ETHN, GE_WM)) return false;
156 
158  bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0;
159  bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
160  bool has_glasses = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
161 
162  if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_EYE_COLOUR, ge)) return false;
163  for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
164  switch (cmfv) {
165  case CMFV_MOUSTACHE: if (!has_moustache) continue; break;
166  case CMFV_LIPS:
167  case CMFV_NOSE: if (has_moustache) continue; break;
168  case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
169  case CMFV_GLASSES: if (!has_glasses) continue; break;
170  default: break;
171  }
172  if (!AreCompanyManagerFaceBitsValid(cmf, cmfv, ge)) return false;
173  }
174 
175  return true;
176 }
177 
182 void InvalidateCompanyWindows(const Company *company)
183 {
184  CompanyID cid = company->index;
185 
188 }
189 
196 {
197  if (cost.GetCost() > 0) {
199  if (c != nullptr && cost.GetCost() > c->money) {
200  SetDParam(0, cost.GetCost());
201  cost.MakeError(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY);
202  return false;
203  }
204  }
205  return true;
206 }
207 
213 static void SubtractMoneyFromAnyCompany(Company *c, const CommandCost &cost)
214 {
215  if (cost.GetCost() == 0) return;
216  assert(cost.GetExpensesType() != INVALID_EXPENSES);
217 
218  c->money -= cost.GetCost();
219  c->yearly_expenses[0][cost.GetExpensesType()] += cost.GetCost();
220 
221  if (HasBit(1 << EXPENSES_TRAIN_INC |
222  1 << EXPENSES_ROADVEH_INC |
223  1 << EXPENSES_AIRCRAFT_INC |
224  1 << EXPENSES_SHIP_INC, cost.GetExpensesType())) {
225  c->cur_economy.income -= cost.GetCost();
226  } else if (HasBit(1 << EXPENSES_TRAIN_RUN |
227  1 << EXPENSES_ROADVEH_RUN |
228  1 << EXPENSES_AIRCRAFT_RUN |
229  1 << EXPENSES_SHIP_RUN |
230  1 << EXPENSES_PROPERTY |
231  1 << EXPENSES_LOAN_INT, cost.GetExpensesType())) {
232  c->cur_economy.expenses -= cost.GetCost();
233  }
234 
236 }
237 
243 {
245  if (c != nullptr) SubtractMoneyFromAnyCompany(c, cost);
246 }
247 
254 {
255  Company *c = Company::Get(company);
256  byte m = c->money_fraction;
257  Money cost = cst.GetCost();
258 
259  c->money_fraction = m - (byte)cost;
260  cost >>= 8;
261  if (c->money_fraction > m) cost++;
262  if (cost != 0) SubtractMoneyFromAnyCompany(c, CommandCost(cst.GetExpensesType(), cost));
263 }
264 
267 {
268  for (Company *c : Company::Iterate()) {
269  c->terraform_limit = std::min<uint32>(c->terraform_limit + _settings_game.construction.terraform_per_64k_frames, _settings_game.construction.terraform_frame_burst << 16);
270  c->clear_limit = std::min<uint32>(c->clear_limit + _settings_game.construction.clear_per_64k_frames, _settings_game.construction.clear_frame_burst << 16);
271  c->tree_limit = std::min<uint32>(c->tree_limit + _settings_game.construction.tree_per_64k_frames, _settings_game.construction.tree_frame_burst << 16);
272  }
273 }
274 
281 void GetNameOfOwner(Owner owner, TileIndex tile)
282 {
283  SetDParam(2, owner);
284 
285  if (owner != OWNER_TOWN) {
286  if (!Company::IsValidID(owner)) {
287  SetDParam(0, STR_COMPANY_SOMEONE);
288  } else {
289  SetDParam(0, STR_COMPANY_NAME);
290  SetDParam(1, owner);
291  }
292  } else {
293  assert(tile != 0);
294  const Town *t = ClosestTownFromTile(tile, UINT_MAX);
295 
296  SetDParam(0, STR_TOWN_NAME);
297  SetDParam(1, t->index);
298  }
299 }
300 
301 
311 {
312  assert(owner < OWNER_END);
313  assert(owner != OWNER_TOWN || tile != 0);
314 
315  if (owner == _current_company) return CommandCost();
316 
317  GetNameOfOwner(owner, tile);
318  return_cmd_error(STR_ERROR_OWNED_BY);
319 }
320 
329 {
330  Owner owner = GetTileOwner(tile);
331 
332  assert(owner < OWNER_END);
333 
334  if (owner == _current_company) return CommandCost();
335 
336  /* no need to get the name of the owner unless we're the local company (saves some time) */
337  if (IsLocalCompany()) GetNameOfOwner(owner, tile);
338  return_cmd_error(STR_ERROR_OWNED_BY);
339 }
340 
346 {
347  /* Reserve space for extra unicode character. We need to do this to be able
348  * to detect too long company name. */
349  char buffer[(MAX_LENGTH_COMPANY_NAME_CHARS + 1) * MAX_CHAR_LENGTH];
350 
351  if (c->name_1 != STR_SV_UNNAMED) return;
352  if (c->last_build_coordinate == 0) return;
353 
355 
356  StringID str;
357  uint32 strp;
358  if (t->name.empty() && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) {
359  str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_COMPANY_NAME_START;
360  strp = t->townnameparts;
361 
362 verify_name:;
363  /* No companies must have this name already */
364  for (const Company *cc : Company::Iterate()) {
365  if (cc->name_1 == str && cc->name_2 == strp) goto bad_town_name;
366  }
367 
368  GetString(buffer, str, lastof(buffer));
369  if (Utf8StringLength(buffer) >= MAX_LENGTH_COMPANY_NAME_CHARS) goto bad_town_name;
370 
371 set_name:;
372  c->name_1 = str;
373  c->name_2 = strp;
374 
376 
377  if (c->is_ai) {
378  CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
379  cni->FillData(c);
380  SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
381  SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
382  SetDParamStr(2, cni->company_name);
383  SetDParam(3, t->index);
384  AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NT_COMPANY_INFO, NF_COMPANY, NR_TILE, c->last_build_coordinate, NR_NONE, UINT32_MAX, cni);
385  }
386  return;
387  }
388 bad_town_name:;
389 
390  if (c->president_name_1 == SPECSTR_PRESIDENT_NAME) {
391  str = SPECSTR_ANDCO_NAME;
392  strp = c->president_name_2;
393  goto set_name;
394  } else {
395  str = SPECSTR_ANDCO_NAME;
396  strp = Random();
397  goto verify_name;
398  }
399 }
400 
402 static const byte _colour_sort[COLOUR_END] = {2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 1, 1, 1};
404 static const Colours _similar_colour[COLOUR_END][2] = {
405  { COLOUR_BLUE, COLOUR_LIGHT_BLUE }, // COLOUR_DARK_BLUE
406  { COLOUR_GREEN, COLOUR_DARK_GREEN }, // COLOUR_PALE_GREEN
407  { INVALID_COLOUR, INVALID_COLOUR }, // COLOUR_PINK
408  { COLOUR_ORANGE, INVALID_COLOUR }, // COLOUR_YELLOW
409  { INVALID_COLOUR, INVALID_COLOUR }, // COLOUR_RED
410  { COLOUR_DARK_BLUE, COLOUR_BLUE }, // COLOUR_LIGHT_BLUE
411  { COLOUR_PALE_GREEN, COLOUR_DARK_GREEN }, // COLOUR_GREEN
412  { COLOUR_PALE_GREEN, COLOUR_GREEN }, // COLOUR_DARK_GREEN
413  { COLOUR_DARK_BLUE, COLOUR_LIGHT_BLUE }, // COLOUR_BLUE
414  { COLOUR_BROWN, COLOUR_ORANGE }, // COLOUR_CREAM
415  { COLOUR_PURPLE, INVALID_COLOUR }, // COLOUR_MAUVE
416  { COLOUR_MAUVE, INVALID_COLOUR }, // COLOUR_PURPLE
417  { COLOUR_YELLOW, COLOUR_CREAM }, // COLOUR_ORANGE
418  { COLOUR_CREAM, INVALID_COLOUR }, // COLOUR_BROWN
419  { COLOUR_WHITE, INVALID_COLOUR }, // COLOUR_GREY
420  { COLOUR_GREY, INVALID_COLOUR }, // COLOUR_WHITE
421 };
422 
427 static Colours GenerateCompanyColour()
428 {
429  Colours colours[COLOUR_END];
430 
431  /* Initialize array */
432  for (uint i = 0; i < COLOUR_END; i++) colours[i] = (Colours)i;
433 
434  /* And randomize it */
435  for (uint i = 0; i < 100; i++) {
436  uint r = Random();
437  Swap(colours[GB(r, 0, 4)], colours[GB(r, 4, 4)]);
438  }
439 
440  /* Bubble sort it according to the values in table 1 */
441  for (uint i = 0; i < COLOUR_END; i++) {
442  for (uint j = 1; j < COLOUR_END; j++) {
443  if (_colour_sort[colours[j - 1]] < _colour_sort[colours[j]]) {
444  Swap(colours[j - 1], colours[j]);
445  }
446  }
447  }
448 
449  /* Move the colours that look similar to each company's colour to the side */
450  for (const Company *c : Company::Iterate()) {
451  Colours pcolour = (Colours)c->colour;
452 
453  for (uint i = 0; i < COLOUR_END; i++) {
454  if (colours[i] == pcolour) {
455  colours[i] = INVALID_COLOUR;
456  break;
457  }
458  }
459 
460  for (uint j = 0; j < 2; j++) {
461  Colours similar = _similar_colour[pcolour][j];
462  if (similar == INVALID_COLOUR) break;
463 
464  for (uint i = 1; i < COLOUR_END; i++) {
465  if (colours[i - 1] == similar) Swap(colours[i - 1], colours[i]);
466  }
467  }
468  }
469 
470  /* Return the first available colour */
471  for (uint i = 0; i < COLOUR_END; i++) {
472  if (colours[i] != INVALID_COLOUR) return colours[i];
473  }
474 
475  NOT_REACHED();
476 }
477 
483 {
484  for (;;) {
485 restart:;
486  c->president_name_2 = Random();
487  c->president_name_1 = SPECSTR_PRESIDENT_NAME;
488 
489  /* Reserve space for extra unicode character. We need to do this to be able
490  * to detect too long president name. */
492  SetDParam(0, c->index);
493  GetString(buffer, STR_PRESIDENT_NAME, lastof(buffer));
494  if (Utf8StringLength(buffer) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) continue;
495 
496  for (const Company *cc : Company::Iterate()) {
497  if (c != cc) {
498  /* Reserve extra space so even overlength president names can be compared. */
499  char buffer2[(MAX_LENGTH_PRESIDENT_NAME_CHARS + 1) * MAX_CHAR_LENGTH];
500  SetDParam(0, cc->index);
501  GetString(buffer2, STR_PRESIDENT_NAME, lastof(buffer2));
502  if (strcmp(buffer2, buffer) == 0) goto restart;
503  }
504  }
505  return;
506  }
507 }
508 
515 {
516  for (LiveryScheme scheme = LS_BEGIN; scheme < LS_END; scheme++) {
517  c->livery[scheme].in_use = 0;
518  c->livery[scheme].colour1 = c->colour;
519  c->livery[scheme].colour2 = c->colour;
520  }
521 
522  for (Group *g : Group::Iterate()) {
523  if (g->owner == c->index) {
524  g->livery.in_use = 0;
525  g->livery.colour1 = c->colour;
526  g->livery.colour2 = c->colour;
527  }
528  }
529 }
530 
539 {
540  if (!Company::CanAllocateItem()) return nullptr;
541 
542  /* we have to generate colour before this company is valid */
543  Colours colour = GenerateCompanyColour();
544 
545  Company *c;
546  if (company == INVALID_COMPANY) {
547  c = new Company(STR_SV_UNNAMED, is_ai);
548  } else {
549  if (Company::IsValidID(company)) return nullptr;
550  c = new (company) Company(STR_SV_UNNAMED, is_ai);
551  }
552 
553  c->colour = colour;
554 
556  _company_colours[c->index] = (Colours)c->colour;
557 
558  c->money = c->current_loan = (std::min<int64>(INITIAL_LOAN, _economy.max_loan) * _economy.inflation_prices >> 16) / 50000 * 50000;
559 
560  c->share_owners[0] = c->share_owners[1] = c->share_owners[2] = c->share_owners[3] = INVALID_OWNER;
561 
565  RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false, false); // create a random company manager face
566 
569 
571 
578 
579  if (is_ai && (!_networking || _network_server)) AI::StartNew(c->index);
580 
581  AI::BroadcastNewEvent(new ScriptEventCompanyNew(c->index), c->index);
582  Game::NewEvent(new ScriptEventCompanyNew(c->index));
583 
584  return c;
585 }
586 
589 {
591 }
592 
594 static bool MaybeStartNewCompany()
595 {
597 
598  /* count number of competitors */
599  uint n = 0;
600  for (const Company *c : Company::Iterate()) {
601  if (c->is_ai) n++;
602  }
603 
605  /* Send a command to all clients to start up a new AI.
606  * Works fine for Multiplayer and Singleplayer */
607  return DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
608  }
609 
610  return false;
611 }
612 
615 {
617 }
618 
626 {
627  const Company *c1 = Company::Get(cbig);
628  const Company *c2 = Company::Get(csmall);
629 
630  /* Do the combined vehicle counts stay within the limits? */
635 }
636 
647 {
648  /* Amount of time out for each company to take over a company;
649  * Timeout is a quarter (3 months of 30 days) divided over the
650  * number of companies. The minimum number of days in a quarter
651  * is 90: 31 in January, 28 in February and 31 in March.
652  * Note that the company going bankrupt can't buy itself. */
653  static const int TAKE_OVER_TIMEOUT = 3 * 30 * DAY_TICKS / (MAX_COMPANIES - 1);
654 
655  assert(c->bankrupt_asked != 0);
656 
657  /* We're currently asking some company to buy 'us' */
658  if (c->bankrupt_timeout != 0) {
660  if (c->bankrupt_timeout > 0) return;
661  c->bankrupt_timeout = 0;
662 
663  return;
664  }
665 
666  /* Did we ask everyone for bankruptcy? If so, bail out. */
667  if (c->bankrupt_asked == MAX_UVALUE(CompanyMask)) return;
668 
669  Company *best = nullptr;
670  int32 best_performance = -1;
671 
672  /* Ask the company with the highest performance history first */
673  for (Company *c2 : Company::Iterate()) {
674  if (c2->bankrupt_asked == 0 && // Don't ask companies going bankrupt themselves
675  !HasBit(c->bankrupt_asked, c2->index) &&
676  best_performance < c2->old_economy[1].performance_history &&
677  MayCompanyTakeOver(c2->index, c->index)) {
678  best_performance = c2->old_economy[1].performance_history;
679  best = c2;
680  }
681  }
682 
683  /* Asked all companies? */
684  if (best_performance == -1) {
685  c->bankrupt_asked = MAX_UVALUE(CompanyMask);
686  return;
687  }
688 
689  SetBit(c->bankrupt_asked, best->index);
690 
691  c->bankrupt_timeout = TAKE_OVER_TIMEOUT;
692  if (best->is_ai) {
693  AI::NewEvent(best->index, new ScriptEventCompanyAskMerger(c->index, ClampToI32(c->bankrupt_value)));
694  } else if (IsInteractiveCompany(best->index)) {
696  }
697 }
698 
701 {
702  if (_game_mode == GM_EDITOR) return;
703 
705  if (c != nullptr) {
706  if (c->name_1 != 0) GenerateCompanyName(c);
708  }
709 
710  if (_next_competitor_start == 0) {
711  /* AI::GetStartNextTime() can return 0. */
713  }
714 
715  if (_game_mode != GM_MENU && AI::CanStartNew() && --_next_competitor_start == 0) {
716  /* Allow multiple AIs to possibly start in the same tick. */
717  do {
718  if (!MaybeStartNewCompany()) break;
719 
720  /* In networking mode, we can only send a command to start but it
721  * didn't execute yet, so we cannot loop. */
722  if (_networking) break;
723  } while (AI::GetStartNextTime() == 0);
724  }
725 
727 }
728 
734 {
735  /* Copy statistics */
736  for (Company *c : Company::Iterate()) {
737  memmove(&c->yearly_expenses[1], &c->yearly_expenses[0], sizeof(c->yearly_expenses) - sizeof(c->yearly_expenses[0]));
738  memset(&c->yearly_expenses[0], 0, sizeof(c->yearly_expenses[0]));
739  SetWindowDirty(WC_FINANCES, c->index);
740  }
741 
747  } else {
749  }
750  }
751 }
752 
759 {
760  SetDParam(0, c->index);
761  GetString(this->company_name, STR_COMPANY_NAME, lastof(this->company_name));
762 
763  if (other == nullptr) {
764  *this->other_company_name = '\0';
765  } else {
766  SetDParam(0, other->index);
767  GetString(this->other_company_name, STR_COMPANY_NAME, lastof(this->other_company_name));
768  c = other;
769  }
770 
771  SetDParam(0, c->index);
772  GetString(this->president_name, STR_PRESIDENT_NAME_MANAGER, lastof(this->president_name));
773 
774  this->colour = c->colour;
775  this->face = c->face;
776 
777 }
778 
783 void CompanyAdminUpdate(const Company *company)
784 {
786 }
787 
794 {
796 }
797 
810 CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
811 {
813  CompanyID company_id = (CompanyID)GB(p1, 16, 8);
814 
815  switch ((CompanyCtrlAction)GB(p1, 0, 16)) {
816  case CCA_NEW: { // Create a new company
817  /* This command is only executed in a multiplayer game */
818  if (!_networking) return CMD_ERROR;
819 
820  /* Has the network client a correct ClientIndex? */
821  if (!(flags & DC_EXEC)) return CommandCost();
822 
823  ClientID client_id = (ClientID)p2;
825 
826  /* Delete multiplayer progress bar */
828 
829  Company *c = DoStartupNewCompany(false);
830 
831  /* A new company could not be created, revert to being a spectator */
832  if (c == nullptr) {
833  /* We check for "ci != nullptr" as a client could have left by
834  * the time we execute this command. */
835  if (_network_server && ci != nullptr) {
838  }
839  break;
840  }
841 
842  /* This is the client (or non-dedicated server) who wants a new company */
843  if (client_id == _network_own_client_id) {
848  }
849 
850  /* Now that we have a new company, broadcast our company settings to
851  * all clients so everything is in sync */
853 
855  }
856 
858  break;
859  }
860 
861  case CCA_NEW_AI: { // Make a new AI company
862  if (company_id != INVALID_COMPANY && company_id >= MAX_COMPANIES) return CMD_ERROR;
863 
864  /* For network games, company deletion is delayed. */
865  if (!_networking && company_id != INVALID_COMPANY && Company::IsValidID(company_id)) return CMD_ERROR;
866 
867  if (!(flags & DC_EXEC)) return CommandCost();
868 
869  /* For network game, just assume deletion happened. */
870  assert(company_id == INVALID_COMPANY || !Company::IsValidID(company_id));
871 
872  Company *c = DoStartupNewCompany(true, company_id);
873  if (c != nullptr) NetworkServerNewCompany(c, nullptr);
874  break;
875  }
876 
877  case CCA_DELETE: { // Delete a company
878  CompanyRemoveReason reason = (CompanyRemoveReason)GB(p1, 24, 8);
879  if (reason >= CRR_END) return CMD_ERROR;
880 
881  /* We can't delete the last existing company in singleplayer mode. */
882  if (!_networking && Company::GetNumItems() == 1) return CMD_ERROR;
883 
884  Company *c = Company::GetIfValid(company_id);
885  if (c == nullptr) return CMD_ERROR;
886 
887  if (!(flags & DC_EXEC)) return CommandCost();
888 
889  /* Delete any open window of the company */
891  CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
892  cni->FillData(c);
893 
894  /* Show the bankrupt news */
895  SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
896  SetDParam(1, STR_NEWS_COMPANY_BANKRUPT_DESCRIPTION);
897  SetDParamStr(2, cni->company_name);
898  AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
899 
900  /* Remove the company */
902  if (c->is_ai) AI::Stop(c->index);
903 
904  CompanyID c_index = c->index;
905  delete c;
906  AI::BroadcastNewEvent(new ScriptEventCompanyBankrupt(c_index));
907  Game::NewEvent(new ScriptEventCompanyBankrupt(c_index));
908  CompanyAdminRemove(c_index, (CompanyRemoveReason)reason);
909 
911  break;
912  }
913 
914  default: return CMD_ERROR;
915  }
916 
920 
921  return CommandCost();
922 }
923 
933 CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
934 {
936 
937  if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
938 
939  if (flags & DC_EXEC) {
940  Company::Get(_current_company)->face = cmf;
942  }
943  return CommandCost();
944 }
945 
957 CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
958 {
959  Colours colour = Extract<Colours, 0, 8>(p2);
960  LiveryScheme scheme = Extract<LiveryScheme, 0, 8>(p1);
961  bool second = HasBit(p1, 8);
962 
963  if (scheme >= LS_END || (colour >= COLOUR_END && colour != INVALID_COLOUR)) return CMD_ERROR;
964 
965  /* Default scheme can't be reset to invalid. */
966  if (scheme == LS_DEFAULT && colour == INVALID_COLOUR) return CMD_ERROR;
967 
969 
970  /* Ensure no two companies have the same primary colour */
971  if (scheme == LS_DEFAULT && !second) {
972  for (const Company *cc : Company::Iterate()) {
973  if (cc != c && cc->colour == colour) return CMD_ERROR;
974  }
975  }
976 
977  if (flags & DC_EXEC) {
978  if (!second) {
979  if (scheme != LS_DEFAULT) SB(c->livery[scheme].in_use, 0, 1, colour != INVALID_COLOUR);
980  if (colour == INVALID_COLOUR) colour = (Colours)c->livery[LS_DEFAULT].colour1;
981  c->livery[scheme].colour1 = colour;
982 
983  /* If setting the first colour of the default scheme, adjust the
984  * original and cached company colours too. */
985  if (scheme == LS_DEFAULT) {
986  for (int i = 1; i < LS_END; i++) {
987  if (!HasBit(c->livery[i].in_use, 0)) c->livery[i].colour1 = colour;
988  }
990  c->colour = colour;
992  }
993  } else {
994  if (scheme != LS_DEFAULT) SB(c->livery[scheme].in_use, 1, 1, colour != INVALID_COLOUR);
995  if (colour == INVALID_COLOUR) colour = (Colours)c->livery[LS_DEFAULT].colour2;
996  c->livery[scheme].colour2 = colour;
997 
998  if (scheme == LS_DEFAULT) {
999  for (int i = 1; i < LS_END; i++) {
1000  if (!HasBit(c->livery[i].in_use, 1)) c->livery[i].colour2 = colour;
1001  }
1002  }
1003  }
1004 
1005  if (c->livery[scheme].in_use != 0) {
1006  /* If enabling a scheme, set the default scheme to be in use too */
1007  c->livery[LS_DEFAULT].in_use = 1;
1008  } else {
1009  /* Else loop through all schemes to see if any are left enabled.
1010  * If not, disable the default scheme too. */
1011  c->livery[LS_DEFAULT].in_use = 0;
1012  for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
1013  if (c->livery[scheme].in_use != 0) {
1014  c->livery[LS_DEFAULT].in_use = 1;
1015  break;
1016  }
1017  }
1018  }
1019 
1020  ResetVehicleColourMap();
1022 
1023  /* All graph related to companies use the company colour. */
1030  /* The smallmap owner view also stores the company colours. */
1031  BuildOwnerLegend();
1033 
1034  /* Company colour data is indirectly cached. */
1035  for (Vehicle *v : Vehicle::Iterate()) {
1036  if (v->owner == _current_company) v->InvalidateNewGRFCache();
1037  }
1038 
1039  extern void UpdateObjectColours(const Company *c);
1041  }
1042  return CommandCost();
1043 }
1044 
1050 static bool IsUniqueCompanyName(const char *name)
1051 {
1052  for (const Company *c : Company::Iterate()) {
1053  if (!c->name.empty() && c->name == name) return false;
1054  }
1055 
1056  return true;
1057 }
1058 
1068 CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
1069 {
1070  bool reset = StrEmpty(text);
1071 
1072  if (!reset) {
1074  if (!IsUniqueCompanyName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
1075  }
1076 
1077  if (flags & DC_EXEC) {
1079  if (reset) {
1080  c->name.clear();
1081  } else {
1082  c->name = text;
1083  }
1085  CompanyAdminUpdate(c);
1086  }
1087 
1088  return CommandCost();
1089 }
1090 
1096 static bool IsUniquePresidentName(const char *name)
1097 {
1098  for (const Company *c : Company::Iterate()) {
1099  if (!c->president_name.empty() && c->president_name == name) return false;
1100  }
1101 
1102  return true;
1103 }
1104 
1114 CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
1115 {
1116  bool reset = StrEmpty(text);
1117 
1118  if (!reset) {
1120  if (!IsUniquePresidentName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
1121  }
1122 
1123  if (flags & DC_EXEC) {
1125 
1126  if (reset) {
1127  c->president_name.clear();
1128  } else {
1129  c->president_name = text;
1130 
1131  if (c->name_1 == STR_SV_UNNAMED && c->name.empty()) {
1132  char buf[80];
1133 
1134  seprintf(buf, lastof(buf), "%s Transport", text);
1135  DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY, buf);
1136  }
1137  }
1138 
1140  CompanyAdminUpdate(c);
1141  }
1142 
1143  return CommandCost();
1144 }
1145 
1153 {
1154  const VehicleDefaultSettings *vds = (c == nullptr) ? &_settings_client.company.vehicle : &c->settings.vehicle;
1155  switch (type) {
1156  default: NOT_REACHED();
1157  case VEH_TRAIN: return vds->servint_trains;
1158  case VEH_ROAD: return vds->servint_roadveh;
1159  case VEH_AIRCRAFT: return vds->servint_aircraft;
1160  case VEH_SHIP: return vds->servint_ships;
1161  }
1162 }
1163 
1169 {
1170  uint32 total = 0;
1171  for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
1172  if (RoadTypeIsRoad(rt)) total += this->road[rt];
1173  }
1174  return total;
1175 }
1176 
1182 {
1183  uint32 total = 0;
1184  for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
1185  if (RoadTypeIsTram(rt)) total += this->road[rt];
1186  }
1187  return total;
1188 }
1189 
1202 CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
1203 {
1205 
1207  CommandCost amount(EXPENSES_OTHER, std::min<Money>(p1, 20000000LL));
1208  CompanyID dest_company = (CompanyID)p2;
1209 
1210  /* You can only transfer funds that is in excess of your loan */
1211  if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() < 0) return_cmd_error(STR_ERROR_INSUFFICIENT_FUNDS);
1212  if (!Company::IsValidID(dest_company)) return CMD_ERROR;
1213 
1214  if (flags & DC_EXEC) {
1215  /* Add money to company */
1216  Backup<CompanyID> cur_company(_current_company, dest_company, FILE_LINE);
1218  cur_company.Restore();
1219 
1220  if (_networking) {
1221  char dest_company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
1222  SetDParam(0, dest_company);
1223  GetString(dest_company_name, STR_COMPANY_NAME, lastof(dest_company_name));
1224 
1225  char from_company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
1227  GetString(from_company_name, STR_COMPANY_NAME, lastof(from_company_name));
1228 
1229  NetworkTextMessage(NETWORK_ACTION_GIVE_MONEY, GetDrawStringCompanyColour(_current_company), false, from_company_name, dest_company_name, amount.GetCost());
1230  }
1231  }
1232 
1233  /* Subtract money from local-company */
1234  return amount;
1235 }
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:483
game.hpp
HandleBankruptcyTakeover
static void HandleBankruptcyTakeover(Company *c)
Handle the bankruptcy take over of a company.
Definition: company_cmd.cpp:646
BuildOwnerLegend
void BuildOwnerLegend()
Completes the array for the owned property legend.
Definition: smallmap_gui.cpp:325
CompanyProperties::is_ai
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Definition: company_base.h:94
VehicleSettings::max_aircraft
UnitID max_aircraft
max planes in game per company
Definition: settings_type.h:460
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
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:3321
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:141
EXPENSES_ROADVEH_RUN
@ EXPENSES_ROADVEH_RUN
Running costs road vehicles.
Definition: economy_type.h:161
INVALID_EXPENSES
@ INVALID_EXPENSES
Invalid expense type.
Definition: economy_type.h:172
DoCommand
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:450
CommandCost::MakeError
void MakeError(StringID message)
Makes this CommandCost behave like an error command.
Definition: command_type.h:100
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
CompanyNewsInformation::colour
byte colour
The colour related to the company.
Definition: news_type.h:154
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3220
Company::group_all
GroupStatistics group_all[VEH_COMPANY_END]
NOSAVE: Statistics for the ALL_GROUP group.
Definition: company_base.h:123
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:783
command_func.h
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:340
CMD_ERROR
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Definition: command_func.h:23
statusbar_widget.h
Company::avail_railtypes
RailTypes avail_railtypes
Rail types available to this company.
Definition: company_base.h:115
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:3595
smallmap_gui.h
GenerateCompanyName
static void GenerateCompanyName(Company *c)
Generate the name of a company from the last build coordinate.
Definition: company_cmd.cpp:345
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:51
SetDefaultCompanySettings
void SetDefaultCompanySettings(CompanyID cid)
Set the company settings for a new company to their default values.
Definition: settings.cpp:2026
Company::avail_roadtypes
RoadTypes avail_roadtypes
Road types available to this company.
Definition: company_base.h:116
_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:404
company_base.h
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
EXPENSES_OTHER
@ EXPENSES_OTHER
Other expenses.
Definition: economy_type.h:170
NetworkClientInfo::client_playas
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition: network_base.h:27
CompanyProperties::inaugurated_year
Year inaugurated_year
Year of starting the company.
Definition: company_base.h:79
company_gui.h
CmdGiveMoney
CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Transfer funds (money) from one company to another.
Definition: company_cmd.cpp:1202
_network_server
bool _network_server
network-server is active
Definition: network.cpp:53
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:325
WC_CLIENT_LIST
@ WC_CLIENT_LIST
Client list; Window numbers:
Definition: window_type.h:472
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:227
CmdCompanyCtrl
CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Control the companies: add, delete, etc.
Definition: company_cmd.cpp:810
CompanyProperties::money_fraction
byte money_fraction
Fraction of money of the company, too small to represent in money.
Definition: company_base.h:67
NetworkUpdateClientInfo
void NetworkUpdateClientInfo(ClientID client_id)
Send updated client info of a particular client.
Definition: network_server.cpp:1601
Company::PostDestructor
static void PostDestructor(size_t index)
Invalidating some stuff after removing item from the pool.
Definition: company_cmd.cpp:86
AI::GetStartNextTime
static int GetStartNextTime()
Get the number of days before the next AI should start.
Definition: ai_core.cpp:307
WC_PERFORMANCE_HISTORY
@ WC_PERFORMANCE_HISTORY
Performance history graph; Window numbers:
Definition: window_type.h:540
WID_S_RIGHT
@ WID_S_RIGHT
Right part; bank balance.
Definition: statusbar_widget.h:17
WC_CLIENT_LIST_POPUP
@ WC_CLIENT_LIST_POPUP
Popup for the client list; Window numbers:
Definition: window_type.h:478
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition: settings_type.h:549
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
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:544
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:102
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:250
vehicle_base.h
EXPENSES_AIRCRAFT_RUN
@ EXPENSES_AIRCRAFT_RUN
Running costs aircraft.
Definition: economy_type.h:162
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
CompanyProperties::name
std::string name
Name of the company if the user changed it.
Definition: company_base.h:58
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:83
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
GetCompanyRoadTypes
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Definition: road.cpp:188
town.h
SoundSettings::new_year
bool new_year
Play sound on new year, summarising the performance during the last year.
Definition: settings_type.h:186
CompanyProperties::last_build_coordinate
TileIndex last_build_coordinate
Coordinate of the last build thing by this company.
Definition: company_base.h:75
CompanyProperties::face
CompanyManagerFace face
Face description of the president.
Definition: company_base.h:64
DeleteCompanyWindows
void DeleteCompanyWindows(CompanyID company)
Delete all windows of a company.
Definition: window.cpp:1200
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:222
VehicleDefaultSettings::servint_ships
uint16 servint_ships
service interval for ships
Definition: settings_type.h:535
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
DC_EXEC
@ DC_EXEC
execute the given command
Definition: command_type.h:348
WC_COMPANY_LEAGUE
@ WC_COMPANY_LEAGUE
Company league window; Window numbers:
Definition: window_type.h:552
_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:52
IsLocalCompany
static bool IsLocalCompany()
Is the current company the local company?
Definition: company_func.h:43
CompanyNewsInformation::company_name
char company_name[64]
The name of the company.
Definition: news_type.h:149
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:199
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:346
CompanyProperties::current_loan
Money current_loan
Amount of money borrowed from the bank.
Definition: company_base.h:68
_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:614
ClearEnginesHiddenFlagOfCompany
void ClearEnginesHiddenFlagOfCompany(CompanyID cid)
Clear the 'hidden' flag for all engines of a new company.
Definition: engine.cpp:875
MayCompanyTakeOver
bool MayCompanyTakeOver(CompanyID cbig, CompanyID csmall)
May company cbig buy company csmall?
Definition: company_cmd.cpp:625
CompanyInfrastructure::GetRoadTotal
uint32 GetRoadTotal() const
Get total sum of all owned road bits.
Definition: company_cmd.cpp:1168
CompanyProperties::name_2
uint32 name_2
Parameter of name_1.
Definition: company_base.h:56
GroupStatistics::num_vehicle
uint16 num_vehicle
Number of vehicles.
Definition: group.h:26
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
ai.hpp
GENDER_FEMALE
@ GENDER_FEMALE
This bit set means a female, otherwise male.
Definition: company_manager_face.h:20
IsInsideMM
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:204
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:534
Group
Group data.
Definition: group.h:66
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:3234
WC_GRAPH_LEGEND
@ WC_GRAPH_LEGEND
Legend for graphs; Window numbers:
Definition: window_type.h:510
NetworkClientInfo::GetByClientID
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition: network.cpp:119
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:334
ShowCompanyFinances
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
Definition: company_gui.cpp:480
_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:324
CompanyInfrastructure::GetTramTotal
uint32 GetTramTotal() const
Get total sum of all owned tram bits.
Definition: company_cmd.cpp:1181
CheckOwnership
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
Definition: company_cmd.cpp:310
return_cmd_error
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
Definition: command_func.h:33
StartupCompanies
void StartupCompanies()
Start the next competitor now.
Definition: company_cmd.cpp:588
AI::NewEvent
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Definition: ai_core.cpp:234
CompanyProperties::colour
byte colour
Company colour.
Definition: company_base.h:70
CommandCost
Common return value for all commands.
Definition: command_type.h:23
CompanyEconomyEntry::performance_history
int32 performance_history
Company score (scale 0-1000)
Definition: company_base.h:26
cmd_helper.h
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
CCA_NEW_AI
@ CCA_NEW_AI
Create a new AI company.
Definition: company_type.h:66
CompanyProperties::num_valid_stat_ent
byte num_valid_stat_ent
Number of valid statistical entries in old_economy.
Definition: company_base.h:99
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:570
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
CompanyNewsInformation::president_name
char president_name[64]
The name of the president.
Definition: news_type.h:150
CommandCost::GetExpensesType
ExpensesType GetExpensesType() const
The expense type of the cost.
Definition: command_type.h:91
VehicleSettings::max_ships
UnitID max_ships
max ships in game per company
Definition: settings_type.h:461
SubtractMoneyFromCompanyFract
void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cst)
Subtract money from a company, including the money fraction.
Definition: company_cmd.cpp:253
ConstructionSettings::tree_frame_burst
uint16 tree_frame_burst
how many trees may, over a short period, be planted?
Definition: settings_type.h:328
GeneratePresidentName
static void GeneratePresidentName(Company *c)
Generate a random president name of a company.
Definition: company_cmd.cpp:482
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
NetworkSettings::default_company_pass
char default_company_pass[NETWORK_PASSWORD_LENGTH]
default password for new companies in encrypted form
Definition: settings_type.h:261
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:39
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:66
EXPENSES_SHIP_INC
@ EXPENSES_SHIP_INC
Income from ships.
Definition: economy_type.h:168
InvalidateCompanyWindows
void InvalidateCompanyWindows(const Company *company)
Refresh all windows owned by a company.
Definition: company_cmd.cpp:182
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:323
GetNameOfOwner
void GetNameOfOwner(Owner owner, TileIndex tile)
Set the right DParams to get the name of an owner.
Definition: company_cmd.cpp:281
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:80
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:273
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
CCA_NEW
@ CCA_NEW
Create a new company.
Definition: company_type.h:65
Game::NewEvent
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition: game_core.cpp:141
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition: settings_type.h:559
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:2039
AI::BroadcastNewEvent
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company=MAX_COMPANIES)
Broadcast a new event to all active AIs.
Definition: ai_core.cpp:259
safeguards.h
DeleteConstructionWindows
void DeleteConstructionWindows()
Delete all windows that are used for construction of vehicle etc.
Definition: window.cpp:3430
CommandCost::GetCost
Money GetCost() const
The costs as made up to this moment.
Definition: command_type.h:82
IsInteractiveCompany
static bool IsInteractiveCompany(CompanyID company)
Is the user representing company?
Definition: company_func.h:53
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:60
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:52
rail.h
CompanyNewsInformation::FillData
void FillData(const struct Company *c, const struct Company *other=nullptr)
Fill the CompanyNewsInformation struct with the required data.
Definition: company_cmd.cpp:758
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:978
CompanyProperties::president_name
std::string president_name
Name of the president if the user changed it.
Definition: company_base.h:62
IsValidCompanyManagerFace
static bool IsValidCompanyManagerFace(CompanyManagerFace cmf)
Checks whether a company manager's face is a valid encoding.
Definition: company_cmd.cpp:153
VehicleDefaultSettings
Default settings for vehicles.
Definition: settings_type.h:530
CompanyInfrastructure::road
uint32 road[ROADTYPE_END]
Count of company owned track bits for each road type.
Definition: company_base.h:31
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:96
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:327
AdminCompanyRemoveReason
AdminCompanyRemoveReason
Reasons for removing a company - communicated to admins.
Definition: tcp_admin.h:101
CmdSetCompanyManagerFace
CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Change the company manager's face.
Definition: company_cmd.cpp:933
CompanyCtrlAction
CompanyCtrlAction
The action to do with CMD_COMPANY_CTRL.
Definition: company_type.h:64
CompanyProperties::share_owners
Owner share_owners[4]
Owners of the 4 shares of the company. INVALID_OWNER if nobody has bought them yet.
Definition: company_base.h:77
ROADTYPE_BEGIN
@ ROADTYPE_BEGIN
Used for iterations.
Definition: road_type.h:23
date_func.h
WC_INCOME_GRAPH
@ WC_INCOME_GRAPH
Income graph; Window numbers:
Definition: window_type.h:522
stdafx.h
NR_NONE
@ NR_NONE
Empty reference.
Definition: news_type.h:50
CmdSetCompanyColour
CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Change the company's company-colour.
Definition: company_cmd.cpp:957
EXPENSES_AIRCRAFT_INC
@ EXPENSES_AIRCRAFT_INC
Income from aircraft.
Definition: economy_type.h:167
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
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:910
EXPENSES_LOAN_INT
@ EXPENSES_LOAN_INT
Interest payments over the loan.
Definition: economy_type.h:169
CompaniesYearlyLoop
void CompaniesYearlyLoop()
A year has passed, update the economic data of all companies, and perhaps show the financial overview...
Definition: company_cmd.cpp:733
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:195
CompanyAdminRemove
void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
Called whenever a company is removed in order to notify admins.
Definition: company_cmd.cpp:793
CompanyProperties::bankrupt_asked
CompanyMask bankrupt_asked
which companies were asked about buying it?
Definition: company_base.h:82
NetworkClientInfo::client_id
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition: network_base.h:24
CompanyProperties::president_name_2
uint32 president_name_2
Parameter of president_name_1.
Definition: company_base.h:61
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:142
_network_own_client_id
ClientID _network_own_client_id
Our client identifier.
Definition: network.cpp:59
_colour_sort
static const byte _colour_sort[COLOUR_END]
Sorting weights for the company colours.
Definition: company_cmd.cpp:402
NetworkAdminCompanyUpdate
void NetworkAdminCompanyUpdate(const Company *company)
Notify the admin network of company updates.
Definition: network_admin.cpp:894
_company_pool
CompanyPool _company_pool("Company")
Pool of companies.
WC_COMPANY_VALUE
@ WC_COMPANY_VALUE
Company value graph; Window numbers:
Definition: window_type.h:546
ShowBuyCompanyDialog
void ShowBuyCompanyDialog(CompanyID company)
Show the query to buy another company.
Definition: company_gui.cpp:2863
NR_TILE
@ NR_TILE
Reference tile. Scroll to tile when clicking on the news.
Definition: news_type.h:51
CompanyEconomyEntry::expenses
Money expenses
The amount of expenses.
Definition: company_base.h:24
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
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:378
CompanyNewsInformation
Data that needs to be stored for company news messages.
Definition: news_type.h:148
strings_func.h
Pool
Base class for all pools.
Definition: pool_type.hpp:81
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
CompanyProperties::cur_economy
CompanyEconomyEntry cur_economy
Economic data of the company of this quarter.
Definition: company_base.h:97
WC_PERFORMANCE_DETAIL
@ WC_PERFORMANCE_DETAIL
Performance detail window; Window numbers:
Definition: window_type.h:564
VehicleDefaultSettings::servint_trains
uint16 servint_trains
service interval for trains
Definition: settings_type.h:532
VehicleSettings::max_trains
UnitID max_trains
max trains in game per company
Definition: settings_type.h:458
Pool::PoolItem<&_company_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:359
Backup::Restore
void Restore()
Restore the variable.
Definition: backup_type.hpp:112
CMD_RENAME_COMPANY
@ CMD_RENAME_COMPANY
change the company name
Definition: command_type.h:246
MaybeStartNewCompany
static bool MaybeStartNewCompany()
Start a new competitor company if possible.
Definition: company_cmd.cpp:594
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:88
GetDrawStringCompanyColour
TextColour GetDrawStringCompanyColour(CompanyID company)
Get the colour for DrawString-subroutines which matches the colour of the company.
Definition: company_cmd.cpp:130
_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:80
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:1152
NetworkServerNewCompany
void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci)
Perform all the server specific administration of a new company.
Definition: network_server.cpp:2196
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:3339
WC_NETWORK_STATUS_WINDOW
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
Definition: window_type.h:485
Pool::PoolItem<&_company_pool >::CleaningPool
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
Definition: pool_type.hpp:308
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:153
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:534
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:299
CmdRenamePresident
CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Change the name of the president.
Definition: company_cmd.cpp:1114
MAX_UVALUE
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
Definition: stdafx.h:463
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:442
NT_COMPANY_INFO
@ NT_COMPANY_INFO
Company info (new companies, bankruptcy messages)
Definition: news_type.h:25
SubtractMoneyFromAnyCompany
static void SubtractMoneyFromAnyCompany(Company *c, const CommandCost &cost)
Deduct costs of a command from the money of a company.
Definition: company_cmd.cpp:213
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:538
DifficultySettings::max_no_competitors
byte max_no_competitors
the number of competitors (AIs)
Definition: settings_type.h:55
company_func.h
VehicleSettings::max_roadveh
UnitID max_roadveh
max trucks in game per company
Definition: settings_type.h:459
ConstructionSettings::clear_frame_burst
uint16 clear_frame_burst
how many tiles may, over a short period, be cleared?
Definition: settings_type.h:326
CMD_COMPANY_CTRL
@ CMD_COMPANY_CTRL
used in multiplayer to create a new companies etc.
Definition: command_type.h:281
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
CmdRenameCompany
CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Change the name of the company.
Definition: company_cmd.cpp:1068
CompanyEconomyEntry::income
Money income
The amount of income.
Definition: company_base.h:23
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, void *free_data=nullptr)
Add a new newsitem to be shown.
Definition: news_gui.cpp:789
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:60
NetworkChangeCompanyPassword
const char * NetworkChangeCompanyPassword(CompanyID company_id, const char *password)
Change the company password of a given company.
Definition: network.cpp:162
CheckTileOwnership
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
Definition: company_cmd.cpp:328
WC_SEND_NETWORK_MSG
@ WC_SEND_NETWORK_MSG
Chatbox; Window numbers:
Definition: window_type.h:491
Company::~Company
~Company()
Destructor.
Definition: company_cmd.cpp:75
SND_01_BAD_YEAR
@ SND_01_BAD_YEAR
40 == 0x28 New year: performance declined
Definition: sound_type.h:79
window_func.h
IsUniqueCompanyName
static bool IsUniqueCompanyName(const char *name)
Is the given name in use as name of a company?
Definition: company_cmd.cpp:1050
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
CRR_END
@ CRR_END
Sentinel for end.
Definition: company_type.h:60
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1619
ClientSettings::network
NetworkSettings network
settings related to the network
Definition: settings_type.h:568
EXPENSES_TRAIN_RUN
@ EXPENSES_TRAIN_RUN
Running costs trains.
Definition: economy_type.h:160
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:83
VehicleDefaultSettings::servint_roadveh
uint16 servint_roadveh
service interval for road vehicles
Definition: settings_type.h:533
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
LiveryScheme
LiveryScheme
List of different livery schemes.
Definition: livery.h:20
OWNER_END
@ OWNER_END
Last + 1 owner.
Definition: company_type.h:28
CCA_DELETE
@ CCA_DELETE
Delete a company.
Definition: company_type.h:67
ClientSettings::company
CompanySettings company
default values for per-company settings
Definition: settings_type.h:569
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:551
GameSettings::vehicle
VehicleSettings vehicle
options for vehicles
Definition: settings_type.h:558
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:318
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:242
AI::Stop
static void Stop(CompanyID company)
Stop a company to be controlled by an AI.
Definition: ai_core.cpp:102
WC_FINANCES
@ WC_FINANCES
Finances of a company; Window numbers:
Definition: window_type.h:516
network_admin.h
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:215
OnTick_Companies
void OnTick_Companies()
Called every tick for updating some company info.
Definition: company_cmd.cpp:700
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:427
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:528
story_base.h
EXPENSES_ROADVEH_INC
@ EXPENSES_ROADVEH_INC
Income from road vehicles.
Definition: economy_type.h:166
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
Company
Definition: company_base.h:110
ChangeOwnershipOfCompanyItems
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
Definition: economy.cpp:282
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
SetWindowClassesDirty
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition: window.cpp:3248
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:98
IsUniquePresidentName
static bool IsUniquePresidentName(const char *name)
Is the given name in use as president name of a company?
Definition: company_cmd.cpp:1096
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:83
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:383
Company::settings
CompanySettings settings
settings specific for each company
Definition: company_base.h:122
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:266
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:23
EXPENSES_SHIP_RUN
@ EXPENSES_SHIP_RUN
Running costs ships.
Definition: economy_type.h:163
OWNER_TOWN
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
Definition: company_type.h:24
EXPENSES_TRAIN_INC
@ EXPENSES_TRAIN_INC
Income from trains.
Definition: economy_type.h:165
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:286
CompanyRemoveReason
CompanyRemoveReason
The reason why the company was removed.
Definition: company_type.h:55
UpdateObjectColours
void UpdateObjectColours(const Company *c)
Updates the colour of the object whenever a company changes.
Definition: object_cmd.cpp:174
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:514
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:567
CompanyProperties::name_1
StringID name_1
Name of the company if the user did not change it.
Definition: company_base.h:57
NetworkSettings::max_companies
uint8 max_companies
maximum amount of companies
Definition: settings_type.h:268
news_func.h
Livery::colour2
byte colour2
Second colour, for vehicles with 2CC support.
Definition: livery.h:81
CompanyNewsInformation::other_company_name
char other_company_name[64]
The name of the company taking over this one.
Definition: news_type.h:151
Livery::colour1
byte colour1
First colour, for all vehicles.
Definition: livery.h:80
backup_type.hpp