Eliminate use of __attribute__

Ideally this would be standard C++, but here I've settled for things that should be supported by both clang and VS/cl.exe:
- Deprecated attribute retained, but now uses __declspec syntax
- Packed attribute replaced with pragma pack, except one instance where it unnecessary
- Aligned attribute replaced with explicit padding bytes inserted in the structs where needed
- Unused attribute simply removed (though where possible, the unused entities were also removed)
This commit is contained in:
2014-12-02 13:07:11 -05:00
parent d61c0a5c1e
commit 03c64ebd7b
20 changed files with 545 additions and 83 deletions

View File

@@ -328,6 +328,7 @@
914B2B9418E8005B007B6799 /* SND99.WAV in Copy Mac Sounds */ = {isa = PBXBuildFile; fileRef = 914B2B2E18E7FFEF007B6799 /* SND99.WAV */; };
914CA4441905789C00B6ADD1 /* watch.gif in Copy Mac Cursors */ = {isa = PBXBuildFile; fileRef = 914CA4431905788F00B6ADD1 /* watch.gif */; };
914CA45819074E0100B6ADD1 /* scen.menus.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 914CA45719074D0A00B6ADD1 /* scen.menus.mac.mm */; };
915325171A2E1DF0000A9A1C /* oldstructs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 915325161A2E1DA8000A9A1C /* oldstructs.cpp */; };
91870F81190C8C1C0081C150 /* winutil.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 919145FF18E63B70005CF3A4 /* winutil.mac.mm */; };
91870F83190C8C1F0081C150 /* tarball.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91BFA3D81902AD78001686E4 /* tarball.cpp */; };
91870F84190C90980081C150 /* scen.menu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 914CA49F190C4E9200B6ADD1 /* scen.menu.xib */; };
@@ -1245,6 +1246,7 @@
914CA45719074D0A00B6ADD1 /* scen.menus.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = scen.menus.mac.mm; sourceTree = "<group>"; };
914CA4641909B00100B6ADD1 /* scen.menus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = scen.menus.h; sourceTree = "<group>"; };
914CA49F190C4E9200B6ADD1 /* scen.menu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = scen.menu.xib; sourceTree = "<group>"; };
915325161A2E1DA8000A9A1C /* oldstructs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = oldstructs.cpp; path = ../oldstructs.cpp; sourceTree = "<group>"; };
917B573F100B956C0096C978 /* undo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = undo.h; sourceTree = "<group>"; };
918D59A718EA513900735B66 /* dialog.keys.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = dialog.keys.h; sourceTree = "<group>"; };
919145FB18E3A32F005CF3A4 /* boe.appleevents.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = boe.appleevents.mm; sourceTree = "<group>"; };
@@ -1493,6 +1495,7 @@
913D03320FA0FFE700184C18 /* src */,
91AC61300FA270B300EEAE67 /* classes.h */,
91E5C5A10F9EACE200C21460 /* oldstructs.h */,
915325161A2E1DA8000A9A1C /* oldstructs.cpp */,
);
path = classes;
sourceTree = "<group>";
@@ -2396,6 +2399,7 @@
91FCC8F218FEEFE0007026CE /* pc.editors.cpp in Sources */,
91BFA3DA1902B13D001686E4 /* tarball.cpp in Sources */,
91BFA3E919033E01001686E4 /* gzstream.cpp in Sources */,
915325171A2E1DF0000A9A1C /* oldstructs.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -47,7 +47,7 @@ bool load_scenario_header(fs::path filename/*,short header_entry*/);
//short get_buf_ptr(short flag);
//bool check_p (short pword);
void init_town() __attribute__((deprecated));
__declspec(deprecated) void init_town();
//void port_talk_nodes();
//void port_town();

View File

@@ -148,6 +148,10 @@ void check_for_intel();
bool mac_is_intel;
int main(int argc, char* argv[]) {
#if 0
void debug_oldstructs();
debug_oldstructs();
#endif
try{
init_directories(argv[0]);
//data_store = (piles_of_stuff_dumping_type *) NewPtr(sizeof(piles_of_stuff_dumping_type));

View File

@@ -1,6 +1,6 @@
class cDialog;
void init_party(short mode) __attribute__((deprecated));
void init_party_scen_data() __attribute__((deprecated));
__declspec(deprecated) void init_party(short mode);
__declspec(deprecated) void init_party_scen_data();
void make_boats();
bool create_pc(short spot,cDialog* parent_num);
bool take_sp(short pc_num,short amt);

View File

@@ -66,7 +66,7 @@ public:
char sign_strs[8][256];
bool special_spot[48][48];
char(& out_strs(short i))[256] __attribute__((deprecated));
__declspec(deprecated) char(& out_strs(short i))[256];
cOutdoors();
cOutdoors& operator = (legacy::outdoor_record_type& old);
};

View File

@@ -100,7 +100,7 @@ public:
cOutdoors* outdoors;
cTown* towns;
char(& scen_strs(short i))[256] __attribute__((deprecated));
__declspec(deprecated) char(& scen_strs(short i))[256];
cScenario& operator = (legacy::scenario_data_type& old);
void append(legacy::scen_item_data_type& old);
void writeTo(std::ostream& file);

View File

@@ -99,7 +99,7 @@ public:
char comment[3][256];
char spec_strs[100][256];
char sign_strs[20][256];
char(& town_strs(short i))[256] __attribute__((deprecated));
__declspec(deprecated) char(& town_strs(short i))[256];
cSpeech talking;
virtual ~cTown(){}

View File

@@ -56,9 +56,9 @@ public:
void append(unsigned char(& old_sfx)[64][64], unsigned char(& old_misc_i)[64][64]);
void append(legacy::big_tr_type& old);
unsigned char explored(char x,char y) const __attribute__((deprecated));
unsigned char misc_i(char x, char y) const __attribute__((deprecated));
unsigned char sfx(char x, char y) const __attribute__((deprecated));
__declspec(deprecated) unsigned char explored(char x,char y) const;
__declspec(deprecated) unsigned char misc_i(char x, char y) const;
__declspec(deprecated) unsigned char sfx(char x, char y) const;
cTown* operator -> ();
cCurTown();

View File

@@ -22,7 +22,7 @@
extern sf::Texture bg_gworld;
void cButton::attachFocusHandler(focus_callback_t f __attribute__((unused))) throw(xHandlerNotSupported){
void cButton::attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported){
throw xHandlerNotSupported(true);
}
@@ -388,11 +388,11 @@ void cLedGroup::hide(std::string id){
choices[id]->hide();
}
void cLedGroup::setFormat(eFormat prop __attribute__((unused)), short val __attribute__((unused))) throw(xUnsupportedProp) {
void cLedGroup::setFormat(eFormat prop, short val) throw(xUnsupportedProp) {
throw xUnsupportedProp(prop);
}
short cLedGroup::getFormat(eFormat prop __attribute__((unused))) throw(xUnsupportedProp) {
short cLedGroup::getFormat(eFormat prop) throw(xUnsupportedProp) {
throw xUnsupportedProp(prop);
}

View File

@@ -256,11 +256,11 @@ cControl::cControl(eControlType t, cDialog& p) : parent(&p), inWindow(&p.win), t
cControl::cControl(eControlType t, sf::RenderWindow& p) : parent(NULL), inWindow(&p), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {}
bool cControl::triggerClickHandler(cDialog& __attribute__((unused)), std::string __attribute__((unused)), eKeyMod __attribute__((unused)), location __attribute__((unused))){
bool cControl::triggerClickHandler(cDialog&, std::string, eKeyMod, location){
return true;
}
bool cControl::triggerFocusHandler(cDialog& me __attribute__((unused)), std::string id __attribute__((unused)), bool losingFocus __attribute__((unused))){
bool cControl::triggerFocusHandler(cDialog& me, std::string id, bool losingFocus){
return true;
}

View File

@@ -150,12 +150,12 @@ cStringChoice::cStringChoice(
void cStringChoice::attachHandlers() {
using namespace std::placeholders;
dlg["left"].attachClickHandler(std::bind(&cStringChoice::onLeft,this,_1,_2));
dlg["right"].attachClickHandler(std::bind(&cStringChoice::onRight,this,_1,_2));
dlg["done"].attachClickHandler(std::bind(&cStringChoice::onOkay,this,_1,_2));
dlg["cancel"].attachClickHandler(std::bind(&cStringChoice::onCancel,this,_1,_2));
dlg["left"].attachClickHandler(std::bind(&cStringChoice::onLeft,this));
dlg["right"].attachClickHandler(std::bind(&cStringChoice::onRight,this));
dlg["done"].attachClickHandler(std::bind(&cStringChoice::onOkay,this,_1));
dlg["cancel"].attachClickHandler(std::bind(&cStringChoice::onCancel,this,_1));
leds = &dynamic_cast<cLedGroup&>(dlg["strings"]);
leds->attachFocusHandler(std::bind(&cStringChoice::onSelect,this,_1,_3));
leds->attachFocusHandler(std::bind(&cStringChoice::onSelect,this,_3));
}
size_t cStringChoice::show(std::string select){
@@ -193,32 +193,32 @@ void cStringChoice::fillPage(){
}
}
bool cStringChoice::onLeft(cDialog& me __attribute__((unused)), std::string id __attribute__((unused))){
bool cStringChoice::onLeft(){
if(page == 0) page = strings.size() / per_page;
else page--;
fillPage();
return true;
}
bool cStringChoice::onRight(cDialog& me __attribute__((unused)), std::string id __attribute__((unused))){
bool cStringChoice::onRight(){
if(page == strings.size() / per_page) page = 0;
else page++;
fillPage();
return true;
}
bool cStringChoice::onCancel(cDialog& me, std::string id __attribute__((unused))){
bool cStringChoice::onCancel(cDialog& me){
me.toast();
return true;
}
bool cStringChoice::onOkay(cDialog& me, std::string id __attribute__((unused))){
bool cStringChoice::onOkay(cDialog& me){
dlg.setResult(cur);
me.toast();
return true;
}
bool cStringChoice::onSelect(cDialog& me, bool losing) {
bool cStringChoice::onSelect(bool losing) {
if(losing) return true;
int i = boost::lexical_cast<int>(leds->getSelected().substr(3));
cur = page * 40 + i - 1;

View File

@@ -82,11 +82,11 @@ public:
class cStringChoice {
static const size_t per_page;
cDialog dlg;
bool onLeft(cDialog& me, std::string id);
bool onRight(cDialog& me, std::string id);
bool onCancel(cDialog& me, std::string id);
bool onOkay(cDialog& me, std::string id);
bool onSelect(cDialog& me, bool losing);
bool onLeft();
bool onRight();
bool onCancel(cDialog& me);
bool onOkay(cDialog& me);
bool onSelect(bool losing);
void attachHandlers();
void fillPage();
std::vector<std::string> strings;

View File

@@ -11,11 +11,11 @@
#include "dialog.h"
#include "graphtool.h"
void cTextField::attachClickHandler(click_callback_t f __attribute__((unused))) throw(xHandlerNotSupported){
void cTextField::attachClickHandler(click_callback_t f) throw(xHandlerNotSupported){
throw xHandlerNotSupported(false);
}
void cTextField::attachFocusHandler(focus_callback_t f __attribute__((unused))) throw(){
void cTextField::attachFocusHandler(focus_callback_t f) throw(){
onFocus = f;
}
@@ -29,7 +29,7 @@ bool cTextField::triggerFocusHandler(cDialog& me, std::string id, bool losingFoc
return passed;
}
void cTextField::setFormat(eFormat prop, short val __attribute__((unused))) throw(xUnsupportedProp){
void cTextField::setFormat(eFormat prop, short val) throw(xUnsupportedProp){
throw xUnsupportedProp(prop);
}

View File

@@ -18,7 +18,7 @@ void cTextMsg::attachClickHandler(click_callback_t f) throw(){
clickable = onClick != NULL;
}
void cTextMsg::attachFocusHandler(focus_callback_t f __attribute__((unused))) throw(xHandlerNotSupported){
void cTextMsg::attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported){
throw xHandlerNotSupported(true);
}

View File

@@ -76,7 +76,7 @@ void cPict::attachClickHandler(click_callback_t f) throw(){
}
}
void cPict::attachFocusHandler(focus_callback_t f __attribute__((unused))) throw(xHandlerNotSupported){
void cPict::attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported){
throw xHandlerNotSupported(true);
}

447
osx/oldstructs.cpp Normal file
View File

@@ -0,0 +1,447 @@
//
// oldstructs.cpp
// BoE
//
// Created by Celtic Minstrel on 14-12-02.
//
//
#include "oldstructs.h"
#include <fstream>
#include <unistd.h>
using namespace legacy;
#define STRUCT_INFO(what) \
log << #what << ": " << sizeof(what) << " bytes" << std::endl
#define MEM_INFO(what,member) \
log << " " << #member << ": " << sizeof(what :: member) << " bytes, offset " \
<< offsetof(what,member) << std::endl
// This is just a function to output all known information about each struct and its members.
void debug_oldstructs() {
char cwd[256];
getcwd(cwd, 256);
printf("%s" ,cwd);
std::ofstream log("oldstructs.txt");
STRUCT_INFO(Rect);
MEM_INFO(Rect,top);
MEM_INFO(Rect,left);
MEM_INFO(Rect,bottom);
MEM_INFO(Rect,right);
STRUCT_INFO(Boolean);
STRUCT_INFO(location);
MEM_INFO(location,x);
MEM_INFO(location,y);
STRUCT_INFO(special_node_type);
MEM_INFO(special_node_type,type);
MEM_INFO(special_node_type,sd1);
MEM_INFO(special_node_type,sd2);
MEM_INFO(special_node_type,pic);
MEM_INFO(special_node_type,m1);
MEM_INFO(special_node_type,m2);
MEM_INFO(special_node_type,ex1a);
MEM_INFO(special_node_type,ex1b);
MEM_INFO(special_node_type,ex2a);
MEM_INFO(special_node_type,ex2b);
MEM_INFO(special_node_type,jumpto);
STRUCT_INFO(talking_node_type);
MEM_INFO(talking_node_type,personality);
MEM_INFO(talking_node_type,type);
MEM_INFO(talking_node_type,link1);
MEM_INFO(talking_node_type,link2);
MEM_INFO(talking_node_type,extras);
STRUCT_INFO(talking_record_type);
MEM_INFO(talking_record_type,strlens);
MEM_INFO(talking_record_type,talk_nodes);
STRUCT_INFO(terrain_type_type);
MEM_INFO(terrain_type_type,picture);
MEM_INFO(terrain_type_type,blockage);
MEM_INFO(terrain_type_type,flag1);
MEM_INFO(terrain_type_type,flag2);
MEM_INFO(terrain_type_type,special);
MEM_INFO(terrain_type_type,trans_to_what);
MEM_INFO(terrain_type_type,fly_over);
MEM_INFO(terrain_type_type,boat_over);
MEM_INFO(terrain_type_type,block_horse);
MEM_INFO(terrain_type_type,light_radius);
MEM_INFO(terrain_type_type,step_sound);
MEM_INFO(terrain_type_type,shortcut_key);
MEM_INFO(terrain_type_type,res1);
MEM_INFO(terrain_type_type,res2);
MEM_INFO(terrain_type_type,res3);
STRUCT_INFO(wandering_type);
MEM_INFO(wandering_type,monst);
STRUCT_INFO(out_wandering_type);
MEM_INFO(out_wandering_type,monst);
MEM_INFO(out_wandering_type,friendly);
MEM_INFO(out_wandering_type,spec_on_meet);
MEM_INFO(out_wandering_type,spec_on_win);
MEM_INFO(out_wandering_type,spec_on_flee);
MEM_INFO(out_wandering_type,cant_flee);
MEM_INFO(out_wandering_type,end_spec1);
MEM_INFO(out_wandering_type,end_spec2);
STRUCT_INFO(outdoor_record_type);
MEM_INFO(outdoor_record_type,terrain);
MEM_INFO(outdoor_record_type,special_locs);
MEM_INFO(outdoor_record_type,special_id);
MEM_INFO(outdoor_record_type,exit_locs);
MEM_INFO(outdoor_record_type,exit_dests);
MEM_INFO(outdoor_record_type,sign_locs);
MEM_INFO(outdoor_record_type,wandering);
MEM_INFO(outdoor_record_type,special_enc);
MEM_INFO(outdoor_record_type,wandering_locs);
MEM_INFO(outdoor_record_type,info_rect);
MEM_INFO(outdoor_record_type,strlens);
MEM_INFO(outdoor_record_type,specials);
STRUCT_INFO(creature_start_type);
MEM_INFO(creature_start_type,number);
MEM_INFO(creature_start_type,start_attitude);
MEM_INFO(creature_start_type,start_loc);
MEM_INFO(creature_start_type,mobile);
MEM_INFO(creature_start_type,time_flag);
MEM_INFO(creature_start_type,extra1);
MEM_INFO(creature_start_type,extra2);
MEM_INFO(creature_start_type,spec1);
MEM_INFO(creature_start_type,spec2);
MEM_INFO(creature_start_type,spec_enc_code);
MEM_INFO(creature_start_type,time_code);
MEM_INFO(creature_start_type,monster_time);
MEM_INFO(creature_start_type,personality);
MEM_INFO(creature_start_type,special_on_kill);
MEM_INFO(creature_start_type,facial_pic);
STRUCT_INFO(short_item_record_type);
MEM_INFO(short_item_record_type,variety);
MEM_INFO(short_item_record_type,item_level);
MEM_INFO(short_item_record_type,awkward);
MEM_INFO(short_item_record_type,bonus);
MEM_INFO(short_item_record_type,protection);
MEM_INFO(short_item_record_type,charges);
MEM_INFO(short_item_record_type,type);
MEM_INFO(short_item_record_type,graphic_num);
MEM_INFO(short_item_record_type,ability);
MEM_INFO(short_item_record_type,type_flag);
MEM_INFO(short_item_record_type,is_special);
MEM_INFO(short_item_record_type,value);
MEM_INFO(short_item_record_type,identified);
MEM_INFO(short_item_record_type,magic);
MEM_INFO(short_item_record_type,weight);
MEM_INFO(short_item_record_type,description_flag);
MEM_INFO(short_item_record_type,full_name);
MEM_INFO(short_item_record_type,name);
MEM_INFO(short_item_record_type,reserved1);
MEM_INFO(short_item_record_type,reserved2);
MEM_INFO(short_item_record_type,magic_use_type);
MEM_INFO(short_item_record_type,ability_strength);
MEM_INFO(short_item_record_type,treas_class);
MEM_INFO(short_item_record_type,real_abil);
STRUCT_INFO(item_record_type);
MEM_INFO(item_record_type,variety);
MEM_INFO(item_record_type,item_level);
MEM_INFO(item_record_type,awkward);
MEM_INFO(item_record_type,bonus);
MEM_INFO(item_record_type,protection);
MEM_INFO(item_record_type,charges);
MEM_INFO(item_record_type,type);
MEM_INFO(item_record_type,magic_use_type);
MEM_INFO(item_record_type,graphic_num);
MEM_INFO(item_record_type,ability);
MEM_INFO(item_record_type,ability_strength);
MEM_INFO(item_record_type,type_flag);
MEM_INFO(item_record_type,is_special);
MEM_INFO(item_record_type,value);
MEM_INFO(item_record_type,weight);
MEM_INFO(item_record_type,special_class);
MEM_INFO(item_record_type,item_loc);
MEM_INFO(item_record_type,full_name);
MEM_INFO(item_record_type,name);
MEM_INFO(item_record_type,treas_class);
MEM_INFO(item_record_type,item_properties);
MEM_INFO(item_record_type,reserved1);
MEM_INFO(item_record_type,reserved2);
STRUCT_INFO(preset_item_type);
MEM_INFO(preset_item_type,item_loc);
MEM_INFO(preset_item_type,item_code);
MEM_INFO(preset_item_type,ability);
MEM_INFO(preset_item_type,charges);
MEM_INFO(preset_item_type,always_there);
MEM_INFO(preset_item_type,property);
MEM_INFO(preset_item_type,contained);
STRUCT_INFO(preset_field_type);
MEM_INFO(preset_field_type,field_loc);
MEM_INFO(preset_field_type,field_type);
STRUCT_INFO(town_record_type);
MEM_INFO(town_record_type,town_chop_time);
MEM_INFO(town_record_type,town_chop_key);
MEM_INFO(town_record_type,wandering);
MEM_INFO(town_record_type,wandering_locs);
MEM_INFO(town_record_type,special_locs);
MEM_INFO(town_record_type,spec_id);
MEM_INFO(town_record_type,sign_locs);
MEM_INFO(town_record_type,lighting);
MEM_INFO(town_record_type,start_locs);
MEM_INFO(town_record_type,exit_locs);
MEM_INFO(town_record_type,exit_specs);
MEM_INFO(town_record_type,in_town_rect);
MEM_INFO(town_record_type,preset_items);
MEM_INFO(town_record_type,max_num_monst);
MEM_INFO(town_record_type,preset_fields);
MEM_INFO(town_record_type,spec_on_entry);
MEM_INFO(town_record_type,spec_on_entry_if_dead);
MEM_INFO(town_record_type,timer_spec_times);
MEM_INFO(town_record_type,timer_specs);
MEM_INFO(town_record_type,strlens);
MEM_INFO(town_record_type,specials);
MEM_INFO(town_record_type,specials1);
MEM_INFO(town_record_type,specials2);
MEM_INFO(town_record_type,res1);
MEM_INFO(town_record_type,res2);
MEM_INFO(town_record_type,difficulty);
STRUCT_INFO(big_tr_type);
MEM_INFO(big_tr_type,terrain);
MEM_INFO(big_tr_type,room_rect);
MEM_INFO(big_tr_type,creatures);
MEM_INFO(big_tr_type,lighting);
STRUCT_INFO(ave_tr_type);
MEM_INFO(ave_tr_type,terrain);
MEM_INFO(ave_tr_type,room_rect);
MEM_INFO(ave_tr_type,creatures);
MEM_INFO(ave_tr_type,lighting);
STRUCT_INFO(tiny_tr_type);
MEM_INFO(tiny_tr_type,terrain);
MEM_INFO(tiny_tr_type,room_rect);
MEM_INFO(tiny_tr_type,creatures);
MEM_INFO(tiny_tr_type,lighting);
STRUCT_INFO(city_block_type);
MEM_INFO(city_block_type,block_type);
MEM_INFO(city_block_type,block_destroy_time);
MEM_INFO(city_block_type,block_alignment);
MEM_INFO(city_block_type,block_key_time);
MEM_INFO(city_block_type,block_loc);
STRUCT_INFO(city_ter_rect_type);
MEM_INFO(city_ter_rect_type,what_rect);
MEM_INFO(city_ter_rect_type,ter_type);
MEM_INFO(city_ter_rect_type,hollow);
STRUCT_INFO(template_town_type);
MEM_INFO(template_town_type,creatures);
MEM_INFO(template_town_type,city_block);
MEM_INFO(template_town_type,city_ter_rect);
STRUCT_INFO(scen_item_data_type);
MEM_INFO(scen_item_data_type,scen_items);
MEM_INFO(scen_item_data_type,monst_names);
MEM_INFO(scen_item_data_type,ter_names);
STRUCT_INFO(item_storage_shortcut_type);
MEM_INFO(item_storage_shortcut_type,ter_type);
MEM_INFO(item_storage_shortcut_type,item_num);
MEM_INFO(item_storage_shortcut_type,item_odds);
MEM_INFO(item_storage_shortcut_type,property);
STRUCT_INFO(monster_record_type);
MEM_INFO(monster_record_type,m_num);
MEM_INFO(monster_record_type,level);
MEM_INFO(monster_record_type,m_name);
MEM_INFO(monster_record_type,health);
MEM_INFO(monster_record_type,m_health);
MEM_INFO(monster_record_type,mp);
MEM_INFO(monster_record_type,max_mp);
MEM_INFO(monster_record_type,armor);
MEM_INFO(monster_record_type,skill);
MEM_INFO(monster_record_type,a);
MEM_INFO(monster_record_type,a1_type);
MEM_INFO(monster_record_type,a23_type);
MEM_INFO(monster_record_type,m_type);
MEM_INFO(monster_record_type,speed);
MEM_INFO(monster_record_type,ap);
MEM_INFO(monster_record_type,mu);
MEM_INFO(monster_record_type,cl);
MEM_INFO(monster_record_type,breath);
MEM_INFO(monster_record_type,breath_type);
MEM_INFO(monster_record_type,treasure);
MEM_INFO(monster_record_type,spec_skill);
MEM_INFO(monster_record_type,poison);
MEM_INFO(monster_record_type,morale);
MEM_INFO(monster_record_type,m_morale);
MEM_INFO(monster_record_type,corpse_item);
MEM_INFO(monster_record_type,corpse_item_chance);
MEM_INFO(monster_record_type,status);
MEM_INFO(monster_record_type,direction);
MEM_INFO(monster_record_type,immunities);
MEM_INFO(monster_record_type,x_width);
MEM_INFO(monster_record_type,y_width);
MEM_INFO(monster_record_type,radiate_1);
MEM_INFO(monster_record_type,radiate_2);
MEM_INFO(monster_record_type,default_attitude);
MEM_INFO(monster_record_type,summon_type);
MEM_INFO(monster_record_type,default_facial_pic);
MEM_INFO(monster_record_type,res1);
MEM_INFO(monster_record_type,res2);
MEM_INFO(monster_record_type,res3);
MEM_INFO(monster_record_type,picture_num);
STRUCT_INFO(horse_record_type);
MEM_INFO(horse_record_type,horse_loc);
MEM_INFO(horse_record_type,horse_loc_in_sec);
MEM_INFO(horse_record_type,horse_sector);
MEM_INFO(horse_record_type,which_town);
MEM_INFO(horse_record_type,exists);
MEM_INFO(horse_record_type,property);
STRUCT_INFO(boat_record_type);
MEM_INFO(boat_record_type,boat_loc);
MEM_INFO(boat_record_type,boat_loc_in_sec);
MEM_INFO(boat_record_type,boat_sector);
MEM_INFO(boat_record_type,which_town);
MEM_INFO(boat_record_type,exists);
MEM_INFO(boat_record_type,property);
STRUCT_INFO(talk_save_type);
MEM_INFO(talk_save_type,personality);
MEM_INFO(talk_save_type,town_num);
MEM_INFO(talk_save_type,str1);
MEM_INFO(talk_save_type,str2);
STRUCT_INFO(creature_data_type);
MEM_INFO(creature_data_type,active);
MEM_INFO(creature_data_type,attitude);
MEM_INFO(creature_data_type,number);
MEM_INFO(creature_data_type,m_loc);
MEM_INFO(creature_data_type,m_d);
MEM_INFO(creature_data_type,mobile);
MEM_INFO(creature_data_type,summoned);
MEM_INFO(creature_data_type,monst_start);
STRUCT_INFO(creature_list_type);
MEM_INFO(creature_list_type,dudes);
MEM_INFO(creature_list_type,which_town);
MEM_INFO(creature_list_type,friendly);
STRUCT_INFO(outdoor_creature_type);
MEM_INFO(outdoor_creature_type,exists);
MEM_INFO(outdoor_creature_type,direction);
MEM_INFO(outdoor_creature_type,what_monst);
MEM_INFO(outdoor_creature_type,which_sector);
MEM_INFO(outdoor_creature_type,m_loc);
STRUCT_INFO(party_record_type);
MEM_INFO(party_record_type,age);
MEM_INFO(party_record_type,gold);
MEM_INFO(party_record_type,food);
MEM_INFO(party_record_type,stuff_done);
MEM_INFO(party_record_type,item_taken);
MEM_INFO(party_record_type,light_level);
MEM_INFO(party_record_type,outdoor_corner);
MEM_INFO(party_record_type,i_w_c);
MEM_INFO(party_record_type,p_loc);
MEM_INFO(party_record_type,loc_in_sec);
MEM_INFO(party_record_type,boats);
MEM_INFO(party_record_type,horses);
MEM_INFO(party_record_type,creature_save);
MEM_INFO(party_record_type,in_boat);
MEM_INFO(party_record_type,in_horse);
MEM_INFO(party_record_type,out_c);
MEM_INFO(party_record_type,magic_store_items);
MEM_INFO(party_record_type,imprisoned_monst);
MEM_INFO(party_record_type,m_seen);
MEM_INFO(party_record_type,journal_str);
MEM_INFO(party_record_type,journal_day);
MEM_INFO(party_record_type,special_notes_str);
MEM_INFO(party_record_type,talk_save);
MEM_INFO(party_record_type,direction);
MEM_INFO(party_record_type,at_which_save_slot);
MEM_INFO(party_record_type,alchemy);
MEM_INFO(party_record_type,can_find_town);
MEM_INFO(party_record_type,key_times);
MEM_INFO(party_record_type,party_event_timers);
MEM_INFO(party_record_type,global_or_town);
MEM_INFO(party_record_type,node_to_call);
MEM_INFO(party_record_type,spec_items);
MEM_INFO(party_record_type,help_received);
MEM_INFO(party_record_type,m_killed);
MEM_INFO(party_record_type,total_m_killed);
MEM_INFO(party_record_type,total_dam_done);
MEM_INFO(party_record_type,total_xp_gained);
MEM_INFO(party_record_type,total_dam_taken);
MEM_INFO(party_record_type,scen_name);
STRUCT_INFO(scenario_data_type);
MEM_INFO(scenario_data_type,out_width);
MEM_INFO(scenario_data_type,out_height);
MEM_INFO(scenario_data_type,difficulty);
MEM_INFO(scenario_data_type,intro_pic);
MEM_INFO(scenario_data_type,default_ground);
MEM_INFO(scenario_data_type,town_size);
MEM_INFO(scenario_data_type,town_hidden);
MEM_INFO(scenario_data_type,flag_a);
MEM_INFO(scenario_data_type,intro_mess_pic);
MEM_INFO(scenario_data_type,intro_mess_len);
MEM_INFO(scenario_data_type,where_start);
MEM_INFO(scenario_data_type,out_sec_start);
MEM_INFO(scenario_data_type,out_start);
MEM_INFO(scenario_data_type,which_town_start);
MEM_INFO(scenario_data_type,flag_b);
MEM_INFO(scenario_data_type,town_data_size);
MEM_INFO(scenario_data_type,town_to_add_to);
MEM_INFO(scenario_data_type,flag_to_add_to_town);
MEM_INFO(scenario_data_type,flag_c);
MEM_INFO(scenario_data_type,out_data_size);
MEM_INFO(scenario_data_type,store_item_rects);
MEM_INFO(scenario_data_type,store_item_towns);
MEM_INFO(scenario_data_type,flag_e);
MEM_INFO(scenario_data_type,special_items);
MEM_INFO(scenario_data_type,special_item_special);
MEM_INFO(scenario_data_type,rating);
MEM_INFO(scenario_data_type,uses_custom_graphics);
MEM_INFO(scenario_data_type,flag_f);
MEM_INFO(scenario_data_type,scen_monsters);
MEM_INFO(scenario_data_type,scen_boats);
MEM_INFO(scenario_data_type,scen_horses);
MEM_INFO(scenario_data_type,flag_g);
MEM_INFO(scenario_data_type,ter_types);
MEM_INFO(scenario_data_type,scenario_timer_times);
MEM_INFO(scenario_data_type,scenario_timer_specs);
MEM_INFO(scenario_data_type,flag_h);
MEM_INFO(scenario_data_type,scen_specials);
MEM_INFO(scenario_data_type,storage_shortcuts);
MEM_INFO(scenario_data_type,flag_d);
MEM_INFO(scenario_data_type,scen_str_len);
MEM_INFO(scenario_data_type,flag_i);
MEM_INFO(scenario_data_type,last_out_edited);
MEM_INFO(scenario_data_type,last_town_edited);
STRUCT_INFO(setup_save_type);
MEM_INFO(setup_save_type,setup);
STRUCT_INFO(pc_record_type);
MEM_INFO(pc_record_type,main_status);
MEM_INFO(pc_record_type,name);
MEM_INFO(pc_record_type,skills);
MEM_INFO(pc_record_type,max_health);
MEM_INFO(pc_record_type,cur_health);
MEM_INFO(pc_record_type,max_sp);
MEM_INFO(pc_record_type,cur_sp);
MEM_INFO(pc_record_type,experience);
MEM_INFO(pc_record_type,skill_pts);
MEM_INFO(pc_record_type,level);
MEM_INFO(pc_record_type,status);
MEM_INFO(pc_record_type,items);
MEM_INFO(pc_record_type,equip);
MEM_INFO(pc_record_type,priest_spells);
MEM_INFO(pc_record_type,mage_spells);
MEM_INFO(pc_record_type,which_graphic);
MEM_INFO(pc_record_type,weap_poisoned);
MEM_INFO(pc_record_type,advan);
MEM_INFO(pc_record_type,traits);
MEM_INFO(pc_record_type,race);
MEM_INFO(pc_record_type,exp_adj);
MEM_INFO(pc_record_type,direction);
STRUCT_INFO(town_item_list);
MEM_INFO(town_item_list,items);
STRUCT_INFO(stored_town_maps_type);
MEM_INFO(stored_town_maps_type,town_maps);
STRUCT_INFO(stored_outdoor_maps_type);
MEM_INFO(stored_outdoor_maps_type,outdoor_maps);
STRUCT_INFO(stored_items_list_type);
MEM_INFO(stored_items_list_type,items);
STRUCT_INFO(current_town_type);
MEM_INFO(current_town_type,town_num);
MEM_INFO(current_town_type,difficulty);
MEM_INFO(current_town_type,town);
MEM_INFO(current_town_type,explored);
MEM_INFO(current_town_type,hostile);
MEM_INFO(current_town_type,monst);
MEM_INFO(current_town_type,in_boat);
MEM_INFO(current_town_type,p_loc);
STRUCT_INFO(out_info_type);
MEM_INFO(out_info_type,expl);
}

View File

@@ -22,6 +22,7 @@ namespace legacy {
typedef struct Rect Rect;
typedef uint8_t Boolean;
}
using pad_t = uint8_t; // To make the padding bytes super-explicit
//#define NLS 25
// // number of left slots for buttons
//#define NRS 400
@@ -29,41 +30,42 @@ namespace legacy {
//#define NRSONPAGE 33
// // number of right slots for scrolling list on page at 1 time
#pragma pack(push,1)
struct location {
int8_t x,y;
} __attribute__((packed));
};
struct special_node_type {
int16_t type,sd1,sd2,pic,m1,m2,ex1a,ex1b,ex2a,ex2b,jumpto;
} __attribute__((packed));
};
struct talking_node_type {
int16_t personality,type;
int8_t link1[4],link2[4];
int16_t extras[4];
} __attribute__((packed));
};
struct talking_record_type {
uint8_t strlens[200];
talking_node_type talk_nodes[60];
} __attribute__((packed));
};
struct terrain_type_type {
int16_t picture;
uint8_t blockage,flag1,flag2,special,trans_to_what,fly_over,boat_over;
uint8_t block_horse,light_radius,step_sound,shortcut_key,res1,res2,res3;
} __attribute__((packed));
};
struct wandering_type {
uint8_t monst[4];
} __attribute__((packed));
};
struct out_wandering_type {
uint8_t monst[7];
uint8_t friendly[3];
int16_t spec_on_meet,spec_on_win,spec_on_flee,cant_flee;
int16_t end_spec1,end_spec2;
} __attribute__((packed));
};
struct outdoor_record_type {
uint8_t terrain[48][48];
@@ -77,7 +79,7 @@ namespace legacy {
Rect info_rect[8];
uint8_t strlens[180];
special_node_type specials[60];
} __attribute__((packed));
};
struct creature_start_type {
uint8_t number;
@@ -90,7 +92,7 @@ namespace legacy {
int8_t spec_enc_code,time_code;
int16_t monster_time,personality;
int16_t special_on_kill,facial_pic;
} __attribute__((packed));
};
struct short_item_record_type {
int16_t variety, item_level;
@@ -102,29 +104,30 @@ namespace legacy {
char full_name[25], name[15];
uint8_t reserved1,reserved2;
uint8_t magic_use_type, ability_strength, treas_class, real_abil;
} __attribute__((packed));
};
struct item_record_type {
int16_t variety, item_level;
int8_t awkward, bonus, protection, charges, type, magic_use_type;
uint8_t graphic_num,ability, ability_strength,type_flag, is_special;
int16_t value __attribute__((aligned(2)));
pad_t xxx;
int16_t value;
uint8_t weight, special_class;
location item_loc;
char full_name[25], name[15];
uint8_t treas_class,item_properties,reserved1,reserved2;
} __attribute__((packed));
};
struct preset_item_type {
location item_loc;
int16_t item_code,ability;
uint8_t charges,always_there,property,contained;
} __attribute__((packed));
};
struct preset_field_type {
location field_loc;
int16_t field_type;
} __attribute__((packed));
};
struct town_record_type {
int16_t town_chop_time,town_chop_key;
@@ -148,28 +151,28 @@ namespace legacy {
special_node_type specials[100];
uint8_t specials1,specials2,res1,res2;
int16_t difficulty;
} __attribute__((packed));
};
struct big_tr_type {
uint8_t terrain[64][64];
Rect room_rect[16];
creature_start_type creatures[60];
uint8_t lighting[8][64];
} __attribute__((packed));
};
struct ave_tr_type {
uint8_t terrain[48][48];
Rect room_rect[16];
creature_start_type creatures[40];
uint8_t lighting[6][48];
} __attribute__((packed));
};
struct tiny_tr_type {
uint8_t terrain[32][32];
Rect room_rect[16];
creature_start_type creatures[30];
uint8_t lighting[4][32];
} __attribute__((packed));
};
struct city_block_type {
int16_t block_type;
@@ -177,29 +180,29 @@ namespace legacy {
int8_t block_alignment;
int8_t block_key_time;
location block_loc;
} __attribute__((packed));
};
struct city_ter_rect_type {
Rect what_rect;
uint8_t ter_type;
uint8_t hollow;
} __attribute__((packed));
};
struct template_town_type {
creature_start_type creatures[30];
city_block_type city_block[15];
city_ter_rect_type city_ter_rect[10];
} __attribute__((packed));
};
struct scen_item_data_type {
item_record_type scen_items[400];
char monst_names[256][20];
char ter_names[256][30];
} __attribute__((packed));
};
struct item_storage_shortcut_type {
int16_t ter_type,item_num[10],item_odds[10],property;
} __attribute__((packed));
};
struct monster_record_type {
uint8_t m_num,level,m_name[26];
@@ -214,48 +217,50 @@ namespace legacy {
uint8_t default_attitude,summon_type,default_facial_pic,res1,res2,res3;
int16_t picture_num;
} __attribute__((packed));
};
struct horse_record_type {
location horse_loc,horse_loc_in_sec,horse_sector;
int16_t which_town;
Boolean exists,property;
} __attribute__((packed));
};
struct boat_record_type {
location boat_loc,boat_loc_in_sec,boat_sector;
int16_t which_town;
Boolean exists,property;
} __attribute__((packed));
};
struct talk_save_type {
int16_t personality;
int16_t town_num;
int16_t str1,str2;
} __attribute__((packed));
};
struct creature_data_type {
int16_t active,attitude;
uint8_t number; // TODO: I think there should be a byte of padding near here, but where exactly??
location m_loc __attribute__((aligned(2)));
uint8_t number;
pad_t xxx;
location m_loc;
monster_record_type m_d;
int16_t mobile;
int16_t summoned;
creature_start_type monst_start;
} __attribute__((packed));
};
struct creature_list_type {
creature_data_type dudes[60];
int16_t which_town;
int16_t friendly;
} __attribute__((packed));
};
struct outdoor_creature_type {
Boolean exists; // TODO: I think there should be a byte of padding near here, but where exactly??
int16_t direction __attribute__((aligned(2)));
Boolean exists;
pad_t xxx;
int16_t direction;
out_wandering_type what_monst;
location which_sector,m_loc;
} __attribute__((packed));
};
struct party_record_type {
int32_t age;
@@ -287,7 +292,7 @@ namespace legacy {
int16_t m_killed[200];
int32_t total_m_killed,total_dam_done,total_xp_gained,total_dam_taken;
char scen_name[256];
} __attribute__((packed));
};
struct scenario_data_type {
uint8_t out_width,out_height,difficulty,intro_pic,default_ground;
@@ -295,7 +300,8 @@ namespace legacy {
uint8_t town_hidden[200];
int16_t flag_a;
int16_t intro_mess_pic,intro_mess_len;
location where_start __attribute__((aligned(2)));
pad_t xxx;
location where_start;
location out_sec_start,out_start;
int16_t which_town_start;
int16_t flag_b;
@@ -326,11 +332,11 @@ namespace legacy {
int16_t flag_i;
location last_out_edited;
int16_t last_town_edited;
} __attribute__((packed));
};
struct setup_save_type {
uint8_t setup[4][64][64];
} __attribute__((packed));
};
struct pc_record_type {
int16_t main_status;
@@ -344,23 +350,23 @@ namespace legacy {
int16_t which_graphic,weap_poisoned;
Boolean advan[15],traits[15];
int16_t race,exp_adj,direction;
} __attribute__((packed));
};
struct town_item_list {
item_record_type items[115];
} __attribute__((packed));
};
struct stored_town_maps_type {
int8_t town_maps[200][8][64];
} __attribute__((packed));
};
struct stored_outdoor_maps_type {
int8_t outdoor_maps[100][6][48];
} __attribute__((packed));
};
struct stored_items_list_type {
item_record_type items[115];
} __attribute__((packed));
};
struct current_town_type {
int16_t town_num, difficulty;
@@ -370,11 +376,11 @@ namespace legacy {
creature_list_type monst;
Boolean in_boat;
location p_loc;
} __attribute__((packed));
};
struct out_info_type {
int8_t expl[96][96];
} __attribute__((packed));
};
// struct piles_of_stuff_dumping_type {
// int8_t strings_ls[NLS][40];
@@ -385,6 +391,7 @@ namespace legacy {
// int8_t talk_strs[170][256];
// scen_item_data_type scen_item_list;
// };
#pragma pack(pop)
};
#endif

View File

@@ -1,5 +1,5 @@
void init_scenario() __attribute__((deprecated));
__declspec(deprecated) void init_scenario();
short edit_ter_type(ter_num_t which_ter);
short edit_monst_type(short which_monst);
cMonster edit_monst_abil(cMonster starting_record,short parent_num);

View File

@@ -1,5 +1,5 @@
void init_town(short size) __attribute__((deprecated));
void init_out() __attribute__((deprecated));
__declspec(deprecated) void init_town(short size);
__declspec(deprecated) void init_out();
void edit_placed_monst(short which_m);
cCreature edit_placed_monst_adv(cCreature monst_record, class cDialog& parent);
void edit_sign(short which_sign,short picture);

View File

@@ -766,7 +766,7 @@ bool load_party(fs::path file_to_load){
// flag_type flag;
// flag_type *flag_ptr;
short vers,n;
struct __attribute__((packed)) {ushort a; ushort b; ushort c; ushort d; ushort e;} flags;
struct {ushort a; ushort b; ushort c; ushort d; ushort e;} flags;
// TODO: Putting these flags in hex would make some things a bit clearer
static const unsigned short mac_flags[3][2] = {