(partial merge of 97f0723a4c69580457a4e1ba4b0ff60ecd4e2621)

Preparations to support easily adding fields
This commit is contained in:
Terane436
2022-01-14 11:04:33 +01:00
committed by Celtic Minstrel
parent bbb9050bf5
commit 242fd65824
3 changed files with 90 additions and 208 deletions

View File

@@ -582,56 +582,56 @@ int cParty::get_shared_dmg(int) const {
int cParty::get_health() const {
int health = 0;
for(int i = 0; i < 6; i++)
if(adven[i]->is_alive())
health += adven[i]->cur_health;
for(auto pc : adven)
if (pc && pc->is_alive())
health += pc->cur_health;
return health;
}
int cParty::get_magic() const {
int magic = 0;
for(int i = 0; i < 6; i++)
if(adven[i]->is_alive())
magic += adven[i]->cur_sp;
for(auto pc : adven)
if (pc && pc->is_alive())
magic += pc->cur_sp;
return magic;
}
int cParty::get_level() const {
short j = 0;
for(int i = 0; i < 6; i++)
if(adven[i]->main_status == eMainStatus::ALIVE)
j += adven[i]->level;
for(auto pc : adven)
if (pc && pc->main_status == eMainStatus::ALIVE)
j += pc->level;
return j;
}
void cParty::heal(int how_much) {
for(int i = 0; i < 6; i++)
adven[i]->heal(how_much);
for(auto pc : adven)
if (pc) pc->heal(how_much);
}
void cParty::poison(int how_much) {
for(int i = 0; i < 6; i++)
adven[i]->poison(how_much);
for(auto pc : adven)
if (pc) pc->poison(how_much);
}
void cParty::cure(int how_much) {
for(int i = 0; i < 6; i++)
adven[i]->cure(how_much);
for(auto pc : adven)
if (pc) pc->cure(how_much);
}
void cParty::acid(int how_much) {
for(int i = 0; i < 6; i++)
adven[i]->acid(how_much);
for(auto pc : adven)
if (pc) pc->acid(how_much);
}
void cParty::curse(int how_much) {
for(int i = 0; i < 6; i++)
adven[i]->curse(how_much);
for(auto pc : adven)
if (pc) pc->curse(how_much);
}
void cParty::slow(int how_much) {
for(int i = 0; i < 6; i++)
adven[i]->slow(how_much);
for(auto pc : adven)
if (pc) pc->slow(how_much);
}
void cParty::web(int how_much) {

View File

@@ -206,61 +206,6 @@ cTown*const cCurTown::record() const {
return univ.scenario.towns[univ.party.town_num];
}
bool cCurTown::is_explored(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_explored(fields[x][y]);
}
bool cCurTown::is_force_wall(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_force_wall(fields[x][y]);
}
bool cCurTown::is_fire_wall(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_fire_wall(fields[x][y]);
}
bool cCurTown::is_antimagic(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_antimagic(fields[x][y]);
}
bool cCurTown::is_scloud(short x, short y) const{ // stinking cloud
if(!record()->is_on_map(x,y)) return false;
return is_scloud(fields[x][y]);
}
bool cCurTown::is_ice_wall(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_ice_wall(fields[x][y]);
}
bool cCurTown::is_blade_wall(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_blade_wall(fields[x][y]);
}
bool cCurTown::is_sleep_cloud(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_sleep_cloud(fields[x][y]);
}
bool cCurTown::is_block(short x, short y) const{ // currently unused
if(!record()->is_on_map(x,y)) return false;
return is_block(fields[x][y]);
}
bool cCurTown::is_spot(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_spot(fields[x][y]);
}
bool cCurTown::is_road(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_road(fields[x][y]);
}
bool cCurTown::is_special(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
location check(x,y);
@@ -270,81 +215,6 @@ bool cCurTown::is_special(short x, short y) const{
return false;
}
bool cCurTown::is_web(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_web(fields[x][y]);
}
bool cCurTown::is_crate(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_crate(fields[x][y]);
}
bool cCurTown::is_barrel(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_barrel(fields[x][y]);
}
bool cCurTown::is_fire_barr(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_fire_barr(fields[x][y]);
}
bool cCurTown::is_force_barr(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_force_barr(fields[x][y]);
}
bool cCurTown::is_quickfire(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_quickfire(fields[x][y]);
}
bool cCurTown::is_sm_blood(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_sm_blood(fields[x][y]);
}
bool cCurTown::is_med_blood(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_med_blood(fields[x][y]);
}
bool cCurTown::is_lg_blood(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_lg_blood(fields[x][y]);
}
bool cCurTown::is_sm_slime(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_sm_slime(fields[x][y]);
}
bool cCurTown::is_lg_slime(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_lg_slime(fields[x][y]);
}
bool cCurTown::is_ash(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_ash(fields[x][y]);
}
bool cCurTown::is_bones(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_bones(fields[x][y]);
}
bool cCurTown::is_rubble(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_rubble(fields[x][y]);
}
bool cCurTown::is_force_cage(short x, short y) const{
if(!record()->is_on_map(x,y)) return false;
return is_force_cage(fields[x][y]);
}
bool cCurTown::set_explored(short x, short y, bool b){
if(!record()->is_on_map(x,y)) return false;
if(b) fields[x][y] |= SPECIAL_EXPLORED;

View File

@@ -9,18 +9,19 @@
#ifndef BOE_DATA_UNIVERSE_H
#define BOE_DATA_UNIVERSE_H
#include <array>
#include <iosfwd>
#include <memory>
#include <set>
#include <array>
#include <boost/filesystem/path.hpp>
#include "party.hpp"
#include "population.hpp"
#include "fields.hpp"
#include "item.hpp"
#include "party.hpp"
#include "pictypes.hpp"
#include "population.hpp"
#include "scenario.hpp"
#include "talking.hpp"
#include "town.hpp"
#include "pictypes.hpp"
namespace legacy {
struct out_info_type;
@@ -37,6 +38,17 @@ class cCurTown {
cUniverse& univ;
cTown* arena;
cTown*const record() const;
template<eFieldType Field> static bool test_field(unsigned long allFields)
{
return allFields & Field;
}
template<eFieldType Field> bool test_field(short x, short y) const
{
if(!record()->is_on_map(x,y)) return false;
return fields[x][y] & Field;
}
public:
bool quickfire_present = false, belt_present = false;
// formerly current_town_type
@@ -61,59 +73,59 @@ public:
void prep_arena(); // Set up for a combat arena
void place_preset_fields();
static bool is_explored(unsigned long allFields) { return allFields & SPECIAL_EXPLORED; }
static bool is_force_wall(unsigned long allFields) { return allFields & WALL_FORCE; }
static bool is_fire_wall(unsigned long allFields) { return allFields & WALL_FIRE; }
static bool is_antimagic(unsigned long allFields) { return allFields & FIELD_ANTIMAGIC; }
static bool is_scloud(unsigned long allFields) { return allFields & CLOUD_STINK; } // stinking cloud
static bool is_ice_wall(unsigned long allFields) { return allFields & WALL_ICE; }
static bool is_blade_wall(unsigned long allFields) { return allFields & WALL_BLADES; }
static bool is_sleep_cloud(unsigned long allFields) { return allFields & CLOUD_SLEEP; }
static bool is_block(unsigned long allFields) { return allFields & OBJECT_BLOCK; } // currently unused
static bool is_spot(unsigned long allFields) { return allFields & SPECIAL_SPOT; }
static bool is_web(unsigned long allFields) { return allFields & FIELD_WEB; }
static bool is_crate(unsigned long allFields) { return allFields & OBJECT_CRATE; }
static bool is_barrel(unsigned long allFields) { return allFields & OBJECT_BARREL; }
static bool is_fire_barr(unsigned long allFields) { return allFields & BARRIER_FIRE; }
static bool is_force_barr(unsigned long allFields) { return allFields & BARRIER_FORCE; }
static bool is_quickfire(unsigned long allFields) { return allFields & FIELD_QUICKFIRE; }
static bool is_sm_blood(unsigned long allFields) { return allFields & SFX_SMALL_BLOOD; }
static bool is_med_blood(unsigned long allFields) { return allFields & SFX_MEDIUM_BLOOD; }
static bool is_lg_blood(unsigned long allFields) { return allFields & SFX_LARGE_BLOOD; }
static bool is_sm_slime(unsigned long allFields) { return allFields & SFX_SMALL_SLIME; }
static bool is_lg_slime(unsigned long allFields) { return allFields & SFX_LARGE_SLIME; }
static bool is_ash(unsigned long allFields) { return allFields & SFX_ASH; }
static bool is_bones(unsigned long allFields) { return allFields & SFX_BONES; }
static bool is_rubble(unsigned long allFields) { return allFields & SFX_RUBBLE; }
static bool is_force_cage(unsigned long allFields) { return allFields & BARRIER_CAGE; }
static bool is_road(unsigned long allFields) { return allFields & SPECIAL_ROAD; }
bool is_explored(short x, short y) const;
bool is_force_wall(short x, short y) const;
bool is_fire_wall(short x, short y) const;
bool is_antimagic(short x, short y) const;
bool is_scloud(short x, short y) const; // stinking cloud
bool is_ice_wall(short x, short y) const;
bool is_blade_wall(short x, short y) const;
bool is_sleep_cloud(short x, short y) const;
bool is_block(short x, short y) const; // currently unused
bool is_spot(short x, short y) const;
static bool is_explored(unsigned long allFields) { return test_field<SPECIAL_EXPLORED>(allFields); }
static bool is_force_wall(unsigned long allFields) { return test_field<WALL_FORCE>(allFields); }
static bool is_fire_wall(unsigned long allFields) { return test_field<WALL_FIRE>(allFields); }
static bool is_antimagic(unsigned long allFields) { return test_field<FIELD_ANTIMAGIC>(allFields); }
static bool is_scloud(unsigned long allFields) { return test_field<CLOUD_STINK>(allFields); } // stinking cloud
static bool is_ice_wall(unsigned long allFields) { return test_field<WALL_ICE>(allFields); }
static bool is_blade_wall(unsigned long allFields) { return test_field<WALL_BLADES>(allFields); }
static bool is_sleep_cloud(unsigned long allFields) { return test_field<CLOUD_SLEEP>(allFields); }
static bool is_block(unsigned long allFields) { return test_field<OBJECT_BLOCK>(allFields); } // currently unused
static bool is_spot(unsigned long allFields) { return test_field<SPECIAL_SPOT>(allFields); }
static bool is_web(unsigned long allFields) { return test_field<FIELD_WEB>(allFields); }
static bool is_crate(unsigned long allFields) { return test_field<OBJECT_CRATE>(allFields); }
static bool is_barrel(unsigned long allFields) { return test_field<OBJECT_BARREL>(allFields); }
static bool is_fire_barr(unsigned long allFields) { return test_field<BARRIER_FIRE>(allFields); }
static bool is_force_barr(unsigned long allFields) { return test_field<BARRIER_FORCE>(allFields); }
static bool is_quickfire(unsigned long allFields) { return test_field<FIELD_QUICKFIRE>(allFields); }
static bool is_sm_blood(unsigned long allFields) { return test_field<SFX_SMALL_BLOOD>(allFields); }
static bool is_med_blood(unsigned long allFields) { return test_field<SFX_MEDIUM_BLOOD>(allFields); }
static bool is_lg_blood(unsigned long allFields) { return test_field<SFX_LARGE_BLOOD>(allFields); }
static bool is_sm_slime(unsigned long allFields) { return test_field<SFX_SMALL_SLIME>(allFields); }
static bool is_lg_slime(unsigned long allFields) { return test_field<SFX_LARGE_SLIME>(allFields); }
static bool is_ash(unsigned long allFields) { return test_field<SFX_ASH>(allFields); }
static bool is_bones(unsigned long allFields) { return test_field<SFX_BONES>(allFields); }
static bool is_rubble(unsigned long allFields) { return test_field<SFX_RUBBLE>(allFields); }
static bool is_force_cage(unsigned long allFields) { return test_field<BARRIER_CAGE>(allFields); }
static bool is_road(unsigned long allFields) { return test_field<SPECIAL_ROAD>(allFields); }
bool is_explored(short x, short y) const { return test_field<SPECIAL_EXPLORED>(x,y); }
bool is_force_wall(short x, short y) const { return test_field<WALL_FORCE>(x,y); }
bool is_fire_wall(short x, short y) const { return test_field<WALL_FIRE>(x,y); }
bool is_antimagic(short x, short y) const { return test_field<FIELD_ANTIMAGIC>(x,y); }
bool is_scloud(short x, short y) const { return test_field<CLOUD_STINK>(x,y); } // stinking cloud
bool is_ice_wall(short x, short y) const { return test_field<WALL_ICE>(x,y); }
bool is_blade_wall(short x, short y) const { return test_field<WALL_BLADES>(x,y); }
bool is_sleep_cloud(short x, short y) const { return test_field<CLOUD_SLEEP>(x,y); }
bool is_block(short x, short y) const { return test_field<OBJECT_BLOCK>(x,y); } // currently unused
bool is_spot(short x, short y) const { return test_field<SPECIAL_SPOT>(x,y); }
bool is_special(short x, short y) const;
bool is_web(short x, short y) const;
bool is_crate(short x, short y) const;
bool is_barrel(short x, short y) const;
bool is_fire_barr(short x, short y) const;
bool is_force_barr(short x, short y) const;
bool is_quickfire(short x, short y) const;
bool is_sm_blood(short x, short y) const;
bool is_med_blood(short x, short y) const;
bool is_lg_blood(short x, short y) const;
bool is_sm_slime(short x, short y) const;
bool is_lg_slime(short x, short y) const;
bool is_ash(short x, short y) const;
bool is_bones(short x, short y) const;
bool is_rubble(short x, short y) const;
bool is_force_cage(short x, short y) const;
bool is_road(short x, short y) const;
bool is_web(short x, short y) const { return test_field<FIELD_WEB>(x,y); }
bool is_crate(short x, short y) const { return test_field<OBJECT_CRATE>(x,y); }
bool is_barrel(short x, short y) const { return test_field<OBJECT_BARREL>(x,y); }
bool is_fire_barr(short x, short y) const { return test_field<BARRIER_FIRE>(x,y); }
bool is_force_barr(short x, short y) const { return test_field<BARRIER_FORCE>(x,y); }
bool is_quickfire(short x, short y) const { return test_field<FIELD_QUICKFIRE>(x,y); }
bool is_sm_blood(short x, short y) const { return test_field<SFX_SMALL_BLOOD>(x,y); }
bool is_med_blood(short x, short y) const { return test_field<SFX_MEDIUM_BLOOD>(x,y); }
bool is_lg_blood(short x, short y) const { return test_field<SFX_LARGE_BLOOD>(x,y); }
bool is_sm_slime(short x, short y) const { return test_field<SFX_SMALL_SLIME>(x,y); }
bool is_lg_slime(short x, short y) const { return test_field<SFX_LARGE_SLIME>(x,y); }
bool is_ash(short x, short y) const { return test_field<SFX_ASH>(x,y); }
bool is_bones(short x, short y) const { return test_field<SFX_BONES>(x,y); }
bool is_rubble(short x, short y) const { return test_field<SFX_RUBBLE>(x,y); }
bool is_force_cage(short x, short y) const { return test_field<BARRIER_CAGE>(x,y); }
bool is_road(short x, short y) const { return test_field<SPECIAL_ROAD>(x,y); }
bool set_explored(short x, short y, bool b);
bool set_force_wall(short x, short y, bool b);
bool set_fire_wall(short x, short y, bool b);