stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus data/ccl/stratagus.ccl src/clone/ccl_...


From: Nehal Mistry
Subject: [Stratagus-CVS] stratagus data/ccl/stratagus.ccl src/clone/ccl_...
Date: Sun, 02 Nov 2003 21:19:34 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Nehal Mistry <address@hidden>   03/11/02 21:19:34

Modified files:
        data/ccl       : stratagus.ccl 
        src/clone      : ccl_player.c groups.c selection.c 
        src/game       : game.c 
        src/include    : unit.h 

Log message:
        fix some bugs for multiple unit selection; make MaxSelection and 
NumUnitsPerGroup configurable via ccl

Patches:
Index: stratagus/data/ccl/stratagus.ccl
diff -u stratagus/data/ccl/stratagus.ccl:1.25 
stratagus/data/ccl/stratagus.ccl:1.26
--- stratagus/data/ccl/stratagus.ccl:1.25       Fri Oct 31 17:16:54 2003
+++ stratagus/data/ccl/stratagus.ccl    Sun Nov  2 21:19:32 2003
@@ -26,7 +26,7 @@
 ;;      along with this program; if not, write to the Free Software
 ;;      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA
 ;;
-;;     $Id: stratagus.ccl,v 1.25 2003/10/31 22:16:54 jsalmon3 Exp $
+;;     $Id: stratagus.ccl,v 1.26 2003/11/03 02:19:32 nehalmistry Exp $
 
 ;; For documentation see stratagus/doc/ccl/ccl.html
 
@@ -376,6 +376,11 @@
 (a-star 'fixed-unit-cost 1000 'moving-unit-cost 20 'dont-know-unseen-terrain 
'unseen-terrain-cost 2)
 
 ;;-----------------------------------------------------------------------------
+
+;;     Maximum number of selectable units
+(set-max-selectable! 18)
+;;     Maximum number of units per group
+(set-num-units-per-group! 18)
 
 ;;     All player food unit limit
 (set-all-players-food-unit-limit! 200)
Index: stratagus/src/clone/ccl_player.c
diff -u stratagus/src/clone/ccl_player.c:1.41 
stratagus/src/clone/ccl_player.c:1.42
--- stratagus/src/clone/ccl_player.c:1.41       Thu Oct  9 16:54:36 2003
+++ stratagus/src/clone/ccl_player.c    Sun Nov  2 21:19:33 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_player.c,v 1.41 2003/10/09 20:54:36 jsalmon3 Exp $
+//     $Id: ccl_player.c,v 1.42 2003/11/03 02:19:33 nehalmistry Exp $
 
 //@{
 
@@ -339,6 +339,28 @@
 }
 
 /**
+**     Set MaxSelectable
+**
+**     @param          Max number of selectable units.
+*/
+local SCM CclSetMaxSelectable(SCM max)
+{
+    MaxSelectable = gh_scm2int(max);
+    return max;
+}
+
+/**
+**     Set NumUnitsPerGroup
+**
+**     @param num      Number of units per group.
+*/
+local SCM CclSetNumUnitsPerGroup(SCM num)
+{
+    NumUnitsPerGroup = gh_scm2int(num);
+    return num;
+}
+
+/**
 **     Set player unit limit.
 **
 **     @param limit    Unit limit.
@@ -631,6 +653,10 @@
     gh_new_procedure4_0("change-units-owner", CclChangeUnitsOwner);
     gh_new_procedure0_0("get-this-player", CclGetThisPlayer);
     gh_new_procedure1_0("set-this-player!", CclSetThisPlayer);
+
+    gh_new_procedure1_0("set-max-selectable!", CclSetMaxSelectable);
+    gh_new_procedure1_0("set-num-units-per-group!",
+       CclSetNumUnitsPerGroup);
 
     gh_new_procedure1_0("set-all-players-food-unit-limit!",
        CclSetAllPlayersFoodUnitLimit);
Index: stratagus/src/clone/groups.c
diff -u stratagus/src/clone/groups.c:1.22 stratagus/src/clone/groups.c:1.23
--- stratagus/src/clone/groups.c:1.22   Thu Oct  9 19:04:03 2003
+++ stratagus/src/clone/groups.c        Sun Nov  2 21:19:33 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: groups.c,v 1.22 2003/10/09 23:04:03 jsalmon3 Exp $
+//     $Id: groups.c,v 1.23 2003/11/03 02:19:33 nehalmistry Exp $
 
 //@{
 
@@ -50,11 +50,12 @@
 **     Defines a group of units.
 */
 typedef struct _unit_group_ {
-    Unit*      Units[NUM_UNITS_PER_GROUP];     /// Units in the group
-    int                NumUnits;                       /// How many units in 
the group
+    Unit**     Units;                  /// Units in the group
+    int                NumUnits;               /// How many units in the group
 } UnitGroup;                           /// group of units
 
 global UnitGroup Groups[NUM_GROUPS];   /// Number of groups predefined
+global int NumUnitsPerGroup;
 
 /*----------------------------------------------------------------------------
 --     Functions
@@ -72,6 +73,8 @@
     for (i = 0; i < NUM_GROUPS; ++i) {
        int n;
 
+       Groups[i].Units = malloc(NumUnitsPerGroup * sizeof(Unit*));
+
        if ((n = Groups[i].NumUnits)) {         // Cleanup after load
            while (n--) {
                DebugLevel0Fn("FIXME: old code!\n");
@@ -93,7 +96,7 @@
     char* ref;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: groups $Id: groups.c,v 1.22 2003/10/09 
23:04:03 jsalmon3 Exp $\n\n");
+    CLprintf(file, ";;; MODULE: groups $Id: groups.c,v 1.23 2003/11/03 
02:19:33 nehalmistry Exp $\n\n");
 
     for (g = 0; g < NUM_GROUPS; ++g) {
        CLprintf(file, "(group %d %d '(", g, Groups[g].NumUnits);
@@ -114,6 +117,7 @@
     int i;
 
     for (i = 0; i < NUM_GROUPS; ++i) {
+       free(Groups[i].Units);
         memset(&Groups[i], 0, sizeof(Groups[i]));
     }
 }
@@ -173,7 +177,7 @@
     DebugCheck(num > NUM_GROUPS);
 
     group = &Groups[num];
-    for (i = 0; group->NumUnits < NUM_UNITS_PER_GROUP && i < nunits; ++i) {
+    for (i = 0; group->NumUnits < NumUnitsPerGroup && i < nunits; ++i) {
         group->Units[group->NumUnits++] = units[i];
        units[i]->GroupId |= (1 << num);
     }
@@ -188,7 +192,7 @@
  */
 global void SetGroup(Unit** units, int nunits, int num)
 {
-    DebugCheck(num > NUM_GROUPS || nunits > NUM_UNITS_PER_GROUP);
+    DebugCheck(num > NUM_GROUPS || nunits > NumUnitsPerGroup);
 
     ClearGroup(num);
     AddToGroup(units, nunits, num);
Index: stratagus/src/clone/selection.c
diff -u stratagus/src/clone/selection.c:1.53 
stratagus/src/clone/selection.c:1.54
--- stratagus/src/clone/selection.c:1.53        Tue Oct 28 15:20:42 2003
+++ stratagus/src/clone/selection.c     Sun Nov  2 21:19:33 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: selection.c,v 1.53 2003/10/28 20:20:42 n0body Exp $
+//     $Id: selection.c,v 1.54 2003/11/03 02:19:33 nehalmistry Exp $
 
 //@{
 
@@ -55,11 +55,8 @@
 ----------------------------------------------------------------------------*/
 
 global int NumSelected;                        /// Number of selected units
-global Unit* Selected[MaxSelectable] = {
-    NoUnitP, NoUnitP, NoUnitP,
-    NoUnitP, NoUnitP, NoUnitP,
-    NoUnitP, NoUnitP, NoUnitP
-};                                     /// All selected units
+global int MaxSelectable;              /// Maximum number of selected units
+global Unit** Selected;                        /// All selected units
 
 local unsigned GroupId;                        /// Unique group # for 
automatic groups
 
@@ -967,6 +964,8 @@
 {
     int i;
 
+    Selected = malloc(NumUnitsPerGroup * sizeof(Unit*));
+
     if ((i = NumSelected)) {           // Cleanup after load
        while (i--) {
            Selected[i] = UnitSlots[(int)Selected[i]];
@@ -985,7 +984,7 @@
     char* ref;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: selection $Id: selection.c,v 1.53 2003/10/28 
20:20:42 n0body Exp $\n\n");
+    CLprintf(file, ";;; MODULE: selection $Id: selection.c,v 1.54 2003/11/03 
02:19:33 nehalmistry Exp $\n\n");
 
     CLprintf(file, "(set-group-id! %d)\n", GroupId);
     CLprintf(file, "(selection %d '(", NumSelected);
@@ -1005,6 +1004,7 @@
     GroupId = 0;
     NumSelected = 0;
     DebugCheck(NoUnitP);               // Code fails if none zero
+    free(Selected);
     memset(Selected, 0, sizeof(Selected));
 }
 
Index: stratagus/src/game/game.c
diff -u stratagus/src/game/game.c:1.109 stratagus/src/game/game.c:1.110
--- stratagus/src/game/game.c:1.109     Wed Oct 29 07:58:36 2003
+++ stratagus/src/game/game.c   Sun Nov  2 21:19:33 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: game.c,v 1.109 2003/10/29 12:58:36 mr-russ Exp $
+//     $Id: game.c,v 1.110 2003/11/03 02:19:33 nehalmistry Exp $
 
 //@{
 
@@ -410,6 +410,8 @@
     LoadConstructions();
     LoadUnitTypes();
     LoadDecorations();
+
+    InitSelections();
 
     DebugLevel0("Graphics uses %d bytes (%d KB, %d MB)\n" _C_
        AllocatedGraphicMemory _C_
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.228 stratagus/src/include/unit.h:1.229
--- stratagus/src/include/unit.h:1.228  Sun Nov  2 19:14:33 2003
+++ stratagus/src/include/unit.h        Sun Nov  2 21:19:33 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.h,v 1.228 2003/11/03 00:14:33 nehalmistry Exp $
+//     $Id: unit.h,v 1.229 2003/11/03 02:19:33 nehalmistry Exp $
 
 #ifndef __UNIT_H__
 #define __UNIT_H__
@@ -670,18 +670,6 @@
 #define UnitMovementMask(unit) \
     ((unit)->Type->MovementMask)
 
-
-/**
-**     How many units could be selected
-*/
-#define MaxSelectable  54
-
-// FIXME: hardcoded...
-/**
-**     How many units could be in a group
-*/
-#define NUM_UNITS_PER_GROUP MaxSelectable
-
 /**
 **     How many groups supported
 */
@@ -727,9 +715,12 @@
 extern void DrawUnitSelection(const Unit*);
 extern void (*DrawSelection)(VMemType, int, int, int, int);
 
-//     in selection.c
-extern Unit* Selected[MaxSelectable];  /// currently selected units
+extern int MaxSelectable;              /// How many units could be selected
+extern int NumUnitsPerGroup;           /// How many units could be in a group
+
+extern Unit** Selected;                        /// currently selected units
 extern int NumSelected;                        /// how many units selected
+
 
 /*----------------------------------------------------------------------------
 --     Functions




reply via email to

[Prev in Thread] Current Thread [Next in Thread]