From 77b5cadac636ddee4ed39bcaf1344c270fcaa447 Mon Sep 17 00:00:00 2001 From: pauldubois Date: Mon, 10 Mar 2008 03:30:55 +0000 Subject: Batch of tiny changes for MSVC compiles. Most of these fall into the category: - don't use struct to refer to a class, and vice versa - msvc doesn't like unistd.h or dirent.h Doesn't fix all the struct/class problems; I think I'll silence those for now and move on because it's not all that important. Tested on OS X. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3571 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/FixVec.h | 1 - crawl-ref/source/Kills.h | 12 ++++++------ crawl-ref/source/acr.cc | 4 ++-- crawl-ref/source/beam.h | 12 +++++++----- crawl-ref/source/chardump.cc | 4 ++-- crawl-ref/source/database.cc | 4 +++- crawl-ref/source/decks.cc | 14 +++++++------- crawl-ref/source/delay.h | 2 +- crawl-ref/source/describe.cc | 2 +- crawl-ref/source/dgnevent.cc | 1 + crawl-ref/source/dungeon.cc | 2 +- crawl-ref/source/dungeon.h | 4 +++- crawl-ref/source/effects.cc | 6 +++--- crawl-ref/source/effects.h | 2 +- crawl-ref/source/externs.h | 10 +++++++--- crawl-ref/source/fight.cc | 4 ++-- crawl-ref/source/fight.h | 2 +- crawl-ref/source/files.cc | 2 ++ crawl-ref/source/ghost.h | 2 +- crawl-ref/source/libgui.h | 2 +- crawl-ref/source/luadgn.h | 2 +- crawl-ref/source/mapdef.h | 11 +++++++---- crawl-ref/source/misc.h | 2 +- crawl-ref/source/mon-util.h | 2 +- crawl-ref/source/monplace.h | 2 +- crawl-ref/source/monstuff.h | 16 ++++++++-------- crawl-ref/source/mstuff2.h | 12 ++++++------ crawl-ref/source/msvc.h | 16 ++++++++++++++++ crawl-ref/source/player.h | 2 +- crawl-ref/source/spells2.h | 2 +- crawl-ref/source/store.cc | 13 +++++++++++++ crawl-ref/source/store.h | 17 +++++++++++++++-- crawl-ref/source/terrain.h | 2 +- crawl-ref/source/travel.h | 4 ++-- crawl-ref/source/xom.h | 2 +- 35 files changed, 127 insertions(+), 70 deletions(-) create mode 100644 crawl-ref/source/msvc.h (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/FixVec.h b/crawl-ref/source/FixVec.h index 8ac6a5cfcf..6fd2f91caa 100644 --- a/crawl-ref/source/FixVec.h +++ b/crawl-ref/source/FixVec.h @@ -18,7 +18,6 @@ #include #include "debug.h" - // ========================================================================== // class FixedVector // ========================================================================== diff --git a/crawl-ref/source/Kills.h b/crawl-ref/source/Kills.h index fe20ce7030..9f7b002ea5 100644 --- a/crawl-ref/source/Kills.h +++ b/crawl-ref/source/Kills.h @@ -17,12 +17,12 @@ std::string apostrophise(const std::string &name); -struct monsters; +class monsters; // Not intended for external use! struct kill_monster_desc { - kill_monster_desc(const struct monsters *); + kill_monster_desc(const monsters *); kill_monster_desc() { } void save(FILE*) const; @@ -52,7 +52,7 @@ struct kill_monster_desc class kill_def { public: - kill_def(const struct monsters *mon); + kill_def(const monsters *mon); kill_def() : kills(0), exp(0) { // This object just says to the world that it's uninitialized @@ -61,7 +61,7 @@ public: void save(FILE*) const; void load(FILE*); - void add_kill(const struct monsters *mon, unsigned short place); + void add_kill(const monsters *mon, unsigned short place); void add_place(unsigned short place, bool force = false); void merge(const kill_def &k, bool unique_monster); @@ -83,7 +83,7 @@ private: class kill_ghost { public: - kill_ghost(const struct monsters *mon); + kill_ghost(const monsters *mon); kill_ghost() { } void save(FILE*) const; @@ -151,7 +151,7 @@ private: kill_map kills; ghost_vec ghosts; - void record_ghost_kill(const struct monsters *mon); + void record_ghost_kill(const monsters *mon); }; class KillMaster diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 1e3a6c7bff..8a1942265a 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3183,7 +3183,7 @@ static command_type get_next_cmd() // Clamp idle time so that play time is more meaningful. if (after - before > IDLE_TIME_CLAMP) { - you.real_time += (before - you.start_time) + IDLE_TIME_CLAMP; + you.real_time += int(before - you.start_time) + IDLE_TIME_CLAMP; you.start_time = after; } @@ -3925,7 +3925,7 @@ static void move_player(int move_x, int move_y) if (targ_monst != NON_MONSTER && !mons_is_submerged(&menv[targ_monst])) { - struct monsters *mon = &menv[targ_monst]; + monsters *mon = &menv[targ_monst]; if (can_swap_places && !beholder) { diff --git a/crawl-ref/source/beam.h b/crawl-ref/source/beam.h index f3bd33b2ca..a384ddd6d1 100644 --- a/crawl-ref/source/beam.h +++ b/crawl-ref/source/beam.h @@ -18,6 +18,8 @@ #include "externs.h" #include "ray.h" +class monsters; + enum demon_beam_type { DMNBM_HELLFIRE, // 0 @@ -181,8 +183,8 @@ void fire_beam( struct bolt &pbolt, item_def *item = NULL, /* *********************************************************************** * called from: beam * *********************************************************************** */ -bool nasty_beam( struct monsters *mon, struct bolt &beam ); -bool nice_beam( struct monsters *mon, struct bolt &beam ); +bool nasty_beam( monsters *mon, struct bolt &beam ); +bool nice_beam( monsters *mon, struct bolt &beam ); // last updated 12may2000 {dlb} /* *********************************************************************** @@ -199,7 +201,7 @@ void explosion( bolt &pbolt, bool hole_in_the_middle = false, /* *********************************************************************** * called from: effects - spells2 - spells4 * *********************************************************************** */ -int mons_adjust_flavoured( struct monsters *monster, struct bolt &pbolt, +int mons_adjust_flavoured( monsters *monster, struct bolt &pbolt, int hurted, bool doFlavouredEffects = true ); @@ -214,7 +216,7 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int who, /* *********************************************************************** * called from: fight - monstuff - mstuff2 * *********************************************************************** */ -int mons_ench_f2( struct monsters *monster, struct bolt &pbolt ); +int mons_ench_f2( monsters *monster, struct bolt &pbolt ); /* *********************************************************************** @@ -234,7 +236,7 @@ bool check_line_of_sight( int sx, int sy, int tx, int ty ); /* *********************************************************************** * called from: monstuff * *********************************************************************** */ -void mimic_alert( struct monsters *mimic ); +void mimic_alert( monsters *mimic ); void zapping( zap_type ztype, int power, struct bolt &pbolt ); diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index 986cc5a2d8..86c0675d4a 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -24,7 +24,7 @@ #include #include #include -#if !defined(__IBMCPP__) +#if !defined(__IBMCPP__) && !defined(_MSC_VER) #include #endif #include @@ -353,7 +353,7 @@ static void sdump_misc(dump_params &par) sdump_visits(par); } -#define TO_PERCENT(x, y) (100.0 * ((float) (x)) / ((float) (y))) +#define TO_PERCENT(x, y) (100.0f * ((float) (x)) / ((float) (y))) static std::string sdump_turns_place_info(PlaceInfo place_info, std::string name = "") diff --git a/crawl-ref/source/database.cc b/crawl-ref/source/database.cc index 2dd17109ca..ee772c2b5b 100644 --- a/crawl-ref/source/database.cc +++ b/crawl-ref/source/database.cc @@ -11,10 +11,12 @@ #include #include #include -#include #include #include #include +#if !_MSC_VER +#include +#endif #include "clua.h" #include "database.h" diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index a060dbed1d..aaad67e19f 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -207,11 +207,11 @@ static void shuffle_deck(item_def &deck) // Don't use std::shuffle(), since we want to apply exactly the // same shuffling to both the cards vector and the flags vector. - std::vector pos; + std::vector pos; for (unsigned long i = 0; i < cards.size(); i++) pos.push_back(random2(cards.size())); - for (unsigned long i = 0; i < pos.size(); i++) + for (vec_size i = 0; i < pos.size(); i++) { std::swap(cards[i], cards[pos[i]]); std::swap(flags[i], flags[pos[i]]); @@ -527,13 +527,13 @@ static bool check_buggy_deck(item_def& deck) CrawlVector &cards = props["cards"].get_vector(); CrawlVector &flags = props["card_flags"].get_vector(); - unsigned long num_cards = cards.size(); - unsigned long num_flags = flags.size(); + vec_size num_cards = cards.size(); + vec_size num_flags = flags.size(); unsigned int num_buggy = 0; unsigned int num_marked = 0; - for (unsigned long i = 0; i < num_cards; i++) + for (vec_size i = 0; i < num_cards; i++) { unsigned char card = cards[i].get_byte(); unsigned char _flags = flags[i].get_byte(); @@ -2671,8 +2671,8 @@ void init_deck(item_def &item) props.set_default_flags(SFLAG_CONST_TYPE); - props["cards"].new_vector(SV_BYTE).resize(item.plus); - props["card_flags"].new_vector(SV_BYTE).resize(item.plus); + props["cards"].new_vector(SV_BYTE).resize((vec_size)item.plus); + props["card_flags"].new_vector(SV_BYTE).resize((vec_size)item.plus); props["drawn_cards"].new_vector(SV_BYTE); for (int i = 0; i < item.plus; i++) diff --git a/crawl-ref/source/delay.h b/crawl-ref/source/delay.h index d82a369d53..7c00e1bd5f 100644 --- a/crawl-ref/source/delay.h +++ b/crawl-ref/source/delay.h @@ -14,7 +14,7 @@ #include "enum.h" -struct monsters; +class monsters; struct ait_hp_loss; enum activity_interrupt_payload_type diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index fad463d168..604017808d 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -2219,7 +2219,7 @@ std::string ghost_description(const monsters &mons, bool concise) gstr << ghost.name << " the " << skill_title( ghost.best_skill, - ghost.best_skill_level, + (unsigned char)ghost.best_skill_level, gspecies, str, dex, GOD_NO_GOD ) << ", a" diff --git a/crawl-ref/source/dgnevent.cc b/crawl-ref/source/dgnevent.cc index da2a42ad2c..3bfcc22f85 100644 --- a/crawl-ref/source/dgnevent.cc +++ b/crawl-ref/source/dgnevent.cc @@ -10,6 +10,7 @@ #include "AppHdr.h" #include "dgnevent.h" #include "stuff.h" +#include dgn_event_dispatcher dungeon_events; diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index e997931c82..828559db35 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -1160,7 +1160,7 @@ void dgn_set_colours_from_monsters() env.floor_colour = LIGHTGREY; } else - env.floor_colour = fix_black_colour(mcolour[env.mons_alloc[9]]); + env.floor_colour = fix_black_colour((char)mcolour[env.mons_alloc[9]]); if (env.mons_alloc[8] < 0 || env.mons_alloc[8] == MONS_PROGRAM_BUG diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h index 13765fe22e..a43734bda4 100644 --- a/crawl-ref/source/dungeon.h +++ b/crawl-ref/source/dungeon.h @@ -21,6 +21,7 @@ #include "travel.h" #include "stuff.h" #include +#include enum portal_type { @@ -72,8 +73,9 @@ enum map_mask_type class dgn_region; typedef std::vector dgn_region_list; -struct dgn_region +class dgn_region { + public: // pos is top-left corner. coord_def pos, size; diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index d6af67574d..4e7a8e51f9 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -64,7 +64,7 @@ bool holy_word(int pow, int caster, bool silent) { bool holy_influenced = false; - struct monsters *monster; + monsters *monster; if (!silent) mpr("You speak a Word of immense power!"); @@ -205,7 +205,7 @@ int torment_monsters(int x, int y, int pow, int caster) if (mon == NON_MONSTER) return 0; - struct monsters *monster = &menv[mon]; + monsters *monster = &menv[mon]; if (monster->type == -1) return 0; @@ -605,7 +605,7 @@ void mons_direct_effect(struct bolt &pbolt, int i) { // note the translation here - important {dlb} int o = menv[i].foe; - struct monsters *monster = &menv[o]; + monsters *monster = &menv[o]; int damage_taken = 0; // annoy the target diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h index 7d04dd68e1..2514d8b1f9 100644 --- a/crawl-ref/source/effects.h +++ b/crawl-ref/source/effects.h @@ -19,7 +19,7 @@ struct bolt; class monsters; -class item_def; +struct item_def; // last updated 12may2000 {dlb} diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 2fb110a339..60e4a1abb2 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -70,9 +70,9 @@ const int kPathLen = 256; // penalty (Xom's granted or from a deck of cards). #define NO_BERSERK_PENALTY -1 -class item_def; +struct item_def; class melee_attack; -class coord_def; +struct coord_def; class level_id; class actor @@ -1291,7 +1291,7 @@ struct map_cell }; class map_marker; -class tagHeader; +struct tagHeader; class map_markers { public: @@ -1869,4 +1869,8 @@ private: extern game_options Options; +#if _MSC_VER +# include "msvc.h" +#endif + #endif // EXTERNS_H diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 05daf9791b..edb1071324 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -84,7 +84,7 @@ // ... was 5, 12, 21 // how these are used will be replaced by a function in a second ... :P {dlb} -static void stab_message(struct monsters *defender, int stab_bonus); +static void stab_message(monsters *defender, int stab_bonus); static inline int player_weapon_str_weight( void ); static inline int player_weapon_dex_weight( void ); @@ -3973,7 +3973,7 @@ static inline int calc_stat_to_dam_base( void ) #endif } -static void stab_message( struct monsters *defender, int stab_bonus ) +static void stab_message( monsters *defender, int stab_bonus ) { switch(stab_bonus) { diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h index 26dcd38ed1..9717b90a15 100644 --- a/crawl-ref/source/fight.h +++ b/crawl-ref/source/fight.h @@ -70,7 +70,7 @@ int calc_your_to_hit( bool random_factor ); int calc_heavy_armour_penalty( bool random_factor ); -struct melee_attack +class melee_attack { public: // At the moment this only covers players fighting monsters diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 0c4d6d4aa0..de893583a1 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -52,7 +52,9 @@ #include #include +#if !_MSC_VER #include +#endif #include "externs.h" diff --git a/crawl-ref/source/ghost.h b/crawl-ref/source/ghost.h index 3f397526d1..ccc521c135 100644 --- a/crawl-ref/source/ghost.h +++ b/crawl-ref/source/ghost.h @@ -16,7 +16,7 @@ #include "itemprop.h" #include "mon-util.h" -struct ghost_demon +class ghost_demon { public: std::string name; diff --git a/crawl-ref/source/libgui.h b/crawl-ref/source/libgui.h index c06f983b7f..2fec6447ab 100644 --- a/crawl-ref/source/libgui.h +++ b/crawl-ref/source/libgui.h @@ -68,7 +68,7 @@ private: int oldmode; }; -class coord_def; +struct coord_def; void gui_init_view_params(coord_def &termsz, coord_def &viewsz, coord_def &msgp, coord_def &msgsz, coord_def &hudp, coord_def &hudsz); diff --git a/crawl-ref/source/luadgn.h b/crawl-ref/source/luadgn.h index f0b92af987..87737d61fa 100644 --- a/crawl-ref/source/luadgn.h +++ b/crawl-ref/source/luadgn.h @@ -50,7 +50,7 @@ public: static dlua_chunk precompiled(const std::string &compiled); void clear(); - void add(int line, const std::string &line); + void add(int line, const std::string &line2); void set_chunk(const std::string &s); int load(CLua &interp); diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index 75b50b9db5..154f2ffa90 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -161,7 +161,7 @@ public: typedef std::pair map_weighted_colour; typedef std::vector map_colour_list; -struct colour_spec : public map_transformer +class colour_spec : public map_transformer { public: colour_spec(int _key, bool _fix, const map_colour_list &clist) @@ -181,8 +181,9 @@ public: map_colour_list colours; }; -struct shuffle_spec : public map_transformer +class shuffle_spec : public map_transformer { + public: std::string shuffle; shuffle_spec(const std::string &spec) @@ -199,8 +200,9 @@ struct shuffle_spec : public map_transformer } }; -struct map_marker_spec : public map_transformer +class map_marker_spec : public map_transformer { + public: int key; std::string marker; @@ -391,8 +393,9 @@ private: std::string error; }; -struct mons_spec +class mons_spec { + public: int mid; int monnum; // The zombified monster for zombies, or head // count for hydras, or colour for draconians. diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index bf590a5a71..31e92ee619 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -99,7 +99,7 @@ bool is_damaging_cloud(cloud_type type); void curare_hits_player(int agent, int degree); -bool mons_is_safe(const struct monsters *mon, bool want_move = false); +bool mons_is_safe(const monsters *mon, bool want_move = false); bool i_feel_safe(bool announce = false, bool want_move = false); void setup_environment_effects(); diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index 159fa60337..e568018f20 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -425,7 +425,7 @@ bool mons_is_unique(int mclass); * called from: describe - fight * *********************************************************************** */ // int exper_value(int mclass, int mHD, int maxhp); -int exper_value( const struct monsters *monster ); +int exper_value( const monsters *monster ); // last updated 12may2000 {dlb} diff --git a/crawl-ref/source/monplace.h b/crawl-ref/source/monplace.h index 0e85080c17..642c599abd 100644 --- a/crawl-ref/source/monplace.h +++ b/crawl-ref/source/monplace.h @@ -171,7 +171,7 @@ bool drac_colour_incompatible(int drac, int colour); /* *********************************************************************** * called from: monplace monstuff * *********************************************************************** */ -void mark_interesting_monst(struct monsters* monster, +void mark_interesting_monst(monsters* monster, beh_type behaviour = BEH_SLEEP); bool grid_compatible(dungeon_feature_type grid_wanted, diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h index e097ac040f..034aabe13d 100644 --- a/crawl-ref/source/monstuff.h +++ b/crawl-ref/source/monstuff.h @@ -82,13 +82,13 @@ void mons_check_pool(monsters *monster, killer_type killer = KILL_NONE, /* *********************************************************************** * called from: monstuff - fight * *********************************************************************** */ -void monster_cleanup(struct monsters *monster); +void monster_cleanup(monsters *monster); /* *********************************************************************** * called from: monstuff beam effects fight view * *********************************************************************** */ -void behaviour_event( struct monsters *mon, int event_type, +void behaviour_event( monsters *mon, int event_type, int src = MHITNOT, int src_x = 0, int src_y = 0 ); /* *********************************************************************** @@ -100,7 +100,7 @@ bool curse_an_item(bool decay_potions); /* *********************************************************************** * called from: fight * *********************************************************************** */ -bool monster_blink(struct monsters *monster); +bool monster_blink(monsters *monster); /* *********************************************************************** @@ -124,13 +124,13 @@ bool simple_monster_message(const monsters *monster, const char *event, /* *********************************************************************** * called from: acr * *********************************************************************** */ -bool swap_places(struct monsters *monster); +bool swap_places(monsters *monster); /* *********************************************************************** * called from: bang - beam - direct - fight - spells1 - spells2 - spells3 * *********************************************************************** */ -void print_wounds(const struct monsters *monster); +void print_wounds(const monsters *monster); /* *********************************************************************** @@ -174,14 +174,14 @@ int hurt_monster(monsters *victim, int damage_dealt); /* *********************************************************************** * called from: beam - fight - files - monstuff - spells1 * *********************************************************************** */ -bool heal_monster(struct monsters *patient, int health_boost, bool permit_growth); +bool heal_monster(monsters *patient, int health_boost, bool permit_growth); /* *********************************************************************** * called from: monplace - spells2 - view * *********************************************************************** */ -void seen_monster(struct monsters *monster); +void seen_monster(monsters *monster); -bool shift_monster( struct monsters *mon, int x = 0, int y = 0 ); +bool shift_monster(monsters *mon, int x = 0, int y = 0 ); int mons_weapon_damage_rating(const item_def &launcher); int mons_pick_best_missile(monsters *mons, item_def **launcher, diff --git a/crawl-ref/source/mstuff2.h b/crawl-ref/source/mstuff2.h index 26fc063909..d168e2b946 100644 --- a/crawl-ref/source/mstuff2.h +++ b/crawl-ref/source/mstuff2.h @@ -44,7 +44,7 @@ bolt mons_spells(int spell_cast, int power); /* *********************************************************************** * called from: monstuff * *********************************************************************** */ -void setup_dragon(struct monsters *monster, struct bolt &pbolt); +void setup_dragon(monsters *monster, struct bolt &pbolt); // last updated 13feb2001 {gdl} @@ -63,7 +63,7 @@ void setup_mons_cast(const monsters *monster, bolt &pbolt, int spell_cast); /* *********************************************************************** * called from: monstuff * *********************************************************************** */ -bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used); +bool mons_throw(monsters *monster, struct bolt &pbolt, int hand_used); bool mons_thrown_object_destroyed( item_def *item, int x, int y, bool returning, int midx ); @@ -72,20 +72,20 @@ bool mons_thrown_object_destroyed( item_def *item, int x, int y, /* *********************************************************************** * called from: monstuff * *********************************************************************** */ -void setup_generic_throw(struct monsters *monster, struct bolt &pbolt); +void setup_generic_throw(monsters *monster, struct bolt &pbolt); // last updated 12may2000 {dlb} /* *********************************************************************** * called from: monstuff * *********************************************************************** */ -void mons_trap(struct monsters *monster); +void mons_trap(monsters *monster); // last updated 12may2000 {dlb} /* *********************************************************************** * called from: beam - fight - files - monstuff - mstuff2 - spells4 * *********************************************************************** */ -void monster_teleport(struct monsters *monster, bool instan, +void monster_teleport(monsters *monster, bool instan, bool silent = false); @@ -93,7 +93,7 @@ void monster_teleport(struct monsters *monster, bool instan, /* *********************************************************************** * called from: monstuff * *********************************************************************** */ -void spore_goes_pop(struct monsters *monster); +void spore_goes_pop(monsters *monster); bool orc_battle_cry(monsters *chief); bool orange_statue_effects(monsters *mons); diff --git a/crawl-ref/source/msvc.h b/crawl-ref/source/msvc.h new file mode 100644 index 0000000000..d1dab39485 --- /dev/null +++ b/crawl-ref/source/msvc.h @@ -0,0 +1,16 @@ +#define snprintf _snprintf +#define itoa _itoa +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#define unlink _unlink + +// No va_copy in MSVC +#if defined(_MSC_VER) || !defined(va_copy) +#define va_copy(dst, src) \ + ((void) memcpy(&(dst), &(src), sizeof(va_list))) +#endif + +#pragma warning( disable : 4290 ) +#pragma warning( disable : 4351 ) +// bool -> int +#pragma warning( disable : 4800 ) diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 9cf4c2fe1c..33f5d3fda6 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -17,7 +17,7 @@ #include "externs.h" class monsters; -class item_def; +struct item_def; enum genus_type { diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h index 9a486edca7..c1d0b8fdcb 100644 --- a/crawl-ref/source/spells2.h +++ b/crawl-ref/source/spells2.h @@ -62,7 +62,7 @@ int corpse_rot(int power); int summon_elemental(int pow, int restricted_type, unsigned char unfriendly); -class dist; +struct dist; // last updated 24may2000 {dlb} /* *********************************************************************** * called from: spell diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc index 7c01f62431..ecd55b619f 100644 --- a/crawl-ref/source/store.cc +++ b/crawl-ref/source/store.cc @@ -771,6 +771,18 @@ const CrawlStoreValue &CrawlStoreValue::operator ///////////////////// // Typecast operators +#if _MSC_VER +CrawlStoreValue::operator bool&() { return get_bool(); } +CrawlStoreValue::operator char&() { return get_byte(); } +CrawlStoreValue::operator short&() { return get_short(); } +CrawlStoreValue::operator float&() { return get_float(); } +CrawlStoreValue::operator long&() { return get_long(); } +CrawlStoreValue::operator std::string&() { return get_string(); } +CrawlStoreValue::operator coord_def&() { return get_coord(); } +CrawlStoreValue::operator CrawlHashTable&() { return get_table(); } +CrawlStoreValue::operator CrawlVector&() { return get_vector(); } +CrawlStoreValue::operator item_def&() { return get_item(); } +#else &CrawlStoreValue::operator bool() { return get_bool(); @@ -820,6 +832,7 @@ const CrawlStoreValue &CrawlStoreValue::operator { return get_item(); } +#endif /////////////////////////// // Const typecast operators diff --git a/crawl-ref/source/store.h b/crawl-ref/source/store.h index 88984eb0a7..727892cd02 100644 --- a/crawl-ref/source/store.h +++ b/crawl-ref/source/store.h @@ -22,8 +22,8 @@ struct tagHeader; class CrawlHashTable; class CrawlVector; -class item_def; -class coord_def; +struct item_def; +struct coord_def; typedef unsigned char hash_size; typedef unsigned char vec_size; @@ -168,6 +168,18 @@ public: const CrawlStoreValue &operator [] (const vec_size &index) const; // Typecast operators +#if _MSC_VER + operator bool&(); + operator char&(); + operator short&(); + operator long&(); + operator float&(); + operator std::string&(); + operator coord_def&(); + operator CrawlHashTable&(); + operator CrawlVector&(); + operator item_def&(); +#else &operator bool(); &operator char(); &operator short(); @@ -178,6 +190,7 @@ public: &operator CrawlHashTable(); &operator CrawlVector(); &operator item_def(); +#endif operator bool() const; operator char() const; diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h index cd980bd298..c4af306e4f 100644 --- a/crawl-ref/source/terrain.h +++ b/crawl-ref/source/terrain.h @@ -15,7 +15,7 @@ #include "enum.h" -class coord_def; +struct coord_def; // last updated 12may2000 {dlb} /* *********************************************************************** diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index 7528cb3ebf..c71853285b 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -96,7 +96,7 @@ bool is_travelsafe_square(int x, int y, bool ignore_hostile = false, void start_explore(bool grab_items = false); struct level_pos; -struct level_id; +class level_id; struct travel_target; void start_translevel_travel(const travel_target &pos); @@ -175,7 +175,7 @@ enum explore_stop_type // Structs for interlevel travel. // Identifies a level. -struct level_id +class level_id { public: branch_type branch; // The branch in which the level is. diff --git a/crawl-ref/source/xom.h b/crawl-ref/source/xom.h index ec8878c9b1..61c015a736 100644 --- a/crawl-ref/source/xom.h +++ b/crawl-ref/source/xom.h @@ -13,7 +13,7 @@ #ifndef XOM_H #define XOM_H -class item_def; +struct item_def; enum xom_message_type { -- cgit v1.2.3-54-g00ecf