Loading

Paste #pp2vtpnsv

  1. Index: src/economy.cpp
  2. ===================================================================
  3. --- src/economy.cpp (revision 27964)
  4. +++ src/economy.cpp (working copy)
  5. @@ -294,7 +294,15 @@
  6.     Backup<CompanyByte> cur_company(_current_company, old_owner, FILE_LINE);
  7.  #ifdef ENABLE_NETWORK
  8.     /* In all cases, make spectators of clients connected to that company */
  9. -   if (_networking) NetworkClientsToSpectators(old_owner);
  10. +   if (_networking) {
  11. +       if (Company::IsValidHumanID(new_owner)) {
  12. +           /* Move clients to the new company */
  13. +           NetworkClientsToCompany(old_owner, new_owner);
  14. +       } else {
  15. +           /* Make spectators of clients connected to that company */
  16. +           NetworkClientsToSpectators(old_owner);
  17. +       }
  18. +   }
  19.  #endif /* ENABLE_NETWORK */
  20.     if (old_owner == _local_company) {
  21.         /* Single player cheated to AI company.
  22. Index: src/network/network_client.cpp
  23. ===================================================================
  24. --- src/network/network_client.cpp  (revision 27964)
  25. +++ src/network/network_client.cpp  (working copy)
  26. @@ -1219,6 +1219,26 @@
  27.  }
  28.  
  29.  /**
  30. + * Move the clients of a company to another company.
  31. + * @param cid_from The company to move the clients from.
  32. + * @param cid_to The company to move the clients to.
  33. + */
  34. +void NetworkClientsToCompany(CompanyID cid_from, CompanyID cid_to)
  35. +{
  36. +   if (!_network_server) return;
  37. +
  38. +   Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
  39. +
  40. +   NetworkClientInfo *ci;
  41. +   FOR_ALL_CLIENT_INFOS(ci) {
  42. +       if (ci->client_playas != cid_from) continue;
  43. +       NetworkServerDoMove(ci->client_id, cid_to);
  44. +   }
  45. +
  46. +   cur_company.Restore();
  47. +}
  48. +
  49. +/**
  50.   * Send the server our name.
  51.   */
  52.  void NetworkUpdateClientName()
  53. Index: src/network/network_func.h
  54. ===================================================================
  55. --- src/network/network_func.h  (revision 27964)
  56. +++ src/network/network_func.h  (working copy)
  57. @@ -53,6 +53,7 @@
  58.  
  59.  void NetworkUpdateClientInfo(ClientID client_id);
  60.  void NetworkClientsToSpectators(CompanyID cid);
  61. +void NetworkClientsToCompany(CompanyID cid_from, CompanyID cid_to);
  62.  void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password = NULL, const char *join_company_password = NULL);
  63.  void NetworkClientRequestMove(CompanyID company, const char *pass = "");
  64.  void NetworkClientSendRcon(const char *password, const char *command);

Comments