Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2014, 3:10:42 PM (9 years ago)
Author:
maxima
Message:

Changes of Phillip. He couldn't upload himself. New Campaign Menu added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc

    r9986 r10157  
    3636#include "network/Host.h"
    3737#include "worldentities/pawns/Pawn.h"
    38 
     38#include <iostream>
     39#include <fstream>
     40#include <string>
     41#include <ios>
    3942
    4043namespace orxonox
     
    7881    void Mission::start()
    7982    {
     83        std::fstream myfile;
     84                myfile.open("/home/pmao/pmao-extra-0/orxonox/storymodeHS14/data/gui/scripts/campaign.txt");
     85                std::string line;
     86                std::string mission=this->getFilename();
     87                int k=58-mission.length();
     88                std::string helperstring = "";
     89                if(myfile.is_open()){
     90                        while (k>1) {
     91                                helperstring=helperstring+" ";
     92                                k=k-1;
     93                        }
     94                        helperstring=helperstring+".";
     95                       while(getline (myfile,line)){
     96                          if(line==mission+" 0"+helperstring){
     97                                  long pos = myfile.tellp();
     98                                  myfile.seekp (pos-61);
     99                                  myfile << mission+" 1"+helperstring;
     100                          }
     101                        }}
     102                else{
     103                        this->end();
     104                }
     105                        myfile.flush();
     106                        myfile.clear();
     107                        myfile.close();
    80108        Gametype::start();
    81109        this->setTeams();
     
    84112    }
    85113
     114    std::string GenerateHelperString(int number){
     115        std::string helperstring = "";
     116        while (number>1) {
     117                helperstring=helperstring+" ";
     118                number=number-1;
     119        }
     120        helperstring=helperstring+".";
     121        return helperstring;
     122    }
     123
    86124    void Mission::end()
    87125    {
    88         if (this->missionAccomplished_ && !this->gtinfo_->hasEnded())
     126
     127        if (this->missionAccomplished_ && !this->gtinfo_->hasEnded()){
    89128            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
     129            std::fstream myfile;
     130                                myfile.open("/home/pmao/pmao-extra-0/orxonox/storymodeHS14/data/gui/scripts/campaign.txt");
     131                                std::string line;
     132                                std::string mission=this->getFilename();
     133                                int k=58-mission.length();
     134                                std::string helperstring = "";
     135                                if(myfile.is_open()){
     136                                        while (k>1) {
     137                                                helperstring=helperstring+" ";
     138                                                k=k-1;
     139                                        }
     140                                        helperstring=helperstring+".";
     141                                       while(getline (myfile,line)){
     142                                          if(line==mission+" 0"+helperstring){
     143                                                  long pos = myfile.tellp();
     144                                                  myfile.seekp (pos-61);
     145                                                  myfile << mission+" 1"+helperstring;
     146                                          }
     147                                        }}
     148                                        myfile.flush();
     149                                        myfile.clear();
     150                                        myfile.close();
     151                  }
     152
    90153        else if (!this->gtinfo_->hasEnded())
    91154            this->gtinfo_->sendAnnounceMessage("Mission failed!");
     
    106169        for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
    107170        {//TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions!
    108             it->setMissionAccomplished(accomplished);
     171            if(accomplished){
     172                std::fstream myfile;
     173                        myfile.open("/home/pmao/pmao-extra-0/orxonox/storymodeHS14/data/gui/scripts/campaign.txt");
     174                        std::string line;
     175                        std::string mission=it->getFilename();
     176                        int k=58-mission.length();
     177                    std::string helperstring = "";
     178                    if(myfile.is_open()){
     179                        while (k>1) {
     180                                helperstring=helperstring+" ";
     181                            k=k-1;
     182                                    }
     183                    helperstring=helperstring+".";
     184                        while(getline (myfile,line)){
     185                                if(line==mission+" 0"+helperstring){
     186                                long pos = myfile.tellp();
     187                            myfile.seekp (pos-61);
     188                            myfile << mission+" 1"+helperstring;
     189                                          }
     190                        }
     191                    }
     192                    myfile.flush();
     193                    myfile.clear();
     194                    myfile.close();
     195            }
     196                it->setMissionAccomplished(accomplished);
    109197            it->end();
    110         }
    111     }
    112    
     198
     199        }
     200    }
     201
    113202    void Mission::setLivesWrapper(unsigned int amount)
    114203    {
Note: See TracChangeset for help on using the changeset viewer.