From c68dddd372ec82a7cdeb25bfd842c9e13ddeb46b Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 19 Dec 2020 16:13:26 +0000 Subject: [PATCH] Move various definitions into namespaces --- common/include/maths.h | 3 -- common/include/physfs-serial.h | 4 ++ common/main/digi.h | 13 ++++--- common/main/fwd-segment.h | 2 +- common/main/fwd-wall.h | 22 ++++------- common/main/fwd-weapon.h | 4 -- common/main/morph.h | 4 +- common/main/multi.h | 3 -- common/main/newdemo.h | 8 ---- common/main/object.h | 14 ++++++- common/main/playsave.h | 8 ++++ common/main/powerup.h | 2 +- common/main/switch.h | 11 +----- common/main/wall.h | 3 +- similar/main/digiobj.cpp | 3 +- similar/main/newdemo.cpp | 27 ++++++++++---- similar/main/powerup.cpp | 7 ---- similar/main/switch.cpp | 2 - similar/main/wall.cpp | 67 +++++++++++++++++++++++++++------- similar/main/weapon.cpp | 16 ++++++-- 20 files changed, 131 insertions(+), 92 deletions(-) diff --git a/common/include/maths.h b/common/include/maths.h index 4569fb3db..a940b1105 100644 --- a/common/include/maths.h +++ b/common/include/maths.h @@ -16,9 +16,7 @@ #define D_RAND_MAX 32767 -#ifdef __cplusplus #include -#include "dxxsconf.h" #include "dsx-ns.h" #include @@ -207,4 +205,3 @@ static inline void clamp_fix_symmetric(fix& f, const fix& bound) } } -#endif diff --git a/common/include/physfs-serial.h b/common/include/physfs-serial.h index bda521af4..579ba51ce 100644 --- a/common/include/physfs-serial.h +++ b/common/include/physfs-serial.h @@ -10,6 +10,8 @@ #include "physfsx.h" #include "serial.h" +namespace dcx { + class PHYSFSX_short_read : public std::runtime_error { public: @@ -49,3 +51,5 @@ void PHYSFSX_serialize_write(PHYSFS_File *fp, const T &t) if (PHYSFS_write(fp, buf, sizeof(buf[0]), maximum_size) != maximum_size) throw E(fp); } + +} diff --git a/common/main/digi.h b/common/main/digi.h index 46060fb8e..65bc01ad0 100644 --- a/common/main/digi.h +++ b/common/main/digi.h @@ -43,6 +43,12 @@ namespace dcx { struct sound_object; extern int digi_volume; +enum class sound_stack : uint8_t +{ + allow_stacking, + cancel_previous, +}; + } namespace dsx { struct digi_sound @@ -64,11 +70,6 @@ extern void digi_close(); extern void digi_play_sample( int sndnum, fix max_volume ); extern void digi_play_sample_once( int sndnum, fix max_volume ); #if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II) -enum class sound_stack : uint8_t -{ - allow_stacking, - cancel_previous, -}; void digi_link_sound_to_object(unsigned soundnum, vcobjptridx_t objnum, uint8_t forever, fix max_volume, sound_stack once); void digi_kill_sound_linked_to_segment(vmsegidx_t segnum, unsigned sidenum, int soundnum); void digi_link_sound_to_pos(unsigned soundnum, vcsegptridx_t segnum, unsigned sidenum, const vms_vector &pos, int forever, fix max_volume); @@ -154,7 +155,7 @@ int verify_sound_channel_free( int channel ); } -namespace dcx { +namespace dsx { class RAIIdigi_sound { diff --git a/common/main/fwd-segment.h b/common/main/fwd-segment.h index c7bc07fdc..9271f0a5a 100644 --- a/common/main/fwd-segment.h +++ b/common/main/fwd-segment.h @@ -178,7 +178,7 @@ void dl_index_write(const dl_index *di, PHYSFS_File *fp); using dlindexnum_t = uint16_t; } #define DXX_VALPTRIDX_REPORT_ERROR_STYLE_default_dl_index trap_terse -DXX_VALPTRIDX_DECLARE_SUBTYPE(dsx::, dl_index, dlindexnum_t, 500); +DXX_VALPTRIDX_DECLARE_SUBTYPE(dsx::, dl_index, ::dsx::dlindexnum_t, 500); namespace dsx { DXX_VALPTRIDX_DEFINE_SUBTYPE_TYPEDEFS(dl_index, dlindex); int subtract_light(const d_level_shared_destructible_light_state &LevelSharedDestructibleLightState, vmsegptridx_t segnum, sidenum_fast_t sidenum); diff --git a/common/main/fwd-wall.h b/common/main/fwd-wall.h index 5e689d105..879fcd05f 100644 --- a/common/main/fwd-wall.h +++ b/common/main/fwd-wall.h @@ -243,19 +243,20 @@ namespace dsx { wall_hit_process_t wall_hit_process(player_flags, vmsegptridx_t seg, unsigned side, fix damage, unsigned playernum, const object &obj); // Opens/destroys specified door. -} -#endif void wall_toggle(fvmwallptr &vmwallptr, vmsegptridx_t segnum, unsigned side); // Called once per frame.. -#ifdef dsx -namespace dsx { void wall_frame_process(); -} -#endif //set the tmap_num or tmap_num2 field for a wall/door void wall_set_tmap_num(const wclip &, vmsegptridx_t seg, unsigned side, vmsegptridx_t csegp, unsigned cside, unsigned frame_num); +void wclip_read(PHYSFS_File *, wclip &wc); +void wall_read(PHYSFS_File *fp, wall &w); +void wall_write(PHYSFS_File *fp, const wall &w, short version); + +void wall_close_door_ref(fvmsegptridx &vmsegptridx, wall_array &Walls, const wall_animations_array &WallAnims, active_door &); +} +#endif #if defined(DXX_BUILD_DESCENT_II) //start wall open <-> closed transitions @@ -270,18 +271,9 @@ void blast_nearby_glass(const object &objp, fix damage); #endif #endif -void wclip_read(PHYSFS_File *, wclip &wc); -#if 0 -void wclip_write(PHYSFS_File *, const wclip &); -#endif - void v16_wall_read(PHYSFS_File *fp, v16_wall &w); void v19_wall_read(PHYSFS_File *fp, v19_wall &w); -void wall_read(PHYSFS_File *fp, wall &w); void active_door_read(PHYSFS_File *fp, active_door &ad); void active_door_write(PHYSFS_File *fp, const active_door &ad); - -void wall_write(PHYSFS_File *fp, const wall &w, short version); -void wall_close_door_ref(fvmsegptridx &vmsegptridx, wall_array &Walls, const wall_animations_array &WallAnims, active_door &); #endif diff --git a/common/main/fwd-weapon.h b/common/main/fwd-weapon.h index ec9ee2fb1..1158f68a3 100644 --- a/common/main/fwd-weapon.h +++ b/common/main/fwd-weapon.h @@ -230,12 +230,8 @@ namespace dsx { void InitWeaponOrdering(); void CyclePrimary(player_info &); void CycleSecondary(player_info &); -} -#endif void ReorderPrimary(); void ReorderSecondary(); -#ifdef dsx -namespace dsx { #if defined(DXX_BUILD_DESCENT_II) void check_to_use_primary_super_laser(player_info &player_info); void init_seismic_disturbances(void); diff --git a/common/main/morph.h b/common/main/morph.h index 4124017ed..d0d0a8f96 100644 --- a/common/main/morph.h +++ b/common/main/morph.h @@ -79,8 +79,8 @@ struct morph_data : prohibit_void_ptr }; object_base *const obj; // object which is morphing const object_signature_t Morph_sig; - typename object::control_type morph_save_control_type; - typename object::movement_type morph_save_movement_type; + typename object_base::control_type morph_save_control_type; + typename object_base::movement_type morph_save_movement_type; uint8_t n_submodels_active; std::array submodel_active; // which submodels are active const max_vectors max_vecs; diff --git a/common/main/multi.h b/common/main/multi.h index 37438c86b..500529759 100644 --- a/common/main/multi.h +++ b/common/main/multi.h @@ -55,7 +55,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #endif -#ifdef __cplusplus #include #include "digi.h" #include "pack.h" @@ -884,5 +883,3 @@ static inline unsigned get_player_or_team_color(unsigned pnum) ? get_team_color(get_team(pnum)) : get_player_color(pnum); } - -#endif diff --git a/common/main/newdemo.h b/common/main/newdemo.h index 6bbd4d546..ad6f2242b 100644 --- a/common/main/newdemo.h +++ b/common/main/newdemo.h @@ -74,18 +74,10 @@ extern struct object DemoRightExtra,DemoLeftExtra; namespace dsx { extern void newdemo_record_start_demo(); extern void newdemo_record_start_frame(fix frame_time ); -} -#endif -#ifdef dsx -#ifdef dsx -namespace dsx { void newdemo_record_render_object(vmobjptridx_t obj); void newdemo_record_viewer_object(vcobjptridx_t obj); -} -#endif icobjptridx_t newdemo_find_object(object_signature_t signature); void newdemo_record_kill_sound_linked_to_object(vcobjptridx_t); -namespace dsx { void newdemo_start_playback(const char *filename); void newdemo_record_morph_frame(vcobjptridx_t); } diff --git a/common/main/object.h b/common/main/object.h index 962451869..9e6f17ba6 100644 --- a/common/main/object.h +++ b/common/main/object.h @@ -35,7 +35,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "polyobj.h" #include "laser.h" -#ifdef __cplusplus #include #include #include "dxxsconf.h" @@ -260,6 +259,10 @@ struct laser_info : prohibit_void_ptr, laser_parent } }; +} + +namespace dcx { + // Same as above but structure Savegames/Multiplayer objects expect struct laser_info_rw { @@ -523,6 +526,8 @@ struct obj_position segnum_t segnum; // segment number containing object }; +} + #define set_object_type(O,T) \ ( DXX_BEGIN_COMPOUND_STATEMENT { \ object_base &dxx_object_type_ref = (O); \ @@ -547,6 +552,8 @@ struct obj_position dxx_object_type_ref.type = static_cast(dxx_object_type_value); \ } DXX_END_COMPOUND_STATEMENT ) +namespace dsx { + template constexpr std::array init_object_number_array(std::index_sequence) { @@ -562,6 +569,10 @@ struct object_number_array : std::array } }; +} + +namespace dcx { + unsigned laser_parent_is_matching_signature(const laser_parent &l, const object_base &o); struct d_level_unique_control_center_state @@ -807,6 +818,5 @@ void check_warn_object_type(const object_base &, object_type_t, const char *file #endif } -#endif #endif diff --git a/common/main/playsave.h b/common/main/playsave.h index 32ccab518..0e0e50994 100644 --- a/common/main/playsave.h +++ b/common/main/playsave.h @@ -81,6 +81,8 @@ struct hli #include "fwd-weapon.h" #include "d_array.h" +namespace dcx { + enum class FiringAutoselectMode : uint8_t { Immediate, @@ -109,6 +111,10 @@ enum MouselookMode : uint8_t MPAnarchy = 4, }; +} + +namespace dsx { + struct player_config : prohibit_void_ptr { ubyte ControlType; @@ -188,6 +194,8 @@ struct player_config : prohibit_void_ptr int DynLightColor; d_sp_gameplay_options SPGameplayOptions; }; + +} #endif extern struct player_config PlayerCfg; diff --git a/common/main/powerup.h b/common/main/powerup.h index 027cebd48..9626b7a69 100644 --- a/common/main/powerup.h +++ b/common/main/powerup.h @@ -135,13 +135,13 @@ void powerup_type_info_read(PHYSFS_File *fp, powerup_type_info &pti); void powerup_type_info_write(PHYSFS_File *fp, const powerup_type_info &pti); extern unsigned N_powerup_types; -void draw_powerup(const d_vclip_array &Vclip, grs_canvas &, const object_base &obj); } //returns true if powerup consumed #ifdef dsx namespace dsx { +void draw_powerup(const d_vclip_array &Vclip, grs_canvas &, const object_base &obj); using d_powerup_info_array = std::array; extern d_powerup_info_array Powerup_info; int do_powerup(vmobjptridx_t obj); diff --git a/common/main/switch.h b/common/main/switch.h index 7ebd67251..7995fc322 100644 --- a/common/main/switch.h +++ b/common/main/switch.h @@ -29,7 +29,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include "maths.h" -#ifdef __cplusplus #include "pack.h" #include "fwd-object.h" #include "fwd-segment.h" @@ -80,9 +79,7 @@ enum class trigger_behavior_flags : uint8_t disabled = 4, // Set after one-shot fires }; -enum class trigger_behavior_flag_mask : uint8_t -{ -}; +enum class trigger_behavior_flag_mask : uint8_t; static constexpr trigger_behavior_flag_mask operator~(const trigger_behavior_flags value) { @@ -249,7 +246,6 @@ extern void v30_trigger_read(v30_trigger *t, PHYSFS_File *fp); extern void trigger_read(trigger *t, PHYSFS_File *fp); void v29_trigger_read_as_v31(PHYSFS_File *fp, trigger &t); void v30_trigger_read_as_v31(PHYSFS_File *fp, trigger &t); -} /* * reads n trigger structs from a PHYSFS_File and swaps if specified @@ -257,13 +253,8 @@ void v30_trigger_read_as_v31(PHYSFS_File *fp, trigger &t); void trigger_read(PHYSFS_File *fp, trigger &t); void trigger_write(PHYSFS_File *fp, const trigger &t); -#ifdef dsx -namespace dsx { void v29_trigger_write(PHYSFS_File *fp, const trigger &t); void v30_trigger_write(PHYSFS_File *fp, const trigger &t); void v31_trigger_write(PHYSFS_File *fp, const trigger &t); } #endif -#endif - -#endif diff --git a/common/main/wall.h b/common/main/wall.h index bb7cbbf0a..8c375ef4d 100644 --- a/common/main/wall.h +++ b/common/main/wall.h @@ -25,7 +25,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #pragma once -#ifdef __cplusplus +#include "dsx-ns.h" #include "fwd-segment.h" #include "fwd-wall.h" #include "fwd-object.h" @@ -243,4 +243,3 @@ constexpr std::integral_constant wclip_frames_none{}; } #endif -#endif diff --git a/similar/main/digiobj.cpp b/similar/main/digiobj.cpp index d34b45b79..635f1e2b6 100644 --- a/similar/main/digiobj.cpp +++ b/similar/main/digiobj.cpp @@ -60,7 +60,6 @@ constexpr std::integral_constant SOF_LINK_TO_POS{}; // Sound is li constexpr std::integral_constant SOF_PLAY_FOREVER{}; // Play forever (or until level is stopped), otherwise plays once constexpr std::integral_constant SOF_PERMANENT{}; // Part of the level, like a waterfall or fan -constexpr std::integral_constant RAIIdigi_sound::invalid_channel; constexpr std::integral_constant MAX_SOUND_OBJECTS{}; struct sound_object @@ -149,6 +148,8 @@ static std::pair find_soun namespace dsx { +constexpr std::integral_constant RAIIdigi_sound::invalid_channel; + /* Find the sound which actually equates to a sound number */ int digi_xlat_sound(int soundno) { diff --git a/similar/main/newdemo.cpp b/similar/main/newdemo.cpp index 4b041b76c..5995e6d77 100644 --- a/similar/main/newdemo.cpp +++ b/similar/main/newdemo.cpp @@ -306,6 +306,8 @@ static typename std::enable_if::value, int>::type newdemo_re return _newdemo_read(buffer, elsize, nelem); } +namespace dsx { + icobjptridx_t newdemo_find_object(object_signature_t signature) { auto &Objects = LevelUniqueObjectState.Objects; @@ -318,6 +320,10 @@ icobjptridx_t newdemo_find_object(object_signature_t signature) return object_none; } +} + +namespace { + static int _newdemo_write(const void *buffer, int elsize, int nelem ) { int num_written, total_size; @@ -566,13 +572,16 @@ static void nd_read_shortpos(object_base &obj) auto &vcvertptr = Vertices.vcptr; extract_orient_from_segment(vcvertptr, obj.orient, vcsegptr(obj.segnum)); } - } object *prev_obj=NULL; //ptr to last object read in +} + namespace dsx { +namespace { + static uint16_t nd_get_object_signature(const vcobjptridx_t objp) { return (static_cast(objp->signature) << 9) ^ objp.get_unchecked_index(); // It's OKAY! We made sure, obj->signature is never has a value which short cannot handle!!! We cannot do this otherwise, without breaking the demo format! @@ -1008,8 +1017,13 @@ static void nd_write_object(const vcobjptridx_t objp) } } + } +} + +namespace { + static void nd_record_meta(char (&buf)[7], const char *s) { for (auto l = strlen(s) + 1; l;) @@ -1039,6 +1053,8 @@ static void nd_rdt(char (&buf)[7]) nd_record_meta(buf, st); } +} + static void nd_rbe() { char buf[7]{ND_EVENT_PALETTE_EFFECT, 0x80}; @@ -1144,9 +1160,7 @@ void newdemo_record_start_demo() newdemo_record_oneframeevent_update(0); #endif } -} -namespace dsx { void newdemo_record_start_frame(fix frame_time ) { if (nd_record_v_no_space) @@ -1198,9 +1212,7 @@ void newdemo_record_start_frame(fix frame_time ) } } -} -namespace dsx { void newdemo_record_render_object(const vmobjptridx_t obj) { if (!nd_record_v_recordframe) @@ -1217,9 +1229,7 @@ void newdemo_record_render_object(const vmobjptridx_t obj) nd_write_byte(ND_EVENT_RENDER_OBJECT); nd_write_object(obj); } -} -namespace dsx { void newdemo_record_viewer_object(const vcobjptridx_t obj) { if (!nd_record_v_recordframe) @@ -1272,13 +1282,14 @@ void newdemo_record_link_sound_to_object3( int soundno, objnum_t objnum, fix max nd_write_int( loop_end ); } +namespace dsx { void newdemo_record_kill_sound_linked_to_object(const vcobjptridx_t objp) { pause_game_world_time p; nd_write_byte( ND_EVENT_KILL_SOUND_TO_OBJ ); nd_write_int(nd_get_object_signature(objp)); } - +} void newdemo_record_wall_hit_process( segnum_t segnum, int side, int damage, int playernum ) { diff --git a/similar/main/powerup.cpp b/similar/main/powerup.cpp index 8bd9143bd..49c2fa6c4 100644 --- a/similar/main/powerup.cpp +++ b/similar/main/powerup.cpp @@ -119,19 +119,12 @@ void do_powerup_frame(const d_vclip_array &Vclip, const vmobjptridx_t obj) } } -} - -namespace dcx { - void draw_powerup(const d_vclip_array &Vclip, grs_canvas &canvas, const object_base &obj) { auto &vci = obj.rtype.vclip_info; draw_object_blob(canvas, obj, Vclip[vci.vclip_num].frames[vci.framenum]); } -} - -namespace dsx { namespace { static void _powerup_basic_nonhud(int redadd, int greenadd, int blueadd, int score) diff --git a/similar/main/switch.cpp b/similar/main/switch.cpp index a33de0a56..48861dd57 100644 --- a/similar/main/switch.cpp +++ b/similar/main/switch.cpp @@ -742,7 +742,6 @@ ASSERT_SERIAL_UDT_MESSAGE_SIZE(trigger, 54); DEFINE_SERIAL_UDT_TO_MESSAGE(trigger, t, (t.type, t.flags, t.num_links, serial::pad<1>(), t.value, serial::pad<4>(), t.seg, t.side)); ASSERT_SERIAL_UDT_MESSAGE_SIZE(trigger, 52); #endif -} /* * reads n trigger structs from a PHYSFS_File and swaps if specified @@ -757,7 +756,6 @@ void trigger_write(PHYSFS_File *fp, const trigger &t) PHYSFSX_serialize_write(fp, t); } -namespace dsx { void v29_trigger_write(PHYSFS_File *fp, const trigger &rt) { const trigger *t = &rt; diff --git a/similar/main/wall.cpp b/similar/main/wall.cpp index 618782d6a..a841c1258 100644 --- a/similar/main/wall.cpp +++ b/similar/main/wall.cpp @@ -140,6 +140,8 @@ struct find_cloaked_wall_predicate } #endif +namespace { + static std::pair get_transparency_check_values(const unique_side &side) { if (const auto masked_tmap_num2 = static_cast(get_texture_index(side.tmap_num2))) @@ -156,6 +158,8 @@ static uint_fast32_t check_transparency(const GameBitmaps_array &GameBitmaps, co return GameBitmaps[Textures[v.first].index].get_flag_mask(v.second); } +} + //----------------------------------------------------------------- // This function checks whether we can fly through the given side. // In other words, whether or not we have a 'doorway' @@ -171,6 +175,8 @@ static uint_fast32_t check_transparency(const GameBitmaps_array &GameBitmaps, co // WID_NO_WALL 5 // 1/0/1 no wall, can fly through namespace dsx { +namespace { + static WALL_IS_DOORWAY_result_t wall_is_doorway(const GameBitmaps_array &GameBitmaps, const Textures_array &Textures, fvcwallptr &vcwallptr, const shared_side &sside, const unique_side &uside) { auto &w = *vcwallptr(sside.wall_num); @@ -213,6 +219,8 @@ static WALL_IS_DOORWAY_result_t wall_is_doorway(const GameBitmaps_array &GameBit return WID_WALL; // There are children behind the door. } +} + WALL_IS_DOORWAY_result_t WALL_IS_DOORWAY(const GameBitmaps_array &GameBitmaps, const Textures_array &Textures, fvcwallptr &vcwallptr, const cscusegment seg, const uint_fast32_t side) { const auto child = seg.s.children[side]; @@ -227,12 +235,9 @@ WALL_IS_DOORWAY_result_t WALL_IS_DOORWAY(const GameBitmaps_array &GameBitmaps, c return wall_is_doorway(GameBitmaps, Textures, vcwallptr, sside, uside); } -} - #if DXX_USE_EDITOR //----------------------------------------------------------------- // Initializes all the walls (in other words, no special walls) -namespace dsx { void wall_init() { init_exploding_walls(); @@ -256,7 +261,6 @@ void wall_init() CloakingWalls.set_count(0); #endif -} } #endif @@ -289,6 +293,9 @@ void wall_set_tmap_num(const wclip &anim, const vmsegptridx_t seg, const unsigne } } +} + +namespace { // ------------------------------------------------------------------------------- //when the wall has used all its hitpoints, this will destroy it @@ -334,6 +341,7 @@ static void blast_blastable_wall(const vmsegptridx_t seg, const unsigned side, w } +} //----------------------------------------------------------------- // Destroys a blastable wall. @@ -515,11 +523,8 @@ void wall_open_door(const vmsegptridx_t seg, const unsigned side) } } -} #if defined(DXX_BUILD_DESCENT_II) -namespace dsx { - //----------------------------------------------------------------- // start the transition from closed -> open wall void start_wall_cloak(const vmsegptridx_t seg, const unsigned side) @@ -681,8 +686,6 @@ void start_wall_decloak(const vmsegptridx_t seg, const unsigned side) back_ls = s1_uvls.l; } } - -} #endif //----------------------------------------------------------------- @@ -711,6 +714,12 @@ void wall_close_door_ref(fvmsegptridx &vmsegptridx, wall_array &Walls, const wal } } +} + +namespace dcx { + +namespace { + static unsigned check_poke(fvcvertptr &vcvertptr, const object_base &obj, const shared_segment &seg, const unsigned side) { //note: don't let objects with zero size block door @@ -719,7 +728,14 @@ static unsigned check_poke(fvcvertptr &vcvertptr, const object_base &obj, const return get_seg_masks(vcvertptr, obj.pos, seg, obj.size).sidemask & (1 << side); //pokes through side! } +} + +} + namespace dsx { + +namespace { + static unsigned is_door_side_obstructed(fvcobjptridx &vcobjptridx, fvcsegptr &vcsegptr, const cscusegment seg, const unsigned side) { auto &LevelSharedVertexState = LevelSharedSegmentState.get_vertex_state(); @@ -752,6 +768,8 @@ static unsigned is_door_obstructed(fvcobjptridx &vcobjptridx, fvcsegptr &vcsegpt return is_door_side_obstructed(vcobjptridx, vcsegptr, csegp, Connectside); } +} + #if defined(DXX_BUILD_DESCENT_II) //----------------------------------------------------------------- // Closes a door @@ -836,6 +854,8 @@ void wall_close_door(wall_array &Walls, const vmsegptridx_t seg, const unsigned } #endif +namespace { + //----------------------------------------------------------------- // Animates opening of a door. // Called in the game loop. @@ -1048,6 +1068,8 @@ static void wall_illusion_op(fvmwallptr &vmwallptr, const vcsegptridx_t seg, con } } +} + //----------------------------------------------------------------- // Turns off an illusionary wall (This will be used primarily for // wall switches or triggers that can turn on/off illusionary walls.) @@ -1072,6 +1094,8 @@ void wall_illusion_on(fvmwallptr &vmwallptr, const vcsegptridx_t seg, const unsi } +namespace { + // ----------------------------------------------------------------------------- // Allowed to open the normally locked special boss door if in multiplayer mode. static int special_boss_opening_allowed(segnum_t segnum, int sidenum) @@ -1082,6 +1106,8 @@ static int special_boss_opening_allowed(segnum_t segnum, int sidenum) return 0; } +} + //----------------------------------------------------------------- // Determines what happens when a wall is shot //returns info about wall. see wall.h for codes @@ -1180,7 +1206,6 @@ wall_hit_process_t wall_hit_process(const player_flags powerup_flags, const vmse } return wall_hit_process_t::WHP_NOT_SPECIAL; //default is treat like normal wall } -} //----------------------------------------------------------------- // Opens doors/destroys wall/shuts off triggers. @@ -1242,6 +1267,8 @@ bool ad_removal_predicate::operator()(active_door &d) const } #if defined(DXX_BUILD_DESCENT_II) +namespace { + static void copy_cloaking_wall_light_to_wall(std::array &back_uvls, std::array &front_uvls, const cloaking_wall &d) { range_for (const uint_fast32_t i, xrange(4u)) @@ -1348,9 +1375,12 @@ bool cw_removal_predicate::operator()(cloaking_wall &d) ++ num_cloaking_walls; return r.remove; } + +} #endif -namespace dsx { +namespace { + static void process_exploding_walls() { if (Newdemo_state == ND_STATE_PLAYBACK) @@ -1373,6 +1403,8 @@ static void process_exploding_walls() } } +} + void wall_frame_process() { process_exploding_walls(); @@ -1625,6 +1657,7 @@ void blast_nearby_glass(const object &objp, const fix damage) DEFINE_SERIAL_UDT_TO_MESSAGE(wclip, wc, (wc.play_time, wc.num_frames, wc.frames, wc.open_sound, wc.close_sound, wc.flags, wc.filename, serial::pad<1>())); ASSERT_SERIAL_UDT_MESSAGE_SIZE(wclip, 26 + (sizeof(int16_t) * MAX_CLIP_FRAMES)); +namespace dsx { /* * reads a wclip structure from a PHYSFS_File */ @@ -1639,6 +1672,7 @@ void wclip_write(PHYSFS_File *fp, const wclip &wc) PHYSFSX_serialize_write(fp, wc); } #endif +} struct wrap_v16_wall { @@ -1687,6 +1721,7 @@ void v19_wall_read(PHYSFS_File *fp, v19_wall &w) DEFINE_SERIAL_UDT_TO_MESSAGE(wall, w, (serial::sign_extend(w.segnum), w.sidenum, serial::pad<3, 0>(), w.hps, serial::sign_extend(w.linked_wall), w.type, w.flags, w.state, w.trigger, w.clip_num, w.keys, _SERIAL_UDT_WALL_D2X_MEMBERS)); ASSERT_SERIAL_UDT_MESSAGE_SIZE(wall, 24); +namespace dsx { /* * reads a wall structure from a PHYSFS_File */ @@ -1696,6 +1731,8 @@ void wall_read(PHYSFS_File *fp, wall &w) w.flags &= ~WALL_EXPLODING; } +} + DEFINE_SERIAL_UDT_TO_MESSAGE(active_door, d, (d.n_parts, d.front_wallnum, d.back_wallnum, d.time)); ASSERT_SERIAL_UDT_MESSAGE_SIZE(active_door, 16); @@ -1712,6 +1749,8 @@ void active_door_write(PHYSFS_File *fp, const active_door &ad) PHYSFSX_serialize_write(fp, ad); } +namespace dsx { + void wall_write(PHYSFS_File *fp, const wall &w, short version) { if (version <= 16) @@ -1722,9 +1761,11 @@ void wall_write(PHYSFS_File *fp, const wall &w, short version) PHYSFSX_serialize_write(fp, w); } +} + #if defined(DXX_BUILD_DESCENT_II) -DEFINE_SERIAL_UDT_TO_MESSAGE(cloaking_wall, cw, (cw.front_wallnum, cw.back_wallnum, cw.front_ls, cw.back_ls, cw.time)); -ASSERT_SERIAL_UDT_MESSAGE_SIZE(cloaking_wall, 40); +DEFINE_SERIAL_UDT_TO_MESSAGE(dsx::cloaking_wall, cw, (cw.front_wallnum, cw.back_wallnum, cw.front_ls, cw.back_ls, cw.time)); +ASSERT_SERIAL_UDT_MESSAGE_SIZE(dsx::cloaking_wall, 40); namespace dsx { void cloaking_wall_read(cloaking_wall &cw, PHYSFS_File *fp) diff --git a/similar/main/weapon.cpp b/similar/main/weapon.cpp index 542b8c711..75ccde753 100644 --- a/similar/main/weapon.cpp +++ b/similar/main/weapon.cpp @@ -914,16 +914,20 @@ static void ReorderWeapon() } -void ReorderPrimary () +namespace dsx { + +void ReorderPrimary() { ReorderWeapon(); } -void ReorderSecondary () +void ReorderSecondary() { ReorderWeapon(); } +} + namespace { template @@ -1636,10 +1640,14 @@ void do_seismic_stuff(void) DEFINE_BITMAP_SERIAL_UDT(); #if defined(DXX_BUILD_DESCENT_I) -DEFINE_SERIAL_UDT_TO_MESSAGE(weapon_info, w, (w.render, w.model_num, w.model_num_inner, w.persistent, w.flash_vclip, w.flash_sound, w.robot_hit_vclip, w.robot_hit_sound, w.wall_hit_vclip, w.wall_hit_sound, w.fire_count, w.ammo_usage, w.weapon_vclip, w.destroyable, w.matter, w.bounce, w.homing_flag, w.dum1, w.dum2, w.dum3, w.energy_usage, w.fire_wait, w.bitmap, w.blob_size, w.flash_size, w.impact_size, w.strength, w.speed, w.mass, w.drag, w.thrust, w.po_len_to_width_ratio, w.light, w.lifetime, w.damage_radius, w.picture)); +DEFINE_SERIAL_UDT_TO_MESSAGE(dsx::weapon_info, w, (w.render, w.model_num, w.model_num_inner, w.persistent, w.flash_vclip, w.flash_sound, w.robot_hit_vclip, w.robot_hit_sound, w.wall_hit_vclip, w.wall_hit_sound, w.fire_count, w.ammo_usage, w.weapon_vclip, w.destroyable, w.matter, w.bounce, w.homing_flag, w.dum1, w.dum2, w.dum3, w.energy_usage, w.fire_wait, w.bitmap, w.blob_size, w.flash_size, w.impact_size, w.strength, w.speed, w.mass, w.drag, w.thrust, w.po_len_to_width_ratio, w.light, w.lifetime, w.damage_radius, w.picture)); #elif defined(DXX_BUILD_DESCENT_II) namespace { -struct v2_weapon_info : weapon_info {}; + +struct v2_weapon_info : weapon_info +{ +}; + } template