Some code cleanup, mainly constants

- Strip out unused constants
- Use const instead of #define
- Remove some obsolete comments
This commit is contained in:
2017-02-12 00:04:53 -05:00
parent 2b8ff52992
commit 59f2a7b94e
18 changed files with 64 additions and 214 deletions

View File

@@ -104,7 +104,6 @@
<ClInclude Include="..\..\pcedit\pc.action.hpp" />
<ClInclude Include="..\..\pcedit\pc.editors.hpp" />
<ClInclude Include="..\..\pcedit\pc.fileio.hpp" />
<ClInclude Include="..\..\pcedit\pc.global.hpp" />
<ClInclude Include="..\..\pcedit\pc.graphics.hpp" />
<ClInclude Include="..\..\pcedit\pc.menus.hpp" />
<ClInclude Include="..\..\..\rsrc\menus\pcresource.h" />

View File

@@ -44,9 +44,6 @@
<ClInclude Include="..\..\pcedit\pc.fileio.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\pcedit\pc.global.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\pcedit\pc.graphics.hpp">
<Filter>Header Files</Filter>
</ClInclude>

View File

@@ -684,7 +684,6 @@
91B3EEFC0F969BD300BF5B67 /* pc.action.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pc.action.hpp; sourceTree = "<group>"; };
91B3EEFD0F969BD300BF5B67 /* pc.editors.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pc.editors.hpp; sourceTree = "<group>"; };
91B3EEFE0F969BD300BF5B67 /* pc.fileio.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pc.fileio.hpp; sourceTree = "<group>"; };
91B3EEFF0F969BD300BF5B67 /* pc.global.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pc.global.hpp; sourceTree = "<group>"; };
91B3EF000F969BD300BF5B67 /* pc.graphics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pc.graphics.hpp; sourceTree = "<group>"; };
91B3EF050F969BD300BF5B67 /* pc.main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pc.main.cpp; sourceTree = "<group>"; };
91B3EF060F969BD300BF5B67 /* pc.action.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pc.action.cpp; sourceTree = "<group>"; };
@@ -1211,7 +1210,6 @@
91B3EEFC0F969BD300BF5B67 /* pc.action.hpp */,
91B3EEFD0F969BD300BF5B67 /* pc.editors.hpp */,
91B3EEFE0F969BD300BF5B67 /* pc.fileio.hpp */,
91B3EEFF0F969BD300BF5B67 /* pc.global.hpp */,
91B3EF000F969BD300BF5B67 /* pc.graphics.hpp */,
91FCC8DA18FE2CCA007026CE /* pc.menus.hpp */,
);

View File

@@ -11,19 +11,6 @@
#include <set>
/*
This file contain numerous constans in form of #defines.
Almost all of these constants cannot be changed because
that would make the game work improperly.
*/
#define NUM_OF_PCS 6
#define INVALID_PC NUM_OF_PCS
#define INVALID_TOWN 200
#define NUM_OF_BOATS 30
#define NUM_OF_HORSES 30
/* overall mode; some seem to be missing */
enum eGameMode {
MODE_OUTDOORS = 0,
@@ -36,7 +23,7 @@ enum eGameMode {
MODE_COMBAT = 10,
MODE_SPELL_TARGET = 11,
MODE_FIRING = 12, // firing from bow or crossbow
MODE_THROWING = 13, // throwing missle
MODE_THROWING = 13, // throwing missile
MODE_FANCY_TARGET = 14, // spell target, that is; I think it's for multitarget spells
MODE_DROP_COMBAT = 15,
MODE_TALKING = 20,
@@ -68,58 +55,11 @@ enum eStatMode {
MODE_ENCHANT = 6,
};
#ifndef DIR_ARRAY_DEF
extern signed char dir_x_dif[9];
extern signed char dir_y_dif[9];
#endif
//inline eDamageType operator + (eDamageType lhs, eDamageType rhs){
// if(lhs == DAMAGE_MARKED || lhs == DAMAGE_NO_PRINT){
// if(rhs != DAMAGE_MARKED && rhs != DAMAGE_NO_PRINT)
// return (eDamageType) ((int)lhs + (int)rhs);
// }else if(rhs == DAMAGE_MARKED || rhs == DAMAGE_NO_PRINT)
// return (eDamageType) ((int)lhs + (int)rhs);
// else{
// int a = lhs, b = rhs, c = 0;
// if(a > 30){
// c += 30;
// a -= 30;
// if(b > 30) b -= 30;
// else if(b > 10) b -= 10;
// if(a == b) c += a;
// else c += 4;
// }else if(b > 30){
// c += 30;
// b -= 30;
// if(a > 30) a -= 30;
// else if(a > 10) a -= 10;
// if(a == b) c += a;
// else c += 4;
// }else if(a > 10){
// c += 10;
// a -= 10;
// if(b > 30){
// b -= 30;
// c += 20;
// }else if(b > 10) b -= 10;
// if(a == b) c += a;
// else c += 4;
// }else if(b > 10){
// c += 10;
// b -= 10;
// if(a > 30){
// a -= 30;
// c += 20;
// }else if(a > 10) a -= 10;
// if(a == b) c += a;
// else c += 4;
// }
// return (eDamageType) c; // this SHOULD guarantee a valid result...
// }
//}
static const signed char dir_x_dif[9] = {0,1,1,1,0,-1,-1,-1,0};
static const signed char dir_y_dif[9] = {-1,-1,0,1,1,1,0,-1,0};
/* trap type */
/* used in pc_record_type::runTrap(...) */
/* used in run_trap(...) */
enum eTrapType {
TRAP_RANDOM = 0,
TRAP_BLADE = 1,
@@ -138,51 +78,40 @@ enum eTrapType {
};
// Startup button rects
#define STARTBTN_LOAD 0
#define STARTBTN_NEW 1
#define STARTBTN_ORDER 2
#define STARTBTN_JOIN 3
#define STARTBTN_CUSTOM 4
const int STARTBTN_LOAD = 0;
const int STARTBTN_NEW = 1;
const int STARTBTN_ORDER = 2;
const int STARTBTN_JOIN = 3;
const int STARTBTN_CUSTOM = 4;
// Shop rects
#define SHOPRECT_WHOLE_AREA 0
#define SHOPRECT_ACTIVE_AREA 1
#define SHOPRECT_GRAPHIC 2
#define SHOPRECT_ITEM_NAME 3
#define SHOPRECT_ITEM_COST 4
#define SHOPRECT_ITEM_EXTRA 5
#define SHOPRECT_ITEM_HELP 6
const int SHOPRECT_WHOLE_AREA = 0;
const int SHOPRECT_ACTIVE_AREA = 1;
const int SHOPRECT_GRAPHIC = 2;
const int SHOPRECT_ITEM_NAME = 3;
const int SHOPRECT_ITEM_COST = 4;
const int SHOPRECT_ITEM_EXTRA = 5;
const int SHOPRECT_ITEM_HELP = 6;
// Item button rects
#define ITEMBTN_NAME 0
#define ITEMBTN_USE 1
#define ITEMBTN_GIVE 2
#define ITEMBTN_DROP 3
#define ITEMBTN_INFO 4
#define ITEMBTN_SPEC 5 // Sell, Identify, or Enchant
#define ITEMBTN_ALL 10 // use, give, drop, info
#define ITEMBTN_NORM 11 // give, drop, info
const int ITEMBTN_NAME = 0;
const int ITEMBTN_USE = 1;
const int ITEMBTN_GIVE = 2;
const int ITEMBTN_DROP = 3;
const int ITEMBTN_INFO = 4;
const int ITEMBTN_SPEC = 5; // Sell, Identify, or Enchant
const int ITEMBTN_ALL = 10; // use, give, drop, info
const int ITEMBTN_NORM = 11; // give, drop, info
// PC button rects
#define PCBTN_NAME 0
#define PCBTN_HP 1
#define PCBTN_SP 2
#define PCBTN_INFO 3
#define PCBTN_TRADE 4
const int PCBTN_NAME = 0;
const int PCBTN_HP = 1;
const int PCBTN_SP = 2;
const int PCBTN_INFO = 3;
const int PCBTN_TRADE = 4;
// Item window modes (non-PC)
#define ITEM_WIN_SPECIAL 6
#define ITEM_WIN_QUESTS 7
//Spell select
#define SPELL_SELECT_NONE 0
#define SPELL_SELECT_ACTIVE 1
#define SPELL_SELECT_ANY 2
//Spell refer
#define SPELL_REFER 0
#define SPELL_IMMED 1
#define SPELL_TARGET 2
#define SPELL_FANCY_TARGET 3
const int ITEM_WIN_SPECIAL = 6;
const int ITEM_WIN_QUESTS = 7;
#endif

View File

@@ -8,33 +8,21 @@
#include <sstream>
#include "boe.consts.hpp"
#define DRAG_EDGE 15
#define DISPLAY_LEFT 23
#define DISPLAY_TOP 23
#define BITMAP_WIDTH 28
#define BITMAP_HEIGHT 36
#define PC_WIN_UL_X 291
#define PC_WIN_UL_Y 5
#define ITEM_WIN_UL_X 291
#define ITEM_WIN_UL_Y 130
#define TEXT_WIN_UL_X 291
#define TEXT_WIN_UL_Y 283
#define NUM_BUTTONS 15
#define ASB add_string_to_buf
#define PSD univ.party.stuff_done
#define NUM_MONST_G 173
#define NUM_TER_G 251
#define NUM_ITEM_G 120
#define NUM_FACE_G 80
#define NUM_DLOG_G 28
const int PC_WIN_UL_X = 291;
const int PC_WIN_UL_Y = 5;
const int ITEM_WIN_UL_X = 291;
const int ITEM_WIN_UL_Y = 130;
const int TEXT_WIN_UL_X = 291;
const int TEXT_WIN_UL_Y = 283;
#define CDGT cd_retrieve_text_edit_str
#define CDGN cd_retrieve_text_edit_num
#define CDST cd_set_text_edit_str
#define CDSN cd_set_text_edit_num
const int NUM_MONST_G = 173;
const int NUM_TER_G = 251;
const int NUM_ITEM_G = 120;
const int NUM_FACE_G = 80;
const int NUM_DLOG_G = 28;
struct scen_header_type{
int intro_pic, rating, difficulty, ver[3], prog_make_ver[3];

View File

@@ -1569,10 +1569,10 @@ void draw_targeting_line(location where_curs) {
if((abs(store_loc.x - which_space.x) <= 4) &&
(abs(store_loc.y - which_space.y) <= 4) &&
(current_pat.pattern[store_loc.x - which_space.x + 4][store_loc.y - which_space.y + 4] != 0)) {
target_rect.left = 13 + BITMAP_WIDTH * i + 5 + ul.x;
target_rect.right = target_rect.left + BITMAP_WIDTH;
target_rect.top = 13 + BITMAP_HEIGHT * j + 5 + ul.y;
target_rect.bottom = target_rect.top + BITMAP_HEIGHT;
target_rect.left = 13 + 28 * i + 5 + ul.x;
target_rect.right = target_rect.left + 28;
target_rect.top = 13 + 36 * j + 5 + ul.y;
target_rect.bottom = target_rect.top + 36;
frame_rect(mainPtr, target_rect, sf::Color::White);
target_rect.inset(-5,-5);
redraw_rect2 = rectunion(target_rect,redraw_rect2);

View File

@@ -1,5 +1,4 @@
#define DIR_ARRAY_DEF
#include "boe.global.hpp"
#include "universe.hpp"
@@ -56,8 +55,6 @@ long start_time;
short on_spell_menu[2][62];
short on_monst_menu[256];
signed char dir_x_dif[9] = {0,1,1,1,0,-1,-1,-1,0};
signed char dir_y_dif[9] = {-1,-1,0,1,1,1,0,-1,0};
extern bool map_visible;
@@ -204,7 +201,6 @@ void Handle_One_Event() {
through_sending();
Handle_Update();
//(cur_time - last_anim_time > 42)
if((animTimer.getElapsedTime().asMilliseconds() >= fortyTicks) && (overall_mode != MODE_STARTUP) && (anim_onscreen) && get_bool_pref("DrawTerrainAnimation", true)
&& (!gInBackground)) {
animTimer.restart();

View File

@@ -145,7 +145,6 @@ void show_logo() {
from_rect = rectangle(pict_to_draw);
play_sound(-95);
// TODO: Looping 10 times here is a bit of a hack; fix it
while(sound_going(95)) {
draw_splash(pict_to_draw, mainPtr, logo_from);
handle_splash_events();

View File

@@ -1,5 +1,6 @@
#define LINES_IN_TEXT_WIN 11
#define TEXT_BUF_LEN 70
const int LINES_IN_TEXT_WIN = 11;
const int TEXT_BUF_LEN = 70;
#include <sstream>
#include <list>
@@ -1055,7 +1056,6 @@ void add_string_to_buf(std::string str, unsigned short indent) {
through_sending();
}
sprintf((char *)text_buffer[buf_pointer].line, "%-49.49s", str.c_str());
// c2pstr((char *)text_buffer[buf_pointer].line);
if(buf_pointer == (TEXT_BUF_LEN - 1))
buf_pointer = 0;
else buf_pointer++;
@@ -1193,15 +1193,10 @@ void draw_text_label(const text_label_t& label) {
win_draw_string(terrain_screen_gworld, text_rect, label.str, eTextMode::LEFT_TOP, style);
}
// TODO: This seems to duplicate logic found in graphtool to get a rect from a picture index
// TODO: Replace uses of this function with direct use of calc_rect
rectangle coord_to_rect(short i,short j) {
rectangle to_return;
to_return.left = 13 + BITMAP_WIDTH * i;
to_return.right = to_return.left + BITMAP_WIDTH;
to_return.top = 13 + BITMAP_HEIGHT * j;
to_return.bottom = to_return.top + BITMAP_HEIGHT;
rectangle to_return = calc_rect(i, j);
to_return.offset(13, 13);
return to_return;
}

View File

@@ -2,7 +2,6 @@
#include <cstdio>
#include "pc.graphics.hpp"
#include "pc.global.hpp"
#include "universe.hpp"
#include "pc.editors.hpp"
#include "pc.fileio.hpp"

View File

@@ -1,6 +1,5 @@
#include "pc.graphics.hpp"
#include "pc.global.hpp"
#include "universe.hpp"
#include "pc.editors.hpp"
#include "graphtool.hpp"

View File

@@ -2,7 +2,6 @@
#include <cstring>
#include <cstdio>
#include "pc.global.hpp"
#include "universe.hpp"
#include "pc.fileio.hpp"
#include "pc.graphics.hpp"

View File

@@ -1,34 +0,0 @@
#define DRAG_EDGE 15
#define T_M 60
#define NUM_TOWN_ITEMS 115
#define DRAG_EDGE 15
#define DISPLAY_LEFT 23
#define DISPLAY_TOP 23
#define BITMAP_WIDTH 28
#define BITMAP_HEIGHT 36
#define PC_WIN_UL_X 291
#define PC_WIN_UL_Y 5
#define ITEM_WIN_UL_X 291
#define ITEM_WIN_UL_Y 130
#define TEXT_WIN_UL_X 291
#define TEXT_WIN_UL_Y 283
#define NUM_BUTTONS 15
#define DOOR_LIGHT can_enter = run_trap(7,&PSD[c_town.town_num][which],4220,0); break;
#define DOOR_HEAVY can_enter = run_trap(7,&PSD[c_town.town_num][which],4220,20); break;
#define DOOR_ALARM can_enter = run_trap(7,&PSD[c_town.town_num][which],4220,11); break;
#define DRESSER_LIGHT can_enter = run_trap(7,&PSD[c_town.town_num][which],4221,0); break;
#define DRESSER_HEAVY can_enter = run_trap(7,&PSD[c_town.town_num][which],4221,20); break;
#define DRESSER_ALARM can_enter = run_trap(7,&PSD[c_town.town_num][which],4221,11); break;
#define FLOOR_LIGHT can_enter = run_trap(7,&PSD[c_town.town_num][which],4222,0); break;
#define FLOOR_HEAVY can_enter = run_trap(7,&PSD[c_town.town_num][which],4222,20); break;
#define FLOOR_ALARM can_enter = run_trap(7,&PSD[c_town.town_num][which],4222,11); break;
#define CHEST_LIGHT can_enter = run_trap(7,&PSD[c_town.town_num][which],3450,0); break;
#define CHEST_HEAVY can_enter = run_trap(7,&PSD[c_town.town_num][which],3450,20); break;
#define CHEST_ALARM can_enter = run_trap(7,&PSD[c_town.town_num][which],3450,11); break;

View File

@@ -1,6 +1,5 @@
#include <iomanip>
#include "pc.global.hpp"
#include "universe.hpp"
#include "pc.graphics.hpp"
#include "pc.editors.hpp"

View File

@@ -2,7 +2,6 @@
#include <iostream>
#include <cstring>
#include <boost/filesystem/operations.hpp>
#include "pc.global.hpp"
#include "universe.hpp"
#include "pc.graphics.hpp"
#include "pc.editors.hpp"

View File

@@ -21,8 +21,6 @@
#include "winutil.hpp"
#include "choicedlog.hpp"
#define DONE_BUTTON_ITEM 1
extern cScenario scenario;
extern cTown* town;

View File

@@ -2,30 +2,22 @@
#ifndef BOE_SCEN_GLOBAL_HPP
#define BOE_SCEN_GLOBAL_HPP
#define DRAG_EDGE 15
const int BITMAP_WIDTH = 28;
const int BITMAP_HEIGHT = 36;
#define DISPLAY_LEFT 23
#define DISPLAY_TOP 23
#define BITMAP_WIDTH 28
#define BITMAP_HEIGHT 36
#define NUM_BUTTONS 15
const int NUM_DLOG_B = 53;
#define NUM_DLOG_B 53
const int NLS = 26; // number of left slots for buttons
#define NRS right_button_status.size() // number of right slots for scrolling list
const int NRSONPAGE = 33; // number of right slots for scrolling list on page at 1 time
#define NLS 26
// number of left slots for buttons
#define NRS right_button_status.size()
// number of right slots for scrolling list
#define NRSONPAGE 33
// number of right slots for scrolling list on page at 1 time
const int RIGHT_AREA_UL_X = 287;
const int RIGHT_AREA_UL_Y = 5;
const int RIGHT_AREA_WIDTH = 290;
const int RIGHT_AREA_HEIGHT = 400;
#define RIGHT_AREA_UL_X 287
#define RIGHT_AREA_UL_Y 5
#define RIGHT_AREA_WIDTH 290
#define RIGHT_AREA_HEIGHT 400
#define TER_RECT_UL_X 6
#define TER_RECT_UL_Y 19 // Formerly 25
const int TER_RECT_UL_X = 6;
const int TER_RECT_UL_Y = 19;
enum eScenMode {
MODE_DRAWING = 0,

View File

@@ -20,8 +20,6 @@
namespace fs = boost::filesystem;
#define LINES_IN_TEXT_WIN 11
struct m_pic_index_t {
unsigned char i, x, y;
};