1 /* Definitions for the historical record.
2    Copyright (C) 1992-1995, 1998-2000 Stanley T. Shebs.
3 
4 Xconq is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.  See the file COPYING.  */
8 
9 /*! \file kernel/history.h
10  * \brief Definitions for the historical record.
11  */
12 
13 #undef  DEF_HEVT
14 #define DEF_HEVT(name, CODE, datadescs) CODE,
15 
16 /*! \brief History Event type. */
17 typedef enum {
18 
19 #include "history.def"
20 
21     NUMHEVTTYPES
22 } HistEventType;
23 
24 /*! \brief Historical Event description.
25  *
26  * This is the form of the description of a event type.
27  * It contains the name of the event, and the description
28  * of the event.
29  */
30 typedef struct a_hevt_defn {
31     char *name;         	/*!< Name of event. */
32     char *datadescs;	/*!< Drescription of event. */
33 } HevtDefn;
34 
35 /*! \brief Historical Event.
36  *
37  * This ddefines an historical event.
38  */
39 typedef struct a_histevent {
40     HistEventType type;         		/*!< type of historical event */
41     short startdate;            		/*!< date of event's start */
42     short enddate;              		/*!< date of event's end */
43     SideMask observers;         	/*!< which sides know about this event */
44     struct a_histevent *next;   	/*!< link to next in list */
45     struct a_histevent *prev;		/*!< link to previous in list */
46     int data[4];                		/*!< data describing event */
47 } HistEvent;
48 
49 
50 /*! \brief Unit History.
51  *
52  * This is a snapshot of key bits of state of a \Unit at a particular
53  * moment.
54  */
55 typedef struct a_pastunit {
56     short type;                 		/*!< type */
57     int id;                     			/*!< truly unique id number */
58     char *name;                 		/*!< the name, if given */
59     int number;                 		/*!< semi-unique number */
60     short x;                    			/*!< x position of unit in world */
61     short y;                    			/*!< y position of unit in world */
62     short z;                    			/*!< z position of unit in world */
63     struct a_side *side;        		/*!< whose side this unit is on */
64     struct a_pastunit *next;    	/*!< pointer to next in list */
65 } PastUnit;
66 
67 /*! \brief Reasons for gain. */
68 enum gain_reasons {
69     initial_gain = 0,       	/*!< Initial */
70     build_gain = 1,         	/*!< build */
71     capture_gain = 2,       	/*1< capture */
72     other_gain = 3,         	/*!< other */
73     num_gain_reasons = 4    	/*!< number of gain reasons. */
74 };
75 
76 /*! \brief Reasons for loss. */
77 enum loss_reasons {
78     combat_loss = 0,        	/*!< Combat */
79     capture_loss = 1,       	/*!< Capture */
80     starvation_loss = 2,    	/*!< Starvation */
81     accident_loss = 3,      	/*!< Accident */
82     attrition_loss = 4,		/*!< Attrition */
83     disband_loss = 5,       	/*!< Disband */
84     other_loss = 6,         	/*!< Other */
85     num_loss_reasons = 7    	/*!< number of loss reasons. */
86 };
87 
88 /*! \brief Damage resons. */
89 enum damage_reasons {
90     combat_dmg,         	/*!< combat */
91     accident_dmg,       	/*!< accident */
92     attrition_dmg,       	/*!< attrition */
93     starvation_dmg		/*!< starvation */
94 };
95 
96 /*! \brief Historical Event Definition array. */
97 extern HevtDefn hevtdefns[];
98 
99 /*1 \brief Historical Events list. */
100 extern HistEvent *history;
101 
102 /*! \brief Past Unit History list. */
103 extern PastUnit *past_unit_list;
104 
105 extern void init_history(void);
106 extern void start_history(void);
107 extern HistEvent *create_historical_event(HistEventType type);
108 extern HistEvent *record_event(HistEventType type, SideMask observers, ...);
109 extern void record_unit_death(Unit *unit, HistEventType reason);
110 extern void record_unit_name_change(Unit *unit, char *newname);
111 extern void record_unit_side_change(Unit *unit, Side *newside,
112 				    HistEventType reason, Unit *agent);
113 extern void count_gain(Side *side, int u, enum gain_reasons reason);
114 extern void count_loss(Side *side, int u, enum loss_reasons reason);
115 extern void end_history(void);
116 extern HistEvent *get_nth_history_line(Side *side, int n, HistEvent **nextevt);
117 extern PastUnit *create_past_unit(int type, int id);
118 extern PastUnit *find_past_unit(int n);
119 extern char *past_unit_desig(PastUnit *pastunit);
120 extern PastUnit *change_unit_to_past_unit(Unit *unit);
121 extern void dump_statistics(void);
122 
123 extern int update_total_hist_lines(Side *side);
124 extern int build_hist_contents(Side *side, int n, HistEvent **histcontents, int numvis);
125 extern int total_gain(Side *side, int u);
126 extern int total_loss(Side *side, int u);
127