Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10878


Ignore:
Timestamp:
Nov 27, 2015, 6:49:54 PM (9 years ago)
Author:
fvultier
Message:
 
Location:
code/branches/fabienHS15
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsAssff.oxi

    r10814 r10878  
    4545    </weaponpacks>
    4646    <munition>
    47       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     47      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=2 replenishinterval=7.5/>
    4848      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    4949      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsAssff2.oxi

    r10814 r10878  
    4343    </weaponpacks>
    4444    <munition>
    45       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     45      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    4646      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    4747      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsCollateral.oxi

    r10814 r10878  
    4747    </weaponpacks>
    4848    <munition>
    49       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     49      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    5050      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    5151      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsEscort.oxi

    r10791 r10878  
    2727    </weaponpacks>
    2828    <munition>
    29       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     29      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    3030    </munition>     
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsFPS.oxi

    r10791 r10878  
    5151    </weaponpacks>
    5252    <munition>
    53       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval=0.5/>
     53      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval=7.5/>
    5454      <LightningMunition initialmagazines=2 maxmagazines=2 munitionpermagazine=8 />
    5555    </munition>   
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsFPS_HS14.oxi

    r10791 r10878  
    5151    </weaponpacks>
    5252    <munition>
    53       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval=0.5/>
     53      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval=7.5/>
    5454      <LightningMunition initialmagazines=2 maxmagazines=2 munitionpermagazine=8 />
    5555    </munition>     
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsFS15.oxi

    r10814 r10878  
    5151</weaponpacks>
    5252<munition>
    53   <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     53  <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    5454  <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    5555  <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsGhost.oxi

    r10791 r10878  
    3737    </weaponpacks>
    3838    <munition>
    39       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     39      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    4040      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    4141      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsH2.oxi

    r10791 r10878  
    4444    </weaponpacks>
    4545    <munition>
    46       <LaserMunition initialmagazines=10 maxmagazines=10 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     46      <LaserMunition initialmagazines=10 maxmagazines=10 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    4747    </munition>
    4848
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsHXY.oxi

    r10791 r10878  
    2626    </weaponpacks>
    2727    <munition>
    28       <LaserMunition initialmagazines=10 maxmagazines=10 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     28      <LaserMunition initialmagazines=10 maxmagazines=10 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    2929      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    3030    </munition>
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsHeartAttack.oxi

    r10814 r10878  
    4242    </weaponpacks>
    4343    <munition>
    44       <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=0.25/>
     44      <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=6.0/>
    4545      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    4646      <RocketMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsHeavyCruiser.oxi

    r10814 r10878  
    4545    </weaponpacks>
    4646    <munition>
    47       <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=0.3/>
     47      <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=5.0/>
    4848      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    4949      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsHeavyCruiserBody.oxi

    r10814 r10878  
    4747    </weaponpacks>
    4848    <munition>
    49       <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=0.3/>
     49      <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.0/>
    5050      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    5151      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsImmTest.oxi

    r10814 r10878  
    5757    </weaponpacks>
    5858    <munition>
    59       <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=0.3/>
     59      <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.0/>
    6060      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    6161      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsPirate.oxi

    r10791 r10878  
    2424    </weaponpacks>
    2525    <munition>
    26       <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=0.3/>
     26      <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.0/>
    2727    </munition>
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsRing.oxi

    r10791 r10878  
    3030    </weaponpacks>
    3131    <munition>
    32       <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=0.3/>
     32      <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    3333      <GravityBombMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=1 />
    3434      <IceMunition initialmagazines=16 maxmagazines=16 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsSpacecruiser.oxi

    r10814 r10878  
    8989    </weaponpacks>
    9090    <munition>
    91       <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=0.2/>
     91      <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    9292      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    9393      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsSwallow.oxi

    r10791 r10878  
    2525    </weaponpacks>
    2626    <munition>
    27       <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     27      <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    2828      <SplitMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    2929    </munition>
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsTransporter.oxi

    r10791 r10878  
    2626    </weaponpacks>
    2727    <munition>
    28       <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     28      <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    2929      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    3030    </munition>
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsTurret.oxi

    r10791 r10878  
    2222    </weaponpacks>
    2323    <munition>
    24       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     24      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    2525    </munition>
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsTurret1.oxi

    r10791 r10878  
    2222    </weaponpacks>
    2323    <munition>
    24       <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
     24      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    2525    </munition>
  • code/branches/fabienHS15/data/levels/includes/weaponSettingsbigship.oxi

    r10814 r10878  
    4848    </weaponpacks>
    4949    <munition>
    50       <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=0.4/>
     50      <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
    5151      <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
    5252      <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDEnemyShieldBar.cc

    r10842 r10878  
    7171                target = target->getParent();
    7272            pawn = orxonox_cast<Pawn*>(target);
    73             // Don't show the HealthBar if the pawn is invisible
     73            // Don't show the EnemyShieldBar if the pawn is invisible
    7474            if (pawn && !pawn->isVisible())
    7575                pawn = NULL;
    7676        }
    77         // Set the pawn as owner of the HealthBar
     77        // Set the pawn as owner of the EnemyShieldBar
    7878        this->setShieldBarOwner(pawn);
    7979        this->setVisible(pawn != NULL);
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.cc

    r10795 r10878  
    160160                    ReplenishingMunition* replenishingMunition = dynamic_cast<ReplenishingMunition*>(munition);
    161161
    162                     if (replenishingMunition->canAddMunition(1))
     162                    if (replenishingMunition->canAddMagazines(1))
    163163                    {
    164164                        float progress = 1.0f - replenishingMunition->getProgress();
  • code/branches/fabienHS15/src/modules/weapons/munitions/FusionMunition.cc

    r10791 r10878  
    4646        this->maxMunitionPerMagazine_ = 10;
    4747        this->maxMagazines_ = 10;
    48         this->magazines_ = 10;
     48        this->unassignedMagazines_ = 10;
    4949
    5050        this->deployment_ = MunitionDeployment::Separate;
  • code/branches/fabienHS15/src/modules/weapons/munitions/GravityBombMunition.cc

    r10791 r10878  
    1818        this->maxMunitionPerMagazine_ = 1;
    1919        this->maxMagazines_ = 30;
    20         this->magazines_ = 15;
     20        this->unassignedMagazines_ = 15;
    2121
    2222        this->deployment_ = MunitionDeployment::Stack;
  • code/branches/fabienHS15/src/modules/weapons/munitions/IceMunition.cc

    r10791 r10878  
    4646        this->maxMunitionPerMagazine_ = 1;
    4747        this->maxMagazines_ = 50;
    48         this->magazines_ = 25;
     48        this->unassignedMagazines_ = 25;
    4949
    5050        this->deployment_ = MunitionDeployment::Stack;
  • code/branches/fabienHS15/src/modules/weapons/munitions/LaserMunition.cc

    r10791 r10878  
    4646        this->maxMunitionPerMagazine_ = 20;
    4747        this->maxMagazines_ = 10;
    48         this->magazines_ = 10;
     48        this->unassignedMagazines_ = 10;
    4949
    5050        this->deployment_ = MunitionDeployment::Separate;
     
    5353        this->bAllowMultiMunitionRemovementUnderflow_ = true;
    5454
    55         this->replenishInterval_ = 0.5f;
     55        this->replenishInterval_ = 7.0f;
    5656        this->replenishAmount_ = 1;
    5757
  • code/branches/fabienHS15/src/modules/weapons/munitions/LightningMunition.cc

    r10791 r10878  
    4646        this->maxMunitionPerMagazine_ = 20;
    4747        this->maxMagazines_ = 1;
    48         this->magazines_ = 1;
     48        this->unassignedMagazines_ = 1;
    4949
    5050        this->deployment_ = MunitionDeployment::Share;
  • code/branches/fabienHS15/src/modules/weapons/munitions/RocketMunition.cc

    r10791 r10878  
    4646        this->maxMunitionPerMagazine_ = 1;
    4747        this->maxMagazines_ = 30;
    48         this->magazines_ = 10;
     48        this->unassignedMagazines_ = 10;
    4949
    5050        this->deployment_ = MunitionDeployment::Stack;
  • code/branches/fabienHS15/src/modules/weapons/munitions/SplitMunition.cc

    r10791 r10878  
    4646        this->maxMunitionPerMagazine_ = 5;
    4747        this->maxMagazines_ = 10;
    48         this->magazines_ = 5;
     48        this->unassignedMagazines_ = 5;
    4949
    5050        this->deployment_ = MunitionDeployment::Share;
  • code/branches/fabienHS15/src/orxonox/controllers/HumanController.cc

    r10624 r10878  
    199199    @brief
    200200        Starts the boosting mode.
    201         Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore).
     201        Resets the boosting timeout and tells the ControllableEntity to boost (or not boost anymore).
    202202    */
    203203    void HumanController::startBoosting(void)
  • code/branches/fabienHS15/src/orxonox/weaponsystem/Munition.cc

    r10791 r10878  
    4444        this->maxMunitionPerMagazine_ = 10;
    4545        this->maxMagazines_ = 10;
    46         this->magazines_ = 10;
     46        this->unassignedMagazines_ = 10;
    4747
    4848        this->deployment_ = MunitionDeployment::Stack;
     
    5757    Munition::~Munition()
    5858    {
    59         for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
     59        for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
    6060            delete it->second;
    6161    }
     
    7979
    8080            // Use the map to get the magazine assigned to the given user
    81             std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.find(user);
    82             if (it != this->currentMagazines_.end())
     81            std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.find(user);
     82            if (it != this->assignedMagazines_.end())
    8383                return it->second;
    8484        }
     
    8686        {
    8787            // We don't use separate magazines for each user, so just take the first magazine
    88             if (this->currentMagazines_.size() > 0)
    89                 return this->currentMagazines_.begin()->second;
     88            if (this->assignedMagazines_.size() > 0)
     89                return this->assignedMagazines_.begin()->second;
    9090        }
    9191
     
    100100            if (deployment_ == MunitionDeployment::Stack)
    101101                // With stacked munition every magazine contributes to the total amount
    102                 return this->maxMunitionPerMagazine_ * this->magazines_ + magazine->munition_;
     102                return this->maxMunitionPerMagazine_ * this->unassignedMagazines_ + magazine->munition_;
    103103            else
    104104                // Wihtout stacked munition we just consider the current magazine
     
    125125            Magazine* magazine = this->getMagazine(0);
    126126            if (magazine && magazine->munition_ == this->maxMunitionPerMagazine_)
    127                 return this->magazines_ + 1;
    128         }
    129 
    130         return this->magazines_;
     127                return this->unassignedMagazines_ + 1;
     128        }
     129
     130        return this->unassignedMagazines_;
    131131    }
    132132
    133133    void Munition::setNumMagazines(unsigned int numMagazines)
    134134    {
    135         this->magazines_ = numMagazines;
     135        this->unassignedMagazines_ = numMagazines;
    136136    }
    137137
     
    154154            if (deployment_ == MunitionDeployment::Stack)
    155155            {
    156                 munition += this->maxMunitionPerMagazine_ * this->magazines_;
     156                munition += this->maxMunitionPerMagazine_ * this->unassignedMagazines_;
    157157            }
    158158
     
    200200                    magazine->munition_ = 0;
    201201
    202                     if (this->reload(0))
     202                    if (this->reload(NULL))
    203203                        // Successfully reloaded, continue recursively
    204204                        return this->takeMunition(amount, 0);
     
    224224    {
    225225        // As long as we have enough magazines (and don't stack munition) we can reload
    226         return (this->magazines_ > 0 && deployment_ != MunitionDeployment::Stack);
     226        return (this->unassignedMagazines_ > 0 && deployment_ != MunitionDeployment::Stack);
    227227    }
    228228
     
    252252
    253253        // Check if we actually can reload
    254         if (this->magazines_ == 0)
     254        if (this->unassignedMagazines_ == 0)
    255255            return false;
    256256
     
    266266
    267267        // Remove the current magazine for the given user
    268         std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.find(user);
    269         if (it != this->currentMagazines_.end())
     268        std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.find(user);
     269        if (it != this->assignedMagazines_.end())
    270270        {
    271271            if (it->first == lastFilledWeaponMode_)
     
    274274            }           
    275275            delete it->second;
    276             this->currentMagazines_.erase(it);
     276            this->assignedMagazines_.erase(it);
    277277        }
    278278
    279279        // Load a new magazine
    280         this->currentMagazines_[user] = new Magazine(this, bUseReloadTime);
    281         this->magazines_--;
     280        this->assignedMagazines_[user] = new Magazine(this, bUseReloadTime);
     281        this->unassignedMagazines_--;
    282282
    283283        return true;
     
    299299        {
    300300            // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition)
    301             for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
     301            for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
    302302                if (it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
    303303                    return true;
     
    325325                {
    326326                    magazine->munition_ -= this->maxMunitionPerMagazine_;
    327                     this->magazines_++;
     327                    this->unassignedMagazines_++;
    328328                }
    329329
    330330                // If we reached the limit, reduce both magazines and munition to the maximum
    331                 if (this->magazines_ >= this->maxMagazines_)
    332                 {
    333                     this->magazines_ = this->maxMagazines_;
     331                if (this->unassignedMagazines_ >= this->maxMagazines_)
     332                {
     333                    this->unassignedMagazines_ = this->maxMagazines_;
    334334                    magazine->munition_ = this->maxMunitionPerMagazine_;
    335335                }
     
    349349            if (lastFilledWeaponMode_ == NULL)
    350350            {
    351                 it = this->currentMagazines_.begin();
     351                it = this->assignedMagazines_.begin();
    352352            }
    353353            else
    354354            {
    355                 it = this->currentMagazines_.find(lastFilledWeaponMode_);
     355                it = this->assignedMagazines_.find(lastFilledWeaponMode_);
    356356                ++ it;
    357357            }
     
    362362            {
    363363                bool change = false;
    364                 while (it != this->currentMagazines_.end())
     364                while (it != this->assignedMagazines_.end())
    365365                {
    366366                    // Add munition if the magazine isn't full (but only to loaded magazines)
     
    383383                }                   
    384384
    385                 it = this->currentMagazines_.begin();
     385                it = this->assignedMagazines_.begin();
    386386                firstLoop = false;
    387387            }
     
    400400        else
    401401            // If we don't stack munition, we're more limited
    402             return ((this->currentMagazines_.size() + this->magazines_) < this->maxMagazines_);
    403     }
    404 
    405     bool Munition::addMagazines(unsigned int amount)
    406     {
     402            return ((this->assignedMagazines_.size() + this->unassignedMagazines_) < this->maxMagazines_);
     403    }
     404
     405    unsigned int Munition::addMagazines(unsigned int amount)
     406    {
     407        unsigned int addedMagazines = 0;
     408
    407409        if (!this->canAddMagazines(amount))
    408             return false;
     410            return 0;
    409411
    410412        // Calculate how many magazines are needed
    411         int needed_magazines = this->maxMagazines_ - this->magazines_ - this->currentMagazines_.size();
     413        int needed_magazines = this->maxMagazines_ - this->unassignedMagazines_ - this->assignedMagazines_.size();
    412414
    413415        // If zero or less magazines are needed, we definitively don't need more magazines (unless we stack munition - then a magazine contributes directly to the munition)
    414416        if (needed_magazines <= 0 && deployment_ != MunitionDeployment::Stack)
    415             return false;
     417            return 0;
    416418
    417419        if (amount <= static_cast<unsigned int>(needed_magazines))
    418420        {
    419421            // We need more magazines than we get, so just add them
    420             this->magazines_ += amount;
     422            this->unassignedMagazines_ += amount;
     423            addedMagazines = amount;
    421424        }
    422425        else
    423426        {
    424427            // We get more magazines than we need, so just add the needed amount
    425             this->magazines_ += needed_magazines;
     428            this->unassignedMagazines_ += needed_magazines;
     429            addedMagazines = needed_magazines;
    426430            if (deployment_ == MunitionDeployment::Stack)
    427431            {
     
    433437        }
    434438
    435         return true;
     439        // Reload as many empty magazines as possible
     440        // Double loop and break is needed because the reload function changes the assigned magazines. This may confuse the iterator.
     441        for (unsigned int i = 0; i < addedMagazines; ++i)
     442        {
     443            for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
     444            {
     445                if (needReload(it->first))
     446                {
     447                    reload(it->first);
     448                    break;
     449                }
     450            }
     451        }
     452
     453        return addedMagazines;
    436454    }
    437455
     
    440458        if (deployment_ == MunitionDeployment::Stack)
    441459        {
    442             if (this->magazines_ >= amount)
     460            if (this->unassignedMagazines_ >= amount)
    443461            {
    444462                // We have enough magazines
    445463                return true;
    446464            }
    447             else if (this->magazines_ == amount - 1)
     465            else if (this->unassignedMagazines_ == amount - 1)
    448466            {
    449467                // We lack one magazine, check if the current magazine is still full, if yes we're fine
     
    461479        {
    462480            // In case we're not stacking munition, just check the number of magazines
    463             return (this->magazines_ >= amount);
     481            return (this->unassignedMagazines_ >= amount);
    464482        }
    465483
     
    472490            return false;
    473491
    474         if (this->magazines_ >= amount)
     492        if (this->unassignedMagazines_ >= amount)
    475493        {
    476494            // We have enough magazines, just remove the amount
    477             this->magazines_ -= amount;
     495            this->unassignedMagazines_ -= amount;
    478496        }
    479497        else if (deployment_ == MunitionDeployment::Stack)
    480498        {
    481499            // We don't have enough magazines, but we're stacking munition, so additionally remove the bullets from the current magazine
    482             this->magazines_ = 0;
     500            this->unassignedMagazines_ = 0;
    483501            Magazine* magazine = this->getMagazine(0);
    484502            if (magazine)
     
    500518
    501519        // Remove the current magazine for the given user
    502         std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.find(user);
    503         if (it != this->currentMagazines_.end())
     520        std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.find(user);
     521        if (it != this->assignedMagazines_.end())
    504522        {
    505523            if (it->first == lastFilledWeaponMode_)
     
    508526            }
    509527            delete it->second;
    510             this->currentMagazines_.erase(it);           
     528            this->assignedMagazines_.erase(it);           
    511529            return true;
    512530        }
  • code/branches/fabienHS15/src/orxonox/weaponsystem/Munition.h

    r10794 r10878  
    9797
    9898            bool canAddMagazines(unsigned int amount) const;
    99             bool addMagazines(unsigned int amount);
     99            /**
     100            @brief Try to add magazines.
     101            @param amount The amount of magazines tried to add.
     102            @return The amount of magazines sucessfully added.
     103            */
     104            unsigned int addMagazines(unsigned int amount);
    100105
    101106            bool canRemoveMagazines(unsigned int amount) const;
     
    107112            unsigned int maxMunitionPerMagazine_;
    108113            unsigned int maxMagazines_;
    109             unsigned int magazines_;
    110             std::map<WeaponMode*, Magazine*> currentMagazines_; // Maps weapon modes to magazines that are currently used.
     114            unsigned int unassignedMagazines_; // Number of magazines that are not assigned to a weapon mode. These are alway treated as full.
     115            std::map<WeaponMode*, Magazine*> assignedMagazines_; // Maps weapon modes to magazines that are currently used.
    111116
    112117            MunitionDeployment::Value deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.
     
    115120            bool bAllowMultiMunitionRemovementUnderflow_;
    116121
    117             float reloadTime_;
     122            float reloadTime_; // The time needed to replace a magazine by a new one.
    118123            WeaponMode* lastFilledWeaponMode_; // Pointer to the weapon mode that got the last munition during the last call of addMunition.
    119124
  • code/branches/fabienHS15/src/orxonox/weaponsystem/ReplenishingMunition.cc

    r10791 r10878  
    7676    void ReplenishingMunition::replenish()
    7777    {
    78         if (this->canAddMunition(this->replenishAmount_))
     78        if (this->canAddMagazines(this->replenishAmount_))
    7979        {
    8080            // Make a temporary copy of bAllowMunitionRefilling_, because this might be disallowed in every
     
    8484
    8585            // Replenish munition
    86             this->addMunition(this->replenishAmount_);
     86            this->addMagazines(this->replenishAmount_);
    8787
    8888            // Write back the temporary value
  • code/branches/fabienHS15/src/orxonox/weaponsystem/ReplenishingMunition.h

    r10791 r10878  
    6464        protected:                         
    6565            float replenishInterval_; //!< The interval in which the munition is replenished.
    66             unsigned int replenishAmount_; //!< The amount by which it is replenished.
     66            unsigned int replenishAmount_; //!< The amount of magazines by which it is replenished.
    6767
    6868        private:
    69             void replenish();
     69            void replenish(); //!< Every call of this function replenishes the munition. This function is called by the timer.
    7070            void initializeTimer();
    7171
Note: See TracChangeset for help on using the changeset viewer.