Some test cases for saving scenarios, and fix some bugs they revealed
- Fix variable town entry and saved item rects not being saved if they referenced an invalid town - Fix "blank" scenario timers being saved - Fix junk data appearing in timers - Output operators for location and rectangle types - Set timer node_type to 2 when loading from town record
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "location.hpp"
|
||||
#include "mathutil.hpp"
|
||||
#include <iostream>
|
||||
|
||||
bool operator == (location p1,location p2){
|
||||
if((p1.x == p2.x) & (p1.y == p2.y))
|
||||
@@ -186,3 +187,30 @@ rectangle rect(int top, int left, int bottom, int right) {
|
||||
return rectangle(top, left, bottom, right);
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& out, location l) {
|
||||
out << '(' << l.x << ',' << l.y << ')';
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& out, spec_loc_t l) {
|
||||
out << static_cast<location&>(l);
|
||||
out << ':' << l.spec;
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& out, sign_loc_t l) {
|
||||
out << static_cast<location&>(l);
|
||||
out << " -- \"" << l.text << '"';
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& out, rectangle r) {
|
||||
out << "{" << r.topLeft() << " - " << r.bottomRight() << '}';
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& out, info_rect_t r) {
|
||||
out << static_cast<rectangle&>(r);
|
||||
out << " -- \"" << r.descr << '"';
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
struct rectangle;
|
||||
|
||||
@@ -136,4 +137,10 @@ rectangle rect();
|
||||
rectangle rect(location tl, location br);
|
||||
rectangle rect(int top, int left, int bottom, int right);
|
||||
|
||||
std::ostream& operator<< (std::ostream& out, location l);
|
||||
std::ostream& operator<< (std::ostream& out, spec_loc_t l);
|
||||
std::ostream& operator<< (std::ostream& out, sign_loc_t l);
|
||||
std::ostream& operator<< (std::ostream& out, rectangle r);
|
||||
std::ostream& operator<< (std::ostream& out, info_rect_t r);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
|
||||
#include "oldstructs.hpp"
|
||||
|
||||
void cScenario::reset_version() {
|
||||
format.prog_make_ver[0] = 2;
|
||||
format.prog_make_ver[1] = 0;
|
||||
format.prog_make_ver[2] = 0;
|
||||
format.flag1 = 'O'; format.flag2 = 'B';
|
||||
format.flag3 = 'O'; format.flag4 = 'E';
|
||||
}
|
||||
|
||||
cScenario::~cScenario() {
|
||||
destroy_terrain();
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ public:
|
||||
size_t which_town_start;
|
||||
spec_num_t init_spec;
|
||||
std::array<spec_loc_t,10> town_mods;
|
||||
rectangle store_item_rects[3];
|
||||
short store_item_towns[3];
|
||||
std::array<rectangle,3> store_item_rects;
|
||||
std::array<short,3> store_item_towns;
|
||||
std::vector<cSpecItem> special_items;
|
||||
std::vector<cQuest> quests;
|
||||
std::vector<cShop> shops;
|
||||
@@ -115,6 +115,7 @@ public:
|
||||
bool is_monst_used(mon_num_t monst);
|
||||
bool is_item_used(item_num_t item);
|
||||
|
||||
void reset_version();
|
||||
cScenario& operator=(cScenario&& other);
|
||||
cScenario(cScenario&) = delete;
|
||||
explicit cScenario();
|
||||
|
||||
@@ -42,9 +42,9 @@ public:
|
||||
|
||||
class cTimer {
|
||||
public:
|
||||
long time;
|
||||
short node_type;
|
||||
short node;
|
||||
long time = 0;
|
||||
short node_type = 0;
|
||||
short node = -1;
|
||||
};
|
||||
|
||||
struct pending_special_type {
|
||||
|
||||
Reference in New Issue
Block a user