MCPcopy Create free account
hub / github.com/ZDoom/Raze / pushmove

Function pushmove

source/core/gamefuncs.cpp:1171–1225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1169//==========================================================================
1170
1171int pushmove(DVector3& pos, sectortype** pSect, double walldist, double ceildist, double floordist, unsigned cliptype)
1172{
1173 auto wallflags = EWallFlags::FromInt(cliptype & 65535);
1174 int maxhitwalls = 0;
1175 bool pushed = true;
1176
1177 for(int direction = 1; pushed; direction = -direction)
1178 {
1179 pushed = false;
1180
1181 if (*pSect == nullptr)
1182 return -1;
1183
1184 BFSSectorSearch search(*pSect);
1185
1186 while (auto sec = search.GetNext())
1187 {
1188 // this must go both forward and backward so we cannot use iterators. Pity
1189 for (unsigned i = 0; i < sec->walls.Size(); i++)
1190 {
1191 auto wal = direction > 0 ? &sec->walls[i] : &sec->walls[sec->walls.Size() - 1 - i];
1192
1193 if (IsCloseToWall(pos.XY(), wal, walldist - 0.25) == EClose::InFront)
1194 {
1195 bool blocked = false;
1196 if (!wal->twoSided() || wal->cstat & wallflags) blocked = true;
1197 else
1198 {
1199 auto pvect = NearestPointOnWall(pos.X, pos.Y, wal);
1200 blocked = checkOpening(pvect, pos.Z, sec, wal->nextSector(), ceildist, floordist);
1201 }
1202
1203 if (blocked)
1204 {
1205 auto dv = wal->delta().Rotated90CCW().Unit() * 0.5;
1206 for (int t = 0; t < 16; t++)
1207 {
1208 pos += dv;
1209 if (IsCloseToWall(pos.XY(), wal, (walldist - 0.25)) == EClose::Outside) break;
1210 }
1211 pushed = true;
1212
1213 updatesector(pos, pSect);
1214 if (++maxhitwalls >= 32) return -1;
1215 if (*pSect == nullptr) return -1;
1216 }
1217 else
1218 search.Add(wal->nextSector());
1219 }
1220 }
1221 }
1222 if (!pushed) return 0;
1223 }
1224 return -1;
1225}
1226
1227//==========================================================================
1228//

Callers

nothing calls this directly

Calls 12

IsCloseToWallFunction · 0.85
NearestPointOnWallFunction · 0.85
checkOpeningFunction · 0.85
updatesectorFunction · 0.85
twoSidedMethod · 0.80
nextSectorMethod · 0.80
Rotated90CCWMethod · 0.80
deltaMethod · 0.80
GetNextMethod · 0.45
SizeMethod · 0.45
UnitMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected