Changeset - r24695:05e093ea8aec
[Not reviewed]
master
0 8 0
glx22 - 4 years ago 2021-01-22 15:24:29
glx@openttd.org
Change: Apply some consistency to singleplayer related comments
8 files changed with 11 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -879,13 +879,13 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
		}
 

	
 
		case CCA_DELETE: { // Delete a company
 
			CompanyRemoveReason reason = (CompanyRemoveReason)GB(p1, 24, 8);
 
			if (reason >= CRR_END) return CMD_ERROR;
 

	
 
			/* We can't delete the last existing company in offline mode. */
 
			/* We can't delete the last existing company in singleplayer mode. */
 
			if (!_networking && Company::GetNumItems() == 1) return CMD_ERROR;
 

	
 
			Company *c = Company::GetIfValid(company_id);
 
			if (c == nullptr) return CMD_ERROR;
 

	
 
			if (!(flags & DC_EXEC)) return CommandCost();
src/console_cmds.cpp
Show inline comments
 
@@ -1245,13 +1245,13 @@ DEF_CONSOLE_CMD(ConReloadAI)
 
	CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
 
	if (!Company::IsValidID(company_id)) {
 
		IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
 
		return true;
 
	}
 

	
 
	/* In offline mode the player can be in an AI company, after cheating or loading network save with an AI in first slot. */
 
	/* In singleplayer mode the player can be in an AI company, after cheating or loading network save with an AI in first slot. */
 
	if (Company::IsHumanID(company_id) || company_id == _local_company) {
 
		IConsoleWarning("Company is not controlled by an AI.");
 
		return true;
 
	}
 

	
 
	/* First kill the company of the AI, then start a new one. This should start the current AI again */
 
@@ -1283,13 +1283,13 @@ DEF_CONSOLE_CMD(ConStopAI)
 
	CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
 
	if (!Company::IsValidID(company_id)) {
 
		IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
 
		return true;
 
	}
 

	
 
	/* In offline mode the player can be in an AI company, after cheating or loading network save with an AI in first slot. */
 
	/* In singleplayer mode the player can be in an AI company, after cheating or loading network save with an AI in first slot. */
 
	if (Company::IsHumanID(company_id) || company_id == _local_company) {
 
		IConsoleWarning("Company is not controlled by an AI.");
 
		return true;
 
	}
 

	
 
	/* Now kill the company of the AI. */
src/economy.cpp
Show inline comments
 
@@ -286,13 +286,13 @@ void ChangeOwnershipOfCompanyItems(Owner
 
	 * are the current local company. */
 
	Backup<CompanyID> cur_company(_current_company, old_owner, FILE_LINE);
 
	/* In all cases, make spectators of clients connected to that company */
 
	if (_networking) NetworkClientsToSpectators(old_owner);
 
	if (old_owner == _local_company) {
 
		/* Single player cheated to AI company.
 
		 * There are no spectators in single player, so we must pick some other company. */
 
		 * There are no spectators in singleplayer mode, so we must pick some other company. */
 
		assert(!_networking);
 
		Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
 
		for (const Company *c : Company::Iterate()) {
 
			if (c->index != old_owner) {
 
				SetLocalCompany(c->index);
 
				break;
 
@@ -602,13 +602,13 @@ static void CompanyCheckBankrupt(Company
 

	
 
		/* Bankrupt company after 6 months (if the company has no value) or latest
 
		 * after 9 months (if it still had value after 6 months) */
 
		default:
 
		case 10: {
 
			if (!_networking && _local_company == c->index) {
 
				/* If we are in offline mode, leave the company playing. Eg. there
 
				/* If we are in singleplayer mode, leave the company playing. Eg. there
 
				 * is no THE-END, otherwise mark the client as spectator to make sure
 
				 * he/she is no long in control of this company. However... when you
 
				 * join another company (cheat) the "unowned" company can bankrupt. */
 
				c->bankrupt_asked = MAX_UVALUE(CompanyMask);
 
				break;
 
			}
 
@@ -2111,13 +2111,13 @@ CommandCost CmdBuyCompany(TileIndex tile
 
	Company *c = Company::GetIfValid(target_company);
 
	if (c == nullptr) return CMD_ERROR;
 

	
 
	/* Disable takeovers when not asked */
 
	if (!HasBit(c->bankrupt_asked, _current_company)) return CMD_ERROR;
 

	
 
	/* Disable taking over the local company in single player */
 
	/* Disable taking over the local company in singleplayer mode */
 
	if (!_networking && _local_company == c->index) return CMD_ERROR;
 

	
 
	/* Do not allow companies to take over themselves */
 
	if (target_company == _current_company) return CMD_ERROR;
 

	
 
	/* Disable taking over when not allowed. */
src/highscore_gui.cpp
Show inline comments
 
@@ -110,13 +110,13 @@ struct EndGameWindow : EndGameHighScoreB
 
		/* In a network game show the endscores of the custom difficulty 'network' which is
 
		 * a TOP5 of that game, and not an all-time TOP5. */
 
		if (_networking) {
 
			this->window_number = SP_MULTIPLAYER;
 
			this->rank = SaveHighScoreValueNetwork();
 
		} else {
 
			/* in single player _local company is always valid */
 
			/* in singleplayer mode _local company is always valid */
 
			const Company *c = Company::Get(_local_company);
 
			this->window_number = SP_CUSTOM;
 
			this->rank = SaveHighScoreValue(c);
 
		}
 

	
 
		MarkWholeScreenDirty();
src/main_gui.cpp
Show inline comments
 
@@ -310,13 +310,13 @@ struct MainWindow : Window
 

	
 
			case GHK_CRASH: // Crash the game
 
				*(volatile byte *)0 = 0;
 
				break;
 

	
 
			case GHK_MONEY: // Gimme money
 
				/* You can only cheat for money in single player. */
 
				/* You can only cheat for money in singleplayer mode. */
 
				if (!_networking) DoCommandP(0, 10000000, 0, CMD_MONEY_CHEAT);
 
				break;
 

	
 
			case GHK_UPDATE_COORDS: // Update the coordinates of all station signs
 
				UpdateAllVirtCoords();
 
				break;
src/network/network_command.cpp
Show inline comments
 
@@ -295,13 +295,13 @@ void NetworkDistributeCommands()
 
 */
 
const char *NetworkGameSocketHandler::ReceiveCommand(Packet *p, CommandPacket *cp)
 
{
 
	cp->company = (CompanyID)p->Recv_uint8();
 
	cp->cmd     = p->Recv_uint32();
 
	if (!IsValidCommand(cp->cmd))               return "invalid command";
 
	if (GetCommandFlags(cp->cmd) & CMD_OFFLINE) return "offline only command";
 
	if (GetCommandFlags(cp->cmd) & CMD_OFFLINE) return "single-player only command";
 
	if ((cp->cmd & CMD_FLAGS_MASK) != 0)        return "invalid command flag";
 

	
 
	cp->p1      = p->Recv_uint32();
 
	cp->p2      = p->Recv_uint32();
 
	cp->tile    = p->Recv_uint32();
 
	p->Recv_string(cp->text, lengthof(cp->text), (!_network_server && GetCommandFlags(cp->cmd) & CMD_STR_CTRL) != 0 ? SVS_ALLOW_CONTROL_CODE | SVS_REPLACE_WITH_QUESTION_MARK : SVS_REPLACE_WITH_QUESTION_MARK);
src/openttd.cpp
Show inline comments
 
@@ -1128,13 +1128,13 @@ void SwitchToMode(SwitchMode new_mode)
 
				ShowErrorMessage(STR_WARNING_FALLBACK_SOUNDSET, INVALID_STRING_ID, WL_CRITICAL);
 
				BaseSounds::ini_set = BaseSounds::GetUsedSet()->name;
 
			}
 
			break;
 

	
 
		case SM_SAVE_GAME: // Save game.
 
			/* Make network saved games on pause compatible to singleplayer */
 
			/* Make network saved games on pause compatible to singleplayer mode */
 
			if (SaveOrLoad(_file_to_saveload.name, SLO_SAVE, DFT_GAME_FILE, NO_DIRECTORY) != SL_OK) {
 
				SetDParamStr(0, GetSaveLoadErrorString());
 
				ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR);
 
			} else {
 
				DeleteWindowById(WC_SAVELOAD, 0);
 
			}
src/saveload/afterload.cpp
Show inline comments
 
@@ -568,13 +568,13 @@ bool AfterLoadGame()
 
		DEBUG(net, 0, "The loading savegame was paused due to an error state.");
 
		DEBUG(net, 0, "  The savegame cannot be used for multiplayer!");
 
		/* Restore the signals */
 
		ResetSignalHandlers();
 
		return false;
 
	} else if (!_networking || _network_server) {
 
		/* If we are in single player, i.e. not networking, and loading the
 
		/* If we are in singleplayer mode, i.e. not networking, and loading the
 
		 * savegame or we are loading the savegame as network server we do
 
		 * not want to be bothered by being paused because of the automatic
 
		 * reason of a network server, e.g. joining clients or too few
 
		 * active clients. Note that resetting these values for a network
 
		 * client are very bad because then the client is going to execute
 
		 * the game loop when the server is not, i.e. it desyncs. */
0 comments (0 inline, 0 general)