Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/mood.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
mood.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* common */
19#include "fc_types.h"
20#include "game.h"
21#include "player.h"
22
23#include "mood.h"
24
25/**********************************************************************/
28 enum mood_type player_mood(struct player *pplayer)
29{
30 if (pplayer->last_war_action >= 0
31 && pplayer->last_war_action + WAR_MOOD_LASTS >= game.info.turn) {
32 players_iterate(other) {
33 struct player_diplstate *us, *them;
34
35 us = player_diplstate_get(pplayer, other);
36 them = player_diplstate_get(other, pplayer);
37
38 if (us->type == DS_WAR
39 || us->has_reason_to_cancel > 0
40 || them->has_reason_to_cancel > 0) {
41 return MOOD_COMBAT;
42 }
43 } players_iterate_end;
44 }
45
46 return MOOD_PEACEFUL;
47}
fc_types.h
game
struct civ_game game
Definition game.c:57
game.h
player_mood
enum mood_type player_mood(struct player *pplayer)
Definition mood.c:28
mood.h
WAR_MOOD_LASTS
#define WAR_MOOD_LASTS
Definition mood.h:17
player_diplstate_get
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
player.h
players_iterate_end
#define players_iterate_end
Definition player.h:535
players_iterate
#define players_iterate(_pplayer)
Definition player.h:530
civ_game::info
struct packet_game_info info
Definition game.h:89
packet_game_info::turn
int turn
Definition packets_gen.h:241
player_diplstate
Definition player.h:200
player_diplstate::type
enum diplstate_type type
Definition player.h:201
player_diplstate::has_reason_to_cancel
char has_reason_to_cancel
Definition player.h:205
player
Definition player.h:249
player::last_war_action
int last_war_action
Definition player.h:270