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

Function PM_ChangeLightOff

Source/player.cpp:1159–1202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1157}
1158
1159void PM_ChangeLightOff(int pnum)
1160{
1161 int x, y;
1162 int xmul, ymul;
1163 int lx, ly;
1164 int offx, offy;
1165 const LightListStruct *l;
1166
1167 if ((DWORD)pnum >= MAX_PLRS) {
1168 app_fatal("PM_ChangeLightOff: illegal player %d", pnum);
1169 }
1170
1171 // check if issue is upstream
1172 if(plr[pnum]._plid == -1)
1173 return;
1174
1175 l = &LightList[plr[pnum]._plid];
1176 x = 2 * plr[pnum]._pyoff + plr[pnum]._pxoff;
1177 y = 2 * plr[pnum]._pyoff - plr[pnum]._pxoff;
1178 if (x < 0) {
1179 xmul = -1;
1180 x = -x;
1181 } else {
1182 xmul = 1;
1183 }
1184 if (y < 0) {
1185 ymul = -1;
1186 y = -y;
1187 } else {
1188 ymul = 1;
1189 }
1190
1191 x = (x >> 3) * xmul;
1192 y = (y >> 3) * ymul;
1193 lx = x + (l->_lx << 3);
1194 ly = y + (l->_ly << 3);
1195 offx = l->_xoff + (l->_lx << 3);
1196 offy = l->_yoff + (l->_ly << 3);
1197
1198 if (abs(lx - offx) < 3 && abs(ly - offy) < 3)
1199 return;
1200
1201 ChangeLightOff(plr[pnum]._plid, x, y);
1202}
1203
1204void PM_ChangeOffset(int pnum)
1205{

Callers 3

PM_ChangeOffsetFunction · 0.85
StartWalk2Function · 0.85
StartWalk3Function · 0.85

Calls 2

app_fatalFunction · 0.85
ChangeLightOffFunction · 0.85

Tested by

no test coverage detected