18
18
19
19
#include "network/protocols/server_lobby.hpp"
20
20
21
- // #include "addons/addon.hpp"
22
- // #include "config/user_config.hpp"
23
21
#include "items/network_item_manager.hpp"
24
- // #include "items/powerup_manager.hpp"
25
22
#include "items/attachment.hpp"
26
- // #include "karts/controller/player_controller.hpp"
27
23
#include "karts/kart_properties.hpp"
28
24
#include "karts/kart_properties_manager.hpp"
29
25
#include "karts/official_karts.hpp"
34
30
#include "network/database_connector.hpp"
35
31
#include "network/event.hpp"
36
32
#include "network/game_setup.hpp"
37
- // #include "network/network.hpp"
38
33
#include "network/network_config.hpp"
39
34
#include "network/network_player_profile.hpp"
40
- // #include "network/peer_vote.hpp"
41
35
#include "network/protocol_manager.hpp"
42
36
#include "network/protocols/connect_to_peer.hpp"
43
- // #include "network/protocols/command_permissions.hpp"
44
37
#include "network/protocols/game_protocol.hpp"
45
38
#include "network/protocols/game_events_protocol.hpp"
46
39
#include "network/protocols/ranking.hpp"
47
40
#include "network/race_event_manager.hpp"
48
41
#include "network/server_config.hpp"
49
- // #include "network/socket_address.hpp"
50
42
#include "network/stk_host.hpp"
51
43
#include "network/stk_ipv6.hpp"
52
44
#include "network/stk_peer.hpp"
53
- // #include "online/online_profile.hpp"
54
45
#include "online/request_manager.hpp"
55
46
#include "online/xml_request.hpp"
56
- // #include "race/race_manager.hpp"
57
47
#include "tracks/check_manager.hpp"
58
48
#include "tracks/track.hpp"
59
49
#include "tracks/track_manager.hpp"
60
50
#include "utils/game_info.hpp"
61
51
#include "utils/hit_processor.hpp"
62
- // #include "utils/log.hpp"
63
- // #include "utils/random_generator.hpp"
64
- // #include "utils/string_utils.hpp"
65
- // #include "utils/time.hpp"
66
52
#include "utils/translation.hpp"
67
53
68
54
#include <algorithm>
@@ -171,7 +157,6 @@ ServerLobby::ServerLobby() : LobbyProtocol()
171
157
m_troll_active = ServerConfig::m_troll_active;
172
158
173
159
m_hit_processor = std::make_shared<HitProcessor>(this);
174
- // feb16 remove this
175
160
176
161
m_available_teams = ServerConfig::m_init_available_teams;
177
162
@@ -431,7 +416,6 @@ void ServerLobby::setup()
431
416
m_winner_peer_id = 0;
432
417
m_client_starting_time = 0;
433
418
m_ai_count = 0;
434
- getHitProcessor()->m_collecting_teammate_hit_info = false;
435
419
auto players = STKHost::get()->getPlayersForNewGame();
436
420
if (m_game_setup->isGrandPrix() && !m_game_setup->isGrandPrixStarted())
437
421
{
@@ -527,12 +511,8 @@ void ServerLobby::handleChat(Event* event)
527
511
event->getPeer()->getConsecutiveMessages() >
528
512
ServerConfig::m_chat_consecutive_interval / 2)
529
513
{
530
- NetworkString* chat = getNetworkString();
531
- chat->setSynchronous(true);
532
- core::stringw warn = "Spam detected";
533
- chat->addUInt8(LE_CHAT).encodeString16(warn);
534
- event->getPeer()->sendPacket(chat, PRM_RELIABLE);
535
- delete chat;
514
+ std::string msg = "Spam detected";
515
+ sendStringToPeer(msg, event->getPeerSP());
536
516
return;
537
517
}
538
518
@@ -547,12 +527,8 @@ void ServerLobby::handleChat(Event* event)
547
527
548
528
if (!StringUtils::startsWith(message_utf8, prefix))
549
529
{
550
- NetworkString* chat = getNetworkString();
551
- chat->setSynchronous(true);
552
- core::stringw warn = "Don't try to impersonate others!";
553
- chat->addUInt8(LE_CHAT).encodeString16(warn);
554
- event->getPeer()->sendPacket(chat, PRM_RELIABLE);
555
- delete chat;
530
+ std::string warn = "Don't try to impersonate others!";
531
+ sendStringToPeer(warn, event->getPeerSP());
556
532
return;
557
533
}
558
534
@@ -1163,7 +1139,7 @@ void ServerLobby::asynchronousUpdate()
1163
1139
// reset
1164
1140
1165
1141
// maybe this is not the best place for this?
1166
- getHitProcessor()->m_last_teammate_hit_msg = 0 ;
1142
+ getHitProcessor()->resetLastHits() ;
1167
1143
1168
1144
if (m_end_voting_period.load() == 0)
1169
1145
return;
@@ -1930,17 +1906,7 @@ void ServerLobby::update(int ticks)
1930
1906
}
1931
1907
}
1932
1908
}
1933
- if (getHitProcessor()->m_teammate_swatter_punish.size() > 0)
1934
- {
1935
- // punish players who swattered teammates
1936
- for (auto& kart : getHitProcessor()->m_teammate_swatter_punish)
1937
- {
1938
- kart->getAttachment()->set(Attachment::ATTACH_ANVIL,
1939
- stk_config->time2Ticks(kart->getKartProperties()->getAnvilDuration()));
1940
- kart->adjustSpeed(kart->getKartProperties()->getAnvilSpeedFactor());
1941
- }
1942
- getHitProcessor()->m_teammate_swatter_punish.clear();
1943
- }
1909
+ getHitProcessor()->punishSwatterHits();
1944
1910
}
1945
1911
}
1946
1912
if (m_state.load() == WAITING_FOR_START_GAME) {
0 commit comments