783 if (!(cp->cmd == CMD_PLAYER_CTRL && cp->p1 == 0) && ci->client_playas-1 != cp->player) { |
783 if (!(cp->cmd == CMD_PLAYER_CTRL && cp->p1 == 0) && ci->client_playas-1 != cp->player) { |
784 // The player did a command with the wrong player_id.. bad!! |
784 // The player did a command with the wrong player_id.. bad!! |
785 SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); |
785 SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); |
786 return; |
786 return; |
787 } |
787 } |
788 if (cp->cmd == CMD_PLAYER_CTRL) { |
788 switch (cp->cmd) { |
789 if (cp->p1 == 0) |
789 /* Player_ctrl is not always allowed */ |
790 // UGLY! p2 is mis-used to get the client-id in CmdPlayerCtrl |
790 case CMD_PLAYER_CTRL: |
791 cp->p2 = cs - _clients; |
791 { |
792 else { |
792 /* cp->p1 == 0, is allowed */ |
793 /* We do NOT allow any client to send any PLAYER_CTRL packet.. |
793 if (cp->p1 == 0) { |
794 (they can delete random players with it if they like */ |
794 // UGLY! p2 is mis-used to get the client-id in CmdPlayerCtrl |
795 SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); |
795 cp->p2 = cs - _clients; |
796 return; |
796 } else { |
797 } |
797 /* The rest are cheats */ |
|
798 SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_CHEATER); |
|
799 return; |
|
800 } |
|
801 } break; |
|
802 |
|
803 /* Don't allow those commands if server == advertising (considered cheating) */ |
|
804 case CMD_MONEY_CHEAT: |
|
805 { |
|
806 if (_network_advertise) { |
|
807 SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_CHEATER); |
|
808 return; |
|
809 } |
|
810 } break; |
798 } |
811 } |
799 |
812 |
800 |
813 |
801 // The frame can be executed in the same frame as the next frame-packet |
814 // The frame can be executed in the same frame as the next frame-packet |
802 // That frame just before that frame is saved in _frame_counter_max |
815 // That frame just before that frame is saved in _frame_counter_max |