]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/cl_physics.qc
new physics cvar: sv_airstrafeaccel_qw; also try to fix analog input issues with...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
1 .float race_penalty;
2 .float restart_jump;
3
4 float sv_accelerate;
5 float sv_friction;
6 float sv_maxspeed;
7 float sv_airaccelerate;
8 float sv_maxairspeed;
9 float sv_stopspeed;
10 float sv_gravity;
11 float sv_airaccel_sideways_friction;
12 float sv_airaccel_qw;
13 float sv_airstopaccelerate;
14 float sv_airstrafeaccelerate;
15 float sv_maxairstrafespeed;
16 float sv_airstrafeaccel_qw;
17 float sv_aircontrol;
18 float sv_aircontrol_power;
19 float sv_warsowbunny_airforwardaccel;
20 float sv_warsowbunny_accel;
21 float sv_warsowbunny_topspeed;
22 float sv_warsowbunny_turnaccel;
23 float sv_warsowbunny_backtosideratio;
24
25 .float ladder_time;
26 .entity ladder_entity;
27 .float gravity;
28 .float swamp_slowdown;
29 .float lastflags;
30 .float lastground;
31 .float wasFlying;
32 .float spectatorspeed;
33
34 /*
35 =============
36 PlayerJump
37
38 When you press the jump key
39 =============
40 */
41 void PlayerJump (void)
42 {
43         float mjumpheight;
44
45         mjumpheight = cvar("sv_jumpvelocity");
46         if (self.waterlevel >= WATERLEVEL_SWIMMING)
47         {
48                 if (self.watertype == CONTENT_WATER)
49                         self.velocity_z = 200;
50                 else if (self.watertype == CONTENT_SLIME)
51                         self.velocity_z = 80;
52                 else
53                         self.velocity_z = 50;
54
55                 return;
56         }
57
58         if (!(self.flags & FL_ONGROUND))
59                 return;
60
61         if(!sv_pogostick)
62                 if (!(self.flags & FL_JUMPRELEASED))
63                         return;
64
65         if(self.health <= g_bloodloss)
66                 return;
67
68         if(g_runematch)
69         {
70                 if(self.runes & RUNE_SPEED)
71                 {
72                         if(self.runes & CURSE_SLOW)
73                                 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_combo_jumpheight");
74                         else
75                                 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_jumpheight");
76                 }
77                 else if(self.runes & CURSE_SLOW)
78                 {
79                         mjumpheight = mjumpheight * cvar("g_balance_curse_slow_jumpheight");
80                 }
81         }
82
83         if(g_minstagib && (self.items & IT_INVINCIBLE))
84         {
85                 mjumpheight = mjumpheight * cvar("g_minstagib_speed_jumpheight");
86         }
87
88         if(cvar_string("sv_jumpspeedcap_min") != "")
89                 self.velocity_z = max(cvar("sv_jumpvelocity") * cvar("sv_jumpspeedcap_min"), self.velocity_z);
90         if(cvar_string("sv_jumpspeedcap_max") != "") {
91                 if(trace_fraction < 1 && trace_plane_normal_z < 0.98 && cvar("sv_jumpspeedcap_max_disable_on_ramps")) {
92                         // don't do jump speedcaps on ramps to preserve old xonotic ramjump style
93                         //print("Trace plane normal z: ", ftos(trace_plane_normal_z), ", disabling speed cap!\n");
94                 }
95                 else
96                         self.velocity_z = min(cvar("sv_jumpvelocity") * cvar("sv_jumpspeedcap_max"), self.velocity_z) + trace_ent.velocity_z;
97         }
98
99         if(!(self.lastflags & FL_ONGROUND))
100         {
101                 if(cvar("speedmeter"))
102                         dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
103                 if(self.lastground < time - 0.3)
104                 {
105                         self.velocity_x *= (1 - cvar("sv_friction_on_land"));
106                         self.velocity_y *= (1 - cvar("sv_friction_on_land"));
107                 }
108                 if(self.jumppadcount > 1)
109                         dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
110                 self.jumppadcount = 0;
111         }
112
113         self.velocity_z = self.velocity_z + mjumpheight;
114         self.oldvelocity_z = self.velocity_z;
115
116         self.flags &~= FL_ONGROUND;
117         self.flags &~= FL_JUMPRELEASED;
118
119         if (self.crouch)
120                 setanim(self, self.anim_duckjump, FALSE, TRUE, TRUE);
121         else
122                 setanim(self, self.anim_jump, FALSE, TRUE, TRUE);
123
124         if(g_jump_grunt)
125                 PlayerSound(playersound_jump, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
126
127         self.restart_jump = -1; // restart jump anim next time
128         // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping)
129 }
130
131 void CheckWaterJump()
132 {
133         local vector start, end;
134
135 // check for a jump-out-of-water
136         makevectors (self.angles);
137         start = self.origin;
138         start_z = start_z + 8;
139         v_forward_z = 0;
140         normalize(v_forward);
141         end = start + v_forward*24;
142         traceline (start, end, TRUE, self);
143         if (trace_fraction < 1)
144         {       // solid at waist
145                 start_z = start_z + self.maxs_z - 8;
146                 end = start + v_forward*24;
147                 self.movedir = trace_plane_normal * -50;
148                 traceline (start, end, TRUE, self);
149                 if (trace_fraction == 1)
150                 {       // open at eye level
151                         self.flags |= FL_WATERJUMP;
152                         self.velocity_z = 225;
153                         self.flags &~= FL_JUMPRELEASED;
154                         self.teleport_time = time + 2;  // safety net
155                         return;
156                 }
157         }
158 };
159
160 float racecar_angle(float forward, float down)
161 {
162         float ret, angle_mult;
163
164         if(forward < 0)
165         {
166                 forward = -forward;
167                 down = -down;
168         }
169
170         ret = vectoyaw('0 1 0' * down + '1 0 0' * forward);
171
172         angle_mult = forward / (800 + forward);
173
174         if(ret > 180)
175                 return ret * angle_mult + 360 * (1 - angle_mult);
176         else
177                 return ret * angle_mult;
178 }
179
180 void RaceCarPhysics()
181 {
182         // using this move type for "big rigs"
183         // the engine does not push the entity!
184
185         float accel, steer, f;
186         vector angles_save, rigvel;
187
188         angles_save = self.angles;
189         accel = bound(-1, self.movement_x / sv_maxspeed, 1);
190         steer = bound(-1, self.movement_y / sv_maxspeed, 1);
191
192         if(g_bugrigs_reverse_speeding)
193         {
194                 if(accel < 0)
195                 {
196                         // back accel is DIGITAL
197                         // to prevent speedhack
198                         if(accel < -0.5)
199                                 accel = -1;
200                         else
201                                 accel = 0;
202                 }
203         }
204
205         self.angles_x = 0;
206         self.angles_z = 0;
207         makevectors(self.angles); // new forward direction!
208
209         if(self.flags & FL_ONGROUND || g_bugrigs_air_steering)
210         {
211                 float myspeed, upspeed, steerfactor, accelfactor;
212
213                 myspeed = self.velocity * v_forward;
214                 upspeed = self.velocity * v_up;
215
216                 // responsiveness factor for steering and acceleration
217                 f = 1 / (1 + pow(max(-myspeed, myspeed) / g_bugrigs_speed_ref, g_bugrigs_speed_pow));
218                 //MAXIMA: f(v) := 1 / (1 + (v / g_bugrigs_speed_ref) ^ g_bugrigs_speed_pow);
219
220                 if(myspeed < 0 && g_bugrigs_reverse_spinning)
221                         steerfactor = -myspeed * g_bugrigs_steer;
222                 else
223                         steerfactor = -myspeed * f * g_bugrigs_steer;
224
225                 if(myspeed < 0 && g_bugrigs_reverse_speeding)
226                         accelfactor = g_bugrigs_accel;
227                 else
228                         accelfactor = f * g_bugrigs_accel;
229                 //MAXIMA: accel(v) := f(v) * g_bugrigs_accel;
230
231                 if(accel < 0)
232                 {
233                         if(myspeed > 0)
234                         {
235                                 myspeed = max(0, myspeed - frametime * (g_bugrigs_friction_floor - g_bugrigs_friction_brake * accel));
236                         }
237                         else
238                         {
239                                 if(!g_bugrigs_reverse_speeding)
240                                         myspeed = min(0, myspeed + frametime * g_bugrigs_friction_floor);
241                         }
242                 }
243                 else
244                 {
245                         if(myspeed >= 0)
246                         {
247                                 myspeed = max(0, myspeed - frametime * g_bugrigs_friction_floor);
248                         }
249                         else
250                         {
251                                 if(g_bugrigs_reverse_stopping)
252                                         myspeed = 0;
253                                 else
254                                         myspeed = min(0, myspeed + frametime * (g_bugrigs_friction_floor + g_bugrigs_friction_brake * accel));
255                         }
256                 }
257                 // terminal velocity = velocity at which 50 == accelfactor, that is, 1549 units/sec
258                 //MAXIMA: friction(v) := g_bugrigs_friction_floor;
259
260                 self.angles_y += steer * frametime * steerfactor; // apply steering
261                 makevectors(self.angles); // new forward direction!
262
263                 myspeed += accel * accelfactor * frametime;
264
265                 rigvel = myspeed * v_forward + '0 0 1' * upspeed;
266         }
267         else
268         {
269                 myspeed = vlen(self.velocity);
270
271                 // responsiveness factor for steering and acceleration
272                 f = 1 / (1 + pow(max(0, myspeed / g_bugrigs_speed_ref), g_bugrigs_speed_pow));
273                 steerfactor = -myspeed * f;
274                 self.angles_y += steer * frametime * steerfactor; // apply steering
275
276                 rigvel = self.velocity;
277                 makevectors(self.angles); // new forward direction!
278         }
279
280         rigvel = rigvel * max(0, 1 - vlen(rigvel) * g_bugrigs_friction_air * frametime);
281         //MAXIMA: airfriction(v) := v * v * g_bugrigs_friction_air;
282         //MAXIMA: total_acceleration(v) := accel(v) - friction(v) - airfriction(v);
283         //MAXIMA: solve(total_acceleration(v) = 0, v);
284
285         if(g_bugrigs_planar_movement)
286         {
287                 vector rigvel_xy, neworigin, up;
288                 float mt;
289
290                 rigvel_z -= frametime * sv_gravity; // 4x gravity plays better
291                 rigvel_xy = rigvel;
292                 rigvel_xy_z = 0;
293
294                 if(g_bugrigs_planar_movement_car_jumping && !g_touchexplode) // touchexplode is a better way to handle collisions
295                         mt = MOVE_NORMAL;
296                 else
297                         mt = MOVE_NOMONSTERS;
298
299                 tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 1024', mt, self);
300                 up = trace_endpos - self.origin;
301
302                 // BUG RIGS: align the move to the surface instead of doing collision testing
303                 // can we move?
304                 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos + rigvel_xy * frametime, mt, self);
305
306                 // align to surface
307                 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos - up + '0 0 1' * rigvel_z * frametime, mt, self);
308
309                 if(trace_fraction < 0.5)
310                 {
311                         trace_fraction = 1;
312                         neworigin = self.origin;
313                 }
314                 else
315                         neworigin = trace_endpos;
316
317                 if(trace_fraction < 1)
318                 {
319                         // now set angles_x so that the car points parallel to the surface
320                         self.angles = vectoangles(
321                                         '1 0 0' * v_forward_x * trace_plane_normal_z
322                                         +
323                                         '0 1 0' * v_forward_y * trace_plane_normal_z
324                                         +
325                                         '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y)
326                                         );
327                         self.flags |= FL_ONGROUND;
328                 }
329                 else
330                 {
331                         // now set angles_x so that the car points forward, but is tilted in velocity direction
332                         self.flags &~= FL_ONGROUND;
333                 }
334
335                 self.velocity = (neworigin - self.origin) * (1.0 / frametime);
336                 self.movetype = MOVETYPE_NOCLIP;
337         }
338         else
339         {
340                 rigvel_z -= frametime * sv_gravity; // 4x gravity plays better
341                 self.velocity = rigvel;
342                 self.movetype = MOVETYPE_FLY;
343         }
344
345         trace_fraction = 1;
346         tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self);
347         if(trace_fraction != 1)
348         {
349                 self.angles = vectoangles2(
350                                 '1 0 0' * v_forward_x * trace_plane_normal_z
351                                 +
352                                 '0 1 0' * v_forward_y * trace_plane_normal_z
353                                 +
354                                 '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y),
355                                 trace_plane_normal
356                                 );
357         }
358         else
359         {
360                 vector vel_local;
361
362                 vel_local_x = v_forward * self.velocity;
363                 vel_local_y = v_right * self.velocity;
364                 vel_local_z = v_up * self.velocity;
365
366                 self.angles_x = racecar_angle(vel_local_x, vel_local_z);
367                 self.angles_z = racecar_angle(-vel_local_y, vel_local_z);
368         }
369
370         // smooth the angles
371         vector vf1, vu1, smoothangles;
372         makevectors(self.angles);
373         f = bound(0, frametime * g_bugrigs_angle_smoothing, 1);
374         if(f == 0)
375                 f = 1;
376         vf1 = v_forward * f;
377         vu1 = v_up * f;
378         makevectors(angles_save);
379         vf1 = vf1 + v_forward * (1 - f);
380         vu1 = vu1 + v_up * (1 - f);
381         smoothangles = vectoangles2(vf1, vu1);
382         self.angles_x = -smoothangles_x;
383         self.angles_z =  smoothangles_z;
384 }
385
386 float IsMoveInDirection(vector mv, float angle) // key mix factor
387 {
388         if(mv_x == 0 && mv_y == 0)
389                 return 0; // avoid division by zero
390         angle -= RAD2DEG * atan2(mv_y, mv_x);
391         angle = remainder(angle, 360) / 45;
392         if(angle >  1)
393                 return 0;
394         if(angle < -1)
395                 return 0;
396         return 1 - fabs(angle);
397 }
398
399 float GeomLerp(float a, float lerp, float b)
400 {
401         if(a == 0)
402         {
403                 if(lerp < 1)
404                         return 0;
405                 else
406                         return b;
407         }
408         if(b == 0)
409         {
410                 if(lerp > 0)
411                         return 0;
412                 else
413                         return a;
414         }
415         return a * pow(fabs(b / a), lerp);
416 }
417
418 void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
419 {
420         float zspeed, xyspeed, dot, k;
421
422 #if 0
423         // this doesn't play well with analog input
424         if(self.movement_x == 0 || self.movement_y != 0)
425                 return; // can't control movement if not moving forward or backward
426         k = 32;
427 #else
428         k = 32 * (2 * IsMoveInDirection(self.movement, 0) - 1);
429         if(k <= 0)
430                 return;
431 #endif
432
433         k *= bound(0, wishspeed / sv_maxairspeed, 1);
434
435         zspeed = self.velocity_z;
436         self.velocity_z = 0;
437         xyspeed = vlen(self.velocity); self.velocity = normalize(self.velocity);
438
439         dot = self.velocity * wishdir;
440
441         if(dot > 0) // we can't change direction while slowing down
442         {
443                 k *= fabs(sv_aircontrol)*pow(dot, sv_aircontrol_power)*frametime;
444                 self.velocity = normalize(self.velocity * xyspeed + wishdir * k);
445         }
446
447         self.velocity = self.velocity * xyspeed;
448         self.velocity_z = zspeed;
449 }
450
451 // example config for alternate speed clamping:
452 //   sv_airaccel_qw 0.8
453 //   sv_airaccel_sideways_friction 0
454 //   prvm_globalset server speedclamp_mode 1
455 //     (or 2)
456 void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float sidefric)
457 {
458         float vel_straight;
459         float vel_z;
460         vector vel_perpend;
461         float step;
462
463         vector vel_xy;
464         float vel_xy_current;
465         float vel_xy_backward, vel_xy_forward;
466         float speedclamp;
467
468         speedclamp = (accelqw < 0);
469         if(speedclamp)
470                 accelqw = -accelqw;
471
472         if(cvar("sv_gameplayfix_q2airaccelerate"))
473                 wishspeed0 = wishspeed;
474
475         vel_straight = self.velocity * wishdir;
476         vel_z = self.velocity_z;
477         vel_xy = self.velocity - vel_z * '0 0 1';
478         vel_perpend = vel_xy - vel_straight * wishdir;
479
480         step = accel * frametime * wishspeed0;
481
482         vel_xy_current  = vlen(vel_xy);
483         vel_xy_forward  = vel_xy_current + bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
484         vel_xy_backward = vel_xy_current - bound(0, wishspeed + vel_xy_current, step) * accelqw - step * (1 - accelqw);
485         if(vel_xy_backward < 0)
486                 vel_xy_backward = 0; // not that it REALLY occurs that this would cause wrong behaviour afterwards
487
488         vel_straight = vel_straight + bound(0, wishspeed - vel_straight, step) * accelqw + step * (1 - accelqw);
489
490         if(sidefric < 0 && (vel_perpend*vel_perpend))
491                 // negative: only apply so much sideways friction to stay below the speed you could get by "braking"
492         {
493                 float f, fminimum;
494                 f = max(0, 1 + frametime * wishspeed * sidefric);
495                 fminimum = (vel_xy_backward*vel_xy_backward - vel_straight*vel_straight) / (vel_perpend*vel_perpend);
496                 // this cannot be > 1
497                 if(fminimum <= 0)
498                         vel_perpend = vel_perpend * max(0, f);
499                 else
500                 {
501                         fminimum = sqrt(fminimum);
502                         vel_perpend = vel_perpend * max(fminimum, f);
503                 }
504         }
505         else
506                 vel_perpend = vel_perpend * max(0, 1 - frametime * wishspeed * sidefric);
507         
508         vel_xy = vel_straight * wishdir + vel_perpend;
509         
510         if(speedclamp)
511         {
512                 // ensure we don't get too fast or decelerate faster than we should
513                 vel_xy_current = min(vlen(vel_xy), vel_xy_forward);
514                 if(vel_xy_current > 0) // prevent division by zero
515                         vel_xy = normalize(vel_xy) * vel_xy_current;
516         }
517
518         self.velocity = vel_xy + vel_z * '0 0 1';
519 }
520
521 void PM_AirAccelerate(vector wishdir, float wishspeed)
522 {
523         vector curvel, wishvel, acceldir, curdir;
524         float addspeed, accelspeed, curspeed, f;
525         float dot;
526
527         if(wishspeed == 0)
528                 return;
529
530         curvel = self.velocity;
531         curvel_z = 0;
532         curspeed = vlen(curvel);
533
534         if(wishspeed > curspeed * 1.01)
535         {
536                 wishspeed = min(wishspeed, curspeed + sv_warsowbunny_airforwardaccel * sv_maxspeed * frametime);
537         }
538         else
539         {
540                 f = max(0, (sv_warsowbunny_topspeed - curspeed) / (sv_warsowbunny_topspeed - sv_maxspeed));
541                 wishspeed = max(curspeed, sv_maxspeed) + sv_warsowbunny_accel * f * sv_maxspeed * frametime;
542         }
543         wishvel = wishdir * wishspeed;
544         acceldir = wishvel - curvel;
545         addspeed = vlen(acceldir);
546         acceldir = normalize(acceldir);
547
548         accelspeed = min(addspeed, sv_warsowbunny_turnaccel * sv_maxspeed * frametime);
549
550         if(sv_warsowbunny_backtosideratio < 1)
551         {
552                 curdir = normalize(curvel);
553                 dot = acceldir * curdir;
554                 if(dot < 0)
555                         acceldir = acceldir - (1 - sv_warsowbunny_backtosideratio) * dot * curdir;
556         }
557
558         self.velocity += accelspeed * acceldir;
559 }
560
561 .vector movement_old;
562 .float buttons_old;
563 .vector v_angle_old;
564 .string lastclassname;
565
566 .float() PlayerPhysplug;
567
568 string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
569 .float specialcommand_pos;
570 void SpecialCommand()
571 {
572 #ifdef TETRIS
573         TetrisImpulse();
574 #else
575         if(!CheatImpulse(99))
576                 print("A hollow voice says \"Plugh\".\n");
577 #endif
578 }
579
580 float speedaward_speed;
581 string speedaward_holder;
582 void race_send_speedaward(float msg)
583 {
584         // send the best speed of the round
585         WriteByte(msg, SVC_TEMPENTITY);
586         WriteByte(msg, TE_CSQC_RACE);
587         WriteByte(msg, RACE_NET_SPEED_AWARD);
588         WriteInt24_t(msg, floor(speedaward_speed+0.5));
589         WriteString(msg, speedaward_holder);
590 }
591
592 float speedaward_alltimebest;
593 string speedaward_alltimebest_holder;
594 void race_send_speedaward_alltimebest(float msg)
595 {
596         // send the best speed
597         WriteByte(msg, SVC_TEMPENTITY);
598         WriteByte(msg, TE_CSQC_RACE);
599         WriteByte(msg, RACE_NET_SPEED_AWARD_BEST);
600         WriteInt24_t(msg, floor(speedaward_alltimebest+0.5));
601         WriteString(msg, speedaward_alltimebest_holder);
602 }
603
604 string GetMapname(void);
605 float speedaward_lastupdate;
606 float speedaward_lastsent;
607 .float jumppadusetime;
608 void SV_PlayerPhysics()
609 {
610         local vector wishvel, wishdir, v;
611         local float wishspeed, f, maxspd_mod, spd, maxairspd, airaccel, swampspd_mod, buttons;
612         string temps;
613         float buttons_prev;
614         float not_allowed_to_move;
615         string c;
616
617     if(self.PlayerPhysplug)
618         if(self.PlayerPhysplug())
619             return;
620
621         self.race_movetime_frac += frametime;
622         f = floor(self.race_movetime_frac);
623         self.race_movetime_frac -= f;
624         self.race_movetime_count += f;
625         self.race_movetime = self.race_movetime_frac + self.race_movetime_count;
626
627         anticheat_physics();
628
629         buttons = self.BUTTON_ATCK + 2 * self.BUTTON_JUMP + 4 * self.BUTTON_ATCK2 + 8 * self.BUTTON_ZOOM + 16 * self.BUTTON_CROUCH + 32 * self.BUTTON_HOOK + 64 * self.BUTTON_USE + 128 * (self.movement_x < 0) + 256 * (self.movement_x > 0) + 512 * (self.movement_y < 0) + 1024 * (self.movement_y > 0);
630
631         if(!buttons)
632                 c = "x";
633         else if(buttons == 1)
634                 c = "1";
635         else if(buttons == 2)
636                 c = " ";
637         else if(buttons == 128)
638                 c = "s";
639         else if(buttons == 256)
640                 c = "w";
641         else if(buttons == 512)
642                 c = "a";
643         else if(buttons == 1024)
644                 c = "d";
645         else
646                 c = "?";
647
648         if(c == substring(specialcommand, self.specialcommand_pos, 1))
649         {
650                 self.specialcommand_pos += 1;
651                 if(self.specialcommand_pos >= strlen(specialcommand))
652                 {
653                         self.specialcommand_pos = 0;
654                         SpecialCommand();
655                         return;
656                 }
657         }
658         else if(self.specialcommand_pos && (c != substring(specialcommand, self.specialcommand_pos - 1, 1)))
659                 self.specialcommand_pos = 0;
660
661         if(!sv_maxidle_spectatorsareidle || self.movetype == MOVETYPE_WALK)
662         {
663                 if(buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old)
664                         self.parm_idlesince = time;
665         }
666         buttons_prev = self.buttons_old;
667         self.buttons_old = buttons;
668         self.movement_old = self.movement;
669         self.v_angle_old = self.v_angle;
670
671         if(time < self.nickspamtime)
672         if(self.nickspamcount >= cvar("g_nick_flood_penalty_yellow"))
673         {
674                 // slight annoyance for nick change scripts
675                 self.movement = -1 * self.movement;
676                 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
677
678                 if(self.nickspamcount >= cvar("g_nick_flood_penalty_red")) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
679                 {
680                         self.angles_x = random() * 360;
681                         self.angles_y = random() * 360;
682                         // at least I'm not forcing retardedview by also assigning to angles_z
683                         self.fixangle = 1;
684                 }
685         }
686
687         if (self.punchangle != '0 0 0')
688         {
689                 f = vlen(self.punchangle) - 10 * frametime;
690                 if (f > 0)
691                         self.punchangle = normalize(self.punchangle) * f;
692                 else
693                         self.punchangle = '0 0 0';
694         }
695
696         if (self.punchvector != '0 0 0')
697         {
698                 f = vlen(self.punchvector) - 30 * frametime;
699                 if (f > 0)
700                         self.punchvector = normalize(self.punchvector) * f;
701                 else
702                         self.punchvector = '0 0 0';
703         }
704
705         if (clienttype(self) == CLIENTTYPE_BOT)
706         {
707                 if(playerdemo_read())
708                         return;
709                 bot_think();
710         }
711         
712         MUTATOR_CALLHOOK(PlayerPhysics);
713
714         self.items &~= IT_USING_JETPACK;
715
716         if(self.classname == "player")
717         {
718                 if(self.race_penalty)
719                         if(time > self.race_penalty)
720                                 self.race_penalty = 0;
721
722                 not_allowed_to_move = 0;
723                 if(self.race_penalty)
724                         not_allowed_to_move = 1;
725                 if(!cvar("sv_ready_restart_after_countdown"))
726                 if(time < game_starttime)
727                         not_allowed_to_move = 1;
728
729                 if(not_allowed_to_move)
730                 {
731                         self.velocity = '0 0 0';
732                         self.movetype = MOVETYPE_NONE;
733                         self.disableclientprediction = 2;
734                 }
735                 else if(self.disableclientprediction == 2)
736                 {
737                         if(self.movetype == MOVETYPE_NONE)
738                                 self.movetype = MOVETYPE_WALK;
739                         self.disableclientprediction = 0;
740                 }
741         }
742
743         if (self.movetype == MOVETYPE_NONE)
744                 return;
745
746         maxspd_mod = 1;
747
748         if(g_runematch)
749         {
750                 if(self.runes & RUNE_SPEED)
751                 {
752                         if(self.runes & CURSE_SLOW)
753                                 maxspd_mod = maxspd_mod * cvar("g_balance_rune_speed_combo_moverate");
754                         else
755                                 maxspd_mod = maxspd_mod * cvar("g_balance_rune_speed_moverate");
756                 }
757                 else if(self.runes & CURSE_SLOW)
758                 {
759                         maxspd_mod = maxspd_mod * cvar("g_balance_curse_slow_moverate");
760                 }
761         }
762
763         if(g_minstagib && (self.items & IT_INVINCIBLE))
764         {
765                 maxspd_mod = cvar("g_minstagib_speed_moverate");
766         }
767
768         if(g_nexball && self.ballcarried)
769         {
770                 maxspd_mod = cvar("g_nexball_basketball_carrier_speed");
771         }
772
773         swampspd_mod = 1;
774         if(self.in_swamp) {
775                 swampspd_mod = self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
776         }
777
778         if(self.classname != "player")
779         {
780                 maxspd_mod = cvar("sv_spectator_speed_multiplier");
781                 if(!self.spectatorspeed)
782                         self.spectatorspeed = maxspd_mod;
783                 if(self.impulse && self.impulse <= 19)
784                 {
785                         if(self.lastclassname != "player")
786                         {
787                                 if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18)
788                                         self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
789                                 else if(self.impulse == 11)
790                                         self.spectatorspeed = maxspd_mod;
791                                 else if(self.impulse == 12 || self.impulse == 16  || self.impulse == 19)
792                                         self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
793                                 else if(self.impulse >= 1 && self.impulse <= 9)
794                                         self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
795                         } // otherwise just clear
796                         self.impulse = 0;
797                 }
798                 maxspd_mod = self.spectatorspeed;
799         }
800
801         spd = max(sv_maxspeed, sv_maxairspeed) * maxspd_mod * swampspd_mod;
802         if(self.speed != spd)
803         {
804                 self.speed = spd;
805                 temps = ftos(spd);
806                 stuffcmd(self, strcat("cl_forwardspeed ", temps, "\n"));
807                 stuffcmd(self, strcat("cl_backspeed ", temps, "\n"));
808                 stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
809                 stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
810         }
811
812         maxspd_mod *= swampspd_mod; // only one common speed modder please!
813         swampspd_mod = 1;
814
815         // if dead, behave differently
816         if (self.deadflag)
817                 goto end;
818
819         if (!self.fixangle && !g_bugrigs)
820         {
821                 self.angles_x = 0;
822                 self.angles_y = self.v_angle_y;
823                 self.angles_z = 0;
824         }
825
826         if(self.flags & FL_ONGROUND)
827         if(self.wasFlying)
828         {
829                 self.wasFlying = 0;
830
831                 if(self.waterlevel < WATERLEVEL_SWIMMING)
832                 if(time >= self.ladder_time)
833                 if not(self.hook)
834                 {
835                         self.nextstep = time + 0.3 + random() * 0.1;
836                         trace_dphitq3surfaceflags = 0;
837                         tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
838                         if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
839                         {
840                                 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
841                                         GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
842                                 else
843                                         GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
844                         }
845                 }
846         }
847
848         if(IsFlying(self))
849                 self.wasFlying = 1;
850
851         if(self.classname == "player")
852         {
853                 if(sv_doublejump && time - self.jumppadusetime > 2 * sys_frametime)
854                 {
855                         tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
856                         self.flags &~= FL_ONGROUND;
857                         if(trace_fraction < 1 && trace_plane_normal_z > 0.7)
858                                 self.flags |= FL_ONGROUND;
859                 }
860
861                 if (self.BUTTON_JUMP)
862                         PlayerJump ();
863                 else
864                         self.flags |= FL_JUMPRELEASED;
865
866                 if (self.waterlevel == WATERLEVEL_SWIMMING)
867                         CheckWaterJump ();
868         }
869
870         if (self.flags & FL_WATERJUMP )
871         {
872                 self.velocity_x = self.movedir_x;
873                 self.velocity_y = self.movedir_y;
874                 if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
875                 {
876                         self.flags &~= FL_WATERJUMP;
877                         self.teleport_time = 0;
878                 }
879         }
880         else if (g_bugrigs && self.classname == "player")
881         {
882                 RaceCarPhysics();
883         }
884         else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY)
885         {
886                 // noclipping or flying
887                 self.flags &~= FL_ONGROUND;
888
889                 self.velocity = self.velocity * (1 - frametime * sv_friction);
890                 makevectors(self.v_angle);
891                 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
892                 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
893                 // acceleration
894                 wishdir = normalize(wishvel);
895                 wishspeed = vlen(wishvel);
896                 if (wishspeed > sv_maxspeed*maxspd_mod)
897                         wishspeed = sv_maxspeed*maxspd_mod;
898                 if (time >= self.teleport_time)
899                         PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
900         }
901         else if (self.waterlevel >= WATERLEVEL_SWIMMING)
902         {
903                 // swimming
904                 self.flags &~= FL_ONGROUND;
905
906                 makevectors(self.v_angle);
907                 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
908                 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
909                 if (wishvel == '0 0 0')
910                         wishvel = '0 0 -60'; // drift towards bottom
911
912                 wishdir = normalize(wishvel);
913                 wishspeed = vlen(wishvel);
914                 if (wishspeed > sv_maxspeed*maxspd_mod)
915                         wishspeed = sv_maxspeed*maxspd_mod;
916                 wishspeed = wishspeed * 0.7;
917
918                 // water friction
919                 self.velocity = self.velocity * (1 - frametime * sv_friction);
920
921                 // water acceleration
922                 PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
923         }
924         else if (time < self.ladder_time)
925         {
926                 // on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
927                 self.flags &~= FL_ONGROUND;
928
929                 self.velocity = self.velocity * (1 - frametime * sv_friction);
930                 makevectors(self.v_angle);
931                 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
932                 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
933                 if (self.gravity)
934                         self.velocity_z = self.velocity_z + self.gravity * sv_gravity * frametime;
935                 else
936                         self.velocity_z = self.velocity_z + sv_gravity * frametime;
937                 if (self.ladder_entity.classname == "func_water")
938                 {
939                         f = vlen(wishvel);
940                         if (f > self.ladder_entity.speed)
941                                 wishvel = wishvel * (self.ladder_entity.speed / f);
942
943                         self.watertype = self.ladder_entity.skin;
944                         f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
945                         if ((self.origin_z + self.view_ofs_z) < f)
946                                 self.waterlevel = WATERLEVEL_SUBMERGED;
947                         else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
948                                 self.waterlevel = WATERLEVEL_SWIMMING;
949                         else if ((self.origin_z + self.mins_z + 1) < f)
950                                 self.waterlevel = WATERLEVEL_WETFEET;
951                         else
952                         {
953                                 self.waterlevel = WATERLEVEL_NONE;
954                                 self.watertype = CONTENT_EMPTY;
955                         }
956                 }
957                 // acceleration
958                 wishdir = normalize(wishvel);
959                 wishspeed = vlen(wishvel);
960                 if (wishspeed > sv_maxspeed*maxspd_mod)
961                         wishspeed = sv_maxspeed*maxspd_mod;
962                 if (time >= self.teleport_time)
963                 {
964                         // water acceleration
965                         PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
966                 }
967         }
968         else if ((self.items & IT_JETPACK) && self.BUTTON_HOOK && (!cvar("g_jetpack_fuel") || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO))
969         {
970                 //makevectors(self.v_angle_y * '0 1 0');
971                 makevectors(self.v_angle);
972                 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
973                 // add remaining speed as Z component
974                 maxairspd = sv_maxairspeed*max(1, maxspd_mod);
975                 // fix speedhacks :P
976                 wishvel = normalize(wishvel) * min(vlen(wishvel) / maxairspd, 1);
977                 // add the unused velocity as up component
978                 wishvel_z = 0;
979
980                 // if(self.BUTTON_JUMP)
981                         wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
982
983                 // it is now normalized, so...
984                 float a_side, a_up, a_add, a_diff;
985                 a_side = cvar("g_jetpack_acceleration_side");
986                 a_up = cvar("g_jetpack_acceleration_up");
987                 a_add = cvar("g_jetpack_antigravity") * sv_gravity;
988
989                 wishvel_x *= a_side;
990                 wishvel_y *= a_side;
991                 wishvel_z *= a_up;
992                 wishvel_z += a_add;
993
994                 float best;
995                 best = 0;
996                 //////////////////////////////////////////////////////////////////////////////////////
997                 // finding the maximum over all vectors of above form
998                 // with wishvel having an absolute value of 1
999                 //////////////////////////////////////////////////////////////////////////////////////
1000                 // we're finding the maximum over
1001                 //   f(a_side, a_up, a_add, z) := a_side * (1 - z^2) + (a_add + a_up * z)^2;
1002                 // for z in the range from -1 to 1
1003                 //////////////////////////////////////////////////////////////////////////////////////
1004                 // maximum is EITHER attained at the single extreme point:
1005                 a_diff = a_side * a_side - a_up * a_up;
1006                 if(a_diff != 0)
1007                 {
1008                         f = a_add * a_up / a_diff; // this is the zero of diff(f(a_side, a_up, a_add, z), z)
1009                         if(f > -1 && f < 1) // can it be attained?
1010                         {
1011                                 best = (a_diff + a_add * a_add) * (a_diff + a_up * a_up) / a_diff;
1012                                 //print("middle\n");
1013                         }
1014                 }
1015                 // OR attained at z = 1:
1016                 f = (a_up + a_add) * (a_up + a_add);
1017                 if(f > best)
1018                 {
1019                         best = f;
1020                         //print("top\n");
1021                 }
1022                 // OR attained at z = -1:
1023                 f = (a_up - a_add) * (a_up - a_add);
1024                 if(f > best)
1025                 {
1026                         best = f;
1027                         //print("bottom\n");
1028                 }
1029                 best = sqrt(best);
1030                 //////////////////////////////////////////////////////////////////////////////////////
1031
1032                 //print("best possible acceleration: ", ftos(best), "\n");
1033
1034                 float fxy, fz;
1035                 fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / cvar("g_jetpack_maxspeed_side"), 1);
1036                 if(wishvel_z - sv_gravity > 0)
1037                         fz = bound(0, 1 - self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
1038                 else
1039                         fz = bound(0, 1 + self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
1040
1041                 float fvel;
1042                 fvel = vlen(wishvel);
1043                 wishvel_x *= fxy;
1044                 wishvel_y *= fxy;
1045                 wishvel_z = (wishvel_z - sv_gravity) * fz + sv_gravity;
1046
1047                 fvel = min(1, vlen(wishvel) / best);
1048                 if(cvar("g_jetpack_fuel") && !(self.items & IT_UNLIMITED_WEAPON_AMMO))
1049                         f = min(1, self.ammo_fuel / (cvar("g_jetpack_fuel") * frametime * fvel));
1050                 else
1051                         f = 1;
1052
1053                 //print("this acceleration: ", ftos(vlen(wishvel) * f), "\n");
1054
1055                 if (f > 0 && wishvel != '0 0 0')
1056                 {
1057                         self.velocity = self.velocity + wishvel * f * frametime;
1058                         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
1059                                 self.ammo_fuel -= cvar("g_jetpack_fuel") * frametime * fvel * f;
1060                         self.flags &~= FL_ONGROUND;
1061                         self.items |= IT_USING_JETPACK;
1062
1063                         // jetpack also inhibits health regeneration, but only for 1 second
1064                         self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen"));
1065                 }
1066         }
1067         else if (self.flags & FL_ONGROUND)
1068         {
1069                 // we get here if we ran out of ammo
1070                 if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32))
1071                         sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1072
1073                 // walking
1074                 makevectors(self.v_angle_y * '0 1 0');
1075                 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
1076
1077                 if(!(self.lastflags & FL_ONGROUND))
1078                 {
1079                         if(cvar("speedmeter"))
1080                                 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
1081                         if(self.lastground < time - 0.3)
1082                                 self.velocity = self.velocity * (1 - cvar("sv_friction_on_land"));
1083                         if(self.jumppadcount > 1)
1084                                 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
1085                         self.jumppadcount = 0;
1086                 }
1087
1088 #ifdef LETS_TEST_FTEQCC
1089                 if(self.velocity_x || self.velocity_y)
1090                 {
1091                         // good
1092                 }
1093                 else
1094                 {
1095                         if(self.velocity_x)
1096                                 checkclient();
1097                         if(self.velocity_y)
1098                                 checkclient();
1099                 }
1100 #endif
1101
1102                 v = self.velocity;
1103                 v_z = 0;
1104                 f = vlen(v);
1105                 if(f > 0)
1106                 {
1107                         if (f < sv_stopspeed)
1108                                 f = 1 - frametime * (sv_stopspeed / f) * sv_friction;
1109                         else
1110                                 f = 1 - frametime * sv_friction;
1111                         if (f > 0)
1112                                 self.velocity = self.velocity * f;
1113                         else
1114                                 self.velocity = '0 0 0';
1115                 }
1116
1117                 // acceleration
1118                 wishdir = normalize(wishvel);
1119                 wishspeed = vlen(wishvel);
1120                 if (wishspeed > sv_maxspeed*maxspd_mod)
1121                         wishspeed = sv_maxspeed*maxspd_mod;
1122                 if (self.crouch)
1123                         wishspeed = wishspeed * 0.5;
1124                 if (time >= self.teleport_time)
1125                         PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
1126         }
1127         else
1128         {
1129                 float wishspeed0;
1130                 // we get here if we ran out of ammo
1131                 if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32))
1132                         sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1133
1134                 if(maxspd_mod < 1)
1135                 {
1136                         maxairspd = sv_maxairspeed*maxspd_mod;
1137                         airaccel = sv_airaccelerate*maxspd_mod;
1138                 }
1139                 else
1140                 {
1141                         maxairspd = sv_maxairspeed;
1142                         airaccel = sv_airaccelerate;
1143                 }
1144                 // airborn
1145                 makevectors(self.v_angle_y * '0 1 0');
1146                 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
1147                 // acceleration
1148                 wishdir = normalize(wishvel);
1149                 wishspeed = wishspeed0 = vlen(wishvel);
1150                 if (wishspeed0 > sv_maxspeed*maxspd_mod)
1151                         wishspeed0 = sv_maxspeed*maxspd_mod;
1152                 if (wishspeed > maxairspd)
1153                         wishspeed = maxairspd;
1154                 if (self.crouch)
1155                         wishspeed = wishspeed * 0.5;
1156                 if (time >= self.teleport_time)
1157                 {
1158                         float accelerating;
1159                         float wishspeed2;
1160                         float airaccelqw;
1161                         float strafity;
1162
1163                         airaccelqw = sv_airaccel_qw;
1164                         accelerating = (self.velocity * wishdir > 0);
1165                         wishspeed2 = wishspeed;
1166
1167                         // CPM
1168                         if(sv_airstopaccelerate)
1169                                 if(self.velocity * wishdir < 0)
1170                                         airaccel = sv_airstopaccelerate*maxspd_mod;
1171                         // this doesn't play well with analog input, but can't r
1172                         // fixed like the AirControl can. So, don't set the maxa
1173                         // cvars when you want to support analog input.
1174                         // note that for straight forward jumping:
1175                         // step = accel * frametime * wishspeed0;
1176                         // accel  = bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
1177                         // -->
1178                         // dv/dt = accel * maxspeed (when slow)
1179                         // dv/dt = accel * maxspeed * (1 - accelqw) (when fast)
1180                         // log dv/dt = logaccel + logmaxspeed (when slow)
1181                         // log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast)
1182                         strafity = IsMoveInDirection(self.movement, -90) + IsMoveInDirection(self.movement, +90); // if one is nonzero, other is always zero
1183                         if(sv_maxairstrafespeed)
1184                                 wishspeed = min(wishspeed, GeomLerp(sv_maxairspeed*maxspd_mod, strafity, sv_maxairstrafespeed*maxspd_mod));
1185                         if(sv_airstrafeaccelerate)
1186                                 airaccel = GeomLerp(airaccel, strafity, sv_airstrafeaccelerate*maxspd_mod);
1187                         if(sv_airstrafeaccel_qw)
1188                                 airaccelqw = sign((strafity > 0.5) ? sv_airstrafeaccel_qw : sv_airaccel_qw) * (1-GeomLerp(1-fabs(airaccelqw), strafity, 1-fabs(sv_airstrafeaccel_qw)));
1189                         // !CPM
1190
1191                         if(sv_warsowbunny_turnaccel && accelerating && self.movement_y == 0 && self.movement_x != 0)
1192                                 PM_AirAccelerate(wishdir, wishspeed);
1193                         else
1194                                 PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, sv_airaccel_sideways_friction / maxairspd);
1195
1196                         if(sv_aircontrol)
1197                                 CPM_PM_Aircontrol(wishdir, wishspeed2);
1198                 }
1199         }
1200
1201         if((g_cts || g_race) && self.classname != "observer") {
1202                 if(vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) {
1203                         speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');
1204                         speedaward_holder = self.netname;
1205                         speedaward_lastupdate = time;
1206                 }
1207                 if(speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1) {
1208                         string rr;
1209                         if(g_cts)
1210                                 rr = CTS_RECORD;
1211                         else
1212                                 rr = RACE_RECORD;
1213                         race_send_speedaward(MSG_ALL);
1214                         speedaward_lastsent = speedaward_speed;
1215                         if (speedaward_speed > speedaward_alltimebest) {
1216                                 speedaward_alltimebest = speedaward_speed;
1217                                 speedaward_alltimebest_holder = speedaward_holder;
1218                                 db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed"), ftos(speedaward_alltimebest));
1219                                 db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/netname"), speedaward_alltimebest_holder);
1220                                 race_send_speedaward_alltimebest(MSG_ALL);
1221                         }
1222                 }
1223         }
1224 :end
1225         if(self.flags & FL_ONGROUND)
1226                 self.lastground = time;
1227
1228         self.lastflags = self.flags;
1229         self.lastclassname = self.classname;
1230 };