stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src action/action_build.c action/acti...


From: Russell Smith
Subject: [Stratagus-CVS] stratagus/src action/action_build.c action/acti...
Date: Sun, 16 Nov 2003 01:49:29 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Russell Smith <address@hidden>  03/11/16 01:49:28

Modified files:
        src/action     : action_build.c action_train.c command.c 
        src/ai         : ai_local.h ai_resource.c ccl_ai.c new_ai.c 
        src/clone      : ccl_player.c clone.c player.c unit.c 
        src/game       : trigger.c 
        src/include    : player.h 
        src/ui         : botpanel.c mainscr.c 

Log message:
        Food Replaced with Supply.  Buildings can have demand

Patches:
Index: stratagus/src/action/action_build.c
diff -u stratagus/src/action/action_build.c:1.102 
stratagus/src/action/action_build.c:1.103
--- stratagus/src/action/action_build.c:1.102   Mon Nov 10 22:06:51 2003
+++ stratagus/src/action/action_build.c Sun Nov 16 01:49:23 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_build.c,v 1.102 2003/11/11 03:06:51 n0body Exp $
+//     $Id: action_build.c,v 1.103 2003/11/16 06:49:23 mr-russ Exp $
 
 //@{
 
@@ -197,7 +197,7 @@
     //
     // Check if hiting any limits for the building.
     //
-    if (!PlayerCheckLimits(unit->Player, type)) {
+    if (PlayerCheckLimits(unit->Player, type) < 0) {
        NotifyPlayer(unit->Player, NotifyYellow, unit->X, unit->Y,
            "Can't build more units %s", type->Name);
        if (unit->Player->Ai) {
Index: stratagus/src/action/action_train.c
diff -u stratagus/src/action/action_train.c:1.61 
stratagus/src/action/action_train.c:1.62
--- stratagus/src/action/action_train.c:1.61    Sun Nov  9 17:13:56 2003
+++ stratagus/src/action/action_train.c Sun Nov 16 01:49:24 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_train.c,v 1.61 2003/11/09 22:13:56 n0body Exp $
+//     $Id: action_train.c,v 1.62 2003/11/16 06:49:24 mr-russ Exp $
 
 //@{
 
@@ -92,11 +92,11 @@
        }
 
        //
-       //      Check if enough food available.
+       //      Check if enough supply available.
        //
-       if ((food = !PlayerCheckFood(player, unit->Data.Train.What[0])) ||
-               !PlayerCheckLimits(player, unit->Data.Train.What[0])) {
-           if (food && unit->Player->Ai) {
+       food = PlayerCheckLimits(player, unit->Data.Train.What[0]);
+       if (food < 0) {
+           if (food == -3 && unit->Player->Ai) {
                AiNeedMoreFarms(unit, unit->Orders[0].Type);
            }
 
Index: stratagus/src/action/command.c
diff -u stratagus/src/action/command.c:1.118 
stratagus/src/action/command.c:1.119
--- stratagus/src/action/command.c:1.118        Tue Nov 11 04:57:31 2003
+++ stratagus/src/action/command.c      Sun Nov 16 01:49:24 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: command.c,v 1.118 2003/11/11 09:57:31 mr-russ Exp $
+//     $Id: command.c,v 1.119 2003/11/16 06:49:24 mr-russ Exp $
 
 //@{
 
@@ -864,8 +864,7 @@
        //      Check if enough resources remains? (NETWORK!)
        //      FIXME: wrong if append to message queue!!!
        //
-       if (!PlayerCheckFood(unit->Player, type) ||
-               !PlayerCheckLimits(unit->Player, type) ||
+       if (PlayerCheckLimits(unit->Player, type) < 0 ||
                PlayerCheckUnitType(unit->Player, type)) {
            return;
        }
Index: stratagus/src/ai/ai_local.h
diff -u stratagus/src/ai/ai_local.h:1.43 stratagus/src/ai/ai_local.h:1.44
--- stratagus/src/ai/ai_local.h:1.43    Fri Nov 14 12:35:51 2003
+++ stratagus/src/ai/ai_local.h Sun Nov 16 01:49:25 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_local.h,v 1.43 2003/11/14 17:35:51 pludov Exp $
+//      $Id: ai_local.h,v 1.44 2003/11/16 06:49:25 mr-russ Exp $
 
 #ifndef __AI_LOCAL_H__
 #define __AI_LOCAL_H__
@@ -292,7 +292,7 @@
     int                        Collect[MaxCosts];/// Collect % of resources
     int                        NeededMask;     /// Mask for needed resources
 
-    int                        NeedFood;       /// Flag need food
+    int                        NeedSupply;     /// Flag need food
 
     AiExplorationRequest*FirstExplorationRequest;/// Requests for exploration
     unsigned int       LastExplorationGameCycle;/// When did the last explore 
occur ?
Index: stratagus/src/ai/ai_resource.c
diff -u stratagus/src/ai/ai_resource.c:1.79 stratagus/src/ai/ai_resource.c:1.80
--- stratagus/src/ai/ai_resource.c:1.79 Mon Nov  3 07:36:13 2003
+++ stratagus/src/ai/ai_resource.c      Sun Nov 16 01:49:25 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_resource.c,v 1.79 2003/11/03 12:36:13 pludov Exp $
+//      $Id: ai_resource.c,v 1.80 2003/11/16 06:49:25 mr-russ Exp $
 
 //@{
 
@@ -124,7 +124,7 @@
 **     @todo   The number of food currently trained can be stored global
 **             for faster use.
 */
-local int AiCheckFood(const PlayerAi * pai, const UnitType * type)
+local int AiCheckSupply(const PlayerAi * pai, const UnitType * type)
 {
     int remaining;
     const AiBuildQueue *queue;
@@ -144,7 +144,7 @@
     //
     //  We are already out of food.
     //
-    remaining += pai->Player->Food - pai->Player->NumFoodUnits - type->Demand;
+    remaining += pai->Player->Supply - pai->Player->Demand - type->Demand;
     DebugLevel3Fn("-Demand %d\n" _C_ remaining);
     if (remaining < 0) {
        DebugLevel3Fn(" player %d needs more food\n" _C_ pai->Player->Player);
@@ -308,7 +308,7 @@
 /**
 **     Build new units to reduce the food shortage.
 */
-local void AiRequestFarms(void)
+local void AiRequestSupply(void)
 {
     int i;
     int n;
@@ -730,12 +730,12 @@
        AiPlayer->Player->Resources[1] _C_
        AiPlayer->Player->Resources[2] _C_ AiPlayer->Player->Resources[3]);
 
-    // Food has the highest priority
-    if (AiPlayer->NeedFood) {
+    // Suppy has the highest priority
+    if (AiPlayer->NeedSupply) {
        DebugLevel3Fn("player %d needs food.\n" _C_ AiPlayer->Player->Player);
        if (!(AiPlayer->UnitTypeBuilded && 
AiPlayer->UnitTypeBuilded->Type->Supply)) {
-           AiPlayer->NeedFood = 0;
-           AiRequestFarms();
+           AiPlayer->NeedSupply = 0;
+           AiRequestSupply();
        }
     }
     //
@@ -751,27 +751,23 @@
            //          Buildings can be destructed.
 
            //
-           //  Check limits, AI should be broken if reached.
-           //
-           if (!PlayerCheckLimits(AiPlayer->Player, type)) {
-               DebugLevel2Fn("Unit limits reached\n");
-               continue;
-           }
-           //
            //  Check if we have enough food.
            //
            if (!type->Building) {
                // Count future
-               if (!AiCheckFood(AiPlayer, type)) {
-                   AiPlayer->NeedFood = 1;
-                   AiRequestFarms();
-               }
-               // Current limit
-               if (!PlayerCheckFood(AiPlayer->Player, type)) {
-                   continue;
+               if (!AiCheckSupply(AiPlayer, type)) {
+                   AiPlayer->NeedSupply = 1;
+                   AiRequestSupply();
                }
            }
            //
+           //  Check limits, AI should be broken if reached.
+           //
+           if (PlayerCheckLimits(AiPlayer->Player, type) < 0) {
+               DebugLevel2Fn("Unit limits reached, or Need Supply\n");
+               continue;
+           }
+           //
            //  Check if resources available.
            //
            if ((c = AiCheckUnitTypeCosts(type))) {
@@ -1391,9 +1387,9 @@
     //
     //  Look if we can build a farm in advance.
     //
-    if (!AiPlayer->NeedFood && AiPlayer->Player->NumFoodUnits == 
AiPlayer->Player->Food) {
+    if (!AiPlayer->NeedSupply && AiPlayer->Player->Supply == 
AiPlayer->Player->Demand) {
        DebugLevel3Fn("Farm in advance request\n");
-       AiRequestFarms();
+       AiRequestSupply();
     }
     //
     //  Collect resources.
Index: stratagus/src/ai/ccl_ai.c
diff -u stratagus/src/ai/ccl_ai.c:1.80 stratagus/src/ai/ccl_ai.c:1.81
--- stratagus/src/ai/ccl_ai.c:1.80      Wed Nov 12 15:35:41 2003
+++ stratagus/src/ai/ccl_ai.c   Sun Nov 16 01:49:25 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ccl_ai.c,v 1.80 2003/11/12 20:35:41 jsalmon3 Exp $
+//      $Id: ccl_ai.c,v 1.81 2003/11/16 06:49:25 mr-russ Exp $
 
 //@{
 
@@ -262,7 +262,7 @@
        {"needed",              &IORessourceArray,&((PlayerAi *) 0)->Needed,    
        0},
        {"collect",             &IORessourceArray,&((PlayerAi *) 0)->Collect,   
        0},
        {"neededmask",          &IORessourceMask,&((PlayerAi *) 0)->Reserve,    
        0},
-       {"need-food",           &IOBool,        &((PlayerAi *) 0)->NeedFood,    
        0},
+       {"need-supply",         &IOBool,        &((PlayerAi *) 0)->NeedSupply,  
        0},
        {"exploration-requests",&IOLinkedList,  &((PlayerAi *) 
0)->FirstExplorationRequest,&AiExplorationRequestStructDef},
        {"last-exploration",    &IOInt,         &((PlayerAi *) 
0)->LastExplorationGameCycle,0},
        {"unit-type-requests",  &IOTable,       0,                              
        &UnitTypeRequestsTableDef},
Index: stratagus/src/ai/new_ai.c
diff -u stratagus/src/ai/new_ai.c:1.89 stratagus/src/ai/new_ai.c:1.90
--- stratagus/src/ai/new_ai.c:1.89      Sat Nov 15 03:54:54 2003
+++ stratagus/src/ai/new_ai.c   Sun Nov 16 01:49:25 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: new_ai.c,v 1.89 2003/11/15 08:54:54 pludov Exp $
+//      $Id: new_ai.c,v 1.90 2003/11/16 06:49:25 mr-russ Exp $
 
 
 //@{
@@ -782,7 +782,7 @@
 {
     CLprintf(file, "\n;;; -----------------------------------------\n");
     CLprintf(file,
-       ";;; MODULE: AI $Id: new_ai.c,v 1.89 2003/11/15 08:54:54 pludov Exp 
$\n\n");
+       ";;; MODULE: AI $Id: new_ai.c,v 1.90 2003/11/16 06:49:25 mr-russ Exp 
$\n\n");
 
     SaveAiTypesWcName(file);
     SaveAiHelper(file);
@@ -1481,7 +1481,7 @@
 
     DebugCheck(unit->Player->Type == PlayerPerson);
 
-    ((PlayerAi *) unit->Player->Ai)->NeedFood = 1;
+    ((PlayerAi *) unit->Player->Ai)->NeedSupply = 1;
 }
 
 /**
Index: stratagus/src/clone/ccl_player.c
diff -u stratagus/src/clone/ccl_player.c:1.45 
stratagus/src/clone/ccl_player.c:1.46
--- stratagus/src/clone/ccl_player.c:1.45       Fri Nov 14 11:41:47 2003
+++ stratagus/src/clone/ccl_player.c    Sun Nov 16 01:49:25 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_player.c,v 1.45 2003/11/14 16:41:47 pludov Exp $
+//     $Id: ccl_player.c,v 1.46 2003/11/16 06:49:25 mr-russ Exp $
 
 //@{
 
@@ -223,11 +223,14 @@
            player->AiEnabled = 1;
        } else if (gh_eq_p(value, gh_symbol2scm("ai-disabled"))) {
            player->AiEnabled = 0;
-       } else if (gh_eq_p(value, gh_symbol2scm("food"))) {
-           player->Food = gh_scm2int(gh_car(list));
+       } else if (gh_eq_p(value, gh_symbol2scm("supply"))) {
+           player->Supply = gh_scm2int(gh_car(list));
            list = gh_cdr(list);
-       } else if (gh_eq_p(value, gh_symbol2scm("food-unit-limit"))) {
-           player->FoodUnitLimit = gh_scm2int(gh_car(list));
+       } else if (gh_eq_p(value, gh_symbol2scm("demand"))) {
+           player->Demand = gh_scm2int(gh_car(list));
+           list = gh_cdr(list);
+       } else if (gh_eq_p(value, gh_symbol2scm("unit-limit"))) {
+           player->UnitLimit = gh_scm2int(gh_car(list));
            list = gh_cdr(list);
        } else if (gh_eq_p(value, gh_symbol2scm("building-limit"))) {
            player->BuildingLimit = gh_scm2int(gh_car(list));
@@ -475,18 +478,18 @@
 **     @param limit    Unit limit.
 */
 #if defined(USE_GUILE) || defined(USE_SIOD)
-local SCM CclSetAllPlayersFoodUnitLimit(SCM limit)
+local SCM CclSetAllPlayersUnitLimit(SCM limit)
 {
     int i;
 
     for (i = 0; i < PlayerMax; ++i) {
-       Players[i].FoodUnitLimit = gh_scm2int(limit);
+       Players[i].UnitLimit = gh_scm2int(limit);
     }
 
     return limit;
 }
 #elif defined(USE_LUA)
-local int CclSetAllPlayersFoodUnitLimit(lua_State* l)
+local int CclSetAllPlayersUnitLimit(lua_State* l)
 {
     int i;
 
@@ -495,7 +498,7 @@
        lua_error(l);
     }
     for (i = 0; i < PlayerMax; ++i) {
-       Players[i].FoodUnitLimit = lua_tonumber(l, 1);
+       Players[i].UnitLimit = lua_tonumber(l, 1);
     }
 
     lua_pushnumber(l, lua_tonumber(l, 1));
@@ -966,8 +969,8 @@
 
     gh_new_procedure1_0("set-max-selectable!", CclSetMaxSelectable);
 
-    gh_new_procedure1_0("set-all-players-food-unit-limit!",
-       CclSetAllPlayersFoodUnitLimit);
+    gh_new_procedure1_0("set-all-players-unit-limit!",
+       CclSetAllPlayersUnitLimit);
     gh_new_procedure1_0("set-all-players-building-limit!",
        CclSetAllPlayersBuildingLimit);
     gh_new_procedure1_0("set-all-players-total-unit-limit!",
@@ -993,8 +996,8 @@
 
     lua_register(Lua, "SetMaxSelectable", CclSetMaxSelectable);
 
-    lua_register(Lua, "SetAllPlayersFoodUnitLimit",
-       CclSetAllPlayersFoodUnitLimit);
+    lua_register(Lua, "SetAllPlayersUnitLimit",
+       CclSetAllPlayersUnitLimit);
     lua_register(Lua, "SetAllPlayersBuildingLimit",
        CclSetAllPlayersBuildingLimit);
     lua_register(Lua, "SetAllPlayersTotalUnitLimit",
Index: stratagus/src/clone/clone.c
diff -u stratagus/src/clone/clone.c:1.224 stratagus/src/clone/clone.c:1.225
--- stratagus/src/clone/clone.c:1.224   Wed Nov 12 15:40:24 2003
+++ stratagus/src/clone/clone.c Sun Nov 16 01:49:25 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: clone.c,v 1.224 2003/11/12 20:40:24 jsalmon3 Exp $
+//     $Id: clone.c,v 1.225 2003/11/16 06:49:25 mr-russ Exp $
 
 //@{
 
@@ -1088,7 +1088,8 @@
            NetPlayers = 0;
 
            // Start new music for menus
-           if (PlayingMusic && strcmp(CurrentMusicFile, MenuMusic)) {
+           if (PlayingMusic && MenuMusic != NULL &&
+               strcmp(CurrentMusicFile, MenuMusic)) {
                StopMusic();
            }
            PlaySectionMusic(PlaySectionMainMenu);
Index: stratagus/src/clone/player.c
diff -u stratagus/src/clone/player.c:1.97 stratagus/src/clone/player.c:1.98
--- stratagus/src/clone/player.c:1.97   Fri Nov 14 23:38:51 2003
+++ stratagus/src/clone/player.c        Sun Nov 16 01:49:26 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: player.c,v 1.97 2003/11/15 04:38:51 mr-russ Exp $
+//     $Id: player.c,v 1.98 2003/11/16 06:49:26 mr-russ Exp $
 
 //@{
 
@@ -202,7 +202,7 @@
     int j;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: players $Id: player.c,v 1.97 2003/11/15 
04:38:51 mr-russ Exp $\n\n");
+    CLprintf(file, ";;; MODULE: players $Id: player.c,v 1.98 2003/11/16 
06:49:26 mr-russ Exp $\n\n");
 
     //
     // Dump table wc2 race numbers -> internal symbol.
@@ -310,9 +310,10 @@
 
        // Ai done by load ais.
 
-       CLprintf (file, "  'food %d", Players[i].Food);
-       CLprintf(file, " 'food-unit-limit %d", Players[i].FoodUnitLimit);
+       CLprintf(file, " 'supply %d", Players[i].Supply);
+       CLprintf(file, " 'demand %d", Players[i].Demand);
        CLprintf(file, " 'building-limit %d", Players[i].BuildingLimit);
+       CLprintf(file, " 'unit-limit %d", Players[i].UnitLimit);
        CLprintf(file, " 'total-unit-limit %d", Players[i].TotalUnitLimit);
 
        CLprintf(file, "\n  'score %d", Players[i].Score);
@@ -511,8 +512,8 @@
     */
     memset(&(player->UnitTypesCount), 0, sizeof(player->UnitTypesCount));
 
-    player->Food = 0;
-    player->NumFoodUnits = 0;
+    player->Supply = 0;
+    player->Demand = 0;
     player->NumBuildings = 0;
     player->TotalNumUnits = 0;
     player->Score = 0;
@@ -595,53 +596,40 @@
 **     @param player   Pointer to player.
 **     @param type     Type of unit.
 **
-**     @return         True if enought, false otherwise.
+**     @return         True if enough, negative on problem.
 **
 **     @note   The return values of the PlayerCheck functions are inconsistent.
 */
 global int PlayerCheckLimits(const Player* player, const UnitType* type)
 {
-    // FIXME: currently all units costs 1 unit slot.
     //
     // Check game limits.
     //
     if (NumUnits < UnitMax) {
-       if ((type->Building ?  player->NumBuildings < player->BuildingLimit :
-               player->NumFoodUnits + type->Demand <= player->FoodUnitLimit) &&
-               player->TotalNumUnits < player->TotalUnitLimit) {
-           return 1;
+       if (type->Building && player->NumBuildings >= player->BuildingLimit) {
+           NotifyPlayer(player, NotifyYellow, 0, 0, "Building Limit Reached");
+           return -1;
+       }
+       if (!type->Building && (player->TotalNumUnits - player->NumBuildings) 
>= player->UnitLimit) {
+           NotifyPlayer(player, NotifyYellow, 0, 0, "Unit Limit Reached");
+           return -2;
+       }
+       if (player->Demand + type->Demand > player->Supply && type->Demand) {
+           NotifyPlayer(player, NotifyYellow, 0, 0, "Not enough food...build 
more farms.");
+           return -3;
+       }
+       if (player->TotalNumUnits >= player->TotalUnitLimit) {
+           NotifyPlayer(player, NotifyYellow, 0, 0, "Unit Limit Reached");
+           return -4;
        }
-    }
-
-    NotifyPlayer(player, NotifyYellow, 0, 0, "Cannot create more units.");
-    if (player->Ai) {
-       // AiNoMoreUnits(player, type);
-    }
-    return 0;
-}
-
-/**
-**     Check if enough food for new unit is available.
-**
-**     @param player   Pointer to player.
-**     @param type     Type of unit.
-**     @return         True if enought, false otherwise.
-**
-**     @note   The return values of the PlayerCheck functions are inconsistent.
-*/
-global int PlayerCheckFood(const Player* player, const UnitType* type)
-{
-    // FIXME: currently all units costs 1 food
-
-    if (player->Food < player->NumFoodUnits + type->Demand) {
-       NotifyPlayer(player, NotifyYellow, 0, 0, "Not enough food...build more 
farms.");
+       return 1;
+    } else {
+       NotifyPlayer(player, NotifyYellow, 0, 0, "Cannot create more units.");
        if (player->Ai) {
-           // FIXME: message to AI, called too much
-           DebugLevel3("Ai: Not enough food...build more farms.\n");
+           // AiNoMoreUnits(player, type);
        }
-       return 0;
+       return -5;
     }
-    return 1;
 }
 
 /**
Index: stratagus/src/clone/unit.c
diff -u stratagus/src/clone/unit.c:1.337 stratagus/src/clone/unit.c:1.338
--- stratagus/src/clone/unit.c:1.337    Fri Nov 14 23:38:51 2003
+++ stratagus/src/clone/unit.c  Sun Nov 16 01:49:26 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.c,v 1.337 2003/11/15 04:38:51 mr-russ Exp $
+//     $Id: unit.c,v 1.338 2003/11/16 06:49:26 mr-russ Exp $
 
 //@{
 
@@ -435,7 +435,7 @@
     }
 
     if (type->Demand) {
-       player->NumFoodUnits += type->Demand;   // food needed
+       player->Demand += type->Demand; // food needed
        if (player == ThisPlayer) {
            MustRedraw |= RedrawResources;      // update food
        }
@@ -779,7 +779,7 @@
     // Handle unit demand. (Currently only food supported.)
     //
     if (type->Demand) {
-       player->NumFoodUnits -= type->Demand;
+       player->Demand -= type->Demand;
        if (player == ThisPlayer) {
            MustRedraw |= RedrawResources;      // update food
            // FIXME: MustRedraw |= RedrawFood;
@@ -791,7 +791,7 @@
     //
     if (unit->Orders[0].Action != UnitActionBuilded) {
        if (type->Supply) {                     // supply
-           player->Food -= type->Supply;
+           player->Supply -= type->Supply;
            if (player == ThisPlayer) {
                MustRedraw |= RedrawResources;
                // FIXME: MustRedraw |= RedrawFood;
@@ -890,7 +890,7 @@
     //         Note an upgraded unit can't give more supply.
     //
     if (type->Supply && !upgrade) {
-       player->Food += type->Supply;
+       player->Supply += type->Supply;
        if (player == ThisPlayer) {
            MustRedraw |= RedrawResources;      // update food
        }
@@ -1582,12 +1582,12 @@
     if (unit->Type->GivesResource) {
        DebugLevel0Fn("Resource transfer not supported\n");
     }
-    if (!unit->Type->Building) {
-       newplayer->NumFoodUnits += unit->Type->Demand;
-       if (newplayer == ThisPlayer) {
-           MustRedraw |= RedrawResources;// update food
-       }
-    } else {
+    newplayer->Demand += unit->Type->Demand;
+    newplayer->Supply += unit->Type->Supply;
+    if (newplayer == ThisPlayer) {
+       MustRedraw |= RedrawResources;// update food
+    }
+    if (unit->Type->Building) {
        newplayer->NumBuildings++;
     }
     newplayer->UnitTypesCount[unit->Type->Type]++;
@@ -3851,7 +3851,7 @@
     int RunStart;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.337 2003/11/15 04:38:51 
mr-russ Exp $\n\n");
+    CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.338 2003/11/16 06:49:26 
mr-russ Exp $\n\n");
 
     //
     // Local variables
Index: stratagus/src/game/trigger.c
diff -u stratagus/src/game/trigger.c:1.46 stratagus/src/game/trigger.c:1.47
--- stratagus/src/game/trigger.c:1.46   Wed Nov 12 15:43:22 2003
+++ stratagus/src/game/trigger.c        Sun Nov 16 01:49:26 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: trigger.c,v 1.46 2003/11/12 20:43:22 jsalmon3 Exp $
+//     $Id: trigger.c,v 1.47 2003/11/16 06:49:26 mr-russ Exp $
 
 //@{
 
@@ -242,7 +242,7 @@
        }
     } else if (unittype == ALL_FOODUNITS) {
        for (; plynr < pn; ++plynr) {
-           if (compare(Players[plynr].NumFoodUnits, q)) {
+           if (compare(Players[plynr].TotalNumUnits - 
Players[plynr].NumBuildings, q)) {
                return SCM_BOOL_T;
            }
        }
@@ -1216,7 +1216,7 @@
     int trigger;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: trigger $Id: trigger.c,v 1.46 2003/11/12 
20:43:22 jsalmon3 Exp $\n\n");
+    CLprintf(file, ";;; MODULE: trigger $Id: trigger.c,v 1.47 2003/11/16 
06:49:26 mr-russ Exp $\n\n");
 
     i = 0;
     trigger = -1;
Index: stratagus/src/include/player.h
diff -u stratagus/src/include/player.h:1.76 stratagus/src/include/player.h:1.77
--- stratagus/src/include/player.h:1.76 Thu Oct 23 14:38:35 2003
+++ stratagus/src/include/player.h      Sun Nov 16 01:49:26 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: player.h,v 1.76 2003/10/23 18:38:35 n0body Exp $
+//     $Id: player.h,v 1.77 2003/11/16 06:49:26 mr-russ Exp $
 
 #ifndef __PLAYER_H__
 #define __PLAYER_H__
@@ -177,9 +177,9 @@
 **             Total number of units (incl. buildings) in the Player::Units
 **             table.
 **
-**     Player::NumFoodUnits
+**     Player::Demand
 **
-**             Total number of units that need food, used to check food limit.
+**             Total unit demand, used to demand limit.
 **             A player can only build up to Player::Food units and not more
 **             than Player::FoodUnitLimit units.
 **
@@ -317,10 +317,6 @@
     int                Incomes[MaxCosts];      /// income of the resources
     int                Revenue[MaxCosts];      /// income rate of the resources
 
-//  FIXME: needed again? if not remove
-//    unsigned UnitFlags[
-//     (UnitTypeMax+BitsOf(unsigned)-1)
-//         /BitsOf(unsigned)];         /// flags what units are available
     // FIXME: shouldn't use the constant
     int                UnitTypesCount[UnitTypeMax];    /// total units of 
unit-type
 
@@ -330,11 +326,12 @@
     Unit**     Units;                  /// units of this player
     int                TotalNumUnits;          /// total # units for units' 
list
 
-    int                NumFoodUnits;           /// # units (need food)
-    int                NumBuildings;           /// # buildings (don't need 
food)
+    int                NumBuildings;           /// # buildings
 
-    int                Food;                   /// food available/produced
-    int                FoodUnitLimit;          /// # food units allowed
+    int                Supply;                 /// supply available/produced
+    int                Demand;                 /// demand of player
+    
+    int                UnitLimit;              /// # food units allowed
     int                BuildingLimit;          /// # buildings allowed
     int                TotalUnitLimit;         /// # total unit number allowed
 
@@ -488,11 +485,8 @@
     /// Set a resource of the player
 extern void PlayerSetResource(Player* player,int resource,int value);
 
-    /// Check if the unit-type didn't break any unit limits
+    /// Check if the unit-type didn't break any unit limits and supply/demand
 extern int PlayerCheckLimits(const Player* player,const UnitType* type);
-
-    /// Check if enough food is available for unit-type
-extern int PlayerCheckFood(const Player* player,const UnitType* type);
 
     /// Check if enough resources are available for costs
 extern int PlayerCheckCosts(const Player* player,const int* costs);
Index: stratagus/src/ui/botpanel.c
diff -u stratagus/src/ui/botpanel.c:1.97 stratagus/src/ui/botpanel.c:1.98
--- stratagus/src/ui/botpanel.c:1.97    Mon Nov  3 01:14:30 2003
+++ stratagus/src/ui/botpanel.c Sun Nov 16 01:49:27 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: botpanel.c,v 1.97 2003/11/03 06:14:30 nehalmistry Exp $
+//     $Id: botpanel.c,v 1.98 2003/11/16 06:49:27 mr-russ Exp $
 
 //@{
 
@@ -103,7 +103,7 @@
     char* cp;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: buttons $Id: botpanel.c,v 1.97 2003/11/03 
06:14:30 nehalmistry Exp $\n\n");
+    CLprintf(file, ";;; MODULE: buttons $Id: botpanel.c,v 1.98 2003/11/16 
06:49:27 mr-russ Exp $\n\n");
 
     for (i = 0; i < NumUnitButtons; ++i) {
        CLprintf(file, "(define-button 'pos %d 'level %d 'icon '%s\n",
@@ -1002,7 +1002,7 @@
                        !EnableTrainingQueue)) {
                NotifyPlayer(Selected[0]->Player, NotifyYellow, Selected[0]->X,
                    Selected[0]->Y, "Unit training queue is full");
-           } else if (PlayerCheckFood(ThisPlayer, type) &&
+           } else if (PlayerCheckLimits(ThisPlayer, type) >= 0 &&
                    !PlayerCheckUnitType(ThisPlayer, type)) {
                //PlayerSubUnitType(ThisPlayer,type);
                SendCommandTrainUnit(Selected[0], type,
Index: stratagus/src/ui/mainscr.c
diff -u stratagus/src/ui/mainscr.c:1.142 stratagus/src/ui/mainscr.c:1.143
--- stratagus/src/ui/mainscr.c:1.142    Thu Nov 13 15:15:55 2003
+++ stratagus/src/ui/mainscr.c  Sun Nov 16 01:49:28 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mainscr.c,v 1.142 2003/11/13 20:15:55 mr-russ Exp $
+//     $Id: mainscr.c,v 1.143 2003/11/16 06:49:28 mr-russ Exp $
 
 //@{
 
@@ -447,16 +447,16 @@
 
     if (type->Building && !type->CanAttack) {
        if (type->Supply) {             // Supply unit
-           VideoDrawText(x + 16, y + 8 + 63, GameFont, "Food Usage");
-           VideoDrawText(x + 58, y + 8 + 78, GameFont, "Grown:");
-           VideoDrawNumber(x + 108, y + 8 + 78, GameFont, unit->Player->Food);
-           VideoDrawText(x + 71, y + 8 + 94, GameFont, "Used:");
-           if (unit->Player->Food < unit->Player->NumFoodUnits) {
+           VideoDrawText(x + 16, y + 8 + 63, GameFont, "Usage");
+           VideoDrawText(x + 58, y + 8 + 78, GameFont, "Supply:");
+           VideoDrawNumber(x + 108, y + 8 + 78, GameFont, 
unit->Player->Supply);
+           VideoDrawText(x + 51, y + 8 + 94, GameFont, "Demand:");
+           if (unit->Player->Supply < unit->Player->Demand) {
                VideoDrawReverseNumber(x + 108, y + 8 + 94, GameFont,
-                   unit->Player->NumFoodUnits);
+                   unit->Player->Demand);
            } else {
                VideoDrawNumber(x + 108, y + 8 + 94, GameFont,
-                   unit->Player->NumFoodUnits);
+                   unit->Player->Demand);
            }
        }
     } else {
@@ -597,8 +597,8 @@
            TheUI.Resources[FoodCost].IconX, TheUI.Resources[FoodCost].IconY);
     }
     if (TheUI.Resources[FoodCost].TextX != -1) {
-       sprintf(tmp, "%d/%d", ThisPlayer->NumFoodUnits, ThisPlayer->Food);
-       if (ThisPlayer->Food < ThisPlayer->NumFoodUnits) {
+       sprintf(tmp, "%d/%d", ThisPlayer->Demand, ThisPlayer->Supply);
+       if (ThisPlayer->Supply < ThisPlayer->Demand) {
            VideoDrawReverseText(TheUI.Resources[FoodCost].TextX,
                TheUI.Resources[FoodCost].TextY, GameFont, tmp);
        } else {




reply via email to

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