| 829 | } |
| 830 | |
| 831 | bool cEnvironment::LoadGradientResource(cString desc, Feedback& feedback) |
| 832 | { |
| 833 | if (desc.GetSize() == 0) { |
| 834 | feedback.Error("gradient resource line with no resources listed"); |
| 835 | return false; |
| 836 | } |
| 837 | |
| 838 | while (desc.GetSize() > 0) { |
| 839 | cString cur_resource = desc.PopWord(); |
| 840 | const cString name = cur_resource.Pop(':'); |
| 841 | |
| 842 | /* If resource does not already exist create it, however if it already |
| 843 | exists (for instance was created as a cell resource) return an error*/ |
| 844 | |
| 845 | cResource* new_resource; |
| 846 | if (!resource_lib.DoesResourceExist(name)) { |
| 847 | new_resource = resource_lib.AddResource(name); |
| 848 | } else { |
| 849 | new_resource = resource_lib.GetResource(name); |
| 850 | } |
| 851 | |
| 852 | new_resource->SetGeometry("grid"); |
| 853 | new_resource->SetInitial(0.0); |
| 854 | new_resource->SetOutflow(1.0); |
| 855 | new_resource->SetXDiffuse(0.0); |
| 856 | new_resource->SetYDiffuse(0.0); |
| 857 | new_resource->SetXGravity(0.0); |
| 858 | new_resource->SetYGravity(0.0); |
| 859 | new_resource->SetGradient(true); |
| 860 | |
| 861 | while (cur_resource.GetSize() != 0) { |
| 862 | cString var_entry = cur_resource.Pop(':'); |
| 863 | cString var_name; |
| 864 | cString var_value; |
| 865 | const cString var_type = cStringUtil::Stringf("gradient resource '%s'", static_cast<const char*>(name)); |
| 866 | // Parse this entry. |
| 867 | if (!ParseSetting(var_entry, var_name, var_value, var_type, feedback)) { |
| 868 | return false; |
| 869 | } |
| 870 | |
| 871 | if (var_name == "peakx") { |
| 872 | if (!AssertInputInt(var_value, "peakx", var_type, feedback)) return false; |
| 873 | new_resource->SetPeakX( var_value.AsInt() ); |
| 874 | } |
| 875 | else if (var_name == "peaky") { |
| 876 | if (!AssertInputInt(var_value, "peaky", var_type, feedback)) return false; |
| 877 | new_resource->SetPeakY( var_value.AsInt() ); |
| 878 | } |
| 879 | else if (var_name == "height") { |
| 880 | if (!AssertInputInt(var_value, "height", var_type, feedback)) return false; |
| 881 | new_resource->SetHeight( var_value.AsInt() ); |
| 882 | } |
| 883 | else if (var_name == "spread") { |
| 884 | if (!AssertInputInt(var_value, "spread", var_type, feedback)) return false; |
| 885 | new_resource->SetSpread( var_value.AsInt() ); |
| 886 | } |
| 887 | else if (var_name == "plateau") { |
| 888 | if (!AssertInputDouble(var_value, "plateau", var_type, feedback)) return false; |
nothing calls this directly
no test coverage detected