Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 3, 2015, 11:38:07 PM (9 years ago)
Author:
landauf
Message:

improved campaign mode. use config value instead of writing a new file.
moved configuration of campaign (the list of missions) from the lua file to the default config. you need to delete your local orxonox.ini in order to see the changes.

File:
1 edited

Legend:

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

    r10251 r10253  
    3636#include "core/CoreIncludes.h"
    3737#include "core/command/ConsoleCommand.h"
     38#include "core/config/ConfigValueIncludes.h"
    3839#include "infos/PlayerInfo.h"
    3940#include "network/Host.h"
    4041#include "worldentities/pawns/Pawn.h"
    41 #include <iostream>
    42 #include <fstream>
    43 #include <string>
    44 #include <ios>
     42#include "LevelManager.h"
    4543
    4644namespace orxonox
     
    9391    }
    9492
    95     std::string GenerateHelperString(int number)
    96     {
    97         std::string helperstring = "";
    98         while (number > 1)
    99         {
    100             helperstring = helperstring + " ";
    101             number = number - 1;
    102         }
    103         helperstring = helperstring + ".";
    104         return helperstring;
    105     }
    106 
    10793    void Mission::end()
    10894    {
     
    11298            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
    11399
    114             boost::filesystem::path filepath("campaign.txt");
    115             std::fstream myfile;
    116             myfile.open(filepath.string().c_str(), std::fstream::out);
    117 
    118             std::string line;
    119             std::string mission = this->getFilename();
    120             int k = 58 - mission.length();
    121             std::string helperstring = "";
    122             if (myfile.is_open())
    123             {
    124                 while (k > 1)
    125                 {
    126                     helperstring = helperstring + " ";
    127                     k = k - 1;
    128                 }
    129                 helperstring = helperstring + ".";
    130                 while (getline(myfile, line))
    131                 {
    132                     if (line == mission + " 0" + helperstring)
    133                     {
    134                         long pos = (long) myfile.tellp();
    135                         myfile.seekp(pos - 61);
    136                         myfile << mission + " 1" + helperstring;
    137                     }
    138                 }
    139             } else {
    140                 orxout(internal_warning) << "failed to open campaign file" << endl;
    141             }
    142             myfile.flush();
    143             myfile.clear();
    144             myfile.close();
     100            LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename());
    145101        }
    146102
Note: See TracChangeset for help on using the changeset viewer.