mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 04:02:30 +01:00
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;
|
||||
|
||||
// Check if the command was for the unit before it morphed, if so cancel it
|
||||
bool isCancelPreMorphCommand = false;
|
||||
if(ct == NULL && unit->getPreMorphType() != NULL) {
|
||||
const CommandType *ctPreMorph = unit->getPreMorphType()->findCommandTypeById(networkCommand->getCommandTypeId());
|
||||
if(ctPreMorph != NULL) {
|
||||
ct = unit->getType()->getFirstCtOfClass(ccStop);
|
||||
isCancelPreMorphCommand = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1111,6 +1113,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
||||
|
||||
CardinalDir facing;
|
||||
// get facing/target ... the target might be dead due to lag, cope with it
|
||||
if(isCancelPreMorphCommand == false) {
|
||||
if(ct->getClass() == ccBuild) {
|
||||
//assert(networkCommand->getTargetId() >= 0 && networkCommand->getTargetId() < 4);
|
||||
if(networkCommand->getTargetId() < 0 || networkCommand->getTargetId() >= 4) {
|
||||
@ -1123,9 +1126,11 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
||||
else if (networkCommand->getTargetId() != Unit::invalidId ) {
|
||||
target= world->findUnitById(networkCommand->getTargetId());
|
||||
}
|
||||
}
|
||||
|
||||
//create command
|
||||
Command *command= NULL;
|
||||
if(isCancelPreMorphCommand == false) {
|
||||
if(unitType != NULL) {
|
||||
command= new Command(ct, networkCommand->getPosition(), unitType, facing);
|
||||
}
|
||||
@ -1135,6 +1140,10 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
||||
else {
|
||||
command= new Command(ct, target);
|
||||
}
|
||||
}
|
||||
else {
|
||||
command= new Command(ct, NULL);
|
||||
}
|
||||
|
||||
// Add in any special state
|
||||
CommandStateType commandStateType = networkCommand->getCommandStateType();
|
||||
|
Loading…
x
Reference in New Issue
Block a user