enet_multiplayer_peer.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. /**************************************************************************/
  2. /* enet_multiplayer_peer.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "enet_multiplayer_peer.h"
  31. #include "core/io/ip.h"
  32. #include "core/io/marshalls.h"
  33. #include "core/os/os.h"
  34. void ENetMultiplayerPeer::set_target_peer(int p_peer) {
  35. target_peer = p_peer;
  36. }
  37. int ENetMultiplayerPeer::get_packet_peer() const {
  38. ERR_FAIL_COND_V_MSG(!_is_active(), 1, "The multiplayer instance isn't currently active.");
  39. ERR_FAIL_COND_V(incoming_packets.size() == 0, 1);
  40. return incoming_packets.front()->get().from;
  41. }
  42. MultiplayerPeer::TransferMode ENetMultiplayerPeer::get_packet_mode() const {
  43. ERR_FAIL_COND_V_MSG(!_is_active(), TRANSFER_MODE_RELIABLE, "The multiplayer instance isn't currently active.");
  44. ERR_FAIL_COND_V(incoming_packets.size() == 0, TRANSFER_MODE_RELIABLE);
  45. return incoming_packets.front()->get().transfer_mode;
  46. }
  47. int ENetMultiplayerPeer::get_packet_channel() const {
  48. ERR_FAIL_COND_V_MSG(!_is_active(), 1, "The multiplayer instance isn't currently active.");
  49. ERR_FAIL_COND_V(incoming_packets.size() == 0, 1);
  50. int ch = incoming_packets.front()->get().channel;
  51. if (ch >= SYSCH_MAX) { // First 2 channels are reserved.
  52. return ch - SYSCH_MAX + 1;
  53. }
  54. return 0;
  55. }
  56. Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth) {
  57. ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
  58. set_refuse_new_connections(false);
  59. Ref<ENetConnection> host;
  60. host.instantiate();
  61. Error err = host->create_host_bound(bind_ip, p_port, p_max_clients, 0, p_max_channels > 0 ? p_max_channels + SYSCH_MAX : 0, p_out_bandwidth);
  62. if (err != OK) {
  63. return err;
  64. }
  65. active_mode = MODE_SERVER;
  66. unique_id = 1;
  67. connection_status = CONNECTION_CONNECTED;
  68. hosts[0] = host;
  69. return OK;
  70. }
  71. Error ENetMultiplayerPeer::create_client(const String &p_address, int p_port, int p_channel_count, int p_in_bandwidth, int p_out_bandwidth, int p_local_port) {
  72. ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
  73. set_refuse_new_connections(false);
  74. Ref<ENetConnection> host;
  75. host.instantiate();
  76. Error err;
  77. if (p_local_port) {
  78. err = host->create_host_bound(bind_ip, p_local_port, 1, 0, p_in_bandwidth, p_out_bandwidth);
  79. } else {
  80. err = host->create_host(1, 0, p_in_bandwidth, p_out_bandwidth);
  81. }
  82. if (err != OK) {
  83. return err;
  84. }
  85. unique_id = generate_unique_id();
  86. Ref<ENetPacketPeer> peer = host->connect_to_host(p_address, p_port, p_channel_count > 0 ? p_channel_count + SYSCH_MAX : 0, unique_id);
  87. if (peer.is_null()) {
  88. host->destroy();
  89. ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Couldn't connect to the ENet multiplayer server.");
  90. }
  91. // Need to wait for CONNECT event.
  92. connection_status = CONNECTION_CONNECTING;
  93. active_mode = MODE_CLIENT;
  94. peers[1] = peer;
  95. hosts[0] = host;
  96. return OK;
  97. }
  98. Error ENetMultiplayerPeer::create_mesh(int p_id) {
  99. ERR_FAIL_COND_V_MSG(p_id <= 0, ERR_INVALID_PARAMETER, "The unique ID must be greater then 0");
  100. ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
  101. active_mode = MODE_MESH;
  102. unique_id = p_id;
  103. connection_status = CONNECTION_CONNECTED;
  104. return OK;
  105. }
  106. Error ENetMultiplayerPeer::add_mesh_peer(int p_id, Ref<ENetConnection> p_host) {
  107. ERR_FAIL_COND_V(p_host.is_null(), ERR_INVALID_PARAMETER);
  108. ERR_FAIL_COND_V_MSG(active_mode != MODE_MESH, ERR_UNCONFIGURED, "The multiplayer instance is not configured as a mesh. Call 'create_mesh' first.");
  109. List<Ref<ENetPacketPeer>> host_peers;
  110. p_host->get_peers(host_peers);
  111. ERR_FAIL_COND_V_MSG(host_peers.size() != 1 || host_peers[0]->get_state() != ENetPacketPeer::STATE_CONNECTED, ERR_INVALID_PARAMETER, "The provided host must have exactly one peer in the connected state.");
  112. hosts[p_id] = p_host;
  113. peers[p_id] = host_peers[0];
  114. emit_signal(SNAME("peer_connected"), p_id);
  115. return OK;
  116. }
  117. void ENetMultiplayerPeer::_store_packet(int32_t p_source, ENetConnection::Event &p_event) {
  118. Packet packet;
  119. packet.packet = p_event.packet;
  120. packet.channel = p_event.channel_id;
  121. packet.from = p_source;
  122. if (p_event.packet->flags & ENET_PACKET_FLAG_RELIABLE) {
  123. packet.transfer_mode = TRANSFER_MODE_RELIABLE;
  124. } else if (p_event.packet->flags & ENET_PACKET_FLAG_UNSEQUENCED) {
  125. packet.transfer_mode = TRANSFER_MODE_UNRELIABLE;
  126. } else {
  127. packet.transfer_mode = TRANSFER_MODE_UNRELIABLE_ORDERED;
  128. }
  129. packet.packet->referenceCount++;
  130. incoming_packets.push_back(packet);
  131. }
  132. void ENetMultiplayerPeer::_disconnect_inactive_peers() {
  133. HashSet<int> to_drop;
  134. for (const KeyValue<int, Ref<ENetPacketPeer>> &E : peers) {
  135. if (E.value->is_active()) {
  136. continue;
  137. }
  138. to_drop.insert(E.key);
  139. }
  140. for (const int &P : to_drop) {
  141. peers.erase(P);
  142. if (hosts.has(P)) {
  143. hosts.erase(P);
  144. }
  145. ERR_CONTINUE(active_mode == MODE_CLIENT && P != TARGET_PEER_SERVER);
  146. emit_signal(SNAME("peer_disconnected"), P);
  147. }
  148. }
  149. void ENetMultiplayerPeer::poll() {
  150. ERR_FAIL_COND_MSG(!_is_active(), "The multiplayer instance isn't currently active.");
  151. _pop_current_packet();
  152. _disconnect_inactive_peers();
  153. switch (active_mode) {
  154. case MODE_CLIENT: {
  155. if (!peers.has(1)) {
  156. close();
  157. return;
  158. }
  159. ENetConnection::Event event;
  160. ENetConnection::EventType ret = hosts[0]->service(0, event);
  161. do {
  162. if (ret == ENetConnection::EVENT_CONNECT) {
  163. connection_status = CONNECTION_CONNECTED;
  164. emit_signal(SNAME("peer_connected"), 1);
  165. } else if (ret == ENetConnection::EVENT_DISCONNECT) {
  166. if (connection_status == CONNECTION_CONNECTED) {
  167. // Client just disconnected from server.
  168. emit_signal(SNAME("peer_disconnected"), 1);
  169. }
  170. close();
  171. } else if (ret == ENetConnection::EVENT_RECEIVE) {
  172. _store_packet(1, event);
  173. } else if (ret != ENetConnection::EVENT_NONE) {
  174. close(); // Error.
  175. }
  176. } while (hosts.has(0) && hosts[0]->check_events(ret, event) > 0);
  177. } break;
  178. case MODE_SERVER: {
  179. ENetConnection::Event event;
  180. ENetConnection::EventType ret = hosts[0]->service(0, event);
  181. do {
  182. if (ret == ENetConnection::EVENT_CONNECT) {
  183. if (is_refusing_new_connections()) {
  184. event.peer->reset();
  185. continue;
  186. }
  187. // Client joined with invalid ID, probably trying to exploit us.
  188. if (event.data < 2 || peers.has((int)event.data)) {
  189. event.peer->reset();
  190. continue;
  191. }
  192. int id = event.data;
  193. event.peer->set_meta(SNAME("_net_id"), id);
  194. peers[id] = event.peer;
  195. emit_signal(SNAME("peer_connected"), id);
  196. } else if (ret == ENetConnection::EVENT_DISCONNECT) {
  197. int id = event.peer->get_meta(SNAME("_net_id"));
  198. if (!peers.has(id)) {
  199. // Never fully connected.
  200. continue;
  201. }
  202. emit_signal(SNAME("peer_disconnected"), id);
  203. peers.erase(id);
  204. } else if (ret == ENetConnection::EVENT_RECEIVE) {
  205. int32_t source = event.peer->get_meta(SNAME("_net_id"));
  206. _store_packet(source, event);
  207. } else if (ret != ENetConnection::EVENT_NONE) {
  208. close(); // Error
  209. }
  210. } while (hosts.has(0) && hosts[0]->check_events(ret, event) > 0);
  211. } break;
  212. case MODE_MESH: {
  213. HashSet<int> to_drop;
  214. for (KeyValue<int, Ref<ENetConnection>> &E : hosts) {
  215. ENetConnection::Event event;
  216. ENetConnection::EventType ret = E.value->service(0, event);
  217. do {
  218. if (ret == ENetConnection::EVENT_CONNECT) {
  219. event.peer->reset();
  220. } else if (ret == ENetConnection::EVENT_RECEIVE) {
  221. _store_packet(E.key, event);
  222. } else if (ret == ENetConnection::EVENT_NONE) {
  223. break; // Keep polling the others.
  224. } else {
  225. to_drop.insert(E.key); // Error or disconnect.
  226. break; // Keep polling the others.
  227. }
  228. } while (E.value->check_events(ret, event) > 0);
  229. }
  230. for (const int &P : to_drop) {
  231. if (peers.has(P)) {
  232. emit_signal(SNAME("peer_disconnected"), P);
  233. peers.erase(P);
  234. }
  235. hosts.erase(P);
  236. }
  237. } break;
  238. default:
  239. return;
  240. }
  241. }
  242. bool ENetMultiplayerPeer::is_server() const {
  243. return active_mode == MODE_SERVER;
  244. }
  245. bool ENetMultiplayerPeer::is_server_relay_supported() const {
  246. return active_mode == MODE_SERVER || active_mode == MODE_CLIENT;
  247. }
  248. void ENetMultiplayerPeer::disconnect_peer(int p_peer, bool p_force) {
  249. ERR_FAIL_COND(!_is_active() || !peers.has(p_peer));
  250. peers[p_peer]->peer_disconnect(0); // Will be removed during next poll.
  251. if (active_mode == MODE_CLIENT || active_mode == MODE_SERVER) {
  252. hosts[0]->flush();
  253. } else {
  254. ERR_FAIL_COND(!hosts.has(p_peer));
  255. hosts[p_peer]->flush();
  256. }
  257. if (p_force) {
  258. peers.erase(p_peer);
  259. if (hosts.has(p_peer)) {
  260. hosts.erase(p_peer);
  261. }
  262. if (active_mode == MODE_CLIENT) {
  263. hosts.clear(); // Avoid flushing again.
  264. close();
  265. }
  266. }
  267. }
  268. void ENetMultiplayerPeer::close() {
  269. if (!_is_active()) {
  270. return;
  271. }
  272. _pop_current_packet();
  273. for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) {
  274. if (E.value.is_valid() && E.value->get_state() == ENetPacketPeer::STATE_CONNECTED) {
  275. E.value->peer_disconnect_now(0);
  276. }
  277. }
  278. for (KeyValue<int, Ref<ENetConnection>> &E : hosts) {
  279. E.value->flush();
  280. }
  281. active_mode = MODE_NONE;
  282. incoming_packets.clear();
  283. peers.clear();
  284. hosts.clear();
  285. unique_id = 0;
  286. connection_status = CONNECTION_DISCONNECTED;
  287. set_refuse_new_connections(false);
  288. }
  289. int ENetMultiplayerPeer::get_available_packet_count() const {
  290. return incoming_packets.size();
  291. }
  292. Error ENetMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
  293. ERR_FAIL_COND_V_MSG(incoming_packets.size() == 0, ERR_UNAVAILABLE, "No incoming packets available.");
  294. _pop_current_packet();
  295. current_packet = incoming_packets.front()->get();
  296. incoming_packets.pop_front();
  297. *r_buffer = (const uint8_t *)(current_packet.packet->data);
  298. r_buffer_size = current_packet.packet->dataLength;
  299. return OK;
  300. }
  301. Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
  302. ERR_FAIL_COND_V_MSG(!_is_active(), ERR_UNCONFIGURED, "The multiplayer instance isn't currently active.");
  303. ERR_FAIL_COND_V_MSG(connection_status != CONNECTION_CONNECTED, ERR_UNCONFIGURED, "The multiplayer instance isn't currently connected to any server or client.");
  304. ERR_FAIL_COND_V_MSG(target_peer != 0 && !peers.has(ABS(target_peer)), ERR_INVALID_PARAMETER, vformat("Invalid target peer: %d", target_peer));
  305. ERR_FAIL_COND_V(active_mode == MODE_CLIENT && !peers.has(1), ERR_BUG);
  306. int packet_flags = 0;
  307. int channel = SYSCH_RELIABLE;
  308. int tr_channel = get_transfer_channel();
  309. switch (get_transfer_mode()) {
  310. case TRANSFER_MODE_UNRELIABLE: {
  311. packet_flags = ENET_PACKET_FLAG_UNSEQUENCED | ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT;
  312. channel = SYSCH_UNRELIABLE;
  313. } break;
  314. case TRANSFER_MODE_UNRELIABLE_ORDERED: {
  315. packet_flags = ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT;
  316. channel = SYSCH_UNRELIABLE;
  317. } break;
  318. case TRANSFER_MODE_RELIABLE: {
  319. packet_flags = ENET_PACKET_FLAG_RELIABLE;
  320. channel = SYSCH_RELIABLE;
  321. } break;
  322. }
  323. if (tr_channel > 0) {
  324. channel = SYSCH_MAX + tr_channel - 1;
  325. }
  326. #ifdef DEBUG_ENABLED
  327. if ((packet_flags & ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT) && p_buffer_size > ENET_HOST_DEFAULT_MTU) {
  328. WARN_PRINT_ONCE(vformat("Sending %d bytes unreliably which is above the MTU (%d), this will result in higher packet loss", p_buffer_size, ENET_HOST_DEFAULT_MTU));
  329. }
  330. #endif
  331. ENetPacket *packet = enet_packet_create(nullptr, p_buffer_size, packet_flags);
  332. memcpy(&packet->data[0], p_buffer, p_buffer_size);
  333. if (is_server()) {
  334. if (target_peer == 0) {
  335. hosts[0]->broadcast(channel, packet);
  336. } else if (target_peer < 0) {
  337. // Send to all but one and make copies for sending.
  338. int exclude = -target_peer;
  339. for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) {
  340. if (E.key == exclude) {
  341. continue;
  342. }
  343. E.value->send(channel, packet);
  344. }
  345. _destroy_unused(packet);
  346. } else {
  347. peers[target_peer]->send(channel, packet);
  348. }
  349. ERR_FAIL_COND_V(!hosts.has(0), ERR_BUG);
  350. hosts[0]->flush();
  351. } else if (active_mode == MODE_CLIENT) {
  352. peers[1]->send(channel, packet); // Send to server for broadcast.
  353. ERR_FAIL_COND_V(!hosts.has(0), ERR_BUG);
  354. hosts[0]->flush();
  355. } else {
  356. if (target_peer <= 0) {
  357. int exclude = ABS(target_peer);
  358. for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) {
  359. if (E.key == exclude) {
  360. continue;
  361. }
  362. E.value->send(channel, packet);
  363. ERR_CONTINUE(!hosts.has(E.key));
  364. hosts[E.key]->flush();
  365. }
  366. _destroy_unused(packet);
  367. } else {
  368. peers[target_peer]->send(channel, packet);
  369. ERR_FAIL_COND_V(!hosts.has(target_peer), ERR_BUG);
  370. hosts[target_peer]->flush();
  371. }
  372. }
  373. return OK;
  374. }
  375. int ENetMultiplayerPeer::get_max_packet_size() const {
  376. return 1 << 24; // Anything is good
  377. }
  378. void ENetMultiplayerPeer::_pop_current_packet() {
  379. if (current_packet.packet) {
  380. current_packet.packet->referenceCount--;
  381. _destroy_unused(current_packet.packet);
  382. current_packet.packet = nullptr;
  383. current_packet.from = 0;
  384. current_packet.channel = -1;
  385. }
  386. }
  387. MultiplayerPeer::ConnectionStatus ENetMultiplayerPeer::get_connection_status() const {
  388. return connection_status;
  389. }
  390. int ENetMultiplayerPeer::get_unique_id() const {
  391. ERR_FAIL_COND_V_MSG(!_is_active(), 0, "The multiplayer instance isn't currently active.");
  392. return unique_id;
  393. }
  394. void ENetMultiplayerPeer::set_refuse_new_connections(bool p_enabled) {
  395. #ifdef GODOT_ENET
  396. if (_is_active()) {
  397. for (KeyValue<int, Ref<ENetConnection>> &E : hosts) {
  398. E.value->refuse_new_connections(p_enabled);
  399. }
  400. }
  401. #endif
  402. MultiplayerPeer::set_refuse_new_connections(p_enabled);
  403. }
  404. Ref<ENetConnection> ENetMultiplayerPeer::get_host() const {
  405. ERR_FAIL_COND_V(!_is_active(), nullptr);
  406. ERR_FAIL_COND_V(active_mode == MODE_MESH, nullptr);
  407. return hosts[0];
  408. }
  409. Ref<ENetPacketPeer> ENetMultiplayerPeer::get_peer(int p_id) const {
  410. ERR_FAIL_COND_V(!_is_active(), nullptr);
  411. ERR_FAIL_COND_V(!peers.has(p_id), nullptr);
  412. ERR_FAIL_COND_V(active_mode == MODE_CLIENT && p_id != 1, nullptr);
  413. return peers[p_id];
  414. }
  415. void ENetMultiplayerPeer::_destroy_unused(ENetPacket *p_packet) {
  416. if (p_packet->referenceCount == 0) {
  417. enet_packet_destroy(p_packet);
  418. }
  419. }
  420. void ENetMultiplayerPeer::_bind_methods() {
  421. ClassDB::bind_method(D_METHOD("create_server", "port", "max_clients", "max_channels", "in_bandwidth", "out_bandwidth"), &ENetMultiplayerPeer::create_server, DEFVAL(32), DEFVAL(0), DEFVAL(0), DEFVAL(0));
  422. ClassDB::bind_method(D_METHOD("create_client", "address", "port", "channel_count", "in_bandwidth", "out_bandwidth", "local_port"), &ENetMultiplayerPeer::create_client, DEFVAL(0), DEFVAL(0), DEFVAL(0), DEFVAL(0));
  423. ClassDB::bind_method(D_METHOD("create_mesh", "unique_id"), &ENetMultiplayerPeer::create_mesh);
  424. ClassDB::bind_method(D_METHOD("add_mesh_peer", "peer_id", "host"), &ENetMultiplayerPeer::add_mesh_peer);
  425. ClassDB::bind_method(D_METHOD("set_bind_ip", "ip"), &ENetMultiplayerPeer::set_bind_ip);
  426. ClassDB::bind_method(D_METHOD("get_host"), &ENetMultiplayerPeer::get_host);
  427. ClassDB::bind_method(D_METHOD("get_peer", "id"), &ENetMultiplayerPeer::get_peer);
  428. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "host", PROPERTY_HINT_RESOURCE_TYPE, "ENetConnection", PROPERTY_USAGE_NONE), "", "get_host");
  429. }
  430. ENetMultiplayerPeer::ENetMultiplayerPeer() {
  431. bind_ip = IPAddress("*");
  432. }
  433. ENetMultiplayerPeer::~ENetMultiplayerPeer() {
  434. if (_is_active()) {
  435. close();
  436. }
  437. }
  438. // Sets IP for ENet to bind when using create_server or create_client
  439. // if no IP is set, then ENet bind to ENET_HOST_ANY
  440. void ENetMultiplayerPeer::set_bind_ip(const IPAddress &p_ip) {
  441. ERR_FAIL_COND_MSG(!p_ip.is_valid() && !p_ip.is_wildcard(), vformat("Invalid bind IP address: %s", String(p_ip)));
  442. bind_ip = p_ip;
  443. }