updating to the latest ioquake3 version

This commit is contained in:
Richard Allen 2010-08-22 04:27:48 +00:00
parent 71a4c5d261
commit 5aab7746ae
148 changed files with 12655 additions and 10236 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* Main include header for the SDL library */
/** @file SDL.h
* Main include header for the SDL library
*/
#ifndef _SDL_H
#define _SDL_H
@ -47,41 +49,46 @@
extern "C" {
#endif
/* As of version 0.5, SDL is loaded dynamically into the application */
/** @file SDL.h
* @note As of version 0.5, SDL is loaded dynamically into the application
*/
/* These are the flags which may be passed to SDL_Init() -- you should
specify the subsystems which you will be using in your application.
*/
/** @name SDL_INIT Flags
* These are the flags which may be passed to SDL_Init() -- you should
* specify the subsystems which you will be using in your application.
*/
/*@{*/
#define SDL_INIT_TIMER 0x00000001
#define SDL_INIT_AUDIO 0x00000010
#define SDL_INIT_VIDEO 0x00000020
#define SDL_INIT_CDROM 0x00000100
#define SDL_INIT_JOYSTICK 0x00000200
#define SDL_INIT_NOPARACHUTE 0x00100000 /* Don't catch fatal signals */
#define SDL_INIT_EVENTTHREAD 0x01000000 /* Not supported on all OS's */
#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */
#define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */
#define SDL_INIT_EVERYTHING 0x0000FFFF
/*@}*/
/* This function loads the SDL dynamically linked library and initializes
* the subsystems specified by 'flags' (and those satisfying dependencies)
* Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
* signal handlers for some commonly ignored fatal signals (like SIGSEGV)
/** This function loads the SDL dynamically linked library and initializes
* the subsystems specified by 'flags' (and those satisfying dependencies)
* Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
* signal handlers for some commonly ignored fatal signals (like SIGSEGV)
*/
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
/* This function initializes specific SDL subsystems */
/** This function initializes specific SDL subsystems */
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
/* This function cleans up specific SDL subsystems */
/** This function cleans up specific SDL subsystems */
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
/* This function returns mask of the specified subsystems which have
been initialized.
If 'flags' is 0, it returns a mask of all initialized subsystems.
*/
/** This function returns mask of the specified subsystems which have
* been initialized.
* If 'flags' is 0, it returns a mask of all initialized subsystems.
*/
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
/* This function cleans up all initialized subsystems and unloads the
* dynamically linked library. You should call it upon all exit conditions.
/** This function cleans up all initialized subsystems and unloads the
* dynamically linked library. You should call it upon all exit conditions.
*/
extern DECLSPEC void SDLCALL SDL_Quit(void);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,10 @@
slouken@libsdl.org
*/
/* Include file for SDL application focus event handling */
/**
* @file SDL_active.h
* Include file for SDL application focus event handling
*/
#ifndef _SDL_active_h
#define _SDL_active_h
@ -34,13 +37,15 @@
extern "C" {
#endif
/* The available application states */
#define SDL_APPMOUSEFOCUS 0x01 /* The app has mouse coverage */
#define SDL_APPINPUTFOCUS 0x02 /* The app has input focus */
#define SDL_APPACTIVE 0x04 /* The application is active */
/** @name The available application states */
/*@{*/
#define SDL_APPMOUSEFOCUS 0x01 /**< The app has mouse coverage */
#define SDL_APPINPUTFOCUS 0x02 /**< The app has input focus */
#define SDL_APPACTIVE 0x04 /**< The application is active */
/*@}*/
/* Function prototypes */
/*
/**
* This function returns the current state of the application, which is a
* bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
* SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,10 @@
slouken@libsdl.org
*/
/* Access to the raw audio mixing buffer for the SDL library */
/**
* @file SDL_audio.h
* Access to the raw audio mixing buffer for the SDL library
*/
#ifndef _SDL_audio_h
#define _SDL_audio_h
@ -38,89 +41,11 @@
extern "C" {
#endif
/* The calculated values in this structure are calculated by SDL_OpenAudio() */
typedef struct SDL_AudioSpec {
int freq; /* DSP frequency -- samples per second */
Uint16 format; /* Audio data format */
Uint8 channels; /* Number of channels: 1 mono, 2 stereo */
Uint8 silence; /* Audio buffer silence value (calculated) */
Uint16 samples; /* Audio buffer size in samples (power of 2) */
Uint16 padding; /* Necessary for some compile environments */
Uint32 size; /* Audio buffer size in bytes (calculated) */
/* This function is called when the audio device needs more data.
'stream' is a pointer to the audio data buffer
'len' is the length of that buffer in bytes.
Once the callback returns, the buffer will no longer be valid.
Stereo samples are stored in a LRLRLR ordering.
*/
void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len);
void *userdata;
} SDL_AudioSpec;
/* Audio format flags (defaults to LSB byte order) */
#define AUDIO_U8 0x0008 /* Unsigned 8-bit samples */
#define AUDIO_S8 0x8008 /* Signed 8-bit samples */
#define AUDIO_U16LSB 0x0010 /* Unsigned 16-bit samples */
#define AUDIO_S16LSB 0x8010 /* Signed 16-bit samples */
#define AUDIO_U16MSB 0x1010 /* As above, but big-endian byte order */
#define AUDIO_S16MSB 0x9010 /* As above, but big-endian byte order */
#define AUDIO_U16 AUDIO_U16LSB
#define AUDIO_S16 AUDIO_S16LSB
/* Native audio byte ordering */
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define AUDIO_U16SYS AUDIO_U16LSB
#define AUDIO_S16SYS AUDIO_S16LSB
#else
#define AUDIO_U16SYS AUDIO_U16MSB
#define AUDIO_S16SYS AUDIO_S16MSB
#endif
/* A structure to hold a set of audio conversion filters and buffers */
typedef struct SDL_AudioCVT {
int needed; /* Set to 1 if conversion possible */
Uint16 src_format; /* Source audio format */
Uint16 dst_format; /* Target audio format */
double rate_incr; /* Rate conversion increment */
Uint8 *buf; /* Buffer to hold entire audio data */
int len; /* Length of original audio buffer */
int len_cvt; /* Length of converted audio buffer */
int len_mult; /* buffer must be len*len_mult big */
double len_ratio; /* Given len, final size is len*len_ratio */
void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
int filter_index; /* Current audio conversion function */
} SDL_AudioCVT;
/* Function prototypes */
/* These functions are used internally, and should not be used unless you
* have a specific need to specify the audio driver you want to use.
* You should normally use SDL_Init() or SDL_InitSubSystem().
*/
extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
/* This function fills the given character buffer with the name of the
* current audio driver, and returns a pointer to it if the audio driver has
* been initialized. It returns NULL if no driver has been initialized.
*/
extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
/*
* This function opens the audio device with the desired parameters, and
* returns 0 if successful, placing the actual hardware parameters in the
* structure pointed to by 'obtained'. If 'obtained' is NULL, the audio
* data passed to the callback function will be guaranteed to be in the
* requested format, and will be automatically converted to the hardware
* audio format if necessary. This function returns -1 if it failed
* to open the audio device, or couldn't set up the audio thread.
*
/**
* When filling in the desired audio spec structure,
* 'desired->freq' should be the desired audio frequency in samples-per-second.
* 'desired->format' should be the desired audio format.
* 'desired->samples' is the desired size of the audio buffer, in samples.
* - 'desired->freq' should be the desired audio frequency in samples-per-second.
* - 'desired->format' should be the desired audio format.
* - 'desired->samples' is the desired size of the audio buffer, in samples.
* This number should be a power of two, and may be adjusted by the audio
* driver to a value more suitable for the hardware. Good values seem to
* range between 512 and 8096 inclusive, depending on the application and
@ -130,38 +55,138 @@ extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
* and left channels in LR ordering.
* Note that the number of samples is directly related to time by the
* following formula: ms = (samples*1000)/freq
* 'desired->size' is the size in bytes of the audio buffer, and is
* - 'desired->size' is the size in bytes of the audio buffer, and is
* calculated by SDL_OpenAudio().
* 'desired->silence' is the value used to set the buffer to silence,
* - 'desired->silence' is the value used to set the buffer to silence,
* and is calculated by SDL_OpenAudio().
* 'desired->callback' should be set to a function that will be called
* - 'desired->callback' should be set to a function that will be called
* when the audio device is ready for more data. It is passed a pointer
* to the audio buffer, and the length in bytes of the audio buffer.
* This function usually runs in a separate thread, and so you should
* protect data structures that it accesses by calling SDL_LockAudio()
* and SDL_UnlockAudio() in your code.
* 'desired->userdata' is passed as the first parameter to your callback
* - 'desired->userdata' is passed as the first parameter to your callback
* function.
*
* @note The calculated values in this structure are calculated by SDL_OpenAudio()
*
*/
typedef struct SDL_AudioSpec {
int freq; /**< DSP frequency -- samples per second */
Uint16 format; /**< Audio data format */
Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */
Uint8 silence; /**< Audio buffer silence value (calculated) */
Uint16 samples; /**< Audio buffer size in samples (power of 2) */
Uint16 padding; /**< Necessary for some compile environments */
Uint32 size; /**< Audio buffer size in bytes (calculated) */
/**
* This function is called when the audio device needs more data.
*
* @param[out] stream A pointer to the audio data buffer
* @param[in] len The length of the audio buffer in bytes.
*
* Once the callback returns, the buffer will no longer be valid.
* Stereo samples are stored in a LRLRLR ordering.
*/
void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len);
void *userdata;
} SDL_AudioSpec;
/**
* @name Audio format flags
* defaults to LSB byte order
*/
/*@{*/
#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */
#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */
#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */
#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */
#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */
#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */
#define AUDIO_U16 AUDIO_U16LSB
#define AUDIO_S16 AUDIO_S16LSB
/**
* @name Native audio byte ordering
*/
/*@{*/
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define AUDIO_U16SYS AUDIO_U16LSB
#define AUDIO_S16SYS AUDIO_S16LSB
#else
#define AUDIO_U16SYS AUDIO_U16MSB
#define AUDIO_S16SYS AUDIO_S16MSB
#endif
/*@}*/
/*@}*/
/** A structure to hold a set of audio conversion filters and buffers */
typedef struct SDL_AudioCVT {
int needed; /**< Set to 1 if conversion possible */
Uint16 src_format; /**< Source audio format */
Uint16 dst_format; /**< Target audio format */
double rate_incr; /**< Rate conversion increment */
Uint8 *buf; /**< Buffer to hold entire audio data */
int len; /**< Length of original audio buffer */
int len_cvt; /**< Length of converted audio buffer */
int len_mult; /**< buffer must be len*len_mult big */
double len_ratio; /**< Given len, final size is len*len_ratio */
void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
int filter_index; /**< Current audio conversion function */
} SDL_AudioCVT;
/* Function prototypes */
/**
* @name Audio Init and Quit
* These functions are used internally, and should not be used unless you
* have a specific need to specify the audio driver you want to use.
* You should normally use SDL_Init() or SDL_InitSubSystem().
*/
/*@{*/
extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
/*@}*/
/**
* This function fills the given character buffer with the name of the
* current audio driver, and returns a pointer to it if the audio driver has
* been initialized. It returns NULL if no driver has been initialized.
*/
extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
/**
* This function opens the audio device with the desired parameters, and
* returns 0 if successful, placing the actual hardware parameters in the
* structure pointed to by 'obtained'. If 'obtained' is NULL, the audio
* data passed to the callback function will be guaranteed to be in the
* requested format, and will be automatically converted to the hardware
* audio format if necessary. This function returns -1 if it failed
* to open the audio device, or couldn't set up the audio thread.
*
* The audio device starts out playing silence when it's opened, and should
* be enabled for playing by calling SDL_PauseAudio(0) when you are ready
* for your audio callback function to be called. Since the audio driver
* may modify the requested size of the audio buffer, you should allocate
* any local mixing buffers after you open the audio device.
*
* @sa SDL_AudioSpec
*/
extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
/*
* Get the current audio state:
*/
typedef enum {
SDL_AUDIO_STOPPED = 0,
SDL_AUDIO_PLAYING,
SDL_AUDIO_PAUSED
} SDL_audiostatus;
/** Get the current audio state */
extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void);
/*
/**
* This function pauses and unpauses the audio callback processing.
* It should be called with a parameter of 0 after opening the audio
* device to start playing sound. This is so you can safely initialize
@ -170,11 +195,11 @@ extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void);
*/
extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
/*
/**
* This function loads a WAVE from the data source, automatically freeing
* that source if 'freesrc' is non-zero. For example, to load a WAVE file,
* you could do:
* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
* @code SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); @endcode
*
* If this function succeeds, it returns the given SDL_AudioSpec,
* filled with the audio data format of the wave data, and sets
@ -189,27 +214,29 @@ extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
*/
extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
/* Compatibility convenience function -- loads a WAV from a file */
/** Compatibility convenience function -- loads a WAV from a file */
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
/*
/**
* This function frees data previously allocated with SDL_LoadWAV_RW()
*/
extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf);
/*
/**
* This function takes a source format and rate and a destination format
* and rate, and initializes the 'cvt' structure with information needed
* by SDL_ConvertAudio() to convert a buffer of audio data from one format
* to the other.
* This function returns 0, or -1 if there was an error.
*
* @return This function returns 0, or -1 if there was an error.
*/
extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
Uint16 src_format, Uint8 src_channels, int src_rate,
Uint16 dst_format, Uint8 dst_channels, int dst_rate);
/* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
/**
* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
* created an audio buffer cvt->buf, and filled it with cvt->len bytes of
* audio data in the source format, this function will convert it in-place
* to the desired format.
@ -219,26 +246,30 @@ extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
*/
extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt);
/*
#define SDL_MIX_MAXVOLUME 128
/**
* This takes two audio buffers of the playing audio format and mixes
* them, performing addition, volume adjustment, and overflow clipping.
* The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
* for full audio volume. Note this does not change hardware volume.
* This is provided for convenience -- you can mix your own audio data.
*/
#define SDL_MIX_MAXVOLUME 128
extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume);
/*
/**
* @name Audio Locks
* The lock manipulated by these functions protects the callback function.
* During a LockAudio/UnlockAudio pair, you can be guaranteed that the
* callback function is not running. Do not call these from the callback
* function or you will cause deadlock.
*/
/*@{*/
extern DECLSPEC void SDLCALL SDL_LockAudio(void);
extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
/*@}*/
/*
/**
* This function shuts down audio processing and closes the audio device.
*/
extern DECLSPEC void SDLCALL SDL_CloseAudio(void);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,5 +20,10 @@
slouken@libsdl.org
*/
/**
* @file SDL_byteorder.h
* @deprecated Use SDL_endian.h instead
*/
/* DEPRECATED */
#include "SDL_endian.h"

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,10 @@
slouken@libsdl.org
*/
/* This is the CD-audio control API for Simple DirectMedia Layer */
/**
* @file SDL_cdrom.h
* This is the CD-audio control API for Simple DirectMedia Layer
*/
#ifndef _SDL_cdrom_h
#define _SDL_cdrom_h
@ -34,19 +37,25 @@
extern "C" {
#endif
/* In order to use these functions, SDL_Init() must have been called
with the SDL_INIT_CDROM flag. This causes SDL to scan the system
for CD-ROM drives, and load appropriate drivers.
*/
/**
* @file SDL_cdrom.h
* In order to use these functions, SDL_Init() must have been called
* with the SDL_INIT_CDROM flag. This causes SDL to scan the system
* for CD-ROM drives, and load appropriate drivers.
*/
/* The maximum number of CD-ROM tracks on a disk */
/** The maximum number of CD-ROM tracks on a disk */
#define SDL_MAX_TRACKS 99
/* The types of CD-ROM track possible */
/** @name Track Types
* The types of CD-ROM track possible
*/
/*@{*/
#define SDL_AUDIO_TRACK 0x00
#define SDL_DATA_TRACK 0x04
/*@}*/
/* The possible states which a CD-ROM drive can be in. */
/** The possible states which a CD-ROM drive can be in. */
typedef enum {
CD_TRAYEMPTY,
CD_STOPPED,
@ -55,30 +64,35 @@ typedef enum {
CD_ERROR = -1
} CDstatus;
/* Given a status, returns true if there's a disk in the drive */
/** Given a status, returns true if there's a disk in the drive */
#define CD_INDRIVE(status) ((int)(status) > 0)
typedef struct SDL_CDtrack {
Uint8 id; /* Track number */
Uint8 type; /* Data or audio track */
Uint8 id; /**< Track number */
Uint8 type; /**< Data or audio track */
Uint16 unused;
Uint32 length; /* Length, in frames, of this track */
Uint32 offset; /* Offset, in frames, from start of disk */
Uint32 length; /**< Length, in frames, of this track */
Uint32 offset; /**< Offset, in frames, from start of disk */
} SDL_CDtrack;
/* This structure is only current as of the last call to SDL_CDStatus() */
/** This structure is only current as of the last call to SDL_CDStatus() */
typedef struct SDL_CD {
int id; /* Private drive identifier */
CDstatus status; /* Current drive status */
int id; /**< Private drive identifier */
CDstatus status; /**< Current drive status */
/* The rest of this structure is only valid if there's a CD in drive */
int numtracks; /* Number of tracks on disk */
int cur_track; /* Current track position */
int cur_frame; /* Current frame offset within current track */
/** The rest of this structure is only valid if there's a CD in drive */
/*@{*/
int numtracks; /**< Number of tracks on disk */
int cur_track; /**< Current track position */
int cur_frame; /**< Current frame offset within current track */
SDL_CDtrack track[SDL_MAX_TRACKS+1];
/*@}*/
} SDL_CD;
/* Conversion functions from frames to Minute/Second/Frames and vice versa */
/** @name Frames / MSF Conversion Functions
* Conversion functions from frames to Minute/Second/Frames and vice versa
*/
/*@{*/
#define CD_FPS 75
#define FRAMES_TO_MSF(f, M,S,F) { \
int value = f; \
@ -89,76 +103,93 @@ typedef struct SDL_CD {
*(M) = value; \
}
#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F))
/*@}*/
/* CD-audio API functions: */
/* Returns the number of CD-ROM drives on the system, or -1 if
SDL_Init() has not been called with the SDL_INIT_CDROM flag.
/**
* Returns the number of CD-ROM drives on the system, or -1 if
* SDL_Init() has not been called with the SDL_INIT_CDROM flag.
*/
extern DECLSPEC int SDLCALL SDL_CDNumDrives(void);
/* Returns a human-readable, system-dependent identifier for the CD-ROM.
Example:
"/dev/cdrom"
"E:"
"/dev/disk/ide/1/master"
*/
/**
* Returns a human-readable, system-dependent identifier for the CD-ROM.
* Example:
* - "/dev/cdrom"
* - "E:"
* - "/dev/disk/ide/1/master"
*/
extern DECLSPEC const char * SDLCALL SDL_CDName(int drive);
/* Opens a CD-ROM drive for access. It returns a drive handle on success,
or NULL if the drive was invalid or busy. This newly opened CD-ROM
becomes the default CD used when other CD functions are passed a NULL
CD-ROM handle.
Drives are numbered starting with 0. Drive 0 is the system default CD-ROM.
*/
/**
* Opens a CD-ROM drive for access. It returns a drive handle on success,
* or NULL if the drive was invalid or busy. This newly opened CD-ROM
* becomes the default CD used when other CD functions are passed a NULL
* CD-ROM handle.
* Drives are numbered starting with 0. Drive 0 is the system default CD-ROM.
*/
extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive);
/* This function returns the current status of the given drive.
If the drive has a CD in it, the table of contents of the CD and current
play position of the CD will be stored in the SDL_CD structure.
*/
/**
* This function returns the current status of the given drive.
* If the drive has a CD in it, the table of contents of the CD and current
* play position of the CD will be stored in the SDL_CD structure.
*/
extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom);
/* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play
until the end of the CD. This function will skip data tracks.
This function should only be called after calling SDL_CDStatus() to
get track information about the CD.
For example:
// Play entire CD:
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
// Play last track:
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
}
// Play first and second track and 10 seconds of third track:
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
This function returns 0, or -1 if there was an error.
*/
/**
* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
* tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play
* until the end of the CD. This function will skip data tracks.
* This function should only be called after calling SDL_CDStatus() to
* get track information about the CD.
* For example:
* @code
* // Play entire CD:
* if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
* SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
* // Play last track:
* if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
* SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
* }
* // Play first and second track and 10 seconds of third track:
* if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
* SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
* @endcode
*
* @return This function returns 0, or -1 if there was an error.
*/
extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom,
int start_track, int start_frame, int ntracks, int nframes);
/* Play the given CD starting at 'start' frame for 'length' frames.
It returns 0, or -1 if there was an error.
*/
/**
* Play the given CD starting at 'start' frame for 'length' frames.
* @return It returns 0, or -1 if there was an error.
*/
extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length);
/* Pause play -- returns 0, or -1 on error */
/** Pause play
* @return returns 0, or -1 on error
*/
extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom);
/* Resume play -- returns 0, or -1 on error */
/** Resume play
* @return returns 0, or -1 on error
*/
extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom);
/* Stop play -- returns 0, or -1 on error */
/** Stop play
* @return returns 0, or -1 on error
*/
extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom);
/* Eject CD-ROM -- returns 0, or -1 on error */
/** Eject CD-ROM
* @return returns 0, or -1 on error
*/
extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom);
/* Closes the handle for the CD-ROM drive */
/** Closes the handle for the CD-ROM drive */
extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -26,14 +26,14 @@
#include "SDL_platform.h"
/* Add any platform that doesn't build using the configure system */
#if defined(__AMIGA__)
#include "SDL_config_amiga.h"
#elif defined(__DREAMCAST__)
#if defined(__DREAMCAST__)
#include "SDL_config_dreamcast.h"
#elif defined(__MACOS__)
#include "SDL_config_macos.h"
#elif defined(__MACOSX__)
#include "SDL_config_macosx.h"
#elif defined(__SYMBIAN32__)
#include "SDL_config_symbian.h" /* must be before win32! */
#elif defined(__WIN32__)
#include "SDL_config_win32.h"
#elif defined(__OS2__)

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -25,6 +25,9 @@
#include "SDL_platform.h"
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
#include <AvailabilityMacros.h>
/* This is a set of defines to configure the SDL features */
#define SDL_HAS_64BIT_TYPE 1
@ -87,7 +90,6 @@
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_COREAUDIO 1
#define SDL_AUDIO_DRIVER_SNDMGR 1
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
@ -114,14 +116,30 @@
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_DUMMY 1
#if TARGET_API_MAC_CARBON
#if ((defined TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON))
#define SDL_VIDEO_DRIVER_TOOLBOX 1
#else
#define SDL_VIDEO_DRIVER_QUARTZ 1
#endif
#define SDL_VIDEO_DRIVER_DGA 1
#define SDL_VIDEO_DRIVER_X11 1
#define SDL_VIDEO_DRIVER_X11_DGAMOUSE 1
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER "/usr/X11R6/lib/libXrender.1.dylib"
#define SDL_VIDEO_DRIVER_X11_VIDMODE 1
#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
#define SDL_VIDEO_DRIVER_X11_XME 1
#define SDL_VIDEO_DRIVER_X11_XRANDR 1
#define SDL_VIDEO_DRIVER_X11_XV 1
/* Enable OpenGL support */
#define SDL_VIDEO_OPENGL 1
#define SDL_VIDEO_OPENGL_GLX 1
/* Disable screensaver */
#define SDL_VIDEO_DISABLE_SCREENSAVER 1
/* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -27,7 +27,7 @@
/* This is a set of defines to configure the SDL features */
#ifdef __GNUC__
#if defined(__GNUC__) || defined(__DMC__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
@ -46,6 +46,13 @@ typedef unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
#define DWORD_PTR DWORD
#endif
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
#endif
#else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
@ -165,6 +172,9 @@ typedef unsigned int uintptr_t;
#define SDL_VIDEO_OPENGL_WGL 1
#endif
/* Disable screensaver */
#define SDL_VIDEO_DISABLE_SCREENSAVER 1
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES 1

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,8 +20,10 @@
slouken@libsdl.org
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* CPU feature detection for SDL */
/**
* @file SDL_cpuinfo.h
* CPU feature detection for SDL
*/
#ifndef _SDL_cpuinfo_h
#define _SDL_cpuinfo_h
@ -34,36 +36,28 @@
extern "C" {
#endif
/* This function returns true if the CPU has the RDTSC instruction
*/
/** This function returns true if the CPU has the RDTSC instruction */
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
/* This function returns true if the CPU has MMX features
*/
/** This function returns true if the CPU has MMX features */
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
/* This function returns true if the CPU has MMX Ext. features
*/
/** This function returns true if the CPU has MMX Ext. features */
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void);
/* This function returns true if the CPU has 3DNow features
*/
/** This function returns true if the CPU has 3DNow features */
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
/* This function returns true if the CPU has 3DNow! Ext. features
*/
/** This function returns true if the CPU has 3DNow! Ext. features */
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void);
/* This function returns true if the CPU has SSE features
*/
/** This function returns true if the CPU has SSE features */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
/* This function returns true if the CPU has SSE2 features
*/
/** This function returns true if the CPU has SSE2 features */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
/* This function returns true if the CPU has AltiVec features
*/
/** This function returns true if the CPU has AltiVec features */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
/* Ends C function definitions when using C++ */

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,16 +20,23 @@
slouken@libsdl.org
*/
/* Functions for reading and writing endian-specific values */
/**
* @file SDL_endian.h
* Functions for reading and writing endian-specific values
*/
#ifndef _SDL_endian_h
#define _SDL_endian_h
#include "SDL_stdinc.h"
/* The two types of endianness */
/** @name SDL_ENDIANs
* The two types of endianness
*/
/*@{*/
#define SDL_LIL_ENDIAN 1234
#define SDL_BIG_ENDIAN 4321
/*@}*/
#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
#if defined(__hppa__) || \
@ -50,13 +57,16 @@
extern "C" {
#endif
/* Use inline functions for compilers that support them, and static
functions for those that do not. Because these functions become
static for compilers that do not support inline functions, this
header should only be included in files that actually use them.
*/
/**
* @name SDL_Swap Functions
* Use inline functions for compilers that support them, and static
* functions for those that do not. Because these functions become
* static for compilers that do not support inline functions, this
* header should only be included in files that actually use them.
*/
/*@{*/
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
static __inline__ Uint16 SDL_Swap16(Uint16 x)
{
__asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x));
@ -88,7 +98,8 @@ static __inline__ Uint16 SDL_Swap16(Uint16 x) {
}
#endif
#if defined(__GNUC__) && defined(__i386__)
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
static __inline__ Uint32 SDL_Swap32(Uint32 x)
{
__asm__("bswap %0" : "=r" (x) : "0" (x));
@ -123,7 +134,8 @@ static __inline__ Uint32 SDL_Swap32(Uint32 x) {
#endif
#ifdef SDL_HAS_64BIT_TYPE
#if defined(__GNUC__) && defined(__i386__)
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
static __inline__ Uint64 SDL_Swap64(Uint64 x)
{
union {
@ -148,9 +160,9 @@ static __inline__ Uint64 SDL_Swap64(Uint64 x)
Uint32 hi, lo;
/* Separate into high and low 32-bit values and swap them */
lo = (Uint32)(x&0xFFFFFFFF);
lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
x >>= 32;
hi = (Uint32)(x&0xFFFFFFFF);
hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
x = SDL_Swap32(lo);
x <<= 32;
x |= SDL_Swap32(hi);
@ -159,14 +171,18 @@ static __inline__ Uint64 SDL_Swap64(Uint64 x)
#endif
#else
/* This is mainly to keep compilers from complaining in SDL code.
If there is no real 64-bit datatype, then compilers will complain about
the fake 64-bit datatype that SDL provides when it compiles user code.
*/
* If there is no real 64-bit datatype, then compilers will complain about
* the fake 64-bit datatype that SDL provides when it compiles user code.
*/
#define SDL_Swap64(X) (X)
#endif /* SDL_HAS_64BIT_TYPE */
/*@}*/
/* Byteswap item from the specified endianness to the native endianness */
/**
* @name SDL_SwapLE and SDL_SwapBE Functions
* Byteswap item from the specified endianness to the native endianness
*/
/*@{*/
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define SDL_SwapLE16(X) (X)
#define SDL_SwapLE32(X) (X)
@ -182,6 +198,7 @@ static __inline__ Uint64 SDL_Swap64(Uint64 x)
#define SDL_SwapBE32(X) (X)
#define SDL_SwapBE64(X) (X)
#endif
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,10 @@
slouken@libsdl.org
*/
/* Simple error message routines for SDL */
/**
* @file SDL_error.h
* Simple error message routines for SDL
*/
#ifndef _SDL_error_h
#define _SDL_error_h
@ -33,12 +36,20 @@
extern "C" {
#endif
/* Public functions */
/**
* @name Public functions
*/
/*@{*/
extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...);
extern DECLSPEC char * SDLCALL SDL_GetError(void);
extern DECLSPEC void SDLCALL SDL_ClearError(void);
/*@}*/
/* Private error message function - used internally */
/**
* @name Private functions
* @internal Private error message function - used internally
*/
/*@{*/
#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
typedef enum {
@ -50,7 +61,7 @@ typedef enum {
SDL_LASTERROR
} SDL_errorcode;
extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,10 @@
slouken@libsdl.org
*/
/* Include file for SDL event handling */
/**
* @file SDL_events.h
* Include file for SDL event handling
*/
#ifndef _SDL_events_h
#define _SDL_events_h
@ -39,45 +42,48 @@
extern "C" {
#endif
/* General keyboard/mouse state definitions */
/** @name General keyboard/mouse state definitions */
/*@{*/
#define SDL_RELEASED 0
#define SDL_PRESSED 1
/*@}*/
/* Event enumerations */
/** Event enumerations */
typedef enum {
SDL_NOEVENT = 0, /* Unused (do not remove) */
SDL_ACTIVEEVENT, /* Application loses/gains visibility */
SDL_KEYDOWN, /* Keys pressed */
SDL_KEYUP, /* Keys released */
SDL_MOUSEMOTION, /* Mouse moved */
SDL_MOUSEBUTTONDOWN, /* Mouse button pressed */
SDL_MOUSEBUTTONUP, /* Mouse button released */
SDL_JOYAXISMOTION, /* Joystick axis motion */
SDL_JOYBALLMOTION, /* Joystick trackball motion */
SDL_JOYHATMOTION, /* Joystick hat position change */
SDL_JOYBUTTONDOWN, /* Joystick button pressed */
SDL_JOYBUTTONUP, /* Joystick button released */
SDL_QUIT, /* User-requested quit */
SDL_SYSWMEVENT, /* System specific event */
SDL_EVENT_RESERVEDA, /* Reserved for future use.. */
SDL_EVENT_RESERVEDB, /* Reserved for future use.. */
SDL_VIDEORESIZE, /* User resized video mode */
SDL_VIDEOEXPOSE, /* Screen needs to be redrawn */
SDL_EVENT_RESERVED2, /* Reserved for future use.. */
SDL_EVENT_RESERVED3, /* Reserved for future use.. */
SDL_EVENT_RESERVED4, /* Reserved for future use.. */
SDL_EVENT_RESERVED5, /* Reserved for future use.. */
SDL_EVENT_RESERVED6, /* Reserved for future use.. */
SDL_EVENT_RESERVED7, /* Reserved for future use.. */
/* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */
SDL_NOEVENT = 0, /**< Unused (do not remove) */
SDL_ACTIVEEVENT, /**< Application loses/gains visibility */
SDL_KEYDOWN, /**< Keys pressed */
SDL_KEYUP, /**< Keys released */
SDL_MOUSEMOTION, /**< Mouse moved */
SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
SDL_MOUSEBUTTONUP, /**< Mouse button released */
SDL_JOYAXISMOTION, /**< Joystick axis motion */
SDL_JOYBALLMOTION, /**< Joystick trackball motion */
SDL_JOYHATMOTION, /**< Joystick hat position change */
SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
SDL_JOYBUTTONUP, /**< Joystick button released */
SDL_QUIT, /**< User-requested quit */
SDL_SYSWMEVENT, /**< System specific event */
SDL_EVENT_RESERVEDA, /**< Reserved for future use.. */
SDL_EVENT_RESERVEDB, /**< Reserved for future use.. */
SDL_VIDEORESIZE, /**< User resized video mode */
SDL_VIDEOEXPOSE, /**< Screen needs to be redrawn */
SDL_EVENT_RESERVED2, /**< Reserved for future use.. */
SDL_EVENT_RESERVED3, /**< Reserved for future use.. */
SDL_EVENT_RESERVED4, /**< Reserved for future use.. */
SDL_EVENT_RESERVED5, /**< Reserved for future use.. */
SDL_EVENT_RESERVED6, /**< Reserved for future use.. */
SDL_EVENT_RESERVED7, /**< Reserved for future use.. */
/** Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */
SDL_USEREVENT = 24,
/* This last event is only for bounding internal arrays
It is the number of bits in the event mask datatype -- Uint32
/** This last event is only for bounding internal arrays
* It is the number of bits in the event mask datatype -- Uint32
*/
SDL_NUMEVENTS = 32
} SDL_EventType;
/* Predefined event masks */
/** @name Predefined event masks */
/*@{*/
#define SDL_EVENTMASK(X) (1<<(X))
typedef enum {
SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT),
@ -107,108 +113,109 @@ typedef enum {
SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT)
} SDL_EventMask ;
#define SDL_ALLEVENTS 0xFFFFFFFF
/*@}*/
/* Application visibility event structure */
/** Application visibility event structure */
typedef struct SDL_ActiveEvent {
Uint8 type; /* SDL_ACTIVEEVENT */
Uint8 gain; /* Whether given states were gained or lost (1/0) */
Uint8 state; /* A mask of the focus states */
Uint8 type; /**< SDL_ACTIVEEVENT */
Uint8 gain; /**< Whether given states were gained or lost (1/0) */
Uint8 state; /**< A mask of the focus states */
} SDL_ActiveEvent;
/* Keyboard event structure */
/** Keyboard event structure */
typedef struct SDL_KeyboardEvent {
Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */
Uint8 which; /* The keyboard device index */
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */
Uint8 which; /**< The keyboard device index */
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
SDL_keysym keysym;
} SDL_KeyboardEvent;
/* Mouse motion event structure */
/** Mouse motion event structure */
typedef struct SDL_MouseMotionEvent {
Uint8 type; /* SDL_MOUSEMOTION */
Uint8 which; /* The mouse device index */
Uint8 state; /* The current button state */
Uint16 x, y; /* The X/Y coordinates of the mouse */
Sint16 xrel; /* The relative motion in the X direction */
Sint16 yrel; /* The relative motion in the Y direction */
Uint8 type; /**< SDL_MOUSEMOTION */
Uint8 which; /**< The mouse device index */
Uint8 state; /**< The current button state */
Uint16 x, y; /**< The X/Y coordinates of the mouse */
Sint16 xrel; /**< The relative motion in the X direction */
Sint16 yrel; /**< The relative motion in the Y direction */
} SDL_MouseMotionEvent;
/* Mouse button event structure */
/** Mouse button event structure */
typedef struct SDL_MouseButtonEvent {
Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
Uint8 which; /* The mouse device index */
Uint8 button; /* The mouse button index */
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
Uint16 x, y; /* The X/Y coordinates of the mouse at press time */
Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
Uint8 which; /**< The mouse device index */
Uint8 button; /**< The mouse button index */
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
Uint16 x, y; /**< The X/Y coordinates of the mouse at press time */
} SDL_MouseButtonEvent;
/* Joystick axis motion event structure */
/** Joystick axis motion event structure */
typedef struct SDL_JoyAxisEvent {
Uint8 type; /* SDL_JOYAXISMOTION */
Uint8 which; /* The joystick device index */
Uint8 axis; /* The joystick axis index */
Sint16 value; /* The axis value (range: -32768 to 32767) */
Uint8 type; /**< SDL_JOYAXISMOTION */
Uint8 which; /**< The joystick device index */
Uint8 axis; /**< The joystick axis index */
Sint16 value; /**< The axis value (range: -32768 to 32767) */
} SDL_JoyAxisEvent;
/* Joystick trackball motion event structure */
/** Joystick trackball motion event structure */
typedef struct SDL_JoyBallEvent {
Uint8 type; /* SDL_JOYBALLMOTION */
Uint8 which; /* The joystick device index */
Uint8 ball; /* The joystick trackball index */
Sint16 xrel; /* The relative motion in the X direction */
Sint16 yrel; /* The relative motion in the Y direction */
Uint8 type; /**< SDL_JOYBALLMOTION */
Uint8 which; /**< The joystick device index */
Uint8 ball; /**< The joystick trackball index */
Sint16 xrel; /**< The relative motion in the X direction */
Sint16 yrel; /**< The relative motion in the Y direction */
} SDL_JoyBallEvent;
/* Joystick hat position change event structure */
/** Joystick hat position change event structure */
typedef struct SDL_JoyHatEvent {
Uint8 type; /* SDL_JOYHATMOTION */
Uint8 which; /* The joystick device index */
Uint8 hat; /* The joystick hat index */
Uint8 value; /* The hat position value:
SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
Note that zero means the POV is centered.
*/
Uint8 type; /**< SDL_JOYHATMOTION */
Uint8 which; /**< The joystick device index */
Uint8 hat; /**< The joystick hat index */
Uint8 value; /**< The hat position value:
* SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
* SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
* SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
* Note that zero means the POV is centered.
*/
} SDL_JoyHatEvent;
/* Joystick button event structure */
/** Joystick button event structure */
typedef struct SDL_JoyButtonEvent {
Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
Uint8 which; /* The joystick device index */
Uint8 button; /* The joystick button index */
Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
Uint8 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
Uint8 which; /**< The joystick device index */
Uint8 button; /**< The joystick button index */
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
} SDL_JoyButtonEvent;
/* The "window resized" event
When you get this event, you are responsible for setting a new video
mode with the new width and height.
/** The "window resized" event
* When you get this event, you are responsible for setting a new video
* mode with the new width and height.
*/
typedef struct SDL_ResizeEvent {
Uint8 type; /* SDL_VIDEORESIZE */
int w; /* New width */
int h; /* New height */
Uint8 type; /**< SDL_VIDEORESIZE */
int w; /**< New width */
int h; /**< New height */
} SDL_ResizeEvent;
/* The "screen redraw" event */
/** The "screen redraw" event */
typedef struct SDL_ExposeEvent {
Uint8 type; /* SDL_VIDEOEXPOSE */
Uint8 type; /**< SDL_VIDEOEXPOSE */
} SDL_ExposeEvent;
/* The "quit requested" event */
/** The "quit requested" event */
typedef struct SDL_QuitEvent {
Uint8 type; /* SDL_QUIT */
Uint8 type; /**< SDL_QUIT */
} SDL_QuitEvent;
/* A user-defined event type */
/** A user-defined event type */
typedef struct SDL_UserEvent {
Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */
int code; /* User defined event code */
void *data1; /* User defined data pointer */
void *data2; /* User defined data pointer */
Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */
int code; /**< User defined event code */
void *data1; /**< User defined data pointer */
void *data2; /**< User defined data pointer */
} SDL_UserEvent;
/* If you want to use this event, you should include SDL_syswm.h */
/** If you want to use this event, you should include SDL_syswm.h */
struct SDL_SysWMmsg;
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
typedef struct SDL_SysWMEvent {
@ -216,7 +223,7 @@ typedef struct SDL_SysWMEvent {
SDL_SysWMmsg *msg;
} SDL_SysWMEvent;
/* General event structure */
/** General event structure */
typedef union SDL_Event {
Uint8 type;
SDL_ActiveEvent active;
@ -237,96 +244,108 @@ typedef union SDL_Event {
/* Function prototypes */
/* Pumps the event loop, gathering events from the input devices.
This function updates the event queue and internal input device state.
This should only be run in the thread that sets the video mode.
*/
/** Pumps the event loop, gathering events from the input devices.
* This function updates the event queue and internal input device state.
* This should only be run in the thread that sets the video mode.
*/
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
/* Checks the event queue for messages and optionally returns them.
If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
the back of the event queue.
If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
of the event queue, matching 'mask', will be returned and will not
be removed from the queue.
If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
of the event queue, matching 'mask', will be returned and will be
removed from the queue.
This function returns the number of events actually stored, or -1
if there was an error. This function is thread-safe.
*/
typedef enum {
SDL_ADDEVENT,
SDL_PEEKEVENT,
SDL_GETEVENT
} SDL_eventaction;
/* */
/**
* Checks the event queue for messages and optionally returns them.
*
* If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
* the back of the event queue.
* If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
* of the event queue, matching 'mask', will be returned and will not
* be removed from the queue.
* If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
* of the event queue, matching 'mask', will be returned and will be
* removed from the queue.
*
* @return
* This function returns the number of events actually stored, or -1
* if there was an error.
*
* This function is thread-safe.
*/
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents,
SDL_eventaction action, Uint32 mask);
/* Polls for currently pending events, and returns 1 if there are any pending
events, or 0 if there are none available. If 'event' is not NULL, the next
event is removed from the queue and stored in that area.
/** Polls for currently pending events, and returns 1 if there are any pending
* events, or 0 if there are none available. If 'event' is not NULL, the next
* event is removed from the queue and stored in that area.
*/
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event);
/* Waits indefinitely for the next available event, returning 1, or 0 if there
was an error while waiting for events. If 'event' is not NULL, the next
event is removed from the queue and stored in that area.
/** Waits indefinitely for the next available event, returning 1, or 0 if there
* was an error while waiting for events. If 'event' is not NULL, the next
* event is removed from the queue and stored in that area.
*/
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event);
/* Add an event to the event queue.
This function returns 0 on success, or -1 if the event queue was full
or there was some other error.
/** Add an event to the event queue.
* This function returns 0 on success, or -1 if the event queue was full
* or there was some other error.
*/
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event);
/*
This function sets up a filter to process all events before they
change internal state and are posted to the internal event queue.
The filter is protypted as:
*/
/** @name Event Filtering */
/*@{*/
typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event);
/*
If the filter returns 1, then the event will be added to the internal queue.
If it returns 0, then the event will be dropped from the queue, but the
internal state will still be updated. This allows selective filtering of
dynamically arriving events.
WARNING: Be very careful of what you do in the event filter function, as
it may run in a different thread!
There is one caveat when dealing with the SDL_QUITEVENT event type. The
event filter is only called when the window manager desires to close the
application window. If the event filter returns 1, then the window will
be closed, otherwise the window will remain open if possible.
If the quit event is generated by an interrupt signal, it will bypass the
internal queue and be delivered to the application at the next event poll.
*/
/**
* This function sets up a filter to process all events before they
* change internal state and are posted to the internal event queue.
*
* The filter is protypted as:
* @code typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); @endcode
*
* If the filter returns 1, then the event will be added to the internal queue.
* If it returns 0, then the event will be dropped from the queue, but the
* internal state will still be updated. This allows selective filtering of
* dynamically arriving events.
*
* @warning Be very careful of what you do in the event filter function, as
* it may run in a different thread!
*
* There is one caveat when dealing with the SDL_QUITEVENT event type. The
* event filter is only called when the window manager desires to close the
* application window. If the event filter returns 1, then the window will
* be closed, otherwise the window will remain open if possible.
* If the quit event is generated by an interrupt signal, it will bypass the
* internal queue and be delivered to the application at the next event poll.
*/
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter);
/*
Return the current event filter - can be used to "chain" filters.
If there is no event filter set, this function returns NULL.
*/
/**
* Return the current event filter - can be used to "chain" filters.
* If there is no event filter set, this function returns NULL.
*/
extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void);
/*@}*/
/*
This function allows you to set the state of processing certain events.
If 'state' is set to SDL_IGNORE, that event will be automatically dropped
from the event queue and will not event be filtered.
If 'state' is set to SDL_ENABLE, that event will be processed normally.
If 'state' is set to SDL_QUERY, SDL_EventState() will return the
current processing state of the specified event.
*/
/** @name Event State */
/*@{*/
#define SDL_QUERY -1
#define SDL_IGNORE 0
#define SDL_DISABLE 0
#define SDL_ENABLE 1
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state);
/*@}*/
/**
* This function allows you to set the state of processing certain events.
* If 'state' is set to SDL_IGNORE, that event will be automatically dropped
* from the event queue and will not event be filtered.
* If 'state' is set to SDL_ENABLE, that event will be processed normally.
* If 'state' is set to SDL_QUERY, SDL_EventState() will return the
* current processing state of the specified event.
*/
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,5 +20,9 @@
slouken@libsdl.org
*/
/** @file SDL_getenv.h
* @deprecated Use SDL_stdinc.h instead
*/
/* DEPRECATED */
#include "SDL_stdinc.h"

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* Include file for SDL joystick event handling */
/** @file SDL_joystick.h
* Include file for SDL joystick event handling
*/
#ifndef _SDL_joystick_h
#define _SDL_joystick_h
@ -34,97 +36,108 @@
extern "C" {
#endif
/* In order to use these functions, SDL_Init() must have been called
with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
for joysticks, and load appropriate drivers.
*/
/** @file SDL_joystick.h
* @note In order to use these functions, SDL_Init() must have been called
* with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
* for joysticks, and load appropriate drivers.
*/
/* The joystick structure used to identify an SDL joystick */
/** The joystick structure used to identify an SDL joystick */
struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick;
/* Function prototypes */
/*
/**
* Count the number of joysticks attached to the system
*/
extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
/*
/**
* Get the implementation dependent name of a joystick.
*
* This can be called before any joysticks are opened.
* If no name can be found, this function returns NULL.
*/
extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index);
/*
* Open a joystick for use - the index passed as an argument refers to
/**
* Open a joystick for use.
*
* @param[in] device_index
* The index passed as an argument refers to
* the N'th joystick on the system. This index is the value which will
* identify this joystick in future joystick events.
*
* This function returns a joystick identifier, or NULL if an error occurred.
* @return This function returns a joystick identifier, or NULL if an error occurred.
*/
extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index);
/*
/**
* Returns 1 if the joystick has been opened, or 0 if it has not.
*/
extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index);
/*
/**
* Get the device index of an opened joystick.
*/
extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick);
/*
/**
* Get the number of general axis controls on a joystick
*/
extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
/*
/**
* Get the number of trackballs on a joystick
*
* Joystick trackballs have only relative motion events associated
* with them and their state cannot be polled.
*/
extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
/*
/**
* Get the number of POV hats on a joystick
*/
extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
/*
/**
* Get the number of buttons on a joystick
*/
extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick);
/*
/**
* Update the current state of the open joysticks.
*
* This is called automatically by the event loop if any joystick
* events are enabled.
*/
extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
/*
/**
* Enable/disable joystick event polling.
*
* If joystick events are disabled, you must call SDL_JoystickUpdate()
* yourself and check the state of the joystick when you want joystick
* information.
* The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
*
* @param[in] state The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
*/
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
/*
/**
* Get the current state of an axis control on a joystick
* The state is a value ranging from -32768 to 32767.
* The axis indices start at index 0.
*
* @param[in] axis The axis indices start at index 0.
*
* @return The state is a value ranging from -32768 to 32767.
*/
extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
/*
* Get the current state of a POV hat on a joystick
* The return value is one of the following positions:
/**
* @name Hat Positions
* The return value of SDL_JoystickGetHat() is one of the following positions:
*/
/*@{*/
#define SDL_HAT_CENTERED 0x00
#define SDL_HAT_UP 0x01
#define SDL_HAT_RIGHT 0x02
@ -134,25 +147,32 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int a
#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
/*
* The hat indices start at index 0.
/*@}*/
/**
* Get the current state of a POV hat on a joystick
*
* @param[in] hat The hat indices start at index 0.
*/
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
/*
/**
* Get the ball axis change since the last poll
* This returns 0, or -1 if you passed it invalid parameters.
* The ball indices start at index 0.
*
* @param[in] ball The ball indices start at index 0.
*
* @return This returns 0, or -1 if you passed it invalid parameters.
*/
extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
/*
/**
* Get the current state of a button on a joystick
* The button indices start at index 0.
*
* @param[in] button The button indices start at index 0.
*/
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button);
/*
/**
* Close a joystick previously opened with SDL_JoystickOpen()
*/
extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* Include file for SDL keyboard event handling */
/** @file SDL_keyboard.h
* Include file for SDL keyboard event handling
*/
#ifndef _SDL_keyboard_h
#define _SDL_keyboard_h
@ -35,78 +37,90 @@
extern "C" {
#endif
/* Keysym structure
- The scancode is hardware dependent, and should not be used by general
applications. If no hardware scancode is available, it will be 0.
- The 'unicode' translated character is only available when character
translation is enabled by the SDL_EnableUNICODE() API. If non-zero,
this is a UNICODE character corresponding to the keypress. If the
high 9 bits of the character are 0, then this maps to the equivalent
ASCII character:
char ch;
if ( (keysym.unicode & 0xFF80) == 0 ) {
ch = keysym.unicode & 0x7F;
} else {
An international character..
}
/** Keysym structure
*
* - The scancode is hardware dependent, and should not be used by general
* applications. If no hardware scancode is available, it will be 0.
*
* - The 'unicode' translated character is only available when character
* translation is enabled by the SDL_EnableUNICODE() API. If non-zero,
* this is a UNICODE character corresponding to the keypress. If the
* high 9 bits of the character are 0, then this maps to the equivalent
* ASCII character:
* @code
* char ch;
* if ( (keysym.unicode & 0xFF80) == 0 ) {
* ch = keysym.unicode & 0x7F;
* } else {
* An international character..
* }
* @endcode
*/
typedef struct SDL_keysym {
Uint8 scancode; /* hardware specific scancode */
SDLKey sym; /* SDL virtual keysym */
SDLMod mod; /* current key modifiers */
Uint16 unicode; /* translated character */
Uint8 scancode; /**< hardware specific scancode */
SDLKey sym; /**< SDL virtual keysym */
SDLMod mod; /**< current key modifiers */
Uint16 unicode; /**< translated character */
} SDL_keysym;
/* This is the mask which refers to all hotkey bindings */
/** This is the mask which refers to all hotkey bindings */
#define SDL_ALL_HOTKEYS 0xFFFFFFFF
/* Function prototypes */
/*
/**
* Enable/Disable UNICODE translation of keyboard input.
*
* This translation has some overhead, so translation defaults off.
*
* @param[in] enable
* If 'enable' is 1, translation is enabled.
* If 'enable' is 0, translation is disabled.
* If 'enable' is -1, the translation state is not changed.
* It returns the previous state of keyboard translation.
*
* @return It returns the previous state of keyboard translation.
*/
extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
/*
* Enable/Disable keyboard repeat. Keyboard repeat defaults to off.
* 'delay' is the initial delay in ms between the time when a key is
* pressed, and keyboard repeat begins.
* 'interval' is the time in ms between keyboard repeat events.
*/
#define SDL_DEFAULT_REPEAT_DELAY 500
#define SDL_DEFAULT_REPEAT_INTERVAL 30
/*
* If 'delay' is set to 0, keyboard repeat is disabled.
/**
* Enable/Disable keyboard repeat. Keyboard repeat defaults to off.
*
* @param[in] delay
* 'delay' is the initial delay in ms between the time when a key is
* pressed, and keyboard repeat begins.
*
* @param[in] interval
* 'interval' is the time in ms between keyboard repeat events.
*
* If 'delay' is set to 0, keyboard repeat is disabled.
*/
extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
/*
/**
* Get a snapshot of the current state of the keyboard.
* Returns an array of keystates, indexed by the SDLK_* syms.
* Used:
* Usage:
* @code
* Uint8 *keystate = SDL_GetKeyState(NULL);
* if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
* if ( keystate[SDLK_RETURN] ) //... \<RETURN> is pressed.
* @endcode
*/
extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys);
/*
/**
* Get the current key modifier state
*/
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
/*
* Set the current key modifier state
/**
* Set the current key modifier state.
* This does not change the keyboard state, only the key modifier flags.
*/
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
/*
/**
* Get the name of an SDL virtual keysym
*/
extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -23,14 +23,16 @@
#ifndef _SDL_keysym_h
#define _SDL_keysym_h
/* What we really want is a mapping of every raw key on the keyboard.
To support international keyboards, we use the range 0xA1 - 0xFF
as international virtual keycodes. We'll follow in the footsteps of X11...
The names of the keys
/** What we really want is a mapping of every raw key on the keyboard.
* To support international keyboards, we use the range 0xA1 - 0xFF
* as international virtual keycodes. We'll follow in the footsteps of X11...
* @brief The names of the keys
*/
typedef enum {
/* The keyboard syms have been cleverly chosen to map to ASCII */
/** @name ASCII mapped keysyms
* The keyboard syms have been cleverly chosen to map to ASCII
*/
/*@{*/
SDLK_UNKNOWN = 0,
SDLK_FIRST = 0,
SDLK_BACKSPACE = 8,
@ -108,8 +110,10 @@ typedef enum {
SDLK_z = 122,
SDLK_DELETE = 127,
/* End of ASCII mapped keysyms */
/*@}*/
/* International keyboard syms */
/** @name International keyboard syms */
/*@{*/
SDLK_WORLD_0 = 160, /* 0xA0 */
SDLK_WORLD_1 = 161,
SDLK_WORLD_2 = 162,
@ -206,8 +210,10 @@ typedef enum {
SDLK_WORLD_93 = 253,
SDLK_WORLD_94 = 254,
SDLK_WORLD_95 = 255, /* 0xFF */
/*@}*/
/* Numeric keypad */
/** @name Numeric keypad */
/*@{*/
SDLK_KP0 = 256,
SDLK_KP1 = 257,
SDLK_KP2 = 258,
@ -225,8 +231,10 @@ typedef enum {
SDLK_KP_PLUS = 270,
SDLK_KP_ENTER = 271,
SDLK_KP_EQUALS = 272,
/*@}*/
/* Arrows + Home/End pad */
/** @name Arrows + Home/End pad */
/*@{*/
SDLK_UP = 273,
SDLK_DOWN = 274,
SDLK_RIGHT = 275,
@ -236,8 +244,10 @@ typedef enum {
SDLK_END = 279,
SDLK_PAGEUP = 280,
SDLK_PAGEDOWN = 281,
/*@}*/
/* Function keys */
/** @name Function keys */
/*@{*/
SDLK_F1 = 282,
SDLK_F2 = 283,
SDLK_F3 = 284,
@ -253,8 +263,10 @@ typedef enum {
SDLK_F13 = 294,
SDLK_F14 = 295,
SDLK_F15 = 296,
/*@}*/
/* Key state modifier keys */
/** @name Key state modifier keys */
/*@{*/
SDLK_NUMLOCK = 300,
SDLK_CAPSLOCK = 301,
SDLK_SCROLLOCK = 302,
@ -266,27 +278,30 @@ typedef enum {
SDLK_LALT = 308,
SDLK_RMETA = 309,
SDLK_LMETA = 310,
SDLK_LSUPER = 311, /* Left "Windows" key */
SDLK_RSUPER = 312, /* Right "Windows" key */
SDLK_MODE = 313, /* "Alt Gr" key */
SDLK_COMPOSE = 314, /* Multi-key compose key */
SDLK_LSUPER = 311, /**< Left "Windows" key */
SDLK_RSUPER = 312, /**< Right "Windows" key */
SDLK_MODE = 313, /**< "Alt Gr" key */
SDLK_COMPOSE = 314, /**< Multi-key compose key */
/*@}*/
/* Miscellaneous function keys */
/** @name Miscellaneous function keys */
/*@{*/
SDLK_HELP = 315,
SDLK_PRINT = 316,
SDLK_SYSREQ = 317,
SDLK_BREAK = 318,
SDLK_MENU = 319,
SDLK_POWER = 320, /* Power Macintosh power key */
SDLK_EURO = 321, /* Some european keyboards */
SDLK_UNDO = 322, /* Atari keyboard has Undo */
SDLK_POWER = 320, /**< Power Macintosh power key */
SDLK_EURO = 321, /**< Some european keyboards */
SDLK_UNDO = 322, /**< Atari keyboard has Undo */
/*@}*/
/* Add any other keys here */
SDLK_LAST
} SDLKey;
/* Enumeration of valid key mods (possibly OR'd together) */
/** Enumeration of valid key mods (possibly OR'd together) */
typedef enum {
KMOD_NONE = 0x0000,
KMOD_LSHIFT= 0x0001,

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,22 +20,24 @@
slouken@libsdl.org
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent library loading routines */
/** @file SDL_loadso.h
* System dependent library loading routines
*/
/* Some things to keep in mind:
- These functions only work on C function names. Other languages may
have name mangling and intrinsic language support that varies from
compiler to compiler.
- Make sure you declare your function pointers with the same calling
convention as the actual library function. Your code will crash
mysteriously if you do not do this.
- Avoid namespace collisions. If you load a symbol from the library,
it is not defined whether or not it goes into the global symbol
namespace for the application. If it does and it conflicts with
symbols in your code or other shared libraries, you will not get
the results you expect. :)
*/
/** @file SDL_loadso.h
* Some things to keep in mind:
* - These functions only work on C function names. Other languages may
* have name mangling and intrinsic language support that varies from
* compiler to compiler.
* - Make sure you declare your function pointers with the same calling
* convention as the actual library function. Your code will crash
* mysteriously if you do not do this.
* - Avoid namespace collisions. If you load a symbol from the library,
* it is not defined whether or not it goes into the global symbol
* namespace for the application. If it does and it conflicts with
* symbols in your code or other shared libraries, you will not get
* the results you expect. :)
*/
#ifndef _SDL_loadso_h
@ -50,19 +52,21 @@
extern "C" {
#endif
/* This function dynamically loads a shared object and returns a pointer
/**
* This function dynamically loads a shared object and returns a pointer
* to the object handle (or NULL if there was an error).
* The 'sofile' parameter is a system dependent name of the object file.
*/
extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile);
/* Given an object handle, this function looks up the address of the
/**
* Given an object handle, this function looks up the address of the
* named function in the shared object and returns it. This address
* is no longer valid after calling SDL_UnloadObject().
*/
extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name);
/* Unload a shared object from memory */
/** Unload a shared object from memory */
extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
/* Ends C function definitions when using C++ */

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -25,7 +25,9 @@
#include "SDL_stdinc.h"
/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */
/** @file SDL_main.h
* Redefine main() on Win32 and MacOS so that it is called by winmain.c
*/
#if defined(__WIN32__) || \
(defined(__MWERKS__) && !defined(__BEOS__)) || \
@ -38,22 +40,25 @@
#define C_LINKAGE
#endif /* __cplusplus */
/* The application's main() function must be called with C linkage,
and should be declared like this:
#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[])
{
}
/** The application's main() function must be called with C linkage,
* and should be declared like this:
* @code
* #ifdef __cplusplus
* extern "C"
* #endif
* int main(int argc, char *argv[])
* {
* }
* @endcode
*/
#define main SDL_main
/* The prototype for the application's main() function */
/** The prototype for the application's main() function */
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
/* From the SDL library code -- needed for registering the app on Win32 */
/** @name From the SDL library code -- needed for registering the app on Win32 */
/*@{*/
#ifdef __WIN32__
#include "begin_code.h"
@ -61,19 +66,21 @@ extern C_LINKAGE int SDL_main(int argc, char *argv[]);
extern "C" {
#endif
/* This should be called from your WinMain() function, if any */
/** This should be called from your WinMain() function, if any */
extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
/* This can also be called, but is no longer necessary */
/** This can also be called, but is no longer necessary */
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
/* This can also be called, but is no longer necessary (SDL_Quit calls it) */
/** This can also be called, but is no longer necessary (SDL_Quit calls it) */
extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif
/*@}*/
/* From the SDL library code -- needed for registering QuickDraw on MacOS */
/** @name From the SDL library code -- needed for registering QuickDraw on MacOS */
/*@{*/
#if defined(__MACOS__)
#include "begin_code.h"
@ -81,10 +88,10 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
extern "C" {
#endif
/* Forward declaration so we don't need to include QuickDraw.h */
/** Forward declaration so we don't need to include QuickDraw.h */
struct QDGlobals;
/* This should be called from your main() function, if any */
/** This should be called from your main() function, if any */
extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
#ifdef __cplusplus
@ -92,6 +99,7 @@ extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
#endif
#include "close_code.h"
#endif
/*@}*/
#endif /* Need to redefine main()? */

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* Include file for SDL mouse event handling */
/** @file SDL_mouse.h
* Include file for SDL mouse event handling
*/
#ifndef _SDL_mouse_h
#define _SDL_mouse_h
@ -35,18 +37,18 @@
extern "C" {
#endif
typedef struct WMcursor WMcursor; /* Implementation dependent */
typedef struct WMcursor WMcursor; /**< Implementation dependent */
typedef struct SDL_Cursor {
SDL_Rect area; /* The area of the mouse cursor */
Sint16 hot_x, hot_y; /* The "tip" of the cursor */
Uint8 *data; /* B/W cursor data */
Uint8 *mask; /* B/W cursor mask */
Uint8 *save[2]; /* Place to save cursor area */
WMcursor *wm_cursor; /* Window-manager cursor */
SDL_Rect area; /**< The area of the mouse cursor */
Sint16 hot_x, hot_y; /**< The "tip" of the cursor */
Uint8 *data; /**< B/W cursor data */
Uint8 *mask; /**< B/W cursor mask */
Uint8 *save[2]; /**< Place to save cursor area */
WMcursor *wm_cursor; /**< Window-manager cursor */
} SDL_Cursor;
/* Function prototypes */
/*
/**
* Retrieve the current state of the mouse.
* The current button state is returned as a button bitmask, which can
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
@ -54,7 +56,7 @@ typedef struct SDL_Cursor {
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
/*
/**
* Retrieve the current state of the mouse.
* The current button state is returned as a button bitmask, which can
* be tested using the SDL_BUTTON(X) macros, and x and y are set to the
@ -62,12 +64,12 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
*/
extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
/*
/**
* Set the position of the mouse cursor (generates a mouse motion event)
*/
extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
/*
/**
* Create a cursor using the specified data and mask (in MSB format).
* The cursor width must be a multiple of 8 bits.
*
@ -83,24 +85,24 @@ extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor
(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
/*
/**
* Set the currently active cursor to the specified one.
* If the cursor is currently visible, the change will be immediately
* represented on the display.
*/
extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor);
/*
/**
* Returns the currently active cursor.
*/
extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void);
/*
/**
* Deallocates a cursor created with SDL_CreateCursor().
*/
extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor);
/*
/**
* Toggle whether or not the cursor is shown on the screen.
* The cursor start off displayed, but can be turned off.
* SDL_ShowCursor() returns 1 if the cursor was being displayed
@ -109,12 +111,13 @@ extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor);
*/
extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
/* Used as a mask when testing buttons in buttonstate
Button 1: Left mouse button
Button 2: Middle mouse button
Button 3: Right mouse button
Button 4: Mouse wheel up (may also be a real button)
Button 5: Mouse wheel down (may also be a real button)
/*@{*/
/** Used as a mask when testing buttons in buttonstate
* Button 1: Left mouse button
* Button 2: Middle mouse button
* Button 3: Right mouse button
* Button 4: Mouse wheel up (may also be a real button)
* Button 5: Mouse wheel down (may also be a real button)
*/
#define SDL_BUTTON(X) (1 << ((X)-1))
#define SDL_BUTTON_LEFT 1
@ -122,10 +125,14 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
#define SDL_BUTTON_RIGHT 3
#define SDL_BUTTON_WHEELUP 4
#define SDL_BUTTON_WHEELDOWN 5
#define SDL_BUTTON_X1 6
#define SDL_BUTTON_X2 7
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)
#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -23,10 +23,11 @@
#ifndef _SDL_mutex_h
#define _SDL_mutex_h
/* Functions to provide thread synchronization primitives
These are independent of the other SDL routines.
*/
/** @file SDL_mutex.h
* Functions to provide thread synchronization primitives
*
* @note These are independent of the other SDL routines.
*/
#include "SDL_stdinc.h"
#include "SDL_error.h"
@ -37,122 +38,135 @@
extern "C" {
#endif
/* Synchronization functions which can time out return this value
if they time out.
*/
/** Synchronization functions which can time out return this value
* if they time out.
*/
#define SDL_MUTEX_TIMEDOUT 1
/* This is the timeout value which corresponds to never time out */
/** This is the timeout value which corresponds to never time out */
#define SDL_MUTEX_MAXWAIT (~(Uint32)0)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Mutex functions */
/** @name Mutex functions */ /*@{*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* The SDL mutex structure, defined in SDL_mutex.c */
/** The SDL mutex structure, defined in SDL_mutex.c */
struct SDL_mutex;
typedef struct SDL_mutex SDL_mutex;
/* Create a mutex, initialized unlocked */
/** Create a mutex, initialized unlocked */
extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void);
/* Lock the mutex (Returns 0, or -1 on error) */
#define SDL_LockMutex(m) SDL_mutexP(m)
/** Lock the mutex
* @return 0, or -1 on error
*/
extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex);
/* Unlock the mutex (Returns 0, or -1 on error)
It is an error to unlock a mutex that has not been locked by
the current thread, and doing so results in undefined behavior.
*/
#define SDL_UnlockMutex(m) SDL_mutexV(m)
/** Unlock the mutex
* @return 0, or -1 on error
*
* It is an error to unlock a mutex that has not been locked by
* the current thread, and doing so results in undefined behavior.
*/
extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex);
/* Destroy a mutex */
/** Destroy a mutex */
extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex);
/*@}*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Semaphore functions */
/** @name Semaphore functions */ /*@{*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* The SDL semaphore structure, defined in SDL_sem.c */
/** The SDL semaphore structure, defined in SDL_sem.c */
struct SDL_semaphore;
typedef struct SDL_semaphore SDL_sem;
/* Create a semaphore, initialized with value, returns NULL on failure. */
/** Create a semaphore, initialized with value, returns NULL on failure. */
extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
/* Destroy a semaphore */
/** Destroy a semaphore */
extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem);
/* This function suspends the calling thread until the semaphore pointed
/**
* This function suspends the calling thread until the semaphore pointed
* to by sem has a positive count. It then atomically decreases the semaphore
* count.
*/
extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem);
/* Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error.
*/
/** Non-blocking variant of SDL_SemWait().
* @return 0 if the wait succeeds,
* SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem);
/* Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
the allotted time, and -1 on error.
On some platforms this function is implemented by looping with a delay
of 1 ms, and so should be avoided if possible.
*/
/** Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
* the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
* the allotted time, and -1 on error.
*
* On some platforms this function is implemented by looping with a delay
* of 1 ms, and so should be avoided if possible.
*/
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms);
/* Atomically increases the semaphore's count (not blocking), returns 0,
or -1 on error.
/** Atomically increases the semaphore's count (not blocking).
* @return 0, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem);
/* Returns the current count of the semaphore */
/** Returns the current count of the semaphore */
extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem);
/*@}*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Condition variable functions */
/** @name Condition_variable_functions */ /*@{*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* The SDL condition variable structure, defined in SDL_cond.c */
/*@{*/
/** The SDL condition variable structure, defined in SDL_cond.c */
struct SDL_cond;
typedef struct SDL_cond SDL_cond;
/*@}*/
/* Create a condition variable */
/** Create a condition variable */
extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void);
/* Destroy a condition variable */
/** Destroy a condition variable */
extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond);
/* Restart one of the threads that are waiting on the condition variable,
returns 0 or -1 on error.
/** Restart one of the threads that are waiting on the condition variable,
* @return 0 or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond);
/* Restart all threads that are waiting on the condition variable,
returns 0 or -1 on error.
/** Restart all threads that are waiting on the condition variable,
* @return 0 or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond);
/* Wait on the condition variable, unlocking the provided mutex.
The mutex must be locked before entering this function!
The mutex is re-locked once the condition variable is signaled.
Returns 0 when it is signaled, or -1 on error.
/** Wait on the condition variable, unlocking the provided mutex.
* The mutex must be locked before entering this function!
* The mutex is re-locked once the condition variable is signaled.
* @return 0 when it is signaled, or -1 on error.
*/
extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut);
/* Waits for at most 'ms' milliseconds, and returns 0 if the condition
variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
signaled in the allotted time, and -1 on error.
On some platforms this function is implemented by looping with a delay
of 1 ms, and so should be avoided if possible.
*/
/** Waits for at most 'ms' milliseconds, and returns 0 if the condition
* variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
* signaled in the allotted time, and -1 on error.
* On some platforms this function is implemented by looping with a delay
* of 1 ms, and so should be avoided if possible.
*/
extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms);
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
@ -160,3 +174,4 @@ extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex
#include "close_code.h"
#endif /* _SDL_mutex_h */

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* This is a simple file to encapsulate the OpenGL API headers */
/** @file SDL_opengl.h
* This is a simple file to encapsulate the OpenGL API headers
*/
#include "SDL_config.h"
@ -48,10 +50,12 @@
#undef __glext_h_
#endif
/* This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials.
It is included here because glext.h is not available on some systems.
If you don't want this version included, simply define "NO_SDL_GLEXT"
/** @name GLext.h
* This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials.
* It is included here because glext.h is not available on some systems.
* If you don't want this version included, simply define "NO_SDL_GLEXT"
*/
/*@{*/
#ifndef NO_SDL_GLEXT
#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY)
#define __glext_h_
@ -6549,3 +6553,4 @@ typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid
#endif
#endif /* NO_SDL_GLEXT */
/*@}*/

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* Try to get a standard set of platform defines */
/** @file SDL_platform.h
* Try to get a standard set of platform defines
*/
#ifndef _SDL_platform_h
#define _SDL_platform_h
@ -29,14 +31,14 @@
#undef __AIX__
#define __AIX__ 1
#endif
#if defined(AMIGA) || defined(__AMIGA) || defined(__amigados__)
#undef __AMIGA__
#define __AMIGA__ 1
#endif
#if defined(__BEOS__)
#undef __BEOS__
#define __BEOS__ 1
#endif
#if defined(__HAIKU__)
#undef __HAIKU__
#define __HAIKU__ 1
#endif
#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
#undef __BSDI__
#define __BSDI__ 1
@ -45,10 +47,14 @@
#undef __DREAMCAST__
#define __DREAMCAST__ 1
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#undef __FREEBSD__
#define __FREEBSD__ 1
#endif
#if defined(__HAIKU__)
#undef __HAIKU__
#define __HAIKU__ 1
#endif
#if defined(hpux) || defined(__hpux) || defined(__hpux__)
#undef __HPUX__
#define __HPUX__ 1

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* Include file for SDL quit event handling */
/** @file SDL_quit.h
* Include file for SDL quit event handling
*/
#ifndef _SDL_quit_h
#define _SDL_quit_h
@ -28,22 +30,25 @@
#include "SDL_stdinc.h"
#include "SDL_error.h"
/*
An SDL_QUITEVENT is generated when the user tries to close the application
window. If it is ignored or filtered out, the window will remain open.
If it is not ignored or filtered, it is queued normally and the window
is allowed to close. When the window is closed, screen updates will
complete, but have no effect.
/** @file SDL_quit.h
* An SDL_QUITEVENT is generated when the user tries to close the application
* window. If it is ignored or filtered out, the window will remain open.
* If it is not ignored or filtered, it is queued normally and the window
* is allowed to close. When the window is closed, screen updates will
* complete, but have no effect.
*
* SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
* and SIGTERM (system termination request), if handlers do not already
* exist, that generate SDL_QUITEVENT events as well. There is no way
* to determine the cause of an SDL_QUITEVENT, but setting a signal
* handler in your application will override the default generation of
* quit events for that signal.
*/
SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
and SIGTERM (system termination request), if handlers do not already
exist, that generate SDL_QUITEVENT events as well. There is no way
to determine the cause of an SDL_QUITEVENT, but setting a signal
handler in your application will override the default generation of
quit events for that signal.
*/
/** @file SDL_quit.h
* There are no functions directly affecting the quit event
*/
/* There are no functions directly affecting the quit event */
#define SDL_QuitRequested() \
(SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK))

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,9 +20,10 @@
slouken@libsdl.org
*/
/* This file provides a general interface for SDL to read and write
data sources. It can easily be extended to files, memory, etc.
*/
/** @file SDL_rwops.h
* This file provides a general interface for SDL to read and write
* data sources. It can easily be extended to files, memory, etc.
*/
#ifndef _SDL_rwops_h
#define _SDL_rwops_h
@ -36,36 +37,41 @@
extern "C" {
#endif
/* This is the read/write operation structure -- very basic */
/** This is the read/write operation structure -- very basic */
typedef struct SDL_RWops {
/* Seek to 'offset' relative to whence, one of stdio's whence values:
SEEK_SET, SEEK_CUR, SEEK_END
Returns the final offset in the data source.
/** Seek to 'offset' relative to whence, one of stdio's whence values:
* SEEK_SET, SEEK_CUR, SEEK_END
* Returns the final offset in the data source.
*/
int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
/* Read up to 'num' objects each of size 'objsize' from the data
source to the area pointed at by 'ptr'.
Returns the number of objects read, or -1 if the read failed.
/** Read up to 'maxnum' objects each of size 'size' from the data
* source to the area pointed at by 'ptr'.
* Returns the number of objects read, or -1 if the read failed.
*/
int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
/* Write exactly 'num' objects each of size 'objsize' from the area
pointed at by 'ptr' to data source.
Returns 'num', or -1 if the write failed.
/** Write exactly 'num' objects each of size 'objsize' from the area
* pointed at by 'ptr' to data source.
* Returns 'num', or -1 if the write failed.
*/
int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
/* Close and free an allocated SDL_FSops structure */
/** Close and free an allocated SDL_FSops structure */
int (SDLCALL *close)(struct SDL_RWops *context);
Uint32 type;
union {
#ifdef __WIN32__
#if defined(__WIN32__) && !defined(__SYMBIAN32__)
struct {
int append;
void* h;
int append;
void *h;
struct {
void *data;
int size;
int left;
} buffer;
} win32io;
#endif
#ifdef HAVE_STDIO_H
@ -87,7 +93,8 @@ typedef struct SDL_RWops {
} SDL_RWops;
/* Functions to create SDL_RWops structures from various data sources */
/** @name Functions to create SDL_RWops structures from various data sources */
/*@{*/
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
@ -101,34 +108,43 @@ extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size
extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
#define RW_SEEK_SET 0 /* Seek from the beginning of data */
#define RW_SEEK_CUR 1 /* Seek relative to current read point */
#define RW_SEEK_END 2 /* Seek relative to the end of data */
/*@}*/
/* Macros to easily read and write from an SDL_RWops structure */
/** @name Seek Reference Points */
/*@{*/
#define RW_SEEK_SET 0 /**< Seek from the beginning of data */
#define RW_SEEK_CUR 1 /**< Seek relative to current read point */
#define RW_SEEK_END 2 /**< Seek relative to the end of data */
/*@}*/
/** @name Macros to easily read and write from an SDL_RWops structure */
/*@{*/
#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
#define SDL_RWclose(ctx) (ctx)->close(ctx)
/*@}*/
/* Read an item of the specified endianness and return in native format */
/** @name Read an item of the specified endianness and return in native format */
/*@{*/
extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
/*@}*/
/* Write an item of native format to the specified endianness */
/** @name Write an item of native format to the specified endianness */
/*@{*/
extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* This is a general header that includes C language support */
/** @file SDL_stdinc.h
* This is a general header that includes C language support
*/
#ifndef _SDL_stdinc_h
#define _SDL_stdinc_h
@ -68,16 +70,27 @@
#ifdef HAVE_CTYPE_H
# include <ctype.h>
#endif
#ifdef HAVE_ICONV_H
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
# include <iconv.h>
#endif
/* The number of elements in an array */
/** The number of elements in an array */
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
#define SDL_TABLESIZE(table) SDL_arraysize(table)
/* Basic data types */
typedef enum SDL_bool {
/* Use proper C++ casts when compiled as C++ to be compatible with the option
-Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above. */
#ifdef __cplusplus
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
#define SDL_static_cast(type, expression) static_cast<type>(expression)
#else
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
#define SDL_static_cast(type, expression) ((type)(expression))
#endif
/** @name Basic data types */
/*@{*/
typedef enum {
SDL_FALSE = 0,
SDL_TRUE = 1
} SDL_bool;
@ -91,7 +104,9 @@ typedef uint32_t Uint32;
#ifdef SDL_HAS_64BIT_TYPE
typedef int64_t Sint64;
#ifndef SYMBIAN32_GCCE
typedef uint64_t Uint64;
#endif
#else
/* This is really just a hack to prevent the compiler from complaining */
typedef struct {
@ -100,7 +115,10 @@ typedef struct {
} Uint64, Sint64;
#endif
/* Make sure the types really have the right sizes */
/*@}*/
/** @name Make sure the types really have the right sizes */
/*@{*/
#define SDL_COMPILE_TIME_ASSERT(name, x) \
typedef int SDL_dummy_ ## name[(x) * 2 - 1]
@ -112,12 +130,14 @@ SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
/*@}*/
/* Check to make sure enums are the size of ints, for structure packing.
For both Watcom C/C++ and Borland C/C++ the compiler option that makes
enums having the size of an int must be enabled.
This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
*/
/** @name Enum Size Check
* Check to make sure enums are the size of ints, for structure packing.
* For both Watcom C/C++ and Borland C/C++ the compiler option that makes
* enums having the size of an int must be enabled.
* This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
*/
/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
#ifdef __MWERKS__
#pragma enumsalwaysint on
@ -127,8 +147,10 @@ typedef enum {
DUMMY_ENUM_VALUE
} SDL_DUMMY_ENUM;
#ifndef __NDS__
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
#endif
/*@}*/
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@ -170,6 +192,8 @@ extern DECLSPEC void SDLCALL SDL_free(void *mem);
# define alloca _alloca
# elif defined(__WATCOMC__)
# include <malloc.h>
# elif defined(__BORLANDC__)
# include <malloc.h>
# elif defined(__DMC__)
# include <stdlib.h>
# elif defined(__AIX__)
@ -181,10 +205,10 @@ extern DECLSPEC void SDLCALL SDL_free(void *mem);
# endif
#endif
#ifdef HAVE_ALLOCA
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*count)
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
#define SDL_stack_free(data)
#else
#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*count)
#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count))
#define SDL_stack_free(data) SDL_free(data)
#endif
@ -242,7 +266,7 @@ do { \
"cld\n\t" \
"rep ; stosl\n\t" \
: "=&D" (u0), "=&a" (u1), "=&c" (u2) \
: "0" (dst), "1" (val), "2" ((Uint32)(len)) \
: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len)) \
: "memory" ); \
} while(0)
#endif
@ -251,8 +275,9 @@ do { \
do { \
unsigned _count = (len); \
unsigned _n = (_count + 3) / 4; \
Uint32 *_p = (Uint32 *)(dst); \
Uint32 *_p = SDL_static_cast(Uint32 *, dst); \
Uint32 _val = (val); \
if (len == 0) break; \
switch (_count % 4) { \
case 0: do { *_p++ = _val; \
case 3: *_p++ = _val; \
@ -263,7 +288,10 @@ do { \
} while(0)
#endif
#if defined(__GNUC__) && defined(i386)
/* We can count on memcpy existing on Mac OS X and being well-tuned. */
#if defined(__MACH__) && defined(__APPLE__)
#define SDL_memcpy(dst, src, len) memcpy(dst, src, len)
#elif defined(__GNUC__) && defined(i386)
#define SDL_memcpy(dst, src, len) \
do { \
int u0, u1, u2; \
@ -278,7 +306,7 @@ do { \
"movsb\n" \
"2:" \
: "=&c" (u0), "=&D" (u1), "=&S" (u2) \
: "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
: "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \
: "memory" ); \
} while(0)
#endif
@ -292,7 +320,10 @@ extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len
#endif
#endif
#if defined(__GNUC__) && defined(i386)
/* We can count on memcpy existing on Mac OS X and being well-tuned. */
#if defined(__MACH__) && defined(__APPLE__)
#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
#elif defined(__GNUC__) && defined(i386)
#define SDL_memcpy4(dst, src, len) \
do { \
int ecx, edi, esi; \
@ -300,7 +331,7 @@ do { \
"cld\n\t" \
"rep ; movsl" \
: "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
: "0" ((unsigned)(len)), "1" (dst), "2" (src) \
: "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src) \
: "memory" ); \
} while(0)
#endif
@ -312,13 +343,14 @@ do { \
#define SDL_revcpy(dst, src, len) \
do { \
int u0, u1, u2; \
char *dstp = (char *)(dst); \
char *srcp = (char *)(src); \
char *dstp = SDL_static_cast(char *, dst); \
char *srcp = SDL_static_cast(char *, src); \
int n = (len); \
if ( n >= 4 ) { \
__asm__ __volatile__ ( \
"std\n\t" \
"rep ; movsl\n\t" \
"cld\n\t" \
: "=&c" (u0), "=&D" (u1), "=&S" (u2) \
: "0" (n >> 2), \
"1" (dstp+(n-4)), "2" (srcp+(n-4)) \
@ -551,29 +583,31 @@ extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
#endif
/* The SDL implementation of iconv() returns these error codes */
/** @name SDL_ICONV Error Codes
* The SDL implementation of iconv() returns these error codes
*/
/*@{*/
#define SDL_ICONV_ERROR (size_t)-1
#define SDL_ICONV_E2BIG (size_t)-2
#define SDL_ICONV_EILSEQ (size_t)-3
#define SDL_ICONV_EINVAL (size_t)-4
/*@}*/
#ifdef HAVE_ICONV
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
#define SDL_iconv_t iconv_t
#define SDL_iconv_open iconv_open
#define SDL_iconv_close iconv_close
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
#else
typedef struct _SDL_iconv_t *SDL_iconv_t;
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode);
extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
#endif
/* This function converts a string between encodings in one pass, returning a
string that must be freed with SDL_free() or NULL on error.
*/
extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, char *inbuf, size_t inbytesleft);
#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1)
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
/** This function converts a string between encodings in one pass, returning a
* string that must be freed with SDL_free() or NULL on error.
*/
extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft);
#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* Include file for SDL custom system window manager hooks */
/** @file SDL_syswm.h
* Include file for SDL custom system window manager hooks
*/
#ifndef _SDL_syswm_h
#define _SDL_syswm_h
@ -35,11 +37,12 @@
extern "C" {
#endif
/* Your application has access to a special type of event 'SDL_SYSWMEVENT',
which contains window-manager specific information and arrives whenever
an unhandled window event occurs. This event is ignored by default, but
you can enable it with SDL_EventState()
*/
/** @file SDL_syswm.h
* Your application has access to a special type of event 'SDL_SYSWMEVENT',
* which contains window-manager specific information and arrives whenever
* an unhandled window event occurs. This event is ignored by default, but
* you can enable it with SDL_EventState()
*/
#ifdef SDL_PROTOTYPES_ONLY
struct SDL_SysWMinfo;
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
@ -60,12 +63,12 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
#undef Cursor
#endif
/* These are the various supported subsystems under UNIX */
/** These are the various supported subsystems under UNIX */
typedef enum {
SDL_SYSWM_X11
} SDL_SYSWM_TYPE;
/* The UNIX custom event structure */
/** The UNIX custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
SDL_SYSWM_TYPE subsystem;
@ -74,28 +77,38 @@ struct SDL_SysWMmsg {
} event;
};
/* The UNIX custom window manager information structure.
When this structure is returned, it holds information about which
low level system it is using, and will be one of SDL_SYSWM_TYPE.
/** The UNIX custom window manager information structure.
* When this structure is returned, it holds information about which
* low level system it is using, and will be one of SDL_SYSWM_TYPE.
*/
typedef struct SDL_SysWMinfo {
SDL_version version;
SDL_SYSWM_TYPE subsystem;
union {
struct {
Display *display; /* The X11 display */
Window window; /* The X11 display window */
/* These locking functions should be called around
any X11 functions using the display variable.
They lock the event thread, so should not be
called around event functions or from event filters.
Display *display; /**< The X11 display */
Window window; /**< The X11 display window */
/** These locking functions should be called around
* any X11 functions using the display variable,
* but not the gfxdisplay variable.
* They lock the event thread, so should not be
* called around event functions or from event filters.
*/
/*@{*/
void (*lock_func)(void);
void (*unlock_func)(void);
/*@}*/
/* Introduced in SDL 1.0.2 */
Window fswindow; /* The X11 fullscreen window */
Window wmwindow; /* The X11 managed input window */
/** @name Introduced in SDL 1.0.2 */
/*@{*/
Window fswindow; /**< The X11 fullscreen window */
Window wmwindow; /**< The X11 managed input window */
/*@}*/
/** @name Introduced in SDL 1.2.12 */
/*@{*/
Display *gfxdisplay; /**< The X11 display to which rendering is done */
/*@}*/
} x11;
} info;
} SDL_SysWMinfo;
@ -103,13 +116,13 @@ typedef struct SDL_SysWMinfo {
#elif defined(SDL_VIDEO_DRIVER_NANOX)
#include <microwin/nano-X.h>
/* The generic custom event structure */
/** The generic custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
int data;
};
/* The windows custom window manager information structure */
/** The windows custom window manager information structure */
typedef struct SDL_SysWMinfo {
SDL_version version ;
GR_WINDOW_ID window ; /* The display window */
@ -119,50 +132,50 @@ typedef struct SDL_SysWMinfo {
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/* The windows custom event structure */
/** The windows custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
HWND hwnd; /* The window for the message */
UINT msg; /* The type of message */
WPARAM wParam; /* WORD message parameter */
LPARAM lParam; /* LONG message parameter */
HWND hwnd; /**< The window for the message */
UINT msg; /**< The type of message */
WPARAM wParam; /**< WORD message parameter */
LPARAM lParam; /**< LONG message parameter */
};
/* The windows custom window manager information structure */
/** The windows custom window manager information structure */
typedef struct SDL_SysWMinfo {
SDL_version version;
HWND window; /* The Win32 display window */
HGLRC hglrc; /* The OpenGL context, if any */
HWND window; /**< The Win32 display window */
HGLRC hglrc; /**< The OpenGL context, if any */
} SDL_SysWMinfo;
#elif defined(SDL_VIDEO_DRIVER_RISCOS)
/* RISC OS custom event structure */
/** RISC OS custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
int eventCode; /* The window for the message */
int eventCode; /**< The window for the message */
int pollBlock[64];
};
/* The RISC OS custom window manager information structure */
/** The RISC OS custom window manager information structure */
typedef struct SDL_SysWMinfo {
SDL_version version;
int wimpVersion; /* Wimp version running under */
int taskHandle; /* The RISC OS task handle */
int window; /* The RISC OS display window */
int wimpVersion; /**< Wimp version running under */
int taskHandle; /**< The RISC OS task handle */
int window; /**< The RISC OS display window */
} SDL_SysWMinfo;
#elif defined(SDL_VIDEO_DRIVER_PHOTON)
#include <sys/neutrino.h>
#include <Ph.h>
/* The QNX custom event structure */
/** The QNX custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
int data;
};
/* The QNX custom window manager information structure */
/** The QNX custom window manager information structure */
typedef struct SDL_SysWMinfo {
SDL_version version;
int data;
@ -170,13 +183,13 @@ typedef struct SDL_SysWMinfo {
#else
/* The generic custom event structure */
/** The generic custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
int data;
};
/* The generic custom window manager information structure */
/** The generic custom window manager information structure */
typedef struct SDL_SysWMinfo {
SDL_version version;
int data;
@ -187,16 +200,18 @@ typedef struct SDL_SysWMinfo {
#endif /* SDL_PROTOTYPES_ONLY */
/* Function prototypes */
/*
/**
* This function gives you custom hooks into the window manager information.
* It fills the structure pointed to by 'info' with custom information and
* returns 1 if the function is implemented. If it's not implemented, or
* the version member of the 'info' structure is invalid, it returns 0.
*
* You typically use this function like this:
* @code
* SDL_SysWMInfo info;
* SDL_VERSION(&info.version);
* if ( SDL_GetWMInfo(&info) ) { ... }
* @endcode
*/
extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -23,10 +23,11 @@
#ifndef _SDL_thread_h
#define _SDL_thread_h
/* Header for the SDL thread management routines
These are independent of the other SDL routines.
*/
/** @file SDL_thread.h
* Header for the SDL thread management routines
*
* @note These are independent of the other SDL routines.
*/
#include "SDL_stdinc.h"
#include "SDL_error.h"
@ -40,25 +41,25 @@
extern "C" {
#endif
/* The SDL thread structure, defined in SDL_thread.c */
/** The SDL thread structure, defined in SDL_thread.c */
struct SDL_Thread;
typedef struct SDL_Thread SDL_Thread;
/* Create a thread */
#if (defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)
/*
We compile SDL into a DLL on OS/2. This means, that it's the DLL which
creates a new thread for the calling process with the SDL_CreateThread()
API. There is a problem with this, that only the RTL of the SDL.DLL will
be initialized for those threads, and not the RTL of the calling application!
To solve this, we make a little hack here.
We'll always use the caller's _beginthread() and _endthread() APIs to
start a new thread. This way, if it's the SDL.DLL which uses this API,
then the RTL of SDL.DLL will be used to create the new thread, and if it's
the application, then the RTL of the application will be used.
So, in short:
Always use the _beginthread() and _endthread() of the calling runtime library!
*/
/** Create a thread */
#if ((defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)) && !defined(__SYMBIAN32__)
/**
* We compile SDL into a DLL on OS/2. This means, that it's the DLL which
* creates a new thread for the calling process with the SDL_CreateThread()
* API. There is a problem with this, that only the RTL of the SDL.DLL will
* be initialized for those threads, and not the RTL of the calling application!
* To solve this, we make a little hack here.
* We'll always use the caller's _beginthread() and _endthread() APIs to
* start a new thread. This way, if it's the SDL.DLL which uses this API,
* then the RTL of SDL.DLL will be used to create the new thread, and if it's
* the application, then the RTL of the application will be used.
* So, in short:
* Always use the _beginthread() and _endthread() of the calling runtime library!
*/
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
#ifndef _WIN32_WCE
#include <process.h> /* This has _beginthread() and _endthread() defined! */
@ -92,21 +93,21 @@ extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *),
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
#endif
/* Get the 32-bit thread identifier for the current thread */
/** Get the 32-bit thread identifier for the current thread */
extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
/* Get the 32-bit thread identifier for the specified thread,
equivalent to SDL_ThreadID() if the specified thread is NULL.
/** Get the 32-bit thread identifier for the specified thread,
* equivalent to SDL_ThreadID() if the specified thread is NULL.
*/
extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread);
/* Wait for a thread to finish.
The return code for the thread function is placed in the area
pointed to by 'status', if 'status' is not NULL.
/** Wait for a thread to finish.
* The return code for the thread function is placed in the area
* pointed to by 'status', if 'status' is not NULL.
*/
extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status);
/* Forcefully kill a thread without worrying about its state */
/** Forcefully kill a thread without worrying about its state */
extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -23,7 +23,9 @@
#ifndef _SDL_timer_h
#define _SDL_timer_h
/* Header for the SDL time management routines */
/** @file SDL_timer.h
* Header for the SDL time management routines
*/
#include "SDL_stdinc.h"
#include "SDL_error.h"
@ -34,24 +36,26 @@
extern "C" {
#endif
/* This is the OS scheduler timeslice, in milliseconds */
/** This is the OS scheduler timeslice, in milliseconds */
#define SDL_TIMESLICE 10
/* This is the maximum resolution of the SDL timer on all platforms */
#define TIMER_RESOLUTION 10 /* Experimentally determined */
/** This is the maximum resolution of the SDL timer on all platforms */
#define TIMER_RESOLUTION 10 /**< Experimentally determined */
/* Get the number of milliseconds since the SDL library initialization.
/**
* Get the number of milliseconds since the SDL library initialization.
* Note that this value wraps if the program runs for more than ~49 days.
*/
extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
/* Wait a specified number of milliseconds before returning */
/** Wait a specified number of milliseconds before returning */
extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
/* Function prototype for the timer callback function */
/** Function prototype for the timer callback function */
typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval);
/* Set a callback to run after the specified number of milliseconds has
/**
* Set a callback to run after the specified number of milliseconds has
* elapsed. The callback function is passed the current timer interval
* and returns the next timer interval. If the returned value is the
* same as the one passed in, the periodic alarm continues, otherwise a
@ -68,7 +72,7 @@ typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval);
* later on an unloaded system. If you wanted to set a flag signaling
* a frame update at 30 frames per second (every 33 ms), you might set a
* timer for 30 ms:
* SDL_SetTimer((33/10)*10, flag_update);
* @code SDL_SetTimer((33/10)*10, flag_update); @endcode
*
* If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init().
*
@ -81,11 +85,14 @@ typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval);
*/
extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback);
/* New timer API, supports multiple timers
/** @name New timer API
* New timer API, supports multiple timers
* Written by Stephane Peter <megastep@lokigames.com>
*/
/*@{*/
/* Function prototype for the new timer callback function.
/**
* Function prototype for the new timer callback function.
* The callback function is passed the current timer interval and returns
* the next timer interval. If the returned value is the same as the one
* passed in, the periodic alarm continues, otherwise a new alarm is
@ -93,19 +100,22 @@ extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback call
*/
typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param);
/* Definition of the timer ID type */
/** Definition of the timer ID type */
typedef struct _SDL_TimerID *SDL_TimerID;
/* Add a new timer to the pool of timers already running.
Returns a timer ID, or NULL when an error occurs.
/** Add a new timer to the pool of timers already running.
* Returns a timer ID, or NULL when an error occurs.
*/
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param);
/* Remove one of the multiple timers knowing its ID.
/**
* Remove one of the multiple timers knowing its ID.
* Returns a boolean value indicating success.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,5 +20,9 @@
slouken@libsdl.org
*/
/** @file SDL_types.h
* @deprecated Use SDL_stdinc.h instead.
*/
/* DEPRECATED */
#include "SDL_stdinc.h"

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* This header defines the current SDL version */
/** @file SDL_version.h
* This header defines the current SDL version
*/
#ifndef _SDL_version_h
#define _SDL_version_h
@ -33,11 +35,14 @@
extern "C" {
#endif
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
/** @name Version Number
* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
/*@{*/
#define SDL_MAJOR_VERSION 1
#define SDL_MINOR_VERSION 2
#define SDL_PATCHLEVEL 11
#define SDL_PATCHLEVEL 14
/*@}*/
typedef struct SDL_version {
Uint8 major;
@ -45,7 +50,8 @@ typedef struct SDL_version {
Uint8 patch;
} SDL_version;
/* This macro can be used to fill a version structure with the compile-time
/**
* This macro can be used to fill a version structure with the compile-time
* version of the SDL library.
*/
#define SDL_VERSION(X) \
@ -55,24 +61,24 @@ typedef struct SDL_version {
(X)->patch = SDL_PATCHLEVEL; \
}
/* This macro turns the version numbers into a numeric value:
(1,2,3) -> (1203)
This assumes that there will never be more than 100 patchlevels
*/
/** This macro turns the version numbers into a numeric value:
* (1,2,3) -> (1203)
* This assumes that there will never be more than 100 patchlevels
*/
#define SDL_VERSIONNUM(X, Y, Z) \
((X)*1000 + (Y)*100 + (Z))
/* This is the version number macro for the current SDL version */
/** This is the version number macro for the current SDL version */
#define SDL_COMPILEDVERSION \
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
/* This macro will evaluate to true if compiled with SDL at least X.Y.Z */
/** This macro will evaluate to true if compiled with SDL at least X.Y.Z */
#define SDL_VERSION_ATLEAST(X, Y, Z) \
(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
/* This function gets the version of the dynamically linked SDL library.
it should NOT be used to fill a version structure, instead you should
use the SDL_Version() macro.
/** This function gets the version of the dynamically linked SDL library.
* it should NOT be used to fill a version structure, instead you should
* use the SDL_Version() macro.
*/
extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,9 @@
slouken@libsdl.org
*/
/* Header file for access to the SDL raw framebuffer window */
/** @file SDL_video.h
* Header file for access to the SDL raw framebuffer window
*/
#ifndef _SDL_video_h
#define _SDL_video_h
@ -35,11 +37,16 @@
extern "C" {
#endif
/* Transparency definitions: These define alpha as the opacity of a surface */
/** @name Transparency definitions
* These define alpha as the opacity of a surface
*/
/*@{*/
#define SDL_ALPHA_OPAQUE 255
#define SDL_ALPHA_TRANSPARENT 0
/*@}*/
/* Useful data types */
/** @name Useful data types */
/*@{*/
typedef struct SDL_Rect {
Sint16 x, y;
Uint16 w, h;
@ -57,8 +64,9 @@ typedef struct SDL_Palette {
int ncolors;
SDL_Color *colors;
} SDL_Palette;
/*@}*/
/* Everything in the pixel format structure is read-only */
/** Everything in the pixel format structure is read-only */
typedef struct SDL_PixelFormat {
SDL_Palette *palette;
Uint8 BitsPerPixel;
@ -76,128 +84,149 @@ typedef struct SDL_PixelFormat {
Uint32 Bmask;
Uint32 Amask;
/* RGB color key information */
/** RGB color key information */
Uint32 colorkey;
/* Alpha value information (per-surface alpha) */
/** Alpha value information (per-surface alpha) */
Uint8 alpha;
} SDL_PixelFormat;
/* This structure should be treated as read-only, except for 'pixels',
which, if not NULL, contains the raw pixel data for the surface.
*/
/** This structure should be treated as read-only, except for 'pixels',
* which, if not NULL, contains the raw pixel data for the surface.
*/
typedef struct SDL_Surface {
Uint32 flags; /* Read-only */
SDL_PixelFormat *format; /* Read-only */
int w, h; /* Read-only */
Uint16 pitch; /* Read-only */
void *pixels; /* Read-write */
int offset; /* Private */
Uint32 flags; /**< Read-only */
SDL_PixelFormat *format; /**< Read-only */
int w, h; /**< Read-only */
Uint16 pitch; /**< Read-only */
void *pixels; /**< Read-write */
int offset; /**< Private */
/* Hardware-specific surface info */
/** Hardware-specific surface info */
struct private_hwdata *hwdata;
/* clipping information */
SDL_Rect clip_rect; /* Read-only */
Uint32 unused1; /* for binary compatibility */
/** clipping information */
SDL_Rect clip_rect; /**< Read-only */
Uint32 unused1; /**< for binary compatibility */
/* Allow recursive locks */
Uint32 locked; /* Private */
/** Allow recursive locks */
Uint32 locked; /**< Private */
/* info for fast blit mapping to other surfaces */
struct SDL_BlitMap *map; /* Private */
/** info for fast blit mapping to other surfaces */
struct SDL_BlitMap *map; /**< Private */
/* format version, bumped at every change to invalidate blit maps */
unsigned int format_version; /* Private */
/** format version, bumped at every change to invalidate blit maps */
unsigned int format_version; /**< Private */
/* Reference count -- used when freeing surface */
int refcount; /* Read-mostly */
/** Reference count -- used when freeing surface */
int refcount; /**< Read-mostly */
} SDL_Surface;
/* These are the currently supported flags for the SDL_surface */
/* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */
#define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */
#define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */
#define SDL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible */
/* Available for SDL_SetVideoMode() */
#define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */
#define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */
#define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */
#define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */
#define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */
#define SDL_OPENGLBLIT 0x0000000A /* Create an OpenGL rendering context and use it for blitting */
#define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */
#define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */
/* Used internally (read-only) */
#define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */
#define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */
#define SDL_RLEACCELOK 0x00002000 /* Private flag */
#define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */
#define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */
#define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */
/** @name SDL_Surface Flags
* These are the currently supported flags for the SDL_surface
*/
/*@{*/
/* Evaluates to true if the surface needs to be locked before access */
/** Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */
/*@{*/
#define SDL_SWSURFACE 0x00000000 /**< Surface is in system memory */
#define SDL_HWSURFACE 0x00000001 /**< Surface is in video memory */
#define SDL_ASYNCBLIT 0x00000004 /**< Use asynchronous blits if possible */
/*@}*/
/** Available for SDL_SetVideoMode() */
/*@{*/
#define SDL_ANYFORMAT 0x10000000 /**< Allow any video depth/pixel-format */
#define SDL_HWPALETTE 0x20000000 /**< Surface has exclusive palette */
#define SDL_DOUBLEBUF 0x40000000 /**< Set up double-buffered video mode */
#define SDL_FULLSCREEN 0x80000000 /**< Surface is a full screen display */
#define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */
#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */
#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */
#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */
/*@}*/
/** Used internally (read-only) */
/*@{*/
#define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */
#define SDL_SRCCOLORKEY 0x00001000 /**< Blit uses a source color key */
#define SDL_RLEACCELOK 0x00002000 /**< Private flag */
#define SDL_RLEACCEL 0x00004000 /**< Surface is RLE encoded */
#define SDL_SRCALPHA 0x00010000 /**< Blit uses source alpha blending */
#define SDL_PREALLOC 0x01000000 /**< Surface uses preallocated memory */
/*@}*/
/*@}*/
/** Evaluates to true if the surface needs to be locked before access */
#define SDL_MUSTLOCK(surface) \
(surface->offset || \
((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
/* typedef for private surface blitting functions */
/** typedef for private surface blitting functions */
typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect,
struct SDL_Surface *dst, SDL_Rect *dstrect);
/* Useful for determining the video hardware capabilities */
/** Useful for determining the video hardware capabilities */
typedef struct SDL_VideoInfo {
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */
Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */
Uint32 wm_available :1; /**< Flag: Can you talk to a window manager? */
Uint32 UnusedBits1 :6;
Uint32 UnusedBits2 :1;
Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */
Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */
Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */
Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */
Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */
Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */
Uint32 blit_fill :1; /* Flag: Accelerated color fill */
Uint32 blit_hw :1; /**< Flag: Accelerated blits HW --> HW */
Uint32 blit_hw_CC :1; /**< Flag: Accelerated blits with Colorkey */
Uint32 blit_hw_A :1; /**< Flag: Accelerated blits with Alpha */
Uint32 blit_sw :1; /**< Flag: Accelerated blits SW --> HW */
Uint32 blit_sw_CC :1; /**< Flag: Accelerated blits with Colorkey */
Uint32 blit_sw_A :1; /**< Flag: Accelerated blits with Alpha */
Uint32 blit_fill :1; /**< Flag: Accelerated color fill */
Uint32 UnusedBits3 :16;
Uint32 video_mem; /* The total amount of video memory (in K) */
SDL_PixelFormat *vfmt; /* Value: The format of the video surface */
int current_w; /* Value: The current video mode width */
int current_h; /* Value: The current video mode height */
Uint32 video_mem; /**< The total amount of video memory (in K) */
SDL_PixelFormat *vfmt; /**< Value: The format of the video surface */
int current_w; /**< Value: The current video mode width */
int current_h; /**< Value: The current video mode height */
} SDL_VideoInfo;
/* The most common video overlay formats.
For an explanation of these pixel formats, see:
http://www.webartz.com/fourcc/indexyuv.htm
For information on the relationship between color spaces, see:
http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
/** @name Overlay Formats
* The most common video overlay formats.
* For an explanation of these pixel formats, see:
* http://www.webartz.com/fourcc/indexyuv.htm
*
* For information on the relationship between color spaces, see:
* http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
*/
#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */
#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */
#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
/*@{*/
#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */
#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */
#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
/*@}*/
/* The YUV hardware video overlay */
/** The YUV hardware video overlay */
typedef struct SDL_Overlay {
Uint32 format; /* Read-only */
int w, h; /* Read-only */
int planes; /* Read-only */
Uint16 *pitches; /* Read-only */
Uint8 **pixels; /* Read-write */
Uint32 format; /**< Read-only */
int w, h; /**< Read-only */
int planes; /**< Read-only */
Uint16 *pitches; /**< Read-only */
Uint8 **pixels; /**< Read-write */
/* Hardware-specific surface info */
/** @name Hardware-specific surface info */
/*@{*/
struct private_yuvhwfuncs *hwfuncs;
struct private_yuvhwdata *hwdata;
/*@{*/
/* Special flags */
Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */
/** @name Special flags */
/*@{*/
Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */
Uint32 UnusedBits :31;
/*@}*/
} SDL_Overlay;
/* Public enumeration for setting the OpenGL window attributes. */
/** Public enumeration for setting the OpenGL window attributes. */
typedef enum {
SDL_GL_RED_SIZE,
SDL_GL_GREEN_SIZE,
@ -218,17 +247,23 @@ typedef enum {
SDL_GL_SWAP_CONTROL
} SDL_GLattr;
/* flags for SDL_SetPalette() */
/** @name flags for SDL_SetPalette() */
/*@{*/
#define SDL_LOGPAL 0x01
#define SDL_PHYSPAL 0x02
/*@}*/
/* Function prototypes */
/* These functions are used internally, and should not be used unless you
/**
* @name Video Init and Quit
* These functions are used internally, and should not be used unless you
* have a specific need to specify the video driver you want to use.
* You should normally use SDL_Init() or SDL_InitSubSystem().
*
* SDL_VideoInit() initializes the video subsystem -- sets up a connection
*/
/*@{*/
/**
* Initializes the video subsystem. Sets up a connection
* to the window manager, etc, and determines the current video mode and
* pixel format, but does not initialize a window or graphics mode.
* Note that event handling is activated by this routine.
@ -239,14 +274,16 @@ typedef enum {
*/
extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags);
extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
/*@}*/
/* This function fills the given character buffer with the name of the
/**
* This function fills the given character buffer with the name of the
* video driver, and returns a pointer to it if the video driver has
* been initialized. It returns NULL if no driver has been initialized.
*/
extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
/*
/**
* This function returns a pointer to the current display surface.
* If SDL is doing format conversion on the display surface, this
* function returns the publicly visible surface, not the real video
@ -254,7 +291,7 @@ extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
*/
extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void);
/*
/**
* This function returns a read-only pointer to information about the
* video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt'
* member of the returned structure will contain the pixel format of the
@ -262,7 +299,7 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void);
*/
extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void);
/*
/**
* Check to see if a particular video mode is supported.
* It returns 0 if the requested mode is not supported under any bit depth,
* or returns the bits-per-pixel of the closest available mode with the
@ -275,7 +312,7 @@ extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void);
*/
extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags);
/*
/**
* Return a pointer to an array of available screen dimensions for the
* given format and video flags, sorted largest to smallest. Returns
* NULL if there are no dimensions available for a particular format,
@ -286,7 +323,7 @@ extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint
*/
extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags);
/*
/**
* Set up a video mode with the specified width, height and bits-per-pixel.
*
* If 'bpp' is 0, it is treated as the current display bits per pixel.
@ -347,18 +384,24 @@ extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint3
extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode
(int width, int height, int bpp, Uint32 flags);
/*
* Makes sure the given list of rectangles is updated on the given screen.
* If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
* screen.
/** @name SDL_Update Functions
* These functions should not be called while 'screen' is locked.
*/
/*@{*/
/**
* Makes sure the given list of rectangles is updated on the given screen.
*/
extern DECLSPEC void SDLCALL SDL_UpdateRects
(SDL_Surface *screen, int numrects, SDL_Rect *rects);
/**
* If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
* screen.
*/
extern DECLSPEC void SDLCALL SDL_UpdateRect
(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h);
/*@}*/
/*
/**
* On hardware that supports double-buffering, this function sets up a flip
* and returns. The hardware will wait for vertical retrace, and then swap
* video buffers before the next video surface blit or lock will return.
@ -370,7 +413,7 @@ extern DECLSPEC void SDLCALL SDL_UpdateRect
*/
extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen);
/*
/**
* Set the gamma correction for each of the color channels.
* The gamma values range (approximately) between 0.1 and 10.0
*
@ -380,7 +423,7 @@ extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen);
*/
extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
/*
/**
* Set the gamma translation table for the red, green, and blue channels
* of the video hardware. Each table is an array of 256 16-bit quantities,
* representing a mapping between the input and output for that channel.
@ -394,7 +437,7 @@ extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
*/
extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue);
/*
/**
* Retrieve the current values of the gamma translation tables.
*
* You must pass in valid pointers to arrays of 256 16-bit quantities.
@ -405,7 +448,7 @@ extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *gr
*/
extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue);
/*
/**
* Sets a portion of the colormap for the given 8-bit surface. If 'surface'
* is not a palettized surface, this function does nothing, returning 0.
* If all of the colors were set as passed to SDL_SetColors(), it will
@ -423,7 +466,7 @@ extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface,
SDL_Color *colors, int firstcolor, int ncolors);
/*
/**
* Sets a portion of the colormap for a given 8-bit surface.
* 'flags' is one or both of:
* SDL_LOGPAL -- set logical palette, which controls how blits are mapped
@ -443,31 +486,37 @@ extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags,
SDL_Color *colors, int firstcolor,
int ncolors);
/*
/**
* Maps an RGB triple to an opaque pixel value for a given pixel format
*/
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB
(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b);
(const SDL_PixelFormat * const format,
const Uint8 r, const Uint8 g, const Uint8 b);
/*
/**
* Maps an RGBA quadruple to a pixel value for a given pixel format
*/
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(SDL_PixelFormat *format,
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA
(const SDL_PixelFormat * const format,
const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a);
/*
/**
* Maps a pixel value into the RGB components for a given pixel format
*/
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt,
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
const SDL_PixelFormat * const fmt,
Uint8 *r, Uint8 *g, Uint8 *b);
/*
/**
* Maps a pixel value into the RGBA components for a given pixel format
*/
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt,
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
const SDL_PixelFormat * const fmt,
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
/*
/** @sa SDL_CreateRGBSurface */
#define SDL_AllocSurface SDL_CreateRGBSurface
/**
* Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
* If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
* If the depth is greater than 8 bits, the pixel format is set using the
@ -501,16 +550,16 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt,
* reason the surface could not be placed in video memory, it will not have
* the SDL_HWSURFACE flag set, and will be created in system memory instead.
*/
#define SDL_AllocSurface SDL_CreateRGBSurface
extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface
(Uint32 flags, int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
/** @sa SDL_CreateRGBSurface */
extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
int width, int height, int depth, int pitch,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface);
/*
/**
* SDL_LockSurface() sets up a surface for directly accessing the pixels.
* Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
* to and read from 'surface->pixels', using the pixel format stored in
@ -531,7 +580,7 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface);
extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface);
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
/*
/**
* Load a surface from a seekable SDL data source (memory or file.)
* If 'freesrc' is non-zero, the source will be closed after being read.
* Returns the new surface, or NULL if there was an error.
@ -539,10 +588,10 @@ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
*/
extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc);
/* Convenience macro -- load a surface from a file */
/** Convenience macro -- load a surface from a file */
#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
/*
/**
* Save a surface to a seekable SDL data source (memory or file.)
* If 'freedst' is non-zero, the source will be closed after being written.
* Returns 0 if successful or -1 if there was an error.
@ -550,11 +599,11 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
(SDL_Surface *surface, SDL_RWops *dst, int freedst);
/* Convenience macro -- save a surface to a file */
/** Convenience macro -- save a surface to a file */
#define SDL_SaveBMP(surface, file) \
SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
/*
/**
* Sets the color key (transparent pixel) in a blittable surface.
* If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
* 'key' will be the transparent pixel in the source image of a blit.
@ -566,7 +615,7 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
extern DECLSPEC int SDLCALL SDL_SetColorKey
(SDL_Surface *surface, Uint32 flag, Uint32 key);
/*
/**
* This function sets the alpha value for the entire surface, as opposed to
* using the alpha component of each pixel. This value measures the range
* of transparency of the surface, 0 being completely transparent to 255
@ -583,7 +632,7 @@ extern DECLSPEC int SDLCALL SDL_SetColorKey
*/
extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
/*
/**
* Sets the clipping rectangle for the destination surface in a blit.
*
* If the clip rectangle is NULL, clipping will be disabled.
@ -597,14 +646,14 @@ extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint
*/
extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect);
/*
/**
* Gets the clipping rectangle for the destination surface in a blit.
* 'rect' must be a pointer to a valid rectangle which will be filled
* with the correct values.
*/
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect);
/*
/**
* Creates a new surface of the specified format, and then copies and maps
* the given surface to it so the blit of the converted surface will be as
* fast as possible. If this function fails, it returns NULL.
@ -619,7 +668,7 @@ extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rec
extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags);
/*
/**
* This performs a fast blit from the source surface to the destination
* surface. It assumes that the source and destination rectangles are
* the same size. If either 'srcrect' or 'dstrect' are NULL, the entire
@ -675,35 +724,38 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
* If either of the surfaces were in video memory, and the blit returns -2,
* the video memory was lost, so it should be reloaded with artwork and
* re-blitted:
while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
while ( SDL_LockSurface(image) < 0 )
Sleep(10);
-- Write image pixels to image->pixels --
SDL_UnlockSurface(image);
}
* @code
* while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
* while ( SDL_LockSurface(image) < 0 )
* Sleep(10);
* -- Write image pixels to image->pixels --
* SDL_UnlockSurface(image);
* }
* @endcode
*
* This happens under DirectX 5.0 when the system switches away from your
* fullscreen application. The lock will also fail until you have access
* to the video memory again.
*
* You should call SDL_BlitSurface() unless you know exactly how SDL
* blitting works internally and how to use the other blit functions.
*/
/* You should call SDL_BlitSurface() unless you know exactly how SDL
blitting works internally and how to use the other blit functions.
*/
#define SDL_BlitSurface SDL_UpperBlit
/* This is the public blit function, SDL_BlitSurface(), and it performs
rectangle validation and clipping before passing it to SDL_LowerBlit()
*/
/** This is the public blit function, SDL_BlitSurface(), and it performs
* rectangle validation and clipping before passing it to SDL_LowerBlit()
*/
extern DECLSPEC int SDLCALL SDL_UpperBlit
(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect);
/* This is a semi-private blit function and it performs low-level surface
blitting only.
*/
/** This is a semi-private blit function and it performs low-level surface
* blitting only.
*/
extern DECLSPEC int SDLCALL SDL_LowerBlit
(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect);
/*
/**
* This function performs a fast fill of the given rectangle with 'color'
* The given rectangle is clipped to the destination surface clip area
* and the final fill rectangle is saved in the passed in pointer.
@ -715,7 +767,7 @@ extern DECLSPEC int SDLCALL SDL_LowerBlit
extern DECLSPEC int SDLCALL SDL_FillRect
(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
/*
/**
* This function takes a surface and copies it to a new surface of the
* pixel format and colors of the video framebuffer, suitable for fast
* blitting onto the display surface. It calls SDL_ConvertSurface()
@ -728,7 +780,7 @@ extern DECLSPEC int SDLCALL SDL_FillRect
*/
extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface);
/*
/**
* This function takes a surface and copies it to a new surface of the
* pixel format and colors of the video framebuffer (if possible),
* suitable for fast alpha blitting onto the display surface.
@ -744,38 +796,39 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surfac
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* YUV video surface overlay functions */
/** @name YUV video surface overlay functions */ /*@{*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This function creates a video output overlay
Calling the returned surface an overlay is something of a misnomer because
the contents of the display surface underneath the area where the overlay
is shown is undefined - it may be overwritten with the converted YUV data.
*/
/** This function creates a video output overlay
* Calling the returned surface an overlay is something of a misnomer because
* the contents of the display surface underneath the area where the overlay
* is shown is undefined - it may be overwritten with the converted YUV data.
*/
extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height,
Uint32 format, SDL_Surface *display);
/* Lock an overlay for direct access, and unlock it when you are done */
/** Lock an overlay for direct access, and unlock it when you are done */
extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay);
extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay);
/* Blit a video overlay to the display surface.
The contents of the video surface underneath the blit destination are
not defined.
The width and height of the destination rectangle may be different from
that of the overlay, but currently only 2x scaling is supported.
*/
/** Blit a video overlay to the display surface.
* The contents of the video surface underneath the blit destination are
* not defined.
* The width and height of the destination rectangle may be different from
* that of the overlay, but currently only 2x scaling is supported.
*/
extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect);
/* Free a video overlay */
/** Free a video overlay */
extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay);
/*@}*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* OpenGL support functions. */
/** @name OpenGL support functions. */ /*@{*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
/**
* Dynamically load an OpenGL library, or the default one if path is NULL
*
* If you do this, you need to retrieve all of the GL functions used in
@ -783,17 +836,17 @@ extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay);
*/
extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
/*
/**
* Get the address of a GL function
*/
extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc);
/*
/**
* Set an attribute of the OpenGL subsystem before intialization.
*/
extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
/*
/**
* Get an attribute of the OpenGL subsystem from the windowing
* interface, such as glX. This is of course different from getting
* the values from SDL's internal OpenGL subsystem, which only
@ -804,30 +857,38 @@ extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
*/
extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value);
/*
/**
* Swap the OpenGL buffers, if double-buffering is supported.
*/
extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
/*
/** @name OpenGL Internal Functions
* Internal functions that should not be called unless you have read
* and understood the source code for these functions.
*/
/*@{*/
extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects);
extern DECLSPEC void SDLCALL SDL_GL_Lock(void);
extern DECLSPEC void SDLCALL SDL_GL_Unlock(void);
/*@}*/
/*@}*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* These functions allow interaction with the window manager, if any. */
/** @name Window Manager Functions */
/** These functions allow interaction with the window manager, if any. */ /*@{*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Sets/Gets the title and icon text of the display window (UTF-8 encoded)
/**
* Sets the title and icon text of the display window (UTF-8 encoded)
*/
extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon);
/**
* Gets the title and icon text of the display window (UTF-8 encoded)
*/
extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon);
/*
/**
* Sets the icon for the display window.
* This function must be called before the first call to SDL_SetVideoMode().
* It takes an icon surface, and a mask in MSB format.
@ -835,14 +896,14 @@ extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon);
*/
extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask);
/*
/**
* This function iconifies the window, and returns 1 if it succeeded.
* If the function succeeds, it generates an SDL_APPACTIVE loss event.
* This function is a noop and returns 0 in non-windowed environments.
*/
extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
/*
/**
* Toggle fullscreen mode without changing the contents of the screen.
* If the display surface does not require locking before accessing
* the pixel information, then the memory pointers will not change.
@ -859,24 +920,25 @@ extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
*/
extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface);
/*
* This function allows you to set and query the input grab state of
* the application. It returns the new input grab state.
*/
typedef enum {
SDL_GRAB_QUERY = -1,
SDL_GRAB_OFF = 0,
SDL_GRAB_ON = 1,
SDL_GRAB_FULLSCREEN /* Used internally */
SDL_GRAB_FULLSCREEN /**< Used internally */
} SDL_GrabMode;
/*
/**
* This function allows you to set and query the input grab state of
* the application. It returns the new input grab state.
*
* Grabbing means that the mouse is confined to the application window,
* and nearly all keyboard input is passed directly to the application,
* and not interpreted by a window manager, if any.
*/
extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
/* Not in public API at the moment - do not use! */
/*@}*/
/** @internal Not in public API at the moment - do not use! */
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect);

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@ -20,20 +20,28 @@
slouken@libsdl.org
*/
/* This file sets things up for C dynamic library function definitions,
static inlined functions, and structures aligned at 4-byte alignment.
If you don't like ugly C preprocessor code, don't look at this file. :)
*/
/**
* @file begin_code.h
* This file sets things up for C dynamic library function definitions,
* static inlined functions, and structures aligned at 4-byte alignment.
* If you don't like ugly C preprocessor code, don't look at this file. :)
*/
/* This shouldn't be nested -- included it around code only. */
/**
* @file begin_code.h
* This shouldn't be nested -- included it around code only.
*/
#ifdef _begin_code_h
#error Nested inclusion of begin_code.h
#endif
#define _begin_code_h
/* Some compilers use a special export keyword */
/**
* @def DECLSPEC
* Some compilers use a special export keyword
*/
#ifndef DECLSPEC
# if defined(__BEOS__)
# if defined(__BEOS__) || defined(__HAIKU__)
# if defined(__GNUC__)
# define DECLSPEC __declspec(dllexport)
# else
@ -56,6 +64,15 @@
# else
# define DECLSPEC
# endif
# elif defined (__GNUC__) && __GNUC__ < 4
# /* Added support for GCC-EMX <v4.x */
# /* this is needed for XFree86/OS2 developement */
# /* F. Ambacher(anakor@snafu.de) 05.2008 */
# ifdef BUILD_SDL
# define DECLSPEC __declspec(dllexport)
# else
# define DECLSPEC
# endif
# else
# define DECLSPEC
# endif
@ -68,31 +85,45 @@
# endif
#endif
/* By default SDL uses the C calling convention */
/**
* @def SDLCALL
* By default SDL uses the C calling convention
*/
#ifndef SDLCALL
#if defined(__WIN32__) && !defined(__GNUC__)
#define SDLCALL __cdecl
#else
#ifdef __OS2__
/* But on OS/2, we use the _System calling convention */
/* to be compatible with every compiler */
#define SDLCALL _System
#else
#define SDLCALL
#endif
#endif
# if defined(__WIN32__) && !defined(__GNUC__)
# define SDLCALL __cdecl
# elif defined(__OS2__)
# if defined (__GNUC__) && __GNUC__ < 4
# /* Added support for GCC-EMX <v4.x */
# /* this is needed for XFree86/OS2 developement */
# /* F. Ambacher(anakor@snafu.de) 05.2008 */
# define SDLCALL _cdecl
# else
# /* On other compilers on OS/2, we use the _System calling convention */
# /* to be compatible with every compiler */
# define SDLCALL _System
# endif
# else
# define SDLCALL
# endif
#endif /* SDLCALL */
/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
#ifdef __SYMBIAN32__
#ifndef EKA2
#undef DECLSPEC
#define DECLSPEC
#elif !defined(__WINS__)
#undef DECLSPEC
#define DECLSPEC __declspec(dllexport)
#endif /* !EKA2 */
#endif /* __SYMBIAN32__ */
/* Force structure packing at 4 byte alignment.
This is necessary if the header is included in code which has structure
packing set to an alternate value, say for loading structures from disk.
The packing is reset to the previous value in close_code.h
/**
* @file begin_code.h
* Force structure packing at 4 byte alignment.
* This is necessary if the header is included in code which has structure
* packing set to an alternate value, say for loading structures from disk.
* The packing is reset to the previous value in close_code.h
*/
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
#ifdef _MSC_VER
@ -107,7 +138,10 @@
#pragma enumsalwaysint on
#endif /* Compiler needs structure packing set */
/* Set up compiler-specific options for inlining functions */
/**
* @def SDL_INLINE_OKAY
* Set up compiler-specific options for inlining functions
*/
#ifndef SDL_INLINE_OKAY
#ifdef __GNUC__
#define SDL_INLINE_OKAY
@ -116,29 +150,36 @@
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
defined(__DMC__) || defined(__SC__) || \
defined(__WATCOMC__) || defined(__LCC__) || \
defined(__DECC)
defined(__DECC) || defined(__EABI__)
#ifndef __inline__
#define __inline__ __inline
#endif
#define SDL_INLINE_OKAY
#else
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
#ifndef __inline__
#define __inline__ inline
#endif
#define SDL_INLINE_OKAY
#endif /* Not a funky compiler */
#endif /* Visual C++ */
#endif /* GNU C */
#endif /* SDL_INLINE_OKAY */
/* If inlining isn't supported, remove "__inline__", turning static
inlined functions into static functions (resulting in code bloat
in all files which include the offending header files)
*/
/**
* @def __inline__
* If inlining isn't supported, remove "__inline__", turning static
* inlined functions into static functions (resulting in code bloat
* in all files which include the offending header files)
*/
#ifndef SDL_INLINE_OKAY
#define __inline__
#endif
/* Apparently this is needed by several Windows compilers */
/**
* @def NULL
* Apparently this is needed by several Windows compilers
*/
#if !defined(__MACH__)
#ifndef NULL
#ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@ -20,13 +20,18 @@
slouken@libsdl.org
*/
/* This file reverses the effects of begin_code.h and should be included
after you finish any function and structure declarations in your headers
*/
/**
* @file close_code.h
* This file reverses the effects of begin_code.h and should be included
* after you finish any function and structure declarations in your headers
*/
#undef _begin_code_h
/* Reset structure packing at previous byte alignment */
/**
* @file close_code.h
* Reset structure packing at previous byte alignment
*/
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
#ifdef __BORLANDC__
#pragma nopackwarning

View file

@ -28,12 +28,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#if id386
.data
.align 4
Ljmptab: .long Lcase0, Lcase1, Lcase2, Lcase3
.long Lcase4, Lcase5, Lcase6, Lcase7
.text
// TODO: rounding needed?
@ -57,368 +51,4 @@ LOutOfRange:
movl $0xFFFFFFFF,%eax
ret
#if 0
#define in 4
#define out 8
.align 2
.globl C(TransformVector)
C(TransformVector):
movl in(%esp),%eax
movl out(%esp),%edx
flds (%eax) // in[0]
fmuls C(vright) // in[0]*vright[0]
flds (%eax) // in[0] | in[0]*vright[0]
fmuls C(vup) // in[0]*vup[0] | in[0]*vright[0]
flds (%eax) // in[0] | in[0]*vup[0] | in[0]*vright[0]
fmuls C(vpn) // in[0]*vpn[0] | in[0]*vup[0] | in[0]*vright[0]
flds 4(%eax) // in[1] | ...
fmuls C(vright)+4 // in[1]*vright[1] | ...
flds 4(%eax) // in[1] | in[1]*vright[1] | ...
fmuls C(vup)+4 // in[1]*vup[1] | in[1]*vright[1] | ...
flds 4(%eax) // in[1] | in[1]*vup[1] | in[1]*vright[1] | ...
fmuls C(vpn)+4 // in[1]*vpn[1] | in[1]*vup[1] | in[1]*vright[1] | ...
fxch %st(2) // in[1]*vright[1] | in[1]*vup[1] | in[1]*vpn[1] | ...
faddp %st(0),%st(5) // in[1]*vup[1] | in[1]*vpn[1] | ...
faddp %st(0),%st(3) // in[1]*vpn[1] | ...
faddp %st(0),%st(1) // vpn_accum | vup_accum | vright_accum
flds 8(%eax) // in[2] | ...
fmuls C(vright)+8 // in[2]*vright[2] | ...
flds 8(%eax) // in[2] | in[2]*vright[2] | ...
fmuls C(vup)+8 // in[2]*vup[2] | in[2]*vright[2] | ...
flds 8(%eax) // in[2] | in[2]*vup[2] | in[2]*vright[2] | ...
fmuls C(vpn)+8 // in[2]*vpn[2] | in[2]*vup[2] | in[2]*vright[2] | ...
fxch %st(2) // in[2]*vright[2] | in[2]*vup[2] | in[2]*vpn[2] | ...
faddp %st(0),%st(5) // in[2]*vup[2] | in[2]*vpn[2] | ...
faddp %st(0),%st(3) // in[2]*vpn[2] | ...
faddp %st(0),%st(1) // vpn_accum | vup_accum | vright_accum
fstps 8(%edx) // out[2]
fstps 4(%edx) // out[1]
fstps (%edx) // out[0]
ret
#endif
#define EMINS 4+4
#define EMAXS 4+8
#define P 4+12
.align 2
.globl C(BoxOnPlaneSide)
C(BoxOnPlaneSide):
pushl %ebx
movl P(%esp),%edx
movl EMINS(%esp),%ecx
xorl %eax,%eax
movl EMAXS(%esp),%ebx
movb pl_signbits(%edx),%al
cmpb $8,%al
jge Lerror
flds pl_normal(%edx) // p->normal[0]
fld %st(0) // p->normal[0] | p->normal[0]
// bk000422 - warning: missing prefix `*' in absolute indirect address, maybe misassembled!
// bk001129 - fix from Andrew Henderson, was: Ljmptab(,%eax,4)
jmp *Ljmptab(,%eax,4)
//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
Lcase0:
fmuls (%ebx) // p->normal[0]*emaxs[0] | p->normal[0]
flds pl_normal+4(%edx) // p->normal[1] | p->normal[0]*emaxs[0] |
// p->normal[0]
fxch %st(2) // p->normal[0] | p->normal[0]*emaxs[0] |
// p->normal[1]
fmuls (%ecx) // p->normal[0]*emins[0] |
// p->normal[0]*emaxs[0] | p->normal[1]
fxch %st(2) // p->normal[1] | p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fld %st(0) // p->normal[1] | p->normal[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fmuls 4(%ebx) // p->normal[1]*emaxs[1] | p->normal[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
flds pl_normal+8(%edx) // p->normal[2] | p->normal[1]*emaxs[1] |
// p->normal[1] | p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fxch %st(2) // p->normal[1] | p->normal[1]*emaxs[1] |
// p->normal[2] | p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fmuls 4(%ecx) // p->normal[1]*emins[1] |
// p->normal[1]*emaxs[1] |
// p->normal[2] | p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fxch %st(2) // p->normal[2] | p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fld %st(0) // p->normal[2] | p->normal[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fmuls 8(%ebx) // p->normal[2]*emaxs[2] |
// p->normal[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1] |
// p->normal[0]*emaxs[0] |
// p->normal[0]*emins[0]
fxch %st(5) // p->normal[0]*emins[0] |
// p->normal[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1] |
// p->normal[0]*emaxs[0] |
// p->normal[2]*emaxs[2]
faddp %st(0),%st(3) //p->normal[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0] |
// p->normal[2]*emaxs[2]
fmuls 8(%ecx) //p->normal[2]*emins[2] |
// p->normal[1]*emaxs[1] |
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0] |
// p->normal[2]*emaxs[2]
fxch %st(1) //p->normal[1]*emaxs[1] |
// p->normal[2]*emins[2] |
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0] |
// p->normal[2]*emaxs[2]
faddp %st(0),%st(3) //p->normal[2]*emins[2] |
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]|
// p->normal[2]*emaxs[2]
fxch %st(3) //p->normal[2]*emaxs[2] +
// p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]|
// p->normal[2]*emins[2]
faddp %st(0),%st(2) //p->normal[1]*emins[1]+p->normal[0]*emins[0]|
// dist1 | p->normal[2]*emins[2]
jmp LSetSides
//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
Lcase1:
fmuls (%ecx) // emins[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ebx) // emaxs[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ebx) // emaxs[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ecx) // emins[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ebx) // emaxs[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ecx) // emins[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
Lcase2:
fmuls (%ebx) // emaxs[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ecx) // emins[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ecx) // emins[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ebx) // emaxs[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ebx) // emaxs[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ecx) // emins[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
Lcase3:
fmuls (%ecx) // emins[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ebx) // emaxs[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ecx) // emins[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ebx) // emaxs[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ebx) // emaxs[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ecx) // emins[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
Lcase4:
fmuls (%ebx) // emaxs[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ecx) // emins[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ebx) // emaxs[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ecx) // emins[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ecx) // emins[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ebx) // emaxs[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
Lcase5:
fmuls (%ecx) // emins[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ebx) // emaxs[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ebx) // emaxs[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ecx) // emins[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ecx) // emins[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ebx) // emaxs[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
Lcase6:
fmuls (%ebx) // emaxs[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ecx) // emins[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ecx) // emins[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ebx) // emaxs[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ecx) // emins[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ebx) // emaxs[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
jmp LSetSides
//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
Lcase7:
fmuls (%ecx) // emins[0]
flds pl_normal+4(%edx)
fxch %st(2)
fmuls (%ebx) // emaxs[0]
fxch %st(2)
fld %st(0)
fmuls 4(%ecx) // emins[1]
flds pl_normal+8(%edx)
fxch %st(2)
fmuls 4(%ebx) // emaxs[1]
fxch %st(2)
fld %st(0)
fmuls 8(%ecx) // emins[2]
fxch %st(5)
faddp %st(0),%st(3)
fmuls 8(%ebx) // emaxs[2]
fxch %st(1)
faddp %st(0),%st(3)
fxch %st(3)
faddp %st(0),%st(2)
LSetSides:
// sides = 0;
// if (dist1 >= p->dist)
// sides = 1;
// if (dist2 < p->dist)
// sides |= 2;
faddp %st(0),%st(2) // dist1 | dist2
fcomps pl_dist(%edx)
xorl %ecx,%ecx
fnstsw %ax
fcomps pl_dist(%edx)
andb $1,%ah
xorb $1,%ah
addb %ah,%cl
fnstsw %ax
andb $1,%ah
addb %ah,%ah
addb %ah,%cl
// return sides;
popl %ebx
movl %ecx,%eax // return status
ret
Lerror:
movl 1, %eax
ret
#endif // id386

View file

@ -34,13 +34,4 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define C(label) _##label
#endif
// plane_t structure
// !!! if this is changed, it must be changed in q_shared.h too !!!
#define pl_normal 0
#define pl_dist 12
#define pl_type 16
#define pl_signbits 17
#define pl_pad 18
#define pl_size 20
#endif

View file

@ -42,6 +42,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "be_aas.h"
#include "be_aas_funcs.h"
#include "be_aas_def.h"
#include "be_aas_cluster.h"
extern botlib_import_t botimport;

View file

@ -247,7 +247,7 @@ int AAS_StartFrame(float time)
//
aasworld.frameroutingupdates = 0;
//
if (bot_developer)
if (botDeveloper)
{
if (LibVarGetValue("showcacheupdates"))
{

View file

@ -311,7 +311,7 @@ int AAS_EnableRoutingArea(int areanum, int enable)
if (areanum <= 0 || areanum >= aasworld.numareas)
{
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_ERROR, "AAS_EnableRoutingArea: areanum %d out of range\n", areanum);
} //end if
@ -1603,7 +1603,7 @@ int AAS_AreaRouteToGoalArea(int areanum, vec3_t origin, int goalareanum, int tra
//
if (areanum <= 0 || areanum >= aasworld.numareas)
{
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_ERROR, "AAS_AreaTravelTimeToGoalArea: areanum %d out of range\n", areanum);
} //end if
@ -1611,7 +1611,7 @@ int AAS_AreaRouteToGoalArea(int areanum, vec3_t origin, int goalareanum, int tra
} //end if
if (goalareanum <= 0 || goalareanum >= aasworld.numareas)
{
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_ERROR, "AAS_AreaTravelTimeToGoalArea: goalareanum %d out of range\n", goalareanum);
} //end if

View file

@ -150,7 +150,7 @@ aas_link_t *AAS_AllocAASLink(void)
if (!link)
{
#ifndef BSPC
if (bot_developer)
if (botDeveloper)
#endif
{
botimport.Print(PRT_FATAL, "empty aas link heap\n");

View file

@ -416,7 +416,7 @@ int BotLoadCachedCharacter(char *charfile, float skill, int reload)
//
botimport.Print(PRT_MESSAGE, "loaded skill %d from %s\n", intskill, charfile);
#ifdef DEBUG
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_MESSAGE, "skill %d loaded in %d msec from %s\n", intskill, Sys_MilliSeconds() - starttime, charfile);
} //end if

View file

@ -1992,7 +1992,7 @@ bot_replychat_t *BotLoadReplyChat(char *filename)
botimport.Print(PRT_MESSAGE, "loaded %s\n", filename);
//
//BotDumpReplyChat(replychatlist);
if (bot_developer)
if (botDeveloper)
{
BotCheckReplyChatIntegrety(replychatlist);
} //end if
@ -2191,7 +2191,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname)
botimport.Print(PRT_MESSAGE, "loaded %s from %s\n", chatname, chatfile);
//
//BotDumpInitialChat(chat);
if (bot_developer)
if (botDeveloper)
{
BotCheckInitialChatIntegrety(chat);
} //end if

View file

@ -522,7 +522,7 @@ void BotInitInfoEntities(void)
numcampspots++;
} //end else if
} //end for
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_MESSAGE, "%d map locations\n", numlocations);
botimport.Print(PRT_MESSAGE, "%d camp spots\n", numcampspots);

View file

@ -772,7 +772,7 @@ int BotGetReachabilityToGoal(vec3_t origin, int areanum,
if (i != MAX_AVOIDREACH && avoidreachtries[i] > AVOIDREACH_TRIES)
{
#ifdef DEBUG
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_MESSAGE, "avoiding reachability %d\n", avoidreach[i]);
} //end if
@ -3076,7 +3076,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
} //end if
else
{
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_MESSAGE, "client %d: on func_plat without reachability\n", ms->client);
} //end if
@ -3106,7 +3106,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
} //end if
else
{
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_MESSAGE, "client %d: on func_bobbing without reachability\n", ms->client);
} //end if
@ -3208,7 +3208,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
else
{
#ifdef DEBUG
if (bot_developer)
if (botDeveloper)
{
if (ms->reachability_time < AAS_Time())
{
@ -3242,7 +3242,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
if (!AAS_AreaReachability(ms->areanum))
{
#ifdef DEBUG
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_MESSAGE, "area %d no reachability\n", ms->areanum);
} //end if
@ -3273,12 +3273,12 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
} //end if
#ifdef DEBUG
else if (bot_developer)
else if (botDeveloper)
{
botimport.Print(PRT_MESSAGE, "goal not reachable\n");
Com_Memset(&reach, 0, sizeof(aas_reachability_t)); //make compiler happy
} //end else
if (bot_developer)
if (botDeveloper)
{
//if still going for the same goal
if (ms->lastgoalareanum == goal->areanum)
@ -3346,7 +3346,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
Com_Memset(&reach, 0, sizeof(aas_reachability_t));
} //end else
#ifdef DEBUG
if (bot_developer)
if (botDeveloper)
{
if (result->failure)
{
@ -3402,7 +3402,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
} //end else
} //end if
} //end for
if (bot_developer)
if (botDeveloper)
{
//if a jumppad is found with the trace but no reachability is found
if (foundjumppad && !ms->lastreachnum)
@ -3447,7 +3447,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
} //end switch
result->traveltype = reach.traveltype;
#ifdef DEBUG
if (bot_developer)
if (botDeveloper)
{
if (result->failure)
{

View file

@ -64,13 +64,20 @@ int ReadValue(source_t *source, float *value)
if (!strcmp(token.string, "-"))
{
SourceWarning(source, "negative value set to zero\n");
if (!PC_ExpectTokenType(source, TT_NUMBER, 0, &token)) return qfalse;
} //end if
if(!PC_ExpectAnyToken(source, &token))
{
SourceError(source, "Missing return value\n");
return qfalse;
}
}
if (token.type != TT_NUMBER)
{
SourceError(source, "invalid return value %s\n", token.string);
return qfalse;
} //end if
}
*value = token.floatvalue;
return qtrue;
} //end of the function ReadValue
@ -422,7 +429,7 @@ weightconfig_t *ReadWeightConfig(char *filename)
//if the file was located in a pak file
botimport.Print(PRT_MESSAGE, "loaded %s\n", filename);
#ifdef DEBUG
if (bot_developer)
if (botDeveloper)
{
botimport.Print(PRT_MESSAGE, "weights loaded in %d msec\n", Sys_MilliSeconds() - starttime);
} //end if

View file

@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "l_struct.h"
#include "botlib.h"
#include "be_interface.h"
#include "be_ea.h"
#define MAX_USERMOVE 400
#define MAX_COMMANDARGUMENTS 10

View file

@ -58,7 +58,7 @@ botlib_globals_t botlibglobals;
botlib_export_t be_botlib_export;
botlib_import_t botimport;
//
int bot_developer;
int botDeveloper;
//qtrue if the library is setup
int botlibsetup = qfalse;
@ -136,29 +136,35 @@ qboolean BotLibSetup(char *str)
int Export_BotLibSetup(void)
{
int errnum;
char logfilename[MAX_OSPATH];
char *homedir, *gamedir;
bot_developer = LibVarGetValue("bot_developer");
botDeveloper = LibVarGetValue("bot_developer");
memset( &botlibglobals, 0, sizeof(botlibglobals) );
//initialize byte swapping (litte endian etc.)
// Swap_Init();
homedir = LibVarGetString("homedir");
gamedir = LibVarGetString("gamedir");
if (homedir[0]) {
if (gamedir[0]) {
Com_sprintf(logfilename, sizeof(logfilename), "%s%c%s%cbotlib.log", homedir, PATH_SEP, gamedir, PATH_SEP);
if(botDeveloper)
{
char *homedir, *gamedir;
char logfilename[MAX_OSPATH];
homedir = LibVarGetString("homedir");
gamedir = LibVarGetString("gamedir");
if (*homedir)
{
if(*gamedir)
Com_sprintf(logfilename, sizeof(logfilename), "%s%c%s%cbotlib.log", homedir, PATH_SEP, gamedir, PATH_SEP);
else
Com_sprintf(logfilename, sizeof(logfilename), "%s%c" BASEGAME "%cbotlib.log", homedir, PATH_SEP, PATH_SEP);
}
else {
Com_sprintf(logfilename, sizeof(logfilename), "%s%c" BASEGAME "%cbotlib.log", homedir, PATH_SEP, PATH_SEP);
}
} else {
Com_sprintf(logfilename, sizeof(logfilename), "botlib.log");
else
Com_sprintf(logfilename, sizeof(logfilename), "botlib.log");
Log_Open(logfilename);
}
Log_Open(logfilename);
//
botimport.Print(PRT_MESSAGE, "------- BotLib Initialization -------\n");
//
botlibglobals.maxclients = (int) LibVarValue("maxclients", "128");
botlibglobals.maxentities = (int) LibVarValue("maxentities", "1024");

View file

@ -50,7 +50,7 @@ typedef struct botlib_globals_s
extern botlib_globals_t botlibglobals;
extern botlib_import_t botimport;
extern int bot_developer; //true if developer is on
extern int botDeveloper; //true if developer is on
//
int Sys_MilliSeconds(void);

View file

@ -443,7 +443,7 @@ name: default: module(s): description:
"log" "0" l_log.c enable/disable creating a log file
"maxclients" "4" be_interface.c maximum number of clients
"maxentities" "1024" be_interface.c maximum number of entities
"bot_developer" "0" be_interface.c bot developer mode
"bot_developer" "0" be_interface.c bot developer mode (it's "botDeveloper" in C to prevent symbol clash).
"phys_friction" "6" be_aas_move.c ground friction
"phys_stopspeed" "100" be_aas_move.c stop speed

View file

@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../qcommon/q_shared.h"
#include "botlib.h"
#include "be_interface.h" //for botimport.Print
#include "l_crc.h"
// FIXME: byte swap?

View file

@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "botlib.h"
#include "be_interface.h" //for botimport.Print
#include "l_libvar.h"
#include "l_log.h"
#define MAX_LOGFILENAMESIZE 1024

View file

@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../qcommon/q_shared.h"
#include "botlib.h"
#include "l_log.h"
#include "l_memory.h"
#include "be_interface.h"
//#define MEMDEBUG

View file

@ -948,7 +948,7 @@ void PC_ConvertPath(char *path)
if ((*ptr == '\\' || *ptr == '/') &&
(*(ptr+1) == '\\' || *(ptr+1) == '/'))
{
strcpy(ptr, ptr+1);
memmove(ptr, ptr+1, strlen(ptr));
} //end if
else
{
@ -2561,12 +2561,16 @@ int PC_DollarDirective_evalint(source_t *source)
sprintf(token.string, "%d", abs(value));
token.type = TT_NUMBER;
token.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL;
#ifdef NUMBERVALUE
token.intvalue = value;
token.floatvalue = value;
token.intvalue = abs(value);
token.floatvalue = token.intvalue;
#endif //NUMBERVALUE
PC_UnreadSourceToken(source, &token);
if (value < 0) UnreadSignToken(source);
if (value < 0)
UnreadSignToken(source);
return qtrue;
} //end of the function PC_DollarDirective_evalint
//============================================================================
@ -2588,12 +2592,16 @@ int PC_DollarDirective_evalfloat(source_t *source)
sprintf(token.string, "%1.2f", fabs(value));
token.type = TT_NUMBER;
token.subtype = TT_FLOAT|TT_LONG|TT_DECIMAL;
#ifdef NUMBERVALUE
token.intvalue = (unsigned long) value;
token.floatvalue = value;
token.floatvalue = fabs(value);
token.intvalue = (unsigned long) token.floatvalue;
#endif //NUMBERVALUE
PC_UnreadSourceToken(source, &token);
if (value < 0) UnreadSignToken(source);
if (value < 0)
UnreadSignToken(source);
return qtrue;
} //end of the function PC_DollarDirective_evalfloat
//============================================================================

View file

@ -1118,7 +1118,7 @@ void StripDoubleQuotes(char *string)
{
if (*string == '\"')
{
strcpy(string, string+1);
memmove(string, string+1, strlen(string));
} //end if
if (string[strlen(string)-1] == '\"')
{
@ -1135,7 +1135,7 @@ void StripSingleQuotes(char *string)
{
if (*string == '\'')
{
strcpy(string, string+1);
memmove(string, string+1, strlen(string));
} //end if
if (string[strlen(string)-1] == '\'')
{
@ -1156,13 +1156,21 @@ float ReadSignedFloat(script_t *script)
PS_ExpectAnyToken(script, &token);
if (!strcmp(token.string, "-"))
{
if(!PS_ExpectAnyToken(script, &token))
{
ScriptError(script, "Missing float value\n", token.string);
return 0;
}
sign = -1.0;
PS_ExpectTokenType(script, TT_NUMBER, 0, &token);
} //end if
else if (token.type != TT_NUMBER)
}
if (token.type != TT_NUMBER)
{
ScriptError(script, "expected float value, found %s\n", token.string);
} //end else if
return 0;
}
return sign * token.floatvalue;
} //end of the function ReadSignedFloat
//============================================================================
@ -1179,13 +1187,21 @@ signed long int ReadSignedInt(script_t *script)
PS_ExpectAnyToken(script, &token);
if (!strcmp(token.string, "-"))
{
if(!PS_ExpectAnyToken(script, &token))
{
ScriptError(script, "Missing integer value\n", token.string);
return 0;
}
sign = -1;
PS_ExpectTokenType(script, TT_NUMBER, TT_INTEGER, &token);
} //end if
else if (token.type != TT_NUMBER || token.subtype == TT_FLOAT)
}
if (token.type != TT_NUMBER || token.subtype == TT_FLOAT)
{
ScriptError(script, "expected integer value, found %s\n", token.string);
} //end else if
return 0;
}
return sign * token.intvalue;
} //end of the function ReadSignedInt
//============================================================================

View file

@ -555,7 +555,7 @@ void CL_WriteAVIAudioFrame( const byte *pcmBuffer, int size )
afd.numAudioFrames++;
afd.moviSize += ( chunkSize + paddingSize );
afd.a.totalBytes =+ bytesInBuffer;
afd.a.totalBytes += bytesInBuffer;
// Index
bufIndex = 0;

View file

@ -339,6 +339,8 @@ rescan:
// clear notify lines and outgoing commands before passing
// the restart to the cgame
Con_ClearNotify();
// reparse the string, because Con_ClearNotify() may have done another Cmd_TokenizeString()
Cmd_TokenizeString( s );
Com_Memset( cl.cmds, 0, sizeof( cl.cmds ) );
return qtrue;
}
@ -465,7 +467,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
Cmd_RemoveCommand( VMA(1) );
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand( VMA(1) );
CL_AddReliableCommand(VMA(1), qfalse);
return 0;
case CG_UPDATESCREEN:
// this is used during lengthy level loading, so pump message loop

View file

@ -292,7 +292,7 @@ void CL_cURL_BeginDownload( const char *localName, const char *remoteURL )
if(!(clc.sv_allowDownload & DLF_NO_DISCONNECT) &&
!clc.cURLDisconnected) {
CL_AddReliableCommand("disconnect");
CL_AddReliableCommand("disconnect", qtrue);
CL_WritePacket();
CL_WritePacket();
CL_WritePacket();
@ -332,8 +332,7 @@ void CL_cURL_PerformDownload(void)
qcurl_easy_strerror(msg->data.result),
code, clc.downloadURL);
}
*clc.downloadTempName = *clc.downloadName = 0;
Cvar_Set( "cl_downloadName", "" );
CL_NextDownload();
}
#endif /* USE_CURL */

View file

@ -435,52 +435,88 @@ void CL_JoystickMove( usercmd_t *cmd ) {
CL_MouseMove
=================
*/
void CL_MouseMove( usercmd_t *cmd ) {
float mx, my;
float accelSensitivity;
float rate;
void CL_MouseMove(usercmd_t *cmd)
{
float mx, my;
// allow mouse smoothing
if ( m_filter->integer ) {
mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
} else {
if (m_filter->integer)
{
mx = (cl.mouseDx[0] + cl.mouseDx[1]) * 0.5f;
my = (cl.mouseDy[0] + cl.mouseDy[1]) * 0.5f;
}
else
{
mx = cl.mouseDx[cl.mouseIndex];
my = cl.mouseDy[cl.mouseIndex];
}
cl.mouseIndex ^= 1;
cl.mouseDx[cl.mouseIndex] = 0;
cl.mouseDy[cl.mouseIndex] = 0;
rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
// scale by FOV
accelSensitivity *= cl.cgameSensitivity;
if ( rate && cl_showMouseRate->integer ) {
Com_Printf( "%f : %f\n", rate, accelSensitivity );
}
mx *= accelSensitivity;
my *= accelSensitivity;
if (!mx && !my) {
if (mx == 0.0f && my == 0.0f)
return;
if (cl_mouseAccel->value != 0.0f)
{
if(cl_mouseAccelStyle->integer == 0)
{
float accelSensitivity;
float rate;
rate = sqrt(mx * mx + my * my) / (float) frame_msec;
accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
mx *= accelSensitivity;
my *= accelSensitivity;
if(cl_showMouseRate->integer)
Com_Printf("rate: %f, accelSensitivity: %f\n", rate, accelSensitivity);
}
else
{
float rate[2];
float power[2];
// sensitivity remains pretty much unchanged at low speeds
// cl_mouseAccel is a power value to how the acceleration is shaped
// cl_mouseAccelOffset is the rate for which the acceleration will have doubled the non accelerated amplification
// NOTE: decouple the config cvars for independent acceleration setup along X and Y?
rate[0] = fabs(mx) / (float) frame_msec;
rate[1] = fabs(my) / (float) frame_msec;
power[0] = powf(rate[0] / cl_mouseAccelOffset->value, cl_mouseAccel->value);
power[1] = powf(rate[1] / cl_mouseAccelOffset->value, cl_mouseAccel->value);
mx = cl_sensitivity->value * (mx + ((mx < 0) ? -power[0] : power[0]) * cl_mouseAccelOffset->value);
my = cl_sensitivity->value * (my + ((my < 0) ? -power[1] : power[1]) * cl_mouseAccelOffset->value);
if(cl_showMouseRate->integer)
Com_Printf("ratex: %f, ratey: %f, powx: %f, powy: %f\n", rate[0], rate[1], power[0], power[1]);
}
}
else
{
mx *= cl_sensitivity->value;
my *= cl_sensitivity->value;
}
// ingame FOV
mx *= cl.cgameSensitivity;
my *= cl.cgameSensitivity;
// add mouse X/Y movement to cmd
if ( in_strafe.active ) {
cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
} else {
if(in_strafe.active)
cmd->rightmove = ClampChar(cmd->rightmove + m_side->value * mx);
else
cl.viewangles[YAW] -= m_yaw->value * mx;
}
if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
if ((in_mlooking || cl_freelook->integer) && !in_strafe.active)
cl.viewangles[PITCH] += m_pitch->value * my;
} else {
cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
}
else
cmd->forwardmove = ClampChar(cmd->forwardmove - m_forward->value * my);
}
@ -863,7 +899,7 @@ void CL_WritePacket( void ) {
// also use the message acknowledge
key ^= clc.serverMessageSequence;
// also use the last acknowledged server command in the key
key ^= Com_HashKey(clc.serverCommands[ clc.serverCommandSequence & (MAX_RELIABLE_COMMANDS-1) ], 32);
key ^= MSG_HashKey(clc.serverCommands[ clc.serverCommandSequence & (MAX_RELIABLE_COMMANDS-1) ], 32);
// write all the commands, including the predicted command
for ( i = 0 ; i < count ; i++ ) {

View file

@ -740,7 +740,7 @@ void Message_Key( int key ) {
CL_AddReliableCommand( buffer );
CL_AddReliableCommand(buffer, qfalse);
}
Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_MESSAGE );
Field_Clear( &chatField );
@ -1118,94 +1118,72 @@ void CL_InitKeyCommands( void ) {
/*
===================
CL_AddKeyUpCommands
CL_ParseBinding
Execute the commands in the bind string
===================
*/
void CL_AddKeyUpCommands( int key, char *kb, unsigned time) {
int i;
char button[1024], *buttonPtr;
char cmd[1024];
qboolean keyevent;
void CL_ParseBinding( int key, qboolean down, unsigned time )
{
char buf[ MAX_STRING_CHARS ], *p = buf, *end;
if ( !kb ) {
if( !keys[key].binding || !keys[key].binding[0] )
return;
}
keyevent = qfalse;
buttonPtr = button;
for ( i = 0; ; i++ ) {
if ( kb[i] == ';' || !kb[i] ) {
*buttonPtr = '\0';
if ( button[0] == '+') {
// button commands add keynum and time as parms so that multiple
// sources can be discriminated and subframe corrected
Com_sprintf (cmd, sizeof(cmd), "-%s %i %i\n", button+1, key, time);
Cbuf_AddText (cmd);
keyevent = qtrue;
} else {
if (keyevent) {
// down-only command
Cbuf_AddText (button);
Cbuf_AddText ("\n");
}
}
buttonPtr = button;
while ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] != 0 ) {
i++;
}
Q_strncpyz( buf, keys[key].binding, sizeof( buf ) );
while( 1 )
{
while( isspace( *p ) )
p++;
end = strchr( p, ';' );
if( end )
*end = '\0';
if( *p == '+' )
{
// button commands add keynum and time as parameters
// so that multiple sources can be discriminated and
// subframe corrected
char cmd[1024];
Com_sprintf( cmd, sizeof( cmd ), "%c%s %d %d\n",
( down ) ? '+' : '-', p + 1, key, time );
Cbuf_AddText( cmd );
}
*buttonPtr++ = kb[i];
if ( !kb[i] ) {
else if( down )
{
// normal commands only execute on key press
Cbuf_AddText( p );
Cbuf_AddText( "\n" );
}
if( !end )
break;
}
p = end + 1;
}
}
/*
===================
CL_KeyEvent
CL_KeyDownEvent
Called by the system for both key up and key down events
Called by CL_KeyEvent to handle a keypress
===================
*/
void CL_KeyEvent (int key, qboolean down, unsigned time) {
char *kb;
char cmd[1024];
void CL_KeyDownEvent( int key, unsigned time )
{
keys[key].down = qtrue;
keys[key].repeats++;
if( keys[key].repeats == 1 )
anykeydown++;
// update auto-repeat status and BUTTON_ANY status
keys[key].down = down;
if (down) {
keys[key].repeats++;
if ( keys[key].repeats == 1) {
anykeydown++;
}
} else {
keys[key].repeats = 0;
anykeydown--;
if (anykeydown < 0) {
anykeydown = 0;
}
}
if (key == K_ENTER)
if( keys[K_ALT].down && key == K_ENTER )
{
if (down)
{
if (keys[K_ALT].down)
{
Cvar_SetValue( "r_fullscreen",
!Cvar_VariableIntegerValue( "r_fullscreen" ) );
return;
}
}
Cvar_SetValue( "r_fullscreen",
!Cvar_VariableIntegerValue( "r_fullscreen" ) );
return;
}
// console key is hardcoded, so the user can never unbind it
if (key == K_CONSOLE ||
( key == K_ESCAPE && keys[K_SHIFT].down ) ) {
if (!down) {
return;
}
if( key == K_CONSOLE || ( keys[K_SHIFT].down && key == K_ESCAPE ) )
{
Con_ToggleConsole_f ();
Key_ClearStates ();
return;
@ -1213,7 +1191,7 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
// keys can still be used for bound actions
if ( down && ( key < 128 || key == K_MOUSE1 ) &&
if ( ( key < 128 || key == K_MOUSE1 ) &&
( clc.demoplaying || cls.state == CA_CINEMATIC ) && Key_GetCatcher( ) == 0 ) {
if (Cvar_VariableValue ("com_cameraMode") == 0) {
@ -1222,9 +1200,8 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
}
}
// escape is always handled special
if ( key == K_ESCAPE && down ) {
if ( key == K_ESCAPE ) {
if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) {
// clear message mode
Message_Key( key );
@ -1250,43 +1227,20 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
return;
}
VM_Call( uivm, UI_KEY_EVENT, key, down );
VM_Call( uivm, UI_KEY_EVENT, key, qtrue );
return;
}
//
// key up events only perform actions if the game key binding is
// a button command (leading + sign). These will be processed even in
// console mode and menu mode, to keep the character from continuing
// an action started before a mode switch.
//
if (!down ) {
if ( cls.state != CA_DISCONNECTED ) {
kb = keys[key].binding;
CL_AddKeyUpCommands( key, kb, time );
}
if ( Key_GetCatcher( ) & KEYCATCH_UI && uivm ) {
VM_Call( uivm, UI_KEY_EVENT, key, down );
} else if ( Key_GetCatcher( ) & KEYCATCH_CGAME && cgvm ) {
VM_Call( cgvm, CG_KEY_EVENT, key, down );
}
return;
}
// distribute the key down event to the apropriate handler
if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) {
Console_Key( key );
} else if ( Key_GetCatcher( ) & KEYCATCH_UI ) {
if ( uivm ) {
VM_Call( uivm, UI_KEY_EVENT, key, down );
VM_Call( uivm, UI_KEY_EVENT, key, qtrue );
}
} else if ( Key_GetCatcher( ) & KEYCATCH_CGAME ) {
if ( cgvm ) {
VM_Call( cgvm, CG_KEY_EVENT, key, down );
VM_Call( cgvm, CG_KEY_EVENT, key, qtrue );
}
} else if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) {
Message_Key( key );
@ -1294,47 +1248,60 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
Console_Key( key );
} else {
// send the bound action
kb = keys[key].binding;
if ( !kb ) {
if (key >= 200) {
Com_Printf ("%s is unbound, use controls menu to set.\n"
, Key_KeynumToString( key ) );
}
} else if (kb[0] == '+') {
int i;
char button[1024], *buttonPtr;
buttonPtr = button;
for ( i = 0; ; i++ ) {
if ( kb[i] == ';' || !kb[i] ) {
*buttonPtr = '\0';
if ( button[0] == '+') {
// button commands add keynum and time as parms so that multiple
// sources can be discriminated and subframe corrected
Com_sprintf (cmd, sizeof(cmd), "%s %i %i\n", button, key, time);
Cbuf_AddText (cmd);
} else {
// down-only command
Cbuf_AddText (button);
Cbuf_AddText ("\n");
}
buttonPtr = button;
while ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] != 0 ) {
i++;
}
}
*buttonPtr++ = kb[i];
if ( !kb[i] ) {
break;
}
}
} else {
// down-only command
Cbuf_AddText (kb);
Cbuf_AddText ("\n");
}
CL_ParseBinding( key, qtrue, time );
}
return;
}
/*
===================
CL_KeyUpEvent
Called by CL_KeyEvent to handle a keyrelease
===================
*/
void CL_KeyUpEvent( int key, unsigned time )
{
keys[key].repeats = 0;
keys[key].down = qfalse;
anykeydown--;
if (anykeydown < 0) {
anykeydown = 0;
}
// don't process key-up events for the console key
if ( key == K_CONSOLE || ( key == K_ESCAPE && keys[K_SHIFT].down ) )
return;
//
// key up events only perform actions if the game key binding is
// a button command (leading + sign). These will be processed even in
// console mode and menu mode, to keep the character from continuing
// an action started before a mode switch.
//
if( cls.state != CA_DISCONNECTED )
CL_ParseBinding( key, qfalse, time );
if ( Key_GetCatcher( ) & KEYCATCH_UI && uivm ) {
VM_Call( uivm, UI_KEY_EVENT, key, qfalse );
} else if ( Key_GetCatcher( ) & KEYCATCH_CGAME && cgvm ) {
VM_Call( cgvm, CG_KEY_EVENT, key, qfalse );
}
}
/*
===================
CL_KeyEvent
Called by the system for both key up and key down events
===================
*/
void CL_KeyEvent (int key, qboolean down, unsigned time) {
if( down )
CL_KeyDownEvent( key, time );
else
CL_KeyUpEvent( key, time );
}
/*
===================

View file

@ -73,6 +73,8 @@ cvar_t *cl_freelook;
cvar_t *cl_sensitivity;
cvar_t *cl_mouseAccel;
cvar_t *cl_mouseAccelOffset;
cvar_t *cl_mouseAccelStyle;
cvar_t *cl_showMouseRate;
cvar_t *m_pitch;
@ -189,11 +191,13 @@ void CL_UpdateVoipIgnore(const char *idstr, qboolean ignore)
if ((id >= 0) && (id < MAX_CLIENTS)) {
clc.voipIgnore[id] = ignore;
CL_AddReliableCommand(va("voip %s %d",
ignore ? "ignore" : "unignore", id));
ignore ? "ignore" : "unignore", id), qfalse);
Com_Printf("VoIP: %s ignoring player #%d\n",
ignore ? "Now" : "No longer", id);
return;
}
}
Com_Printf("VoIP: invalid player ID#\n");
}
static
@ -234,15 +238,31 @@ void CL_Voip_f( void )
} else if (strcmp(cmd, "unignore") == 0) {
CL_UpdateVoipIgnore(Cmd_Argv(2), qfalse);
} else if (strcmp(cmd, "gain") == 0) {
CL_UpdateVoipGain(Cmd_Argv(2), atof(Cmd_Argv(3)));
if (Cmd_Argc() > 3) {
CL_UpdateVoipGain(Cmd_Argv(2), atof(Cmd_Argv(3)));
} else if (Q_isanumber(Cmd_Argv(2))) {
int id = atoi(Cmd_Argv(2));
if (id >= 0 && id < MAX_CLIENTS) {
Com_Printf("VoIP: current gain for player #%d "
"is %f\n", id, clc.voipGain[id]);
} else {
Com_Printf("VoIP: invalid player ID#\n");
}
} else {
Com_Printf("usage: voip gain <playerID#> [value]\n");
}
} else if (strcmp(cmd, "muteall") == 0) {
Com_Printf("VoIP: muting incoming voice\n");
CL_AddReliableCommand("voip muteall");
CL_AddReliableCommand("voip muteall", qfalse);
clc.voipMuteAll = qtrue;
} else if (strcmp(cmd, "unmuteall") == 0) {
Com_Printf("VoIP: unmuting incoming voice\n");
CL_AddReliableCommand("voip unmuteall");
CL_AddReliableCommand("voip unmuteall", qfalse);
clc.voipMuteAll = qfalse;
} else {
Com_Printf("usage: voip [un]ignore <playerID#>\n"
" voip [un]muteall\n"
" voip gain <playerID#> [value]\n");
}
}
@ -301,8 +321,6 @@ void CL_CaptureVoip(void)
dontCapture = qtrue; // not connected to a server.
else if (!cl_connectedToVoipServer)
dontCapture = qtrue; // server doesn't support VoIP.
else if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive"))
dontCapture = qtrue; // single player game.
else if (clc.demoplaying)
dontCapture = qtrue; // playing back a demo.
else if ( cl_voip->integer == 0 )
@ -441,17 +459,25 @@ The given command will be transmitted to the server, and is gauranteed to
not have future usercmd_t executed before it is executed
======================
*/
void CL_AddReliableCommand( const char *cmd ) {
int index;
void CL_AddReliableCommand(const char *cmd, qboolean isDisconnectCmd)
{
int unacknowledged = clc.reliableSequence - clc.reliableAcknowledge;
// if we would be losing an old command that hasn't been acknowledged,
// we must drop the connection
if ( clc.reliableSequence - clc.reliableAcknowledge > MAX_RELIABLE_COMMANDS ) {
Com_Error( ERR_DROP, "Client command overflow" );
// also leave one slot open for the disconnect command in this case.
if ((isDisconnectCmd && unacknowledged > MAX_RELIABLE_COMMANDS) ||
(!isDisconnectCmd && unacknowledged >= MAX_RELIABLE_COMMANDS))
{
if(com_errorEntered)
return;
else
Com_Error(ERR_DROP, "Client command overflow");
}
clc.reliableSequence++;
index = clc.reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 );
Q_strncpyz( clc.reliableCommands[ index ], cmd, sizeof( clc.reliableCommands[ index ] ) );
Q_strncpyz(clc.reliableCommands[++clc.reliableSequence & (MAX_RELIABLE_COMMANDS - 1)],
cmd, sizeof(*clc.reliableCommands));
}
/*
@ -901,7 +927,7 @@ void CL_PlayDemo_f( void ) {
char retry[MAX_OSPATH];
if (Cmd_Argc() != 2) {
Com_Printf ("playdemo <demoname>\n");
Com_Printf ("demo <demoname>\n");
return;
}
@ -909,14 +935,17 @@ void CL_PlayDemo_f( void ) {
// 2 means don't force disconnect of local client
Cvar_Set( "sv_killserver", "2" );
CL_Disconnect( qtrue );
// open the demo file
arg = Cmd_Argv(1);
CL_Disconnect( qtrue );
// check for an extension .dm_?? (?? is protocol)
ext_test = arg + strlen(arg) - 6;
if ((strlen(arg) > 6) && (ext_test[0] == '.') && ((ext_test[1] == 'd') || (ext_test[1] == 'D')) && ((ext_test[2] == 'm') || (ext_test[2] == 'M')) && (ext_test[3] == '_'))
if ((strlen(arg) > 6) && (ext_test[0] == '.') &&
((ext_test[1] == 'd') || (ext_test[1] == 'D')) &&
((ext_test[2] == 'm') || (ext_test[2] == 'M')) &&
(ext_test[3] == '_'))
{
protocol = atoi(ext_test+4);
i=0;
@ -1217,12 +1246,15 @@ void CL_Disconnect( qboolean showMainMenu ) {
// send a disconnect message to the server
// send it a few times in case one is dropped
if ( cls.state >= CA_CONNECTED ) {
CL_AddReliableCommand( "disconnect" );
CL_AddReliableCommand("disconnect", qtrue);
CL_WritePacket();
CL_WritePacket();
CL_WritePacket();
}
// Remove pure paks
FS_PureServerSetLoadedPaks("", "");
CL_ClearState ();
// wipe the client connection
@ -1276,9 +1308,9 @@ void CL_ForwardCommandToServer( const char *string ) {
}
if ( Cmd_Argc() > 1 ) {
CL_AddReliableCommand( string );
CL_AddReliableCommand(string, qfalse);
} else {
CL_AddReliableCommand( cmd );
CL_AddReliableCommand(cmd, qfalse);
}
}
@ -1420,45 +1452,10 @@ void CL_ForwardToServer_f( void ) {
// don't forward the first argument
if ( Cmd_Argc() > 1 ) {
CL_AddReliableCommand( Cmd_Args() );
CL_AddReliableCommand(Cmd_Args(), qfalse);
}
}
/*
==================
CL_Setenv_f
Mostly for controlling voodoo environment variables
==================
*/
void CL_Setenv_f( void ) {
int argc = Cmd_Argc();
if ( argc > 2 ) {
char buffer[1024];
int i;
strcpy( buffer, Cmd_Argv(1) );
strcat( buffer, "=" );
for ( i = 2; i < argc; i++ ) {
strcat( buffer, Cmd_Argv( i ) );
strcat( buffer, " " );
}
putenv( buffer );
} else if ( argc == 2 ) {
char *env = getenv( Cmd_Argv(1) );
if ( env ) {
Com_Printf( "%s=%s\n", Cmd_Argv(1), env );
} else {
Com_Printf( "%s undefined\n", Cmd_Argv(1));
}
}
}
/*
==================
CL_Disconnect_f
@ -1660,7 +1657,7 @@ void CL_SendPureChecksums( void ) {
// if we are pure we need to send back a command with our referenced pk3 checksums
Com_sprintf(cMsg, sizeof(cMsg), "cp %d %s", cl.serverId, FS_ReferencedPakPureChecksums());
CL_AddReliableCommand( cMsg );
CL_AddReliableCommand(cMsg, qfalse);
}
/*
@ -1669,7 +1666,7 @@ CL_ResetPureClientAtServer
=================
*/
void CL_ResetPureClientAtServer( void ) {
CL_AddReliableCommand( va("vdr") );
CL_AddReliableCommand("vdr", qfalse);
}
/*
@ -1740,6 +1737,19 @@ void CL_Vid_Restart_f( void ) {
}
}
/*
=================
CL_Snd_Restart
Restart the sound subsystem
=================
*/
void CL_Snd_Restart(void)
{
S_Shutdown();
S_Init();
}
/*
=================
CL_Snd_Restart_f
@ -1749,10 +1759,9 @@ The cgame and game must also be forced to restart because
handles will be invalid
=================
*/
void CL_Snd_Restart_f( void ) {
S_Shutdown();
S_Init();
void CL_Snd_Restart_f(void)
{
CL_Snd_Restart();
CL_Vid_Restart_f();
}
@ -1848,7 +1857,7 @@ void CL_DownloadsComplete( void ) {
FS_Restart(clc.checksumFeed); // We possibly downloaded a pak, restart the file system to load it
// inform the server so we get new gamestate info
CL_AddReliableCommand( "donedl" );
CL_AddReliableCommand("donedl", qfalse);
// by sending the donedl command we request a new gamestate
// so we don't want to load stuff yet
@ -1915,7 +1924,7 @@ void CL_BeginDownload( const char *localName, const char *remoteName ) {
clc.downloadBlock = 0; // Starting new file
clc.downloadCount = 0;
CL_AddReliableCommand( va("download %s", remoteName) );
CL_AddReliableCommand(va("download %s", remoteName), qfalse);
}
/*
@ -1925,11 +1934,25 @@ CL_NextDownload
A download completed or failed
=================
*/
void CL_NextDownload(void) {
void CL_NextDownload(void)
{
char *s;
char *remoteName, *localName;
qboolean useCURL = qfalse;
// A download has finished, check whether this matches a referenced checksum
if(*clc.downloadName)
{
char *zippath = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), clc.downloadName, "");
zippath[strlen(zippath)-1] = '\0';
if(!FS_CompareZipChecksum(zippath))
Com_Error(ERR_DROP, "Incorrect checksum for file: %s", clc.downloadName);
}
*clc.downloadTempName = *clc.downloadName = 0;
Cvar_Set("cl_downloadName", "");
// We are looking to start a download here
if (*clc.downloadList) {
s = clc.downloadList;
@ -2036,6 +2059,10 @@ void CL_InitDownloads(void) {
if ( *clc.downloadList ) {
// if autodownloading is not enabled on the server
cls.state = CA_CONNECTED;
*clc.downloadTempName = *clc.downloadName = 0;
Cvar_Set( "cl_downloadName", "" );
CL_NextDownload();
return;
}
@ -2086,7 +2113,7 @@ void CL_CheckForResend( void ) {
// The challenge request shall be followed by a client challenge so no malicious server can hijack this connection.
Com_sprintf(data, sizeof(data), "getchallenge %d", clc.challenge);
NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, data);
NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "%s", data);
break;
case CA_CHALLENGING:
@ -2574,7 +2601,7 @@ void CL_CheckUserinfo( void ) {
if(cvar_modifiedFlags & CVAR_USERINFO)
{
cvar_modifiedFlags &= ~CVAR_USERINFO;
CL_AddReliableCommand( va("userinfo \"%s\"", Cvar_InfoString( CVAR_USERINFO ) ) );
CL_AddReliableCommand(va("userinfo \"%s\"", Cvar_InfoString( CVAR_USERINFO ) ), qfalse);
}
}
@ -3092,6 +3119,13 @@ void CL_Init( void ) {
cl_mouseAccel = Cvar_Get ("cl_mouseAccel", "0", CVAR_ARCHIVE);
cl_freelook = Cvar_Get( "cl_freelook", "1", CVAR_ARCHIVE );
// 0: legacy mouse acceleration
// 1: new implementation
cl_mouseAccelStyle = Cvar_Get( "cl_mouseAccelStyle", "0", CVAR_ARCHIVE );
// offset for the power function (for style 1, ignored otherwise)
// this should be set to the max rate value
cl_mouseAccelOffset = Cvar_Get( "cl_mouseAccelOffset", "5", CVAR_ARCHIVE );
cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0);
cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE);
@ -3136,13 +3170,13 @@ void CL_Init( void ) {
cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE);
// userinfo
Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("rate", "3000", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("name", "Suislide", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("snaps", "20", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("model", "sarge", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("headmodel", "sarge", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("team_model", "james", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("team_headmodel", "*james", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("model", "reactionmale", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("headmodel", "reactionmale", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("team_model", "reactionmale", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("team_headmodel", "*reactionmale", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("g_redTeam", "Stroggs", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("g_blueTeam", "Pagans", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("color1", "4", CVAR_USERINFO | CVAR_ARCHIVE );
@ -3179,7 +3213,7 @@ void CL_Init( void ) {
// just demand it. Who doesn't have at least a DSL line now, anyhow? If
// you don't, you don't need VoIP. :)
if ((cl_voip->integer) && (Cvar_VariableIntegerValue("rate") < 25000)) {
Com_Printf("Your network rate is too slow for VoIP.\n");
Com_Printf(S_COLOR_YELLOW "Your network rate is too slow for VoIP.\n");
Com_Printf("Set 'Data Rate' to 'LAN/Cable/xDSL' in 'Setup/System/Network' and restart.\n");
Com_Printf("Until then, VoIP is disabled.\n");
Cvar_Set("cl_voip", "0");
@ -3212,7 +3246,6 @@ void CL_Init( void ) {
Cmd_AddCommand ("globalservers", CL_GlobalServers_f);
Cmd_AddCommand ("rcon", CL_Rcon_f);
Cmd_SetCommandCompletionFunc( "rcon", CL_CompleteRcon );
Cmd_AddCommand ("setenv", CL_Setenv_f );
Cmd_AddCommand ("ping", CL_Ping_f );
Cmd_AddCommand ("serverstatus", CL_ServerStatus_f );
Cmd_AddCommand ("showip", CL_ShowIP_f );
@ -3243,14 +3276,14 @@ CL_Shutdown
===============
*/
void CL_Shutdown( void ) {
void CL_Shutdown( char *finalmsg ) {
static qboolean recursive = qfalse;
// check whether the client is running at all.
if(!(com_cl_running && com_cl_running->integer))
return;
Com_Printf( "----- CL_Shutdown -----\n" );
Com_Printf( "----- Client Shutdown (%s) -----\n", finalmsg );
if ( recursive ) {
Com_Printf( "WARNING: Recursive shutdown\n" );
@ -3279,7 +3312,6 @@ void CL_Shutdown( void ) {
Cmd_RemoveCommand ("localservers");
Cmd_RemoveCommand ("globalservers");
Cmd_RemoveCommand ("rcon");
Cmd_RemoveCommand ("setenv");
Cmd_RemoveCommand ("ping");
Cmd_RemoveCommand ("serverstatus");
Cmd_RemoveCommand ("showip");
@ -4130,13 +4162,15 @@ void CL_ShowIP_f(void) {
Sys_ShowIP();
}
#ifndef STANDALONE
/*
=================
bool CL_CDKeyValidate
=================
*/
qboolean CL_CDKeyValidate( const char *key, const char *checksum ) {
#ifdef STANDALONE
return qtrue;
#else
char ch;
byte sum;
char chs[3];
@ -4193,5 +4227,5 @@ qboolean CL_CDKeyValidate( const char *key, const char *checksum ) {
}
return qfalse;
}
#endif
}

View file

@ -366,7 +366,11 @@ void CL_SystemInfoChanged( void ) {
// in the future, (val) will be a protocol version string, so only
// accept explicitly 1, not generally non-zero.
s = Info_ValueForKey( systemInfo, "sv_voip" );
cl_connectedToVoipServer = (atoi( s ) == 1);
if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive"))
cl_connectedToVoipServer = qfalse;
else
cl_connectedToVoipServer = (atoi( s ) == 1);
#endif
s = Info_ValueForKey( systemInfo, "sv_cheats" );
@ -552,7 +556,7 @@ void CL_ParseDownload ( msg_t *msg ) {
if (!*clc.downloadTempName) {
Com_Printf("Server sending download, but no download was requested\n");
CL_AddReliableCommand( "stopdl" );
CL_AddReliableCommand("stopdl", qfalse);
return;
}
@ -594,7 +598,7 @@ void CL_ParseDownload ( msg_t *msg ) {
if (!clc.download) {
Com_Printf( "Could not create %s\n", clc.downloadTempName );
CL_AddReliableCommand( "stopdl" );
CL_AddReliableCommand("stopdl", qfalse);
CL_NextDownload();
return;
}
@ -603,7 +607,7 @@ void CL_ParseDownload ( msg_t *msg ) {
if (size)
FS_Write( data, size, clc.download );
CL_AddReliableCommand( va("nextdl %d", clc.downloadBlock) );
CL_AddReliableCommand(va("nextdl %d", clc.downloadBlock), qfalse);
clc.downloadBlock++;
clc.downloadCount += size;
@ -619,8 +623,6 @@ void CL_ParseDownload ( msg_t *msg ) {
// rename the file
FS_SV_Rename ( clc.downloadTempName, clc.downloadName );
}
*clc.downloadTempName = *clc.downloadName = 0;
Cvar_Set( "cl_downloadName", "" );
// send intentions now
// We need this because without it, we would hold the last nextdl and then start

View file

@ -273,14 +273,16 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
xx = x;
re.SetColor( setColor );
while ( *s ) {
if ( !noColorEscape && Q_IsColorString( s ) ) {
if ( Q_IsColorString( s ) ) {
if ( !forceColor ) {
Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
color[3] = setColor[3];
re.SetColor( color );
}
s += 2;
continue;
if ( !noColorEscape ) {
s += 2;
continue;
}
}
SCR_DrawSmallChar( xx, y, *s );
xx += SMALLCHAR_WIDTH;
@ -362,8 +364,6 @@ void SCR_DrawVoipMeter( void ) {
return; // not connected to a server.
else if (!cl_connectedToVoipServer)
return; // server doesn't support VoIP.
else if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive"))
return; // single player game.
else if (clc.demoplaying)
return; // playing back a demo.
else if (!cl_voip->integer)
@ -575,8 +575,10 @@ void SCR_UpdateScreen( void ) {
// that case.
if( uivm || com_dedicated->integer )
{
// XXX
extern cvar_t* r_anaglyphMode;
// if running in stereo, we need to draw the frame twice
if ( cls.glconfig.stereoEnabled || Cvar_VariableIntegerValue("r_anaglyphMode")) {
if ( cls.glconfig.stereoEnabled || r_anaglyphMode->integer) {
SCR_DrawScreenField( STEREO_LEFT );
SCR_DrawScreenField( STEREO_RIGHT );
} else {

View file

@ -625,8 +625,8 @@ static void Key_GetBindingBuf( int keynum, char *buf, int buflen ) {
CLUI_GetCDKey
====================
*/
#ifndef STANDALONE
static void CLUI_GetCDKey( char *buf, int buflen ) {
#ifndef STANDALONE
cvar_t *fs;
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO );
if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) {
@ -636,6 +636,9 @@ static void CLUI_GetCDKey( char *buf, int buflen ) {
Com_Memcpy( buf, cl_cdkey, 16);
buf[16] = 0;
}
#else
*buf = 0;
#endif
}
@ -644,6 +647,7 @@ static void CLUI_GetCDKey( char *buf, int buflen ) {
CLUI_SetCDKey
====================
*/
#ifndef STANDALONE
static void CLUI_SetCDKey( char *buf ) {
cvar_t *fs;
fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO );
@ -963,15 +967,15 @@ intptr_t CL_UISystemCalls( intptr_t *args ) {
case UI_MEMORY_REMAINING:
return Hunk_MemoryRemaining();
#ifndef STANDALONE
case UI_GET_CDKEY:
CLUI_GetCDKey( VMA(1), args[2] );
return 0;
case UI_SET_CDKEY:
#ifndef STANDALONE
CLUI_SetCDKey( VMA(1) );
return 0;
#endif
return 0;
case UI_SET_PBCLSTATUS:
return 0;
@ -1053,11 +1057,8 @@ intptr_t CL_UISystemCalls( intptr_t *args ) {
re.RemapShader( VMA(1), VMA(2), VMA(3) );
return 0;
#ifndef STANDALONE
case UI_VERIFY_CDKEY:
return CL_CDKeyValidate(VMA(1), VMA(2));
#endif
default:
Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] );

View file

@ -379,6 +379,8 @@ extern cvar_t *cl_sensitivity;
extern cvar_t *cl_freelook;
extern cvar_t *cl_mouseAccel;
extern cvar_t *cl_mouseAccelOffset;
extern cvar_t *cl_mouseAccelStyle;
extern cvar_t *cl_showMouseRate;
extern cvar_t *m_pitch;
@ -431,7 +433,7 @@ extern cvar_t *cl_voip;
void CL_Init (void);
void CL_FlushMemory(void);
void CL_ShutdownAll(void);
void CL_AddReliableCommand( const char *cmd );
void CL_AddReliableCommand(const char *cmd, qboolean isDisconnectCmd);
void CL_StartHunkUsers( qboolean rendererOnly );

View file

@ -39,14 +39,26 @@
#include "libmumblelink.h"
#ifndef MIN
#define MIN(a, b) ((a)<(b)?(a):(b))
#endif
typedef struct
{
uint32_t uiVersion;
uint32_t uiTick;
float fPosition[3];
float fFront[3];
float fTop[3];
float fAvatarPosition[3];
float fAvatarFront[3];
float fAvatarTop[3];
wchar_t name[256];
/* new in mumble 1.2 */
float fCameraPosition[3];
float fCameraFront[3];
float fCameraTop[3];
wchar_t identity[256];
uint32_t context_len;
unsigned char context[256];
wchar_t description[2048];
} LinkedMem;
static LinkedMem *lm = NULL;
@ -94,26 +106,65 @@ int mumble_link(const char* name)
lm = (LinkedMem *) (mmap(NULL, sizeof(LinkedMem), PROT_READ | PROT_WRITE, MAP_SHARED, shmfd,0));
if (lm == (void *) (-1)) {
lm = NULL;
close(shmfd);
return -1;
}
close(shmfd);
#endif
memset(lm, 0, sizeof(LinkedMem));
mbstowcs(lm->name, name, sizeof(lm->name));
return 0;
}
void mumble_update_coordinates(float fPosition[3], float fFront[3], float fTop[3])
{
mumble_update_coordinates2(fPosition, fFront, fTop, fPosition, fFront, fTop);
}
void mumble_update_coordinates2(float fAvatarPosition[3], float fAvatarFront[3], float fAvatarTop[3],
float fCameraPosition[3], float fCameraFront[3], float fCameraTop[3])
{
if (!lm)
return;
memcpy(lm->fPosition, fPosition, sizeof(fPosition));
memcpy(lm->fFront, fFront, sizeof(fFront));
memcpy(lm->fTop, fTop, sizeof(fTop));
lm->uiVersion = 1;
memcpy(lm->fAvatarPosition, fAvatarPosition, sizeof(lm->fAvatarPosition));
memcpy(lm->fAvatarFront, fAvatarFront, sizeof(lm->fAvatarFront));
memcpy(lm->fAvatarTop, fAvatarTop, sizeof(lm->fAvatarTop));
memcpy(lm->fCameraPosition, fCameraPosition, sizeof(lm->fCameraPosition));
memcpy(lm->fCameraFront, fCameraFront, sizeof(lm->fCameraFront));
memcpy(lm->fCameraTop, fCameraTop, sizeof(lm->fCameraTop));
lm->uiVersion = 2;
lm->uiTick = GetTickCount();
}
void mumble_set_identity(const char* identity)
{
size_t len;
if (!lm)
return;
len = MIN(sizeof(lm->identity), strlen(identity)+1);
mbstowcs(lm->identity, identity, len);
}
void mumble_set_context(const unsigned char* context, size_t len)
{
if (!lm)
return;
len = MIN(sizeof(lm->context), len);
lm->context_len = len;
memcpy(lm->context, context, len);
}
void mumble_set_description(const char* description)
{
size_t len;
if (!lm)
return;
len = MIN(sizeof(lm->description), strlen(description)+1);
mbstowcs(lm->description, description, len);
}
void mumble_unlink()
{
if(!lm)

View file

@ -23,4 +23,13 @@
int mumble_link(const char* name);
int mumble_islinked(void);
void mumble_update_coordinates(float fPosition[3], float fFront[3], float fTop[3]);
/* new for mumble 1.2: also set camera position */
void mumble_update_coordinates2(float fAvatarPosition[3], float fAvatarFront[3], float fAvatarTop[3],
float fCameraPosition[3], float fCameraFront[3], float fCameraTop[3]);
void mumble_set_description(const char* description);
void mumble_set_context(const unsigned char* context, size_t len);
void mumble_set_identity(const char* identity);
void mumble_unlink(void);

View file

@ -33,10 +33,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "snd_codec.h"
#include "client.h"
void S_Play_f(void);
void S_SoundList_f(void);
void S_Music_f(void);
void S_Update_( void );
void S_Base_StopAllSounds(void);
void S_Base_StopBackgroundTrack( void );
@ -916,7 +912,7 @@ void S_ByteSwapRawSamples( int samples, int width, int s_channels, const byte *d
/*
============
S_RawSamples
S_Base_RawSamples
Music streaming
============
@ -937,10 +933,13 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
}
rawsamples = s_rawsamples[stream];
intVolume = 256 * volume;
if(s_muted->integer)
intVolume = 0;
else
intVolume = 256 * volume * s_volume->value;
if ( s_rawend[stream] < s_soundtime ) {
Com_DPrintf( "S_RawSamples: resetting minimum: %i < %i\n", s_rawend[stream], s_soundtime );
Com_DPrintf( "S_Base_RawSamples: resetting minimum: %i < %i\n", s_rawend[stream], s_soundtime );
s_rawend[stream] = s_soundtime;
}
@ -1018,7 +1017,7 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
}
if ( s_rawend[stream] > s_soundtime + MAX_RAW_SAMPLES ) {
Com_DPrintf( "S_RawSamples: overflowed %i > %i\n", s_rawend[stream], s_soundtime );
Com_DPrintf( "S_Base_RawSamples: overflowed %i > %i\n", s_rawend[stream], s_soundtime );
}
}
@ -1312,7 +1311,9 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
}
Com_DPrintf( "S_StartBackgroundTrack( %s, %s )\n", intro, loop );
if ( !intro[0] ) {
if(!*intro)
{
S_Base_StopBackgroundTrack();
return;
}
@ -1353,17 +1354,13 @@ void S_UpdateBackgroundTrack( void ) {
byte raw[30000]; // just enough to fit in a mac stack frame
int fileBytes;
int r;
static float musicVolume = 0.5f;
if(!s_backgroundStream) {
return;
}
// graeme see if this is OK
musicVolume = (musicVolume + (s_musicVolume->value * 2))/4.0f;
// don't bother playing anything if musicvolume is 0
if ( musicVolume <= 0 ) {
if ( s_musicVolume->value <= 0 ) {
return;
}
@ -1378,6 +1375,9 @@ void S_UpdateBackgroundTrack( void ) {
// decide how much data needs to be read from the file
fileSamples = bufferSamples * s_backgroundStream->info.rate / dma.speed;
if (!fileSamples)
return;
// our max buffer size
fileBytes = fileSamples * (s_backgroundStream->info.width * s_backgroundStream->info.channels);
if ( fileBytes > sizeof(raw) ) {
@ -1397,7 +1397,7 @@ void S_UpdateBackgroundTrack( void ) {
{
// add to raw buffer
S_Base_RawSamples( 0, fileSamples, s_backgroundStream->info.rate,
s_backgroundStream->info.width, s_backgroundStream->info.channels, raw, musicVolume );
s_backgroundStream->info.width, s_backgroundStream->info.channels, raw, s_musicVolume->value );
}
else
{

View file

@ -192,6 +192,7 @@ extern int s_rawend[MAX_RAW_STREAMS];
extern cvar_t *s_volume;
extern cvar_t *s_musicVolume;
extern cvar_t *s_muted;
extern cvar_t *s_doppler;
extern cvar_t *s_testsound;

View file

@ -27,10 +27,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "snd_public.h"
cvar_t *s_volume;
cvar_t *s_muted;
cvar_t *s_musicVolume;
cvar_t *s_doppler;
cvar_t *s_backend;
cvar_t *s_muteWhenMinimized;
cvar_t *s_muteWhenUnfocused;
static soundInterface_t si;
@ -228,11 +230,25 @@ S_Update
*/
void S_Update( void )
{
if( s_muteWhenMinimized->integer && com_minimized->integer ) {
S_StopAllSounds( );
return;
if(s_muted->integer)
{
if(!(s_muteWhenMinimized->integer && com_minimized->integer) &&
!(s_muteWhenUnfocused->integer && com_unfocused->integer))
{
s_muted->integer = qfalse;
s_muted->modified = qtrue;
}
}
else
{
if((s_muteWhenMinimized->integer && com_minimized->integer) ||
(s_muteWhenUnfocused->integer && com_unfocused->integer))
{
s_muted->integer = qtrue;
s_muted->modified = qtrue;
}
}
if( si.Update ) {
si.Update( );
}
@ -432,6 +448,20 @@ void S_Music_f( void ) {
}
/*
=================
S_Music_f
=================
*/
void S_StopMusic_f( void )
{
if(!si.StopBackgroundTrack)
return;
si.StopBackgroundTrack();
}
//=============================================================================
/*
@ -448,9 +478,11 @@ void S_Init( void )
s_volume = Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE );
s_musicVolume = Cvar_Get( "s_musicvolume", "0.25", CVAR_ARCHIVE );
s_muted = Cvar_Get("s_muted", "0", CVAR_ROM);
s_doppler = Cvar_Get( "s_doppler", "1", CVAR_ARCHIVE );
s_backend = Cvar_Get( "s_backend", "", CVAR_ROM );
s_muteWhenMinimized = Cvar_Get( "s_muteWhenMinimized", "0", CVAR_ARCHIVE );
s_muteWhenUnfocused = Cvar_Get( "s_muteWhenUnfocused", "0", CVAR_ARCHIVE );
cv = Cvar_Get( "s_initsound", "1", 0 );
if( !cv->integer ) {
@ -461,6 +493,7 @@ void S_Init( void )
Cmd_AddCommand( "play", S_Play_f );
Cmd_AddCommand( "music", S_Music_f );
Cmd_AddCommand( "stopmusic", S_StopMusic_f );
Cmd_AddCommand( "s_list", S_SoundList );
Cmd_AddCommand( "s_stop", S_StopAllSounds );
Cmd_AddCommand( "s_info", S_SoundInfo );
@ -507,6 +540,7 @@ void S_Shutdown( void )
Cmd_RemoveCommand( "play" );
Cmd_RemoveCommand( "music");
Cmd_RemoveCommand( "stopmusic");
Cmd_RemoveCommand( "s_list" );
Cmd_RemoveCommand( "s_stop" );
Cmd_RemoveCommand( "s_info" );

View file

@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "snd_local.h"
#include "snd_codec.h"
#define DEF_COMSOUNDMEGS "32"
#define DEF_COMSOUNDMEGS "8"
/*
===============================================================================

View file

@ -637,7 +637,10 @@ void S_PaintChannels( int endtime ) {
int ltime, count;
int sampleOffset;
snd_vol = s_volume->value*255;
if(s_muted->integer)
snd_vol = 0;
else
snd_vol = s_volume->value*255;
//Com_Printf ("%i to %i\n", s_paintedtime, endtime);
while ( s_paintedtime < endtime ) {

File diff suppressed because it is too large Load diff

View file

@ -14,6 +14,9 @@
* JPEG library. Most applications need only include jpeglib.h.
*/
#ifdef __WIN64__
#include "basetsd.h"
#endif
#ifdef _MSC_VER

View file

@ -158,9 +158,11 @@ typedef short INT16;
/* INT32 must hold at least signed 32-bit values. */
/* MinGW basetsd.h defines INT32 - don't redefine it */
#if !(defined __MINGW32__ && defined _BASETSD_H)
#ifndef __WIN64
#if !(defined __MINGW32__ && (defined _BASETSD_H || defined _BASETSD_H_))
typedef long INT32;
#endif
#endif
/* Datatype used for image dimensions. The JPEG standard only supports
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore

View file

@ -1,5 +1,5 @@
# libSDL.la - a libtool library file
# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)
# Generated by ltmain.sh (GNU libtool) 2.2.6
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
@ -13,13 +13,19 @@ library_names='libSDL.dll.a'
# The name of the static archive.
old_library='libSDL.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=' -luser32 -lgdi32 -lwinmm -ldxguid'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libSDL.
current=11
age=11
revision=1
revision=3
# Is this an already installed library?
installed=yes
@ -32,4 +38,4 @@ dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/Users/hercules/tmp/SDL-1.2.12/lib'
libdir='/usr/local/lib'

View file

@ -6,6 +6,9 @@
// SSE is enabled.
#ifndef _USE_SSE
# define USE_ALLOCA
# if defined(__sun) /* Solaris needs this for alloca(). */
# define HAVE_ALLOCA_H
# endif
#endif
/* Default to floating point */

View file

@ -1,64 +1,64 @@
/*---------------------------------------------------------------------------*\
Original Copyright
FILE........: AK2LSPD.H
TYPE........: Turbo C header file
COMPANY.....: Voicetronix
AUTHOR......: James Whitehall
DATE CREATED: 21/11/95
Modified by Jean-Marc Valin
This file contains functions for converting Linear Prediction
Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
LSP coefficients are not in radians format but in the x domain of the
unit circle.
\*---------------------------------------------------------------------------*/
/**
@file lsp.h
@brief Line Spectral Pair (LSP) functions.
*/
/* Speex License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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 FOUNDATION 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.
*/
#ifndef __AK2LSPD__
#define __AK2LSPD__
#include "arch.h"
int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, spx_word16_t delta, char *stack);
void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack);
/*Added by JMV*/
void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin);
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
#endif /* __AK2LSPD__ */
/*---------------------------------------------------------------------------*\
Original Copyright
FILE........: AK2LSPD.H
TYPE........: Turbo C header file
COMPANY.....: Voicetronix
AUTHOR......: James Whitehall
DATE CREATED: 21/11/95
Modified by Jean-Marc Valin
This file contains functions for converting Linear Prediction
Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
LSP coefficients are not in radians format but in the x domain of the
unit circle.
\*---------------------------------------------------------------------------*/
/**
@file lsp.h
@brief Line Spectral Pair (LSP) functions.
*/
/* Speex License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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 FOUNDATION 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.
*/
#ifndef __AK2LSPD__
#define __AK2LSPD__
#include "arch.h"
int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, spx_word16_t delta, char *stack);
void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack);
/*Added by JMV*/
void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin);
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
#endif /* __AK2LSPD__ */

View file

@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
cvar_t *cl_shownet;
void CL_Shutdown( void ) {
void CL_Shutdown( char *finalmsg ) {
}
void CL_Init( void ) {
@ -85,6 +85,10 @@ void CL_FlushMemory( void ) {
void CL_StartHunkUsers( qboolean rendererOnly ) {
}
void CL_Snd_Restart(void)
{
}
void CL_ShutdownAll(void) {}
qboolean CL_CDKeyValidate( const char *key, const char *checksum ) { return qtrue; }

View file

@ -166,6 +166,12 @@ UI_CreditMenu
===============
*/
void UI_CreditMenu( void ) {
/* This UI_FillRect() hack will blank the borders if you're in widescreen,
so you get a completely black background instead of stripes from the
previous frame on each side of the credits.. */
const float black[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
UI_FillRect(0 - uis.bias, 0, (640.0f / uis.xscale) * 2.0f, 480.0f / uis.yscale, black);
memset( &s_credits, 0 ,sizeof(s_credits) );
s_credits.menu.draw = UI_CreditMenu_Draw;

View file

@ -169,7 +169,7 @@ static void UI_LoadArenas( void ) {
int numdirs;
vmCvar_t arenasFile;
char filename[128];
char dirlist[1024];
char dirlist[2048];
char* dirptr;
int i, n;
int dirlen;
@ -188,7 +188,7 @@ static void UI_LoadArenas( void ) {
}
// get all arenas from .arena files
numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 1024 );
numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 2048 );
dirptr = dirlist;
for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
dirlen = strlen(dirptr);

View file

@ -120,27 +120,27 @@ extern vmCvar_t ui_ioq3;
#define MTYPE_PTEXT 9
#define MTYPE_BTEXT 10
#define QMF_BLINK 0x00000001
#define QMF_SMALLFONT 0x00000002
#define QMF_LEFT_JUSTIFY 0x00000004
#define QMF_CENTER_JUSTIFY 0x00000008
#define QMF_RIGHT_JUSTIFY 0x00000010
#define QMF_NUMBERSONLY 0x00000020 // edit field is only numbers
#define QMF_HIGHLIGHT 0x00000040
#define QMF_HIGHLIGHT_IF_FOCUS 0x00000080 // steady focus
#define QMF_PULSEIFFOCUS 0x00000100 // pulse if focus
#define QMF_HASMOUSEFOCUS 0x00000200
#define QMF_NOONOFFTEXT 0x00000400
#define QMF_MOUSEONLY 0x00000800 // only mouse input allowed
#define QMF_HIDDEN 0x00001000 // skips drawing
#define QMF_GRAYED 0x00002000 // grays and disables
#define QMF_INACTIVE 0x00004000 // disables any input
#define QMF_NODEFAULTINIT 0x00008000 // skip default initialization
#define QMF_OWNERDRAW 0x00010000
#define QMF_PULSE 0x00020000
#define QMF_LOWERCASE 0x00040000 // edit field is all lower case
#define QMF_UPPERCASE 0x00080000 // edit field is all upper case
#define QMF_SILENT 0x00100000
#define QMF_BLINK ((unsigned int) 0x00000001)
#define QMF_SMALLFONT ((unsigned int) 0x00000002)
#define QMF_LEFT_JUSTIFY ((unsigned int) 0x00000004)
#define QMF_CENTER_JUSTIFY ((unsigned int) 0x00000008)
#define QMF_RIGHT_JUSTIFY ((unsigned int) 0x00000010)
#define QMF_NUMBERSONLY ((unsigned int) 0x00000020) // edit field is only numbers
#define QMF_HIGHLIGHT ((unsigned int) 0x00000040)
#define QMF_HIGHLIGHT_IF_FOCUS ((unsigned int) 0x00000080) // steady focus
#define QMF_PULSEIFFOCUS ((unsigned int) 0x00000100) // pulse if focus
#define QMF_HASMOUSEFOCUS ((unsigned int) 0x00000200)
#define QMF_NOONOFFTEXT ((unsigned int) 0x00000400)
#define QMF_MOUSEONLY ((unsigned int) 0x00000800) // only mouse input allowed
#define QMF_HIDDEN ((unsigned int) 0x00001000) // skips drawing
#define QMF_GRAYED ((unsigned int) 0x00002000) // grays and disables
#define QMF_INACTIVE ((unsigned int) 0x00004000) // disables any input
#define QMF_NODEFAULTINIT ((unsigned int) 0x00008000) // skip default initialization
#define QMF_OWNERDRAW ((unsigned int) 0x00010000)
#define QMF_PULSE ((unsigned int) 0x00020000)
#define QMF_LOWERCASE ((unsigned int) 0x00040000) // edit field is all lower case
#define QMF_UPPERCASE ((unsigned int) 0x00080000) // edit field is all upper case
#define QMF_SILENT ((unsigned int) 0x00100000)
// callback notifications
#define QM_GOTFOCUS 1
@ -175,7 +175,7 @@ typedef struct
int bottom;
menuframework_s *parent;
int menuPosition;
unsigned flags;
unsigned int flags;
void (*callback)( void *self, int event );
void (*statusbar)( void *self );

View file

@ -40,7 +40,7 @@ This is the only way control passes into the module.
This must be the very first function compiled into the .qvm file
================
*/
intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
switch ( command ) {
case UI_GETAPIVERSION:
return UI_API_VERSION;
@ -174,13 +174,13 @@ static cvarTable_t cvarTable[] = {
{ &ui_arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM },
{ &ui_botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM },
{ &ui_spScores1, "g_spScores1", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores2, "g_spScores2", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores3, "g_spScores3", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores4, "g_spScores4", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores5, "g_spScores5", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spAwards, "g_spAwards", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spVideos, "g_spVideos", "", CVAR_ARCHIVE | CVAR_ROM },
{ &ui_spScores1, "g_spScores1", "", CVAR_ARCHIVE },
{ &ui_spScores2, "g_spScores2", "", CVAR_ARCHIVE },
{ &ui_spScores3, "g_spScores3", "", CVAR_ARCHIVE },
{ &ui_spScores4, "g_spScores4", "", CVAR_ARCHIVE },
{ &ui_spScores5, "g_spScores5", "", CVAR_ARCHIVE },
{ &ui_spAwards, "g_spAwards", "", CVAR_ARCHIVE },
{ &ui_spVideos, "g_spVideos", "", CVAR_ARCHIVE },
{ &ui_spSkill, "g_spSkill", "2", CVAR_ARCHIVE | CVAR_LATCH },
{ &ui_spSelection, "ui_spSelection", "", CVAR_ROM },

View file

@ -199,6 +199,11 @@ static void UI_SPLevelMenu_SetBots( void ) {
}
botInfo = UI_GetBotInfoByName( bot );
if(!botInfo)
{
botInfo = UI_GetBotInfoByNumber( levelMenuInfo.numBots );
}
if( botInfo ) {
levelMenuInfo.botPics[levelMenuInfo.numBots] = PlayerIconHandle( Info_ValueForKey( botInfo, "model" ) );
Q_strncpyz( levelMenuInfo.botNames[levelMenuInfo.numBots], Info_ValueForKey( botInfo, "name" ), 10 );

View file

@ -51,11 +51,7 @@ START SERVER MENU *****
#define MAX_MAPCOLS 2
#define MAX_MAPSPERPAGE 4
#define MAX_SERVERSTEXT 8192
#define MAX_SERVERMAPS 64
#define MAX_NAMELENGTH 16
#define ID_GAMETYPE 10
#define ID_PICTURES 11 // 12, 13, 14
#define ID_PREVPAGE 15
@ -87,8 +83,7 @@ typedef struct {
int nummaps;
int page;
int maxpages;
char maplist[MAX_SERVERMAPS][MAX_NAMELENGTH];
int mapGamebits[MAX_SERVERMAPS];
int maplist[MAX_ARENAS];
} startserver_t;
static startserver_t s_startserver;
@ -167,6 +162,8 @@ static void StartServer_Update( void ) {
int i;
int top;
static char picname[MAX_MAPSPERPAGE][64];
const char *info;
char mapname[MAX_NAMELENGTH];
top = s_startserver.page*MAX_MAPSPERPAGE;
@ -174,8 +171,12 @@ static void StartServer_Update( void ) {
{
if (top+i >= s_startserver.nummaps)
break;
info = UI_GetArenaInfoByNumber( s_startserver.maplist[ top + i ]);
Q_strncpyz( mapname, Info_ValueForKey( info, "map"), MAX_NAMELENGTH );
Q_strupr( mapname );
Com_sprintf( picname[i], sizeof(picname[i]), "levelshots/%s", s_startserver.maplist[top+i] );
Com_sprintf( picname[i], sizeof(picname[i]), "levelshots/%s", mapname );
s_startserver.mappics[i].generic.flags &= ~QMF_HIGHLIGHT;
s_startserver.mappics[i].generic.name = picname[i];
@ -216,7 +217,8 @@ static void StartServer_Update( void ) {
}
// set the map name
strcpy( s_startserver.mapname.string, s_startserver.maplist[s_startserver.currentmap] );
info = UI_GetArenaInfoByNumber( s_startserver.maplist[ s_startserver.currentmap ]);
Q_strncpyz( s_startserver.mapname.string, Info_ValueForKey( info, "map" ), MAX_NAMELENGTH);
}
Q_strupr( s_startserver.mapname.string );
@ -262,15 +264,13 @@ static void StartServer_GametypeEvent( void* ptr, int event ) {
}
for( i = 0; i < count; i++ ) {
info = UI_GetArenaInfoByNumber( i );
gamebits = GametypeBits( Info_ValueForKey( info, "type") );
if( !( gamebits & matchbits ) ) {
continue;
}
Q_strncpyz( s_startserver.maplist[s_startserver.nummaps], Info_ValueForKey( info, "map"), MAX_NAMELENGTH );
Q_strupr( s_startserver.maplist[s_startserver.nummaps] );
s_startserver.mapGamebits[s_startserver.nummaps] = gamebits;
s_startserver.maplist[ s_startserver.nummaps ] = i;
s_startserver.nummaps++;
}
s_startserver.maxpages = (s_startserver.nummaps + MAX_MAPSPERPAGE-1)/MAX_MAPSPERPAGE;
@ -330,6 +330,7 @@ static void StartServer_LevelshotDraw( void *self ) {
int w;
int h;
int n;
const char *info;
b = (menubitmap_s *)self;
@ -363,7 +364,9 @@ static void StartServer_LevelshotDraw( void *self ) {
x += b->width / 2;
y += 4;
n = s_startserver.page * MAX_MAPSPERPAGE + b->generic.id - ID_PICTURES;
UI_DrawString( x, y, s_startserver.maplist[n], UI_CENTER|UI_SMALLFONT, color_orange );
info = UI_GetArenaInfoByNumber( s_startserver.maplist[ n ]);
UI_DrawString( x, y, Info_ValueForKey( info, "map" ), UI_CENTER|UI_SMALLFONT, color_orange );
x = b->generic.x;
y = b->generic.y;
@ -556,6 +559,7 @@ void StartServer_Cache( void )
const char *info;
qboolean precache;
char picname[64];
char mapname[ MAX_NAMELENGTH ];
trap_R_RegisterShaderNoMip( GAMESERVER_BACK0 );
trap_R_RegisterShaderNoMip( GAMESERVER_BACK1 );
@ -572,22 +576,16 @@ void StartServer_Cache( void )
precache = trap_Cvar_VariableValue("com_buildscript");
s_startserver.nummaps = UI_GetNumArenas();
for( i = 0; i < s_startserver.nummaps; i++ ) {
info = UI_GetArenaInfoByNumber( i );
Q_strncpyz( s_startserver.maplist[i], Info_ValueForKey( info, "map"), MAX_NAMELENGTH );
Q_strupr( s_startserver.maplist[i] );
s_startserver.mapGamebits[i] = GametypeBits( Info_ValueForKey( info, "type") );
if( precache ) {
Com_sprintf( picname, sizeof(picname), "levelshots/%s", s_startserver.maplist[i] );
if( precache ) {
for( i = 0; i < UI_GetNumArenas(); i++ ) {
info = UI_GetArenaInfoByNumber( i );
Q_strncpyz( mapname, Info_ValueForKey( info, "map"), MAX_NAMELENGTH );
Q_strupr( mapname );
Com_sprintf( picname, sizeof(picname), "levelshots/%s", mapname );
trap_R_RegisterShaderNoMip(picname);
}
}
s_startserver.maxpages = (s_startserver.nummaps + MAX_MAPSPERPAGE-1)/MAX_MAPSPERPAGE;
}
@ -732,7 +730,7 @@ static void ServerOptions_Start( void ) {
int skill;
int n;
char buf[64];
const char *info;
timelimit = atoi( s_serveroptions.timelimit.field.buffer );
fraglimit = atoi( s_serveroptions.fraglimit.field.buffer );
@ -790,7 +788,8 @@ static void ServerOptions_Start( void ) {
trap_Cvar_SetValue( "sv_punkbuster", s_serveroptions.punkbuster.curvalue );
// the wait commands will allow the dedicated to take effect
trap_Cmd_ExecuteText( EXEC_APPEND, va( "wait ; wait ; map %s\n", s_startserver.maplist[s_startserver.currentmap] ) );
info = UI_GetArenaInfoByNumber( s_startserver.maplist[ s_startserver.currentmap ]);
trap_Cmd_ExecuteText( EXEC_APPEND, va( "wait ; wait ; map %s\n", Info_ValueForKey( info, "map" )));
// add bots
trap_Cmd_ExecuteText( EXEC_APPEND, "wait 3\n" );
@ -1093,6 +1092,10 @@ static void ServerOptions_InitBotNames( void ) {
}
botInfo = UI_GetBotInfoByName( bot );
if( !botInfo )
{
botInfo = UI_GetBotInfoByNumber( count );
}
bot = Info_ValueForKey( botInfo, "name" );
Q_strncpyz( s_serveroptions.playerNameBuffers[count], bot, sizeof(s_serveroptions.playerNameBuffers[count]) );
@ -1125,6 +1128,8 @@ ServerOptions_SetMenuItems
*/
static void ServerOptions_SetMenuItems( void ) {
static char picname[64];
char mapname[MAX_NAMELENGTH];
const char *info;
switch( s_serveroptions.gametype ) {
case GT_FFA:
@ -1155,7 +1160,10 @@ static void ServerOptions_SetMenuItems( void ) {
s_serveroptions.pure.curvalue = Com_Clamp( 0, 1, trap_Cvar_VariableValue( "sv_pure" ) );
// set the map pic
Com_sprintf( picname, 64, "levelshots/%s", s_startserver.maplist[s_startserver.currentmap] );
info = UI_GetArenaInfoByNumber( s_startserver.maplist[ s_startserver.currentmap ]);
Q_strncpyz( mapname, Info_ValueForKey( info, "map"), MAX_NAMELENGTH );
Q_strupr( mapname );
Com_sprintf( picname, 64, "levelshots/%s", mapname );
s_serveroptions.mappic.generic.name = picname;
// set the map name

View file

@ -247,6 +247,7 @@ GRAPHICS OPTIONS MENU
#define ID_DISPLAY 107
#define ID_SOUND 108
#define ID_NETWORK 109
#define ID_RATIO 110
typedef struct {
menuframework_s menu;
@ -261,6 +262,7 @@ typedef struct {
menutext_s network;
menulist_s list;
menulist_s ratio;
menulist_s mode;
menulist_s driver;
menuslider_s tq;
@ -331,12 +333,31 @@ static const char *builtinResolutions[ ] =
"1280x1024",
"1600x1200",
"2048x1536",
"856x480 wide screen",
"856x480",
NULL
};
static const char *knownRatios[ ][2] =
{
{ "1.25:1", "5:4" },
{ "1.33:1", "4:3" },
{ "1.50:1", "3:2" },
{ "1.56:1", "14:9" },
{ "1.60:1", "16:10" },
{ "1.67:1", "5:3" },
{ "1.78:1", "16:9" },
{ NULL , NULL }
};
#define MAX_RESOLUTIONS 32
static const char* ratios[ MAX_RESOLUTIONS ];
static char ratioBuf[ MAX_RESOLUTIONS ][ 8 ];
static int ratioToRes[ MAX_RESOLUTIONS ];
static int resToRatio[ MAX_RESOLUTIONS ];
static char resbuf[ MAX_STRING_CHARS ];
static const char* detectedResolutions[ 32 ];
static const char* detectedResolutions[ MAX_RESOLUTIONS ];
static const char** resolutions = builtinResolutions;
static qboolean resolutionsDetected = qfalse;
@ -358,7 +379,7 @@ static int GraphicsOptions_FindBuiltinResolution( int mode )
for( i = 0; builtinResolutions[ i ]; i++ )
{
if( !strcmp( builtinResolutions[ i ], detectedResolutions[ mode ] ) )
if( !Q_stricmp( builtinResolutions[ i ], detectedResolutions[ mode ] ) )
return i;
}
@ -382,13 +403,68 @@ static int GraphicsOptions_FindDetectedResolution( int mode )
for( i = 0; detectedResolutions[ i ]; i++ )
{
if( !strcmp( builtinResolutions[ mode ], detectedResolutions[ i ] ) )
if( !Q_stricmp( builtinResolutions[ mode ], detectedResolutions[ i ] ) )
return i;
}
return -1;
}
/*
=================
GraphicsOptions_GetAspectRatios
=================
*/
static void GraphicsOptions_GetAspectRatios( void )
{
int i, r;
// build ratio list from resolutions
for( r = 0; resolutions[r]; r++ )
{
int w, h;
char *x;
char str[ sizeof(ratioBuf[0]) ];
// calculate resolution's aspect ratio
x = strchr( resolutions[r], 'x' ) + 1;
Q_strncpyz( str, resolutions[r], x-resolutions[r] );
w = atoi( str );
h = atoi( x );
Com_sprintf( str, sizeof(str), "%.2f:1", (float)w / (float)h );
// add ratio to list if it is new
// establish res/ratio relationship
for( i = 0; ratioBuf[i][0]; i++ )
{
if( !Q_stricmp( str, ratioBuf[i] ) )
break;
}
if( !ratioBuf[i][0] )
{
Q_strncpyz( ratioBuf[i], str, sizeof(ratioBuf[i]) );
ratioToRes[i] = r;
}
resToRatio[r] = i;
}
// prepare itemlist pointer array
// rename common ratios ("1.33:1" -> "4:3")
for( r = 0; ratioBuf[r][0]; r++ )
{
for( i = 0; knownRatios[i][0]; i++ )
{
if( !Q_stricmp( ratioBuf[r], knownRatios[i][0] ) )
{
Q_strncpyz( ratioBuf[r], knownRatios[i][1], sizeof(ratioBuf[r]) );
break;
}
}
ratios[r] = ratioBuf[r];
}
ratios[r] = NULL;
}
/*
=================
GraphicsOptions_GetInitialVideo
@ -408,6 +484,35 @@ static void GraphicsOptions_GetInitialVideo( void )
s_ivo.texturebits = s_graphicsoptions.texturebits.curvalue;
}
/*
=================
GraphicsOptions_GetResolutions
=================
*/
static void GraphicsOptions_GetResolutions( void )
{
Q_strncpyz(resbuf, UI_Cvar_VariableString("r_availableModes"), sizeof(resbuf));
if(*resbuf)
{
char* s = resbuf;
unsigned int i = 0;
while( s && i < sizeof(detectedResolutions)/sizeof(detectedResolutions[0])-1)
{
detectedResolutions[i++] = s;
s = strchr(s, ' ');
if( s )
*s++ = '\0';
}
detectedResolutions[ i ] = NULL;
if( i > 0 )
{
resolutions = detectedResolutions;
resolutionsDetected = qtrue;
}
}
}
/*
=================
GraphicsOptions_CheckConfig
@ -624,6 +729,11 @@ static void GraphicsOptions_Event( void* ptr, int event ) {
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_RATIO:
s_graphicsoptions.mode.curvalue =
ratioToRes[ s_graphicsoptions.ratio.curvalue ];
// fall through to apply mode constraints
case ID_MODE:
// clamp 3dfx video modes
if ( s_graphicsoptions.driver.curvalue == 1 )
@ -633,12 +743,16 @@ static void GraphicsOptions_Event( void* ptr, int event ) {
else if ( s_graphicsoptions.mode.curvalue > 6 )
s_graphicsoptions.mode.curvalue = 6;
}
s_graphicsoptions.ratio.curvalue =
resToRatio[ s_graphicsoptions.mode.curvalue ];
break;
case ID_LIST:
ivo = &s_ivo_templates[s_graphicsoptions.list.curvalue];
s_graphicsoptions.mode.curvalue = GraphicsOptions_FindDetectedResolution(ivo->mode);
s_graphicsoptions.ratio.curvalue =
resToRatio[ s_graphicsoptions.mode.curvalue ];
s_graphicsoptions.tq.curvalue = ivo->tq;
s_graphicsoptions.lighting.curvalue = ivo->lighting;
s_graphicsoptions.colordepth.curvalue = ivo->colordepth;
@ -726,7 +840,7 @@ static void GraphicsOptions_SetMenuItems( void )
for(i = 0; detectedResolutions[i]; ++i)
{
if(!strcmp(buf, detectedResolutions[i]))
if(!Q_stricmp(buf, detectedResolutions[i]))
{
s_graphicsoptions.mode.curvalue = i;
break;
@ -740,6 +854,8 @@ static void GraphicsOptions_SetMenuItems( void )
s_graphicsoptions.mode.curvalue = 3;
}
}
s_graphicsoptions.ratio.curvalue =
resToRatio[ s_graphicsoptions.mode.curvalue ];
s_graphicsoptions.fs.curvalue = trap_Cvar_VariableValue("r_fullscreen");
s_graphicsoptions.allow_extensions.curvalue = trap_Cvar_VariableValue("r_allowExtensions");
s_graphicsoptions.tq.curvalue = 3-trap_Cvar_VariableValue( "r_picmip");
@ -889,28 +1005,9 @@ void GraphicsOptions_MenuInit( void )
// zero set all our globals
memset( &s_graphicsoptions, 0 ,sizeof(graphicsoptions_t) );
Q_strncpyz(resbuf, UI_Cvar_VariableString("r_availableModes"), sizeof(resbuf));
if(*resbuf)
{
char* s = resbuf;
unsigned int i = 0;
while( s && i < sizeof(detectedResolutions)/sizeof(detectedResolutions[0])-1)
{
detectedResolutions[i++] = s;
s = strchr(s, ' ');
if( s )
*s++ = '\0';
}
detectedResolutions[ i ] = NULL;
if( i > 0 )
{
resolutions = detectedResolutions;
resolutionsDetected = qtrue;
}
}
GraphicsOptions_GetResolutions();
GraphicsOptions_GetAspectRatios();
GraphicsOptions_Cache();
s_graphicsoptions.menu.wrapAround = qtrue;
@ -980,7 +1077,7 @@ void GraphicsOptions_MenuInit( void )
s_graphicsoptions.network.style = UI_RIGHT;
s_graphicsoptions.network.color = color_red;
y = 240 - 6 * (BIGCHAR_HEIGHT + 2);
y = 240 - 7 * (BIGCHAR_HEIGHT + 2);
s_graphicsoptions.list.generic.type = MTYPE_SPINCONTROL;
s_graphicsoptions.list.generic.name = "Graphics Settings:";
s_graphicsoptions.list.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
@ -1009,9 +1106,19 @@ void GraphicsOptions_MenuInit( void )
s_graphicsoptions.allow_extensions.itemnames = enabled_names;
y += BIGCHAR_HEIGHT+2;
s_graphicsoptions.ratio.generic.type = MTYPE_SPINCONTROL;
s_graphicsoptions.ratio.generic.name = "Aspect Ratio:";
s_graphicsoptions.ratio.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_graphicsoptions.ratio.generic.x = 400;
s_graphicsoptions.ratio.generic.y = y;
s_graphicsoptions.ratio.itemnames = ratios;
s_graphicsoptions.ratio.generic.callback = GraphicsOptions_Event;
s_graphicsoptions.ratio.generic.id = ID_RATIO;
y += BIGCHAR_HEIGHT+2;
// references/modifies "r_mode"
s_graphicsoptions.mode.generic.type = MTYPE_SPINCONTROL;
s_graphicsoptions.mode.generic.name = "Video Mode:";
s_graphicsoptions.mode.generic.name = "Resolution:";
s_graphicsoptions.mode.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_graphicsoptions.mode.generic.x = 400;
s_graphicsoptions.mode.generic.y = y;
@ -1129,6 +1236,7 @@ void GraphicsOptions_MenuInit( void )
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.list );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.driver );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.allow_extensions );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.ratio );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.mode );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.colordepth );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.fs );

View file

@ -36,7 +36,6 @@ BASIC MATH
===============================================================================
*/
/*
================
CM_ProjectPointOntoVector

View file

@ -52,6 +52,8 @@ bind g "cmd use rocket ; +attack ; wait ; -attack ; cmd use blaster"
void Cmd_Wait_f( void ) {
if ( Cmd_Argc() == 2 ) {
cmd_wait = atoi( Cmd_Argv( 1 ) );
if ( cmd_wait < 0 )
cmd_wait = 1; // ignore the argument
} else {
cmd_wait = 1;
}
@ -176,7 +178,7 @@ void Cbuf_Execute (void)
while (cmd_text.cursize)
{
if ( cmd_wait ) {
if ( cmd_wait > 0 ) {
// skip out while text still remains in buffer, leaving it
// for next frame
cmd_wait--;
@ -295,11 +297,7 @@ Just prints the rest of the line to the console
*/
void Cmd_Echo_f (void)
{
int i;
for (i=1 ; i<Cmd_Argc() ; i++)
Com_Printf ("%s ",Cmd_Argv(i));
Com_Printf ("\n");
Com_Printf ("%s\n", Cmd_Args());
}

View file

@ -82,6 +82,7 @@ cvar_t *com_unfocused;
cvar_t *com_maxfpsUnfocused;
cvar_t *com_minimized;
cvar_t *com_maxfpsMinimized;
cvar_t *com_abnormalExit;
cvar_t *com_standalone;
// com_speeds times
@ -93,8 +94,9 @@ int com_frameTime;
int com_frameMsec;
int com_frameNumber;
qboolean com_errorEntered;
qboolean com_fullyInitialized;
qboolean com_errorEntered = qfalse;
qboolean com_fullyInitialized = qfalse;
qboolean com_gameRestarting = qfalse;
char com_errorMessage[MAXPRINTMSG];
@ -236,16 +238,30 @@ void QDECL Com_DPrintf( const char *fmt, ...) {
Com_Error
Both client and server can use this, and it will
do the apropriate things.
do the appropriate thing.
=============
*/
void QDECL Com_Error( int code, const char *fmt, ... ) {
va_list argptr;
static int lastErrorTime;
static int errorCount;
static qboolean calledSysError = qfalse;
int currentTime;
Cvar_Set( "com_errorCode", va( "%i", code ) );
if(com_errorEntered)
{
if(!calledSysError)
{
calledSysError = qtrue;
Sys_Error("recursive error after: %s", com_errorMessage);
}
return;
}
com_errorEntered = qtrue;
Cvar_Set("com_errorCode", va("%i", code));
// when we are running automated scripts, make sure we
// know if anything failed
@ -264,11 +280,6 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
}
lastErrorTime = currentTime;
if ( com_errorEntered ) {
Sys_Error( "recursive error after: %s", com_errorMessage );
}
com_errorEntered = qtrue;
va_start (argptr,fmt);
Q_vsnprintf (com_errorMessage, sizeof(com_errorMessage),fmt,argptr);
va_end (argptr);
@ -303,20 +314,22 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
VM_Forced_Unload_Start();
CL_FlushMemory( );
VM_Forced_Unload_Done();
com_errorEntered = qfalse;
CL_CDDialog();
} else {
Com_Printf("Server didn't have CD\n" );
}
FS_PureServerSetLoadedPaks("", "");
com_errorEntered = qfalse;
longjmp (abortframe, -1);
} else {
CL_Shutdown ();
CL_Shutdown (va("Client fatal crashed: %s", com_errorMessage));
SV_Shutdown (va("Server fatal crashed: %s", com_errorMessage));
}
Com_Shutdown ();
calledSysError = qtrue;
Sys_Error ("%s", com_errorMessage);
}
@ -334,7 +347,7 @@ void Com_Quit_f( void ) {
char *p = Cmd_Args( );
if ( !com_errorEntered ) {
SV_Shutdown (p[0] ? p : "Server quit");
CL_Shutdown ();
CL_Shutdown (p[0] ? p : "Client quit");
Com_Shutdown ();
FS_Shutdown(qtrue);
}
@ -672,22 +685,6 @@ int Com_FilterPath(char *filter, char *name, int casesensitive)
return Com_Filter(new_filter, new_name, casesensitive);
}
/*
============
Com_HashKey
============
*/
int Com_HashKey(char *string, int maxlen) {
int register hash, i;
hash = 0;
for (i = 0; i < maxlen && string[i] != '\0'; i++) {
hash += string[i] * (119 + i);
}
hash = (hash ^ (hash >> 10) ^ (hash >> 20));
return hash;
}
/*
================
Com_RealTime
@ -1397,9 +1394,11 @@ void Com_InitSmallZoneMemory( void ) {
void Com_InitZoneMemory( void ) {
cvar_t *cv;
//FIXME: 05/01/06 com_zoneMegs is useless right now as neither Reaction.cfg nor
// Com_StartupVariable have been executed by this point. The net result is that
// s_zoneTotal will always be set to the default value.
// Please note: com_zoneMegs can only be set on the command line, and
// not in Reaction.cfg or Com_StartupVariable, as they haven't been
// executed by this point. It's a chicken and egg problem. We need the
// memory manager configured to handle those places where you would
// configure the memory manager.
// allocate the random block zone
cv = Cvar_Get( "com_zoneMegs", DEF_COMZONEMEGS_S, CVAR_LATCH | CVAR_ARCHIVE );
@ -2360,6 +2359,114 @@ static void Com_Crash_f( void ) {
* ( int * ) 0 = 0x12345678;
}
/*
==================
Com_Setenv_f
For controlling environment variables
==================
*/
void Com_Setenv_f(void)
{
int argc = Cmd_Argc();
char *arg1 = Cmd_Argv(1);
if(argc > 2)
{
char *arg2 = Cmd_ArgsFrom(2);
Sys_SetEnv(arg1, arg2);
}
else if(argc == 2)
{
char *env = getenv(arg1);
if(env)
Com_Printf("%s=%s\n", arg1, env);
else
Com_Printf("%s undefined\n", arg1);
}
}
/*
==================
Com_ExecuteCfg
For controlling environment variables
==================
*/
void Com_ExecuteCfg(void)
{
Cbuf_ExecuteText(EXEC_NOW, "exec default.cfg\n");
Cbuf_Execute(); // Always execute after exec to prevent text buffer overflowing
if(!Com_SafeMode())
{
// skip the Reaction.cfg and autoexec.cfg if "safe" is on the command line
Cbuf_ExecuteText(EXEC_NOW, "exec " Q3CONFIG_CFG "\n");
Cbuf_Execute();
Cbuf_ExecuteText(EXEC_NOW, "exec autoexec.cfg\n");
Cbuf_Execute();
}
}
/*
==================
Com_GameRestart
Change to a new mod properly with cleaning up cvars before switching.
==================
*/
void Com_GameRestart(int checksumFeed, qboolean clientRestart)
{
// make sure no recursion can be triggered
if(!com_gameRestarting && com_fullyInitialized)
{
com_gameRestarting = qtrue;
if(clientRestart)
{
CL_Disconnect(qfalse);
CL_ShutdownAll();
}
// Kill server if we have one
if(com_sv_running->integer)
SV_Shutdown("Game directory changed");
FS_Restart(checksumFeed);
// Clean out any user and VM created cvars
Cvar_Restart(qtrue);
Com_ExecuteCfg();
// Restart sound subsystem so old handles are flushed
CL_Snd_Restart();
if(clientRestart)
CL_StartHunkUsers(qfalse);
com_gameRestarting = qfalse;
}
}
/*
==================
Com_GameRestart_f
Expose possibility to change current running mod to the user
==================
*/
void Com_GameRestart_f(void)
{
Cvar_Set("fs_game", Cmd_Argv(1));
Com_GameRestart(0, qtrue);
}
#ifndef STANDALONE
// TTimo: centralizing the cl_cdkey stuff after I discovered a buffer overflow problem with the dedicated server version
@ -2550,12 +2657,12 @@ void Com_Init( char *commandLine ) {
// Swap_Init ();
Cbuf_Init ();
Com_InitZoneMemory();
Cmd_Init ();
// override anything from the config files with command line args
Com_StartupVariable( NULL );
Com_InitZoneMemory();
Cmd_Init ();
// get the developer cvar set as early as possible
Com_StartupVariable( "developer" );
@ -2566,16 +2673,21 @@ void Com_Init( char *commandLine ) {
Com_InitJournaling();
Cbuf_AddText ("exec default.cfg\n");
// skip the Reaction.cfg if "safe" is on the command line
if ( !Com_SafeMode() ) {
Cbuf_AddText ("exec " Q3CONFIG_CFG "\n");
// Add some commands here already so users can use them from config files
Cmd_AddCommand ("setenv", Com_Setenv_f);
if (com_developer && com_developer->integer)
{
Cmd_AddCommand ("error", Com_Error_f);
Cmd_AddCommand ("crash", Com_Crash_f);
Cmd_AddCommand ("freeze", Com_Freeze_f);
}
Cmd_AddCommand ("quit", Com_Quit_f);
Cmd_AddCommand ("changeVectors", MSG_ReportChangeVectors_f );
Cmd_AddCommand ("writeconfig", Com_WriteConfig_f );
Cmd_SetCommandCompletionFunc( "writeconfig", Cmd_CompleteCfgName );
Cmd_AddCommand("game_restart", Com_GameRestart_f);
Cbuf_AddText ("exec autoexec.cfg\n");
Cbuf_Execute ();
Com_ExecuteCfg();
// override anything from the config files with command line args
Com_StartupVariable( NULL );
@ -2626,25 +2738,28 @@ void Com_Init( char *commandLine ) {
com_maxfpsUnfocused = Cvar_Get( "com_maxfpsUnfocused", "0", CVAR_ARCHIVE );
com_minimized = Cvar_Get( "com_minimized", "0", CVAR_ROM );
com_maxfpsMinimized = Cvar_Get( "com_maxfpsMinimized", "0", CVAR_ARCHIVE );
com_abnormalExit = Cvar_Get( "com_abnormalExit", "0", CVAR_ROM );
com_standalone = Cvar_Get( "com_standalone", "0", CVAR_INIT );
com_introPlayed = Cvar_Get( "com_introplayed", "0", CVAR_ARCHIVE);
if ( com_developer && com_developer->integer ) {
Cmd_AddCommand ("error", Com_Error_f);
Cmd_AddCommand ("crash", Com_Crash_f );
Cmd_AddCommand ("freeze", Com_Freeze_f);
}
Cmd_AddCommand ("quit", Com_Quit_f);
Cmd_AddCommand ("changeVectors", MSG_ReportChangeVectors_f );
Cmd_AddCommand ("writeconfig", Com_WriteConfig_f );
Cmd_SetCommandCompletionFunc( "writeconfig", Cmd_CompleteCfgName );
s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, __DATE__ );
com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
Sys_Init();
if( Sys_WritePIDFile( ) ) {
#ifndef DEDICATED
const char *message = "The last time " CLIENT_WINDOW_TITLE " ran, "
"it didn't exit properly. This may be due to inappropriate video "
"settings. Would you like to start with \"safe\" video settings?";
if( Sys_Dialog( DT_YES_NO, message, "Abnormal Exit" ) == DR_YES ) {
Cvar_Set( "com_abnormalExit", "1" );
}
#endif
}
// Pick a random port value
Com_RandomBytes( (byte*)&qport, sizeof(int) );
Netchan_Init( qport & 0xffff );
@ -2964,6 +3079,12 @@ void Com_Frame( void ) {
if ( com_speeds->integer ) {
timeAfter = Sys_Milliseconds ();
}
#else
if ( com_speeds->integer ) {
timeAfter = Sys_Milliseconds ();
timeBeforeEvents = timeAfter;
timeBeforeClient = timeAfter;
}
#endif
//

View file

@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "q_shared.h"
#include "qcommon.h"
cvar_t *cvar_vars;
cvar_t *cvar_vars = NULL;
cvar_t *cvar_cheats;
int cvar_modifiedFlags;
@ -33,7 +33,7 @@ cvar_t cvar_indexes[MAX_CVARS];
int cvar_numIndexes;
#define FILE_HASH_SIZE 256
static cvar_t* hashTable[FILE_HASH_SIZE];
static cvar_t *hashTable[FILE_HASH_SIZE];
cvar_t *Cvar_Set2( const char *var_name, const char *value, qboolean force);
@ -181,11 +181,14 @@ int Cvar_Flags(const char *var_name)
Cvar_CommandCompletion
============
*/
void Cvar_CommandCompletion( void(*callback)(const char *s) ) {
void Cvar_CommandCompletion(void (*callback)(const char *s))
{
cvar_t *cvar;
for ( cvar = cvar_vars ; cvar ; cvar = cvar->next ) {
callback( cvar->name );
for(cvar = cvar_vars; cvar; cvar = cvar->next)
{
if(cvar->name)
callback(cvar->name);
}
}
@ -304,6 +307,7 @@ The flags will be or'ed in if the variable exists.
cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
cvar_t *var;
long hash;
int index;
if ( !var_name || ! var_value ) {
Com_Error( ERR_FATAL, "Cvar_Get: NULL parameter" );
@ -322,13 +326,15 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
#endif
var = Cvar_FindVar (var_name);
if ( var ) {
var_value = Cvar_Validate( var, var_value, qfalse );
if(var)
{
var_value = Cvar_Validate(var, var_value, qfalse);
// if the C code is now specifying a variable that the user already
// set a value for, take the new value as the reset value
if ( ( var->flags & CVAR_USER_CREATED ) && !( flags & CVAR_USER_CREATED )
&& var_value[0] ) {
if(var->flags & CVAR_USER_CREATED)
{
var->flags &= ~CVAR_USER_CREATED;
Z_Free( var->resetString );
var->resetString = CopyString( var_value );
@ -343,13 +349,22 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
var->latchedString = CopyString(var_value);
}
// ZOID--needs to be set so that cvars the game sets as
// SERVERINFO get sent to clients
cvar_modifiedFlags |= flags;
}
// Make sure the game code cannot mark engine-added variables as gamecode vars
if(var->flags & CVAR_VM_CREATED)
{
if(!(flags & CVAR_VM_CREATED))
var->flags &= ~CVAR_VM_CREATED;
}
else
{
if(flags & CVAR_VM_CREATED)
flags &= ~CVAR_VM_CREATED;
}
var->flags |= flags;
// only allow one non-empty reset string without a warning
if ( !var->resetString[0] ) {
// we don't have a reset string yet
@ -369,17 +384,37 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
Z_Free( s );
}
// ZOID--needs to be set so that cvars the game sets as
// SERVERINFO get sent to clients
cvar_modifiedFlags |= flags;
return var;
}
//
// allocate a new cvar
//
if ( cvar_numIndexes >= MAX_CVARS ) {
Com_Error( ERR_FATAL, "MAX_CVARS" );
// find a free cvar
for(index = 0; index < MAX_CVARS; index++)
{
if(!cvar_indexes[index].name)
break;
}
var = &cvar_indexes[cvar_numIndexes];
cvar_numIndexes++;
if(index >= MAX_CVARS)
{
if(!com_errorEntered)
Com_Error(ERR_FATAL, "Error: Too many cvars, cannot create a new one!");
return NULL;
}
var = &cvar_indexes[index];
if(index >= cvar_numIndexes)
cvar_numIndexes = index + 1;
var->name = CopyString (var_name);
var->string = CopyString (var_value);
var->modified = qtrue;
@ -391,6 +426,10 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
// link the variable in
var->next = cvar_vars;
if(cvar_vars)
cvar_vars->prev = var;
var->prev = NULL;
cvar_vars = var;
var->flags = flags;
@ -398,7 +437,13 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
cvar_modifiedFlags |= var->flags;
hash = generateHashValue(var_name);
var->hashIndex = hash;
var->hashNext = hashTable[hash];
if(hashTable[hash])
hashTable[hash]->hashPrev = var;
var->hashPrev = NULL;
hashTable[hash] = var;
return var;
@ -470,15 +515,23 @@ cvar_t *Cvar_Set2( const char *var_name, const char *value, qboolean force ) {
value = var->resetString;
}
value = Cvar_Validate( var, value, qtrue );
value = Cvar_Validate(var, value, qtrue);
if((var->flags & CVAR_LATCH) && var->latchedString) {
if(!strcmp(value,var->latchedString))
if((var->flags & CVAR_LATCH) && var->latchedString)
{
if(!strcmp(value, var->string))
{
Z_Free(var->latchedString);
var->latchedString = NULL;
return var;
}
if(!strcmp(value, var->latchedString))
return var;
}
else if (!strcmp(value,var->string)) {
else if(!strcmp(value, var->string))
return var;
}
// note what types of cvars have been modified (userinfo, archive, serverinfo, systeminfo)
cvar_modifiedFlags |= var->flags;
@ -609,12 +662,15 @@ Cvar_SetCheatState
Any testing variables will be reset to the safe values
============
*/
void Cvar_SetCheatState( void ) {
void Cvar_SetCheatState(void)
{
cvar_t *var;
// set all default vars to the safe value
for ( var = cvar_vars ; var ; var = var->next ) {
if ( var->flags & CVAR_CHEAT ) {
for(var = cvar_vars; var ; var = var->next)
{
if(var->flags & CVAR_CHEAT)
{
// the CVAR_LATCHED|CVAR_CHEAT vars might escape the reset here
// because of a different var->latchedString
if (var->latchedString)
@ -622,9 +678,8 @@ void Cvar_SetCheatState( void ) {
Z_Free(var->latchedString);
var->latchedString = NULL;
}
if (strcmp(var->resetString,var->string)) {
Cvar_Set( var->name, var->resetString );
}
if (strcmp(var->resetString,var->string))
Cvar_Set(var->name, var->resetString);
}
}
}
@ -690,21 +745,44 @@ void Cvar_Print_f(void)
============
Cvar_Toggle_f
Toggles a cvar for easy single key binding
Toggles a cvar for easy single key binding, optionally through a list of
given values
============
*/
void Cvar_Toggle_f( void ) {
int v;
int i, c = Cmd_Argc();
char *curval;
if ( Cmd_Argc() != 2 ) {
Com_Printf ("usage: toggle <variable>\n");
if(c < 2) {
Com_Printf("usage: toggle <variable> [value1, value2, ...]\n");
return;
}
v = Cvar_VariableValue( Cmd_Argv( 1 ) );
v = !v;
if(c == 2) {
Cvar_Set2(Cmd_Argv(1), va("%d",
!Cvar_VariableValue(Cmd_Argv(1))),
qfalse);
return;
}
Cvar_Set2 (Cmd_Argv(1), va("%i", v), qfalse);
if(c == 3) {
Com_Printf("toggle: nothing to toggle to\n");
return;
}
curval = Cvar_VariableString(Cmd_Argv(1));
// don't bother checking the last arg for a match since the desired
// behaviour is the same as no match (set to the first argument)
for(i = 2; i + 1 < c; i++) {
if(strcmp(curval, Cmd_Argv(i)) == 0) {
Cvar_Set2(Cmd_Argv(1), Cmd_Argv(i + 1), qfalse);
return;
}
}
// fallback
Cvar_Set2(Cmd_Argv(1), Cmd_Argv(2), qfalse);
}
/*
@ -716,12 +794,12 @@ weren't declared in C code.
============
*/
void Cvar_Set_f( void ) {
int i, c, l, len;
char cmd[5], combined[MAX_STRING_TOKENS];
cvar_t *v;
int c;
char *cmd;
cvar_t *v;
c = Cmd_Argc();
Q_strncpyz( cmd, Cmd_Argv(0), sizeof( cmd ) );
cmd = Cmd_Argv(0);
if ( c < 2 ) {
Com_Printf ("usage: %s <variable> <value>\n", cmd);
@ -732,35 +810,28 @@ void Cvar_Set_f( void ) {
return;
}
combined[0] = 0;
l = 0;
for ( i = 2 ; i < c ; i++ ) {
len = strlen ( Cmd_Argv( i ) + 1 );
if ( l + len >= MAX_STRING_TOKENS - 2 ) {
break;
}
strcat( combined, Cmd_Argv( i ) );
if ( i != c-1 ) {
strcat( combined, " " );
}
l += len;
}
v = Cvar_Set2 (Cmd_Argv(1), combined, qfalse);
v = Cvar_Set2 (Cmd_Argv(1), Cmd_ArgsFrom(2), qfalse);
if( !v ) {
return;
}
switch( cmd[3] ) {
default:
case '\0':
case 'a':
if( !( v->flags & CVAR_ARCHIVE ) ) {
v->flags |= CVAR_ARCHIVE;
cvar_modifiedFlags |= CVAR_ARCHIVE;
}
break;
case 'u':
v->flags |= CVAR_USERINFO;
if( !( v->flags & CVAR_USERINFO ) ) {
v->flags |= CVAR_USERINFO;
cvar_modifiedFlags |= CVAR_USERINFO;
}
break;
case 's':
v->flags |= CVAR_SERVERINFO;
break;
case 'a':
v->flags |= CVAR_ARCHIVE;
if( !( v->flags & CVAR_SERVERINFO ) ) {
v->flags |= CVAR_SERVERINFO;
cvar_modifiedFlags |= CVAR_SERVERINFO;
}
break;
}
}
@ -786,14 +857,16 @@ Appends lines containing "set variable value" for all variables
with the archive flag set to qtrue.
============
*/
void Cvar_WriteVariables( fileHandle_t f ) {
void Cvar_WriteVariables(fileHandle_t f)
{
cvar_t *var;
char buffer[1024];
for (var = cvar_vars ; var ; var = var->next) {
if( Q_stricmp( var->name, "cl_cdkey" ) == 0 ) {
for (var = cvar_vars; var; var = var->next)
{
if(!var->name || Q_stricmp( var->name, "cl_cdkey" ) == 0)
continue;
}
if( var->flags & CVAR_ARCHIVE ) {
// write the latched value, even if it hasn't taken effect yet
if ( var->latchedString ) {
@ -835,7 +908,8 @@ void Cvar_List_f( void ) {
i = 0;
for (var = cvar_vars ; var ; var = var->next, i++)
{
if (match && !Com_Filter(match, var->name, qfalse)) continue;
if(!var->name || (match && !Com_Filter(match, var->name, qfalse)))
continue;
if (var->flags & CVAR_SERVERINFO) {
Com_Printf("S");
@ -890,6 +964,113 @@ void Cvar_List_f( void ) {
Com_Printf ("%i cvar indexes\n", cvar_numIndexes);
}
/*
============
Cvar_Unset
Unsets a cvar
============
*/
cvar_t *Cvar_Unset(cvar_t *cv)
{
cvar_t *next = cv->next;
if(cv->name)
Z_Free(cv->name);
if(cv->string)
Z_Free(cv->string);
if(cv->latchedString)
Z_Free(cv->latchedString);
if(cv->resetString)
Z_Free(cv->resetString);
if(cv->prev)
cv->prev->next = cv->next;
else
cvar_vars = cv->next;
if(cv->next)
cv->next->prev = cv->prev;
if(cv->hashPrev)
cv->hashPrev->hashNext = cv->hashNext;
else
hashTable[cv->hashIndex] = cv->hashNext;
if(cv->hashNext)
cv->hashNext->hashPrev = cv->hashPrev;
Com_Memset(cv, '\0', sizeof(*cv));
return next;
}
/*
============
Cvar_Unset_f
Unsets a userdefined cvar
============
*/
void Cvar_Unset_f(void)
{
cvar_t *cv;
if(Cmd_Argc() != 2)
{
Com_Printf("Usage: %s <varname>\n", Cmd_Argv(0));
return;
}
cv = Cvar_FindVar(Cmd_Argv(1));
if(!cv)
return;
if(cv->flags & CVAR_USER_CREATED)
Cvar_Unset(cv);
else
Com_Printf("Error: %s: Variable %s is not user created.\n", Cmd_Argv(0), cv->name);
}
/*
============
Cvar_Restart
Resets all cvars to their hardcoded values and removes userdefined variables
and variables added via the VMs if requested.
============
*/
void Cvar_Restart(qboolean unsetVM)
{
cvar_t *curvar;
curvar = cvar_vars;
while(curvar)
{
if((curvar->flags & CVAR_USER_CREATED) ||
(unsetVM && (curvar->flags & CVAR_VM_CREATED)))
{
// throw out any variables the user/vm created
curvar = Cvar_Unset(curvar);
continue;
}
if(!(curvar->flags & (CVAR_ROM | CVAR_INIT | CVAR_NORESTART)))
{
// Just reset the rest to their default values.
Cvar_Set2(curvar->name, curvar->resetString, qfalse);
}
curvar = curvar->next;
}
}
/*
============
Cvar_Restart_f
@ -897,69 +1078,29 @@ Cvar_Restart_f
Resets all cvars to their hardcoded values
============
*/
void Cvar_Restart_f( void ) {
cvar_t *var;
cvar_t **prev;
prev = &cvar_vars;
while ( 1 ) {
var = *prev;
if ( !var ) {
break;
}
// don't mess with rom values, or some inter-module
// communication will get broken (com_cl_running, etc)
if ( var->flags & ( CVAR_ROM | CVAR_INIT | CVAR_NORESTART ) ) {
prev = &var->next;
continue;
}
// throw out any variables the user created
if ( var->flags & CVAR_USER_CREATED ) {
*prev = var->next;
if ( var->name ) {
Z_Free( var->name );
}
if ( var->string ) {
Z_Free( var->string );
}
if ( var->latchedString ) {
Z_Free( var->latchedString );
}
if ( var->resetString ) {
Z_Free( var->resetString );
}
// clear the var completely, since we
// can't remove the index from the list
Com_Memset( var, 0, sizeof( var ) );
continue;
}
Cvar_Set( var->name, var->resetString );
prev = &var->next;
}
void Cvar_Restart_f(void)
{
Cvar_Restart(qfalse);
}
/*
=====================
Cvar_InfoString
=====================
*/
char *Cvar_InfoString( int bit ) {
char *Cvar_InfoString(int bit)
{
static char info[MAX_INFO_STRING];
cvar_t *var;
info[0] = 0;
for (var = cvar_vars ; var ; var = var->next) {
if (var->flags & bit) {
for(var = cvar_vars; var; var = var->next)
{
if(var->name && (var->flags & bit))
Info_SetValueForKey (info, var->name, var->string);
}
}
return info;
}
@ -970,16 +1111,17 @@ Cvar_InfoString_Big
handles large info strings ( CS_SYSTEMINFO )
=====================
*/
char *Cvar_InfoString_Big( int bit ) {
char *Cvar_InfoString_Big(int bit)
{
static char info[BIG_INFO_STRING];
cvar_t *var;
info[0] = 0;
for (var = cvar_vars ; var ; var = var->next) {
if (var->flags & bit) {
for (var = cvar_vars; var; var = var->next)
{
if(var->name && (var->flags & bit))
Info_SetValueForKey_Big (info, var->name, var->string);
}
}
return info;
}
@ -1018,13 +1160,25 @@ Cvar_Register
basically a slightly modified Cvar_Get for the interpreted modules
=====================
*/
void Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) {
void Cvar_Register(vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags)
{
cvar_t *cv;
cv = Cvar_Get( varName, defaultValue, flags );
if ( !vmCvar ) {
return;
// There is code in Cvar_Get to prevent CVAR_ROM cvars being changed by the
// user. In other words CVAR_ARCHIVE and CVAR_ROM are mutually exclusive
// flags. Unfortunately some historical game code (including single player
// baseq3) sets both flags. We unset CVAR_ROM for such cvars.
if ((flags & (CVAR_ARCHIVE | CVAR_ROM)) == (CVAR_ARCHIVE | CVAR_ROM)) {
Com_DPrintf( S_COLOR_YELLOW "WARNING: Unsetting CVAR_ROM cvar '%s', "
"since it is also CVAR_ARCHIVE\n", varName );
flags &= ~CVAR_ROM;
}
cv = Cvar_Get(varName, defaultValue, flags | CVAR_VM_CREATED);
if (!vmCvar)
return;
vmCvar->handle = cv - cvar_indexes;
vmCvar->modificationCount = -1;
Cvar_Update( vmCvar );
@ -1089,7 +1243,11 @@ Cvar_Init
Reads in all archived cvars
============
*/
void Cvar_Init (void) {
void Cvar_Init (void)
{
Com_Memset(cvar_indexes, '\0', sizeof(cvar_indexes));
Com_Memset(hashTable, '\0', sizeof(hashTable));
cvar_cheats = Cvar_Get("sv_cheats", "1", CVAR_ROM | CVAR_SYSTEMINFO );
Cmd_AddCommand ("print", Cvar_Print_f);
@ -1105,6 +1263,9 @@ void Cvar_Init (void) {
Cmd_SetCommandCompletionFunc( "seta", Cvar_CompleteCvarName );
Cmd_AddCommand ("reset", Cvar_Reset_f);
Cmd_SetCommandCompletionFunc( "reset", Cvar_CompleteCvarName );
Cmd_AddCommand ("unset", Cvar_Unset_f);
Cmd_SetCommandCompletionFunc("unset", Cvar_CompleteCvarName);
Cmd_AddCommand ("cvarlist", Cvar_List_f);
Cmd_AddCommand ("cvar_restart", Cvar_Restart_f);
}

View file

@ -202,6 +202,7 @@ static const unsigned pak_checksums[] = {
typedef struct fileInPack_s {
char *name; // name of the file
unsigned long pos; // file info position in zip
unsigned long len; // uncompress file size
struct fileInPack_s* next; // next file in the hash
} fileInPack_t;
@ -247,9 +248,8 @@ static searchpath_t *fs_searchpaths;
static int fs_readCount; // total bytes read
static int fs_loadCount; // total files read
static int fs_loadStack; // total files in memory
static int fs_packFiles; // total number of files in packs
static int fs_packFiles = 0; // total number of files in packs
static int fs_fakeChkSum;
static int fs_checksumFeed;
typedef union qfile_gus {
@ -280,7 +280,7 @@ static fileHandleData_t fsh[MAX_FILE_HANDLES];
static qboolean fs_reordered;
// never load anything from pk3 files that are not present at the server when pure
static int fs_numServerPaks;
static int fs_numServerPaks = 0;
static int fs_serverPaks[MAX_SEARCH_PATHS]; // checksums
static char *fs_serverPakNames[MAX_SEARCH_PATHS]; // pk3 names
@ -437,10 +437,18 @@ Fix things up differently for win/unix/mac
*/
static void FS_ReplaceSeparators( char *path ) {
char *s;
qboolean lastCharWasSep = qfalse;
for ( s = path ; *s ; s++ ) {
if ( *s == '/' || *s == '\\' ) {
*s = PATH_SEP;
if ( !lastCharWasSep ) {
*s = PATH_SEP;
lastCharWasSep = qtrue;
} else {
memmove (s, s + 1, strlen (s));
}
} else {
lastCharWasSep = qfalse;
}
}
}
@ -464,7 +472,7 @@ char *FS_BuildOSPath( const char *base, const char *game, const char *qpath ) {
}
Com_sprintf( temp, sizeof(temp), "/%s/%s", game, qpath );
FS_ReplaceSeparators( temp );
FS_ReplaceSeparators( temp );
Com_sprintf( ospath[toggle], sizeof( ospath[0] ), "%s%s", base, temp );
return ospath[toggle];
@ -478,8 +486,9 @@ FS_CreatePath
Creates any directories needed to store the given filename
============
*/
static qboolean FS_CreatePath (char *OSPath) {
qboolean FS_CreatePath (char *OSPath) {
char *ofs;
char path[MAX_OSPATH];
// make absolutely sure that it can't back up the path
// FIXME: is c: allowed???
@ -488,14 +497,25 @@ static qboolean FS_CreatePath (char *OSPath) {
return qtrue;
}
for (ofs = OSPath+1 ; *ofs ; ofs++) {
if (*ofs == PATH_SEP) {
Q_strncpyz( path, OSPath, sizeof( path ) );
FS_ReplaceSeparators( path );
// Skip creation of the root directory as it will always be there
ofs = strchr( path, PATH_SEP );
ofs++;
for (; ofs != NULL && *ofs ; ofs++) {
if (*ofs == PATH_SEP) {
// create the directory
*ofs = 0;
Sys_Mkdir (OSPath);
if (!Sys_Mkdir (path)) {
Com_Error( ERR_FATAL, "FS_CreatePath: failed to create path \"%s\"\n",
path );
}
*ofs = PATH_SEP;
}
}
return qfalse;
}
@ -991,7 +1011,6 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
fileInPack_t *pakFile;
directory_t *dir;
long hash;
unz_s *zfi;
FILE *temp;
int l;
char demoExt[16];
@ -1119,26 +1138,17 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
if ( uniqueFILE ) {
// open a new file on the pakfile
fsh[*file].handleFiles.file.z = unzReOpen (pak->pakFilename, pak->handle);
fsh[*file].handleFiles.file.z = unzOpen (pak->pakFilename);
if (fsh[*file].handleFiles.file.z == NULL) {
Com_Error (ERR_FATAL, "Couldn't reopen %s", pak->pakFilename);
Com_Error (ERR_FATAL, "Couldn't open %s", pak->pakFilename);
}
} else {
fsh[*file].handleFiles.file.z = pak->handle;
}
Q_strncpyz( fsh[*file].name, filename, sizeof( fsh[*file].name ) );
fsh[*file].zipFile = qtrue;
zfi = (unz_s *)fsh[*file].handleFiles.file.z;
// in case the file was new
temp = zfi->file;
// set the file position in the zip file (also sets the current file info)
unzSetCurrentFileInfoPosition(pak->handle, pakFile->pos);
if ( zfi != pak->handle ) {
// copy the file info into the unzip structure
Com_Memcpy( zfi, pak->handle, sizeof(unz_s) );
}
// we copy this back into the structure
zfi->file = temp;
unzSetOffset(fsh[*file].handleFiles.file.z, pakFile->pos);
// open the file in the zip
unzOpenCurrentFile( fsh[*file].handleFiles.file.z );
fsh[*file].zipFilePos = pakFile->pos;
@ -1147,7 +1157,7 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
Com_Printf( "FS_FOpenFileRead: %s (found in '%s')\n",
filename, pak->pakFilename );
}
return zfi->cur_file_info.uncompressed_size;
return pakFile->len;
}
pakFile = pakFile->next;
} while(pakFile != NULL);
@ -1181,14 +1191,6 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
continue;
}
if ( Q_stricmp( filename + l - 4, ".cfg" ) // for config files
&& Q_stricmp( filename + l - 5, ".menu" ) // menu files
&& Q_stricmp( filename + l - 5, ".game" ) // menu files
&& Q_stricmp( filename + l - strlen(demoExt), demoExt ) // menu files
&& Q_stricmp( filename + l - 4, ".dat" ) ) { // for journal files
fs_fakeChkSum = random();
}
Q_strncpyz( fsh[*file].name, filename, sizeof( fsh[*file].name ) );
fsh[*file].zipFile = qfalse;
if ( fs_debug->integer ) {
@ -1382,7 +1384,7 @@ int FS_Seek( fileHandle_t f, long offset, int origin ) {
switch( origin ) {
case FS_SEEK_SET:
unzSetCurrentFileInfoPosition(fsh[f].handleFiles.file.z, fsh[f].zipFilePos);
unzSetOffset(fsh[f].handleFiles.file.z, fsh[f].zipFilePos);
unzOpenCurrentFile(fsh[f].handleFiles.file.z);
//fallthrough
@ -1678,7 +1680,7 @@ Creates a new pak_t in the search chain for the contents
of a zip file.
=================
*/
static pack_t *FS_LoadZipFile( char *zipfile, const char *basename )
static pack_t *FS_LoadZipFile(const char *zipfile, const char *basename)
{
fileInPack_t *buildBuffer;
pack_t *pack;
@ -1701,8 +1703,6 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename )
if (err != UNZ_OK)
return NULL;
fs_packFiles += gi.number_entry;
len = 0;
unzGoToFirstFile(uf);
for (i = 0; i < gi.number_entry; i++)
@ -1762,15 +1762,15 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename )
strcpy( buildBuffer[i].name, filename_inzip );
namePtr += strlen(filename_inzip) + 1;
// store the file position in the zip
unzGetCurrentFileInfoPosition(uf, &buildBuffer[i].pos);
//
buildBuffer[i].pos = unzGetOffset(uf);
buildBuffer[i].len = file_info.uncompressed_size;
buildBuffer[i].next = pack->hashTable[hash];
pack->hashTable[hash] = &buildBuffer[i];
unzGoToNextFile(uf);
}
pack->checksum = Com_BlockChecksum( &fs_headerLongs[ 1 ], 4 * ( fs_numHeaderLongs - 1 ) );
pack->pure_checksum = Com_BlockChecksum( fs_headerLongs, 4 * fs_numHeaderLongs );
pack->checksum = Com_BlockChecksum( &fs_headerLongs[ 1 ], sizeof(*fs_headerLongs) * ( fs_numHeaderLongs - 1 ) );
pack->pure_checksum = Com_BlockChecksum( fs_headerLongs, sizeof(*fs_headerLongs) * fs_numHeaderLongs );
pack->checksum = LittleLong( pack->checksum );
pack->pure_checksum = LittleLong( pack->pure_checksum );
@ -1780,6 +1780,50 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename )
return pack;
}
/*
=================
FS_FreePak
Frees a pak structure and releases all associated resources
=================
*/
static void FS_FreePak(pack_t *thepak)
{
unzClose(thepak->handle);
Z_Free(thepak->buildBuffer);
Z_Free(thepak);
}
/*
=================
FS_GetZipChecksum
Compares whether the given pak file matches a referenced checksum
=================
*/
qboolean FS_CompareZipChecksum(const char *zipfile)
{
pack_t *thepak;
int index, checksum;
thepak = FS_LoadZipFile(zipfile, "");
if(!thepak)
return qfalse;
checksum = thepak->checksum;
FS_FreePak(thepak);
for(index = 0; index < fs_numServerReferencedPaks; index++)
{
if(checksum == fs_serverReferencedPaks[index])
return qtrue;
}
return qfalse;
}
/*
=================================================================================
@ -2484,6 +2528,8 @@ void FS_AddGameDirectory( const char *path, const char *dir ) {
continue;
// store the game name for downloading
strcpy(pak->pakGamename, dir);
fs_packFiles += pak->numfiles;
search = Z_Malloc (sizeof(searchpath_t));
search->pack = pak;
@ -2575,7 +2621,8 @@ qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) {
havepak = qfalse;
// never autodownload any of the id paks
if ( FS_idPak(fs_serverReferencedPakNames[i], BASEGAME) || FS_idPak(fs_serverReferencedPakNames[i], "missionpack") ) {
if ( FS_idPak(fs_serverReferencedPakNames[i], "baseq3")
|| FS_idPak(fs_serverReferencedPakNames[i], "missionpack") ) {
continue;
}
@ -2673,18 +2720,16 @@ void FS_Shutdown( qboolean closemfp ) {
}
// free everything
for ( p = fs_searchpaths ; p ; p = next ) {
for(p = fs_searchpaths; p; p = next)
{
next = p->next;
if ( p->pack ) {
unzClose(p->pack->handle);
Z_Free( p->pack->buildBuffer );
Z_Free( p->pack );
}
if ( p->dir ) {
Z_Free( p->dir );
}
Z_Free( p );
if(p->pack)
FS_FreePak(p->pack);
if (p->dir)
Z_Free(p->dir);
Z_Free(p);
}
// any FS_ calls will now be an error until reinitialized
@ -2758,6 +2803,8 @@ static void FS_Startup( const char *gameName )
Com_Printf( "----- FS_Startup -----\n" );
fs_packFiles = 0;
fs_debug = Cvar_Get( "fs_debug", "0", 0 );
fs_basepath = Cvar_Get ("fs_basepath", Sys_DefaultInstallPath(), CVAR_INIT );
fs_basegame = Cvar_Get ("fs_basegame", "", CVAR_INIT );
@ -2783,11 +2830,12 @@ static void FS_Startup( const char *gameName )
// NOTE: same filtering below for mods and basegame
if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) {
FS_CreatePath ( fs_homepath->string );
FS_AddGameDirectory ( fs_homepath->string, gameName );
}
// check for additional base game so mods can be based upon other mods
if ( fs_basegame->string[0] && !Q_stricmp( gameName, BASEGAME ) && Q_stricmp( fs_basegame->string, gameName ) ) {
if ( fs_basegame->string[0] && Q_stricmp( fs_basegame->string, gameName ) ) {
if (fs_basepath->string[0]) {
FS_AddGameDirectory(fs_basepath->string, fs_basegame->string);
}
@ -2797,7 +2845,7 @@ static void FS_Startup( const char *gameName )
}
// check for additional game folder for mods
if ( fs_gamedirvar->string[0] && !Q_stricmp( gameName, BASEGAME ) && Q_stricmp( fs_gamedirvar->string, gameName ) ) {
if ( fs_gamedirvar->string[0] && Q_stricmp( fs_gamedirvar->string, gameName ) ) {
if (fs_basepath->string[0]) {
FS_AddGameDirectory(fs_basepath->string, fs_gamedirvar->string);
}
@ -2854,7 +2902,7 @@ Note: If you're building a game that doesn't depend on the
Q3 media pak0.pk3, you'll want to remove this function
===================
*/
/* JBravo - Not...
/* JBravo - Not
static void FS_CheckPak0( void )
{
searchpath_t *path;
@ -2922,33 +2970,34 @@ static void FS_CheckPak0( void )
&&
(!founddemo && (foundPak & 0x1ff) != 0x1ff) )
{
char errorText[MAX_STRING_CHARS] = "";
if((foundPak&1) != 1 )
{
Com_Printf("\n\n"
"pak0.pk3 is missing. Please copy it\n"
"from your legitimate Q3 CDROM.\n");
Q_strcat(errorText, sizeof(errorText),
"\"pak0.pk3\" is missing. Please copy it "
"from your legitimate Q3 CDROM. ");
}
if((foundPak&0x1fe) != 0x1fe )
{
Com_Printf("\n\n"
"Point Release files are missing. Please\n"
"re-install the 1.32 point release.\n");
Q_strcat(errorText, sizeof(errorText),
"Point Release files are missing. Please "
"re-install the 1.32 point release. ");
}
Com_Printf("\n\n"
"Also check that your Q3 executable is in\n"
"the correct place and that every file\n"
"in the %s directory is present and readable.\n", BASEGAME);
Q_strcat(errorText, sizeof(errorText),
va("Also check that your ioq3 executable is in "
"the correct place and that every file "
"in the \"%s\" directory is present and readable", BASEGAME));
Com_Error(ERR_FATAL, "You need to install Quake III Arena in order to play");
Com_Error(ERR_FATAL, "%s", errorText);
}
if(foundPak & 1)
Cvar_Set("com_standalone", "0");
}
*/
#endif
/*
@ -3124,10 +3173,6 @@ const char *FS_ReferencedPakPureChecksums( void ) {
numPaks++;
}
}
if (fs_fakeChkSum != 0) {
// only added if a non-pure file is referenced
Q_strcat( info, sizeof( info ), va("%i ", fs_fakeChkSum ) );
}
}
// last checksum is the encoded number of referenced pk3s
checksum ^= numPaks;
@ -3322,7 +3367,7 @@ void FS_InitFilesystem( void ) {
FS_Startup( BASEGAME );
#ifndef STANDALONE
// FS_CheckPak0( ); /* JBravo - Not... */
// FS_CheckPak0( );
#endif
// if we can't find default.cfg, assume that the paths are
@ -3357,7 +3402,7 @@ void FS_Restart( int checksumFeed ) {
FS_Startup( BASEGAME );
#ifndef STANDALONE
// FS_CheckPak0( ); /* JBravo - Not... */
// FS_CheckPak0( );
#endif
// if we can't find default.cfg, assume that the paths are
@ -3397,11 +3442,20 @@ FS_ConditionalRestart
restart if necessary
=================
*/
qboolean FS_ConditionalRestart( int checksumFeed ) {
if( fs_gamedirvar->modified || checksumFeed != fs_checksumFeed ) {
FS_Restart( checksumFeed );
qboolean FS_ConditionalRestart(int checksumFeed)
{
if(fs_gamedirvar->modified)
{
Com_GameRestart(checksumFeed, qfalse);
return qtrue;
}
else if(checksumFeed != fs_checksumFeed)
{
FS_Restart(checksumFeed);
return qtrue;
}
return qfalse;
}

View file

@ -311,9 +311,9 @@ void MSG_WriteString( msg_t *sb, const char *s ) {
}
Q_strncpyz( string, s, sizeof( string ) );
// get rid of 0xff chars, because old clients don't like them
// get rid of 0x80+ and '%' chars, because old clients don't like them
for ( i = 0 ; i < l ; i++ ) {
if ( ((byte *)string)[i] > 127 ) {
if ( ((byte *)string)[i] > 127 || string[i] == '%' ) {
string[i] = '.';
}
}
@ -337,9 +337,9 @@ void MSG_WriteBigString( msg_t *sb, const char *s ) {
}
Q_strncpyz( string, s, sizeof( string ) );
// get rid of 0xff chars, because old clients don't like them
// get rid of 0x80+ and '%' chars, because old clients don't like them
for ( i = 0 ; i < l ; i++ ) {
if ( ((byte *)string)[i] > 127 ) {
if ( ((byte *)string)[i] > 127 || string[i] == '%' ) {
string[i] = '.';
}
}
@ -525,6 +525,21 @@ void MSG_ReadData( msg_t *msg, void *data, int len ) {
}
}
// a string hasher which gives the same hash value even if the
// string is later modified via the legacy MSG read/write code
int MSG_HashKey(const char *string, int maxlen) {
int hash, i;
hash = 0;
for (i = 0; i < maxlen && string[i] != '\0'; i++) {
if (string[i] & 0x80 || string[i] == '%')
hash += '.' * (119 + i);
else
hash += string[i] * (119 + i);
}
hash = (hash ^ (hash >> 10) ^ (hash >> 20));
return hash;
}
/*
=============================================================================
@ -1028,6 +1043,10 @@ void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to,
numFields = sizeof(entityStateFields)/sizeof(entityStateFields[0]);
lc = MSG_ReadByte(msg);
if ( lc > numFields || lc < 0 ) {
Com_Error( ERR_DROP, "invalid entityState field count" );
}
// shownet 2/3 will interleave with other printed info, -1 will
// just print the delta records`
if ( cl_shownet->integer >= 2 || cl_shownet->integer == -1 ) {
@ -1361,6 +1380,10 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t
numFields = sizeof( playerStateFields ) / sizeof( playerStateFields[0] );
lc = MSG_ReadByte(msg);
if ( lc > numFields || lc < 0 ) {
Com_Error( ERR_DROP, "invalid playerState field count" );
}
for ( i = 0, field = playerStateFields ; i < lc ; i++, field++ ) {
fromF = (int *)( (byte *)from + field->offset );
toF = (int *)( (byte *)to + field->offset );

View file

@ -550,7 +550,7 @@ static void NET_QueuePacket( int length, const void *data, netadr_t to,
Com_Memcpy(new->data, data, length);
new->length = length;
new->to = to;
new->release = Sys_Milliseconds() + offset;
new->release = Sys_Milliseconds() + (int)((float)offset / com_timescale->value);
new->next = NULL;
if(!packetQueue) {

Some files were not shown because too many files have changed in this diff Show more