Update of /cvsroot/xconq/xconq/src/include/gdl/unit
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv23113/unit
Modified Files:
action.h goal.h pastunit.h plan.h task.h unit.h
Log Message:
Add CVS serialization support.
Fix copyrights.
Index: pastunit.h
===================================================================
RCS file: /cvsroot/xconq/xconq/src/include/gdl/unit/pastunit.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pastunit.h 29 May 2006 22:43:09 -0000 1.1
--- pastunit.h 2 Jun 2006 16:58:34 -0000 1.2
***************
*** 6,10 ****
/*//////////////////////////// COPYRIGHT NOTICE ////////////////////////////////
! Copyright (C) 1989 Stanley T. Shebs
Copyright (C) 1991-2000 Stanley T. Shebs
Copyright (C) 2006 Eric A. McDonald
--- 6,10 ----
/*//////////////////////////// COPYRIGHT NOTICE ////////////////////////////////
! Copyright (C) 1987-1989 Stanley T. Shebs
Copyright (C) 1991-2000 Stanley T. Shebs
Copyright (C) 2006 Eric A. McDonald
***************
*** 37,40 ****
--- 37,41 ----
#include "gdl/lisp.h"
+ #include "gdl/side/side.h"
NAMESPACE_XCONQ_BEGIN
***************
*** 70,73 ****
--- 71,87 ----
extern PastUnit *past_unit_list;
+ // Queries
+
+ //! Get past unit from ID.
+ extern PastUnit *find_past_unit(int n);
+
+ //! Return a handle for past unit on given side.
+ /*!
+ Build a short phrase describing a given past unit to a given side,
+ basically consisting of indication of unit's side, then of unit
+ itself.
+ */
+ extern char *past_unit_handle(Side *side, PastUnit *past_unit);
+
// Lifecycle Management
***************
*** 80,83 ****
--- 94,100 ----
extern void interp_past_unit(Obj *form);
+ //! Serialize past unit to GDL.
+ extern void write_past_unit(PastUnit *pastunit);
+
NAMESPACE_GDL_END
NAMESPACE_XCONQ_END
Index: goal.h
===================================================================
RCS file: /cvsroot/xconq/xconq/src/include/gdl/unit/goal.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** goal.h 29 May 2006 22:43:09 -0000 1.1
--- goal.h 2 Jun 2006 16:58:34 -0000 1.2
***************
*** 107,113 ****
// GDL I/O
! //! Read goal from GDL form.
extern Goal *interp_goal(Obj *form);
NAMESPACE_GDL_END
NAMESPACE_XCONQ_END
--- 107,116 ----
// GDL I/O
! //! Read unit goal from GDL form.
extern Goal *interp_goal(Obj *form);
+ //! Serialize unit goal to GDL.
+ extern void write_goal(Goal *goal, int keyword);
+
NAMESPACE_GDL_END
NAMESPACE_XCONQ_END
Index: unit.h
===================================================================
RCS file: /cvsroot/xconq/xconq/src/include/gdl/unit/unit.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** unit.h 29 May 2006 22:43:09 -0000 1.1
--- unit.h 2 Jun 2006 16:58:34 -0000 1.2
***************
*** 68,71 ****
--- 68,86 ----
#define unit_alt(unit) (((unit)->z & 1) == 0 ? ((unit)->z >> 1) : 0)
+ //! Unit's point value.
+ #define unit_point_value(unit) \
+ ((unit)->extras ? (unit)->extras->point_value : -1)
+
+ //! Turn unit is to appear on.
+ #define unit_appear_turn(unit) \
+ ((unit)->extras ? (unit)->extras->appear : -1)
+
+ //! Turn unit is to disappear on.
+ #define unit_disappear_turn(unit) \
+ ((unit)->extras ? (unit)->extras->disappear : -1)
+
+ //! Sides unit can be on.
+ #define unit_sides(unit) ((unit)->extras ? (unit)->extras->sides : lispnil)
+
//! Can unit pass the terrain at the cell?
#define impassable(u, x, y) (!could_be_on((u)->type, terrain_at((x), (y))))
***************
*** 372,375 ****
--- 387,405 ----
extern char *unit_desig(Unit *unit);
+ //! Handle briefly describing any unit.
+ /*!
+ This version allows the caller to supply a side other than the
+ unit's actual side, such as when describing an out-of-date image of
+ a unit that may have been captured.
+ */
+ extern char *apparent_unit_handle(Side *side, Unit *unit, Side *side2);
+ //! Handle briefly describing side's unit.
+ /*!
+ Build a short phrase describing a given unit to a given side,
+ basically consisting of indication of unit's side, then of unit
+ itself.
+ */
+ extern char *unit_handle(Side *side, Unit *unit);
+
//! Find alive unit by ID.
/*! \todo This is used a lot, it should be sped up. */
***************
*** 402,405 ****
--- 432,447 ----
extern int can_occupy(Unit *unit, Unit *transport);
+ // Sorting
+
+ //! Sort units.
+ /*! Do a bubble sort.
+ Data is generally coherent, so bubble sort not too bad if we allow
+ early termination when everything is already in order.
+
+ \note If slowness objectionable, replace with something clever, but be
+ sure that average performance in real games is what's being improved.
+ */
+ extern void sort_units(int byidonly);
+
// Vision and Visibility
***************
*** 452,455 ****
--- 494,508 ----
extern void init_unit_opinions(Unit *unit, int nsides);
+ //! Get rid of all dead units at once.
+ /*!
+ This routine is basically a garbage collector, and should not be
+ called during a unit list traversal. The process starts by finding
+ the first live unit, making it the head, then linking around all in
+ the middle. Dead units stay on the dead unit list for each side
+ until that side has had a chance to move. Then they are finally
+ flushed in a permanent fashion.
+ */
+ extern void flush_dead_units(void);
+
// Images
***************
*** 485,488 ****
--- 538,551 ----
extern Unit *interp_unit(Obj *form);
+ //! Serialize unit properties to GDL.
+ /*! Write various properties, but only if they have non-default values. */
+ extern void write_unit_properties(Unit *unit);
+ //! Serialize units to GDL.
+ /*!
+ \todo Should write out "unit groups" with dict prepended, then can use with
+ multiple games
+ */
+ extern void write_units(struct a_module *module);
+
NAMESPACE_GDL_END
NAMESPACE_XCONQ_END
Index: plan.h
===================================================================
RCS file: /cvsroot/xconq/xconq/src/include/gdl/unit/plan.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** plan.h 29 May 2006 22:43:09 -0000 1.1
--- plan.h 2 Jun 2006 16:58:34 -0000 1.2
***************
*** 41,44 ****
--- 41,49 ----
#include "gdl/unit/goal.h"
+ // Iterator Macros
+
+ #define for_all_tasks(plan,task) \
+ for (task = (plan)->tasks; task != NULL; task = task->next)
+
NAMESPACE_XCONQ_BEGIN
NAMESPACE_GDL_BEGIN
***************
*** 115,118 ****
--- 120,128 ----
} Plan;
+ // Global Variables
+
+ //! Array of plan type names.
+ extern char *plantypenames[];
+
// Lifecycle Management
***************
*** 135,141 ****
// GDL I/O
! // Read unit plan from GDL form.
extern void interp_unit_plan(struct a_unit *unit, Obj *props);
NAMESPACE_GDL_END
NAMESPACE_XCONQ_END
--- 145,154 ----
// GDL I/O
! //! Read unit plan from GDL form.
extern void interp_unit_plan(struct a_unit *unit, Obj *props);
+ //! Serialize unit plan to GDL.
+ extern void write_unit_plan(Unit *unit);
+
NAMESPACE_GDL_END
NAMESPACE_XCONQ_END
Index: action.h
===================================================================
RCS file: /cvsroot/xconq/xconq/src/include/gdl/unit/action.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** action.h 29 May 2006 22:43:09 -0000 1.1
--- action.h 2 Jun 2006 16:58:34 -0000 1.2
***************
*** 132,135 ****
--- 132,140 ----
extern void interp_action(Action *action, Obj *props);
+ //! Serialize action to GDL.
+ extern void write_action(Action *action, int id);
+ //! Serialize unit actor state to GDL.
+ extern void write_unit_act(Unit *unit);
+
NAMESPACE_GDL_END
NAMESPACE_XCONQ_END
Index: task.h
===================================================================
RCS file: /cvsroot/xconq/xconq/src/include/gdl/unit/task.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** task.h 29 May 2006 22:43:09 -0000 1.1
--- task.h 2 Jun 2006 16:58:34 -0000 1.2
***************
*** 44,47 ****
--- 44,52 ----
#define MAXTASKARGS 6
+ // Function Macros: Queries
+
+ //! Is argument a task type?
+ #define is_task_type(x) (between(0, (x), NUMTASKTYPES - 1))
+
NAMESPACE_XCONQ_BEGIN
NAMESPACE_GDL_BEGIN
***************
*** 158,161 ****
--- 163,169 ----
extern Task *interp_task(Obj *form);
+ //! Serialize task to GDL.
+ extern void write_task(Task *task);
+
NAMESPACE_GDL_END
NAMESPACE_XCONQ_END
|