Exemplo n.º 1
0
/**
 * Copy error parameters from current DParams.
 */
void ErrorMessageData::CopyOutDParams()
{
	/* Reset parameters */
	for (size_t i = 0; i < lengthof(this->strings); i++) free(this->strings[i]);
	memset(this->decode_params, 0, sizeof(this->decode_params));
	memset(this->strings, 0, sizeof(this->strings));

	/* Get parameters using type information */
	if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack);
	CopyOutDParam(this->decode_params, this->strings, this->detailed_msg == INVALID_STRING_ID ? this->summary_msg : this->detailed_msg, lengthof(this->decode_params));
	if (this->textref_stack_size > 0) StopTextRefStackUsage();

	if (this->detailed_msg == STR_ERROR_OWNED_BY) {
		CompanyID company = (CompanyID)GetDParamX(this->decode_params, 2);
		if (company < MAX_COMPANIES) face = company;
	}
}
Exemplo n.º 2
0
	/**
	 * Display an error message in a window.
	 * @param summary_msg  General error message showed in first line. Must be valid.
	 * @param detailed_msg Detailed error message showed in second line. Can be INVALID_STRING_ID.
	 * @param duration     The amount of time to show this error message.
	 * @param x            World X position (TileVirtX) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
	 * @param y            World Y position (TileVirtY) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
	 * @param textref_stack_size Number of uint32 values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used.
	 * @param textref_stack Values to put on the #TextRefStack.
	 */
	ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration, int x, int y, uint textref_stack_size, const uint32 *textref_stack) :
		duration(duration),
		textref_stack_size(textref_stack_size),
		summary_msg(summary_msg),
		detailed_msg(detailed_msg)
	{
		this->position.x = x;
		this->position.y = y;
		if (textref_stack_size > 0) StartTextRefStackUsage(textref_stack_size, textref_stack);
		CopyOutDParam(this->decode_params, this->strings, detailed_msg == INVALID_STRING_ID ? summary_msg : detailed_msg, lengthof(this->decode_params));
		if (textref_stack_size > 0) {
			StopTextRefStackUsage();
			MemCpyT(this->textref_stack, textref_stack, textref_stack_size);
		}

		CompanyID company = (CompanyID)GetDParamX(this->decode_params, 2);
		this->face = (this->detailed_msg == STR_ERROR_OWNED_BY && company < MAX_COMPANIES) ? company : INVALID_COMPANY;

		assert(summary_msg != INVALID_STRING_ID);
	}