Changeset - r7806:a2c6f8da57ac
[Not reviewed]
master
0 2 0
glx - 17 years ago 2007-10-29 23:29:06
glx@openttd.org
(svn r11356) -Fix (r11305): funding industries in MP game was causing desync
2 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1561,25 +1561,25 @@ static Industry *CreateNewIndustryHelper
 
		if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_EXEC, it, type);
 
		DoCreateNewIndustry(i, tile, type, it, itspec_index, t, OWNER_NONE);
 
		i_auto_delete.Detach();
 
	}
 

	
 
	return i;
 
}
 

	
 
/** Build/Fund an industry
 
 * @param tile tile where industry is built
 
 * @param flags of operations to conduct
 
 * @param p1 industry type see build_industry.h and see industry.h
 
 * @param p2 unused
 
 * @param p2 first layout to try
 
 * @return index of the newly create industry, or CMD_ERROR if it failed
 
 */
 
CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	const IndustrySpec *indspec;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_OTHER);
 

	
 
	indspec = GetIndustrySpec(p1);
 

	
 
	/* Check if the to-be built/founded industry is available for this climate. */
 
	if (!indspec->enabled) {
 
@@ -1609,25 +1609,25 @@ CommandCost CmdBuildIndustry(TileIndex t
 
							SetDParam(1, ind->town->index);
 
						}
 
						AddNewsItem(indspec->new_industry_text,
 
								NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0);
 
						break;
 
					}
 
				}
 
			}
 
		}
 
	} else {
 
		int count = indspec->num_table;
 
		const IndustryTileTable * const *itt = indspec->table;
 
		int num = RandomRange(count);
 
		int num = clamp(p2, 0, count - 1);
 

	
 
		_error_message = STR_0239_SITE_UNSUITABLE;
 
		do {
 
			if (--count < 0) return CMD_ERROR;
 
			if (--num < 0) num = indspec->num_table - 1;
 
		} while (!CheckIfIndustryTilesAreFree(tile, itt[num], num, p1));
 

	
 
		if (CreateNewIndustryHelper(tile, p1, flags, indspec, num) == NULL) return CMD_ERROR;
 
	}
 

	
 
	return CommandCost(indspec->GetConstructionCost());
 
}
src/industry_gui.cpp
Show inline comments
 
@@ -306,25 +306,25 @@ static void BuildDynamicIndustryWndProc(
 
				_current_player = OWNER_NONE;
 
				_generating_world = true;
 
				_ignore_restrictions = true;
 
				success = TryBuildIndustry(e->we.place.tile, WP(w, fnd_d).select);
 
				if (!success) {
 
					SetDParam(0, indsp->name);
 
					ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y);
 
				}
 

	
 
				_ignore_restrictions = false;
 
				_generating_world = false;
 
			} else {
 
				success = DoCommandP(e->we.place.tile, WP(w, fnd_d).select, 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
 
				success = DoCommandP(e->we.place.tile, WP(w, fnd_d).select, InteractiveRandomRange(indsp->num_table), NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
 
			}
 

	
 
			/* If an industry has been built, just reset the cursor and the system */
 
			if (success) ResetObjectToPlace();
 
		} break;
 

	
 
		case WE_TICK:
 
			if (!WP(w, fnd_d).timer_enabled) break;
 
			if (--WP(w, fnd_d).callback_timer == 0) {
 
				/* We have just passed another day.
 
				 * See if we need to update availability of currently selected industry */
 
				WP(w, fnd_d).callback_timer = DAY_TICKS;  //restart counter
0 comments (0 inline, 0 general)