diff options
author | truelight <truelight@openttd.org> | 2004-12-21 17:31:10 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2004-12-21 17:31:10 +0000 |
commit | 19e384261584366cfc339a93eff96d7c411a6541 (patch) | |
tree | 3ac5effcddc64108d8ab997ed95c5f2a2f7d1bab /network_server.c | |
parent | 8ab0190c294b243b9544203a7cdaf6d3c40718d5 (diff) | |
download | openttd-19e384261584366cfc339a93eff96d7c411a6541.tar.xz |
(svn r1204) -Add: [Network] Added some cheaters-protection (money-cheat mostly)
Diffstat (limited to 'network_server.c')
-rw-r--r-- | network_server.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/network_server.c b/network_server.c index 59665cfa9..a42d7b5c8 100644 --- a/network_server.c +++ b/network_server.c @@ -785,16 +785,29 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); return; } - if (cp->cmd == CMD_PLAYER_CTRL) { - if (cp->p1 == 0) - // UGLY! p2 is mis-used to get the client-id in CmdPlayerCtrl - cp->p2 = cs - _clients; - else { - /* We do NOT allow any client to send any PLAYER_CTRL packet.. - (they can delete random players with it if they like */ - SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); - return; - } + switch (cp->cmd) { + /* Player_ctrl is not always allowed */ + case CMD_PLAYER_CTRL: + { + /* cp->p1 == 0, is allowed */ + if (cp->p1 == 0) { + // UGLY! p2 is mis-used to get the client-id in CmdPlayerCtrl + cp->p2 = cs - _clients; + } else { + /* The rest are cheats */ + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_CHEATER); + return; + } + } break; + + /* Don't allow those commands if server == advertising (considered cheating) */ + case CMD_MONEY_CHEAT: + { + if (_network_advertise) { + SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_CHEATER); + return; + } + } break; } |