Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Zandronum source code
- * Copyright (C) 2012 Santeri Piippo
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the Skulltag Development Team nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- * 4. Redistributions in any form must be accompanied by information on how to
- * obtain complete source code for the software and any accompanying
- * software that uses the software. The source code must either be included
- * in the distribution or be available for no more than the cost of
- * distribution plus a nominal fee, and must be freely redistributable
- * under reasonable conditions. For an executable file, complete source
- * code means the source code for all modules it contains. It does not
- * include source code for modules or files that typically accompany the
- * major components of the operating system on which the executable file
- * runs.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * Filename: votedef.h
- *
- * Description: VOTEDEF declarations
- *
- * -----------------------------------------------------------------------------
- */
- #ifndef VOTEDEF_H
- #define VOTEDEF_H
- #include "zstring.h"
- #include "basictypes.h"
- #include "networkshared.h"
- #include "doomdef.h"
- class FBaseCVar;
- class VoteDef
- {
- public:
- // ============================================================================
- // Vote parameter types
- enum ArgumentType
- {
- Int, // integer number
- Float, // floating point number
- Player, // any valid player
- MapType, // map type for changemap and map
- NumArgTypes, // end of parm list, must be last in this list!
- };
- // ============================================================================
- // Flags for votes
- enum
- {
- NoPassedLimit = ( 1 << 0 ), // this vote can be called without delay as long as it passes
- NotSelf = ( 1 << 1 ), // player argument must not be the caller
- NotAdmin = ( 1 << 2 ), // player argument must not be an admin
- PlayerIndex = ( 1 << 3 ), // player argument given as an index instead of a name
- PlayerInGame = ( 1 << 4 ), // player given must be in game
- NumFlags = 5 // end of vote list
- };
- // ============================================================================
- // Native type - also tokens for k_NativeNames
- enum NativeType
- {
- Kick,
- KickFromGame,
- ChangeMap,
- Map,
- FragLimit,
- TimeLimit,
- PointLimit,
- DuelLimit,
- WinLimit,
- NumNatives,
- };
- // ============================================================================
- // Enum type for k_PropertyTokens
- enum
- {
- VTPROP_ARGUMENT,
- VTPROP_ACSSCRIPT,
- VTPROP_DESCRIPTION,
- VTPROP_FLAGS,
- VTPROP_FORBIDCVAR,
- VTPROP_VALUERANGE,
- };
- // ============================================================================
- // Structure for input for ApplyCommand
- struct ApplyInput
- {
- unsigned type; // Type of vote
- FString arg; // Vote argument
- FString reason; // Reason string
- unsigned yes, no; // Count of yes/no votes
- unsigned caller; // Index of vote caller
- };
- // ============================================================================
- // Structure for result from ApplyCommand
- struct ApplyResult
- {
- FString command; // Resulting command string (natives)
- FString error; // Failed? Why?
- long arg; // Script argument
- };
- // ============================================================================
- VoteDef( const FString& name, NativeType native );
- ~VoteDef( );
- const ArgumentType& argType( ) const;
- void copyTo( VoteDef* other ) const;
- const FString& description( ) const;
- const DWORD& flags( ) const;
- FBaseCVar* forbidCVar( ) const;
- int getIndex( ) const;
- FString getUsage( ) const;
- const float& max( ) const;
- const float& min( ) const;
- const FString& name( ) const;
- const NativeType& nativeType( ) const;
- const ULONG& scriptNum( ) const;
- // ============================================================================
- static bool applyCommand( ApplyInput input, ApplyResult& result );
- static void deinit( );
- static VoteDef* findByIndex( unsigned index );
- static VoteDef* findByName( FString name );
- static void init( );
- static FString makeSummary( const ApplyInput& input );
- static unsigned numTypes( );
- static void parseLump( int lump );
- static void storeIPAddresses( );
- protected:
- // ============================================================================
- FString m_name; // Name of the type
- ULONG m_script; // Script number to execute
- DWORD m_flags; // Flags of this vote
- ArgumentType m_argType; // Argument type
- FString m_description; // Description string
- FBaseCVar* m_forbidCVar; // CVar that forbids the use of this vote
- bool m_autogenForbidCVar; // Was the name of the CVar auto-generated?
- float m_min, m_max; // Minimum and maximum input values
- NativeType m_native; // Native vote type, these have special behavior.
- // ============================================================================
- static TArray<VoteDef*> k_Defs; // The one array of vote type definitions.
- static NETADDRESS_s k_IPStorage[MAXPLAYERS]; // IP addresses of clients for kick votes.
- static const char* k_ParameterTokens[]; // Tokens for the parser
- static const char* k_PropertyTokens[];
- static const char* k_FlagTokens[];
- static const char* k_NativeNames[];
- // Is the given player an admin as far as +ISADMIN is concerned?
- static bool playerIsAdmin( ULONG idx );
- };
- #endif // VOTEDEF_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement