Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.
/ DF Public archive

Commit

Permalink
Game: Allow to kick bots in custom game
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymaster committed Dec 30, 2015
1 parent d792b78 commit 57b0cc9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
15 changes: 9 additions & 6 deletions DF Sources/g_game.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3981,7 +3981,7 @@ procedure GameCommands(P: SArray);
end
else if cmd = 'kick' then
begin
if g_Game_IsServer and g_Game_IsNet then
if g_Game_IsServer and (gGameSettings.GameType <> GT_SINGLE) then
begin
if Length(P) < 2 then
begin
Expand All @@ -3994,20 +3994,22 @@ procedure GameCommands(P: SArray);
Exit;
end;

pl := g_Net_Client_ByName(P[1]);
if g_Game_IsNet then
pl := g_Net_Client_ByName(P[1]);
if (pl <> nil) then
enet_peer_disconnect(pl^.Peer, NET_DISC_KICK)
else if gPlayers <> nil then
for a := Low(gPlayers) to High(gPlayers) do
if gPlayers[a] <> nil then
if gPlayers[a] is TBot then
if (gPlayers[a] is TBot) and (gPlayers[a].Name = P[1]) then
begin
gPlayers[a].Lives := 0;
gPlayers[a].Kill(K_SIMPLEKILL, 0, 0);
g_Console_Add(Format(_lc[I_PLAYER_LEAVE], [gPlayers[a].Name]), True);
g_Player_Remove(gPlayers[a].UID);
end;
end;
end else
g_Console_Add(_lc[I_MSG_GM_UNAVAIL]);
end
else if cmd = 'kick_id' then
begin
Expand All @@ -4030,7 +4032,8 @@ procedure GameCommands(P: SArray);
if NetClients[a].Used and (NetClients[a].Peer <> nil) then
enet_peer_disconnect(NetClients[a].Peer, NET_DISC_KICK);
end;
end;
end else
g_Console_Add(_lc[I_MSG_SERVERONLY]);
end
else if cmd = 'clientlist' then
begin
Expand Down Expand Up @@ -4098,7 +4101,7 @@ procedure GameCommands(P: SArray);
gExit := EXIT_SIMPLE;
EndGame;
end;

g_Game_StartClient(NetClientIP, NetClientPort);
end
else if (cmd = 'addbot') or
Expand Down
7 changes: 5 additions & 2 deletions DF Sources/g_player.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5411,8 +5411,11 @@ TTarget = record
begin // Èãðîê
with g_Player_Get(Target.UID) do
begin
Target.X := FObj.X;
Target.Y := FObj.Y;
if not IsBadReadPtr(@FObj, SizeOf(TObj)) then
begin
Target.X := FObj.X;
Target.Y := FObj.Y;
end;
end;

Target.cX := Target.X + PLAYER_RECT_CX;
Expand Down

0 comments on commit 57b0cc9

Please sign in to comment.