private void OnMsgGetBuildInfo(byte[] buffer) { PBuildList ret = Net.Deserialize <PBuildList>(buffer); if (!Net.CheckErrorCode(ret.errorCode, eCommand.GET_BUILD_INFO)) { return; } foreach (var item in ret.buildList) { BuildingInfo info = GetBuilding(item.buildId); if (info == null) { // 新增建筑 info = CreateBuilding(item.cfgId); BuildingList.Add(info); } info.Deserialize(item); } // 更新最大储量 UpdateMaxStorage(); // 刷新地图 UIManager.Instance.RefreshWindow <UICityView>(); }
internal static BuildingList getBuildings(MySqlConnection sql, Filters f) { BuildingList bld = new BuildingList(); String type = ""; if (f.safeValue("tp") != "") { type = "t_type='" + f.safeValue("tp") + "' AND "; } if (f.ContainsKey("nest")) { type = String.Format("(t_type='{0}' OR t_type='{1}' OR t_type='{2}') AND", Building.GetName(BuildingType.Jurta), Building.GetName(BuildingType.Female), Building.GetName(BuildingType.DualFemale)); } String busy = ""; if (f.ContainsKey(Filters.FREE)) { busy = "((" + type + "(t_busy1=0 OR t_busy2=0 OR t_busy3=0 OR t_busy4=0))"; if (f.safeInt("rcnt") > 0) { for (int i = 0; i < f.safeInt("rcnt"); i++) { int r = f.safeInt("r" + i.ToString()); if (r > 0) { busy += String.Format(" OR (t_busy1={0:d} OR t_busy2={0:d} OR t_busy3={0:d} OR t_busy4={0:d})", r); } } } busy += ")"; } MySqlCommand cmd = new MySqlCommand(String.Format(@"SELECT t_id, Coalesce(m_upper,0) AS m_upper, Coalesce(m_lower,0) AS m_lower, m_id, t_type, t_delims, t_nest, t_heater, t_repair, t_notes, t_busy1, t_busy2, t_busy3, t_busy4 FROM minifarms, tiers WHERE (m_upper = t_id OR m_lower = t_id) AND t_repair = 0 {0:s} ORDER BY m_id;", busy != "" ? "AND " + busy : ""), sql); _logger.Debug("free Buildings cmd:" + cmd.CommandText); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { bld.Add(GetBuilding(rd, false, false) as Building); } rd.Close(); return(bld); }
private void OnMsgPushGetBuild(byte[] buffer) { PBuildList ret = Net.Deserialize <PBuildList>(buffer); if (!Net.CheckErrorCode(ret.errorCode, eCommand.PUSH_GET_BUILD)) { return; } foreach (var item in ret.buildList) { BuildingInfo info = CreateBuilding(item.cfgId); info.Deserialize(item); BuildingList.Add(info); } // 刷新地图 UIManager.Instance.RefreshWindow <UICityView>(); }