X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FLevel%2FDialog.cpp;h=7649c2a308ec35575ef60ee1ead1e40722d80ce8;hb=0aab437dc560d2afa982e61cc2547756ad7b0761;hp=64d30155bce7eb10e5f93452f6720196a86543e6;hpb=475fb97fd19a8bc2c58c603d0bc5dcf8cc63b40d;p=lugaru.git diff --git a/Source/Level/Dialog.cpp b/Source/Level/Dialog.cpp index 64d3015..7649c2a 100644 --- a/Source/Level/Dialog.cpp +++ b/Source/Level/Dialog.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games -Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) +Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -22,9 +22,9 @@ along with Lugaru. If not, see . #include "Game.hpp" #include "Objects/Person.hpp" -#include "Utils/binio.h" #include "Utils/Folders.hpp" #include "Utils/Input.hpp" +#include "Utils/binio.h" extern int hostile; @@ -43,7 +43,8 @@ void Dialog::loadDialogs(FILE* tfile) } } -Dialog::Dialog(FILE* tfile) : gonethrough(0) +Dialog::Dialog(FILE* tfile) + : gonethrough(0) { int numdialogscenes; funpackf(tfile, "Bi", &numdialogscenes); @@ -68,8 +69,9 @@ std::string funpackf_string(FILE* tfile, int maxlength) char* text = new char[maxlength]; for (m = 0; m < templength; m++) { funpackf(tfile, "Bb", &text[m]); - if (text[m] == '\0') + if (text[m] == '\0') { break; + } } text[m] = 0; std::string result(text); @@ -103,14 +105,16 @@ DialogScene::DialogScene(FILE* tfile) funpackf(tfile, "Bi", &participantfocus); funpackf(tfile, "Bi", &participantaction); - for (int m = 0; m < 10; m++) + for (int m = 0; m < 10; m++) { funpackf(tfile, "Bf Bf Bf", &participantfacing[m].x, &participantfacing[m].y, &participantfacing[m].z); + } funpackf(tfile, "Bf Bf", &camerayaw, &camerapitch); } /* Load dialog from txt file, used by console */ -Dialog::Dialog(int type, std::string filename) : type(type) +Dialog::Dialog(int type, std::string filename) + : type(type) { ifstream ipstream(Folders::getResourcePath(filename)); ipstream.ignore(256, ':'); @@ -125,7 +129,7 @@ Dialog::Dialog(int type, std::string filename) : type(type) ipstream.close(); } -DialogScene::DialogScene(ifstream &ipstream) +DialogScene::DialogScene(ifstream& ipstream) { ipstream.ignore(256, ':'); ipstream.ignore(256, ':'); @@ -141,8 +145,9 @@ DialogScene::DialogScene(ifstream &ipstream) ipstream.ignore(256, ' '); getline(ipstream, text); for (int j = 0; j < 128; j++) { - if (text[j] == '\\') + if (text[j] == '\\') { text[j] = '\n'; + } } ipstream.ignore(256, ':'); ipstream >> sound; @@ -154,13 +159,13 @@ void Dialog::tick(int id) bool special = (type > 9); if ((!hostile || (type > 40) && (type < 50)) && - (playerId < Person::players.size()) && - (playerId > 0) && - ((gonethrough == 0) || !special) && - (special || Input::isKeyPressed(Game::attackkey))) { + (playerId < Person::players.size()) && + (playerId > 0) && + ((gonethrough == 0) || !special) && + (special || Input::isKeyPressed(Game::attackkey))) { if ((distsq(&Person::players[0]->coords, &Person::players[playerId]->coords) < 6) || - (Person::players[playerId]->howactive >= typedead1) || - (type > 40) && (type < 50)) { + (Person::players[playerId]->howactive >= typedead1) || + (type > 40) && (type < 50)) { whichdialogue = id; play(); dialoguetime = 0; @@ -226,8 +231,9 @@ void DialogScene::save(FILE* tfile) fpackf(tfile, "Bi", participantfocus); fpackf(tfile, "Bi", participantaction); - for (int m = 0; m < 10; m++) + for (int m = 0; m < 10; m++) { fpackf(tfile, "Bf Bf Bf", participantfacing[m].x, participantfacing[m].y, participantfacing[m].z); + } fpackf(tfile, "Bf Bf", camerayaw, camerapitch); }