MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / DiffTimers

Method DiffTimers

src/lua/LuaCallOuts.cpp:1587–1599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1585
1586
1587int LuaCallOuts::DiffTimers(lua_State* L) {
1588 const int args = lua_gettop(L); // number of arguments
1589 if ((args != 2) || !lua_isuserdata(L, 1) || !lua_isuserdata(L, 2)) {
1590 luaL_error(L, "Incorrect arguments to DiffTimers()");
1591 }
1592 const char* p1 = (char*) lua_touserdata(L, 1);
1593 const char* p2 = (char*) lua_touserdata(L, 2);
1594 const uint32_t t1 = uint32_t(p1 - (char*)0);
1595 const uint32_t t2 = uint32_t(p2 - (char*)0);
1596 const uint32_t diffTime = (t1 - t2);
1597 lua_pushfloat(L, float(diffTime) * 0.001f); // return seconds
1598 return 1;
1599}
1600
1601
1602//============================================================================//

Callers

nothing calls this directly

Calls 5

lua_pushfloatFunction · 0.85
lua_gettopFunction · 0.50
lua_isuserdataFunction · 0.50
luaL_errorFunction · 0.50
lua_touserdataFunction · 0.50

Tested by

no test coverage detected