File diff r11916:e3a8d08bf479 → r11917:612c11f7ab47
src/signs_cmd.cpp
Show inline comments
 
@@ -64,63 +64,63 @@ CommandCost CmdPlaceSign(TileIndex tile,
 
 * @param p2 unused
 
 * @return 0 if succesfull, otherwise CMD_ERROR
 
 */
 
CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	if (!IsValidSignID(p1)) return CMD_ERROR;
 

	
 
	/* Rename the signs when empty, otherwise remove it */
 
	if (!StrEmpty(text)) {
 
		if (strlen(text) >= MAX_LENGTH_SIGN_NAME_BYTES) return CMD_ERROR;
 

	
 
		if (flags & DC_EXEC) {
 
			Sign *si = GetSign(p1);
 
			Sign *si = Sign::Get(p1);
 

	
 
			/* Delete the old name */
 
			free(si->name);
 
			/* Assign the new one */
 
			si->name = strdup(text);
 
			si->owner = _current_company;
 

	
 
			/* Update; mark sign dirty twice, because it can either becom longer, or shorter */
 
			MarkSignDirty(si);
 
			UpdateSignVirtCoords(si);
 
			MarkSignDirty(si);
 
			InvalidateWindowData(WC_SIGN_LIST, 0, 1);
 
		}
 
	} else { // Delete sign
 
		if (flags & DC_EXEC) {
 
			Sign *si = GetSign(p1);
 
			Sign *si = Sign::Get(p1);
 

	
 
			MarkSignDirty(si);
 
			delete si;
 

	
 
			InvalidateWindowData(WC_SIGN_LIST, 0, 0);
 
		}
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
/**
 
 * Callback function that is called after a sign is placed
 
 * @param success of the operation
 
 * @param tile unused
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		ShowRenameSignWindow(GetSign(_new_sign_id));
 
		ShowRenameSignWindow(Sign::Get(_new_sign_id));
 
		ResetObjectToPlace();
 
	}
 
}
 

	
 
/**
 
 *
 
 * PlaceProc function, called when someone pressed the button if the
 
 *  sign-tool is selected
 
 * @param tile on which to place the sign
 
 */
 
void PlaceProc_Sign(TileIndex tile)
 
{