Lot more tests!

- Tests for converting legacy terrain types
- Tests for initialization to sane values

Fixes:
- cCreature no longer initializes spec1 and spec2 to 0. This probably didn't cause bugs, but who knows...
- In fact, cCreature no longer explicitly initializes anything in its cTownperson superclass. That's what the superclass constructor is for after all.
- Relatedly, cTownperson now defaults to a facial graphic of -1. Also a docile attitude.
- iLiving defaults to ap 0, direction here.
- Fix Change When Step terrains to properly support not having a sound while still allowing an arbitrary number of custom sounds.
- Add support for a lack of sound to Change When Used terrains, including at conversion time (original game supported it but OBoE was forcing the sound to a door sound).
- Fix conversion of crumbling terrain types (old conversion was allowing quickfire to destroy them)

Other:
- New addAttack method in cMonster.
- Change snd_num_t to signed, because it's been getting annoying that I can't easily use -1 to mean "no sound".
This commit is contained in:
2015-10-04 18:44:58 -04:00
parent d178dcea63
commit 96229d1f40
12 changed files with 489 additions and 27 deletions

View File

@@ -262,6 +262,8 @@
91CC173E1B421CA0003D9A69 /* scen_write.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91CC173B1B421CA0003D9A69 /* scen_write.cpp */; };
91CC17491B422D5C003D9A69 /* scen_read.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91CC173A1B421CA0003D9A69 /* scen_read.cpp */; };
91D634560F8FD77800674AB3 /* BoE.icns in Resources */ = {isa = PBXBuildFile; fileRef = 2B8F435C0C0973680012E4A8 /* BoE.icns */; };
91E128E41BC1624700C8BE1D /* ter_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E128E31BC1624700C8BE1D /* ter_legacy.cpp */; };
91E128E61BC19DA400C8BE1D /* init.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E128E51BC19DA400C8BE1D /* init.cpp */; };
91E381461B97673700F69B81 /* town_write.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E381451B97671E00F69B81 /* town_write.cpp */; };
91E381481B97677900F69B81 /* talk_write.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E381471B97675900F69B81 /* talk_write.cpp */; };
91E3814A1B97679800F69B81 /* out_write.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E381491B97678D00F69B81 /* out_write.cpp */; };
@@ -750,6 +752,8 @@
91D635AD0F90E7B500674AB3 /* valleydy.meg */ = {isa = PBXFileReference; lastKnownFileType = file; path = valleydy.meg; sourceTree = "<group>"; };
91D635AE0F90E7B500674AB3 /* zakhazi.exs */ = {isa = PBXFileReference; lastKnownFileType = file; path = zakhazi.exs; sourceTree = "<group>"; };
91D635AF0F90E7B500674AB3 /* zakhazi.meg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zakhazi.meg; sourceTree = "<group>"; };
91E128E31BC1624700C8BE1D /* ter_legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ter_legacy.cpp; sourceTree = "<group>"; };
91E128E51BC19DA400C8BE1D /* init.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = init.cpp; sourceTree = "<group>"; };
91E1862B1B2B2AC0006A99EA /* estreams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = estreams.cpp; sourceTree = "<group>"; };
91E30F2A1A74819B0057C54A /* fileio_party.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fileio_party.cpp; sourceTree = "<group>"; };
91E30F2D1A7481C20057C54A /* fileio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fileio.cpp; sourceTree = "<group>"; };
@@ -1324,6 +1328,7 @@
children = (
91CC17391B421CA0003D9A69 /* catch.cpp */,
91C763D81B4C4BB30086D879 /* enums.cpp */,
91E128E51BC19DA400C8BE1D /* init.cpp */,
919B13A31BBD8849009905A4 /* item_legacy.cpp */,
91EF27761B693D5500666469 /* item_read.cpp */,
91EF27781B693D5F00666469 /* item_write.cpp */,
@@ -1339,6 +1344,7 @@
919B13A51BBDE985009905A4 /* spec_legacy.cpp */,
91C2A6EE1B8FAA8E00346948 /* talk_read.cpp */,
91E381471B97675900F69B81 /* talk_write.cpp */,
91E128E31BC1624700C8BE1D /* ter_legacy.cpp */,
91EF27721B693D3800666469 /* ter_read.cpp */,
91EF27741B693D4800666469 /* ter_write.cpp */,
91C2A6EC1B8FA91400346948 /* town_read.cpp */,
@@ -1868,6 +1874,8 @@
919B13A21BBCDF14009905A4 /* monst_legacy.cpp in Sources */,
919B13A41BBD8854009905A4 /* item_legacy.cpp in Sources */,
919B13A61BBDE986009905A4 /* spec_legacy.cpp in Sources */,
91E128E41BC1624700C8BE1D /* ter_legacy.cpp in Sources */,
91E128E61BC19DA400C8BE1D /* init.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -293,7 +293,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
break;
case eTerSpec::CHANGE_WHEN_STEP_ON:
alter_space(where_check.x,where_check.y,ter_flag1);
if(ter_flag2 < 200) {
if(ter_flag2 >= 0) {
play_sound(-1 * ter_flag2);
}
give_help(47,65);
@@ -1256,7 +1256,8 @@ bool use_space(location where) {
}
add_string_to_buf(" OK.");
alter_space(where.x,where.y,univ.scenario.ter_types[ter].flag1);
play_sound(univ.scenario.ter_types[ter].flag2);
if(univ.scenario.ter_types[ter].flag2 >= 0)
play_sound(univ.scenario.ter_types[ter].flag2);
return true;
} else if(univ.scenario.ter_types[ter].special == eTerSpec::CALL_SPECIAL_WHEN_USED) {
short spec_type = 0;

View File

@@ -17,15 +17,11 @@
const short cCreature::charm_odds[21] = {90,90,85,80,78, 75,73,60,40,30, 20,10,4,1,0, 0,0,0,0,0, 0};
cCreature::cCreature(){
number = active = 0;
attitude = start_attitude = eAttitude::DOCILE;
start_loc.x = start_loc.y = cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80;
mobility = 1;
summon_time = 0;
time_flag = eMonstTime::ALWAYS;
spec1 = spec2 = spec_enc_code = time_code = monster_time = 0;
personality = special_on_kill = facial_pic = -1;
cCreature::cCreature() {
active = 0;
attitude = eAttitude::DOCILE;
cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80;
summon_time = 0;
target = 6;
}

View File

@@ -19,8 +19,8 @@ class iLiving {
public:
// HACK: This is only really marked mutable so that I can use operator[] from const methods
mutable std::map<eStatus,short> status;
short ap;
eDirection direction;
short ap = 0;
eDirection direction = DIR_HERE;
short marked_damage = 0; // for use during animations
virtual bool is_alive() const = 0;

View File

@@ -138,6 +138,17 @@ void cMonster::append(legacy::monster_record_type& old){
see_spec = -1;
}
int cMonster::addAttack(unsigned short dice, unsigned short sides, eMonstMelee type) {
int which = 0;
while(which < 3 && a[which].dice > 0 && a[which].sides > 0)
which++;
if(which >= 3) return -1;
a[which].dice = dice;
a[which].sides = sides;
a[which].type = type;
return which;
}
std::map<eMonstAbil,uAbility>::iterator cMonster::addAbil(eMonstAbilTemplate what, int param) {
switch(what) {
// Missiles: {true, type, missile pic, dice, sides, skill, range, odds}
@@ -415,6 +426,8 @@ cTownperson::cTownperson() {
personality = -1;
special_on_kill = -1;
special_on_talk = -1;
facial_pic = -1;
start_attitude = eAttitude::DOCILE;
}
cTownperson::cTownperson(location loc, mon_num_t num, const cMonster& monst) : cTownperson() {

View File

@@ -120,6 +120,7 @@ public:
spec_num_t see_spec;
std::map<eMonstAbil,uAbility>::iterator addAbil(eMonstAbilTemplate what, int param = 0);
int addAttack(unsigned short dice, unsigned short sides, eMonstMelee type = eMonstMelee::SWING);
void append(legacy::monster_record_type& old);
cMonster();

View File

@@ -162,6 +162,7 @@ void cTerrain::append(legacy::terrain_type_type& old){
break;
case 1:
special = eTerSpec::CHANGE_WHEN_STEP_ON;
if(flag2 == 200) flag2 = -1;
flag3 = 0;
break;
case 2:
@@ -186,7 +187,7 @@ void cTerrain::append(legacy::terrain_type_type& old){
break;
case 7:
special = eTerSpec::CRUMBLING;
flag2 = 1; // destroyed by Move Mountains but not by quickfire; 0 = both, 2 = quickfire only
flag2 = 0; // destroyed by Move Mountains but not by quickfire; 1 = both, 2 = quickfire only
break;
case 8:
special = eTerSpec::LOCKABLE;
@@ -254,7 +255,6 @@ void cTerrain::append(legacy::terrain_type_type& old){
break;
case 22:
special = eTerSpec::CHANGE_WHEN_USED;
flag2 = 59;
flag3 = 0;
break;
case 23:

View File

@@ -11,7 +11,7 @@
#include <SFML/Audio.hpp>
typedef unsigned short snd_num_t;
typedef signed int snd_num_t;
void init_snd_tool();
bool sound_going(snd_num_t which_s);
void play_sound(short which, short how_many_times = 1);