- changed command speed change to only change speed min every 160 frames or more as required.
This commit is contained in:
parent
98234228d9
commit
50bdd2039e
|
@ -36,6 +36,7 @@ using namespace Shared::Util;
|
|||
namespace Glest{ namespace Game{
|
||||
|
||||
const int CHANGE_COMMAND_SPEED = 325;
|
||||
const int MIN_FRAMECOUNT_CHANGE_COMMAND_SPEED = 160;
|
||||
|
||||
//Mutex Unit::mutexDeletedUnits;
|
||||
//map<void *,bool> Unit::deletedUnits;
|
||||
|
@ -515,6 +516,9 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
|
|||
|
||||
mutexCommands = new Mutex(CODE_AT_LINE);
|
||||
changedActiveCommand = false;
|
||||
lastChangedActiveCommandFrame = 0;
|
||||
changedActiveCommandFrame = 0;
|
||||
|
||||
lastSynchDataString="";
|
||||
modelFacing = CardinalDir::NORTH;
|
||||
lastStuckFrame = 0;
|
||||
|
@ -1784,26 +1788,37 @@ std::pair<CommandResult,string> Unit::giveCommand(Command *command, bool tryQueu
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Clear commands because current is NOT queable.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
bool willChangedActiveCommand = (commands.empty() == false);
|
||||
if(willChangedActiveCommand){
|
||||
if(willChangedActiveCommand == true) {
|
||||
|
||||
CommandClass currCommandClass = getCurrCommand()->getCommandType()->getClass();
|
||||
CommandClass commandClass = command->getCommandType()->getClass();
|
||||
if(currCommandClass
|
||||
== commandClass){
|
||||
if(currCommandClass == commandClass) {
|
||||
|
||||
willChangedActiveCommand = false;
|
||||
}
|
||||
else if(currCommandClass==ccAttack || currCommandClass==ccAttackStopped ||
|
||||
commandClass==ccAttack || commandClass==ccAttackStopped){
|
||||
else if(currCommandClass == ccAttack ||
|
||||
currCommandClass == ccAttackStopped ||
|
||||
commandClass == ccAttack ||
|
||||
commandClass == ccAttackStopped) {
|
||||
|
||||
willChangedActiveCommand= true;
|
||||
}
|
||||
else {
|
||||
willChangedActiveCommand= false;
|
||||
}
|
||||
}
|
||||
|
||||
if(willChangedActiveCommand == true) {
|
||||
|
||||
lastChangedActiveCommandFrame = changedActiveCommandFrame;
|
||||
changedActiveCommandFrame = getFrameCount();
|
||||
|
||||
//printf("Line: %d getCurrCommand() [%s] command [%s]\n",__LINE__,getCurrCommand()->toString(false).c_str(),command->toString(false).c_str());
|
||||
}
|
||||
|
||||
clearCommands();
|
||||
changedActiveCommand = willChangedActiveCommand;
|
||||
|
||||
|
||||
|
||||
//printf("In [%s::%s] Line: %d cleared existing commands\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
@ -2153,9 +2168,13 @@ int64 Unit::getUpdateProgress() {
|
|||
//speed
|
||||
int speed = currSkill->getTotalSpeed(&totalUpgrade);
|
||||
|
||||
if(changedActiveCommand) {
|
||||
if(changedActiveCommand == true) {
|
||||
if(changedActiveCommandFrame - lastChangedActiveCommandFrame >= MIN_FRAMECOUNT_CHANGE_COMMAND_SPEED) {
|
||||
//printf("Line: %d speed = %d changedActiveCommandFrame [%u] lastChangedActiveCommandFrame [%u] skill [%s] command [%s]\n",__LINE__,speed,changedActiveCommandFrame,lastChangedActiveCommandFrame,currSkill->toString(false).c_str(),getCurrCommand()->toString(false).c_str());
|
||||
//printf("Line: %d speed = %d changedActiveCommandFrame [%u] lastChangedActiveCommandFrame [%u] total = %u\n",__LINE__,speed,changedActiveCommandFrame,lastChangedActiveCommandFrame,(changedActiveCommandFrame - lastChangedActiveCommandFrame));
|
||||
speed = CHANGE_COMMAND_SPEED;
|
||||
}
|
||||
}
|
||||
|
||||
//speed modifier
|
||||
int64 diagonalFactor = getDiagonalFactor();
|
||||
|
@ -2532,8 +2551,12 @@ bool Unit::update() {
|
|||
int speed= currSkill->getTotalSpeed(&totalUpgrade);
|
||||
|
||||
if(changedActiveCommand) {
|
||||
if(changedActiveCommandFrame - lastChangedActiveCommandFrame >= MIN_FRAMECOUNT_CHANGE_COMMAND_SPEED) {
|
||||
//printf("Line: %d speed = %d changedActiveCommandFrame [%u] lastChangedActiveCommandFrame [%u] skill [%s] command [%s]\n",__LINE__,speed,changedActiveCommandFrame,lastChangedActiveCommandFrame,currSkill->toString(false).c_str(),getCurrCommand()->toString(false).c_str());
|
||||
//printf("Line: %d speed = %d changedActiveCommandFrame [%u] lastChangedActiveCommandFrame [%u] total = %u\n",__LINE__,speed,changedActiveCommandFrame,lastChangedActiveCommandFrame,(changedActiveCommandFrame - lastChangedActiveCommandFrame));
|
||||
speed = CHANGE_COMMAND_SPEED;
|
||||
}
|
||||
}
|
||||
|
||||
//speed modifier
|
||||
int64 diagonalFactor = getDiagonalFactor();
|
||||
|
|
|
@ -471,6 +471,8 @@ private:
|
|||
//static std::map<void *,bool> deletedUnits;
|
||||
|
||||
bool changedActiveCommand;
|
||||
uint32 lastChangedActiveCommandFrame;
|
||||
uint32 changedActiveCommandFrame;
|
||||
|
||||
int32 lastAttackerUnitId;
|
||||
int32 lastAttackedUnitId;
|
||||
|
|
|
@ -59,9 +59,27 @@ private:
|
|||
Vec2i lastPos;
|
||||
Vec2i pos;
|
||||
|
||||
void reset() {
|
||||
cellHeight = 0;
|
||||
currField = fLand;
|
||||
tileSetAirHeight = standardAirHeight;
|
||||
cellLandUnitHeight = 0;
|
||||
cellObjectHeight = 0;
|
||||
currSkill = scStop;
|
||||
curUnitTypeSize = 0;
|
||||
progress = 0;
|
||||
lastPos = Vec2i(0,0);
|
||||
pos = Vec2i(0,0);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
StreflopTest() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void test_warmup_cases() {
|
||||
int unitTypeHeight = 0;
|
||||
|
||||
cellHeight = 1.1;
|
||||
currField = fLand;
|
||||
|
@ -73,8 +91,7 @@ public:
|
|||
progress = 10;
|
||||
lastPos = Vec2i(1,1);
|
||||
pos = Vec2i(1,2);
|
||||
|
||||
int unitTypeHeight = 1;
|
||||
unitTypeHeight = 1;
|
||||
Vec3f result = getCurrVector(unitTypeHeight);
|
||||
CPPUNIT_ASSERT_EQUAL( string("x [1] y [1.6] z [1.0001]"), result.getString() );
|
||||
|
||||
|
@ -172,7 +189,6 @@ public:
|
|||
progress = 21250;
|
||||
lastPos = Vec2i(96,34);
|
||||
pos = Vec2i(95,35);
|
||||
|
||||
unitTypeHeight = 3;
|
||||
result = getCurrVector(unitTypeHeight);
|
||||
CPPUNIT_ASSERT_EQUAL( string("x [95] y [4.37037] z [35]"), result.getString() );
|
||||
|
@ -180,22 +196,23 @@ public:
|
|||
}
|
||||
|
||||
void test_known_out_of_synch_cases() {
|
||||
// Documented cases of out of synch go here to test cross platform for
|
||||
// consistency
|
||||
// int unitTypeHeight = 0;
|
||||
|
||||
// cellHeight = 2.870369;
|
||||
// cellHeight = 1.1;
|
||||
// currField = fLand;
|
||||
// tileSetAirHeight = standardAirHeight;
|
||||
// cellLandUnitHeight = 0;
|
||||
// cellLandUnitHeight = 1;
|
||||
// cellObjectHeight = 0;
|
||||
// currSkill = scAttack;
|
||||
// currSkill = scMove;
|
||||
// curUnitTypeSize = 1;
|
||||
// progress = 21250;
|
||||
// lastPos = Vec2i(96,34);
|
||||
// pos = Vec2i(95,35);
|
||||
//
|
||||
// int unitTypeHeight = 3;
|
||||
// progress = 10;
|
||||
// lastPos = Vec2i(1,1);
|
||||
// pos = Vec2i(1,2);
|
||||
// unitTypeHeight = 1;
|
||||
// Vec3f result = getCurrVector(unitTypeHeight);
|
||||
// CPPUNIT_ASSERT_EQUAL( string("x [95] y [4.37037] z [35]"), result.getString() );
|
||||
|
||||
// CPPUNIT_ASSERT_EQUAL( string("x [1] y [1.6] z [1.0001]"), result.getString() );
|
||||
}
|
||||
|
||||
// =========================== Helper Methods =================================
|
||||
|
|
Loading…
Reference in New Issue