${SRCDIR}/Account.cpp
${SRCDIR}/ConsoleCmds.cpp
${SRCDIR}/Dialog.cpp
+ ${SRCDIR}/Hotspot.cpp
${SRCDIR}/Game.cpp
${SRCDIR}/GameDraw.cpp
${SRCDIR}/GameInitDispose.cpp
${SRCDIR}/Account.h
${SRCDIR}/ConsoleCmds.h
${SRCDIR}/Dialog.h
+ ${SRCDIR}/Hotspot.h
${SRCDIR}/Game.h
${SRCDIR}/Lights.h
${SRCDIR}/Menu.h
#include "ConsoleCmds.h"
#include "Game.h"
#include "Dialog.h"
+#include "Hotspot.h"
#include "Utils/Folders.h"
const char *cmd_names[cmd_count] = {
extern float slomofreq;
extern int tutoriallevel;
extern int hostile;
-extern XYZ hotspot[40];
-extern int hotspottype[40];
-extern float hotspotsize[40];
-extern char hotspottext[40][256];
extern int maptype;
-extern int numhotspots;
extern Objects objects;
extern int slomo;
extern float slomodelay;
fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", objects.type[k], objects.yaw[k], objects.pitch[k],
objects.position[k].x, objects.position[k].y, objects.position[k].z, objects.scale[k]);
- fpackf(tfile, "Bi", numhotspots);
- for (int i = 0; i < numhotspots; i++) {
- fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i], hotspotsize[i], hotspot[i].x, hotspot[i].y, hotspot[i].z);
- int templength = strlen(hotspottext[i]);
+ fpackf(tfile, "Bi", Hotspot::hotspots.size());
+ for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+ fpackf(tfile, "Bi Bf Bf Bf Bf", Hotspot::hotspots[i].type, Hotspot::hotspots[i].size, Hotspot::hotspots[i].position.x, Hotspot::hotspots[i].position.y, Hotspot::hotspots[i].position.z);
+ int templength = strlen(Hotspot::hotspots[i].text);
fpackf(tfile, "Bi", templength);
for (int l = 0; l < templength; l++)
- fpackf(tfile, "Bb", hotspottext[i][l]);
+ fpackf(tfile, "Bb", Hotspot::hotspots[i].text[l]);
}
fpackf(tfile, "Bi", Person::players.size());
void ch_hs(const char *args)
{
- hotspot[numhotspots] = Person::players[0]->coords;
-
float size;
int type, shift;
sscanf(args, "%f%d %n", &size, &type, &shift);
- hotspotsize[numhotspots] = size;
- hotspottype[numhotspots] = type;
-
- strcpy(hotspottext[numhotspots], args + shift);
- strcat(hotspottext[numhotspots], "\n");
+ Hotspot::hotspots.emplace_back(Person::players[0]->coords, type, size);
- numhotspots++;
+ strcpy(Hotspot::hotspots.back().text, args + shift);
+ strcat(Hotspot::hotspots.back().text, "\n");
}
void ch_dialogue(const char *args)
void ch_ddialogue(const char *args)
{
- Dialog::dialogs.pop_back();
+ if (!Dialog::dialogs.empty()) {
+ Dialog::dialogs.pop_back();
+ }
}
void ch_dhs(const char *args)
{
- if (numhotspots)
- numhotspots--;
+ if (!Hotspot::hotspots.empty()) {
+ Hotspot::hotspots.pop_back();
+ }
}
void ch_immobile(const char *args)
#include "Awards.h"
#include "Menu.h"
#include "Dialog.h"
+#include "Hotspot.h"
extern XYZ viewer;
extern int environment;
extern float damagedealt;
extern bool invertmouse;
-extern int numhotspots;
-extern int killhotspot;
-extern XYZ hotspot[40];
-extern int hotspottype[40];
-extern float hotspotsize[40];
-extern char hotspottext[40][256];
-extern int currenthotspot;
-
extern bool campaign;
extern bool winfreeze;
}
//Hot spots
- if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
+ if (Hotspot::hotspots.size() && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
float closestdist = -1;
float distance = 0;
- int closest = currenthotspot;
- for (int i = 0; i < numhotspots; i++) {
- distance = distsq(&Person::players[0]->coords, &hotspot[i]);
+ int closest = Hotspot::current;
+ for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+ distance = distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position);
if (closestdist == -1 || distance < closestdist) {
- if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
+ if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position) < Hotspot::hotspots[i].size && ((Hotspot::hotspots[i].type <= 10 && Hotspot::hotspots[i].type >= 0) || (Hotspot::hotspots[i].type <= 40 && Hotspot::hotspots[i].type >= 20))) {
closestdist = distance;
closest = i;
}
}
}
if (closest != -1) {
- currenthotspot = closest;
- if (hotspottype[closest] <= 10) {
- if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
+ Hotspot::current = closest;
+ if (Hotspot::hotspots[closest].type <= 10) {
+ if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[closest].position) < Hotspot::hotspots[closest].size)
tutorialstagetime = 0;
tutorialmaxtime = 1;
tutorialopac = tutorialmaxtime - tutorialstagetime;
if (tutorialopac < 0)
tutorialopac = 0;
- sprintf (string, "%s", hotspottext[closest]);
+ sprintf (string, "%s", Hotspot::hotspots[closest].text);
int lastline = 0;
int line = 0;
done = 1;
i++;
}
- } else if ((hotspottype[closest] >= 20) && (Dialog::dialogs[hotspottype[closest] - 20].gonethrough == 0)) {
- Dialog::whichdialogue = hotspottype[closest] - 20;
+ } else if ((Hotspot::hotspots[closest].type >= 20) && (Dialog::dialogs[Hotspot::hotspots[closest].type - 20].gonethrough == 0)) {
+ Dialog::whichdialogue = Hotspot::hotspots[closest].type - 20;
Dialog::currentDialog().play();
Dialog::currentDialog().gonethrough++;
}
#include "ConsoleCmds.h"
#include "Dialog.h"
#include "Utils/Folders.h"
+#include "Hotspot.h"
#include <algorithm>
#include <set>
extern bool gamestarted;
-extern int numhotspots;
-extern int killhotspot;
-extern XYZ hotspot[40];
-extern int hotspottype[40];
-extern float hotspotsize[40];
-extern char hotspottext[40][256];
-extern int currenthotspot;
-
extern int hostile;
extern bool stillloading;
if (accountactive)
difficulty = accountactive->getDifficulty();
- numhotspots = 0;
- currenthotspot = -1;
+ Hotspot::hotspots.clear();
+ Hotspot::current = -1;
bonustime = 1;
skyboxtexture = 1;
}
if (mapvers >= 7) {
+ int numhotspots;
funpackf(tfile, "Bi", &numhotspots);
- for (int i = 0; i < numhotspots; i++) {
- funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i], &hotspotsize[i], &hotspot[i].x, &hotspot[i].y, &hotspot[i].z);
+ Hotspot::hotspots.resize(numhotspots);
+ for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+ funpackf(tfile, "Bi Bf Bf Bf Bf", &Hotspot::hotspots[i].type, &Hotspot::hotspots[i].size, &Hotspot::hotspots[i].position.x, &Hotspot::hotspots[i].position.y, &Hotspot::hotspots[i].position.z);
funpackf(tfile, "Bi", &templength);
if (templength)
for (int l = 0; l < templength; l++)
- funpackf(tfile, "Bb", &hotspottext[i][l]);
- hotspottext[i][templength] = '\0';
- if (hotspottype[i] == -111)
+ funpackf(tfile, "Bb", &Hotspot::hotspots[i].text[l]);
+ Hotspot::hotspots[i].text[templength] = '\0';
+ if (Hotspot::hotspots[i].type == -111)
indemo = 1;
}
- } else
- numhotspots = 0;
+ } else {
+ Hotspot::hotspots.clear();
+ }
if (visibleloading)
LoadingScreen();
//hotspots
static float hotspotvisual[40];
- if (numhotspots) {
+ if (Hotspot::hotspots.size()) {
XYZ hotspotsprite;
if (editorenabled)
- for (int i = 0; i < numhotspots; i++)
+ for (int i = 0; i < Hotspot::hotspots.size(); i++)
hotspotvisual[i] -= multiplier / 320;
- for (int i = 0; i < numhotspots; i++) {
+ for (int i = 0; i < Hotspot::hotspots.size(); i++) {
while (hotspotvisual[i] < 0) {
hotspotsprite = 0;
- hotspotsprite.x = float(abs(Random() % 100000)) / 100000 * hotspotsize[i];
+ hotspotsprite.x = float(abs(Random() % 100000)) / 100000 * Hotspot::hotspots[i].size;
hotspotsprite = DoRotation(hotspotsprite, 0, 0, Random() % 360);
hotspotsprite = DoRotation(hotspotsprite, 0, Random() % 360, 0);
- hotspotsprite += hotspot[i];
+ hotspotsprite += Hotspot::hotspots[i].position;
Sprite::MakeSprite(breathsprite, hotspotsprite, hotspotsprite * 0, 1, 0.5, 0, 7, 0.4);
- hotspotvisual[i] += 0.1 / hotspotsize[i] / hotspotsize[i] / hotspotsize[i];
+ hotspotvisual[i] += 0.1 / Hotspot::hotspots[i].size / Hotspot::hotspots[i].size / Hotspot::hotspots[i].size;
}
}
- for (int i = 0; i < numhotspots; i++) {
- if (hotspottype[i] <= 10 && hotspottype[i] > 0) {
- hotspot[i] = Person::players[hotspottype[i]]->coords;
+ for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+ if (Hotspot::hotspots[i].type <= 10 && Hotspot::hotspots[i].type > 0) {
+ Hotspot::hotspots[i].position = Person::players[Hotspot::hotspots[i].type]->coords;
}
}
}
if (Dialog::currentScene().sound != 0) {
playdialoguescenesound();
if (Dialog::currentScene().sound == -5) {
- hotspot[numhotspots] = Person::players[0]->coords;
- hotspotsize[numhotspots] = 10;
- hotspottype[numhotspots] = -1;
-
- numhotspots++;
+ Hotspot::hotspots.emplace_back(Person::players[0]->coords, -1, 10);
}
if (Dialog::currentScene().sound == -6) {
hostile = 1;
}
}
- killhotspot = 2;
- for (int i = 0; i < numhotspots; i++) {
- if (hotspottype[i] > 10 && hotspottype[i] < 20) {
- if (Person::players[hotspottype[i] - 10]->dead == 0)
- killhotspot = 0;
- else if (killhotspot == 2)
- killhotspot = 1;
+ Hotspot::killhotspot = 2;
+ for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+ if (Hotspot::hotspots[i].type > 10 && Hotspot::hotspots[i].type < 20) {
+ if (Person::players[Hotspot::hotspots[i].type - 10]->dead == 0)
+ Hotspot::killhotspot = 0;
+ else if (Hotspot::killhotspot == 2)
+ Hotspot::killhotspot = 1;
}
}
- if (killhotspot == 2)
- killhotspot = 0;
+ if (Hotspot::killhotspot == 2)
+ Hotspot::killhotspot = 0;
winhotspot = false;
- for (int i = 0; i < numhotspots; i++)
- if (hotspottype[i] == -1)
- if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i])
+ for (int i = 0; i < Hotspot::hotspots.size(); i++)
+ if (Hotspot::hotspots[i].type == -1)
+ if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position) < Hotspot::hotspots[i].size)
winhotspot = true;
int numalarmed = 0;
}
- if (killhotspot) {
+ if (Hotspot::killhotspot) {
changedelay = 1;
targetlevel = whichlevel + 1;
if (targetlevel > numchallengelevels - 1)
changedelay = .1;
alldead = false;
winhotspot = false;
- killhotspot = 0;
+ Hotspot::killhotspot = 0;
}
if (!editorenabled && gameon && !mainmenu) {
(Person::players[0]->dead ||
(alldead && maptype == mapkilleveryone) ||
(winhotspot) ||
- (killhotspot)))
+ (Hotspot::killhotspot)))
loading = 1;
if ((Person::players[0]->dead ||
(alldead && maptype == mapkilleveryone) ||
(winhotspot) ||
(windialogue) ||
- (killhotspot)) &&
+ (Hotspot::killhotspot)) &&
changedelay <= 0) {
if (whichlevel != -2 && !loading && !Person::players[0]->dead) {
winfreeze = true;
int whichjointstartarray[26] = {0};
int whichjointendarray[26] = {0};
-int numhotspots = 0;
-XYZ hotspot[40];
-int hotspottype[40] = {0};
-float hotspotsize[40] = {0};
-char hotspottext[40][256] = {0};
-int currenthotspot = 0;
-int killhotspot = 0;
-
float smoketex = 0;
float slomospeed = 0;
--- /dev/null
+/*
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "Hotspot.h"
+
+std::vector<Hotspot> Hotspot::hotspots;
+int Hotspot::current = 0;
+int Hotspot::killhotspot = 0;
+
+Hotspot::Hotspot() :
+ position(),
+ type(0),
+ size(0)
+{
+}
+
+Hotspot::Hotspot(XYZ p, int t, float s) :
+ position(p),
+ type(t),
+ size(s)
+{
+}
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+Lugaru is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _HOTSPOT_H_
+#define _HOTSPOT_H_
+
+#include "Quaternions.h"
+#include <vector>
+
+class Hotspot
+{
+public:
+ static std::vector<Hotspot> hotspots;
+ static int current;
+ static int killhotspot;
+
+ Hotspot();
+ Hotspot(XYZ position, int type, float size);
+
+ XYZ position;
+ int type;
+ float size;
+ char text[256] = {0};
+};
+
+#endif