Skip to content

Commit

Permalink
standardize on reliable_copy_string
Browse files Browse the repository at this point in the history
  • Loading branch information
gafferongames committed Dec 28, 2023
1 parent 8fe512d commit 55ab431
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 60 deletions.
48 changes: 8 additions & 40 deletions reliable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2088,21 +2088,13 @@ void test_packets()
sender_config.fragment_above = 500;
receiver_config.fragment_above = 500;

#if defined(_MSC_VER)
strcpy_s( sender_config.name, sizeof( sender_config.name ), "sender" );
#else
strcpy( sender_config.name, "sender" );
#endif
reliable_copy_string( sender_config.name, "sender", sizeof( sender_config.name ) );
sender_config.context = &context;
sender_config.id = 0;
sender_config.transmit_packet_function = &test_transmit_packet_function;
sender_config.process_packet_function = &test_process_packet_function_validate;

#if defined(_MSC_VER)
strcpy_s( receiver_config.name, sizeof( receiver_config.name ), "receiver" );
#else
strcpy( receiver_config.name, "receiver" );
#endif
reliable_copy_string( receiver_config.name, "receiver", sizeof( receiver_config.name ) );
receiver_config.context = &context;
receiver_config.id = 1;
receiver_config.transmit_packet_function = &test_transmit_packet_function;
Expand Down Expand Up @@ -2162,21 +2154,13 @@ void test_large_packets()
sender_config.fragment_above = TEST_MAX_PACKET_BYTES;
receiver_config.fragment_above = TEST_MAX_PACKET_BYTES;

#if defined(_MSC_VER)
strcpy_s( sender_config.name, sizeof( sender_config.name ), "sender" );
#else
strcpy( sender_config.name, "sender" );
#endif
reliable_copy_string( sender_config.name, "sender", sizeof( sender_config.name ) );
sender_config.context = &context;
sender_config.id = 0;
sender_config.transmit_packet_function = &test_transmit_packet_function;
sender_config.process_packet_function = &test_process_packet_function_validate_large;

#if defined(_MSC_VER)
strcpy_s( receiver_config.name, sizeof( receiver_config.name ), "receiver" );
#else
strcpy( receiver_config.name, "receiver" );
#endif
reliable_copy_string( receiver_config.name, "receiver", sizeof( receiver_config.name ) );
receiver_config.context = &context;
receiver_config.id = 1;
receiver_config.transmit_packet_function = &test_transmit_packet_function;
Expand Down Expand Up @@ -2222,21 +2206,13 @@ void test_sequence_buffer_rollover()
sender_config.fragment_above = 500;
receiver_config.fragment_above = 500;

#if defined(_MSC_VER)
strcpy_s( sender_config.name, sizeof( sender_config.name ), "sender" );
#else
strcpy( sender_config.name, "sender" );
#endif
reliable_copy_string( sender_config.name, "sender", sizeof( sender_config.name ) );
sender_config.context = &context;
sender_config.id = 0;
sender_config.transmit_packet_function = &test_transmit_packet_function;
sender_config.process_packet_function = &test_process_packet_function;

#if defined(_MSC_VER)
strcpy_s( receiver_config.name, sizeof( receiver_config.name ), "receiver" );
#else
strcpy( receiver_config.name, "receiver" );
#endif
reliable_copy_string( receiver_config.name, "receiver", sizeof( receiver_config.name ) );
receiver_config.context = &context;
receiver_config.id = 1;
receiver_config.transmit_packet_function = &test_transmit_packet_function;
Expand Down Expand Up @@ -2335,21 +2311,13 @@ void test_fragment_cleanup()
receiver_config.free_function = &test_tracking_free_function;
receiver_config.fragment_reassembly_buffer_size = 4;

#if defined(_MSC_VER)
strcpy_s( sender_config.name, sizeof( sender_config.name ), "sender" );
#else
strcpy( sender_config.name, "sender" );
#endif
reliable_copy_string( sender_config.name, "sender", sizeof( sender_config.name ) );
sender_config.context = &context;
sender_config.id = 0;
sender_config.transmit_packet_function = &test_transmit_packet_function;
sender_config.process_packet_function = &test_process_packet_function;

#if defined(_MSC_VER)
strcpy_s( receiver_config.name, sizeof( receiver_config.name ), "receiver" );
#else
strcpy( receiver_config.name, "receiver" );
#endif
reliable_copy_string( receiver_config.name, "receiver", sizeof( receiver_config.name ) );
receiver_config.context = &context;
receiver_config.id = 1;
receiver_config.transmit_packet_function = &test_transmit_packet_function;
Expand Down
12 changes: 2 additions & 10 deletions soak.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,13 @@ void soak_initialize()
client_config.fragment_above = 500;
server_config.fragment_above = 500;

#ifdef _MSC_VER
strcpy_s( client_config.name, sizeof( client_config.name ), "client" );
#else
strcpy( client_config.name, "client" );
#endif
reliable_copy_string( client_config.name, "client", sizeof( client_config.name ) );
client_config.context = &global_context;
client_config.id = 0;
client_config.transmit_packet_function = &test_transmit_packet_function;
client_config.process_packet_function = &test_process_packet_function;

#ifdef _MSC_VER
strcpy_s( server_config.name, sizeof( server_config.name ), "server" );
#else
strcpy( server_config.name, "server" );
#endif
reliable_copy_string( server_config.name, "server", sizeof( server_config.name ) );
server_config.context = &global_context;
server_config.id = 1;
server_config.transmit_packet_function = &test_transmit_packet_function;
Expand Down
12 changes: 2 additions & 10 deletions stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,13 @@ void stats_initialize()
client_config.fragment_above = MAX_PACKET_BYTES;
server_config.fragment_above = MAX_PACKET_BYTES;

#ifdef _MSC_VER
strcpy_s( client_config.name, sizeof( client_config.name ), "client" );
#else
strcpy( client_config.name, "client" );
#endif
reliable_copy_string( client_config.name, "client", sizeof( client_config.name ) );
client_config.context = &global_context;
client_config.id = 0;
client_config.transmit_packet_function = &test_transmit_packet_function;
client_config.process_packet_function = &test_process_packet_function;

#ifdef _MSC_VER
strcpy_s( server_config.name, sizeof( server_config.name ), "server" );
#else
strcpy( server_config.name, "server" );
#endif
reliable_copy_string( server_config.name, "server", sizeof( server_config.name ) );
server_config.context = &global_context;
server_config.id = 1;
server_config.transmit_packet_function = &test_transmit_packet_function;
Expand Down

0 comments on commit 55ab431

Please sign in to comment.