@@ -18,6 +18,9 @@ CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
1818 IGameController(pGameServer)
1919{
2020 m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME;
21+
22+ if (g_Config.m_SvKoBo3 )
23+ m_pGameType = " KO-Run" ;
2124 m_GameFlags = protocol7::GAMEFLAG_RACE;
2225}
2326
@@ -27,9 +30,10 @@ CScore *CGameControllerDDRace::Score()
2730{
2831 return GameServer ()->Score ();
2932}
30-
33+ static bool has_finished = false ;
3134void CGameControllerDDRace::KO_Start ()
3235{
36+ has_finished = false ;
3337 bool finished = (GameServer ()->ko_player_count <= 1 );
3438 if (finished)
3539 {
@@ -60,6 +64,62 @@ void CGameControllerDDRace::KO_Start()
6064 return ;
6165 }
6266
67+ if (g_Config.m_SvKoBo3 )
68+ {
69+ int wins = -1 ;
70+ GameServer ()->ko_player_count = 0 ;
71+ for (int i = 0 ; i < MAX_CLIENTS; i++)
72+ {
73+ if (!GameServer ()->PlayerExists (i))
74+ continue ;
75+
76+ if (GameServer ()->m_apPlayers [i]->GetTeam () == TEAM_SPECTATORS)
77+ continue ;
78+
79+ GameServer ()->ko_player_count ++;
80+
81+ if (GameServer ()->m_apPlayers [i]->m_player_eliminated )
82+ continue ;
83+
84+ wins = GameServer ()->m_apPlayers [i]->m_ko_wins ;
85+
86+ if (wins >= 2 )
87+ {
88+ char aBuf[256 ];
89+ str_format (aBuf, sizeof (aBuf), " %s wins!" , Server ()->ClientName (i));
90+ GameServer ()->SendBroadcast (aBuf, -1 , true );
91+ GameServer ()->SendChat (-1 , TEAM_ALL, aBuf);
92+ }
93+ }
94+
95+ char aBuf[256 ];
96+ for (int i = 0 ; i < MAX_CLIENTS; i++)
97+ {
98+ if (!GameServer ()->PlayerExists (i))
99+ {
100+ continue ;
101+ }
102+
103+ if (GameServer ()->m_apPlayers [i]->GetTeam () == TEAM_SPECTATORS)
104+ continue ;
105+
106+ GameServer ()->m_apPlayers [i]->KillCharacter (WEAPON_WORLD);
107+ GameServer ()->m_apPlayers [i]->m_player_eliminated = false ;
108+
109+ str_format (aBuf, sizeof (aBuf), " %s : %i" , Server ()->ClientName (i), GameServer ()->m_apPlayers [i]->m_ko_wins );
110+ GameServer ()->SendChat (-1 , TEAM_ALL, aBuf);
111+ }
112+
113+ if (wins >= 2 )
114+ {
115+ GameServer ()->ko_game = false ;
116+ GameServer ()->ko_round = 0 ;
117+ GameServer ()->ko_player_count = 0 ;
118+ g_Config.m_SvSpectatorSlots = 0 ;
119+ return ;
120+ }
121+ }
122+
63123 m_RoundStartTick = Server ()->Tick ();
64124
65125 GameServer ()->ko_round ++;
@@ -217,34 +277,64 @@ void CGameControllerDDRace::HandleCharacterTiles(CCharacter *pChr, int MapIndex)
217277
218278 pPlayer->KillCharacter (WEAPON_GAME, false );
219279
220- if (GameServer ()->ko_player_count <= 2 && GameServer ()->ko_players_finished == 1 )
221- {
222- str_format (aBuf, sizeof (aBuf), " %s Wins!" , Server ()->ClientName (pPlayer->GetCid ()));
223- pPlayer->m_elimination = -2 ;
224- GameServer ()->SendBroadcast (aBuf, -1 , true );
225- GameServer ()->SendChat (-1 , TEAM_ALL, aBuf);
280+ if (!has_finished)
281+ {
282+ pPlayer->m_ko_wins ++;
283+ has_finished = true ;
284+ }
226285
227- for (int i = 0 ; i < MAX_CLIENTS; i++)
286+ if (GameServer ()->ko_player_count <= 2 && GameServer ()->ko_players_finished == 1 )
287+ {
288+ if (pPlayer->m_ko_wins < 2 && g_Config.m_SvKoBo3 )
228289 {
229- if (! GameServer ()-> PlayerExists (i) || i == pPlayer-> GetCid () )
290+ for ( int i = 0 ; i < MAX_CLIENTS; i++ )
230291 {
231- continue ;
292+ if (!GameServer ()->PlayerExists (i))
293+ {
294+ continue ;
295+ }
296+
297+ if (GameServer ()->m_apPlayers [i]->GetTeam () == TEAM_SPECTATORS)
298+ continue ;
299+
300+ GameServer ()->m_apPlayers [i]->KillCharacter (WEAPON_WORLD);
301+ GameServer ()->m_apPlayers [i]->m_player_eliminated = false ;
302+
303+ str_format (aBuf, sizeof (aBuf), " %s : %i" , Server ()->ClientName (i), GameServer ()->m_apPlayers [i]->m_ko_wins );
304+ GameServer ()->SendChat (-1 , TEAM_ALL, aBuf);
232305 }
233-
234- GameServer ()->m_apPlayers [i]->KillCharacter (WEAPON_WORLD);
235- if (GameServer ()->m_apPlayers [i]->m_player_eliminated )
306+ }else
307+ {
308+ str_format (aBuf, sizeof (aBuf), " %s Wins!" , Server ()->ClientName (pPlayer->GetCid ()));
309+ pPlayer->m_elimination = -2 ;
310+ GameServer ()->SendBroadcast (aBuf, -1 , true );
311+ GameServer ()->SendChat (-1 , TEAM_ALL, aBuf);
312+
313+ for (int i = 0 ; i < MAX_CLIENTS; i++)
236314 {
237- str_format (aBuf, sizeof (aBuf), " you survived until round %i!" , GameServer ()->m_apPlayers [i]->m_ko_round );
238- GameServer ()->SendChatTarget (i, aBuf);
239- continue ;
315+ if (!GameServer ()->PlayerExists (i) || i == pPlayer->GetCid ())
316+ {
317+ continue ;
318+ }
319+
320+ GameServer ()->m_apPlayers [i]->KillCharacter (WEAPON_WORLD);
321+ if (GameServer ()->m_apPlayers [i]->m_player_eliminated && !g_Config.m_SvKoBo3 )
322+ {
323+ str_format (aBuf, sizeof (aBuf), " you survived until round %i!" , GameServer ()->m_apPlayers [i]->m_ko_round );
324+ GameServer ()->SendChatTarget (i, aBuf);
325+ continue ;
326+ }
240327 }
241- }
242328
243- GameServer ()->ko_game = false ;
244- }else
329+ GameServer ()->ko_game = false ;
330+ }
331+ }else if (!g_Config.m_SvKoBo3 )
245332 {
246- str_format (aBuf, sizeof (aBuf), " %i spots left!" , GameServer ()->ko_player_count -GameServer ()->ko_players_tobe_eliminated -GameServer ()->ko_players_finished );
247- GameServer ()->SendChat (-1 , TEAM_ALL, aBuf);
333+ if (GameServer ()->ko_player_count -GameServer ()->ko_players_tobe_eliminated -GameServer ()->ko_players_finished >= 0 )
334+ {
335+ str_format (aBuf, sizeof (aBuf), " %i spots left!" , GameServer ()->ko_player_count -GameServer ()->ko_players_tobe_eliminated -GameServer ()->ko_players_finished );
336+ GameServer ()->SendChat (-1 , TEAM_ALL, aBuf);
337+ }
248338 }
249339 }
250340
@@ -373,7 +463,9 @@ void CGameControllerDDRace::Tick()
373463
374464 if (playersIn < 1 )
375465 {
376- m_Warmup = 10 * Server ()->TickSpeed ();
466+ m_Warmup = 5 * Server ()->TickSpeed ();
467+ if (!g_Config.m_SvKoBo3 )
468+ m_Warmup = 10 * Server ()->TickSpeed ();
377469 m_Timer = 1 ;
378470 }
379471 }
0 commit comments