devilutionX/Source/track.cpp
Anders Jenbo 87ea335ec4 Compile gamemenu.cpp, track.cpp & trigs.cpp as C (#525)
This enables processing pfile.h as a C header, this adds two minor
warnings to the compile process but should be fine (game works)
2018-12-30 03:27:03 +01:00

49 lines
1 KiB
C++

//HEADER_GOES_HERE
#include "../types.h"
static BYTE sgbIsScrolling;
static DWORD sgdwLastWalk;
static BOOL sgbIsWalking;
void __cdecl track_process()
{
if (!sgbIsWalking)
return;
if (cursmx < 0 || cursmx >= MAXDUNX - 1 || cursmy < 0 || cursmy >= MAXDUNY - 1)
return;
if (plr[myplr]._pVar8 <= 6 && plr[myplr]._pmode != PM_STAND)
return;
if (cursmx != plr[myplr]._ptargx || cursmy != plr[myplr]._ptargy) {
DWORD tick = GetTickCount();
if ((int)(tick - sgdwLastWalk) >= 300) {
sgdwLastWalk = tick;
NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy);
if (!sgbIsScrolling)
sgbIsScrolling = 1;
}
}
}
void __fastcall track_repeat_walk(BOOL rep)
{
if (sgbIsWalking == rep)
return;
sgbIsWalking = rep;
if (rep) {
sgbIsScrolling = 0;
sgdwLastWalk = GetTickCount() - 50;
NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy);
} else if (sgbIsScrolling) {
sgbIsScrolling = 0;
}
}
BOOL __cdecl track_isscrolling()
{
return sgbIsScrolling;
}