-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpaused_spec_movement.patch
122 lines (111 loc) · 4.27 KB
/
paused_spec_movement.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Index: src/engine/main.cpp
===================================================================
--- src/engine/main.cpp (revision 6518)
+++ src/engine/main.cpp (working copy)
@@ -1360,8 +1360,7 @@
curtime = scaledtime/100;
timeerr = scaledtime%100;
if(!multiplayer(false) && curtime>200) curtime = 200;
- if(game::ispaused()) curtime = 0;
- lastmillis += curtime;
+ if(!game::ispaused()) lastmillis += curtime;
totalmillis = millis;
updatetime();
Index: src/engine/physics.cpp
===================================================================
--- src/engine/physics.cpp (revision 6518)
+++ src/engine/physics.cpp (working copy)
@@ -1759,6 +1759,20 @@
cleardynentcache();
}
+void fakephysicsframe() // induces fake physsteps for moving camera while paused
+{
+ static int lastfakephysframe = 0;
+ int diff = totalmillis - lastfakephysframe;
+ if(diff > curtime) { diff = curtime; lastfakephysframe = totalmillis; }
+ if(diff <= 0) physsteps = 0;
+ else
+ {
+ physframetime = clamp(game::scaletime(PHYSFRAMETIME)/100, 1, PHYSFRAMETIME);
+ physsteps = (diff + physframetime - 1)/physframetime;
+ lastfakephysframe += physsteps * physframetime;
+ }
+}
+
VAR(physinterp, 0, 1, 1);
void interppos(physent *pl)
Index: src/engine/ragdoll.h
===================================================================
--- src/engine/ragdoll.h (revision 6518)
+++ src/engine/ragdoll.h (working copy)
@@ -508,7 +508,7 @@
void moveragdoll(dynent *d)
{
- if(!curtime || !d->ragdoll) return;
+ if(!curtime || game::ispaused() || !d->ragdoll) return;
if(!d->ragdoll->collidemillis || lastmillis < d->ragdoll->collidemillis)
{
Index: src/engine/server.cpp
===================================================================
--- src/engine/server.cpp (revision 6518)
+++ src/engine/server.cpp (working copy)
@@ -623,8 +623,7 @@
int scaledtime = server::scaletime(elapsedtime) + timeerr;
curtime = scaledtime/100;
timeerr = scaledtime%100;
- if(server::ispaused()) curtime = 0;
- lastmillis += curtime;
+ if(!server::ispaused()) lastmillis += curtime;
totalmillis = millis;
updatetime();
}
Index: src/fpsgame/client.cpp
===================================================================
--- src/fpsgame/client.cpp (revision 6518)
+++ src/fpsgame/client.cpp (working copy)
@@ -791,7 +791,7 @@
bool ispaused() { return gamepaused; }
- bool allowmouselook() { return !gamepaused || !remote || m_edit; }
+ bool allowmouselook() { return player1->state==CS_SPECTATOR || !gamepaused || !remote || m_edit; }
void changegamespeed(int val)
{
Index: src/fpsgame/fps.cpp
===================================================================
--- src/fpsgame/fps.cpp (revision 6518)
+++ src/fpsgame/fps.cpp (working copy)
@@ -238,7 +238,12 @@
void updateworld() // main game update loop
{
if(!maptime) { maptime = lastmillis; maprealtime = totalmillis; return; }
- if(!curtime) { gets2c(); if(player1->clientnum>=0) c2sinfo(); return; }
+ if(!curtime || ispaused()) {
+ gets2c();
+ if(curtime && player1->state==CS_SPECTATOR) { fakephysicsframe(); moveplayer(player1, 10, true); }
+ if(player1->clientnum>=0) c2sinfo();
+ return;
+ }
physicsframe();
ai::navigate();
Index: src/fpsgame/movable.cpp
===================================================================
--- src/fpsgame/movable.cpp (revision 6518)
+++ src/fpsgame/movable.cpp (working copy)
@@ -129,7 +129,7 @@
void updatemovables(int curtime)
{
- if(!curtime) return;
+ if(!curtime || ispaused()) return;
loopv(movables)
{
movable *m = movables[i];
Index: src/shared/iengine.h
===================================================================
--- src/shared/iengine.h (revision 6518)
+++ src/shared/iengine.h (working copy)
@@ -387,6 +387,7 @@
extern bool overlapsdynent(const vec &o, float radius);
extern bool movecamera(physent *pl, const vec &dir, float dist, float stepdist);
extern void physicsframe();
+extern void fakephysicsframe();
extern void dropenttofloor(entity *e);
extern bool droptofloor(vec &o, float radius, float height);