29 #define MULTI_LAGLOSS_DEF_LAG (-1)
30 #define MULTI_LAGLOSS_DEF_LAGMIN (-1)
31 #define MULTI_LAGLOSS_DEF_LAGMAX (-1)
32 #define MULTI_LAGLOSS_DEF_LOSS (-1.0f)
33 #define MULTI_LAGLOSS_DEF_LOSSMIN (-1.0f)
34 #define MULTI_LAGLOSS_DEF_LOSSMAX (-1.0f)
35 #define MULTI_LAGLOSS_DEF_STREAK (2500)
69 #define MAX_LAG_BUFFERS 1 // only 1 buffer in non-debug builds
71 #define MAX_LAG_BUFFERS 1000
103 #if defined(NDEBUG) || !defined(MULTI_USE_LAG)
116 if(Lag_buffers[idx] == NULL){
158 if(Lag_buffers[idx] != NULL){
160 Lag_buffers[
idx] = NULL;
178 Assert(except_fds == NULL);
184 if(select(nfds, readfds, writefds, except_fds, timeout)){
188 ret_val = recvfrom(readfds->fd_array[0], t_buf, 1024, 0, (
SOCKADDR*)&ip_addr, &t_from_len);
201 memcpy(item->
data, t_buf, ret_val);
204 item->
socket = readfds->fd_array[0];
211 readfds->fd_count = 0;
220 readfds->fd_count = 1;
283 if (rand_val < 0.5
f) {
328 if (rand_val < 0.5) {
354 nprintf((
"Network",
"Out of lag buffers!\n"));
360 Assert( lagp != &Lag_free_list );
391 dc_printf(
"Lag System Not Initialized!\n");
400 dc_printf(
"Base \t\tMin \t\tMax \t\tStreak\n");
415 dc_printf(
"\tSets the lag base value if <ms> is within the max and min limits (see lag_min and lag_max)\n");
416 dc_printf(
"\tIf <ms> is outside of the max and min limits, then nothing is done\n");
417 dc_printf(
"\tIf <ms> is negative, then lag simulation is turned off\n\n");
420 dc_printf(
"\tSets the lag min value if <ms> is less than the base value\n");
421 dc_printf(
"\tIf <ms> is outside the base or max values, then nothing is done\n");
422 dc_printf(
"\tIf <ms> is negative, then the min limit is removed\n\n");
425 dc_printf(
"\tSets the lag max value if <ms> is greater than the base value\n");
426 dc_printf(
"\tIf <ms> is outside the base or min values, then nothing is done\n");
427 dc_printf(
"\tIf <ms> is negative, then the max limit is removed\n\n");
429 dc_printf(
"loss <0-100> (-1 to disable)\n");
430 dc_printf(
"\tSimilar to lag, but applies value to loss base value\n\n");
433 dc_printf(
"\tSimilar to lag_min, but applies value to loss min value\n\n");
436 dc_printf(
"\tSimilar to lag_max, but applies value to loss max value\n\n");
440 dc_printf(
"\tSets the duration of lag streaks where the lag is consistant for <ms>\n");
441 dc_printf(
"\tEx: A value of 2000 would result in lag streaks that last 2 seconds each\n\n");
444 dc_printf(
"\tDisplays this text. Passing --status will display the status of the entire lag system");
447 DCF(lag,
"Sets the lag base value (Muliplayer)")
453 dc_printf(
"Lag System Not Initialized!\n");
474 dc_printf(
"Turning simulated lag off\n");
478 dc_printf(
"Base value greater than max value, ignoring...");
481 dc_printf(
"Base value smaller than min value, ignoring...");
487 dc_printf(
"Base value set to %i", value);
491 DCF(lag_min,
"Sets the lag min value (Multiplayer)")
497 dc_printf(
"Lag System Not Initialized!\n");
513 dc_printf(
"Min value greater than base value, ignoring...");
516 }
else if (value < 0) {
525 DCF(lag_max,
"Sets the lag max value (Multiplayer)")
531 dc_printf(
"Lag System Not Initialized!\n");
549 dc_printf(
"Max value smaller than base value, ignoring...");
551 }
else if (value < 0) {
560 DCF(loss,
"Sets the loss base value (Multiplayer)")
567 dc_printf(
"Lag System Not Initialized!\n");
584 val_f = (
float)val_i / 100.0
f;
587 dc_printf(
"Illegal loss base value, ignoring...");
588 }
else if (val_i < 0){
590 dc_printf(
"Turning simulated loss off\n");
596 dc_printf(
"Base value greater than max value, ignoring...");
599 dc_printf(
"Base value smaller than min value, ignoring...");
606 DCF(loss_min,
"Sets the loss min value (Multiplayer)")
613 dc_printf(
"Lag System Not Initialized!\n");
629 val_f = (
float)val_i / 100.0
f;
632 dc_printf(
"Min value greater than base value, ignoring...");
643 DCF(loss_max,
"Sets the loss max value (Multiplayer)")
649 dc_printf(
"Lag System Not Initialized!\n");
664 val_f = (
float)val_i / 100.0
f;
667 dc_printf(
"Max value smaller than base value, ignoring...");
678 DCF(lagloss,
"Help provider for the lag system (Multiplayer)")
682 dc_printf(
"Lag System Not Initialized!\n");
689 DCF(lag_streak,
"Sets the duration of lag streaks (Multiplayer)")
695 dc_printf(
"Lag System Not Initialized!\n");
713 dc_printf(
"Ignoring invalid value (must be non-negative)\n");
717 DCF(lag_bad,
"Lag system shortcut - Sets for 'bad' lag simulation (Multiplayer)")
721 dc_printf(
"Lag System Not Initialized!\n");
730 dc_printf(
"Setting bad lag/loss parameters\n");
746 DCF(lag_avg,
"Lag system shortcut - Sets for 'average' lag simulation (Multiplayer)")
750 dc_printf(
"Lag System Not Initialized!\n");
759 dc_printf(
"Setting avg lag/loss parameters\n");
775 DCF(lag_good,
"Lag system shortcut - Sets for 'good' lag simulation (Multiplayer)")
779 dc_printf(
"Lag System Not Initialized!\n");
788 dc_printf(
"Setting good lag/loss parameters\n");
int timestamp(int delta_ms)
int multi_lag_should_be_lost()
int multi_lag_recvfrom(uint s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen)
lag_buf * multi_lag_get_free()
#define list_append(head, elem)
#define Assertion(expr, msg,...)
#define END_OF_LIST(head)
#define MULTI_LAGLOSS_DEF_LOSSMAX
GLenum GLuint GLenum GLsizei const GLchar * buf
#define DCF(function_name, help_text)
The potent DCF macro, used to define new debug commands for the console.
lag_buf * Lag_buffers[MAX_LAG_BUFFERS]
#define MULTI_LAGLOSS_DEF_LAGMAX
#define MULTI_LAGLOSS_DEF_LAG
dc_printf("Base value set to %i", value)
int multi_lag_get_random_lag()
bool dc_optional_string_either(const char *str1, const char *str2)
Searches for an optional string and it's alias.
#define MULTI_LAGLOSS_DEF_STREAK
GLbitfield GLuint64 timeout
void dc_stuff_int(int *i)
Stuffs an int to the given variable. Supports binary (0b), hexadecimal (0x), and octal (0o) formats...
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void multi_lag_put_free(lag_buf *buf)
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new featur...
GLenum GLsizei GLenum GLenum const GLvoid * data
#define timestamp_elapsed(stamp)
#define list_remove(head, elem)
int multi_lag_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *except_fds, const timeval *timeout)
#define MULTI_LAGLOSS_DEF_LAGMIN
#define MULTI_LAGLOSS_DEF_LOSSMIN
#define MULTI_LAGLOSS_DEF_LOSS