Remove Supply and Demand.
This commit is contained in:
parent
c058e9032c
commit
a2e50ec8c0
12 changed files with 5 additions and 394 deletions
|
@ -115,55 +115,6 @@ static int AiCheckCosts(const int *costs)
|
|||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
** Check if the AI player needs food.
|
||||
**
|
||||
** It counts buildings in progress and units in training queues.
|
||||
**
|
||||
** @param pai AI player.
|
||||
** @param type Unit-type that should be build.
|
||||
**
|
||||
** @return True if enought, false otherwise.
|
||||
**
|
||||
** @todo The number of food currently trained can be stored global
|
||||
** for faster use.
|
||||
*/
|
||||
static int AiCheckSupply(const PlayerAi *pai, const CUnitType *type)
|
||||
{
|
||||
int remaining;
|
||||
const AiBuildQueue *queue;
|
||||
int i;
|
||||
|
||||
//
|
||||
// Count food supplies under construction.
|
||||
//
|
||||
remaining = 0;
|
||||
for (i = 0; i < (int)pai->UnitTypeBuilt.size(); ++i) {
|
||||
queue = &pai->UnitTypeBuilt[i];
|
||||
if (queue->Type->Supply) {
|
||||
remaining += queue->Made * queue->Type->Supply;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// We are already out of food.
|
||||
//
|
||||
remaining += pai->Player->Supply - pai->Player->Demand - type->Demand;
|
||||
if (remaining < 0) {
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Count what we train.
|
||||
//
|
||||
for (i = 0; i < (int)pai->UnitTypeBuilt.size(); ++i) {
|
||||
queue = &pai->UnitTypeBuilt[i];
|
||||
if ((remaining -= queue->Made * queue->Type->Demand) < 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
** Check if the costs for a unit-type are available for the AI.
|
||||
**
|
||||
|
@ -295,68 +246,6 @@ static int AiBuildBuilding(const CUnitType *type, CUnitType *building)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Build new units to reduce the food shortage.
|
||||
*/
|
||||
static void AiRequestSupply(void)
|
||||
{
|
||||
int i;
|
||||
int n;
|
||||
int c;
|
||||
CUnitType *type;
|
||||
AiBuildQueue *queue;
|
||||
int counter[UnitTypeMax];
|
||||
unsigned int needmask;
|
||||
|
||||
//
|
||||
// Don't request supply if we're sleeping. When the script starts it may
|
||||
// request a better unit than the one we pick here. If we only have enough
|
||||
// resources for one unit we don't want to build the wrong one.
|
||||
//
|
||||
if (AiPlayer->SleepCycles != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Count the already made build requests.
|
||||
//
|
||||
memset(counter, 0, sizeof(counter));
|
||||
for (i = 0; i < (int)AiPlayer->UnitTypeBuilt.size(); ++i) {
|
||||
queue = &AiPlayer->UnitTypeBuilt[i];
|
||||
counter[queue->Type->Slot] += queue->Want;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if we can build this?
|
||||
//
|
||||
n = AiHelpers.UnitLimit[0].size();
|
||||
needmask = 0;
|
||||
for (i = 0; i < n; ++i) {
|
||||
type = AiHelpers.UnitLimit[0][i];
|
||||
if (counter[type->Slot]) { // Already ordered.
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if resources available.
|
||||
//
|
||||
if ((c = AiCheckUnitTypeCosts(type))) {
|
||||
needmask |= c;
|
||||
} else {
|
||||
if (AiMakeUnit(type)) {
|
||||
AiBuildQueue newqueue;
|
||||
newqueue.Type = type;
|
||||
newqueue.Want = 1;
|
||||
newqueue.Made = 1;
|
||||
AiPlayer->UnitTypeBuilt.insert(
|
||||
AiPlayer->UnitTypeBuilt.begin(), newqueue);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
AiPlayer->NeededMask |= needmask;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Check if we can train the unit.
|
||||
**
|
||||
|
@ -529,14 +418,6 @@ static void AiCheckingWork(void)
|
|||
CUnitType *type;
|
||||
AiBuildQueue *queue;
|
||||
|
||||
// Suppy has the highest priority
|
||||
if (AiPlayer->NeedSupply) {
|
||||
if (!(!AiPlayer->UnitTypeBuilt.empty() &&
|
||||
AiPlayer->UnitTypeBuilt[0].Type->Supply)) {
|
||||
AiPlayer->NeedSupply = false;
|
||||
AiRequestSupply();
|
||||
}
|
||||
}
|
||||
//
|
||||
// Look to the build requests, what can be done.
|
||||
//
|
||||
|
@ -550,13 +431,6 @@ static void AiCheckingWork(void)
|
|||
// FIXME: must check if requirements are fulfilled.
|
||||
// Buildings can be destroyed.
|
||||
|
||||
//
|
||||
// Check if we have enough food.
|
||||
//
|
||||
if (type->Demand && !AiCheckSupply(AiPlayer, type)) {
|
||||
AiPlayer->NeedSupply = true;
|
||||
AiRequestSupply();
|
||||
}
|
||||
//
|
||||
// Check limits, AI should be broken if reached.
|
||||
//
|
||||
|
@ -1132,12 +1006,6 @@ void AiResourceManager(void)
|
|||
//
|
||||
AiCheckingWork();
|
||||
//
|
||||
// Look if we can build a farm in advance.
|
||||
//
|
||||
if (!AiPlayer->NeedSupply && AiPlayer->Player->Supply == AiPlayer->Player->Demand) {
|
||||
AiRequestSupply();
|
||||
}
|
||||
//
|
||||
// Collect resources.
|
||||
//
|
||||
if ((GameCycle / CYCLES_PER_SECOND) % COLLECT_RESOURCES_INTERVAL ==
|
||||
|
|
|
@ -117,55 +117,6 @@ static std::vector<CUnitType *> getReparableUnits()
|
|||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
** Get sorted list of unittype with Supply not null.
|
||||
**
|
||||
** @note Better (supply / cost) first.
|
||||
*/
|
||||
static std::vector<CUnitType *> getSupplyUnits()
|
||||
{
|
||||
std::vector<CUnitType *> res;
|
||||
std::vector<CUnitType *> sorted_res;
|
||||
|
||||
|
||||
for (std::vector<CUnitType *>::const_iterator i = UnitTypes.begin(); i != UnitTypes.end(); ++i) {
|
||||
CUnitType *type = *i;
|
||||
|
||||
if (type->Supply > 0) {
|
||||
res.push_back(type);
|
||||
}
|
||||
}
|
||||
// Now, sort them, best first.
|
||||
while (!res.empty()) {
|
||||
float bestscore;
|
||||
CUnitType *besttype;
|
||||
|
||||
bestscore = 0;
|
||||
for (std::vector<CUnitType *>::const_iterator i = res.begin(); i != res.end(); ++i) {
|
||||
CUnitType *type = *i;
|
||||
float score;
|
||||
unsigned int cost = 0;
|
||||
|
||||
for (unsigned j = 0; j < MaxCosts; ++j) {
|
||||
cost += type->_Costs[j];
|
||||
}
|
||||
score = ((float) type->Supply) / cost;
|
||||
if (score > bestscore) {
|
||||
bestscore = score;
|
||||
besttype = type;
|
||||
}
|
||||
}
|
||||
sorted_res.push_back(besttype);
|
||||
for (std::vector<CUnitType *>::iterator i = res.begin(); i != res.end(); ++i) {
|
||||
if (*i == besttype) {
|
||||
i = res.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sorted_res;
|
||||
}
|
||||
|
||||
/**
|
||||
** Init AiHelper.
|
||||
**
|
||||
|
@ -178,11 +129,6 @@ static void InitAiHelper(AiHelper &aiHelper)
|
|||
extern std::vector<ButtonAction *> UnitButtonTable;
|
||||
|
||||
std::vector<CUnitType *> reparableUnits = getReparableUnits();
|
||||
std::vector<CUnitType *> supplyUnits = getSupplyUnits();
|
||||
|
||||
for (std::vector<CUnitType *>::const_iterator i = supplyUnits.begin(); i != supplyUnits.end(); ++i) {
|
||||
AiHelperInsert(aiHelper.UnitLimit, 0, *i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)UnitButtonTable.size(); ++i) {
|
||||
const ButtonAction &button = *UnitButtonTable[i];
|
||||
|
@ -1187,9 +1133,6 @@ static int CclDefineAiPlayer(lua_State *l)
|
|||
lua_pop(l, 1);
|
||||
ai->NeededMask |= (1 << DefaultResourceNumber(type));
|
||||
}
|
||||
} else if (!strcmp(value, "need-supply")) {
|
||||
ai->NeedSupply = true;
|
||||
--j;
|
||||
} else if (!strcmp(value, "exploration")) {
|
||||
if (!lua_istable(l, j + 1)) {
|
||||
LuaError(l, "incorrect argument");
|
||||
|
|
|
@ -324,8 +324,6 @@ public:
|
|||
CUnit *Units[UnitMax]; /// units of this player
|
||||
int TotalNumUnits; /// total # units for units' list
|
||||
int NumBuildings; /// # buildings
|
||||
int Supply; /// supply available/produced
|
||||
int Demand; /// demand of player
|
||||
|
||||
int UnitLimit; /// # food units allowed
|
||||
int BuildingLimit; /// # buildings allowed
|
||||
|
|
|
@ -356,18 +356,10 @@
|
|||
**
|
||||
** CUnitType::Weapon
|
||||
**
|
||||
** Currently sound for weapon
|
||||
** Current sound for weapon
|
||||
**
|
||||
** @todo temporary solution
|
||||
**
|
||||
** CUnitType::Supply
|
||||
**
|
||||
** How much food does this unit supply.
|
||||
**
|
||||
** CUnitType::Demand
|
||||
**
|
||||
** Food demand
|
||||
**
|
||||
** CUnitType::ImproveIncomes[::MaxCosts]
|
||||
**
|
||||
** Gives the player an improved income.
|
||||
|
@ -585,8 +577,6 @@ enum {
|
|||
CARRYRESOURCE_INDEX,
|
||||
XP_INDEX,
|
||||
KILL_INDEX,
|
||||
SUPPLY_INDEX,
|
||||
DEMAND_INDEX,
|
||||
ARMOR_INDEX,
|
||||
SIGHTRANGE_INDEX,
|
||||
ATTACKRANGE_INDEX,
|
||||
|
@ -812,7 +802,7 @@ public:
|
|||
BoolFlag(NULL), Variable(NULL), CanTargetFlag(NULL),
|
||||
SelectableByRectangle(0), IsNotSelectable(0), Decoration(0),
|
||||
Indestructible(0), Teleporter(0),
|
||||
GivesResource(0), Supply(0), Demand(0), FieldFlags(0), MovementMask(0),
|
||||
GivesResource(0), FieldFlags(0), MovementMask(0),
|
||||
Sprite(NULL), ShadowSprite(NULL)
|
||||
{
|
||||
memset(_Costs, 0, sizeof(_Costs));
|
||||
|
@ -933,9 +923,6 @@ public:
|
|||
|
||||
CUnitSound Sound; /// Sounds for events
|
||||
|
||||
int Supply; /// Food supply
|
||||
int Demand; /// Food demand
|
||||
|
||||
int ProductionRate[MaxCosts]; /// Rate that resources are produced
|
||||
int MaxUtilizationRate[MaxCosts]; /// Max resource rate that can be used
|
||||
int ProductionCosts[MaxCosts]; /// Total cost to produce this type
|
||||
|
|
|
@ -429,7 +429,6 @@ void SavePlayers(CFile *file)
|
|||
// TotalNumUnits done by load units.
|
||||
// NumBuildings done by load units.
|
||||
|
||||
file->printf(" \"supply\", %d,", p->Supply);
|
||||
file->printf(" \"unit-limit\", %d,", p->UnitLimit);
|
||||
file->printf(" \"building-limit\", %d,", p->BuildingLimit);
|
||||
file->printf(" \"total-unit-limit\", %d,", p->TotalUnitLimit);
|
||||
|
@ -608,8 +607,6 @@ void CreatePlayer(int type)
|
|||
|
||||
memset(player->UnitTypesCount, 0, sizeof(player->UnitTypesCount));
|
||||
|
||||
player->Supply = 0;
|
||||
player->Demand = 0;
|
||||
player->NumBuildings = 0;
|
||||
player->TotalNumUnits = 0;
|
||||
player->Score = 0;
|
||||
|
@ -664,8 +661,6 @@ void CPlayer::Clear()
|
|||
memset(Units, 0, sizeof(Units));
|
||||
TotalNumUnits = 0;
|
||||
NumBuildings = 0;
|
||||
Supply = 0;
|
||||
Demand = 0;
|
||||
// FIXME: can't clear limits since it's initialized already
|
||||
// UnitLimit = 0;
|
||||
// BuildingLimit = 0;
|
||||
|
@ -718,10 +713,6 @@ int CPlayer::CheckLimits(const CUnitType *type) const
|
|||
Notify(NotifyYellow, -1, -1, _("Unit Limit Reached"));
|
||||
return -2;
|
||||
}
|
||||
if (this->Demand + type->Demand > this->Supply && type->Demand) {
|
||||
Notify(NotifyYellow, -1, -1, _("Insufficient Supply, increase Supply."));
|
||||
return -3;
|
||||
}
|
||||
if (this->TotalNumUnits >= this->TotalUnitLimit) {
|
||||
Notify(NotifyYellow, -1, -1, _("Total Unit Limit Reached"));
|
||||
return -4;
|
||||
|
|
|
@ -329,10 +329,6 @@ static int CclPlayer(lua_State *l)
|
|||
} else if (!strcmp(value, "ai-disabled")) {
|
||||
player->AiEnabled = 0;
|
||||
--j;
|
||||
} else if (!strcmp(value, "supply")) {
|
||||
player->Supply = LuaToNumber(l, j + 1);
|
||||
} else if (!strcmp(value, "demand")) {
|
||||
player->Demand = LuaToNumber(l, j + 1);
|
||||
} else if (!strcmp(value, "unit-limit")) {
|
||||
player->UnitLimit = LuaToNumber(l, j + 1);
|
||||
} else if (!strcmp(value, "building-limit")) {
|
||||
|
@ -762,12 +758,6 @@ static int CclGetPlayerData(lua_State *l)
|
|||
} else if (!strcmp(data, "NumBuildings")) {
|
||||
lua_pushnumber(l, p->NumBuildings);
|
||||
return 1;
|
||||
} else if (!strcmp(data, "Supply")) {
|
||||
lua_pushnumber(l, p->Supply);
|
||||
return 1;
|
||||
} else if (!strcmp(data, "Demand")) {
|
||||
lua_pushnumber(l, p->Demand);
|
||||
return 1;
|
||||
} else if (!strcmp(data, "UnitLimit")) {
|
||||
lua_pushnumber(l, p->UnitLimit);
|
||||
return 1;
|
||||
|
@ -854,8 +844,6 @@ static int CclSetPlayerData(lua_State *l)
|
|||
// } else if (!strcmp(data, "AiEnabled")) {
|
||||
// } else if (!strcmp(data, "TotalNumUnits")) {
|
||||
// } else if (!strcmp(data, "NumBuildings")) {
|
||||
// } else if (!strcmp(data, "Supply")) {
|
||||
// } else if (!strcmp(data, "Demand")) {
|
||||
} else if (!strcmp(data, "UnitLimit")) {
|
||||
p->UnitLimit = LuaToNumber(l, 3);
|
||||
} else if (!strcmp(data, "BuildingLimit")) {
|
||||
|
|
|
@ -26,8 +26,6 @@ class CPlayer
|
|||
CUnit *Units[UnitMax];
|
||||
int TotalNumUnits;
|
||||
int NumBuildings;
|
||||
int Supply;
|
||||
int Demand;
|
||||
|
||||
int UnitLimit;
|
||||
int BuildingLimit;
|
||||
|
|
126
tolua/tolua.cpp
126
tolua/tolua.cpp
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
** Lua binding: stratagus
|
||||
** Generated automatically by tolua++-1.0.92 on Thu Mar 29 23:28:22 2007.
|
||||
** Generated automatically by tolua++-1.0.92 on Sun Apr 1 23:37:09 2007.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
@ -12935,66 +12935,6 @@ static int tolua_set_CPlayer_NumBuildings(lua_State* tolua_S)
|
|||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* get function: Supply of class CPlayer */
|
||||
#ifndef TOLUA_DISABLE_tolua_get_CPlayer_Supply
|
||||
static int tolua_get_CPlayer_Supply(lua_State* tolua_S)
|
||||
{
|
||||
CPlayer* self = (CPlayer*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Supply'",NULL);
|
||||
#endif
|
||||
tolua_pushnumber(tolua_S,(lua_Number)self->Supply);
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* set function: Supply of class CPlayer */
|
||||
#ifndef TOLUA_DISABLE_tolua_set_CPlayer_Supply
|
||||
static int tolua_set_CPlayer_Supply(lua_State* tolua_S)
|
||||
{
|
||||
CPlayer* self = (CPlayer*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Supply'",NULL);
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
|
||||
#endif
|
||||
self->Supply = ((int) tolua_tonumber(tolua_S,2,0))
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* get function: Demand of class CPlayer */
|
||||
#ifndef TOLUA_DISABLE_tolua_get_CPlayer_Demand
|
||||
static int tolua_get_CPlayer_Demand(lua_State* tolua_S)
|
||||
{
|
||||
CPlayer* self = (CPlayer*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Demand'",NULL);
|
||||
#endif
|
||||
tolua_pushnumber(tolua_S,(lua_Number)self->Demand);
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* set function: Demand of class CPlayer */
|
||||
#ifndef TOLUA_DISABLE_tolua_set_CPlayer_Demand
|
||||
static int tolua_set_CPlayer_Demand(lua_State* tolua_S)
|
||||
{
|
||||
CPlayer* self = (CPlayer*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Demand'",NULL);
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
|
||||
#endif
|
||||
self->Demand = ((int) tolua_tonumber(tolua_S,2,0))
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* get function: UnitLimit of class CPlayer */
|
||||
#ifndef TOLUA_DISABLE_tolua_get_CPlayer_UnitLimit
|
||||
static int tolua_get_CPlayer_UnitLimit(lua_State* tolua_S)
|
||||
|
@ -13773,66 +13713,6 @@ static int tolua_set_CUnitType_MinAttackRange(lua_State* tolua_S)
|
|||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* get function: Supply of class CUnitType */
|
||||
#ifndef TOLUA_DISABLE_tolua_get_CUnitType_Supply
|
||||
static int tolua_get_CUnitType_Supply(lua_State* tolua_S)
|
||||
{
|
||||
CUnitType* self = (CUnitType*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Supply'",NULL);
|
||||
#endif
|
||||
tolua_pushnumber(tolua_S,(lua_Number)self->Supply);
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* set function: Supply of class CUnitType */
|
||||
#ifndef TOLUA_DISABLE_tolua_set_CUnitType_Supply
|
||||
static int tolua_set_CUnitType_Supply(lua_State* tolua_S)
|
||||
{
|
||||
CUnitType* self = (CUnitType*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Supply'",NULL);
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
|
||||
#endif
|
||||
self->Supply = ((int) tolua_tonumber(tolua_S,2,0))
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* get function: Demand of class CUnitType */
|
||||
#ifndef TOLUA_DISABLE_tolua_get_CUnitType_Demand
|
||||
static int tolua_get_CUnitType_Demand(lua_State* tolua_S)
|
||||
{
|
||||
CUnitType* self = (CUnitType*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Demand'",NULL);
|
||||
#endif
|
||||
tolua_pushnumber(tolua_S,(lua_Number)self->Demand);
|
||||
return 1;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* set function: Demand of class CUnitType */
|
||||
#ifndef TOLUA_DISABLE_tolua_set_CUnitType_Demand
|
||||
static int tolua_set_CUnitType_Demand(lua_State* tolua_S)
|
||||
{
|
||||
CUnitType* self = (CUnitType*) tolua_tousertype(tolua_S,1,0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Demand'",NULL);
|
||||
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
|
||||
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
|
||||
#endif
|
||||
self->Demand = ((int) tolua_tonumber(tolua_S,2,0))
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* function: UnitTypeByIdent */
|
||||
#ifndef TOLUA_DISABLE_tolua_stratagus_UnitTypeByIdent00
|
||||
static int tolua_stratagus_UnitTypeByIdent00(lua_State* tolua_S)
|
||||
|
@ -16678,8 +16558,6 @@ TOLUA_API int tolua_stratagus_open (lua_State* tolua_S)
|
|||
tolua_array(tolua_S,"Units",tolua_get_stratagus_CPlayer_Units,tolua_set_stratagus_CPlayer_Units);
|
||||
tolua_variable(tolua_S,"TotalNumUnits",tolua_get_CPlayer_TotalNumUnits,tolua_set_CPlayer_TotalNumUnits);
|
||||
tolua_variable(tolua_S,"NumBuildings",tolua_get_CPlayer_NumBuildings,tolua_set_CPlayer_NumBuildings);
|
||||
tolua_variable(tolua_S,"Supply",tolua_get_CPlayer_Supply,tolua_set_CPlayer_Supply);
|
||||
tolua_variable(tolua_S,"Demand",tolua_get_CPlayer_Demand,tolua_set_CPlayer_Demand);
|
||||
tolua_variable(tolua_S,"UnitLimit",tolua_get_CPlayer_UnitLimit,tolua_set_CPlayer_UnitLimit);
|
||||
tolua_variable(tolua_S,"BuildingLimit",tolua_get_CPlayer_BuildingLimit,tolua_set_CPlayer_BuildingLimit);
|
||||
tolua_variable(tolua_S,"TotalUnitLimit",tolua_get_CPlayer_TotalUnitLimit,tolua_set_CPlayer_TotalUnitLimit);
|
||||
|
@ -16708,8 +16586,6 @@ TOLUA_API int tolua_stratagus_open (lua_State* tolua_S)
|
|||
tolua_variable(tolua_S,"Name",tolua_get_CUnitType_Name,tolua_set_CUnitType_Name);
|
||||
tolua_variable(tolua_S,"Slot",tolua_get_CUnitType_Slot,NULL);
|
||||
tolua_variable(tolua_S,"MinAttackRange",tolua_get_CUnitType_MinAttackRange,tolua_set_CUnitType_MinAttackRange);
|
||||
tolua_variable(tolua_S,"Supply",tolua_get_CUnitType_Supply,tolua_set_CUnitType_Supply);
|
||||
tolua_variable(tolua_S,"Demand",tolua_get_CUnitType_Demand,tolua_set_CUnitType_Demand);
|
||||
tolua_endmodule(tolua_S);
|
||||
tolua_function(tolua_S,"UnitTypeByIdent",tolua_stratagus_UnitTypeByIdent00);
|
||||
tolua_cclass(tolua_S,"CUnit","CUnit","",NULL);
|
||||
|
|
|
@ -5,9 +5,6 @@ class CUnitType
|
|||
tolua_readonly int Slot;
|
||||
|
||||
int MinAttackRange;
|
||||
|
||||
int Supply;
|
||||
int Demand;
|
||||
};
|
||||
|
||||
CUnitType *UnitTypeByIdent(const std::string ident);
|
||||
|
|
|
@ -375,7 +375,7 @@ void UpdateStatusLineForButton(const ButtonAction *button)
|
|||
case ButtonTrain:
|
||||
// FIXME: store pointer in button table!
|
||||
stats = &UnitTypes[button->Value]->Stats[ThisPlayer->Index];
|
||||
SetCosts(0, UnitTypes[button->Value]->Demand, stats->Costs);
|
||||
SetCosts(0, 0, stats->Costs);
|
||||
break;
|
||||
case ButtonSpellCast:
|
||||
SetCosts(SpellTypeTable[button->Value]->ManaCost, 0, NULL);
|
||||
|
|
|
@ -516,10 +516,6 @@ static int CclDefineUnitType(lua_State *l)
|
|||
type->DecayRate = LuaToNumber(l, -1);
|
||||
} else if (!strcmp(value, "Points")) {
|
||||
type->Points = LuaToNumber(l, -1);
|
||||
} else if (!strcmp(value, "Demand")) {
|
||||
type->Demand = LuaToNumber(l, -1);
|
||||
} else if (!strcmp(value, "Supply")) {
|
||||
type->Supply = LuaToNumber(l, -1);
|
||||
} else if (!strcmp(value, "Corpse")) {
|
||||
type->CorpseName = LuaToString(l, -1);
|
||||
type->CorpseType = NULL;
|
||||
|
@ -1840,19 +1836,6 @@ void UpdateUnitVariables(const CUnit *unit)
|
|||
unit->Variable[CARRYRESOURCE_INDEX].Max = unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity;
|
||||
}
|
||||
|
||||
// Supply
|
||||
unit->Variable[SUPPLY_INDEX].Value = unit->Type->Supply;
|
||||
unit->Variable[SUPPLY_INDEX].Max = unit->Player->Supply;
|
||||
if (unit->Player->Supply < unit->Type->Supply) { // Come with 1st supply building.
|
||||
unit->Variable[SUPPLY_INDEX].Value = unit->Variable[SUPPLY_INDEX].Max;
|
||||
}
|
||||
unit->Variable[SUPPLY_INDEX].Enable = unit->Type->Supply > 0;
|
||||
|
||||
// Demand
|
||||
unit->Variable[DEMAND_INDEX].Value = unit->Type->Demand;
|
||||
unit->Variable[DEMAND_INDEX].Max = unit->Player->Demand;
|
||||
unit->Variable[DEMAND_INDEX].Enable = unit->Type->Demand > 0;
|
||||
|
||||
// SightRange
|
||||
unit->Variable[SIGHTRANGE_INDEX].Value = type->Variable[SIGHTRANGE_INDEX].Value;
|
||||
unit->Variable[SIGHTRANGE_INDEX].Max = unit->Stats->Variables[SIGHTRANGE_INDEX].Max;
|
||||
|
@ -1926,7 +1909,7 @@ void InitDefinedVariables()
|
|||
{
|
||||
const char *var[NVARALREADYDEFINED] = {"HitPoints", "Build", "Mana", "Transport",
|
||||
"Training", "GiveResource", "CarryResource",
|
||||
"Xp", "Kill", "Supply", "Demand", "Armor", "SightRange",
|
||||
"Xp", "Kill", "Armor", "SightRange",
|
||||
"AttackRange", "PiercingDamage", "BasicDamage", "PosX", "PosY", "RadarRange",
|
||||
"RadarJammerRange", "AutoRepairRange", "Bloodlust", "Haste", "Slow", "Invisible",
|
||||
"UnholyArmor", "Slot"
|
||||
|
|
|
@ -355,7 +355,6 @@ void CUnit::AssignToPlayer(CPlayer *player)
|
|||
*PlayerSlot = this;
|
||||
|
||||
player->UnitTypesCount[type->Slot]++;
|
||||
player->Demand += type->Demand; // food needed
|
||||
}
|
||||
|
||||
|
||||
|
@ -863,17 +862,10 @@ void UnitLost(CUnit *unit)
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Handle unit demand. (Currently only food supported.)
|
||||
//
|
||||
player->Demand -= type->Demand;
|
||||
|
||||
//
|
||||
// Update information.
|
||||
//
|
||||
if (unit->Orders[0]->Action != UnitActionBuilt) {
|
||||
player->Supply -= type->Supply;
|
||||
|
||||
//
|
||||
// Handle income improvements, look if a player loses a building
|
||||
// which have given him a better income, find the next best
|
||||
|
@ -962,14 +954,6 @@ void UpdateForNewUnit(const CUnit *unit, int upgrade)
|
|||
player = unit->Player;
|
||||
type = unit->Type;
|
||||
|
||||
//
|
||||
// Handle unit supply. (Currently only food supported.)
|
||||
// Note an upgraded unit can't give more supply.
|
||||
//
|
||||
if (!upgrade) {
|
||||
player->Supply += type->Supply;
|
||||
}
|
||||
|
||||
//
|
||||
// Update resources
|
||||
//
|
||||
|
@ -1478,8 +1462,6 @@ void CUnit::ChangeOwner(CPlayer *newplayer)
|
|||
if (Type->GivesResource) {
|
||||
DebugPrint("Resource transfer not supported\n");
|
||||
}
|
||||
newplayer->Demand += Type->Demand;
|
||||
newplayer->Supply += Type->Supply;
|
||||
if (Type->Building) {
|
||||
newplayer->NumBuildings++;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue