Changeset - r25492:95b5ff29c101
[Not reviewed]
master
0 3 0
rubidium42 - 3 years ago 2021-05-14 15:43:23
rubidium@openttd.org
Codechange: [Network] Let NetworkCompanyInfo use std::string
3 files changed with 12 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/network/network_client.cpp
Show inline comments
 
@@ -615,13 +615,13 @@ NetworkRecvStatus ClientNetworkGameSocke
 
		CompanyID current = (Owner)p->Recv_uint8();
 
		if (current >= MAX_COMPANIES) return NETWORK_RECV_STATUS_CLOSE_QUERY;
 

	
 
		NetworkCompanyInfo *company_info = GetLobbyCompanyInfo(current);
 
		if (company_info == nullptr) return NETWORK_RECV_STATUS_CLOSE_QUERY;
 

	
 
		p->Recv_string(company_info->company_name, sizeof(company_info->company_name));
 
		company_info->company_name = p->Recv_string(NETWORK_COMPANY_NAME_LENGTH);
 
		company_info->inaugurated_year = p->Recv_uint32();
 
		company_info->company_value    = p->Recv_uint64();
 
		company_info->money            = p->Recv_uint64();
 
		company_info->income           = p->Recv_uint64();
 
		company_info->performance      = p->Recv_uint16();
 
		company_info->use_password     = p->Recv_bool();
 
@@ -630,13 +630,13 @@ NetworkRecvStatus ClientNetworkGameSocke
 
		}
 
		for (uint i = 0; i < NETWORK_VEH_END; i++) {
 
			company_info->num_station[i] = p->Recv_uint16();
 
		}
 
		company_info->ai               = p->Recv_bool();
 

	
 
		p->Recv_string(company_info->clients, sizeof(company_info->clients));
 
		company_info->clients = p->Recv_string(NETWORK_CLIENTS_LENGTH);
 

	
 
		SetWindowDirty(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY);
 

	
 
		return NETWORK_RECV_STATUS_OKAY;
 
	}
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -1280,13 +1280,13 @@ struct NetworkLobbyWindow : public Windo
 
	}
 

	
 
	CompanyID NetworkLobbyFindCompanyIndex(byte pos) const
 
	{
 
		/* Scroll through all this->company_info and get the 'pos' item that is not empty. */
 
		for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
			if (!StrEmpty(this->company_info[i].company_name)) {
 
			if (!this->company_info[i].company_name.empty()) {
 
				if (pos-- == 0) return i;
 
			}
 
		}
 

	
 
		return COMPANY_FIRST;
 
	}
 
@@ -1395,13 +1395,13 @@ struct NetworkLobbyWindow : public Windo
 
	{
 
		const int detail_height = 12 + FONT_HEIGHT_NORMAL + 12;
 
		/* Draw info about selected company when it is selected in the left window. */
 
		GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + detail_height - 1, PC_DARK_BLUE);
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 12, STR_NETWORK_GAME_LOBBY_COMPANY_INFO, TC_FROMSTRING, SA_HOR_CENTER);
 

	
 
		if (this->company == INVALID_COMPANY || StrEmpty(this->company_info[this->company].company_name)) return;
 
		if (this->company == INVALID_COMPANY || this->company_info[this->company].company_name.empty()) return;
 

	
 
		int y = r.top + detail_height + 4;
 
		const NetworkGameInfo *gi = &this->server->info;
 

	
 
		SetDParam(0, gi->clients_on);
 
		SetDParam(1, gi->clients_max);
src/network/network_gui.h
Show inline comments
 
@@ -24,20 +24,20 @@ void ShowNetworkGameWindow();
 
void ShowClientList();
 
void ShowNetworkCompanyPasswordWindow(Window *parent);
 

	
 

	
 
/** Company information stored at the client side */
 
struct NetworkCompanyInfo : NetworkCompanyStats {
 
	char company_name[NETWORK_COMPANY_NAME_LENGTH]; ///< Company name
 
	Year inaugurated_year;                          ///< What year the company started in
 
	Money company_value;                            ///< The company value
 
	Money money;                                    ///< The amount of money the company has
 
	Money income;                                   ///< How much did the company earned last year
 
	uint16 performance;                             ///< What was their performance last month?
 
	bool use_password;                              ///< Is there a password
 
	char clients[NETWORK_CLIENTS_LENGTH];           ///< The clients that control this company (Name1, name2, ..)
 
	std::string company_name; ///< Company name
 
	Year inaugurated_year;    ///< What year the company started in
 
	Money company_value;      ///< The company value
 
	Money money;              ///< The amount of money the company has
 
	Money income;             ///< How much did the company earn last year
 
	uint16 performance;       ///< What was his performance last month?
 
	bool use_password;        ///< Is there a password
 
	std::string clients;      ///< The clients that control this company (Name1, name2, ..)
 
};
 

	
 
NetworkCompanyInfo *GetLobbyCompanyInfo(CompanyID company);
 
NetworkGameList *GetLobbyGameInfo();
 

	
 
#endif /* NETWORK_GUI_H */
0 comments (0 inline, 0 general)