attempt to fix weird morph bug found by Elimnator
This commit is contained in:
parent
7c98c35d67
commit
cef0ce9978
|
@ -1078,10 +1078,12 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
||||||
//ct = NULL;
|
//ct = NULL;
|
||||||
|
|
||||||
// Check if the command was for the unit before it morphed, if so cancel it
|
// Check if the command was for the unit before it morphed, if so cancel it
|
||||||
|
bool isCancelPreMorphCommand = false;
|
||||||
if(ct == NULL && unit->getPreMorphType() != NULL) {
|
if(ct == NULL && unit->getPreMorphType() != NULL) {
|
||||||
const CommandType *ctPreMorph = unit->getPreMorphType()->findCommandTypeById(networkCommand->getCommandTypeId());
|
const CommandType *ctPreMorph = unit->getPreMorphType()->findCommandTypeById(networkCommand->getCommandTypeId());
|
||||||
if(ctPreMorph != NULL) {
|
if(ctPreMorph != NULL) {
|
||||||
ct = unit->getType()->getFirstCtOfClass(ccStop);
|
ct = unit->getType()->getFirstCtOfClass(ccStop);
|
||||||
|
isCancelPreMorphCommand = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,29 +1113,36 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
||||||
|
|
||||||
CardinalDir facing;
|
CardinalDir facing;
|
||||||
// get facing/target ... the target might be dead due to lag, cope with it
|
// get facing/target ... the target might be dead due to lag, cope with it
|
||||||
if (ct->getClass() == ccBuild) {
|
if(isCancelPreMorphCommand == false) {
|
||||||
//assert(networkCommand->getTargetId() >= 0 && networkCommand->getTargetId() < 4);
|
if(ct->getClass() == ccBuild) {
|
||||||
if(networkCommand->getTargetId() < 0 || networkCommand->getTargetId() >= 4) {
|
//assert(networkCommand->getTargetId() >= 0 && networkCommand->getTargetId() < 4);
|
||||||
char szBuf[8096]="";
|
if(networkCommand->getTargetId() < 0 || networkCommand->getTargetId() >= 4) {
|
||||||
snprintf(szBuf,8096,"networkCommand->getTargetId() >= 0 && networkCommand->getTargetId() < 4, [%s]",networkCommand->toString().c_str());
|
char szBuf[8096]="";
|
||||||
throw megaglest_runtime_error(szBuf);
|
snprintf(szBuf,8096,"networkCommand->getTargetId() >= 0 && networkCommand->getTargetId() < 4, [%s]",networkCommand->toString().c_str());
|
||||||
|
throw megaglest_runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
facing = CardinalDir(networkCommand->getTargetId());
|
||||||
|
}
|
||||||
|
else if (networkCommand->getTargetId() != Unit::invalidId ) {
|
||||||
|
target= world->findUnitById(networkCommand->getTargetId());
|
||||||
}
|
}
|
||||||
facing = CardinalDir(networkCommand->getTargetId());
|
|
||||||
}
|
|
||||||
else if (networkCommand->getTargetId() != Unit::invalidId ) {
|
|
||||||
target= world->findUnitById(networkCommand->getTargetId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//create command
|
//create command
|
||||||
Command *command= NULL;
|
Command *command= NULL;
|
||||||
if(unitType != NULL) {
|
if(isCancelPreMorphCommand == false) {
|
||||||
command= new Command(ct, networkCommand->getPosition(), unitType, facing);
|
if(unitType != NULL) {
|
||||||
}
|
command= new Command(ct, networkCommand->getPosition(), unitType, facing);
|
||||||
else if(target == NULL) {
|
}
|
||||||
command= new Command(ct, networkCommand->getPosition());
|
else if(target == NULL) {
|
||||||
|
command= new Command(ct, networkCommand->getPosition());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
command= new Command(ct, target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
command= new Command(ct, target);
|
command= new Command(ct, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add in any special state
|
// Add in any special state
|
||||||
|
|
Loading…
Reference in New Issue