MCPcopy Create free account
hub / github.com/diasurgical/devilution / InitRndLocObj5x5

Function InitRndLocObj5x5

Source/objects.cpp:198–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198void InitRndLocObj5x5(int min, int max, int objtype)
199{
200 BOOL exit;
201 int xp, yp, numobjs, i, k, m, n;
202
203 numobjs = min + random_(139, max - min);
204 for (i = 0; i < numobjs; i++) {
205 k = 0;
206 for (;;) {
207 exit = TRUE;
208 xp = random_(139, 80) + 16;
209 yp = random_(139, 80) + 16;
210 for (n = -2; n <= 2; n++) {
211 for (m = -2; m <= 2; m++) {
212 if (!RndLocOk(xp + m, yp + n))
213 exit = FALSE;
214 }
215 }
216 if (exit)
217 break;
218 k++;
219 if (k > 20000)
220 return;
221 }
222 AddObject(objtype, xp, yp);
223 }
224}
225
226void ClrAllObjects()
227{

Callers 1

InitObjectsFunction · 0.85

Calls 3

random_Function · 0.85
RndLocOkFunction · 0.85
AddObjectFunction · 0.85

Tested by

no test coverage detected