Commit graph

51 commits

Author SHA1 Message Date
Kp e3faab0899 Use alias template per_player_array for arrays that are MAX_PLAYERS long
This removes the need to repeat MAX_PLAYERS in every usage, and prepares
for a future change to use enumerated_array instead of std::array.
2022-09-24 17:47:53 +00:00
Kp b737524415 Use enum class for next_level_request_secret_flag
Instead of passing a bare `int` named `secret_flag`, define it as an
`enum class : uint8_t` to name the two special values.

Rework the passing of this value, to deal with some confusing
inconsistencies when reading the code.

Before this change:
In D1:
- Multiplayer will always go to the secret level, regardless of which
  exit door the player used.
In D2:
- Flying through a D1 secret exit in multiplayer shows the on-HUD error
  "Secret Level Teleporter disabled in multiplayer!", and does not exit
  the level.  This is at best confusing, and at worst dangerous, since
  D1 secret exits are only available during the countdown, so the player
  has little time to realize that the normal exit must be used instead.
- Like D1, multiplayer will request to go to the secret level regardless
  of the exit used.  Unlike D1, the caller ignores the flag and always
  advances to the next regular level.

After this change:
- No observable differences for the player in-game.  The questionable D2
  secret exit handling for D1 is retained.
- The code makes clearer that secret exits do not work in D2
  multiplayer, by way of `#if defined(DXX_BUILD_DESCENT_I)` guarding the
  existence of the parameter and all updates to it.
2022-07-16 15:26:12 +00:00
Kp 6215ef8e06 Pass LevelSharedRobotInfoState to various functions that need it 2022-07-09 13:39:29 +00:00
Kp 8d9989024e Split inferno.h to fwd-inferno.h 2022-02-12 18:57:12 +00:00
Kp 0fcaa76fd1 Move Next_level_num to local scope
It does not need to be a global.  For each function that uses it, it is
assigned earlier in that same function.
2021-11-01 03:37:19 +00:00
Kp fc63029833 Move more symbols into namespaces 2020-12-26 21:17:29 +00:00
Kp 0eaabdb2fb Move N_polygon_models into d_level_shared_polygon_model_state 2020-08-24 01:31:28 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp efc071e830 Make init_player_stats_ship static 2019-07-07 22:00:02 +00:00
Kp 5d99ec361d Simplify copy_defaults_to_robot
Write the shields once at the end.
2019-03-03 00:31:07 +00:00
Kp a0ed5cb283 Pass Vclip as context 2018-10-21 00:24:07 +00:00
Kp 88832e3679 Use constexpr integral_constant for various magic numbers 2017-10-14 17:10:30 +00:00
Kp e859833f62 Use valptridx for Players
Currently, N_players is still a free variable and Players.count is
unused.  Future work will replace N_players with Players.count.
2017-08-13 20:38:32 +00:00
Kp 4cf4ce38b0 Cache player references 2017-08-13 20:38:31 +00:00
Kp 599ac9dee0 Always qualify valptridx type/factory
Previously, valptridx used PREFIX for allow-invalid+mutable, c#PREFIX
for allow-invalid+const, v#PREFIX for require-valid+mutable, vc#PREFIX
for require-valid+const.  Convert the types, factories, and all usage
sites to specify a qualifier for all four combinations:

	im#PREFIX -> allow-invalid+mutable
	ic#PREFIX -> allow-invalid+const
	vm#PREFIX -> require-valid+mutable
	vc#PREFIX -> require-valid+const

Changes to common/include/valptridx.h and common/include/fwd-valptridx.h
are manual.  All other changes are generated by:

	git grep -lz -e '\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\>' | xargs -0 sed -i -e 's/\<\(v\?\)\(\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\)\>/\1m\2/g'

for the 'm' prefix and:

	git grep -lz -e '\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\>' | xargs -0 sed -i -e 's/\<\([cm]\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\)\>/i&/g'

for the 'i' prefix.
2017-06-10 03:31:02 +00:00
Chris Taylor a418f8caec Remove call to window_close(Game_wind) when multiplayer level syncing fails
Replace call to window_close(Game_wind) with returning window_event_result::close to game_handler. Applies to when there is a failure in net_udp_level_sync(). Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-10 13:02:59 +08:00
Chris Taylor 4cc801f42f Remove calls to window_close(Game_wind) when game finished or over
Replace calls to window_close(Game_wind) with returning window_event_result::close to game handler. Applies to when DoEndGame() is called, DoGameOver() is called, aborting in the kmatrix screen (multiplayer game) during AdvanceLevel() and playing one demo frame causes playback to stop in GameProcessFrame(). Closing a window within its handler is problematic - it can result in an unstable state.
2017-01-08 21:08:50 +08:00
Kp f8cc32a4af Merge pull #272 into master 2016-11-26 22:51:49 +00:00
Kp 6153fc6f8d Recharge omega cannon on entering new level 2016-11-26 22:51:49 +00:00
Chris Taylor 2995cb628c Never set Current_level_num to 0
This will be required when proper game state editing is implemented. Also remove hacks that check Current_level_num == 0.
2016-11-21 15:22:11 +08:00
Chris Taylor ac52a30214 Fix spurious exploding wall and crash when playing a level loaded with the editor
When File->'Play in 320x200' is chosen, use StartNewGame(Current_level_num). For now use create_new_mission and Current_level_num = 1 every time. Also remove the now redundant hacks GM_EDITOR and editor_reset_stuff_on_level.
2016-11-12 15:38:38 +08:00
Kp 4faca3012c Pass player_info to do_cloak_invul_secret_stuff 2016-10-28 03:39:42 +00:00
Kp fa620d5011 Make DoEndLevelScoreGlitz static 2016-10-15 00:53:14 +00:00
Kp 3024bb8bbe Pass object_base &to create_player_appearance_effect 2016-10-02 19:35:34 +00:00
Kp ee1003f29f Move conditionally compiled code into namespace dsx 2016-08-25 04:05:32 +00:00
Kp 99bbd0cf26 Mark global constants as constexpr
s/^const \([^*]*=.*;\)/constexpr \1/
2016-07-23 04:10:42 +00:00
Kp 5a94f8bf4f Fix check_header_includes build 2016-01-09 16:38:12 +00:00
Kp 26e948d5f1 Uninline namespace dsx 2015-12-13 18:00:49 +00:00
Kp dc8c0323d8 Uninline namespace dcx 2015-12-13 18:00:49 +00:00
Kp 8109379fdd Use inline namespace dsx for similar/misc/ 2015-12-13 18:00:48 +00:00
Kp bb41075adb Add preprocessor guards around types that vary by game 2015-11-26 02:56:55 +00:00
Kp 2196008178 Move fwdobject.h -> fwd-object.h for consistency 2015-10-10 03:44:14 +00:00
Kp f00725f740 Use forward-declaration header for player.h 2015-07-25 23:10:45 +00:00
Kp 4149ab6e5f Reduce gameseq.h includes 2015-04-19 04:18:51 +00:00
Kp 6a4c7ed78e Inline away D1 secret_restore values 2015-04-02 02:36:53 +00:00
Kp 90fbebf8fd Convert most global arrays to array<> 2015-04-02 02:36:52 +00:00
Kp 499b1d3b66 Use range_for for NumNetPlayerPositions 2014-12-23 04:20:27 +00:00
Kp 90666ba19b Use PHYSFSX_gets_line_t for Current_level_name 2014-12-20 04:36:07 +00:00
Kp f9a339dfc8 Pass bash_to_shield arg as vobjptr_t 2014-11-26 04:02:08 +00:00
Kp f206b3b127 Reduce inclusion of object.h 2014-11-23 04:36:58 +00:00
Kp 53aa70cecb Use vsegptridx_t 2014-10-28 03:08:51 +00:00
Kp aff354926e Remove unused bash_to_shield parameter s 2014-10-17 02:07:52 +00:00
Kp 66cb80c343 Propagate use of objptridx 2014-08-17 20:31:18 +00:00
zico ad7cb106bc Changed custom D1X license to GPLv3 2014-06-01 19:55:23 +02:00
Kp a3dd2ea963 Pass objptridx_t to create_player_appearance_effect 2014-01-11 22:57:55 +00:00
Kp 038bbad26a Rearrange headers to build under all test modes 2013-12-22 20:56:35 +00:00
Kp 9de54cfa74 Switch to C++ linkage
import fileinput
guard = 0
cxxguard = '#ifdef __cplusplus\n'
for line in fileinput.input(inplace=True):
	if line == cxxguard:
		guard = 1
		continue
	if guard:
		if line == 'extern "C" {\n':
			guard = 2
			continue
		if line == '}\n':
			guard = 0
			continue
		if guard == 2:
			assert(line == '#endif\n')
			guard = 0
			print cxxguard,
			continue
	print line,
2013-12-06 03:35:32 +00:00
Kp 64350f83b8 Move similar/main/cntrlcen.c -> similar/main/cntrlcen.cpp 2013-10-05 21:35:58 +00:00
Kp c58c4e4d06 Move declarations to headers 2013-10-03 03:11:52 +00:00
Kp a1ba420031 Mark various parameters and variables as const 2013-07-20 23:12:24 +00:00