dansk language; fix for fog of war off; command queuing works a bit better ( especially when attacking );

This commit is contained in:
Titus Tscharntke 2010-12-23 10:44:11 +00:00
parent 8b0b6300ed
commit cfba817280
9 changed files with 59 additions and 33 deletions

View File

@ -950,7 +950,9 @@ void MenuStateConnectedGame::update() {
listBoxFogOfWar.setSelectedItemIndex(2);
}
if((gameSettings->getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources){
listBoxFogOfWar.setSelectedItemIndex(1);
if(gameSettings->getFogOfWar() == true){
listBoxFogOfWar.setSelectedItemIndex(1);
}
}
// Allow Observers

View File

@ -1984,7 +1984,8 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
gameSettings->setAllowObservers(listBoxAllowObservers.getSelectedItemIndex() == 1);
uint32 valueFlags1 = gameSettings->getFlagTypes1();
if(listBoxFogOfWar.getSelectedItemIndex() == 1) {
if(listBoxFogOfWar.getSelectedItemIndex() == 1 ||
listBoxFogOfWar.getSelectedItemIndex() == 2 ) {
valueFlags1 |= ft1_show_map_resources;
gameSettings->setFlagTypes1(valueFlags1);
}
@ -2265,7 +2266,9 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
listBoxFogOfWar.setSelectedItemIndex(2);
}
if((gameSettings.getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources){
listBoxFogOfWar.setSelectedItemIndex(1);
if(gameSettings.getFogOfWar() == true){
listBoxFogOfWar.setSelectedItemIndex(1);
}
}
listBoxAllowObservers.setSelectedItem(gameSettings.getAllowObservers() == true ? lang.get("Yes") : lang.get("No"));

View File

@ -30,6 +30,7 @@ Command::Command(const CommandType *ct, const Vec2i &pos){
this->commandType= ct;
this->pos= pos;
this->unitRef= NULL;
unitType= NULL;
stateType = cst_None;
stateValue = -1;
@ -51,6 +52,7 @@ Command::Command(const CommandType *ct, Unit* unit){
Command::Command(const CommandType *ct, const Vec2i &pos, const UnitType *unitType, CardinalDir facing){
this->commandType= ct;
this->pos= pos;
this->unitRef= NULL;
this->unitType= unitType;
this->facing = facing;
stateType = cst_None;
@ -61,6 +63,12 @@ Command::Command(const CommandType *ct, const Vec2i &pos, const UnitType *unitTy
}
}
int Command::getPriority(){
if(this->commandType->commandTypeClass==ccAttack && getUnit()==NULL){
return 5; // attacks to the ground have low priority
}
return this->commandType->getTypePriority();
}
// =============== set ===============
void Command::setCommandType(const CommandType *commandType){

View File

@ -59,7 +59,10 @@ public:
Unit* getUnit() const {return unitRef.getUnit();}
const UnitType* getUnitType() const {return unitType;}
CardinalDir getFacing() const {return facing;}
//Priority: commands of higher priority will cancel commands of lower priority
virtual int getPriority();
//set
void setCommandType(const CommandType *commandType);
void setPos(const Vec2i &pos);

View File

@ -738,11 +738,6 @@ int Unit::getCountOfProducedUnits(const UnitType *ut) const{
return count;
}
#define deleteSingleCommand(command) {\
undoCommand(command);\
delete command;\
}
//give one command (clear, and push back)
CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
@ -761,18 +756,18 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
const int command_priority = command->getCommandType()->getPriority();
const int command_priority = command->getPriority();
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if(command->getCommandType()->isQueuable(tryQueue) && (commands.empty() || (command_priority >= commands.back()->getCommandType()->getPriority()))){
if(command->getCommandType()->isQueuable(tryQueue)){
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//Delete all lower-prioirty commands
for (list<Command*>::iterator i = commands.begin(); i != commands.end();) {
if ((*i)->getCommandType()->getPriority() < command_priority) {
deleteSingleCommand(*i);
if ((*i)->getPriority() < command_priority) {
deleteQueuedCommand(*i);
i = commands.erase(i);
}
else {
@ -797,7 +792,6 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
//empty command queue
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
clearCommands();
this->unitPath->clear();
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
}
@ -1424,6 +1418,7 @@ void Unit::updateTarget(){
void Unit::clearCommands() {
this->setCurrentUnitTitle("");
this->unitPath->clear();
while(!commands.empty()){
undoCommand(commands.back());
delete commands.back();
@ -1431,6 +1426,17 @@ void Unit::clearCommands() {
}
}
void Unit::deleteQueuedCommand(Command *command) {
if(getCurrCommand()==command)
{
this->setCurrentUnitTitle("");
this->unitPath->clear();
}
undoCommand(command);
delete command;
}
CommandResult Unit::checkCommand(Command *command) const {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -474,6 +474,7 @@ private:
float computeHeight(const Vec2i &pos) const;
void updateTarget();
void clearCommands();
void deleteQueuedCommand(Command *command);
CommandResult undoCommand(Command *command);
void stopDamageParticles();
void startDamageParticles();

View File

@ -95,7 +95,7 @@ public:
return (q != qNever) && (q != qOnlyLast);
}
//Priority: commands of higher priority will cancel commands of lower priority
virtual int getPriority() const {return 0;}
virtual int getTypePriority() const {return 10;}
//get
CommandClass getClass() const;
@ -118,7 +118,7 @@ public:
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
virtual string toString() const;
virtual Queueability isQueuable() const {return qNever;}
virtual int getPriority() const {return 100000;}
virtual int getTypePriority() const {return 100000;}
//get
const StopSkillType *getStopSkillType() const {return stopSkillType;};
};
@ -300,7 +300,6 @@ public:
virtual string toString() const;
virtual const ProducibleType *getProduced() const;
virtual Queueability isQueuable() const {return qAlways;}
virtual int getPriority() const {return 5;} //higher priority to cancel attack
//get
const ProduceSkillType *getProduceSkillType() const {return produceSkillType;}
@ -326,7 +325,6 @@ public:
virtual string getReqDesc() const;
virtual const ProducibleType *getProduced() const;
virtual Queueability isQueuable() const {return qAlways;}
virtual int getPriority() const {return 5;} //higher priority to cancel attack (and same as Build)
//get
const UpgradeSkillType *getUpgradeSkillType() const {return upgradeSkillType;}

View File

@ -346,6 +346,12 @@ void UnitUpdater::updateAttack(Unit *unit) {
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if( (command->getUnit()==NULL || !(command->getUnit()->isAlive()) ) && unit->getCommandSize()>1)
{
unit->finishCommand(); // all queued "ground attacks" are skipped if somthing else is queued after them.
return;
}
//if found
if(attackableOnRange(unit, &target, act->getAttackSkillType())) {
if(unit->getEp()>=act->getAttackSkillType()->getEpCost()) {
@ -361,6 +367,7 @@ void UnitUpdater::updateAttack(Unit *unit) {
else {
//compute target pos
Vec2i pos;
Command *nextCommand;
if(command->getUnit()!=NULL) {
pos= command->getUnit()->getCenteredPos();
}
@ -400,22 +407,21 @@ void UnitUpdater::updateAttack(Unit *unit) {
unit->finishCommand();
}
else {
//if unit arrives destPos order has ended
switch (tsValue){
case tsMoving:
unit->setCurrSkill(act->getMoveSkillType());
break;
case tsBlocked:
if(unit->getPath()->isBlocked()){
//if unit arrives destPos order has ended
switch (tsValue){
case tsMoving:
unit->setCurrSkill(act->getMoveSkillType());
break;
case tsBlocked:
if(unit->getPath()->isBlocked()){
unit->finishCommand();
}
break;
default:
unit->finishCommand();
}
break;
default:
unit->finishCommand();
}
}
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
}
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -1795,7 +1801,7 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
float currentDistance;
float nearestDistance;
for(int i = attackWarnings.size()-1; i>-1; --i) {
if(world->getFrameCount()-attackWarnings[i]->lastFrameCount>100) { //after 100 frames attack break we warn again
if(world->getFrameCount()-attackWarnings[i]->lastFrameCount>200) { //after 200 frames attack break we warn again
AttackWarningData *toDelete=attackWarnings[i];
attackWarnings.erase(attackWarnings.begin()+i);
delete toDelete; // old one

View File

@ -64,7 +64,6 @@ void WaterEffects::addWaterSplash(const Vec2f &pos, int size){
}
}
waterSplashes.push_back(WaterSplash(pos,size));
printf("count of watereffects=%d\n",getWaterSplashCount());
}
}}//end namespace