/*
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.
along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
+#include "Level/Dialog.hpp"
-#include "Level/Dialog.h"
-#include "Objects/Person.h"
+#include "Game.hpp"
+#include "Objects/Person.hpp"
+#include "Utils/Folders.hpp"
+#include "Utils/Input.hpp"
#include "Utils/binio.h"
-#include "Utils/Folders.h"
-#include "Utils/Input.h"
extern int hostile;
}
}
-Dialog::Dialog(FILE* tfile) : gonethrough(0)
+Dialog::Dialog(FILE* tfile)
+ : gonethrough(0)
{
int numdialogscenes;
funpackf(tfile, "Bi", &numdialogscenes);
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);
void fpackf_string(FILE* tfile, std::string text)
{
fpackf(tfile, "Bi", text.size());
- for (int m = 0; m < text.size(); m++) {
- fpackf(tfile, "Bb", text[m]);
- if (text[m] == '\0')
+ for (unsigned i = 0; i < text.size(); i++) {
+ fpackf(tfile, "Bb", text[i]);
+ if (text[i] == '\0') {
break;
+ }
}
}
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, ':');
ipstream.close();
}
-DialogScene::DialogScene(ifstream &ipstream)
+DialogScene::DialogScene(ifstream& ipstream)
{
ipstream.ignore(256, ':');
ipstream.ignore(256, ':');
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;
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;
void Dialog::play()
{
- for (int i = 0; i < scenes.size(); i++) {
+ for (unsigned i = 0; i < scenes.size(); i++) {
int playerId = scenes[i].participantfocus;
- Person::players[playerId]->coords = participantlocation[playerId];
+ Person::players.at(playerId)->coords = participantlocation[playerId];
Person::players[playerId]->yaw = participantyaw[playerId];
Person::players[playerId]->targetyaw = participantyaw[playerId];
Person::players[playerId]->velocity = 0;
{
fpackf(tfile, "Bi", dialogs.size());
- for (int k = 0; k < dialogs.size(); k++) {
- dialogs[k].save(tfile);
+ for (unsigned i = 0; i < dialogs.size(); i++) {
+ dialogs[i].save(tfile);
}
}
fpackf(tfile, "Bf Bf Bf", participantlocation[l].x, participantlocation[l].y, participantlocation[l].z);
fpackf(tfile, "Bf", participantyaw[l]);
}
- for (int l = 0; l < scenes.size(); l++) {
+ for (unsigned l = 0; l < scenes.size(); l++) {
scenes[l].save(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);
}