Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next-EnumLib

This commit is contained in:
Alug committed 2024-02-09 10:20:46 +01:00
commit a984476bfc
138 files changed
+11027 -7712

No files matched your search

+2
View File
@@ -16,3 +16,5 @@
#Appveyor
/appveyor.yml -crlf -whitespace
# Other
*.c text=auto
*.h text=auto
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large. Load diff
+429 -429
View File
@@ -1,429 +1,429 @@
/*
* libopenmpt_ext.hpp
* ------------------
* Purpose: libopenmpt public c++ interface for libopenmpt extensions
* Notes :
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#ifndef LIBOPENMPT_EXT_HPP
#define LIBOPENMPT_EXT_HPP
#include "libopenmpt_config.h"
#include "libopenmpt.hpp"
/*!
* \page libopenmpt_ext_cpp_overview libopenmpt_ext C++ API
*
* libopenmpt_ext is now included in all builds by default.
*
* \section libopenmpt-ext-cpp-detailed Detailed documentation
*
* \ref libopenmpt_ext_cpp
*
*/
/*! \defgroup libopenmpt_ext_cpp libopenmpt_ext C++ */
namespace openmpt {
/*! \addtogroup libopenmpt_ext_cpp
@{
*/
class module_ext_impl;
class LIBOPENMPT_CXX_API_CLASS module_ext : public module {
private:
module_ext_impl * ext_impl;
private:
// non-copyable
LIBOPENMPT_CXX_API_MEMBER module_ext( const module_ext & );
LIBOPENMPT_CXX_API_MEMBER void operator = ( const module_ext & );
public:
LIBOPENMPT_CXX_API_MEMBER module_ext( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector<std::byte> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector<std::uint8_t> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::byte * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER virtual ~module_ext();
public:
//! Retrieve a libopenmpt extension.
/*! Example: Retrieving the interactive extension to change the tempo of a module:
\code{.cpp}
openmpt::module_ext *mod = new openmpt::module_ext( stream );
#ifdef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE
openmpt::ext::interactive *interactive = static_cast<openmpt::ext::interactive *>( self->mod->get_interface( openmpt::ext::interactive_id ) );
if ( interactive ) {
interactive->set_tempo_factor( 2.0 ); // play module at double speed
} else {
// interface not available
}
#else
// interfae not available
#endif
\endcode
\param interface_id The name of the extension interface to retrieve.
\return The interface object. This may be a nullptr if the extension was not found.
*/
LIBOPENMPT_CXX_API_MEMBER void * get_interface( const std::string & interface_id );
}; // class module_ext
/*!
@}
*/
namespace ext {
/*! \addtogroup libopenmpt_ext_cpp
@{
*/
#define LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(name) \
static const char name ## _id [] = # name ; \
class name; \
/**/
#define LIBOPENMPT_EXT_CXX_INTERFACE(name) \
protected: \
name () {} \
virtual ~ name () {} \
public: \
/**/
#ifndef LIBOPENMPT_EXT_INTERFACE_PATTERN_VIS
#define LIBOPENMPT_EXT_INTERFACE_PATTERN_VIS
#endif
LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(pattern_vis)
class pattern_vis {
LIBOPENMPT_EXT_CXX_INTERFACE(pattern_vis)
//! Pattern command type
enum effect_type {
effect_unknown = 0,
effect_general = 1,
effect_global = 2,
effect_volume = 3,
effect_panning = 4,
effect_pitch = 5
}; // enum effect_type
//! Get pattern command type for pattern highlighting
/*!
\param pattern The pattern whose data should be retrieved.
\param row The row from which the data should be retrieved.
\param channel The channel from which the data should be retrieved.
\return The command type in the effect column at the given pattern position (see openmpt::ext::pattern_vis::effect_type)
\sa openmpt::ext::pattern_vis::get_pattern_row_channel_effect_type
*/
virtual effect_type get_pattern_row_channel_volume_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0;
//! Get pattern command type for pattern highlighting
/*!
\param pattern The pattern whose data should be retrieved.
\param row The row from which the data should be retrieved.
\param channel The channel from which the data should be retrieved.
\return The command type in the volume column at the given pattern position (see openmpt::ext::pattern_vis::effect_type)
\sa openmpt::ext::pattern_vis::get_pattern_row_channel_volume_effect_type
*/
virtual effect_type get_pattern_row_channel_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0;
}; // class pattern_vis
#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE
#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE
#endif
LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive)
class interactive {
LIBOPENMPT_EXT_CXX_INTERFACE(interactive)
//! Set the current ticks per row (speed)
/*!
\param speed The new tick count in range [1, 65535].
\throws openmpt::exception Throws an exception derived from openmpt::exception if the speed is outside the specified range.
\remarks The tick count may be reset by pattern commands at any time.
\sa openmpt::module::get_current_speed
*/
virtual void set_current_speed( std::int32_t speed ) = 0;
//! Set the current module tempo
/*!
\param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range.
\remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands.
\sa openmpt::module::get_current_tempo
\deprecated Please use openmpt::ext::interactive3::set_current_tempo2().
*/
LIBOPENMPT_ATTR_DEPRECATED virtual void set_current_tempo( std::int32_t tempo ) = 0;
//! Set the current module tempo factor without affecting playback pitch
/*!
\param factor The new tempo factor in range ]0.0, 4.0] - 1.0 means unmodified tempo.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range.
\remarks Modifying the tempo without applying the same pitch factor using openmpt::ext::interactive::set_pitch_factor may cause rhythmic samples (e.g. drum loops) to go out of sync.
\sa openmpt::ext::interactive::get_tempo_factor
*/
virtual void set_tempo_factor( double factor ) = 0;
//! Gets the current module tempo factor
/*!
\return The current tempo factor.
\sa openmpt::ext::interactive::set_tempo_factor
*/
virtual double get_tempo_factor( ) const = 0;
//! Set the current module pitch factor without affecting playback speed
/*!
\param factor The new pitch factor in range ]0.0, 4.0] - 1.0 means unmodified pitch.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range.
\remarks Modifying the pitch without applying the the same tempo factor using openmpt::ext::interactive::set_tempo_factor may cause rhythmic samples (e.g. drum loops) to go out of sync.
\remarks To shift the pich by `n` semitones, the parameter can be calculated as follows: `pow( 2.0, n / 12.0 )`
\sa openmpt::ext::interactive::get_pitch_factor
*/
virtual void set_pitch_factor( double factor ) = 0;
//! Gets the current module pitch factor
/*!
\return The current pitch factor.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the pitch is outside the specified range.
\sa openmpt::ext::interactive::set_pitch_factor
*/
virtual double get_pitch_factor( ) const = 0;
//! Set the current global volume
/*!
\param volume The new global volume in range [0.0, 1.0]
\throws openmpt::exception Throws an exception derived from openmpt::exception if the volume is outside the specified range.
\remarks The global volume may be reset by pattern commands at any time. Use openmpt::module::set_render_param to apply a global overall volume factor that is independent of pattern commands.
\sa openmpt::ext::interactive::get_global_volume
*/
virtual void set_global_volume( double volume ) = 0;
//! Get the current global volume
/*!
\return The current global volume in range [0.0, 1.0]
\sa openmpt::ext::interactive::set_global_volume
*/
virtual double get_global_volume( ) const = 0;
//! Set the current channel volume for a channel
/*!
\param channel The channel whose volume should be set, in range [0, openmpt::module::get_num_channels()[
\param volume The new channel volume in range [0.0, 1.0]
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel or volume is outside the specified range.
\remarks The channel volume may be reset by pattern commands at any time.
\sa openmpt::ext::interactive::get_channel_volume
*/
virtual void set_channel_volume( std::int32_t channel, double volume ) = 0;
//! Get the current channel volume for a channel
/*!
\param channel The channel whose volume should be retrieved, in range [0, openmpt::module::get_num_channels()[
\return The current channel volume in range [0.0, 1.0]
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\sa openmpt::ext::interactive::set_channel_volume
*/
virtual double get_channel_volume( std::int32_t channel ) const = 0;
//! Set the current mute status for a channel
/*!
\param channel The channel whose mute status should be set, in range [0, openmpt::module::get_num_channels()[
\param mute The new mute status. true is muted, false is unmuted.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\sa openmpt::ext::interactive::get_channel_mute_status
*/
virtual void set_channel_mute_status( std::int32_t channel, bool mute ) = 0;
//! Get the current mute status for a channel
/*!
\param channel The channel whose mute status should be retrieved, in range [0, openmpt::module::get_num_channels()[
\return The current channel mute status. true is muted, false is unmuted.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\sa openmpt::ext::interactive::set_channel_mute_status
*/
virtual bool get_channel_mute_status( std::int32_t channel ) const = 0;
//! Set the current mute status for an instrument
/*!
\param instrument The instrument whose mute status should be set, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[
\param mute The new mute status. true is muted, false is unmuted.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range.
\sa openmpt::ext::interactive::get_instrument_mute_status
*/
virtual void set_instrument_mute_status( std::int32_t instrument, bool mute ) = 0;
//! Get the current mute status for an instrument
/*!
\param instrument The instrument whose mute status should be retrieved, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[
\return The current instrument mute status. true is muted, false is unmuted.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range.
\sa openmpt::ext::interactive::set_instrument_mute_status
*/
virtual bool get_instrument_mute_status( std::int32_t instrument ) const = 0;
//! Play a note using the specified instrument
/*!
\param instrument The instrument that should be played, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[
\param note The note to play, in rage [0, 119]. 60 is the middle C.
\param volume The volume at which the note should be triggered, in range [0.0, 1.0]
\param panning The panning position at which the note should be triggered, in range [-1.0, 1.0], 0.0 is center.
\return The channel on which the note is played. This can pe be passed to openmpt::ext::interactive::stop_note to stop the note.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument or note is outside the specified range.
\sa openmpt::ext::interactive::stop_note
\sa openmpt::ext::interactive2::note_off
\sa openmpt::ext::interactive2::note_fade
*/
virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ) = 0;
//! Stop the note playing on the specified channel
/*!
\param channel The channel on which the note should be stopped. This is the value returned by a previous play_note call.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\sa openmpt::ext::interactive::play_note
\sa openmpt::ext::interactive2::note_off
\sa openmpt::ext::interactive2::note_fade
*/
virtual void stop_note( std::int32_t channel ) = 0;
}; // class interactive
#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE2
#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE2
#endif
LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive2)
class interactive2 {
LIBOPENMPT_EXT_CXX_INTERFACE(interactive2)
//! Sends a key-off command for the note playing on the specified channel
/*!
\param channel The channel on which the key-off event should be triggered. This is the value returned by a previous play_note call.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\remarks This method releases envelopes and sample sustain loops. If the sample has no sustain loop, or if the module does not use instruments, it does nothing.
\sa openmpt::ext::interactive::play_note
\sa openmpt::ext::interactive::stop_note
\sa openmpt::ext::interactive2::note_fade
\since 0.6.0
*/
virtual void note_off(int32_t channel ) = 0;
//! Sends a note fade command for the note playing on the specified channel
/*!
\param channel The channel on which the note should be faded. This is the value returned by a previous play_note call.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\remarks This method uses the instrument's fade-out value. If the module does not use instruments, or the instrument's fade-out value is 0, it does nothing.
\sa openmpt::ext::interactive::play_note
\sa openmpt::ext::interactive::stop_note
\sa openmpt::ext::interactive2::note_off
\since 0.6.0
*/
virtual void note_fade(int32_t channel) = 0;
//! Set the current panning position for a channel
/*!
\param channel The channel whose panning will be changed, in range [0, openmpt::module::get_num_channels()[
\param panning The panning position to set on the channel, in range [-1.0, 1.0], 0.0 is center.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\remarks This command affects subsequent notes played on the same channel, and may itself be overridden by subsequent panning commands encountered in the module itself.
\sa openmpt::ext::interactive2::get_channel_panning
\since 0.6.0
*/
virtual void set_channel_panning(int32_t channel, double panning ) = 0;
//! Get the current panning position for a channel
/*!
\param channel The channel whose panning should be retrieved, in range [0, openmpt::module::get_num_channels()[
\return The current channel panning, in range [-1.0, 1.0], 0.0 is center.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\sa openmpt::ext::interactive2::set_channel_panning
\since 0.6.0
*/
virtual double get_channel_panning( int32_t channel ) = 0;
//! Set the finetune for the currently playing note on a channel
/*!
\param channel The channel whose finetune will be changed, in range [0, openmpt::module::get_num_channels()[
\param finetune The finetune to set on the channel, in range [-1.0, 1.0], 0.0 is center.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\remarks The finetune range depends on the pitch wheel depth of the instrument playing on the current channel; for sample-based modules, the depth of this command is fixed to +/-1 semitone.
\remarks This command does not affect subsequent notes played on the same channel, but may itself be overridden by subsequent finetune commands encountered in the module itself.
\sa openmpt::ext::interactive2::get_note_finetune
\since 0.6.0
*/
virtual void set_note_finetune(int32_t channel, double finetune ) = 0;
//! Get the finetune for the currently playing note on a channel
/*!
\param channel The channel whose finetune should be retrieved, in range [0, openmpt::module::get_num_channels()[
\return The current channel finetune, in range [-1.0, 1.0], 0.0 is center.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\remarks The finetune range depends on the pitch wheel depth of the instrument playing on the current channel; for sample-based modules, the depth of this command is fixed to +/-1 semitone.
\sa openmpt::ext::interactive2::set_note_finetune
\since 0.6.0
*/
virtual double get_note_finetune( int32_t channel ) = 0;
}; // class interactive2
#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE3
#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE3
#endif
LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive3)
class interactive3 {
LIBOPENMPT_EXT_CXX_INTERFACE(interactive3)
//! Set the current module tempo
/*!
\param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range.
\remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands.
\sa openmpt::module::get_current_tempo2
\since 0.7.0
*/
virtual void set_current_tempo2( double tempo ) = 0;
}; // class interactive3
/* add stuff here */
#undef LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE
#undef LIBOPENMPT_EXT_CXX_INTERFACE
/*!
@}
*/
} // namespace ext
} // namespace openmpt
#endif // LIBOPENMPT_EXT_HPP
/*
* libopenmpt_ext.hpp
* ------------------
* Purpose: libopenmpt public c++ interface for libopenmpt extensions
* Notes :
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#ifndef LIBOPENMPT_EXT_HPP
#define LIBOPENMPT_EXT_HPP
#include "libopenmpt_config.h"
#include "libopenmpt.hpp"
/*!
* \page libopenmpt_ext_cpp_overview libopenmpt_ext C++ API
*
* libopenmpt_ext is now included in all builds by default.
*
* \section libopenmpt-ext-cpp-detailed Detailed documentation
*
* \ref libopenmpt_ext_cpp
*
*/
/*! \defgroup libopenmpt_ext_cpp libopenmpt_ext C++ */
namespace openmpt {
/*! \addtogroup libopenmpt_ext_cpp
@{
*/
class module_ext_impl;
class LIBOPENMPT_CXX_API_CLASS module_ext : public module {
private:
module_ext_impl * ext_impl;
private:
// non-copyable
LIBOPENMPT_CXX_API_MEMBER module_ext( const module_ext & );
LIBOPENMPT_CXX_API_MEMBER void operator = ( const module_ext & );
public:
LIBOPENMPT_CXX_API_MEMBER module_ext( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector<std::byte> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector<std::uint8_t> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::byte * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER module_ext( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() );
LIBOPENMPT_CXX_API_MEMBER virtual ~module_ext();
public:
//! Retrieve a libopenmpt extension.
/*! Example: Retrieving the interactive extension to change the tempo of a module:
\code{.cpp}
openmpt::module_ext *mod = new openmpt::module_ext( stream );
#ifdef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE
openmpt::ext::interactive *interactive = static_cast<openmpt::ext::interactive *>( self->mod->get_interface( openmpt::ext::interactive_id ) );
if ( interactive ) {
interactive->set_tempo_factor( 2.0 ); // play module at double speed
} else {
// interface not available
}
#else
// interfae not available
#endif
\endcode
\param interface_id The name of the extension interface to retrieve.
\return The interface object. This may be a nullptr if the extension was not found.
*/
LIBOPENMPT_CXX_API_MEMBER void * get_interface( const std::string & interface_id );
}; // class module_ext
/*!
@}
*/
namespace ext {
/*! \addtogroup libopenmpt_ext_cpp
@{
*/
#define LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(name) \
static const char name ## _id [] = # name ; \
class name; \
/**/
#define LIBOPENMPT_EXT_CXX_INTERFACE(name) \
protected: \
name () {} \
virtual ~ name () {} \
public: \
/**/
#ifndef LIBOPENMPT_EXT_INTERFACE_PATTERN_VIS
#define LIBOPENMPT_EXT_INTERFACE_PATTERN_VIS
#endif
LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(pattern_vis)
class pattern_vis {
LIBOPENMPT_EXT_CXX_INTERFACE(pattern_vis)
//! Pattern command type
enum effect_type {
effect_unknown = 0,
effect_general = 1,
effect_global = 2,
effect_volume = 3,
effect_panning = 4,
effect_pitch = 5
}; // enum effect_type
//! Get pattern command type for pattern highlighting
/*!
\param pattern The pattern whose data should be retrieved.
\param row The row from which the data should be retrieved.
\param channel The channel from which the data should be retrieved.
\return The command type in the effect column at the given pattern position (see openmpt::ext::pattern_vis::effect_type)
\sa openmpt::ext::pattern_vis::get_pattern_row_channel_effect_type
*/
virtual effect_type get_pattern_row_channel_volume_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0;
//! Get pattern command type for pattern highlighting
/*!
\param pattern The pattern whose data should be retrieved.
\param row The row from which the data should be retrieved.
\param channel The channel from which the data should be retrieved.
\return The command type in the volume column at the given pattern position (see openmpt::ext::pattern_vis::effect_type)
\sa openmpt::ext::pattern_vis::get_pattern_row_channel_volume_effect_type
*/
virtual effect_type get_pattern_row_channel_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0;
}; // class pattern_vis
#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE
#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE
#endif
LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive)
class interactive {
LIBOPENMPT_EXT_CXX_INTERFACE(interactive)
//! Set the current ticks per row (speed)
/*!
\param speed The new tick count in range [1, 65535].
\throws openmpt::exception Throws an exception derived from openmpt::exception if the speed is outside the specified range.
\remarks The tick count may be reset by pattern commands at any time.
\sa openmpt::module::get_current_speed
*/
virtual void set_current_speed( std::int32_t speed ) = 0;
//! Set the current module tempo
/*!
\param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range.
\remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands.
\sa openmpt::module::get_current_tempo
\deprecated Please use openmpt::ext::interactive3::set_current_tempo2().
*/
LIBOPENMPT_ATTR_DEPRECATED virtual void set_current_tempo( std::int32_t tempo ) = 0;
//! Set the current module tempo factor without affecting playback pitch
/*!
\param factor The new tempo factor in range ]0.0, 4.0] - 1.0 means unmodified tempo.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range.
\remarks Modifying the tempo without applying the same pitch factor using openmpt::ext::interactive::set_pitch_factor may cause rhythmic samples (e.g. drum loops) to go out of sync.
\sa openmpt::ext::interactive::get_tempo_factor
*/
virtual void set_tempo_factor( double factor ) = 0;
//! Gets the current module tempo factor
/*!
\return The current tempo factor.
\sa openmpt::ext::interactive::set_tempo_factor
*/
virtual double get_tempo_factor( ) const = 0;
//! Set the current module pitch factor without affecting playback speed
/*!
\param factor The new pitch factor in range ]0.0, 4.0] - 1.0 means unmodified pitch.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range.
\remarks Modifying the pitch without applying the the same tempo factor using openmpt::ext::interactive::set_tempo_factor may cause rhythmic samples (e.g. drum loops) to go out of sync.
\remarks To shift the pich by `n` semitones, the parameter can be calculated as follows: `pow( 2.0, n / 12.0 )`
\sa openmpt::ext::interactive::get_pitch_factor
*/
virtual void set_pitch_factor( double factor ) = 0;
//! Gets the current module pitch factor
/*!
\return The current pitch factor.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the pitch is outside the specified range.
\sa openmpt::ext::interactive::set_pitch_factor
*/
virtual double get_pitch_factor( ) const = 0;
//! Set the current global volume
/*!
\param volume The new global volume in range [0.0, 1.0]
\throws openmpt::exception Throws an exception derived from openmpt::exception if the volume is outside the specified range.
\remarks The global volume may be reset by pattern commands at any time. Use openmpt::module::set_render_param to apply a global overall volume factor that is independent of pattern commands.
\sa openmpt::ext::interactive::get_global_volume
*/
virtual void set_global_volume( double volume ) = 0;
//! Get the current global volume
/*!
\return The current global volume in range [0.0, 1.0]
\sa openmpt::ext::interactive::set_global_volume
*/
virtual double get_global_volume( ) const = 0;
//! Set the current channel volume for a channel
/*!
\param channel The channel whose volume should be set, in range [0, openmpt::module::get_num_channels()[
\param volume The new channel volume in range [0.0, 1.0]
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel or volume is outside the specified range.
\remarks The channel volume may be reset by pattern commands at any time.
\sa openmpt::ext::interactive::get_channel_volume
*/
virtual void set_channel_volume( std::int32_t channel, double volume ) = 0;
//! Get the current channel volume for a channel
/*!
\param channel The channel whose volume should be retrieved, in range [0, openmpt::module::get_num_channels()[
\return The current channel volume in range [0.0, 1.0]
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\sa openmpt::ext::interactive::set_channel_volume
*/
virtual double get_channel_volume( std::int32_t channel ) const = 0;
//! Set the current mute status for a channel
/*!
\param channel The channel whose mute status should be set, in range [0, openmpt::module::get_num_channels()[
\param mute The new mute status. true is muted, false is unmuted.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\sa openmpt::ext::interactive::get_channel_mute_status
*/
virtual void set_channel_mute_status( std::int32_t channel, bool mute ) = 0;
//! Get the current mute status for a channel
/*!
\param channel The channel whose mute status should be retrieved, in range [0, openmpt::module::get_num_channels()[
\return The current channel mute status. true is muted, false is unmuted.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\sa openmpt::ext::interactive::set_channel_mute_status
*/
virtual bool get_channel_mute_status( std::int32_t channel ) const = 0;
//! Set the current mute status for an instrument
/*!
\param instrument The instrument whose mute status should be set, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[
\param mute The new mute status. true is muted, false is unmuted.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range.
\sa openmpt::ext::interactive::get_instrument_mute_status
*/
virtual void set_instrument_mute_status( std::int32_t instrument, bool mute ) = 0;
//! Get the current mute status for an instrument
/*!
\param instrument The instrument whose mute status should be retrieved, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[
\return The current instrument mute status. true is muted, false is unmuted.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range.
\sa openmpt::ext::interactive::set_instrument_mute_status
*/
virtual bool get_instrument_mute_status( std::int32_t instrument ) const = 0;
//! Play a note using the specified instrument
/*!
\param instrument The instrument that should be played, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[
\param note The note to play, in rage [0, 119]. 60 is the middle C.
\param volume The volume at which the note should be triggered, in range [0.0, 1.0]
\param panning The panning position at which the note should be triggered, in range [-1.0, 1.0], 0.0 is center.
\return The channel on which the note is played. This can pe be passed to openmpt::ext::interactive::stop_note to stop the note.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument or note is outside the specified range.
\sa openmpt::ext::interactive::stop_note
\sa openmpt::ext::interactive2::note_off
\sa openmpt::ext::interactive2::note_fade
*/
virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ) = 0;
//! Stop the note playing on the specified channel
/*!
\param channel The channel on which the note should be stopped. This is the value returned by a previous play_note call.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\sa openmpt::ext::interactive::play_note
\sa openmpt::ext::interactive2::note_off
\sa openmpt::ext::interactive2::note_fade
*/
virtual void stop_note( std::int32_t channel ) = 0;
}; // class interactive
#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE2
#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE2
#endif
LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive2)
class interactive2 {
LIBOPENMPT_EXT_CXX_INTERFACE(interactive2)
//! Sends a key-off command for the note playing on the specified channel
/*!
\param channel The channel on which the key-off event should be triggered. This is the value returned by a previous play_note call.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\remarks This method releases envelopes and sample sustain loops. If the sample has no sustain loop, or if the module does not use instruments, it does nothing.
\sa openmpt::ext::interactive::play_note
\sa openmpt::ext::interactive::stop_note
\sa openmpt::ext::interactive2::note_fade
\since 0.6.0
*/
virtual void note_off(int32_t channel ) = 0;
//! Sends a note fade command for the note playing on the specified channel
/*!
\param channel The channel on which the note should be faded. This is the value returned by a previous play_note call.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\remarks This method uses the instrument's fade-out value. If the module does not use instruments, or the instrument's fade-out value is 0, it does nothing.
\sa openmpt::ext::interactive::play_note
\sa openmpt::ext::interactive::stop_note
\sa openmpt::ext::interactive2::note_off
\since 0.6.0
*/
virtual void note_fade(int32_t channel) = 0;
//! Set the current panning position for a channel
/*!
\param channel The channel whose panning will be changed, in range [0, openmpt::module::get_num_channels()[
\param panning The panning position to set on the channel, in range [-1.0, 1.0], 0.0 is center.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\remarks This command affects subsequent notes played on the same channel, and may itself be overridden by subsequent panning commands encountered in the module itself.
\sa openmpt::ext::interactive2::get_channel_panning
\since 0.6.0
*/
virtual void set_channel_panning(int32_t channel, double panning ) = 0;
//! Get the current panning position for a channel
/*!
\param channel The channel whose panning should be retrieved, in range [0, openmpt::module::get_num_channels()[
\return The current channel panning, in range [-1.0, 1.0], 0.0 is center.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\sa openmpt::ext::interactive2::set_channel_panning
\since 0.6.0
*/
virtual double get_channel_panning( int32_t channel ) = 0;
//! Set the finetune for the currently playing note on a channel
/*!
\param channel The channel whose finetune will be changed, in range [0, openmpt::module::get_num_channels()[
\param finetune The finetune to set on the channel, in range [-1.0, 1.0], 0.0 is center.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid.
\remarks The finetune range depends on the pitch wheel depth of the instrument playing on the current channel; for sample-based modules, the depth of this command is fixed to +/-1 semitone.
\remarks This command does not affect subsequent notes played on the same channel, but may itself be overridden by subsequent finetune commands encountered in the module itself.
\sa openmpt::ext::interactive2::get_note_finetune
\since 0.6.0
*/
virtual void set_note_finetune(int32_t channel, double finetune ) = 0;
//! Get the finetune for the currently playing note on a channel
/*!
\param channel The channel whose finetune should be retrieved, in range [0, openmpt::module::get_num_channels()[
\return The current channel finetune, in range [-1.0, 1.0], 0.0 is center.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range.
\remarks The finetune range depends on the pitch wheel depth of the instrument playing on the current channel; for sample-based modules, the depth of this command is fixed to +/-1 semitone.
\sa openmpt::ext::interactive2::set_note_finetune
\since 0.6.0
*/
virtual double get_note_finetune( int32_t channel ) = 0;
}; // class interactive2
#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE3
#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE3
#endif
LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive3)
class interactive3 {
LIBOPENMPT_EXT_CXX_INTERFACE(interactive3)
//! Set the current module tempo
/*!
\param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module.
\throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range.
\remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands.
\sa openmpt::module::get_current_tempo2
\since 0.7.0
*/
virtual void set_current_tempo2( double tempo ) = 0;
}; // class interactive3
/* add stuff here */
#undef LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE
#undef LIBOPENMPT_EXT_CXX_INTERFACE
/*!
@}
*/
} // namespace ext
} // namespace openmpt
#endif // LIBOPENMPT_EXT_HPP
@@ -21,7 +21,7 @@
/*! \brief libopenmpt minor version number */
#define OPENMPT_API_VERSION_MINOR 7
/*! \brief libopenmpt patch version number */
#define OPENMPT_API_VERSION_PATCH 2
#define OPENMPT_API_VERSION_PATCH 3
/*! \brief libopenmpt pre-release tag */
#define OPENMPT_API_VERSION_PREREL ""
/*! \brief libopenmpt pre-release flag */
Binary file not shown.
Binary file not shown.
Binary file not shown.
+20
View File
@@ -0,0 +1,20 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Sonic Robo Blast 2 Kart Saturn
Comment=A kart racing mod based on the 3D Sonic the Hedgehog fangame Sonic Robo Blast 2
TryExec=srb2kart.sh
Exec=srb2kart.sh
Icon=org.srb2.SRB2Kart-Saturn
Terminal=false
Categories=Game;SportsGame;
Keywords=kart;sonic;racer;multiplayer;doom;
Actions=OpenGL;Software;
[Desktop Action OpenGL]
Name=OpenGL renderer
Exec=srb2kart.sh -opengl
[Desktop Action Software]
Name=Software renderer
Exec=srb2kart.sh -software
+80
View File
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2023 Flathub maintainers -->
<component type="desktop-application">
<id>org.srb2.SRB2Kart-Saturn</id>
<metadata_license>FSFAP</metadata_license>
<project_license>GPL-2.0+</project_license>
<name>Sonic Robo Blast 2 Kart Saturn</name>
<summary>Modded SRB2Kart adding many custom features</summary>
<description>
<p>
A modded net-compatible version of SRB2Kart v1.6 that offers multiple code optimizations, palette rendering, player sprite rotation, base Kart HUD customization, and many more.
</p>
</description>
<launchable type="desktop-id">org.srb2.SRB2Kart-Saturn.desktop</launchable>
<screenshots>
<screenshot type="default">
<image>https://wiki.srb2.org/w/images/a/ac/Srb2kart_title.png</image>
<caption>Title screen</caption>
</screenshot>
<screenshot>
<image>https://user-images.githubusercontent.com/15758649/227740700-26e0962b-5572-486c-b633-7d4990d86f89.png</image>
<caption>Game modes</caption>
</screenshot>
<screenshot>
<image>https://user-images.githubusercontent.com/1964655/82821921-3d180c00-9ea5-11ea-937b-e1f53fe6c686.png</image>
<caption>Game play as Sonic</caption>
</screenshot>
<screenshot>
<image>https://user-images.githubusercontent.com/1964655/82821933-41442980-9ea5-11ea-9146-38998161edae.png</image>
<caption>Game play as Tails</caption>
</screenshot>
<screenshot>
<image>https://user-images.githubusercontent.com/1964655/82821966-502adc00-9ea5-11ea-9cbd-274d7adb479e.png</image>
<caption>Game play as Eggman</caption>
</screenshot>
<screenshot>
<image>https://user-images.githubusercontent.com/1964655/82821980-5620bd00-9ea5-11ea-9eec-2835ebb2a262.png</image>
<caption>Game play as Metal Sonic</caption>
</screenshot>
</screenshots>
<url type="homepage">https://github.com/Indev450/SRB2Kart-Saturn</url>
<url type="bugtracker">https://github.com/Indev450/SRB2Kart-Saturn/issues</url>
<developer_name>Indev450</developer_name>
<provides>
<binary>srb2kart</binary>
</provides>
<releases>
<release version="5.1" date="2023-12-20">
<description>
<p>The complete changelog can be found on the build's GitHub repository.</p>
</description>
<url>https://github.com/Indev450/SRB2Kart-Saturn/releases/tag/v5.1</url>
</release>
<release version="5.0" date="2023-12-17">
<description>
<p>The complete changelog can be found on the build's GitHub repository.</p>
</description>
<url>https://github.com/Indev450/SRB2Kart-Saturn/releases/tag/v5</url>
</release>
</releases>
<categories>
<category>Game</category>
<category>SportsGame</category>
</categories>
<recommends>
<control>keyboard</control>
<control>gamepad</control>
</recommends>
<content_rating type="oars-1.1">
<content_attribute id="violence-cartoon">moderate</content_attribute>
<content_attribute id="language-humor">mild</content_attribute>
<content_attribute id="social-chat">intense</content_attribute>
<content_attribute id="social-info">mild</content_attribute>
</content_rating>
<keywords>
<keyword>doom</keyword>
<keyword>multiplayer</keyword>
<keyword>racing</keyword>
</keywords>
</component>
+4 -3
View File
@@ -3,7 +3,6 @@
# Core sources
set(SRB2_CORE_SOURCES
am_map.c
args.c
b_bot.c
command.c
comptime.c
@@ -53,7 +52,6 @@ set(SRB2_CORE_SOURCES
set(SRB2_CORE_HEADERS
am_map.h
args.h
b_bot.h
byteptr.h
command.h
@@ -107,7 +105,6 @@ set(SRB2_CORE_HEADERS
m_swap.h
md5.h
mserv.h
p5prof.h
s_sound.h
screen.h
sounds.h
@@ -457,6 +454,8 @@ endif()
if(${SRB2_CONFIG_HWRENDER})
add_definitions(-DHWRENDER)
set(SRB2_HWRENDER_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c
@@ -472,6 +471,8 @@ if(${SRB2_CONFIG_HWRENDER})
)
set (SRB2_HWRENDER_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
+1 -2
View File
@@ -275,7 +275,7 @@ else
OPTS+=-DHWRENDER
OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o $(OBJDIR)/hw_light.o \
$(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o $(OBJDIR)/hw_trick.o \
$(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o
$(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o $(OBJDIR)/hw_shaders.o
endif
OPTS += -DCOMPVERSION
@@ -538,7 +538,6 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/i_time.o \
$(OBJDIR)/lzf.o \
$(OBJDIR)/b_bot.o \
$(OBJDIR)/args.o \
$(i_net_o) \
$(i_system_o) \
$(i_sound_o) \
-37
View File
@@ -1,37 +0,0 @@
#include "../command.h"
#include "../s_sound.h"
#include "../i_sound.h"
//
// CD MUSIC I/O
//
UINT8 cdaudio_started = 0;
consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
void I_InitCD(void){}
void I_StopCD(void){}
void I_PauseCD(void){}
void I_ResumeCD(void){}
void I_ShutdownCD(void){}
void I_UpdateCD(void){}
void I_PlayCD(UINT8 track, UINT8 looping)
{
(void)track;
(void)looping;
}
boolean I_SetVolumeCD(INT32 volume)
{
(void)volume;
return false;
}
-2
View File
@@ -24,12 +24,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define APNG_H
#ifndef _MSC_VER
#ifndef _WII
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
#endif
#endif
#ifndef _LFS64_LARGEFILE
#define _LFS64_LARGEFILE
-1309
View File
File diff suppressed because it is too large. Load diff
-206
View File
@@ -1,206 +0,0 @@
// -----------------------------------------------------------------------------
// Args: a C99 library for parsing command line arguments.
// Version: 2.8.0
// Notes: This has been edited to work properly within SRB2.
// Licensed under the 0BSD license.
// -----------------------------------------------------------------------------
#ifndef args_h
#define args_h
#include "doomtype.h"
// -----------------------------------------------------------------------------
// Types.
// -----------------------------------------------------------------------------
// An ArgParser instance stores registered flags, options and commands.
typedef struct ArgParser ArgParser;
// A command callback function should accept two arguments: the command's name
// and the command's ArgParser instance.
typedef void (*ap_callback_t)(char* cmd_name, ArgParser* cmd_parser);
// -----------------------------------------------------------------------------
// Initialization, parsing, teardown.
// -----------------------------------------------------------------------------
// Initializes a new ArgParser instance. Returns NULL if sufficient memory
// cannot be allocated for the new parser.
ArgParser* ap_new();
// Specifies a helptext string for the parser. If [helptext] is not NULL, this
// activates an automatic --help/-h flag. (Either --help or -h can be overridden
// by explicitly registered flags.) The parser stores and manages its own copy
// of the [helptext] string so [helptext] can be freed immediately after this
// call if it was dynamically constructed.
void ap_set_helptext(ArgParser* parser, const char* helptext);
// Returns a pointer to the parser's helptext string.
char* ap_get_helptext(ArgParser* parser);
// Specifies a version string for the parser. If [version] is not NULL, this
// activates an automatic --version/-v flag. (Either --version or -v can be
// overridden by explicitly registered flags.) The parser stores and manages its
// own copy of the [version] string so [version] can be freed immediately after
// this call if it was dynamically constructed.
void ap_set_version(ArgParser* parser, const char* version);
// Returns a pointer to the parser's version string.
char* ap_get_version(ArgParser* parser);
// If toggled to true, the first positional argument ends option parsing; all
// subsequent arguments will be treated as positionals. Defaults to false.
void ap_first_pos_arg_ends_options(ArgParser* parser, boolean enable);
// Parses the application's command line arguments. The parameters are assumed
// to be [argc] and [argv] as supplied to main(), i.e. the first element of the
// array is assumed to be the binary name and is therefore ignored. Returns true
// if the arguments were successfully parsed. Returns false if parsing failed
// due to a memory allocation error. (This memory allocation error may have
// occured during set-up rather than during parsing.)
boolean ap_parse(ArgParser* parser, int argc, char** argv);
// Frees the memory associated with the parser and any subparsers.
void ap_free(ArgParser* parser);
// -----------------------------------------------------------------------------
// Register flags and options.
// -----------------------------------------------------------------------------
// Registers a new flag.
void ap_flag(ArgParser* parser, const char* name);
// Registers a new string-valued option.
void ap_str_opt(ArgParser* parser, const char* name, const char* fallback);
// Registers a new integer-valued option.
void ap_int_opt(ArgParser* parser, const char* name, int fallback);
// Registers a new double-valued option.
void ap_dbl_opt(ArgParser* parser, const char* name, double fallback);
// -----------------------------------------------------------------------------
// Inspect flags and options.
// -----------------------------------------------------------------------------
// Returns the number of times the specified flag or option was found.
int ap_count(ArgParser* parser, const char* name);
// Returns true if the specified flag or option was found.
boolean ap_found(ArgParser* parser, const char* name);
// Returns the value of a string option.
char* ap_str_value(ArgParser* parser, const char* name);
// Returns the string value at the specified index.
char* ap_str_value_at_index(ArgParser* parser, const char* name, int index);
// Returns the value of an integer option.
int ap_int_value(ArgParser* parser, const char* name);
// Returns the integer value at the specified index.
int ap_int_value_at_index(ArgParser* parser, const char* name, int index);
// Returns the value of a floating-point option.
double ap_dbl_value(ArgParser* parser, const char* name);
// Returns the floating-point value at the specified index.
double ap_dbl_value_at_index(ArgParser* parser, const char* name, int index);
// Returns an option's values as a freshly-allocated array of string
// pointers. The array's memory is not affected by calls to ap_free().
// Returns NULL if memory allocation fails.
char** ap_str_values(ArgParser* parser, const char* name);
// Returns an option's values as a freshly-allocated array of integers.
// The array's memory is not affected by calls to ap_free().
// Returns NULL if memory allocation fails.
int* ap_int_values(ArgParser* parser, const char* name);
// Returns an option's values as a freshly-allocated array of doubles.
// The array's memory is not affected by calls to ap_free().
// Returns NULL if memory allocation fails.
double* ap_dbl_values(ArgParser* parser, const char* name);
// -----------------------------------------------------------------------------
// Positional arguments.
// -----------------------------------------------------------------------------
// Returns true if the parser has found one or more positional arguments.
boolean ap_has_args(ArgParser* parser);
// Returns the number of positional arguments.
int ap_count_args(ArgParser* parser);
// Returns the positional argument at the specified index.
char* ap_arg(ArgParser* parser, int index);
// Returns the positional arguments as a freshly-allocated array of string
// pointers. The memory occupied by the returned array is not affected by
// calls to ap_free(). Returns NULL if memory allocation fails.
char** ap_args(ArgParser* parser);
// Attempts to parse and return the positional arguments as a freshly allocated
// array of integers. Exits with an error message on failure. The memory
// occupied by the returned array is not affected by calls to ap_free().
// Returns NULL if memory allocation fails.
int* ap_args_as_ints(ArgParser* parser);
// Attempts to parse and return the positional arguments as a freshly allocated
// array of doubles. Exits with an error message on failure. The memory
// occupied by the returned array is not affected by calls to ap_free().
// Returns NULL if memory allocation fails.
double* ap_args_as_doubles(ArgParser* parser);
// -----------------------------------------------------------------------------
// Commands.
// -----------------------------------------------------------------------------
// Registers a new command. Returns the ArgParser instance for the command.
// Returns NULL if sufficient memory cannot be allocated for the new parser.
ArgParser* ap_cmd(ArgParser* parser, const char* name);
// Registers a callback function on a command parser. The function will be
// called if the command is found.
void ap_callback(ArgParser* parser, ap_callback_t function);
// Returns true if the parser has found a command.
boolean ap_has_cmd(ArgParser* parser);
// Returns the command name, if the parser has found a command.
char* ap_cmd_name(ArgParser* parser);
// Returns the command's parser instance, if the parser has found a command.
ArgParser* ap_cmd_parser(ArgParser* parser);
// This booleanean switch toggles support for an automatic 'help' command that
// prints subcommand helptext. The value defaults to false but gets toggled
// automatically to true whenever a command is registered. You can use this
// function to disable the feature if required.
void ap_enable_help_command(ArgParser* parser, boolean enable);
// -----------------------------------------------------------------------------
// Debugging utilities.
// -----------------------------------------------------------------------------
// Dump a parser instance for debugging.
void ap_print(ArgParser* parser);
// True if an attempt to allocate memory failed.
boolean ap_had_memory_error(ArgParser* parser);
// -----------------------------------------------------------------------------
// Deprecated.
// -----------------------------------------------------------------------------
// Replaced by ap_enable_help_command().
void ap_cmd_help(ArgParser* parser, boolean enable);
// Replaced by ap_set_helptext().
void ap_helptext(ArgParser* parser, const char* helptext);
// Replaced by ap_set_version().
void ap_version(ArgParser* parser, const char* version);
#endif
+77 -24
View File
@@ -49,6 +49,7 @@ static void COM_CEchoDuration_f(void);
static void COM_Exec_f(void);
static void COM_Wait_f(void);
static void COM_Help_f(void);
static void COM_Find_f(void);
static void COM_Toggle_f(void);
static void COM_Add_f(void);
@@ -299,6 +300,7 @@ void COM_Init(void)
COM_AddCommand("exec", COM_Exec_f);
COM_AddCommand("wait", COM_Wait_f);
COM_AddCommand("help", COM_Help_f);
COM_AddCommand("find", COM_Find_f);
COM_AddCommand("toggle", COM_Toggle_f);
COM_AddCommand("add", COM_Add_f);
RegisterNetXCmd(XD_NETVAR, Got_NetVar);
@@ -820,7 +822,7 @@ static void COM_Help_f(void)
if (cvar)
{
CONS_Printf("\x82""Variable %s:\n", cvar->name);
CONS_Printf(M_GetText(" flags :"));
CONS_Printf(M_GetText(" flags: "));
if (cvar->flags & CV_SAVE)
CONS_Printf("AUTOSAVE ");
if (cvar->flags & CV_FLOAT)
@@ -874,30 +876,9 @@ static void COM_Help_f(void)
return;
}
CONS_Printf("No exact match, searching...\n");
// commands
CONS_Printf("\x82""Commands:\n");
for (cmd = com_commands; cmd; cmd = cmd->next)
{
if (!strstr(cmd->name, help))
continue;
CONS_Printf("%s ",cmd->name);
i++;
}
CONS_Printf("No variable or command named %s", help);
CONS_Printf("\x82""\nCheck wiki.srb2.org for more or try typing help without arguments\n");
// variables
CONS_Printf("\x82""\nVariables:\n");
for (cvar = consvar_vars; cvar; cvar = cvar->next)
{
if ((cvar->flags & CV_NOSHOWHELP) || (!strstr(cvar->name, help)))
continue;
CONS_Printf("%s ", cvar->name);
i++;
}
CONS_Printf("\x82""\nCheck wiki.srb2.org for more or type help <command or variable>\n");
CONS_Debug(DBG_GAMELOGIC, "\x87Total : %d\n", i);
}
return;
}
@@ -927,6 +908,78 @@ static void COM_Help_f(void)
}
}
static void COM_Find_f(void)
{
static char prefix[80];
xcommand_t *cmd;
consvar_t *cvar;
cmdalias_t *alias;
const char *match;
const char *help;
size_t helplen;
boolean matchesany;
if (COM_Argc() != 2)
{
CONS_Printf(M_GetText("find <text>: Search for variables, commands and aliases containing <text>\n"));
return;
}
help = COM_Argv(1);
helplen = strlen(help);
CONS_Printf("\x82""Variables:\n");
matchesany = false;
for (cvar = consvar_vars; cvar; cvar = cvar->next)
{
if (cvar->flags & CV_NOSHOWHELP)
continue;
match = strstr(cvar->name, help);
if (match != NULL)
{
memcpy(prefix, cvar->name, match - cvar->name);
prefix[match - cvar->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
CONS_Printf("\x82""Commands:\n");
matchesany = false;
for (cmd = com_commands; cmd; cmd = cmd->next)
{
match = strstr(cmd->name, help);
if (match != NULL)
{
memcpy(prefix, cmd->name, match - cmd->name);
prefix[match - cmd->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
CONS_Printf("\x82""Aliases:\n");
matchesany = false;
for (alias = com_alias; alias; alias = alias->next)
{
match = strstr(alias->name, help);
if (match != NULL)
{
memcpy(prefix, alias->name, match - alias->name);
prefix[match - alias->name] = '\0';
CONS_Printf(" %s\x83%s\x80%s\n", prefix, help, &match[helplen]);
matchesany = true;
}
}
if (!matchesany)
CONS_Printf(" (none)\n");
}
/** Toggles a console variable. Useful for on/off values.
*
* This works on on/off, yes/no values only
+4 -14
View File
@@ -869,7 +869,9 @@ boolean CON_Responder(event_t *ev)
static UINT8 consdown = false; // console is treated differently due to rare usage
// sequential completions a la 4dos
static char completion[80];
static char completioncmd[80 + sizeof("find ")] = "find ";
static char *completion = &completioncmd[sizeof("find ")-1];
static INT32 comskips, varskips;
const char *cmd = "";
@@ -948,7 +950,6 @@ boolean CON_Responder(event_t *ev)
// show all cvars/commands that match what we have inputted
if (key == KEY_TAB)
{
size_t i, len;
if (!completion[0])
{
@@ -957,19 +958,8 @@ boolean CON_Responder(event_t *ev)
strcpy(completion, inputlines[inputline]);
comskips = varskips = 0;
}
len = strlen(completion);
//first check commands
CONS_Printf("\nCommands:\n");
for (i = 0, cmd = COM_CompleteCommand(completion, i); cmd; cmd = COM_CompleteCommand(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
//now we move on to CVARs
CONS_Printf("Variables:\n");
for (i = 0, cmd = CV_CompleteVar(completion, i); cmd; cmd = CV_CompleteVar(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
COM_BufInsertText(completioncmd);
return true;
}
+126 -20
View File
@@ -47,6 +47,7 @@
#include "k_kart.h"
#include "s_sound.h" // sfx_syfail
#include "m_perfstats.h"
#include "d_main.h"
#ifdef CLIENT_LOADINGSCREEN
// cl loading screen
@@ -171,6 +172,8 @@ static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL};
consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_shownodeip = {"showipinnodelist", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}};
consvar_t cv_playbackspeed = {"playbackspeed", "1", 0, playbackspeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -1899,6 +1902,15 @@ static void CL_LoadReceivedSavegame(void)
demo.title = false;
automapactive = false;
if (!postautoloaded)
{
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0)
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfilespost);
postautoloaded = true;
}
// load a base level
if (P_LoadNetGame())
{
@@ -1939,12 +1951,13 @@ static void CL_LoadReceivedSavegame(void)
static void SendAskInfo(INT32 node)
{
tic_t asktime;
#ifdef HOLEPUNCH
if (node != 0 && node != BROADCASTADDR &&
cv_rendezvousserver.string[0])
{
I_NetRequestHolePunch(node);
}
#endif
asktime = I_GetTime();
@@ -3345,7 +3358,7 @@ static void Command_Nodes(void)
{
CONS_Printf("%.2u: %*s", i, (int)maxlen, player_names[i]);
CONS_Printf(" - %.2d", playernode[i]);
if (I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL)
if ((I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) && (cv_shownodeip.value))
CONS_Printf(" - %s", address);
if (IsPlayerAdmin(i))
@@ -3359,6 +3372,94 @@ static void Command_Nodes(void)
}
}
//Screw the base game nodes lets replace with listplayers instead.
static void Command_Listplayers(void)
{
const char *address;
int width = 0;
boolean admin;
boolean spectator;
/*
Mode of player status for an individual player (admin, spectator).
1 for admin
2 for spectator
4 for both
*/
int mode = 0;
INT32 totalplayers = 0;
const char *cc;
const char *pcc;
INT32 i;
int n;
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i])
{
n = strlen(player_names[i]);
if (n > width)
width = n;
if (mode != 7)
{
admin = IsPlayerAdmin(i);
spectator = players[i].spectator;
if (admin)
mode |= 1;
if (spectator)
mode |= 2;
if (admin && spectator)
mode |= 4;
}
}
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i])
{
admin = IsPlayerAdmin(i);
spectator = players[i].spectator;
if (admin)
cc = "\x85";/* red */
else if (spectator)
cc = "\x86";/* gray */
else
cc = "";
pcc = HU_SkinColorToConsoleColor(players[i].skincolor);
CONS_Printf("%.2d: ""%s""%-*s""\x80", i, pcc,width, player_names[i]);
if ((I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) && (cv_shownodeip.value))
CONS_Printf(" -- %s", address);
else/* print spacer */
{
/* ...but not if there's a crammed status and were admin */
if (mode != 7 || !admin)
CONS_Printf(" -- ");/* -- self */
}
if (admin)
CONS_Printf(M_GetText("%s"" (admin)"),cc);
if (spectator)
CONS_Printf(M_GetText("%s"" (spectator)"),cc);
CONS_Printf("\n");
totalplayers++;
}
if (totalplayers == 1)
CONS_Printf("\nThere is 1 player in the game.\n");
else
CONS_Printf("\nThere are %d players in the game.\n", totalplayers);
}
static void Command_Ban(void)
{
if (COM_Argc() < 2)
@@ -3924,6 +4025,7 @@ void D_ClientServerInit(void)
COM_AddCommand("reloadbans", Command_ReloadBan);
COM_AddCommand("connect", Command_connect);
COM_AddCommand("nodes", Command_Nodes);
COM_AddCommand("listplayers", Command_Listplayers);
#ifdef HAVE_CURL
COM_AddCommand("set_http_login", Command_set_http_login);
COM_AddCommand("list_http_logins", Command_list_http_logins);
@@ -4215,6 +4317,13 @@ static void Got_RemovePlayer(UINT8 **p, INT32 playernum)
pnum = READUINT8(*p);
reason = READUINT8(*p);
if (pnum == serverplayer)
{
CONS_Alert(CONS_WARNING, "Attempt to remove server player\n");
return;
}
CL_RemovePlayer(pnum, reason);
#ifdef HAVE_DISCORDRPC
@@ -4981,36 +5090,26 @@ static void HandlePacketFromPlayer(SINT8 node)
/// \todo Use a separate cvar for that kind of timeout?
freezetimeout[node] = I_GetTime() + connectiontimeout;
//Ported this from 2.2 Prevent dropped ticcmds due to interp timing jutter
// If we've alredy received a ticcmd for this tic, just submit it for the next one.
tic_t faketic = maketic;
if ((!!(netcmds[maketic % TICQUEUE][netconsole].angleturn & TICCMD_RECEIVED))
&& (maketic - firstticstosend < TICQUEUE - 1))
faketic++;
// Don't do anything for packets of type NODEKEEPALIVE?
// Sryder 2018/07/01: Update the freezetimeout still!
if (netbuffer->packettype == PT_NODEKEEPALIVE
|| netbuffer->packettype == PT_NODEKEEPALIVEMIS)
break;
// Copy ticcmd Prevent dropped ticcmds due to interp timing jutter
G_MoveTiccmd(&netcmds[faketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1);
// Copy ticcmd
G_MoveTiccmd(&netcmds[maketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1);
// Check ticcmd for "speed hacks"
if (CheckForSpeedHacks((UINT8)netconsole))
break;
// Splitscreen cmd Prevent dropped ticcmds due to interp timing jutter
// Splitscreen cmd
if (((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS)
|| (netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS)
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
&& (nodetoplayer2[node] >= 0))
{
G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer2[node]],
G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer2[node]],
&netbuffer->u.client2pak.cmd2, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer2[node]))
@@ -5021,7 +5120,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
&& (nodetoplayer3[node] >= 0))
{
G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer3[node]],
G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer3[node]],
&netbuffer->u.client3pak.cmd3, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer3[node]))
@@ -5031,7 +5130,7 @@ static void HandlePacketFromPlayer(SINT8 node)
if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)
&& (nodetoplayer4[node] >= 0))
{
G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer4[node]],
G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer4[node]],
&netbuffer->u.client4pak.cmd4, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer4[node]))
@@ -5299,7 +5398,7 @@ static void HandlePacketFromPlayer(SINT8 node)
}
else
{
DEBFILE(va("frame not in bound: %u\n", neededtic));
DEBFILE(va("frame not in bound: %u (bounds are from %u to %u)\n", neededtic, realstart, realend));
/*if (realend < neededtic - 2 * TICRATE || neededtic + 2 * TICRATE < realstart)
I_Error("Received an out of order PT_SERVERTICS packet!\n"
"Got tics %d-%d, needed tic %d\n\n"
@@ -6153,6 +6252,7 @@ static void UpdatePingTable(void)
}
}
#ifdef HOLEPUNCH
static void RenewHolePunch(void)
{
if (cv_rendezvousserver.string[0])
@@ -6168,6 +6268,7 @@ static void RenewHolePunch(void)
}
}
}
#endif
// Handle timeouts to prevent definitive freezes from happenning
static void HandleNodeTimeouts(void)
@@ -6201,11 +6302,14 @@ void NetKeepAlive(void)
#ifdef MASTERSERVER
MasterClient_Ticker();
#endif
#ifdef HOLEPUNCH
if (netgame && serverrunning)
{
RenewHolePunch();
}
#endif
if (client)
{
@@ -6318,10 +6422,12 @@ void NetUpdate(void)
MasterClient_Ticker(); // Acking the Master Server
#endif
#ifdef HOLEPUNCH
if (netgame && serverrunning)
{
RenewHolePunch();
}
#endif
if (client)
{
+2
View File
@@ -515,6 +515,8 @@ extern consvar_t cv_kicktime;
extern consvar_t cv_showjoinaddress;
extern consvar_t cv_playbackspeed;
extern consvar_t cv_shownodeip;
#define BASEPACKETSIZE offsetof(doomdata_t, u)
#define FILETXHEADER offsetof(filetx_pak, data)
#define BASESERVERTICSSIZE offsetof(doomdata_t, u.serverpak.cmds[0])
+193 -17
View File
@@ -66,7 +66,7 @@
#include "fastcmp.h"
#include "r_fps.h" // Frame interpolation/uncapped
#include "keys.h"
#include "filesrch.h" // refreshdirmenu
#include "filesrch.h" // refreshdirmenu, pathisdirectory
#include "d_protocol.h"
#include "m_perfstats.h"
@@ -94,8 +94,6 @@
// platform independant focus loss
UINT8 window_notinfocus = false;
INT32 window_x;
INT32 window_y;
//
// DEMO LOOP
@@ -105,6 +103,13 @@ static const char *pagename = "MAP1PIC";
static char *startupwadfiles[MAX_WADFILES];
static char *startuppwads[MAX_WADFILES];
// autoloading
static char *autoloadwadfiles[MAX_WADFILES];
char *autoloadwadfilespost[MAX_WADFILES];
boolean autoloading;
boolean autoloaded;
boolean postautoloaded;
boolean devparm = false; // started game with -devparm
boolean singletics = false; // timedemo
@@ -885,7 +890,162 @@ static void D_AddFile(const char *file, char **filearray)
filearray[pnumwadfiles] = newfile;
}
static inline void D_CleanFile(char **filearray)
// Taken from TSoURDt3rd
// https://github.com/StarManiaKG/The-Story-of-Uncapped-Revengence-Discord-the-3rd/blob/main/src/STAR/star_functions.c
static INT32 D_DetectFileType(const char* filename)
{
if (pathisdirectory(filename) == 1)
return 1;
else
{
if (!stricmp(&filename[strlen(filename) - 4], ".wad"))
return 2;
else if (!stricmp(&filename[strlen(filename) - 4], ".pk3"))
return 3;
else if (!stricmp(&filename[strlen(filename) - 5], ".kart"))
return 4;
else if (!stricmp(&filename[strlen(filename) - 4], ".lua"))
return 5;
else if (!stricmp(&filename[strlen(filename) - 4], ".soc"))
return 6;
else if (!stricmp(&filename[strlen(filename) - 4], ".cfg"))
return 7;
else if (!stricmp(&filename[strlen(filename) - 4], ".txt"))
return 8;
}
return 0;
}
// autoload that shit
static void D_AutoloadFile(const char *file, char **filearray)
{
size_t pnumwadfiles;
char *newfile;
INT32 fileType = D_DetectFileType(file);
for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++)
;
newfile = malloc(strlen(file) + 1);
if (!newfile)
I_Error("No more free memory to AutoloadFile %s",file);
if (!fileType)
{
CONS_Printf("D_AutoloadFile: File %s is unknown or invalid\n", file);
return;
}
strcpy(newfile, file);
if (fileType <= 6)
filearray[pnumwadfiles] = newfile;
else
COM_BufAddText(va("exec %s\n", newfile));
}
static char *strremove(char *str, const char *sub) {
char *p, *q, *r;
if (*sub && (q = r = strstr(str, sub)) != NULL) {
size_t len = strlen(sub);
while ((r = strstr(p = r + len, sub)) != NULL) {
while (p < r)
*q++ = *p++;
}
while ((*q++ = *p++) != '\0')
continue;
}
return str;
}
// FIND THEM
static void D_FindAddonsToAutoload(void)
{
FILE *autoloadconfigfile;
const char *autoloadpath;
boolean postload;
INT32 i, len;
boolean hasprefix = false;
char wadsToAutoload[256] = "", renameAutoloadStrings[256] = "";
// does it exist tho
autoloadpath = va("%s"PATHSEP"%s",srb2home,AUTOLOADCONFIGFILENAME);
autoloadconfigfile = fopen(autoloadpath, "r");
// If the file is found, run our shit
if (!autoloadconfigfile) // nope outta here
return;
while (fgets(wadsToAutoload, sizeof wadsToAutoload, autoloadconfigfile) != NULL)
{
postload = false;
// skip if commented or empty
if ((wadsToAutoload[1] == '\0' || wadsToAutoload[1] == '\n')
|| (wadsToAutoload[0] == '#'))
continue;
// this marks it so that it loads after loading server addons
else if (fastncmp(wadsToAutoload, "postload ", 9)) {
strremove(wadsToAutoload, "postload ");
postload = true;
}
// Remove Any Empty or Skipped Lines
for (i = 0; wadsToAutoload[i] != '\0'; i++)
{
if (wadsToAutoload[i] == '\n')
wadsToAutoload[i] = '\0';
}
len = strlen(wadsToAutoload);
hasprefix = false;
for (i = 0; i < len; ++i)
{
if (wadsToAutoload[i] == '_')
{
hasprefix = true;
break;
}
}
// Lets just hope no one adds bonuschars in autoload
if (hasprefix)
{
// We searching for c in prefix, which stands for "character" and doesn't work well with
// autoload atm, only fine for postload
for (i = 0; i < len; ++i)
{
if (wadsToAutoload[i] == '_') break; // Prefix end
if (wadsToAutoload[i] == 'c' || wadsToAutoload[i] == 'C')
{
CONS_Alert(CONS_WARNING, "forcing postload for %s as local skin\n", wadsToAutoload);
postload = true;
break; // Found it
}
}
}
// LOAD IT
if (!postload)
D_AutoloadFile(wadsToAutoload, autoloadwadfiles);
else
D_AutoloadFile(wadsToAutoload, autoloadwadfilespost);
// end it here
for (i = 0; wadsToAutoload[i] != '\0'; i++)
wadsToAutoload[i] = '\0';
}
// we dont want memory leaks around here do we?
fclose(autoloadconfigfile);
}
void D_CleanFile(char **filearray)
{
size_t pnumwadfiles;
for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++)
@@ -921,6 +1081,8 @@ boolean snw_speedo; // snowy speedometer check
boolean clr_hud; // colour hud check
boolean big_lap; // bigger lap counter
boolean big_lap_color; // bigger lap counter but colour
boolean kartzspeedo; // kartZ speedometer
boolean statdp; // New stat
static void IdentifyVersion(void)
{
@@ -1186,6 +1348,9 @@ void D_SRB2Main(void)
if (M_CheckParm("-password") && M_IsNextParm())
D_SetPassword(M_GetNextParm());
// FIND THEM
D_FindAddonsToAutoload();
// add any files specified on the command line with -file wadfile
// to the wad list
if (!(M_CheckParm("-connect") && !M_CheckParm("-server")))
@@ -1278,23 +1443,35 @@ void D_SRB2Main(void)
mainwads++;
if (found_extra2_kart)
mainwads++;
// now check for speedometer stuff
if (W_CheckMultipleLumps("SP_SMSTC", "K_TRNULL", "SP_MKMH", "SP_MMPH", "SP_MFRAC", "SP_MPERC", NULL))
snw_speedo = true;
// check for bigger lap count
if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL))
big_lap = true;
// now check for colour hud stuff
if (W_CheckMultipleLumps("K_SCTIME", "K_SCTIMW", "K_SCLAPS", "K_SCLAPW", \
"K_SCBALN", "K_SCBALW", "K_SCKARM", "K_SCTOUT", "K_ISMULC", "K_ITMULC", "K_ITBC","K_ITBCD", "K_ISBC", "K_ISBCD", NULL))
clr_hud = true;
// check for bigger lap count but color** its color bitch
if (W_CheckMultipleLumps("K_SCLAPB", "K_SCLA2B", NULL))
big_lap_color = true;
// kartzspeedo
if (W_CheckMultipleLumps("K_KZSP1", "K_KZSP2", "K_KZSP3", "K_KZSP4", "K_KZSP5", \
"K_KZSP6", "K_KZSP7", "K_KZSP8", "K_KZSP9", "K_KZSP10", "K_KZSP11", "K_KZSP12", \
"K_KZSP13", "K_KZSP14", "K_KZSP15", "K_KZSP16", "K_KZSP17", "K_KZSP18", "K_KZSP19", \
"K_KZSP20", "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25", NULL))
kartzspeedo = true;
// stat display for extended player setup
if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", "K_STATN3", "K_STATN4", \
"K_STATN5", "K_STATN6", NULL))
statdp = true;
}
//
@@ -1372,14 +1549,6 @@ void D_SRB2Main(void)
HWR_AddCommands();
#endif
#ifdef HWRENDER
if (rendermode == render_opengl)
{
for (i = 0; i < numwadfiles; i++)
HWR_LoadShaders(i, (wadfiles[i]->type == RET_PK3));
}
#endif
//--------------------------------------------------------- CONSOLE
// setup loading screen
SCR_Startup();
@@ -1490,12 +1659,19 @@ void D_SRB2Main(void)
I_StartupSound();
I_InitMusic();
S_InitSfxChannels(cv_soundvolume.value);
S_InitMusicDefs();
}
S_InitMusicDefs();
S_InitMTDefs();
CONS_Printf("ST_Init(): Init status bar.\n");
ST_Init();
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0)
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfiles);
// Set up splitscreen players before joining!
if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm()))
{
+10
View File
@@ -32,6 +32,14 @@ extern boolean snw_speedo; // snowy speedometer check
extern boolean clr_hud; // colour hud check
extern boolean big_lap; // bigger lap counter
extern boolean big_lap_color; //bigger lap counter but colour
extern boolean kartzspeedo; //kartZ speedo
extern boolean statdp; //stat display for extended player setup
extern boolean autoloading;
extern boolean autoloaded;
extern boolean postautoloaded;
extern char *autoloadwadfilespost[MAX_WADFILES];
// the infinite loop of D_SRB2Loop() called from win_main for windows version
void D_SRB2Loop(void) FUNCNORETURN;
@@ -48,6 +56,8 @@ void D_PostEvent(const event_t *ev);
void D_ProcessEvents(void);
void D_CleanFile(char **filearray);
const char *D_Home(void);
//
+10
View File
@@ -51,7 +51,9 @@ doomcom_t *doomcom = NULL;
/// \brief network packet data, points inside doomcom
doomdata_t *netbuffer = NULL;
/// \brief hole punching packet, also points inside doomcom
#ifdef HOLEPUNCH
holepunch_t *holepunchpacket = NULL;
#endif
#ifdef DEBUGFILE
FILE *debugfile = NULL; // put some net info in a file during the game
@@ -75,8 +77,10 @@ boolean (*I_NetCanGet)(void) = NULL;
void (*I_NetCloseSocket)(void) = NULL;
void (*I_NetFreeNodenum)(INT32 nodenum) = NULL;
SINT8 (*I_NetMakeNodewPort)(const char *address, const char* port) = NULL;
#ifdef HOLEPUNCH
void (*I_NetRequestHolePunch)(INT32 node) = NULL;
void (*I_NetRegisterHolePunch)(void) = NULL;
#endif
boolean (*I_NetOpenSocket)(void) = NULL;
boolean (*I_Ban) (INT32 node) = NULL;
void (*I_ClearBans)(void) = NULL;
@@ -827,6 +831,10 @@ static const char *packettypename[NUMPACKETTYPE] =
"CLIENTJOIN",
"NODETIMEOUT",
"RESYNCHING",
"TELLFILESNEEDED",
"MOREFILESNEEDED",
"PING"
};
@@ -1349,7 +1357,9 @@ boolean D_CheckNetGame(void)
I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES);
netbuffer = (doomdata_t *)(void *)&doomcom->data;
#ifdef HOLEPUNCH
holepunchpacket = (holepunch_t *)(void *)&doomcom->data;
#endif
#ifdef DEBUGFILE
if (M_CheckParm("-debugfile"))
+64 -54
View File
@@ -35,7 +35,6 @@
#include "p_spec.h"
#include "m_cheat.h"
#include "d_clisrv.h"
#include "v_video.h"
#include "d_main.h"
#include "m_random.h"
#include "f_finale.h"
@@ -195,6 +194,8 @@ static void Command_Isgamemodified_f(void);
static void Command_Cheats_f(void);
static void Command_ListSkins(void);
static void Command_SkinSearch(void);
#ifdef _DEBUG
static void Command_Togglemodified_f(void);
@@ -295,12 +296,16 @@ consvar_t cv_skin4 = {"skin4", DEFAULTSKIN4, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Sk
// haha I've beaten you now, ONLINE
consvar_t cv_localskin = {"internal___localskin", "none", CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showlocalskinmenus = {"showlocalskinmenus", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
INT32 cv_debug;
consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usemouse2 = {"use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2, 0, NULL, NULL, 0, 0, NULL};
//WTF
consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2
consvar_t cv_usejoystick = {"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t,
@@ -412,7 +417,7 @@ consvar_t cv_kartdebugcheckpoint = {"kartdebugcheckpoint", "Off", CV_NOSHOWHELP,
consvar_t cv_kartdebugnodes = {"kartdebugnodes", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_kartdebugcolorize = {"kartdebugcolorize", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t votetime_cons_t[] = {{10, "MIN"}, {3600, "MAX"}, {0, NULL}};
static CV_PossibleValue_t votetime_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, NULL}};
consvar_t cv_votetime = {"votetime", "20", CV_NETVAR, votetime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ringslinger = {"ringslinger", "No", CV_NETVAR|CV_NOSHOWHELP|CV_CALL|CV_CHEAT, CV_YesNo,
@@ -478,6 +483,10 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0
static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}};
consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}};
consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -509,7 +518,7 @@ static CV_PossibleValue_t skinselectspin_cons_t[] = {
consvar_t cv_skinselectspin = {"skinselectspin", "5", CV_SAVE, skinselectspin_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t perfstats_cons_t[] = {
{0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {0, NULL}};
{0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {4, "PreThinkFrame"}, {5, "PostThinkFrame"}, {0, NULL}};
consvar_t cv_perfstats = {"perfstats", "Off", CV_CALL, perfstats_cons_t, PS_PerfStats_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ps_thinkframe_page = {"ps_thinkframe_page", "1", CV_CALL, CV_Natural, PS_ThinkFrame_Page_OnChange, 0, NULL, NULL, 0, 0, NULL};
@@ -523,8 +532,8 @@ consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_
consvar_t cv_showtrackaddon = {"showtrackaddon", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t skinselectmenu_t[] = {{SKINMENUTYPE_SCROLL, "Scroll"}, {SKINMENUTYPE_2D, "2d"}, {SKINMENUTYPE_GRID, "Grid"}, {0, NULL}};
consvar_t cv_skinselectmenu = {"skinselectmenu", "Grid", CV_SAVE, skinselectmenu_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t skinselectmenu_t[] = {{SKINMENUTYPE_SCROLL, "Scroll"}, {SKINMENUTYPE_2D, "2d"}, {SKINMENUTYPE_GRID, "Grid"}, {SKINMENUTYPE_EXTENDED, "Extended"}, {0, NULL}};
consvar_t cv_skinselectmenu = {"skinselectmenu", "Extended", CV_SAVE, skinselectmenu_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t skinselectgridsort_t[] ={
{ SKINMENUSORT_REALNAME, "Real name" },
@@ -774,6 +783,7 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_joinnextround);
#endif
CV_RegisterVar(&cv_showjoinaddress);
CV_RegisterVar(&cv_shownodeip);
CV_RegisterVar(&cv_blamecfail);
#endif
@@ -788,6 +798,7 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_showping);
CV_RegisterVar(&cv_pingmeasurement);
CV_RegisterVar(&cv_pingicon);
CV_RegisterVar(&cv_pingstyle);
#ifdef SEENAMES
CV_RegisterVar(&cv_allowseenames);
@@ -944,9 +955,6 @@ void D_RegisterClientCommands(void)
#endif
#endif
// FIXME: not to be here.. but needs be done for config loading
CV_RegisterVar(&cv_usegamma);
// m_menu.c
//CV_RegisterVar(&cv_compactscoreboard);
CV_RegisterVar(&cv_chatheight);
@@ -967,6 +975,8 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_luaimmersion);
CV_RegisterVar(&cv_fakelocalskin);
CV_RegisterVar(&cv_showlocalskinmenus);
//CV_RegisterVar(&cv_crosshair);
//CV_RegisterVar(&cv_crosshair2);
@@ -1097,22 +1107,12 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_ps_thinkframe_page);
CV_RegisterVar(&cv_ps_samplesize);
CV_RegisterVar(&cv_ps_descriptor);
CV_RegisterVar(&cv_invincmusicfade);
CV_RegisterVar(&cv_growmusicfade);
CV_RegisterVar(&cv_respawnfademusicout);
CV_RegisterVar(&cv_respawnfademusicback);
CV_RegisterVar(&cv_resetspecialmusic);
CV_RegisterVar(&cv_resume);
CV_RegisterVar(&cv_fading);
//Value used to store last server player has joined
CV_RegisterVar(&cv_lastserver);
CV_RegisterVar(&cv_showallmaps);
CV_RegisterVar(&cv_showmusicfilename);
// ingame object placing
COM_AddCommand("objectplace", Command_ObjectPlace_f);
@@ -1158,6 +1158,7 @@ void D_RegisterClientCommands(void)
#endif
COM_AddCommand("listskins", Command_ListSkins);
COM_AddCommand("skinsearch", Command_SkinSearch);
}
/**
@@ -3082,7 +3083,7 @@ static void Got_Pause(UINT8 **cp, INT32 playernum)
if (paused)
{
if (!menuactive || netgame)
if ((!menuactive || netgame) && (!cv_pausemusic.value))
S_PauseAudio();
}
else
@@ -4605,14 +4606,6 @@ static void Command_Addfile(void)
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
}
// i hate myself
static boolean DumbStartsWith(const char *pre, const char *str)
{
size_t lenpre = strlen(pre),
lenstr = strlen(str);
return lenstr < lenpre ? false : memcmp(pre, str, lenpre) == 0;
}
/** Adds something at runtime.
*/
static void
@@ -4649,16 +4642,13 @@ Command_Addskins (void)
*/
}
// args n stuff
#include "args.h"
static void Command_GLocalSkin (void)
static void Command_GLocalSkin (void)
{
size_t first_option;
size_t option_display;
size_t option_all;
size_t option_player;
option_player = COM_CheckPartialParm("-p");
option_display = COM_CheckPartialParm("-d");
option_all = COM_CheckPartialParm("-a");
@@ -4686,31 +4676,27 @@ static void Command_GLocalSkin (void)
fuck = ConcatCommandArgv(1, first_option);
char* player_name = player_names[consoleplayer];
char* display_num = "0";
const char* player_name = player_names[consoleplayer];
const char* display_num = "0";
size_t dnum = 0;
if (option_display) // -display
{
// handle default: 0
if (COM_Argv(option_display + 1)[0] == "" || COM_Argv(option_display + 1)[0] != "-")
if (COM_Argc() >= option_display)
display_num = COM_Argv(option_display + 1);
if (isdigit(display_num[0]) || display_num == "0")
{
dnum = atoi(display_num);
if (dnum > 3 || dnum < 0) // nuh uh
dnum = 0;
SetLocalPlayerSkin(displayplayers[dnum], fuck, NULL);
dnum = atoi(display_num);
if (dnum > 3) // nuh uh
dnum = 0;
CONS_Printf("Successfully applied localskin to displayed player.\n");
return;
}
CONS_Printf("Could not apply localskin.\n");
SetLocalPlayerSkin(displayplayers[dnum], fuck, NULL);
CONS_Printf("Successfully applied localskin to displayed player.\n");
Z_Free(fuck);
return;
}
}
else if (option_all) // -all
{
int i;
@@ -4723,34 +4709,38 @@ static void Command_GLocalSkin (void)
}
CONS_Printf("Successfully applied localskin to all players.\n");
Z_Free(fuck);
return;
}
}
else // -player or no other arguments
{
if (option_player)
if (option_player)
{
int i;
player_name = COM_Argv(option_player + 1);
for (i = 0; i < MAXPLAYERS; ++i)
for (i = 0; i < MAXPLAYERS; ++i)
{
if (fasticmp(player_names[i], player_name))
SetLocalPlayerSkin(i, fuck, NULL);
}
CONS_Printf("Successfully applied localskin to specified player.\n");
Z_Free(fuck);
return;
}
else
}
else
{
SetLocalPlayerSkin(consoleplayer, fuck, &cv_localskin);
CONS_Printf("Successfully applied localskin.\n");
Z_Free(fuck);
return;
}
CONS_Printf("Could not apply localskin.\n");
Z_Free(fuck);
return;
}
}
@@ -6060,6 +6050,26 @@ static void Command_ListSkins(void)
}
}
static void Command_SkinSearch(void)
{
size_t i;
UINT16 s;
UINT16 ic = 0;
//skin_t *skininput = &skins[s];
for (i = 1; i < COM_Argc(); i++){
for( s = 0 ; s < numallskins ; s++ )
{
skin_t *skininput = &skins[s];
if (strcasestr(skininput->realname,COM_Argv(i)))
{
ic++;
CONS_Printf("%d. %s%s:\x80 %s\n", ic,HU_SkinColorToConsoleColor(skininput->prefcolor),skininput->realname,skininput->name);
}
}
}
CONS_Printf("Total %d skins.\n", ic);
}
/** Sends a color change for the console player, unless that player is moving.
* \sa cv_playercolor, Color2_OnChange, Skin_OnChange
* \author Graue <graue@oceanbase.org>
+6 -1
View File
@@ -41,6 +41,8 @@ extern consvar_t cv_splitplayers;
extern consvar_t cv_seenames, cv_allowseenames;
#endif
extern consvar_t cv_usemouse;
//WTF
extern consvar_t cv_mouseturn;
extern consvar_t cv_usejoystick;
extern consvar_t cv_usejoystick2;
extern consvar_t cv_usejoystick3;
@@ -154,6 +156,7 @@ extern consvar_t cv_pingtimeout;
extern consvar_t cv_showping;
extern consvar_t cv_pingmeasurement;
extern consvar_t cv_pingicon;
extern consvar_t cv_pingstyle;
//extern consvar_t cv_smallpos;
extern consvar_t cv_showminimapnames;
@@ -164,6 +167,7 @@ extern consvar_t cv_showlapemblem;
extern consvar_t cv_showviewpointtext;
extern consvar_t cv_luaimmersion;
extern consvar_t cv_fakelocalskin;
extern consvar_t cv_showlocalskinmenus;
extern consvar_t cv_skipmapcheck;
@@ -183,7 +187,8 @@ typedef enum
{
SKINMENUTYPE_SCROLL = 0,
SKINMENUTYPE_2D, // 1
SKINMENUTYPE_GRID // 2
SKINMENUTYPE_GRID, // 2
SKINMENUTYPE_EXTENDED // 3
} skinmenutype_t;
typedef enum
+1 -1
View File
@@ -1342,7 +1342,7 @@ void CURLGetFile(void)
if (easyres == CURLE_HTTP_RETURNED_ERROR)
curl_easy_getinfo(e, CURLINFO_RESPONSE_CODE, &response_code);
easy_handle_error = (response_code) ? va("HTTP reponse code %ld", response_code) : curl_easy_strerror(easyres);
easy_handle_error = (response_code) ? va("HTTP response code %ld", response_code) : curl_easy_strerror(easyres);
curl_curfile->status = FS_FALLBACK;
curl_curfile->currentsize = curl_origfilesize;
curl_curfile->totalsize = curl_origtotalfilesize;
+2 -2
View File
@@ -416,8 +416,8 @@ typedef struct player_s
UINT8 skincolor;
INT32 skin;
INT32 localskin;
boolean skinlocal;
INT32 localskin; // current localskin number
boolean skinlocal; // determines if localskin is a skin already loaded in the server
UINT32 score; // player score
fixed_t dashspeed; // dashing speed
+1
View File
@@ -8289,6 +8289,7 @@ struct {
// Frame settings
{"FF_FRAMEMASK",FF_FRAMEMASK},
{"FF_HORIZONTALFLIP",FF_HORIZONTALFLIP},
{"FF_PAPERSPRITE",FF_PAPERSPRITE},
{"FF_ANIMATE",FF_ANIMATE},
{"FF_FULLBRIGHT",FF_FULLBRIGHT},
+5 -1
View File
@@ -101,7 +101,7 @@ static void DRPC_HandleReady(const DiscordUser *user)
{
if (cv_discordstreamer.value)
{
CONS_Printf("Discord: connected to %s\n", user->username);
CONS_Printf("Discord: connection successful\n");
}
else
{
@@ -480,14 +480,18 @@ void DRPC_UpdatePresence(void)
// Server info
if (netgame)
{
#ifdef MASTERSERVER
if (cv_advertise.value)
{
discordPresence.state = "Public";
}
else
{
#endif
discordPresence.state = "Private";
#ifdef MASTERSERVER
}
#endif
discordPresence.partyId = server_context; // Thanks, whoever gave us Mumble support, for implementing the EXACT thing Discord wanted for this field!
discordPresence.partySize = D_NumPlayers(); // Players in server
+3 -2
View File
@@ -127,8 +127,8 @@ extern char logfilename[1024];
#else
#define VERSION 1 // Game version
#define SUBVERSION 6 // more precise version number
#define VERSIONSTRING "Saturn v4 "
#define VERSIONSTRINGW L"Saturn v4"
#define VERSIONSTRING "Saturn v5.1 "
#define VERSIONSTRINGW L"Saturn v5.1"
// Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates!
// And change CMakeLists.txt (not src/, but in root), for CMake users!
// AND appveyor.yml, for the build bots!
@@ -639,6 +639,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
#if defined (HAVE_CURL) && ! defined (NONET)
#define MASTERSERVER
#define HOLEPUNCH
#else
#undef UPDATE_ALERT
#endif
-2
View File
@@ -108,8 +108,6 @@ extern boolean digital_disabled;
extern boolean menuactive; // Menu overlaid?
extern UINT8 paused; // Game paused?
extern UINT8 window_notinfocus; // are we in focus? (backend independant -- handles auto pausing and display of "focus lost" message)
extern INT32 window_x;
extern INT32 window_y;
extern boolean nodrawers;
extern boolean noblit;
-38
View File
@@ -1,38 +0,0 @@
#include "../command.h"
#include "../s_sound.h"
#include "../i_sound.h"
//
// CD MUSIC I/O
//
UINT8 cdaudio_started = 0;
consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
void I_InitCD(void){}
void I_StopCD(void){}
void I_PauseCD(void){}
void I_ResumeCD(void){}
void I_ShutdownCD(void){}
void I_UpdateCD(void){}
void I_PlayCD(UINT8 track, UINT8 looping)
{
(void)track;
(void)looping;
}
boolean I_SetVolumeCD(int volume)
{
(void)volume;
return false;
}
+1 -1
View File
@@ -169,7 +169,7 @@ void I_SetMusicVolume(UINT8 volume)
(void)volume;
}
boolean I_SetSongTrack(int track)
boolean I_SetSongTrack(INT32 track)
{
(void)track;
return false;
+17 -3
View File
@@ -520,6 +520,19 @@ static const char *credits[] = {
"Karol \"Fooruman\" D""\x1E""browski", // Dąbrowski, <Sryder> accents in srb2 :ytho:
"\"Virt\"",
"",
"\1Saturn",
"\"Alufolie91\" aka \"Alug\"",
"\"Indev\"",
"\"Haya\"",
"\"NepDisk\"",
"\"Xyzzy\"",
" ",
"\"Sunflower\" aka \"AnimeSonic\"",
"\"Yuz\" aka \"Yuzler\"",
"\"Democrab\"",
"\"Expand\" aka \"Maver\"",
"\"Nexit\"",
"",
"\1Special Thanks",
"SEGA",
"Sonic Team",
@@ -559,10 +572,11 @@ static struct {
{224, 80+(216*13), "K_ITMINE", SKINCOLOR_BRONZE},
{224, 80+(216*14), "K_ITTHNS", SKINCOLOR_RASPBERRY},
{224, 80+(216*15), "K_ITINV1", SKINCOLOR_GREY},
{224, 80+(216*16), "K_ITSINK", SKINCOLOR_PINETREE},
// This Tyler52 gag is troublesome
// Alignment should be ((spaces+1 * 100) + (headers+1 * 38) + (lines * 15))
// Current max image spacing: (216*17)
{112, (16*100)+(19*38)+(103*15), "TYLER52", SKINCOLOR_NONE},
{112, (17*100)+(20*38)+(114*15), "TYLER52", SKINCOLOR_NONE},
{0, 0, NULL, SKINCOLOR_NONE}
};
@@ -596,6 +610,7 @@ void F_StartCredits(void)
timetonext = 2*TICRATE;
}
void F_CreditDrawer(void)
{
UINT16 i;
@@ -925,7 +940,6 @@ void F_GameEndTicker(void)
D_StartTitle();
}
// ==============
// TITLE SCREEN
// ==============
@@ -988,7 +1002,7 @@ void F_TitleScreenDrawer(void)
else
{
INT32 transval = 0;
if (finalecount <= (50+(9<<1)))
transval = (finalecount - 50)>>1;
+36
View File
@@ -337,6 +337,23 @@ size_t dir_on[menudepth];
UINT8 refreshdirmenu = 0;
char *refreshdirname = NULL;
// Checks if the specified path is a directory.
// Returns 1 if so, 0 if not, and -1 if an error occurred.
// direrror is set if there was an error.
INT32 pathisdirectory(const char *path)
{
struct stat fsstat;
if (stat(path, &fsstat) < 0)
{
return -1;
}
else if (S_ISDIR(fsstat.st_mode))
return 1;
return 0;
}
filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, boolean completepath, int maxsearchdepth)
{
filestatus_t retval = FS_NOTFOUND;
@@ -396,9 +413,28 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
// okay, now we actually want searchpath to incorporate d_name
strcpy(&searchpath[searchpathindex[depthleft]],dent->d_name);
#if defined(__linux__) || defined(__FreeBSD__)
if (dent->d_type == DT_UNKNOWN)
if (lstat(searchpath,&fsstat) == 0 && S_ISDIR(fsstat.st_mode))
dent->d_type = DT_DIR;
else if (lstat(searchpath,&fsstat) == 0 && S_ISLNK(fsstat.st_mode))
dent->d_type = DT_LNK;
// Symlinks aren't always directory symlinks. Dunno if this would resolve recursive
// symlinks, but i think stat already does that
if (dent->d_type == DT_LNK && stat(searchpath,&fsstat) == 0 && !S_ISDIR(fsstat.st_mode))
{
dent->d_type = DT_UNKNOWN;
}
// Linux and FreeBSD has a special field for file type on dirent, so use that to speed up lookups.
// FIXME: should we also follow symlinks?
if ((dent->d_type == DT_DIR && depthleft) || (dent->d_type == DT_LNK && depthleft))
#else
if (stat(searchpath,&fsstat) < 0) // do we want to follow symlinks? if not: change it to lstat
; // was the file (re)moved? can't stat it
else if (S_ISDIR(fsstat.st_mode) && depthleft)
#endif
{
searchpathindex[--depthleft] = strlen(searchpath) + 1;
dirhandle[depthleft] = opendir(searchpath);
+1
View File
@@ -89,6 +89,7 @@ typedef enum
REFRESHDIR_GAMEDATA = 64
} refreshdir_enum;
INT32 pathisdirectory(const char *path);
void closefilemenu(boolean validsize);
void searchfilemenu(char *tempname);
boolean preparefilemenu(boolean samedepth, boolean replayhut);
+34 -25
View File
@@ -496,12 +496,11 @@ consvar_t cv_ydeadzone4 = {"joy4_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_c
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_gravstretch = {"gravstretch", "0", CV_FLOAT | CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t stretchfactor_t[] = {
{0, "Off"}, {FRACUNIT/8, "0.125"}, {FRACUNIT/4, "0.250"},
{3*FRACUNIT/8, "0.375"}, {FRACUNIT/2, "0.500"}, {5*FRACUNIT/8, "0.625"},
{3*FRACUNIT/4, "0.750"}, {7*FRACUNIT/8, "0.875"}, {FRACUNIT, "Max"}, {0, NULL}};
consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}};
consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -512,17 +511,14 @@ static CV_PossibleValue_t sloperolldist_cons_t[] = {
{3072, "3072"}, {4096, "4096"}, {6144, "6144"},
{8192, "8192"}, {0, "Infinite"}, {0, NULL}};
consvar_t cv_sloperolldist = {"sloperolldist", "Infinite", CV_SAVE, sloperolldist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, "Everything"}, {0, NULL}};
consvar_t cv_spriteroll = {"spriteroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_resetspecialmusic = {"resetspecialmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_resume = {"resume", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fading = {"fading", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
#if MAXPLAYERS > 16
#error "please update player_name table using the new value for MAXPLAYERS"
#endif
@@ -1423,9 +1419,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
side += ((axis * sidemove[0]) >> 10);
}
// Specator mouse turning
if (player->spectator)
if (player->spectator || cv_mouseturn.value)
{
//THIS WORKS WTF????????
cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8)));
cmd->driftturn = (INT16)(cmd->driftturn - ((mousex*(encoremode ? -1 : 1)*8)));
}
@@ -1961,7 +1957,7 @@ boolean G_Responder(event_t *ev)
paused = true;
S_PauseAudio();
}
else if (paused)
else if ((paused) && (!cv_pausemusic.value))
S_PauseAudio();
else
S_ResumeAudio();
@@ -2828,7 +2824,7 @@ void G_PlayerReborn(INT32 player)
/* I'm putting this here because lol */
fade = ( cv_fading.value && P_IsLocalPlayer(p) );
fade = (cv_fading.value && cv_birdmusic.value && P_IsLocalPlayer(p));
if (fade)
{
@@ -5036,16 +5032,29 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc)
INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
{
boolean usemapcode = false;
INT32 newmapnum;
size_t mapnamelen;
size_t mapnamelen = strlen(mapname);
char *p;
mapnamelen = strlen(mapname);
if (mapnamelen == 2)/* maybe two digit code */
if (mapnamelen == 1)
{
if (mapname[0] == '*') // current map
return gamemap;
else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map
{
newmapnum = mapheaderinfo[gamemap-1]->nextlevel;
if (newmapnum < 1 || newmapnum > NUMMAPS)
{
CONS_Alert(CONS_ERROR, M_GetText("NextLevel (%d) is not a valid map.\n"), newmapnum);
return 0;
}
else
return newmapnum;
}
}
else if (mapnamelen == 2)/* maybe two digit code */
{
if (( newmapnum = M_MapNumber(mapname[0], mapname[1]) ))
usemapcode = true;
@@ -8189,7 +8198,7 @@ void G_AddGhost(char *defdemoname)
count = READUINT16(p);
while (count--)
{
SKIPSTRING(p);
p += 2;
SKIPSTRING(p);
p++;
}
+29 -30
View File
@@ -127,25 +127,33 @@ extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
// Hud offsets
extern consvar_t cv_item_xoffset;
extern consvar_t cv_item_yoffset;
extern consvar_t cv_time_xoffset;
extern consvar_t cv_time_yoffset;
extern consvar_t cv_laps_xoffset;
extern consvar_t cv_laps_yoffset;
extern consvar_t cv_spdm_xoffset;
extern consvar_t cv_spdm_yoffset;
extern consvar_t cv_posi_xoffset;
extern consvar_t cv_posi_yoffset;
extern consvar_t cv_face_xoffset;
extern consvar_t cv_face_yoffset;
extern consvar_t cv_stcd_xoffset;
extern consvar_t cv_stcd_yoffset;
extern consvar_t cv_chek_yoffset;
extern consvar_t cv_mini_xoffset;
extern consvar_t cv_mini_yoffset;
extern consvar_t cv_want_xoffset;
extern consvar_t cv_want_yoffset;
#define DECL_HUD_OFFSET_X(name)\
extern consvar_t cv_##name##_xoffset;
#define DECL_HUD_OFFSET_Y(name)\
extern consvar_t cv_##name##_yoffset;
#define DECL_HUD_OFFSET(name)\
DECL_HUD_OFFSET_X(name)\
DECL_HUD_OFFSET_Y(name)
DECL_HUD_OFFSET(item); // Item box
DECL_HUD_OFFSET(time); // Time
DECL_HUD_OFFSET(laps); // Number of laps
DECL_HUD_OFFSET(dnft); // Countdown (did not finish timer)
DECL_HUD_OFFSET(speed); // Speedometer
DECL_HUD_OFFSET(posi); // Position in race
DECL_HUD_OFFSET(face); // Mini rankings
DECL_HUD_OFFSET(stcd); // Starting countdown
DECL_HUD_OFFSET_Y(chek); // Check gfx
DECL_HUD_OFFSET(mini); // Minimap
DECL_HUD_OFFSET(want); // Wanted
DECL_HUD_OFFSET(stat); // Stats
#undef DECL_HUD_OFFSET
#undef DECL_HUD_OFFSET_X
#undef DECL_HUD_OFFSET_Y
extern consvar_t cv_showinput;
extern consvar_t cv_newspeedometer;
@@ -156,23 +164,14 @@ extern consvar_t cv_saltysquish;
extern consvar_t cv_driftsparkpulse;
extern consvar_t cv_gravstretch;
extern consvar_t cv_sloperoll;
extern consvar_t cv_spriteroll;
extern consvar_t cv_sliptideroll;
extern consvar_t cv_slamsound;
extern consvar_t cv_sloperolldist;
extern consvar_t cv_invincmusicfade;
extern consvar_t cv_growmusicfade;
extern consvar_t cv_respawnfademusicout;
extern consvar_t cv_respawnfademusicback;
extern consvar_t cv_resetspecialmusic;
extern consvar_t cv_sparkroll;
extern consvar_t cv_cechotoggle;
extern consvar_t cv_resume;
extern consvar_t cv_fading;
#ifndef NONET
extern consvar_t cv_chatlogsize;
#endif
+462
View File
@@ -0,0 +1,462 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2020-2023 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_batching.c
/// \brief Draw call batching and related things.
#ifdef HWRENDER
#include "hw_glob.h"
#include "hw_batching.h"
#include "hw_main.h"
#include "../i_system.h"
typedef struct
{
FSurfaceInfo surf; // surf also has its own polyflags for some reason, but it seems unused
unsigned int vertsIndex; // location of verts in unsortedVertices
FUINT numVerts;
FBITFIELD polyFlags;
GLMipmap_t *texture;
int shader;
// this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls
boolean horizonSpecial;
} DrawCallInfo;
// The texture for the next polygon given to HWR_ProcessPolygon.
// Set with HWR_SetCurrentTexture.
GLMipmap_t *current_texture = NULL;
boolean currently_batching = false;
// Dynamic arrays for:
// - unsorted draw calls
// - sorted order of draw calls
// - unsorted vertices
// - final (sorted) vertices
// - vertex indices for sorted vertices
// contains the draw calls from DrawPolygon, waiting to be processed
DrawCallInfo* drawCalls = NULL;
int drawCallsSize = 0;
int drawCallsCapacity = 65536;
// contains sorted order (array indices) for drawCalls
// (therefore size and capacity shared with it)
UINT32* drawCallOrder = NULL;
// contains unsorted vertices and texture coordinates from DrawPolygon
FOutVector* unsortedVertices = NULL;
int unsortedVerticesSize = 0;
int unsortedVerticesCapacity = 65536;
// contains subset of sorted vertices and texture coordinates to be sent to gpu
FOutVector* finalVertices = NULL;
int finalVerticesSize = 0;
int finalVerticesCapacity = 65536;
// contains vertex indices into finalVertices for glDrawElements,
// taking into account fan->triangles conversion
UINT32* finalIndices = NULL; // this is alloced with 3x finalVertices size
int finalIndicesSize = 0;
// Enables batching mode. HWR_ProcessPolygon will collect polygons instead of passing them directly to the rendering backend.
// Call HWR_RenderBatches to render all the collected geometry.
void HWR_StartBatching(void)
{
if (currently_batching)
I_Error("Repeat call to HWR_StartBatching without HWR_RenderBatches");
// init arrays if that has not been done yet
if (!finalVertices)
{
finalVertices = malloc(finalVerticesCapacity * sizeof(FOutVector));
finalIndices = malloc(finalVerticesCapacity * 3 * sizeof(UINT32));
drawCalls = malloc(drawCallsCapacity * sizeof(DrawCallInfo));
drawCallOrder = malloc(drawCallsCapacity * sizeof(UINT32));
unsortedVertices = malloc(unsortedVerticesCapacity * sizeof(FOutVector));
}
currently_batching = true;
}
// This replaces the direct calls to pfnSetTexture in cases where batching is available.
// The texture selection is saved for the next HWR_ProcessPolygon call.
// Doing this was easier than getting a texture pointer to HWR_ProcessPolygon.
void HWR_SetCurrentTexture(GLMipmap_t *texture)
{
if (currently_batching)
current_texture = texture;
else
HWD.pfnSetTexture(texture);
}
static void HWR_CollectDrawCallInfo(FSurfaceInfo *pSurf, FUINT iNumPts, FBITFIELD PolyFlags, int shader_target, boolean horizonSpecial)
{
// make sure dynamic array has capacity
if (drawCallsSize == drawCallsCapacity)
{
DrawCallInfo* new_array;
// ran out of space, make new array double the size
drawCallsCapacity *= 2;
new_array = malloc(drawCallsCapacity * sizeof(DrawCallInfo));
memcpy(new_array, drawCalls, drawCallsSize * sizeof(DrawCallInfo));
free(drawCalls);
drawCalls = new_array;
// also need to redo the index array, dont need to copy it though
free(drawCallOrder);
drawCallOrder = malloc(drawCallsCapacity * sizeof(UINT32));
}
// add entry to array
drawCalls[drawCallsSize].surf = *pSurf;
drawCalls[drawCallsSize].vertsIndex = unsortedVerticesSize;
drawCalls[drawCallsSize].numVerts = iNumPts;
drawCalls[drawCallsSize].polyFlags = PolyFlags;
drawCalls[drawCallsSize].texture = current_texture;
drawCalls[drawCallsSize].shader = (shader_target != -1) ? HWR_GetShaderFromTarget(shader_target) : shader_target;
drawCalls[drawCallsSize].horizonSpecial = horizonSpecial;
drawCallsSize++;
}
static void HWR_CollectDrawCallVertices(FOutVector *pOutVerts, FUINT iNumPts)
{
// make sure dynamic array has capacity
while (unsortedVerticesSize + (int)iNumPts > unsortedVerticesCapacity)
{
FOutVector* new_array;
// need more space for vertices in unsortedVertices
unsortedVerticesCapacity *= 2;
new_array = malloc(unsortedVerticesCapacity * sizeof(FOutVector));
memcpy(new_array, unsortedVertices, unsortedVerticesSize * sizeof(FOutVector));
free(unsortedVertices);
unsortedVertices = new_array;
}
// add vertices to array
memcpy(&unsortedVertices[unsortedVerticesSize], pOutVerts, iNumPts * sizeof(FOutVector));
unsortedVerticesSize += iNumPts;
}
// If batching is enabled, this function collects the polygon data and the chosen texture
// for later use in HWR_RenderBatches. Otherwise the rendering backend is used to
// render the polygon immediately.
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader_target, boolean horizonSpecial)
{
if (currently_batching)
{
if (!pSurf)
{
// handling null FSurfaceInfo is not implemented
I_Error("Got a null FSurfaceInfo in batching");
}
HWR_CollectDrawCallInfo(pSurf, iNumPts, PolyFlags, shader_target, horizonSpecial);
HWR_CollectDrawCallVertices(pOutVerts, iNumPts);
}
else
{
HWD.pfnSetShader((shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target);
HWD.pfnDrawPolygon(pSurf, pOutVerts, iNumPts, PolyFlags);
}
}
static int compareDrawCalls(const void *p1, const void *p2)
{
UINT32 index1 = *(const UINT32*)p1;
UINT32 index2 = *(const UINT32*)p2;
DrawCallInfo* poly1 = &drawCalls[index1];
DrawCallInfo* poly2 = &drawCalls[index2];
int diff;
INT64 diff64;
UINT32 downloaded1 = 0;
UINT32 downloaded2 = 0;
int shader1 = poly1->shader;
int shader2 = poly2->shader;
// make skywalls and horizon lines first in order
if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial)
shader1 = -1;
if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial)
shader2 = -1;
diff = shader1 - shader2;
if (diff != 0) return diff;
// skywalls and horizon lines must retain their order for horizon lines to work
if (shader1 == -1 && shader2 == -1)
return index1 - index2;
if (poly1->texture)
downloaded1 = poly1->texture->downloaded; // there should be a opengl texture name here, usable for comparisons
if (poly2->texture)
downloaded2 = poly2->texture->downloaded;
diff64 = downloaded1 - downloaded2;
if (diff64 != 0) return diff64;
diff = poly1->polyFlags - poly2->polyFlags;
if (diff != 0) return diff;
diff64 = poly1->surf.PolyColor.rgba - poly2->surf.PolyColor.rgba;
if (diff64 < 0) return -1; else if (diff64 > 0) return 1;
diff64 = poly1->surf.TintColor.rgba - poly2->surf.TintColor.rgba;
if (diff64 < 0) return -1; else if (diff64 > 0) return 1;
diff64 = poly1->surf.FadeColor.rgba - poly2->surf.FadeColor.rgba;
if (diff64 < 0) return -1; else if (diff64 > 0) return 1;
diff = poly1->surf.LightInfo.light_level - poly2->surf.LightInfo.light_level;
if (diff != 0) return diff;
diff = poly1->surf.LightInfo.fade_start - poly2->surf.LightInfo.fade_start;
if (diff != 0) return diff;
diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end;
return diff;
}
static int compareDrawCallsNoShaders(const void *p1, const void *p2)
{
UINT32 index1 = *(const UINT32*)p1;
UINT32 index2 = *(const UINT32*)p2;
DrawCallInfo* poly1 = &drawCalls[index1];
DrawCallInfo* poly2 = &drawCalls[index2];
int diff;
INT64 diff64;
GLMipmap_t *texture1 = poly1->texture;
GLMipmap_t *texture2 = poly2->texture;
UINT32 downloaded1 = 0;
UINT32 downloaded2 = 0;
if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial)
texture1 = NULL;
if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial)
texture2 = NULL;
if (texture1)
downloaded1 = texture1->downloaded; // there should be a opengl texture name here, usable for comparisons
if (texture2)
downloaded2 = texture2->downloaded;
// skywalls and horizon lines must retain their order for horizon lines to work
if (!texture1 && !texture2)
return index1 - index2;
diff64 = downloaded1 - downloaded2;
if (diff64 != 0) return diff64;
diff = poly1->polyFlags - poly2->polyFlags;
if (diff != 0) return diff;
diff64 = poly1->surf.PolyColor.rgba - poly2->surf.PolyColor.rgba;
if (diff64 < 0) return -1; else if (diff64 > 0) return 1;
return 0;
}
static void HWR_CollectVerticesIntoBatch(DrawCallInfo *drawCall)
{
int firstVIndex;
int lastVIndex;
int numVerts = drawCall->numVerts;
// before writing, check if there is enough room
// using 'while' instead of 'if' here makes sure that there will *always* be enough room.
// probably never will this loop run more than once though
while (finalVerticesSize + numVerts > finalVerticesCapacity)
{
FOutVector* new_array;
UINT32* new_index_array;
finalVerticesCapacity *= 2;
new_array = malloc(finalVerticesCapacity * sizeof(FOutVector));
memcpy(new_array, finalVertices, finalVerticesSize * sizeof(FOutVector));
free(finalVertices);
finalVertices = new_array;
// also increase size of index array, 3x of vertex array since
// going from fans to triangles increases vertex count to 3x
new_index_array = malloc(finalVerticesCapacity * 3 * sizeof(UINT32));
memcpy(new_index_array, finalIndices, finalIndicesSize * sizeof(UINT32));
free(finalIndices);
finalIndices = new_index_array;
}
// write the vertices of the polygon
memcpy(&finalVertices[finalVerticesSize], &unsortedVertices[drawCall->vertsIndex],
numVerts * sizeof(FOutVector));
// write the indexes, pointing to the fan vertexes but in triangles format
firstVIndex = finalVerticesSize;
lastVIndex = finalVerticesSize + numVerts;
finalVerticesSize += 2;
while (finalVerticesSize < lastVIndex)
{
finalIndices[finalIndicesSize++] = firstVIndex;
finalIndices[finalIndicesSize++] = finalVerticesSize - 1;
finalIndices[finalIndicesSize++] = finalVerticesSize++;
}
}
static GLMipmap_t *HWR_GetDrawCallTexture(DrawCallInfo *dc)
{
return (dc->polyFlags & PF_NoTexture) ? NULL : dc->texture;
}
// flags returned by HWR_MarkStateChanges
#define SHADER_CHANGED 1
#define TEXTURE_CHANGED 2
#define POLYFLAGS_CHANGED 4
#define SURFACEINFO_CHANGED 8
static unsigned int HWR_MarkStateChanges(DrawCallInfo *current, DrawCallInfo *next)
{
unsigned int stateChanges = 0;
FSurfaceInfo *currentSI = &current->surf;
FSurfaceInfo *nextSI = &next->surf;
// check if a state change is required and flag it to stateChanges
if (current->shader != next->shader && cv_grshaders.value && gr_shadersavailable)
stateChanges |= SHADER_CHANGED;
if (HWR_GetDrawCallTexture(current) != HWR_GetDrawCallTexture(next))
stateChanges |= TEXTURE_CHANGED;
if (current->polyFlags != next->polyFlags)
stateChanges |= POLYFLAGS_CHANGED;
if (cv_grshaders.value && gr_shadersavailable)
{
if (currentSI->PolyColor.rgba != nextSI->PolyColor.rgba ||
currentSI->TintColor.rgba != nextSI->TintColor.rgba ||
currentSI->FadeColor.rgba != nextSI->FadeColor.rgba ||
currentSI->LightInfo.light_level != nextSI->LightInfo.light_level ||
currentSI->LightInfo.fade_start != nextSI->LightInfo.fade_start ||
currentSI->LightInfo.fade_end != nextSI->LightInfo.fade_end)
{
stateChanges |= SURFACEINFO_CHANGED;
}
}
else
{
if (currentSI->PolyColor.rgba != nextSI->PolyColor.rgba)
stateChanges |= SURFACEINFO_CHANGED;
}
return stateChanges;
}
static void HWR_ExecuteStateChanges(unsigned int stateChanges, DrawCallInfo *dc)
{
if ((stateChanges & SHADER_CHANGED) && cv_grshaders.value && gr_shadersavailable)
{
HWD.pfnSetShader(dc->shader);
ps_hw_numshaders.value.i++;
}
if (stateChanges & TEXTURE_CHANGED)
{
// for PF_NoTexture the texture is set in DrawIndexedTriangles
if (!(dc->polyFlags & PF_NoTexture))
{
// texture should be already ready for use from calls to
// SetTexture during batch collection
HWD.pfnSetTexture(dc->texture);
}
ps_hw_numtextures.value.i++;
}
// these two are just parameters to DrawIndexedTriangles
// (changes to polyflags states are tracked in r_opengl.c though)
if (stateChanges & POLYFLAGS_CHANGED)
ps_hw_numpolyflags.value.i++;
if (stateChanges & SURFACEINFO_CHANGED)
ps_hw_numcolors.value.i++;
}
static void HWR_InitBatchingStats(void)
{
ps_hw_numpolys.value.i = drawCallsSize;
ps_hw_numcalls.value.i = ps_hw_numverts.value.i
= ps_hw_numshaders.value.i = ps_hw_numtextures.value.i
= ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 0;
}
// This function organizes the geometry and draw calls collected by HWR_ProcessPolygon
// calls into batches and uses the rendering backend to draw them.
void HWR_RenderBatches(void)
{
int drawCallReadPos = 0; // position in drawCallOrder
int i;
if (!currently_batching)
I_Error("HWR_RenderBatches called without starting batching");
currently_batching = false; // no longer collecting batches
HWR_InitBatchingStats();
if (!drawCallsSize)
return; // nothing to draw
// init drawCallOrder
for (i = 0; i < drawCallsSize; i++)
drawCallOrder[i] = i;
// sort the draw calls
PS_START_TIMING(ps_hw_batchsorttime);
if (cv_grshaders.value && gr_shadersavailable)
qsort(drawCallOrder, drawCallsSize, sizeof(UINT32), compareDrawCalls);
else
qsort(drawCallOrder, drawCallsSize, sizeof(UINT32), compareDrawCallsNoShaders);
PS_STOP_TIMING(ps_hw_batchsorttime);
// sort grouping order
// 1. shader
// 2. texture
// 3. polyflags
// 4. colors + light level
// not sure about what order of the last 2 should be, or if it even matters
PS_START_TIMING(ps_hw_batchdrawtime);
// set state for first batch
HWR_ExecuteStateChanges(0xFFFF, &drawCalls[drawCallOrder[0]]);
// - iterate through draw calls
// - accumulate converted vertices and indices into finalVertices and finalIndices
// and send them as a combined draw call when a state change occurs
while (1)
{
boolean stopFlag = false;
unsigned int stateChanges = 0; // flags defined above HWR_MarkStateChanges
DrawCallInfo *currentDrawCall = &drawCalls[drawCallOrder[drawCallReadPos++]];
DrawCallInfo *nextDrawCall = NULL;
HWR_CollectVerticesIntoBatch(currentDrawCall);
if (drawCallReadPos >= drawCallsSize) // was that the last draw call?
{
stopFlag = true;
}
else
{
nextDrawCall = &drawCalls[drawCallOrder[drawCallReadPos]];
stateChanges = HWR_MarkStateChanges(currentDrawCall, nextDrawCall);
}
if (stateChanges || stopFlag)
{
// execute combined draw call
HWD.pfnDrawIndexedTriangles(&currentDrawCall->surf, finalVertices,
finalIndicesSize, currentDrawCall->polyFlags, finalIndices);
// update stats
ps_hw_numcalls.value.i++;
ps_hw_numverts.value.i += finalIndicesSize;
// reset final geometry collection arrays
finalVerticesSize = 0;
finalIndicesSize = 0;
}
else
continue;
// if we're here then either its time to stop or time to change state
if (stopFlag)
break;
else
HWR_ExecuteStateChanges(stateChanges, nextDrawCall);
}
// reset the arrays (set sizes to 0)
drawCallsSize = 0;
unsortedVerticesSize = 0;
PS_STOP_TIMING(ps_hw_batchdrawtime);
}
#endif // HWRENDER
+27
View File
@@ -0,0 +1,27 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_batching.h
/// \brief Draw call batching and related things.
#ifndef __HWR_BATCHING_H__
#define __HWR_BATCHING_H__
#include "hw_defs.h"
#include "hw_data.h"
#include "hw_drv.h"
void HWR_StartBatching(void);
void HWR_SetCurrentTexture(GLMipmap_t *texture);
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial);
void HWR_RenderBatches(void);
extern boolean currently_batching;
#endif
+2 -2
View File
@@ -894,11 +894,11 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
ls_count = ls_percent = 0; // reset the loading status
CON_Drawer(); //let the user know what we are doing
I_FinishUpdate(); // page flip or blit buffer
#endif
// reset the portal flag
gr_maphasportals = 0;
#endif
// find min/max boundaries of map
//CONS_Debug(DBG_RENDER, "Looking for boundaries of map...\n");
M_ClearBox(rootbbox);
+238 -40
View File
@@ -17,6 +17,7 @@
#include "hw_main.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "hw_batching.h"
#include "../doomstat.h" //gamemode
#include "../i_video.h" //rendermode
@@ -33,12 +34,20 @@ static INT32 blocksize, blockwidth, blockheight;
INT32 patchformat = GR_TEXFMT_AP_88; // use alpha for holes
INT32 textureformat = GR_TEXFMT_P_8; // use chromakey for hole
RGBA_t mapPalette[256] = {0}; // the palette for the currently loaded level or menu etc.
// Returns a pointer to the palette which should be used for caching textures.
RGBA_t *HWR_GetTexturePalette(void)
{
return HWR_ShouldUsePaletteRendering() ? mapPalette : pLocalPalette;
}
// sprite, use alpha and chroma key for hole
static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
INT32 pblockwidth, INT32 pblockheight, INT32 blockmodulo,
INT32 ptexturewidth, INT32 ptextureheight,
INT32 originx, INT32 originy, // where to draw patch in surface block
const patch_t *realpatch, INT32 bpp)
const patch_t *realpatch, INT32 bpp, RGBA_t *palette)
{
INT32 x, x1, x2;
INT32 col, ncols;
@@ -67,6 +76,8 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
if (!ptexturewidth)
return;
palette = HWR_GetTexturePalette();
col = x * pblockwidth / ptexturewidth;
ncols = ((x2 - x) * pblockwidth) / ptexturewidth;
@@ -152,10 +163,10 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
case 2 : texelu16 = (UINT16)((alpha<<8) | texel);
memcpy(dest, &texelu16, sizeof(UINT16));
break;
case 3 : colortemp = V_GetColor(texel);
case 3 : colortemp = palette[texel];
memcpy(dest, &colortemp, sizeof(RGBA_t)-sizeof(UINT8));
break;
case 4 : colortemp = V_GetColor(texel);
case 4 : colortemp = palette[texel];
colortemp.s.alpha = alpha;
memcpy(dest, &colortemp, sizeof(RGBA_t));
break;
@@ -329,6 +340,9 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
INT32 i;
boolean skyspecial = false; //poor hack for Legacy large skies..
RGBA_t *palette;
palette = HWR_GetTexturePalette();
texture = textures[texnum];
@@ -349,7 +363,12 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
HWR_ResizeBlock (texture->width, texture->height, &grtex->mipmap.grInfo);
grtex->mipmap.width = (UINT16)blockwidth;
grtex->mipmap.height = (UINT16)blockheight;
grtex->mipmap.grInfo.format = textureformat;
//grtex->mipmap.grInfo.format = textureformat;
if (skyspecial)
grtex->mipmap.grInfo.format = GR_RGBA; // that skyspecial code below assumes this format ...
else
grtex->mipmap.grInfo.format = textureformat;
grtex->mipmap.colormap = colormaps;
@@ -365,7 +384,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
INT32 j;
RGBA_t col;
col = V_GetColor(HWR_CHROMAKEY_EQUIVALENTCOLORINDEX);
col = palette[HWR_CHROMAKEY_EQUIVALENTCOLORINDEX];
for (j = 0; j < blockheight; j++)
{
for (i = 0; i < blockwidth; i++)
@@ -388,7 +407,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
texture->width, texture->height,
patch->originx, patch->originy,
realpatch,
format2bpp[grtex->mipmap.grInfo.format]);
format2bpp[grtex->mipmap.grInfo.format], palette);
Z_Unlock(realpatch);
}
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
@@ -412,6 +431,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
void HWR_MakePatch (patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap)
{
INT32 newwidth, newheight;
RGBA_t *palette = HWR_GetTexturePalette();
// don't do it twice (like a cache)
if (grMipmap->width == 0)
@@ -456,7 +477,7 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, bo
grPatch->width, grPatch->height,
0, 0,
patch,
format2bpp[grMipmap->grInfo.format]);
format2bpp[grMipmap->grInfo.format], palette);
}
grPatch->max_s = (float)newwidth / (float)blockwidth;
@@ -557,25 +578,6 @@ void HWR_PrepLevelCache(size_t pnumtextures)
I_Error("HWR_PrepLevelCache: can't alloc gr_textures");
}
void HWR_SetPalette(RGBA_t *palette)
{
//Hudler: 16/10/99: added for OpenGL gamma correction
RGBA_t gamma_correction = {0x7F7F7F7F};
//Hurdler 16/10/99: added for OpenGL gamma correction
gamma_correction.s.red = (UINT8)cv_grgammared.value;
gamma_correction.s.green = (UINT8)cv_grgammagreen.value;
gamma_correction.s.blue = (UINT8)cv_grgammablue.value;
HWD.pfnSetPalette(palette, &gamma_correction);
// hardware driver will flush there own cache if cache is non paletized
// now flush data texture cache so 32 bit texture are recomputed
if (patchformat == GR_RGBA || textureformat == GR_RGBA)
{
Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE);
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED);
}
}
// --------------------------------------------------------------------------
// Make sure texture is downloaded and set it as the source
// --------------------------------------------------------------------------
@@ -591,7 +593,11 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
HWR_GenerateTexture(tex, grtex);
HWD.pfnSetTexture(&grtex->mipmap);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grtex->mipmap.downloaded)
HWD.pfnSetTexture(&grtex->mipmap);
HWR_SetCurrentTexture(&grtex->mipmap);
// The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
@@ -672,18 +678,14 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
grmip->colormap += (256*32);
#endif
grmip->colormap = colormaps;
#ifdef GLENCORE
if (!noencoremap && encoremap)
grmip->colormap += (256*32);
#endif
if (!grmip->downloaded && !grmip->grInfo.data)
HWR_CacheFlat(grmip, flatlumpnum);
HWD.pfnSetTexture(grmip);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grmip->downloaded)
HWD.pfnSetTexture(grmip);
HWR_SetCurrentTexture(grmip);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
@@ -709,8 +711,11 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
Z_Free(patch);
}
HWD.pfnSetTexture(grmip);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grmip->downloaded)
HWD.pfnSetTexture(grmip);
HWR_SetCurrentTexture(grmip);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
@@ -740,7 +745,11 @@ void HWR_GetPatch(GLPatch_t *gpatch)
Z_Free(ptr);
}
HWD.pfnSetTexture(gpatch->mipmap);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!gpatch->mipmap->downloaded)
HWD.pfnSetTexture(gpatch->mipmap);
HWR_SetCurrentTexture(gpatch->mipmap);
// The system-memory patch data can be purged now.
Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED);
@@ -829,6 +838,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
UINT8 *flat;
UINT8 *dest, *src, texel;
RGBA_t col;
RGBA_t *palette = HWR_GetTexturePalette();
// Place the flats data into flat
W_ReadLump(fademasklumpnum, Z_Malloc(W_LumpLength(fademasklumpnum),
@@ -846,7 +856,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
{
// fademask bpp is always 1, and is used just for alpha
texel = src[(posx)>>FRACBITS];
col = V_GetColor(texel);
col = palette[texel];
*dest = col.s.red; // take the red level of the colour and use it for alpha, as fademasks do
dest++;
@@ -922,4 +932,192 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
}
// =================================================
// PALETTE HANDLING
// =================================================
void HWR_SetPalette(RGBA_t *palette)
{
if (HWR_ShouldUsePaletteRendering())
{
// set the palette for palette postprocessing
if (cv_grpalettedepth.value == 16)
{
// crush to 16-bit rgb565, like software currently does in the standard configuration
// Note: Software's screenshots have the 24-bit palette, but the screen gets
// the 16-bit version! For making comparison screenshots either use an external screenshot
// tool or set the palette depth to 24 bits.
RGBA_t crushed_palette[256];
int i;
for (i = 0; i < 256; i++)
{
float fred = (float)(palette[i].s.red >> 3);
float fgreen = (float)(palette[i].s.green >> 2);
float fblue = (float)(palette[i].s.blue >> 3);
crushed_palette[i].s.red = (UINT8)(fred / 31.0f * 255.0f);
crushed_palette[i].s.green = (UINT8)(fgreen / 63.0f * 255.0f);
crushed_palette[i].s.blue = (UINT8)(fblue / 31.0f * 255.0f);
crushed_palette[i].s.alpha = 255;
}
HWD.pfnSetScreenPalette(crushed_palette);
}
else
{
HWD.pfnSetScreenPalette(palette);
}
// this part is responsible for keeping track of the palette OUTSIDE of a level.
if ((!(gamestate == GS_LEVEL)) || (gamestate == GS_TITLESCREEN))
HWR_SetMapPalette();
}
else
{
// set the palette for the textures
HWD.pfnSetTexturePalette(palette);
// reset mapPalette so next call to HWR_SetMapPalette will update everything correctly
memset(mapPalette, 0, sizeof(mapPalette));
// hardware driver will flush there own cache if cache is non paletized
// now flush data texture cache so 32 bit texture are recomputed
//if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA)
if (patchformat == GR_RGBA || textureformat == GR_RGBA)
{
Z_FreeTag(PU_HWRCACHE);
Z_FreeTag(PU_HWRCACHE_UNLOCKED);
}
}
}
static void HWR_SetPaletteLookup(RGBA_t *palette)
{
int r, g, b;
UINT8 *lut = Z_Malloc(
HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*sizeof(UINT8),
PU_STATIC, NULL);
#define STEP_SIZE (256/HWR_PALETTE_LUT_SIZE)
for (b = 0; b < HWR_PALETTE_LUT_SIZE; b++)
{
for (g = 0; g < HWR_PALETTE_LUT_SIZE; g++)
{
for (r = 0; r < HWR_PALETTE_LUT_SIZE; r++)
{
lut[b*HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE+g*HWR_PALETTE_LUT_SIZE+r] =
NearestPaletteColor(r*STEP_SIZE, g*STEP_SIZE, b*STEP_SIZE, palette);
}
}
}
#undef STEP_SIZE
HWD.pfnSetPaletteLookup(lut);
Z_Free(lut);
}
// Updates mapPalette to reflect the loaded level or other game state.
// Textures are flushed if needed.
// Call this function only in palette rendering mode.
void HWR_SetMapPalette(void)
{
RGBA_t RGBA_converted[256];
RGBA_t *palette;
int i;
if ((!(gamestate == GS_LEVEL)) || (gamestate == GS_TITLESCREEN))
{
// outside of a level, pMasterPalette should have PLAYPAL ready for us
//palette = pMasterPalette; // we dont have this in kart so just use pLocalPalette as before
palette = pLocalPalette;
}
else
{
// in a level pLocalPalette might have a flash palette, but we
// want the map's original palette.
lumpnum_t lumpnum = W_GetNumForName(GetPalette());
size_t palsize = W_LumpLength(lumpnum);
UINT8 *RGB_data;
if (palsize < 768) // 256 * 3
I_Error("HWR_SetMapPalette: A programmer assumed palette lumps are at least 768 bytes long, but apparently this was a wrong assumption!\n");
RGB_data = W_CacheLumpNum(lumpnum, PU_CACHE);
// we got the RGB palette now, but we need it in RGBA format.
for (i = 0; i < 256; i++)
{
RGBA_converted[i].s.red = *(RGB_data++);
RGBA_converted[i].s.green = *(RGB_data++);
RGBA_converted[i].s.blue = *(RGB_data++);
RGBA_converted[i].s.alpha = 255;
}
palette = RGBA_converted;
}
// check if the palette has changed from the previous one
if (memcmp(mapPalette, palette, sizeof(mapPalette)))
{
memcpy(mapPalette, palette, sizeof(mapPalette));
// in palette rendering mode, this means that all rgba textures now have wrong colors
// and the lookup table is outdated
HWR_SetPaletteLookup(mapPalette);
HWD.pfnSetTexturePalette(mapPalette);
//if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA)
if (patchformat == GR_RGBA || textureformat == GR_RGBA)
{
Z_FreeTag(PU_HWRCACHE);
Z_FreeTag(PU_HWRCACHE_UNLOCKED);
}
}
}
// Creates a hardware lighttable from the supplied lighttable.
// Returns the id of the hw lighttable, usable in FSurfaceInfo.
UINT32 HWR_CreateLightTable(UINT8 *lighttable)
{
UINT32 i, id;
RGBA_t *palette = HWR_GetTexturePalette();
RGBA_t *hw_lighttable = Z_Malloc(256 * 32 * sizeof(RGBA_t), PU_STATIC, NULL);
// To make the palette index -> RGBA mapping easier for the shader,
// the hardware lighttable is composed of RGBA colors instead of palette indices.
for (i = 0; i < 256 * 32; i++)
hw_lighttable[i] = palette[lighttable[i]];
id = HWD.pfnCreateLightTable(hw_lighttable);
Z_Free(hw_lighttable);
return id;
}
// get hwr lighttable id for colormap, create it if it doesn't already exist
UINT32 HWR_GetLightTableID(extracolormap_t *colormap)
{
boolean default_colormap = false;
if (!colormap)
{
colormap = &extra_colormaps[num_extra_colormaps]; // a place to store the hw lighttable id
// alternatively could just store the id in a global variable if there are issues
default_colormap = true;
}
// create hw lighttable if there isn't one
if (!colormap->gl_lighttable_id)
{
UINT8 *colormap_pointer;
if (default_colormap)
colormap_pointer = colormaps; // don't actually use the data from the "default colormap"
else
colormap_pointer = colormap->colormap;
colormap->gl_lighttable_id = HWR_CreateLightTable(colormap_pointer);
}
return colormap->gl_lighttable_id;
}
// Note: all hardware lighttable ids assigned before this
// call become invalid and must not be used.
void HWR_ClearLightTables(void)
{
//if (vid.glstate == VID_GL_LIBRARY_LOADED) // we have pfnInit which is essentially the same, but it doesent work here for whatever reason, since this should not be done in software renderer ever!
if (rendermode == render_opengl)
HWD.pfnClearLightTables();
}
#endif //HWRENDER
+64 -8
View File
@@ -25,6 +25,12 @@
#define NZCLIP_PLANE 0.9f // Seems to be only used for the HUD and screen textures
#define FAR_ZCLIP_DEFAULT 32768.0f
// The width/height/depth of the palette lookup table used by palette rendering.
// Changing this also requires changing the shader code!
// Also assumed to be a power of two in some parts of the code.
// 64 seems to work perfectly for the vanilla palette.
#define HWR_PALETTE_LUT_SIZE 64
// ==========================================================================
// SIMPLE TYPES
// ==========================================================================
@@ -129,8 +135,10 @@ typedef struct
FLOAT x,y,z; // position
#ifdef USE_FTRANSFORM_ANGLEZ
FLOAT anglex,angley,anglez; // aimingangle / viewangle
FLOAT anglex2,anglez2; // secondaries
#else
FLOAT anglex,angley; // aimingangle / viewangle
FLOAT anglex2; // secondaries
#endif
FLOAT scalex,scaley,scalez;
FLOAT spritexscale,spriteyscale;
@@ -157,6 +165,46 @@ typedef struct
FLOAT s,t;
} FOutVector;
#ifdef GL_SHADERS
// Shader targets used to render specific types of geometry.
// A shader target is resolved to an actual shader with HWR_GetShaderFromTarget.
// The shader returned may be a base shader or a custom shader.
enum
{
SHADER_NONE = -1,
SHADER_FLOOR = 0,
SHADER_WALL,
SHADER_MODEL,
SHADER_SPRITE,
SHADER_WATER,
SHADER_FOG,
SHADER_SKY,
SHADER_PALETTE_POSTPROCESS,
SHADER_UI_COLORMAP_FADE,
NUMSHADERTARGETS
};
// Must be at least NUMSHADERTARGETS*2 to fit base and custom shaders for each shader target.
#define HWR_MAXSHADERS NUMSHADERTARGETS*2
// Custom shader reference table
typedef struct
{
const char *type;
INT32 id;
} customshaderxlat_t;
enum hwdshaderstage
{
HWD_SHADERSTAGE_VERTEX,
HWD_SHADERSTAGE_FRAGMENT,
};
typedef enum hwdshaderstage hwdshaderstage_t;
#endif
// ==========================================================================
// RENDER MODES
// ==========================================================================
@@ -183,14 +231,15 @@ enum EPolyFlags
PF_NoDepthTest = 0x00000200, // Disable the depth test mode
PF_Invisible = 0x00000400, // Disable write to color buffer
PF_Decal = 0x00000800, // Enable polygon offset
PF_Modulated = 0x00001000, // Modulation (multiply output with constant ARGB)
PF_Modulated = 0x00001000, // Modulation (multiply output with constant RGBA)
// When set, pass the color constant into the FSurfaceInfo -> FlatColor
PF_NoTexture = 0x00002000, // Disable texture
PF_Ripple = 0x00004000, // Water shader effect
PF_ColorMapped = 0x00008000, // Surface has "tint" and "fade" colors, which are sent as uniforms to a shader.
// 0x00008000
PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y
PF_ForceWrapX = 0x00020000, // Force repeat texture on X
PF_ForceWrapY = 0x00040000, // Force repeat texture on Y
PF_ForceWrapY = 0x00040000, // Forces repeat texture on Y
PF_Ripple = 0x00100000 // Water ripple effect. The current backend doesn't use it for anything.
// 0x20000000
// 0x40000000
// 0x80000000
@@ -208,7 +257,6 @@ enum ETextureFlags
typedef struct GLMipmap_s FTextureInfo;
// jimita 14032019
struct FLightInfo
{
FUINT light_level;
@@ -225,14 +273,13 @@ struct FSurfaceInfo
RGBA_t TintColor;
RGBA_t FadeColor;
UINT32 LightTableId;
FLightInfo LightInfo; // jimita 14032019
FLightInfo LightInfo;
};
typedef struct FSurfaceInfo FSurfaceInfo;
enum hwdsetspecialstate
{
HWD_SET_SHADERS,
HWD_SET_PALETTE_SHADER_ENABLED,
HWD_SET_TEXTUREFILTERMODE,
HWD_SET_TEXTUREANISOTROPICMODE,
@@ -240,8 +287,6 @@ enum hwdsetspecialstate
HWD_SET_MSAA,
HWD_SET_SCREEN_TEXTURES,
HWD_SET_DEPTH_ONLY_MODE,// for portals
HWD_SET_PORTAL_MODE,// new portal thing
HWD_SET_STENCIL_LEVEL,
@@ -281,4 +326,15 @@ enum hwdfiltermode
HWD_SET_TEXTUREFILTER_MIXED3,
};
// Screen texture slots
enum hwdscreentexture
{
HWD_SCREENTEXTURE_WIPE_START, // source image for the wipe/fade effect
HWD_SCREENTEXTURE_WIPE_END, // destination image for the wipe/fade effect
HWD_SCREENTEXTURE_GENERIC1, // underwater/heat effect, intermission background
HWD_SCREENTEXTURE_GENERIC2, // palette-based colormap fade, final screen texture
NUMSCREENTEXTURES, // (generic3 is unused if palette rendering is disabled)
};
typedef enum hwdscreentexture hwdscreentexture_t;
#endif //_HWR_DEFS_
+68 -26
View File
@@ -122,7 +122,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option)
flags |= PF_ForceWrapY;
// clip it since it is used for bunny scroll in doom I
HWD.pfnDrawPolygon(NULL, v, 4, flags, false);
HWD.pfnDrawPolygon(NULL, v, 4, flags);
}
void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap)
@@ -300,10 +300,10 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags, false);
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags, false);
HWD.pfnDrawPolygon(NULL, v, 4, flags);
}
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h)
@@ -454,10 +454,10 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags, false);
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags, false);
HWD.pfnDrawPolygon(NULL, v, 4, flags);
}
// ==========================================================================
@@ -533,7 +533,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
// BTW, I see we put 0 for PFs, and If I'm right, that
// means we take the previous PFs as default
// how can we be sure they are ok?
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest, false); //PF_Translucent);
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
}
@@ -548,6 +548,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
{
FOutVector v[4];
FSurfaceInfo Surf;
FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest;
v[0].x = v[3].x = -1.0f;
v[2].x = v[1].x = 1.0f;
@@ -562,15 +563,40 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
if (color & 0xFF00) // Do COLORMAP fade.
{
Surf.PolyColor.rgba = UINT2RGBA(0x01010160);
Surf.PolyColor.s.alpha = (strength*8);
if (HWR_ShouldUsePaletteRendering() && cv_grscreentextures.value)
{
const hwdscreentexture_t scr_tex = HWD_SCREENTEXTURE_GENERIC2;
Surf.LightTableId = HWR_GetLightTableID(NULL);
Surf.LightInfo.light_level = strength;
HWD.pfnMakeScreenTexture(scr_tex);
HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_UI_COLORMAP_FADE));
HWD.pfnDrawScreenTexture(scr_tex, &Surf, PF_ColorMapped|PF_NoDepthTest);
HWD.pfnUnSetShader();
return;
}
else
{
Surf.PolyColor.rgba = UINT2RGBA(0x01010160);
Surf.PolyColor.s.alpha = (strength*8);
poly_flags |= PF_Translucent;
}
}
else // Do TRANSMAP** fade.
{
Surf.PolyColor.rgba = pLocalPalette[color].rgba;
Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f);
RGBA_t *palette = HWR_GetTexturePalette();
Surf.PolyColor.rgba = palette[color&0xFF].rgba;
if (HWR_ShouldUsePaletteRendering())
Surf.PolyColor.s.alpha = softwaretranstogl[strength];
else
Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f);
poly_flags |= PF_Translucent;
}
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest, false);
HWD.pfnDrawPolygon(&Surf, v, 4, poly_flags);
}
// Draw the console background with translucency support
@@ -597,7 +623,7 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height)
Surf.PolyColor.rgba = UINT2RGBA(color);
Surf.PolyColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest, false);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
@@ -743,9 +769,10 @@ void HWR_drawAMline(const fline_t *fl, INT32 color)
{
F2DCoord v1, v2;
RGBA_t color_rgba;
color_rgba = V_GetColor(color);
RGBA_t *palette = HWR_GetTexturePalette();
color_rgba = palette[color&0xFF];
v1.x = ((float)fl->a.x-(vid.width/2.0f))*(2.0f/vid.width);
v1.y = ((float)fl->a.y-(vid.height/2.0f))*(2.0f/vid.height);
@@ -763,6 +790,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
FOutVector v[4];
FSurfaceInfo Surf;
float fx, fy, fw, fh, fwait = 0;
RGBA_t *palette = HWR_GetTexturePalette();
if (wh < 0)
return; // consistency w/ software
@@ -843,10 +871,10 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
v[0].t = v[1].t = 0.0f;
v[2].t = v[3].t = 1.0f;
Surf.PolyColor = V_GetColor(color);
Surf.PolyColor = palette[color&0xFF];
HWD.pfnDrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest, false);
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
}
// -------------------+
@@ -857,6 +885,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
FOutVector v[4];
FSurfaceInfo Surf;
float fx, fy, fw, fh;
RGBA_t *palette = HWR_GetTexturePalette();
if (w < 0 || h < 0)
return; // consistency w/ software
@@ -877,7 +906,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT)
{
RGBA_t rgbaColour = V_GetColor(color);
RGBA_t rgbaColour = palette[color&0xFF];
FRGBAFloat clearColour;
clearColour.red = (float)rgbaColour.s.red / 255;
clearColour.green = (float)rgbaColour.s.green / 255;
@@ -954,17 +983,20 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
Surf.PolyColor.rgba = UINT2RGBA(color);
Surf.PolyColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest, false);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
// -----------------+
// HWR_DrawFill : draw flat coloured rectangle, with no texture
// -----------------+
// alug: now with translucency support X)
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
{
FOutVector v[4];
FSurfaceInfo Surf;
float fx, fy, fw, fh;
UINT8 alphalevel = ((color & V_ALPHAMASK) >> V_ALPHASHIFT);
RGBA_t *palette = HWR_GetTexturePalette();
if (w < 0 || h < 0)
return; // consistency w/ software
@@ -985,7 +1017,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT)
{
RGBA_t rgbaColour = V_GetColor(color);
RGBA_t rgbaColour = palette[color&0xFF];
FRGBAFloat clearColour;
clearColour.red = (float)rgbaColour.s.red / 255;
clearColour.green = (float)rgbaColour.s.green / 255;
@@ -1059,10 +1091,17 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
v[0].t = v[1].t = 0.0f;
v[2].t = v[3].t = 1.0f;
Surf.PolyColor = V_GetColor(color);
Surf.PolyColor = palette[color&0xFF];
HWD.pfnDrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest, false);
if (alphalevel)
{
if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans];
else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans];
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
}
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
#ifdef HAVE_PNG
@@ -1138,12 +1177,15 @@ static inline boolean saveTGA(const char *file_name, void *buffer,
UINT8 *HWR_GetScreenshot(void)
{
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
static UINT8 *buf = NULL;
buf = realloc(buf, vid.width * vid.height * 3);
if (!buf)
return NULL;
// returns 24bit 888 RGB
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
HWD.pfnReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
return buf;
}
@@ -1159,7 +1201,7 @@ boolean HWR_Screenshot(const char *pathname)
}
// returns 24bit 888 RGB
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
HWD.pfnReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
#ifdef USE_PNG
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
+34 -41
View File
@@ -28,19 +28,17 @@
// ==========================================================================
EXPORT boolean HWRAPI(Init) (void);
#if defined (PURESDL) || defined (macintosh)
EXPORT void HWRAPI(SetPalette) (INT32 *, RGBA_t *gamma);
#else
EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal, RGBA_t *pgamma);
#endif
EXPORT void HWRAPI(SetupGLInfo) (void);
EXPORT void HWRAPI(SetTexturePalette) (RGBA_t *ppal);
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, boolean horizonSpecial);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data);
EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT16 *dst_data);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
EXPORT void HWRAPI(ClearMipMapCache) (void);
@@ -49,7 +47,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
//Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, FSurfaceInfo *Surface);
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
EXPORT void HWRAPI(SetTransform) (FTransform *stransform);
@@ -58,32 +56,29 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void);
EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform);
EXPORT void HWRAPI(FlushScreenTextures) (void);
EXPORT void HWRAPI(StartScreenWipe) (void);
EXPORT void HWRAPI(EndScreenWipe) (void);
EXPORT void HWRAPI(DoScreenWipe) (void);
EXPORT void HWRAPI(DrawIntermissionBG) (void);
EXPORT void HWRAPI(MakeScreenTexture) (void);
EXPORT void HWRAPI(MakeScreenFinalTexture) (void);
EXPORT void HWRAPI(DrawScreenFinalTexture) (int width, int height);
EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd);
EXPORT void HWRAPI(DrawScreenTexture) (int tex, FSurfaceInfo *surf, FBITFIELD polyflags);
EXPORT void HWRAPI(MakeScreenTexture) (int tex);
EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, int width, int height);
EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
#define SCREENVERTS 10
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
// jimita
EXPORT boolean HWRAPI(LoadShaders) (void);
EXPORT void HWRAPI(KillShaders) (void);
EXPORT void HWRAPI(SetShader) (int shader);
EXPORT boolean HWRAPI(InitShaders) (void);
EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage);
EXPORT boolean HWRAPI(CompileShader) (int slot);
EXPORT void HWRAPI(SetShader) (int slot);
EXPORT void HWRAPI(UnSetShader) (void);
EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value);
EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boolean fragment);
EXPORT boolean HWRAPI(InitCustomShaders) (void);
EXPORT void HWRAPI(StartBatching) (void);
EXPORT void HWRAPI(RenderBatches) (precise_t *sSortTime, precise_t *sDrawTime, int *sNumPolys, int *sNumVerts, int *sNumCalls, int *sNumShaders, int *sNumTextures, int *sNumPolyFlags, int *sNumColors);
EXPORT UINT32 HWRAPI(AddLightTable) (UINT8 *lighttable);
EXPORT void HWRAPI(ClearLightTableCache) (void);
EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut);
EXPORT UINT32 HWRAPI(CreateLightTable)(RGBA_t *hw_lighttable);
EXPORT void HWRAPI(ClearLightTables)(void);
EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette);
// ==========================================================================
// HWR DRIVER OBJECT, FOR CLIENT PROGRAM
@@ -94,15 +89,17 @@ EXPORT void HWRAPI(ClearLightTableCache) (void);
struct hwdriver_s
{
Init pfnInit;
SetPalette pfnSetPalette;
SetupGLInfo pfnSetupGLInfo;
SetTexturePalette pfnSetTexturePalette;
FinishUpdate pfnFinishUpdate;
Draw2DLine pfnDraw2DLine;
DrawPolygon pfnDrawPolygon;
DrawIndexedTriangles pfnDrawIndexedTriangles;
SetBlend pfnSetBlend;
ClearBuffer pfnClearBuffer;
SetTexture pfnSetTexture;
UpdateTexture pfnUpdateTexture;
ReadRect pfnReadRect;
ReadScreenTexture pfnReadScreenTexture;
GClipRect pfnGClipRect;
ClearMipMapCache pfnClearMipMapCache;
SetSpecialState pfnSetSpecialState;
@@ -112,30 +109,26 @@ struct hwdriver_s
GetTextureUsed pfnGetTextureUsed;
PostImgRedraw pfnPostImgRedraw;
FlushScreenTextures pfnFlushScreenTextures;
StartScreenWipe pfnStartScreenWipe;
EndScreenWipe pfnEndScreenWipe;
DoScreenWipe pfnDoScreenWipe;
DrawIntermissionBG pfnDrawIntermissionBG;
DrawScreenTexture pfnDrawScreenTexture;
MakeScreenTexture pfnMakeScreenTexture;
MakeScreenFinalTexture pfnMakeScreenFinalTexture;
RenderVhsEffect pfnRenderVhsEffect;
DrawScreenFinalTexture pfnDrawScreenFinalTexture;
RenderSkyDome pfnRenderSkyDome;
LoadShaders pfnLoadShaders;
KillShaders pfnKillShaders;
InitShaders pfnInitShaders;
LoadShader pfnLoadShader;
CompileShader pfnCompileShader;
SetShader pfnSetShader;
UnSetShader pfnUnSetShader;
SetShaderInfo pfnSetShaderInfo;
LoadCustomShader pfnLoadCustomShader;
InitCustomShaders pfnInitCustomShaders;
StartBatching pfnStartBatching;
RenderBatches pfnRenderBatches;
AddLightTable pfnAddLightTable;
ClearLightTableCache pfnClearLightTableCache;
SetPaletteLookup pfnSetPaletteLookup;
CreateLightTable pfnCreateLightTable;
ClearLightTables pfnClearLightTables;
SetScreenPalette pfnSetScreenPalette;
};
extern struct hwdriver_s hwdriver;
@@ -144,4 +137,4 @@ extern struct hwdriver_s hwdriver;
#endif //not defined _CREATE_DLL_
#endif //__HWR_DRV_H__
#endif //__HWR_DRV_H__
+19
View File
@@ -68,6 +68,11 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap);
void HWR_MakePatch(patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap);
void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
void HWR_SetPalette(RGBA_t *palette);
void HWR_SetMapPalette(void);
UINT32 HWR_CreateLightTable(UINT8 *lighttable);
UINT32 HWR_GetLightTableID(extracolormap_t *colormap);
void HWR_ClearLightTables(void);
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump);
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
@@ -90,4 +95,18 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector,
void HWR_RenderDrawNodes(void);
// --------
// hw_shaders.c
// --------
boolean HWR_InitShaders(void);
void HWR_CompileShaders(void);
int HWR_GetShaderFromTarget(int shader_target);
void HWR_LoadAllCustomShaders(void);
void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3);
const char *HWR_GetShaderName(INT32 shader);
extern customshaderxlat_t shaderxlat[];
#endif //_HW_GLOB_
+852 -875
View File
File diff suppressed because it is too large. Load diff
+21 -10
View File
@@ -64,6 +64,8 @@ extern ps_metric_t ps_hw_numcolors;
extern ps_metric_t ps_hw_batchsorttime;
extern ps_metric_t ps_hw_batchdrawtime;
extern boolean gr_shadersavailable;
// hw_draw.c
void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option);
void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap);
@@ -83,12 +85,16 @@ boolean HWR_Screenshot(const char *lbmname);
// hw_main.c
void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox);
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
void HWR_LoadShaders(UINT16 wadnum, boolean PK3);
void HWR_SetViewSize(void);
void HWR_AddCommands(void);
void HWR_SetTransform(float fpov, player_t *player);
void HWR_ClearClipper(void);
boolean HWR_UseShader(void);
boolean HWR_ShouldUsePaletteRendering(void);
boolean HWR_PalRenderFlashpal(void);
void HWR_TogglePaletteRendering(void);
// My original intention was to split hw_main.c
// into files like hw_bsp.c, hw_sprites.c...
@@ -107,11 +113,12 @@ void HWR_StartScreenWipe(void);
void HWR_EndScreenWipe(void);
void HWR_DrawIntermissionBG(void);
void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum);
void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
void HWR_MakeScreenFinalTexture(void);
void HWR_DrawScreenFinalTexture(int width, int height);
// hw_main.c: Planes
void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap, subsector_t *subsector);
void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
#ifdef POLYOBJECTS
@@ -127,7 +134,7 @@ void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom
void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap);
void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags);
// moved HWR_SplitWall to hw_main.c
void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf);
void HWR_DrawSkyBackground(float fpov);
@@ -142,8 +149,6 @@ void HWR_AddLine(seg_t *line);
boolean HWR_CheckBBox(fixed_t *bspcoord);
void HWR_RenderDrawNodes(void);
void HWR_ClearLightTableCache(void);
// hw_main.c: Sprites
void HWR_AddSprites(sector_t *sec);
void HWR_ProjectSprite(mobj_t *thing);
@@ -156,20 +161,24 @@ extern boolean gr_maphasportals;
// hw_cache.c
void HWR_PrepLevelCache(size_t pnumtextures);
RGBA_t *HWR_GetTexturePalette(void);
// hw_trick.c
void HWR_CorrectSWTricks(void);
void HWR_SetShaderState(void);
// Console variables
extern consvar_t cv_grshaders;
extern consvar_t cv_grfofcut;
extern consvar_t cv_fofzfightfix;
extern consvar_t cv_splitwallfix;
extern consvar_t cv_slopepegfix;
extern consvar_t cv_grshearing;
extern consvar_t cv_grfov;
extern consvar_t cv_grmdls;
extern consvar_t cv_grfog;
extern consvar_t cv_grfogdensity;
extern consvar_t cv_grgammared;
extern consvar_t cv_grgammagreen;
extern consvar_t cv_grgammablue;
extern consvar_t cv_grfiltermode;
extern consvar_t cv_granisotropicmode;
extern consvar_t cv_grcorrecttricks;
@@ -178,12 +187,14 @@ extern consvar_t cv_grsolvetjoin;
extern consvar_t cv_grspritebillboarding;
extern consvar_t cv_grfakecontrast;
extern consvar_t cv_grslopecontrast;
extern consvar_t cv_grhorizonlines;
extern consvar_t cv_grfallbackplayermodel;
extern consvar_t cv_grbatching;
extern consvar_t cv_grrenderdistance;
extern consvar_t cv_grusecustomshaders;
extern consvar_t cv_grpaletteshader;
extern consvar_t cv_grpaletterendering;
extern consvar_t cv_grpalettedepth;
extern consvar_t cv_grflashpal;
extern consvar_t cv_grscreentextures;
extern consvar_t cv_grportals;
extern consvar_t cv_nostencil;
extern consvar_t cv_secbright;
+52 -13
View File
@@ -1149,6 +1149,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
INT32 tics = spr->mobj->tics;
//mdlframe_t *next = NULL;
const UINT8 flip = (UINT8)((spr->mobj->eflags & MFE_VERTICALFLIP) == MFE_VERTICALFLIP);
const UINT8 hflip = (UINT8)(!(spr->mobj->mirrored) != !(spr->mobj->frame & FF_HORIZONTALFLIP));
spritedef_t *sprdef;
spriteframe_t *sprframe;
spriteinfo_t *sprinfo;
@@ -1366,17 +1367,16 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
angle_t sliptideroll = 0;
if (spr->mobj->player)
sliptideroll = ((cv_sloperoll.value) ? spr->mobj->player->sliproll : 0);
sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value) ? spr->mobj->player->sliproll : 0);
if ((spr->mobj->rollangle)||sliptideroll)
if ((spr->mobj->rollangle)||(sliptideroll && cv_sliptideroll.value))
{
angle_t rollang = 0;
rollfactor = ((spr->mobj->rollmodel == true) ? 1 : 0);
if (spr->mobj->player)
rollang = (spr->mobj->rollangle*rollfactor) + (sliptideroll*spr->mobj->player->sliptidemem);
else
rollang = (spr->mobj->rollangle*rollfactor);
rollang = (spr->mobj->player && sliptideroll && cv_sliptideroll.value)
? (spr->mobj->rollangle * rollfactor) + (sliptideroll * spr->mobj->player->sliptidemem)
: (spr->mobj->rollangle * rollfactor);
fixed_t anglef = AngleFixed(rollang);
p.rollangle = FIXED_TO_FLOAT(anglef);
@@ -1401,18 +1401,55 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
p.anglex = 0.0f;
p.anglex2 = 0.0f;
#ifdef USE_FTRANSFORM_ANGLEZ
// Slope rotation from Kart
p.anglez = 0.0f;
p.anglez2 = 0.0f;
// use secondary angles for the slope rotation
if (spr->mobj->standingslope)
{
fixed_t tempz = spr->mobj->standingslope->normal.z;
fixed_t tempy = spr->mobj->standingslope->normal.y;
fixed_t tempx = spr->mobj->standingslope->normal.x;
fixed_t tempangle = AngleFixed(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx));
p.anglez = FIXED_TO_FLOAT(tempangle);
p.anglez2 = FIXED_TO_FLOAT(tempangle);
tempangle = -AngleFixed(R_PointToAngle2(0, 0, tempz, tempy));
p.anglex = FIXED_TO_FLOAT(tempangle);
p.anglex2 = FIXED_TO_FLOAT(tempangle);
}
else if ((spr->mobj->sloperoll || spr->mobj->slopepitch) && (!P_IsObjectOnGround(spr->mobj)) && (!paused))
{
SINT8 flipfactor = flip ? -1 : 1;
angle_t camang = R_PointToAngle(interp.x, interp.y);
angle_t mobjang;
if (spr->mobj->flags & (MF_NOTHINK|MF_SCENERY))
mobjang = spr->mobj->angle;
else
mobjang = interp.angle;
angle_t fmoang;
fmoang = camang - mobjang;
// slopepitch
p.anglex += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINESINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.slopepitch)) );
p.anglez -= flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINECOSINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.slopepitch)) );
// sloperoll
p.anglex += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINECOSINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.sloperoll)) );
p.anglez += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINESINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.sloperoll)) );
p.roll = true;
}
// pitch and roll
if (interp.roll || interp.pitch)
{
SINT8 flipfactor = flip ? -1 : 1;
p.anglex += flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.roll));
p.anglez -= flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.pitch));
p.roll = true;
}
#endif
@@ -1421,22 +1458,24 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
p.mirror = atransform.mirror; // from Kart
#endif
HWD.pfnSetShader(4); // model shader
HWD.pfnSetShader(SHADER_MODEL); // model shader
{
float this_scale = FIXED_TO_FLOAT(interp.scale);
SINT8 flipfactor = flip ? -1 : 1;
float this_scale = FIXED_TO_FLOAT(interp.scale);
float xs = this_scale * FIXED_TO_FLOAT(interp.spritexscale);
float ys = this_scale * FIXED_TO_FLOAT(interp.spriteyscale);
float ox = xs * FIXED_TO_FLOAT(interp.spritexoffset);
float oy = ys * FIXED_TO_FLOAT(interp.spriteyoffset);
float ox = xs * flipfactor*FIXED_TO_FLOAT(interp.spritexoffset);
float oy = ys * flipfactor*FIXED_TO_FLOAT(interp.spriteyoffset);
// offset perpendicular to the camera angle
p.x -= ox * gr_viewsin;
p.y += ox * gr_viewcos;
p.z += oy;
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, &Surf);
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf);
}
}
}
+630
View File
@@ -0,0 +1,630 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2021 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_shaders.c
/// \brief Handles the shaders used by the game.
#ifdef HWRENDER
#include "hw_main.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "hw_shaders.h"
#include "../z_zone.h"
// ================
// Shader sources
// ================
static struct {
const char *vertex;
const char *fragment;
} const gl_shadersources[] = {
// Floor shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER},
// Wall shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
// Sprite shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
// Model shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
// Water shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER},
// Fog shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_FOG_FRAGMENT_SHADER},
// Sky shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SKY_FRAGMENT_SHADER},
// Palette postprocess shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_PALETTE_POSTPROCESS_FRAGMENT_SHADER},
// UI colormap fade shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_UI_COLORMAP_FADE_FRAGMENT_SHADER},
{NULL, NULL},
};
typedef struct
{
int base_shader; // index of base shader_t
int custom_shader; // index of custom shader_t
} shadertarget_t;
typedef struct
{
char *vertex;
char *fragment;
boolean compiled;
} shader_t; // these are in an array and accessed by indices
// the array has NUMSHADERTARGETS entries for base shaders and for custom shaders
// the array could be expanded in the future to fit "dynamic" custom shaders that
// aren't fixed to shader targets
static shader_t gl_shaders[NUMSHADERTARGETS*2];
static shadertarget_t gl_shadertargets[NUMSHADERTARGETS];
#define WHITESPACE_CHARS " \t"
#define PALETTE_RENDERING_DEFINE "#define SRB2_PALETTE_RENDERING"
// Initialize shader variables and the backend's shader system. Load the base shaders.
// Returns false if shaders cannot be used.
boolean HWR_InitShaders(void)
{
int i;
if (!HWD.pfnInitShaders())
return false;
for (i = 0; i < NUMSHADERTARGETS; i++)
{
// set up string pointers for base shaders
gl_shaders[i].vertex = Z_StrDup(gl_shadersources[i].vertex);
gl_shaders[i].fragment = Z_StrDup(gl_shadersources[i].fragment);
// set shader target indices to correct values
gl_shadertargets[i].base_shader = i;
gl_shadertargets[i].custom_shader = -1;
}
HWR_CompileShaders();
return true;
}
// helper function: strstr but returns an int with the substring position
// returns INT32_MAX if not found
static INT32 strstr_int(const char *str1, const char *str2)
{
char *location = strstr(str1, str2);
if (location)
return location - str1;
else
return INT32_MAX;
}
// Creates a preprocessed copy of the shader according to the current graphics settings
// Returns a pointer to the results on success and NULL on failure.
// Remember memory management of the returned string.
static char *HWR_PreprocessShader(char *original)
{
const char *line_ending = "\n";
int line_ending_len;
char *read_pos = original;
int original_len = strlen(original);
int distance_to_end = original_len;
int new_len;
char *new_shader;
char *write_pos;
char shader_glsl_version[3];
int version_pos = -1;
int version_len = 0;
if (strstr(original, "\r\n"))
{
line_ending = "\r\n";
// check if all line endings are same
while ((read_pos = strchr(read_pos, '\n')))
{
read_pos--;
if (*read_pos != '\r')
{
// this file contains mixed CRLF and LF line endings.
// treating it as a LF file during parsing should keep
// the results sane enough as long as the gpu driver is fine
// with these kinds of weirdly formatted shader sources.
line_ending = "\n";
break;
}
read_pos += 2;
}
read_pos = original;
}
line_ending_len = strlen(line_ending);
// Find the #version directive, if it exists. Also don't get fooled if it's
// inside a comment. Copy the version digits so they can be used in the preamble.
// Time for some string parsing :D
#define STARTSWITH(str, with_what) !strncmp(str, with_what, sizeof(with_what)-1)
#define ADVANCE(amount) read_pos += (amount); distance_to_end -= (amount);
while (true)
{
// we're at the start of a line or at the end of a block comment.
// first get any possible whitespace out of the way
int whitespace_len = strspn(read_pos, WHITESPACE_CHARS);
if (whitespace_len == distance_to_end)
break; // we got to the end
ADVANCE(whitespace_len)
if (STARTSWITH(read_pos, "#version"))
{
// found a version directive (and it's not inside a comment)
// now locate, verify and read the version number
int version_number_len;
version_pos = read_pos - original;
ADVANCE(sizeof("#version") - 1)
whitespace_len = strspn(read_pos, WHITESPACE_CHARS);
if (!whitespace_len)
{
CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Syntax error in #version. Expected space after #version, but got other text.\n");
return NULL;
}
else if (whitespace_len == distance_to_end)
{
CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Syntax error in #version. Expected version number, but got end of file.\n");
return NULL;
}
ADVANCE(whitespace_len)
version_number_len = strspn(read_pos, "0123456789");
if (!version_number_len)
{
CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Syntax error in #version. Expected version number, but got other text.\n");
return NULL;
}
else if (version_number_len != 3)
{
CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Syntax error in #version. Expected version with 3 digits, but got %d digits.\n", version_number_len);
return NULL;
}
M_Memcpy(shader_glsl_version, read_pos, 3);
ADVANCE(version_number_len)
version_len = (read_pos - original) - version_pos;
whitespace_len = strspn(read_pos, WHITESPACE_CHARS);
ADVANCE(whitespace_len)
if (STARTSWITH(read_pos, "es"))
{
CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Support for ES shaders is not implemented.\n");
return NULL;
}
break;
}
else
{
// go to next newline or end of next block comment if it starts before the newline
// and is not inside a line comment
INT32 newline_pos = strstr_int(read_pos, line_ending);
INT32 line_comment_pos;
INT32 block_comment_pos;
// optimization: temporarily put a null at the line ending, so strstr does not needlessly
// look past it since we're only interested in the current line
if (newline_pos != INT32_MAX)
read_pos[newline_pos] = '\0';
line_comment_pos = strstr_int(read_pos, "//");
block_comment_pos = strstr_int(read_pos, "/*");
// restore the line ending, remove the null we just put there
if (newline_pos != INT32_MAX)
read_pos[newline_pos] = line_ending[0];
if (line_comment_pos < block_comment_pos)
{
// line comment found, skip rest of the line
if (newline_pos != INT32_MAX)
{
ADVANCE(newline_pos + line_ending_len)
}
else
{
// we got to the end
break;
}
}
else if (block_comment_pos < line_comment_pos)
{
// block comment found, skip past it
INT32 block_comment_end;
ADVANCE(block_comment_pos + 2)
block_comment_end = strstr_int(read_pos, "*/");
if (block_comment_end == INT32_MAX)
{
// could also leave insertion_pos at 0 and let the GLSL compiler
// output an error message for this broken comment
CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Encountered unclosed block comment in shader.\n");
return NULL;
}
ADVANCE(block_comment_end + 2)
}
else if (newline_pos == INT32_MAX)
{
// we got to the end
break;
}
else
{
// nothing special on this line, move to the next one
ADVANCE(newline_pos + line_ending_len)
}
}
}
#undef STARTSWITH
#undef ADVANCE
#define ADD_TO_LEN(def) new_len += sizeof(def) - 1 + line_ending_len;
// Calculate length of modified shader.
new_len = original_len;
if (cv_grpaletterendering.value)
ADD_TO_LEN(PALETTE_RENDERING_DEFINE)
#undef ADD_TO_LEN
#define VERSION_PART "#version "
if (new_len != original_len)
{
if (version_pos != -1)
new_len += sizeof(VERSION_PART) - 1 + 3 + line_ending_len;
new_len += sizeof("#line 0") - 1 + line_ending_len;
}
// Allocate memory for modified shader.
new_shader = Z_Malloc(new_len + 1, PU_STATIC, NULL);
read_pos = original;
write_pos = new_shader;
if (new_len != original_len && version_pos != -1)
{
strcpy(write_pos, VERSION_PART);
write_pos += sizeof(VERSION_PART) - 1;
M_Memcpy(write_pos, shader_glsl_version, 3);
write_pos += 3;
strcpy(write_pos, line_ending);
write_pos += line_ending_len;
}
#undef VERSION_PART
#define WRITE_DEFINE(define) \
{ \
strcpy(write_pos, define); \
write_pos += sizeof(define) - 1; \
strcpy(write_pos, line_ending); \
write_pos += line_ending_len; \
}
// Write the defines.
if (cv_grpaletterendering.value)
WRITE_DEFINE(PALETTE_RENDERING_DEFINE)
#undef WRITE_DEFINE
// Write a #line directive, so compiler errors will report line numbers from the
// original shader without our preamble lines.
if (new_len != original_len)
{
// line numbering in the #line directive is different for versions 110-150
if (version_pos == -1 || shader_glsl_version[0] == '1')
strcpy(write_pos, "#line 0");
else
strcpy(write_pos, "#line 1");
write_pos += sizeof("#line 0") - 1;
strcpy(write_pos, line_ending);
write_pos += line_ending_len;
}
// Copy the original shader.
M_Memcpy(write_pos, read_pos, original_len);
// Erase the original #version directive, if it exists and was copied.
if (new_len != original_len && version_pos != -1)
memset(write_pos + version_pos, ' ', version_len);
// Terminate the new string.
new_shader[new_len] = '\0';
return new_shader;
}
// preprocess and compile shader at gl_shaders[index]
static void HWR_CompileShader(int index)
{
char *vertex_source = gl_shaders[index].vertex;
char *fragment_source = gl_shaders[index].fragment;
if (vertex_source)
{
char *preprocessed = HWR_PreprocessShader(vertex_source);
if (!preprocessed) return;
HWD.pfnLoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX);
}
if (fragment_source)
{
char *preprocessed = HWR_PreprocessShader(fragment_source);
if (!preprocessed) return;
HWD.pfnLoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT);
}
gl_shaders[index].compiled = HWD.pfnCompileShader(index);
}
// compile or recompile shaders
void HWR_CompileShaders(void)
{
int i;
for (i = 0; i < NUMSHADERTARGETS; i++)
{
int custom_index = gl_shadertargets[i].custom_shader;
HWR_CompileShader(i);
if (!gl_shaders[i].compiled)
CONS_Alert(CONS_ERROR, "HWR_CompileShaders: Compilation failed for base %s shader!\n", shaderxlat[i].type);
if (custom_index != -1)
{
HWR_CompileShader(custom_index);
if (!gl_shaders[custom_index].compiled)
CONS_Alert(CONS_ERROR, "HWR_CompileShaders: Recompilation failed for the custom %s shader! See the console messages above for more information.\n", shaderxlat[i].type);
}
}
}
int HWR_GetShaderFromTarget(int shader_target)
{
int custom_shader = gl_shadertargets[shader_target].custom_shader;
// use custom shader if following are true
// - custom shader exists
// - custom shader has been compiled successfully
// - custom shaders are enabled
// - custom shaders are allowed by the server
if (custom_shader != -1 && gl_shaders[custom_shader].compiled &&
cv_grshaders.value == 1)
return custom_shader;
else
return gl_shadertargets[shader_target].base_shader;
}
static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum)
{
UINT16 i;
lumpinfo_t *lump_p;
lump_p = wadfiles[wadnum]->lumpinfo;
for (i = 0; i < wadfiles[wadnum]->numlumps; i++, lump_p++)
if (memcmp(lump_p->name, "SHADERS", 7) == 0)
return i;
return INT16_MAX;
}
customshaderxlat_t shaderxlat[] =
{
{"Flat", SHADER_FLOOR},
{"WallTexture", SHADER_WALL},
{"Sprite", SHADER_SPRITE},
{"Model", SHADER_MODEL},
{"WaterRipple", SHADER_WATER},
{"Fog", SHADER_FOG},
{"Sky", SHADER_SKY},
{"PalettePostprocess", SHADER_PALETTE_POSTPROCESS},
{"UIColormapFade", SHADER_UI_COLORMAP_FADE},
{NULL, 0},
};
void HWR_LoadAllCustomShaders(void)
{
INT32 i;
// read every custom shader
for (i = 0; i < numwadfiles; i++)
HWR_LoadCustomShadersFromFile(i, (wadfiles[i]->type == RET_PK3));
}
void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
{
UINT16 lump;
char *shaderdef, *line;
char *stoken;
char *value;
size_t size;
int linenum = 1;
int shadertype = 0;
int i;
boolean modified_shaders[NUMSHADERTARGETS] = {0};
if (!HWR_UseShader())
return;
lump = HWR_FindShaderDefs(wadnum);
if (lump == INT16_MAX)
return;
shaderdef = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
size = W_LumpLengthPwad(wadnum, lump);
line = Z_Malloc(size+1, PU_STATIC, NULL);
M_Memcpy(line, shaderdef, size);
line[size] = '\0';
stoken = strtok(line, "\r\n ");
while (stoken)
{
if ((stoken[0] == '/' && stoken[1] == '/')
|| (stoken[0] == '#'))// skip comments
{
stoken = strtok(NULL, "\r\n");
goto skip_field;
}
if (!stricmp(stoken, "GLSL"))
{
value = strtok(NULL, "\r\n ");
if (!value)
{
CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_lump;
}
if (!stricmp(value, "VERTEX"))
shadertype = 1;
else if (!stricmp(value, "FRAGMENT"))
shadertype = 2;
skip_lump:
stoken = strtok(NULL, "\r\n ");
linenum++;
}
else
{
value = strtok(NULL, "\r\n= ");
if (!value)
{
CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_field;
}
if (!shadertype)
{
CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
Z_Free(line);
return;
}
for (i = 0; shaderxlat[i].type; i++)
{
if (!stricmp(shaderxlat[i].type, stoken))
{
size_t shader_string_length;
char *shader_source;
char *shader_lumpname;
UINT16 shader_lumpnum;
int shader_index; // index in gl_shaders
if (PK3)
{
shader_lumpname = Z_Malloc(strlen(value) + 12, PU_STATIC, NULL);
strcpy(shader_lumpname, "Shaders/sh_");
strcat(shader_lumpname, value);
shader_lumpnum = W_CheckNumForFullNamePK3(shader_lumpname, wadnum, 0);
}
else
{
shader_lumpname = Z_Malloc(strlen(value) + 4, PU_STATIC, NULL);
strcpy(shader_lumpname, "SH_");
strcat(shader_lumpname, value);
shader_lumpnum = W_CheckNumForNamePwad(shader_lumpname, wadnum, 0);
}
if (shader_lumpnum == INT16_MAX)
{
CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
Z_Free(shader_lumpname);
continue;
}
shader_string_length = W_LumpLengthPwad(wadnum, shader_lumpnum) + 1;
shader_source = Z_Malloc(shader_string_length, PU_STATIC, NULL);
W_ReadLumpPwad(wadnum, shader_lumpnum, shader_source);
shader_source[shader_string_length-1] = '\0';
shader_index = shaderxlat[i].id + NUMSHADERTARGETS;
if (!modified_shaders[shaderxlat[i].id])
{
// this will clear any old custom shaders from previously loaded files
// Z_Free checks if the pointer is NULL!
Z_Free(gl_shaders[shader_index].vertex);
gl_shaders[shader_index].vertex = NULL;
Z_Free(gl_shaders[shader_index].fragment);
gl_shaders[shader_index].fragment = NULL;
}
modified_shaders[shaderxlat[i].id] = true;
if (shadertype == 1)
{
if (gl_shaders[shader_index].vertex)
{
CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: %s is overwriting another %s vertex shader from the same addon! (file %s, line %d)\n", shader_lumpname, shaderxlat[i].type, wadfiles[wadnum]->filename, linenum);
Z_Free(gl_shaders[shader_index].vertex);
}
gl_shaders[shader_index].vertex = shader_source;
}
else
{
if (gl_shaders[shader_index].fragment)
{
CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: %s is overwriting another %s fragment shader from the same addon! (file %s, line %d)\n", shader_lumpname, shaderxlat[i].type, wadfiles[wadnum]->filename, linenum);
Z_Free(gl_shaders[shader_index].fragment);
}
gl_shaders[shader_index].fragment = shader_source;
}
Z_Free(shader_lumpname);
}
}
skip_field:
stoken = strtok(NULL, "\r\n= ");
linenum++;
}
}
for (i = 0; i < NUMSHADERTARGETS; i++)
{
if (modified_shaders[i])
{
int shader_index = i + NUMSHADERTARGETS; // index to gl_shaders
gl_shadertargets[i].custom_shader = shader_index;
// if only one stage (vertex/fragment) is defined, the other one
// is copied from the base shaders.
if (!gl_shaders[shader_index].fragment)
gl_shaders[shader_index].fragment = Z_StrDup(gl_shadersources[i].fragment);
if (!gl_shaders[shader_index].vertex)
gl_shaders[shader_index].vertex = Z_StrDup(gl_shadersources[i].vertex);
HWR_CompileShader(shader_index);
if (!gl_shaders[shader_index].compiled)
CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: A compilation error occured for the %s shader in file %s. See the console messages above for more information.\n", shaderxlat[i].type, wadfiles[wadnum]->filename);
}
}
Z_Free(line);
return;
}
const char *HWR_GetShaderName(INT32 shader)
{
INT32 i;
for (i = 0; shaderxlat[i].type; i++)
{
if (shaderxlat[i].id == shader)
return shaderxlat[i].type;
}
return "Unknown";
}
#endif // HWRENDER
+298
View File
@@ -0,0 +1,298 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2021 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_shaders.h
/// \brief Handles the shaders used by the game.
#ifndef _HW_SHADERS_H_
#define _HW_SHADERS_H_
#include "../doomtype.h"
// ================
// Vertex shaders
// ================
//
// Generic vertex shader
//
#define GLSL_DEFAULT_VERTEX_SHADER \
"void main()\n" \
"{\n" \
"gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \
"gl_FrontColor = gl_Color;\n" \
"gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \
"gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \
"}\0"
// ==================
// Fragment shaders
// ==================
//
// Generic fragment shader
//
#define GLSL_DEFAULT_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"void main(void) {\n" \
"gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \
"}\0"
//
// Software fragment shader
//
// Include GLSL_FLOOR_FUDGES or GLSL_WALL_FUDGES or define the fudges in shaders that use this macro.
#define GLSL_DOOM_COLORMAP \
"float R_DoomColormap(float light, float z)\n" \
"{\n" \
"float lightnum = clamp(light / 17.0, 0.0, 15.0);\n" \
"float lightz = clamp(z / 16.0, 0.0, 127.0);\n" \
"float startmap = (15.0 - lightnum) * 4.0;\n" \
"float scale = 160.0 / (lightz + 1.0);\n" \
"float cap = (155.0 - light) * 0.26;\n" \
"return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \
"}\n"
// lighting cap adjustment:
// first num (155.0), increase to make it start to go dark sooner
// second num (0.26), increase to make it go dark faster
#define GLSL_DOOM_LIGHT_EQUATION \
"float R_DoomLightingEquation(float light)\n" \
"{\n" \
"float z = gl_FragCoord.z / gl_FragCoord.w;\n" \
"float colormap = floor(R_DoomColormap(light, z)) + 0.5;\n" \
"return clamp(colormap, 0.0, 31.0) / 32.0;\n" \
"}\n"
#define GLSL_SOFTWARE_TINT_EQUATION \
"if (tint_color.a > 0.0) {\n" \
"float color_bright = sqrt((base_color.r * base_color.r) + (base_color.g * base_color.g) + (base_color.b * base_color.b));\n" \
"float strength = sqrt(9.0 * tint_color.a);\n" \
"final_color.r = clamp((color_bright * (tint_color.r * strength)) + (base_color.r * (1.0 - strength)), 0.0, 1.0);\n" \
"final_color.g = clamp((color_bright * (tint_color.g * strength)) + (base_color.g * (1.0 - strength)), 0.0, 1.0);\n" \
"final_color.b = clamp((color_bright * (tint_color.b * strength)) + (base_color.b * (1.0 - strength)), 0.0, 1.0);\n" \
"}\n"
#define GLSL_SOFTWARE_FADE_EQUATION \
"float darkness = R_DoomLightingEquation(lighting);\n" \
"if (fade_start != 0.0 || fade_end != 31.0) {\n" \
"float fs = fade_start / 31.0;\n" \
"float fe = fade_end / 31.0;\n" \
"float fd = fe - fs;\n" \
"darkness = clamp((darkness - fs) * (1.0 / fd), 0.0, 1.0);\n" \
"}\n" \
"final_color = mix(final_color, fade_color, darkness);\n"
#define GLSL_PALETTE_RENDERING \
"float tex_pal_idx = texture3D(palette_lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0;\n" \
"float z = gl_FragCoord.z / gl_FragCoord.w;\n" \
"float light_y = clamp(floor(R_DoomColormap(lighting, z)), 0.0, 31.0);\n" \
"vec2 lighttable_coord = vec2((tex_pal_idx + 0.5) / 256.0, (light_y + 0.5) / 32.0);\n" \
"vec4 final_color = texture2D(lighttable_tex, lighttable_coord);\n" \
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
#define GLSL_SOFTWARE_FRAGMENT_SHADER \
"#ifdef SRB2_PALETTE_RENDERING\n" \
"uniform sampler2D tex;\n" \
"uniform sampler3D palette_lookup_tex;\n" \
"uniform sampler2D lighttable_tex;\n" \
"uniform vec4 poly_color;\n" \
"uniform float lighting;\n" \
GLSL_DOOM_COLORMAP \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
GLSL_PALETTE_RENDERING \
"}\n" \
"#else\n" \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"uniform vec4 tint_color;\n" \
"uniform vec4 fade_color;\n" \
"uniform float lighting;\n" \
"uniform float fade_start;\n" \
"uniform float fade_end;\n" \
GLSL_DOOM_COLORMAP \
GLSL_DOOM_LIGHT_EQUATION \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"vec4 base_color = texel * poly_color;\n" \
"vec4 final_color = base_color;\n" \
GLSL_SOFTWARE_TINT_EQUATION \
GLSL_SOFTWARE_FADE_EQUATION \
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
"}\n" \
"#endif\0"
// hand tuned adjustments for light level calculation
#define GLSL_FLOOR_FUDGES \
"#define STARTMAP_FUDGE 1.06\n" \
"#define SCALE_FUDGE 1.15\n"
#define GLSL_WALL_FUDGES \
"#define STARTMAP_FUDGE 1.05\n" \
"#define SCALE_FUDGE 2.2\n"
#define GLSL_FLOOR_FRAGMENT_SHADER \
GLSL_FLOOR_FUDGES \
GLSL_SOFTWARE_FRAGMENT_SHADER
#define GLSL_WALL_FRAGMENT_SHADER \
GLSL_WALL_FUDGES \
GLSL_SOFTWARE_FRAGMENT_SHADER
//
// Water surface shader
//
// Mostly guesstimated, rather than the rest being built off Software science.
// Still needs to distort things underneath/around the water...
//
#define GLSL_WATER_TEXEL \
"float water_z = (gl_FragCoord.z / gl_FragCoord.w) / 2.0;\n" \
"float a = -pi * (water_z * freq) + (leveltime * speed);\n" \
"float sdistort = sin(a) * amp;\n" \
"float cdistort = cos(a) * amp;\n" \
"vec4 texel = texture2D(tex, vec2(gl_TexCoord[0].s - sdistort, gl_TexCoord[0].t - cdistort));\n"
#define GLSL_WATER_FRAGMENT_SHADER \
GLSL_FLOOR_FUDGES \
"const float freq = 0.025;\n" \
"const float amp = 0.025;\n" \
"const float speed = 2.0;\n" \
"const float pi = 3.14159;\n" \
"#ifdef SRB2_PALETTE_RENDERING\n" \
"uniform sampler2D tex;\n" \
"uniform sampler3D palette_lookup_tex;\n" \
"uniform sampler2D lighttable_tex;\n" \
"uniform vec4 poly_color;\n" \
"uniform float lighting;\n" \
"uniform float leveltime;\n" \
GLSL_DOOM_COLORMAP \
"void main(void) {\n" \
GLSL_WATER_TEXEL \
GLSL_PALETTE_RENDERING \
"}\n" \
"#else\n" \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"uniform vec4 tint_color;\n" \
"uniform vec4 fade_color;\n" \
"uniform float lighting;\n" \
"uniform float fade_start;\n" \
"uniform float fade_end;\n" \
"uniform float leveltime;\n" \
GLSL_DOOM_COLORMAP \
GLSL_DOOM_LIGHT_EQUATION \
"void main(void) {\n" \
GLSL_WATER_TEXEL \
"vec4 base_color = texel * poly_color;\n" \
"vec4 final_color = base_color;\n" \
GLSL_SOFTWARE_TINT_EQUATION \
GLSL_SOFTWARE_FADE_EQUATION \
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
"}\n" \
"#endif\0"
//
// Fog block shader
//
// Alpha of the planes themselves are still slightly off -- see HWR_FogBlockAlpha
//
// The floor fudges are used, but should the wall fudges be used instead? or something inbetween?
// or separate values for floors and walls? (need to change more than this shader for that)
#define GLSL_FOG_FRAGMENT_SHADER \
GLSL_FLOOR_FUDGES \
"uniform vec4 tint_color;\n" \
"uniform vec4 fade_color;\n" \
"uniform float lighting;\n" \
"uniform float fade_start;\n" \
"uniform float fade_end;\n" \
GLSL_DOOM_COLORMAP \
GLSL_DOOM_LIGHT_EQUATION \
"void main(void) {\n" \
"vec4 base_color = gl_Color;\n" \
"vec4 final_color = base_color;\n" \
GLSL_SOFTWARE_TINT_EQUATION \
GLSL_SOFTWARE_FADE_EQUATION \
"gl_FragColor = final_color;\n" \
"}\0"
//
// Sky fragment shader
// Modulates poly_color with gl_Color
//
#define GLSL_SKY_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"void main(void) {\n" \
"gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * gl_Color * poly_color;\n" \
"}\0"
// Shader for the palette rendering postprocess step
#define GLSL_PALETTE_POSTPROCESS_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform sampler3D palette_lookup_tex;\n" \
"uniform sampler1D palette_tex;\n" \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"float tex_pal_idx = texture3D(palette_lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0;\n" \
"float palette_coord = (tex_pal_idx + 0.5) / 256.0;\n" \
"vec4 final_color = texture1D(palette_tex, palette_coord);\n" \
"gl_FragColor = final_color;\n" \
"}\0"
// Applies a palettized colormap fade to tex
#define GLSL_UI_COLORMAP_FADE_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform float lighting;\n" \
"uniform sampler3D palette_lookup_tex;\n" \
"uniform sampler2D lighttable_tex;\n" \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"float tex_pal_idx = texture3D(palette_lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0;\n" \
"vec2 lighttable_coord = vec2((tex_pal_idx + 0.5) / 256.0, (lighting + 0.5) / 32.0);\n" \
"gl_FragColor = texture2D(lighttable_tex, lighttable_coord);\n" \
"}\0" \
// ================
// Fallback shaders
// ================
//
// Generic vertex shader
//
#define GLSL_FALLBACK_VERTEX_SHADER \
"void main()\n" \
"{\n" \
"gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \
"gl_FrontColor = gl_Color;\n" \
"gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \
"gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \
"}\0"
//
// Generic fragment shader
//
#define GLSL_FALLBACK_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"void main(void) {\n" \
"gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \
"}\0"
#endif
+5 -15
View File
@@ -117,7 +117,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module
#define pwglDeleteContext wglDeleteContext;
#define pwglMakeCurrent wglMakeCurrent;
#else
static HMODULE OGL32, GLU32;
static HMODULE OGL32;
typedef void *(WINAPI *PFNwglGetProcAddress) (const char *);
static PFNwglGetProcAddress pwglGetProcAddress;
typedef HGLRC (WINAPI *PFNwglCreateContext) (HDC hdc);
@@ -132,13 +132,6 @@ static PFNwglMakeCurrent pwglMakeCurrent;
void *GetGLFunc(const char *proc)
{
void *func = NULL;
if (strncmp(proc, "glu", 3) == 0)
{
if (GLU32)
func = GetProcAddress(GLU32, proc);
else
return NULL;
}
if (pwglGetProcAddress)
func = pwglGetProcAddress(proc);
if (!func)
@@ -155,8 +148,6 @@ boolean LoadGL(void)
if (!OGL32)
return 0;
GLU32 = LoadLibrary("GLU32.DLL");
pwglGetProcAddress = GetGLFunc("wglGetProcAddress");
pwglCreateContext = GetGLFunc("wglCreateContext");
pwglDeleteContext = GetGLFunc("wglDeleteContext");
@@ -528,7 +519,6 @@ EXPORT void HWRAPI(Shutdown) (void)
ReleaseDC(hWnd, hDC);
hDC = NULL;
}
FreeLibrary(GLU32);
FreeLibrary(OGL32);
DBG_Printf ("HWRAPI Shutdown(DONE)\n");
}
@@ -564,15 +554,15 @@ EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl)
// : in OpenGL, we store values for conversion of paletted graphics when
// : they are downloaded to the 3D card.
// -----------------+
EXPORT void HWRAPI(SetPalette) (RGBA_t *pal, RGBA_t *gamma)
EXPORT void HWRAPI(SetPalette) (RGBA_t *pal)
{
INT32 i;
for (i = 0; i < 256; i++)
{
myPaletteData[i].s.red = (UINT8)MIN((pal[i].s.red*gamma->s.red)/127, 255);
myPaletteData[i].s.green = (UINT8)MIN((pal[i].s.green*gamma->s.green)/127, 255);
myPaletteData[i].s.blue = (UINT8)MIN((pal[i].s.blue*gamma->s.blue)/127, 255);
myPaletteData[i].s.red = pal[i].s.red;
myPaletteData[i].s.green = pal[i].s.green;
myPaletteData[i].s.blue = pal[i].s.blue;
myPaletteData[i].s.alpha = pal[i].s.alpha;
}
File diff suppressed because it is too large. Load diff
+1 -9
View File
@@ -35,7 +35,6 @@
#else
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef STATIC_OPENGL // Because of the 1.3 functions, you'll need GLext to compile it if static
#define GL_GLEXT_PROTOTYPES
@@ -46,6 +45,7 @@
#define _CREATE_DLL_ // necessary for Unix AND Windows
#include "../../doomdef.h"
#include "../hw_drv.h"
#include "../../z_zone.h"
// ==========================================================================
// DEFINITIONS
@@ -73,10 +73,6 @@ void Flush(void);
INT32 isExtAvailable(const char *extension, const GLubyte *start);
void SetModelView(GLint w, GLint h);
void SetStates(void);
#ifdef USE_PALETTED_TEXTURE
extern PFNGLCOLORTABLEEXTPROC glColorTableEXT;
extern GLubyte palette_tex[256*3];
#endif
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
@@ -133,8 +129,4 @@ typedef enum
GLF_NOTEXENV = 0x02,
} oglflags_t;
// in order for custom playpals n shit to work properly
extern boolean gl_palette_initialized;
void InitPalette(int flashnum, boolean skiplut);
#endif
-9
View File
@@ -534,9 +534,6 @@ EXPORT INT32 HWRAPI(Startup) (I_Error_t FatalErrorFunction, snddev_t *snd_dev)
case FSOUND_OUTPUT_A3D:
DBG_Printf("FMOD driver: A3D driver.\n");
break;
case FSOUND_OUTPUT_XBOX:
DBG_Printf("FMOD driver: Xbox driver\n");
break;
case FSOUND_OUTPUT_OSS:
DBG_Printf("FMOD driver: Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers.\n");
break;
@@ -549,12 +546,6 @@ EXPORT INT32 HWRAPI(Startup) (I_Error_t FatalErrorFunction, snddev_t *snd_dev)
case FSOUND_OUTPUT_MAC:
DBG_Printf("FMOD driver: Mac SoundManager driver\n");
break;
case FSOUND_OUTPUT_PS2:
DBG_Printf("FMOD driver: PlayStation 2 driver\n");
break;
case FSOUND_OUTPUT_GC:
DBG_Printf("FMOD driver: Gamecube driver\n");
break;
case FSOUND_OUTPUT_NOSOUND_NONREALTIME:
DBG_Printf("FMOD driver: This is the same as nosound, but the sound generation is driven by FSOUND_Update\n");
break;
+6
View File
@@ -87,9 +87,13 @@ Printf_url (const char *url)
{
boolean startup;
#ifdef HAVE_THREADS
I_lock_mutex(&con_mutex);
startup = con_startup;
I_unlock_mutex(con_mutex);
#else
startup = con_startup;
#endif
if (cv_masterserver_debug.value)
(startup ? I_OutputMsg : CONS_Printf)(
@@ -540,6 +544,8 @@ HMS_fetch_rules (char *buffer, size_t buffer_size)
else
buffer = NULL;
}
else
buffer = NULL;
HMS_end(hms);
+90 -45
View File
@@ -1142,6 +1142,10 @@ void HU_Ticker(void)
}
if (cechotimer > 0) --cechotimer;
// Animate the desynch dots
if (hu_resynching)
resynch_ticker++; //tic tic tic tic tic
HU_TickSongCredits();
}
@@ -2575,54 +2579,92 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags)
UINT8 *colormap = NULL;
INT32 measureid = cv_pingmeasurement.value ? 1 : 0;
INT32 gfxnum; // gfx to draw
//SRB2/Kart v1.0 style
UINT8 numbars = 0; // how many ping bars do we draw?
UINT8 barcolor = 31; // color we use for the bars (green, yellow, red or black)
SINT8 i = 0;
SINT8 yoffset = 6;
INT32 dx;
gfxnum = Ping_gfx_num(lag);
if (measureid == 1)
if (!cv_pingstyle.value)
{
if (cv_ticrate.value == 2){
V_DrawScaledPatch(x+12 - pingmeasure[measureid]->width, y+22, flags, pingmeasure[measureid]);
}else{
if (measureid == 1)
V_DrawScaledPatch(x+11 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]);
}
}
if (cv_pingicon.value)
{
if (cv_ticrate.value == 2){
V_DrawScaledPatch(x+2, y+13, flags, pinggfx[gfxnum]);
}else{
V_DrawScaledPatch(x+2, y, flags, pinggfx[gfxnum]);
}
}
if (servermaxping && lag > servermaxping && hu_tick < 4)
{
// flash ping red if too high
colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE);
}
if (cv_pingmeasurement.value)
{
lag = (INT32)(lag * (1000.00f / TICRATE));
}
if (cv_ticrate.value == 2){
x = V_DrawPingNum(x + (measureid == 1 ? 11 - pingmeasure[measureid]->width : 10), y+22, flags, lag, colormap);
}else{
x = V_DrawPingNum(x + (measureid == 1 ? 11 - pingmeasure[measureid]->width : 10), y+9, flags, lag, colormap);
}
if (measureid == 0){
if (cv_ticrate.value == 2){
V_DrawScaledPatch(x+1 - pingmeasure[measureid]->width, y+22, flags, pingmeasure[measureid]);
}else{
V_DrawScaledPatch(x+1 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]);
}
}
if (cv_pingicon.value)
V_DrawScaledPatch(x+2, y, flags, pinggfx[gfxnum]);
if (servermaxping && lag > servermaxping && hu_tick < 4)
colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); // flash ping red if too high
if (cv_pingmeasurement.value)
lag = (INT32)(lag * (1000.00f / TICRATE));
x = V_DrawPingNum(x + (measureid == 1 ? 11 - pingmeasure[measureid]->width : 10), y+9, flags, lag, colormap);
if (measureid == 0)
V_DrawScaledPatch(x+1 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]);
}
else if (cv_pingstyle.value) // old style ping
{
if (cv_pingicon.value)
{
if (lag < 4)
{
numbars = 3;
barcolor = 184;
}
else if (lag < 7)
{
numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it.
barcolor = 103;
}
else if (lag < 10)
{
numbars = 1;
barcolor = 155; // need a better red
}
else // brazil
{
numbars = 0;
barcolor = 31;
}
}
if (cv_pingmeasurement.value)
lag = (INT32)(lag * (1000.00f / TICRATE));
if (vid.width >= 640) // how sad, we're using a shit resolution.
{
if (measureid == 1)
{
//dx = x+1 - (V_SmallStringWidth(va("%dms", lag), V_ALLOWLOWERCASE|flags)/2);
//V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE|flags, va("%dms", lag));
V_DrawRightAlignedSmallString(x+12, y+13, V_ALLOWLOWERCASE|flags, va("%dms", lag));
}
else if (measureid == 0)
{
//dx = x+1 - (V_SmallStringWidth(va("d%d", lag), flags)/2);
//V_DrawSmallString(dx, y+4, flags, va("d%d", lag));
V_DrawRightAlignedSmallString(x+12, y+13, flags, va("d%d", lag));
}
}
if (cv_pingicon.value)
{
for (i=0; (i<3); i++) // Draw the ping bar
{
V_DrawFill(x+2 *(i-1)+7, y+8+yoffset-4, 2, 8-yoffset, 31|flags);
if (i < numbars)
V_DrawFill(x+2 *(i-1)+7, y+8+yoffset-3, 1, 8-yoffset-1, barcolor|flags);
yoffset -= 2;
}
}
}
}
//
@@ -2715,8 +2757,11 @@ static void HU_DrawRankings(void)
//else
//V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, gametype_cons_t[gametype].strvalue);
// draw the current map in the lower right
V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, G_BuildMapTitle(gamemap));
// draw the current map in the lower right if theres none just say its unknown
if (!G_BuildMapTitle(gamemap))
V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "UNKNOWN");
else
V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, G_BuildMapTitle(gamemap));
if (G_GametypeHasTeams())
{
+9 -2
View File
@@ -79,19 +79,24 @@ typedef struct
char data[MAXPACKETLENGTH];
} ATTRPACK doomcom_t;
#ifdef HOLEPUNCH
typedef struct
{
INT32 magic;
INT32 addr;
INT16 port;
} ATTRPACK holepunch_t;
#endif
#if defined(_MSC_VER)
#pragma pack()
#endif
extern doomcom_t *doomcom;
#ifdef HOLEPUNCH
extern holepunch_t *holepunchpacket;
#endif
/** \brief return packet in doomcom struct
*/
@@ -152,12 +157,14 @@ extern void (*I_NetCloseSocket)(void);
/** \brief send a hole punching request
*/
#ifdef HOLEPUNCH
extern void (*I_NetRequestHolePunch)(INT32 node);
#endif
/** \brief register this machine on the hole punching server
*/
#ifdef HOLEPUNCH
extern void (*I_NetRegisterHolePunch)(void);
#endif
extern boolean (*I_Ban) (INT32 node);
extern void (*I_ClearBans)(void);
-2
View File
@@ -369,6 +369,4 @@ const char *I_ClipboardPaste(void);
void I_RegisterSysCommands(void);
void I_CursedWindowMovement(int xd, int yd);
#endif
+19 -2
View File
@@ -201,8 +201,10 @@ static size_t broadcastaddresses = 0;
static boolean nodeconnected[MAXNETNODES+1];
static banned_t *banned;
/* See ../doc/Holepunch-Protocol.txt */
#ifdef HOLEPUNCH
static const INT32 hole_punch_magic = MSBF_LONG (0x52eb11);
#endif
#endif
static size_t numbans = 0;
static size_t banned_size = 0;
@@ -609,8 +611,10 @@ is_external_address (UINT32 p)
}
}
#ifdef HOLEPUNCH
static boolean hole_punch(ssize_t c)
{
/* See ../doc/Holepunch-Protocol.txt */
if (cv_rendezvousserver.string[0] &&
c == 10 && holepunchpacket->magic == hole_punch_magic &&
@@ -631,7 +635,9 @@ static boolean hole_punch(ssize_t c)
{
return false;
}
}
#endif
// Returns true if a packet was received from a new node, false in all other cases
static boolean SOCK_Get(void)
@@ -655,11 +661,12 @@ static boolean SOCK_Get(void)
break;
}
#endif
#ifdef HOLEPUNCH
if (hole_punch(c))
{
break;
}
#endif
// find remote node number
for (j = 1; j <= MAXNETNODES; j++) //include LAN
@@ -1363,7 +1370,7 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
}
/* See ../doc/Holepunch-Protocol.txt */
#ifdef HOLEPUNCH
static void rendezvous(int size)
{
char *addrs = strdup(cv_rendezvousserver.string);
@@ -1391,7 +1398,9 @@ static void rendezvous(int size)
if (tic == refreshtic)
{
#ifdef HOLEPUNCH
holepunchpacket->magic = hole_punch_magic;
#endif
sendto(mysockets[0], doomcom->data, size, 0, &rzv.any, sizeof rzv.ip4);
}
@@ -1417,6 +1426,8 @@ static void SOCK_RegisterHolePunch(void)
}
#endif
#endif
static boolean SOCK_OpenSocket(void)
{
#ifndef NONET
@@ -1439,9 +1450,11 @@ static boolean SOCK_OpenSocket(void)
I_NetCanSend = SOCK_CanSend;
I_NetCanGet = SOCK_CanGet;
#endif
#ifdef HOLEPUNCH
I_NetRequestHolePunch = SOCK_RequestHolePunch;
I_NetRegisterHolePunch = SOCK_RegisterHolePunch;
#endif
// build the socket but close it first
SOCK_CloseSocket();
@@ -1709,6 +1722,7 @@ boolean I_InitTcpNetwork(void)
// server address only in ip
if (serverhostname[0])
{
CV_Set(&cv_lastserver, serverhostname);
COM_BufAddText("connect \"");
COM_BufAddText(serverhostname);
COM_BufAddText("\"\n");
@@ -1718,6 +1732,9 @@ boolean I_InitTcpNetwork(void)
}
else
{
// Not quite sure if we want to save that but i'll do that for now
CV_Set(&cv_lastserver, "any");
// so we're on a LAN
COM_BufAddText("connect any\n");
+473 -298
View File
File diff suppressed because it is too large. Load diff
+6 -1
View File
@@ -17,7 +17,7 @@ extern const UINT8 KartColor_Opposite[MAXSKINCOLORS*2];
void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor);
void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, boolean local);
UINT8 K_GetKartColorByName(const char *name);
UINT8 K_GetHudColor();
UINT8 K_GetHudColor(void);
void K_RegisterKartStuff(void);
@@ -26,6 +26,10 @@ extern consvar_t cv_colorizeditembox;
extern consvar_t cv_colorizedhudcolor;
extern consvar_t cv_darkitembox;
extern consvar_t cv_biglaps;
extern consvar_t cv_highresportrait;
extern consvar_t cv_stat_xoffset;
extern consvar_t cv_stat_yoffset;
extern consvar_t cv_showstats;
boolean K_IsPlayerLosing(player_t *player);
boolean K_IsPlayerWanted(player_t *player);
@@ -45,6 +49,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor);
void K_StealBumper(player_t *player, player_t *victim, boolean force);
void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit, mobj_t *source);
void K_SpawnMineExplosion(mobj_t *source, UINT8 color);
void K_RollMobjBySlopes(mobj_t *mo, boolean usedistance);
void K_SpawnBoostTrail(player_t *player);
void K_SpawnSparkleTrail(mobj_t *mo);
void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent);
+13
View File
@@ -538,6 +538,18 @@ static int lib_pFlashPal(lua_State *L)
return 0;
}
// not sure if this is netsafe...
static int lib_pRollPitchMobj(lua_State *L)
{
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
NOHUD
if (!source)
return LUA_ErrInvalid(L, "mobj_t");
P_RollPitchMobj(source);
return 0;
}
static int lib_pGetClosestAxis(lua_State *L)
{
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@@ -3033,6 +3045,7 @@ static luaL_Reg lib[] = {
{"P_GetMobjGravity",lib_pGetMobjGravity},
{"P_WeaponOrPanel",lib_pWeaponOrPanel},
{"P_FlashPal",lib_pFlashPal},
{"P_RollPitchMobj",lib_pRollPitchMobj},
{"P_GetClosestAxis",lib_pGetClosestAxis},
{"P_SpawnParaloop",lib_pSpawnParaloop},
{"P_BossTargetPlayer",lib_pBossTargetPlayer},
+53 -22
View File
@@ -430,6 +430,9 @@ void LUAh_PlayerJoin(int playernum)
void LUAh_PreThinkFrame(void)
{
hook_p hookp;
// variables used by perf stats
int hook_index = 0;
precise_t time_taken = 0;
if (!gL || !(hooksAvailable[hook_PreThinkFrame/8] & (1<<(hook_PreThinkFrame%8))))
return;
@@ -437,19 +440,32 @@ void LUAh_PreThinkFrame(void)
for (hookp = roothook; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PreThinkFrame)
continue;
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
if (hookp->type == hook_PreThinkFrame)
{
if (cv_perfstats.value == 4)
time_taken = I_GetPreciseTime();
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
}
if (cv_perfstats.value == 4)
{
lua_Debug ar;
time_taken = I_GetPreciseTime() - time_taken;
// we need the function, let's just retrieve it again
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_getinfo(gL, ">S", &ar);
PS_SetPreThinkFrameHookInfo(hook_index, time_taken, ar.short_src);
hook_index++;
}
}
}
}
lua_pop(gL, 1); // Pop error handler
}
@@ -498,6 +514,9 @@ void LUAh_ThinkFrame(void)
void LUAh_PostThinkFrame(void)
{
hook_p hookp;
// variables used by perf stats
int hook_index = 0;
precise_t time_taken = 0;
if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8))))
return;
@@ -505,19 +524,31 @@ void LUAh_PostThinkFrame(void)
for (hookp = roothook; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PostThinkFrame)
continue;
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
if (hookp->type == hook_PostThinkFrame)
{
if (cv_perfstats.value == 5)
time_taken = I_GetPreciseTime();
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
}
if (cv_perfstats.value == 5)
{
lua_Debug ar;
time_taken = I_GetPreciseTime() - time_taken;
// we need the function, let's just retrieve it again
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_getinfo(gL, ">S", &ar);
PS_SetPostThinkFrameHookInfo(hook_index, time_taken, ar.short_src);
hook_index++;
}
}
}
lua_pop(gL, 1); // Pop error handler
}
+1
View File
@@ -31,6 +31,7 @@ enum hud {
hud_battlecomebacktimer, // comeback timer in battlefullscreen. separated for ease of use.
hud_wanted,
hud_speedometer,
hud_statdisplay,
hud_freeplay,
hud_rankings, // Tab rankings
+152
View File
@@ -11,6 +11,7 @@
/// \brief custom HUD rendering library for Lua scripting
#include "doomdef.h"
#include "fastcmp.h"
#ifdef HAVE_BLUA
#include "r_defs.h"
#include "r_local.h"
@@ -54,6 +55,7 @@ static const char *const hud_disable_options[] = {
"battlecomebacktimer", // come back timer in battlefullscreen
"wanted",
"speedometer",
"statdisplay",
"freeplay",
"rankings",
NULL};
@@ -345,6 +347,118 @@ static int libd_cachePatch(lua_State *L)
return 1;
}
// this is structured like getSprite2Patch in vanilla 2.2
// v.getSpritePatch(skin, sprite, [frame, [angle, [rollangle]]])
static int libd_getSpritePatch(lua_State *L)
{
UINT32 i; // sprite prefix
INT32 skn = -1; // skin number
UINT32 frame = 0; // 'A'
UINT8 angle = 0;
spritedef_t *sprdef;
spriteframe_t *sprframe;
#ifdef ROTSPRITE
spriteinfo_t *sprinfo;
#endif
HUDONLY
// mashing together the stuff from getSprite2Patch:
// get skin first!
if (!lua_isnoneornil(L, 1)) // ONLY do this if we have a skin
{
if (lua_isnumber(L, 1)) // find skin by number
{
skn = lua_tonumber(L, 1);
if (skn < 0 || skn >= MAXSKINS)
return luaL_error(L, "skin number %d out of range (0 - %d)", skn, MAXSKINS-1);
if (skn >= numskins)
return 0;
}
else // find skin by name
{
const char *name = luaL_checkstring(L, 1);
for (skn = 0; skn < numskins; skn++)
if (fastcmp(skins[skn].name, name))
break;
if (skn >= numskins)
return 0;
}
}
lua_remove(L, 1); // remove skin now
if (lua_isnumber(L, 1)) // sprite number given, e.g. SPR_THOK
{
i = lua_tonumber(L, 1);
if (i >= NUMSPRITES)
return 0;
}
else if (lua_isstring(L, 1)) // sprite prefix name given, e.g. "THOK"
{
const char *name = lua_tostring(L, 1);
for (i = 0; i < NUMSPRITES; i++)
if (fastcmp(name, sprnames[i]))
break;
if (i >= NUMSPRITES)
return 0;
}
else
return 0;
// get outta dodge if we're a playersprite and have no skin
if ((i == SPR_PLAY) && (skn < 0))
return luaL_error(L, "You must provide a skin for player sprites!");
if (skn < 0) // standard sprite
{
sprdef = &sprites[i];
sprinfo = &spriteinfo[i];
}
else // player skin
{
sprdef = &skins[skn].spritedef;
sprinfo = &skins[skn].sprinfo;
}
// set frame number
frame = luaL_optinteger(L, 2, 0);
frame &= FF_FRAMEMASK; // ignore any bits that are not the actual frame, just in case
if (frame >= sprdef->numframes)
return 0;
// set angle number
sprframe = &sprdef->spriteframes[frame];
angle = luaL_optinteger(L, 3, 1);
// convert WAD editor angle numbers (1-8) to internal angle numbers (0-7)
// keep 0 the same since we'll make it default to angle 1 (which is internally 0)
// in case somebody didn't know that angle 0 really just maps all 8 angles to the same patch
if (angle != 0)
angle--;
if (angle >= 8) // out of range?
angle = (angle & 7); // modulus angle by 8
// rotsprite?????
if (lua_isnumber(L, 4) && (cv_spriteroll.value))
{
angle_t rollangle = luaL_checkangle(L, 4);
INT32 rot = R_GetRollAngle(rollangle);
if (rot) {
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), false, sprinfo, rot);
LUA_PushUserdata(L, rotsprite, META_PATCH);
lua_pushboolean(L, false);
lua_pushboolean(L, true);
return 3;
}
}
// push both the patch and its "flip" value
LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_STATIC), META_PATCH);
lua_pushboolean(L, (sprframe->flip & (1<<angle)) != 0);
return 2;
}
static int libd_draw(lua_State *L)
{
INT32 x, y, flags;
@@ -595,6 +709,42 @@ static int libd_drawOnMinimap(lua_State *L)
return 0;
}
static int libd_drawStretched(lua_State *L)
{
fixed_t x, y, hscale, vscale;
INT32 flags;
patch_t *patch;
UINT8 *colormap = NULL;
huddrawlist_h list;
HUDONLY
x = luaL_checkinteger(L, 1);
y = luaL_checkinteger(L, 2);
hscale = luaL_checkinteger(L, 3);
if (hscale < 0)
return luaL_error(L, "negative horizontal scale");
vscale = luaL_checkinteger(L, 4);
if (vscale < 0)
return luaL_error(L, "negative vertical scale");
patch = *((patch_t **)luaL_checkudata(L, 5, META_PATCH));
flags = luaL_optinteger(L, 6, 0);
if (!lua_isnoneornil(L, 7))
colormap = *((UINT8 **)luaL_checkudata(L, 7, META_COLORMAP));
flags &= ~V_PARAMMASK; // Don't let crashes happen.
lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
list = (huddrawlist_h) lua_touserdata(L, -1);
lua_pop(L, 1);
if (LUA_HUD_IsDrawListValid(list))
LUA_HUD_AddDrawStretched(list, x, y, hscale, vscale, patch, flags, colormap);
else
V_DrawStretchyFixedPatch(x, y, hscale, vscale, flags, patch, colormap);
return 0;
}
static int libd_drawNum(lua_State *L)
{
INT32 x, y, flags, num;
@@ -912,10 +1062,12 @@ static luaL_Reg lib_draw[] = {
{"cachePatch", libd_cachePatch},
{"draw", libd_draw},
{"drawScaled", libd_drawScaled},
{"drawStretched", libd_drawStretched},
{"drawNum", libd_drawNum},
{"drawPaddedNum", libd_drawPaddedNum},
{"drawPingNum", libd_drawPingNum},
{"drawFill", libd_drawFill},
{"getSpritePatch",libd_getSpritePatch},
{"fadeScreen", libd_fadeScreen},
{"drawString", libd_drawString},
{"drawKartString", libd_drawKartString},
+27
View File
@@ -20,6 +20,7 @@
enum drawitem_e {
DI_Draw = 0,
DI_DrawScaled,
DI_DrawStretched,
DI_DrawNum,
DI_DrawPaddedNum,
DI_DrawPingNum,
@@ -216,6 +217,29 @@ void LUA_HUD_AddDrawScaled(
item->colormap = colormap;
}
void LUA_HUD_AddDrawStretched(
huddrawlist_h list,
fixed_t x,
fixed_t y,
fixed_t hscale,
fixed_t vscale,
patch_t *patch,
INT32 flags,
UINT8 *colormap
)
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->type = DI_DrawStretched;
item->x = x;
item->y = y;
item->hscale = hscale;
item->vscale = vscale;
item->patch = patch;
item->flags = flags;
item->colormap = colormap;
}
void LUA_HUD_AddDrawNum(
huddrawlist_h list,
INT32 x,
@@ -377,6 +401,9 @@ void LUA_HUD_DrawList(huddrawlist_h list)
case DI_DrawScaled:
V_DrawFixedPatch(item->x, item->y, item->scale, item->flags, item->patch, item->colormap);
break;
case DI_DrawStretched:
V_DrawStretchyFixedPatch(item->x, item->y, item->hscale, item->vscale, item->flags, item->patch, item->colormap);
break;
case DI_DrawNum:
V_DrawTallNum(item->x, item->y, item->flags, item->num);
break;
+10
View File
@@ -42,6 +42,16 @@ void LUA_HUD_AddDraw(
INT32 flags,
UINT8 *colormap
);
void LUA_HUD_AddDrawStretched(
huddrawlist_h list,
fixed_t x,
fixed_t y,
fixed_t hscale,
fixed_t vscale,
patch_t *patch,
INT32 flags,
UINT8 *colormap
);
void LUA_HUD_AddDrawScaled(
huddrawlist_h list,
fixed_t x,
+49 -8
View File
@@ -83,8 +83,11 @@ static const udata_field_t mobj_fields[] = {
FIELD(mobj_t, snext, udatalib_getter_mobj, mobj_snext_noset),
FIELD(mobj_t, sprev, mobj_sprev_unimplemented, mobj_sprev_unimplemented),
FIELD(mobj_t, angle, udatalib_getter_angle, mobj_angle_setter),
FIELD(mobj_t, pitch, udatalib_getter_angle, udatalib_setter_angle),
FIELD(mobj_t, roll, udatalib_getter_angle, udatalib_setter_angle),
FIELD(mobj_t, rollangle, udatalib_getter_angle, udatalib_setter_angle),
FIELD(mobj_t, sloperoll, udatalib_getter_angle, mobj_sloperoll_noop),
FIELD(mobj_t, slopepitch, udatalib_getter_angle, mobj_sloperoll_noop),
// Macro fails here
{ "rollsum", 0, mobj_rollsum_getter, mobj_rollsum_noset },
FIELD(mobj_t, sprite, udatalib_getter_spritenum, udatalib_setter_spritenum),
@@ -143,6 +146,7 @@ static const udata_field_t mobj_fields[] = {
FIELD(mobj_t, cvmem, udatalib_getter_int32, udatalib_setter_int32),
FIELD(mobj_t, standingslope, udatalib_getter_slope, mobj_standingslope_noset),
FIELD(mobj_t, colorized, udatalib_getter_boolean, udatalib_setter_boolean),
FIELD(mobj_t, mirrored, udatalib_getter_boolean, udatalib_setter_boolean),
FIELD(mobj_t, rollmodel, udatalib_getter_boolean, udatalib_setter_boolean),
{ NULL },
};
@@ -217,7 +221,7 @@ UNIMPLEMENTED(mobjnum)
// For some dumb reason it is valid to set sloperoll, even though it is read
// only
int mobj_sloperoll_noop(lua_State *L) { return 0; }
int mobj_sloperoll_noop(lua_State *L) { (void)L; return 0; }
// Now other getters/setters with arbitary logic
@@ -415,13 +419,48 @@ int mobj_localskin_setter(lua_State *L)
{
mobj_t *mo = GETMO();
// TODO - add ability to set localskin to non-player mobjs
// Will probably just need to reimplement SetLocalPlayerSkin as something
// like SetLocalObjectSkin
if (!mo->player)
return luaL_error(L, "mobj.localskin can't be set for non-player mobjs!");
if (mo->player)
{
SetLocalPlayerSkin(mo->player - players, luaL_optstring(L, 2, "none"), NULL);
}
else
{
INT32 i;
char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin);
strlwr(skin); // all skin names are lowercase
if (strcasecmp(skin, "none"))
{
// Try localskins
for (i = 0; i < numlocalskins; i++)
{
if (stricmp(localskins[i].name, skin) == 0)
{
mo->localskin = &localskins[i];
mo->skinlocal = true;
return 0;
}
}
// Try other skins
for (i = 0; i < numskins; i++)
{
if (fastcmp(skins[i].name, skin))
{
mo->localskin = &skins[i];
mo->skinlocal = false;
return 0;
}
}
}
else
{
mo->localskin = 0;
mo->skinlocal = false;
}
}
SetLocalPlayerSkin(mo->player - players, luaL_checkstring(L, 2), NULL);
return 0;
}
@@ -596,7 +635,9 @@ int mobj_rollsum_getter(lua_State *L)
{
mobj_t *mo = GETMO();
angle_t rollsum = mo->rollangle + cv_sloperoll.value ? mo->sloperoll : 0;
angle_t pitchnroll = P_MobjPitchAndRoll(mo);
angle_t rollsum = mo->rollangle + pitchnroll;
if (mo->player)
{
+1 -1
View File
@@ -303,7 +303,7 @@ int player_localskin_setter(lua_State *L)
{
player_t *plr = GETPLAYER();
SetLocalPlayerSkin(plr - players, luaL_checkstring(L, 2), NULL);
SetLocalPlayerSkin(plr - players, luaL_optstring(L, 2, "none"), NULL);
return 0;
}
+15 -11
View File
@@ -465,19 +465,23 @@ static size_t gifframe_size = 8192;
static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr)
{
UINT8 r, g, b;
size_t src = 0, dest = 0;
size_t size = (vid.width * vid.height * 3);
size_t src, dest;
int x, y;
InitColorLUT();
while (src < size)
for (x = 0; x < vid.width; x += scrbuf_downscaleamt)
{
r = (UINT8)linear[src];
g = (UINT8)linear[src + 1];
b = (UINT8)linear[src + 2];
scr[dest] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS];
src += (3 * scrbuf_downscaleamt);
dest += scrbuf_downscaleamt;
for (y = 0; y < vid.height; y += scrbuf_downscaleamt)
{
dest = y*vid.width + x;
src = dest*3;
r = (UINT8)linear[src];
g = (UINT8)linear[src + 1];
b = (UINT8)linear[src + 2];
scr[dest] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS];
}
}
}
#endif
@@ -514,7 +518,7 @@ static void GIF_framewrite(void)
{
UINT8 *linear = HWR_GetScreenshot();
GIF_rgbconvert(linear, movie_screen);
free(linear);
//free(linear); // Allocated 'statically', no need to free now
}
#endif
}
@@ -530,7 +534,7 @@ static void GIF_framewrite(void)
{
UINT8 *linear = HWR_GetScreenshot();
GIF_rgbconvert(linear, screens[0]);
free(linear);
//free(linear); // Allocated 'statically', no need to free now
}
#endif
-11
View File
@@ -20,11 +20,6 @@
#include <stdlib.h>
#endif
// Was this just for the #define USEASM?
//#ifdef _WIN32_WCE
//#include "sdl12/SRB2CE/cehelp.h"
//#endif
/*!
\brief bits of the fraction
*/
@@ -37,12 +32,7 @@
/** \brief Redefinition of INT32 as fixed_t
unit used as fixed_t
*/
//Max number a stat can have
#define MAXSTAT 9
typedef INT32 fixed_t;
typedef UINT32 ufixed_t;
/*!
@@ -63,7 +53,6 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f)
#define FIXED_TO_FLOAT(x) FixedToFloat(x) // (((float)(x)) / ((float)FRACUNIT))
#define FLOAT_TO_FIXED(f) FloatToFixed(f) // (fixed_t)((f) * ((float)FRACUNIT))
/** \brief The FixedMul function
\param a fixed_t number
+1853 -228
View File
File diff suppressed because it is too large. Load diff
+30
View File
@@ -147,6 +147,8 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt);
#define MAXSTRINGLENGTH 32
#define MAXTOOLTIPS 255
typedef union
{
struct menu_s *submenu; // IT_SUBMENU
@@ -184,6 +186,7 @@ typedef struct menu_s
INT16 x, y; // x, y of menu
INT16 lastOn; // last item user was on in menu
boolean (*quitroutine)(void); // called before quit a menu return true if we can
const char* tooltips[MAXTOOLTIPS]; // tooltips! give me that info bitch
} menu_t;
void M_SetupNextMenu(menu_t *menudef);
@@ -242,6 +245,7 @@ extern description_t description[MAXSKINS];
extern consvar_t cv_showfocuslost;
extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort;
extern consvar_t cv_showallmaps;
extern consvar_t cv_showmusicfilename;
extern CV_PossibleValue_t gametype_cons_t[];
extern char dummystaffname[22];
@@ -269,6 +273,9 @@ void PDistort_menu_Onchange(void);
// Bird menu updating
void Bird_menu_Onchange(void);
// Saturn menu updating
void Saturn_menu_Onchange(void);
void M_ReplayHut(INT32 choice);
void M_SetPlaybackMenuPointer(void);
@@ -278,6 +285,10 @@ INT32 HU_GetHighlightColor(void);
void M_PopupMasterServerRules(void);
#ifdef MASTERSERVER
void M_PopupMasterServerConnectError(void);
#endif
// These defines make it a little easier to make menus
#define DEFAULTMENUSTYLE(header, source, prev, x, y)\
{\
@@ -288,6 +299,20 @@ void M_PopupMasterServerRules(void);
M_DrawGenericMenu,\
x, y,\
0,\
NULL,\
NULL\
}
#define DEFAULTSCROLLSTYLE(header, source, prev, x, y)\
{\
header,\
sizeof(source)/sizeof(menuitem_t),\
prev,\
source,\
M_DrawGenericScrollMenu,\
x, y,\
0,\
NULL,\
NULL\
}
@@ -300,6 +325,7 @@ void M_PopupMasterServerRules(void);
M_DrawPauseMenu,\
x, y,\
0,\
NULL,\
NULL\
}
@@ -312,6 +338,7 @@ void M_PopupMasterServerRules(void);
M_DrawCenteredMenu,\
BASEVIDWIDTH/2, y,\
0,\
NULL,\
NULL\
}
@@ -324,6 +351,7 @@ void M_PopupMasterServerRules(void);
M_DrawServerMenu,\
24,40,\
0,\
NULL,\
NULL\
}
@@ -336,6 +364,7 @@ void M_PopupMasterServerRules(void);
M_DrawControl,\
26, 40,\
0,\
NULL,\
NULL\
}
@@ -348,6 +377,7 @@ void M_PopupMasterServerRules(void);
M_DrawImageDef,\
0, 0,\
0,\
NULL,\
NULL\
}
+1 -1
View File
@@ -193,7 +193,7 @@ INT32 M_MapNumber(char first, char second)
// ==========================================================================
// some libcs has no access function, make our own
#if defined (_WIN32_WCE) || defined (_WII)
#if 0
int access(const char *path, int amode)
{
int accesshandle = -1;
+2
View File
@@ -41,6 +41,8 @@ void M_StopMovie(void);
// the file where game vars and settings are saved
#define CONFIGFILENAME "kartconfig.cfg"
// autoload!
#define AUTOLOADCONFIGFILENAME "autoload.cfg"
INT32 M_MapNumber(char first, char second);
+174 -27
View File
@@ -63,7 +63,10 @@ static ps_metric_t ps_removecount = {0};
ps_metric_t ps_checkposition_calls = {0};
ps_metric_t ps_lua_prethinkframe_time = {0};
ps_metric_t ps_lua_thinkframe_time = {0};
ps_metric_t ps_lua_postthinkframe_time = {0};
ps_metric_t ps_lua_mobjhooks = {0};
ps_metric_t ps_otherlogictime = {0};
@@ -156,7 +159,9 @@ perfstatrow_t gamelogic_rows[] = {
{" mobjs ", " Mobjs: ", &ps_thlist_times[THINK_MOBJ], PS_TIME|PS_LEVEL},
{" dynslop", " Dynamic slopes: ", &ps_thlist_times[THINK_DYNSLOPE], PS_TIME|PS_LEVEL},
{" precip ", " Precipitation: ", &ps_thlist_times[THINK_PRECIP], PS_TIME|PS_LEVEL},*/
{" lprethinkf", " LUAh_PreThinkFrame:", &ps_lua_prethinkframe_time, PS_TIME|PS_LEVEL},
{" lthinkf", " LUAh_ThinkFrame:", &ps_lua_thinkframe_time, PS_TIME|PS_LEVEL},
{" lpostthinkf", " LUAh_PostThinkFrame:", &ps_lua_postthinkframe_time, PS_TIME|PS_LEVEL},
{" other ", " Other: ", &ps_otherlogictime, PS_TIME|PS_LEVEL},
{0}
};
@@ -189,10 +194,43 @@ int ps_frame_index = 0;
int ps_tick_index = 0;
// dynamically allocated resizeable array for thinkframe hook stats
ps_hookinfo_t *prethinkframe_hooks = NULL;
int prethinkframe_hooks_length = 0;
int prethinkframe_hooks_capacity = 16;
ps_hookinfo_t *thinkframe_hooks = NULL;
int thinkframe_hooks_length = 0;
int thinkframe_hooks_capacity = 16;
ps_hookinfo_t *postthinkframe_hooks = NULL;
int postthinkframe_hooks_length = 0;
int postthinkframe_hooks_capacity = 16;
void PS_SetPreThinkFrameHookInfo(int index, precise_t time_taken, char* short_src)
{
if (!prethinkframe_hooks)
{
// array needs to be initialized
prethinkframe_hooks = Z_Calloc(sizeof(ps_hookinfo_t) * prethinkframe_hooks_capacity, PU_STATIC, NULL);
}
if (index >= prethinkframe_hooks_capacity)
{
// array needs more space, realloc with double size
int new_capacity = prethinkframe_hooks_capacity * 2;
prethinkframe_hooks = Z_Realloc(prethinkframe_hooks,
sizeof(ps_hookinfo_t) * new_capacity, PU_STATIC, NULL);
// initialize new memory with zeros so the pointers in the structs are null
memset(&prethinkframe_hooks[prethinkframe_hooks_capacity], 0,
sizeof(ps_hookinfo_t) * prethinkframe_hooks_capacity);
prethinkframe_hooks_capacity = new_capacity;
}
prethinkframe_hooks[index].time_taken.value.p = time_taken;
memcpy(prethinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char));
// since the values are set sequentially from begin to end, the last call should leave
// the correct value to this variable
prethinkframe_hooks_length = index + 1;
}
void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src)
{
if (!thinkframe_hooks)
@@ -218,6 +256,33 @@ void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src)
thinkframe_hooks_length = index + 1;
}
void PS_SetPostThinkFrameHookInfo(int index, precise_t time_taken, char* short_src)
{
if (!postthinkframe_hooks)
{
// array needs to be initialized
postthinkframe_hooks = Z_Calloc(sizeof(ps_hookinfo_t) * postthinkframe_hooks_capacity, PU_STATIC, NULL);
}
if (index >= postthinkframe_hooks_capacity)
{
// array needs more space, realloc with double size
int new_capacity = postthinkframe_hooks_capacity * 2;
postthinkframe_hooks = Z_Realloc(postthinkframe_hooks,
sizeof(ps_hookinfo_t) * new_capacity, PU_STATIC, NULL);
// initialize new memory with zeros so the pointers in the structs are null
memset(&postthinkframe_hooks[postthinkframe_hooks_capacity], 0,
sizeof(ps_hookinfo_t) * postthinkframe_hooks_capacity);
postthinkframe_hooks_capacity = new_capacity;
}
postthinkframe_hooks[index].time_taken.value.p = time_taken;
memcpy(postthinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char));
// since the values are set sequentially from begin to end, the last call should leave
// the correct value to this variable
postthinkframe_hooks_length = index + 1;
}
static boolean PS_HighResolution(void)
{
return (vid.width >= 640 && vid.height >= 400);
@@ -578,7 +643,11 @@ void PS_UpdateTickStats(void)
ps_tictime.value.p -
ps_playerthink_time.value.p -
ps_thinkertime.value.p -
ps_lua_thinkframe_time.value.p;
ps_lua_prethinkframe_time.value.p -
ps_lua_thinkframe_time.value.p -
ps_lua_postthinkframe_time.value.p;
PS_CountThinkers();
}
@@ -590,21 +659,37 @@ void PS_UpdateTickStats(void)
PS_UpdateRowHistories(misc_calls_rows, false);
}
}
if (cv_perfstats.value == 3 && cv_ps_samplesize.value > 1 && PS_IsLevelActive())
if (cv_ps_samplesize.value > 1)
{
int i;
for (i = 0; i < thinkframe_hooks_length; i++)
if(cv_perfstats.value >= 3 && PS_IsLevelActive())
{
PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false, false);
int i;
if (cv_perfstats.value == 3)
{
for (i = 0; i < thinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false, false);
}
else if (cv_perfstats.value == 4)
{
for (i = 0; i < prethinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&prethinkframe_hooks[i].time_taken, true, false, false);
}
else if (cv_perfstats.value == 5)
{
for (i = 0; i < postthinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&postthinkframe_hooks[i].time_taken, true, false, false);
}
}
}
if (cv_perfstats.value && cv_ps_samplesize.value > 1)
{
ps_tick_index++;
if (ps_tick_index >= cv_ps_samplesize.value)
ps_tick_index = 0;
if (ps_tick_samples_left)
ps_tick_samples_left--;
if (cv_perfstats.value)
{
ps_tick_index++;
if (ps_tick_index >= cv_ps_samplesize.value)
ps_tick_index = 0;
if (ps_tick_samples_left)
ps_tick_samples_left--;
}
}
}
@@ -624,7 +709,7 @@ static void PS_DrawDescriptorHeader(void)
int samples_left = max(ps_frame_samples_left, ps_tick_samples_left);
int x, y;
if (cv_perfstats.value == 3)
if (cv_perfstats.value >= 3)
{
x = 2;
y = 0;
@@ -717,21 +802,20 @@ static void PS_DrawGameLogicStats(void)
#define WIDTH 106
#define HEIGHT 4
#define MAX_X 214
#define MAX_Y 192
#define MAX_Y 182
#define START_X 2
#define START_Y 4
#define PAGE_ENTRIES ((MAX_Y - START_Y) / HEIGHT)
static void PS_DrawThinkFrameStats(void)
static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook)
{
char s[100];
int i;
int maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1;
int page = max(1, min(cv_ps_thinkframe_page.value, maxpage));
int pagestart = min((page - 1)*PAGE_ENTRIES, thinkframe_hooks_length);
int pageend = min(pagestart + PAGE_ENTRIES, thinkframe_hooks_length);
int maxpage = 0;
int page = 0;
int pagestart = 0;
int pageend = 0;
// text writing position
int x = START_X;
int y = START_Y;
@@ -741,19 +825,44 @@ static void PS_DrawThinkFrameStats(void)
last_mod_name[0] = '\0';
INT32 total = 0;
//Decide page length based and drawn text on choosen thinker type
if (cv_perfstats.value == 3){
maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1;
page = max(1, min(cv_ps_thinkframe_page.value, maxpage));
pagestart = min((page - 1)*PAGE_ENTRIES, thinkframe_hooks_length);
pageend = min(pagestart + PAGE_ENTRIES, thinkframe_hooks_length);
V_DrawSmallString(MAX_X-50, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "ThinkFrame");
}
else if (cv_perfstats.value == 4){
maxpage = prethinkframe_hooks_length/PAGE_ENTRIES + 1;
page = max(1, min(cv_ps_thinkframe_page.value, maxpage));
pagestart = min((page - 1)*PAGE_ENTRIES, prethinkframe_hooks_length);
pageend = min(pagestart + PAGE_ENTRIES, prethinkframe_hooks_length);
V_DrawSmallString(MAX_X-60, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PreThinkFrame");
}
else if (cv_perfstats.value == 5){
maxpage = postthinkframe_hooks_length/PAGE_ENTRIES + 1;
page = max(1, min(cv_ps_thinkframe_page.value, maxpage));
pagestart = min((page - 1)*PAGE_ENTRIES, postthinkframe_hooks_length);
pageend = min(pagestart + PAGE_ENTRIES, postthinkframe_hooks_length);
V_DrawSmallString(MAX_X-65, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PostThinkFrame");
}
PS_DrawDescriptorHeader();
for (i = 0; i < thinkframe_hooks_length; i++)
for (i = 0; i < hook_length; i++)
{
#define NEXT_ROW() y += HEIGHT;
INT32 value = PS_GetMetricScreenValue(&thinkframe_hooks[i].time_taken, true);
INT32 value = PS_GetMetricScreenValue(&hook[i].time_taken, true);
total += value;
if (i < pagestart || i >= pageend) continue;
char* str = thinkframe_hooks[i].short_src;
char* str = hook[i].short_src;
char* tempstr = tempbuffer;
int len = (int)strlen(str);
char* str_ptr;
@@ -808,6 +917,8 @@ static void PS_DrawThinkFrameStats(void)
snprintf(s, sizeof s - 1, "PAGE %d", page);
V_DrawSmallString(START_X, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, s);
}
}
void PS_ThinkFrame_Page_OnChange(void)
@@ -828,6 +939,24 @@ void PS_ThinkFrame_Page_OnChange(void)
#undef PAGE_ENTRIES
static void PS_DrawPreThinkFrameStats(void)
{
draw_think_frame_stats(prethinkframe_hooks_length, prethinkframe_hooks);
}
static void PS_DrawThinkFrameStats(void)
{
draw_think_frame_stats(thinkframe_hooks_length, thinkframe_hooks);
}
static void PS_DrawPostThinkFrameStats(void)
{
draw_think_frame_stats(postthinkframe_hooks_length, postthinkframe_hooks);
}
void M_DrawPerfStats(void)
{
if (cv_perfstats.value == 1) // rendering
@@ -841,7 +970,7 @@ void M_DrawPerfStats(void)
// tics when frame skips happen
PS_DrawGameLogicStats();
}
else if (cv_perfstats.value == 3) // lua thinkframe
else if (cv_perfstats.value >= 3) // lua thinkframe
{
if (!PS_IsLevelActive())
return;
@@ -850,13 +979,23 @@ void M_DrawPerfStats(void)
// Low resolutions can't really use V_DrawSmallString that is used by thinkframe stats.
// A low-res version using V_DrawThinString could be implemented,
// but it would have much less space for information.
V_DrawThinString(80, 92, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "Perfstats 3 is not available");
V_DrawThinString(80, 92, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "Lua Perfstats is not available");
V_DrawThinString(80, 100, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "for resolutions below 640x400.");
return;
}
else
if (cv_perfstats.value == 3)
{
PS_DrawThinkFrameStats();
}
else if (cv_perfstats.value == 4)
{
PS_DrawPreThinkFrameStats();
}
else if (cv_perfstats.value == 5)
{
PS_DrawPostThinkFrameStats();
}
}
}
@@ -867,10 +1006,18 @@ static void PS_ClearHistory(void)
Z_FreeTags(PU_PERFSTATS, PU_PERFSTATS);
// thinkframe hook metric history pointers need to be cleared manually
for (i = 0; i < prethinkframe_hooks_length; i++)
{
prethinkframe_hooks[i].time_taken.history = NULL;
}
for (i = 0; i < thinkframe_hooks_length; i++)
{
thinkframe_hooks[i].time_taken.history = NULL;
}
for (i = 0; i < postthinkframe_hooks_length; i++)
{
postthinkframe_hooks[i].time_taken.history = NULL;
}
ps_frame_index = ps_tick_index = 0;
// PS_UpdateMetricHistory will set these correctly when it runs
+5
View File
@@ -44,12 +44,17 @@ extern ps_metric_t ps_thlist_times[];
extern ps_metric_t ps_checkposition_calls;
extern ps_metric_t ps_lua_prethinkframe_time;
extern ps_metric_t ps_lua_thinkframe_time;
extern ps_metric_t ps_lua_postthinkframe_time;
extern ps_metric_t ps_lua_mobjhooks;
extern ps_metric_t ps_otherlogictime;
void PS_SetPreThinkFrameHookInfo(int index, precise_t time_taken, char* short_src);
void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src);
void PS_SetPostThinkFrameHookInfo(int index, precise_t time_taken, char* short_src);
void PS_UpdateTickStats(void);
+27 -6
View File
@@ -57,8 +57,12 @@ static void Command_Listserv_f(void);
#endif/*MASTERSERVER*/
static void Update_parameters (void);
#ifdef MASTERSERVER
static void MasterServer_OnChange(void);
static void Advertise_OnChange(void);
@@ -69,16 +73,26 @@ static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
{0, NULL}
};
#endif
#ifdef MASTERSERVER
consvar_t cv_masterserver = {"masterserver", "https://ms.kartkrew.org/ms/api", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange, 0, NULL, NULL, 0, 0, NULL};
#endif
#ifdef HOLEPUNCH
consvar_t cv_rendezvousserver = {"holepunchserver", "relay.kartkrew.org", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif
consvar_t cv_servername = {"servername", "SRB2Kart server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_server_contact = {"server_contact", "", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters, 0, NULL, NULL, 0, 0, NULL};
#ifdef MASTERSERVER
consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, MasterClient_Ticker, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_advertise = {"advertise", "No", CV_NETVAR|CV_CALL|CV_NOINIT, CV_YesNo, Advertise_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_masterserver_nagattempts = {"masterserver_nagattempts", "5", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
int ms_QueryId;
@@ -98,6 +112,7 @@ UINT16 current_port = 0;
void AddMServCommands(void)
{
#ifndef NONET
#ifdef MASTERSERVER
CV_RegisterVar(&cv_masterserver);
CV_RegisterVar(&cv_masterserver_update_rate);
CV_RegisterVar(&cv_masterserver_timeout);
@@ -105,7 +120,11 @@ void AddMServCommands(void)
CV_RegisterVar(&cv_masterserver_token);
CV_RegisterVar(&cv_masterserver_nagattempts);
CV_RegisterVar(&cv_advertise);
#endif
#ifdef HOLEPUNCH
CV_RegisterVar(&cv_rendezvousserver);
#endif
CV_RegisterVar(&cv_servername);
CV_RegisterVar(&cv_server_contact);
#ifdef MASTERSERVER
@@ -121,7 +140,7 @@ static void WarnGUI (void)
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
M_StartMessage(M_GetText("There was a problem connecting to\nthe Master Server\n\nCheck the console for details.\n"), NULL, MM_NOTHING);
M_PopupMasterServerConnectError();
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
@@ -548,19 +567,20 @@ Update_parameters (void)
}
#endif/*MASTERSERVER*/
}
#ifdef MASTERSERVER
static void MasterServer_OnChange(void)
{
#ifdef MASTERSERVER
UnregisterServer();
Set_api(cv_masterserver.string);
if (Online())
RegisterServer();
#endif/*MASTERSERVER*/
}
}
#endif/*MASTERSERVER*/
#ifdef MASTERSERVER
static void
Advertise_OnChange(void)
{
@@ -596,3 +616,4 @@ Advertise_OnChange(void)
M_PopupMasterServerRules();
}
}
#endif
+13 -4
View File
@@ -51,18 +51,25 @@ typedef struct
#endif
// ================================ GLOBALS ===============================
extern consvar_t cv_masterserver, cv_servername;
#ifdef MASTERSERVER
extern consvar_t cv_masterserver;
#endif
extern consvar_t cv_servername;
extern consvar_t cv_server_contact;
#ifdef MASTERSERVER
extern consvar_t cv_masterserver_update_rate;
extern consvar_t cv_masterserver_timeout;
extern consvar_t cv_masterserver_debug;
extern consvar_t cv_masterserver_token;
extern consvar_t cv_rendezvousserver;
extern consvar_t cv_advertise;
extern consvar_t cv_masterserver_nagattempts;
#endif
#ifdef HOLEPUNCH
extern consvar_t cv_rendezvousserver;
#endif
#ifdef HAVE_THREADS
extern int ms_QueryId;
@@ -71,7 +78,7 @@ extern I_mutex ms_QueryId_mutex;
extern msg_server_t *ms_ServerList;
extern I_mutex ms_ServerList_mutex;
#endif
#ifdef MASTERSERVER
void RegisterServer(void);
void UnregisterServer(void);
@@ -97,3 +104,5 @@ int HMS_compare_mod_version (char *buffer, size_t size_of_buffer);
const char * HMS_fetch_rules (char *buffer, size_t size_of_buffer);
#endif
#endif
+1 -1
View File
@@ -2348,7 +2348,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
}
target->player->playerstate = PST_DEAD;
if (cv_fading.value && P_IsLocalPlayer(target->player))
if (cv_fading.value && cv_birdmusic.value && P_IsLocalPlayer(target->player))
{
if (netgame || multiplayer)
ms = cv_respawntime.value * 1000;
-1
View File
@@ -142,7 +142,6 @@ extern consvar_t cv_quaketilt;
extern consvar_t cv_tiltsmoothing;
extern consvar_t cv_actionmovie;
extern consvar_t cv_windowquake;
extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate;
extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate;
+157 -19
View File
@@ -6063,13 +6063,22 @@ static void P_AddOverlay(mobj_t *thing)
static void P_RemoveOverlay(mobj_t *thing)
{
mobj_t *mo;
if (overlaycap == thing)
{
P_SetTarget(&overlaycap, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
for (mo = overlaycap; mo; mo = mo->hnext)
if (mo->hnext == thing)
{
P_SetTarget(&mo->hnext, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
{
if (mo->hnext != thing)
continue;
P_SetTarget(&mo->hnext, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
}
void P_RunShadows(void)
@@ -6175,12 +6184,14 @@ static void P_RemoveShadow(mobj_t *thing)
}
for (mo = shadowcap; mo; mo = mo->hnext)
if (mo->hnext == thing)
{
P_SetTarget(&mo->hnext, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
{
if (mo->hnext != thing)
continue;
P_SetTarget(&mo->hnext, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
}
void A_BossDeath(mobj_t *mo);
@@ -6240,6 +6251,87 @@ static void P_KoopaThinker(mobj_t *koopa)
}
}
//
// P_RollPitchMobj
// Assigns slopepitch and sloperoll to objects, and resets said values when slope-rolling
// is turned off completely.
//
void P_RollPitchMobj(mobj_t* mobj)
{
boolean usedist = false;
if (cv_sloperolldist.value > 0)
usedist = true;
if ((cv_spriteroll.value) && (cv_sloperoll.value == 2))
{
K_RollMobjBySlopes(mobj, usedist);
}
else
{
mobj->sloperoll = FixedAngle(0);
mobj->slopepitch = FixedAngle(0);
}
}
angle_t P_MobjPitchAndRoll(mobj_t *mobj)
{
spritedef_t *sprdef;
spriteframe_t *sprframe;
angle_t ang = 0;
angle_t camang = 0;
angle_t return_angle = 0;
if (!cv_spriteroll.value)
return 0;
if (P_MobjWasRemoved(mobj))
return 0;
size_t rot = mobj->frame & FF_FRAMEMASK;
boolean papersprite = (mobj->frame & FF_PAPERSPRITE);
if (mobj->skin && mobj->sprite == SPR_PLAY)
{
sprdef = &((skin_t *)mobj->skin)->spritedef;
if (rot >= sprdef->numframes)
sprdef = &sprites[mobj->sprite];
}
else
{
sprdef = &sprites[mobj->sprite];
}
if (rot >= sprdef->numframes)
{
sprdef = &sprites[states[S_UNKNOWN].sprite];
rot = states[S_UNKNOWN].frame&FF_FRAMEMASK;
}
sprframe = &sprdef->spriteframes[rot];
// No sprite frame? I guess it is possible
if (!sprframe) return 0;
if (sprframe->rotate != SRF_SINGLE || papersprite)
{
ang = R_PointToAngle(mobj->x, mobj->y) - mobj->angle;
camang = R_PointToAngle(mobj->x, mobj->y);
}
return_angle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mobj->roll)
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch);
if (cv_sloperoll.value)
{
return_angle += FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
}
return return_angle;
}
//
// P_MobjThinker
//
@@ -6382,6 +6474,12 @@ void P_MobjThinker(mobj_t *mobj)
return;
}
if (mobj->state == &states[S_PLAY_SIGN]) // hack to make the player sign icon roll with the sign itself
{
mobj->slopepitch = mobj->target->slopepitch;
mobj->sloperoll = mobj->target->sloperoll;
}
P_AddOverlay(mobj);
break;
case MT_SHADOW:
@@ -6390,7 +6488,12 @@ void P_MobjThinker(mobj_t *mobj)
P_RemoveMobj(mobj);
return;
}
if (mobj->state == &states[S_SHADOW] && cv_sloperoll.value == 2)
{
mobj->slopepitch = mobj->target->slopepitch;
mobj->sloperoll = mobj->target->sloperoll;
}
P_AddShadow(mobj);
break;
/*case MT_BLACKORB:
@@ -6417,6 +6520,7 @@ void P_MobjThinker(mobj_t *mobj)
P_RemoveMobj(mobj);
return;
}
P_RollPitchMobj(mobj);
break;
case MT_SMOLDERING:
if (leveltime % 2 == 0)
@@ -7845,6 +7949,7 @@ void P_MobjThinker(mobj_t *mobj)
fixed_t distbarrier = 512*mapobjectscale;
fixed_t distaway;
P_RollPitchMobj(mobj);
P_SpawnGhostMobj(mobj);
if (mobj->threshold > 0)
@@ -7912,6 +8017,7 @@ void P_MobjThinker(mobj_t *mobj)
}
else
{
P_RollPitchMobj(mobj);
P_SpawnGhostMobj(mobj);
mobj->angle = R_PointToAngle2(0, 0, mobj->momx, mobj->momy);
P_InstaThrust(mobj, mobj->angle, mobj->movefactor);
@@ -7945,6 +8051,9 @@ void P_MobjThinker(mobj_t *mobj)
mobj->momx = mobj->momy = 0;
mobj->health = 1;
}
P_RollPitchMobj(mobj);
if (mobj->threshold > 0)
mobj->threshold--;
break;
@@ -7992,6 +8101,8 @@ void P_MobjThinker(mobj_t *mobj)
|| (mobj->state >= &states[S_SSMINE_DEPLOY8] && mobj->state <= &states[S_SSMINE_DEPLOY13]))
A_GrenadeRing(mobj);
P_RollPitchMobj(mobj);
if (mobj->threshold > 0)
mobj->threshold--;
break;
@@ -8202,6 +8313,8 @@ void P_MobjThinker(mobj_t *mobj)
}
P_MoveOrigin(mobj, destx, desty, mobj->target->z);
mobj->spriteyoffset = mobj->target->spriteyoffset;
mobj->spritexoffset = mobj->target->spritexoffset;
break;
}
case MT_ROCKETSNEAKER:
@@ -8344,6 +8457,10 @@ void P_MobjThinker(mobj_t *mobj)
}
}
}
// fancy sign rotation
P_RollPitchMobj(mobj);
break;
case MT_CDUFO:
if (!mobj->spawnpoint || mobj->fuse)
@@ -9524,6 +9641,10 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->height = info->height;
mobj->flags = info->flags;
mobj->sloperoll = 0;
mobj->slopepitch = 0;
mobj->pitch_sprite = 0;
mobj->roll_sprite = 0;
mobj->health = info->spawnhealth;
@@ -10359,7 +10480,7 @@ void P_SpawnPrecipitation(void)
subsector_t *precipsector = NULL;
precipmobj_t *rainmo = NULL;
if (dedicated || !(cv_drawdist_precip.value) || curWeather == PRECIP_NONE || curWeather == PRECIP_STORM_NORAIN) // SRB2Kart
if (dedicated || /*!cv_precipdensity*/!cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart
return;
// Use the blockmap to narrow down our placing patterns
@@ -10370,8 +10491,16 @@ void P_SpawnPrecipitation(void)
//for (j = 0; j < cv_precipdensity.value; ++j) -- density is 1 for kart always
{
x = basex + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3);
y = basey + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3);
if (cv_lessprecip.value)
{
x = basex*1.5 + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3);
y = basey*1.5 + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3);
}
else
{
x = basex + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3);
y = basey + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3);
}
precipsector = R_IsPointInSubsector(x, y);
@@ -10402,13 +10531,22 @@ void P_SpawnPrecipitation(void)
}
else // everything else.
rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN);
if (curWeather == PRECIP_BLANK)
rainmo->precipflags |= PCF_INVISIBLE;
// Randomly assign a height, now that floorz is set.
rainmo->z = M_RandomRange(rainmo->floorz>>FRACBITS, rainmo->ceilingz>>FRACBITS)<<FRACBITS;
}
}
if (curWeather == PRECIP_BLANK)
{
curWeather = PRECIP_RAIN;
P_SwitchWeather(PRECIP_BLANK);
}
else if (curWeather == PRECIP_STORM_NORAIN)
{
curWeather = PRECIP_RAIN;
P_SwitchWeather(PRECIP_STORM_NORAIN);
}
}
//
@@ -11376,7 +11514,7 @@ void P_SpawnMapThing(mapthing_t *mthing)
mobj = P_SpawnMobj(x, y, z, i);
if (!mobj || P_MobjWasRemoved(mobj)) {
CONS_Alert(CONS_WARNING, "Failed to spawn map thing #%d at %d, %d\n", mthing->type, x>>FRACBITS, y>>FRACBITS);
CONS_Alert(CONS_ERROR, "Failed to spawn map thing #%d at %d, %d. This will crash vanilla clients!\n", mthing->type, x>>FRACBITS, y>>FRACBITS);
return;
}
+19 -8
View File
@@ -283,9 +283,9 @@ typedef struct mobj_s
struct mobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr
// More drawing info: to determine current sprite.
angle_t angle; // orientation
angle_t old_angle; // orientation interpolation
angle_t old_angle2;
angle_t angle, pitch, roll; // orientation
angle_t old_angle, old_pitch, old_roll; // orientation interpolation
angle_t old_angle2, old_pitch2, old_roll2;
angle_t rollangle;
spritenum_t sprite; // used to find patch_t and flip value
UINT32 frame; // frame number, plus bits see p_pspr.h
@@ -302,7 +302,10 @@ typedef struct mobj_s
fixed_t stretchslam; // "squish" effect when you land
//sloperollangle
angle_t sloperoll, reservezangle, reservexydir;
angle_t sloperoll, slopepitch;
angle_t old_sloperoll, old_slopepitch;
angle_t old_sloperoll2, old_slopepitch2;
angle_t pitch_sprite, roll_sprite;
struct msecnode_s *touching_sectorlist; // a linked list of sectors where this object appears
@@ -395,6 +398,7 @@ typedef struct mobj_s
boolean resetinterp; // if true, some fields should not be interpolated (see R_InterpolateMobjState implementation)
boolean colorized; // Whether the mobj uses the rainbow colormap
boolean mirrored; // The object's rotations will be mirrored left to right, e.g., see frame AL from the right and AR from the left
boolean rollmodel; // OpenGL: Should this model rotate?
tic_t slamsoundtimer;
@@ -432,9 +436,9 @@ typedef struct precipmobj_s
struct precipmobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr
// More drawing info: to determine current sprite.
angle_t angle; // orientation
angle_t old_angle; // orientation interpolation
angle_t old_angle2;
angle_t angle, pitch, roll; // orientation
angle_t old_angle, old_pitch, old_roll; // orientation interpolation
angle_t old_angle2, old_pitch2, old_roll2;
angle_t rollangle;
spritenum_t sprite; // used to find patch_t and flip value
UINT32 frame; // frame number, plus bits see p_pspr.h
@@ -451,7 +455,10 @@ typedef struct precipmobj_s
fixed_t stretchslam; // "squish" effect when you land
//sloperollangle
angle_t sloperoll, reservezangle, reservexydir;
angle_t sloperoll, slopepitch;
angle_t old_sloperoll, old_slopepitch;
angle_t old_sloperoll2, old_slopepitch2;
angle_t pitch_sprite, roll_sprite;
struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears
@@ -493,6 +500,10 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum);
// check mobj against water content, before movement code
void P_MobjCheckWater(mobj_t *mobj);
// fancy sprite rotation
void P_RollPitchMobj(mobj_t *mobj);
angle_t P_MobjPitchAndRoll(mobj_t *mobj);
// Player spawn points
void P_SpawnPlayer(INT32 playernum);
void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing);
+2
View File
@@ -37,6 +37,8 @@
/// \brief Frame flags: only the frame number
#define FF_FRAMEMASK 0x1ff
/// \brief Frame flags: Flip sprite horizontally
#define FF_HORIZONTALFLIP 0x400
/// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION)
#define FF_PAPERSPRITE 0x800
/// \brief Frame flags: Simple stateless animation
+19 -5
View File
@@ -1976,14 +1976,28 @@ static void LoadMobjThinker(actionf_p1 thinker)
mobj->thinker.function.acp1 = thinker;
mobj->rollangle = 0;
mobj->spritexoffset = mobj->spriteyoffset = mobj->old_spritexoffset = mobj->old_spriteyoffset = FRACUNIT;
mobj->spritexscale = mobj->spriteyscale = mobj->old_spritexscale = mobj->old_spriteyscale = FRACUNIT;
mobj->realxscale = mobj->realyscale = FRACUNIT;
mobj->pitch = 0;
mobj->roll = 0;
mobj->sloperoll = 0;
mobj->slopepitch = 0;
mobj->pitch_sprite = 0;
mobj->roll_sprite = 0;
mobj->spritexoffset = mobj->old_spritexoffset = 0;
mobj->spriteyoffset = mobj->old_spriteyoffset = 0;
mobj->spritexscale = mobj->old_spritexscale = FRACUNIT;
mobj->spriteyscale = mobj->old_spriteyscale = FRACUNIT;
mobj->realxscale = FRACUNIT;
mobj->realyscale = FRACUNIT;
mobj->stretchslam = 0;
mobj->slamsoundtimer = 0;
mobj->sloperoll = mobj->reservezangle = mobj->reservexydir = 0;
mobj->mirrored = 0;
mobj->z = z;
mobj->floorz = floorz;
mobj->ceilingz = ceilingz;
+23 -7
View File
@@ -2936,7 +2936,9 @@ boolean P_SetupLevel(boolean skipprecip)
// Make sure all sounds are stopped before Z_FreeTags.
S_StopSounds();
S_ClearSfx();
if (!S_PrecacheSound())
S_ClearSfx();
// As oddly named as this is, this handles music only.
// We should be fine starting it here.
@@ -3148,7 +3150,11 @@ boolean P_SetupLevel(boolean skipprecip)
// Correct missing sidedefs & deep water trick
HWR_CorrectSWTricks();
HWR_CreatePlanePolygons((INT32)numnodes - 1);
if (HWR_ShouldUsePaletteRendering()) //unsure if this is the right place, but seems to work since we dont have HWR_LoadLevel like srb2
HWR_SetMapPalette();
}
#endif
// oh god I hope this helps
@@ -3490,11 +3496,8 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
if (wadfiles[wadnum]->important)
partadd_important = true;
if (local)
wadfiles[wadnum]->localfile = true;
else
wadfiles[wadnum]->localfile = false;
wadfiles[wadnum]->localfile = local;
//
// search for sound replacements
@@ -3503,11 +3506,12 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
for (i = 0; i < numlumps; i++, lumpinfo++)
{
name = lumpinfo->name;
lumpnum_t lumpnum = i|(wadnum<<16);
if (name[0] == 'D')
{
if (name[1] == 'S') for (j = 1; j < NUMSFX; j++)
{
if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6))
if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6) && S_sfx[j].lumpnum != lumpnum && S_sfx[j].lumpnum != LUMPERROR)
{
// the sound will be reloaded when needed,
// since sfx->data will be NULL
@@ -3515,6 +3519,10 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
I_FreeSfx(&S_sfx[j]);
// Re-cache it
if (S_PrecacheSound())
S_sfx[j].data = I_GetSfx(&S_sfx[j]);
sreplaces++;
}
}
@@ -3554,6 +3562,11 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
//
S_LoadMusicDefs(wadnum);
//
// edit music defs for stuff like musictest
//
S_LoadMTDefs(wadnum);
//
// search for maps
//
@@ -3587,6 +3600,9 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
if (!mapsadded)
CONS_Printf(M_GetText("No maps added\n"));
// TODO: Experimental SPRTINFO support, test first
R_LoadSpriteInfoLumps(wadnum, wadfiles[wadnum]->numlumps);
refreshdirmenu &= ~REFRESHDIR_GAMEDATA; // Under usual circumstances we'd wait for REFRESHDIR_GAMEDATA to disappear the next frame, but it's a bit too dangerous for that...
partadd_stage = 0;
return wadnum;
+89 -30
View File
@@ -2002,14 +2002,53 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller)
//
void P_SwitchWeather(INT32 weathernum)
{
boolean purge = true;
boolean raintype = (PRECIP_SNOW || PRECIP_RAIN || PRECIP_STORM || PRECIP_STORM_NOSTRIKES || PRECIP_BLANK);
boolean purge = false;
INT32 swap = 0;
if (weathernum == curWeather)
return;
if (weathernum == raintype && curWeather == raintype)
purge = false;
switch (weathernum)
{
case PRECIP_NONE: // None
if (curWeather == PRECIP_NONE)
return; // Nothing to do.
purge = true;
break;
case PRECIP_STORM: // Storm
case PRECIP_STORM_NOSTRIKES: // Storm w/ no lightning
case PRECIP_RAIN: // Rain
if (curWeather == PRECIP_SNOW || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN)
swap = PRECIP_RAIN;
break;
case PRECIP_SNOW: // Snow
if (curWeather == PRECIP_SNOW)
return; // Nothing to do.
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN)
swap = PRECIP_SNOW; // Need to delete the other precips.
break;
case PRECIP_STORM_NORAIN: // Storm w/o rain
if (curWeather == PRECIP_SNOW
|| curWeather == PRECIP_STORM
|| curWeather == PRECIP_STORM_NOSTRIKES
|| curWeather == PRECIP_RAIN
|| curWeather == PRECIP_BLANK)
swap = PRECIP_STORM_NORAIN;
else if (curWeather == PRECIP_STORM_NORAIN)
return;
break;
case PRECIP_BLANK:
if (curWeather == PRECIP_SNOW
|| curWeather == PRECIP_STORM
|| curWeather == PRECIP_STORM_NOSTRIKES
|| curWeather == PRECIP_RAIN)
swap = PRECIP_BLANK;
else if (curWeather == PRECIP_STORM_NORAIN)
swap = PRECIP_BLANK;
else if (curWeather == PRECIP_BLANK)
return;
break;
default:
CONS_Debug(DBG_GAMELOGIC, "P_SwitchWeather: Unknown weather type %d.\n", weathernum);
break;
}
if (purge)
{
@@ -2026,7 +2065,7 @@ void P_SwitchWeather(INT32 weathernum)
P_RemovePrecipMobj(precipmobj);
}
}
else // Rather than respawn all that crap, reuse it!
else if (swap && !((swap == PRECIP_BLANK && curWeather == PRECIP_STORM_NORAIN) || (swap == PRECIP_STORM_NORAIN && curWeather == PRECIP_BLANK))) // Rather than respawn all that crap, reuse it!
{
thinker_t *think;
precipmobj_t *precipmobj;
@@ -2038,7 +2077,7 @@ void P_SwitchWeather(INT32 weathernum)
continue; // not a precipmobj thinker
precipmobj = (precipmobj_t *)think;
if (weathernum == PRECIP_RAIN || weathernum == PRECIP_STORM || weathernum == PRECIP_STORM_NOSTRIKES) // Snow To Rain
if (swap == PRECIP_RAIN) // Snow To Rain
{
precipmobj->flags = mobjinfo[MT_RAIN].flags;
st = &states[mobjinfo[MT_RAIN].spawnstate];
@@ -2053,7 +2092,7 @@ void P_SwitchWeather(INT32 weathernum)
precipmobj->precipflags |= PCF_RAIN;
//think->function.acp1 = (actionf_p1)P_RainThinker;
}
else if (weathernum == PRECIP_SNOW) // Rain To Snow
else if (swap == PRECIP_SNOW) // Rain To Snow
{
INT32 z;
@@ -2078,7 +2117,7 @@ void P_SwitchWeather(INT32 weathernum)
//think->function.acp1 = (actionf_p1)P_SnowThinker;
}
else // Remove precip, but keep it around for reuse.
else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse.
{
//think->function.acp1 = (actionf_p1)P_NullPrecipThinker;
@@ -2092,31 +2131,48 @@ void P_SwitchWeather(INT32 weathernum)
case PRECIP_SNOW: // snow
curWeather = PRECIP_SNOW;
if (purge)
if (!swap)
P_SpawnPrecipitation();
break;
case PRECIP_RAIN: // rain
{
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_RAIN;
if (purge)
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
}
case PRECIP_STORM: // storm
{
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_STORM;
if (purge)
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
}
case PRECIP_STORM_NOSTRIKES: // storm w/o lightning
{
if (purge)
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_STORM_NOSTRIKES;
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
@@ -2124,11 +2180,14 @@ void P_SwitchWeather(INT32 weathernum)
case PRECIP_STORM_NORAIN: // storm w/o rain
curWeather = PRECIP_STORM_NORAIN;
if (!swap)
P_SpawnPrecipitation();
break;
case PRECIP_BLANK: //preloaded
case PRECIP_BLANK:
curWeather = PRECIP_BLANK;
if (purge)
if (!swap)
P_SpawnPrecipitation();
break;
@@ -3568,8 +3627,8 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
case 5: // Spikes
// Don't do anything. In Soviet Russia, spikes find you.
break;
case 6: // Death Pit (Camera Mod)
case 7: // Death Pit (No Camera Mod)
case 6: // Death Pit (Camera Tilt)
case 7: // Death Pit (No Camera Tilt)
if (roversector || P_MobjReadyToTrigger(player->mo, sector))
P_DamageMobj(player->mo, NULL, NULL, 10000);
break;
@@ -3626,8 +3685,8 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
{
case 1: // Trigger Linedef Exec (Pushable Objects)
break;
case 2: // Linedef executor requires all players present+doesn't require touching floor
case 3: // Linedef executor requires all players present
case 2: // Linedef executor requires all players present+doesn't require touching floor // Trigger Linedef Exec (Anywhere, All Players)
case 3: // Linedef executor requires all players present // Trigger Linedef Exec (Floor Touch, All Players)
/// \todo check continues for proper splitscreen support?
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && !players[i].bot && players[i].mo && (gametype != GT_COOP || players[i].lives > 0))
@@ -3684,16 +3743,16 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
}
}
/* FALLTHRU */
case 4: // Linedef executor that doesn't require touching floor
case 5: // Linedef executor
case 6: // Linedef executor (7 Emeralds)
case 7: // Linedef executor (NiGHTS Mare)
case 4: // Linedef executor that doesn't require touching floor // Trigger Linedef Exec (Anywhere in Sector)
case 5: // Linedef executor // Trigger Linedef Exec (Floor Touch)
case 6: // Linedef executor (7 Emeralds) // unused
case 7: // SRB2kart: Linedef executor (Race Lap)
if (!player->bot)
P_LinedefExecute(sector->tag, player->mo, sector);
break;
case 8: // Tells pushable things to check FOFs
case 8: // Tells pushable things to check FOFs // Check for Linedef Executor on FOFs
break;
case 9: // Egg trap capsule
case 9: // Egg trap capsule // unused
{
thinker_t *th;
mobj_t *mo2;
@@ -3733,12 +3792,12 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
P_DoPlayerExit(&players[i]);
break;
}
case 10: // Special Stage Time/Rings
case 10: // Special Stage Time/Rings // unused
case 11: // Custom Gravity
break;
case 12: // Lua sector special
case 12: // SRB2kart: Invert Encore Remap
break;
case 15: // Invert Encore Remap
case 15: // no idea but keep it dont want anything to break
break;
}
DoneSection2:
+9 -2
View File
@@ -662,7 +662,10 @@ void P_Ticker(boolean run)
ps_checkposition_calls.value.i = 0;
#ifdef HAVE_BLUA
PS_START_TIMING(ps_lua_prethinkframe_time);
LUAh_PreThinkFrame();
PS_STOP_TIMING(ps_lua_prethinkframe_time);
#endif
PS_START_TIMING(ps_playerthink_time);
@@ -772,8 +775,6 @@ void P_Ticker(boolean run)
quake.x = M_RandomRange(-ir,ir);
quake.y = M_RandomRange(-ir,ir);
quake.z = M_RandomRange(-ir,ir);
if (cv_windowquake.value)
I_CursedWindowMovement(FixedInt(quake.x), FixedInt(quake.y));
ir >>= 2;
ir = M_RandomRange(-ir,ir);
if (ir < 0)
@@ -825,7 +826,11 @@ void P_Ticker(boolean run)
D_MapChange(gamemap, gametype, encoremode, true, 0, false, false);
#ifdef HAVE_BLUA
PS_START_TIMING(ps_lua_postthinkframe_time);
LUAh_PostThinkFrame();
PS_STOP_TIMING(ps_lua_postthinkframe_time);
#endif
}
@@ -920,6 +925,8 @@ void P_PreTicker(INT32 frames)
// Run shield positioning
//P_RunShields();
P_RunOverlays();
P_RunShadows();
P_UpdateSpecials();
P_RespawnSpecials();
+37 -12
View File
@@ -1281,13 +1281,17 @@ void P_RestoreMusic(player_t *player)
if (wantedmus == 2 && cv_growmusic.value)
{
S_ChangeMusicInternal("kgrow", true);
S_SetRestoreMusicFadeInCvar(&cv_growmusicfade);
if (cv_birdmusic.value)
S_SetRestoreMusicFadeInCvar(&cv_growmusicfade);
}
// Item - Invincibility
else if (wantedmus == 1 && cv_supermusic.value)
{
S_ChangeMusicInternal("kinvnc", true);
S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade);
if (cv_birdmusic.value)
S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade);
}
else
{
@@ -1297,14 +1301,20 @@ void P_RestoreMusic(player_t *player)
if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1))
S_SpeedMusic(1.2f);
#endif
if (mapmusresume && cv_resume.value)
position = mapmusresume;
else
position = mapmusposition;
if (cv_birdmusic.value)
{
if (mapmusresume && cv_resume.value)
position = mapmusresume;
else
position = mapmusposition;
S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0,
S_GetRestoreMusicFadeIn());
S_ClearRestoreMusicFadeInCvar();
S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0,
S_GetRestoreMusicFadeIn());
S_ClearRestoreMusicFadeInCvar();
}
else
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
mapmusresume = 0;
}
}
@@ -1687,11 +1697,15 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
else
ghost->angle = mobj->angle;
ghost->pitch = mobj->pitch;
ghost->roll = mobj->roll;
ghost->sprite = mobj->sprite;
ghost->frame = mobj->frame;
ghost->tics = -1;
ghost->frame &= ~FF_TRANSMASK;
ghost->frame |= tr_trans50<<FF_TRANSSHIFT;
ghost->slopepitch = mobj->slopepitch;
ghost->sloperoll = mobj->sloperoll;
ghost->fuse = ghost->info->damage;
@@ -1714,6 +1728,10 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
ghost->old_y = mobj->old_y2;
ghost->old_z = mobj->old_z2;
ghost->old_angle = (mobj->player ? mobj->player->old_frameangle2 : mobj->old_angle2);
ghost->old_pitch = mobj->old_pitch2;
ghost->old_roll = mobj->old_roll2;
ghost->old_sloperoll = mobj->old_sloperoll2;
ghost->old_slopepitch = mobj->old_slopepitch2;
return ghost;
}
@@ -7159,7 +7177,6 @@ consvar_t cv_quaketilt = {"quaketilt", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL,
consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_windowquake = {"windowquake", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
fixed_t t_cam_dist = -42;
fixed_t t_cam_height = -42;
@@ -8063,7 +8080,7 @@ boolean P_SpectatorJoinGame(player_t *player)
// Pressing fire assigns you to a team that needs players if allowed.
// Partial code reproduction from p_tick.c autobalance code.
else if (G_GametypeHasTeams())
{
{
INT32 changeto = 0;
INT32 z, numplayersred = 0, numplayersblue = 0;
@@ -8099,6 +8116,10 @@ boolean P_SpectatorJoinGame(player_t *player)
player->kartstuff[k_spectatewait] = 0;
player->ctfteam = changeto;
player->playerstate = PST_REBORN;
//center camera if its not already
if ((P_IsLocalPlayer(player)) && localaiming[0] != 0)
localaiming[0] = 0;
//Reset away view
if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer)
@@ -8113,7 +8134,7 @@ boolean P_SpectatorJoinGame(player_t *player)
}
// Joining in game from firing.
else
{
{
if (player->mo)
{
P_RemoveMobj(player->mo);
@@ -8124,6 +8145,10 @@ boolean P_SpectatorJoinGame(player_t *player)
player->kartstuff[k_spectatewait] = 0;
player->playerstate = PST_REBORN;
//center camera if its not already
if ((P_IsLocalPlayer(player)) && localaiming[0] != 0)
localaiming[0] = 0;
//Reset away view
if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer)
displayplayers[0] = consoleplayer;
Loaded 100 of 138 files, more files were not shown because too many files have changed in this diff. Show more