Author: cazfi
Date: Tue Mar 11 23:05:32 2014
New Revision: 24653

URL: http://svn.gna.org/viewcvs/freeciv?rev=24653&view=rev
Log:
Add concept of nation mood.

Updated network protocol to the fact that PACKET_SCENARIO_INFO never
needs to be sent from client to the server.

Reported by Jacob Nevins <jtn>

See bug #21348

Added:
    trunk/server/mood.c
    trunk/server/mood.h
Modified:
    trunk/common/fc_types.h
    trunk/common/packets.def
    trunk/fc_version
    trunk/server/Makefile.am
    trunk/server/plrhand.c

Modified: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=24653&r1=24652&r2=24653&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Tue Mar 11 23:05:32 2014
@@ -566,6 +566,15 @@
 #define SPECENUM_COUNT ACHIEVEMENT_COUNT
 #include "specenum_gen.h"
 
+/* Used in the network protocol. */
+#define SPECENUM_NAME mood_type
+#define SPECENUM_VALUE0 MOOD_PEACEFUL
+#define SPECENUM_VALUE0NAME "Peaceful"
+#define SPECENUM_VALUE1 MOOD_COMBAT
+#define SPECENUM_VALUE1NAME "Combat"
+#define SPECENUM_COUNT MOOD_COUNT
+#include "specenum_gen.h"
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=24653&r1=24652&r2=24653&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Tue Mar 11 23:05:32 2014
@@ -216,6 +216,7 @@
 type GUI_TYPE           = uint8(enum gui_type)
 type IMPR_GENUS         = uint8(enum impr_genus_id)
 type KNOWN              = uint8(enum known_type)
+type MOOD               = uint8(enum mood_type)
 type ORDERS             = uint8(enum unit_orders)
 type PHASE_MODE         = uint8(enum phase_mode_types)
 type PLACE_TYPE         = uint8(enum spaceship_place_type)
@@ -732,6 +733,7 @@
   GOVERNMENT government;
   GOVERNMENT target_government;
   BOOL real_embassy[MAX_NUM_PLAYER_SLOTS];
+  MOOD  mood;
   UINT8 style;
   UINT8 city_style;
   SINT8 music_style;

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=24653&r1=24652&r2=24653&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Tue Mar 11 23:05:32 2014
@@ -52,7 +52,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Mar.11b"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Mar.12"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/Makefile.am?rev=24653&r1=24652&r2=24653&view=diff
==============================================================================
--- trunk/server/Makefile.am    (original)
+++ trunk/server/Makefile.am    Tue Mar 11 23:05:32 2014
@@ -74,6 +74,8 @@
                maphand.h       \
                meta.c          \
                meta.h          \
+               mood.c          \
+               mood.h          \
                notify.c        \
                notify.h        \
                plrhand.c       \

Added: trunk/server/mood.c
URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/mood.c?rev=24653&view=auto
==============================================================================
--- trunk/server/mood.c (added)
+++ trunk/server/mood.c Tue Mar 11 23:05:32 2014
@@ -0,0 +1,42 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <fc_config.h>
+#endif
+
+/* common */
+#include "fc_types.h"
+#include "player.h"
+
+/* server */
+
+#include "mood.h"
+
+/**************************************************************************
+  What is the player mood?
+**************************************************************************/
+enum mood_type player_mood(struct player *pplayer)
+{
+  players_iterate(other) {
+    struct player_diplstate *state;
+
+    state = player_diplstate_get(pplayer, other);
+
+    if (state->type == DS_WAR) {
+      return MOOD_COMBAT;
+    }
+  } players_iterate_end;
+
+  return MOOD_PEACEFUL;
+}

Added: trunk/server/mood.h
URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/mood.h?rev=24653&view=auto
==============================================================================
--- trunk/server/mood.h (added)
+++ trunk/server/mood.h Tue Mar 11 23:05:32 2014
@@ -0,0 +1,18 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__MOOD_H
+#define FC__MOOD_H
+
+enum mood_type player_mood(struct player *pplayer);
+
+#endif  /* FC__MOOD_H */

Modified: trunk/server/plrhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/plrhand.c?rev=24653&r1=24652&r2=24653&view=diff
==============================================================================
--- trunk/server/plrhand.c      (original)
+++ trunk/server/plrhand.c      Tue Mar 11 23:05:32 2014
@@ -52,6 +52,7 @@
 #include "diplhand.h"
 #include "gamehand.h"
 #include "maphand.h"
+#include "mood.h"
 #include "notify.h"
 #include "plrhand.h"
 #include "sernet.h"
@@ -1140,8 +1141,10 @@
       || (receiver
           && player_diplstate_get(plr, receiver)->type == DS_TEAM)) {
     packet->tech_goal       = research->tech_goal;
+    packet->mood            = player_mood(plr);
   } else {
     packet->tech_goal       = A_UNSET;
+    packet->mood            = MOOD_COUNT;
   }
 
   /* 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to