- 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{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
const int CHANGE_COMMAND_SPEED = 325;
|
const int CHANGE_COMMAND_SPEED = 325;
|
||||||
|
const int MIN_FRAMECOUNT_CHANGE_COMMAND_SPEED = 160;
|
||||||
|
|
||||||
//Mutex Unit::mutexDeletedUnits;
|
//Mutex Unit::mutexDeletedUnits;
|
||||||
//map<void *,bool> Unit::deletedUnits;
|
//map<void *,bool> Unit::deletedUnits;
|
||||||
|
@ -515,6 +516,9 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
|
||||||
|
|
||||||
mutexCommands = new Mutex(CODE_AT_LINE);
|
mutexCommands = new Mutex(CODE_AT_LINE);
|
||||||
changedActiveCommand = false;
|
changedActiveCommand = false;
|
||||||
|
lastChangedActiveCommandFrame = 0;
|
||||||
|
changedActiveCommandFrame = 0;
|
||||||
|
|
||||||
lastSynchDataString="";
|
lastSynchDataString="";
|
||||||
modelFacing = CardinalDir::NORTH;
|
modelFacing = CardinalDir::NORTH;
|
||||||
lastStuckFrame = 0;
|
lastStuckFrame = 0;
|
||||||
|
@ -1783,26 +1787,37 @@ std::pair<CommandResult,string> Unit::giveCommand(Command *command, bool tryQueu
|
||||||
//empty command queue
|
//empty command queue
|
||||||
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__);
|
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);
|
bool willChangedActiveCommand = (commands.empty() == false);
|
||||||
if(willChangedActiveCommand){
|
if(willChangedActiveCommand == true) {
|
||||||
CommandClass currCommandClass=getCurrCommand()->getCommandType()->getClass();
|
|
||||||
CommandClass commandClass=command->getCommandType()->getClass();
|
CommandClass currCommandClass = getCurrCommand()->getCommandType()->getClass();
|
||||||
if(currCommandClass
|
CommandClass commandClass = command->getCommandType()->getClass();
|
||||||
== commandClass){
|
if(currCommandClass == commandClass) {
|
||||||
willChangedActiveCommand= false;
|
|
||||||
|
willChangedActiveCommand = false;
|
||||||
}
|
}
|
||||||
else if(currCommandClass==ccAttack || currCommandClass==ccAttackStopped ||
|
else if(currCommandClass == ccAttack ||
|
||||||
commandClass==ccAttack || commandClass==ccAttackStopped){
|
currCommandClass == ccAttackStopped ||
|
||||||
|
commandClass == ccAttack ||
|
||||||
|
commandClass == ccAttackStopped) {
|
||||||
|
|
||||||
willChangedActiveCommand= true;
|
willChangedActiveCommand= true;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
willChangedActiveCommand= false;
|
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();
|
clearCommands();
|
||||||
changedActiveCommand= willChangedActiveCommand;
|
changedActiveCommand = willChangedActiveCommand;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//printf("In [%s::%s] Line: %d cleared existing commands\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line: %d cleared existing commands\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -2153,9 +2168,13 @@ int64 Unit::getUpdateProgress() {
|
||||||
//speed
|
//speed
|
||||||
int speed = currSkill->getTotalSpeed(&totalUpgrade);
|
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 = CHANGE_COMMAND_SPEED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//speed modifier
|
//speed modifier
|
||||||
int64 diagonalFactor = getDiagonalFactor();
|
int64 diagonalFactor = getDiagonalFactor();
|
||||||
|
@ -2532,8 +2551,12 @@ bool Unit::update() {
|
||||||
int speed= currSkill->getTotalSpeed(&totalUpgrade);
|
int speed= currSkill->getTotalSpeed(&totalUpgrade);
|
||||||
|
|
||||||
if(changedActiveCommand) {
|
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 = CHANGE_COMMAND_SPEED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//speed modifier
|
//speed modifier
|
||||||
int64 diagonalFactor = getDiagonalFactor();
|
int64 diagonalFactor = getDiagonalFactor();
|
||||||
|
|
|
@ -471,6 +471,8 @@ private:
|
||||||
//static std::map<void *,bool> deletedUnits;
|
//static std::map<void *,bool> deletedUnits;
|
||||||
|
|
||||||
bool changedActiveCommand;
|
bool changedActiveCommand;
|
||||||
|
uint32 lastChangedActiveCommandFrame;
|
||||||
|
uint32 changedActiveCommandFrame;
|
||||||
|
|
||||||
int32 lastAttackerUnitId;
|
int32 lastAttackerUnitId;
|
||||||
int32 lastAttackedUnitId;
|
int32 lastAttackedUnitId;
|
||||||
|
|
|
@ -59,9 +59,27 @@ private:
|
||||||
Vec2i lastPos;
|
Vec2i lastPos;
|
||||||
Vec2i pos;
|
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:
|
public:
|
||||||
|
|
||||||
|
StreflopTest() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
void test_warmup_cases() {
|
void test_warmup_cases() {
|
||||||
|
int unitTypeHeight = 0;
|
||||||
|
|
||||||
cellHeight = 1.1;
|
cellHeight = 1.1;
|
||||||
currField = fLand;
|
currField = fLand;
|
||||||
|
@ -73,8 +91,7 @@ public:
|
||||||
progress = 10;
|
progress = 10;
|
||||||
lastPos = Vec2i(1,1);
|
lastPos = Vec2i(1,1);
|
||||||
pos = Vec2i(1,2);
|
pos = Vec2i(1,2);
|
||||||
|
unitTypeHeight = 1;
|
||||||
int unitTypeHeight = 1;
|
|
||||||
Vec3f result = getCurrVector(unitTypeHeight);
|
Vec3f result = getCurrVector(unitTypeHeight);
|
||||||
CPPUNIT_ASSERT_EQUAL( string("x [1] y [1.6] z [1.0001]"), result.getString() );
|
CPPUNIT_ASSERT_EQUAL( string("x [1] y [1.6] z [1.0001]"), result.getString() );
|
||||||
|
|
||||||
|
@ -172,7 +189,6 @@ public:
|
||||||
progress = 21250;
|
progress = 21250;
|
||||||
lastPos = Vec2i(96,34);
|
lastPos = Vec2i(96,34);
|
||||||
pos = Vec2i(95,35);
|
pos = Vec2i(95,35);
|
||||||
|
|
||||||
unitTypeHeight = 3;
|
unitTypeHeight = 3;
|
||||||
result = getCurrVector(unitTypeHeight);
|
result = getCurrVector(unitTypeHeight);
|
||||||
CPPUNIT_ASSERT_EQUAL( string("x [95] y [4.37037] z [35]"), result.getString() );
|
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() {
|
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;
|
// currField = fLand;
|
||||||
// tileSetAirHeight = standardAirHeight;
|
// tileSetAirHeight = standardAirHeight;
|
||||||
// cellLandUnitHeight = 0;
|
// cellLandUnitHeight = 1;
|
||||||
// cellObjectHeight = 0;
|
// cellObjectHeight = 0;
|
||||||
// currSkill = scAttack;
|
// currSkill = scMove;
|
||||||
// curUnitTypeSize = 1;
|
// curUnitTypeSize = 1;
|
||||||
// progress = 21250;
|
// progress = 10;
|
||||||
// lastPos = Vec2i(96,34);
|
// lastPos = Vec2i(1,1);
|
||||||
// pos = Vec2i(95,35);
|
// pos = Vec2i(1,2);
|
||||||
//
|
// unitTypeHeight = 1;
|
||||||
// int unitTypeHeight = 3;
|
|
||||||
// Vec3f result = getCurrVector(unitTypeHeight);
|
// 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 =================================
|
// =========================== Helper Methods =================================
|
||||||
|
|
Loading…
Reference in New Issue