<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40269 >

As requested in PR#40184, the trivial but useful civclient
player accessor helper functions that are used throught the
new editor code.


----------------------------------------------------------------------
嘘つきは全然好きじゃない。
diff --git a/client/civclient.c b/client/civclient.c
index 3c4df8e..f614a6f 100644
--- a/client/civclient.c
+++ b/client/civclient.c
@@ -808,3 +808,38 @@ bool is_server_busy(void)
 {
   return server_busy;
 }
+
+/****************************************************************************
+  ...
+****************************************************************************/
+bool client_is_global_observer(void)
+{
+  return client.conn.playing == NULL && client.conn.observer == TRUE;
+}
+
+/****************************************************************************
+  ...
+****************************************************************************/
+int client_player_number(void)
+{
+  if (client.conn.playing == NULL) {
+    return -1;
+  }
+  return player_number(client.conn.playing);
+}
+
+/****************************************************************************
+  Either controlling or observing.
+****************************************************************************/
+bool client_has_player(void)
+{
+  return client.conn.playing != NULL;
+}
+
+/****************************************************************************
+  Either controlling or observing.
+****************************************************************************/
+struct player *client_player(void)
+{
+  return client.conn.playing;
+}
diff --git a/client/civclient.h b/client/civclient.h
index 2af79f0..d149d60 100644
--- a/client/civclient.h
+++ b/client/civclient.h
@@ -74,6 +74,10 @@ extern struct civclient {
 
 void wait_till_request_got_processed(int request_id);
 bool client_is_observer(void);
+bool client_is_global_observer(void);
+int client_player_number(void);
+bool client_has_player(void);
+struct player *client_player(void);
 void set_seconds_to_turndone(double seconds);
 int get_seconds_to_turndone(void);
 double real_timer_callback(void);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to