Removed research and upgrades, removed Module.make

This commit is contained in:
jim4 2007-03-15 04:20:44 +00:00
parent 0a4c7f7fdb
commit 2ae331965d
68 changed files with 97 additions and 3244 deletions

View file

@ -1,35 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/action
MSRC = action_attack.cpp action_board.cpp action_build.cpp \
action_die.cpp action_follow.cpp action_move.cpp action_patrol.cpp \
action_repair.cpp action_research.cpp action_resource.cpp \
action_returngoods.cpp action_spellcast.cpp action_stand.cpp \
action_still.cpp action_train.cpp action_unload.cpp action_upgradeto.cpp \
actions.cpp command.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -1,120 +0,0 @@
// ____ _ __
// / __ )____ _____ | | / /___ ___________
// / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
// / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
// /_____/\____/____/ |__/|__/\__,_/_/ /____/
//
// A futuristic real-time strategy game.
// This file is part of Bos Wars.
//
/**@name action_research.cpp - The research action. */
//
// (c) Copyright 1998-2005 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
// $Id$
//@{
/*----------------------------------------------------------------------------
-- Includes
----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include "stratagus.h"
#include "video.h"
#include "sound.h"
#include "unitsound.h"
#include "unittype.h"
#include "animation.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "upgrade_structs.h"
#include "upgrade.h"
#include "interface.h"
#include "ai.h"
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
/**
** Unit researches!
**
** @param unit Pointer of researching unit.
*/
void HandleActionResearch(CUnit *unit)
{
const CUpgrade *upgrade;
if (!unit->SubAction) { // first entry
upgrade = unit->Data.Research.Upgrade = unit->Orders[0]->Arg1.Upgrade;
#if 0
// FIXME: I want to support both, but with network we need this check
// but if want combined upgrades this is worse
//
// Check if an other building has already started?
//
if (unit->Player->UpgradeTimers.Upgrades[upgrade - Upgrades]) {
DebugPrint("Two researches running\n");
PlayerAddCosts(unit->Player, upgrade->Costs);
unit->Orders[0]->Action = UnitActionStill;
unit->SubAction = 0;
return;
}
#endif
unit->SubAction = 1;
} else {
upgrade = unit->Data.Research.Upgrade;
}
unit->Type->Animations->Research ?
UnitShowAnimation(unit, unit->Type->Animations->Research) :
UnitShowAnimation(unit, unit->Type->Animations->Still);
if (unit->Wait) {
unit->Wait--;
return;
}
unit->Player->UpgradeTimers.Upgrades[upgrade->ID] += SpeedResearch;
if (unit->Player->UpgradeTimers.Upgrades[upgrade->ID] >=
upgrade->Costs[TimeCost]) {
unit->Player->Notify(NotifyGreen, unit->X, unit->Y,
_("%s: complete"), unit->Type->Name.c_str());
if (unit->Player->AiEnabled) {
AiResearchComplete(unit, upgrade);
}
UpgradeAcquire(unit->Player, upgrade);
unit->Orders[0]->Action = UnitActionStill;
unit->SubAction = 0;
// Upgrade can change all
SelectedUnitChanged();
return;
}
unit->Wait = CYCLES_PER_SECOND / 6;
}
//@}

View file

@ -1,209 +0,0 @@
// ____ _ __
// / __ )____ _____ | | / /___ ___________
// / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
// / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
// /_____/\____/____/ |__/|__/\__,_/_/ /____/
//
// A futuristic real-time strategy game.
// This file is part of Bos Wars.
//
/**@name action_upgradeto.cpp - The unit upgrading to new action. */
//
// (c) Copyright 1998-2005 by Lutz Sammer and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; only version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
// $Id$
//@{
/*----------------------------------------------------------------------------
-- Includes
----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include "stratagus.h"
#include "player.h"
#include "unittype.h"
#include "animation.h"
#include "unit.h"
#include "actions.h"
#include "ai.h"
#include "interface.h"
#include "map.h"
#include "spells.h"
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
/**
** Transform an unit in another.
**
** @param unit unit to transform.
** @param newtype new type of the unit.
**
** @return 0 on error, 1 if nothing happens, 2 else.
*/
int TransformUnitIntoType(CUnit *unit, CUnitType *newtype)
{
CPlayer *player;
CUnitType *oldtype;
const CUnitStats *newstats;
int x;
int y;
int i;
CUnit *container;
Assert(unit);
Assert(newtype);
oldtype = unit->Type;
if (oldtype == newtype) { // nothing to do
return 1;
}
x = unit->X + (oldtype->TileWidth - newtype->TileWidth) / 2;
y = unit->Y + (oldtype->TileHeight - newtype->TileHeight) / 2;
container = unit->Container;
if (container) {
MapUnmarkUnitSight(unit);
} else {
SaveSelection();
unit->Remove(NULL);
if (!UnitTypeCanBeAt(newtype, x, y)) {
unit->Place(unit->X, unit->Y);
RestoreSelection();
// FIXME unit is not modified, try later ?
return 0;
}
}
player = unit->Player;
player->UnitTypesCount[oldtype->Slot]--;
player->UnitTypesCount[newtype->Slot]++;
player->Demand += newtype->Demand - oldtype->Demand;
player->Supply += newtype->Supply - oldtype->Supply;
// adjust Variables with percent.
newstats = &newtype->Stats[player->Index];
for (i = 0; i < UnitTypeVar.NumberVariable; ++i) {
if (unit->Variable[i].Max) {
unit->Variable[i].Value = newstats->Variables[i].Max *
unit->Variable[i].Value / unit->Variable[i].Max;
} else {
unit->Variable[i].Value = newstats->Variables[i].Value;
}
unit->Variable[i].Max = newstats->Variables[i].Max;
unit->Variable[i].Increase = newstats->Variables[i].Increase;
unit->Variable[i].Enable = newstats->Variables[i].Enable;
}
unit->Type = newtype;
unit->Stats = &newtype->Stats[player->Index];
if (newtype->CanCastSpell && !unit->AutoCastSpell) {
unit->AutoCastSpell = new char[SpellTypeTable.size()];
memset(unit->AutoCastSpell, 0, SpellTypeTable.size() * sizeof(char));
}
UpdateForNewUnit(unit, 1);
// Update Possible sight range change
UpdateUnitSightRange(unit);
if (!container) {
unit->Place(x, y);
RestoreSelection();
} else {
MapMarkUnitSight(unit);
}
//
// Update possible changed buttons.
//
if (IsOnlySelected(unit) || unit->Player == ThisPlayer) {
// could affect the buttons of any selected unit
SelectedUnitChanged();
}
return 1;
}
/**
** Unit transform into unit.
**
** @param unit Pointer to unit.
*/
void HandleActionTransformInto(CUnit *unit)
{
// What to do if an error occurs ?
TransformUnitIntoType(unit, unit->CriticalOrder.Type);
unit->CriticalOrder.Action = UnitActionStill;
}
/**
** Unit upgrades unit!
**
** @param unit Pointer to unit.
*/
void HandleActionUpgradeTo(CUnit *unit)
{
CPlayer *player;
CUnitType *newtype;
const CUnitStats *newstats;
Assert(unit);
if (!unit->SubAction) { // first entry
unit->Data.UpgradeTo.Ticks = 0;
unit->SubAction = 1;
}
unit->Type->Animations->Upgrade ?
UnitShowAnimation(unit, unit->Type->Animations->Upgrade) :
UnitShowAnimation(unit, unit->Type->Animations->Still);
if (unit->Wait) {
unit->Wait--;
return;
}
player = unit->Player;
newtype = unit->Orders[0]->Type;
newstats = &newtype->Stats[player->Index];
// FIXME: Should count down here
unit->Data.UpgradeTo.Ticks += SpeedUpgrade;
if (unit->Data.UpgradeTo.Ticks < newstats->Costs[TimeCost]) {
unit->Wait = CYCLES_PER_SECOND / 6;
return;
}
unit->Orders[0]->Action = UnitActionStill;
unit->SubAction = unit->State = 0;
if (TransformUnitIntoType(unit, newtype) == 0) {
player->Notify(NotifyGreen, unit->X, unit->Y,
_("Upgrade to %s canceled"), newtype->Name.c_str());
return ;
}
// Warn AI.
if (player->AiEnabled) {
AiUpgradeToComplete(unit, newtype);
}
player->Notify(NotifyGreen, unit->X, unit->Y,
_("Upgrade to %s complete"), unit->Type->Name.c_str());
}
//@}

View file

@ -278,8 +278,6 @@ static void (*HandleActionTable[256])(CUnit *) = {
HandleActionDie,
HandleActionSpellCast,
HandleActionTrain,
HandleActionUpgradeTo,
HandleActionResearch,
HandleActionBuilt,
HandleActionBoard,
HandleActionUnload,
@ -288,7 +286,6 @@ static void (*HandleActionTable[256])(CUnit *) = {
HandleActionRepair,
HandleActionResource,
HandleActionReturnGoods,
HandleActionTransformInto,
HandleActionNotWritten,
// Enough for the future ?

View file

@ -871,45 +871,6 @@ void CommandCancelTraining(CUnit *unit, int slot, const CUnitType *type)
}
}
/**
** Building starts upgrading to.
**
** @param unit pointer to unit.
** @param type upgrade to type
** @param flush if true, flush command queue.
*/
void CommandUpgradeTo(CUnit *unit, CUnitType *type, int flush)
{
COrder *order;
//
// Check if unit is still valid and Goal still alive? (NETWORK!)
//
if (!unit->Removed && unit->Orders[0]->Action != UnitActionDie) {
//
// Check if enough resources remains? (NETWORK!)
//
if (unit->Player->CheckUnitType(type)) {
return;
}
if (!flush) {
DebugPrint("FIXME: must support order queing!!");
}
if (!(order = GetNextOrder(unit, flush))) {
return;
}
order->Init();
// FIXME: if you give quick an other order, the resources are lost!
unit->Player->SubUnitType(type);
order->Action = UnitActionUpgradeTo;
order->Type = type;
}
ClearSavedAction(unit);
}
/**
** Immediate transforming unit into type.
**
@ -928,128 +889,6 @@ void CommandTransformIntoType(CUnit *unit, CUnitType *type)
order->Type = type;
}
/**
** Cancel building upgrading to.
**
** @param unit pointer to unit.
*/
void CommandCancelUpgradeTo(CUnit *unit)
{
ReleaseOrders(unit); // empty command queue
//
// Check if unit is still upgrading? (NETWORK!)
//
if (unit->Orders[0]->Action == UnitActionUpgradeTo) {
unit->Player->AddCostsFactor(
unit->Orders[0]->Type->Stats[unit->Player->Index].Costs,
CancelUpgradeCostsFactor);
unit->Orders[0]->Init();
unit->Orders[0]->Action = UnitActionStill;
unit->SubAction = 0;
//
// Update interface.
//
if (unit->Player == ThisPlayer && unit->Selected) {
SelectedUnitChanged();
}
}
ClearSavedAction(unit);
}
/**
** Building starts researching.
**
** @param unit pointer to unit.
** @param what what to research.
** @param flush if true, flush command queue.
*/
void CommandResearch(CUnit *unit, CUpgrade *what, int flush)
{
COrder *order;
//
// Check if unit is still valid and Goal still alive? (NETWORK!)
//
if (!unit->Removed && unit->Orders[0]->Action != UnitActionDie) {
//
// Check if enough resources remains? (NETWORK!)
//
if (unit->Player->CheckCosts(what->Costs)) {
return;
}
if (!flush) {
DebugPrint("FIXME: must support order queing!!");
} else {
if (unit->Orders[0]->Action == UnitActionResearch) {
const CUpgrade *upgrade;
// Cancel current research
upgrade = unit->Data.Research.Upgrade;
unit->Player->UpgradeTimers.Upgrades[upgrade->ID] = 0;
unit->Player->AddCostsFactor(upgrade->Costs,
CancelResearchCostsFactor);
unit->SubAction = 0;
}
}
if (!(order = GetNextOrder(unit, flush))) {
return;
}
order->Init();
// FIXME: if you give quick an other order, the resources are lost!
unit->Player->SubCosts(what->Costs);
order->Action = UnitActionResearch;
order->X = order->Y = -1;
order->Arg1.Upgrade = what;
}
ClearSavedAction(unit);
}
/**
** Cancel Building researching.
**
** @param unit Pointer to unit.
*/
void CommandCancelResearch(CUnit *unit)
{
ReleaseOrders(unit); // empty command queue
//
// Check if unit is still researching? (NETWORK!)
//
if (unit->Orders[0]->Action == UnitActionResearch) {
const CUpgrade *upgrade;
upgrade = unit->Data.Research.Upgrade;
unit->Player->UpgradeTimers.Upgrades[upgrade->ID] = 0;
unit->Player->AddCostsFactor(upgrade->Costs,
CancelResearchCostsFactor);
unit->Orders[0]->Init();
unit->Orders[0]->Action = UnitActionStill;
unit->SubAction = 0;
//
// Update interface.
//
if (unit->Player == ThisPlayer && unit->Selected) {
SelectedUnitChanged();
}
}
ClearSavedAction(unit);
}
/**
** Cast a spell at position or unit.
**

View file

@ -1,32 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/ai
MSRC = ai.cpp ai_building.cpp ai_force.cpp ai_magic.cpp ai_plan.cpp ai_resource.cpp \
script_ai.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))
HDRS += src/ai/ai_local.h

View file

@ -123,14 +123,6 @@
** ::AiTrainingComplete()
**
** Called if AI unit has completed training a new unit.
**
** ::AiUpgradeToComplete()
**
** Called if AI unit has completed upgrade to new unit-type.
**
** ::AiResearchComplete()
**
** Called if AI unit has completed research of an upgrade or spell.
*/
/*----------------------------------------------------------------------------
@ -282,42 +274,6 @@ static void AiCheckUnits(void)
counter[t] -= x;
}
}
//
// Look if some upgrade-to are missing.
//
n = AiPlayer->UpgradeToRequests.size();
for (i = 0; i < n; ++i) {
t = AiPlayer->UpgradeToRequests[i]->Slot;
x = 1;
//
// Add equivalent units
//
e = unit_types_count[t];
if (t < (int)AiHelpers.Equiv.size()) {
for (j = 0; j < (int)AiHelpers.Equiv[t].size(); ++j) {
e += unit_types_count[AiHelpers.Equiv[t][j]->Slot];
}
}
if (x > e + counter[t]) { // Request it.
AiAddUpgradeToRequest(AiPlayer->UpgradeToRequests[i]);
counter[t] += x - e - counter[t];
}
counter[t] -= x;
}
//
// Look if some researches are missing.
//
n = (int)AiPlayer->ResearchRequests.size();
for (i = 0; i < n; ++i) {
if (UpgradeIdAllowed(AiPlayer->Player,
AiPlayer->ResearchRequests[i]->ID) == 'A') {
AiAddResearchRequest(AiPlayer->ResearchRequests[i]);
}
}
}
/*----------------------------------------------------------------------------
@ -447,18 +403,6 @@ static void SaveAiPlayer(CFile *file, int plynr, PlayerAi *ai)
}
file->printf("},\n");
file->printf(" \"upgrade\", {");
for (i = 0; i < (int)ai->UpgradeToRequests.size(); ++i) {
file->printf("\"%s\", ", ai->UpgradeToRequests[i]->Ident.c_str());
}
file->printf("},\n");
file->printf(" \"research\", {");
for (i = 0; i < (int)ai->ResearchRequests.size(); ++i) {
file->printf("\"%s\", ", ai->ResearchRequests[i]->Ident.c_str());
}
file->printf("},\n");
//
// Building queue
//
@ -614,8 +558,6 @@ void FreeAi()
//
AiHelpers.Train.clear();
AiHelpers.Build.clear();
AiHelpers.Upgrade.clear();
AiHelpers.Research.clear();
AiHelpers.Repair.clear();
AiHelpers.UnitLimit.clear();
AiHelpers.Equiv.clear();
@ -1091,38 +1033,6 @@ void AiTrainingComplete(CUnit *unit, CUnit *what)
AiAssignToForce(what);
}
/**
** Called if upgrading of an unit is completed.
**
** @param unit Pointer to unit working.
** @param what Pointer to the new unit-type.
*/
void AiUpgradeToComplete(CUnit *unit, const CUnitType *what)
{
DebugPrint("%d: %d(%s) upgrade-to %s at %d,%d completed\n" _C_
unit->Player->Index _C_ UnitNumber(unit) _C_ unit->Type->Ident.c_str() _C_
what->Ident.c_str() _C_ unit->X _C_ unit->Y);
Assert(unit->Player->Type != PlayerPerson);
}
/**
** Called if reseaching of an unit is completed.
**
** @param unit Pointer to unit working.
** @param what Pointer to the new upgrade.
*/
void AiResearchComplete(CUnit *unit, const CUpgrade *what)
{
DebugPrint("%d: %d(%s) research %s at %d,%d completed\n" _C_
unit->Player->Index _C_ UnitNumber(unit) _C_ unit->Type->Ident.c_str() _C_
what->Ident.c_str() _C_ unit->X _C_ unit->Y);
Assert(unit->Player->Type != PlayerPerson);
// FIXME: upgrading knights -> paladins, must rebuild lists!
}
/**
** This is called for each player, each game cycle.
**

View file

@ -47,7 +47,6 @@
class CUnit;
class CUnitType;
class CUpgrade;
class CPlayer;
/**
@ -218,8 +217,6 @@ public:
std::vector<AiTransportRequest> TransportRequests;/// Requests for transport
unsigned long LastCanNotMoveGameCycle; /// Last can not move cycle
std::vector<AiRequestType> UnitTypeRequests; /// unit-types to build/train request,priority list
std::vector<CUnitType *> UpgradeToRequests; /// Upgrade to unit-type requested and priority list
std::vector<CUpgrade *> ResearchRequests; /// Upgrades requested and priority list
std::vector<AiBuildQueue> UnitTypeBuilt; /// What the resource manager should build
int LastRepairBuilding; /// Last building checked for repair in this turn
unsigned TriedRepairWorkers[UnitMax]; /// No. workers that failed trying to repair a building
@ -230,7 +227,7 @@ public:
**
** Contains informations needed for the AI. If the AI needs an unit or
** building or upgrade or spell, it could lookup in this tables to find
** where it could be trained, built or researched.
** where it could be trained or built.
*/
class AiHelper {
public:
@ -245,16 +242,6 @@ public:
*/
std::vector<std::vector<CUnitType *> > Build;
/**
** The index is the upgrade that should be made, giving a table of all
** units/buildings which could do the upgrade.
*/
std::vector<std::vector<CUnitType *> > Upgrade;
/**
** The index is the research that should be made, giving a table of all
** units/buildings which could research this upgrade.
*/
std::vector<std::vector<CUnitType *> > Research;
/**
** The index is the unit that should be repaired, giving a table of all
** units/buildings which could repair this unit.
*/
@ -290,10 +277,6 @@ extern PlayerAi *AiPlayer; /// Current AI player
//
/// Add unit-type request to resource manager
extern void AiAddUnitTypeRequest(CUnitType *type, int count);
/// Add upgrade-to request to resource manager
extern void AiAddUpgradeToRequest(CUnitType *type);
/// Add research request to resource manager
extern void AiAddResearchRequest(CUpgrade *upgrade);
/// Periodic called resource manager handler
extern void AiResourceManager(void);
/// Ask the ai to explore around x,y

View file

@ -520,192 +520,6 @@ static int AiMakeUnit(CUnitType *type)
return 0;
}
/**
** Check if we can research the upgrade.
**
** @param type Unit that can research the upgrade.
** @param what What should be researched.
**
** @return True if made, false if can't be made.
**
** @note We must check if the dependencies are fulfilled.
*/
static int AiResearchUpgrade(const CUnitType *type, CUpgrade *what)
{
CUnit *table[UnitMax];
CUnit *unit;
int nunits;
int i;
int num;
#ifdef DEBUG
unit = NoUnitP;
#endif
// Remove all units already doing something.
//
nunits = FindPlayerUnitsByType(AiPlayer->Player, type, table);
for (num = i = 0; i < nunits; ++i) {
unit = table[i];
if (unit->IsIdle()) {
table[num++] = unit;
}
}
for (i = 0; i < num; ++i) {
unit = table[i];
CommandResearch(unit, what, FlushCommands);
return 1;
}
return 0;
}
/**
** Check if the research can be done.
**
** @param upgrade Upgrade to research
*/
void AiAddResearchRequest(CUpgrade *upgrade)
{
int i;
int n;
const int *unit_count;
std::vector<std::vector<CUnitType *> > *tablep;
std::vector<CUnitType *> *table;
//
// Check if resources are available.
//
if ((i = AiCheckCosts(upgrade->Costs))) {
AiPlayer->NeededMask |= i;
return;
}
//
// Check if we have a place for the upgrade to research
//
n = AiHelpers.Research.size();
tablep = &AiHelpers.Research;
if (upgrade->ID > n) { // Oops not known.
DebugPrint("Nothing known about `%s'\n" _C_ upgrade->Ident.c_str());
return;
}
table = &(*tablep)[upgrade->ID];
if (!table->size()) { // Oops not known.
DebugPrint("Nothing known about `%s'\n" _C_ upgrade->Ident.c_str());
return;
}
unit_count = AiPlayer->Player->UnitTypesCount;
for (i = 0; i < (int)table->size(); ++i) {
//
// The type is available
//
if (unit_count[(*table)[i]->Slot]) {
if (AiResearchUpgrade((*table)[i], upgrade)) {
return;
}
}
}
return;
}
/**
** Check if we can upgrade to unit-type.
**
** @param type Unit that can upgrade to unit-type
** @param what To what should be upgraded.
**
** @return True if made, false if can't be made.
**
** @note We must check if the dependencies are fulfilled.
*/
static int AiUpgradeTo(const CUnitType *type, CUnitType *what)
{
CUnit *table[UnitMax];
CUnit *unit;
int nunits;
int i;
int num;
#ifdef DEBUG
unit = NoUnitP;
#endif
// Remove all units already doing something.
//
nunits = FindPlayerUnitsByType(AiPlayer->Player, type, table);
for (num = i = 0; i < nunits; ++i) {
unit = table[i];
if (unit->IsIdle()) {
table[num++] = unit;
}
}
for (i = 0; i < num; ++i) {
unit = table[i];
CommandUpgradeTo(unit, what, FlushCommands);
return 1;
}
return 0;
}
/**
** Check if the upgrade-to can be done.
**
** @param type FIXME: docu
*/
void AiAddUpgradeToRequest(CUnitType *type)
{
int i;
int n;
const int *unit_count;
std::vector<std::vector<CUnitType *> > *tablep;
std::vector<CUnitType *> *table;
//
// Check if resources are available.
//
if ((i = AiCheckUnitTypeCosts(type))) {
AiPlayer->NeededMask |= i;
return;
}
//
// Check if we have a place for the upgrade to.
//
n = AiHelpers.Upgrade.size();
tablep = &AiHelpers.Upgrade;
if (type->Slot > n) { // Oops not known.
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident.c_str());
return;
}
table = &(*tablep)[type->Slot];
if (!table->size()) { // Oops not known.
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident.c_str());
return;
}
unit_count = AiPlayer->Player->UnitTypesCount;
for (i = 0; i < (int)table->size(); ++i) {
//
// The type is available
//
if (unit_count[(*table)[i]->Slot]) {
if (AiUpgradeTo((*table)[i], type)) {
return;
}
}
}
return;
}
/**
** Check what must be built / trained.
*/
@ -1238,7 +1052,6 @@ static void AiCheckRepair(void)
// Don't repair attacked unit ( wait 5 sec before repairing )
if (unit->Type->RepairHP &&
unit->Orders[0]->Action != UnitActionBuilt &&
unit->Orders[0]->Action != UnitActionUpgradeTo &&
unit->Variable[HP_INDEX].Value < unit->Variable[HP_INDEX].Max &&
unit->Attacked + 5 * CYCLES_PER_SECOND < GameCycle) {

View file

@ -214,24 +214,6 @@ static void InitAiHelper(AiHelper &aiHelper)
}
break;
}
case ButtonUpgradeTo :
{
CUnitType *upgradeToType = UnitTypeByIdent(button.ValueStr);
for (std::vector<CUnitType *>::const_iterator j = unitmask.begin(); j != unitmask.end(); ++j) {
AiHelperInsert(aiHelper.Upgrade, upgradeToType->Slot, *j);
}
break;
}
case ButtonResearch :
{
int researchId = UpgradeIdByIdent(button.ValueStr);
for (std::vector<CUnitType *>::const_iterator j = unitmask.begin(); j != unitmask.end(); ++j) {
AiHelperInsert(aiHelper.Research, researchId, *j);
}
break;
}
default:
break;
}
@ -271,16 +253,12 @@ static int CclDefineAiHelper(lua_State *l)
++k;
//
// Type build,train,research/upgrade.
// Type build,train.
//
if (!strcmp(value, "build")) {
what = -1;
} else if (!strcmp(value, "train")) {
what = -1;
} else if (!strcmp(value, "upgrade")) {
what = -1;
} else if (!strcmp(value, "research")) {
what = -1;
} else if (!strcmp(value, "unit-limit")) {
what = -1;
} else if (!strcmp(value, "unit-equiv")) {
@ -428,45 +406,6 @@ static AiRequestType *FindInUnitTypeRequests(const CUnitType *type)
return NULL;
}
/**
** Find unit-type in upgrade-to table.
**
** @param type Unit-type to be found.
*/
static int FindInUpgradeToRequests(const CUnitType *type)
{
int i;
int n;
n = AiPlayer->UpgradeToRequests.size();
for (i = 0; i < n; ++i) {
if (AiPlayer->UpgradeToRequests[i] == type) {
return 1;
}
}
return 0;
}
/**
** Append unit-type to request table.
**
** @param type Unit-type to be appended.
*/
static void InsertUpgradeToRequests(CUnitType *type)
{
AiPlayer->UpgradeToRequests.push_back(type);
}
/**
** Append unit-type to request table.
**
** @param upgrade Upgrade to be appended.
*/
static void InsertResearchRequests(CUpgrade *upgrade)
{
AiPlayer->ResearchRequests.push_back(upgrade);
}
//----------------------------------------------------------------------------
/**
@ -631,13 +570,6 @@ static int CclAiWait(lua_State *l)
}
}
}
//
// Look if we have an upgrade-to request.
//
if (FindInUpgradeToRequests(type)) {
lua_pushboolean(l, 1);
return 1;
}
DebugPrint("Broken? waiting on %s which wasn't requested.\n" _C_ type->Ident.c_str());
lua_pushboolean(l, 0);
return 1;
@ -861,47 +793,6 @@ static int CclAiSleep(lua_State *l)
return 1;
}
/**
** Research an upgrade.
**
** @param l Lua state.
*/
static int CclAiResearch(lua_State *l)
{
const char *str;
CUpgrade *upgrade;
LuaCheckArgs(l, 1);
if ((str = LuaToString(l, 1))) {
upgrade = CUpgrade::Get(str);
} else {
LuaError(l, "Upgrade needed");
upgrade = 0;
}
InsertResearchRequests(upgrade);
lua_pushboolean(l, 0);
return 1;
}
/**
** Upgrade an unit to an new unit-type.
**
** @param l Lua state.
*/
static int CclAiUpgradeTo(lua_State *l)
{
CUnitType *type;
LuaCheckArgs(l, 1);
type = CclGetUnitType(l);
InsertUpgradeToRequests(type);
lua_pushboolean(l, 0);
return 1;
}
/**
** Return the player of the running AI.
**
@ -997,18 +888,6 @@ static int CclAiDump(lua_State *l)
printf("%s ", AiPlayer->UnitTypeRequests[i].Type->Ident.c_str());
}
printf("\n");
n = (int)AiPlayer->UpgradeToRequests.size();
printf("UpgradeToRequests(%d):\n", n);
for (i = 0; i < n; ++i) {
printf("%s ", AiPlayer->UpgradeToRequests[i]->Ident.c_str());
}
printf("\n");
n = (int)AiPlayer->ResearchRequests.size();
printf("ResearchRequests(%d):\n", n);
for (i = 0; i < n; ++i) {
printf("%s ", AiPlayer->ResearchRequests[i]->Ident.c_str());
}
printf("\n");
//
// Building queue
@ -1392,32 +1271,6 @@ static int CclDefineAiPlayer(lua_State *l)
ai->UnitTypeRequests[i].Count = count;
++i;
}
} else if (!strcmp(value, "upgrade")) {
if (!lua_istable(l, j + 1)) {
LuaError(l, "incorrect argument");
}
subargs = luaL_getn(l, j + 1);
for (k = 0; k < subargs; ++k) {
const char *ident;
lua_rawgeti(l, j + 1, k + 1);
ident = LuaToString(l, -1);
lua_pop(l, 1);
ai->UpgradeToRequests.push_back(UnitTypeByIdent(ident));
}
} else if (!strcmp(value, "research")) {
if (!lua_istable(l, j + 1)) {
LuaError(l, "incorrect argument");
}
subargs = luaL_getn(l, j + 1);
for (k = 0; k < subargs; ++k) {
const char *ident;
lua_rawgeti(l, j + 1, k + 1);
ident = LuaToString(l, -1);
lua_pop(l, 1);
ai->ResearchRequests.push_back(CUpgrade::Get(ident));
}
} else if (!strcmp(value, "building")) {
if (!lua_istable(l, j + 1)) {
LuaError(l, "incorrect argument");
@ -1501,8 +1354,6 @@ void AiCclRegister(void)
lua_register(Lua, "AiAttackWithForce", CclAiAttackWithForce);
lua_register(Lua, "AiSleep", CclAiSleep);
lua_register(Lua, "AiResearch", CclAiResearch);
lua_register(Lua, "AiUpgradeTo", CclAiUpgradeTo);
lua_register(Lua, "AiPlayer", CclAiPlayer);
lua_register(Lua, "AiSetReserve", CclAiSetReserve);

View file

@ -1,30 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/beos
MSRC = beos.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -1,30 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/editor
MSRC = script_editor.cpp editloop.cpp editor.cpp edmap.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -1,30 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/game
MSRC = game.cpp loadgame.cpp savegame.cpp trigger.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -663,11 +663,6 @@ void CreateGame(const std::string &filename, CMap *map)
DebugPlayers();
PlayersInitAi();
//
// Upgrades
//
InitUpgrades();
//
// Dependencies
//

View file

@ -94,7 +94,6 @@ void CleanModules(void)
CleanUnits();
CleanSelections();
CleanGroups();
CleanUpgrades();
CleanDependencies();
CleanButtons();
CleanMissileTypes();
@ -137,7 +136,6 @@ void InitModules(void)
InitSelections();
InitGroups();
InitSpells();
InitUpgrades();
InitDependencies();
InitButtons();

View file

@ -284,7 +284,6 @@ void SaveGame(const std::string &filename)
SaveCcl(&file);
SaveUnitTypes(&file);
SaveUpgrades(&file);
SavePlayers(&file);
Map.Save(&file);
SaveUnits(&file);

View file

@ -1,111 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004-2006 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/guichan
MSRC = \
cliprectangle.cpp \
color.cpp \
defaultfont.cpp \
exception.cpp \
focushandler.cpp \
gfont.cpp \
graphics.cpp \
gui.cpp \
guichan.cpp \
image.cpp \
imagefont.cpp \
key.cpp \
keyinput.cpp \
mouseinput.cpp \
rectangle.cpp \
sdl/gsdl.cpp \
sdl/sdlgraphics.cpp \
sdl/sdlimageloader.cpp \
sdl/sdlinput.cpp \
widget.cpp \
widgets/button.cpp \
widgets/checkbox.cpp \
widgets/container.cpp \
widgets/dropdown.cpp \
widgets/icon.cpp \
widgets/label.cpp \
widgets/listbox.cpp \
widgets/radiobutton.cpp \
widgets/scrollarea.cpp \
widgets/slider.cpp \
widgets/textbox.cpp \
widgets/textfield.cpp \
widgets/window.cpp \
SRC += $(addprefix $(MODULE)/,$(MSRC))
MHDRS = \
include/guichan/actionlistener.h \
include/guichan/allegro.h \
include/guichan/basiccontainer.h \
include/guichan/cliprectangle.h \
include/guichan/color.h \
include/guichan/defaultfont.h \
include/guichan/exception.h \
include/guichan/focushandler.h \
include/guichan/font.h \
include/guichan/graphics.h \
include/guichan/gsdl.h \
include/guichan/gui.h \
include/guichan/image.h \
include/guichan/imagefont.h \
include/guichan/imageloader.h \
include/guichan/input.h \
include/guichan/key.h \
include/guichan/keyinput.h \
include/guichan/keylistener.h \
include/guichan/listmodel.h \
include/guichan/mouseinput.h \
include/guichan/mouselistener.h \
include/guichan/platform.h \
include/guichan/rectangle.h \
include/guichan/sdl/sdlgraphics.h \
include/guichan/sdl/sdlimageloader.h \
include/guichan/sdl/sdlinput.h \
include/guichan/sdl/sdlpixel.h \
include/guichan/widget.h \
include/guichan/widgets/button.h \
include/guichan/widgets/checkbox.h \
include/guichan/widgets/container.h \
include/guichan/widgets/dropdown.h \
include/guichan/widgets/icon.h \
include/guichan/widgets/label.h \
include/guichan/widgets/listbox.h \
include/guichan/widgets/radiobutton.h \
include/guichan/widgets/scrollarea.h \
include/guichan/widgets/slider.h \
include/guichan/widgets/textbox.h \
include/guichan/widgets/textfield.h \
include/guichan/widgets/window.h \
include/guichan/x.h \
include/guichan.h
HDRS += $(addprefix $(MODULE)/,$(MHDRS))

View file

@ -1,36 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004-2005 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/include
MHDRS = actions.h ai.h animation.h commands.h construct.h cursor.h depend.h \
editor.h font.h stratagus.h icons.h interface.h iocompat.h iolib.h \
map.h menus.h minimap.h missile.h movie.h myendian.h \
net_lowlevel.h netconnect.h network.h pathfinder.h player.h \
results.h script.h script_sound.h settings.h sound.h sound_server.h \
spells.h tileset.h translate.h trigger.h ui.h unit.h unitsound.h \
unittype.h upgrade.h upgrade_structs.h util.h video.h wav.h widgets.h
HDRS += $(addprefix $(MODULE)/,$(MHDRS))

View file

@ -45,7 +45,6 @@ enum _diplomacy_ {
class CUnit;
class CUnitType;
class CUpgrade;
class SpellType;
class COrder;
class CAnimation;
@ -114,17 +113,8 @@ extern void CommandTrainUnit(CUnit *unit, CUnitType *what,
/// Prepare command cancel training
extern void CommandCancelTraining(CUnit *unit, int slot,
const CUnitType *type);
/// Prepare command upgrade to
extern void CommandUpgradeTo(CUnit *unit, CUnitType *what,
int flush);
/// immediate transforming into type.
extern void CommandTransformIntoType(CUnit *unit, CUnitType *type);
/// Prepare command cancel upgrade to
extern void CommandCancelUpgradeTo(CUnit *unit);
/// Prepare command research
extern void CommandResearch(CUnit *unit, CUpgrade *what, int flush);
/// Prepare command cancel research
extern void CommandCancelResearch(CUnit *unit);
/// Prepare command spellcast
extern void CommandSpellCast(CUnit *unit, int x, int y,
CUnit *dest, SpellType *spell, int flush);
@ -179,14 +169,6 @@ extern void HandleActionBuild(CUnit *unit);
extern void HandleActionBuilt(CUnit *unit);
/// Handle command train
extern void HandleActionTrain(CUnit *unit);
/// Handle command upgrade to
extern void HandleActionUpgradeTo(CUnit *unit);
/// Handle command transform into
extern void HandleActionTransformInto(CUnit *unit);
/// Handle command upgrade
extern void HandleActionUpgrade(CUnit *unit);
/// Handle command research
extern void HandleActionResearch(CUnit *unit);
/// Handle command spellcast
extern void HandleActionSpellCast(CUnit *unit);

View file

@ -40,7 +40,6 @@ class CPlayer;
class CFile;
class CUnit;
class CUnitType;
class CUpgrade;
/*----------------------------------------------------------------------------
-- Variables
@ -86,11 +85,6 @@ extern void AiCanNotReach(CUnit *unit,
extern void AiCanNotMove(CUnit *unit);
/// Called if AI unit has completed training
extern void AiTrainingComplete(CUnit *unit, CUnit *what);
/// Called if AI unit has completed upgrade to
extern void AiUpgradeToComplete(CUnit *unit,
const CUnitType *what);
/// Called if AI unit has completed research
extern void AiResearchComplete(CUnit *unit, const CUpgrade *what);
//@}

View file

@ -105,8 +105,7 @@ public:
class CAnimations {
public:
CAnimations() : Start(NULL), Still(NULL), Death(NULL), Attack(NULL),
Move(NULL), Repair(NULL), Train(NULL), Research(NULL),
Upgrade(NULL), Build(NULL)
Move(NULL), Repair(NULL), Train(NULL), Build(NULL)
{
memset(Harvest, 0, sizeof(Harvest));
}
@ -118,8 +117,6 @@ public:
CAnimation *Move;
CAnimation *Repair;
CAnimation *Train;
CAnimation *Research;
CAnimation *Upgrade;
CAnimation *Build;
CAnimation *Harvest[MaxCosts];
};

View file

@ -46,7 +46,6 @@ enum ReplayType {
class CFile;
class CUnitType;
class CUpgrade;
/*----------------------------------------------------------------------------
-- Variables
@ -126,15 +125,6 @@ extern void SendCommandTrainUnit(CUnit *unit,
/// Send cancel training command
extern void SendCommandCancelTraining(CUnit *unit, int slot,
const CUnitType *type);
/// Send upgrade to command
extern void SendCommandUpgradeTo(CUnit *unit,
CUnitType *what, int flush);
/// Send cancel upgrade to command
extern void SendCommandCancelUpgradeTo(CUnit *unit);
/// Send research command
extern void SendCommandResearch(CUnit *unit, CUpgrade *what, int flush);
/// Send cancel research command
extern void SendCommandCancelResearch(CUnit *unit);
/// Send spell cast command
extern void SendCommandSpellCast(CUnit *unit, int x, int y,
CUnit *dest, int spellid, int flush);

View file

@ -7,7 +7,7 @@
// A futuristic real-time strategy game.
// This file is part of Bos Wars.
//
/**@name depend.h - The units/upgrade dependencies headerfile. */
/**@name depend.h - The units dependencies headerfile. */
//
// (c) Copyright 2000-2004 by Vladi Belperchinov-Shabanski
//
@ -43,9 +43,9 @@
**
** typedef struct _depend_rule_ DependRule;
**
** This structure is used define the requirements of upgrades or
** This structure is used define the requirements of
** unit-types. The structure is used to define the base (the wanted)
** upgrade or unit-type and the requirements upgrades or unit-types.
** unit-type and the requirements unit-types.
** The requirements could be combination of and-rules and or-rules.
**
** This structure is very complex because nearly everything has two
@ -55,7 +55,7 @@
**
** DependRule::Next
**
** Next rule in hash chain for the base upgrade/unit-type.
** Next rule in hash chain for the base unit-type.
** Next and-rule for the requirements.
**
** DependRule::Count
@ -79,13 +79,9 @@
**
** An unit-type pointer.
**
** DependRule::Kind::Upgrade
**
** An upgrade pointer.
**
** DependRule::Rule
**
** For the base upgrade/unit-type the rules which must be meet.
** For the base unit-type the rules which must be met.
** For the requirements alternative or-rules.
**
*/
@ -96,11 +92,9 @@
class CPlayer;
class CUnitType;
class CUpgrade;
enum {
DependRuleUnitType, /// Kind is an unit-type
DependRuleUpgrade, /// Kind is an upgrade
};
/// Dependency rule
@ -108,10 +102,9 @@ class DependRule {
public:
DependRule *Next; /// next hash chain, or rules
unsigned char Count; /// how many required
char Type; /// an unit-type or upgrade
char Type; /// a unit-type
union {
CUnitType *UnitType; /// unit-type pointer
CUpgrade *Upgrade; /// upgrade pointer
} Kind; /// required object
DependRule *Rule; /// requirements, and rule
};

View file

@ -65,10 +65,7 @@ enum ButtonCmd {
ButtonTrain, /// order train
ButtonStandGround, /// order stand ground
ButtonReturn, /// order return goods
ButtonResearch, /// order reseach
ButtonUpgradeTo, /// order upgrade
ButtonCancel, /// cancel
ButtonCancelUpgrade, /// cancel upgrade
ButtonCancelTrain, /// cancel training
ButtonCancelBuild, /// cancel building
};
@ -100,8 +97,6 @@ public:
enum _button_area_ {
ButtonAreaSelected, /// Selected button
ButtonAreaTraining, /// Training button
ButtonAreaUpgrading, /// Upgrading button
ButtonAreaResearching, /// Researching button
ButtonAreaTransporting, /// Transporting button
ButtonAreaButton, /// Button panel button
ButtonAreaMenu, /// Menu button
@ -369,9 +364,6 @@ extern bool ButtonCheckTrue(const CUnit *unit,
const ButtonAction *button);
/// Check is always false
extern bool ButtonCheckFalse(const CUnit *unit,
const ButtonAction *button);
/// Check if allowed upgrade is ready
extern bool ButtonCheckUpgrade(const CUnit *unit,
const ButtonAction *button);
/// Check if allowed units exists
extern bool ButtonCheckUnitsOr(const CUnit *unit,
@ -385,24 +377,12 @@ extern bool ButtonCheckNetwork(const CUnit *unit,
/// Check if don't have network play
extern bool ButtonCheckNoNetwork(const CUnit *unit,
const ButtonAction *button);
/// Check if unit isn't working (train,upgrade,research)
/// Check if unit isn't working (train)
extern bool ButtonCheckNoWork(const CUnit *unit,
const ButtonAction *button);
/// Check if unit isn't researching or upgrading
extern bool ButtonCheckNoResearch(const CUnit *unit,
const ButtonAction *button);
/// Check if all requirements for an attack to are meet
extern bool ButtonCheckAttack(const CUnit *unit,
const ButtonAction *button);
/// Check if all requirements for an upgrade to are meet
extern bool ButtonCheckUpgradeTo(const CUnit *unit,
const ButtonAction *button);
/// Check if all requirements for a research are meet
extern bool ButtonCheckResearch(const CUnit *unit,
const ButtonAction *button);
/// Check if all requirements for a single research are meet
extern bool ButtonCheckSingleResearch(const CUnit *unit,
const ButtonAction *button);
//
// in ccl_ui.c

View file

@ -41,7 +41,7 @@
/// Network protocol minor version (maximal 99)
#define NetworkProtocolMinorVersion 9
/// Network protocol patch level (maximal 99)
#define NetworkProtocolPatchLevel 5
#define NetworkProtocolPatchLevel 6
/// Network protocol version (1,2,3) -> 10203
#define NetworkProtocolVersion \
(NetworkProtocolMajorVersion * 10000 + NetworkProtocolMinorVersion * 100 + \

View file

@ -93,10 +93,6 @@ enum _message_type_ {
MessageCommandReturn, /// Unit command return goods
MessageCommandTrain, /// Unit command train
MessageCommandCancelTrain, /// Unit command cancel training
MessageCommandUpgrade, /// Unit command upgrade
MessageCommandCancelUpgrade, /// Unit command cancel upgrade
MessageCommandResearch, /// Unit command research
MessageCommandCancelResearch, /// Unit command cancel research
MessageExtendedCommand, /// Command is the next byte

View file

@ -246,7 +246,7 @@
**
** CPlayer::Allow
**
** Contains which unit-types and upgrades are allowed for the
** Contains which unit-types are allowed for the
** player. Possible values are:
** @li `A' -- allowed,
** @li `F' -- forbidden,
@ -254,14 +254,6 @@
** @li `Q' -- acquired but forbidden (does it make sense?:))
** @li `E' -- enabled, allowed by level but currently forbidden
** @see CAllow
**
** CPlayer::UpgradeTimers
**
** Timer for the upgrades. One timer for all possible upgrades.
** Initial 0 counted up by the upgrade action, until it reaches
** the upgrade time.
** @see _upgrade_timers_
** @note it is planned to combine research for faster upgrades.
*/
/*----------------------------------------------------------------------------
@ -336,9 +328,8 @@ public:
CUnitColors UnitColors; /// Unit colors for new units
// Upgrades/Allows:
CAllow Allow; /// Allowed for player
CUpgradeTimers UpgradeTimers; /// Timer for the upgrades
// Allows:
CAllow Allow; /// Allowed for player
/// Change player name

View file

@ -209,7 +209,6 @@ extern char NameLine[];
#define PlayerMax 8 /// How many players are supported
#define UnitTypeMax 257 /// How many unit types supported
#define UpgradeMax 8 /// How many upgrades supported
#define UnitMax 2048 /// How many units supported
/*----------------------------------------------------------------------------
@ -278,8 +277,6 @@ extern std::string StratagusLibPath; /// Location of stratagus data
extern int SpeedBuild; /// Speed factor for building
extern int SpeedTrain; /// Speed factor for training
extern int SpeedUpgrade; /// Speed factor for upgrading
extern int SpeedResearch; /// Speed factor for researching
extern bool UseHPForXp; /// true if gain XP by dealing damage, false if by killing.
@ -315,10 +312,6 @@ extern void ShowLoadProgress(const char *fmt, ...);
#define CancelBuildingCostsFactor 75
/// How many resources the player gets back if canceling training
#define CancelTrainingCostsFactor 100
/// How many resources the player gets back if canceling research
#define CancelResearchCostsFactor 100
/// How many resources the player gets back if canceling upgrade
#define CancelUpgradeCostsFactor 100
extern std::string CompileOptions;
//@}

View file

@ -562,10 +562,6 @@ public:
int TrainingTextX; /// Multiple Training X Text position
int TrainingTextY; /// Multiple Training Y Text position
CUIButton *UpgradingButton; /// Button info for upgrade
CUIButton *ResearchingButton; /// Button info for researching
std::vector<CUIButton> TransportingButtons;/// Button info for transporting
// Completed bar

View file

@ -363,7 +363,6 @@ class SpellType;
class CUnitColors;
class CConstructionFrame;
class CVariable;
class CUpgrade;
class CBuildRestrictionOnTop;
class CFile;
struct lua_State;
@ -396,8 +395,6 @@ typedef enum _unit_action_ {
UnitActionSpellCast, /// unit casts spell
UnitActionTrain, /// building is training
UnitActionUpgradeTo, /// building is upgrading itself
UnitActionResearch, /// building is researching spell
UnitActionBuilt, /// building is under construction
// Compound actions
@ -453,7 +450,6 @@ public:
} Patrol; /// position.
int ResourcePos; /// ResourcePos == (X<<16 | Y).
SpellType *Spell; /// spell when casting.
CUpgrade *Upgrade; /// upgrade.
} Arg1; /// Extra command argument.
};
@ -682,12 +678,6 @@ public:
struct _order_repair_ {
int Cycles; /// Cycles unit has been repairing for
} Repair; /// Repairing unit
struct _order_research_ {
CUpgrade *Upgrade; /// Upgrade researched
} Research; /// Research action
struct _order_upgradeto_ {
int Ticks; /// Ticks to complete
} UpgradeTo; /// Upgrade to action
struct _order_train_ {
int Ticks; /// Ticks to complete
} Train; /// Train units action

View file

@ -590,9 +590,7 @@ enum {
BUILD_INDEX,
MANA_INDEX,
TRANSPORT_INDEX,
RESEARCH_INDEX,
TRAINING_INDEX,
UPGRADINGTO_INDEX,
GIVERESOURCE_INDEX,
CARRYRESOURCE_INDEX,
XP_INDEX,

View file

@ -9,7 +9,7 @@
//
/**@name upgrade.h - The upgrades headerfile. */
//
// (c) Copyright 1999-2006 by Vladi Belperchinov-Shabanski and Jimmy Salmon
// (c) Copyright 1999-2007 by Vladi Belperchinov-Shabanski and Jimmy Salmon
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -38,48 +38,18 @@
class CFile;
class CPlayer;
class CUpgrade;
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
/// init upgrade/allow structures
extern void InitUpgrades(void);
/// save the upgrades
extern void SaveUpgrades(CFile *file);
/// cleanup upgrade module
extern void CleanUpgrades(void);
/// Register CCL features for upgrades
extern void UpgradesCclRegister(void);
/*----------------------------------------------------------------------------
-- General/Map functions
----------------------------------------------------------------------------*/
// AllowStruct and UpgradeTimers will be static in the player so will be
/// Register CCL features for upgrades
extern void UpgradesCclRegister(void);
// AllowStruct will be static in the player so will be
// load/saved with the player struct
extern int UnitTypeIdByIdent(const std::string &sid);
extern int UpgradeIdByIdent(const std::string &sid);
/*----------------------------------------------------------------------------
-- Upgrades
----------------------------------------------------------------------------*/
/// Upgrade will be acquired
extern void UpgradeAcquire(CPlayer *player, const CUpgrade *upgrade);
/// for now it will be empty?
/// perhaps acquired upgrade can be lost if (for example) a building is lost
/// (lumber mill? stronghold?)
/// this function will apply all modifiers in reverse way
extern void UpgradeLost(CPlayer *player, int id);
/*----------------------------------------------------------------------------
-- Allow(s)
@ -90,12 +60,6 @@ extern void UpgradeLost(CPlayer *player, int id);
extern int UnitIdAllowed(const CPlayer *player, int id);
extern char UpgradeIdAllowed(const CPlayer *player, int id);
extern char UpgradeIdentAllowed(const CPlayer *player, const std::string &ident);
/// Check if the upgrade is researched.
extern int UpgradeIdentAvailable(const CPlayer *player, const std::string &ident);
//@}
#endif // !__UPGRADE_H__

View file

@ -136,60 +136,10 @@ public:
int Costs[MaxCosts]; /// current costs of the unit
};
/**
** The main useable upgrades.
*/
class CUpgrade {
public:
CUpgrade(const std::string &ident);
~CUpgrade();
static CUpgrade *New(const std::string &ident);
static CUpgrade *Get(const std::string &ident);
void SetIcon(CIcon *icon);
std::string Ident; /// identifier
int ID; /// numerical id
int Costs[MaxCosts]; /// costs for the upgrade
// TODO: not used by buttons
CIcon *Icon; /// icon to display to the user
};
/*----------------------------------------------------------------------------
-- upgrades and modifiers
----------------------------------------------------------------------------*/
/**
** This is the modifier of an upgrade.
** This do the real action of an upgrade, an upgrade can have multiple
** modifiers.
*/
class CUpgradeModifier {
public:
CUpgradeModifier() : UpgradeId(0), ConvertTo(NULL)
{
memset(ChangeUnits, 0, sizeof(ChangeUnits));
memset(ChangeUpgrades, 0, sizeof(ChangeUpgrades));
memset(ApplyTo, 0, sizeof(ApplyTo));
}
int UpgradeId; /// used to filter required modifier
CUnitStats Modifier; /// modifier of unit stats.
// allow/forbid bitmaps -- used as chars for example:
// `?' -- leave as is, `F' -- forbid, `A' -- allow
// TODO: see below allow more semantics?
// TODO: pointers or ids would be faster and less memory use
int ChangeUnits[UnitTypeMax]; /// add/remove allowed units
char ChangeUpgrades[UpgradeMax]; /// allow/forbid upgrades
char ApplyTo[UnitTypeMax]; /// which unit types are affected
CUnitType *ConvertTo; /// convert to this unit-type.
};
/**
** Allow what a player can do. Every #CPlayer has an own allow struct.
**
@ -207,48 +157,13 @@ class CAllow {
public:
CAllow() { this->Clear(); }
void RevertUpgrades() {
for (int i = 0; i < UpgradeMax; i++) {
if (Upgrades[i] == 'R') {
Upgrades[i] = 'A';
}
}
}
void Clear() {
memset(Units, 0, sizeof(Units));
memset(Upgrades, 0, sizeof(Upgrades));
}
int Units[UnitTypeMax]; /// maximum amount of units allowed
char Upgrades[UpgradeMax]; /// upgrades allowed/disallowed
int Units[UnitTypeMax]; /// maximum amount of units allowed
};
/**
** Upgrade timer used in the player structure.
** Every player has an own UpgradeTimers struct.
*/
class CUpgradeTimers {
public:
CUpgradeTimers() { this->Clear(); }
void Clear() {
memset(Upgrades, 0, sizeof(Upgrades));
}
/**
** all 0 at the beginning, all upgrade actions do increment values in
** this struct.
*/
int Upgrades[UpgradeMax]; /// counter for each upgrade
};
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
extern std::vector<CUpgrade *> AllUpgrades; /// the main user usable upgrades
//@}
#endif // !__UPGRADE_STRUCTS_H__

View file

@ -1,31 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/map
MSRC = script_map.cpp script_tileset.cpp map.cpp map_draw.cpp map_fog.cpp \
map_radar.cpp map_save.cpp minimap.cpp tileset.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -1,30 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/network
MSRC = commands.cpp lowlevel.cpp netconnect.cpp network.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -845,14 +845,6 @@ static void DoNextReplay(void)
SendCommandTrainUnit(UnitSlots[unit], UnitTypeByIdent(val), flags);
} else if (!strcmp(action, "cancel-train")) {
SendCommandCancelTraining(UnitSlots[unit], num, (val && *val) ? UnitTypeByIdent(val) : NULL);
} else if (!strcmp(action, "upgrade-to")) {
SendCommandUpgradeTo(UnitSlots[unit], UnitTypeByIdent(val), flags);
} else if (!strcmp(action, "cancel-upgrade-to")) {
SendCommandCancelUpgradeTo(UnitSlots[unit]);
} else if (!strcmp(action, "research")) {
SendCommandResearch(UnitSlots[unit], CUpgrade::Get(val), flags);
} else if (!strcmp(action, "cancel-research")) {
SendCommandCancelResearch(UnitSlots[unit]);
} else if (!strcmp(action, "spell-cast")) {
SendCommandSpellCast(UnitSlots[unit], posx, posy, dunit, num, flags);
} else if (!strcmp(action, "auto-spell-cast")) {
@ -1264,74 +1256,6 @@ void SendCommandCancelTraining(CUnit *unit, int slot, const CUnitType *type)
}
}
/**
** Send command: Building starts upgrading to.
**
** @param unit pointer to unit.
** @param what pointer to unit-type of the unit upgrade.
** @param flush Flag flush all pending commands.
*/
void SendCommandUpgradeTo(CUnit *unit, CUnitType *what, int flush)
{
if (!IsNetworkGame()) {
CommandLog("upgrade-to", unit, flush, -1, -1, NoUnitP, what->Ident.c_str(), -1);
CommandUpgradeTo(unit, what, flush);
} else {
NetworkSendCommand(MessageCommandUpgrade, unit, 0, 0, NoUnitP, what, flush);
}
}
/**
** Send command: Cancel building upgrading to.
**
** @param unit Pointer to unit.
*/
void SendCommandCancelUpgradeTo(CUnit *unit)
{
if (!IsNetworkGame()) {
CommandLog("cancel-upgrade-to", unit, FlushCommands,
-1, -1, NoUnitP, NULL, -1);
CommandCancelUpgradeTo(unit);
} else {
NetworkSendCommand(MessageCommandCancelUpgrade, unit,
0, 0, NoUnitP, NULL, FlushCommands);
}
}
/**
** Send command: Building/unit research.
**
** @param unit pointer to unit.
** @param what research-type of the research.
** @param flush Flag flush all pending commands.
*/
void SendCommandResearch(CUnit *unit, CUpgrade *what, int flush)
{
if (!IsNetworkGame()) {
CommandLog("research", unit, flush, -1, -1, NoUnitP, what->Ident.c_str(), -1);
CommandResearch(unit, what, flush);
} else {
NetworkSendCommand(MessageCommandResearch, unit,
what->ID, 0, NoUnitP, NULL, flush);
}
}
/**
** Send command: Cancel Building/unit research.
**
** @param unit pointer to unit.
*/
void SendCommandCancelResearch(CUnit *unit)
{
if (!IsNetworkGame()) {
CommandLog("cancel-research", unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
CommandCancelResearch(unit);
} else {
NetworkSendCommand(MessageCommandCancelResearch, unit,
0, 0, NoUnitP, NULL, FlushCommands);
}
}
/**
** Send command: Unit spell cast on position/unit.
**
@ -1604,26 +1528,6 @@ void ParseCommand(unsigned char msgnr, UnitRef unum,
CommandCancelTraining(unit, (short)x, NULL);
}
break;
case MessageCommandUpgrade:
CommandLog("upgrade-to", unit, status, -1, -1, NoUnitP,
UnitTypes[dstnr]->Ident.c_str(), -1);
CommandUpgradeTo(unit, UnitTypes[dstnr], status);
break;
case MessageCommandCancelUpgrade:
CommandLog("cancel-upgrade-to", unit, FlushCommands, -1, -1, NoUnitP,
NULL, -1);
CommandCancelUpgradeTo(unit);
break;
case MessageCommandResearch:
CommandLog("research", unit, status, -1, -1, NoUnitP,
AllUpgrades[x]->Ident.c_str(), -1);
CommandResearch(unit, AllUpgrades[x], status);
break;
case MessageCommandCancelResearch:
CommandLog("cancel-research", unit, FlushCommands, -1, -1, NoUnitP,
NULL, -1);
CommandCancelResearch(unit);
break;
default:
id = (msgnr&0x7f) - MessageCommandSpellCast;
if (y != (unsigned short)0xFFFF) {

View file

@ -1,30 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/pathfinder
MSRC = astar.cpp script_pathfinder.cpp pathfinder.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -1,31 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/sound
MSRC = script_sound.cpp music.cpp ogg.cpp sound.cpp sound_id.cpp \
sound_server.cpp unitsound.cpp wav.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -106,8 +106,6 @@ static void MapAnimSounds(CUnitType *type)
MapAnimSounds2(type->Animations->Move);
MapAnimSounds2(type->Animations->Repair);
MapAnimSounds2(type->Animations->Train);
MapAnimSounds2(type->Animations->Research);
MapAnimSounds2(type->Animations->Upgrade);
MapAnimSounds2(type->Animations->Build);
for (i = 0; i < MaxCosts; ++i) {
MapAnimSounds2(type->Animations->Harvest[i]);

View file

@ -401,28 +401,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="action\action_research.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="action\action_resource.cpp"
>
@ -577,28 +555,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="action\action_upgradeto.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="action\actions.cpp"
>

View file

@ -1,33 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/stratagus
MSRC = construct.cpp groups.cpp iolib.cpp mainloop.cpp missile.cpp \
player.cpp script.cpp script_missile.cpp script_player.cpp \
script_spell.cpp selection.cpp spells.cpp stratagus.cpp translate.cpp \
util.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -251,13 +251,6 @@ void SavePlayers(CFile *file)
// Allow saved by allow.
file->printf("\n \"timers\", {");
for (j = 0; j < UpgradeMax; ++j) {
if (j) {
file->printf(" ");
}
file->printf("%d,", Players[i].UpgradeTimers.Upgrades[j]);
}
file->printf("})\n\n");
}
@ -481,12 +474,6 @@ void CPlayer::Clear()
TotalRazings = 0;
TotalKills = 0;
Color = 0;
// Allow has already been initialised by DefineAllow and DefineUnitAllow.
// Thus we cannot simply clear it.
// But we have to revert upgrades that could have happened during a
// the previous game.
Allow.RevertUpgrades();
UpgradeTimers.Clear();
}
/*----------------------------------------------------------------------------

View file

@ -2160,34 +2160,6 @@ static int CclSetSpeedTrain(lua_State *l)
return 1;
}
/**
** For debug increase upgrading speed.
**
** @param l Lua state.
*/
static int CclSetSpeedUpgrade(lua_State *l)
{
LuaCheckArgs(l, 1);
SpeedUpgrade = LuaToNumber(l, 1);
lua_pushnumber(l, SpeedUpgrade);
return 1;
}
/**
** For debug increase researching speed.
**
** @param l Lua state.
*/
static int CclSetSpeedResearch(lua_State *l)
{
LuaCheckArgs(l, 1);
SpeedResearch = LuaToNumber(l, 1);
lua_pushnumber(l, SpeedResearch);
return 1;
}
/**
** For debug increase all speeds.
**
@ -2204,7 +2176,7 @@ static int CclSetSpeeds(lua_State *l)
SpeedResourcesHarvest[i] = s;
SpeedResourcesReturn[i] = s;
}
SpeedBuild = SpeedTrain = SpeedUpgrade = SpeedResearch = s;
SpeedBuild = SpeedTrain = s;
lua_pushnumber(l, s);
return 1;
@ -2422,8 +2394,6 @@ void InitCcl(void)
lua_register(Lua, "SetSpeedResourcesReturn", CclSetSpeedResourcesReturn);
lua_register(Lua, "SetSpeedBuild", CclSetSpeedBuild);
lua_register(Lua, "SetSpeedTrain", CclSetSpeedTrain);
lua_register(Lua, "SetSpeedUpgrade", CclSetSpeedUpgrade);
lua_register(Lua, "SetSpeedResearch", CclSetSpeedResearch);
lua_register(Lua, "SetSpeeds", CclSetSpeeds);
lua_register(Lua, "SetUseHPForXp", ScriptSetUseHPForXp);
lua_register(Lua, "SetDamageFormula", CclSetDamageFormula);
@ -2553,11 +2523,9 @@ void LoadCcl(void)
*/
void SaveCcl(CFile *file)
{
int i;
file->printf("SetGodMode(%s)\n", GodMode ? "true" : "false");
for (i = 0; i < MaxCosts; ++i) {
for (int i = 0; i < MaxCosts; ++i) {
file->printf("SetSpeedResourcesHarvest(\"%s\", %d)\n",
DefaultResourceNames[i], SpeedResourcesHarvest[i]);
file->printf("SetSpeedResourcesReturn(\"%s\", %d)\n",
@ -2565,8 +2533,6 @@ void SaveCcl(CFile *file)
}
file->printf("SetSpeedBuild(%d)\n", SpeedBuild);
file->printf("SetSpeedTrain(%d)\n", SpeedTrain);
file->printf("SetSpeedUpgrade(%d)\n", SpeedUpgrade);
file->printf("SetSpeedResearch(%d)\n", SpeedResearch);
}
//@}

View file

@ -311,19 +311,6 @@ static int CclPlayer(lua_State *l)
b = LuaToNumber(l, -1);
lua_pop(l, 1);
player->Color = Video.MapRGB(TheScreen->format, r, g, b);
} else if (!strcmp(value, "timers")) {
if (!lua_istable(l, j + 1)) {
LuaError(l, "incorrect argument");
}
subargs = luaL_getn(l, j + 1);
if (subargs != UpgradeMax) {
LuaError(l, "Wrong upgrade timer length: %d" _C_ i);
}
for (k = 0; k < subargs; ++k) {
lua_rawgeti(l, j + 1, k + 1);
player->UpgradeTimers.Upgrades[k] = LuaToNumber(l, -1);
lua_pop(l, 1);
}
} else {
LuaError(l, "Unsupported tag: %s" _C_ value);
}

View file

@ -749,12 +749,6 @@ static int CclDefineSpell(lua_State *l)
if (!spell->SoundWhenCast.Sound) {
spell->SoundWhenCast.Name.clear();
}
} else if (!strcmp(value, "depend-upgrade")) {
value = LuaToString(l, i + 1);
spell->DependencyId = UpgradeIdByIdent(value);
if (spell->DependencyId == -1) {
lua_pushfstring(l, "Bad upgrade name: %s", value);
}
} else {
LuaError(l, "Unsupported tag: %s" _C_ value);
}

View file

@ -1009,7 +1009,7 @@ SpellType *SpellTypeByIdent(const std::string &ident)
// ****************************************************************************
/**
** Check if spell is research for player \p player.
** Check if spell is available for player \p player.
** @param player player for who we want to know if he knows the spell.
** @param spellid id of the spell to check.
**
@ -1020,7 +1020,7 @@ bool SpellIsAvailable(const CPlayer *player, int spellid)
int dependencyId;
dependencyId = SpellTypeTable[spellid]->DependencyId;
return dependencyId == -1 || UpgradeIdAllowed(player, dependencyId) == 'R';
return dependencyId == -1;
}
/**
@ -1033,7 +1033,7 @@ bool SpellIsAvailable(const CPlayer *player, int spellid)
** @param y Y coord of target spot when/if target does not exist
**
** @return =!0 if spell should/can casted, 0 if not
** @note caster must know the spell, and spell must be researched.
** @note caster must know the spell, and spell must be available.
*/
int CanCastSpell(const CUnit *caster, const SpellType *spell,
const CUnit *target, int x, int y)

View file

@ -240,8 +240,6 @@ int SpeedResourcesHarvest[MaxCosts]; /// speed factor for harvesting resources
int SpeedResourcesReturn[MaxCosts]; /// speed factor for returning resources
int SpeedBuild = 1; /// speed factor for building
int SpeedTrain = 1; /// speed factor for training
int SpeedUpgrade = 1; /// speed factor for upgrading
int SpeedResearch = 1; /// speed factor for researching
/*============================================================================
== DISPLAY

View file

@ -1,33 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2005 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/tolua
MSRC = tolua.cpp tolua_event.cpp tolua_is.cpp tolua_map.cpp tolua_push.cpp \
tolua_to.cpp
MHDRS = tolua_event.h tolua++.h
SRC += $(addprefix $(MODULE)/,$(MSRC))
HDRS += $(addprefix $(MODULE)/,$(MHDRS))

View file

@ -21,10 +21,6 @@ mt = { __index = function(t, key) return CIcon:Get(key) end }
Icons = {}
setmetatable(Icons, mt)
mt = { __index = function(t, key) return CUpgrade:Get(key) end }
Upgrades = {}
setmetatable(Upgrades, mt)
mt = { __index = function(t, key) return CFont:Get(key) end }
Fonts = {}
setmetatable(Fonts, mt)
@ -57,7 +53,6 @@ $pfile "ui.pkg"
$pfile "network.pkg"
$pfile "video.pkg"
$pfile "font.pkg"
$pfile "upgrade.pkg"
$pfile "player.pkg"
$pfile "unittype.pkg"
$pfile "unit.pkg"

View file

@ -1,6 +1,6 @@
/*
** Lua binding: stratagus
** Generated automatically by tolua++-1.0.92 on 02/08/07 22:13:16.
** Generated automatically by tolua++-1.0.92 on 03/14/07 20:15:00.
*/
#ifndef __cplusplus
@ -286,68 +286,67 @@ static int tolua_collect_Slider (lua_State* tolua_S)
static void tolua_reg_types (lua_State* tolua_S)
{
tolua_usertype(tolua_S,"CPlayerColorGraphic");
tolua_usertype(tolua_S,"MenuScreen");
tolua_usertype(tolua_S,"BasicContainer");
tolua_usertype(tolua_S,"vector<CUIButton>");
tolua_usertype(tolua_S,"CFontColor");
tolua_usertype(tolua_S,"CMap");
tolua_usertype(tolua_S,"LuaActionListener");
tolua_usertype(tolua_S,"ImageRadioButton");
tolua_usertype(tolua_S,"CNetworkHost");
tolua_usertype(tolua_S,"vector<CUIButton>");
tolua_usertype(tolua_S,"CEditor");
tolua_usertype(tolua_S,"SettingsPresets");
tolua_usertype(tolua_S,"CFontColor");
tolua_usertype(tolua_S,"Settings");
tolua_usertype(tolua_S,"CPreference");
tolua_usertype(tolua_S,"CUserInterface");
tolua_usertype(tolua_S,"gcn::Graphics");
tolua_usertype(tolua_S,"vector<CFiller>");
tolua_usertype(tolua_S,"CIcon");
tolua_usertype(tolua_S,"CUnitType");
tolua_usertype(tolua_S,"CMapInfo");
tolua_usertype(tolua_S,"TextField");
tolua_usertype(tolua_S,"CFont");
tolua_usertype(tolua_S,"CUIButton");
tolua_usertype(tolua_S,"CMapArea");
tolua_usertype(tolua_S,"CheckBox");
tolua_usertype(tolua_S,"ImageButton");
tolua_usertype(tolua_S,"ImageWidget");
tolua_usertype(tolua_S,"CPlayer");
tolua_usertype(tolua_S,"CUnit");
tolua_usertype(tolua_S,"Window");
tolua_usertype(tolua_S,"Graphics");
tolua_usertype(tolua_S,"CColor");
tolua_usertype(tolua_S,"CButtonPanel");
tolua_usertype(tolua_S,"CStatusLine");
tolua_usertype(tolua_S,"CServerSetup");
tolua_usertype(tolua_S,"CMinimap");
tolua_usertype(tolua_S,"MenuScreen");
tolua_usertype(tolua_S,"ImageSlider");
tolua_usertype(tolua_S,"ListBoxWidget");
tolua_usertype(tolua_S,"Color");
tolua_usertype(tolua_S,"ButtonStyle");
tolua_usertype(tolua_S,"ListBox");
tolua_usertype(tolua_S,"DropDownWidget");
tolua_usertype(tolua_S,"CFiller");
tolua_usertype(tolua_S,"MultiLineLabel");
tolua_usertype(tolua_S,"CPieMenu");
tolua_usertype(tolua_S,"ScrollArea");
tolua_usertype(tolua_S,"Windows");
tolua_usertype(tolua_S,"Button");
tolua_usertype(tolua_S,"DropDown");
tolua_usertype(tolua_S,"CInfoPanel");
tolua_usertype(tolua_S,"Container");
tolua_usertype(tolua_S,"ButtonWidget");
tolua_usertype(tolua_S,"Windows");
tolua_usertype(tolua_S,"CVideo");
tolua_usertype(tolua_S,"ImageCheckBox");
tolua_usertype(tolua_S,"ScrollingWidget");
tolua_usertype(tolua_S,"CGraphic");
tolua_usertype(tolua_S,"StatBoxWidget");
tolua_usertype(tolua_S,"CUITimer");
tolua_usertype(tolua_S,"Widget");
tolua_usertype(tolua_S,"Label");
tolua_usertype(tolua_S,"Settings");
tolua_usertype(tolua_S,"CResourceInfo");
tolua_usertype(tolua_S,"vector<CFiller>");
tolua_usertype(tolua_S,"CUnitType");
tolua_usertype(tolua_S,"CMapInfo");
tolua_usertype(tolua_S,"CFont");
tolua_usertype(tolua_S,"CServerSetup");
tolua_usertype(tolua_S,"MultiLineLabel");
tolua_usertype(tolua_S,"ImageWidget");
tolua_usertype(tolua_S,"SettingsPresets");
tolua_usertype(tolua_S,"gcn::Graphics");
tolua_usertype(tolua_S,"CStatusLine");
tolua_usertype(tolua_S,"ListBox");
tolua_usertype(tolua_S,"Window");
tolua_usertype(tolua_S,"CPreference");
tolua_usertype(tolua_S,"CFiller");
tolua_usertype(tolua_S,"BasicContainer");
tolua_usertype(tolua_S,"vector<string>");
tolua_usertype(tolua_S,"CUpgrade");
tolua_usertype(tolua_S,"Container");
tolua_usertype(tolua_S,"ButtonWidget");
tolua_usertype(tolua_S,"CVideo");
tolua_usertype(tolua_S,"ImageCheckBox");
tolua_usertype(tolua_S,"LuaActionListener");
tolua_usertype(tolua_S,"ImageRadioButton");
tolua_usertype(tolua_S,"CEditor");
tolua_usertype(tolua_S,"CUserInterface");
tolua_usertype(tolua_S,"CNetworkHost");
tolua_usertype(tolua_S,"TextField");
tolua_usertype(tolua_S,"CMapArea");
tolua_usertype(tolua_S,"CResourceInfo");
tolua_usertype(tolua_S,"CUITimer");
tolua_usertype(tolua_S,"RadioButton");
tolua_usertype(tolua_S,"CMinimap");
tolua_usertype(tolua_S,"Button");
tolua_usertype(tolua_S,"DropDown");
tolua_usertype(tolua_S,"ImageButton");
tolua_usertype(tolua_S,"Widget");
tolua_usertype(tolua_S,"Slider");
}
@ -3351,66 +3350,6 @@ static int tolua_set_CUserInterface_TrainingButtons(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* get function: UpgradingButton of class CUserInterface */
#ifndef TOLUA_DISABLE_tolua_get_CUserInterface_UpgradingButton_ptr
static int tolua_get_CUserInterface_UpgradingButton_ptr(lua_State* tolua_S)
{
CUserInterface* self = (CUserInterface*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'UpgradingButton'",NULL);
#endif
tolua_pushusertype(tolua_S,(void*)self->UpgradingButton,"CUIButton");
return 1;
}
#endif //#ifndef TOLUA_DISABLE
/* set function: UpgradingButton of class CUserInterface */
#ifndef TOLUA_DISABLE_tolua_set_CUserInterface_UpgradingButton_ptr
static int tolua_set_CUserInterface_UpgradingButton_ptr(lua_State* tolua_S)
{
CUserInterface* self = (CUserInterface*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'UpgradingButton'",NULL);
if (!tolua_isusertype(tolua_S,2,"CUIButton",0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
self->UpgradingButton = ((CUIButton*) tolua_tousertype(tolua_S,2,0))
;
return 0;
}
#endif //#ifndef TOLUA_DISABLE
/* get function: ResearchingButton of class CUserInterface */
#ifndef TOLUA_DISABLE_tolua_get_CUserInterface_ResearchingButton_ptr
static int tolua_get_CUserInterface_ResearchingButton_ptr(lua_State* tolua_S)
{
CUserInterface* self = (CUserInterface*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'ResearchingButton'",NULL);
#endif
tolua_pushusertype(tolua_S,(void*)self->ResearchingButton,"CUIButton");
return 1;
}
#endif //#ifndef TOLUA_DISABLE
/* set function: ResearchingButton of class CUserInterface */
#ifndef TOLUA_DISABLE_tolua_set_CUserInterface_ResearchingButton_ptr
static int tolua_set_CUserInterface_ResearchingButton_ptr(lua_State* tolua_S)
{
CUserInterface* self = (CUserInterface*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'ResearchingButton'",NULL);
if (!tolua_isusertype(tolua_S,2,"CUIButton",0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
self->ResearchingButton = ((CUIButton*) tolua_tousertype(tolua_S,2,0))
;
return 0;
}
#endif //#ifndef TOLUA_DISABLE
/* get function: TransportingButtons of class CUserInterface */
#ifndef TOLUA_DISABLE_tolua_get_CUserInterface_TransportingButtons
static int tolua_get_CUserInterface_TransportingButtons(lua_State* tolua_S)
@ -12578,148 +12517,6 @@ static int tolua_set_stratagus_CFontColor_Colors(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* method: New of class CUpgrade */
#ifndef TOLUA_DISABLE_tolua_stratagus_CUpgrade_New00
static int tolua_stratagus_CUpgrade_New00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"CUpgrade",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const std::string ident = ((const std::string) tolua_tocppstring(tolua_S,2,0));
{
CUpgrade* tolua_ret = (CUpgrade*) CUpgrade::New(ident);
tolua_pushusertype(tolua_S,(void*)tolua_ret,"CUpgrade");
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'New'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: Get of class CUpgrade */
#ifndef TOLUA_DISABLE_tolua_stratagus_CUpgrade_Get00
static int tolua_stratagus_CUpgrade_Get00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"CUpgrade",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const std::string ident = ((const std::string) tolua_tocppstring(tolua_S,2,0));
{
CUpgrade* tolua_ret = (CUpgrade*) CUpgrade::Get(ident);
tolua_pushusertype(tolua_S,(void*)tolua_ret,"CUpgrade");
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'Get'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* get function: Costs of class CUpgrade */
#ifndef TOLUA_DISABLE_tolua_get_stratagus_CUpgrade_Costs
static int tolua_get_stratagus_CUpgrade_Costs(lua_State* tolua_S)
{
int tolua_index;
CUpgrade* self;
lua_pushstring(tolua_S,".self");
lua_rawget(tolua_S,1);
self = (CUpgrade*) lua_touserdata(tolua_S,-1);
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
}
#endif
tolua_index = (int)tolua_tonumber(tolua_S,2,0);
#ifndef TOLUA_RELEASE
if (tolua_index<0 || tolua_index>=MaxCosts)
tolua_error(tolua_S,"array indexing out of range.",NULL);
#endif
tolua_pushnumber(tolua_S,(lua_Number)self->Costs[tolua_index]);
return 1;
}
#endif //#ifndef TOLUA_DISABLE
/* set function: Costs of class CUpgrade */
#ifndef TOLUA_DISABLE_tolua_set_stratagus_CUpgrade_Costs
static int tolua_set_stratagus_CUpgrade_Costs(lua_State* tolua_S)
{
int tolua_index;
CUpgrade* self;
lua_pushstring(tolua_S,".self");
lua_rawget(tolua_S,1);
self = (CUpgrade*) lua_touserdata(tolua_S,-1);
#ifndef TOLUA_RELEASE
{
tolua_Error tolua_err;
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
}
#endif
tolua_index = (int)tolua_tonumber(tolua_S,2,0);
#ifndef TOLUA_RELEASE
if (tolua_index<0 || tolua_index>=MaxCosts)
tolua_error(tolua_S,"array indexing out of range.",NULL);
#endif
self->Costs[tolua_index] = ((int) tolua_tonumber(tolua_S,3,0));
return 0;
}
#endif //#ifndef TOLUA_DISABLE
/* get function: Icon of class CUpgrade */
#ifndef TOLUA_DISABLE_tolua_get_CUpgrade_Icon_ptr
static int tolua_get_CUpgrade_Icon_ptr(lua_State* tolua_S)
{
CUpgrade* self = (CUpgrade*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Icon'",NULL);
#endif
tolua_pushusertype(tolua_S,(void*)self->Icon,"CIcon");
return 1;
}
#endif //#ifndef TOLUA_DISABLE
/* set function: Icon of class CUpgrade */
#ifndef TOLUA_DISABLE_tolua_set_CUpgrade_Icon_ptr
static int tolua_set_CUpgrade_Icon_ptr(lua_State* tolua_S)
{
CUpgrade* self = (CUpgrade*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'Icon'",NULL);
if (!tolua_isusertype(tolua_S,2,"CIcon",0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
self->Icon = ((CIcon*) tolua_tousertype(tolua_S,2,0))
;
return 0;
}
#endif //#ifndef TOLUA_DISABLE
/* get function: Index of class CPlayer */
#ifndef TOLUA_DISABLE_tolua_get_CPlayer_Index
static int tolua_get_CPlayer_Index(lua_State* tolua_S)
@ -16070,32 +15867,25 @@ TOLUA_API int tolua_stratagus_open (lua_State* tolua_S)
110,115, 44, 32,109,116, 41, 10,109,116, 32, 61, 32,123, 32,
95, 95,105,110,100,101,120, 32, 61, 32,102,117,110, 99,116,
105,111,110, 40,116, 44, 32,107,101,121, 41, 32,114,101,116,
117,114,110, 32, 67, 85,112,103,114, 97,100,101, 58, 71,101,
116, 40,107,101,121, 41, 32,101,110,100, 32,125, 10, 85,112,
103,114, 97,100,101,115, 32, 61, 32,123,125, 10,115,101,116,
109,101,116, 97,116, 97, 98,108,101, 40, 85,112,103,114, 97,
100,101,115, 44, 32,109,116, 41, 10,109,116, 32, 61, 32,123,
32, 95, 95,105,110,100,101,120, 32, 61, 32,102,117,110, 99,
116,105,111,110, 40,116, 44, 32,107,101,121, 41, 32,114,101,
116,117,114,110, 32, 67, 70,111,110,116, 58, 71,101,116, 40,
107,101,121, 41, 32,101,110,100, 32,125, 10, 70,111,110,116,
115, 32, 61, 32,123,125, 10,115,101,116,109,101,116, 97,116,
97, 98,108,101, 40, 70,111,110,116,115, 44, 32,109,116, 41,
10,109,116, 32, 61, 32,123, 32, 95, 95,105,110,100,101,120,
32, 61, 32,102,117,110, 99,116,105,111,110, 40,116, 44, 32,
107,101,121, 41, 32,114,101,116,117,114,110, 32, 67, 70,111,
110,116, 67,111,108,111,114, 58, 71,101,116, 40,107,101,121,
41, 32,101,110,100, 32,125, 10, 70,111,110,116, 67,111,108,
111,114,115, 32, 61, 32,123,125, 10,115,101,116,109,101,116,
97,116, 97, 98,108,101, 40, 70,111,110,116, 67,111,108,111,
114,115, 44, 32,109,116, 41, 10,109,116, 32, 61, 32,123, 32,
95, 95,105,110,100,101,120, 32, 61, 32,102,117,110, 99,116,
105,111,110, 40,116, 44, 32,107,101,121, 41, 32,114,101,116,
117,114,110, 32, 85,110,105,116, 84,121,112,101, 66,121, 73,
100,101,110,116, 40,107,101,121, 41, 32,101,110,100, 32,125,
10, 85,110,105,116, 84,121,112,101,115, 32, 61, 32,123,125,
10,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 85,
110,105,116, 84,121,112,101,115, 44, 32,109,116, 41,32
117,114,110, 32, 67, 70,111,110,116, 58, 71,101,116, 40,107,
101,121, 41, 32,101,110,100, 32,125, 10, 70,111,110,116,115,
32, 61, 32,123,125, 10,115,101,116,109,101,116, 97,116, 97,
98,108,101, 40, 70,111,110,116,115, 44, 32,109,116, 41, 10,
109,116, 32, 61, 32,123, 32, 95, 95,105,110,100,101,120, 32,
61, 32,102,117,110, 99,116,105,111,110, 40,116, 44, 32,107,
101,121, 41, 32,114,101,116,117,114,110, 32, 67, 70,111,110,
116, 67,111,108,111,114, 58, 71,101,116, 40,107,101,121, 41,
32,101,110,100, 32,125, 10, 70,111,110,116, 67,111,108,111,
114,115, 32, 61, 32,123,125, 10,115,101,116,109,101,116, 97,
116, 97, 98,108,101, 40, 70,111,110,116, 67,111,108,111,114,
115, 44, 32,109,116, 41, 10,109,116, 32, 61, 32,123, 32, 95,
95,105,110,100,101,120, 32, 61, 32,102,117,110, 99,116,105,
111,110, 40,116, 44, 32,107,101,121, 41, 32,114,101,116,117,
114,110, 32, 85,110,105,116, 84,121,112,101, 66,121, 73,100,
101,110,116, 40,107,101,121, 41, 32,101,110,100, 32,125, 10,
85,110,105,116, 84,121,112,101,115, 32, 61, 32,123,125, 10,
115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 85,110,
105,116, 84,121,112,101,115, 44, 32,109,116, 41,32
};
tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 1");
lua_settop(tolua_S, top);
@ -16302,8 +16092,6 @@ TOLUA_API int tolua_stratagus_open (lua_State* tolua_S)
tolua_variable(tolua_S,"MaxSelectedTextY",tolua_get_CUserInterface_MaxSelectedTextY,tolua_set_CUserInterface_MaxSelectedTextY);
tolua_variable(tolua_S,"SingleTrainingButton",tolua_get_CUserInterface_SingleTrainingButton_ptr,tolua_set_CUserInterface_SingleTrainingButton_ptr);
tolua_variable(tolua_S,"TrainingButtons",tolua_get_CUserInterface_TrainingButtons,tolua_set_CUserInterface_TrainingButtons);
tolua_variable(tolua_S,"UpgradingButton",tolua_get_CUserInterface_UpgradingButton_ptr,tolua_set_CUserInterface_UpgradingButton_ptr);
tolua_variable(tolua_S,"ResearchingButton",tolua_get_CUserInterface_ResearchingButton_ptr,tolua_set_CUserInterface_ResearchingButton_ptr);
tolua_variable(tolua_S,"TransportingButtons",tolua_get_CUserInterface_TransportingButtons,tolua_set_CUserInterface_TransportingButtons);
tolua_variable(tolua_S,"CompletedBarColorRGB",tolua_get_CUserInterface_CompletedBarColorRGB,tolua_set_CUserInterface_CompletedBarColorRGB);
tolua_variable(tolua_S,"CompletedBarShadow",tolua_get_CUserInterface_CompletedBarShadow,tolua_set_CUserInterface_CompletedBarShadow);
@ -16896,13 +16684,6 @@ TOLUA_API int tolua_stratagus_open (lua_State* tolua_S)
tolua_function(tolua_S,"Get",tolua_stratagus_CFontColor_Get00);
tolua_array(tolua_S,"Colors",tolua_get_stratagus_CFontColor_Colors,tolua_set_stratagus_CFontColor_Colors);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"CUpgrade","CUpgrade","",NULL);
tolua_beginmodule(tolua_S,"CUpgrade");
tolua_function(tolua_S,"New",tolua_stratagus_CUpgrade_New00);
tolua_function(tolua_S,"Get",tolua_stratagus_CUpgrade_Get00);
tolua_array(tolua_S,"Costs",tolua_get_stratagus_CUpgrade_Costs,tolua_set_stratagus_CUpgrade_Costs);
tolua_variable(tolua_S,"Icon",tolua_get_CUpgrade_Icon_ptr,tolua_set_CUpgrade_Icon_ptr);
tolua_endmodule(tolua_S);
tolua_constant(tolua_S,"PlayerNeutral",PlayerNeutral);
tolua_constant(tolua_S,"PlayerNobody",PlayerNobody);
tolua_constant(tolua_S,"PlayerComputer",PlayerComputer);

View file

@ -135,8 +135,6 @@ class CUserInterface
CUIButton *SingleTrainingButton;
vector<CUIButton> TrainingButtons;
CUIButton *UpgradingButton;
CUIButton *ResearchingButton;
vector<CUIButton> TransportingButtons;
CColor CompletedBarColorRGB;

View file

@ -1,9 +0,0 @@
class CUpgrade
{
static CUpgrade *New(const std::string ident);
static CUpgrade *Get(const std::string ident);
int Costs[MaxCosts];
CIcon *Icon;
};

View file

@ -1,31 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/ui
MSRC = botpanel.cpp button_checks.cpp script_ui.cpp icons.cpp interface.cpp \
mainscr.cpp menu_proc.cpp mouse.cpp ui.cpp widgets.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -123,12 +123,6 @@ int AddButton(int pos, int level, const std::string &icon_ident,
case ButtonTrain:
ba->Value = UnitTypeIdByIdent(value);
break;
case ButtonResearch:
ba->Value = UpgradeIdByIdent(value);
break;
case ButtonUpgradeTo:
ba->Value = UnitTypeIdByIdent(value);
break;
case ButtonBuild:
ba->Value = UnitTypeIdByIdent(value);
break;
@ -379,14 +373,10 @@ void UpdateStatusLineForButton(const ButtonAction *button)
switch (button->Action) {
case ButtonBuild:
case ButtonTrain:
case ButtonUpgradeTo:
// FIXME: store pointer in button table!
stats = &UnitTypes[button->Value]->Stats[ThisPlayer->Index];
SetCosts(0, UnitTypes[button->Value]->Demand, stats->Costs);
break;
case ButtonResearch:
SetCosts(0, 0, AllUpgrades[button->Value]->Costs);
break;
case ButtonSpellCast:
SetCosts(SpellTypeTable[button->Value]->ManaCost, 0, NULL);
break;
@ -409,7 +399,6 @@ void UpdateStatusLineForButton(const ButtonAction *button)
** @return 1 if button is allowed, 0 else.
**
** @todo FIXME: better check. (dependancy, resource, ...)
** @todo FIXME: make difference with impossible and not yet researched.
*/
static bool IsButtonAllowed(const CUnit *unit, const ButtonAction *buttonaction)
{
@ -470,13 +459,8 @@ static bool IsButtonAllowed(const CUnit *unit, const ButtonAction *buttonaction)
break;
}
// FALL THROUGH
case ButtonUpgradeTo:
case ButtonResearch:
case ButtonBuild:
res = CheckDependByIdent(unit->Player, buttonaction->ValueStr);
if (res && !strncmp(buttonaction->ValueStr.c_str(), "upgrade-", 8)) {
res = UpgradeIdentAllowed(unit->Player, buttonaction->ValueStr) == 'A';
}
break;
case ButtonSpellCast:
res = SpellIsAvailable(unit->Player, buttonaction->Value);
@ -487,10 +471,6 @@ static bool IsButtonAllowed(const CUnit *unit, const ButtonAction *buttonaction)
case ButtonCancel:
res = true;
break;
case ButtonCancelUpgrade:
res = unit->Orders[0]->Action == UnitActionUpgradeTo ||
unit->Orders[0]->Action == UnitActionResearch;
break;
case ButtonCancelTrain:
res = unit->Orders[0]->Action == UnitActionTrain;
break;
@ -590,12 +570,6 @@ static ButtonAction *UpdateButtonPanelSingleUnit(const CUnit *unit)
if (unit->Orders[0]->Action == UnitActionBuilt) {
// Trick 17 to get the cancel-build button
strcpy_s(unit_ident, sizeof(unit_ident), ",cancel-build,");
} else if (unit->Orders[0]->Action == UnitActionUpgradeTo) {
// Trick 17 to get the cancel-upgrade button
strcpy_s(unit_ident, sizeof(unit_ident), ",cancel-upgrade,");
} else if (unit->Orders[0]->Action == UnitActionResearch) {
// Trick 17 to get the cancel-upgrade button
strcpy_s(unit_ident, sizeof(unit_ident), ",cancel-upgrade,");
} else {
sprintf(unit_ident, ",%s,", unit->Type->Ident.c_str());
}
@ -810,14 +784,6 @@ void CButtonPanel::DoClicked(int button)
break;
case ButtonCancel:
case ButtonCancelUpgrade:
if (NumSelected == 1) {
if (Selected[0]->Orders[0]->Action == UnitActionUpgradeTo) {
SendCommandCancelUpgradeTo(Selected[0]);
} else if (Selected[0]->Orders[0]->Action == UnitActionResearch) {
SendCommandCancelResearch(Selected[0]);
}
}
UI.StatusLine.Clear();
ClearCosts();
CurrentButtonLevel = 0;
@ -877,28 +843,6 @@ void CButtonPanel::DoClicked(int button)
ClearCosts();
}
break;
case ButtonUpgradeTo:
// FIXME: store pointer in button table!
type = UnitTypes[CurrentButtons[button].Value];
if (!Selected[0]->Player->CheckUnitType(type)) {
//PlayerSubUnitType(player,type);
SendCommandUpgradeTo(Selected[0],type,
!(KeyModifiers & ModifierShift));
UI.StatusLine.Clear();
ClearCosts();
}
break;
case ButtonResearch:
i = CurrentButtons[button].Value;
if (!Selected[0]->Player->CheckCosts(AllUpgrades[i]->Costs)) {
//PlayerSubCosts(player,Upgrades[i].Costs);
SendCommandResearch(Selected[0], AllUpgrades[i],
!(KeyModifiers & ModifierShift));
UI.StatusLine.Clear();
ClearCosts();
}
break;
}
}

View file

@ -77,19 +77,6 @@ bool ButtonCheckFalse(const CUnit *unit, const ButtonAction *button)
return false;
}
/**
** Check for button enabled, if upgrade is ready.
**
** @param unit Pointer to unit for button.
** @param button Pointer to button to check/enable.
**
** @return True if enabled.
*/
bool ButtonCheckUpgrade(const CUnit *unit, const ButtonAction *button)
{
return UpgradeIdentAllowed(unit->Player, button->AllowStr) == 'R';
}
/**
** Check for button enabled, if any unit is available.
**
@ -172,7 +159,7 @@ bool ButtonCheckNoNetwork(const CUnit *unit, const ButtonAction *button)
/**
** Check for button enabled, if the unit isn't working.
** Working is training, upgrading, researching.
** Working is training.
**
** @param unit Pointer to unit for button.
** @param button Pointer to button to check/enable.
@ -181,40 +168,7 @@ bool ButtonCheckNoNetwork(const CUnit *unit, const ButtonAction *button)
*/
bool ButtonCheckNoWork(const CUnit *unit, const ButtonAction *button)
{
return unit->Orders[0]->Action != UnitActionTrain &&
unit->Orders[0]->Action != UnitActionUpgradeTo &&
unit->Orders[0]->Action != UnitActionResearch;
}
/**
** Check for button enabled, if the unit isn't researching.
**
** @param unit Pointer to unit for button.
** @param button Pointer to button to check/enable.
**
** @return True if enabled.
*/
bool ButtonCheckNoResearch(const CUnit *unit, const ButtonAction *button)
{
return unit->Orders[0]->Action != UnitActionUpgradeTo &&
unit->Orders[0]->Action != UnitActionResearch;
}
/**
** Check for button enabled, if all requirements for an upgrade to unit
** are met.
**
** @param unit Pointer to unit for button.
** @param button Pointer to button to check/enable.
**
** @return True if enabled.
*/
bool ButtonCheckUpgradeTo(const CUnit *unit, const ButtonAction *button)
{
if (unit->Orders[0]->Action != UnitActionStill) {
return false;
}
return CheckDependByIdent(unit->Player, button->ValueStr);
return unit->Orders[0]->Action != UnitActionTrain;
}
/**
@ -230,51 +184,4 @@ bool ButtonCheckAttack(const CUnit *unit, const ButtonAction *button)
return unit->Type->CanAttack;
}
/**
** Check if all requirements for upgrade research are met.
**
** @param unit Pointer to unit for button.
** @param button Pointer to button to check/enable.
**
** @return True if enabled.
*/
bool ButtonCheckResearch(const CUnit *unit, const ButtonAction *button)
{
// don't show any if working
if (!ButtonCheckNoWork(unit, button)) {
return false;
}
// check if allowed
if (!CheckDependByIdent(unit->Player, button->ValueStr)) {
return false;
}
if (!strncmp(button->ValueStr.c_str(), "upgrade-", 8) &&
UpgradeIdentAllowed(unit->Player, button->ValueStr) != 'A') {
return false;
}
return true;
}
/**
** Check if all requirements for upgrade research are met only one
** running research allowed.
**
** @param unit Pointer to unit for button.
** @param button Pointer to button to check/enable.
**
** @return True if enabled.
*/
bool ButtonCheckSingleResearch(const CUnit *unit,
const ButtonAction *button)
{
if (ButtonCheckResearch(unit, button)) {
if (!unit->Player->UpgradeTimers.Upgrades[
UpgradeIdByIdent(button->ValueStr)]) {
return true;
}
}
return false;
}
//@}

View file

@ -108,7 +108,7 @@ CIcon *CIcon::Get(const std::string &ident)
{
CIcon *icon = Icons[ident];
if (!icon) {
DebugPrint("icon not found: %s" _C_ ident.c_str());
DebugPrint("icon not found: %s\n" _C_ ident.c_str());
}
return icon;
}

View file

@ -647,36 +647,6 @@ static void DrawUnitInfo(CUnit *unit)
}
return;
}
//
// Building upgrading to better type.
//
if (unit->Orders[0]->Action == UnitActionUpgradeTo) {
if (UI.UpgradingButton) {
unit->Orders[0]->Type->Icon.Icon->DrawUnitIcon(unit->Player,
UI.UpgradingButton->Style,
(ButtonAreaUnderCursor == ButtonAreaUpgrading &&
ButtonUnderCursor == 0) ?
(IconActive | (MouseButtons & LeftButton)) : 0,
UI.UpgradingButton->X, UI.UpgradingButton->Y, "");
}
return;
}
//
// Building research new technology.
//
if (unit->Orders[0]->Action == UnitActionResearch) {
if (UI.ResearchingButton) {
unit->Data.Research.Upgrade->Icon->DrawUnitIcon(unit->Player,
UI.ResearchingButton->Style,
(ButtonAreaUnderCursor == ButtonAreaResearching &&
ButtonUnderCursor == 0) ?
(IconActive | (MouseButtons & LeftButton)) : 0,
UI.ResearchingButton->X, UI.ResearchingButton->Y, "");
}
return;
}
}
//
@ -1249,9 +1219,7 @@ void CInfoPanel::Draw(void)
ThisPlayer->IsAllied(Selected[0]) ||
ReplayRevealMap) {
if (Selected[0]->Orders[0]->Action == UnitActionBuilt ||
Selected[0]->Orders[0]->Action == UnitActionResearch ||
Selected[0]->Orders[0]->Action == UnitActionUpgradeTo ||
Selected[0]->Orders[0]->Action == UnitActionTrain) {
Selected[0]->Orders[0]->Action == UnitActionTrain) {
i = 3;
} else if (Selected[0]->Stats->Variables[MANA_INDEX].Max) {
i = 2;

View file

@ -519,20 +519,6 @@ static void HandleMouseOn(int x, int y)
}
}
}
} else if (Selected[0]->Orders[0]->Action == UnitActionUpgradeTo) {
if (OnButton(x, y, UI.UpgradingButton)) {
ButtonAreaUnderCursor = ButtonAreaUpgrading;
ButtonUnderCursor = 0;
CursorOn = CursorOnButton;
return;
}
} else if (Selected[0]->Orders[0]->Action == UnitActionResearch) {
if (OnButton(x, y, UI.ResearchingButton)) {
ButtonAreaUnderCursor = ButtonAreaResearching;
ButtonUnderCursor = 0;
CursorOn = CursorOnButton;
return;
}
}
}
if (NumSelected == 1) {
@ -1568,30 +1554,6 @@ void UIHandleButtonDown(unsigned button)
}
}
//
// clicked on upgrading button
//
} else if (ButtonAreaUnderCursor == ButtonAreaUpgrading) {
if (!GameObserve && !GamePaused &&
ThisPlayer->IsTeamed(Selected[0])) {
if (ButtonUnderCursor == 0 && NumSelected == 1) {
DebugPrint("Cancel upgrade %s\n" _C_
Selected[0]->Type->Ident.c_str());
SendCommandCancelUpgradeTo(Selected[0]);
}
}
//
// clicked on researching button
//
} else if (ButtonAreaUnderCursor == ButtonAreaResearching) {
if (!GameObserve && !GamePaused &&
ThisPlayer->IsTeamed(Selected[0])) {
if (ButtonUnderCursor == 0 && NumSelected == 1) {
DebugPrint("Cancel research %s\n" _C_
Selected[0]->Type->Ident.c_str());
SendCommandCancelResearch(Selected[0]);
}
}
//
// clicked on button panel
//
} else if (ButtonAreaUnderCursor == ButtonAreaTransporting) {

View file

@ -1181,16 +1181,10 @@ static int CclDefineButton(lua_State *l)
ba.Action = ButtonReturn;
} else if (!strcmp(value, "cast-spell")) {
ba.Action = ButtonSpellCast;
} else if (!strcmp(value, "research")) {
ba.Action = ButtonResearch;
} else if (!strcmp(value, "upgrade-to")) {
ba.Action = ButtonUpgradeTo;
} else if (!strcmp(value, "unload")) {
ba.Action = ButtonUnload;
} else if (!strcmp(value, "cancel")) {
ba.Action = ButtonCancel;
} else if (!strcmp(value, "cancel-upgrade")) {
ba.Action = ButtonCancelUpgrade;
} else if (!strcmp(value, "cancel-train-unit")) {
ba.Action = ButtonCancelTrain;
} else if (!strcmp(value, "cancel-build")) {
@ -1215,8 +1209,6 @@ static int CclDefineButton(lua_State *l)
ba.Allowed = ButtonCheckTrue;
} else if (!strcmp(value, "check-false")) {
ba.Allowed = ButtonCheckFalse;
} else if (!strcmp(value, "check-upgrade")) {
ba.Allowed = ButtonCheckUpgrade;
} else if (!strcmp(value, "check-units-or")) {
ba.Allowed = ButtonCheckUnitsOr;
} else if (!strcmp(value, "check-units-and")) {
@ -1227,16 +1219,8 @@ static int CclDefineButton(lua_State *l)
ba.Allowed = ButtonCheckNoNetwork;
} else if (!strcmp(value, "check-no-work")) {
ba.Allowed = ButtonCheckNoWork;
} else if (!strcmp(value, "check-no-research")) {
ba.Allowed = ButtonCheckNoResearch;
} else if (!strcmp(value, "check-attack")) {
ba.Allowed = ButtonCheckAttack;
} else if (!strcmp(value, "check-upgrade-to")) {
ba.Allowed = ButtonCheckUpgradeTo;
} else if (!strcmp(value, "check-research")) {
ba.Allowed = ButtonCheckResearch;
} else if (!strcmp(value, "check-single-research")) {
ba.Allowed = ButtonCheckSingleResearch;
} else {
LuaError(l, "Unsupported action: %s" _C_ value);
}

View file

@ -74,7 +74,6 @@ CUserInterface::CUserInterface() :
SingleTrainingButton(NULL),
SingleTrainingFont(0), SingleTrainingTextX(0), SingleTrainingTextY(0),
TrainingFont(0), TrainingTextX(0), TrainingTextY(0),
UpgradingButton(NULL), ResearchingButton(NULL),
CompletedBarColor(0), CompletedBarShadow(0),
ViewportMode(VIEWPORT_SINGLE), MouseViewport(NULL),
SelectedViewport(NULL), NumViewports(0),
@ -267,8 +266,6 @@ void CleanUserInterface(void)
UI.SingleTrainingText.clear();
UI.TrainingButtons.clear();
UI.TrainingText.clear();
delete UI.UpgradingButton;
delete UI.ResearchingButton;
UI.TransportingButtons.clear();
// Button Panel

View file

@ -1,31 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/unit
MSRC = depend.cpp script_unit.cpp script_unittype.cpp \
unit.cpp unit_cache.cpp unit_draw.cpp unit_find.cpp unittype.cpp upgrade.cpp
SRC += $(addprefix $(MODULE)/,$(MSRC))

View file

@ -80,10 +80,6 @@ void AddDependency(const char *target, const char *required, int count,
// target string refers to unit-xxx
rule.Type = DependRuleUnitType;
rule.Kind.UnitType = UnitTypeByIdent(target);
} else if (!strncmp(target, "upgrade-", 8)) {
// target string refers to upgrade-XXX
rule.Type = DependRuleUpgrade;
rule.Kind.Upgrade = CUpgrade::Get(target);
} else {
DebugPrint("dependency target `%s' should be unit-type or upgrade\n" _C_
target);
@ -95,8 +91,7 @@ void AddDependency(const char *target, const char *required, int count,
// Find correct hash slot.
//
if ((node = DependHash[hash])) { // find correct entry
while (node->Type != rule.Type ||
node->Kind.Upgrade != rule.Kind.Upgrade) {
while (node->Type != rule.Type) {
if (!node->Next) { // end of list
temp = new DependRule;
temp->Next = NULL;
@ -137,10 +132,6 @@ void AddDependency(const char *target, const char *required, int count,
// required string refers to unit-xxx
temp->Type = DependRuleUnitType;
temp->Kind.UnitType = UnitTypeByIdent(required);
} else if (!strncmp(required, "upgrade-", 8)) {
// required string refers to upgrade-XXX
temp->Type = DependRuleUpgrade;
temp->Kind.Upgrade = CUpgrade::Get(required);
} else {
DebugPrint("dependency required `%s' should be unit-type or upgrade\n" _C_
required);
@ -184,7 +175,7 @@ void AddDependency(const char *target, const char *required, int count,
** Check if this upgrade or unit is available.
**
** @param player For this player available.
** @param target Unit or Upgrade.
** @param target Unit.
**
** @return True if available, false otherwise.
*/
@ -205,13 +196,6 @@ bool CheckDependByIdent(const CPlayer *player, const std::string &target)
return false;
}
rule.Type = DependRuleUnitType;
} else if (!strncmp(target.c_str(), "upgrade-", 8)) {
// target string refers to upgrade-XXX
rule.Kind.Upgrade = CUpgrade::Get(target);
if (UpgradeIdAllowed(player, rule.Kind.Upgrade->ID) != 'A') {
return false;
}
rule.Type = DependRuleUpgrade;
} else {
DebugPrint("target `%s' should be unit-type or upgrade\n" _C_ target.c_str());
return false;
@ -223,8 +207,7 @@ bool CheckDependByIdent(const CPlayer *player, const std::string &target)
i = (int)(long)rule.Kind.UnitType % (sizeof(DependHash) / sizeof(*DependHash));
if ((node = DependHash[i])) { // find correct entry
while (node->Type != rule.Type ||
node->Kind.Upgrade != rule.Kind.Upgrade) {
while (node->Type != rule.Type) {
if (!node->Next) { // end of list
return true;
}
@ -249,12 +232,6 @@ bool CheckDependByIdent(const CPlayer *player, const std::string &target)
goto try_or;
}
break;
case DependRuleUpgrade:
i = UpgradeIdAllowed(player, temp->Kind.Upgrade->ID) != 'R';
if (temp->Count ? i : !i) {
goto try_or;
}
break;
}
temp = temp->Rule;
}

View file

@ -169,10 +169,6 @@ void CclParseOrder(lua_State *l, COrder *order)
order->Action = UnitActionSpellCast;
} else if (!strcmp(value, "action-train")) {
order->Action = UnitActionTrain;
} else if (!strcmp(value, "action-upgrade-to")) {
order->Action = UnitActionUpgradeTo;
} else if (!strcmp(value, "action-research")) {
order->Action = UnitActionResearch;
} else if (!strcmp(value, "action-built")) {
order->Action = UnitActionBuilt;
} else if (!strcmp(value, "action-board")) {
@ -266,12 +262,6 @@ void CclParseOrder(lua_State *l, COrder *order)
order->Arg1.Spell = SpellTypeByIdent(LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "upgrade")) {
++j;
lua_rawgeti(l, -1, j + 1);
order->Arg1.Upgrade = CUpgrade::Get(LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "mine")) {
++j;
lua_rawgeti(l, -1, j + 1);
@ -393,65 +383,6 @@ static void CclParseResWorker(lua_State *l, CUnit *unit)
}
}
/**
** Parse research
**
** @param l Lua state.
** @param unit Unit pointer which should be filled with the data.
*/
static void CclParseResearch(lua_State *l, CUnit *unit)
{
const char *value;
int args;
int j;
if (!lua_istable(l, -1)) {
LuaError(l, "incorrect argument");
}
args = luaL_getn(l, -1);
for (j = 0; j < args; ++j) {
lua_rawgeti(l, -1, j + 1);
value = LuaToString(l, -1);
lua_pop(l, 1);
++j;
if (!strcmp(value, "ident")) {
lua_rawgeti(l, -1, j + 1);
value = LuaToString(l, -1);
lua_pop(l, 1);
unit->Data.Research.Upgrade = CUpgrade::Get(value);
}
}
}
/**
** Parse upgrade to
**
** @param l Lua state.
** @param unit Unit pointer which should be filled with the data.
*/
static void CclParseUpgradeTo(lua_State *l, CUnit *unit)
{
const char *value;
int args;
int j;
if (!lua_istable(l, -1)) {
LuaError(l, "incorrect argument");
}
args = luaL_getn(l, -1);
for (j = 0; j < args; ++j) {
lua_rawgeti(l, -1, j + 1);
value = LuaToString(l, -1);
lua_pop(l, 1);
++j;
if (!strcmp(value, "ticks")) {
lua_rawgeti(l, -1, j + 1);
unit->Data.UpgradeTo.Ticks = LuaToNumber(l, -1);
lua_pop(l, 1);
}
}
}
/**
** Parse stored data for train order
**
@ -805,14 +736,6 @@ static int CclUnit(lua_State *l)
lua_pushvalue(l, j + 1);
CclParseResWorker(l, unit);
lua_pop(l, 1);
} else if (!strcmp(value, "data-research")) {
lua_pushvalue(l, j + 1);
CclParseResearch(l, unit);
lua_pop(l, 1);
} else if (!strcmp(value, "data-upgrade-to")) {
lua_pushvalue(l, j + 1);
CclParseUpgradeTo(l, unit);
lua_pop(l, 1);
} else if (!strcmp(value, "data-train")) {
lua_pushvalue(l, j + 1);
CclParseTrain(l, unit);

View file

@ -1384,10 +1384,6 @@ static int CclDefineAnimations(lua_State *l)
anims->Repair = ParseAnimation(l, -1);
} else if (!strcmp(value, "Train")) {
anims->Train = ParseAnimation(l, -1);
} else if (!strcmp(value, "Research")) {
anims->Research = ParseAnimation(l, -1);
} else if (!strcmp(value, "Upgrade")) {
anims->Upgrade = ParseAnimation(l, -1);
} else if (!strcmp(value, "Build")) {
anims->Build = ParseAnimation(l, -1);
} else if (!strncmp(value, "Harvest_", 8)) {
@ -1769,13 +1765,6 @@ void UpdateUnitVariables(const CUnit *unit)
unit->Variable[TRANSPORT_INDEX].Value = unit->BoardCount;
unit->Variable[TRANSPORT_INDEX].Max = unit->Type->MaxOnBoard;
// Research.
if (unit->Orders[0]->Action == UnitActionResearch) {
unit->Variable[RESEARCH_INDEX].Value =
unit->Player->UpgradeTimers.Upgrades[unit->Data.Research.Upgrade->ID];
unit->Variable[RESEARCH_INDEX].Max = unit->Data.Research.Upgrade->Costs[TimeCost];
}
// Training
if (unit->Orders[0]->Action == UnitActionTrain) {
unit->Variable[TRAINING_INDEX].Value = unit->Data.Train.Ticks;
@ -1783,13 +1772,6 @@ void UpdateUnitVariables(const CUnit *unit)
unit->Orders[0]->Type->Stats[unit->Player->Index].Costs[TimeCost];
}
// UpgradeTo
if (unit->Orders[0]->Action == UnitActionUpgradeTo) {
unit->Variable[UPGRADINGTO_INDEX].Value = unit->Data.UpgradeTo.Ticks;
unit->Variable[UPGRADINGTO_INDEX].Max =
unit->Orders[0]->Type->Stats[unit->Player->Index].Costs[TimeCost];
}
// Resources.
if (unit->Type->GivesResource) {
unit->Variable[GIVERESOURCE_INDEX].Value = unit->ResourcesHeld;
@ -1885,7 +1867,7 @@ void UpdateUnitVariables(const CUnit *unit)
void InitDefinedVariables()
{
const char *var[NVARALREADYDEFINED] = {"HitPoints", "Build", "Mana", "Transport",
"Research", "Training", "UpgradeTo", "GiveResource", "CarryResource",
"Training", "GiveResource", "CarryResource",
"Xp", "Kill", "Supply", "Demand", "Armor", "SightRange",
"AttackRange", "PiercingDamage", "BasicDamage", "PosX", "PosY", "RadarRange",
"RadarJammerRange", "AutoRepairRange", "Bloodlust", "Haste", "Slow", "Invisible",

View file

@ -895,13 +895,6 @@ void UnitLost(CUnit *unit)
}
}
//
// Handle research cancels.
//
if (unit->Orders[0]->Action == UnitActionResearch) {
unit->Player->UpgradeTimers.Upgrades[unit->Data.Research.Upgrade->ID] = 0;
}
DebugPrint("Lost %s(%d)\n" _C_ unit->Type->Ident.c_str() _C_ UnitNumber(unit));
// Destroy resource-platform, must re-make resource patch.
@ -1034,8 +1027,7 @@ static void UnitFillSeenValues(CUnit *unit)
unit->Seen.IY = unit->IY;
unit->Seen.IX = unit->IX;
unit->Seen.Frame = unit->Frame;
unit->Seen.State = (unit->Orders[0]->Action == UnitActionBuilt) |
((unit->Orders[0]->Action == UnitActionUpgradeTo) << 1);
unit->Seen.State = (unit->Orders[0]->Action == UnitActionBuilt);
if (unit->Orders[0]->Action == UnitActionDie) {
unit->Seen.State = 3;
}
@ -3505,12 +3497,6 @@ void SaveOrder(const COrder *order, CFile *file)
case UnitActionTrain:
file->printf("\"action-train\",");
break;
case UnitActionUpgradeTo:
file->printf("\"action-upgrade-to\",");
break;
case UnitActionResearch:
file->printf("\"action-research\",");
break;
case UnitActionBuilt:
file->printf("\"action-built\",");
break;
@ -3570,11 +3556,6 @@ void SaveOrder(const COrder *order, CFile *file)
file->printf(" \"spell\", \"%s\",", order->Arg1.Spell->Ident.c_str());
}
break;
case UnitActionResearch:
if (order->Arg1.Upgrade) {
file->printf(" \"upgrade\", \"%s\",", order->Arg1.Upgrade->Ident.c_str());
}
break;
case UnitActionResource :
case UnitActionReturnGoods :
file->printf(" \"mine\", %d,", order->Arg1.ResourcePos);
@ -3800,16 +3781,6 @@ void SaveUnit(const CUnit *unit, CFile *file)
file->printf("}");
break;
}
case UnitActionResearch:
file->printf(",\n \"data-research\", {");
file->printf("\"ident\", \"%s\",", unit->Data.Research.Upgrade->Ident.c_str());
file->printf("}");
break;
case UnitActionUpgradeTo:
file->printf(",\n \"data-upgrade-to\", {");
file->printf("\"ticks\", %d,", unit->Data.UpgradeTo.Ticks);
file->printf("}");
break;
case UnitActionTrain:
file->printf(",\n \"data-train\", {");
file->printf("\"ticks\", %d, ", unit->Data.Train.Ticks);

View file

@ -425,7 +425,7 @@ static int CclShowHealthBar(lua_State *l)
** DefineDecorations({Index = "Mana", HideNeutral = true, CenterX = true,
** OffsetPercent = {50, 100},
** Method = {"sprite", {0}}})
** For index Mana, Transport, Research, Training, UpgradeTo, Resource.
** For index Mana, Transport, Training, Resource.
** Except for ressource which have HideNeutral = false.
**
** @param l Lua state
@ -436,12 +436,8 @@ static int CclShowManaDot(lua_State *l)
"OffsetPercent = {50, 100},Method = {\"sprite\", {\"sprite-mana\"}}})\n"
"DefineDecorations({Index = \"Transport\", HideNeutral = true, CenterX = true,"
"OffsetPercent = {50, 100},Method = {\"sprite\", {\"sprite-mana\"}}})\n"
"DefineDecorations({Index = \"Research\", HideNeutral = true, CenterX = true,"
"OffsetPercent = {50, 100},Method = {\"sprite\", {\"sprite-mana\"}}})\n"
"DefineDecorations({Index = \"Training\", HideNeutral = true, CenterX = true,"
"OffsetPercent = {50, 100},Method = {\"sprite\", {\"sprite-mana\"}}})\n"
"DefineDecorations({Index = \"UpgradeTo\", HideNeutral = true, CenterX = true,"
"OffsetPercent = {50, 100},Method = {\"sprite\", {\"sprite-mana\"}}})\n"
"DefineDecorations({Index = \"GiveResource\", HideNeutral = false, CenterX = true,"
"OffsetPercent = {50, 100},Method = {\"sprite\", {\"sprite-mana\"}}})\n"
"DefineDecorations({Index = \"CarryResource\", HideNeutral = false, CenterX = true,"
@ -463,7 +459,7 @@ static int CclShowManaDot(lua_State *l)
** DefineDecorations({Index = "Mana", HideNeutral = true, CenterX = true,
** OffsetPercent = {50, 100},
** Method = {"bar", {Width = 3, BorderSize = 1}}})
** For index Mana, Transport, Research, Training, UpgradeTo, Resource.
** For index Mana, Transport, Training, Resource.
**
** @param l Lua state
*/
@ -473,12 +469,8 @@ static int CclShowManaHorizontal(lua_State *l)
"OffsetPercent = {50, 100}, Method = {\"bar\", {Width = 3, BorderSize = 1}}})\n"
"DefineDecorations({Index = \"Transport\", HideNeutral = true, CenterX = true,"
"OffsetPercent = {50, 100}, Method = {\"bar\", {Width = 3, BorderSize = 1}}})\n"
"DefineDecorations({Index = \"Research\", HideNeutral = true, CenterX = true,"
"OffsetPercent = {50, 100}, Method = {\"bar\", {Width = 3, BorderSize = 1}}})\n"
"DefineDecorations({Index = \"Training\", HideNeutral = true, CenterX = true,"
"OffsetPercent = {50, 100}, Method = {\"bar\", {Width = 3, BorderSize = 1}}})\n"
"DefineDecorations({Index = \"UpgradeTo\", HideNeutral = true, CenterX = true,"
"OffsetPercent = {50, 100}, Method = {\"bar\", {Width = 3, BorderSize = 1}}})\n"
"DefineDecorations({Index = \"GiveResource\", HideNeutral = false, CenterX = true,"
"OffsetPercent = {50, 100}, Method = {\"bar\", {Width = 3, BorderSize = 1}}})\n"
"DefineDecorations({Index = \"CarryResource\", HideNeutral = false, CenterX = true,"
@ -499,7 +491,7 @@ static int CclShowManaHorizontal(lua_State *l)
** Equivalent of
** DefineDecorations({Index = "Mana", HideNeutral = true,
** Method = {"bar", {Width = 3, BorderSize = 1, Orientation = "vertical"}}})
** For index Mana, Transport, Research, Training, UpgradeTo, Resource.
** For index Mana, Transport, Training, Resource.
**
** @param l Lua state
*/
@ -509,12 +501,8 @@ static int CclShowManaVertical(lua_State *l)
"Method = {\"bar\", {Width = 3, BorderSize = 1, Orientation = \"vertical\"}}})\n"
"DefineDecorations({Index = \"Transport\", HideNeutral = true,"
"Method = {\"bar\", {Width = 3, BorderSize = 1, Orientation = \"vertical\"}}})\n"
"DefineDecorations({Index = \"Research\", HideNeutral = true,"
"Method = {\"bar\", {Width = 3, BorderSize = 1, Orientation = \"vertical\"}}})\n"
"DefineDecorations({Index = \"Training\", HideNeutral = true,"
"Method = {\"bar\", {Width = 3, BorderSize = 1, Orientation = \"vertical\"}}})\n"
"DefineDecorations({Index = \"UpgradeTo\", HideNeutral = true,"
"Method = {\"bar\", {Width = 3, BorderSize = 1, Orientation = \"vertical\"}}})\n"
"DefineDecorations({Index = \"GiveResource\", HideNeutral = false,"
"Method = {\"bar\", {Width = 3, BorderSize = 1, Orientation = \"vertical\"}}})\n"
"DefineDecorations({Index = \"CarryResource\", HideNeutral = false,"
@ -1062,14 +1050,6 @@ static void ShowSingleOrder(const CUnit *unit, int x1, int y1, const COrder *ord
e_color = color = ColorGray;
break;
case UnitActionUpgradeTo:
e_color = color = ColorGray;
break;
case UnitActionResearch:
e_color = color = ColorGray;
break;
case UnitActionBuild:
DrawSelection(ColorGray, x2 - order->Type->BoxWidth / 2,
y2 - order->Type->BoxHeight / 2,
@ -1381,8 +1361,7 @@ void CUnit::Draw() const
x = this->IX;
x += CurrentViewport->Map2ViewportX(this->X);
y += CurrentViewport->Map2ViewportY(this->Y);
state = (this->Orders[0]->Action == UnitActionBuilt) |
((this->Orders[0]->Action == UnitActionUpgradeTo) << 1);
state = (this->Orders[0]->Action == UnitActionBuilt);
constructed = this->Constructed;
// Reset Type to the type being upgraded to
if (state == 2) {

View file

@ -64,104 +64,11 @@
----------------------------------------------------------------------------*/
static void AllowUnitId(CPlayer *player, int id, int units);
static void AllowUpgradeId(CPlayer *player, int id, char af);
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
std::vector<CUpgrade *> AllUpgrades; /// The main user useable upgrades
/// How many upgrades modifiers supported
#define UPGRADE_MODIFIERS_MAX (UpgradeMax * 4)
/// Upgrades modifiers
static CUpgradeModifier *UpgradeModifiers[UPGRADE_MODIFIERS_MAX];
/// Number of upgrades modifiers used
static int NumUpgradeModifiers;
std::map<std::string, CUpgrade *> Upgrades;
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
CUpgrade::CUpgrade(const std::string &ident) :
Ident(ident), ID(0)
{
memset(this->Costs, 0, sizeof(this->Costs));
}
CUpgrade::~CUpgrade()
{
}
/**
** Create a new upgrade
**
** @param ident Upgrade identifier
*/
CUpgrade *CUpgrade::New(const std::string &ident)
{
CUpgrade *upgrade = Upgrades[ident];
if (upgrade) {
return upgrade;
} else {
upgrade = new CUpgrade(ident);
Upgrades[ident] = upgrade;
upgrade->ID = AllUpgrades.size();
AllUpgrades.push_back(upgrade);
return upgrade;
}
}
/**
** Get an upgrade
**
** @param ident Upgrade identifier
**
** @return Upgrade pointer or NULL if not found.
*/
CUpgrade *CUpgrade::Get(const std::string &ident)
{
CUpgrade *upgrade = Upgrades[ident];
if (!upgrade) {
DebugPrint("upgrade not found: %s\n" _C_ ident.c_str());
}
return upgrade;
}
/**
** Init upgrade/allow structures
*/
void InitUpgrades(void)
{
}
/**
** Cleanup the upgrade module.
*/
void CleanUpgrades(void)
{
//
// Free the upgrades.
//
while (AllUpgrades.size()) {
CUpgrade *upgrade = AllUpgrades.back();
AllUpgrades.pop_back();
delete upgrade;
}
Upgrades.clear();
//
// Free the upgrade modifiers.
//
for (int i = 0; i < NumUpgradeModifiers; ++i) {
delete[] UpgradeModifiers[i]->Modifier.Variables;
delete UpgradeModifiers[i];
}
NumUpgradeModifiers = 0;
}
/**
** Save state of the dependencies to file.
**
@ -186,151 +93,12 @@ void SaveUpgrades(CFile *file)
file->printf(")\n");
}
file->printf("\n");
//
// Save the upgrades
//
for (std::vector<CUpgrade *>::size_type j = 0; j < AllUpgrades.size(); ++j) {
file->printf("DefineAllow(\"%s\", \"", AllUpgrades[j]->Ident.c_str());
for (int p = 0; p < PlayerMax; ++p) {
file->printf("%c", Players[p].Allow.Upgrades[j]);
}
file->printf("\")\n");
}
}
/*----------------------------------------------------------------------------
-- Ccl part of upgrades
----------------------------------------------------------------------------*/
/**
** Define a new upgrade modifier.
**
** @param l List of modifiers.
*/
static int CclDefineModifier(lua_State *l)
{
const char *key;
const char *value;
CUpgradeModifier *um;
int args;
int j;
args = lua_gettop(l);
um = new CUpgradeModifier;
memset(um->ChangeUpgrades, '?', sizeof(um->ChangeUpgrades));
memset(um->ApplyTo, '?', sizeof(um->ApplyTo));
um->Modifier.Variables = new CVariable[UnitTypeVar.NumberVariable];
um->UpgradeId = UpgradeIdByIdent(LuaToString(l, 1));
for (j = 1; j < args; ++j) {
if (!lua_istable(l, j + 1)) {
LuaError(l, "incorrect argument");
}
lua_rawgeti(l, j + 1, 1);
key = LuaToString(l, -1);
lua_pop(l, 1);
#if 1 // To be removed. must modify lua file.
if (!strcmp(key, "attack-range")) {
key = "AttackRange";
} else if (!strcmp(key, "sight-range")) {
key = "SightRange";
} else if (!strcmp(key, "basic-damage")) {
key = "BasicDamage";
} else if (!strcmp(key, "piercing-damage")) {
key = "PiercingDamage";
} else if (!strcmp(key, "armor")) {
key = "Armor";
} else if (!strcmp(key, "hit-points")) {
key = "HitPoints";
}
#endif
if (!strcmp(key, "regeneration-rate")) {
lua_rawgeti(l, j + 1, 2);
um->Modifier.Variables[HP_INDEX].Increase = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(key, "cost")) {
int i;
if (!lua_istable(l, j + 1) || luaL_getn(l, j + 1) != 2) {
LuaError(l, "incorrect argument");
}
lua_rawgeti(l, j + 1, 1);
value = LuaToString(l, -1);
lua_pop(l, 1);
for (i = 0; i < MaxCosts; ++i) {
if (!strcmp(value, DefaultResourceNames[i])) {
break;
}
}
if (i == MaxCosts) {
LuaError(l, "Resource not found: %s" _C_ value);
}
lua_rawgeti(l, j + 1, 2);
um->Modifier.Costs[i] = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(key, "allow-unit")) {
lua_rawgeti(l, j + 1, 2);
value = LuaToString(l, -1);
lua_pop(l, 1);
if (!strncmp(value, "unit-", 5)) {
lua_rawgeti(l, j + 1, 3);
um->ChangeUnits[UnitTypeIdByIdent(value)] = LuaToNumber(l, -1);
lua_pop(l, 1);
} else {
LuaError(l, "unit expected");
}
} else if (!strcmp(key, "allow")) {
lua_rawgeti(l, j + 1, 2);
value = LuaToString(l, -1);
lua_pop(l, 1);
if (!strncmp(value, "upgrade-", 8)) {
lua_rawgeti(l, j + 1, 3);
um->ChangeUpgrades[UpgradeIdByIdent(value)] = LuaToNumber(l, -1);
lua_pop(l, 1);
} else {
LuaError(l, "upgrade expected");
}
} else if (!strcmp(key, "apply-to")) {
lua_rawgeti(l, j + 1, 2);
value = LuaToString(l, -1);
lua_pop(l, 1);
um->ApplyTo[UnitTypeIdByIdent(value)] = 'X';
} else if (!strcmp(key, "convert-to")) {
lua_rawgeti(l, j + 1, 2);
value = LuaToString(l, -1);
lua_pop(l, 1);
um->ConvertTo = UnitTypeByIdent(value);
} else {
int index; // variable index;
index = GetVariableIndex(key);
if (index != -1) {
lua_rawgeti(l, j + 1, 2);
if (lua_istable(l, -1)) {
DefineVariableField(l, um->Modifier.Variables + index, -1);
} else if (lua_isnumber(l, -1)) {
um->Modifier.Variables[index].Enable = 1;
um->Modifier.Variables[index].Value = LuaToNumber(l, -1);
um->Modifier.Variables[index].Max = LuaToNumber(l, -1);
} else {
LuaError(l, "bad argument type for '%s'\n" _C_ key);
}
lua_pop(l, 1);
} else {
LuaError(l, "wrong tag: %s" _C_ key);
}
}
}
UpgradeModifiers[NumUpgradeModifiers++] = um;
return 0;
}
/**
** Define which units are allowed and how much.
*/
@ -396,11 +164,6 @@ static int CclDefineAllow(lua_State *l)
AllowUnitId(&Players[i], id, 0);
}
}
} else if (!strncmp(ident, "upgrade-", 8)) {
id = UpgradeIdByIdent(ident);
for (i = 0; i < n; ++i) {
AllowUpgradeId(&Players[i], id, ids[i]);
}
} else {
DebugPrint(" wrong ident %s\n" _C_ ident);
}
@ -414,7 +177,6 @@ static int CclDefineAllow(lua_State *l)
*/
void UpgradesCclRegister(void)
{
lua_register(Lua, "DefineModifier", CclDefineModifier);
lua_register(Lua, "DefineAllow", CclDefineAllow);
lua_register(Lua, "DefineUnitAllow", CclDefineUnitAllow);
}
@ -423,7 +185,7 @@ void UpgradesCclRegister(void)
-- General/Map functions
----------------------------------------------------------------------------*/
// AllowStruct and UpgradeTimers will be static in the player so will be
// AllowStruct will be static in the player so will be
// load/saved with the player struct
/**
@ -444,236 +206,6 @@ int UnitTypeIdByIdent(const std::string &ident)
return -1;
}
/**
** Upgrade ID by identifier.
**
** @param ident The upgrade identifier.
** @return Upgrade ID (int) or -1 if not found.
*/
int UpgradeIdByIdent(const std::string &ident)
{
const CUpgrade *upgrade;
if ((upgrade = CUpgrade::Get(ident))) {
return upgrade->ID;
}
DebugPrint(" fix this %s\n" _C_ ident.c_str());
return -1;
}
/*----------------------------------------------------------------------------
-- Upgrades
----------------------------------------------------------------------------*/
/**
** Convert unit-type to.
**
** @param player For this player.
** @param src From this unit-type.
** @param dst To this unit-type.
*/
static void ConvertUnitTypeTo(CPlayer *player, const CUnitType *src, CUnitType *dst)
{
CUnit *unit;
int i;
int j;
for (i = 0; i < player->TotalNumUnits; ++i) {
unit = player->Units[i];
//
// Convert already existing units to this type.
//
if (unit->Type == src) {
CommandTransformIntoType(unit, dst);
//
// Convert trained units to this type.
// FIXME: what about buildings?
//
} else {
for (j = 0; j < unit->OrderCount; ++j) {
if (unit->Orders[j]->Action == UnitActionTrain &&
unit->Orders[j]->Type == src) {
if (j == 0) {
// Must Adjust Ticks to the fraction that was trained
unit->Data.Train.Ticks =
unit->Data.Train.Ticks *
dst->Stats[player->Index].Costs[TimeCost] /
src->Stats[player->Index].Costs[TimeCost];
}
unit->Orders[j]->Type = dst;
}
}
}
}
}
/**
** Apply the modifiers of an upgrade.
**
** This function will mark upgrade done and do all required modifications
** to unit types and will modify allow/forbid maps
**
** @param player Player that get all the upgrades.
** @param um Upgrade modifier that do the effects
*/
static void ApplyUpgradeModifier(CPlayer *player, const CUpgradeModifier *um)
{
int z; // iterator on upgrade or unittype.
int j; // iterator on cost or variable.
int pn; // player number.
int varModified; // 0 if variable is not modified.
int numunits; // number of unit of the current type.
CUnit *unitupgrade[UnitMax]; // array of unit of the current type
CUnit *unit; // current unit.
Assert(player);
Assert(um);
pn = player->Index;
for (z = 0; z < UpgradeMax; ++z) {
// allow/forbid upgrades for player. only if upgrade is not acquired
// FIXME: check if modify is allowed
if (player->Allow.Upgrades[z] != 'R') {
if (um->ChangeUpgrades[z] == 'A') {
player->Allow.Upgrades[z] = 'A';
}
if (um->ChangeUpgrades[z] == 'F') {
player->Allow.Upgrades[z] = 'F';
}
// we can even have upgrade acquired w/o costs
if (um->ChangeUpgrades[z] == 'R') {
player->Allow.Upgrades[z] = 'R';
}
}
}
for (z = 0; z < UnitTypeMax; ++z) {
// add/remove allowed units
// FIXME: check if modify is allowed
player->Allow.Units[z] += um->ChangeUnits[z];
Assert(um->ApplyTo[z] == '?' || um->ApplyTo[z] == 'X');
// this modifier should be applied to unittype id == z
if (um->ApplyTo[z] == 'X') {
// If Sight range is upgraded, we need to change EVERY unit
// to the new range, otherwise the counters get confused.
if (um->Modifier.Variables[SIGHTRANGE_INDEX].Value) {
numunits = FindUnitsByType(UnitTypes[z], unitupgrade);
for (numunits--; numunits >= 0; --numunits) {
unit = unitupgrade[numunits];
if (unit->Player->Index == pn && !unit->Removed) {
MapUnmarkUnitSight(unit);
unit->CurrentSightRange = UnitTypes[z]->Stats[pn].Variables[SIGHTRANGE_INDEX].Max +
um->Modifier.Variables[SIGHTRANGE_INDEX].Value;
MapMarkUnitSight(unit);
}
}
}
// upgrade costs :)
for (j = 0; j < MaxCosts; ++j) {
UnitTypes[z]->Stats[pn].Costs[j] += um->Modifier.Costs[j];
}
varModified = 0;
for (j = 0; j < UnitTypeVar.NumberVariable; j++) {
varModified |= um->Modifier.Variables[j].Value
| um->Modifier.Variables[j].Max
| um->Modifier.Variables[j].Increase;
UnitTypes[z]->Stats[pn].Variables[j].Value += um->Modifier.Variables[j].Value;
if (UnitTypes[z]->Stats[pn].Variables[j].Value < 0) {
UnitTypes[z]->Stats[pn].Variables[j].Value = 0;
}
UnitTypes[z]->Stats[pn].Variables[j].Max += um->Modifier.Variables[j].Max;
if (UnitTypes[z]->Stats[pn].Variables[j].Max < 0) {
UnitTypes[z]->Stats[pn].Variables[j].Max = 0;
}
if (UnitTypes[z]->Stats[pn].Variables[j].Value > UnitTypes[z]->Stats[pn].Variables[j].Max) {
UnitTypes[z]->Stats[pn].Variables[j].Value = UnitTypes[z]->Stats[pn].Variables[j].Max;
}
UnitTypes[z]->Stats[pn].Variables[j].Increase += um->Modifier.Variables[j].Increase;
}
// And now modify ingame units
if (varModified) {
numunits = FindUnitsByType(UnitTypes[z], unitupgrade);
numunits--; // Change to 0 Start not 1 start
for (; numunits >= 0; --numunits) {
unit = unitupgrade[numunits];
if (unit->Player->Index != player->Index) {
continue;
}
for (j = 0; j < UnitTypeVar.NumberVariable; j++) {
unit->Variable[j].Value += um->Modifier.Variables[j].Value;
if (unit->Variable[j].Value < 0) {
unit->Variable[j].Value = 0;
}
unit->Variable[j].Max += um->Modifier.Variables[j].Max;
if (unit->Variable[j].Max < 0) {
unit->Variable[j].Max = 0;
}
if (unit->Variable[j].Value > unit->Variable[j].Max) {
unit->Variable[j].Value = unit->Variable[j].Max;
}
unit->Variable[j].Increase += um->Modifier.Variables[j].Increase;
}
}
}
if (um->ConvertTo) {
ConvertUnitTypeTo(player,UnitTypes[z], um->ConvertTo);
}
}
}
}
/**
** Handle that an upgrade was acquired.
**
** @param player Player researching the upgrade.
** @param upgrade Upgrade ready researched.
*/
void UpgradeAcquire(CPlayer *player, const CUpgrade *upgrade)
{
int z;
int id;
id = upgrade->ID;
player->UpgradeTimers.Upgrades[id] = upgrade->Costs[TimeCost];
AllowUpgradeId(player, id, 'R'); // research done
for (z = 0; z < NumUpgradeModifiers; ++z) {
if (UpgradeModifiers[z]->UpgradeId == id) {
ApplyUpgradeModifier(player, UpgradeModifiers[z]);
}
}
//
// Upgrades could change the buttons displayed.
//
if (player == ThisPlayer) {
SelectedUnitChanged();
}
}
#if 0 // UpgradeLost not implemented.
/**
** for now it will be empty?
** perhaps acquired upgrade can be lost if (for example) a building is lost
** (lumber mill? stronghold?)
** this function will apply all modifiers in reverse way
*/
void UpgradeLost(Player *player, int id)
{
player->UpgradeTimers.Upgrades[id] = 0;
AllowUpgradeId(player, id, 'A'); // research is lost i.e. available
// FIXME: here we should reverse apply upgrade...
}
#endif
/*----------------------------------------------------------------------------
-- Allow(s)
----------------------------------------------------------------------------*/
@ -692,19 +224,6 @@ static void AllowUnitId(CPlayer *player, int id, int units)
player->Allow.Units[id] = units;
}
/**
** Change allow for an upgrade.
**
** @param player Player to change
** @param id upgrade id
** @param af `A'llow/`F'orbid/`R'eseached
*/
static void AllowUpgradeId(CPlayer *player, int id, char af)
{
Assert(af == 'A' || af == 'F' || af == 'R');
player->Allow.Upgrades[id] = af;
}
/**
** Return the allow state of the unit.
**
@ -719,68 +238,4 @@ int UnitIdAllowed(const CPlayer *player, int id)
return player->Allow.Units[id];
}
/**
** Return the allow state of an upgrade.
**
** @param player Check state for this player.
** @param id Upgrade identifier.
**
** @return the allow state of the upgrade.
*/
char UpgradeIdAllowed(const CPlayer *player, int id)
{
Assert(id >= 0 && id < UpgradeMax);
return player->Allow.Upgrades[id];
}
// ***************by string identifiers's
/**
** Return the allow state of an upgrade.
**
** @param player Check state for this player.
** @param ident Upgrade identifier.
**
** @note This function shouldn't be used during runtime, it is only for setup.
*/
char UpgradeIdentAllowed(const CPlayer *player, const std::string &ident)
{
int id;
if ((id = UpgradeIdByIdent(ident)) != -1) {
return UpgradeIdAllowed(player, id);
}
DebugPrint("Fix your code, wrong idenifier `%s'\n" _C_ ident.c_str());
return '-';
}
/*----------------------------------------------------------------------------
-- Check availablity
----------------------------------------------------------------------------*/
/**
** Check if upgrade (also spells) available for the player.
**
** @param player Player pointer.
** @param ident Upgrade ident.
*/
int UpgradeIdentAvailable(const CPlayer *player, const std::string &ident)
{
int allow;
#if 0
//
// Check dependencies
//
if (!CheckDependByIdent(player, ident)) {
return 0;
}
#endif
//
// Allowed by level
//
allow = UpgradeIdentAllowed(player, ident);
return allow == 'R' || allow == 'X';
}
//@}

View file

@ -1,32 +0,0 @@
## ____ _ __
## / __ )____ _____ | | / /___ ___________
## / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
## / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
## /_____/\____/____/ |__/|__/\__,_/_/ /____/
##
## A futuristic real-time strategy game.
## This file is part of Bos Wars.
##
## Module.make - Module Makefile (included from Makefile).
##
## (c) Copyright 2004 by The Stratagus Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MODULE = src/video
MSRC = cursor.cpp font.cpp graphic.cpp linedraw.cpp movie.cpp png.cpp sdl.cpp sprite.cpp video.cpp
MHDRS = intern_video.h
SRC += $(addprefix $(MODULE)/,$(MSRC))
HDRS += $(addprefix $(MODULE)/,$(MHDRS))