stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src/unit upgrade.c


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src/unit upgrade.c
Date: Tue, 28 Oct 2003 17:23:24 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/10/28 17:23:24

Modified files:
        src/unit       : upgrade.c 

Log message:
        Removed hard-coded cost names

Patches:
Index: stratagus/src/unit/upgrade.c
diff -u stratagus/src/unit/upgrade.c:1.62 stratagus/src/unit/upgrade.c:1.63
--- stratagus/src/unit/upgrade.c:1.62   Thu Oct 23 21:58:34 2003
+++ stratagus/src/unit/upgrade.c        Tue Oct 28 17:23:23 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: upgrade.c,v 1.62 2003/10/24 01:58:34 n0body Exp $
+//     $Id: upgrade.c,v 1.63 2003/10/28 22:23:23 jsalmon3 Exp $
 
 //@{
 
@@ -544,7 +544,7 @@
     int p;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: upgrades $Id: upgrade.c,v 1.62 2003/10/24 
01:58:34 n0body Exp $\n\n");
+    CLprintf(file, ";;; MODULE: upgrades $Id: upgrade.c,v 1.63 2003/10/28 
22:23:23 jsalmon3 Exp $\n\n");
 
     /* remove?
     //
@@ -772,20 +772,23 @@
            hit_points = gh_scm2int(gh_cadr(value));
        } else if (gh_eq_p(temp, gh_symbol2scm("regeneration-rate"))) {
            regeneration_rate = gh_scm2int(gh_cadr(value));
-       } else if (gh_eq_p(temp, gh_symbol2scm("time-cost"))) {
-           costs[0] = gh_scm2int(gh_cadr(value));
-       } else if (gh_eq_p(temp, gh_symbol2scm("gold-cost"))) {
-           costs[1] = gh_scm2int(gh_cadr(value));
-       } else if (gh_eq_p(temp, gh_symbol2scm("wood-cost"))) {
-           costs[2] = gh_scm2int(gh_cadr(value));
-       } else if (gh_eq_p(temp, gh_symbol2scm("oil-cost"))) {
-           costs[3] = gh_scm2int(gh_cadr(value));
-       } else if (gh_eq_p(temp, gh_symbol2scm("ore-cost"))) {
-           costs[4] = gh_scm2int(gh_cadr(value));
-       } else if (gh_eq_p(temp, gh_symbol2scm("stone-cost"))) {
-           costs[5] = gh_scm2int(gh_cadr(value));
-       } else if (gh_eq_p(temp, gh_symbol2scm("coal-cost"))) {
-           costs[6] = gh_scm2int(gh_cadr(value));
+       } else if (gh_eq_p(temp, gh_symbol2scm("cost"))) {
+           int i;
+           char* name;
+
+           value = gh_car(gh_cdr(value));
+           name = gh_scm2newstr(gh_car(value), NULL);
+           for (i = 0; i < MaxCosts; ++i) {
+               if (!strcmp(name, DefaultResourceNames[i])) {
+                   break;
+               }
+           }
+           if (i == MaxCosts) {
+               errl("Resource not found", gh_car(value));
+           }
+           free(name);
+           value = gh_cdr(value);
+           costs[i] = gh_scm2int(gh_car(value));
        } else if (gh_eq_p(temp, gh_symbol2scm("allow"))) {
            value = gh_cdr(value);
            str = gh_scm2newstr(gh_car(value), NULL);
@@ -818,7 +821,7 @@
 
     AddUpgradeModifierBase(uid, attack_range, sight_range, basic_damage,
        piercing_damage, armor, speed, hit_points, regeneration_rate, costs,
-       units,upgrades, apply_to,convert_to);
+       units, upgrades, apply_to,convert_to);
 
     return SCM_UNSPECIFIED;
 }




reply via email to

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