Lunatic: various changes.

- swap 2d and 3rd args in xmath.rotate() -- now rotate(point, ang, pivot)
- add vec3 method 'rotate', calling xmath.rotate
- store game tic count in savegames

git-svn-id: https://svn.eduke32.com/eduke32@3929 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-07-04 19:38:46 +00:00
parent d580c1e998
commit 7c3f7909cc
9 changed files with 28 additions and 14 deletions

View file

@ -123,8 +123,6 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine
ud.god = ud.cashman = ud.eog = ud.showallmap = 0;
ud.noclip = ud.scrollmode = ud.overhead_on = 0; //= ud.pause_on = 0;
// G_NewGame(ud.volume_number,ud.level_number,ud.player_skill);
// G_ResetTimers();
totalclock = ototalclock = lockclock = 0;
return 1;

View file

@ -5711,7 +5711,7 @@ void G_RestoreMapState(void)
Net_ResetPrediction();
G_ClearFIFO();
G_ResetTimers();
G_ResetTimers(0);
}
}

View file

@ -1512,7 +1512,7 @@ end
function _rotatepoint(pivotx, pivoty, posx, posy, ang)
local pos = ivec3(posx, posy)
local pivot = ivec3(pivotx, pivoty)
pos = rotate(pos, pivot, ang):toivec3()
pos = rotate(pos, ang, pivot):toivec3()
return pos.x, pos.y
end

View file

@ -120,7 +120,7 @@ gameactor
-- SPAWNSPERTIC*GTICSPERSEC stars.
local ii = ((gv.gametic*SPAWNSPERTIC)%(GTICSPERSEC*SPAWNSPERTIC)) + i
local v = (radius/16)*angvec(ii*TWOPI/(GTICSPERSEC*SPAWNSPERTIC))
local circvec = xmath.rotate(xmath.vec3(0, v.x, 16*v.y), xmath.vec3(), spr.ang) -- XXX
local circvec = xmath.vec3(0, v.x, 16*v.y):rotate(spr.ang)
local pos = spr^(zofs + radius) + 256*bangvec(spr.ang) + circvec
con.insertsprite{D.TRANSPORTERSTAR+4, pos, spr.sectnum, statnum=actor.STAT.ACTOR,

View file

@ -65,14 +65,14 @@ t = os.clock()
local function _rotatepoint(pivotx, pivoty, posx, posy, ang)
local pos = xmath.ivec3(posx, posy)
local pivot = xmath.ivec3(pivotx, pivoty)
pos = xmath.rotate(pos, pivot, ang):toivec3()
pos = xmath.rotate(pos, ang, pivot):toivec3()
return pos.x, pos.y
end
sum = 0
for i=1,numpoints do
for j=1,numpoints do
-- local p = xmath.rotate(pts[i], pts[j], j)
-- local p = xmath.rotate(pts[i], j, pts[j])
-- sum = sum+p.x
sum = sum + _rotatepoint(pts[j].x, pts[j].y, pts[i].x, pts[i].y, j)
end

View file

@ -159,6 +159,8 @@ local vec2_mt = {
},
}
local l_rotate -- fwd-decl (XXX: could be the other way around)
-- The vec3 metatable is shared between the integer- and double-based 3-vector
-- types. However, some operations are slightly different.
local vec3_mt = {
@ -220,7 +222,7 @@ local vec3_mt = {
tobuild = function(v) return v:_ctor(v.x, v.y, 16*v.z) end,
-- TODO: v:rotate()?
rotate = function(v, ang, pivot) return l_rotate(v, ang, pivot) end,
-- PRIVATE methods --
@ -283,10 +285,12 @@ end
---=== MISCELLANEOUS MATH ===---
local zerovec = vec3()
-- Point rotation. Note the different order of arguments from engine function.
-- XXX: passing mixed vec2/vec3 is problematic. Get rid of vec2?
-- <ang>: BUILD angle (0-2047 based)
function rotate(pos, pivot, ang)
function rotate(pos, ang, pivot)
pivot = pivot or zerovec
local p = vec3(pos)-pivot
local c, s = cosb(ang), sinb(ang)
local x, y = p.x, p.y
@ -295,6 +299,8 @@ function rotate(pos, pivot, ang)
return p
end
l_rotate = rotate
-- Two-element vector cross product.
-- Anti-commutative, distributive.

View file

@ -1676,7 +1676,7 @@ static inline void clearfrags(void)
}
}
void G_ResetTimers(void)
void G_ResetTimers(uint8_t keepgtics)
{
vel = svel = angvel = horiz = 0;
@ -1686,7 +1686,8 @@ void G_ResetTimers(void)
lockclock = 0;
ready2send = 1;
g_levelTextTime = 85;
g_moveThingsCount = 0;
if (!keepgtics)
g_moveThingsCount = 0;
}
void G_ClearFIFO(void)
@ -2042,7 +2043,7 @@ int32_t G_EnterLevel(int32_t g)
clearfrags();
G_ResetTimers(); // Here we go
G_ResetTimers(0); // Here we go
//Bsprintf(g_szBuf,"G_EnterLevel L=%d V=%d",ud.level_number, ud.volume_number);
//AddLog(g_szBuf);

View file

@ -42,7 +42,7 @@ void G_CacheMapData(void);
void G_FadeLoad(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t ticwait);
void G_FreeMapState(int32_t mapnum);
void G_NewGame(int32_t vn,int32_t ln,int32_t sk);
void G_ResetTimers(void);
void G_ResetTimers(uint8_t keepgtics);
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
void G_UpdateScreenArea(void);
void G_SetViewportShrink(int32_t dir);

View file

@ -917,6 +917,11 @@ static const dataspec_t svgm_udnetw[] =
{ 0, connectpoint2, sizeof(connectpoint2), 1 },
{ 0, &randomseed, sizeof(randomseed), 1 },
{ 0, &g_globalRandom, sizeof(g_globalRandom), 1 },
#ifdef LUNATIC
// Save game tic count for Lunatic because it is exposed to userland. See
// test/helixspawner.lua for an example.
{ 0, &g_moveThingsCount, sizeof(g_moveThingsCount), 1 },
#endif
// { 0, &lockclock_dummy, sizeof(lockclock), 1 },
{ DS_END, 0, 0, 0 }
};
@ -1999,7 +2004,11 @@ static void postloadplayer(int32_t savegamep)
//8
// if (savegamep) ?
G_ResetTimers();
#ifdef LUNATIC
G_ResetTimers(1);
#else
G_ResetTimers(0);
#endif
#ifdef POLYMER
//9