Attached Files |
-
build_once.patch (3,187 bytes) 2007-07-28 15:07
Index: rts/Game/command.h
===================================================================
--- rts/Game/command.h (revision 4098)
+++ rts/Game/command.h (working copy)
@@ -88,6 +88,7 @@
#define SHIFT_KEY (1 << 5) // 32
#define CONTROL_KEY (1 << 6) // 64
#define ALT_KEY (1 << 7) // 128
+#define DONT_REPEAT (1 << 8) // 256
struct Command {
@@ -96,7 +97,7 @@
: timeOut(INT_MAX), options(0), tag(0) {};
int id;
vector<float> params;
- unsigned char options;
+ int options;
unsigned int tag;
int timeOut; // remove this command after this frame
// can only be set locally, not sent over net
Index: rts/Sim/Units/CommandAI/CommandAI.cpp
===================================================================
--- rts/Sim/Units/CommandAI/CommandAI.cpp (revision 4098)
+++ rts/Sim/Units/CommandAI/CommandAI.cpp (working copy)
@@ -1204,7 +1204,9 @@
void CCommandAI::FinishCommand(void)
{
const int type = commandQue.front().id;
+ const bool dontrepeat = commandQue.front().options & DONT_REPEAT;
if (repeatOrders
+ && !dontrepeat
&& (type != CMD_STOP)
&& (type != CMD_PATROL)
&& (type != CMD_SET_WANTED_MAX_SPEED)
@@ -1293,7 +1295,7 @@
}
Command& c=commandQue[a];
file->lsInt(c.id);
- file->lsUChar(c.options);
+ file->lsInt(c.options);
file->lsInt(c.timeOut);
int paramSize=c.params.size();
Index: rts/Sim/Units/CommandAI/FactoryCAI.cpp
===================================================================
--- rts/Sim/Units/CommandAI/FactoryCAI.cpp (revision 4098)
+++ rts/Sim/Units/CommandAI/FactoryCAI.cpp (working copy)
@@ -237,11 +237,23 @@
} else {
if(c.options & ALT_KEY){
for(int a=0;a<numItems;++a){
- commandQue.push_front(c);
+ if (repeatOrders) {
+ Command nc(c);
+ nc.options |= DONT_REPEAT;
+ if (commandQue.empty())
+ commandQue.push_front(nc);
+ else
+ commandQue.insert(commandQue.begin()+1, nc);
+ } else {
+ commandQue.push_front(c);
+ }
+
}
- building=false;
- CFactory* fac=(CFactory*)owner;
- fac->StopBuild();
+ if (!repeatOrders) {
+ building=false;
+ CFactory* fac=(CFactory*)owner;
+ fac->StopBuild();
+ }
} else {
for(int a=0;a<numItems;++a){
commandQue.push_back(c);
@@ -294,7 +306,7 @@
void CFactoryCAI::CancelRestrictedUnit(const Command& c, BuildOption& buildOption)
{
- if(!repeatOrders) {
+ if(!repeatOrders || c.options & DONT_REPEAT) {
buildOption.numQued--;
ENTER_MIXED;
if (owner->team == gu->myTeam) {
@@ -331,7 +343,7 @@
building=false;
if(owner->group)
owner->group->CommandFinished(owner->id,commandQue.front().id);
- if(!repeatOrders)
+ if(!repeatOrders || c.options & DONT_REPEAT)
boi->second.numQued--;
UpdateIconName(c.id,boi->second);
FinishCommand();
@@ -347,7 +359,7 @@
} else {
const UnitDef *def = unitDefHandler->GetUnitByName(boi->second.name);
if(luaRules && !luaRules->AllowUnitCreation(def, owner, NULL)) {
- if(!repeatOrders){
+ if(!repeatOrders || c.options & DONT_REPEAT){
boi->second.numQued--;
}
UpdateIconName(c.id,boi->second);
-
build_once_v2.patch (3,517 bytes) 2007-07-29 22:09
Index: rts/Game/command.h
===================================================================
--- rts/Game/command.h (revision 4106)
+++ rts/Game/command.h (working copy)
@@ -54,7 +54,6 @@
#define CMD_CAPTURE 130
#define CMD_AUTOREPAIRLEVEL 135
#define CMD_LOOPBACKATTACK 140
-#define CMD_IDLEMODE 145
#define CMDTYPE_ICON 0 // expect 0 parameters in return
#define CMDTYPE_ICON_MODE 5 // expect 1 parameter in return (number selected mode)
@@ -84,13 +83,16 @@
// bits for the option field of Command
-#define INTERNAL_ORDER (1 << 3) // 8
+#define DONT_REPEAT (1 << 3) // 8
#define RIGHT_MOUSE_KEY (1 << 4) // 16
#define SHIFT_KEY (1 << 5) // 32
#define CONTROL_KEY (1 << 6) // 64
#define ALT_KEY (1 << 7) // 128
+#define INTERNAL_ORDER (DONT_REPEAT)
+
+
struct Command {
CR_DECLARE_STRUCT(Command);
Command()
Index: rts/Sim/Units/CommandAI/CommandAI.cpp
===================================================================
--- rts/Sim/Units/CommandAI/CommandAI.cpp (revision 4106)
+++ rts/Sim/Units/CommandAI/CommandAI.cpp (working copy)
@@ -1204,11 +1204,13 @@
void CCommandAI::FinishCommand(void)
{
const int type = commandQue.front().id;
+ const bool dontrepeat = commandQue.front().options & DONT_REPEAT
+ || commandQue.front().options & INTERNAL_ORDER;
if (repeatOrders
+ && !dontrepeat
&& (type != CMD_STOP)
&& (type != CMD_PATROL)
- && (type != CMD_SET_WANTED_MAX_SPEED)
- && !(commandQue.front().options & INTERNAL_ORDER)){
+ && (type != CMD_SET_WANTED_MAX_SPEED)){
commandQue.push_back(commandQue.front());
}
commandQue.pop_front();
Index: rts/Sim/Units/CommandAI/FactoryCAI.cpp
===================================================================
--- rts/Sim/Units/CommandAI/FactoryCAI.cpp (revision 4106)
+++ rts/Sim/Units/CommandAI/FactoryCAI.cpp (working copy)
@@ -237,11 +237,23 @@
} else {
if(c.options & ALT_KEY){
for(int a=0;a<numItems;++a){
- commandQue.push_front(c);
+ if (repeatOrders) {
+ Command nc(c);
+ nc.options |= DONT_REPEAT;
+ if (commandQue.empty())
+ commandQue.push_front(nc);
+ else
+ commandQue.insert(commandQue.begin()+1, nc);
+ } else {
+ commandQue.push_front(c);
+ }
+
}
- building=false;
- CFactory* fac=(CFactory*)owner;
- fac->StopBuild();
+ if (!repeatOrders) {
+ building=false;
+ CFactory* fac=(CFactory*)owner;
+ fac->StopBuild();
+ }
} else {
for(int a=0;a<numItems;++a){
commandQue.push_back(c);
@@ -294,7 +306,7 @@
void CFactoryCAI::CancelRestrictedUnit(const Command& c, BuildOption& buildOption)
{
- if(!repeatOrders) {
+ if(!repeatOrders || c.options & DONT_REPEAT) {
buildOption.numQued--;
ENTER_MIXED;
if (owner->team == gu->myTeam) {
@@ -331,7 +343,7 @@
building=false;
if(owner->group)
owner->group->CommandFinished(owner->id,commandQue.front().id);
- if(!repeatOrders)
+ if(!repeatOrders || c.options & DONT_REPEAT)
boi->second.numQued--;
UpdateIconName(c.id,boi->second);
FinishCommand();
@@ -347,7 +359,7 @@
} else {
const UnitDef *def = unitDefHandler->GetUnitByName(boi->second.name);
if(luaRules && !luaRules->AllowUnitCreation(def, owner, NULL)) {
- if(!repeatOrders){
+ if(!repeatOrders || c.options & DONT_REPEAT){
boi->second.numQued--;
}
UpdateIconName(c.id,boi->second);
|
---|