Changeset 10249 for code/branches/storymodeHS14/src
- Timestamp:
- Feb 1, 2015, 10:37:36 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc
r10174 r10249 73 73 void Mission::pawnKilled(Pawn* victim, Pawn* killer) 74 74 { 75 if (victim && victim->getPlayer() && victim->getPlayer()->isHumanPlayer() 75 if (victim && victim->getPlayer() && victim->getPlayer()->isHumanPlayer()) 76 76 { 77 77 this->lives_--; … … 81 81 void Mission::start() 82 82 { 83 83 std::fstream myfile; 84 84 85 85 Gametype::start(); … … 90 90 } 91 91 92 std::string GenerateHelperString(int number){ 93 std::string helperstring = ""; 94 while (number>1) { 95 helperstring=helperstring+" "; 96 number=number-1; 97 } 98 helperstring=helperstring+"."; 99 return helperstring; 92 std::string GenerateHelperString(int number) 93 { 94 std::string helperstring = ""; 95 while (number > 1) 96 { 97 helperstring = helperstring + " "; 98 number = number - 1; 99 } 100 helperstring = helperstring + "."; 101 return helperstring; 100 102 } 101 103 … … 103 105 { 104 106 105 if (this->missionAccomplished_ && !this->gtinfo_->hasEnded()){ 107 if (this->missionAccomplished_ && !this->gtinfo_->hasEnded()) 108 { 106 109 this->gtinfo_->sendAnnounceMessage("Mission accomplished!"); 107 110 std::fstream myfile; 108 myfile.open("/home/maxima/maxima-extra-0/orxonox/storymodeHS14/campaign.txt"); 109 std::string line; 110 std::string mission=this->getFilename(); 111 int k=58-mission.length(); 112 std::string helperstring = ""; 113 if(myfile.is_open()){ 114 while (k>1) { 115 helperstring=helperstring+" "; 116 k=k-1; 117 } 118 helperstring=helperstring+"."; 119 while(getline (myfile,line)){ 120 if(line==mission+" 0"+helperstring){ 121 long pos = myfile.tellp(); 122 myfile.seekp (pos-61); 123 myfile << mission+" 1"+helperstring; 124 } 125 }} 126 myfile.flush(); 127 myfile.clear(); 128 myfile.close(); 129 } 111 myfile.open("/home/maxima/maxima-extra-0/orxonox/storymodeHS14/campaign.txt"); 112 std::string line; 113 std::string mission = this->getFilename(); 114 int k = 58 - mission.length(); 115 std::string helperstring = ""; 116 if (myfile.is_open()) 117 { 118 while (k > 1) 119 { 120 helperstring = helperstring + " "; 121 k = k - 1; 122 } 123 helperstring = helperstring + "."; 124 while (getline(myfile, line)) 125 { 126 if (line == mission + " 0" + helperstring) 127 { 128 long pos = myfile.tellp(); 129 myfile.seekp(pos - 61); 130 myfile << mission + " 1" + helperstring; 131 } 132 } 133 } 134 myfile.flush(); 135 myfile.clear(); 136 myfile.close(); 137 } 130 138 131 139 else if (!this->gtinfo_->hasEnded()) … … 135 143 136 144 void Mission::setTeams() 137 { //Set pawn-colours145 { //Set pawn-colours 138 146 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 139 147 { 140 148 Pawn* pawn = static_cast<Pawn*>(*it); 141 if(!pawn) continue; 142 this->setDefaultObjectColour(pawn); 149 if (!pawn) 150 continue; 151 this->setDefaultObjectColour(pawn); 143 152 } 144 153 } … … 146 155 { 147 156 for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it) 148 {//TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions! 149 /* if(accomplished){ 150 std::fstream myfile; 151 myfile.open("/home/pmao/pmao-extra-0/orxonox/storymodeHS14/data/gui/scripts/campaign.txt"); 152 std::string line; 153 std::string mission=it->getFilename(); 154 int k=58-mission.length(); 155 std::string helperstring = ""; 156 if(myfile.is_open()){ 157 while (k>1) { 158 helperstring=helperstring+" "; 159 k=k-1; 160 } 161 helperstring=helperstring+"."; 162 while(getline (myfile,line)){ 163 if(line==mission+" 0"+helperstring){ 164 long pos = myfile.tellp(); 165 myfile.seekp (pos-61); 166 myfile << mission+" 1"+helperstring; 167 } 168 } 169 } 170 myfile.flush(); 171 myfile.clear(); 172 myfile.close(); 173 }*/ 174 it->setMissionAccomplished(accomplished); 157 { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions! 158 it->setMissionAccomplished(accomplished); 175 159 it->end(); 176 160 … … 181 165 { 182 166 for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it) 183 { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would affect ALL missions!167 { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would affect ALL missions! 184 168 it->setLives(amount); 185 169 } 186 170 } 187 171 188 189 172 }
Note: See TracChangeset
for help on using the changeset viewer.