MCPcopy Create free account
hub / github.com/cuberite/cuberite / SetDefString

Method SetDefString

src/ProbabDistrib.cpp:64–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62
63
64bool cProbabDistrib::SetDefString(const AString & a_DefString)
65{
66 AStringVector Points = StringSplitAndTrim(a_DefString, ";");
67 if (Points.empty())
68 {
69 return false;
70 }
71 cPoints Pts;
72 for (AStringVector::const_iterator itr = Points.begin(), end = Points.end(); itr != end; ++itr)
73 {
74 AStringVector Split = StringSplitAndTrim(*itr, ",");
75 if (Split.size() != 2)
76 {
77 // Bad format
78 return false;
79 }
80 int Value = atoi(Split[0].c_str());
81 int Prob = atoi(Split[1].c_str());
82 if (
83 ((Value == 0) && (Split[0] != "0")) ||
84 ((Prob == 0) && (Split[1] != "0"))
85 )
86 {
87 // Number parse error
88 return false;
89 }
90 Pts.push_back(cPoint(Value, Prob));
91 } // for itr - Points[]
92
93 SetPoints(Pts);
94 return true;
95}
96
97
98

Callers 1

Calls 7

StringSplitAndTrimFunction · 0.85
cPointClass · 0.85
emptyMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
sizeMethod · 0.80
c_strMethod · 0.80

Tested by

no test coverage detected