773 callback = NetworkRecv_uint8(p); |
773 callback = NetworkRecv_uint8(p); |
774 |
774 |
775 ci = DEREF_CLIENT_INFO(cs); |
775 ci = DEREF_CLIENT_INFO(cs); |
776 // Only CMD_PLAYER_CTRL is always allowed, for the rest, playas needs |
776 // Only CMD_PLAYER_CTRL is always allowed, for the rest, playas needs |
777 // to match the player in the packet |
777 // to match the player in the packet |
778 if (cp->cmd != CMD_PLAYER_CTRL && ci->client_playas-1 != cp->player) { |
778 if (!(cp->cmd == CMD_PLAYER_CTRL && cp->p1 == 0) && ci->client_playas-1 != cp->player) { |
779 // The player did a command with the wrong player_id.. bad!! |
779 // The player did a command with the wrong player_id.. bad!! |
780 SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); |
780 SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); |
781 return; |
781 return; |
782 } |
782 } |
783 if (cp->cmd == CMD_PLAYER_CTRL) { |
783 if (cp->cmd == CMD_PLAYER_CTRL) { |
784 // UGLY! p2 is mis-used to get the client-id in CmdPlayerCtrl |
784 if (cp->p1 == 0) |
785 cp->p2 = cs - _clients; |
785 // UGLY! p2 is mis-used to get the client-id in CmdPlayerCtrl |
|
786 cp->p2 = cs - _clients; |
|
787 else { |
|
788 /* We do NOT allow any client to send any PLAYER_CTRL packet.. |
|
789 (they can delete random players with it if they like */ |
|
790 SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); |
|
791 return; |
|
792 } |
786 } |
793 } |
787 |
794 |
788 |
795 |
789 // The frame can be executed in the same frame as the next frame-packet |
796 // The frame can be executed in the same frame as the next frame-packet |
790 // That frame just before that frame is saved in _frame_counter_max |
797 // That frame just before that frame is saved in _frame_counter_max |