MCPcopy Index your code
hub / github.com/assaultcube/AC / entinmap

Function entinmap

source/src/physics.cpp:945–964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

943}
944
945void entinmap(physent *d) // brute force but effective way to find a free spawn spot in the map
946{
947 vec orig(d->o);
948 loopi(100) // try max 100 times
949 {
950 float dx = (rnd(21)-10)/10.0f*i; // increasing distance
951 float dy = (rnd(21)-10)/10.0f*i;
952 d->o.x += dx;
953 d->o.y += dy;
954 if(!collide(d, true))
955 {
956 d->resetinterp();
957 return;
958 }
959 d->o = orig;
960 }
961 // leave ent at original pos, possibly stuck
962 d->resetinterp();
963 conoutf("can't find entity spawn spot! (%d, %d)", int(d->o.x), int(d->o.y));
964}
965

Callers 7

nextplayerstartFunction · 0.85
empty_worldFunction · 0.85
gotovantagepointFunction · 0.85
toggleeditFunction · 0.85
movemapFunction · 0.85
findplayerstartFunction · 0.85
spectatemodeFunction · 0.85

Calls 4

collideFunction · 0.85
resetinterpMethod · 0.80
loopiFunction · 0.70
conoutfFunction · 0.70

Tested by

no test coverage detected