Merge branch 'next' of https://git.do.srb2.org/STJr/SRB2 into udmf-fofs-mkii

# Conflicts:
#	src/p_user.c
This commit is contained in:
Nev3r 2020-10-27 22:23:30 +01:00
commit 3d2d44bfff
177 changed files with 12174 additions and 12831 deletions

View file

@ -43,7 +43,7 @@ jobs:
- v1-SRB2-APT
- run:
name: Install SDK
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
- save_cache:
key: v1-SRB2-APT
@ -71,4 +71,4 @@ jobs:
- save_cache:
key: v1-SRB2-{{ .Branch }}-{{ checksum "objs/Linux/SDL/Release/depend.dep" }}
paths:
- /root/.ccache
- /root/.ccache

View file

@ -26,6 +26,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.4
compiler: gcc-4.4
@ -43,6 +44,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.6
compiler: gcc-4.6
@ -60,6 +62,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.7
compiler: gcc-4.7
@ -83,6 +86,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
@ -101,6 +105,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-7
compiler: gcc-7
@ -119,6 +124,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-8
compiler: gcc-8
@ -141,6 +147,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- clang-3.5
compiler: clang-3.5
@ -159,6 +166,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- clang-3.6
compiler: clang-3.6
@ -177,6 +185,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- clang-3.7
compiler: clang-3.7
@ -195,6 +204,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- clang-3.8
compiler: clang-3.8
@ -213,6 +223,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- clang-3.9
compiler: clang-3.9
@ -323,6 +334,7 @@ matrix:
- libpng-dev
- libgl1-mesa-dev
- libgme-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
@ -468,6 +480,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
@ -495,6 +508,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
@ -522,6 +536,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
@ -549,6 +564,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
@ -576,6 +592,7 @@ matrix:
- libgl1-mesa-dev
- libgme-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
- gcc-4.8
compiler: gcc-4.8
@ -619,6 +636,7 @@ addons:
- libgme-dev
- zlib1g-dev
- libopenmpt-dev
- libcurl4-openssl-dev
- p7zip-full
homebrew:
taps:
@ -629,6 +647,7 @@ addons:
- p7zip
- libopenmpt
- cmake
- curl
update: true

View file

@ -109,13 +109,10 @@ FILE_PATTERNS = *.c \
*.mm \
*.dox
RECURSIVE = YES
EXCLUDE = ./src/djgppdos/internal.h \
./src/djgppdos/setup.c \
./src/sdl/IMG_xpm.c \
EXCLUDE = ./src/sdl/IMG_xpm.c \
./src/sdl/SRB2DC/scramble.c
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = */src/hardware/*/* \
*/src/djgppdos/bcd.? \
*/src/sdl/SDL_main/* \
*/src/*/*_private.h \
*/src/sdl/*/*help.? \

View file

@ -1,4 +1,4 @@
version: 2.2.6.{branch}-{build}
version: 2.2.8.{branch}-{build}
os: MinGW
environment:

View file

@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing

View file

@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing

View file

@ -11,6 +11,7 @@ Build-Depends: debhelper (>= 7.0.50~),
zlib1g-dev,
libgme-dev,
libopenmpt-dev,
libcurl4-openssl-dev,
libglu1-dev | libglu-dev,
libosmesa6-dev | libgl-dev,
nasm [i386]

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
#ifndef __CURL_CURLVER_H
#define __CURL_CURLVER_H
#ifndef CURLINC_CURLVER_H
#define CURLINC_CURLVER_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@ -26,17 +26,17 @@
a script at release-time. This was made its own header file in 7.11.2 */
/* This is the global package copyright */
#define LIBCURL_COPYRIGHT "1996 - 2011 Daniel Stenberg, <daniel@haxx.se>."
#define LIBCURL_COPYRIGHT "1996 - 2020 Daniel Stenberg, <daniel@haxx.se>."
/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "7.21.6"
#define LIBCURL_VERSION "7.69.0"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
#define LIBCURL_VERSION_MINOR 21
#define LIBCURL_VERSION_PATCH 6
#define LIBCURL_VERSION_MINOR 69
#define LIBCURL_VERSION_PATCH 0
/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
@ -52,18 +52,26 @@
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
and it is always a greater number in a more recent release. It makes
comparisons with greater than and less than work.
Note: This define is the full hex number and _does not_ use the
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
#define LIBCURL_VERSION_NUM 0x071506
#define LIBCURL_VERSION_NUM 0x074500
/*
* This is the date and time when the full source package was created. The
* timestamp is not stored in git, as the timestamp is properly set in the
* tarballs by the maketgz script.
*
* The format of the date should follow this template:
* The format of the date follows this template:
*
* "Mon Feb 12 11:35:33 UTC 2007"
* "2007-11-23"
*/
#define LIBCURL_TIMESTAMP "Fri Apr 22 17:18:50 UTC 2011"
#define LIBCURL_TIMESTAMP "2020-03-04"
#endif /* __CURL_CURLVER_H */
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
#define CURL_AT_LEAST_VERSION(x,y,z) \
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
#endif /* CURLINC_CURLVER_H */

View file

@ -1,5 +1,5 @@
#ifndef __CURL_EASY_H
#define __CURL_EASY_H
#ifndef CURLINC_EASY_H
#define CURLINC_EASY_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@ -58,7 +58,7 @@ CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
* curl_easy_duphandle() for each new thread to avoid a series of identical
* curl_easy_setopt() invokes in every thread.
*/
CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl);
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
/*
* NAME curl_easy_reset()
@ -95,6 +95,16 @@ CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
size_t buflen, size_t *n);
/*
* NAME curl_easy_upkeep()
*
* DESCRIPTION
*
* Performs connection upkeep for the given session handle.
*/
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
#ifdef __cplusplus
}
#endif

View file

@ -1,5 +1,5 @@
#ifndef __CURL_MPRINTF_H
#define __CURL_MPRINTF_H
#ifndef CURLINC_MPRINTF_H
#define CURLINC_MPRINTF_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@ -24,8 +24,7 @@
#include <stdarg.h>
#include <stdio.h> /* needed for FILE */
#include "curl.h"
#include "curl.h" /* for CURL_EXTERN */
#ifdef __cplusplus
extern "C" {
@ -44,38 +43,8 @@ CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
CURL_EXTERN char *curl_maprintf(const char *format, ...);
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
#ifdef _MPRINTF_REPLACE
# undef printf
# undef fprintf
# undef sprintf
# undef vsprintf
# undef snprintf
# undef vprintf
# undef vfprintf
# undef vsnprintf
# undef aprintf
# undef vaprintf
# define printf curl_mprintf
# define fprintf curl_mfprintf
#ifdef CURLDEBUG
/* When built with CURLDEBUG we define away the sprintf() functions since we
don't want internal code to be using them */
# define sprintf sprintf_was_used
# define vsprintf vsprintf_was_used
#else
# define sprintf curl_msprintf
# define vsprintf curl_mvsprintf
#endif
# define snprintf curl_msnprintf
# define vprintf curl_mvprintf
# define vfprintf curl_mvfprintf
# define vsnprintf curl_mvsnprintf
# define aprintf curl_maprintf
# define vaprintf curl_mvaprintf
#endif
#ifdef __cplusplus
}
#endif
#endif /* __CURL_MPRINTF_H */
#endif /* CURLINC_MPRINTF_H */

View file

@ -1,5 +1,5 @@
#ifndef __CURL_MULTI_H
#define __CURL_MULTI_H
#ifndef CURLINC_MULTI_H
#define CURLINC_MULTI_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@ -52,7 +52,11 @@
extern "C" {
#endif
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
typedef struct Curl_multi CURLM;
#else
typedef void CURLM;
#endif
typedef enum {
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
@ -64,6 +68,12 @@ typedef enum {
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
attempted to get added - again */
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
callback */
CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
CURLM_LAST
} CURLMcode;
@ -72,6 +82,11 @@ typedef enum {
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
/* bitmask bits for CURLMOPT_PIPELINING */
#define CURLPIPE_NOTHING 0L
#define CURLPIPE_HTTP1 1L
#define CURLPIPE_MULTIPLEX 2L
typedef enum {
CURLMSG_NONE, /* first, not used */
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
@ -89,6 +104,19 @@ struct CURLMsg {
};
typedef struct CURLMsg CURLMsg;
/* Based on poll(2) structure and values.
* We don't use pollfd and POLL* constants explicitly
* to cover platforms without poll(). */
#define CURL_WAIT_POLLIN 0x0001
#define CURL_WAIT_POLLPRI 0x0002
#define CURL_WAIT_POLLOUT 0x0004
struct curl_waitfd {
curl_socket_t fd;
short events;
short revents; /* not supported yet */
};
/*
* Name: curl_multi_init()
*
@ -133,6 +161,43 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
fd_set *exc_fd_set,
int *max_fd);
/*
* Name: curl_multi_wait()
*
* Desc: Poll on all fds within a CURLM set as well as any
* additional fds passed to the function.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
struct curl_waitfd extra_fds[],
unsigned int extra_nfds,
int timeout_ms,
int *ret);
/*
* Name: curl_multi_poll()
*
* Desc: Poll on all fds within a CURLM set as well as any
* additional fds passed to the function.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
struct curl_waitfd extra_fds[],
unsigned int extra_nfds,
int timeout_ms,
int *ret);
/*
* Name: curl_multi_wakeup()
*
* Desc: wakes up a sleeping curl_multi_poll call.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
/*
* Name: curl_multi_perform()
*
@ -146,8 +211,8 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
*
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
* returns errors etc regarding the whole multi stack. There might
* still have occurred problems on invidual transfers even when this
* returns OK.
* still have occurred problems on individual transfers even when
* this returns OK.
*/
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
int *running_handles);
@ -180,7 +245,7 @@ CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
* curl_multi_cleanup().
*
* The 'CURLMsg' struct is meant to be very simple and only contain
* very basic informations. If more involved information is wanted,
* very basic information. If more involved information is wanted,
* we will provide the particular "transfer handle" in that struct
* and that should/could/would be used in subsequent
* curl_easy_getinfo() calls (or similar). The point being that we
@ -279,37 +344,58 @@ CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
long *milliseconds);
#undef CINIT /* re-using the same name as in curl.h */
#ifdef CURL_ISOCPP
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
#else
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
#define LONG CURLOPTTYPE_LONG
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
#define OFF_T CURLOPTTYPE_OFF_T
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
#endif
typedef enum {
/* This is the socket callback function pointer */
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1),
/* This is the argument passed to the socket callback */
CINIT(SOCKETDATA, OBJECTPOINT, 2),
CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2),
/* set to 1 to enable pipelining for this multi handle */
CINIT(PIPELINING, LONG, 3),
CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3),
/* This is the timer callback function pointer */
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4),
/* This is the argument passed to the timer callback */
CINIT(TIMERDATA, OBJECTPOINT, 5),
CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5),
/* maximum number of entries in the connection cache */
CINIT(MAXCONNECTS, LONG, 6),
CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6),
/* maximum number of (pipelining) connections to one host */
CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7),
/* maximum number of requests in a pipeline */
CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8),
/* a connection with a content-length longer than this
will not be considered for pipelining */
CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9),
/* a connection with a chunk length longer than this
will not be considered for pipelining */
CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10),
/* a list of site names(+port) that are blacklisted from
pipelining */
CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11),
/* a list of server types that are blacklisted from
pipelining */
CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12),
/* maximum number of open connections in total */
CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13),
/* This is the server push callback function pointer */
CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14),
/* This is the argument passed to the server push callback */
CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15),
/* maximum number of concurrent streams to support on a connection */
CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16),
CURLMOPT_LASTENTRY /* the last unused */
} CURLMoption;
@ -338,6 +424,31 @@ CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
curl_socket_t sockfd, void *sockp);
/*
* Name: curl_push_callback
*
* Desc: This callback gets called when a new stream is being pushed by the
* server. It approves or denies the new stream.
*
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
*/
#define CURL_PUSH_OK 0
#define CURL_PUSH_DENY 1
struct curl_pushheaders; /* forward declaration only */
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
size_t num);
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
const char *name);
typedef int (*curl_push_callback)(CURL *parent,
CURL *easy,
size_t num_headers,
struct curl_pushheaders *headers,
void *userp);
#ifdef __cplusplus
} /* end of extern "C" */
#endif

View file

@ -1,5 +1,5 @@
#ifndef __STDC_HEADERS_H
#define __STDC_HEADERS_H
#ifndef CURLINC_STDCHEADERS_H
#define CURLINC_STDCHEADERS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@ -24,10 +24,10 @@
#include <sys/types.h>
size_t fread (void *, size_t, size_t, FILE *);
size_t fwrite (const void *, size_t, size_t, FILE *);
size_t fread(void *, size_t, size_t, FILE *);
size_t fwrite(const void *, size_t, size_t, FILE *);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
#endif /* __STDC_HEADERS_H */
#endif /* CURLINC_STDCHEADERS_H */

View file

@ -0,0 +1,504 @@
#ifndef CURLINC_SYSTEM_H
#define CURLINC_SYSTEM_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* Try to keep one section per platform, compiler and architecture, otherwise,
* if an existing section is reused for a different one and later on the
* original is adjusted, probably the piggybacking one can be adversely
* changed.
*
* In order to differentiate between platforms/compilers/architectures use
* only compiler built in predefined preprocessor symbols.
*
* curl_off_t
* ----------
*
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
* wide signed integral data type. The width of this data type must remain
* constant and independent of any possible large file support settings.
*
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
* wide signed integral data type if there is no 64-bit type.
*
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
* only be violated if off_t is the only 64-bit data type available and the
* size of off_t is independent of large file support settings. Keep your
* build on the safe side avoiding an off_t gating. If you have a 64-bit
* off_t then take for sure that another 64-bit data type exists, dig deeper
* and you will find it.
*
*/
#if defined(__DJGPP__) || defined(__GO32__)
# if defined(__DJGPP__) && (__DJGPP__ > 1)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__SALFORDC__)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__BORLANDC__)
# if (__BORLANDC__ < 0x520)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TURBOC__)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__WATCOMC__)
# if defined(__386__)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__POCC__)
# if (__POCC__ < 280)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# elif defined(_MSC_VER)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__LCC__)
# if defined(__e2k__) /* MCST eLbrus C Compiler */
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# else /* Local (or Little) C Compiler */
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
# endif
#elif defined(__SYMBIAN32__)
# if defined(__EABI__) /* Treat all ARM compilers equally */
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__CW32__)
# pragma longlong on
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__VC32__)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
#elif defined(__MWERKS__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(_WIN32_WCE)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__MINGW32__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_WS2TCPIP_H 1
#elif defined(__VMS)
# if defined(__VAX)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
#elif defined(__OS400__)
# if defined(__ILEC400__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__MVS__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# elif defined(_LP64)
# endif
# if defined(_LONG_LONG)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(_LP64)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__370__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# elif defined(_LP64)
# endif
# if defined(_LONG_LONG)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(_LP64)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(TPF)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TINYC__) /* also known as tcc */
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
# if !defined(__LP64) && (defined(__ILP32) || \
defined(__i386) || \
defined(__sparcv8) || \
defined(__sparcv8plus))
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64) || \
defined(__amd64) || defined(__sparcv9)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#elif defined(__xlc__) /* IBM xlc compiler */
# if !defined(_LP64)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
/* ===================================== */
/* KEEP MSVC THE PENULTIMATE ENTRY */
/* ===================================== */
#elif defined(_MSC_VER)
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
/* ===================================== */
/* KEEP GENERIC GCC THE LAST ENTRY */
/* ===================================== */
#elif defined(__GNUC__) && !defined(_SCO_DS)
# if !defined(__LP64__) && \
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
defined(__XTENSA__) || \
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64__) || \
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
defined(__e2k__) || \
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#else
/* generic "safe guess" on old 32 bit style */
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#endif
#ifdef _AIX
/* AIX needs <sys/poll.h> */
#define CURL_PULL_SYS_POLL_H
#endif
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
/* ws2tcpip.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_WS2TCPIP_H
# include <winsock2.h>
# include <windows.h>
# include <ws2tcpip.h>
#endif
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
/* sys/types.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_TYPES_H
# include <sys/types.h>
#endif
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
/* sys/socket.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_SOCKET_H
# include <sys/socket.h>
#endif
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
/* sys/poll.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_POLL_H
# include <sys/poll.h>
#endif
/* Data type definition of curl_socklen_t. */
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
#endif
/* Data type definition of curl_off_t. */
#ifdef CURL_TYPEOF_CURL_OFF_T
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
#endif
/*
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
* these to be visible and exported by the external libcurl interface API,
* while also making them visible to the library internals, simply including
* curl_setup.h, without actually needing to include curl.h internally.
* If some day this section would grow big enough, all this should be moved
* to its own header file.
*/
/*
* Figure out if we can use the ## preprocessor operator, which is supported
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
* or __cplusplus so we need to carefully check for them too.
*/
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
defined(__ILEC400__)
/* This compiler is believed to have an ISO compatible preprocessor */
#define CURL_ISOCPP
#else
/* This compiler is believed NOT to have an ISO compatible preprocessor */
#undef CURL_ISOCPP
#endif
/*
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
*/
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
# define CURLINC_OFF_T_C_HLPR2(x) x
# define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x)
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
#else
# ifdef CURL_ISOCPP
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
# else
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
# endif
# define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix)
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
#endif
#endif /* CURLINC_SYSTEM_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,125 @@
#ifndef CURLINC_URLAPI_H
#define CURLINC_URLAPI_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curl.h"
#ifdef __cplusplus
extern "C" {
#endif
/* the error codes for the URL API */
typedef enum {
CURLUE_OK,
CURLUE_BAD_HANDLE, /* 1 */
CURLUE_BAD_PARTPOINTER, /* 2 */
CURLUE_MALFORMED_INPUT, /* 3 */
CURLUE_BAD_PORT_NUMBER, /* 4 */
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
CURLUE_URLDECODE, /* 6 */
CURLUE_OUT_OF_MEMORY, /* 7 */
CURLUE_USER_NOT_ALLOWED, /* 8 */
CURLUE_UNKNOWN_PART, /* 9 */
CURLUE_NO_SCHEME, /* 10 */
CURLUE_NO_USER, /* 11 */
CURLUE_NO_PASSWORD, /* 12 */
CURLUE_NO_OPTIONS, /* 13 */
CURLUE_NO_HOST, /* 14 */
CURLUE_NO_PORT, /* 15 */
CURLUE_NO_QUERY, /* 16 */
CURLUE_NO_FRAGMENT /* 17 */
} CURLUcode;
typedef enum {
CURLUPART_URL,
CURLUPART_SCHEME,
CURLUPART_USER,
CURLUPART_PASSWORD,
CURLUPART_OPTIONS,
CURLUPART_HOST,
CURLUPART_PORT,
CURLUPART_PATH,
CURLUPART_QUERY,
CURLUPART_FRAGMENT,
CURLUPART_ZONEID /* added in 7.65.0 */
} CURLUPart;
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
if the port number matches the
default for the scheme */
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
missing */
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the
scheme is unknown. */
typedef struct Curl_URL CURLU;
/*
* curl_url() creates a new CURLU handle and returns a pointer to it.
* Must be freed with curl_url_cleanup().
*/
CURL_EXTERN CURLU *curl_url(void);
/*
* curl_url_cleanup() frees the CURLU handle and related resources used for
* the URL parsing. It will not free strings previously returned with the URL
* API.
*/
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
/*
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
* handle must also be freed with curl_url_cleanup().
*/
CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
/*
* curl_url_get() extracts a specific part of the URL from a CURLU
* handle. Returns error code. The returned pointer MUST be freed with
* curl_free() afterwards.
*/
CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
char **part, unsigned int flags);
/*
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
* error code. The passed in string will be copied. Passing a NULL instead of
* a part string, clears that part.
*/
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
const char *part, unsigned int flags);
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif /* CURLINC_URLAPI_H */

Binary file not shown.

BIN
libs/curl/lib32/libcurl.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing

View file

@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing

View file

@ -32,10 +32,12 @@ set(SRB2_CORE_SOURCES
m_fixed.c
m_menu.c
m_misc.c
m_perfstats.c
m_queue.c
m_random.c
md5.c
mserv.c
http-mserv.c
s_sound.c
screen.c
sounds.c
@ -96,6 +98,7 @@ set(SRB2_CORE_HEADERS
m_fixed.h
m_menu.h
m_misc.h
m_perfstats.h
m_queue.h
m_random.h
m_swap.h
@ -126,7 +129,8 @@ set(SRB2_CORE_RENDER_SOURCES
r_sky.c
r_splats.c
r_things.c
r_patch.c
r_textures.c
r_picformats.c
r_portal.c
r_bsp.h
@ -142,7 +146,8 @@ set(SRB2_CORE_RENDER_SOURCES
r_splats.h
r_state.h
r_things.h
r_patch.h
r_textures.h
r_picformats.h
r_portal.h
)
@ -226,6 +231,10 @@ set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support.")
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
"Enable OpenMPT support.")
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
"Enable curl support, used for downloading files via HTTP.")
set(SRB2_CONFIG_HAVE_THREADS ON CACHE BOOL
"Enable multithreading support.")
if(${CMAKE_SYSTEM} MATCHES Windows)
set(SRB2_CONFIG_HAVE_MIXERX ON CACHE BOOL
"Enable SDL Mixer X support.")
@ -258,6 +267,7 @@ set(SRB2_LUA_SOURCES
lua_mathlib.c
lua_mobjlib.c
lua_playerlib.c
lua_polyobjlib.c
lua_script.c
lua_skinlib.c
lua_thinkerlib.c
@ -445,6 +455,32 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
endif()
endif()
if(${SRB2_CONFIG_HAVE_CURL})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(CURL_FOUND ON)
set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl")
else() # 32-bit
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl")
endif()
else()
find_package(CURL)
endif()
if(${CURL_FOUND})
set(SRB2_HAVE_CURL ON)
add_definitions(-DHAVE_CURL)
else()
message(WARNING "You have specified that CURL is available but it was not found. SRB2 may not compile correctly.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_THREADS})
set(SRB2_HAVE_THREADS ON)
set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/i_threads.h)
add_definitions(-DHAVE_THREADS)
endif()
if(${SRB2_CONFIG_HWRENDER})
add_definitions(-DHWRENDER)
set(SRB2_HWRENDER_SOURCES

View file

@ -8,13 +8,11 @@
# terms of the GNU General Public License, version 2.
# See the 'LICENSE' file for more details.
#
# -DPC_DOS -> use DOS specific code (eg:textmode stuff)...
# -DLINUX -> use for the GNU/Linux specific
# -D_WINDOWS -> use for the Win32/DirectX specific
# -DHAVE_SDL -> use for the SDL interface
#
# Sets:
# Compile the DGJPP/DOS version with 'make WATTCP=1'
# Compile the DirectX/Mingw version with 'make MINGW=1'
# Compile the SDL/Mingw version with 'make MINGW=1 SDL=1'
# Compile the SDL/Linux version with 'make LINUX=1'
@ -58,10 +56,10 @@
# Compile with GCC 4.6x version, add 'GCC46=1'
# Compile a profile version, add 'PROFILEMODE=1'
# Compile a debug version, add 'DEBUGMODE=1'
# Compile with extra warnings, add 'WARNINGMODE=1'
# Compile with less warnings, add 'RELAXWARNINGS=1'
# Generate compiler errors for most compiler warnings, add 'ERRORMODE=1'
# Compile without NASM's tmap.nas, add 'NOASM=1'
# Compile without 3D hardware support, add 'NOHW=1'
# Compile without 3D sound support, add 'NOHS=1'
# Compile with GDBstubs, add 'RDB=1'
# Compile without PNG, add 'NOPNG=1'
# Compile without zlib, add 'NOZLIB=1'
@ -82,6 +80,58 @@
#
#############################################################################
ALL_SYSTEMS=\
PANDORA\
LINUX64\
MINGW64\
HAIKU\
DUMMY\
DJGPPDOS\
MINGW\
UNIX\
LINUX\
SOLARIS\
FREEBSD\
MACOSX\
SDL\
# check for user specified system
ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES)))
ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
$(info Detected a Windows system, compiling for 32-bit MinGW SDL2...)
# go for a 32-bit sdl mingw exe by default
MINGW=1
SDL=1
WINDOWSHELL=1
else # if you on the *nix
system:=$(shell uname -s)
ifeq ($(system),Linux)
new_system=LINUX
else
$(error \
Could not automatically detect your system,\
try specifying a system manually)
endif
ifeq ($(shell getconf LONG_BIT),64)
system+=64-bit
new_system:=$(new_system)64
endif
$(info Detected $(system) ($(new_system))...)
$(new_system)=1
endif
endif
# SRB2 data files
D_DIR?=../bin/Resources
D_FILES=$(D_DIR)/srb2.pk3 \
@ -121,7 +171,6 @@ NOPNG=1
NOZLIB=1
NONET=1
NOHW=1
NOHS=1
NOASM=1
NOIPX=1
EXENAME?=srb2dummy
@ -143,11 +192,6 @@ endif
ifdef PANDORA
NONX86=1
NOHW=1
NOHS=1
endif
ifdef DJGPPDOS
include djgppdos/Makefile.cfg
endif
ifndef NOOPENMPT
@ -213,6 +257,7 @@ endif
ifdef NONET
OPTS+=-DNONET
NOCURL=1
else
ifdef NO_IPV6
OPTS+=-DNO_IPV6
@ -228,13 +273,6 @@ else
$(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o
endif
ifdef NOHS
OPTS+=-DNOHS
else
OPTS+=-DHW3SOUND
OBJS+=$(OBJDIR)/hw3sound.o
endif
OPTS += -DCOMPVERSION
ifndef NONX86
@ -322,6 +360,16 @@ else
NOPNG=1
endif
ifndef NOCURL
OPTS+=-DHAVE_CURL
CURLCONFIG?=curl-config
CURL_CFLAGS?=$(shell $(CURLCONFIG) --cflags)
CURL_LDFLAGS?=$(shell $(CURLCONFIG) --libs)
LIBS+=$(CURL_LDFLAGS)
CFLAGS+=$(CURL_CFLAGS)
endif
ifdef STATIC
LIBS:=-static $(LIBS)
endif
@ -438,6 +486,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/m_fixed.o \
$(OBJDIR)/m_menu.o \
$(OBJDIR)/m_misc.o \
$(OBJDIR)/m_perfstats.o \
$(OBJDIR)/m_random.o \
$(OBJDIR)/m_queue.o \
$(OBJDIR)/info.o \
@ -469,7 +518,8 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/r_sky.o \
$(OBJDIR)/r_splats.o \
$(OBJDIR)/r_things.o \
$(OBJDIR)/r_patch.o \
$(OBJDIR)/r_textures.o \
$(OBJDIR)/r_picformats.o \
$(OBJDIR)/r_portal.o \
$(OBJDIR)/screen.o \
$(OBJDIR)/v_video.o \
@ -478,11 +528,11 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/w_wad.o \
$(OBJDIR)/filesrch.o \
$(OBJDIR)/mserv.o \
$(OBJDIR)/http-mserv.o\
$(OBJDIR)/i_tcp.o \
$(OBJDIR)/lzf.o \
$(OBJDIR)/vid_copy.o \
$(OBJDIR)/b_bot.o \
$(i_cdmus_o) \
$(i_net_o) \
$(i_system_o) \
$(i_sound_o) \
@ -498,10 +548,6 @@ POS:=$(BIN)/en.mo
OPTS+=-DGETTEXT
endif
ifdef DJGPPDOS
all: pre-build $(BIN)/$(EXENAME)
endif
ifdef PANDORA
all: pre-build $(BIN)/$(PNDNAME)
endif
@ -561,8 +607,9 @@ ifndef VALGRIND
ifndef NOOBJDUMP
@echo Dumping debugging info
$(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(EXENAME) > $(BIN)/$(DBGNAME).txt
ifdef WINDOWSHELL
-$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt
ifndef WINDOWSHELL
else
-$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt
endif
endif
@ -582,8 +629,9 @@ endif
reobjdump:
@echo Redumping debugging info
$(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(DBGNAME) > $(BIN)/$(DBGNAME).txt
ifdef WINDOWSHELL
-$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt
ifndef WINDOWSHELL
else
-$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt
endif
@ -749,19 +797,6 @@ $(OBJDIR)/ogl_win.o: hardware/r_opengl/ogl_win.c hardware/r_opengl/r_opengl.h \
$(CC) $(CFLAGS) $(WFLAGS) -D_WINDOWS -mwindows -c $< -o $@
endif
ifndef NOHS
$(OBJDIR)/s_ds3d.o: hardware/s_ds3d/s_ds3d.c hardware/hw3dsdrv.h \
hardware/hw_dll.h
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_ds3d.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_ds3d/s_ds3d.c
$(OBJDIR)/s_fmod.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \
hardware/hw_dll.h
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_fmod.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_fmod/s_fmod.c
$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \
hardware/hw_dll.h
$(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_openal.o $(WFLAGS) -D_WINDOWS -mwindows -c hardware/s_openal/s_openal.c
endif
endif
endif

View file

@ -48,7 +48,9 @@ endif
# Automatically set version flag, but not if one was manually set
ifeq (,$(filter GCC%,$(.VARIABLES)))
ifneq (,$(findstring gcc,$(shell $(CC) --version))) # if it's GCC
version:=$(shell $(CC) --version)
# check if this is in fact GCC
ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version))))
version:=$(shell $(CC) -dumpversion)
# Turn version into words of major, minor
@ -208,10 +210,7 @@ WFLAGS=-Wall
ifndef GCC295
#WFLAGS+=-Wno-packed
endif
ifdef ERRORMODE
WARNINGMODE=1
endif
ifdef WARNINGMODE
ifndef RELAXWARNINGS
WFLAGS+=-W
#WFLAGS+=-Wno-sign-compare
ifndef GCC295
@ -345,7 +344,7 @@ ifndef MINGW
ifndef MINGW64
ifndef SDL
ifndef DUMMY
DJGPPDOS=1
$(error No interface or platform flag defined)
endif
endif
endif
@ -355,7 +354,6 @@ endif
endif
#determine the interface directory (where you put all i_*.c)
i_cdmus_o=$(OBJDIR)/i_cdmus.o
i_net_o=$(OBJDIR)/i_net.o
i_system_o=$(OBJDIR)/i_system.o
i_sound_o=$(OBJDIR)/i_sound.o
@ -381,16 +379,6 @@ UPX_OPTS+=-q
endif
#Interface Setup
ifdef DJGPPDOS
INTERFACE=djgppdos
NASMFORMAT=coff
OBJDIR:=$(OBJDIR)/djgppdos
ifdef WATTCP
OBJDIR:=$(OBJDIR)/wattcp
endif
WFLAGS+=-Wno-format
BIN:=$(BIN)/Dos
else
ifdef DUMMY
INTERFACE=dummy
OBJDIR:=$(OBJDIR)/dummy
@ -449,7 +437,6 @@ endif
endif
endif
endif
endif
ifdef ARCHNAME
OBJDIR:=$(OBJDIR)/$(ARCHNAME)

View file

@ -8,8 +8,8 @@
UINT8 cdaudio_started = 0;
consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cd_volume = CVAR_INIT ("cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL);
consvar_t cdUpdate = CVAR_INIT ("cd_update","1",CV_SAVE, NULL, NULL);
void I_InitCD(void){}

View file

@ -16,7 +16,7 @@ boolean allow_fullscreen = false;
consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_vidwait = CVAR_INIT ("vid_wait", "On", CV_SAVE, CV_OnOff, NULL);
void I_StartupGraphics(void){}
void I_ShutdownGraphics(void){}

View file

@ -193,7 +193,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
{
cmd->forwardmove = pcmd->forwardmove;
cmd->sidemove = pcmd->sidemove;
if (pcmd->buttons & BT_USE)
if (pcmd->buttons & BT_SPIN)
{
spin = true;
jump = false;
@ -441,7 +441,7 @@ void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward
if (jump)
cmd->buttons |= BT_JUMP;
if (spin)
cmd->buttons |= BT_USE;
cmd->buttons |= BT_SPIN;
}
void B_MoveBlocked(player_t *player)

View file

@ -47,5 +47,6 @@ OBJS:=$(OBJS) \
$(OBJDIR)/lua_skinlib.o \
$(OBJDIR)/lua_thinkerlib.o \
$(OBJDIR)/lua_maplib.o \
$(OBJDIR)/lua_polyobjlib.o \
$(OBJDIR)/lua_blockmaplib.o \
$(OBJDIR)/lua_hudlib.o

View file

@ -19,6 +19,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include "../m_fixed.h"
/* macro to `unsign' a character */
#define uchar(c) ((unsigned char)(c))
@ -790,7 +791,7 @@ static int str_format (lua_State *L) {
case 'e': case 'E': case 'f':
case 'g': case 'G': {
lua_Number n = luaL_checknumber(L, arg);
sprintf(buff, form, (double)n);
sprintf(buff, form, (double)n / FRACUNIT);
break;
}
case 'q': {

View file

@ -322,8 +322,8 @@ static void Arith (lua_State *L, StkId ra, TValue *rb,
case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
case TM_DIV: if (nc == 0) { lua_pushliteral(L, "divide by zero error"); lua_error(L); } else setnvalue(ra, luai_numdiv(nb, nc)); break;
case TM_MOD: if (nc == 0) { lua_pushliteral(L, "modulo by zero error"); lua_error(L); } else setnvalue(ra, luai_nummod(nb, nc)); break;
case TM_DIV: if (nc == 0) { luaG_runerror(L, "divide by zero error"); } else setnvalue(ra, luai_numdiv(nb, nc)); break;
case TM_MOD: if (nc == 0) { luaG_runerror(L, "modulo by zero error"); } else setnvalue(ra, luai_nummod(nb, nc)); break;
case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
case TM_AND: setnvalue(ra, luai_numand(nb, nc)); break;
@ -492,8 +492,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
if (ttisnumber(rb) && ttisnumber(rc)) {
lua_Number nb = nvalue(rb), nc = nvalue(rc);
if (nc == 0) {
lua_pushliteral(L, "divide by zero error");
lua_error(L);
luaG_runerror(L, "divide by zero error");
}
else
setnvalue(ra, luai_numdiv(nb, nc));
@ -508,8 +507,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
if (ttisnumber(rb) && ttisnumber(rc)) {
lua_Number nb = nvalue(rb), nc = nvalue(rc);
if (nc == 0) {
lua_pushliteral(L, "modulo by zero error");
lua_error(L);
luaG_runerror(L, "modulo by zero error");
}
else
setnvalue(ra, luai_nummod(nb, nc));

View file

@ -79,7 +79,7 @@ CV_PossibleValue_t CV_Natural[] = {{1, "MIN"}, {999999999, "MAX"}, {0, NULL}};
// First implementation is 26 (2.1.21), so earlier configs default at 25 (2.1.20)
// Also set CV_HIDEN during runtime, after config is loaded
static boolean execversion_enabled = false;
consvar_t cv_execversion = {"execversion","25",CV_CALL,CV_Unsigned, CV_EnforceExecVersion, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_execversion = CVAR_INIT ("execversion","25",CV_CALL,CV_Unsigned, CV_EnforceExecVersion);
// for default joyaxis detection
static boolean joyaxis_default = false;
@ -165,6 +165,8 @@ void COM_BufAddTextEx(const char *ptext, int flags)
*/
void COM_BufInsertTextEx(const char *ptext, int flags)
{
const INT32 old_wait = com_wait;
char *temp = NULL;
size_t templen;
@ -176,10 +178,14 @@ void COM_BufInsertTextEx(const char *ptext, int flags)
VS_Clear(&com_text);
}
com_wait = 0;
// add the entire text of the file (or alias)
COM_BufAddTextEx(ptext, flags);
COM_BufExecute(); // do it right away
com_wait += old_wait;
// add the copied off data
if (templen)
{
@ -560,7 +566,7 @@ static boolean COM_Exists(const char *com_name)
* \param partial The partial name of the command (potentially).
* \param skips Number of commands to skip.
* \return The complete command name, or NULL.
* \sa CV_CompleteVar
* \sa CV_CompleteAlias, CV_CompleteVar
*/
const char *COM_CompleteCommand(const char *partial, INT32 skips)
{
@ -581,6 +587,32 @@ const char *COM_CompleteCommand(const char *partial, INT32 skips)
return NULL;
}
/** Completes the name of an alias.
*
* \param partial The partial name of the alias (potentially).
* \param skips Number of aliases to skip.
* \return The complete alias name, or NULL.
* \sa CV_CompleteCommand, CV_CompleteVar
*/
const char *COM_CompleteAlias(const char *partial, INT32 skips)
{
cmdalias_t *a;
size_t len;
len = strlen(partial);
if (!len)
return NULL;
// check functions
for (a = com_alias; a; a = a->next)
if (!strncmp(partial, a->name, len))
if (!skips--)
return a->name;
return NULL;
}
/** Parses a single line of text into arguments and tries to execute it.
* The text can come from the command buffer, a remote client, or stdin.
*
@ -875,6 +907,9 @@ static void COM_Help_f(void)
CONS_Printf(" Current value: %s\n", cvar->string);
else
CONS_Printf(" Current value: %d\n", cvar->value);
if (cvar->revert.v.string != NULL && strcmp(cvar->revert.v.string, cvar->string) != 0)
CONS_Printf(" Value before netgame: %s\n", cvar->revert.v.string);
}
else
{
@ -1201,7 +1236,7 @@ static consvar_t *CV_FindNetVar(UINT16 netid)
{
consvar_t *cvar;
if (netid >= consvar_number_of_netids)
if (netid > consvar_number_of_netids)
return NULL;
for (cvar = consvar_vars; cvar; cvar = cvar->next)
@ -1262,12 +1297,12 @@ void CV_RegisterVar(consvar_t *variable)
// check net variables
if (variable->flags & CV_NETVAR)
{
variable->netid = consvar_number_of_netids++;
/* in case of overflow... */
if (variable->netid > consvar_number_of_netids)
if (consvar_number_of_netids == UINT16_MAX)
I_Error("Way too many netvars");
variable->netid = ++consvar_number_of_netids;
#ifdef OLD22DEMOCOMPAT
CV_RegisterOldDemoVar(variable);
#endif
@ -1280,6 +1315,7 @@ void CV_RegisterVar(consvar_t *variable)
consvar_vars = variable;
}
variable->string = variable->zstring = NULL;
memset(&variable->revert, 0, sizeof variable->revert);
variable->changed = 0; // new variable has not been modified by the user
#ifdef PARANOIA
@ -1321,7 +1357,7 @@ static const char *CV_StringValue(const char *var_name)
* \param partial The partial name of the variable (potentially).
* \param skips Number of variables to skip.
* \return The complete variable name, or NULL.
* \sa COM_CompleteCommand
* \sa COM_CompleteCommand, CV_CompleteAlias
*/
const char *CV_CompleteVar(char *partial, INT32 skips)
{
@ -1392,6 +1428,18 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++)
if (v == var->PossibleValue[i].value || !stricmp(var->PossibleValue[i].strvalue, valstr))
{
if (client && execversion_enabled)
{
if (var->revert.allocated)
{
Z_Free(var->revert.v.string);
}
var->revert.v.const_munge = var->PossibleValue[i].strvalue;
return;
}
var->value = var->PossibleValue[i].value;
var->string = var->PossibleValue[i].strvalue;
goto finish;
@ -1452,12 +1500,36 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
// ...or not.
goto badinput;
found:
if (client && execversion_enabled)
{
if (var->revert.allocated)
{
Z_Free(var->revert.v.string);
}
var->revert.v.const_munge = var->PossibleValue[i].strvalue;
return;
}
var->value = var->PossibleValue[i].value;
var->string = var->PossibleValue[i].strvalue;
goto finish;
}
}
if (client && execversion_enabled)
{
if (var->revert.allocated)
{
Z_Free(var->revert.v.string);
}
var->revert.v.string = Z_StrDup(valstr);
return;
}
// free the old value string
Z_Free(var->zstring);
@ -1676,8 +1748,19 @@ static void CV_LoadVars(UINT8 **p,
serverloading = true;
for (cvar = consvar_vars; cvar; cvar = cvar->next)
{
if (cvar->flags & CV_NETVAR)
{
if (client && cvar->revert.v.string == NULL)
{
cvar->revert.v.const_munge = cvar->string;
cvar->revert.allocated = ( cvar->zstring != NULL );
cvar->zstring = NULL;/* don't free this */
}
Setvalue(cvar, cvar->defaultvalue, true);
}
}
count = READUINT16(*p);
while (count--)
@ -1691,6 +1774,26 @@ static void CV_LoadVars(UINT8 **p,
serverloading = false;
}
void CV_RevertNetVars(void)
{
consvar_t * cvar;
for (cvar = consvar_vars; cvar; cvar = cvar->next)
{
if (cvar->revert.v.string != NULL)
{
Setvalue(cvar, cvar->revert.v.string, false);
if (cvar->revert.allocated)
{
Z_Free(cvar->revert.v.string);
}
cvar->revert.v.string = NULL;
}
}
}
void CV_LoadNetVars(UINT8 **p)
{
CV_LoadVars(p, ReadNetVar);
@ -1764,6 +1867,14 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
// send the value of the variable
UINT8 buf[128];
UINT8 *p = buf;
// Loading from a config in a netgame? Set revert value.
if (client && execversion_enabled)
{
Setvalue(var, value, true);
return;
}
if (!(server || (addedtogame && IsPlayerAdmin(consoleplayer))))
{
CONS_Printf(M_GetText("Only the server or admin can change: %s %s\n"), var->name, var->string);
@ -2297,18 +2408,43 @@ void CV_SaveVariables(FILE *f)
{
char stringtowrite[MAXTEXTCMD+1];
// Silly hack for Min/Max vars
if (!strcmp(cvar->string, "MAX") || !strcmp(cvar->string, "MIN"))
const char * string;
if (cvar->revert.v.string != NULL)
{
if (cvar->flags & CV_FLOAT)
sprintf(stringtowrite, "%f", FIXED_TO_FLOAT(cvar->value));
else
sprintf(stringtowrite, "%d", cvar->value);
string = cvar->revert.v.string;
}
else
strcpy(stringtowrite, cvar->string);
{
string = cvar->string;
}
fprintf(f, "%s \"%s\"\n", cvar->name, stringtowrite);
// Silly hack for Min/Max vars
#define MINVAL 0
#define MAXVAL 1
if (
cvar->PossibleValue != NULL &&
cvar->PossibleValue[0].strvalue &&
stricmp(cvar->PossibleValue[0].strvalue, "MIN") == 0
){ // bounded cvar
int which = stricmp(string, "MAX") == 0;
if (which || stricmp(string, "MIN") == 0)
{
INT32 value = cvar->PossibleValue[which].value;
if (cvar->flags & CV_FLOAT)
sprintf(stringtowrite, "%f", FIXED_TO_FLOAT(value));
else
sprintf(stringtowrite, "%d", value);
string = stringtowrite;
}
}
#undef MINVAL
#undef MAXVAL
fprintf(f, "%s \"%s\"\n", cvar->name, string);
}
}
@ -2370,15 +2506,6 @@ skipwhite:
}
}
// parse single characters
if (c == '{' || c == '}' || c == ')' || c == '(' || c == '\'')
{
com_token[len] = c;
len++;
com_token[len] = 0;
return data + 1;
}
// parse a regular word
do
{
@ -2398,8 +2525,6 @@ skipwhite:
len++;
c = *data;
}
if (c == '{' || c == '}' || c == ')'|| c == '(' || c == '\'')
break;
} while (c > 32);
com_token[len] = 0;

View file

@ -49,6 +49,8 @@ size_t COM_FirstOption(void);
// match existing command or NULL
const char *COM_CompleteCommand(const char *partial, INT32 skips);
const char *COM_CompleteAlias(const char *partial, INT32 skips);
// insert at queu (at end of other command)
#define COM_BufAddText(s) COM_BufAddTextEx(s, 0)
void COM_BufAddTextEx(const char *btext, int flags);
@ -138,12 +140,26 @@ typedef struct consvar_s //NULL, NULL, 0, NULL, NULL |, 0, NULL, NULL, 0, 0, NUL
const char *string; // value in string
char *zstring; // Either NULL or same as string.
// If non-NULL, must be Z_Free'd later.
struct
{
char allocated; // whether to Z_Free
union
{
char * string;
const char * const_munge;
} v;
} revert; // value of netvar before joining netgame
UINT16 netid; // used internaly : netid for send end receive
// used only with CV_NETVAR
char changed; // has variable been changed by the user? 0 = no, 1 = yes
struct consvar_s *next;
} consvar_t;
/* name, defaultvalue, flags, PossibleValue, func */
#define CVAR_INIT( ... ) \
{ __VA_ARGS__, 0, NULL, NULL, {0}, 0U, (char)0, NULL }
#ifdef OLD22DEMOCOMPAT
typedef struct old_demo_var old_demo_var_t;
@ -202,6 +218,9 @@ void CV_SaveVars(UINT8 **p, boolean in_demo);
#define CV_SaveNetVars(p) CV_SaveVars(p, false)
void CV_LoadNetVars(UINT8 **p);
// then revert after leaving a netgame
void CV_RevertNetVars(void);
#define CV_SaveDemoVars(p) CV_SaveVars(p, true)
void CV_LoadDemoVars(UINT8 **p);

View file

@ -32,12 +32,14 @@
* Last updated 2020 / 05 / 11 - v2.2.4 - patch.pk3
* Last updated 2020 / 07 / 07 - v2.2.5 - player.dta & patch.pk3
* Last updated 2020 / 07 / 10 - v2.2.6 - player.dta & patch.pk3
* Last updated 2020 / 09 / 27 - v2.2.7 - patch.pk3
* Last updated 2020 / 10 / 02 - v2.2.8 - patch.pk3
*/
#define ASSET_HASH_SRB2_PK3 "0277c9416756627004e83cbb5b2e3e28"
#define ASSET_HASH_ZONES_PK3 "f7e88afb6af7996a834c7d663144bead"
#define ASSET_HASH_PLAYER_DTA "49dad7b24634c89728cc3e0b689e12bb"
#ifdef USE_PATCH_DTA
#define ASSET_HASH_PATCH_PK3 "ecf00060f03c76b3e49c6ae3925b627f"
#define ASSET_HASH_PATCH_PK3 "466cdf60075262b3f5baa5e07f0999e8"
#endif
#endif

View file

@ -29,6 +29,7 @@
#include "i_video.h"
#include "z_zone.h"
#include "i_system.h"
#include "i_threads.h"
#include "d_main.h"
#include "m_menu.h"
#include "filesrch.h"
@ -44,6 +45,16 @@
#define MAXHUDLINES 20
#ifdef HAVE_THREADS
I_mutex con_mutex;
# define Lock_state() I_lock_mutex(&con_mutex)
# define Unlock_state() I_unlock_mutex(con_mutex)
#else/*HAVE_THREADS*/
# define Lock_state()
# define Unlock_state()
#endif/*HAVE_THREADS*/
static boolean con_started = false; // console has been initialised
boolean con_startup = false; // true at game startup, screen need refreshing
static boolean con_forcepic = true; // at startup toggle console translucency when first off
@ -113,22 +124,22 @@ static void CONS_backcolor_Change(void);
static char con_buffer[CON_BUFFERSIZE];
// how many seconds the hud messages lasts on the screen
static consvar_t cons_msgtimeout = {"con_hudtime", "5", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cons_msgtimeout = CVAR_INIT ("con_hudtime", "5", CV_SAVE, CV_Unsigned, NULL);
// number of lines displayed on the HUD
static consvar_t cons_hudlines = {"con_hudlines", "5", CV_CALL|CV_SAVE, CV_Unsigned, CONS_hudlines_Change, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cons_hudlines = CVAR_INIT ("con_hudlines", "5", CV_CALL|CV_SAVE, CV_Unsigned, CONS_hudlines_Change);
// number of lines console move per frame
// (con_speed needs a limit, apparently)
static CV_PossibleValue_t speed_cons_t[] = {{0, "MIN"}, {64, "MAX"}, {0, NULL}};
static consvar_t cons_speed = {"con_speed", "8", CV_SAVE, speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cons_speed = CVAR_INIT ("con_speed", "8", CV_SAVE, speed_cons_t, NULL);
// percentage of screen height to use for console
static consvar_t cons_height = {"con_height", "50", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cons_height = CVAR_INIT ("con_height", "50", CV_SAVE, CV_Unsigned, NULL);
static CV_PossibleValue_t backpic_cons_t[] = {{0, "translucent"}, {1, "picture"}, {0, NULL}};
// whether to use console background picture, or translucent mode
static consvar_t cons_backpic = {"con_backpic", "translucent", CV_SAVE, backpic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cons_backpic = CVAR_INIT ("con_backpic", "translucent", CV_SAVE, backpic_cons_t, NULL);
static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Black"}, {2, "Sepia"},
{3, "Brown"}, {4, "Pink"}, {5, "Raspberry"},
@ -140,7 +151,7 @@ static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Black"}, {
{0, NULL}};
consvar_t cons_backcolor = {"con_backcolor", "Green", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change, 0, NULL, NULL, 0, 0, NULL};
consvar_t cons_backcolor = CVAR_INIT ("con_backcolor", "Green", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change);
static void CON_Print(char *msg);
@ -150,6 +161,8 @@ static void CONS_hudlines_Change(void)
{
INT32 i;
Lock_state();
// Clear the currently displayed lines
for (i = 0; i < con_hudlines; i++)
con_hudtime[i] = 0;
@ -161,6 +174,8 @@ static void CONS_hudlines_Change(void)
con_hudlines = cons_hudlines.value;
Unlock_state();
CONS_Printf(M_GetText("Number of console HUD lines is now %d\n"), con_hudlines);
}
@ -168,12 +183,16 @@ static void CONS_hudlines_Change(void)
//
static void CONS_Clear_f(void)
{
Lock_state();
memset(con_buffer, 0, CON_BUFFERSIZE);
con_cx = 0;
con_cy = con_totallines-1;
con_line = &con_buffer[con_cy*con_width];
con_scrollup = 0;
Unlock_state();
}
// Choose english keymap
@ -377,20 +396,29 @@ void CON_Init(void)
for (i = 0; i < NUMINPUTS; i++)
bindtable[i] = NULL;
Lock_state();
// clear all lines
memset(con_buffer, 0, CON_BUFFERSIZE);
// make sure it is ready for the loading screen
con_width = 0;
Unlock_state();
CON_RecalcSize();
CON_SetupColormaps();
Lock_state();
//note: CON_Ticker should always execute at least once before D_Display()
con_clipviewtop = -1; // -1 does not clip
con_hudlines = atoi(cons_hudlines.defaultvalue);
Unlock_state();
// setup console input filtering
CON_InputInit();
@ -399,15 +427,23 @@ void CON_Init(void)
COM_AddCommand("cls", CONS_Clear_f);
//COM_AddCommand("english", CONS_English_f);
// set console full screen for game startup MAKE SURE VID_Init() done !!!
Lock_state();
con_destlines = vid.height;
con_curlines = vid.height;
Unlock_state();
if (!dedicated)
{
Lock_state();
con_started = true;
con_startup = true; // need explicit screen refresh until we are in Doom loop
consoletoggle = false;
Unlock_state();
CV_RegisterVar(&cons_msgtimeout);
CV_RegisterVar(&cons_hudlines);
CV_RegisterVar(&cons_speed);
@ -418,19 +454,27 @@ void CON_Init(void)
}
else
{
Lock_state();
con_started = true;
con_startup = false; // need explicit screen refresh until we are in Doom loop
consoletoggle = true;
Unlock_state();
}
}
// Console input initialization
//
static void CON_InputInit(void)
{
Lock_state();
// prepare the first prompt line
memset(inputlines, 0, sizeof (inputlines));
inputline = 0;
input_cur = input_sel = input_len = 0;
Unlock_state();
}
//======================================================================
@ -446,6 +490,8 @@ static void CON_RecalcSize(void)
char *tmp_buffer;
char *string;
Lock_state();
switch (cv_constextsize.value)
{
case V_NOSCALEPATCH:
@ -483,11 +529,18 @@ static void CON_RecalcSize(void)
// check for change of video width
if (conw == con_width)
{
Unlock_state();
return; // didn't change
}
Unlock_state();
tmp_buffer = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL);
string = Z_Malloc(CON_BUFFERSIZE, PU_STATIC, NULL); // BP: it is a line but who know
Lock_state();
oldcon_width = con_width;
oldnumlines = con_totallines;
oldcon_cy = con_cy;
@ -508,6 +561,8 @@ static void CON_RecalcSize(void)
con_line = &con_buffer[con_cy*con_width];
con_scrollup = 0;
Unlock_state();
// re-arrange console text buffer to keep text
if (oldcon_width) // not the first time
{
@ -532,7 +587,11 @@ static void CON_RecalcSize(void)
static void CON_ChangeHeight(void)
{
INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4
INT32 minheight;
Lock_state();
minheight = 20 * con_scalefactor; // 20 = 8+8+4
// toggle console in
con_destlines = (cons_height.value*vid.height)/100;
@ -542,13 +601,19 @@ static void CON_ChangeHeight(void)
con_destlines = vid.height;
con_destlines &= ~0x3; // multiple of text row height
Unlock_state();
}
// Handles Console moves in/out of screen (per frame)
//
static void CON_MoveConsole(void)
{
const fixed_t conspeed = FixedDiv(cons_speed.value*vid.fdupy, FRACUNIT);
fixed_t conspeed;
Lock_state();
conspeed = FixedDiv(cons_speed.value*vid.fdupy, FRACUNIT);
// instant
if (!cons_speed.value)
@ -570,6 +635,8 @@ static void CON_MoveConsole(void)
if (con_curlines < con_destlines)
con_curlines = con_destlines;
}
Unlock_state();
}
// Clear time of console heads up messages
@ -578,16 +645,25 @@ void CON_ClearHUD(void)
{
INT32 i;
Lock_state();
for (i = 0; i < con_hudlines; i++)
con_hudtime[i] = 0;
Unlock_state();
}
// Force console to move out immediately
// note: con_ticker will set consoleready false
void CON_ToggleOff(void)
{
Lock_state();
if (!con_destlines)
{
Unlock_state();
return;
}
con_destlines = 0;
con_curlines = 0;
@ -596,11 +672,19 @@ void CON_ToggleOff(void)
con_clipviewtop = -1; // remove console clipping of view
I_UpdateMouseGrab();
Unlock_state();
}
boolean CON_Ready(void)
{
return consoleready;
boolean ready;
Lock_state();
{
ready = consoleready;
}
Unlock_state();
return ready;
}
// Console ticker: handles console move in/out, cursor blinking
@ -608,7 +692,11 @@ boolean CON_Ready(void)
void CON_Ticker(void)
{
INT32 i;
INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4
INT32 minheight;
Lock_state();
minheight = 20 * con_scalefactor; // 20 = 8+8+4
// cursor blinking
con_tick++;
@ -659,6 +747,8 @@ void CON_Ticker(void)
if (con_hudtime[i] < 0)
con_hudtime[i] = 0;
}
Unlock_state();
}
//
@ -670,32 +760,51 @@ void CON_Ticker(void)
static void CON_InputClear(void)
{
Lock_state();
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
input_cur = input_sel = input_len = 0;
Unlock_state();
}
static void CON_InputSetString(const char *c)
{
Lock_state();
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
strcpy(inputlines[inputline], c);
input_cur = input_sel = input_len = strlen(c);
Unlock_state();
}
static void CON_InputAddString(const char *c)
{
size_t csize = strlen(c);
Lock_state();
if (input_len + csize > CON_MAXPROMPTCHARS-1)
{
Unlock_state();
return;
}
if (input_cur != input_len)
memmove(&inputlines[inputline][input_cur+csize], &inputlines[inputline][input_cur], input_len-input_cur);
memcpy(&inputlines[inputline][input_cur], c, csize);
input_len += csize;
input_sel = (input_cur += csize);
Unlock_state();
}
static void CON_InputDelSelection(void)
{
size_t start, end, len;
Lock_state();
if (input_cur > input_sel)
{
start = input_sel;
@ -714,27 +823,39 @@ static void CON_InputDelSelection(void)
input_len -= len;
input_sel = input_cur = start;
Unlock_state();
}
static void CON_InputAddChar(char c)
{
if (input_len >= CON_MAXPROMPTCHARS-1)
return;
Lock_state();
if (input_cur != input_len)
memmove(&inputlines[inputline][input_cur+1], &inputlines[inputline][input_cur], input_len-input_cur);
inputlines[inputline][input_cur++] = c;
inputlines[inputline][++input_len] = 0;
input_sel = input_cur;
Unlock_state();
}
static void CON_InputDelChar(void)
{
if (!input_cur)
return;
Lock_state();
if (input_cur != input_len)
memmove(&inputlines[inputline][input_cur-1], &inputlines[inputline][input_cur], input_len-input_cur);
inputlines[inputline][--input_len] = 0;
input_sel = --input_cur;
Unlock_state();
}
//
@ -749,9 +870,14 @@ boolean CON_Responder(event_t *ev)
// sequential completions a la 4dos
static char completion[80];
static INT32 comskips, varskips;
const char *cmd = "";
static INT32 skips;
static INT32 com_skips;
static INT32 var_skips;
static INT32 alias_skips;
const char *cmd = NULL;
INT32 key;
if (chat_on)
@ -835,6 +961,44 @@ boolean CON_Responder(event_t *ev)
return true;
}
// backspace and delete command prompt
if (input_sel != input_cur)
{
if (key == KEY_BACKSPACE || key == KEY_DEL)
{
CON_InputDelSelection();
return true;
}
}
else if (key == KEY_BACKSPACE)
{
if (ctrldown)
{
input_sel = M_JumpWordReverse(inputlines[inputline], input_cur);
CON_InputDelSelection();
}
else
CON_InputDelChar();
return true;
}
else if (key == KEY_DEL)
{
if (input_cur == input_len)
return true;
if (ctrldown)
{
input_sel = input_cur + M_JumpWord(&inputlines[inputline][input_cur]);
CON_InputDelSelection();
}
else
{
++input_cur;
CON_InputDelChar();
}
return true;
}
// ctrl modifier -- changes behavior, adds shortcuts
if (ctrldown)
{
@ -848,7 +1012,6 @@ boolean CON_Responder(event_t *ev)
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
return true;
strcpy(completion, inputlines[inputline]);
comskips = varskips = 0;
}
len = strlen(completion);
@ -864,6 +1027,14 @@ boolean CON_Responder(event_t *ev)
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
//and finally aliases
CONS_Printf("Aliases:\n");
for (i = 0, cmd = COM_CompleteAlias(completion, i); cmd; cmd = COM_CompleteAlias(completion, ++i))
CONS_Printf(" \x83" "%s" "\x80" "%s\n", completion, cmd+len);
if (i == 0) CONS_Printf(" (none)\n");
completion[0] = 0;
return true;
}
// ---
@ -932,43 +1103,64 @@ boolean CON_Responder(event_t *ev)
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
return true;
strcpy(completion, inputlines[inputline]);
comskips = varskips = 0;
skips = 0;
com_skips = 0;
var_skips = 0;
alias_skips = 0;
}
else
{
if (shiftdown)
{
if (comskips < 0)
{
if (--varskips < 0)
comskips = -comskips - 2;
}
else if (comskips > 0) comskips--;
if (skips > 0)
skips--;
}
else
{
if (comskips < 0) varskips++;
else comskips++;
skips++;
}
}
if (comskips >= 0)
if (skips <= com_skips)
{
cmd = COM_CompleteCommand(completion, comskips);
if (!cmd) // dirty: make sure if comskips is zero, to have a neg value
comskips = -comskips - 1;
cmd = COM_CompleteCommand(completion, skips);
if (cmd && skips == com_skips)
{
com_skips ++;
var_skips ++;
alias_skips++;
}
}
if (!cmd && skips <= var_skips)
{
cmd = CV_CompleteVar(completion, skips - com_skips);
if (cmd && skips == var_skips)
{
var_skips ++;
alias_skips++;
}
}
if (!cmd && skips <= alias_skips)
{
cmd = COM_CompleteAlias(completion, skips - var_skips);
if (cmd && skips == alias_skips)
{
alias_skips++;
}
}
if (comskips < 0)
cmd = CV_CompleteVar(completion, varskips);
if (cmd)
{
CON_InputSetString(va("%s ", cmd));
}
else
{
if (comskips > 0)
comskips--;
else if (varskips > 0)
varskips--;
skips--;
}
return true;
@ -1025,29 +1217,6 @@ boolean CON_Responder(event_t *ev)
return true;
}
// backspace and delete command prompt
if (input_sel != input_cur)
{
if (key == KEY_BACKSPACE || key == KEY_DEL)
{
CON_InputDelSelection();
return true;
}
}
else if (key == KEY_BACKSPACE)
{
CON_InputDelChar();
return true;
}
else if (key == KEY_DEL)
{
if (input_cur == input_len)
return true;
++input_cur;
CON_InputDelChar();
return true;
}
// move back in input history
if (key == KEY_UPARROW)
{
@ -1153,6 +1322,8 @@ static void CON_Print(char *msg)
S_StartSound(NULL, sfx_radio);
}
Lock_state();
if (!(*msg & 0x80))
{
con_line[con_cx++] = '\x80';
@ -1213,7 +1384,10 @@ static void CON_Print(char *msg)
}
if (*msg == '\0')
{
Unlock_state();
return;
}
// printable character
for (l = 0; l < (con_width-11) && msg[l] > ' '; l++)
@ -1231,6 +1405,8 @@ static void CON_Print(char *msg)
for (; l > 0; l--)
con_line[con_cx++] = *(msg++);
}
Unlock_state();
}
void CON_LogMessage(const char *msg)
@ -1262,6 +1438,7 @@ void CONS_Printf(const char *fmt, ...)
{
va_list argptr;
static char *txt = NULL;
boolean startup;
if (txt == NULL)
txt = malloc(8192);
@ -1273,27 +1450,22 @@ void CONS_Printf(const char *fmt, ...)
// echo console prints to log file
DEBFILE(txt);
if (!con_started)
{
#ifdef PC_DOS
CON_LogMessage(txt);
free(txt);
return;
#endif
}
else
// write message in con text buffer
// write message in con text buffer
if (con_started)
CON_Print(txt);
#ifndef PC_DOS
CON_LogMessage(txt);
#endif
CON_LogMessage(txt);
Lock_state();
// make sure new text is visible
con_scrollup = 0;
startup = con_startup;
Unlock_state();
// if not in display loop, force screen update
if (con_startup && (!setrenderneeded))
if (startup && (!setrenderneeded))
{
#ifdef _WINDOWS
patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH);
@ -1538,8 +1710,12 @@ static void CON_DrawBackpic(void)
lumpnum_t piclump;
int x, w, h;
// Get the lumpnum for CONSBACK, or fallback into MISSING.
piclump = W_CheckNumForName("CONSBACK");
// Get the lumpnum for CONSBACK, STARTUP (Only during game startup) or fallback into MISSING.
if (con_startup)
piclump = W_CheckNumForName("STARTUP");
else
piclump = W_CheckNumForName("CONSBACK");
if (piclump == LUMPERROR)
piclump = W_GetNumForName("MISSING");
@ -1645,8 +1821,13 @@ static void CON_DrawConsole(void)
//
void CON_Drawer(void)
{
Lock_state();
if (!con_started || !graphics_started)
{
Unlock_state();
return;
}
if (needpatchrecache)
HU_LoadGraphics();
@ -1664,4 +1845,6 @@ void CON_Drawer(void)
|| gamestate == GS_INTERMISSION || gamestate == GS_ENDING || gamestate == GS_CUTSCENE
|| gamestate == GS_CREDITS || gamestate == GS_EVALUATION)
CON_DrawHudlines();
Unlock_state();
}

View file

@ -12,11 +12,16 @@
#include "d_event.h"
#include "command.h"
#include "i_threads.h"
void CON_Init(void);
boolean CON_Responder(event_t *ev);
#ifdef HAVE_THREADS
extern I_mutex con_mutex;
#endif
// set true when screen size has changed, to adapt console
extern boolean con_recalc;

View file

@ -44,6 +44,7 @@
#include "lua_script.h"
#include "lua_hook.h"
#include "md5.h"
#include "m_perfstats.h"
#ifndef NONET
// cl loading screen
@ -157,10 +158,10 @@ ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL};
consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showjoinaddress = CVAR_INIT ("showjoinaddress", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}};
consvar_t cv_playbackspeed = {"playbackspeed", "1", 0, playbackspeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL);
static inline void *G_DcpyTiccmd(void* dest, const ticcmd_t* src, const size_t n)
{
@ -1269,19 +1270,25 @@ static UINT8 Snake_GetOppositeDir(UINT8 dir)
return 12 + 5 - dir;
}
static void Snake_FindFreeSlot(UINT8 *x, UINT8 *y, UINT8 headx, UINT8 heady)
static void Snake_FindFreeSlot(UINT8 *freex, UINT8 *freey, UINT8 headx, UINT8 heady)
{
UINT8 x, y;
UINT16 i;
do
{
*x = M_RandomKey(SNAKE_NUM_BLOCKS_X);
*y = M_RandomKey(SNAKE_NUM_BLOCKS_Y);
x = M_RandomKey(SNAKE_NUM_BLOCKS_X);
y = M_RandomKey(SNAKE_NUM_BLOCKS_Y);
for (i = 0; i < snake->snakelength; i++)
if (*x == snake->snakex[i] && *y == snake->snakey[i])
if (x == snake->snakex[i] && y == snake->snakey[i])
break;
} while (i < snake->snakelength || (*x == headx && *y == heady));
} while (i < snake->snakelength || (x == headx && y == heady)
|| (x == snake->applex && y == snake->appley)
|| (snake->bonustype != SNAKE_BONUS_NONE && x == snake->bonusx && y == snake->bonusy));
*freex = x;
*freey = y;
}
static void Snake_Handle(void)
@ -1412,7 +1419,7 @@ static void Snake_Handle(void)
// Check collision with apple
if (x == snake->applex && y == snake->appley)
{
if (snake->snakelength + 1 < SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y)
if (snake->snakelength + 3 < SNAKE_NUM_BLOCKS_X * SNAKE_NUM_BLOCKS_Y)
{
snake->snakelength++;
snake->snakex [snake->snakelength - 1] = snake->snakex [snake->snakelength - 2];
@ -2113,7 +2120,7 @@ static void SV_SendSaveGame(INT32 node)
#ifdef DUMPCONSISTENCY
#define TMPSAVENAME "badmath.sav"
static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cv_dumpconsistency = CVAR_INIT ("dumpconsistency", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
static void SV_SavedGame(void)
{
@ -2228,7 +2235,7 @@ static void CL_LoadReceivedSavegame(void)
#endif
#ifndef NONET
static void SendAskInfo(INT32 node, boolean viams)
static void SendAskInfo(INT32 node)
{
const tic_t asktime = I_GetTime();
netbuffer->packettype = PT_ASKINFO;
@ -2239,10 +2246,6 @@ static void SendAskInfo(INT32 node, boolean viams)
// now allowed traffic from the host to us in, so once the MS relays
// our address to the host, it'll be able to speak to us.
HSendPacket(node, false, 0, sizeof (askinfo_pak));
// Also speak to the MS.
if (viams && node != 0 && node != BROADCASTADDR)
SendAskInfoViaMS(node, asktime);
}
serverelem_t serverlist[MAXSERVERLIST];
@ -2310,13 +2313,95 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
M_SortServerList();
}
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
struct Fetch_servers_ctx
{
int room;
int id;
};
static void
Fetch_servers_thread (struct Fetch_servers_ctx *ctx)
{
msg_server_t *server_list;
server_list = GetShortServersList(ctx->room, ctx->id);
if (server_list)
{
I_lock_mutex(&ms_QueryId_mutex);
{
if (ctx->id != ms_QueryId)
{
free(server_list);
server_list = NULL;
}
}
I_unlock_mutex(ms_QueryId_mutex);
if (server_list)
{
I_lock_mutex(&m_menu_mutex);
{
if (m_waiting_mode == M_WAITING_SERVERS)
m_waiting_mode = M_NOT_WAITING;
}
I_unlock_mutex(m_menu_mutex);
I_lock_mutex(&ms_ServerList_mutex);
{
ms_ServerList = server_list;
}
I_unlock_mutex(ms_ServerList_mutex);
}
}
free(ctx);
}
#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
void CL_QueryServerList (msg_server_t *server_list)
{
INT32 i;
for (i = 0; server_list[i].header.buffer[0]; i++)
{
// Make sure MS version matches our own, to
// thwart nefarious servers who lie to the MS.
/* lol bruh, that version COMES from the servers */
//if (strcmp(version, server_list[i].version) == 0)
{
INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port);
if (node == -1)
break; // no more node free
SendAskInfo(node);
// Force close the connection so that servers can't eat
// up nodes forever if we never get a reply back from them
// (usually when they've not forwarded their ports).
//
// Don't worry, we'll get in contact with the working
// servers again when they send SERVERINFO to us later!
//
// (Note: as a side effect this probably means every
// server in the list will probably be using the same node (e.g. node 1),
// not that it matters which nodes they use when
// the connections are closed afterwards anyway)
// -- Monster Iestyn 12/11/18
Net_CloseConnection(node|FORCECLOSE);
}
}
}
void CL_UpdateServerList(boolean internetsearch, INT32 room)
{
(void)internetsearch;
(void)room;
SL_ClearServerList(0);
if (!netgame && I_NetOpenSocket)
{
MSCloseUDPSocket(); // Tidy up before wiping the slate.
if (I_NetOpenSocket())
{
netgame = true;
@ -2326,71 +2411,54 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
// search for local servers
if (netgame)
SendAskInfo(BROADCASTADDR, false);
SendAskInfo(BROADCASTADDR);
#ifdef MASTERSERVER
if (internetsearch)
{
const msg_server_t *server_list;
INT32 i = -1;
server_list = GetShortServersList(room);
#ifdef HAVE_THREADS
struct Fetch_servers_ctx *ctx;
ctx = malloc(sizeof *ctx);
/* This called from M_Refresh so I don't use a mutex */
m_waiting_mode = M_WAITING_SERVERS;
I_lock_mutex(&ms_QueryId_mutex);
{
ctx->id = ms_QueryId;
}
I_unlock_mutex(ms_QueryId_mutex);
ctx->room = room;
I_spawn_thread("fetch-servers", (I_thread_fn)Fetch_servers_thread, ctx);
#else
msg_server_t *server_list;
server_list = GetShortServersList(room, 0);
if (server_list)
{
char version[8] = "";
#ifndef DEVELOP
strcpy(version, SRB2VERSION);
#else
strcpy(version, GetRevisionString());
CL_QueryServerList(server_list);
free(server_list);
}
#endif
version[sizeof (version) - 1] = '\0';
for (i = 0; server_list[i].header.buffer[0]; i++)
{
// Make sure MS version matches our own, to
// thwart nefarious servers who lie to the MS.
if (strcmp(version, server_list[i].version) == 0)
{
INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port);
if (node == -1)
break; // no more node free
SendAskInfo(node, true);
// Force close the connection so that servers can't eat
// up nodes forever if we never get a reply back from them
// (usually when they've not forwarded their ports).
//
// Don't worry, we'll get in contact with the working
// servers again when they send SERVERINFO to us later!
//
// (Note: as a side effect this probably means every
// server in the list will probably be using the same node (e.g. node 1),
// not that it matters which nodes they use when
// the connections are closed afterwards anyway)
// -- Monster Iestyn 12/11/18
Net_CloseConnection(node|FORCECLOSE);
}
}
}
//no server list?(-1) or no servers?(0)
if (!i)
{
; /// TODO: display error or warning?
}
}
#endif/*MASTERSERVER*/
}
#endif // ifndef NONET
/** Called by CL_ServerConnectionTicker
*
* \param viams ???
* \param asksent ???
* \param asksent The last time we asked the server to join. We re-ask every second in case our request got lost in transmit.
* \return False if the connection was aborted
* \sa CL_ServerConnectionTicker
* \sa CL_ConnectToServer
*
*/
static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
{
#ifndef NONET
INT32 i;
@ -2452,11 +2520,11 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
CL_Reset();
D_StartTitle();
M_StartMessage(M_GetText(
"You have WAD files loaded or have\n"
"modified the game in some way, and\n"
"your file list does not match\n"
"the server's file list.\n"
"Please restart SRB2 before connecting.\n\n"
"You have the wrong addons loaded.\n\n"
"To play on this server, restart\n"
"the game and don't load any addons.\n"
"SRB2 will automatically add\n"
"everything you need when you join.\n\n"
"Press ESC\n"
), NULL, MM_NOTHING);
return false;
@ -2501,11 +2569,10 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
// Ask the info to the server (askinfo packet)
if (*asksent + NEWTICRATE < I_GetTime())
{
SendAskInfo(servernode, viams);
SendAskInfo(servernode);
*asksent = I_GetTime();
}
#else
(void)viams;
(void)asksent;
// No netgames, so we skip this state.
cl_mode = CL_ASKJOIN;
@ -2516,7 +2583,6 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
/** Called by CL_ConnectToServer
*
* \param viams ???
* \param tmpsave The name of the gamestate file???
* \param oldtic Used for knowing when to poll events and redraw
* \param asksent ???
@ -2525,7 +2591,7 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent)
* \sa CL_ConnectToServer
*
*/
static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic_t *oldtic, tic_t *asksent)
static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic_t *asksent)
{
boolean waitmore;
INT32 i;
@ -2537,7 +2603,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic
switch (cl_mode)
{
case CL_SEARCHING:
if (!CL_ServerConnectionSearchTicker(viams, asksent))
if (!CL_ServerConnectionSearchTicker(asksent))
return false;
break;
@ -2673,11 +2739,10 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic
/** Use adaptive send using net_bandwidth and stat.sendbytes
*
* \param viams ???
* \todo Better description...
*
*/
static void CL_ConnectToServer(boolean viams)
static void CL_ConnectToServer(void)
{
INT32 pnumnodes, nodewaited = doomcom->numnodes, i;
tic_t oldtic;
@ -2737,9 +2802,9 @@ static void CL_ConnectToServer(boolean viams)
{
// If the connection was aborted for some reason, leave
#ifndef NONET
if (!CL_ServerConnectionTicker(viams, tmpsave, &oldtic, &asksent))
if (!CL_ServerConnectionTicker(tmpsave, &oldtic, &asksent))
#else
if (!CL_ServerConnectionTicker(viams, (char*)NULL, &oldtic, (tic_t *)NULL))
if (!CL_ServerConnectionTicker((char*)NULL, &oldtic, (tic_t *)NULL))
#endif
return;
@ -2916,9 +2981,6 @@ static void Command_ReloadBan(void) //recheck ban.txt
static void Command_connect(void)
{
// Assume we connect directly.
boolean viams = false;
if (COM_Argc() < 2 || *COM_Argv(1) == 0)
{
CONS_Printf(M_GetText(
@ -2954,9 +3016,6 @@ static void Command_connect(void)
if (netgame && !stricmp(COM_Argv(1), "node"))
{
servernode = (SINT8)atoi(COM_Argv(2));
// Use MS to traverse NAT firewalls.
viams = true;
}
else if (netgame)
{
@ -2965,7 +3024,6 @@ static void Command_connect(void)
}
else if (I_NetOpenSocket)
{
MSCloseUDPSocket(); // Tidy up before wiping the slate.
I_NetOpenSocket();
netgame = true;
multiplayer = true;
@ -2994,7 +3052,7 @@ static void Command_connect(void)
SplitScreen_OnChange();
botingame = false;
botskin = 0;
CL_ConnectToServer(viams);
CL_ConnectToServer();
}
#endif
@ -3110,6 +3168,8 @@ static void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
// Reset the name
sprintf(player_names[playernum], "Player %d", playernum+1);
player_name_changes[playernum] = 0;
if (IsPlayerAdmin(playernum))
{
RemoveAdminPlayer(playernum); // don't stay admin after you're gone
@ -3149,6 +3209,7 @@ void CL_Reset(void)
doomcom->numslots = 1;
SV_StopServer();
SV_ResetServer();
CV_RevertNetVars();
// make sure we don't leave any fileneeded gunk over from a failed join
fileneedednum = 0;
@ -3616,29 +3677,29 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
}
static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}};
consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_netticbuffer = CVAR_INIT ("netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL);
consvar_t cv_allownewplayer = {"allowjoin", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL };
consvar_t cv_joinnextround = {"joinnextround", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done
consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_joinnextround = CVAR_INIT ("joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); /// \todo not done
static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}};
consvar_t cv_maxplayers = {"maxplayers", "8", CV_SAVE, maxplayers_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE|CV_NETVAR, maxplayers_cons_t, NULL);
static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}};
consvar_t cv_joindelay = {"joindelay", "10", CV_SAVE, joindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE|CV_NETVAR, joindelay_cons_t, NULL);
static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}};
consvar_t cv_rejointimeout = {"rejointimeout", "Off", CV_SAVE|CV_FLOAT, rejointimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "Off", CV_SAVE|CV_NETVAR|CV_FLOAT, rejointimeout_cons_t, NULL);
static CV_PossibleValue_t resynchattempts_cons_t[] = {{1, "MIN"}, {20, "MAX"}, {0, "No"}, {0, NULL}};
consvar_t cv_resynchattempts = {"resynchattempts", "10", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL };
consvar_t cv_blamecfail = {"blamecfail", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL };
consvar_t cv_resynchattempts = CVAR_INIT ("resynchattempts", "10", CV_SAVE|CV_NETVAR, resynchattempts_cons_t, NULL);
consvar_t cv_blamecfail = CVAR_INIT ("blamecfail", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
// max file size to send to a player (in kilobytes)
static CV_PossibleValue_t maxsend_cons_t[] = {{0, "MIN"}, {51200, "MAX"}, {0, NULL}};
consvar_t cv_maxsend = {"maxsend", "4096", CV_SAVE, maxsend_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_noticedownload = {"noticedownload", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE|CV_NETVAR, maxsend_cons_t, NULL);
consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
// Speed of file downloading (in packets per tic)
static CV_PossibleValue_t downloadspeed_cons_t[] = {{0, "MIN"}, {32, "MAX"}, {0, NULL}};
consvar_t cv_downloadspeed = {"downloadspeed", "16", CV_SAVE, downloadspeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_downloadspeed = CVAR_INIT ("downloadspeed", "16", CV_SAVE|CV_NETVAR, downloadspeed_cons_t, NULL);
static void Got_AddPlayer(UINT8 **p, INT32 playernum);
@ -3726,6 +3787,8 @@ void SV_ResetServer(void)
adminplayers[i] = -1; // Populate the entire adminplayers array with -1.
}
memset(player_name_changes, 0, sizeof player_name_changes);
mynode = 0;
cl_packetmissed = false;
@ -3791,8 +3854,10 @@ void D_QuitNetGame(void)
for (i = 0; i < MAXNETNODES; i++)
if (nodeingame[i])
HSendPacket(i, true, 0, 0);
#ifdef MASTERSERVER
if (serverrunning && ms_RoomId > 0)
UnregisterServer();
#endif
}
else if (servernode > 0 && servernode < MAXNETNODES && nodeingame[(UINT8)servernode])
{
@ -4055,15 +4120,16 @@ boolean SV_SpawnServer(void)
SV_GenContext();
if (netgame && I_NetOpenSocket)
{
MSCloseUDPSocket(); // Tidy up before wiping the slate.
I_NetOpenSocket();
#ifdef MASTERSERVER
if (ms_RoomId > 0)
RegisterServer();
#endif
}
// non dedicated server just connect to itself
if (!dedicated)
CL_ConnectToServer(false);
CL_ConnectToServer();
else doomcom->numslots = 1;
}
@ -5379,11 +5445,15 @@ void TryRunTics(tic_t realtics)
{
DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic));
ps_tictime = I_GetTimeMicros();
G_Ticker((gametic % NEWTICRATERATIO) == 0);
ExtraDataTicker();
gametic++;
consistancy[gametic%BACKUPTICS] = Consistancy();
ps_tictime = I_GetTimeMicros() - ps_tictime;
// Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame.
if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value)
break;
@ -5520,7 +5590,9 @@ void NetUpdate(void)
// client send the command after a receive of the server
// the server send before because in single player is beter
#ifdef MASTERSERVER
MasterClient_Ticker(); // Acking the Master Server
#endif
if (client)
{
@ -5539,8 +5611,13 @@ void NetUpdate(void)
firstticstosend = gametic;
for (i = 0; i < MAXNETNODES; i++)
if (nodeingame[i] && nettics[i] < firstticstosend)
{
firstticstosend = nettics[i];
if (maketic + 1 >= nettics[i] + BACKUPTICS)
Net_ConnectionTimeout(i);
}
// Don't erase tics not acknowledged
counts = realtics;
@ -5595,7 +5672,13 @@ void NetUpdate(void)
if (nowtime > resptime)
{
resptime = nowtime;
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
M_Ticker();
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
CON_Ticker();
}

View file

@ -14,10 +14,12 @@
#define __D_CLISRV__
#include "d_ticcmd.h"
#include "d_net.h"
#include "d_netcmd.h"
#include "d_net.h"
#include "tables.h"
#include "d_player.h"
#include "mserv.h"
/*
The 'packet version' is used to distinguish packet formats.
@ -483,7 +485,7 @@ typedef struct
#pragma pack()
#endif
#define MAXSERVERLIST 64 // Depends only on the display
#define MAXSERVERLIST (MAXNETNODES-1)
typedef struct
{
SINT8 node;
@ -525,7 +527,12 @@ typedef enum
} kickreason_t;
/* the max number of name changes in some time period */
#define MAXNAMECHANGES (5)
#define NAMECHANGERATE (60*TICRATE)
extern boolean server;
extern boolean serverrunning;
#define client (!server)
extern boolean dedicated; // For dedicated server
extern UINT16 software_MAXPACKETLENGTH;
@ -565,6 +572,7 @@ void CL_AddSplitscreenPlayer(void);
void CL_RemoveSplitscreenPlayer(void);
void CL_Reset(void);
void CL_ClearPlayer(INT32 playernum);
void CL_QueryServerList(msg_server_t *list);
void CL_UpdateServerList(boolean internetsearch, INT32 room);
// Is there a game running
boolean Playing(void);

View file

@ -24,12 +24,6 @@
#include <unistd.h> // for getcwd
#endif
#ifdef PC_DOS
#include <stdio.h> // for snprintf
int snprintf(char *str, size_t n, const char *fmt, ...);
//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
#endif
#ifdef _WIN32
#include <direct.h>
#include <malloc.h>
@ -46,6 +40,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "hu_stuff.h"
#include "i_sound.h"
#include "i_system.h"
#include "i_threads.h"
#include "i_video.h"
#include "m_argv.h"
#include "m_menu.h"
@ -72,6 +67,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "keys.h"
#include "filesrch.h" // refreshdirmenu, mainwadstally
#include "g_input.h" // tutorial mode control scheming
#include "m_perfstats.h"
#ifdef CMAKECONFIG
#include "config.h"
@ -104,6 +100,7 @@ UINT8 window_notinfocus = false;
// DEMO LOOP
//
static char *startupwadfiles[MAX_WADFILES];
static char *startuppwads[MAX_WADFILES];
boolean devparm = false; // started game with -devparm
@ -162,10 +159,6 @@ void D_PostEvent(const event_t *ev)
events[eventhead] = *ev;
eventhead = (eventhead+1) & (MAXEVENTS-1);
}
// just for lock this function
#if defined (PC_DOS) && !defined (DOXYGEN)
void D_PostEvent_end(void) {};
#endif
// modifier keys
// Now handled in I_OsPolling
@ -182,6 +175,8 @@ void D_ProcessEvents(void)
{
event_t *ev;
boolean eaten;
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
{
ev = &events[eventtail];
@ -197,11 +192,31 @@ void D_ProcessEvents(void)
}
// Menu input
if (M_Responder(ev))
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
{
eaten = M_Responder(ev);
}
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
if (eaten)
continue; // menu ate the event
// console input
if (CON_Responder(ev))
#ifdef HAVE_THREADS
I_lock_mutex(&con_mutex);
#endif
{
eaten = CON_Responder(ev);
}
#ifdef HAVE_THREADS
I_unlock_mutex(con_mutex);
#endif
if (eaten)
continue; // ate the event
G_Responder(ev);
@ -421,7 +436,7 @@ static void D_Display(void)
if (!automapactive && !dedicated && cv_renderview.value)
{
rs_rendercalltime = I_GetTimeMicros();
ps_rendercalltime = I_GetTimeMicros();
if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD)
{
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
@ -468,7 +483,7 @@ static void D_Display(void)
if (postimgtype2)
V_DoPostProcessor(1, postimgtype2, postimgparam2);
}
rs_rendercalltime = I_GetTimeMicros() - rs_rendercalltime;
ps_rendercalltime = I_GetTimeMicros() - ps_rendercalltime;
}
if (lastdraw)
@ -482,6 +497,8 @@ static void D_Display(void)
lastdraw = false;
}
ps_uitime = I_GetTimeMicros();
if (gamestate == GS_LEVEL)
{
ST_Drawer();
@ -491,6 +508,10 @@ static void D_Display(void)
else
F_TitleScreenDrawer();
}
else
{
ps_uitime = I_GetTimeMicros();
}
}
// change gamma if needed
@ -520,11 +541,19 @@ static void D_Display(void)
// vid size change is now finished if it was on...
vid.recalc = 0;
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
M_Drawer(); // menu is drawn even on top of everything
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
// focus lost moved to M_Drawer
CON_Drawer();
ps_uitime = I_GetTimeMicros() - ps_uitime;
//
// wipe update
//
@ -604,80 +633,14 @@ static void D_Display(void)
V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-10, V_YELLOWMAP, s);
}
if (cv_renderstats.value)
if (cv_perfstats.value)
{
char s[50];
int frametime = I_GetTimeMicros() - rs_prevframetime;
int divisor = 1;
rs_prevframetime = I_GetTimeMicros();
if (rs_rendercalltime > 10000) divisor = 1000;
snprintf(s, sizeof s - 1, "ft %d", frametime / divisor);
V_DrawThinString(30, 10, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "rtot %d", rs_rendercalltime / divisor);
V_DrawThinString(30, 20, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "bsp %d", rs_bsptime / divisor);
V_DrawThinString(30, 30, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "nbsp %d", rs_numbspcalls);
V_DrawThinString(80, 10, V_MONOSPACE | V_BLUEMAP, s);
snprintf(s, sizeof s - 1, "nspr %d", rs_numsprites);
V_DrawThinString(80, 20, V_MONOSPACE | V_BLUEMAP, s);
snprintf(s, sizeof s - 1, "nnod %d", rs_numdrawnodes);
V_DrawThinString(80, 30, V_MONOSPACE | V_BLUEMAP, s);
snprintf(s, sizeof s - 1, "npob %d", rs_numpolyobjects);
V_DrawThinString(80, 40, V_MONOSPACE | V_BLUEMAP, s);
if (rendermode == render_opengl) // OpenGL specific stats
{
snprintf(s, sizeof s - 1, "nsrt %d", rs_hw_nodesorttime / divisor);
V_DrawThinString(30, 40, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "ndrw %d", rs_hw_nodedrawtime / divisor);
V_DrawThinString(30, 50, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "ssrt %d", rs_hw_spritesorttime / divisor);
V_DrawThinString(30, 60, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "sdrw %d", rs_hw_spritedrawtime / divisor);
V_DrawThinString(30, 70, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "fin %d", rs_swaptime / divisor);
V_DrawThinString(30, 80, V_MONOSPACE | V_YELLOWMAP, s);
if (cv_glbatching.value)
{
snprintf(s, sizeof s - 1, "bsrt %d", rs_hw_batchsorttime / divisor);
V_DrawThinString(80, 55, V_MONOSPACE | V_REDMAP, s);
snprintf(s, sizeof s - 1, "bdrw %d", rs_hw_batchdrawtime / divisor);
V_DrawThinString(80, 65, V_MONOSPACE | V_REDMAP, s);
snprintf(s, sizeof s - 1, "npol %d", rs_hw_numpolys);
V_DrawThinString(130, 10, V_MONOSPACE | V_PURPLEMAP, s);
snprintf(s, sizeof s - 1, "ndc %d", rs_hw_numcalls);
V_DrawThinString(130, 20, V_MONOSPACE | V_PURPLEMAP, s);
snprintf(s, sizeof s - 1, "nshd %d", rs_hw_numshaders);
V_DrawThinString(130, 30, V_MONOSPACE | V_PURPLEMAP, s);
snprintf(s, sizeof s - 1, "nvrt %d", rs_hw_numverts);
V_DrawThinString(130, 40, V_MONOSPACE | V_PURPLEMAP, s);
snprintf(s, sizeof s - 1, "ntex %d", rs_hw_numtextures);
V_DrawThinString(185, 10, V_MONOSPACE | V_PURPLEMAP, s);
snprintf(s, sizeof s - 1, "npf %d", rs_hw_numpolyflags);
V_DrawThinString(185, 20, V_MONOSPACE | V_PURPLEMAP, s);
snprintf(s, sizeof s - 1, "ncol %d", rs_hw_numcolors);
V_DrawThinString(185, 30, V_MONOSPACE | V_PURPLEMAP, s);
}
}
else // software specific stats
{
snprintf(s, sizeof s - 1, "prtl %d", rs_sw_portaltime / divisor);
V_DrawThinString(30, 40, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "plns %d", rs_sw_planetime / divisor);
V_DrawThinString(30, 50, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "mskd %d", rs_sw_maskedtime / divisor);
V_DrawThinString(30, 60, V_MONOSPACE | V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "fin %d", rs_swaptime / divisor);
V_DrawThinString(30, 70, V_MONOSPACE | V_YELLOWMAP, s);
}
M_DrawPerfStats();
}
rs_swaptime = I_GetTimeMicros();
ps_swaptime = I_GetTimeMicros();
I_FinishUpdate(); // page flip or blit buffer
rs_swaptime = I_GetTimeMicros() - rs_swaptime;
ps_swaptime = I_GetTimeMicros() - ps_swaptime;
}
needpatchflush = false;
@ -710,6 +673,7 @@ tic_t rendergametic;
void D_SRB2Loop(void)
{
tic_t oldentertics = 0, entertic = 0, realtics = 0, rendertimeout = INFTICS;
static lumpnum_t gstartuplumpnum;
if (dedicated)
server = true;
@ -749,7 +713,12 @@ void D_SRB2Loop(void)
*/
/* Smells like a hack... Don't fade Sonic's ass into the title screen. */
if (gamestate != GS_TITLESCREEN)
V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(W_GetNumForName("CONSBACK"), PU_PATCH));
{
gstartuplumpnum = W_CheckNumForName("STARTUP");
if (gstartuplumpnum == LUMPERROR)
gstartuplumpnum = W_GetNumForName("MISSING");
V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(gstartuplumpnum, PU_PATCH));
}
for (;;)
{
@ -825,9 +794,6 @@ void D_SRB2Loop(void)
S_UpdateSounds(); // move positional sounds
S_UpdateClosedCaptions();
// check for media change, loop music..
I_UpdateCD();
#ifdef HW3SOUND
HW3S_EndFrameUpdate();
#endif
@ -937,12 +903,12 @@ void D_StartTitle(void)
//
// D_AddFile
//
static void D_AddFile(const char *file)
static void D_AddFile(char **list, const char *file)
{
size_t pnumwadfiles;
char *newfile;
for (pnumwadfiles = 0; startupwadfiles[pnumwadfiles]; pnumwadfiles++)
for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++)
;
newfile = malloc(strlen(file) + 1);
@ -952,16 +918,16 @@ static void D_AddFile(const char *file)
}
strcpy(newfile, file);
startupwadfiles[pnumwadfiles] = newfile;
list[pnumwadfiles] = newfile;
}
static inline void D_CleanFile(void)
static inline void D_CleanFile(char **list)
{
size_t pnumwadfiles;
for (pnumwadfiles = 0; startupwadfiles[pnumwadfiles]; pnumwadfiles++)
for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++)
{
free(startupwadfiles[pnumwadfiles]);
startupwadfiles[pnumwadfiles] = NULL;
free(list[pnumwadfiles]);
list[pnumwadfiles] = NULL;
}
}
@ -1046,7 +1012,7 @@ static void IdentifyVersion(void)
// Load the IWAD
if (srb2wad != NULL && FIL_ReadFileOK(srb2wad))
D_AddFile(srb2wad);
D_AddFile(startupwadfiles, srb2wad);
else
I_Error("srb2.pk3 not found! Expected in %s, ss file: %s\n", srb2waddir, srb2wad);
@ -1057,14 +1023,14 @@ static void IdentifyVersion(void)
// checking in D_SRB2Main
// Add the maps
D_AddFile(va(pandf,srb2waddir,"zones.pk3"));
D_AddFile(startupwadfiles, va(pandf,srb2waddir,"zones.pk3"));
// Add the players
D_AddFile(va(pandf,srb2waddir, "player.dta"));
D_AddFile(startupwadfiles, va(pandf,srb2waddir, "player.dta"));
#ifdef USE_PATCH_DTA
// Add our crappy patches to fix our bugs
D_AddFile(va(pandf,srb2waddir,"patch.pk3"));
D_AddFile(startupwadfiles, va(pandf,srb2waddir,"patch.pk3"));
#endif
#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
@ -1074,7 +1040,7 @@ static void IdentifyVersion(void)
const char *musicpath = va(pandf,srb2waddir,str);\
int ms = W_VerifyNMUSlumps(musicpath); \
if (ms == 1) \
D_AddFile(musicpath); \
D_AddFile(startupwadfiles, musicpath); \
else if (ms == 0) \
I_Error("File "str" has been modified with non-music/sound lumps"); \
}
@ -1088,64 +1054,6 @@ static void IdentifyVersion(void)
#endif
}
#ifdef PC_DOS
/* ======================================================================== */
// Code for printing SRB2's title bar in DOS
/* ======================================================================== */
//
// Center the title string, then add the date and time of compilation.
//
static inline void D_MakeTitleString(char *s)
{
char temp[82];
char *t;
const char *u;
INT32 i;
for (i = 0, t = temp; i < 82; i++)
*t++=' ';
for (t = temp + (80-strlen(s))/2, u = s; *u != '\0' ;)
*t++ = *u++;
u = compdate;
for (t = temp + 1, i = 11; i-- ;)
*t++ = *u++;
u = comptime;
for (t = temp + 71, i = 8; i-- ;)
*t++ = *u++;
temp[80] = '\0';
strcpy(s, temp);
}
static inline void D_Titlebar(void)
{
char title1[82]; // srb2 title banner
char title2[82];
strcpy(title1, "Sonic Robo Blast 2");
strcpy(title2, "Sonic Robo Blast 2");
D_MakeTitleString(title1);
// SRB2 banner
clrscr();
textattr((BLUE<<4)+WHITE);
clreol();
cputs(title1);
// standard srb2 banner
textattr((RED<<4)+WHITE);
clreol();
gotoxy((80-strlen(title2))/2, 2);
cputs(title2);
normvideo();
gotoxy(1,3);
}
#endif
static void
D_ConvertVersionNumbers (void)
{
@ -1189,7 +1097,7 @@ void D_SRB2Main(void)
"in this program.\n\n");
// keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined(NOTERMIOS)
#if !defined(NOTERMIOS)
if (setvbuf(stderr, NULL, _IOFBF, 1000))
I_OutputMsg("setvbuf didnt work\n");
#endif
@ -1227,10 +1135,6 @@ void D_SRB2Main(void)
dedicated = M_CheckParm("-dedicated") != 0;
#endif
#ifdef PC_DOS
D_Titlebar();
#endif
if (devparm)
CONS_Printf(M_GetText("Development mode ON.\n"));
@ -1326,7 +1230,7 @@ void D_SRB2Main(void)
{
if (!W_VerifyNMUSlumps(s))
G_SetGameModified(true);
D_AddFile(s);
D_AddFile(startuppwads, s);
}
}
}
@ -1367,8 +1271,8 @@ void D_SRB2Main(void)
// load wad, including the main wad file
CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
W_InitMultipleFiles(startupwadfiles, mainwads);
D_CleanFile();
W_InitMultipleFiles(startupwadfiles);
D_CleanFile(startupwadfiles);
#ifndef DEVELOP // md5s last updated 22/02/20 (ddmmyy)
@ -1404,8 +1308,6 @@ void D_SRB2Main(void)
// setup loading screen
SCR_Startup();
// we need the font of the console
CONS_Printf("HU_Init(): Setting up heads up display.\n");
HU_Init();
CON_Init();
@ -1417,6 +1319,13 @@ void D_SRB2Main(void)
I_RegisterSysCommands();
CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n");
W_InitMultipleFiles(startuppwads);
D_CleanFile(startuppwads);
CONS_Printf("HU_LoadGraphics()...\n");
HU_LoadGraphics();
//--------------------------------------------------------- CONFIG.CFG
M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"
@ -1470,10 +1379,6 @@ void D_SRB2Main(void)
}
}
// Initialize CD-Audio
if (M_CheckParm("-usecd") && !dedicated)
I_InitCD();
if (M_CheckParm("-noupload"))
COM_BufAddText("downloading 0\n");
@ -1609,6 +1514,12 @@ void D_SRB2Main(void)
ultimatemode = true;
}
if (M_CheckParm("-splitscreen"))
{
autostart = true;
splitscreen = true;
}
// rei/miru: bootmap (Idea: starts the game on a predefined map)
if (bootmap && !(M_CheckParm("-warp") && M_IsNextParm()))
{

View file

@ -19,7 +19,9 @@
#define __D_NET__
// Max computers in a game
#define MAXNETNODES (MAXPLAYERS+4)
// 127 is probably as high as this can go, because
// SINT8 is used for nodes sometimes >:(
#define MAXNETNODES 127
#define BROADCASTADDR MAXNETNODES
#define MAXSPLITSCREENPLAYERS 2 // Max number of players on a single computer
//#define NETSPLITSCREEN // Kart's splitscreen netgame feature

View file

@ -197,186 +197,183 @@ static CV_PossibleValue_t matchboxes_cons_t[] = {{0, "Normal"}, {1, "Mystery"},
static CV_PossibleValue_t chances_cons_t[] = {{0, "MIN"}, {9, "MAX"}, {0, NULL}};
static CV_PossibleValue_t pause_cons_t[] = {{0, "Server"}, {1, "All"}, {0, NULL}};
consvar_t cv_showinputjoy = {"showinputjoy", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showinputjoy = CVAR_INIT ("showinputjoy", "Off", 0, CV_OnOff, NULL);
#ifdef NETGAME_DEVMODE
static consvar_t cv_fishcake = {"fishcake", "Off", CV_CALL|CV_NOSHOWHELP|CV_RESTRICT, CV_OnOff, Fishcake_OnChange, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cv_fishcake = CVAR_INIT ("fishcake", "Off", CV_CALL|CV_NOSHOWHELP|CV_RESTRICT, CV_OnOff, Fishcake_OnChange);
#endif
static consvar_t cv_dummyconsvar = {"dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff,
DummyConsvar_OnChange, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cv_dummyconsvar = CVAR_INIT ("dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, DummyConsvar_OnChange);
consvar_t cv_restrictskinchange = {"restrictskinchange", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_allowteamchange = {"allowteamchange", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_restrictskinchange = CVAR_INIT ("restrictskinchange", "Yes", CV_SAVE|CV_NETVAR|CV_CHEAT, CV_YesNo, NULL);
consvar_t cv_allowteamchange = CVAR_INIT ("allowteamchange", "Yes", CV_SAVE|CV_NETVAR, CV_YesNo, NULL);
consvar_t cv_startinglives = {"startinglives", "3", CV_NETVAR|CV_CHEAT, startingliveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_startinglives = CVAR_INIT ("startinglives", "3", CV_SAVE|CV_NETVAR|CV_CHEAT, startingliveslimit_cons_t, NULL);
static CV_PossibleValue_t respawntime_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "Off"}, {0, NULL}};
consvar_t cv_respawntime = {"respawndelay", "3", CV_NETVAR|CV_CHEAT, respawntime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_respawntime = CVAR_INIT ("respawndelay", "3", CV_SAVE|CV_NETVAR|CV_CHEAT, respawntime_cons_t, NULL);
consvar_t cv_competitionboxes = {"competitionboxes", "Mystery", CV_NETVAR|CV_CHEAT, competitionboxes_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_competitionboxes = CVAR_INIT ("competitionboxes", "Mystery", CV_SAVE|CV_NETVAR|CV_CHEAT, competitionboxes_cons_t, NULL);
#ifdef SEENAMES
static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}};
consvar_t cv_seenames = {"seenames", "Ally/Foe", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_allowseenames = {"allowseenames", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_seenames = CVAR_INIT ("seenames", "Ally/Foe", CV_SAVE, seenames_cons_t, 0);
consvar_t cv_allowseenames = CVAR_INIT ("allowseenames", "Yes", CV_SAVE|CV_NETVAR, CV_YesNo, NULL);
#endif
// names
consvar_t cv_playername = {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playername2 = {"name2", "Tails", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playername = CVAR_INIT ("name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange);
consvar_t cv_playername2 = CVAR_INIT ("name2", "Tails", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name2_OnChange);
// player colors
UINT16 lastgoodcolor = SKINCOLOR_BLUE, lastgoodcolor2 = SKINCOLOR_BLUE;
consvar_t cv_playercolor = {"color", "Blue", CV_CALL|CV_NOINIT, Color_cons_t, Color_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playercolor2 = {"color2", "Orange", CV_CALL|CV_NOINIT, Color_cons_t, Color2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playercolor = CVAR_INIT ("color", "Blue", CV_CALL|CV_NOINIT, Color_cons_t, Color_OnChange);
consvar_t cv_playercolor2 = CVAR_INIT ("color2", "Orange", CV_CALL|CV_NOINIT, Color_cons_t, Color2_OnChange);
// player's skin, saved for commodity, when using a favorite skins wad..
consvar_t cv_skin = {"skin", DEFAULTSKIN, CV_CALL|CV_NOINIT, NULL, Skin_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_skin2 = {"skin2", DEFAULTSKIN2, CV_CALL|CV_NOINIT, NULL, Skin2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_skin = CVAR_INIT ("skin", DEFAULTSKIN, CV_CALL|CV_NOINIT, NULL, Skin_OnChange);
consvar_t cv_skin2 = CVAR_INIT ("skin2", DEFAULTSKIN2, CV_CALL|CV_NOINIT, NULL, Skin2_OnChange);
// saved versions of the above six
consvar_t cv_defaultplayercolor = {"defaultcolor", "Blue", CV_SAVE, Color_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_defaultplayercolor2 = {"defaultcolor2", "Orange", CV_SAVE, Color_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_defaultskin = {"defaultskin", DEFAULTSKIN, CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_defaultskin2 = {"defaultskin2", DEFAULTSKIN2, CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_defaultplayercolor = CVAR_INIT ("defaultcolor", "Blue", CV_SAVE, Color_cons_t, NULL);
consvar_t cv_defaultplayercolor2 = CVAR_INIT ("defaultcolor2", "Orange", CV_SAVE, Color_cons_t, NULL);
consvar_t cv_defaultskin = CVAR_INIT ("defaultskin", DEFAULTSKIN, CV_SAVE, NULL, NULL);
consvar_t cv_defaultskin2 = CVAR_INIT ("defaultskin2", DEFAULTSKIN2, CV_SAVE, NULL, NULL);
consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_skipmapcheck = CVAR_INIT ("skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL);
INT32 cv_debug;
consvar_t cv_usemouse = {"use_mouse", "On", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usemouse2 = {"use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usemouse = CVAR_INIT ("use_mouse", "On", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse);
consvar_t cv_usemouse2 = CVAR_INIT ("use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2);
consvar_t cv_usejoystick = {"use_gamepad", "1", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick2 = {"use_gamepad2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick = CVAR_INIT ("use_gamepad", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick);
consvar_t cv_usejoystick2 = CVAR_INIT ("use_gamepad2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick2);
#if (defined (LJOYSTICK) || defined (HAVE_SDL))
#ifdef LJOYSTICK
consvar_t cv_joyport = {"padport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyport2 = {"padport2", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: for later
consvar_t cv_joyport = CVAR_INIT ("padport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL);
consvar_t cv_joyport2 = CVAR_INIT ("padport2", "/dev/js0", CV_SAVE, joyport_cons_t, NULL); //Alam: for later
#endif
consvar_t cv_joyscale = {"padscale", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale2 = {"padscale2", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale2, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale = CVAR_INIT ("padscale", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale);
consvar_t cv_joyscale2 = CVAR_INIT ("padscale2", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale2);
#else
consvar_t cv_joyscale = {"padscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save
consvar_t cv_joyscale2 = {"padscale2", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save
consvar_t cv_joyscale = CVAR_INIT ("padscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL); //Alam: Dummy for save
consvar_t cv_joyscale2 = CVAR_INIT ("padscale2", "1", CV_SAVE|CV_HIDEN, NULL, NULL); //Alam: Dummy for save
#endif
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
consvar_t cv_mouse2port = {"mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouse2opt = {"mouse2opt", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouse2port = CVAR_INIT ("mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL);
consvar_t cv_mouse2opt = CVAR_INIT ("mouse2opt", "0", CV_SAVE, NULL, NULL);
#else
consvar_t cv_mouse2port = {"mouse2port", "COM2", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouse2port = CVAR_INIT ("mouse2port", "COM2", CV_SAVE, mouse2port_cons_t, NULL);
#endif
consvar_t cv_matchboxes = {"matchboxes", "Normal", CV_NETVAR|CV_CHEAT, matchboxes_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_specialrings = {"specialrings", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_powerstones = {"powerstones", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_matchboxes = CVAR_INIT ("matchboxes", "Normal", CV_SAVE|CV_NETVAR|CV_CHEAT, matchboxes_cons_t, NULL);
consvar_t cv_specialrings = CVAR_INIT ("specialrings", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_powerstones = CVAR_INIT ("powerstones", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_recycler = {"tv_recycler", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_teleporters = {"tv_teleporter", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_superring = {"tv_superring", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_supersneakers = {"tv_supersneaker", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_invincibility = {"tv_invincibility", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_jumpshield = {"tv_jumpshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_watershield = {"tv_watershield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ringshield = {"tv_ringshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_forceshield = {"tv_forceshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_bombshield = {"tv_bombshield", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_1up = {"tv_1up", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_eggmanbox = {"tv_eggman", "5", CV_NETVAR|CV_CHEAT, chances_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_recycler = CVAR_INIT ("tv_recycler", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_teleporters = CVAR_INIT ("tv_teleporter", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_superring = CVAR_INIT ("tv_superring", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_supersneakers = CVAR_INIT ("tv_supersneaker", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_invincibility = CVAR_INIT ("tv_invincibility", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_jumpshield = CVAR_INIT ("tv_jumpshield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_watershield = CVAR_INIT ("tv_watershield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_ringshield = CVAR_INIT ("tv_ringshield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_forceshield = CVAR_INIT ("tv_forceshield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_bombshield = CVAR_INIT ("tv_bombshield", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_1up = CVAR_INIT ("tv_1up", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_eggmanbox = CVAR_INIT ("tv_eggman", "5", CV_SAVE|CV_NETVAR|CV_CHEAT, chances_cons_t, NULL);
consvar_t cv_ringslinger = {"ringslinger", "No", CV_NETVAR|CV_NOSHOWHELP|CV_CALL|CV_CHEAT, CV_YesNo,
Ringslinger_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_gravity = {"gravity", "0.5", CV_RESTRICT|CV_FLOAT|CV_CALL, NULL, Gravity_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ringslinger = CVAR_INIT ("ringslinger", "No", CV_NETVAR|CV_NOSHOWHELP|CV_CALL|CV_CHEAT, CV_YesNo, Ringslinger_OnChange);
consvar_t cv_gravity = CVAR_INIT ("gravity", "0.5", CV_RESTRICT|CV_FLOAT|CV_CALL, NULL, Gravity_OnChange);
consvar_t cv_soundtest = {"soundtest", "0", CV_CALL, NULL, SoundTest_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_soundtest = CVAR_INIT ("soundtest", "0", CV_CALL, NULL, SoundTest_OnChange);
static CV_PossibleValue_t minitimelimit_cons_t[] = {{15, "MIN"}, {9999, "MAX"}, {0, NULL}};
consvar_t cv_countdowntime = {"countdowntime", "60", CV_NETVAR|CV_CHEAT, minitimelimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_countdowntime = CVAR_INIT ("countdowntime", "60", CV_SAVE|CV_NETVAR|CV_CHEAT, minitimelimit_cons_t, NULL);
consvar_t cv_touchtag = {"touchtag", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_hidetime = {"hidetime", "30", CV_NETVAR|CV_CALL, minitimelimit_cons_t, Hidetime_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_touchtag = CVAR_INIT ("touchtag", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_hidetime = CVAR_INIT ("hidetime", "30", CV_SAVE|CV_NETVAR|CV_CALL, minitimelimit_cons_t, Hidetime_OnChange);
consvar_t cv_autobalance = {"autobalance", "Off", CV_NETVAR|CV_CALL, CV_OnOff, AutoBalance_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_teamscramble = {"teamscramble", "Off", CV_NETVAR|CV_CALL|CV_NOINIT, teamscramble_cons_t, TeamScramble_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_scrambleonchange = {"scrambleonchange", "Off", CV_NETVAR, teamscramble_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_autobalance = CVAR_INIT ("autobalance", "Off", CV_SAVE|CV_NETVAR|CV_CALL, CV_OnOff, AutoBalance_OnChange);
consvar_t cv_teamscramble = CVAR_INIT ("teamscramble", "Off", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, teamscramble_cons_t, TeamScramble_OnChange);
consvar_t cv_scrambleonchange = CVAR_INIT ("scrambleonchange", "Off", CV_SAVE|CV_NETVAR, teamscramble_cons_t, NULL);
consvar_t cv_friendlyfire = {"friendlyfire", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_itemfinder = {"itemfinder", "Off", CV_CALL, CV_OnOff, ItemFinder_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_friendlyfire = CVAR_INIT ("friendlyfire", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_itemfinder = CVAR_INIT ("itemfinder", "Off", CV_CALL, CV_OnOff, ItemFinder_OnChange);
// Scoring type options
consvar_t cv_overtime = {"overtime", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_overtime = CVAR_INIT ("overtime", "Yes", CV_SAVE|CV_NETVAR, CV_YesNo, NULL);
consvar_t cv_rollingdemos = {"rollingdemos", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_rollingdemos = CVAR_INIT ("rollingdemos", "On", CV_SAVE, CV_OnOff, NULL);
static CV_PossibleValue_t timetic_cons_t[] = {{0, "Classic"}, {1, "Centiseconds"}, {2, "Mania"}, {3, "Tics"}, {0, NULL}};
consvar_t cv_timetic = {"timerres", "Classic", CV_SAVE, timetic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_timetic = CVAR_INIT ("timerres", "Classic", CV_SAVE, timetic_cons_t, NULL);
static CV_PossibleValue_t powerupdisplay_cons_t[] = {{0, "Never"}, {1, "First-person only"}, {2, "Always"}, {0, NULL}};
consvar_t cv_powerupdisplay = {"powerupdisplay", "First-person only", CV_SAVE, powerupdisplay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_powerupdisplay = CVAR_INIT ("powerupdisplay", "First-person only", CV_SAVE, powerupdisplay_cons_t, NULL);
static CV_PossibleValue_t pointlimit_cons_t[] = {{1, "MIN"}, {MAXSCORE, "MAX"}, {0, "None"}, {0, NULL}};
consvar_t cv_pointlimit = {"pointlimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t,
PointLimit_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pointlimit = CVAR_INIT ("pointlimit", "None", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t, PointLimit_OnChange);
static CV_PossibleValue_t timelimit_cons_t[] = {{1, "MIN"}, {30, "MAX"}, {0, "None"}, {0, NULL}};
consvar_t cv_timelimit = {"timelimit", "None", CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t,
TimeLimit_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_timelimit = CVAR_INIT ("timelimit", "None", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange);
static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, NULL}};
consvar_t cv_numlaps = {"numlaps", "4", CV_NETVAR|CV_CALL|CV_NOINIT, numlaps_cons_t,
NumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_numlaps = CVAR_INIT ("numlaps", "4", CV_NETVAR|CV_CALL|CV_NOINIT, numlaps_cons_t, NumLaps_OnChange);
static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, "Map default"}, {0, NULL}};
consvar_t cv_basenumlaps = {"basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_basenumlaps = CVAR_INIT ("basenumlaps", "Map default", CV_SAVE|CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange);
// Point and time limits for every gametype
INT32 pointlimits[NUMGAMETYPES];
INT32 timelimits[NUMGAMETYPES];
// log elemental hazards -- not a netvar, is local to current player
consvar_t cv_hazardlog = {"hazardlog", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_hazardlog = CVAR_INIT ("hazardlog", "Yes", 0, CV_YesNo, NULL);
consvar_t cv_forceskin = {"forceskin", "None", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_downloading = {"downloading", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_allowexitlevel = {"allowexitlevel", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_forceskin = CVAR_INIT ("forceskin", "None", CV_NETVAR|CV_CALL|CV_CHEAT, NULL, ForceSkin_OnChange);
consvar_t cv_downloading = CVAR_INIT ("downloading", "On", 0, CV_OnOff, NULL);
consvar_t cv_allowexitlevel = CVAR_INIT ("allowexitlevel", "No", CV_SAVE|CV_NETVAR, CV_YesNo, NULL);
consvar_t cv_killingdead = {"killingdead", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_killingdead = CVAR_INIT ("killingdead", "Off", CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_netstat = {"netstat", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // show bandwidth statistics
consvar_t cv_netstat = CVAR_INIT ("netstat", "Off", 0, CV_OnOff, NULL); // show bandwidth statistics
static CV_PossibleValue_t nettimeout_cons_t[] = {{TICRATE/7, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}};
consvar_t cv_nettimeout = {"nettimeout", "350", CV_CALL|CV_SAVE, nettimeout_cons_t, NetTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_nettimeout = CVAR_INIT ("nettimeout", "350", CV_CALL|CV_SAVE, nettimeout_cons_t, NetTimeout_OnChange);
static CV_PossibleValue_t jointimeout_cons_t[] = {{5*TICRATE, "MIN"}, {60*TICRATE, "MAX"}, {0, NULL}};
consvar_t cv_jointimeout = {"jointimeout", "350", CV_CALL|CV_SAVE, jointimeout_cons_t, JoinTimeout_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_maxping = {"maxping", "0", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_jointimeout = CVAR_INIT ("jointimeout", "350", CV_CALL|CV_SAVE|CV_NETVAR, jointimeout_cons_t, JoinTimeout_OnChange);
consvar_t cv_maxping = CVAR_INIT ("maxping", "0", CV_SAVE|CV_NETVAR, CV_Unsigned, NULL);
static CV_PossibleValue_t pingtimeout_cons_t[] = {{8, "MIN"}, {120, "MAX"}, {0, NULL}};
consvar_t cv_pingtimeout = {"pingtimeout", "10", CV_SAVE, pingtimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pingtimeout = CVAR_INIT ("pingtimeout", "10", CV_SAVE|CV_NETVAR, pingtimeout_cons_t, NULL);
// show your ping on the HUD next to framerate. Defaults to warning only (shows up if your ping is > maxping)
static CV_PossibleValue_t showping_cons_t[] = {{0, "Off"}, {1, "Always"}, {2, "Warning"}, {0, NULL}};
consvar_t cv_showping = {"showping", "Warning", CV_SAVE, showping_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showping = CVAR_INIT ("showping", "Warning", CV_SAVE, showping_cons_t, NULL);
// Intermission time Tails 04-19-2002
static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}};
consvar_t cv_inttime = {"inttime", "10", CV_NETVAR, inttime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_inttime = CVAR_INIT ("inttime", "10", CV_SAVE|CV_NETVAR, inttime_cons_t, NULL);
static CV_PossibleValue_t coopstarposts_cons_t[] = {{0, "Per-player"}, {1, "Shared"}, {2, "Teamwork"}, {0, NULL}};
consvar_t cv_coopstarposts = {"coopstarposts", "Per-player", CV_NETVAR|CV_CALL, coopstarposts_cons_t, CoopStarposts_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_coopstarposts = CVAR_INIT ("coopstarposts", "Per-player", CV_SAVE|CV_NETVAR|CV_CALL, coopstarposts_cons_t, CoopStarposts_OnChange);
static CV_PossibleValue_t cooplives_cons_t[] = {{0, "Infinite"}, {1, "Per-player"}, {2, "Avoid Game Over"}, {3, "Single pool"}, {0, NULL}};
consvar_t cv_cooplives = {"cooplives", "Avoid Game Over", CV_NETVAR|CV_CALL|CV_CHEAT, cooplives_cons_t, CoopLives_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cooplives = CVAR_INIT ("cooplives", "Avoid Game Over", CV_SAVE|CV_NETVAR|CV_CALL|CV_CHEAT, cooplives_cons_t, CoopLives_OnChange);
static CV_PossibleValue_t advancemap_cons_t[] = {{0, "Off"}, {1, "Next"}, {2, "Random"}, {0, NULL}};
consvar_t cv_advancemap = {"advancemap", "Next", CV_NETVAR, advancemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_advancemap = CVAR_INIT ("advancemap", "Next", CV_SAVE|CV_NETVAR, advancemap_cons_t, NULL);
static CV_PossibleValue_t playersforexit_cons_t[] = {{0, "One"}, {1, "1/4"}, {2, "Half"}, {3, "3/4"}, {4, "All"}, {0, NULL}};
consvar_t cv_playersforexit = {"playersforexit", "All", CV_NETVAR, playersforexit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playersforexit = CVAR_INIT ("playersforexit", "All", CV_SAVE|CV_NETVAR, playersforexit_cons_t, NULL);
consvar_t cv_exitmove = {"exitmove", "On", CV_NETVAR|CV_CALL, CV_OnOff, ExitMove_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_exitmove = CVAR_INIT ("exitmove", "On", CV_SAVE|CV_NETVAR|CV_CALL, CV_OnOff, ExitMove_OnChange);
consvar_t cv_runscripts = {"runscripts", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_runscripts = CVAR_INIT ("runscripts", "Yes", 0, CV_YesNo, NULL);
consvar_t cv_pause = {"pausepermission", "Server", CV_NETVAR, pause_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mute = {"mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pause = CVAR_INIT ("pausepermission", "Server", CV_SAVE|CV_NETVAR, pause_cons_t, NULL);
consvar_t cv_mute = CVAR_INIT ("mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange);
consvar_t cv_sleep = {"cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL};
consvar_t cv_sleep = CVAR_INIT ("cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL);
static CV_PossibleValue_t perfstats_cons_t[] = {
{0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {0, NULL}};
consvar_t cv_perfstats = CVAR_INIT ("perfstats", "Off", 0, perfstats_cons_t, NULL);
char timedemo_name[256];
boolean timedemo_csv;
@ -861,23 +858,18 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_midimusicvolume);
CV_RegisterVar(&cv_numChannels);
// i_cdmus.c
CV_RegisterVar(&cd_volume);
CV_RegisterVar(&cdUpdate);
// screen.c
CV_RegisterVar(&cv_fullscreen);
CV_RegisterVar(&cv_renderview);
CV_RegisterVar(&cv_renderer);
#ifdef HWRENDER
CV_RegisterVar(&cv_newrenderer);
#endif
CV_RegisterVar(&cv_scr_depth);
CV_RegisterVar(&cv_scr_width);
CV_RegisterVar(&cv_scr_height);
CV_RegisterVar(&cv_soundtest);
CV_RegisterVar(&cv_perfstats);
// ingame object placing
COM_AddCommand("objectplace", Command_ObjectPlace_f);
COM_AddCommand("writethings", Command_Writethings_f);
@ -1130,6 +1122,8 @@ static void SetPlayerName(INT32 playernum, char *newname)
if (netgame)
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
player_name_changes[playernum]++;
strcpy(player_names[playernum], newname);
}
}
@ -1306,7 +1300,12 @@ static void SendNameAndColor(void)
snacpending++;
// Don't change name if muted
if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
if (player_name_changes[consoleplayer] >= MAXNAMECHANGES)
{
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
HU_AddChatText("\x85*You must wait to change your name again", false);
}
else if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
else // Cleanup name if changing it
CleanupPlayerName(consoleplayer, cv_playername.zstring);
@ -1467,8 +1466,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
skin = READUINT8(*cp);
// set name
if (strcasecmp(player_names[playernum], name) != 0)
SetPlayerName(playernum, name);
if (player_name_changes[playernum] < MAXNAMECHANGES)
{
if (strcasecmp(player_names[playernum], name) != 0)
SetPlayerName(playernum, name);
}
// set color
p->skincolor = color % numskincolors;
@ -3245,97 +3247,130 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum)
*/
static void Command_Addfile(void)
{
const char *fn, *p;
char buf[256];
char *buf_p = buf;
INT32 i;
int musiconly; // W_VerifyNMUSlumps isn't boolean
size_t argc = COM_Argc(); // amount of arguments total
size_t curarg; // current argument index
if (COM_Argc() != 2)
const char *addedfiles[argc]; // list of filenames already processed
size_t numfilesadded = 0; // the amount of filenames processed
if (argc < 2)
{
CONS_Printf(M_GetText("addfile <wadfile.wad>: load wad file\n"));
return;
}
else
fn = COM_Argv(1);
// Disallow non-printing characters and semicolons.
for (i = 0; fn[i] != '\0'; i++)
if (!isprint(fn[i]) || fn[i] == ';')
return;
musiconly = W_VerifyNMUSlumps(fn);
if (!musiconly)
{
// ... But only so long as they contain nothing more then music and sprites.
if (netgame && !(server || IsPlayerAdmin(consoleplayer)))
{
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
return;
}
G_SetGameModified(multiplayer);
}
// Add file on your client directly if it is trivial, or you aren't in a netgame.
if (!(netgame || multiplayer) || musiconly)
{
P_AddWadFile(fn);
CONS_Printf(M_GetText("addfile <filename.pk3/wad/lua/soc> [filename2...] [...]: Load add-ons\n"));
return;
}
p = fn+strlen(fn);
while(--p >= fn)
if (*p == '\\' || *p == '/' || *p == ':')
break;
++p;
// check total packet size and no of files currently loaded
// See W_LoadWadFile in w_wad.c
if ((numwadfiles >= MAX_WADFILES)
|| ((packetsizetally + nameonlylength(fn) + 22) > MAXFILENEEDED*sizeof(UINT8)))
// start at one to skip command name
for (curarg = 1; curarg < argc; curarg++)
{
CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn);
return;
}
const char *fn, *p;
char buf[256];
char *buf_p = buf;
INT32 i;
size_t ii;
int musiconly; // W_VerifyNMUSlumps isn't boolean
boolean fileadded = false;
WRITESTRINGN(buf_p,p,240);
fn = COM_Argv(curarg);
// calculate and check md5
{
UINT8 md5sum[16];
#ifdef NOMD5
memset(md5sum,0,16);
#else
FILE *fhandle;
if ((fhandle = W_OpenWadFile(&fn, true)) != NULL)
// For the amount of filenames previously processed...
for (ii = 0; ii < numfilesadded; ii++)
{
tic_t t = I_GetTime();
CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",fn);
md5_stream(fhandle, md5sum);
CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f second\n", fn, (float)(I_GetTime() - t)/TICRATE);
fclose(fhandle);
}
else // file not found
return;
for (i = 0; i < numwadfiles; i++)
{
if (!memcmp(wadfiles[i]->md5sum, md5sum, 16))
// If this is one of them, don't try to add it.
if (!strcmp(fn, addedfiles[ii]))
{
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), fn);
return;
fileadded = true;
break;
}
}
#endif
WRITEMEM(buf_p, md5sum, 16);
}
if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file
SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf);
else
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
// If we've added this one, skip to the next one.
if (fileadded)
{
CONS_Alert(CONS_WARNING, M_GetText("Already processed %s, skipping\n"), fn);
continue;
}
// Disallow non-printing characters and semicolons.
for (i = 0; fn[i] != '\0'; i++)
if (!isprint(fn[i]) || fn[i] == ';')
return;
musiconly = W_VerifyNMUSlumps(fn);
if (!musiconly)
{
// ... But only so long as they contain nothing more then music and sprites.
if (netgame && !(server || IsPlayerAdmin(consoleplayer)))
{
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
continue;
}
G_SetGameModified(multiplayer);
}
// Add file on your client directly if it is trivial, or you aren't in a netgame.
if (!(netgame || multiplayer) || musiconly)
{
P_AddWadFile(fn);
addedfiles[numfilesadded++] = fn;
continue;
}
p = fn+strlen(fn);
while(--p >= fn)
if (*p == '\\' || *p == '/' || *p == ':')
break;
++p;
// check total packet size and no of files currently loaded
// See W_LoadWadFile in w_wad.c
if ((numwadfiles >= MAX_WADFILES)
|| ((packetsizetally + nameonlylength(fn) + 22) > MAXFILENEEDED*sizeof(UINT8)))
{
CONS_Alert(CONS_ERROR, M_GetText("Too many files loaded to add %s\n"), fn);
return;
}
WRITESTRINGN(buf_p,p,240);
// calculate and check md5
{
UINT8 md5sum[16];
#ifdef NOMD5
memset(md5sum,0,16);
#else
FILE *fhandle;
if ((fhandle = W_OpenWadFile(&fn, true)) != NULL)
{
tic_t t = I_GetTime();
CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",fn);
md5_stream(fhandle, md5sum);
CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f second\n", fn, (float)(I_GetTime() - t)/TICRATE);
fclose(fhandle);
}
else // file not found
continue;
for (i = 0; i < numwadfiles; i++)
{
if (!memcmp(wadfiles[i]->md5sum, md5sum, 16))
{
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), fn);
continue;
}
}
#endif
WRITEMEM(buf_p, md5sum, 16);
}
addedfiles[numfilesadded++] = fn;
if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file
SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf);
else
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
}
}
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)

View file

@ -114,6 +114,8 @@ extern consvar_t cv_skipmapcheck;
extern consvar_t cv_sleep;
extern consvar_t cv_perfstats;
extern char timedemo_name[256];
extern boolean timedemo_csv;
extern char timedemo_csv_id[256];

View file

@ -51,6 +51,7 @@ typedef enum
SF_NONIGHTSSUPER = 1<<15, // Disable super colors for NiGHTS (if you have SF_SUPER)
SF_NOSUPERSPRITES = 1<<16, // Don't use super sprites while super
SF_NOSUPERJUMPBOOST = 1<<17, // Disable the jump boost given while super (i.e. Knuckles)
SF_CANBUSTWALLS = 1<<18, // Can naturally bust walls on contact? (i.e. Knuckles)
// free up to and including 1<<31
} skinflags_t;
@ -115,7 +116,7 @@ typedef enum
// True if button down last tic.
PF_ATTACKDOWN = 1<<7,
PF_USEDOWN = 1<<8,
PF_SPINDOWN = 1<<8,
PF_JUMPDOWN = 1<<9,
PF_WPNDOWN = 1<<10,

View file

@ -31,7 +31,7 @@ typedef enum
BT_WEAPONPREV = 1<<5,
BT_ATTACK = 1<<6, // shoot rings
BT_USE = 1<<7, // spin
BT_SPIN = 1<<7,
BT_CAMLEFT = 1<<8, // turn camera left
BT_CAMRIGHT = 1<<9, // turn camera right
BT_TOSSFLAG = 1<<10,

View file

@ -29,8 +29,9 @@
#include "p_local.h" // for var1 and var2, and some constants
#include "p_setup.h"
#include "r_data.h"
#include "r_textures.h"
#include "r_draw.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "r_things.h" // R_Char2Frame
#include "r_sky.h"
#include "fastcmp.h"
@ -46,12 +47,6 @@
#include "hardware/hw_light.h"
#endif
#ifdef PC_DOS
#include <stdio.h> // for snprintf
//int snprintf(char *str, size_t n, const char *fmt, ...);
int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
#endif
// Free slot names
// The crazy word-reading stuff uses these.
static char *FREE_STATES[NUMSTATEFREESLOTS];
@ -9088,7 +9083,7 @@ static const char *const PLAYERFLAG_LIST[] = {
// True if button down last tic.
"ATTACKDOWN",
"USEDOWN",
"SPINDOWN",
"JUMPDOWN",
"WPNDOWN",
@ -9522,6 +9517,7 @@ struct {
{"RING_DIST",RING_DIST},
{"PUSHACCEL",PUSHACCEL},
{"MODID",MODID}, // I don't know, I just thought it would be cool for a wad to potentially know what mod it was loaded into.
{"MODVERSION",MODVERSION}, // or what version of the mod this is.
{"CODEBASE",CODEBASE}, // or what release of SRB2 this is.
{"NEWTICRATE",NEWTICRATE}, // TICRATE*NEWTICRATERATIO
{"NEWTICRATERATIO",NEWTICRATERATIO},
@ -9705,6 +9701,7 @@ struct {
{"SF_NONIGHTSSUPER",SF_NONIGHTSSUPER},
{"SF_NOSUPERSPRITES",SF_NOSUPERSPRITES},
{"SF_NOSUPERJUMPBOOST",SF_NOSUPERJUMPBOOST},
{"SF_CANBUSTWALLS",SF_CANBUSTWALLS},
// Dashmode constants
{"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD},
@ -9922,6 +9919,25 @@ struct {
{"BT_REGULAR",BT_REGULAR},
{"BT_STRONG",BT_STRONG},
// PolyObject flags
{"POF_CLIPLINES",POF_CLIPLINES}, ///< Test against lines for collision
{"POF_CLIPPLANES",POF_CLIPPLANES}, ///< Test against tops and bottoms for collision
{"POF_SOLID",POF_SOLID}, ///< Clips things.
{"POF_TESTHEIGHT",POF_TESTHEIGHT}, ///< Test line collision with heights
{"POF_RENDERSIDES",POF_RENDERSIDES}, ///< Renders the sides.
{"POF_RENDERTOP",POF_RENDERTOP}, ///< Renders the top.
{"POF_RENDERBOTTOM",POF_RENDERBOTTOM}, ///< Renders the bottom.
{"POF_RENDERPLANES",POF_RENDERPLANES}, ///< Renders top and bottom.
{"POF_RENDERALL",POF_RENDERALL}, ///< Renders everything.
{"POF_INVERT",POF_INVERT}, ///< Inverts collision (like a cage).
{"POF_INVERTPLANES",POF_INVERTPLANES}, ///< Render inside planes.
{"POF_INVERTPLANESONLY",POF_INVERTPLANESONLY}, ///< Only render inside planes.
{"POF_PUSHABLESTOP",POF_PUSHABLESTOP}, ///< Pushables will stop movement.
{"POF_LDEXEC",POF_LDEXEC}, ///< This PO triggers a linedef executor.
{"POF_ONESIDE",POF_ONESIDE}, ///< Only use the first side of the linedef.
{"POF_NOSPECIALS",POF_NOSPECIALS}, ///< Don't apply sector specials.
{"POF_SPLAT",POF_SPLAT}, ///< Use splat flat renderer (treat cyan pixels as invisible).
#ifdef HAVE_LUA_SEGS
// Node flags
{"NF_SUBSECTOR",NF_SUBSECTOR}, // Indicate a leaf.
@ -9985,7 +10001,7 @@ struct {
{"BT_WEAPONNEXT",BT_WEAPONNEXT},
{"BT_WEAPONPREV",BT_WEAPONPREV},
{"BT_ATTACK",BT_ATTACK}, // shoot rings
{"BT_USE",BT_USE}, // spin
{"BT_SPIN",BT_SPIN},
{"BT_CAMLEFT",BT_CAMLEFT}, // turn camera left
{"BT_CAMRIGHT",BT_CAMRIGHT}, // turn camera right
{"BT_TOSSFLAG",BT_TOSSFLAG},
@ -10858,6 +10874,11 @@ static inline int lib_getenum(lua_State *L)
lua_pushinteger(L, (lua_Integer)PF_FULLSTASIS);
return 1;
}
else if (fastcmp(p, "USEDOWN")) // Remove case when 2.3 nears release...
{
lua_pushinteger(L, (lua_Integer)PF_SPINDOWN);
return 1;
}
if (mathlib) return luaL_error(L, "playerflag '%s' could not be found.\n", word);
return 0;
}
@ -11124,6 +11145,12 @@ static inline int lib_getenum(lua_State *L)
return 0;
}
if (fastcmp(word, "BT_USE")) // Remove case when 2.3 nears release...
{
lua_pushinteger(L, (lua_Integer)BT_SPIN);
return 1;
}
for (i = 0; INT_CONST[i].n; i++)
if (fastcmp(word,INT_CONST[i].n)) {
lua_pushinteger(L, INT_CONST[i].v);

View file

@ -1,48 +0,0 @@
#
# djgppdos/makefile.cfg for SRB2/DOS
#
#
#now for the DOS stuff, go DOS!
#
# options
OPTS=-DPC_DOS
WFLAGS+=-Wno-cast-qual
NOHW=1
NOHS=1
PNG_CFLAGS=
PNG_LDFLAGS=-lpng -lz
ifdef WATTCP
OPTS+=-DWATTCP
NOOBJDUMP=1
endif
#ifdef DEBUGMODE
LIBS=-lalld
#else
# LIBS=-lalleg
#endif
ifndef NONET
ifdef WATTCP
LIBS+=-lwatt
else
LIBS+=-lsocket
endif
endif
ifdef RDB
LIBS+=-lgdbst -ldzcom
OPTS+=-DREMOTE_DEBUGGING
endif
OBJS=$(OBJDIR)/i_video.o $(OBJDIR)/vid_vesa.o
# name of the exefile
ifdef WATTCP
EXENAME?=srb2dos.exe
else
EXENAME?=srb2w16.exe
endif

View file

@ -1,755 +0,0 @@
/* bcd.c -- Brennan's CD-ROM Audio Playing Library
by Brennan Underwood, http://brennan.home.ml.org/ */
#include <dos.h>
#include <dpmi.h>
#include <go32.h>
#include <fcntl.h>
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
#include <strings.h>
#ifdef STANDALONE
#include <conio.h> /* for getch() */
#endif
#include "bcd.h"
typedef struct {
int is_audio;
int start, end, len;
} Track;
static int mscdex_version;
static int first_drive;
static int num_tracks;
static int lowest_track, highest_track;
static int audio_length;
#ifdef STATIC_TRACKS
static Track tracks[99];
#else
static Track *tracks;
#endif
static int dos_mem_segment, dos_mem_selector = -1;
int _status, _error, _error_code;
const char *_bcd_error = NULL;
#define RESET_ERROR (_error = _error_code = 0)
#define ERROR_BIT (1 << 15)
#define BUSY_BIT (1 << 9)
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#pragma pack(1)
/* I know 'typedef struct {} bleh' is a bad habit, but... */
typedef struct {
unsigned char len;
unsigned char unit;
unsigned char command;
unsigned short status;
unsigned char reserved[8];
} ATTRPACK RequestHeader;
typedef struct {
RequestHeader request_header;
unsigned char descriptor;
unsigned long address;
unsigned short len;
unsigned short secnum;
unsigned long ptr;
} ATTRPACK IOCTLI;
typedef struct {
unsigned char control;
unsigned char lowest;
unsigned char highest;
char total[4];
} ATTRPACK DiskInfo;
typedef struct {
unsigned char control;
unsigned char track_number;
char start[4];
unsigned char info;
} ATTRPACK TrackInfo;
typedef struct {
RequestHeader request;
unsigned char mode;
unsigned long start;
unsigned long len;
} ATTRPACK PlayRequest;
typedef struct {
RequestHeader request;
} ATTRPACK StopRequest;
typedef struct {
RequestHeader request;
} ATTRPACK ResumeRequest;
typedef struct {
unsigned char control;
unsigned char input0;
unsigned char volume0;
unsigned char input1;
unsigned char volume1;
unsigned char input2;
unsigned char volume2;
unsigned char input3;
unsigned char volume3;
} ATTRPACK VolumeRequest;
typedef struct {
unsigned char control;
unsigned char fn;
} ATTRPACK LockRequest;
typedef struct {
unsigned char control;
unsigned char mbyte;
} ATTRPACK MediaChangedRequest;
typedef struct {
unsigned char control;
unsigned long status;
} ATTRPACK StatusRequest;
typedef struct {
unsigned char control;
unsigned char mode;
unsigned long loc;
} ATTRPACK PositionRequest;
#pragma pack()
#ifdef __cplusplus
extern "C" {
#endif
const char *bcd_error(void) {
static char retstr[132];
const char *errorcodes[] = {
"Write-protect violation",
"Unknown unit",
"Drive not ready",
"Unknown command",
"CRC error",
"Bad drive request structure length",
"Seek error",
"Unknown media",
"Sector not found",
"Printer out of paper: world coming to an end",/* I mean really, on a CD? */
"Write fault",
"Read fault",
"General failure",
"Reserved",
"Reserved",
"Invalid disk change"
};
*retstr = 0;
if (_error != 0) {
strcat(retstr, "Device error: ");
if (_error_code < 0 || _error_code > 0xf)
strcat(retstr, "Invalid error");
else
strcat(retstr, errorcodes[_error_code]);
strcat(retstr, " ");
}
if (_bcd_error != NULL) {
if (*retstr) strcat(retstr, ", ");
strcat(retstr, "BCD error: ");
strcat(retstr, _bcd_error);
}
return retstr;
}
/* DOS IOCTL w/ command block */
static void bcd_ioctl(IOCTLI *ioctli, void *command, int len) {
int ioctli_len = sizeof (IOCTLI);
unsigned long command_address = dos_mem_segment << 4;
__dpmi_regs regs;
memset(&regs, 0, sizeof regs);
regs.x.es = (__tb >> 4) & 0xffff;
regs.x.ax = 0x1510;
regs.x.bx = __tb & 0xf;
regs.x.cx = first_drive;
ioctli->address = dos_mem_segment << 16;
ioctli->len = len;
dosmemput(ioctli, ioctli_len, __tb); /* put ioctl into dos area */
dosmemput(command, len, command_address); /* and command too */
if (__dpmi_int(0x2f, &regs) == -1) {
_bcd_error = "__dpmi_int() failed";
return;
}
dosmemget(__tb, ioctli_len, ioctli); /* retrieve results */
dosmemget(command_address, len, command);
_status = ioctli->request_header.status;
if (_status & ERROR_BIT) {
_error = TRUE;
_error_code = _status & 0xff;
} else {
_error = FALSE;
_error_code = 0;
}
}
/* no command block */
FUNCINLINE static ATTRINLINE void bcd_ioctl2(void *cmd, int len) {
__dpmi_regs regs;
memset(&regs, 0, sizeof regs);
regs.x.es = (__tb >> 4) & 0xffff;
regs.x.ax = 0x1510;
regs.x.bx = __tb & 0xf;
regs.x.cx = first_drive;
dosmemput(cmd, len, __tb); /* put ioctl block in dos arena */
if (__dpmi_int(0x2f, &regs) == -1) {
_bcd_error = "__dpmi_int() failed";
return;
}
/* I hate to have no error capability for ioctl2 but the command block
doesn't necessarily have a status field */
RESET_ERROR;
}
FUNCINLINE static ATTRINLINE int red2hsg(char *r) {
return r[0] + r[1]*75 + r[2]*4500 - 150;
}
int bcd_now_playing(void) {
int i, loc = bcd_audio_position();
_bcd_error = NULL;
if (!bcd_audio_busy()) {
_bcd_error = "Audio not playing";
return 0;
}
if (
#ifndef STATIC_TRACKS
tracks == NULL &&
#endif
!bcd_get_audio_info())
return 0;
for (i = lowest_track; i <= highest_track; i++) {
if (loc >= tracks[i].start && loc <= tracks[i].end) return i;
}
/* some bizarre location? */
_bcd_error = "Head outside of bounds";
return 0;
}
/* handles the setup for CD-ROM audio interface */
int bcd_open(void) {
__dpmi_regs regs;
_bcd_error = NULL;
/* disk I/O wouldn't work anyway if you set sizeof tb this low, but... */
if (_go32_info_block.size_of_transfer_buffer < 4096) {
_bcd_error = "Transfer buffer too small";
return 0;
}
memset(&regs, 0, sizeof regs);
regs.x.ax = 0x1500;
regs.x.bx = 0x0;
__dpmi_int(0x2f, &regs);
if (regs.x.bx == 0) { /* abba no longer lives */
_bcd_error = "MSCDEX not found";
return 0;
}
first_drive = regs.x.cx; /* use the first drive */
/* check for mscdex at least 2.0 */
memset(&regs, 0, sizeof regs);
regs.x.ax = 0x150C;
__dpmi_int(0x2f, &regs);
if (regs.x.bx == 0) {
_bcd_error = "MSCDEX version < 2.0";
return 0;
}
mscdex_version = regs.x.bx;
/* allocate 256 bytes of dos memory for the command blocks */
if ((dos_mem_segment = __dpmi_allocate_dos_memory(16, &dos_mem_selector))<0) {
_bcd_error = "Could not allocate 256 bytes of DOS memory";
return 0;
}
return mscdex_version;
}
/* Shuts down CD-ROM audio interface */
int bcd_close(void) {
_bcd_error = NULL;
if (dos_mem_selector != -1) {
__dpmi_free_dos_memory(dos_mem_selector);
dos_mem_selector = -1;
}
#ifndef STATIC_TRACKS
if (tracks) free(tracks);
tracks = NULL;
#endif
RESET_ERROR;
return 1;
}
int bcd_open_door(void) {
IOCTLI ioctli;
char eject = 0;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = 1;
bcd_ioctl(&ioctli, &eject, sizeof eject);
if (_error) return 0;
return 1;
}
int bcd_close_door(void) {
IOCTLI ioctli;
char closeit = 5;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = 1;
bcd_ioctl(&ioctli, &closeit, sizeof closeit);
if (_error) return 0;
return 1;
}
int bcd_lock(int fn) {
IOCTLI ioctli;
LockRequest req;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
memset(&req, 0, sizeof req);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = sizeof req;
req.control = 1;
req.fn = fn ? 1 : 0;
bcd_ioctl(&ioctli, &req, sizeof req);
if (_error) return 0;
return 1;
}
int bcd_disc_changed(void) {
IOCTLI ioctli;
MediaChangedRequest req;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
memset(&req, 0, sizeof req);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 3;
ioctli.len = sizeof req;
req.control = 9;
bcd_ioctl(&ioctli, &req, sizeof req);
return req.mbyte;
}
int bcd_reset(void) {
IOCTLI ioctli;
char reset = 2;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = 1;
bcd_ioctl(&ioctli, &reset, sizeof reset);
if (_error) return 0;
return 1;
}
int bcd_device_status(void) {
IOCTLI ioctli;
StatusRequest req;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
memset(&req, 0, sizeof req);
ioctli.request_header.len = sizeof ioctli; // ok
ioctli.request_header.command = 3;
ioctli.len = sizeof req;
req.control = 6;
bcd_ioctl(&ioctli, &req, sizeof req);
return req.status;
}
static inline int bcd_get_status_word(void) {
IOCTLI ioctli;
DiskInfo disk_info;
/* get cd info as an excuse to get a look at the status word */
memset(&disk_info, 0, sizeof disk_info);
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = 26;
ioctli.request_header.command = 3;
ioctli.len = 7;
disk_info.control = 10;
bcd_ioctl(&ioctli, &disk_info, sizeof disk_info);
return _status;
}
int bcd_audio_busy(void) {
_bcd_error = NULL;
/* If the door is open, then the head is busy, and so the busy bit is
on. It is not, however, playing audio. */
if (bcd_device_status() & BCD_DOOR_OPEN)
return 0;
bcd_get_status_word();
if (_error) return -1;
return (_status & BUSY_BIT) ? 1 : 0;
}
int bcd_audio_position(void) {
IOCTLI ioctli;
PositionRequest req;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
memset(&req, 0, sizeof req);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 3;
ioctli.len = sizeof req;
req.control = 1;
bcd_ioctl(&ioctli, &req, sizeof req);
return req.loc;
}
/* Internal function to get track info */
static inline void bcd_get_track_info(int n, Track *t) {
IOCTLI ioctli;
TrackInfo info;
memset(&ioctli, 0, sizeof ioctli);
memset(&info, 0, sizeof info);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 3;
info.control = 11;
info.track_number = n;
bcd_ioctl(&ioctli, &info, sizeof info);
t->start = red2hsg(info.start);
if (info.info & 64)
t->is_audio = 0;
else
t->is_audio = 1;
}
int bcd_get_audio_info(void) {
IOCTLI ioctli;
DiskInfo disk_info;
int i;
_bcd_error = NULL;
#ifndef STATIC_TRACKS
if (tracks) free(tracks);
tracks = NULL;
#endif
memset(&disk_info, 0, sizeof disk_info);
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = 26;
ioctli.request_header.command = 3;
ioctli.len = 7;
disk_info.control = 10;
bcd_ioctl(&ioctli, &disk_info, sizeof disk_info);
if (_error) return 0;
lowest_track = disk_info.lowest;
highest_track = disk_info.highest;
num_tracks = disk_info.highest - disk_info.lowest + 1;
#ifndef STATIC_TRACKS
//tracks = calloc(num_tracks, sizeof (Track));
/* alloc max space in order to attempt to avoid possible overrun bug */
tracks = calloc(highest_track+1, sizeof (Track));
if (tracks == NULL) {
_bcd_error = "Out of memory allocating tracks\n";
return 0;
}
#endif
/* get track starts */
for (i = lowest_track; i <= highest_track; i++)
bcd_get_track_info(i, tracks+i);
/* figure out track ends */
for (i = lowest_track; i < highest_track; i++)
tracks[i].end = tracks[i+1].start-1;
audio_length = red2hsg(disk_info.total);
tracks[i].end = audio_length;
for (i = lowest_track; i <= highest_track; i++)
tracks[i].len = tracks[i].end - tracks[i].start;
return num_tracks;
}
int bcd_get_track_address(int trackno, int *start, int *len) {
_bcd_error = NULL;
//if (trackno >= num_tracks+1 || trackno <= 0) {
if (trackno < lowest_track || trackno > highest_track) {
_bcd_error = "Track out of range";
*start = *len = 0;
return 0;
}
*start = tracks[trackno].start;
*len = tracks[trackno].len;
return 1;
}
int bcd_track_is_audio(int trackno) {
//if (trackno >= num_tracks+1 || trackno <= 0) {
if (trackno < lowest_track || trackno > highest_track) {
_bcd_error = "Track out of range";
return 0;
}
return tracks[trackno].is_audio;
}
int bcd_set_volume(int volume) {
IOCTLI ioctli;
VolumeRequest v;
_bcd_error = NULL;
if (volume > 255) volume = 255;
else if (volume < 0) volume = 0;
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = sizeof v;
v.control = 3;
v.volume0 = volume;
v.input0 = 0;
v.volume1 = volume;
v.input1 = 1;
v.volume2 = volume;
v.input2 = 2;
v.volume3 = volume;
v.input3 = 3;
bcd_ioctl(&ioctli, &v, sizeof v);
if (_error) return 0;
return 1;
}
int bcd_play(int location, int frames) {
PlayRequest cmd;
memset(&cmd, 0, sizeof cmd);
_bcd_error = NULL;
/* the following should be in user code, but it'll fail otherwise */
if (bcd_audio_busy())
bcd_stop();
cmd.request.len = sizeof cmd;
cmd.request.command = 132;
cmd.start = location;
cmd.len = frames;
bcd_ioctl2(&cmd, sizeof cmd);
if (_error) return 0;
return 1;
}
int bcd_play_track(int trackno) {
_bcd_error = NULL;
if (!bcd_get_audio_info()) return 0;
if (trackno < lowest_track || trackno > highest_track) {
_bcd_error = "Track out of range";
return 0;
}
if (! tracks[trackno].is_audio) {
_bcd_error = "Not an audio track";
return 0;
}
return bcd_play(tracks[trackno].start, tracks[trackno].len);
}
int bcd_stop(void) {
StopRequest cmd;
_bcd_error = NULL;
memset(&cmd, 0, sizeof cmd);
cmd.request.len = sizeof cmd;
cmd.request.command = 133;
bcd_ioctl2(&cmd, sizeof cmd);
if (_error) return 0;
return 1;
}
int bcd_resume(void) {
ResumeRequest cmd;
_bcd_error = NULL;
memset(&cmd, 0, sizeof cmd);
cmd.request.len = sizeof cmd;
cmd.request.command = 136;
bcd_ioctl2(&cmd, sizeof cmd);
if (_error) return 0;
return 1;
}
#ifdef __cplusplus
}
#endif
#ifdef STANDALONE
static char *card(int c) {
return c == 1 ? "" : "s";
}
static void print_hsg(int hsg) {
int hours, minutes, seconds;
seconds = hsg / 75;
minutes = seconds / 60;
seconds %= 60;
hours = minutes / 60;
minutes %= 60;
printf("%2d:%02d:%02d", hours, minutes, seconds);
}
static void print_binary(int v, int len) {
for (;len;len--)
printf("%d", (v & (1 << len)) ? 1 : 0);
}
int main(int argc, char *argv[]) {
int i, n1, n2, t;
if (!bcd_open()) {
fprintf(stderr, "Couldn't open CD-ROM drive. %s\n", bcd_error());
exit(0);
}
for (i = 1; i < argc; i++) {
if (*argv[i] == '-') strcpy(argv[i], argv[i]+1);
if (!strcmp(argv[i], "open") || !strcmp(argv[i], "eject")) {
bcd_open_door();
} else if (!strcmp(argv[i], "close")) {
bcd_close_door();
} else if (!strcmp(argv[i], "sleep")) {
if (++i >= argc) break;
sleep(atoi(argv[i]));
} else if (!strcmp(argv[i], "list")) {
int nd = 0, na = 0, audio_time = 0;
if (!bcd_get_audio_info()) {
printf("Error getting audio info\n");
} else if (lowest_track == 0) {
printf("No audio tracks\n");
} else {
for (t = lowest_track; t <= highest_track; t++) {
printf("Track %2d: ", t);
print_hsg(tracks[t].start);
printf(" -> ");
print_hsg(tracks[t].end);
printf(" (");
print_hsg(tracks[t].len);
if (tracks[t].is_audio) {
na++;
printf(") audio");
audio_time += tracks[t].len;
} else {
nd++;
printf(") data ");
}
printf(" (HSG: %06d->%06d)\n", tracks[t].start, tracks[t].end);
}
printf("%d audio track%s, %d data track%s\n", na, card(na), nd, card(nd));
if (audio_time) {
printf("Audio time: ");
print_hsg(audio_time);
printf("\n");
}
}
} else if (!strcmp(argv[i], "lock")) {
bcd_lock(1);
} else if (!strcmp(argv[i], "pladdr")) {
if (++i >= argc) break;
n1 = atoi(argv[i]);
if (++i >= argc) break;
n2 = atoi(argv[i]);
printf("Playing frame %d to frame %d\n", n1, n2);
bcd_play(n1, n2-n1);
} else if (!strcmp(argv[i], "play")) {
if (++i >= argc) break;
if (bcd_audio_busy()) {
bcd_stop();
delay(1000);
}
n1 = atoi(argv[i]);
printf("Playing track %d\n", n1);
bcd_play_track(n1);
} else if (!strcmp(argv[i], "reset")) {
bcd_reset();
} else if (!strcmp(argv[i], "resume")) {
bcd_resume();
} else if (!strcmp(argv[i], "status")) {
int s;
s = bcd_device_status();
printf("MSCDEX version %d.%d\n", mscdex_version >> 8,
mscdex_version & 0xff);
printf("Device status word '");
print_binary(s, 16);
printf("'\nDoor is %sopen\n", s & BCD_DOOR_OPEN ? "" : "not ");
printf("Door is %slocked\n", s & BCD_DOOR_UNLOCKED ? "not " : "");
printf("Audio is %sbusy\n", bcd_audio_busy() ? "" : "not ");
s = bcd_disc_changed();
if (s == BCD_DISC_UNKNOWN) printf("Media change status unknown\n");
else printf("Media has %schanged\n",
(s == BCD_DISC_CHANGED) ? "" : "not ");
} else if (!strcmp(argv[i], "stop")) {
bcd_stop();
} else if (!strcmp(argv[i], "unlock")) {
bcd_lock(0);
} else if (!strcmp(argv[i], "volume")) {
bcd_set_volume(atoi(argv[++i]));
} else if (!strcmp(argv[i], "wait")) {
while (bcd_audio_busy()) {
int n = bcd_now_playing();
if (n == 0) break;
printf("%2d: ", n);
print_hsg(bcd_audio_position() - tracks[n].start);
printf("\r");
fflush(stdout);
delay(100);
if (kbhit() && getch() == 27) break;
}
printf("\n");
} else if (!strcmp(argv[i], "help") || !strcmp(argv[i], "usage")) {
printf("BCD version %x.%x\n" \
"Usage: BCD {commands}\n" \
"Valid commands:\n" \
"\tclose - close door/tray\n" \
"\tdelay {n} - delay {n} seconds\n" \
"\tlist - list track info\n" \
"\tlock - lock door/tray\n" \
"\topen - open door/tray\n" \
"\tpladdr {n1} {n2}- play frame {n1} to {n2}\n" \
"\tplay {n} - play track {n}\n" \
"\treset - reset the drive\n" \
"\tresume - resume from last stop\n" \
"\tstatus - show drive status\n" \
"\tstop - stop audio playback\n" \
"\tunlock - unlock door/tray\n" \
"\tvolume {n} - set volume to {n} where 0 <= {n} <= 255\n",
BCD_VERSION >> 8, BCD_VERSION & 0xff);
} else
printf("Unknown command '%s'\n", argv[i]);
if (_error || _bcd_error) printf("%s\n", bcd_error());
}
bcd_close();
exit(0);
}
#endif

View file

@ -1,90 +0,0 @@
/* bcd.h -- header file for BCD, a CD-ROM audio playing library for DJGPP
by Brennan Underwood, http://brennan.home.ml.org/ */
#ifndef _BCD_H
#define _BCD_H
#define BCD_VERSION 0x0103
/* Installation and setup functions */
/* Call this first! */
int bcd_open(void);
/* Call before exit. */
int bcd_close(void);
/* open door, unlocking first if necessary */
int bcd_open_door(void);
/* close door */
int bcd_close_door(void);
/* pass 1 to lock door, 0 to unlock */
int bcd_lock(int);
/* returns one of the following 3 #defined symbols */
int bcd_disc_changed(void);
#define BCD_DISC_CHANGED 0xff
#define BCD_DISC_NOT_CHANGED 1
#define BCD_DISC_UNKNOWN 0
/* perform a device reset */
int bcd_reset(void);
/* compare the returned status int to the following bits */
int bcd_device_status(void);
#define BCD_DOOR_OPEN 1
#define BCD_DOOR_UNLOCKED 2
#define BCD_SUPPORT_COOKED 4
#define BCD_READ_ONLY 8
#define BCD_DATA_READ_ONLY 16
#define BCD_SUPPORT_INTERLEAVE 32
/* returns 1 if audio is currently playing, 0 otherwise. -1 on error */
int bcd_audio_busy(void);
/* current head position in frames */
int bcd_audio_position(void);
/* convenience function, if audio busy, returns track# playing now */
int bcd_now_playing(void);
/* query MSCDEX for track list when disc changed or just starting up */
int bcd_get_audio_info(void);
/* get a particular track's info */
int bcd_get_track_address(int trackno, int *start, int *len);
/* check for track's audio/data status */
int bcd_track_is_audio(int trackno);
/* play a particular track from beginning to end */
int bcd_play_track(int tracknum);
/* play an arbitrary section of audio for an arbitrary length of time */
int bcd_play(int start, int len);
/* set the output volume. pass a parameter from 0-255 */
int bcd_set_volume(int);
/* stop and pause are equivalent */
int bcd_stop(void);
#define bcd_pause bcd_stop
int bcd_resume(void);
/* Troubleshooting */
/* Returns a human readable description of the last error encountered */
const char *bcd_error(void);
extern int _error_code;
/* If you are mad enough play the Rach 3, I mean parse _error_code yourself */
#define BCD_DE_WRITE_PROTECT 0
#define BCD_DE_UNKNOWN_UNIT 1
#define BCD_DE_DRIVE_NOT_READY 2
#define BCD_DE_UNKNOWN_COMMAND 3
#define BCD_DE_CRC_ERROR 4
#define BCD_DE_STRUCT_LEN 5
#define BCD_DE_SEEK_ERROR 6
#define BCD_DE_UNKNOWN_MEDIA 7
#define BCD_DE_SECTOR_NOT_FOUND 8
#define BCD_DE_OUT_OF_PAPER 9
#define BCD_DE_WRITE_FAULT 10
#define BCD_DE_READ_FAULT 11
#define BCD_DE_GENERAL_FAILURE 12
#define BCD_DE_INVALID_DISK_CHANGE 15
/* set by BCD itself, for stuff like "Out of memory" */
extern const char *_bcd_error;
/* uncomment this line to force BCD to use a statically allocated
Track array instead of using malloc */
#define STATIC_TRACKS
#endif

View file

@ -1,445 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief cd music interface (uses bcd library)
// Alam_GBC: I hate you, Brennan Underwood :)
#include "../doomtype.h"
#include "bcd.c"
//#include "bcd.h" // CD-Audio library by Brennan Underwood
#include "../doomdef.h"
#include "../i_sound.h"
#include "../command.h"
#include "../i_system.h"
#include "../s_sound.h"
// ------
// protos
// ------
static void Command_Cd_f (void);
//======================================================================
// CD AUDIO MUSIC SUBSYSTEM
//======================================================================
UINT8 cdaudio_started=0; // for system startup/shutdown
#define MAX_CD_TRACKS 256
static boolean cdPlaying = false;
static int cdPlayTrack; // when cdPlaying is true
static boolean cdLooping = false;
static UINT8 cdRemap[MAX_CD_TRACKS];
static boolean cdEnabled=true; // cd info available
static boolean cdValid; // true when last cd audio info was ok
static boolean wasPlaying;
static int cdVolume=0; // current cd volume (0-31)
// 0-31 like Music & Sfx, though CD hardware volume is 0-255.
consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
// allow Update for next/loop track
// some crap cd drivers take up to
// a second for a simple 'busy' check..
// (on those Update can be disabled)
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
// hour,minutes,seconds
FUNCINLINE static ATTRINLINE char *hms(int hsg)
{
int hours, minutes, seconds;
static char s[9];
seconds = hsg / 75;
minutes = seconds / 60;
seconds %= 60;
hours = minutes / 60;
minutes %= 60;
if (hours>0)
sprintf (s, "%d:%02d:%02d", hours, minutes, seconds);
else
sprintf (s, "%2d:%02d", minutes, seconds);
return s;
}
static void Command_Cd_f (void)
{
const char * s;
int i,j;
if (!cdaudio_started)
return;
if (COM_Argc()<2)
{
CONS_Printf ("cd [on] [off] [remap] [reset] [open]\n"
" [info] [play <track>] [loop <track>]\n"
" [stop] [resume]\n");
return;
}
s = COM_Argv(1);
// activate cd music
if (!strncmp(s,"on",2))
{
cdEnabled = true;
return;
}
// stop/deactivate cd music
if (!strncmp(s,"off",3))
{
if (cdPlaying)
I_StopCD ();
cdEnabled = false;
return;
}
// remap tracks
if (!strncmp(s,"remap",5))
{
i = COM_Argc() - 2;
if (i <= 0)
{
CONS_Printf ("CD tracks remapped in that order :\n");
for (j = 1; j < MAX_CD_TRACKS; j++)
if (cdRemap[j] != j)
CONS_Printf (" %2d -> %2d\n", j, cdRemap[j]);
return;
}
for (j = 1; j <= i; j++)
cdRemap[j] = atoi (COM_Argv (j+1));
return;
}
// reset the CD driver, useful on some odd cd's
if (!strncmp(s,"reset",5))
{
cdEnabled = true;
if (cdPlaying)
I_StopCD ();
for (i = 0; i < MAX_CD_TRACKS; i++)
cdRemap[i] = i;
bcd_reset ();
cdValid = bcd_get_audio_info ();
return;
}
// any other command is not allowed until we could retrieve cd information
if (!cdValid)
{
CONS_Printf ("CD is not ready.\n");
return;
}
if (!strncmp(s,"open",4))
{
if (cdPlaying)
I_StopCD ();
bcd_open_door();
cdValid = false;
return;
}
if (!strncmp(s,"info",4))
{
int totaltime = 0;
if (!bcd_get_audio_info())
{
CONS_Printf ("Error getting audio info: %s\n",bcd_error());
cdValid = false;
return;
}
cdValid = true;
if (lowest_track == 0)
CONS_Printf ("No audio tracks\n");
else
{
// display list of tracks
// highlight current playing track
for (i=lowest_track; i <= highest_track; i++)
{
CONS_Printf ("%s%2d. %s %s\n",
cdPlaying && (cdPlayTrack == i) ? "\2 " : " ",
i, tracks[i].is_audio ? "audio" : "data ",
hms(tracks[i].len));
if (tracks[i].is_audio)
totaltime += tracks[i].len;
}
if (totaltime)
CONS_Printf ("\2Total time : %s\n", hms(totaltime));
}
if (cdPlaying)
{
CONS_Printf ("%s track : %d\n", cdLooping ? "looping" : "playing",
cdPlayTrack);
}
return;
}
if (!strncmp(s,"play",4))
{
I_PlayCD ((UINT8)atoi (COM_Argv (2)), false);
return;
}
if (!strncmp(s,"stop",4))
{
I_StopCD ();
return;
}
if (!strncmp(s,"loop",4))
{
I_PlayCD ((UINT8)atoi (COM_Argv (2)), true);
return;
}
if (!strncmp(s,"resume",4))
{
I_ResumeCD ();
return;
}
CONS_Printf ("cd command '%s' unknown\n", s);
}
// pause cd music
void I_StopCD (void)
{
if (!cdaudio_started || !cdEnabled)
return;
bcd_stop();
wasPlaying = cdPlaying;
cdPlaying = false;
}
// continue after a pause
void I_ResumeCD (void)
{
if (!cdaudio_started || !cdEnabled)
return;
if (!cdValid)
return;
if (!wasPlaying)
return;
bcd_resume ();
cdPlaying = true;
}
void I_ShutdownCD (void)
{
int rc;
if (!cdaudio_started)
return;
I_StopCD ();
rc = bcd_close ();
if (!rc)
CONS_Printf ("Error shuting down cd\n");
}
void I_InitCD (void)
{
int rc;
int i;
rc = bcd_open ();
if (rc>=0x200)
{
CONS_Printf ("MSCDEX version %d.%d\n", rc>>8, rc&255);
I_AddExitFunc (I_ShutdownCD);
cdaudio_started = true;
}
else
{
if (!rc)
CONS_Printf ("%s\n", bcd_error() );
cdaudio_started = false;
return;
}
// last saved in config.cfg
i = cd_volume.value;
I_SetVolumeCD (0); // initialize to 0 for some odd cd drivers
I_SetVolumeCD (i); // now set the last saved volume
for (i = 0; i < MAX_CD_TRACKS; i++)
cdRemap[i] = i;
if (!bcd_get_audio_info())
{
CONS_Printf("\2CD Init: No CD in player.\n");
cdEnabled = false;
cdValid = false;
}
else
{
cdEnabled = true;
cdValid = true;
}
COM_AddCommand ("cd", Command_Cd_f);
}
// loop/go to next track when track is finished (if cd_update var is true)
// update the volume when it has changed (from console/menu)
/// \todo check for cd change and restart music ?
void I_UpdateCD (void)
{
int newVolume;
int now;
static int last; //game tics (35th of second)
if (!cdaudio_started)
return;
now = I_GetTime ();
if ((now - last) < 10) // about 1/4 second
return;
last = now;
// update cd volume changed at console/menu
newVolume = cd_volume.value & 31;
if (cdVolume != newVolume)
I_SetVolumeCD (newVolume);
// slow drivers exit here
if (!cdUpdate.value)
return;
if (cdPlaying)
{
if (!bcd_audio_busy())
{
cdPlaying = false;
if (cdLooping)
I_PlayCD (cdPlayTrack, true);
else
{
// play the next cd track, or restart the first
cdPlayTrack++;
if (cdPlayTrack > highest_track)
cdPlayTrack = lowest_track;
while (!tracks[cdPlayTrack].is_audio && cdPlayTrack<highest_track)
cdPlayTrack++;
I_PlayCD (cdPlayTrack, true);
}
}
}
}
//
void I_PlayCD (UINT8 track, UINT8 looping)
{
if (!cdaudio_started || !cdEnabled)
return;
if (!cdValid)
return;
track = cdRemap[track];
if (cdPlaying)
{
if (cdPlayTrack == track)
return;
I_StopCD ();
}
if (track < lowest_track || track > highest_track)
{
//CONS_Printf ("\2CD Audio: wrong track number %d\n", track);
// suppose there are not enough tracks for game levels..
// then do a modulo so we always get something to hear
track = (track % (highest_track-lowest_track+1)) + 1;
//return;
}
cdPlayTrack = track;
if (!tracks[track].is_audio)
{
CONS_Printf ("\2CD Play: not an audio track\n");
return;
}
cdLooping = looping;
if (!bcd_play_track (track))
{
CONS_Printf ("CD Play: could not play track %d\n", track);
cdValid = false;
cdPlaying = false;
return;
}
cdPlaying = true;
}
// volume : logical cd audio volume 0-31 (hardware is 0-255)
boolean I_SetVolumeCD (INT32 volume)
{
int hardvol;
if (!cdaudio_started || !cdEnabled)
return false;
// translate to hardware volume
volume &= 31;
hardvol = ((volume+1)<<3)-1; //highest volume is 255
if (hardvol<=8)
hardvol=0; //lowest volume is ZERO
cdVolume = volume;
if (bcd_set_volume (hardvol))
{
CV_SetValue (&cd_volume, volume);
return true;
}
else
return false;
}

View file

@ -1,78 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief Main program, simply calls D_SRB2Main high level loop.
#include "../doomdef.h"
#include "../m_argv.h"
#include "../d_main.h"
#include "../i_system.h"
#ifdef REMOTE_DEBUGGING
#include <i386-stub.h>
#include "rdb.h"
#endif
//### let's try with Allegro ###
#define alleg_mouse_unused
#define alleg_timer_unused
#define ALLEGRO_NO_KEY_DEFINES
#define alleg_keyboard_unused
#define alleg_joystick_unused
#define alleg_gfx_driver_unused
#define alleg_palette_unused
#define alleg_graphics_unused
#define alleg_vidmem_unused
#define alleg_flic_unused
#define alleg_sound_unused
#define alleg_file_unused
#define alleg_datafile_unused
#define alleg_math_unused
#define alleg_gui_unused
#include <allegro.h>
//### end of Allegro include ###
int main (int argc, char **argv)
{
myargc = argc;
myargv = argv;
{
//added:03-01-98:
// Setup signal handlers and other stuff BEFORE ANYTHING ELSE!
I_StartupSystem();
#ifdef REMOTE_DEBUGGING
/* Only setup if remote debugging is to be done, Muhahahaha!*/
gdb_serial_init(DEBUG_COM_PORT,DEBUG_COM_PORT_SPEED);
gdb_target_init();
breakpoint();
#endif
D_SRB2Main();
D_SRB2Loop();
}
//added:03-01-98:
// hmmm... it will never go here.
return 0;
}
#if ALLEGRO_VERSION == 4
END_OF_MAIN()
#endif

View file

@ -1,113 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1993-1996 by id Software, Inc.
// Portions Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief doomcom network interface
#include <netinet/in.h>
#include <errno.h>
#include <unistd.h>
#include <go32.h>
#include <pc.h>
#include <dpmi.h>
#include <dos.h>
#include <sys/nearptr.h>
#include "../doomdef.h"
#include "../i_system.h"
#include "../d_event.h"
#include "../d_net.h"
#include "../m_argv.h"
#include "../doomstat.h"
#include "../z_zone.h"
#include "../i_net.h"
#include "../i_tcp.h"
//
// NETWORKING
//
typedef enum
{
CMD_SEND = 1,
CMD_GET = 2,
} command_t;
static void External_Driver_Get(void);
static void External_Driver_Send(void);
static void External_Driver_FreeNode(INT32 nodenum);
static inline boolean External_Driver_OpenSocket(void)
{
I_NetGet = External_Driver_Get;
I_NetSend = External_Driver_Send;
I_NetCloseSocket = NULL;
I_NetFreeNodenum = External_Driver_FreeNode;
return true;
}
//
// I_InitNetwork
//
boolean I_InitNetwork (void)
{
int netgamepar;
netgamepar = M_CheckParm ("-net");
if (!netgamepar)
return false;
// externals drivers specific
__djgpp_nearptr_enable();
// set up for network
doomcom=(doomcom_t *)(__djgpp_conventional_base+atoi(myargv[netgamepar+1]));
CONS_Printf("I_DosNet : Using int 0x%x for communication\n",doomcom->intnum);
server = (doomcom->consoleplayer == 0);
if (!server)
COM_BufAddText("connect any\n");
// ipx + time + 4 (padding)
packetheaderlength=30+4+4;
hardware_MAXPACKETLENGTH = 512;
I_NetOpenSocket = External_Driver_OpenSocket;
return true;
}
FUNCNORETURN static ATTRNORETURN void External_Driver_Get(void)
{
I_Error("External_Driver_Get not supported at this time");
}
FUNCNORETURN static ATTRNORETURN void External_Driver_Send(void)
{
I_Error("External_Driver_Send not supported at this time");
}
FUNCNORETURN static ATTRNORETURN void External_Driver_FreeNode(INT32 nodenum)
{
nodenum = 0;
I_Error("External_Driver_FreeNode not supported at this time");
}

View file

@ -1,620 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1993-1996 by id Software, Inc.
// Portions Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief interface level code for sound
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include "../doomdef.h"
#include "../doomstat.h"
#include "../i_system.h"
#include "../i_sound.h"
#include "../z_zone.h"
#include "../m_argv.h"
#include "../m_misc.h"
#include "../w_wad.h"
#include "../s_sound.h"
#include "../console.h"
//### let's try with Allegro ###
#define alleg_mouse_unused
#define alleg_timer_unused
#define ALLEGRO_NO_KEY_DEFINES
#define alleg_keyboard_unused
#define alleg_joystick_unused
#define alleg_gfx_driver_unused
#define alleg_palette_unused
#define alleg_graphics_unused
#define alleg_vidmem_unused
#define alleg_flic_unused
//#define alleg_sound_unused we use it
#define alleg_file_unused
#define alleg_datafile_unused
#define alleg_math_unused
#define alleg_gui_unused
#include <allegro.h>
//### end of Allegro include ###
//allegro has 256 virtual voices
// warning should by a power of 2
#define VIRTUAL_VOICES 256
#define VOICESSHIFT 8
// Needed for calling the actual sound output.
#define SAMPLECOUNT 512
//
// this function converts raw 11khz, 8-bit data to a SAMPLE* that allegro uses
// it is need cuz allegro only loads samples from wavs and vocs
//added:11-01-98: now reads the frequency from the rawdata header.
// dsdata points a 4 UINT16 header:
// +0 : value 3 what does it mean?
// +2 : sample rate, either 11025 or 22050.
// +4 : number of samples, each sample is a single byte since it's 8bit
// +6 : value 0
static inline SAMPLE *raw2SAMPLE(UINT8 *dsdata, size_t len)
{
SAMPLE *spl;
spl=Z_Malloc(sizeof (SAMPLE),PU_SOUND,NULL);
if (spl==NULL)
I_Error("Raw2Sample : no more free mem");
spl->bits = 8;
spl->stereo = 0;
spl->freq = *((UINT16 *)dsdata+1); //mostly 11025, but some at 22050.
spl->len = len-8;
spl->priority = 255; //priority;
spl->loop_start = 0;
spl->loop_end = len-8;
spl->param = -1;
spl->data=(void *)(dsdata+8); //skip the 8bytes header
return spl;
}
// This function loads the sound data from the WAD lump,
// for single sound.
//
void *I_GetSfx (sfxinfo_t * sfx)
{
UINT8 *dssfx;
if (sfx->lumpnum == LUMPERROR)
sfx->lumpnum = S_GetSfxLumpNum (sfx);
sfx->length = W_LumpLength (sfx->lumpnum);
dssfx = (UINT8 *) W_CacheLumpNum (sfx->lumpnum, PU_SOUND);
//_go32_dpmi_lock_data(dssfx,size);
// convert raw data and header from Doom sfx to a SAMPLE for Allegro
return (void *)raw2SAMPLE (dssfx, sfx->length);
}
void I_FreeSfx (sfxinfo_t *sfx)
{
if (sfx->lumpnum == LUMPERROR)
return;
// free sample data
if ( sfx->data )
Z_Free((UINT8 *) ((SAMPLE *)sfx->data)->data - 8);
Z_Free(sfx->data); // Allegro SAMPLE structure
sfx->data = NULL;
sfx->lumpnum = LUMPERROR;
}
FUNCINLINE static ATTRINLINE int Volset(int vol)
{
return (vol*255/31);
}
void I_SetSfxVolume(INT32 volume)
{
if (sound_disabled)
return;
set_volume (Volset(volume),-1);
}
//
// Starting a sound means adding it
// to the current list of active sounds
// in the internal channels.
// As the SFX info struct contains
// e.g. a pointer to the raw data,
// it is ignored.
// As our sound handling does not handle
// priority, it is ignored.
// Pitching (that is, increased speed of playback)
// is set, but currently not used by mixing.
//
INT32 I_StartSound ( sfxenum_t id,
INT32 vol,
INT32 sep,
INT32 pitch,
INT32 priority,
INT32 channel)
{
int voice;
(void)channel;
if (sound_disabled)
return 0;
// UNUSED
priority = 0;
pitch = (pitch-128)/2+128;
voice = play_sample(S_sfx[id].data,vol,sep,(pitch*1000)/128,0);
// Returns a handle
return (id<<VOICESSHIFT)+voice;
}
void I_StopSound (INT32 handle)
{
// You need the handle returned by StartSound.
// Would be looping all channels,
// tracking down the handle,
// an setting the channel to zero.
int voice=handle & (VIRTUAL_VOICES-1);
if (sound_disabled)
return;
if (voice_check(voice)==S_sfx[handle>>VOICESSHIFT].data)
deallocate_voice(voice);
}
INT32 I_SoundIsPlaying(INT32 handle)
{
if (sound_disabled)
return FALSE;
if (voice_check(handle & (VIRTUAL_VOICES-1))==S_sfx[handle>>VOICESSHIFT].data)
return TRUE;
return FALSE;
}
// cut and past from ALLEGRO he don't share it :(
static inline int absolute_freq(int freq, SAMPLE *spl)
{
if (freq == 1000)
return spl->freq;
else
return (spl->freq * freq) / 1000;
}
void I_UpdateSoundParams( INT32 handle,
INT32 vol,
INT32 sep,
INT32 pitch)
{
// I fail too see that this is used.
// Would be using the handle to identify
// on which channel the sound might be active,
// and resetting the channel parameters.
int voice=handle & (VIRTUAL_VOICES-1);
int numsfx=handle>>VOICESSHIFT;
if (sound_disabled)
return;
if (voice_check(voice)==S_sfx[numsfx].data)
{
voice_set_volume(voice, vol);
voice_set_pan(voice, sep);
voice_set_frequency(voice, absolute_freq(pitch*1000/128,
S_sfx[numsfx].data));
}
}
void I_ShutdownSound(void)
{
// Wait till all pending sounds are finished.
//added:03-01-98:
if ( !sound_started )
return;
//added:08-01-98: remove_sound() explicitly because we don't use
// Allegro's allegro_exit();
remove_sound();
sound_started = false;
}
static char soundheader[] = "sound";
#if ALLEGRO_VERSION == 3
static char soundvar[] = "sb_freq";
#else
static char soundvar[] = "sound_freq";
#endif
void I_StartupSound(void)
{
int sfxcard,midicard;
#if ALLEGRO_VERSION == 3
char err[255];
#endif
if (sound_disabled)
sfxcard=DIGI_NONE;
else
sfxcard=DIGI_AUTODETECT;
if (midi_disabled)
midicard=MIDI_NONE;
else
midicard=MIDI_AUTODETECT; //DetectMusicCard();
digital_disabled=true; //Alam: No OGG/MP3/IT/MOD support
// Secure and configure sound device first.
CONS_Printf("I_StartupSound: ");
//Fab:25-04-98:note:install_sound will check for sound settings
// in the sound.cfg or allegro.cfg, in the current directory,
// or the directory pointed by 'ALLEGRO' env var.
#if ALLEGRO_VERSION == 3
if (install_sound(sfxcard,midicard,NULL)!=0)
{
sprintf (err,"Sound init error : %s\n",allegro_error);
CONS_Error (err);
sound_disabled=true;
midi_disabled=true;
}
else
{
CONS_Printf(" configured audio device\n" );
}
//added:08-01-98:we use a similar startup/shutdown scheme as Allegro.
I_AddExitFunc(I_ShutdownSound);
#endif
sound_started = true;
CV_SetValue(&cv_samplerate,get_config_int(soundheader,soundvar,cv_samplerate.value));
}
//
// MUSIC API.
// Still no music done.
// Remains. Dummies.
//
static MIDI* currsong; //im assuming only 1 song will be played at once
static int islooping=0;
static int musicdies=-1;
UINT8 music_started=0;
boolean songpaused=false;
/// ------------------------
// MUSIC SYSTEM
/// ------------------------
/* load_midi_mem:
* Loads a standard MIDI file from memory, returning a pointer to
* a MIDI structure, * or NULL on error.
* It is the load_midi from Allegro modified to load it from memory
*/
static MIDI *load_midi_mem(char *mempointer,int *e)
{
int c = *e;
long data=0;
unsigned char *fp;
MIDI *midi;
int num_tracks=0;
fp = (void *)mempointer;
if (!fp)
return NULL;
midi = malloc(sizeof (MIDI)); /* get some memory */
if (!midi)
return NULL;
for (c=0; c<MIDI_TRACKS; c++)
{
midi->track[c].data = NULL;
midi->track[c].len = 0;
}
fp+=4+4; // header size + 'chunk' size
swab(fp,&data,2); // convert to intel-endian
fp+=2; /* MIDI file type */
if ((data != 0) && (data != 1)) // only type 0 and 1 are suported
return NULL;
swab(fp,&num_tracks,2); /* number of tracks */
fp+=2;
if ((num_tracks < 1) || (num_tracks > MIDI_TRACKS))
return NULL;
swab(fp,&data,2); /* beat divisions */
fp+=2;
midi->divisions = ABS(data);
for (c=0; c<num_tracks; c++)
{ /* read each track */
if (memcmp(fp, "MTrk", 4))
return NULL;
fp+=4;
//swab(fp,&data,4); don't work !!!!??
((char *)&data)[0]=fp[3];
((char *)&data)[1]=fp[2];
((char *)&data)[2]=fp[1];
((char *)&data)[3]=fp[0];
fp+=4;
midi->track[c].len = data;
midi->track[c].data = fp;
fp+=data;
}
lock_midi(midi);
return midi;
}
void I_InitMusic(void)
{
if (midi_disabled)
return;
I_AddExitFunc(I_ShutdownMusic);
music_started = true;
songpaused = false;
}
void I_ShutdownMusic(void)
{
if ( !music_started )
return;
I_StopSong();
music_started=false;
}
/// ------------------------
// MUSIC PROPERTIES
/// ------------------------
musictype_t I_SongType(void)
{
if (currsong)
return MU_MID;
else
return MU_NONE;
}
boolean I_SongPlaying()
{
return (boolean)currsong;
}
boolean I_SongPaused()
{
return songpaused;
}
/// ------------------------
// MUSIC EFFECTS
/// ------------------------
boolean I_SetSongSpeed(float speed)
{
(void)speed;
return false;
}
/// ------------------------
// MUSIC SEEKING
/// ------------------------
UINT32 I_GetSongLength(void)
{
return 0;
}
boolean I_SetSongLoopPoint(UINT32 looppoint)
{
(void)looppoint;
return false;
}
UINT32 I_GetSongLoopPoint(void)
{
return 0;
}
boolean I_SetSongPosition(UINT32 position)
{
(void)position;
return false;
}
UINT32 I_GetSongPosition(void)
{
return 0;
}
/// ------------------------
// MUSIC PLAYBACK
/// ------------------------
boolean I_LoadSong(char *data, size_t len)
{
int e = len; //Alam: For error
if (midi_disabled)
return 0;
if (memcmp(data,"MThd",4)==0) // support mid file in WAD !!!
{
currsong=load_midi_mem(data,&e);
}
else
{
CONS_Printf("Music Lump is not a MIDI lump\n");
return 0;
}
if (currsong==NULL)
{
CONS_Printf("Not a valid mid file : %d\n",e);
return 0;
}
return 1;
}
void I_UnloadSong(void)
{
handle = 0;
if (midi_disabled)
return;
//destroy_midi(currsong);
}
boolean I_PlaySong(boolean looping)
{
handle = 0;
if (midi_disabled)
return false;
islooping = looping;
musicdies = gametic + NEWTICRATE*30;
if (play_midi(currsong,looping)==0)
return true;
return false;
}
void I_StopSong(void)
{
handle = 0;
if (midi_disabled)
return;
islooping = 0;
musicdies = 0;
stop_midi();
songpaused = false;
}
void I_PauseSong (INT32 handle)
{
handle = 0;
if (midi_disabled)
return;
midi_pause();
songpaused = true;
}
void I_ResumeSong (INT32 handle)
{
handle = 0;
if (midi_disabled)
return;
midi_resume();
songpaused = false;
}
void I_SetMusicVolume(INT32 volume)
{
if (midi_disabled)
return;
// Now set volume on output device.
set_volume (-1, Volset(volume));
}
boolean I_SetSongTrack(INT32 track)
{
(void)track;
return false;
}
// Is the song playing?
#if 0
int I_QrySongPlaying(int handle)
{
if (midi_disabled)
return 0;
//return islooping || musicdies > gametic;
return (midi_pos==-1);
}
#endif
/// ------------------------
// MUSIC FADING
/// ------------------------
void I_SetInternalMusicVolume(UINT8 volume)
{
(void)volume;
}
void I_StopFadingSong(void)
{
}
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void));
{
(void)target_volume;
(void)source_volume;
(void)ms;
return false;
}
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
{
(void)target_volume;
(void)ms;
return false;
}
boolean I_FadeOutStopSong(UINT32 ms)
{
(void)ms;
return false;
}
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
{
(void)ms;
(void)looping;
return false;
}

File diff suppressed because it is too large Load diff

View file

@ -1,345 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1993-1996 by id Software, Inc.
// Portions Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief hardware and software level, screen and video i/o, refresh,
/// setup ... a big mess. Got to clean that up!
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/time.h>
#include <sys/types.h>
//#include <sys/socket.h>
#include <netinet/in.h>
//#include <errnos.h>
#include <signal.h>
#include <go32.h>
#include <pc.h>
#include <dpmi.h>
#include <dos.h>
#include <sys/nearptr.h>
#include "../doomdef.h"
#include "../i_system.h"
#include "../v_video.h"
#include "../m_argv.h"
#include "vid_vesa.h"
#include "../i_video.h"
//dosstuff -newly added
static unsigned long dascreen;
static int gfx_use_vesa1;
boolean highcolor;
#define SCREENDEPTH 1 // bytes per pixel, do NOT change.
rendermode_t rendermode=render_soft;
//
// I_OsPolling
//
void I_OsPolling(void)
{
I_GetEvent();
//i dont think i have to do anything else here
}
//
// I_UpdateNoBlit
//
void I_UpdateNoBlit (void)
{
// what is this?
}
//profile stuff ---------------------------------------------------------
//added:16-01-98:wanted to profile the VID_BlitLinearScreen() asm code.
//#define TIMING //uncomment this to enable profiling
#ifdef TIMING
#include "../p5prof.h"
static INT64 mycount;
static INT64 mytotal = 0;
static unsigned long nombre = NEWTICRATE*10;
//static char runtest[10][80];
#endif
//profile stuff ---------------------------------------------------------
//
// I_FinishUpdate
//
static void I_BlitScreenVesa1(void); //see later
void I_FinishUpdate (void)
{
if (marathonmode)
SCR_DisplayMarathonInfo();
// draw captions if enabled
if (cv_closedcaptioning.value)
SCR_ClosedCaptions();
// draw FPS if enabled
if (cv_ticrate.value)
SCR_DisplayTicRate();
if (cv_showping.value && netgame && consoleplayer != serverplayer)
SCR_DisplayLocalPing();
//blast it to the screen
// this code sucks
//memcpy(dascreen,screens[0],screenwidth*screenheight);
//added:03-01-98: I tried to I_WaitVBL(1) here, but it slows down
// the game when the view becomes complicated, it looses ticks
if (cv_vidwait.value)
I_WaitVBL(1);
//added:16-01-98:profile screen blit.
#ifdef TIMING
ProfZeroTimer();
#endif
//added:08-01-98: support vesa1 bank change, without Allegro's BITMAP screen.
if ( gfx_use_vesa1 )
{
I_Error("Banked screen update not finished for dynamic res\n");
I_BlitScreenVesa1(); //blast virtual to physical screen.
}
else
{
//added:16-01-98:use quickie asm routine, last 2 args are
// src and dest rowbytes
// (memcpy is as fast as this one...)
VID_BlitLinearScreen(screens[0], vid.direct,
vid.width*vid.bpp, vid.height,
vid.width*vid.bpp, vid.rowbytes );
}
#ifdef TIMING
RDMSR(0x10,&mycount);
mytotal += mycount; //64bit add
if (nombre--==0)
I_Error("ScreenBlit CPU Spy reports: 0x%d %d\n", *((int *)&mytotal+1),
(int)mytotal );
#endif
}
//
// I_UpdateNoVsync
//
void I_UpdateNoVsync(void)
{
int real_vidwait = cv_vidwait.value;
cv_vidwait.value = 0;
I_FinishUpdate();
cv_vidwait.value = real_vidwait;
}
//
// I_ReadScreen
//
void I_ReadScreen (UINT8 *scr)
{
VID_BlitLinearScreen(screens[0], scr,
vid.width*vid.bpp, vid.height,
vid.width*vid.bpp, vid.rowbytes );
}
void I_SetPalette (RGBA_t *palette)
{
int i;
outportb(0x3c8,0);
for (i=0;i<256;i++,palette++)
{
outportb(0x3c9,palette->s.red>>2);
outportb(0x3c9,palette->s.green>>2);
outportb(0x3c9,palette->s.blue>>2);
}
}
//added 29-12-1997
/*==========================================================================*/
// I_BlastScreen : copy the virtual screen buffer to the physical screen mem
// using bank switching if needed.
/*==========================================================================*/
static void I_BlitScreenVesa1(void)
{
#define VIDBANKSIZE (1<<16)
#define VIDBANKSIZEMASK (VIDBANKSIZE-1) // defines ahoy!
__dpmi_regs r;
UINT8 *p_src;
long i;
long virtualsize;
// virtual screen buffer size
virtualsize = vid.rowbytes * vid.height * SCREENDEPTH;
p_src = screens[0];
for (i=0; virtualsize > 0; i++ )
{
r.x.ax = 0x4f05;
r.x.bx = 0x0;
r.x.cx = 0x0;
r.x.dx = i;
__dpmi_int(0x10,&r); //set bank
M_Memcpy((UINT8 *)dascreen,p_src,(virtualsize < VIDBANKSIZE) ? virtualsize : VIDBANKSIZE );
p_src += VIDBANKSIZE;
virtualsize -= VIDBANKSIZE;
}
}
//added:08-01-98: now we use Allegro's set_gfx_mode, but we want to
// restore the exact text mode that was before.
static INT16 myOldVideoMode;
static inline void I_SaveOldVideoMode(void)
{
__dpmi_regs r;
r.x.ax = 0x4f03; // Return current video mode
__dpmi_int(0x10,&r);
if ( r.x.ax != 0x4f )
myOldVideoMode = -1;
else
myOldVideoMode = r.x.bx;
}
//
// Close the screen, restore previous video mode.
//
void I_ShutdownGraphics (void)
{
__dpmi_regs r;
rendermode = render_none;
if ( !graphics_started )
return;
// free the last video mode screen buffers
if (vid.buffer)
free (vid.buffer);
/* Restore old video mode */
if (myOldVideoMode!=-1)
{
/* Restore old video mode */
r.x.ax = 0x4f02; // Set Super VGA video mode
r.x.bx = myOldVideoMode;
__dpmi_int(0x10,&r);
// Boris: my s3 don't do a cls because "win95" :<
clrscr();
}
else // no vesa put the normal video mode
{
r.x.ax = 0x03;
__dpmi_int(0x10,&r);
}
graphics_started = false;
}
//added:08-01-98:
// Set VESA1 video mode, coz Allegro set_gfx_mode a larger screenwidth...
//
#if 0
int set_vesa1_mode( int width, int height )
{
__dpmi_regs r;
// setup video mode.
r.x.ax = 0x4f02;
if ( ( width==320 )&&( height==200 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x13; // 320x 200x1 (256 colors)
else
if ( ( width==320 )&&( height==240 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x154; // 320x 240x1 (256 colors)
else
if ( ( width==320 )&&( height==400 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x155; // 320x 400x1 (256 colors)
else
if ( ( width==640 )&&( height==400 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x100; // 640x 400x1 (256 colors)
else
if ( ( width==640 )&&( height==480 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x101; // 640x 480x1 (256 colors)
else
if ( ( width==800 )&&( height==600 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x103; // 800x 600x1 (256 colors)
else
if ( ( width==1024)&&( height==768 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x105; //1024x 768x1 (256 colors)
else
I_Error("I_SetVesa1Mode: video mode not supported.");
// enter graphics mode.
__dpmi_int(0x10,&r);
if ( r.x.ax != 0x4f )
I_Error("I_SetVesa1Mode: init video mode failed !");
return 0;
}
#endif
//added:08-01-98: now uses Allegro to setup Linear Frame Buffer video modes.
//
// Initialize video mode, setup dynamic screen size variables,
// and allocate screens.
//
void I_StartupGraphics(void)
{
//added:26-01-98: VID_Init() must be done only once,
// use VID_SetMode() to change vid mode while in the game.
if ( graphics_started )
return;
// remember the exact screen mode we were...
I_SaveOldVideoMode();
CONS_Printf("Vid_Init...");
// 0 for 256 color, else use highcolor modes
highcolor = M_CheckParm ("-highcolor");
VID_Init();
//gfx_use_vesa1 = false;
//added:03-01-98: register exit code for graphics
I_AddExitFunc(I_ShutdownGraphics);
graphics_started = true;
}
void VID_StartupOpenGL(void) {}

View file

@ -1,773 +0,0 @@
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Some definitions for internal use by the library code.
* This should not be included by user programs.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*/
#ifndef INTERNAL_H
#define INTERNAL_H
#include "allegro.h"
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Some definitions for internal use by the library code.
* This should not be included by user programs.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*/
#ifndef INTERNDJ_H
#define INTERNDJ_H
#ifndef DJGPP
#error This file should only be used by the djgpp version of Allegro
#endif
#include <dos.h>
/* file access macros */
#define FILE_OPEN(filename, handle) handle = open(filename, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR)
#define FILE_CREATE(filename, handle) handle = open(filename, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)
#define FILE_CLOSE(handle) close(handle)
#define FILE_READ(handle, buf, size, sz) sz = read(handle, buf, size)
#define FILE_WRITE(handle, buf, size, sz) sz = write(handle, buf, size)
#define FILE_SEARCH_STRUCT struct ffblk
#define FILE_FINDFIRST(filename, attrib, dta) findfirst(filename, dta, attrib)
#define FILE_FINDNEXT(dta) findnext(dta)
#define FILE_ATTRIB ff_attrib
#define FILE_SIZE ff_fsize
#define FILE_NAME ff_name
#define FILE_TIME ff_ftime
#define FILE_DATE ff_fdate
/* macros to enable and disable interrupts */
#define DISABLE() asm volatile ("cli")
#define ENABLE() asm volatile ("sti")
__INLINE__ void enter_critical(void)
{
if (windows_version >= 3) {
__dpmi_regs r;
r.x.ax = 0x1681;
__dpmi_int(0x2F, &r);
}
DISABLE();
}
__INLINE__ void exit_critical(void)
{
if (windows_version >= 3) {
__dpmi_regs r;
r.x.ax = 0x1682;
__dpmi_int(0x2F, &r);
}
ENABLE();
}
/* interrupt hander stuff */
#define _map_irq(irq) (((irq)>7) ? ((irq)+104) : ((irq)+8))
int _install_irq(int num, int (*handler)(void));
void _remove_irq(int num);
void _restore_irq(int irq);
void _enable_irq(int irq);
void _disable_irq(int irq);
#define _eoi(irq) { outportb(0x20, 0x20); if ((irq)>7) outportb(0xA0, 0x20); }
typedef struct _IRQ_HANDLER
{
int (*handler)(void); /* our C handler */
int number; /* irq number */
__dpmi_paddr old_vector; /* original protected mode vector */
} _IRQ_HANDLER;
/* DPMI memory mapping routines */
int _create_physical_mapping(unsigned long *linear, int *segment, unsigned long physaddr, int size);
void _remove_physical_mapping(unsigned long *linear, int *segment);
int _create_linear_mapping(unsigned long *linear, unsigned long physaddr, int size);
void _remove_linear_mapping(unsigned long *linear);
int _create_selector(int *segment, unsigned long linear, int size);
void _remove_selector(int *segment);
void _unlock_dpmi_data(void *addr, int size);
/* bank switching routines */
void _accel_bank_stub(void);
void _accel_bank_stub_end(void);
void _accel_bank_switch (void);
void _accel_bank_switch_end(void);
void _vesa_window_1(void);
void _vesa_window_1_end(void);
void _vesa_window_2(void);
void _vesa_window_2_end(void);
void _vesa_pm_window_1(void);
void _vesa_pm_window_1_end(void);
void _vesa_pm_window_2(void);
void _vesa_pm_window_2_end(void);
void _vesa_pm_es_window_1(void);
void _vesa_pm_es_window_1_end(void);
void _vesa_pm_es_window_2(void);
void _vesa_pm_es_window_2_end(void);
/* stuff for the VESA and VBE/AF drivers */
extern __dpmi_regs _dpmi_reg;
extern int _window_2_offset;
extern void (*_pm_vesa_switcher)(void);
extern void (*_pm_vesa_scroller)(void);
extern void (*_pm_vesa_pallete)(void);
extern int _mmio_segment;
extern void *_accel_driver;
extern int _accel_active;
extern void *_accel_set_bank;
extern void *_accel_idle;
void _fill_vbeaf_libc_exports(void *ptr);
void _fill_vbeaf_pmode_exports(void *ptr);
/* sound lib stuff */
extern int _fm_port;
extern int _mpu_port;
extern int _mpu_irq;
extern int _sb_freq;
extern int _sb_port;
extern int _sb_dma;
extern int _sb_irq;
int _sb_read_dsp_version(void);
int _sb_reset_dsp(int data);
void _sb_voice(int state);
int _sb_set_mixer(int digi_volume, int midi_volume);
void _mpu_poll(void);
int _dma_allocate_mem(int bytes, int *sel, unsigned long *phys);
void _dma_start(int channel, unsigned long addr, int size, int auto_init, int input);
void _dma_stop(int channel);
unsigned long _dma_todo(int channel);
void _dma_lock_mem(void);
#endif /* ifndef INTERNDJ_H */
/* flag for how many times we have been initialised */
extern int _allegro_count;
/* some Allegro functions need a block of scratch memory */
extern void *_scratch_mem;
extern int _scratch_mem_size;
__INLINE__ void _grow_scratch_mem(int size)
{
if (size > _scratch_mem_size) {
size = (size+1023) & 0xFFFFFC00;
_scratch_mem = realloc(_scratch_mem, size);
_scratch_mem_size = size;
}
}
/* list of functions to call at program cleanup */
void _add_exit_func(void (*func)(void));
void _remove_exit_func(void (*func)(void));
/* reads a translation file into memory */
void _load_config_text(void);
/* various bits of mouse stuff */
void _set_mouse_range(void);
extern BITMAP *_mouse_screen;
extern BITMAP *_mouse_sprite, *_mouse_pointer;
extern int _mouse_x_focus, _mouse_y_focus;
extern int _mouse_width, _mouse_height;
/* various bits of timer stuff */
extern int _timer_use_retrace;
extern volatile int _retrace_hpp_value;
/* caches and tables for svga bank switching */
extern int _last_bank_1, _last_bank_2;
extern int *_gfx_bank;
/* bank switching routines */
void _stub_bank_switch (void);
void _stub_bank_switch_end(void);
/* stuff for setting up bitmaps */
void _check_gfx_virginity(void);
BITMAP *_make_bitmap(int w, int h, unsigned long addr, GFX_DRIVER *driver, int color_depth, int bpl);
void _sort_out_virtual_width(int *width, GFX_DRIVER *driver);
GFX_VTABLE *_get_vtable(int color_depth);
extern GFX_VTABLE _screen_vtable;
extern int _sub_bitmap_id_count;
extern int _textmode;
#define BYTES_PER_PIXEL(bpp) (((int)(bpp) + 7) / 8)
int _color_load_depth(int depth);
extern int _color_conv;
BITMAP *_fixup_loaded_bitmap(BITMAP *bmp, PALETTE pal, int bpp);
/* VGA register access routines */
void _vga_vsync(void);
void _vga_set_pallete_range(PALLETE p, int from, int to, int vsync);
extern int _crtc;
/* _read_vga_register:
* Reads the contents of a VGA register.
*/
__INLINE__ int _read_vga_register(int port, int index)
{
if (port==0x3C0)
inportb(_crtc+6);
outportb(port, index);
return inportb(port+1);
}
/* _write_vga_register:
* Writes a byte to a VGA register.
*/
__INLINE__ void _write_vga_register(int port, int index, int v)
{
if (port==0x3C0) {
inportb(_crtc+6);
outportb(port, index);
outportb(port, v);
}
else {
outportb(port, index);
outportb(port+1, v);
}
}
/* _alter_vga_register:
* Alters specific bits of a VGA register.
*/
__INLINE__ void _alter_vga_register(int port, int index, int mask, int v)
{
int temp;
temp = _read_vga_register(port, index);
temp &= (~mask);
temp |= (v & mask);
_write_vga_register(port, index, temp);
}
/* _vsync_out_h:
* Waits until the VGA is not in either a vertical or horizontal retrace.
*/
__INLINE__ void _vsync_out_h(void)
{
do {
} while (inportb(0x3DA) & 1);
}
/* _vsync_out_v:
* Waits until the VGA is not in a vertical retrace.
*/
__INLINE__ void _vsync_out_v(void)
{
do {
} while (inportb(0x3DA) & 8);
}
/* _vsync_in:
* Waits until the VGA is in the vertical retrace period.
*/
__INLINE__ void _vsync_in(void)
{
if (_timer_use_retrace) {
int t = retrace_count;
do {
} while (t == retrace_count);
}
else {
do {
} while (!(inportb(0x3DA) & 8));
}
}
/* _write_hpp:
* Writes to the VGA pelpan register.
*/
__INLINE__ void _write_hpp(int value)
{
if (_timer_use_retrace) {
_retrace_hpp_value = value;
do {
} while (_retrace_hpp_value == value);
}
else {
do {
} while (!(inportb(0x3DA) & 8));
_write_vga_register(0x3C0, 0x33, value);
}
}
void _set_vga_virtual_width(int old_width, int new_width);
/* current drawing mode */
extern int _drawing_mode;
extern BITMAP *_drawing_pattern;
extern int _drawing_x_anchor;
extern int _drawing_y_anchor;
extern unsigned int _drawing_x_mask;
extern unsigned int _drawing_y_mask;
/* graphics drawing routines */
void _normal_line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
void _normal_rectfill(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
int _linear_getpixel8(struct BITMAP *bmp, int x, int y);
void _linear_putpixel8(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline8(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline8(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_sprite8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_v_flip8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_h_flip8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_vh_flip8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_trans_sprite8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite8(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite8(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite8(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _linear_draw_character8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_textout_fixed8(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _linear_blit8(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_blit_backward8(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_masked_blit8(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_clear_to_color8(struct BITMAP *bitmap, int color);
#ifdef ALLEGRO_COLOR16
void _linear_putpixel15(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline15(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline15(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_trans_sprite15(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite15(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite15(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite15(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite15(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
int _linear_getpixel16(struct BITMAP *bmp, int x, int y);
void _linear_putpixel16(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline16(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline16(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_sprite16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_256_sprite16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_v_flip16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_h_flip16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_vh_flip16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_trans_sprite16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite16(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite16(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite16(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _linear_draw_character16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_textout_fixed16(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _linear_blit16(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_blit_backward16(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_masked_blit16(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_clear_to_color16(struct BITMAP *bitmap, int color);
#endif
#ifdef ALLEGRO_COLOR24
int _linear_getpixel24(struct BITMAP *bmp, int x, int y);
void _linear_putpixel24(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline24(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline24(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_sprite24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_256_sprite24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_v_flip24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_h_flip24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_vh_flip24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_trans_sprite24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite24(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite24(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite24(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _linear_draw_character24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_textout_fixed24(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _linear_blit24(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_blit_backward24(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_masked_blit24(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_clear_to_color24(struct BITMAP *bitmap, int color);
#endif
#ifdef ALLEGRO_COLOR32
int _linear_getpixel32(struct BITMAP *bmp, int x, int y);
void _linear_putpixel32(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline32(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline32(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_sprite32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_256_sprite32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_v_flip32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_h_flip32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_vh_flip32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_trans_sprite32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite32(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite32(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite32(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _linear_draw_character32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_textout_fixed32(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _linear_blit32(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_blit_backward32(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_masked_blit32(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_clear_to_color32(struct BITMAP *bitmap, int color);
#endif
int _x_getpixel(struct BITMAP *bmp, int x, int y);
void _x_putpixel(struct BITMAP *bmp, int x, int y, int color);
void _x_vline(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _x_hline(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _x_draw_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_sprite_v_flip(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_sprite_h_flip(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_sprite_vh_flip(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_trans_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_lit_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _x_draw_rle_sprite(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _x_draw_trans_rle_sprite(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _x_draw_lit_rle_sprite(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _x_draw_character(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _x_textout_fixed(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _x_blit_from_memory(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_blit_to_memory(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_blit(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_blit_forward(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_blit_backward(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_masked_blit(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_clear_to_color(struct BITMAP *bitmap, int color);
/* asm helper for stretch_blit() */
void _do_stretch(BITMAP *source, BITMAP *dest, void *drawer, int sx, fixed sy, fixed syd, int dx, int dy, int dh, int color_depth);
/* number of fractional bits used by the polygon rasteriser */
#define POLYGON_FIX_SHIFT 18
/* bitfield specifying which polygon attributes need interpolating */
#define INTERP_FLAT 1
#define INTERP_1COL 2
#define INTERP_3COL 4
#define INTERP_FIX_UV 8
#define INTERP_Z 16
#define INTERP_FLOAT_UV 32
#define OPT_FLOAT_UV_TO_FIX 64
#define COLOR_TO_RGB 128
/* information for polygon scanline fillers */
typedef struct POLYGON_SEGMENT
{
fixed u, v, du, dv; /* fixed point u/v coordinates */
fixed c, dc; /* single color gouraud shade values */
fixed r, g, b, dr, dg, db; /* RGB gouraud shade values */
float z, dz; /* polygon depth (1/z) */
float fu, fv, dfu, dfv; /* floating point u/v coordinates */
unsigned char *texture; /* the texture map */
int umask, vmask, vshift; /* texture map size information */
int seg; /* destination bitmap selector */
} POLYGON_SEGMENT;
/* an active polygon edge */
typedef struct POLYGON_EDGE
{
int top; /* top y position */
int bottom; /* bottom y position */
fixed x, dx; /* fixed point x position and gradient */
fixed w; /* width of line segment */
POLYGON_SEGMENT dat; /* texture/gouraud information */
struct POLYGON_EDGE *prev; /* doubly linked list */
struct POLYGON_EDGE *next;
} POLYGON_EDGE;
/* prototype for the scanline filler functions */
typedef void (*SCANLINE_FILLER)(unsigned long addr, int w, POLYGON_SEGMENT *info);
/* polygon helper functions */
extern SCANLINE_FILLER _optim_alternative_drawer;
POLYGON_EDGE *_add_edge(POLYGON_EDGE *list, POLYGON_EDGE *edge, int sort_by_x);
POLYGON_EDGE *_remove_edge(POLYGON_EDGE *list, POLYGON_EDGE *edge);
void _fill_3d_edge_structure(POLYGON_EDGE *edge, V3D *v1, V3D *v2, int flags, BITMAP *bmp);
void _fill_3d_edge_structure_f(POLYGON_EDGE *edge, V3D_f *v1, V3D_f *v2, int flags, BITMAP *bmp);
SCANLINE_FILLER _get_scanline_filler(int type, int *flags, POLYGON_SEGMENT *info, BITMAP *texture, BITMAP *bmp);
void _clip_polygon_segment(POLYGON_SEGMENT *info, int gap, int flags);
/* polygon scanline filler functions */
void _poly_scanline_gcol8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb8x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit15d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit15d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit16d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit16d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit24d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit24d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit32d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit32d(unsigned long addr, int w, POLYGON_SEGMENT *info);
/* sound lib stuff */
extern int _digi_volume;
extern int _midi_volume;
extern int _flip_pan;
extern int _sound_hq;
extern int (*_midi_init)(void);
extern void (*_midi_exit)(void);
int _midi_allocate_voice(int min, int max);
extern volatile long _midi_tick;
int _digmid_find_patches(char *dir, char *file);
#define VIRTUAL_VOICES 256
typedef struct /* a virtual (as seen by the user) soundcard voice */
{
SAMPLE *sample; /* which sample are we playing? (NULL = free) */
int num; /* physical voice number (-1 = been killed off) */
int autokill; /* set to free the voice when the sample finishes */
long time; /* when we were started (for voice allocation) */
int priority; /* how important are we? */
} VOICE;
extern VOICE _voice[VIRTUAL_VOICES];
typedef struct /* a physical (as used by hardware) soundcard voice */
{
int num; /* the virtual voice currently using me (-1 = free) */
int playmode; /* are we looping? */
int vol; /* current volume (fixed point .12) */
int dvol; /* volume delta, for ramping */
int target_vol; /* target volume, for ramping */
int pan; /* current pan (fixed point .12) */
int dpan; /* pan delta, for sweeps */
int target_pan; /* target pan, for sweeps */
int freq; /* current frequency (fixed point .12) */
int dfreq; /* frequency delta, for sweeps */
int target_freq; /* target frequency, for sweeps */
} PHYS_VOICE;
extern PHYS_VOICE _phys_voice[DIGI_VOICES];
#define MIXER_DEF_SFX 8
#define MIXER_MAX_SFX 64
int _mixer_init(int bufsize, int freq, int stereo, int is16bit, int *voices);
void _mixer_exit(void);
void _mix_some_samples(unsigned long buf, unsigned short seg, int issigned);
void _mixer_init_voice(int voice, SAMPLE *sample);
void _mixer_release_voice(int voice);
void _mixer_start_voice(int voice);
void _mixer_stop_voice(int voice);
void _mixer_loop_voice(int voice, int loopmode);
int _mixer_get_position(int voice);
void _mixer_set_position(int voice, int position);
int _mixer_get_volume(int voice);
void _mixer_set_volume(int voice, int volume);
void _mixer_ramp_volume(int voice, int time, int endvol);
void _mixer_stop_volume_ramp(int voice);
int _mixer_get_frequency(int voice);
void _mixer_set_frequency(int voice, int frequency);
void _mixer_sweep_frequency(int voice, int time, int endfreq);
void _mixer_stop_frequency_sweep(int voice);
int _mixer_get_pan(int voice);
void _mixer_set_pan(int voice, int pan);
void _mixer_sweep_pan(int voice, int time, int endpan);
void _mixer_stop_pan_sweep(int voice);
void _mixer_set_echo(int voice, int strength, int delay);
void _mixer_set_tremolo(int voice, int rate, int depth);
void _mixer_set_vibrato(int voice, int rate, int depth);
/* dummy functions for the NoSound drivers */
int _dummy_detect(int input);
int _dummy_init(int input, int voices);
void _dummy_exit(int input);
int _dummy_mixer_volume(int volume);
void _dummy_init_voice(int voice, SAMPLE *sample);
void _dummy_noop1(int p);
void _dummy_noop2(int p1, int p2);
void _dummy_noop3(int p1, int p2, int p3);
int _dummy_get_position(int voice);
int _dummy_get(int voice);
void _dummy_raw_midi(unsigned char data);
int _dummy_load_patches(char *patches, char *drums);
void _dummy_adjust_patches(char *patches, char *drums);
void _dummy_key_on(int inst, int note, int bend, int vol, int pan);
/* from djgpp's libc, needed to find which directory we were run from */
extern int __crt0_argc;
extern char **__crt0_argv;
#endif /* ifndef INTERNAL_H */

View file

@ -1,22 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2005-2020 by Sonic Team Junior.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief Set Com port and speed for GDBStubs for DJGGP
///
/// copy and rename as rdb.h and set the defines below as needed
#define DEBUG_COM_PORT 2
#define DEBUG_COM_PORT_SPEED 9600

View file

@ -1,903 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief extended vesa VESA2.0 video modes i/o
#include <stdlib.h>
#include "../i_system.h" //I_Error()
#include "vid_vesa.h"
#include "../doomdef.h" //MAXVIDWIDTH, MAXVIDHEIGHT
#include "../screen.h"
#include <dpmi.h>
#include <go32.h>
#include <sys/farptr.h>
#include <sys/movedata.h>
#include <sys/segments.h>
#include <sys/nearptr.h>
#include "../console.h"
#include "../command.h" //added:21-03-98: vid_xxx commands
#include "../i_video.h"
// PROTOS
static vmode_t *VID_GetModePtr (int modenum);
static int VID_VesaGetModeInfo (int modenum);
static void VID_VesaGetExtraModes (void);
static INT32 VID_VesaInitMode (viddef_t *lvid, vmode_t *pcurrentmode);
static void VID_Command_NumModes_f (void);
static void VID_Command_ModeInfo_f (void);
static void VID_Command_ModeList_f (void);
static void VID_Command_Mode_f (void);
consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cv_stretch = {"stretch", "On", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#define VBEVERSION 2 // we need vesa2 or higher
// -----------------------------------------------------
#define MASK_LINEAR(addr) (addr & 0x000FFFFF)
#define RM_TO_LINEAR(addr) (((addr & 0xFFFF0000) >> 12) + (addr & 0xFFFF))
#define RM_OFFSET(addr) (addr & 0xF)
#define RM_SEGMENT(addr) ((addr >> 4) & 0xFFFF)
// -----------------------------------------------------
static int totalvidmem;
static vmode_t vesa_modes[MAX_VESA_MODES] = {{NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, 0}};
static vesa_extra_t vesa_extra[MAX_VESA_MODES];
//this is the only supported non-vesa mode : standard 320x200x256c.
#define NUMVGAVIDMODES 1
static INT32 VGA_InitMode (viddef_t *lvid, vmode_t *pcurrentmode);
static char vgamode1[] ="320x200";
static vmode_t vgavidmodes[NUMVGAVIDMODES] = {
{
NULL,
vgamode1,
320, 200, //(200.0/320.0)*(320.0/240.0),
320, 1, // rowbytes, bytes per pixel
0, 1,
NULL,
VGA_InitMode, 0
}
};
static char names[MAX_VESA_MODES][10];
//----------------------------i_video.c------------------------------------
// these ones should go to i_video.c, but I prefer keep them away from the
// doom sources until the vesa stuff is ok.
static int numvidmodes; //total number of video modes, vga, vesa1, vesa2.
static vmode_t *pvidmodes; //start of videomodes list.
static vmode_t *pcurrentmode; // the current active videomode.
//----------------------------i_video.c------------------------------------
// table des modes videos.
// seul le mode 320x200x256c standard VGA est support sans le VESA.
// ce mode est le mode numro 0 dans la liste.
typedef struct
{
int modenum; // vesa vbe2.0 modenum
int mode_attributes;
int winasegment;
int winbsegment;
int bytes_per_scanline; // bytes per logical scanline (+16)
int win; // window number (A=0, B=1)
int win_size; // window size (+6)
int granularity; // how finely i can set the window in vid mem (+4)
int width, height; // displayed width and height (+18, +20)
int bits_per_pixel; // er, better be 8, 15, 16, 24, or 32 (+25)
int bytes_per_pixel; // er, better be 1, 2, or 4
int memory_model; // and better be 4 or 6, packed or direct color (+27)
int num_pages; // number of complete frame buffer pages (+29)
int red_width; // the # of bits in the red component (+31)
int red_pos; // the bit position of the red component (+32)
int green_width; // etc.. (+33)
int green_pos; // (+34)
int blue_width; // (+35)
int blue_pos; // (+36)
int pptr;
int pagesize;
int numpages;
} modeinfo_t;
static vbeinfoblock_t vesainfo;
static vesamodeinfo_t vesamodeinfo;
// ------------------------------------------------------------------------
// DOS stuff
// ------------------------------------------------------------------------
static unsigned long conventional_memory = (unsigned long)-1;
FUNCINLINE static ATTRINLINE void map_in_conventional_memory(void)
{
if (conventional_memory == (unsigned long)-1)
{
if (__djgpp_nearptr_enable())
{
conventional_memory = __djgpp_conventional_base;
}
}
}
// Converts a flat 32 bit ptr to a realmode 0x12345 type ptr (seg<<4 + offs)
#if 0
unsigned int ptr2real(void *ptr)
{
map_in_conventional_memory();
return (int)ptr - conventional_memory;
}
#endif
// Converts 0x12345 (seg<<4+offs) realmode ptr to a flat 32bit ptr
FUNCINLINE static ATTRINLINE void *real2ptr(unsigned int real)
{
map_in_conventional_memory();
return (void *) (real + conventional_memory);
}
// ------------------------------------------------------------------------
/* ======================================================================== */
// Add the standard VGA video modes (only one now) to the video modes list.
/* ======================================================================== */
static inline void VGA_Init(void)
{
vgavidmodes[NUMVGAVIDMODES-1].pnext = pvidmodes;
pvidmodes = &vgavidmodes[0];
numvidmodes += NUMVGAVIDMODES;
}
//added:30-01-98: return number of video modes in pvidmodes list
INT32 VID_NumModes(void)
{
return numvidmodes;
}
//added:21-03-98: return info on video mode
FUNCINLINE static ATTRINLINE const char *VID_ModeInfo (int modenum, char **ppheader)
{
static const char *badmodestr = "Bad video mode number\n";
vmode_t *pv;
pv = VID_GetModePtr (modenum);
if (!pv)
{
if (ppheader)
*ppheader = NULL;
return badmodestr;
}
else
{
//if (ppheader)
// *ppheader = pv->header;
return pv->name;
}
}
//added:03-02-98: return a video mode number from the dimensions
INT32 VID_GetModeForSize( INT32 w, INT32 h)
{
vmode_t *pv;
int modenum;
pv = pvidmodes;
for (modenum=0; pv!=NULL; pv=pv->pnext,modenum++ )
{
if ( pv->width==(unsigned)w && pv->height==(unsigned)h )
return modenum;
}
return 0;
}
/* ======================================================================== */
//
/* ======================================================================== */
void VID_Init (void)
{
COM_AddCommand ("vid_nummodes", VID_Command_NumModes_f);
COM_AddCommand ("vid_modeinfo", VID_Command_ModeInfo_f);
COM_AddCommand ("vid_modelist", VID_Command_ModeList_f);
COM_AddCommand ("vid_mode", VID_Command_Mode_f);
CV_RegisterVar (&cv_vidwait);
CV_RegisterVar (&cv_stretch);
//setup the videmodes list,
// note that mode 0 must always be VGA mode 0x13
pvidmodes = NULL;
pcurrentmode = NULL;
numvidmodes = 0;
// setup the vesa_modes list
VID_VesaGetExtraModes ();
// the game boots in 320x200 standard VGA, but
// we need a highcolor mode to run the game in highcolor
if (highcolor && numvidmodes==0)
I_Error ("No 15bit highcolor VESA2 video mode found, cannot run in highcolor.\n");
// add the vga modes at the start of the modes list
VGA_Init();
#ifdef DEBUG
CONS_Printf("VID_SetMode(%d)\n",vid.modenum);
#endif
VID_SetMode (0); //vid.modenum);
#ifdef DEBUG
CONS_Printf("after VID_SetMode\n");
CONS_Printf("vid.width %d\n",vid.width);
CONS_Printf("vid.height %d\n",vid.height);
CONS_Printf("vid.buffer %x\n",vid.buffer);
CONS_Printf("vid.rowbytes %d\n",vid.rowbytes);
CONS_Printf("vid.numpages %d\n",vid.numpages);
CONS_Printf("vid.recalc %d\n",vid.recalc);
CONS_Printf("vid.direct %x\n",vid.direct);
#endif
}
// ========================================================================
// Returns a vmode_t from the video modes list, given a video mode number.
// ========================================================================
vmode_t *VID_GetModePtr (int modenum)
{
vmode_t *pv;
pv = pvidmodes;
if (!pv)
I_Error ("VID_error 1\n");
while (modenum--)
{
pv = pv->pnext;
if (!pv)
I_Error ("VID_error 2\n");
}
return pv;
}
//added:30-01-98:return the name of a video mode
const char *VID_GetModeName (INT32 modenum)
{
return (VID_GetModePtr(modenum))->name;
}
// ========================================================================
// Sets a video mode
// ========================================================================
INT32 VID_SetMode (INT32 modenum) //, UINT8 *palette)
{
int vstat;
vmode_t *pnewmode, *poldmode;
if ((modenum >= numvidmodes) || (modenum < 0))
{
if (pcurrentmode == NULL)
{
modenum = 0; // mode hasn't been set yet, so initialize to base
// mode since they gave us an invalid initial mode
}
else
{
//nomodecheck = true;
I_Error ("Unknown video mode: %d\n", modenum);
//nomodecheck = false;
return 0;
}
}
pnewmode = VID_GetModePtr (modenum);
if (pnewmode == pcurrentmode)
return 1; // already in the desired mode
// initialize the new mode
poldmode = pcurrentmode;
pcurrentmode = pnewmode;
// initialize vidbuffer size for setmode
vid.width = pcurrentmode->width;
vid.height = pcurrentmode->height;
//vid.aspect = pcurrentmode->aspect;
vid.rowbytes = pcurrentmode->rowbytes;
vid.bpp = pcurrentmode->bytesperpixel;
//debug
//if (vid.rowbytes != vid.width)
// I_Error("vidrowbytes (%d) <> vidwidth(%d)\n",vid.rowbytes,vid.width);
vstat = (*pcurrentmode->setmode) (&vid, pcurrentmode);
if (vstat < 1)
{
if (vstat == 0)
{
// harware could not setup mode
//if (!VID_SetMode (vid.modenum))
// I_Error ("VID_SetMode: couldn't set video mode (hard failure)");
I_Error("Couldn't set video mode %d\n", modenum);
}
else
if (vstat == -1)
{
CONS_Printf ("Not enough mem for VID_SetMode...\n");
// not enough memory; just put things back the way they were
pcurrentmode = poldmode;
vid.width = pcurrentmode->width;
vid.height = pcurrentmode->height;
vid.rowbytes = pcurrentmode->rowbytes;
vid.bpp = pcurrentmode->bytesperpixel;
return 0;
}
}
vid.modenum = modenum;
//printf ("%s\n", VID_ModeInfo (vid.modenum, NULL));
//added:20-01-98: recalc all tables and realloc buffers based on
// vid values.
vid.recalc = 1;
if (!cv_stretch.value && (float)vid.width/vid.height != ((float)BASEVIDWIDTH/BASEVIDHEIGHT))
vid.height = (int)(vid.width * ((float)BASEVIDHEIGHT/BASEVIDWIDTH));// Adjust the height to match
return 1;
}
void VID_CheckRenderer(void) {}
void VID_CheckGLLoaded(rendermode_t oldrender) {}
// converts a segm:offs 32bit pair to a 32bit flat ptr
#if 0
void *VID_ExtraFarToLinear (void *ptr)
{
int temp;
temp = (int)ptr;
return real2ptr (((temp & 0xFFFF0000) >> 12) + (temp & 0xFFFF));
}
#endif
// ========================================================================
// Helper function for VID_VesaGetExtraModes
// In: vesa mode number, from the vesa videomodenumbers list
// Out: false, if no info for given modenum
// ========================================================================
int VID_VesaGetModeInfo (int modenum)
{
int bytes_per_pixel;
unsigned int i;
__dpmi_regs regs;
for (i=0; i<sizeof (vesamodeinfo_t); i++)
_farpokeb(_dos_ds, MASK_LINEAR(__tb)+i, 0);
regs.x.ax = 0x4f01;
regs.x.di = RM_OFFSET(__tb);
regs.x.es = RM_SEGMENT(__tb);
regs.x.cx = modenum;
__dpmi_int(0x10, &regs);
if (regs.h.ah)
return false;
else
{
dosmemget (MASK_LINEAR(__tb), sizeof (vesamodeinfo_t), &vesamodeinfo);
bytes_per_pixel = (vesamodeinfo.BitsPerPixel+1)/8;
// we add either highcolor or lowcolor video modes, not the two
if (highcolor && (vesamodeinfo.BitsPerPixel != 15))
return false;
if (!highcolor && (vesamodeinfo.BitsPerPixel != 8))
return false;
if ((bytes_per_pixel > 2) ||
(vesamodeinfo.XResolution > MAXVIDWIDTH) ||
(vesamodeinfo.YResolution > MAXVIDHEIGHT))
{
return false;
}
// we only want color graphics modes that are supported by the hardware
if ((vesamodeinfo.ModeAttributes &
(MODE_SUPPORTED_IN_HW | COLOR_MODE | GRAPHICS_MODE) ) !=
(MODE_SUPPORTED_IN_HW | COLOR_MODE | GRAPHICS_MODE))
{
return false;
}
// we only work with linear frame buffers, except for 320x200,
// which is linear when banked at 0xA000
if (!(vesamodeinfo.ModeAttributes & LINEAR_FRAME_BUFFER))
{
if ((vesamodeinfo.XResolution != 320) ||
(vesamodeinfo.YResolution != 200))
{
return false;
}
}
// pagesize
if ((vesamodeinfo.BytesPerScanLine * vesamodeinfo.YResolution)
> totalvidmem)
{
return false;
}
vesamodeinfo.NumberOfImagePages = 1;
#ifdef DEBUG
CONS_Printf("VID: (VESA) info for mode 0x%x\n", modeinfo.modenum);
CONS_Printf(" mode attrib = 0x%0x\n", modeinfo.mode_attributes);
CONS_Printf(" win a attrib = 0x%0x\n", *(UINT8 *)(infobuf+2));
CONS_Printf(" win b attrib = 0x%0x\n", *(UINT8 *)(infobuf+3));
CONS_Printf(" win a seg 0x%0x\n", (int) modeinfo.winasegment);
CONS_Printf(" win b seg 0x%0x\n", (int) modeinfo.winbsegment);
CONS_Printf(" bytes per scanline = %d\n",
modeinfo.bytes_per_scanline);
CONS_Printf(" width = %d, height = %d\n", modeinfo.width,
modeinfo.height);
CONS_Printf(" win = %c\n", 'A' + modeinfo.win);
CONS_Printf(" win granularity = %d\n", modeinfo.granularity);
CONS_Printf(" win size = %d\n", modeinfo.win_size);
CONS_Printf(" bits per pixel = %d\n", modeinfo.bits_per_pixel);
CONS_Printf(" bytes per pixel = %d\n", modeinfo.bytes_per_pixel);
CONS_Printf(" memory model = 0x%x\n", modeinfo.memory_model);
CONS_Printf(" num pages = %d\n", modeinfo.num_pages);
CONS_Printf(" red width = %d\n", modeinfo.red_width);
CONS_Printf(" red pos = %d\n", modeinfo.red_pos);
CONS_Printf(" green width = %d\n", modeinfo.green_width);
CONS_Printf(" green pos = %d\n", modeinfo.green_pos);
CONS_Printf(" blue width = %d\n", modeinfo.blue_width);
CONS_Printf(" blue pos = %d\n", modeinfo.blue_pos);
CONS_Printf(" phys mem = %x\n", modeinfo.pptr);
#endif
}
return true;
}
// ========================================================================
// Get extended VESA modes information, keep the ones that we support,
// so they'll be available in the game Video menu.
// ========================================================================
#define MAXVESADESC 100
static char vesadesc[MAXVESADESC] = "";
void VID_VesaGetExtraModes (void)
{
unsigned int i;
unsigned long addr;
int nummodes;
__dpmi_meminfo phys_mem_info;
unsigned long mode_ptr;
__dpmi_regs regs;
// make a copy of the video modes list! else trash in __tb
UINT16 vmode[MAX_VESA_MODES+1];
int numvmodes;
UINT16 vesamode;
// new ugly stuff...
for (i=0; i<sizeof (vbeinfoblock_t); i++)
_farpokeb(_dos_ds, MASK_LINEAR(__tb)+i, 0);
dosmemput("VBE2", 4, MASK_LINEAR(__tb));
// see if VESA support is available
regs.x.ax = 0x4f00;
regs.x.di = RM_OFFSET(__tb);
regs.x.es = RM_SEGMENT(__tb);
__dpmi_int(0x10, &regs);
if (regs.h.ah)
goto no_vesa;
dosmemget(MASK_LINEAR(__tb), sizeof (vbeinfoblock_t), &vesainfo);
if (strncmp((void *)vesainfo.VESASignature, "VESA", 4) != 0)
{
no_vesa:
CONS_Printf ("No VESA driver\n");
return;
}
if (vesainfo.VESAVersion < (VBEVERSION<<8))
{
CONS_Printf ("VESA VBE %d.0 not available\n", VBEVERSION);
return;
}
//
// vesa version number
//
CONS_Printf ("%4.4s %d.%d (", vesainfo.VESASignature,
vesainfo.VESAVersion>>8,
vesainfo.VESAVersion&0xFF);
//
// vesa description string
//
i = 0;
addr = RM_TO_LINEAR(vesainfo.OemStringPtr);
_farsetsel(_dos_ds);
while (_farnspeekb(addr) != 0)
{
vesadesc[i++] = _farnspeekb(addr++);
if (i == MAXVESADESC-1)
break;
}
vesadesc[i]=0;
CONS_Printf ("%s)\n",vesadesc);
totalvidmem = vesainfo.TotalMemory << 16;
//
// find 8 bit modes
//
numvmodes = 0;
mode_ptr = RM_TO_LINEAR(vesainfo.VideoModePtr);
while ((vmode[numvmodes] = _farpeekw(_dos_ds, mode_ptr)) != 0xFFFF)
{
numvmodes++;
if ( numvmodes == MAX_VESA_MODES )
break;
mode_ptr += 2;
}
vmode[numvmodes] = 0xffff;
nummodes = 0; // number of video modes accepted for the game
numvmodes=0; // go again through vmodes table
while ( ((vesamode=vmode[numvmodes++]) != 0xFFFF) && (nummodes < MAX_VESA_MODES) )
{
//fill the modeinfo struct.
if (VID_VesaGetModeInfo (vesamode))
{
vesa_modes[nummodes].pnext = &vesa_modes[nummodes+1];
if (vesamodeinfo.XResolution > 999)
{
if (vesamodeinfo.YResolution > 999)
{
sprintf (&names[nummodes][0], "%4dx%4d", vesamodeinfo.XResolution,
vesamodeinfo.YResolution);
names[nummodes][9] = 0;
}
else
{
sprintf (&names[nummodes][0], "%4dx%3d", vesamodeinfo.XResolution,
vesamodeinfo.YResolution);
names[nummodes][8] = 0;
}
}
else
{
if (vesamodeinfo.YResolution > 999)
{
sprintf (&names[nummodes][0], "%3dx%4d", vesamodeinfo.XResolution,
vesamodeinfo.YResolution);
names[nummodes][8] = 0;
}
else
{
sprintf (&names[nummodes][0], "%3dx%3d", vesamodeinfo.XResolution,
vesamodeinfo.YResolution);
names[nummodes][7] = 0;
}
}
vesa_modes[nummodes].name = &names[nummodes][0];
vesa_modes[nummodes].width = vesamodeinfo.XResolution;
vesa_modes[nummodes].height = vesamodeinfo.YResolution;
//added:20-01-98:aspect ratio to be implemented...
vesa_modes[nummodes].rowbytes = vesamodeinfo.BytesPerScanLine;
vesa_modes[nummodes].windowed = 0;
vesa_modes[nummodes].pextradata = &vesa_extra[nummodes];
vesa_modes[nummodes].setmode = VID_VesaInitMode;
if (vesamodeinfo.ModeAttributes & LINEAR_FRAME_BUFFER)
{
// add linear bit to mode for linear modes
vesa_extra[nummodes].vesamode = vesamode | LINEAR_MODE;
vesa_modes[nummodes].numpages = 1; //vesamodeinfo.NumberOfImagePages;
phys_mem_info.address = (int)vesamodeinfo.PhysBasePtr;
phys_mem_info.size = 0x400000;
// returns -1 on error
if (__dpmi_physical_address_mapping(&phys_mem_info))
{
//skip this mode, it doesnt work
continue;
}
// if physical mapping was ok... convert the selector:offset
vesa_extra[nummodes].plinearmem =
real2ptr (phys_mem_info.address);
// lock the region
__dpmi_lock_linear_region (&phys_mem_info);
}
else
{
// banked at 0xA0000
vesa_extra[nummodes].vesamode = vesamode;
//vesa_extra[nummodes].pages[0] = 0;
vesa_extra[nummodes].plinearmem =
real2ptr (vesamodeinfo.WinASegment<<4);
vesa_modes[nummodes].numpages = 1; //modeinfo.numpages;
}
vesa_modes[nummodes].bytesperpixel = (vesamodeinfo.BitsPerPixel+1)/8;
nummodes++;
}
}
// add the VESA modes at the start of the mode list (if there are any)
if (nummodes)
{
vesa_modes[nummodes-1].pnext = NULL; //pvidmodes;
pvidmodes = &vesa_modes[0];
numvidmodes += nummodes;
}
}
// ========================================================================
// Free the video buffer of the last video mode,
// allocate a new buffer for the video mode to set.
// ========================================================================
static boolean VID_FreeAndAllocVidbuffer (viddef_t *lvid)
{
int vidbuffersize;
vidbuffersize = (lvid->width * lvid->height * lvid->bpp * NUMSCREENS); //status bar
// free allocated buffer for previous video mode
if (lvid->buffer!=NULL)
{
free(lvid->buffer);
}
// allocate the new screen buffer
if ( (lvid->buffer = (UINT8 *) malloc(vidbuffersize))==NULL )
return false;
// initially clear the video buffer
memset (lvid->buffer, 0x00, vidbuffersize);
#ifdef DEBUG
CONS_Printf("VID_FreeAndAllocVidbuffer done, vidbuffersize: %x\n",vidbuffersize);
#endif
return true;
}
// ========================================================================
// Set video mode routine for STANDARD VGA MODES (NO HIGHCOLOR)
// Out: 1 ok,
// 0 hardware could not set mode,
// -1 no mem
// ========================================================================
static INT32 VGA_InitMode (viddef_t *lvid, vmode_t *currentmodep)
{
__dpmi_regs regs;
if (!VID_FreeAndAllocVidbuffer (lvid))
return -1; //no mem
//added:26-01-98: should clear video mem here
//set mode 0x13
regs.h.ah = 0;
regs.h.al = 0x13;
__dpmi_int(0x10, &regs);
// here it is the standard VGA 64k window, not an LFB
// (you could have 320x200x256c with LFB in the vesa modes)
lvid->direct = (UINT8 *) real2ptr (0xa0000);
lvid->u.numpages = 1;
lvid->bpp = currentmodep->bytesperpixel;
return 1;
}
// ========================================================================
// Set video mode routine for VESA video modes, see VID_SetMode()
// Out: 1 ok,
// 0 hardware could not set mode,
// -1 no mem
// ========================================================================
INT32 VID_VesaInitMode (viddef_t *lvid, vmode_t *currentmodep)
{
vesa_extra_t *pextra;
__dpmi_regs regs;
pextra = currentmodep->pextradata;
#ifdef DEBUG
CONS_Printf("VID_VesaInitMode...\n");
CONS_Printf(" currentmodep->name %s\n",currentmodep->name);
CONS_Printf(" width %d\n",currentmodep->width);
CONS_Printf(" height %d\n",currentmodep->height);
CONS_Printf(" rowbytes %d\n",currentmodep->rowbytes);
CONS_Printf(" windowed %d\n",currentmodep->windowed);
CONS_Printf(" numpages %d\n",currentmodep->numpages);
CONS_Printf(" currentmodep->pextradata :\n");
CONS_Printf(" ->vesamode %x\n",pextra->vesamode);
CONS_Printf(" ->plinearmem %x\n\n",pextra->plinearmem);
#endif
//added:20-01-98:no page flipping now... TO DO!!!
lvid->u.numpages = 1;
// clean up any old vid buffer lying around, alloc new if needed
if (!VID_FreeAndAllocVidbuffer (lvid))
return -1; //no mem
//added:20-01-98: should clear video mem here
// set the mode
regs.x.ax = 0x4f02;
regs.x.bx = pextra->vesamode;
__dpmi_int (0x10, &regs);
if (regs.x.ax != 0x4f)
return 0; // could not set mode
//added:20-01-98: should setup wait_vsync flag, currentpage here...
// plus check for display_enable bit
//added:20-01-98: here we should set the page if page flipping...
// points to LFB, or the start of VGA mem.
lvid->direct = pextra->plinearmem;
lvid->bpp = currentmodep->bytesperpixel;
return 1;
}
// ========================================================================
// VIDEO MODE CONSOLE COMMANDS
// ========================================================================
// vid_nummodes
//
//added:21-03-98:
void VID_Command_NumModes_f (void)
{
int nummodes;
nummodes = VID_NumModes ();
CONS_Printf ("%d video mode(s) available(s)\n", nummodes);
}
// vid_modeinfo <modenum>
//
void VID_Command_ModeInfo_f (void)
{
vmode_t *pv;
int modenum;
if (COM_Argc()!=2)
modenum = vid.modenum; // describe the current mode
else
modenum = atoi (COM_Argv(1)); // .. the given mode number
if (modenum >= VID_NumModes())
{
CONS_Printf ("No such video mode\n");
return;
}
pv = VID_GetModePtr (modenum);
CONS_Printf ("%s\n", VID_ModeInfo (modenum, NULL));
CONS_Printf ("width : %d\n"
"height: %d\n"
"bytes per scanline: %d\n"
"bytes per pixel: %d\n"
"numpages: %d\n",
pv->width,
pv->height,
pv->rowbytes,
pv->bytesperpixel,
pv->numpages );
}
// vid_modelist
//
void VID_Command_ModeList_f (void)
{
int i, nummodes;
const char *pinfo;
char *pheader;
vmode_t *pv;
boolean na;
na = false;
nummodes = VID_NumModes ();
for (i=0 ; i<nummodes ; i++)
{
pv = VID_GetModePtr (i);
pinfo = VID_ModeInfo (i, &pheader);
if (i==0 || pv->bytesperpixel==1)
CONS_Printf ("%d: %s\n", i, pinfo);
else
CONS_Printf ("%d: %s (hicolor)\n", i, pinfo);
}
}
// vid_mode <modenum>
//
void VID_Command_Mode_f (void)
{
int modenum;
if (COM_Argc()!=2)
{
CONS_Printf ("vid_mode <modenum> : set video mode\n");
return;
}
modenum = atoi(COM_Argv(1));
if (modenum >= VID_NumModes())
CONS_Printf ("No such video mode\n");
else
// request vid mode change
setmodeneeded = modenum+1;
}

View file

@ -1,109 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief VESA extra modes.
#include "../doomdef.h"
#include "../screen.h"
#define MODE_SUPPORTED_IN_HW 0x0001
#define COLOR_MODE 0x0008
#define GRAPHICS_MODE 0x0010
#define VGA_INCOMPATIBLE 0x0020
#define LINEAR_FRAME_BUFFER 0x0080
#define LINEAR_MODE 0x4000
#define MAX_VESA_MODES 30 // we'll just take the first 30 if there
// VESA information block structure
typedef struct vbeinfoblock_s
{
UINT8 VESASignature[4];
UINT16 VESAVersion;
unsigned long OemStringPtr;
UINT8 Capabilities[4];
unsigned long VideoModePtr;
UINT16 TotalMemory;
UINT8 OemSoftwareRev[2];
UINT8 OemVendorNamePtr[4];
UINT8 OemProductNamePtr[4];
UINT8 OemProductRevPtr[4];
UINT8 Reserved[222];
UINT8 OemData[256];
} ATTRPACK vbeinfoblock_t;
// VESA information for a specific mode
typedef struct vesamodeinfo_s
{
UINT16 ModeAttributes;
UINT8 WinAAttributes;
UINT8 WinBAttributes;
UINT16 WinGranularity;
UINT16 WinSize;
UINT16 WinASegment;
UINT16 WinBSegment;
unsigned long WinFuncPtr;
UINT16 BytesPerScanLine;
UINT16 XResolution;
UINT16 YResolution;
UINT8 XCharSize;
UINT8 YCharSize;
UINT8 NumberOfPlanes;
UINT8 BitsPerPixel;
UINT8 NumberOfBanks;
UINT8 MemoryModel;
UINT8 BankSize;
UINT8 NumberOfImagePages;
UINT8 Reserved_page;
UINT8 RedMaskSize;
UINT8 RedMaskPos;
UINT8 GreenMaskSize;
UINT8 GreenMaskPos;
UINT8 BlueMaskSize;
UINT8 BlueMaskPos;
UINT8 ReservedMaskSize;
UINT8 ReservedMaskPos;
UINT8 DirectColorModeInfo;
/* VBE 2.0 extensions */
unsigned long PhysBasePtr;
unsigned long OffScreenMemOffset;
UINT16 OffScreenMemSize;
/* VBE 3.0 extensions */
UINT16 LinBytesPerScanLine;
UINT8 BnkNumberOfPages;
UINT8 LinNumberOfPages;
UINT8 LinRedMaskSize;
UINT8 LinRedFieldPos;
UINT8 LinGreenMaskSize;
UINT8 LinGreenFieldPos;
UINT8 LinBlueMaskSize;
UINT8 LinBlueFieldPos;
UINT8 LinRsvdMaskSize;
UINT8 LinRsvdFieldPos;
unsigned long MaxPixelClock;
UINT8 Reserved[190];
} ATTRPACK vesamodeinfo_t;
// setup standard VGA + VESA modes list, activate the default video mode.
void VID_Init (void);

View file

@ -29,7 +29,6 @@
// Use Mixer interface?
#ifdef HAVE_MIXER
#define SOUND SOUND_MIXER
#define NOHS // No HW3SOUND
#ifdef HW3SOUND
#undef HW3SOUND
#endif
@ -45,7 +44,6 @@
// Use FMOD?
#ifdef HAVE_FMOD
#define SOUND SOUND_FMOD
#define NOHS // No HW3SOUND
#ifdef HW3SOUND
#undef HW3SOUND
#endif
@ -62,10 +60,6 @@
#if !defined (HWRENDER) && !defined (NOHW)
#define HWRENDER
#endif
// judgecutor: 3D sound support
#if !defined(HW3SOUND) && !defined (NOHS)
#define HW3SOUND
#endif
#endif
#ifdef _WIN32
@ -110,10 +104,6 @@
#include <io.h>
#endif
#ifdef PC_DOS
#include <conio.h>
#endif
//#define NOMD5
// Uncheck this to compile debugging code
@ -139,8 +129,15 @@ extern char logfilename[1024];
#define VERSIONSTRING "Development EXE"
// most interface strings are ignored in development mode.
// we use comprevision and compbranch instead.
// VERSIONSTRING_RC is for the resource-definition script used by windows builds
#else
#ifdef BETAVERSION
#define VERSIONSTRING "v"SRB2VERSION" "BETAVERSION
#define VERSIONSTRING_RC SRB2VERSION " " BETAVERSION "\0"
#else
#define VERSIONSTRING "v"SRB2VERSION
#define VERSIONSTRING_RC SRB2VERSION "\0"
#endif
// Hey! If you change this, add 1 to the MODVERSION below!
// Otherwise we can't force updates!
#endif
@ -163,7 +160,9 @@ extern char logfilename[1024];
// the other options the same.
// Comment out this line to completely disable update alerts (recommended for testing, but not for release)
#ifndef BETAVERSION
#define UPDATE_ALERT
#endif
// The string used in the alert that pops up in the event of an update being available.
// Please change to apply to your modification (we don't want everyone asking where your mod is on SRB2.org!).
@ -558,8 +557,8 @@ INT32 I_GetKey(void);
#endif
// The character that separates pathnames. Forward slash on
// most systems, but reverse solidus (\) on Windows and DOS.
#if defined (PC_DOS) || defined (_WIN32)
// most systems, but reverse solidus (\) on Windows.
#if defined (_WIN32)
#define PATHSEP "\\"
#else
#define PATHSEP "/"
@ -648,4 +647,10 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Maintain compatibility with older 2.2 demos
#define OLD22DEMOCOMPAT
#if defined (HAVE_CURL) && ! defined (NONET)
#define MASTERSERVER
#else
#undef UPDATE_ALERT
#endif
#endif // __DOOMDEF__

View file

@ -371,4 +371,12 @@ typedef UINT32 tic_t;
#define WSTRING2(s) L ## s
#define WSTRING(s) WSTRING2 (s)
/*
A hack by Monster Iestyn: Return a pointer to a field of
a struct from a pointer to another field in the struct.
Needed for some lua shenanigans.
*/
#define FIELDFROM( type, field, have, want ) \
(void *)((intptr_t)(field) - offsetof (type, have) + offsetof (type, want))
#endif //__DOOMTYPE__

View file

@ -8,8 +8,8 @@
UINT8 cdaudio_started = 0;
consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cd_volume = CVAR_INIT ("cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL);
consvar_t cdUpdate = CVAR_INIT ("cd_update","1",CV_SAVE, NULL, NULL);
void I_InitCD(void){}

View file

@ -8,7 +8,7 @@ boolean highcolor = false;
boolean allow_fullscreen = false;
consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_vidwait = CVAR_INIT ("vid_wait", "On", CV_SAVE, CV_OnOff, NULL);
void I_StartupGraphics(void){}
void I_ShutdownGraphics(void){}

View file

@ -25,6 +25,7 @@
#include "w_wad.h"
#include "z_zone.h"
#include "i_system.h"
#include "i_threads.h"
#include "m_menu.h"
#include "dehacked.h"
#include "g_input.h"
@ -224,6 +225,9 @@ static INT32 cutscene_textspeed = 0;
static UINT8 cutscene_boostspeed = 0;
static tic_t cutscene_lasttextwrite = 0;
// STJR Intro
char stjrintro[9] = "STJRI000";
//
// This alters the text string cutscene_disptext.
// Use the typical string drawing functions to display it.
@ -311,7 +315,7 @@ const char *introtext[NUMINTROSCENES];
static tic_t introscenetime[NUMINTROSCENES] =
{
7*TICRATE + (TICRATE/2), // STJr Presents
5*TICRATE, // STJr Presents
11*TICRATE + (TICRATE/2), // Two months had passed since...
15*TICRATE + (TICRATE/2), // As it was about to drain the rings...
14*TICRATE, // What Sonic, Tails, and Knuckles...
@ -526,6 +530,7 @@ static void F_IntroDrawScene(void)
switch (intro_scenenum)
{
case 0:
bgxoffs = 28;
break;
case 1:
background = W_CachePatchName("INTRO1", PU_PATCH);
@ -616,97 +621,34 @@ static void F_IntroDrawScene(void)
}
else if (intro_scenenum == 0) // STJr presents
{
// "Waaaaaaah" intro
if (finalecount-TICRATE/2 < 4*TICRATE+23) {
// aspect is FRACUNIT/2 for 4:3 (source) resolutions, smaller for 16:10 (SRB2) resolutions
fixed_t aspect = (FRACUNIT + (FRACUNIT*4/3 - FRACUNIT*vid.width/vid.height)/2)>>1;
fixed_t x,y;
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 2);
if (finalecount < 30) { // Cry!
if (finalecount < 4)
S_StopMusic();
if (finalecount == 4)
S_ChangeMusicInternal("_stjr", false);
x = (BASEVIDWIDTH<<FRACBITS)/2 - FixedMul(334<<FRACBITS, aspect)/2;
y = (BASEVIDHEIGHT<<FRACBITS)/2 - FixedMul(358<<FRACBITS, aspect)/2;
V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH1", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
if (finalecount > 6) {
V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH2", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
}
if (finalecount > 10) {
V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH3", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
}
if (finalecount > 14) {
V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH4", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
}
}
else if (finalecount-30 < 20) { // Big eggy
background = W_CachePatchName("FEEDIN", PU_PATCH);
x = (BASEVIDWIDTH<<FRACBITS)/2 - FixedMul(560<<FRACBITS, aspect)/2;
y = (BASEVIDHEIGHT<<FRACBITS) - FixedMul(477<<FRACBITS, aspect);
V_DrawSciencePatch(x, y, V_SNAPTOBOTTOM, background, aspect);
}
else if (finalecount-50 < 30) { // Zoom out
fixed_t scale = FixedDiv(aspect, FixedDiv((finalecount-50)<<FRACBITS, (15<<FRACBITS))+FRACUNIT);
background = W_CachePatchName("FEEDIN", PU_PATCH);
x = (BASEVIDWIDTH<<FRACBITS)/2 - FixedMul(560<<FRACBITS, aspect)/2 + (FixedMul(560<<FRACBITS, aspect) - FixedMul(560<<FRACBITS, scale));
y = (BASEVIDHEIGHT<<FRACBITS) - FixedMul(477<<FRACBITS, scale);
V_DrawSciencePatch(x, y, V_SNAPTOBOTTOM, background, scale);
}
else
if (intro_curtime > 1 && intro_curtime < (INT32)introscenetime[intro_scenenum])
{
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
if (intro_curtime < TICRATE-5) // Make the text shine!
sprintf(stjrintro, "STJRI%03u", intro_curtime-1);
else if (intro_curtime >= TICRATE-6 && intro_curtime < 2*TICRATE-20) // Pause on black screen for just a second
return;
else if (intro_curtime == 2*TICRATE-19)
{
{
// Draw tiny eggy
fixed_t scale = FixedMul(FRACUNIT/3, aspect);
background = W_CachePatchName("FEEDIN", PU_PATCH);
x = (BASEVIDWIDTH<<FRACBITS)/2 - FixedMul(560<<FRACBITS, aspect)/2 + (FixedMul(560<<FRACBITS, aspect) - FixedMul(560<<FRACBITS, scale));
y = (BASEVIDHEIGHT<<FRACBITS) - FixedMul(477<<FRACBITS, scale);
V_DrawSciencePatch(x, y, V_SNAPTOBOTTOM, background, scale);
}
// Fade in the text
// The text fade out is automatically handled when switching to a new intro scene
strncpy(stjrintro, "STJRI029", 9);
S_ChangeMusicInternal("_stjr", false);
if (finalecount-84 < 58) { // Pure Fat is driving up!
int ftime = (finalecount-84);
x = (-189*FRACUNIT) + (FixedMul((6<<FRACBITS)+FRACUNIT/3, ftime<<FRACBITS) - FixedMul((6<<FRACBITS)+FRACUNIT/3, FixedDiv(FixedMul(ftime<<FRACBITS, ftime<<FRACBITS), 120<<FRACBITS)));
y = (BASEVIDHEIGHT<<FRACBITS) - FixedMul(417<<FRACBITS, aspect);
// Draw the body
V_DrawSciencePatch(x, y, V_SNAPTOLEFT|V_SNAPTOBOTTOM, (patch = W_CachePatchName("PUREFAT1", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
// Draw the door
V_DrawSciencePatch(x+FixedMul(344<<FRACBITS, aspect), y+FixedMul(292<<FRACBITS, aspect), V_SNAPTOLEFT|V_SNAPTOBOTTOM, (patch = W_CachePatchName("PUREFAT2", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
// Draw the wheel
V_DrawSciencePatch(x+FixedMul(178<<FRACBITS, aspect), y+FixedMul(344<<FRACBITS, aspect), V_SNAPTOLEFT|V_SNAPTOBOTTOM, (patch = W_CachePatchName(va("TYRE%02u",(abs(finalecount-144)/3)%16), PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
// Draw the wheel cover
V_DrawSciencePatch(x+FixedMul(88<<FRACBITS, aspect), y+FixedMul(238<<FRACBITS, aspect), V_SNAPTOLEFT|V_SNAPTOBOTTOM, (patch = W_CachePatchName("PUREFAT3", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
} else { // Pure Fat has stopped!
y = (BASEVIDHEIGHT<<FRACBITS) - FixedMul(417<<FRACBITS, aspect);
// Draw the body
V_DrawSciencePatch(0, y, V_SNAPTOLEFT|V_SNAPTOBOTTOM, (patch = W_CachePatchName("PUREFAT1", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
// Draw the wheel
V_DrawSciencePatch(FixedMul(178<<FRACBITS, aspect), y+FixedMul(344<<FRACBITS, aspect), V_SNAPTOLEFT|V_SNAPTOBOTTOM, (patch = W_CachePatchName("TYRE00", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
// Draw the wheel cover
V_DrawSciencePatch(FixedMul(88<<FRACBITS, aspect), y+FixedMul(238<<FRACBITS, aspect), V_SNAPTOLEFT|V_SNAPTOBOTTOM, (patch = W_CachePatchName("PUREFAT3", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
// Draw the door
if (finalecount-TICRATE/2 > 4*TICRATE) { // Door is being raised!
int ftime = (finalecount-TICRATE/2-4*TICRATE);
y -= FixedDiv((ftime*ftime)<<FRACBITS, 23<<FRACBITS);
}
V_DrawSciencePatch(FixedMul(344<<FRACBITS, aspect), y+FixedMul(292<<FRACBITS, aspect), V_SNAPTOLEFT|V_SNAPTOBOTTOM, (patch = W_CachePatchName("PUREFAT2", PU_PATCH)), aspect);
W_UnlockCachedPatch(patch);
}
background = W_CachePatchName(stjrintro, PU_PATCH);
wipestyleflags = WSF_FADEIN;
F_WipeStartScreen();
F_TryColormapFade(31);
V_DrawSmallScaledPatch(bgxoffs, 84, 0, background);
F_WipeEndScreen();
F_RunWipe(0,true);
}
if (!WipeInAction) // Draw the patch if not in a wipe
{
background = W_CachePatchName(stjrintro, PU_PATCH);
V_DrawSmallScaledPatch(bgxoffs, 84, 0, background);
}
} else {
V_DrawCreditString((160 - V_CreditStringWidth("SONIC TEAM JR")/2)<<FRACBITS, 80<<FRACBITS, 0, "SONIC TEAM JR");
V_DrawCreditString((160 - V_CreditStringWidth("PRESENTS")/2)<<FRACBITS, 96<<FRACBITS, 0, "PRESENTS");
}
}
else if (intro_scenenum == 10) // Sky Runner
@ -959,7 +901,13 @@ void F_IntroDrawer(void)
I_OsPolling();
I_UpdateNoBlit();
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
M_Drawer(); // menu is drawn even on top of wipes
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001
if (moviemode) // make sure we save frames for the white hold too
@ -1010,7 +958,7 @@ void F_IntroDrawer(void)
F_WipeEndScreen();
F_RunWipe(99,true);
}
/*else if (intro_scenenum == 12 && intro_curtime == 7*TICRATE)
/*else if (intro_scenenum == 11 && intro_curtime == 7*TICRATE)
{
patch_t *confront = W_CachePatchName("CONFRONT", PU_PATCH);
@ -1119,61 +1067,58 @@ static const char *credits[] = {
"\1Credits",
"",
"\1Game Design",
"Ben \"Mystic\" Geyer",
"Sonic Team Junior",
"\"SSNTails\"",
"Johnny \"Sonikku\" Wallbank",
"",
"\1Programming",
"Alam \"GBC\" Arias",
"Logan \"GBA\" Arias",
"Colette \"fickleheart\" Bordelon",
"Andrew \"orospakr\" Clunis",
"Sally \"TehRealSalt\" Cochenour",
"Gregor \"Oogaland\" Dick",
"Callum Dickinson",
"Scott \"Graue\" Feeney",
"Victor \"SteelT\" Fuentes",
"Nathan \"Jazz\" Giroux",
"\"Golden\"",
"Vivian \"toaster\" Grannell",
"Julio \"Chaos Zero 64\" Guir",
"\"Hannu_Hanhi\"", // For many OpenGL performance improvements!
"Kepa \"Nev3r\" Iceta",
"Thomas \"Shadow Hog\" Igoe",
"\"james\"",
"Iestyn \"Monster Iestyn\" Jealous",
"\"Jimita\"",
"Ronald \"Furyhunter\" Kinard", // The SDL2 port
"Louis-Antoine \"LJ Sonic\" de Moulins", // de Rochefort doesn't quite fit on the screen sorry lol
"John \"JTE\" Muniz",
"Ehab \"Wolfy\" Saeed",
"Jonas \"MascaraSnake\" Sauer",
"\"Kaito Sinclaire\"",
"\"SSNTails\"",
"Lachlan \"Lach\" Wright",
"Marco \"mazmazz\" Zafra",
"",
"\1Programming",
"\1Assistance",
"Colette \"fickleheart\" Bordelon",
"\"chi.miru\"", // helped port slope drawing code from ZDoom
"Andrew \"orospakr\" Clunis",
"Sally \"TehRealSalt\" Cochenour",
"Gregor \"Oogaland\" Dick",
"Julio \"Chaos Zero 64\" Guir",
"\"Hannu_Hanhi\"", // For many OpenGL performance improvements!
"\"Kalaron\"", // Coded some of Sryder13's collection of OpenGL fixes, especially fog
"Ronald \"Furyhunter\" Kinard", // The SDL2 port
"\"Lat'\"", // SRB2-CHAT, the chat window from Kart
"Matthew \"Shuffle\" Marsalko",
"Steven \"StroggOnMeth\" McGranahan",
"\"Morph\"", // For SRB2Morphed stuff
"Louis-Antoine \"LJ Sonic\" de Moulins", // de Rochefort doesn't quite fit on the screen sorry lol
"John \"JTE\" Muniz",
"Colin \"Sonict\" Pfaff",
"Sean \"Sryder13\" Ryder",
"Ehab \"Wolfy\" Saeed",
"Tasos \"tatokis\" Sahanidis", // Corrected C FixedMul, making 64-bit builds netplay compatible
"Jonas \"MascaraSnake\" Sauer",
"Wessel \"sphere\" Smit",
"Ben \"Cue\" Woodford",
"\"SSNTails\"",
"\"Varren\"",
"\"VelocitOni\"", // Wrote the original dashmode script
"Ikaro \"Tatsuru\" Vinhas",
// Git contributors with 5+ approved merges of substantive quality,
// or contributors with at least one groundbreaking merge, may be named.
// Everyone else is acknowledged under "Special Thanks > SRB2 Community Contributors".
"Ben \"Cue\" Woodford",
"Lachlan \"Lach\" Wright",
"Marco \"mazmazz\" Zafra",
"",
"\1Art",
"Victor \"VAdaPEGA\" Ara\x1Fjo", // Araújo -- sorry for our limited font! D:
"\"Arrietty\"",
"Ryan \"Blaze Hedgehog\" Bloom",
"Graeme P. \"SuperPhanto\" Caldwell", // for the new brak render
"\"ChrispyPixels\"",
"Paul \"Boinciel\" Clempson",
"Sally \"TehRealSalt\" Cochenour",
@ -1181,6 +1126,8 @@ static const char *credits[] = {
"Desmond \"Blade\" DesJardins",
"Sherman \"CoatRack\" DesJardins",
"\"DirkTheHusky\"",
"Jesse \"Jeck Jims\" Emerick",
"\"Fighter_Builder\"", // for the CEZ3 button debris
"Buddy \"KinkaJoy\" Fischer",
"Vivian \"toaster\" Grannell",
"James \"SwitchKaze\" Hale",
@ -1193,6 +1140,7 @@ static const char *credits[] = {
"Andrew \"Senku Niola\" Moran",
"\"MotorRoach\"",
"Phillip \"TelosTurntable\" Robinson",
"\"Scizor300\"",
"Wessel \"sphere\" Smit",
"David \"Instant Sonic\" Spencer Jr.",
"\"SSNTails\"",
@ -1206,9 +1154,9 @@ static const char *credits[] = {
"Malcolm \"RedXVI\" Brown",
"Dave \"DemonTomatoDave\" Bulmer",
"Paul \"Boinciel\" Clempson",
"\"Cyan Helkaraxe\"",
"Shane \"CobaltBW\" Ellis",
"James \"SeventhSentinel\" Hall",
"Cyan Helkaraxe",
"Kepa \"Nev3r\" Iceta",
"Iestyn \"Monster Iestyn\" Jealous",
"Jarel \"Arrow\" Jones",
@ -1235,8 +1183,9 @@ static const char *credits[] = {
"James \"SeventhSentinel\" Hall",
"Kepa \"Nev3r\" Iceta",
"Thomas \"Shadow Hog\" Igoe",
"Alexander \"DrTapeworm\" Moench-Ford",
"\"Kaito Sinclaire\"",
"Alexander \"DrTapeworm\" Moench-Ford",
"\"Revan\"",
"Anna \"QueenDelta\" Sandlin",
"Wessel \"sphere\" Smit",
"\"Spazzo\"",
@ -1259,7 +1208,7 @@ static const char *credits[] = {
"\1Testing",
"Discord Community Testers",
"Hank \"FuriousFox\" Brannock",
"Cody \"SRB2 Playah\" Koester",
"Cody \"Playah\" Koester",
"Skye \"OmegaVelocity\" Meredith",
"Stephen \"HEDGESMFG\" Moellering",
"Rosalie \"ST218\" Molina",
@ -1276,13 +1225,6 @@ static const char *credits[] = {
"Pascal \"CodeImp\" vd Heiden", // Doom Builder developer
"Randi Heit (<!>)", // For their MSPaint <!> sprite that we nicked
"Simon \"sirjuddington\" Judd", // SLADE developer
// Acknowledged here are the following:
// Minor merge request authors, see guideline above
// - Golden - Expanded thin font
// Creators of small quantities of sprite/texture assets
// - Arietty - New Green Hill-styled textures
// - Scizor300 - the only other contributor to the 2.0 SRB2 Asset Pack
// - Revan/Icefox - the new Nimbus Ruins skybox
"SRB2 Community Contributors",
"",
"\1Produced By",
@ -4097,7 +4039,7 @@ void F_CutsceneTicker(void)
if (netgame && i != serverplayer && !IsPlayerAdmin(i))
continue;
if (players[i].cmd.buttons & BT_USE)
if (players[i].cmd.buttons & BT_SPIN)
{
keypressed = false;
cutscene_boostspeed = 1;
@ -4437,11 +4379,11 @@ static boolean F_GetTextPromptTutorialTag(char *tag, INT32 length)
else if (!strncmp(tag, "TAJ", 3)) // Jump
gcs = G_GetControlScheme(gamecontrol, gcl_jump, num_gcl_jump);
else if (!strncmp(tag, "TAS", 3)) // Spin
gcs = G_GetControlScheme(gamecontrol, gcl_use, num_gcl_use);
gcs = G_GetControlScheme(gamecontrol, gcl_spin, num_gcl_spin);
else if (!strncmp(tag, "TAA", 3)) // Char ability
gcs = G_GetControlScheme(gamecontrol, gcl_jump, num_gcl_jump);
else if (!strncmp(tag, "TAW", 3)) // Shield ability
gcs = G_GetControlScheme(gamecontrol, gcl_jump_use, num_gcl_jump_use);
gcs = G_GetControlScheme(gamecontrol, gcl_jump_spin, num_gcl_jump_spin);
else
gcs = G_GetControlScheme(gamecontrol, gcl_tutorial_used, num_gcl_tutorial_used);
@ -4698,7 +4640,7 @@ void F_TextPromptTicker(void)
else
continue;
if ((players[i].cmd.buttons & BT_USE) || (players[i].cmd.buttons & BT_JUMP))
if ((players[i].cmd.buttons & BT_SPIN) || (players[i].cmd.buttons & BT_JUMP))
{
if (timetonext > 1)
timetonext--;
@ -4721,7 +4663,7 @@ void F_TextPromptTicker(void)
}
keypressed = true; // prevent repeat events
}
else if (!(players[i].cmd.buttons & BT_USE) && !(players[i].cmd.buttons & BT_JUMP))
else if (!(players[i].cmd.buttons & BT_SPIN) && !(players[i].cmd.buttons & BT_JUMP))
keypressed = false;
if (!splitscreen)

View file

@ -25,6 +25,7 @@
#include "z_zone.h"
#include "i_system.h"
#include "i_threads.h"
#include "m_menu.h"
#include "console.h"
#include "d_main.h"
@ -595,7 +596,15 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
I_UpdateNoBlit();
if (drawMenu)
{
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
M_Drawer(); // menu is drawn even on top of wipes
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
}
I_FinishUpdate(); // page flip or blit buffer

View file

@ -312,18 +312,18 @@ static CV_PossibleValue_t addons_cons_t[] = {{0, "Default"},
#endif
{3, "CUSTOM"}, {0, NULL}};
consvar_t cv_addons_option = {"addons_option", "Default", CV_SAVE|CV_CALL, addons_cons_t, Addons_option_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_addons_folder = {"addons_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_addons_option = CVAR_INIT ("addons_option", "Default", CV_SAVE|CV_CALL, addons_cons_t, Addons_option_Onchange);
consvar_t cv_addons_folder = CVAR_INIT ("addons_folder", "", CV_SAVE, NULL, NULL);
static CV_PossibleValue_t addons_md5_cons_t[] = {{0, "Name"}, {1, "Contents"}, {0, NULL}};
consvar_t cv_addons_md5 = {"addons_md5", "Name", CV_SAVE, addons_md5_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_addons_md5 = CVAR_INIT ("addons_md5", "Name", CV_SAVE, addons_md5_cons_t, NULL);
consvar_t cv_addons_showall = {"addons_showall", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_addons_showall = CVAR_INIT ("addons_showall", "No", CV_SAVE, CV_YesNo, NULL);
consvar_t cv_addons_search_case = {"addons_search_case", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_addons_search_case = CVAR_INIT ("addons_search_case", "No", CV_SAVE, CV_YesNo, NULL);
static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}};
consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_addons_search_type = CVAR_INIT ("addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL);
char menupath[1024];
size_t menupathindex[menudepth];

View file

@ -94,7 +94,7 @@ demoghost *ghosts = NULL;
// DEMO RECORDING
//
#define DEMOVERSION 0x000d
#define DEMOVERSION 0x000e
#define DEMOHEADER "\xF0" "SRB2Replay" "\x0F"
#define DF_GHOST 0x01 // This demo contains ghost data too!
@ -345,32 +345,29 @@ void G_WriteGhostTic(mobj_t *ghost)
else
{
// For moving normally:
// Store one full byte of movement, plus one byte of fractional movement.
INT16 momx = (INT16)((ghost->x-oldghost.x)>>8);
INT16 momy = (INT16)((ghost->y-oldghost.y)>>8);
fixed_t momx = ghost->x-oldghost.x;
fixed_t momy = ghost->y-oldghost.y;
if (momx != oldghost.momx
|| momy != oldghost.momy)
{
oldghost.momx = momx;
oldghost.momy = momy;
ziptic |= GZT_MOMXY;
WRITEINT16(demo_p,momx);
WRITEINT16(demo_p,momy);
WRITEFIXED(demo_p,momx);
WRITEFIXED(demo_p,momy);
}
momx = (INT16)((ghost->z-oldghost.z)>>8);
momx = ghost->z-oldghost.z;
if (momx != oldghost.momz)
{
oldghost.momz = momx;
ziptic |= GZT_MOMZ;
WRITEINT16(demo_p,momx);
WRITEFIXED(demo_p,momx);
}
// This SHOULD set oldghost.x/y/z to match ghost->x/y/z
// but it keeps the fractional loss of one byte,
// so it will hopefully be made up for in future tics.
oldghost.x += oldghost.momx<<8;
oldghost.y += oldghost.momy<<8;
oldghost.z += oldghost.momz<<8;
oldghost.x += oldghost.momx;
oldghost.y += oldghost.momy;
oldghost.z += oldghost.momz;
}
#undef MAXMOM
@ -464,7 +461,7 @@ void G_WriteGhostTic(mobj_t *ghost)
if (ghost->player && ghost->player->followmobj && !(ghost->player->followmobj->sprite == SPR_NULL || (ghost->player->followmobj->flags2 & MF2_DONTDRAW))) // bloats tails runs but what can ya do
{
INT16 temp;
fixed_t temp;
UINT8 *followtic_p = demo_p++;
UINT8 followtic = 0;
@ -492,12 +489,12 @@ void G_WriteGhostTic(mobj_t *ghost)
WRITEFIXED(demo_p,ghost->player->followmobj->scale);
}
temp = (INT16)((ghost->player->followmobj->x-ghost->x)>>8);
WRITEINT16(demo_p,temp);
temp = (INT16)((ghost->player->followmobj->y-ghost->y)>>8);
WRITEINT16(demo_p,temp);
temp = (INT16)((ghost->player->followmobj->z-ghost->z)>>8);
WRITEINT16(demo_p,temp);
temp = ghost->player->followmobj->x-ghost->x;
WRITEFIXED(demo_p,temp);
temp = ghost->player->followmobj->y-ghost->y;
WRITEFIXED(demo_p,temp);
temp = ghost->player->followmobj->z-ghost->z;
WRITEFIXED(demo_p,temp);
if (followtic & FZT_SKIN)
WRITEUINT8(demo_p,ghost->player->followmobj->sprite2);
WRITEUINT16(demo_p,ghost->player->followmobj->sprite);
@ -547,11 +544,11 @@ void G_ConsGhostTic(void)
{
if (ziptic & GZT_MOMXY)
{
oldghost.momx = READINT16(demo_p)<<8;
oldghost.momy = READINT16(demo_p)<<8;
oldghost.momx = (demoversion < 0x000e) ? READINT16(demo_p)<<8 : READFIXED(demo_p);
oldghost.momy = (demoversion < 0x000e) ? READINT16(demo_p)<<8 : READFIXED(demo_p);
}
if (ziptic & GZT_MOMZ)
oldghost.momz = READINT16(demo_p)<<8;
oldghost.momz = (demoversion < 0x000e) ? READINT16(demo_p)<<8 : READFIXED(demo_p);
oldghost.x += oldghost.momx;
oldghost.y += oldghost.momy;
oldghost.z += oldghost.momz;
@ -627,9 +624,8 @@ void G_ConsGhostTic(void)
}
if (followtic & FZT_SCALE)
demo_p += sizeof(fixed_t);
demo_p += sizeof(INT16);
demo_p += sizeof(INT16);
demo_p += sizeof(INT16);
// momx, momy and momz
demo_p += (demoversion < 0x000e) ? sizeof(INT16) * 3 : sizeof(fixed_t) * 3;
if (followtic & FZT_SKIN)
demo_p++;
demo_p += sizeof(UINT16);
@ -697,11 +693,11 @@ void G_GhostTicker(void)
{
if (ziptic & GZT_MOMXY)
{
g->oldmo.momx = READINT16(g->p)<<8;
g->oldmo.momy = READINT16(g->p)<<8;
g->oldmo.momx = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p);
g->oldmo.momy = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p);
}
if (ziptic & GZT_MOMZ)
g->oldmo.momz = READINT16(g->p)<<8;
g->oldmo.momz = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p);
g->oldmo.x += g->oldmo.momx;
g->oldmo.y += g->oldmo.momy;
g->oldmo.z += g->oldmo.momz;
@ -905,11 +901,11 @@ void G_GhostTicker(void)
P_SetScale(follow, follow->destscale);
P_UnsetThingPosition(follow);
temp = READINT16(g->p)<<8;
temp = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p);
follow->x = g->mo->x + temp;
temp = READINT16(g->p)<<8;
temp = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p);
follow->y = g->mo->y + temp;
temp = READINT16(g->p)<<8;
temp = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p);
follow->z = g->mo->z + temp;
P_SetThingPosition(follow);
if (followtic & FZT_SKIN)
@ -1010,11 +1006,11 @@ void G_ReadMetalTic(mobj_t *metal)
{
if (ziptic & GZT_MOMXY)
{
oldmetal.momx = READINT16(metal_p)<<8;
oldmetal.momy = READINT16(metal_p)<<8;
oldmetal.momx = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p);
oldmetal.momy = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p);
}
if (ziptic & GZT_MOMZ)
oldmetal.momz = READINT16(metal_p)<<8;
oldmetal.momz = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p);
oldmetal.x += oldmetal.momx;
oldmetal.y += oldmetal.momy;
oldmetal.z += oldmetal.momz;
@ -1149,11 +1145,11 @@ void G_ReadMetalTic(mobj_t *metal)
P_SetScale(follow, follow->destscale);
P_UnsetThingPosition(follow);
temp = READINT16(metal_p)<<8;
temp = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p);
follow->x = metal->x + temp;
temp = READINT16(metal_p)<<8;
temp = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p);
follow->y = metal->y + temp;
temp = READINT16(metal_p)<<8;
temp = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p);
follow->z = metal->z + temp;
P_SetThingPosition(follow);
if (followtic & FZT_SKIN)
@ -1213,32 +1209,30 @@ void G_WriteMetalTic(mobj_t *metal)
else
{
// For moving normally:
// Store one full byte of movement, plus one byte of fractional movement.
INT16 momx = (INT16)((metal->x-oldmetal.x)>>8);
INT16 momy = (INT16)((metal->y-oldmetal.y)>>8);
// Store movement as a fixed value
fixed_t momx = metal->x-oldmetal.x;
fixed_t momy = metal->y-oldmetal.y;
if (momx != oldmetal.momx
|| momy != oldmetal.momy)
{
oldmetal.momx = momx;
oldmetal.momy = momy;
ziptic |= GZT_MOMXY;
WRITEINT16(demo_p,momx);
WRITEINT16(demo_p,momy);
WRITEFIXED(demo_p,momx);
WRITEFIXED(demo_p,momy);
}
momx = (INT16)((metal->z-oldmetal.z)>>8);
momx = metal->z-oldmetal.z;
if (momx != oldmetal.momz)
{
oldmetal.momz = momx;
ziptic |= GZT_MOMZ;
WRITEINT16(demo_p,momx);
WRITEFIXED(demo_p,momx);
}
// This SHOULD set oldmetal.x/y/z to match metal->x/y/z
// but it keeps the fractional loss of one byte,
// so it will hopefully be made up for in future tics.
oldmetal.x += oldmetal.momx<<8;
oldmetal.y += oldmetal.momy<<8;
oldmetal.z += oldmetal.momz<<8;
oldmetal.x += oldmetal.momx;
oldmetal.y += oldmetal.momy;
oldmetal.z += oldmetal.momz;
}
#undef MAXMOM
@ -1307,7 +1301,7 @@ void G_WriteMetalTic(mobj_t *metal)
if (metal->player && metal->player->followmobj && !(metal->player->followmobj->sprite == SPR_NULL || (metal->player->followmobj->flags2 & MF2_DONTDRAW)))
{
INT16 temp;
fixed_t temp;
UINT8 *followtic_p = demo_p++;
UINT8 followtic = 0;
@ -1335,12 +1329,12 @@ void G_WriteMetalTic(mobj_t *metal)
WRITEFIXED(demo_p,metal->player->followmobj->scale);
}
temp = (INT16)((metal->player->followmobj->x-metal->x)>>8);
WRITEINT16(demo_p,temp);
temp = (INT16)((metal->player->followmobj->y-metal->y)>>8);
WRITEINT16(demo_p,temp);
temp = (INT16)((metal->player->followmobj->z-metal->z)>>8);
WRITEINT16(demo_p,temp);
temp = metal->player->followmobj->x-metal->x;
WRITEFIXED(demo_p,temp);
temp = metal->player->followmobj->y-metal->y;
WRITEFIXED(demo_p,temp);
temp = metal->player->followmobj->z-metal->z;
WRITEFIXED(demo_p,temp);
if (followtic & FZT_SKIN)
WRITEUINT8(demo_p,metal->player->followmobj->sprite2);
WRITEUINT16(demo_p,metal->player->followmobj->sprite);
@ -1818,6 +1812,7 @@ void G_DoPlayDemo(char *defdemoname)
demoversion = READUINT16(demo_p);
switch(demoversion)
{
case 0x000d:
case DEMOVERSION: // latest always supported
cnamelen = MAXCOLORNAME;
break;
@ -1933,9 +1928,8 @@ void G_DoPlayDemo(char *defdemoname)
if (use_old_demo_vars)
CV_LoadOldDemoVars(&demo_p);
else
#else
CV_LoadDemoVars(&demo_p);
#endif
CV_LoadDemoVars(&demo_p);
// Sigh ... it's an empty demo.
if (*demo_p == DEMOMARKER)
@ -2073,6 +2067,7 @@ void G_AddGhost(char *defdemoname)
ghostversion = READUINT16(p);
switch(ghostversion)
{
case 0x000d:
case DEMOVERSION: // latest always supported
cnamelen = MAXCOLORNAME;
break;
@ -2168,7 +2163,7 @@ void G_AddGhost(char *defdemoname)
count = READUINT16(p);
while (count--)
{
p += 2;
SKIPSTRING(p);
SKIPSTRING(p);
p++;
}
@ -2324,6 +2319,7 @@ void G_DoPlayMetal(void)
switch(metalversion)
{
case DEMOVERSION: // latest always supported
case 0x000d: // There are checks wheter the momentum is from older demo versions or not
case 0x000c: // all that changed between then and now was longer color name
break;
// too old, cannot support.

View file

@ -297,100 +297,100 @@ static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"},
// don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler.
// it automatically becomes compact with 20+ players, but if you like it, I guess you can turn that on!
consvar_t cv_compactscoreboard= {"compactscoreboard", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_compactscoreboard= CVAR_INIT ("compactscoreboard", "Off", CV_SAVE, CV_OnOff, NULL);
// chat timer thingy
static CV_PossibleValue_t chattime_cons_t[] = {{5, "MIN"}, {999, "MAX"}, {0, NULL}};
consvar_t cv_chattime = {"chattime", "8", CV_SAVE, chattime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chattime = CVAR_INIT ("chattime", "8", CV_SAVE, chattime_cons_t, NULL);
// chatwidth
static CV_PossibleValue_t chatwidth_cons_t[] = {{64, "MIN"}, {300, "MAX"}, {0, NULL}};
consvar_t cv_chatwidth = {"chatwidth", "150", CV_SAVE, chatwidth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chatwidth = CVAR_INIT ("chatwidth", "150", CV_SAVE, chatwidth_cons_t, NULL);
// chatheight
static CV_PossibleValue_t chatheight_cons_t[] = {{6, "MIN"}, {22, "MAX"}, {0, NULL}};
consvar_t cv_chatheight= {"chatheight", "8", CV_SAVE, chatheight_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chatheight= CVAR_INIT ("chatheight", "8", CV_SAVE, chatheight_cons_t, NULL);
// chat notifications (do you want to hear beeps? I'd understand if you didn't.)
consvar_t cv_chatnotifications= {"chatnotifications", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chatnotifications= CVAR_INIT ("chatnotifications", "On", CV_SAVE, CV_OnOff, NULL);
// chat spam protection (why would you want to disable that???)
consvar_t cv_chatspamprotection= {"chatspamprotection", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chatspamprotection= CVAR_INIT ("chatspamprotection", "On", CV_SAVE, CV_OnOff, NULL);
// minichat text background
consvar_t cv_chatbacktint = {"chatbacktint", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chatbacktint = CVAR_INIT ("chatbacktint", "On", CV_SAVE, CV_OnOff, NULL);
// old shit console chat. (mostly exists for stuff like terminal, not because I cared if anyone liked the old chat.)
static CV_PossibleValue_t consolechat_cons_t[] = {{0, "Window"}, {1, "Console"}, {2, "Window (Hidden)"}, {0, NULL}};
consvar_t cv_consolechat = {"chatmode", "Window", CV_SAVE, consolechat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_consolechat = CVAR_INIT ("chatmode", "Window", CV_SAVE, consolechat_cons_t, NULL);
// Pause game upon window losing focus
consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_pauseifunfocused = CVAR_INIT ("pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL);
consvar_t cv_crosshair = {"crosshair", "Cross", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_crosshair2 = {"crosshair2", "Cross", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_invertmouse = {"invertmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_alwaysfreelook = {"alwaysmlook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_invertmouse2 = {"invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_alwaysfreelook2 = {"alwaysmlook2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chasefreelook = {"chasemlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chasefreelook2 = {"chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mousemove2 = {"mousemove2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_crosshair = CVAR_INIT ("crosshair", "Cross", CV_SAVE, crosshair_cons_t, NULL);
consvar_t cv_crosshair2 = CVAR_INIT ("crosshair2", "Cross", CV_SAVE, crosshair_cons_t, NULL);
consvar_t cv_invertmouse = CVAR_INIT ("invertmouse", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_alwaysfreelook = CVAR_INIT ("alwaysmlook", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_invertmouse2 = CVAR_INIT ("invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_alwaysfreelook2 = CVAR_INIT ("alwaysmlook2", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_chasefreelook = CVAR_INIT ("chasemlook", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_chasefreelook2 = CVAR_INIT ("chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_mousemove = CVAR_INIT ("mousemove", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_mousemove2 = CVAR_INIT ("mousemove2", "Off", CV_SAVE, CV_OnOff, NULL);
// previously "analog", "analog2", "useranalog", and "useranalog2", invalidating 2.1-era copies of config.cfg
// changed because it'd be nice to see people try out our actually good controls with gamepads now autobrake exists
consvar_t cv_analog[2] = {
{"sessionanalog", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"sessionanalog2", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog2_OnChange, 0, NULL, NULL, 0, 0, NULL}
CVAR_INIT ("sessionanalog", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog_OnChange),
CVAR_INIT ("sessionanalog2", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog2_OnChange),
};
consvar_t cv_useranalog[2] = {
{"configanalog", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"configanalog2", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange, 0, NULL, NULL, 0, 0, NULL}
CVAR_INIT ("configanalog", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange),
CVAR_INIT ("configanalog2", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange),
};
// deez New User eXperiences
static CV_PossibleValue_t directionchar_cons_t[] = {{0, "Camera"}, {1, "Movement"}, {2, "Simple Locked"}, {0, NULL}};
consvar_t cv_directionchar[2] = {
{"directionchar", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"directionchar2", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar2_OnChange, 0, NULL, NULL, 0, 0, NULL}
CVAR_INIT ("directionchar", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar_OnChange),
CVAR_INIT ("directionchar2", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar2_OnChange),
};
consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_autobrake = CVAR_INIT ("autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange);
consvar_t cv_autobrake2 = CVAR_INIT ("autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange);
// hi here's some new controls
static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_cam_shiftfacing[2] = {
{"cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
CVAR_INIT ("cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
CVAR_INIT ("cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
};
consvar_t cv_cam_turnfacing[2] = {
{"cam_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
CVAR_INIT ("cam_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
CVAR_INIT ("cam2_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
};
consvar_t cv_cam_turnfacingability[2] = {
{"cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
CVAR_INIT ("cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
CVAR_INIT ("cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
};
consvar_t cv_cam_turnfacingspindash[2] = {
{"cam_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
CVAR_INIT ("cam_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
CVAR_INIT ("cam2_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
};
consvar_t cv_cam_turnfacinginput[2] = {
{"cam_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
CVAR_INIT ("cam_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
CVAR_INIT ("cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL),
};
static CV_PossibleValue_t centertoggle_cons_t[] = {{0, "Hold"}, {1, "Toggle"}, {2, "Sticky Hold"}, {0, NULL}};
consvar_t cv_cam_centertoggle[2] = {
{"cam_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
CVAR_INIT ("cam_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL),
CVAR_INIT ("cam2_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL),
};
static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn"}, {0, NULL}};
consvar_t cv_cam_lockedinput[2] = {
{"cam_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
CVAR_INIT ("cam_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL),
CVAR_INIT ("cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL),
};
static CV_PossibleValue_t lockedassist_cons_t[] = {
@ -402,8 +402,8 @@ static CV_PossibleValue_t lockedassist_cons_t[] = {
{0, NULL}
};
consvar_t cv_cam_lockonboss[2] = {
{"cam_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
CVAR_INIT ("cam_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL),
CVAR_INIT ("cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL),
};
typedef enum
@ -422,27 +422,27 @@ typedef enum
AXISFIRENORMAL,
} axis_input_e;
consvar_t cv_turnaxis = {"joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_moveaxis = {"joyaxis_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sideaxis = {"joyaxis_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_lookaxis = {"joyaxis_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_jumpaxis = {"joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_spinaxis = {"joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_firenaxis = {"joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_deadzone = {"joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_digitaldeadzone = {"joy_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_turnaxis = CVAR_INIT ("joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_moveaxis = CVAR_INIT ("joyaxis_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_sideaxis = CVAR_INIT ("joyaxis_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_lookaxis = CVAR_INIT ("joyaxis_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_jumpaxis = CVAR_INIT ("joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_spinaxis = CVAR_INIT ("joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_fireaxis = CVAR_INIT ("joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_firenaxis = CVAR_INIT ("joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_deadzone = CVAR_INIT ("joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL);
consvar_t cv_digitaldeadzone = CVAR_INIT ("joy_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL);
consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_moveaxis2 = {"joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sideaxis2 = {"joyaxis2_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_lookaxis2 = {"joyaxis2_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_jumpaxis2 = {"joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_firenaxis2 = {"joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_deadzone2 = {"joy_deadzone2", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_digitaldeadzone2 = {"joy_digdeadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_turnaxis2 = CVAR_INIT ("joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_moveaxis2 = CVAR_INIT ("joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_sideaxis2 = CVAR_INIT ("joyaxis2_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_lookaxis2 = CVAR_INIT ("joyaxis2_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_jumpaxis2 = CVAR_INIT ("joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_spinaxis2 = CVAR_INIT ("joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_fireaxis2 = CVAR_INIT ("joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_firenaxis2 = CVAR_INIT ("joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL);
consvar_t cv_deadzone2 = CVAR_INIT ("joy_deadzone2", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL);
consvar_t cv_digitaldeadzone2 = CVAR_INIT ("joy_digdeadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL);
#ifdef SEENAMES
player_t *seenplayer; // player we're aiming at right now
@ -452,6 +452,8 @@ player_t *seenplayer; // player we're aiming at right now
// so that it doesn't have to be updated depending on the value of MAXPLAYERS
char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
INT32 player_name_changes[MAXPLAYERS];
INT16 rw_maximums[NUM_WEAPONS] =
{
800, // MAX_INFINITY
@ -1340,8 +1342,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// use with any button/key
axis = PlayerJoyAxis(ssplayer, AXISSPIN);
if (PLAYERINPUTDOWN(ssplayer, gc_use) || (usejoystick && axis > 0))
cmd->buttons |= BT_USE;
if (PLAYERINPUTDOWN(ssplayer, gc_spin) || (usejoystick && axis > 0))
cmd->buttons |= BT_SPIN;
// Centerview can be a toggle in simple mode!
{
@ -1675,6 +1677,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
}
}
// Note: Lat originally made the PlayerCmd hook for SRB2 Kart so credit goes to him.
if (gamestate == GS_LEVEL)
LUAh_PlayerCmd(player, cmd);
//Reset away view if a command is given.
if (ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons)
&& displayplayer != consoleplayer)
@ -2013,7 +2019,7 @@ boolean G_Responder(event_t *ev)
if (F_CreditResponder(ev))
{
// Skip credits for everyone
if (! serverrunning)/* hahahahahaha */
if (! netgame)
F_StartGameEvaluation();
else if (server || IsPlayerAdmin(consoleplayer))
SendNetXCmd(XD_EXITLEVEL, NULL, 0);
@ -2248,7 +2254,10 @@ void G_Ticker(boolean run)
players[i].angleturn += players[i].cmd.angleturn - players[i].oldrelangleturn;
players[i].oldrelangleturn = players[i].cmd.angleturn;
players[i].cmd.angleturn = players[i].angleturn;
if (P_ControlStyle(&players[i]) == CS_LMAOGALOG)
P_ForceLocalAngle(&players[i], players[i].angleturn << 16);
else
players[i].cmd.angleturn = players[i].angleturn;
}
}
@ -2342,6 +2351,11 @@ void G_Ticker(boolean run)
if (camtoggledelay2)
camtoggledelay2--;
if (gametic % NAMECHANGERATE == 0)
{
memset(player_name_changes, 0, sizeof player_name_changes);
}
}
}
@ -2572,7 +2586,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
p->spheres = spheres;
// Don't do anything immediately
p->pflags |= PF_USEDOWN;
p->pflags |= PF_SPINDOWN;
p->pflags |= PF_ATTACKDOWN;
p->pflags |= PF_JUMPDOWN;
@ -3504,7 +3518,7 @@ INT32 G_GetGametypeByName(const char *gametypestr)
//
boolean G_IsSpecialStage(INT32 mapnum)
{
if (gametype != GT_COOP || modeattacking == ATTACKING_RECORD)
if (modeattacking == ATTACKING_RECORD)
return false;
if (mapnum >= sstage_start && mapnum <= sstage_end)
return true;
@ -3805,7 +3819,7 @@ static void G_DoCompleted(void)
// a map of the proper gametype -- skip levels that don't support
// the current gametype. (Helps avoid playing boss levels in Race,
// for instance).
if (!spec)
if (!spec || nextmapoverride)
{
if (nextmap >= 0 && nextmap < NUMMAPS)
{
@ -3857,7 +3871,8 @@ static void G_DoCompleted(void)
if (nextmap < 0 || (nextmap >= NUMMAPS && nextmap < 1100-1) || nextmap > 1103-1)
I_Error("Followed map %d to invalid map %d\n", prevmap + 1, nextmap + 1);
lastmap = nextmap; // Remember last map for when you come out of the special stage.
if (!spec)
lastmap = nextmap; // Remember last map for when you come out of the special stage.
}
if ((gottoken = ((gametyperules & GTR_SPECIALSTAGES) && token)))
@ -3878,7 +3893,7 @@ static void G_DoCompleted(void)
}
}
if (spec && !gottoken)
if (spec && !gottoken && !nextmapoverride)
nextmap = lastmap; // Exiting from a special stage? Go back to the game. Tails 08-11-2001
automapactive = false;

View file

@ -18,6 +18,7 @@
#include "doomstat.h"
#include "d_event.h"
#include "g_demo.h"
#include "m_cheat.h" // objectplacing
extern char gamedatafilename[64];
extern char timeattackfolder[64];
@ -27,7 +28,8 @@ extern char customversionstring[32];
#ifdef SEENAMES
extern player_t *seenplayer;
#endif
extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
extern INT32 player_name_changes[MAXPLAYERS];
extern player_t players[MAXPLAYERS];
extern boolean playeringame[MAXPLAYERS];
@ -64,7 +66,7 @@ typedef enum {
CS_STANDARD,
CS_SIMPLE = CS_LMAOGALOG|CS_STANDARD,
} controlstyle_e;
#define G_ControlStyle(ssplayer) (cv_directionchar[(ssplayer)-1].value == 3 ? CS_LMAOGALOG : ((cv_analog[(ssplayer)-1].value ? CS_LMAOGALOG : 0) | (cv_directionchar[(ssplayer)-1].value ? CS_STANDARD : 0)))
#define G_ControlStyle(ssplayer) (cv_directionchar[(ssplayer)-1].value == 3 ? CS_LMAOGALOG : ((!objectplacing && cv_analog[(ssplayer)-1].value ? CS_LMAOGALOG : 0) | (cv_directionchar[(ssplayer)-1].value ? CS_STANDARD : 0)))
#define P_ControlStyle(player) ((((player)->pflags & PF_ANALOGMODE) ? CS_LMAOGALOG : 0) | (((player)->pflags & PF_DIRECTIONCHAR) ? CS_STANDARD : 0))
extern consvar_t cv_autobrake, cv_autobrake2;

View file

@ -25,11 +25,11 @@ static CV_PossibleValue_t mousesens_cons_t[] = {{1, "MIN"}, {MAXMOUSESENSITIVITY
static CV_PossibleValue_t onecontrolperkey_cons_t[] = {{1, "One"}, {2, "Several"}, {0, NULL}};
// mouse values are used once
consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mousesens2 = {"mousesens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouseysens2 = {"mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mousesens = CVAR_INIT ("mousesens", "20", CV_SAVE, mousesens_cons_t, NULL);
consvar_t cv_mousesens2 = CVAR_INIT ("mousesens2", "20", CV_SAVE, mousesens_cons_t, NULL);
consvar_t cv_mouseysens = CVAR_INIT ("mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL);
consvar_t cv_mouseysens2 = CVAR_INIT ("mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL);
consvar_t cv_controlperkey = CVAR_INIT ("controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL);
INT32 mousex, mousey;
INT32 mlooky; // like mousey but with a custom sensitivity for mlook
@ -57,13 +57,13 @@ const INT32 gcl_tutorial_check[num_gcl_tutorial_check] = {
const INT32 gcl_tutorial_used[num_gcl_tutorial_used] = {
gc_forward, gc_backward, gc_strafeleft, gc_straferight,
gc_turnleft, gc_turnright,
gc_jump, gc_use
gc_jump, gc_spin
};
const INT32 gcl_tutorial_full[num_gcl_tutorial_full] = {
gc_forward, gc_backward, gc_strafeleft, gc_straferight,
gc_lookup, gc_lookdown, gc_turnleft, gc_turnright, gc_centerview,
gc_jump, gc_use,
gc_jump, gc_spin,
gc_fire, gc_firenormal
};
@ -82,10 +82,10 @@ const INT32 gcl_movement_camera[num_gcl_movement_camera] = {
const INT32 gcl_jump[num_gcl_jump] = { gc_jump };
const INT32 gcl_use[num_gcl_use] = { gc_use };
const INT32 gcl_spin[num_gcl_spin] = { gc_spin };
const INT32 gcl_jump_use[num_gcl_jump_use] = {
gc_jump, gc_use
const INT32 gcl_jump_spin[num_gcl_jump_spin] = {
gc_jump, gc_spin
};
typedef struct
@ -583,7 +583,7 @@ static const char *gamecontrolname[num_gamecontrols] =
"fire",
"firenormal",
"tossflag",
"use",
"spin",
"camtoggle",
"camreset",
"lookup",
@ -692,7 +692,7 @@ void G_DefineDefaultControls(void)
gamecontroldefault[gcs_fps][gc_turnright ][0] = KEY_RIGHTARROW;
gamecontroldefault[gcs_fps][gc_centerview ][0] = KEY_END;
gamecontroldefault[gcs_fps][gc_jump ][0] = KEY_SPACE;
gamecontroldefault[gcs_fps][gc_use ][0] = KEY_LSHIFT;
gamecontroldefault[gcs_fps][gc_spin ][0] = KEY_LSHIFT;
gamecontroldefault[gcs_fps][gc_fire ][0] = KEY_RCTRL;
gamecontroldefault[gcs_fps][gc_fire ][1] = KEY_MOUSE1+0;
gamecontroldefault[gcs_fps][gc_firenormal ][0] = 'c';
@ -708,7 +708,7 @@ void G_DefineDefaultControls(void)
gamecontroldefault[gcs_platform][gc_turnright ][0] = KEY_RIGHTARROW;
gamecontroldefault[gcs_platform][gc_centerview ][0] = KEY_END;
gamecontroldefault[gcs_platform][gc_jump ][0] = KEY_SPACE;
gamecontroldefault[gcs_platform][gc_use ][0] = KEY_LSHIFT;
gamecontroldefault[gcs_platform][gc_spin ][0] = KEY_LSHIFT;
gamecontroldefault[gcs_platform][gc_fire ][0] = 's';
gamecontroldefault[gcs_platform][gc_fire ][1] = KEY_MOUSE1+0;
gamecontroldefault[gcs_platform][gc_firenormal ][0] = 'w';
@ -743,7 +743,7 @@ void G_DefineDefaultControls(void)
gamecontroldefault[i][gc_weaponnext ][1] = KEY_JOY1+1; // B
gamecontroldefault[i][gc_weaponprev ][1] = KEY_JOY1+2; // X
gamecontroldefault[i][gc_tossflag ][1] = KEY_JOY1+0; // A
gamecontroldefault[i][gc_use ][1] = KEY_JOY1+4; // LB
gamecontroldefault[i][gc_spin ][1] = KEY_JOY1+4; // LB
gamecontroldefault[i][gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up
gamecontroldefault[i][gc_camreset ][1] = KEY_JOY1+3; // Y
gamecontroldefault[i][gc_centerview ][1] = KEY_JOY1+9; // Right Stick
@ -758,7 +758,7 @@ void G_DefineDefaultControls(void)
gamecontrolbisdefault[i][gc_weaponnext][0] = KEY_2JOY1+1; // B
gamecontrolbisdefault[i][gc_weaponprev][0] = KEY_2JOY1+2; // X
gamecontrolbisdefault[i][gc_tossflag ][0] = KEY_2JOY1+0; // A
gamecontrolbisdefault[i][gc_use ][0] = KEY_2JOY1+4; // LB
gamecontrolbisdefault[i][gc_spin ][0] = KEY_2JOY1+4; // LB
gamecontrolbisdefault[i][gc_camreset ][0] = KEY_2JOY1+3; // Y
gamecontrolbisdefault[i][gc_centerview][0] = KEY_2JOY1+9; // Right Stick
gamecontrolbisdefault[i][gc_jump ][0] = KEY_2JOY1+5; // RB
@ -890,7 +890,7 @@ static INT32 G_FilterKeyByVersion(INT32 numctrl, INT32 keyidx, INT32 player, INT
if (GETMAJOREXECVERSION(cv_execversion.value) < 27 && ( // v2.1.22
numctrl == gc_weaponnext || numctrl == gc_weaponprev || numctrl == gc_tossflag ||
numctrl == gc_use || numctrl == gc_camreset || numctrl == gc_jump ||
numctrl == gc_spin || numctrl == gc_camreset || numctrl == gc_jump ||
numctrl == gc_pause || numctrl == gc_systemmenu || numctrl == gc_camtoggle ||
numctrl == gc_screenshot || numctrl == gc_talkkey || numctrl == gc_scores ||
numctrl == gc_centerview
@ -996,7 +996,9 @@ static void setcontrol(INT32 (*gc)[2])
INT32 player = ((void*)gc == (void*)&gamecontrolbis ? 1 : 0);
boolean nestedoverride = false;
namectrl = COM_Argv(1);
// Update me for 2.3
namectrl = (stricmp(COM_Argv(1), "use")) ? COM_Argv(1) : "spin";
for (numctrl = 0; numctrl < num_gamecontrols && stricmp(namectrl, gamecontrolname[numctrl]);
numctrl++)
;

View file

@ -80,7 +80,7 @@ typedef enum
gc_fire,
gc_firenormal,
gc_tossflag,
gc_use,
gc_spin,
gc_camtoggle,
gc_camreset,
gc_lookup,
@ -141,8 +141,8 @@ extern INT32 gamecontrolbisdefault[num_gamecontrolschemes][num_gamecontrols][2];
#define num_gcl_camera 2
#define num_gcl_movement_camera 6
#define num_gcl_jump 1
#define num_gcl_use 1
#define num_gcl_jump_use 2
#define num_gcl_spin 1
#define num_gcl_jump_spin 2
extern const INT32 gcl_tutorial_check[num_gcl_tutorial_check];
extern const INT32 gcl_tutorial_used[num_gcl_tutorial_used];
@ -151,8 +151,8 @@ extern const INT32 gcl_movement[num_gcl_movement];
extern const INT32 gcl_camera[num_gcl_camera];
extern const INT32 gcl_movement_camera[num_gcl_movement_camera];
extern const INT32 gcl_jump[num_gcl_jump];
extern const INT32 gcl_use[num_gcl_use];
extern const INT32 gcl_jump_use[num_gcl_jump_use];
extern const INT32 gcl_spin[num_gcl_spin];
extern const INT32 gcl_jump_spin[num_gcl_jump_spin];
// peace to my little coder fingers!
// check a gamecontrol being active or not

View file

@ -235,13 +235,13 @@ void HWR_RenderBatches(void)
currently_batching = false;// no longer collecting batches
if (!polygonArraySize)
{
rs_hw_numpolys = rs_hw_numcalls = rs_hw_numshaders = rs_hw_numtextures = rs_hw_numpolyflags = rs_hw_numcolors = 0;
ps_hw_numpolys = ps_hw_numcalls = ps_hw_numshaders = ps_hw_numtextures = ps_hw_numpolyflags = ps_hw_numcolors = 0;
return;// nothing to draw
}
// init stats vars
rs_hw_numpolys = polygonArraySize;
rs_hw_numcalls = rs_hw_numverts = 0;
rs_hw_numshaders = rs_hw_numtextures = rs_hw_numpolyflags = rs_hw_numcolors = 1;
ps_hw_numpolys = polygonArraySize;
ps_hw_numcalls = ps_hw_numverts = 0;
ps_hw_numshaders = ps_hw_numtextures = ps_hw_numpolyflags = ps_hw_numcolors = 1;
// init polygonIndexArray
for (i = 0; i < polygonArraySize; i++)
{
@ -249,12 +249,12 @@ void HWR_RenderBatches(void)
}
// sort polygons
rs_hw_batchsorttime = I_GetTimeMicros();
ps_hw_batchsorttime = I_GetTimeMicros();
if (cv_glshaders.value && gl_shadersavailable)
qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons);
else
qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders);
rs_hw_batchsorttime = I_GetTimeMicros() - rs_hw_batchsorttime;
ps_hw_batchsorttime = I_GetTimeMicros() - ps_hw_batchsorttime;
// sort order
// 1. shader
// 2. texture
@ -262,7 +262,7 @@ void HWR_RenderBatches(void)
// 4. colors + light level
// not sure about what order of the last 2 should be, or if it even matters
rs_hw_batchdrawtime = I_GetTimeMicros();
ps_hw_batchdrawtime = I_GetTimeMicros();
currentShader = polygonArray[polygonIndexArray[0]].shader;
currentTexture = polygonArray[polygonIndexArray[0]].texture;
@ -398,8 +398,8 @@ void HWR_RenderBatches(void)
// execute draw call
HWD.pfnDrawIndexedTriangles(&currentSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray);
// update stats
rs_hw_numcalls++;
rs_hw_numverts += finalIndexWritePos;
ps_hw_numcalls++;
ps_hw_numverts += finalIndexWritePos;
// reset write positions
finalVertexWritePos = 0;
finalIndexWritePos = 0;
@ -416,7 +416,7 @@ void HWR_RenderBatches(void)
currentShader = nextShader;
changeShader = false;
rs_hw_numshaders++;
ps_hw_numshaders++;
}
if (changeTexture)
{
@ -425,21 +425,21 @@ void HWR_RenderBatches(void)
currentTexture = nextTexture;
changeTexture = false;
rs_hw_numtextures++;
ps_hw_numtextures++;
}
if (changePolyFlags)
{
currentPolyFlags = nextPolyFlags;
changePolyFlags = false;
rs_hw_numpolyflags++;
ps_hw_numpolyflags++;
}
if (changeSurfaceInfo)
{
currentSurfaceInfo = nextSurfaceInfo;
changeSurfaceInfo = false;
rs_hw_numcolors++;
ps_hw_numcolors++;
}
// and that should be it?
}
@ -447,7 +447,7 @@ void HWR_RenderBatches(void)
polygonArraySize = 0;
unsortedVertexArraySize = 0;
rs_hw_batchdrawtime = I_GetTimeMicros() - rs_hw_batchdrawtime;
ps_hw_batchdrawtime = I_GetTimeMicros() - ps_hw_batchdrawtime;
}

View file

@ -20,11 +20,12 @@
#include "../doomstat.h" //gamemode
#include "../i_video.h" //rendermode
#include "../r_data.h"
#include "../r_textures.h"
#include "../w_wad.h"
#include "../z_zone.h"
#include "../v_video.h"
#include "../r_draw.h"
#include "../r_patch.h"
#include "../r_picformats.h"
#include "../p_setup.h"
INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes
@ -99,17 +100,15 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
count--;
texel = source[yfrac>>FRACBITS];
alpha = 0xFF;
// Make pixel transparent if chroma keyed
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
alpha = 0x00;
//Hurdler: 25/04/2000: now support colormap in hardware mode
if (mipmap->colormap)
texel = mipmap->colormap[texel];
// If the mipmap is chromakeyed, check if the texel's color
// is equivalent to the chroma key's color index.
alpha = 0xff;
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
alpha = 0x00;
// hope compiler will get this switch out of the loops (dreams...)
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
// Alam: SRB2 uses Mingw, HUGS
@ -211,17 +210,15 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
count--;
texel = source[yfrac>>FRACBITS];
alpha = 0xFF;
// Make pixel transparent if chroma keyed
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
alpha = 0x00;
//Hurdler: 25/04/2000: now support colormap in hardware mode
if (mipmap->colormap)
texel = mipmap->colormap[texel];
// If the mipmap is chromakeyed, check if the texel's color
// is equivalent to the chroma key's color index.
alpha = 0xff;
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
alpha = 0x00;
// hope compiler will get this switch out of the loops (dreams...)
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
// Alam: SRB2 uses Mingw, HUGS
@ -508,13 +505,13 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
realpatch = (patch_t *)pdata;
#ifndef NO_PNG_LUMPS
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL);
if (Picture_IsLumpPNG((UINT8 *)realpatch, lumplength))
realpatch = (patch_t *)Picture_PNGConvert(pdata, PICFMT_PATCH, NULL, NULL, NULL, NULL, lumplength, NULL, 0);
else
#endif
#ifdef WALLFLATS
if (texture->type == TEXTURETYPE_FLAT)
realpatch = R_FlatToPatch(pdata, texture->width, texture->height, 0, 0, NULL, false);
realpatch = (patch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_PATCH, 0, NULL, texture->width, texture->height, 0, 0, 0);
else
#endif
{
@ -550,8 +547,8 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
#ifndef NO_PNG_LUMPS
// lump is a png so convert it
size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum);
if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len))
patch = R_PNGToPatch((const UINT8 *)patch, len, NULL);
if ((patch != NULL) && Picture_IsLumpPNG((const UINT8 *)patch, len))
patch = (patch_t *)Picture_PNGConvert((const UINT8 *)patch, PICFMT_PATCH, NULL, NULL, NULL, NULL, len, NULL, 0);
#endif
// don't do it twice (like a cache)
@ -788,6 +785,8 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
{
UINT8 *flat;
UINT8 *converted;
size_t size;
// setup the texture info
grMipmap->format = GL_TEXFMT_P_8;
@ -795,11 +794,12 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
grMipmap->width = (UINT16)textures[texturenum]->width;
grMipmap->height = (UINT16)textures[texturenum]->height;
size = (grMipmap->width * grMipmap->height);
flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->data);
memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height);
R_TextureToFlat(texturenum, flat);
flat = Z_Malloc(size, PU_HWRCACHE, &grMipmap->data);
converted = (UINT8 *)Picture_TextureToFlat(texturenum);
M_Memcpy(flat, converted, size);
Z_Free(converted);
}
// Download a Doom 'flat' to the hardware cache and make it ready for use
@ -837,7 +837,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
INT32 texturenum = levelflat->u.texture.num;
#ifdef PARANOIA
if ((unsigned)texturenum >= gl_numtextures)
I_Error("HWR_GetLevelFlat: texturenum >= numtextures\n");
I_Error("HWR_GetLevelFlat: texturenum >= numtextures");
#endif
// Who knows?
@ -860,6 +860,53 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
// The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
}
else if (levelflat->type == LEVELFLAT_PATCH)
{
GLPatch_t *patch = W_CachePatchNum(levelflat->u.flat.lumpnum, PU_CACHE);
levelflat->width = (UINT16)SHORT(patch->width);
levelflat->height = (UINT16)SHORT(patch->height);
HWR_GetPatch(patch);
}
#ifndef NO_PNG_LUMPS
else if (levelflat->type == LEVELFLAT_PNG)
{
INT32 pngwidth = 0, pngheight = 0;
GLMipmap_t *mipmap = levelflat->mipmap;
UINT8 *flat;
size_t size;
// Cache the picture.
if (!levelflat->picture)
{
levelflat->picture = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
levelflat->width = (UINT16)pngwidth;
levelflat->height = (UINT16)pngheight;
}
// Make the mipmap.
if (mipmap == NULL)
{
mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_LEVEL, NULL);
mipmap->format = GL_TEXFMT_P_8;
mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
levelflat->mipmap = mipmap;
}
if (!mipmap->data && !mipmap->downloaded)
{
mipmap->width = levelflat->width;
mipmap->height = levelflat->height;
size = (mipmap->width * mipmap->height);
flat = Z_Malloc(size, PU_LEVEL, &mipmap->data);
if (levelflat->picture == NULL)
I_Error("HWR_GetLevelFlat: levelflat->picture == NULL");
M_Memcpy(flat, levelflat->picture, size);
}
// Tell the hardware driver to bind the current texture to the flat's mipmap
HWD.pfnSetTexture(mipmap);
}
#endif
else // set no texture
HWR_SetCurrentTexture(NULL);
}

View file

@ -132,6 +132,77 @@ typedef struct
FLOAT t; // t texture ordinate (t over w)
} FOutVector;
#ifdef GL_SHADERS
// Predefined shader types
enum
{
SHADER_DEFAULT = 0,
SHADER_FLOOR,
SHADER_WALL,
SHADER_SPRITE,
SHADER_MODEL, SHADER_MODEL_LIGHTING,
SHADER_WATER,
SHADER_FOG,
SHADER_SKY,
NUMBASESHADERS,
};
// Maximum amount of shader programs
// Must be higher than NUMBASESHADERS
#define HWR_MAXSHADERS 16
// Shader sources (vertex and fragment)
typedef struct
{
char *vertex;
char *fragment;
} shadersource_t;
// Custom shader reference table
typedef struct
{
const char *type;
INT32 id;
} customshaderxlat_t;
#endif
typedef struct vbo_vertex_s
{
float x, y, z;
float u, v;
unsigned char r, g, b, a;
} gl_skyvertex_t;
typedef enum gl_skyloopmode_e
{
HWD_SKYLOOP_FAN,
HWD_SKYLOOP_STRIP
} gl_skyloopmode_t;
typedef struct
{
gl_skyloopmode_t mode;
int vertexcount;
int vertexindex;
boolean use_texture;
} gl_skyloopdef_t;
typedef struct
{
unsigned int vbo;
int rows, columns;
int loopcount;
int detail, vertex_count;
int texture, width, height;
boolean rebuild; // VBO needs to be rebuilt
gl_skyloopdef_t *loops;
gl_skyvertex_t *data;
} gl_sky_t;
// ==========================================================================
// RENDER MODES

View file

@ -37,7 +37,7 @@ EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, UINT32 *IndexArray);
EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform);
EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
@ -68,14 +68,13 @@ EXPORT void HWRAPI(DrawScreenFinalTexture) (int width, int height);
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
// jimita
EXPORT boolean HWRAPI(LoadShaders) (void);
EXPORT void HWRAPI(KillShaders) (void);
EXPORT boolean HWRAPI(CompileShaders) (void);
EXPORT void HWRAPI(CleanShaders) (void);
EXPORT void HWRAPI(SetShader) (int shader);
EXPORT void HWRAPI(UnSetShader) (void);
EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value);
EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boolean fragment);
EXPORT boolean HWRAPI(InitCustomShaders) (void);
EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boolean isfragment);
// ==========================================================================
// HWR DRIVER OBJECT, FOR CLIENT PROGRAM
@ -120,14 +119,13 @@ struct hwdriver_s
MakeScreenFinalTexture pfnMakeScreenFinalTexture;
DrawScreenFinalTexture pfnDrawScreenFinalTexture;
LoadShaders pfnLoadShaders;
KillShaders pfnKillShaders;
CompileShaders pfnCompileShaders;
CleanShaders pfnCleanShaders;
SetShader pfnSetShader;
UnSetShader pfnUnSetShader;
SetShaderInfo pfnSetShaderInfo;
LoadCustomShader pfnLoadCustomShader;
InitCustomShaders pfnInitCustomShaders;
};
extern struct hwdriver_s hwdriver;

View file

@ -25,7 +25,7 @@
#include "../p_local.h"
#include "../p_setup.h"
#include "../r_local.h"
#include "../r_patch.h"
#include "../r_picformats.h"
#include "../r_bsp.h"
#include "../d_clisrv.h"
#include "../w_wad.h"
@ -146,21 +146,22 @@ static angle_t gl_aimingangle;
static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox);
// Render stats
int rs_hw_nodesorttime = 0;
int rs_hw_nodedrawtime = 0;
int rs_hw_spritesorttime = 0;
int rs_hw_spritedrawtime = 0;
int ps_hw_skyboxtime = 0;
int ps_hw_nodesorttime = 0;
int ps_hw_nodedrawtime = 0;
int ps_hw_spritesorttime = 0;
int ps_hw_spritedrawtime = 0;
// Render stats for batching
int rs_hw_numpolys = 0;
int rs_hw_numverts = 0;
int rs_hw_numcalls = 0;
int rs_hw_numshaders = 0;
int rs_hw_numtextures = 0;
int rs_hw_numpolyflags = 0;
int rs_hw_numcolors = 0;
int rs_hw_batchsorttime = 0;
int rs_hw_batchdrawtime = 0;
int ps_hw_numpolys = 0;
int ps_hw_numverts = 0;
int ps_hw_numcalls = 0;
int ps_hw_numshaders = 0;
int ps_hw_numtextures = 0;
int ps_hw_numpolyflags = 0;
int ps_hw_numcolors = 0;
int ps_hw_batchsorttime = 0;
int ps_hw_batchdrawtime = 0;
boolean gl_shadersavailable = true;
@ -358,7 +359,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
float fflatwidth = 64.0f, fflatheight = 64.0f;
INT32 flatflag = 63;
boolean texflat = false;
size_t len;
float scrollx = 0.0f, scrolly = 0.0f;
angle_t angle = 0;
FSurfaceInfo Surf;
@ -413,16 +413,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
// set texture for polygon
if (levelflat != NULL)
{
if (levelflat->type == LEVELFLAT_TEXTURE)
if (levelflat->type == LEVELFLAT_FLAT)
{
fflatwidth = textures[levelflat->u.texture.num]->width;
fflatheight = textures[levelflat->u.texture.num]->height;
texflat = true;
}
else if (levelflat->type == LEVELFLAT_FLAT)
{
len = W_LumpLength(levelflat->u.flat.lumpnum);
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
switch (len)
{
case 4194304: // 2048x2048 lump
@ -447,9 +440,22 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
fflatwidth = fflatheight = 64.0f;
break;
}
flatflag = ((INT32)fflatwidth)-1;
}
else
{
if (levelflat->type == LEVELFLAT_TEXTURE)
{
fflatwidth = textures[levelflat->u.texture.num]->width;
fflatheight = textures[levelflat->u.texture.num]->height;
}
else if (levelflat->type == LEVELFLAT_PATCH || levelflat->type == LEVELFLAT_PNG)
{
fflatwidth = levelflat->width;
fflatheight = levelflat->height;
}
texflat = true;
}
}
else // set no texture
HWR_SetCurrentTexture(NULL);
@ -494,7 +500,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
if (angle) // Only needs to be done if there's an altered angle
{
angle = (InvAngle(angle)+ANGLE_180)>>ANGLETOFINESHIFT;
angle = (InvAngle(angle))>>ANGLETOFINESHIFT;
// This needs to be done so that it scrolls in a different direction after rotation like software
/*tempxsow = FLOAT_TO_FIXED(scrollx);
@ -528,8 +534,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
{\
tempxsow = FLOAT_TO_FIXED(vert->s);\
tempytow = FLOAT_TO_FIXED(vert->t);\
if (texflat)\
tempytow = -tempytow;\
vert->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\
vert->t = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\
}\
@ -562,11 +566,11 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
PolyFlags |= PF_Masked|PF_Modulated;
if (PolyFlags & PF_Fog)
shader = 6; // fog shader
shader = SHADER_FOG; // fog shader
else if (PolyFlags & PF_Ripple)
shader = 5; // water shader
shader = SHADER_WATER; // water shader
else
shader = 1; // floor shader
shader = SHADER_FLOOR; // floor shader
HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false);
@ -763,7 +767,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
break;
}
HWD.pfnSetShader(2); // wall shader
HWD.pfnSetShader(SHADER_WALL); // wall shader
HWD.pfnDrawPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal);
}
}
@ -800,7 +804,7 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL
{
HWR_Lighting(pSurf, lightlevel, wallcolormap);
HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, 2, false); // wall shader
HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, SHADER_WALL, false); // wall shader
#ifdef WALLSPLATS
if (gl_curline->linedef->splats && cv_splats.value)
@ -1955,7 +1959,7 @@ static cliprange_t * hw_newend;
static cliprange_t gl_solidsegs[MAXSEGS];
// needs fix: walls are incorrectly clipped one column less
static consvar_t cv_glclipwalls = {"gr_clipwalls", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cv_glclipwalls = CVAR_INIT ("gr_clipwalls", "Off", 0, CV_OnOff, NULL);
static void printsolidsegs(void)
{
@ -2260,8 +2264,8 @@ static void HWR_AddLine(seg_t * line)
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y);
// OPTIMIZE: quickly reject orthogonal back sides.
angle1 = R_PointToAngle(v1x, v1y);
angle2 = R_PointToAngle(v2x, v2y);
angle1 = R_PointToAngle64(v1x, v1y);
angle2 = R_PointToAngle64(v2x, v2y);
#ifdef NEWCLIP
// PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle!
@ -2554,8 +2558,8 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord)
py2 = bspcoord[checkcoord[boxpos][3]];
#ifdef NEWCLIP
angle1 = R_PointToAngle(px1, py1);
angle2 = R_PointToAngle(px2, py2);
angle1 = R_PointToAngle64(px1, py1);
angle2 = R_PointToAngle64(px2, py2);
return gld_clipper_SafeCheckRange(angle2, angle1);
#else
// check clip list for an open space
@ -2661,7 +2665,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
float fflatwidth = 64.0f, fflatheight = 64.0f;
INT32 flatflag = 63;
boolean texflat = false;
size_t len;
float scrollx = 0.0f, scrolly = 0.0f;
angle_t angle = 0;
FSurfaceInfo Surf;
@ -2695,16 +2698,9 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
// set texture for polygon
if (levelflat != NULL)
{
if (levelflat->type == LEVELFLAT_TEXTURE)
if (levelflat->type == LEVELFLAT_FLAT)
{
fflatwidth = textures[levelflat->u.texture.num]->width;
fflatheight = textures[levelflat->u.texture.num]->height;
texflat = true;
}
else if (levelflat->type == LEVELFLAT_FLAT)
{
len = W_LumpLength(levelflat->u.flat.lumpnum);
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
switch (len)
{
case 4194304: // 2048x2048 lump
@ -2729,9 +2725,22 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
fflatwidth = fflatheight = 64.0f;
break;
}
flatflag = ((INT32)fflatwidth)-1;
}
else
{
if (levelflat->type == LEVELFLAT_TEXTURE)
{
fflatwidth = textures[levelflat->u.texture.num]->width;
fflatheight = textures[levelflat->u.texture.num]->height;
}
else if (levelflat->type == LEVELFLAT_PATCH || levelflat->type == LEVELFLAT_PNG)
{
fflatwidth = levelflat->width;
fflatheight = levelflat->height;
}
texflat = true;
}
}
else // set no texture
HWR_SetCurrentTexture(NULL);
@ -2752,13 +2761,13 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
{
scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatwidth;
scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatheight;
angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT;
angle = FOFsector->floorpic_angle;
}
else // it's a ceiling
{
scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatwidth;
scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatheight;
angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT;
angle = FOFsector->ceilingpic_angle;
}
}
else if (gl_frontsector)
@ -2767,23 +2776,25 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
{
scrollx = FIXED_TO_FLOAT(gl_frontsector->floor_xoffs)/fflatwidth;
scrolly = FIXED_TO_FLOAT(gl_frontsector->floor_yoffs)/fflatheight;
angle = gl_frontsector->floorpic_angle>>ANGLETOFINESHIFT;
angle = gl_frontsector->floorpic_angle;
}
else // it's a ceiling
{
scrollx = FIXED_TO_FLOAT(gl_frontsector->ceiling_xoffs)/fflatwidth;
scrolly = FIXED_TO_FLOAT(gl_frontsector->ceiling_yoffs)/fflatheight;
angle = gl_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT;
angle = gl_frontsector->ceilingpic_angle;
}
}
if (angle) // Only needs to be done if there's an altered angle
{
angle = (InvAngle(angle))>>ANGLETOFINESHIFT;
// This needs to be done so that it scrolls in a different direction after rotation like software
tempxs = FLOAT_TO_FIXED(scrollx);
/*tempxs = FLOAT_TO_FIXED(scrollx);
tempyt = FLOAT_TO_FIXED(scrolly);
scrollx = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle))));
scrolly = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle))));
scrolly = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle))));*/
// This needs to be done so everything aligns after rotation
// It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does
@ -2813,10 +2824,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
{
tempxs = FLOAT_TO_FIXED(v3d->s);
tempyt = FLOAT_TO_FIXED(v3d->t);
if (texflat)
tempyt = -tempyt;
v3d->s = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle))));
v3d->t = (FIXED_TO_FLOAT(-FixedMul(tempxs, FINESINE(angle)) - FixedMul(tempyt, FINECOSINE(angle))));
v3d->t = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle))));
}
v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x);
@ -2835,7 +2844,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
else
blendmode |= PF_Masked|PF_Modulated|PF_Clip;
HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, 1, false); // floor shader
HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, SHADER_FLOOR, false); // floor shader
}
static void HWR_AddPolyObjectPlanes(void)
@ -3180,7 +3189,7 @@ static void HWR_Subsector(size_t num)
}
// for render stats
rs_numpolyobjects += numpolys;
ps_numpolyobjects += numpolys;
// Sort polyobjects
R_SortPolyObjects(sub);
@ -3288,7 +3297,7 @@ static void HWR_RenderBSPNode(INT32 bspnum)
// Decide which side the view point is on
INT32 side;
rs_numbspcalls++;
ps_numbspcalls++;
// Found a subsector?
if (bspnum & NF_SUBSECTOR)
@ -3647,7 +3656,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
HWR_Lighting(&sSurf, 0, colormap);
sSurf.PolyColor.s.alpha = alpha;
HWR_ProcessPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated|PF_Clip, 3, false); // sprite shader
HWR_ProcessPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader
}
// This is expecting a pointer to an array containing 4 wallVerts for a sprite
@ -3921,7 +3930,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
Surf.PolyColor.s.alpha = alpha;
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader
if (use_linkdraw_hack)
HWR_LinkDrawHackAdd(wallVerts, spr);
@ -3950,7 +3959,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
Surf.PolyColor.s.alpha = alpha;
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader
if (use_linkdraw_hack)
HWR_LinkDrawHackAdd(wallVerts, spr);
@ -4110,7 +4119,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
if (!occlusion) use_linkdraw_hack = true;
}
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader
if (use_linkdraw_hack)
HWR_LinkDrawHackAdd(wallVerts, spr);
@ -4212,7 +4221,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
blend = PF_Translucent|PF_Occlude;
}
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, SHADER_SPRITE, false); // sprite shader
}
#endif
@ -4494,7 +4503,7 @@ static void HWR_CreateDrawNodes(void)
// that is already lying around. This should all be in some sort of linked list or lists.
sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL);
rs_hw_nodesorttime = I_GetTimeMicros();
ps_hw_nodesorttime = I_GetTimeMicros();
for (i = 0; i < numplanes; i++, p++)
{
@ -4514,7 +4523,7 @@ static void HWR_CreateDrawNodes(void)
sortindex[p] = p;
}
rs_numdrawnodes = p;
ps_numdrawnodes = p;
// p is the number of stuff to sort
@ -4549,13 +4558,13 @@ static void HWR_CreateDrawNodes(void)
}
}
rs_hw_nodesorttime = I_GetTimeMicros() - rs_hw_nodesorttime;
ps_hw_nodesorttime = I_GetTimeMicros() - ps_hw_nodesorttime;
rs_hw_nodedrawtime = I_GetTimeMicros();
ps_hw_nodedrawtime = I_GetTimeMicros();
// Okay! Let's draw it all! Woo!
HWD.pfnSetTransform(&atransform);
HWD.pfnSetShader(0);
HWD.pfnSetShader(SHADER_DEFAULT);
for (i = 0; i < p; i++)
{
@ -4588,7 +4597,7 @@ static void HWR_CreateDrawNodes(void)
}
}
rs_hw_nodedrawtime = I_GetTimeMicros() - rs_hw_nodedrawtime;
ps_hw_nodedrawtime = I_GetTimeMicros() - ps_hw_nodedrawtime;
numwalls = 0;
numplanes = 0;
@ -5182,10 +5191,155 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
#endif
// ==========================================================================
//
// Sky dome rendering, ported from PrBoom+
// ==========================================================================
static gl_sky_t gl_sky;
static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, signed char yflip, float delta, boolean foglayer)
{
const float radians = (float)(M_PIl / 180.0f);
const float scale = 10000.0f;
const float maxSideAngle = 60.0f;
float topAngle = (c / (float)sky->columns * 360.0f);
float sideAngle = (maxSideAngle * (sky->rows - r) / sky->rows);
float height = (float)(sin(sideAngle * radians));
float realRadius = (float)(scale * cos(sideAngle * radians));
float x = (float)(realRadius * cos(topAngle * radians));
float y = (!yflip) ? scale * height : -scale * height;
float z = (float)(realRadius * sin(topAngle * radians));
float timesRepeat = (4 * (256.0f / sky->width));
if (fpclassify(timesRepeat) == FP_ZERO)
timesRepeat = 1.0f;
if (!foglayer)
{
vbo->r = 255;
vbo->g = 255;
vbo->b = 255;
vbo->a = (r == 0 ? 0 : 255);
// And the texture coordinates.
vbo->u = (-timesRepeat * c / (float)sky->columns);
if (!yflip) // Flipped Y is for the lower hemisphere.
vbo->v = (r / (float)sky->rows) + 0.5f;
else
vbo->v = 1.0f + ((sky->rows - r) / (float)sky->rows) + 0.5f;
}
if (r != 4)
y += 300.0f;
// And finally the vertex.
vbo->x = x;
vbo->y = y + delta;
vbo->z = z;
}
// Clears the sky dome.
void HWR_ClearSkyDome(void)
{
gl_sky_t *sky = &gl_sky;
if (sky->loops)
free(sky->loops);
if (sky->data)
free(sky->data);
sky->loops = NULL;
sky->data = NULL;
sky->vbo = 0;
sky->rows = sky->columns = 0;
sky->loopcount = 0;
sky->detail = 0;
sky->texture = -1;
sky->width = sky->height = 0;
sky->rebuild = true;
}
void HWR_BuildSkyDome(void)
{
int c, r;
signed char yflip;
int row_count = 4;
int col_count = 4;
float delta;
gl_sky_t *sky = &gl_sky;
gl_skyvertex_t *vertex_p;
texture_t *texture = textures[texturetranslation[skytexture]];
sky->detail = 16;
col_count *= sky->detail;
if ((sky->columns != col_count) || (sky->rows != row_count))
HWR_ClearSkyDome();
sky->columns = col_count;
sky->rows = row_count;
sky->vertex_count = 2 * sky->rows * (sky->columns * 2 + 2) + sky->columns * 2;
if (!sky->loops)
sky->loops = malloc((sky->rows * 2 + 2) * sizeof(sky->loops[0]));
// create vertex array
if (!sky->data)
sky->data = malloc(sky->vertex_count * sizeof(sky->data[0]));
sky->texture = texturetranslation[skytexture];
sky->width = texture->width;
sky->height = texture->height;
vertex_p = &sky->data[0];
sky->loopcount = 0;
for (yflip = 0; yflip < 2; yflip++)
{
sky->loops[sky->loopcount].mode = HWD_SKYLOOP_FAN;
sky->loops[sky->loopcount].vertexindex = vertex_p - &sky->data[0];
sky->loops[sky->loopcount].vertexcount = col_count;
sky->loops[sky->loopcount].use_texture = false;
sky->loopcount++;
delta = 0.0f;
for (c = 0; c < col_count; c++)
{
HWR_SkyDomeVertex(sky, vertex_p, 1, c, yflip, 0.0f, true);
vertex_p->r = 255;
vertex_p->g = 255;
vertex_p->b = 255;
vertex_p->a = 255;
vertex_p++;
}
delta = (yflip ? 5.0f : -5.0f) / 128.0f;
for (r = 0; r < row_count; r++)
{
sky->loops[sky->loopcount].mode = HWD_SKYLOOP_STRIP;
sky->loops[sky->loopcount].vertexindex = vertex_p - &sky->data[0];
sky->loops[sky->loopcount].vertexcount = 2 * col_count + 2;
sky->loops[sky->loopcount].use_texture = true;
sky->loopcount++;
for (c = 0; c <= col_count; c++)
{
HWR_SkyDomeVertex(sky, vertex_p++, r + (yflip ? 1 : 0), (c ? c : 0), yflip, delta, false);
HWR_SkyDomeVertex(sky, vertex_p++, r + (yflip ? 0 : 1), (c ? c : 0), yflip, delta, false);
}
}
}
}
static void HWR_DrawSkyBackground(player_t *player)
{
HWD.pfnSetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated);
if (cv_glskydome.value)
{
FTransform dometransform;
@ -5223,7 +5377,16 @@ static void HWR_DrawSkyBackground(player_t *player)
dometransform.splitscreen = splitscreen;
HWR_GetTexture(texturetranslation[skytexture]);
HWD.pfnRenderSkyDome(skytexture, textures[skytexture]->width, textures[skytexture]->height, dometransform);
if (gl_sky.texture != texturetranslation[skytexture])
{
HWR_ClearSkyDome();
HWR_BuildSkyDome();
}
HWD.pfnSetShader(SHADER_SKY); // sky shader
HWD.pfnSetTransform(&dometransform);
HWD.pfnRenderSkyDome(&gl_sky);
}
else
{
@ -5304,10 +5467,11 @@ static void HWR_DrawSkyBackground(player_t *player)
v[0].t = v[1].t -= ((float) angle / angleturn);
}
HWD.pfnSetShader(7); // sky shader
HWD.pfnUnSetShader();
HWD.pfnDrawPolygon(NULL, v, 4, 0);
HWD.pfnSetShader(0);
}
HWD.pfnSetShader(SHADER_DEFAULT);
}
@ -5511,7 +5675,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
// Reset the shader state.
HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_glshaders.value);
HWD.pfnSetShader(0);
HWD.pfnSetShader(SHADER_DEFAULT);
validcount++;
@ -5614,8 +5778,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
if (viewnumber == 0) // Only do it if it's the first screen being rendered
HWD.pfnClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs.
ps_hw_skyboxtime = I_GetTimeMicros();
if (skybox && drawsky) // If there's a skybox and we should be drawing the sky, draw the skybox
HWR_RenderSkyboxView(viewnumber, player); // This is drawn before everything else so it is placed behind
ps_hw_skyboxtime = I_GetTimeMicros() - ps_hw_skyboxtime;
{
// do we really need to save player (is it not the same)?
@ -5724,11 +5890,11 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
// Reset the shader state.
HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_glshaders.value);
HWD.pfnSetShader(0);
HWD.pfnSetShader(SHADER_DEFAULT);
rs_numbspcalls = 0;
rs_numpolyobjects = 0;
rs_bsptime = I_GetTimeMicros();
ps_numbspcalls = 0;
ps_numpolyobjects = 0;
ps_bsptime = I_GetTimeMicros();
validcount++;
@ -5766,7 +5932,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
}
#endif
rs_bsptime = I_GetTimeMicros() - rs_bsptime;
ps_bsptime = I_GetTimeMicros() - ps_bsptime;
if (cv_glbatching.value)
HWR_RenderBatches();
@ -5781,22 +5947,22 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
#endif
// Draw MD2 and sprites
rs_numsprites = gl_visspritecount;
rs_hw_spritesorttime = I_GetTimeMicros();
ps_numsprites = gl_visspritecount;
ps_hw_spritesorttime = I_GetTimeMicros();
HWR_SortVisSprites();
rs_hw_spritesorttime = I_GetTimeMicros() - rs_hw_spritesorttime;
rs_hw_spritedrawtime = I_GetTimeMicros();
ps_hw_spritesorttime = I_GetTimeMicros() - ps_hw_spritesorttime;
ps_hw_spritedrawtime = I_GetTimeMicros();
HWR_DrawSprites();
rs_hw_spritedrawtime = I_GetTimeMicros() - rs_hw_spritedrawtime;
ps_hw_spritedrawtime = I_GetTimeMicros() - ps_hw_spritedrawtime;
#ifdef NEWCORONAS
//Hurdler: they must be drawn before translucent planes, what about gl fog?
HWR_DrawCoronas();
#endif
rs_numdrawnodes = 0;
rs_hw_nodesorttime = 0;
rs_hw_nodedrawtime = 0;
ps_numdrawnodes = 0;
ps_hw_nodesorttime = 0;
ps_hw_nodedrawtime = 0;
if (numplanes || numpolyplanes || numwalls) //Hurdler: render 3D water and transparent walls after everything
{
HWR_CreateDrawNodes();
@ -5834,34 +6000,32 @@ static CV_PossibleValue_t glfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSA
{0, NULL}};
CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}};
consvar_t cv_glshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glshaders = CVAR_INIT ("gr_shaders", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_fovchange = CVAR_INIT ("gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL);
#ifdef ALAM_LIGHTING
consvar_t cv_gldynamiclighting = {"gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glstaticlighting = {"gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glcoronas = {"gr_coronas", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glcoronasize = {"gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_gldynamiclighting = CVAR_INIT ("gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glstaticlighting = CVAR_INIT ("gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glcoronas = CVAR_INIT ("gr_coronas", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glcoronasize = CVAR_INIT ("gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL);
#endif
consvar_t cv_glmodels = {"gr_models", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glmodellighting = {"gr_modellighting", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glmodels = CVAR_INIT ("gr_models", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glmodelinterpolation = CVAR_INIT ("gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL);
consvar_t cv_glmodellighting = CVAR_INIT ("gr_modellighting", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glshearing = {"gr_shearing", "Off", CV_SAVE, grshearing_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glfakecontrast = {"gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glshearing = CVAR_INIT ("gr_shearing", "Off", CV_SAVE, grshearing_cons_t, NULL);
consvar_t cv_glspritebillboarding = CVAR_INIT ("gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glskydome = CVAR_INIT ("gr_skydome", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glfakecontrast = CVAR_INIT ("gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL);
consvar_t cv_glslopecontrast = CVAR_INIT ("gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glfiltermode = {"gr_filtermode", "Nearest", CV_SAVE|CV_CALL, glfiltermode_cons_t,
CV_glfiltermode_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glanisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t,
CV_glanisotropic_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glfiltermode = CVAR_INIT ("gr_filtermode", "Nearest", CV_SAVE|CV_CALL, glfiltermode_cons_t, CV_glfiltermode_OnChange);
consvar_t cv_glanisotropicmode = CVAR_INIT ("gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t, CV_glanisotropic_OnChange);
consvar_t cv_glsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glsolvetjoin = CVAR_INIT ("gr_solvetjoin", "On", 0, CV_OnOff, NULL);
consvar_t cv_glbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_glbatching = CVAR_INIT ("gr_batching", "On", 0, CV_OnOff, NULL);
static void CV_glfiltermode_OnChange(void)
{
@ -5900,7 +6064,6 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_glfiltermode);
CV_RegisterVar(&cv_glsolvetjoin);
CV_RegisterVar(&cv_renderstats);
CV_RegisterVar(&cv_glbatching);
#ifndef NEWCLIP
@ -5929,7 +6092,6 @@ void HWR_Startup(void)
// do this once
if (!startupdone)
{
INT32 i;
CONS_Printf("HWR_Startup()...\n");
HWR_InitPolyPool();
@ -5940,10 +6102,8 @@ void HWR_Startup(void)
HWR_InitLight();
#endif
// read every custom shader
for (i = 0; i < numwadfiles; i++)
HWR_ReadShaders(i, (wadfiles[i]->type == RET_PK3));
if (!HWR_LoadShaders())
HWR_LoadAllCustomShaders();
if (!HWR_CompileShaders())
gl_shadersavailable = false;
}
@ -6035,7 +6195,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend,
pSurf->PolyColor.s.alpha = alpha; // put the alpha back after lighting
shader = 2; // wall shader
shader = SHADER_WALL; // wall shader
if (blend & PF_Environment)
blendmode |= PF_Occlude; // PF_Occlude must be used for solid objects
@ -6043,7 +6203,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend,
if (fogwall)
{
blendmode |= PF_Fog;
shader = 6; // fog shader
shader = SHADER_FOG; // fog shader
}
blendmode |= PF_Modulated; // No PF_Occlude means overlapping (incorrect) transparency
@ -6228,13 +6388,7 @@ void HWR_DrawScreenFinalTexture(int width, int height)
}
// jimita 18032019
typedef struct
{
char type[16];
INT32 id;
} shaderxlat_t;
static inline UINT16 HWR_CheckShader(UINT16 wadnum)
static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum)
{
UINT16 i;
lumpinfo_t *lump_p;
@ -6247,12 +6401,34 @@ static inline UINT16 HWR_CheckShader(UINT16 wadnum)
return INT16_MAX;
}
boolean HWR_LoadShaders(void)
boolean HWR_CompileShaders(void)
{
return HWD.pfnInitCustomShaders();
return HWD.pfnCompileShaders();
}
void HWR_ReadShaders(UINT16 wadnum, boolean PK3)
customshaderxlat_t shaderxlat[] =
{
{"Flat", SHADER_FLOOR},
{"WallTexture", SHADER_WALL},
{"Sprite", SHADER_SPRITE},
{"Model", SHADER_MODEL},
{"ModelLighting", SHADER_MODEL_LIGHTING},
{"WaterRipple", SHADER_WATER},
{"Fog", SHADER_FOG},
{"Sky", SHADER_SKY},
{NULL, 0},
};
void HWR_LoadAllCustomShaders(void)
{
INT32 i;
// read every custom shader
for (i = 0; i < numwadfiles; i++)
HWR_LoadCustomShadersFromFile(i, (wadfiles[i]->type == RET_PK3));
}
void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
{
UINT16 lump;
char *shaderdef, *line;
@ -6263,19 +6439,7 @@ void HWR_ReadShaders(UINT16 wadnum, boolean PK3)
int shadertype = 0;
int i;
#define SHADER_TYPES 7
shaderxlat_t shaderxlat[SHADER_TYPES] =
{
{"Flat", 1},
{"WallTexture", 2},
{"Sprite", 3},
{"Model", 4},
{"WaterRipple", 5},
{"Fog", 6},
{"Sky", 7},
};
lump = HWR_CheckShader(wadnum);
lump = HWR_FindShaderDefs(wadnum);
if (lump == INT16_MAX)
return;
@ -6301,7 +6465,7 @@ void HWR_ReadShaders(UINT16 wadnum, boolean PK3)
value = strtok(NULL, "\r\n ");
if (!value)
{
CONS_Alert(CONS_WARNING, "HWR_ReadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_lump;
}
@ -6320,19 +6484,19 @@ skip_lump:
value = strtok(NULL, "\r\n= ");
if (!value)
{
CONS_Alert(CONS_WARNING, "HWR_ReadShaders: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_field;
}
if (!shadertype)
{
CONS_Alert(CONS_ERROR, "HWR_ReadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
Z_Free(line);
return;
}
for (i = 0; i < SHADER_TYPES; i++)
for (i = 0; shaderxlat[i].type; i++)
{
if (!stricmp(shaderxlat[i].type, stoken))
{
@ -6358,7 +6522,7 @@ skip_lump:
if (shader_lumpnum == INT16_MAX)
{
CONS_Alert(CONS_ERROR, "HWR_ReadShaders: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
Z_Free(shader_lumpname);
continue;
}
@ -6384,4 +6548,22 @@ skip_field:
return;
}
const char *HWR_GetShaderName(INT32 shader)
{
INT32 i;
if (shader)
{
for (i = 0; shaderxlat[i].type; i++)
{
if (shaderxlat[i].id == shader)
return shaderxlat[i].type;
}
return "Unknown";
}
return "Default";
}
#endif // HWRENDER

View file

@ -31,6 +31,8 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height);
void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight);
void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player);
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
void HWR_ClearSkyDome(void);
void HWR_BuildSkyDome(void);
void HWR_DrawViewBorder(INT32 clearlines);
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
void HWR_InitTextureMapping(void);
@ -68,8 +70,13 @@ void HWR_DrawScreenFinalTexture(int width, int height);
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap);
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
void HWR_ReadShaders(UINT16 wadnum, boolean PK3);
boolean HWR_LoadShaders(void);
boolean HWR_CompileShaders(void);
void HWR_LoadAllCustomShaders(void);
void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3);
const char *HWR_GetShaderName(INT32 shader);
extern customshaderxlat_t shaderxlat[];
extern CV_PossibleValue_t granisotropicmode_cons_t[];
@ -106,21 +113,22 @@ extern FTransform atransform;
// Render stats
extern int rs_hw_nodesorttime;
extern int rs_hw_nodedrawtime;
extern int rs_hw_spritesorttime;
extern int rs_hw_spritedrawtime;
extern int ps_hw_skyboxtime;
extern int ps_hw_nodesorttime;
extern int ps_hw_nodedrawtime;
extern int ps_hw_spritesorttime;
extern int ps_hw_spritedrawtime;
// Render stats for batching
extern int rs_hw_numpolys;
extern int rs_hw_numverts;
extern int rs_hw_numcalls;
extern int rs_hw_numshaders;
extern int rs_hw_numtextures;
extern int rs_hw_numpolyflags;
extern int rs_hw_numcolors;
extern int rs_hw_batchsorttime;
extern int rs_hw_batchdrawtime;
extern int ps_hw_numpolys;
extern int ps_hw_numverts;
extern int ps_hw_numcalls;
extern int ps_hw_numshaders;
extern int ps_hw_numtextures;
extern int ps_hw_numpolyflags;
extern int ps_hw_numcolors;
extern int ps_hw_batchsorttime;
extern int ps_hw_batchdrawtime;
extern boolean gl_shadersavailable;

View file

@ -92,7 +92,13 @@ static void md2_freeModel (model_t *model)
static model_t *md2_readModel(const char *filename)
{
//Filename checking fixed ~Monster Iestyn and Golden
return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC);
if (FIL_FileExists(va("%s"PATHSEP"%s", srb2home, filename)))
return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC);
if (FIL_FileExists(va("%s"PATHSEP"%s", srb2path, filename)))
return LoadModel(va("%s"PATHSEP"%s", srb2path, filename), PU_STATIC);
return NULL;
}
static inline void md2_printModelInfo (model_t *model)
@ -160,8 +166,12 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
png_FILE = fopen(pngfilename, "rb");
if (!png_FILE)
{
pngfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2path, filename);
FIL_ForceExtension(pngfilename, ".png");
png_FILE = fopen(pngfilename, "rb");
//CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for loading\n", filename);
return 0;
if (!png_FILE)
return 0;
}
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
@ -288,7 +298,13 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
FIL_ForceExtension(pcxfilename, ".pcx");
file = fopen(pcxfilename, "rb");
if (!file)
return 0;
{
pcxfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2path, filename);
FIL_ForceExtension(pcxfilename, ".pcx");
file = fopen(pcxfilename, "rb");
if (!file)
return 0;
}
if (fread(&header, sizeof (PcxHeader), 1, file) != 1)
{
@ -493,11 +509,15 @@ void HWR_InitModels(void)
if (!f)
{
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
nomd2s = true;
return;
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
if (!f)
{
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
nomd2s = true;
return;
}
}
// length of the player model prefix
prefixlen = strlen(PLAYERMODELPREFIX);
@ -569,9 +589,13 @@ void HWR_AddPlayerModel(int skin) // For skins that were added after startup
if (!f)
{
CONS_Printf("Error while loading models.dat\n");
nomd2s = true;
return;
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
if (!f)
{
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
nomd2s = true;
return;
}
}
// length of the player model prefix
@ -624,9 +648,13 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s
if (!f)
{
CONS_Printf("Error while loading models.dat\n");
nomd2s = true;
return;
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
if (!f)
{
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
nomd2s = true;
return;
}
}
// Check for any models that match the names of sprite names!
@ -1177,6 +1205,7 @@ static UINT8 HWR_GetModelSprite2(md2_t *md2, skin_t *skin, UINT8 spr2, player_t
return spr2;
}
// Adjust texture coords of model to fit into a patch's max_s and max_t
static void adjustTextureCoords(model_t *model, GLPatch_t *gpatch)
{
int i;
@ -1185,24 +1214,35 @@ static void adjustTextureCoords(model_t *model, GLPatch_t *gpatch)
int j;
mesh_t *mesh = &model->meshes[i];
int numVertices;
float *uvPtr = mesh->uvs;
float *uvReadPtr = mesh->originaluvs;
float *uvWritePtr;
// i dont know if this is actually possible, just logical conclusion of structure in CreateModelVBOs
if (!mesh->frames && !mesh->tinyframes) return;
if (!mesh->frames && !mesh->tinyframes) continue;
if (mesh->frames) // again CreateModelVBO and CreateModelVBOTiny iterate like this so I'm gonna do that too
numVertices = mesh->numTriangles * 3;
else
numVertices = mesh->numVertices;
// if originaluvs points to uvs, we need to allocate new memory for adjusted uvs
// the old uvs are kept around for use in possible readjustments
if (mesh->uvs == mesh->originaluvs)
mesh->uvs = Z_Malloc(numVertices * 2 * sizeof(float), PU_STATIC, NULL);
uvWritePtr = mesh->uvs;
// fix uvs (texture coordinates) to take into account that the actual texture
// has empty space added until the next power of two
for (j = 0; j < numVertices; j++)
{
*uvPtr++ *= gpatch->max_s;
*uvPtr++ *= gpatch->max_t;
*uvWritePtr++ = *uvReadPtr++ * gpatch->max_s;
*uvWritePtr++ = *uvReadPtr++ * gpatch->max_t;
}
}
// Save the values we adjusted the uvs for
model->max_s = gpatch->max_s;
model->max_t = gpatch->max_t;
}
//
@ -1226,6 +1266,10 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
if (spr->precip)
return false;
// Lactozilla: Disallow certain models from rendering
if (!HWR_AllowModel(spr->mobj))
return false;
memset(&p, 0x00, sizeof(FTransform));
// MD2 colormap fix
@ -1330,10 +1374,13 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
if (md2->model)
{
md2_printModelInfo(md2->model);
// if model uses sprite patch as texture, then
// If model uses sprite patch as texture, then
// adjust texture coordinates to take power of two textures into account
if (!gpatch || !gpatch->mipmap->format)
adjustTextureCoords(md2->model, spr->gpatch);
// note down the max_s and max_t that end up in the VBO
md2->model->vbo_max_s = md2->model->max_s;
md2->model->vbo_max_t = md2->model->max_t;
HWD.pfnCreateModelVBOs(md2->model);
}
else
@ -1344,10 +1391,6 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
}
}
// Lactozilla: Disallow certain models from rendering
if (!HWR_AllowModel(spr->mobj))
return false;
//HWD.pfnSetBlend(blend); // This seems to actually break translucency?
finalscale = md2->scale;
//Hurdler: arf, I don't like that implementation at all... too much crappy
@ -1391,6 +1434,14 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
{
// Sprite
gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
// Check if sprite dimensions are different from previously used sprite.
// If so, uvs need to be readjusted.
// Comparing floats with the != operator here should be okay because they
// are just copies of glpatches' max_s and max_t values.
// Instead of the != operator, memcmp is used to avoid a compiler warning.
if (memcmp(&(gpatch->max_s), &(md2->model->max_s), sizeof(md2->model->max_s)) != 0 ||
memcmp(&(gpatch->max_t), &(md2->model->max_t), sizeof(md2->model->max_t)) != 0)
adjustTextureCoords(md2->model, gpatch);
HWR_GetMappedPatch(gpatch, spr->colormap);
}
@ -1549,7 +1600,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
p.mirror = atransform.mirror; // from Kart
#endif
HWD.pfnSetShader(4); // model shader
HWD.pfnSetShader(SHADER_MODEL); // model shader
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, hflip, &Surf);
}

View file

@ -221,6 +221,15 @@ model_t *LoadModel(const char *filename, int ztag)
material->shininess = 25.0f;
}
// Set originaluvs to point to uvs
for (i = 0; i < model->numMeshes; i++)
model->meshes[i].originaluvs = model->meshes[i].uvs;
model->max_s = 1.0;
model->max_t = 1.0;
model->vbo_max_s = 1.0;
model->vbo_max_t = 1.0;
return model;
}

View file

@ -59,6 +59,11 @@ typedef struct mesh_s
int numTriangles;
float *uvs;
// if uv adjustment is needed, uvs is changed to point to adjusted ones and
// this one retains the originals
// note: this member has been added with the assumption that models are never freed.
// (UnloadModel is called by nobody at the time of writing.)
float *originaluvs;
float *lightuvs;
int numFrames;
@ -99,6 +104,15 @@ typedef struct model_s
char *framenames;
boolean interpolate[256];
modelspr2frames_t *spr2frames;
// the max_s and max_t values that the uvs are currently adjusted to
// (if a sprite is used as a texture)
float max_s;
float max_t;
// These are the values that the uvs in the VBO have been adjusted to.
// If they are not same as max_s and max_t, then the VBO won't be used.
float vbo_max_s;
float vbo_max_t;
} model_t;
extern int numModels;

View file

@ -91,9 +91,12 @@ static GLuint startScreenWipe = 0;
static GLuint endScreenWipe = 0;
static GLuint finalScreenTexture = 0;
// Lactozilla: Set shader programs and uniforms
// Lactozilla: Shader functions
static void *Shader_Load(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade);
static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade);
static void Shader_CompileError(const char *message, GLuint program, INT32 shadernum);
static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f};
// shortcut for ((float)1/i)
static const GLfloat byte2float[256] = {
@ -576,15 +579,12 @@ static PFNglUniform2fv pglUniform2fv;
static PFNglUniform3fv pglUniform3fv;
static PFNglGetUniformLocation pglGetUniformLocation;
#define MAXSHADERS 16
#define MAXSHADERPROGRAMS 16
// 18032019
static char *gl_customvertexshaders[MAXSHADERS];
static char *gl_customfragmentshaders[MAXSHADERS];
static GLuint gl_currentshaderprogram = 0;
static boolean gl_shaderprogramchanged = true;
static shadersource_t gl_customshaders[HWR_MAXSHADERS];
// 13062019
typedef enum
{
@ -608,17 +608,59 @@ typedef struct gl_shaderprogram_s
boolean custom;
GLint uniforms[gluniform_max+1];
} gl_shaderprogram_t;
static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS];
static gl_shaderprogram_t gl_shaderprograms[HWR_MAXSHADERS];
// Shader info
static INT32 shader_leveltime = 0;
// ========================
// Fragment shader macros
// ========================
// ================
// Vertex shaders
// ================
//
// GLSL Software fragment shader
// Generic vertex shader
//
#define GLSL_DEFAULT_VERTEX_SHADER \
"void main()\n" \
"{\n" \
"gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \
"gl_FrontColor = gl_Color;\n" \
"gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \
"gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \
"}\0"
// replicates the way fixed function lighting is used by the model lighting option,
// stores the lighting result to gl_Color
// (ambient lighting of 0.75 and diffuse lighting from above)
#define GLSL_MODEL_LIGHTING_VERTEX_SHADER \
"void main()\n" \
"{\n" \
"float nDotVP = dot(gl_Normal, vec3(0, 1, 0));\n" \
"float light = 0.75 + max(nDotVP, 0.0);\n" \
"gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \
"gl_FrontColor = vec4(light, light, light, 1.0);\n" \
"gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \
"gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \
"}\0"
// ==================
// Fragment shaders
// ==================
//
// Generic fragment shader
//
#define GLSL_DEFAULT_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"void main(void) {\n" \
"gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \
"}\0"
//
// Software fragment shader
//
#define GLSL_DOOM_COLORMAP \
@ -678,6 +720,29 @@ static INT32 shader_leveltime = 0;
"gl_FragColor = final_color;\n" \
"}\0"
// same as above but multiplies results with the lighting value from the
// accompanying vertex shader (stored in gl_Color)
#define GLSL_SOFTWARE_MODEL_LIGHTING_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"uniform vec4 tint_color;\n" \
"uniform vec4 fade_color;\n" \
"uniform float lighting;\n" \
"uniform float fade_start;\n" \
"uniform float fade_end;\n" \
GLSL_DOOM_COLORMAP \
GLSL_DOOM_LIGHT_EQUATION \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"vec4 base_color = texel * poly_color;\n" \
"vec4 final_color = base_color;\n" \
GLSL_SOFTWARE_TINT_EQUATION \
GLSL_SOFTWARE_FADE_EQUATION \
"final_color *= gl_Color;\n" \
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
"}\0"
//
// Water surface shader
//
@ -737,90 +802,52 @@ static INT32 shader_leveltime = 0;
"}\0"
//
// GLSL generic fragment shader
// Sky fragment shader
// Modulates poly_color with gl_Color
//
#define GLSL_DEFAULT_FRAGMENT_SHADER \
#define GLSL_SKY_FRAGMENT_SHADER \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"void main(void) {\n" \
"gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \
"gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * gl_Color * poly_color;\n" \
"}\0"
static const char *fragment_shaders[] = {
// Default fragment shader
GLSL_DEFAULT_FRAGMENT_SHADER,
// ================
// Shader sources
// ================
// Floor fragment shader
GLSL_SOFTWARE_FRAGMENT_SHADER,
static struct {
const char *vertex;
const char *fragment;
} const gl_shadersources[] = {
// Default shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_DEFAULT_FRAGMENT_SHADER},
// Wall fragment shader
GLSL_SOFTWARE_FRAGMENT_SHADER,
// Floor shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SOFTWARE_FRAGMENT_SHADER},
// Sprite fragment shader
GLSL_SOFTWARE_FRAGMENT_SHADER,
// Wall shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SOFTWARE_FRAGMENT_SHADER},
// Model fragment shader
GLSL_SOFTWARE_FRAGMENT_SHADER,
// Sprite shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SOFTWARE_FRAGMENT_SHADER},
// Water fragment shader
GLSL_WATER_FRAGMENT_SHADER,
// Model shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SOFTWARE_FRAGMENT_SHADER},
// Fog fragment shader
GLSL_FOG_FRAGMENT_SHADER,
// Model shader + diffuse lighting from above
{GLSL_MODEL_LIGHTING_VERTEX_SHADER, GLSL_SOFTWARE_MODEL_LIGHTING_FRAGMENT_SHADER},
// Sky fragment shader
"uniform sampler2D tex;\n"
"void main(void) {\n"
"gl_FragColor = texture2D(tex, gl_TexCoord[0].st);\n"
"}\0",
// Water shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER},
NULL,
};
// Fog shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_FOG_FRAGMENT_SHADER},
// ======================
// Vertex shader macros
// ======================
// Sky shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SKY_FRAGMENT_SHADER},
//
// GLSL generic vertex shader
//
#define GLSL_DEFAULT_VERTEX_SHADER \
"void main()\n" \
"{\n" \
"gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \
"gl_FrontColor = gl_Color;\n" \
"gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \
"gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \
"}\0"
static const char *vertex_shaders[] = {
// Default vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
// Floor vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
// Wall vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
// Sprite vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
// Model vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
// Water vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
// Fog vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
// Sky vertex shader
GLSL_DEFAULT_VERTEX_SHADER,
NULL,
{NULL, NULL},
};
#endif // GL_SHADERS
@ -866,7 +893,7 @@ void SetupGLFunc4(void)
}
// jimita
EXPORT boolean HWRAPI(LoadShaders) (void)
EXPORT boolean HWRAPI(CompileShaders) (void)
{
#ifdef GL_SHADERS
GLuint gl_vertShader, gl_fragShader;
@ -874,25 +901,23 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
if (!pglUseProgram) return false;
gl_customvertexshaders[0] = NULL;
gl_customfragmentshaders[0] = NULL;
gl_customshaders[0].vertex = NULL;
gl_customshaders[0].fragment = NULL;
for (i = 0; vertex_shaders[i] && fragment_shaders[i]; i++)
for (i = 0; gl_shadersources[i].vertex && gl_shadersources[i].fragment; i++)
{
gl_shaderprogram_t *shader;
const GLchar* vert_shader = vertex_shaders[i];
const GLchar* frag_shader = fragment_shaders[i];
boolean custom = ((gl_customvertexshaders[i] || gl_customfragmentshaders[i]) && (i > 0));
const GLchar *vert_shader = gl_shadersources[i].vertex;
const GLchar *frag_shader = gl_shadersources[i].fragment;
boolean custom = ((gl_customshaders[i].vertex || gl_customshaders[i].fragment) && (i > 0));
// 18032019
if (gl_customvertexshaders[i])
vert_shader = gl_customvertexshaders[i];
if (gl_customfragmentshaders[i])
frag_shader = gl_customfragmentshaders[i];
if (gl_customshaders[i].vertex)
vert_shader = gl_customshaders[i].vertex;
if (gl_customshaders[i].fragment)
frag_shader = gl_customshaders[i].fragment;
if (i >= MAXSHADERS)
break;
if (i >= MAXSHADERPROGRAMS)
if (i >= HWR_MAXSHADERS)
break;
shader = &gl_shaderprograms[i];
@ -905,7 +930,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
gl_vertShader = pglCreateShader(GL_VERTEX_SHADER);
if (!gl_vertShader)
{
GL_MSG_Error("LoadShaders: Error creating vertex shader %d\n", i);
GL_MSG_Error("CompileShaders: Error creating vertex shader %s\n", HWR_GetShaderName(i));
continue;
}
@ -916,15 +941,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
pglGetShaderiv(gl_vertShader, GL_COMPILE_STATUS, &result);
if (result == GL_FALSE)
{
GLchar* infoLog;
GLint logLength;
pglGetShaderiv(gl_vertShader, GL_INFO_LOG_LENGTH, &logLength);
infoLog = malloc(logLength);
pglGetShaderInfoLog(gl_vertShader, logLength, NULL, infoLog);
GL_MSG_Error("LoadShaders: Error compiling vertex shader %d\n%s", i, infoLog);
Shader_CompileError("Error compiling vertex shader", gl_vertShader, i);
continue;
}
@ -934,7 +951,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
gl_fragShader = pglCreateShader(GL_FRAGMENT_SHADER);
if (!gl_fragShader)
{
GL_MSG_Error("LoadShaders: Error creating fragment shader %d\n", i);
GL_MSG_Error("CompileShaders: Error creating fragment shader %s\n", HWR_GetShaderName(i));
continue;
}
@ -945,15 +962,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
pglGetShaderiv(gl_fragShader, GL_COMPILE_STATUS, &result);
if (result == GL_FALSE)
{
GLchar* infoLog;
GLint logLength;
pglGetShaderiv(gl_fragShader, GL_INFO_LOG_LENGTH, &logLength);
infoLog = malloc(logLength);
pglGetShaderInfoLog(gl_fragShader, logLength, NULL, infoLog);
GL_MSG_Error("LoadShaders: Error compiling fragment shader %d\n%s", i, infoLog);
Shader_CompileError("Error compiling fragment shader", gl_fragShader, i);
continue;
}
@ -974,7 +983,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
{
shader->program = 0;
shader->custom = false;
GL_MSG_Error("LoadShaders: Error linking shader program %d\n", i);
GL_MSG_Error("CompileShaders: Error linking shader program %s\n", HWR_GetShaderName(i));
continue;
}
@ -994,8 +1003,10 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
#undef GETUNI
}
#endif
return true;
#else
return false;
#endif
}
//
@ -1023,25 +1034,34 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value)
//
// Custom shader loading
//
EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boolean fragment)
EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boolean isfragment)
{
#ifdef GL_SHADERS
if (!pglUseProgram) return;
if (number < 1 || number > MAXSHADERS)
I_Error("LoadCustomShader(): cannot load shader %d (max %d)", number, MAXSHADERS);
shadersource_t *shader;
if (fragment)
{
gl_customfragmentshaders[number] = malloc(size+1);
strncpy(gl_customfragmentshaders[number], shader, size);
gl_customfragmentshaders[number][size] = 0;
if (!pglUseProgram)
return;
if (number < 1 || number > HWR_MAXSHADERS)
I_Error("LoadCustomShader: cannot load shader %d (min 1, max %d)", number, HWR_MAXSHADERS);
else if (code == NULL)
I_Error("LoadCustomShader: empty shader");
shader = &gl_customshaders[number];
#define COPYSHADER(source) { \
if (shader->source) \
free(shader->source); \
shader->source = malloc(size+1); \
strncpy(shader->source, code, size); \
shader->source[size] = 0; \
}
if (isfragment)
COPYSHADER(fragment)
else
{
gl_customvertexshaders[number] = malloc(size+1);
strncpy(gl_customvertexshaders[number], shader, size);
gl_customvertexshaders[number][size] = 0;
}
COPYSHADER(vertex)
#else
(void)number;
(void)shader;
@ -1050,19 +1070,16 @@ EXPORT void HWRAPI(LoadCustomShader) (int number, char *shader, size_t size, boo
#endif
}
EXPORT boolean HWRAPI(InitCustomShaders) (void)
{
#ifdef GL_SHADERS
KillShaders();
return LoadShaders();
#endif
}
EXPORT void HWRAPI(SetShader) (int shader)
{
#ifdef GL_SHADERS
if (gl_allowshaders)
{
// If using model lighting, set the appropriate shader.
// However don't override a custom shader.
if (shader == SHADER_MODEL && model_lighting
&& !(gl_shaderprograms[SHADER_MODEL].custom && !gl_shaderprograms[SHADER_MODEL_LIGHTING].custom))
shader = SHADER_MODEL_LIGHTING;
if ((GLuint)shader != gl_currentshaderprogram)
{
gl_currentshaderprogram = shader;
@ -1087,9 +1104,23 @@ EXPORT void HWRAPI(UnSetShader) (void)
#endif
}
EXPORT void HWRAPI(KillShaders) (void)
EXPORT void HWRAPI(CleanShaders) (void)
{
// unused.........................
INT32 i;
for (i = 1; i < HWR_MAXSHADERS; i++)
{
shadersource_t *shader = &gl_customshaders[i];
if (shader->vertex)
free(shader->vertex);
if (shader->fragment)
free(shader->fragment);
shader->vertex = NULL;
shader->fragment = NULL;
}
}
// -----------------+
@ -1907,6 +1938,14 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF
if (!shader->program)
return;
// Color uniforms can be left NULL and will be set to white (1.0f, 1.0f, 1.0f, 1.0f)
if (poly == NULL)
poly = &shader_defaultcolor;
if (tint == NULL)
tint = &shader_defaultcolor;
if (fade == NULL)
fade = &shader_defaultcolor;
#define UNIFORM_1(uniform, a, function) \
if (uniform != -1) \
function (uniform, a);
@ -1927,12 +1966,14 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF
UNIFORM_4(shader->uniforms[gluniform_poly_color], poly->red, poly->green, poly->blue, poly->alpha, pglUniform4f);
UNIFORM_4(shader->uniforms[gluniform_tint_color], tint->red, tint->green, tint->blue, tint->alpha, pglUniform4f);
UNIFORM_4(shader->uniforms[gluniform_fade_color], fade->red, fade->green, fade->blue, fade->alpha, pglUniform4f);
if (Surface != NULL)
{
UNIFORM_1(shader->uniforms[gluniform_lighting], Surface->LightInfo.light_level, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_fade_start], Surface->LightInfo.fade_start, pglUniform1f);
UNIFORM_1(shader->uniforms[gluniform_fade_end], Surface->LightInfo.fade_end, pglUniform1f);
}
UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f);
#undef UNIFORM_1
@ -1948,6 +1989,25 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF
#endif
}
static void Shader_CompileError(const char *message, GLuint program, INT32 shadernum)
{
GLchar *infoLog = NULL;
GLint logLength;
pglGetShaderiv(program, GL_INFO_LOG_LENGTH, &logLength);
if (logLength)
{
infoLog = malloc(logLength);
pglGetShaderInfoLog(program, logLength, NULL, infoLog);
}
GL_MSG_Error("CompileShaders: %s (%s)\n%s", message, HWR_GetShaderName(shadernum), (infoLog ? infoLog : ""));
if (infoLog)
free(infoLog);
}
// code that is common between DrawPolygon and DrawIndexedTriangles
// the corona thing is there too, i have no idea if that stuff works with DrawIndexedTriangles and batching
static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD PolyFlags)
@ -2087,233 +2147,83 @@ EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutV
// the DrawPolygon variant of this has some code about polyflags and wrapping here but havent noticed any problems from omitting it?
}
typedef struct vbo_vertex_s
{
float x, y, z;
float u, v;
unsigned char r, g, b, a;
} vbo_vertex_t;
typedef struct
{
int mode;
int vertexcount;
int vertexindex;
int use_texture;
} GLSkyLoopDef;
typedef struct
{
unsigned int id;
int rows, columns;
int loopcount;
GLSkyLoopDef *loops;
vbo_vertex_t *data;
} GLSkyVBO;
static const boolean gl_ext_arb_vertex_buffer_object = true;
#define NULL_VBO_VERTEX ((vbo_vertex_t*)NULL)
#define sky_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->x : &vbo->data[0].x)
#define sky_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->u : &vbo->data[0].u)
#define sky_vbo_r (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->r : &vbo->data[0].r)
#define NULL_VBO_VERTEX ((gl_skyvertex_t*)NULL)
#define sky_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->x : &sky->data[0].x)
#define sky_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->u : &sky->data[0].u)
#define sky_vbo_r (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->r : &sky->data[0].r)
// The texture offset to be applied to the texture coordinates in SkyVertex().
static int rows, columns;
static signed char yflip;
static int texw, texh;
static boolean foglayer;
static float delta = 0.0f;
static int gl_sky_detail = 16;
static INT32 lasttex = -1;
#define MAP_COEFF 128.0f
static void SkyVertex(vbo_vertex_t *vbo, int r, int c)
{
const float radians = (float)(M_PIl / 180.0f);
const float scale = 10000.0f;
const float maxSideAngle = 60.0f;
float topAngle = (c / (float)columns * 360.0f);
float sideAngle = (maxSideAngle * (rows - r) / rows);
float height = (float)(sin(sideAngle * radians));
float realRadius = (float)(scale * cos(sideAngle * radians));
float x = (float)(realRadius * cos(topAngle * radians));
float y = (!yflip) ? scale * height : -scale * height;
float z = (float)(realRadius * sin(topAngle * radians));
float timesRepeat = (4 * (256.0f / texw));
if (fpclassify(timesRepeat) == FP_ZERO)
timesRepeat = 1.0f;
if (!foglayer)
{
vbo->r = 255;
vbo->g = 255;
vbo->b = 255;
vbo->a = (r == 0 ? 0 : 255);
// And the texture coordinates.
vbo->u = (-timesRepeat * c / (float)columns);
if (!yflip) // Flipped Y is for the lower hemisphere.
vbo->v = (r / (float)rows) + 0.5f;
else
vbo->v = 1.0f + ((rows - r) / (float)rows) + 0.5f;
}
if (r != 4)
{
y += 300.0f;
}
// And finally the vertex.
vbo->x = x;
vbo->y = y + delta;
vbo->z = z;
}
static GLSkyVBO sky_vbo;
static void gld_BuildSky(int row_count, int col_count)
{
int c, r;
vbo_vertex_t *vertex_p;
int vertex_count = 2 * row_count * (col_count * 2 + 2) + col_count * 2;
GLSkyVBO *vbo = &sky_vbo;
if ((vbo->columns != col_count) || (vbo->rows != row_count))
{
free(vbo->loops);
free(vbo->data);
memset(vbo, 0, sizeof(&vbo));
}
if (!vbo->data)
{
memset(vbo, 0, sizeof(&vbo));
vbo->loops = malloc((row_count * 2 + 2) * sizeof(vbo->loops[0]));
// create vertex array
vbo->data = malloc(vertex_count * sizeof(vbo->data[0]));
}
vbo->columns = col_count;
vbo->rows = row_count;
vertex_p = &vbo->data[0];
vbo->loopcount = 0;
for (yflip = 0; yflip < 2; yflip++)
{
vbo->loops[vbo->loopcount].mode = GL_TRIANGLE_FAN;
vbo->loops[vbo->loopcount].vertexindex = vertex_p - &vbo->data[0];
vbo->loops[vbo->loopcount].vertexcount = col_count;
vbo->loops[vbo->loopcount].use_texture = false;
vbo->loopcount++;
delta = 0.0f;
foglayer = true;
for (c = 0; c < col_count; c++)
{
SkyVertex(vertex_p, 1, c);
vertex_p->r = 255;
vertex_p->g = 255;
vertex_p->b = 255;
vertex_p->a = 255;
vertex_p++;
}
foglayer = false;
delta = (yflip ? 5.0f : -5.0f) / MAP_COEFF;
for (r = 0; r < row_count; r++)
{
vbo->loops[vbo->loopcount].mode = GL_TRIANGLE_STRIP;
vbo->loops[vbo->loopcount].vertexindex = vertex_p - &vbo->data[0];
vbo->loops[vbo->loopcount].vertexcount = 2 * col_count + 2;
vbo->loops[vbo->loopcount].use_texture = true;
vbo->loopcount++;
for (c = 0; c <= col_count; c++)
{
SkyVertex(vertex_p++, r + (yflip ? 1 : 0), (c ? c : 0));
SkyVertex(vertex_p++, r + (yflip ? 0 : 1), (c ? c : 0));
}
}
}
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
static void RenderDome(INT32 skytexture)
EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky)
{
int i, j;
int vbosize;
GLSkyVBO *vbo = &sky_vbo;
rows = 4;
columns = 4 * gl_sky_detail;
vbosize = 2 * rows * (columns * 2 + 2) + columns * 2;
Shader_Load(NULL, NULL, NULL, NULL);
// Build the sky dome! Yes!
if (lasttex != skytexture)
if (sky->rebuild)
{
// delete VBO when already exists
if (gl_ext_arb_vertex_buffer_object)
{
if (vbo->id)
pglDeleteBuffers(1, &vbo->id);
if (sky->vbo)
pglDeleteBuffers(1, &sky->vbo);
}
lasttex = skytexture;
gld_BuildSky(rows, columns);
if (gl_ext_arb_vertex_buffer_object)
{
// generate a new VBO and get the associated ID
pglGenBuffers(1, &vbo->id);
pglGenBuffers(1, &sky->vbo);
// bind VBO in order to use
pglBindBuffer(GL_ARRAY_BUFFER, vbo->id);
pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo);
// upload data to VBO
pglBufferData(GL_ARRAY_BUFFER, vbosize * sizeof(vbo->data[0]), vbo->data, GL_STATIC_DRAW);
pglBufferData(GL_ARRAY_BUFFER, sky->vertex_count * sizeof(sky->data[0]), sky->data, GL_STATIC_DRAW);
}
sky->rebuild = false;
}
// bind VBO in order to use
if (gl_ext_arb_vertex_buffer_object)
pglBindBuffer(GL_ARRAY_BUFFER, vbo->id);
pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo);
// activate and specify pointers to arrays
pglVertexPointer(3, GL_FLOAT, sizeof(vbo->data[0]), sky_vbo_x);
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbo->data[0]), sky_vbo_u);
pglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vbo->data[0]), sky_vbo_r);
pglVertexPointer(3, GL_FLOAT, sizeof(sky->data[0]), sky_vbo_x);
pglTexCoordPointer(2, GL_FLOAT, sizeof(sky->data[0]), sky_vbo_u);
pglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(sky->data[0]), sky_vbo_r);
// activate color arrays
pglEnableClientState(GL_COLOR_ARRAY);
// set transforms
pglScalef(1.0f, (float)texh / 230.0f, 1.0f);
pglScalef(1.0f, (float)sky->height / 200.0f, 1.0f);
pglRotatef(270.0f, 0.0f, 1.0f, 0.0f);
for (j = 0; j < 2; j++)
{
for (i = 0; i < vbo->loopcount; i++)
for (i = 0; i < sky->loopcount; i++)
{
GLSkyLoopDef *loop = &vbo->loops[i];
gl_skyloopdef_t *loop = &sky->loops[i];
unsigned int mode = 0;
if (j == 0 ? loop->use_texture : !loop->use_texture)
continue;
pglDrawArrays(loop->mode, loop->vertexindex, loop->vertexcount);
switch (loop->mode)
{
case HWD_SKYLOOP_FAN:
mode = GL_TRIANGLE_FAN;
break;
case HWD_SKYLOOP_STRIP:
mode = GL_TRIANGLE_STRIP;
break;
default:
continue;
}
pglDrawArrays(mode, loop->vertexindex, loop->vertexcount);
}
}
@ -2328,16 +2238,6 @@ static void RenderDome(INT32 skytexture)
pglDisableClientState(GL_COLOR_ARRAY);
}
EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform)
{
SetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated);
SetTransform(&transform);
texw = texture_width;
texh = texture_height;
RenderDome(tex);
SetBlend(0);
}
// ==========================================================================
//
// ==========================================================================
@ -2626,6 +2526,8 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
boolean useTinyFrames;
boolean useVBO = true;
int i;
// Because otherwise, scaling the screen negatively vertically breaks the lighting
@ -2660,31 +2562,34 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
poly.alpha = byte2float[Surface->PolyColor.s.alpha];
#ifdef GL_LIGHT_MODEL_AMBIENT
if (model_lighting && (!gl_shadersenabled)) // doesn't work with shaders anyway
if (model_lighting)
{
ambient[0] = poly.red;
ambient[1] = poly.green;
ambient[2] = poly.blue;
ambient[3] = poly.alpha;
if (!gl_shadersenabled)
{
ambient[0] = poly.red;
ambient[1] = poly.green;
ambient[2] = poly.blue;
ambient[3] = poly.alpha;
diffuse[0] = poly.red;
diffuse[1] = poly.green;
diffuse[2] = poly.blue;
diffuse[3] = poly.alpha;
diffuse[0] = poly.red;
diffuse[1] = poly.green;
diffuse[2] = poly.blue;
diffuse[3] = poly.alpha;
if (ambient[0] > 0.75f)
ambient[0] = 0.75f;
if (ambient[1] > 0.75f)
ambient[1] = 0.75f;
if (ambient[2] > 0.75f)
ambient[2] = 0.75f;
if (ambient[0] > 0.75f)
ambient[0] = 0.75f;
if (ambient[1] > 0.75f)
ambient[1] = 0.75f;
if (ambient[2] > 0.75f)
ambient[2] = 0.75f;
pglLightfv(GL_LIGHT0, GL_POSITION, LightPos);
pglLightfv(GL_LIGHT0, GL_POSITION, LightPos);
pglEnable(GL_LIGHTING);
pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
}
pglShadeModel(GL_SMOOTH);
pglEnable(GL_LIGHTING);
pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
}
#endif
else
@ -2766,6 +2671,15 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
if (useTinyFrames)
pglScalef(1 / 64.0f, 1 / 64.0f, 1 / 64.0f);
// Don't use the VBO if it does not have the correct texture coordinates.
// (Can happen when model uses a sprite as a texture and the sprite changes)
// Comparing floats with the != operator here should be okay because they
// are just copies of glpatches' max_s and max_t values.
// Instead of the != operator, memcmp is used to avoid a compiler warning.
if (memcmp(&(model->vbo_max_s), &(model->max_s), sizeof(model->max_s)) != 0 ||
memcmp(&(model->vbo_max_t), &(model->max_t), sizeof(model->max_t)) != 0)
useVBO = false;
pglEnableClientState(GL_NORMAL_ARRAY);
for (i = 0; i < model->numMeshes; i++)
@ -2782,13 +2696,23 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
if (!nextframe || fpclassify(pol) == FP_ZERO)
{
pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID);
pglVertexPointer(3, GL_SHORT, sizeof(vbotiny_t), BUFFER_OFFSET(0));
pglNormalPointer(GL_BYTE, sizeof(vbotiny_t), BUFFER_OFFSET(sizeof(short)*3));
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbotiny_t), BUFFER_OFFSET(sizeof(short) * 3 + sizeof(char) * 6));
if (useVBO)
{
pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID);
pglVertexPointer(3, GL_SHORT, sizeof(vbotiny_t), BUFFER_OFFSET(0));
pglNormalPointer(GL_BYTE, sizeof(vbotiny_t), BUFFER_OFFSET(sizeof(short)*3));
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbotiny_t), BUFFER_OFFSET(sizeof(short) * 3 + sizeof(char) * 6));
pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices);
pglBindBuffer(GL_ARRAY_BUFFER, 0);
pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices);
pglBindBuffer(GL_ARRAY_BUFFER, 0);
}
else
{
pglVertexPointer(3, GL_SHORT, 0, frame->vertices);
pglNormalPointer(GL_BYTE, 0, frame->normals);
pglTexCoordPointer(2, GL_FLOAT, 0, mesh->uvs);
pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices);
}
}
else
{
@ -2824,21 +2748,25 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
if (!nextframe || fpclassify(pol) == FP_ZERO)
{
// Zoom! Take advantage of just shoving the entire arrays to the GPU.
/* pglVertexPointer(3, GL_FLOAT, 0, frame->vertices);
pglNormalPointer(GL_FLOAT, 0, frame->normals);
pglTexCoordPointer(2, GL_FLOAT, 0, mesh->uvs);
pglDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);*/
if (useVBO)
{
pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID);
pglVertexPointer(3, GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(0));
pglNormalPointer(GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(sizeof(float) * 3));
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(sizeof(float) * 6));
pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID);
pglVertexPointer(3, GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(0));
pglNormalPointer(GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(sizeof(float) * 3));
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(sizeof(float) * 6));
pglDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);
// No tinyframes, no mesh indices
//pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices);
pglBindBuffer(GL_ARRAY_BUFFER, 0);
pglDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);
// No tinyframes, no mesh indices
//pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices);
pglBindBuffer(GL_ARRAY_BUFFER, 0);
}
else
{
pglVertexPointer(3, GL_FLOAT, 0, frame->vertices);
pglNormalPointer(GL_FLOAT, 0, frame->normals);
pglTexCoordPointer(2, GL_FLOAT, 0, mesh->uvs);
pglDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);
}
}
else
{
@ -2874,9 +2802,10 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
pglDisable(GL_NORMALIZE);
#ifdef GL_LIGHT_MODEL_AMBIENT
if (model_lighting && (!gl_shadersenabled))
if (model_lighting)
{
pglDisable(GL_LIGHTING);
if (!gl_shadersenabled)
pglDisable(GL_LIGHTING);
pglShadeModel(GL_FLAT);
}
#endif

691
src/http-mserv.c Normal file
View file

@ -0,0 +1,691 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2020 by James R.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
// \brief HTTP based master server
/*
Documentation available here.
<http://mb.srb2.org/MS/tools/api/v1/>
*/
#ifdef HAVE_CURL
#include <curl/curl.h>
#endif
#include "doomdef.h"
#include "d_clisrv.h"
#include "command.h"
#include "m_argv.h"
#include "m_menu.h"
#include "mserv.h"
#include "i_tcp.h"/* for current_port */
#include "i_threads.h"
/* reasonable default I guess?? */
#define DEFAULT_BUFFER_SIZE (4096)
/* I just stop myself from making macros anymore. */
#define Blame( ... ) \
CONS_Printf("\x85" __VA_ARGS__)
static void MasterServer_Debug_OnChange (void);
consvar_t cv_masterserver_timeout = CVAR_INIT
(
"masterserver_timeout", "5", CV_SAVE, CV_Unsigned,
NULL
);
consvar_t cv_masterserver_debug = CVAR_INIT
(
"masterserver_debug", "Off", CV_SAVE|CV_CALL, CV_OnOff,
MasterServer_Debug_OnChange
);
consvar_t cv_masterserver_token = CVAR_INIT
(
"masterserver_token", "", CV_SAVE, NULL,
NULL
);
#ifdef MASTERSERVER
static int hms_started;
static char *hms_api;
#ifdef HAVE_THREADS
static I_mutex hms_api_mutex;
#endif
static char *hms_server_token;
struct HMS_buffer
{
CURL *curl;
char *buffer;
int needle;
int end;
};
static void
Contact_error (void)
{
CONS_Alert(CONS_ERROR,
"There was a problem contacting the master server...\n"
);
}
static size_t
HMS_on_read (char *s, size_t _1, size_t n, void *userdata)
{
struct HMS_buffer *buffer;
size_t blocks;
(void)_1;
buffer = userdata;
if (n >= (size_t)( buffer->end - buffer->needle ))
{
/* resize to next multiple of buffer size */
blocks = ( n / DEFAULT_BUFFER_SIZE + 1 );
buffer->end += ( blocks * DEFAULT_BUFFER_SIZE );
buffer->buffer = realloc(buffer->buffer, buffer->end);
}
memcpy(&buffer->buffer[buffer->needle], s, n);
buffer->needle += n;
return n;
}
static struct HMS_buffer *
HMS_connect (const char *format, ...)
{
va_list ap;
CURL *curl;
char *url;
char *quack_token;
size_t seek;
size_t token_length;
struct HMS_buffer *buffer;
if (! hms_started)
{
if (curl_global_init(CURL_GLOBAL_ALL) != 0)
{
Contact_error();
Blame("From curl_global_init.\n");
return NULL;
}
else
{
atexit(curl_global_cleanup);
hms_started = 1;
}
}
curl = curl_easy_init();
if (! curl)
{
Contact_error();
Blame("From curl_easy_init.\n");
return NULL;
}
if (cv_masterserver_token.string[0])
{
quack_token = curl_easy_escape(curl, cv_masterserver_token.string, 0);
token_length = ( sizeof "?token="-1 )+ strlen(quack_token);
}
else
{
quack_token = NULL;
token_length = 0;
}
#ifdef HAVE_THREADS
I_lock_mutex(&hms_api_mutex);
#endif
seek = strlen(hms_api) + 1;/* + '/' */
va_start (ap, format);
url = malloc(seek + vsnprintf(0, 0, format, ap) + token_length + 1);
va_end (ap);
sprintf(url, "%s/", hms_api);
#ifdef HAVE_THREADS
I_unlock_mutex(hms_api_mutex);
#endif
va_start (ap, format);
seek += vsprintf(&url[seek], format, ap);
va_end (ap);
if (quack_token)
sprintf(&url[seek], "?token=%s", quack_token);
CONS_Printf("HMS: connecting '%s'...\n", url);
buffer = malloc(sizeof *buffer);
buffer->curl = curl;
buffer->end = DEFAULT_BUFFER_SIZE;
buffer->buffer = malloc(buffer->end);
buffer->needle = 0;
if (cv_masterserver_debug.value)
{
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_STDERR, logstream);
}
if (M_CheckParm("-bindaddr") && M_IsNextParm())
{
curl_easy_setopt(curl, CURLOPT_INTERFACE, M_GetNextParm());
}
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, cv_masterserver_timeout.value);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
curl_free(quack_token);
free(url);
return buffer;
}
static int
HMS_do (struct HMS_buffer *buffer)
{
CURLcode cc;
long status;
char *p;
cc = curl_easy_perform(buffer->curl);
if (cc != CURLE_OK)
{
Contact_error();
Blame(
"From curl_easy_perform: %s\n",
curl_easy_strerror(cc)
);
return 0;
}
buffer->buffer[buffer->needle] = '\0';
curl_easy_getinfo(buffer->curl, CURLINFO_RESPONSE_CODE, &status);
if (status != 200)
{
p = strchr(buffer->buffer, '\n');
if (p)
*p = '\0';
Contact_error();
Blame(
"Master server error %ld: %s%s\n",
status,
buffer->buffer,
( (p) ? "" : " (malformed)" )
);
return 0;
}
else
return 1;
}
static void
HMS_end (struct HMS_buffer *buffer)
{
curl_easy_cleanup(buffer->curl);
free(buffer->buffer);
free(buffer);
}
int
HMS_fetch_rooms (int joining, int query_id)
{
struct HMS_buffer *hms;
int ok;
int doing_shit;
char *id;
char *title;
char *room_motd;
int id_no;
char *p;
char *end;
int i;
(void)query_id;
hms = HMS_connect("rooms");
if (! hms)
return 0;
if (HMS_do(hms))
{
doing_shit = 1;
p = hms->buffer;
for (i = 0; i < NUM_LIST_ROOMS && ( end = strstr(p, "\n\n\n") );)
{
*end = '\0';
id = strtok(p, "\n");
title = strtok(0, "\n");
room_motd = strtok(0, "");
if (id && title && room_motd)
{
id_no = atoi(id);
/*
Don't show the 'All' room if hosting. And it's a hack like this
because I'm way too lazy to add another feature to the MS.
*/
if (joining || id_no != 0)
{
#ifdef HAVE_THREADS
I_lock_mutex(&ms_QueryId_mutex);
{
if (query_id != ms_QueryId)
doing_shit = 0;
}
I_unlock_mutex(ms_QueryId_mutex);
if (! doing_shit)
break;
#endif
room_list[i].header.buffer[0] = 1;
room_list[i].id = id_no;
strlcpy(room_list[i].name, title, sizeof room_list[i].name);
strlcpy(room_list[i].motd, room_motd, sizeof room_list[i].motd);
i++;
}
p = ( end + 3 );/* skip the three linefeeds */
}
else
break;
}
if (doing_shit)
room_list[i].header.buffer[0] = 0;
ok = 1;
if (doing_shit)
{
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
#endif
{
for (i = 0; room_list[i].header.buffer[0]; i++)
{
if(*room_list[i].name != '\0')
{
MP_RoomMenu[i+1].text = room_list[i].name;
roomIds[i] = room_list[i].id;
MP_RoomMenu[i+1].status = IT_STRING|IT_CALL;
}
}
}
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
}
}
else
ok = 0;
HMS_end(hms);
return ok;
}
int
HMS_register (void)
{
struct HMS_buffer *hms;
int ok;
char post[256];
char *title;
hms = HMS_connect("rooms/%d/register", ms_RoomId);
if (! hms)
return 0;
title = curl_easy_escape(hms->curl, cv_servername.string, 0);
snprintf(post, sizeof post,
"port=%d&"
"title=%s&"
"version=%s",
current_port,
title,
SRB2VERSION
);
curl_free(title);
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
if (ok)
{
hms_server_token = strdup(strtok(hms->buffer, "\n"));
}
HMS_end(hms);
return ok;
}
int
HMS_unlist (void)
{
struct HMS_buffer *hms;
int ok;
hms = HMS_connect("servers/%s/unlist", hms_server_token);
if (! hms)
return 0;
curl_easy_setopt(hms->curl, CURLOPT_CUSTOMREQUEST, "POST");
ok = HMS_do(hms);
HMS_end(hms);
free(hms_server_token);
return ok;
}
int
HMS_update (void)
{
struct HMS_buffer *hms;
int ok;
char post[256];
char *title;
hms = HMS_connect("servers/%s/update", hms_server_token);
if (! hms)
return 0;
title = curl_easy_escape(hms->curl, cv_servername.string, 0);
snprintf(post, sizeof post,
"title=%s",
title
);
curl_free(title);
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
HMS_end(hms);
return ok;
}
void
HMS_list_servers (void)
{
struct HMS_buffer *hms;
char *list;
char *p;
hms = HMS_connect("servers");
if (! hms)
return;
if (HMS_do(hms))
{
list = curl_easy_unescape(hms->curl, hms->buffer, 0, NULL);
p = strtok(list, "\n");
while (p != NULL)
{
CONS_Printf("\x80%s\n", p);
p = strtok(NULL, "\n");
}
curl_free(list);
}
HMS_end(hms);
}
msg_server_t *
HMS_fetch_servers (msg_server_t *list, int room_number, int query_id)
{
struct HMS_buffer *hms;
int doing_shit;
char local_version[9];
char *room;
char *address;
char *port;
char *title;
char *version;
char *end;
char *section_end;
char *p;
int i;
(void)query_id;
if (room_number > 0)
{
hms = HMS_connect("rooms/%d/servers", room_number);
}
else
hms = HMS_connect("servers");
if (! hms)
return NULL;
if (HMS_do(hms))
{
doing_shit = 1;
snprintf(local_version, sizeof local_version,
"%s",
SRB2VERSION
);
p = hms->buffer;
i = 0;
do
{
section_end = strstr(p, "\n\n");
room = strtok(p, "\n");
p = strtok(0, "");
if (! p)
break;
while (i < MAXSERVERLIST && ( end = strchr(p, '\n') ))
{
*end = '\0';
address = strtok(p, " ");
port = strtok(0, " ");
title = strtok(0, " ");
version = strtok(0, "");
if (address && port && title && version)
{
#ifdef HAVE_THREADS
I_lock_mutex(&ms_QueryId_mutex);
{
if (query_id != ms_QueryId)
doing_shit = 0;
}
I_unlock_mutex(ms_QueryId_mutex);
if (! doing_shit)
break;
#endif
if (strcmp(version, local_version) == 0)
{
strlcpy(list[i].ip, address, sizeof list[i].ip);
strlcpy(list[i].port, port, sizeof list[i].port);
strlcpy(list[i].name, title, sizeof list[i].name);
strlcpy(list[i].version, version, sizeof list[i].version);
list[i].room = atoi(room);
list[i].header.buffer[0] = 1;
i++;
}
if (end == section_end)/* end of list for this room */
break;
else
p = ( end + 1 );/* skip server delimiter */
}
else
{
section_end = 0;/* malformed so quit the parsing */
break;
}
}
if (! doing_shit)
break;
p = ( section_end + 2 );
}
while (section_end) ;
if (doing_shit)
list[i].header.buffer[0] = 0;
}
else
list = NULL;
HMS_end(hms);
return list;
}
int
HMS_compare_mod_version (char *buffer, size_t buffer_size)
{
struct HMS_buffer *hms;
int ok;
char *version;
char *version_name;
hms = HMS_connect("versions/%d", MODID);
if (! hms)
return 0;
ok = 0;
if (HMS_do(hms))
{
version = strtok(hms->buffer, " ");
version_name = strtok(0, "\n");
if (version && version_name)
{
if (atoi(version) != MODVERSION)
{
strlcpy(buffer, version_name, buffer_size);
ok = 1;
}
else
ok = -1;
}
}
HMS_end(hms);
return ok;
}
void
HMS_set_api (char *api)
{
#ifdef HAVE_THREADS
I_lock_mutex(&hms_api_mutex);
#endif
{
free(hms_api);
hms_api = api;
}
#ifdef HAVE_THREADS
I_unlock_mutex(hms_api_mutex);
#endif
}
#endif/*MASTERSERVER*/
static void
MasterServer_Debug_OnChange (void)
{
#ifdef MASTERSERVER
/* TODO: change to 'latest-log.txt' for log files revision. */
if (cv_masterserver_debug.value)
CONS_Printf("Master server debug messages will appear in log.txt\n");
#endif
}

View file

@ -330,8 +330,6 @@ void HU_Init(void)
// set shift translation table
shiftxform = english_shiftxform;
HU_LoadGraphics();
}
static inline void HU_Stop(void)
@ -1466,7 +1464,7 @@ static void HU_drawMiniChat(void)
if (cv_chatbacktint.value) // on request of wolfy
V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT);
V_DrawChatCharacter(x + dx + 2, y+dy, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, !cv_allcaps.value, colormap);
V_DrawChatCharacter(x + dx + 2, y+dy, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, true, colormap);
}
dx += charwidth;
@ -1559,7 +1557,7 @@ static void HU_drawChatLog(INT32 offset)
else
{
if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy)))
V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, !cv_allcaps.value, colormap);
V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, true, colormap);
else
j++; // don't forget to increment this or we'll get stuck in the limbo.
}
@ -1659,7 +1657,7 @@ static void HU_DrawChat(void)
++i;
else
{
V_DrawChatCharacter(chatx + c + 2, y, talk[i] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|cflag, !cv_allcaps.value, V_GetStringColormap(talk[i]|cflag));
V_DrawChatCharacter(chatx + c + 2, y, talk[i] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|cflag, true, V_GetStringColormap(talk[i]|cflag));
i++;
}
@ -1677,7 +1675,7 @@ static void HU_DrawChat(void)
typelines = 1;
if ((strlen(w_chat) == 0 || c_input == 0) && hu_tick < 4)
V_DrawChatCharacter(chatx + 2 + c, y+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL);
V_DrawChatCharacter(chatx + 2 + c, y+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, true, NULL);
while (w_chat[i])
{
@ -1687,7 +1685,7 @@ static void HU_DrawChat(void)
INT32 cursorx = (c+charwidth < boxw-charwidth) ? (chatx + 2 + c+charwidth) : (chatx+1); // we may have to go down.
INT32 cursory = (cursorx != chatx+1) ? (y) : (y+charheight);
if (hu_tick < 4)
V_DrawChatCharacter(cursorx, cursory+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL);
V_DrawChatCharacter(cursorx, cursory+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, true, NULL);
if (cursorx == chatx+1 && saylen == i) // a weirdo hack
{
@ -1700,7 +1698,7 @@ static void HU_DrawChat(void)
if (w_chat[i] < HU_FONTSTART)
++i;
else
V_DrawChatCharacter(chatx + c + 2, y, w_chat[i++] | V_SNAPTOBOTTOM|V_SNAPTOLEFT | t, !cv_allcaps.value, NULL);
V_DrawChatCharacter(chatx + c + 2, y, w_chat[i++] | V_SNAPTOBOTTOM|V_SNAPTOLEFT | t, true, NULL);
c += charwidth;
if (c > boxw-(charwidth*2) && !skippedline)
@ -1825,7 +1823,7 @@ static void HU_DrawChat_Old(void)
}
if ((strlen(w_chat) == 0 || c_input == 0) && hu_tick < 4)
V_DrawCharacter(HU_INPUTX+c, y+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value);
V_DrawCharacter(HU_INPUTX+c, y+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, true);
i = 0;
while (w_chat[i])
@ -1835,7 +1833,7 @@ static void HU_DrawChat_Old(void)
{
INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down.
INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight);
V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value);
V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, true);
}
//Hurdler: isn't it better like that?
@ -2038,9 +2036,6 @@ static void HU_DrawDemoInfo(void)
//
void HU_Drawer(void)
{
if (needpatchrecache)
R_ReloadHUDGraphics();
#ifndef NONET
// draw chat string plus cursor
if (chat_on)

View file

@ -9,7 +9,7 @@
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file i_sound.h
/// \brief System interface, sound, music and CD
/// \brief System interface, sound, music
#ifndef __I_SOUND__
#define __I_SOUND__
@ -241,53 +241,4 @@ boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
boolean I_FadeOutStopSong(UINT32 ms);
boolean I_FadeInPlaySong(UINT32 ms, boolean looping);
/// ------------------------
// CD MUSIC I/O
/// ------------------------
/** \brief cd music interface
*/
extern UINT8 cdaudio_started;
/** \brief Startup the CD system
*/
void I_InitCD(void);
/** \brief Stop the CD playback
*/
void I_StopCD(void);
/** \brief Pause the CD playback
*/
void I_PauseCD(void);
/** \brief Resume the CD playback
*/
void I_ResumeCD(void);
/** \brief Shutdown the CD system
*/
void I_ShutdownCD(void);
/** \brief Update the CD info
*/
void I_UpdateCD(void);
/** \brief The I_PlayCD function
\param track CD track number
\param looping if true, loop the track
\return void
*/
void I_PlayCD(UINT8 track, UINT8 looping);
/** \brief The I_SetVolumeCD function
\param volume volume level to set at
\return return 0 on failure
*/
boolean I_SetVolumeCD(INT32 volume);
#endif

39
src/i_threads.h Normal file
View file

@ -0,0 +1,39 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2020 by James R.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file i_threads.h
/// \brief Multithreading abstraction
#ifdef HAVE_THREADS
#ifndef I_THREADS_H
#define I_THREADS_H
typedef void (*I_thread_fn)(void *userdata);
typedef void * I_mutex;
typedef void * I_cond;
void I_start_threads (void);
void I_stop_threads (void);
void I_spawn_thread (const char *name, I_thread_fn, void *userdata);
/* check in your thread whether to return early */
int I_thread_is_stopped (void);
void I_lock_mutex (I_mutex *);
void I_unlock_mutex (I_mutex);
void I_hold_cond (I_cond *, I_mutex);
void I_wake_one_cond (I_cond *);
void I_wake_all_cond (I_cond *);
#endif/*I_THREADS_H*/
#endif/*HAVE_THREADS*/

View file

@ -5139,7 +5139,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
100, // mass
0, // damage
sfx_None, // activesound
MF_NOCLIP|MF_SPECIAL, // flags
MF_SPECIAL, // flags
S_NULL // raisestate
},

View file

@ -32,9 +32,12 @@
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
#include "lua_hook.h" // hook_cmd_running errors
#define NOHUD if (hud_running)\
return luaL_error(L, "HUD rendering code should not call this function!");
return luaL_error(L, "HUD rendering code should not call this function!");\
else if (hook_cmd_running)\
return luaL_error(L, "CMD building code should not call this function!");
boolean luaL_checkboolean(lua_State *L, int narg) {
luaL_checktype(L, narg, LUA_TBOOLEAN);
@ -170,8 +173,13 @@ static const struct {
{META_SEG, "seg_t"},
{META_NODE, "node_t"},
#endif
{META_SLOPE, "slope_t"},
{META_VECTOR2, "vector2_t"},
{META_VECTOR3, "vector3_t"},
{META_MAPHEADER, "mapheader_t"},
{META_POLYOBJ, "polyobj_t"},
{META_CVAR, "consvar_t"},
{META_SECTORLINES, "sector_t.lines"},
@ -910,44 +918,52 @@ static int lib_pMaceRotate(lua_State *L)
static int lib_pRailThinker(lua_State *L)
{
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
NOHUD
INLEVEL
if (!mobj)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_RailThinker(mobj));
P_SetTarget(&tmthing, ptmthing);
return 1;
}
static int lib_pXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_XYMovement(actor);
P_SetTarget(&tmthing, ptmthing);
return 0;
}
static int lib_pRingXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_RingXYMovement(actor);
P_SetTarget(&tmthing, ptmthing);
return 0;
}
static int lib_pSceneryXYMovement(lua_State *L)
{
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *ptmthing = tmthing;
NOHUD
INLEVEL
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_SceneryXYMovement(actor);
P_SetTarget(&tmthing, ptmthing);
return 0;
}
@ -959,6 +975,7 @@ static int lib_pZMovement(lua_State *L)
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_ZMovement(actor));
P_CheckPosition(actor, actor->x, actor->y);
return 1;
}
@ -970,6 +987,7 @@ static int lib_pRingZMovement(lua_State *L)
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_RingZMovement(actor);
P_CheckPosition(actor, actor->x, actor->y);
return 0;
}
@ -981,6 +999,7 @@ static int lib_pSceneryZMovement(lua_State *L)
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_SceneryZMovement(actor));
P_CheckPosition(actor, actor->x, actor->y);
return 1;
}
@ -992,6 +1011,7 @@ static int lib_pPlayerZMovement(lua_State *L)
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
P_PlayerZMovement(actor);
P_CheckPosition(actor, actor->x, actor->y);
return 0;
}
@ -1715,6 +1735,18 @@ static int lib_pFloorzAtPos(lua_State *L)
return 1;
}
static int lib_pCeilingzAtPos(lua_State *L)
{
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
fixed_t z = luaL_checkfixed(L, 3);
fixed_t height = luaL_checkfixed(L, 4);
//HUDSAFE
INLEVEL
lua_pushfixed(L, P_CeilingzAtPos(x, y, z, height));
return 1;
}
static int lib_pDoSpring(lua_State *L)
{
mobj_t *spring = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -2586,30 +2618,56 @@ static int lib_rGetNameByColor(lua_State *L)
// S_SOUND
////////////
static int GetValidSoundOrigin(lua_State *L, void **origin)
{
const char *type;
lua_settop(L, 1);
type = GetUserdataUType(L);
if (fasticmp(type, "mobj_t"))
{
*origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
if (!(*origin))
return LUA_ErrInvalid(L, "mobj_t");
return 1;
}
else if (fasticmp(type, "sector_t"))
{
*origin = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
if (!(*origin))
return LUA_ErrInvalid(L, "sector_t");
*origin = &((sector_t *)(*origin))->soundorg;
return 1;
}
return LUA_ErrInvalid(L, "mobj_t/sector_t");
}
static int lib_sStartSound(lua_State *L)
{
const void *origin = NULL;
void *origin = NULL;
sfxenum_t sound_id = luaL_checkinteger(L, 2);
player_t *player = NULL;
//NOHUD
if (sound_id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1);
if (!lua_isnil(L, 1))
{
origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
if (!origin)
return LUA_ErrInvalid(L, "mobj_t");
}
if (!lua_isnone(L, 3) && lua_isuserdata(L, 3))
{
player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
if (!lua_isnil(L, 1))
if (!GetValidSoundOrigin(L, &origin))
return 0;
if (!player || P_IsLocalPlayer(player))
{
if (hud_running)
origin = NULL; // HUD rendering startsound shouldn't have an origin, just remove it instead of having a retarded error.
if (hud_running || hook_cmd_running)
origin = NULL; // HUD rendering and CMD building startsound shouldn't have an origin, just remove it instead of having a retarded error.
S_StartSound(origin, sound_id);
}
@ -2618,18 +2676,12 @@ static int lib_sStartSound(lua_State *L)
static int lib_sStartSoundAtVolume(lua_State *L)
{
const void *origin = NULL;
void *origin = NULL;
sfxenum_t sound_id = luaL_checkinteger(L, 2);
INT32 volume = (INT32)luaL_checkinteger(L, 3);
player_t *player = NULL;
//NOHUD
if (!lua_isnil(L, 1))
{
origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
if (!origin)
return LUA_ErrInvalid(L, "mobj_t");
}
if (sound_id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1);
if (!lua_isnone(L, 4) && lua_isuserdata(L, 4))
@ -2638,30 +2690,37 @@ static int lib_sStartSoundAtVolume(lua_State *L)
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
if (!lua_isnil(L, 1))
if (!GetValidSoundOrigin(L, &origin))
return LUA_ErrInvalid(L, "mobj_t/sector_t");
if (!player || P_IsLocalPlayer(player))
S_StartSoundAtVolume(origin, sound_id, volume);
S_StartSoundAtVolume(origin, sound_id, volume);
return 0;
}
static int lib_sStopSound(lua_State *L)
{
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
void *origin = NULL;
//NOHUD
if (!origin)
return LUA_ErrInvalid(L, "mobj_t");
if (!GetValidSoundOrigin(L, &origin))
return LUA_ErrInvalid(L, "mobj_t/sector_t");
S_StopSound(origin);
return 0;
}
static int lib_sStopSoundByID(lua_State *L)
{
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
void *origin = NULL;
sfxenum_t sound_id = luaL_checkinteger(L, 2);
//NOHUD
if (!origin)
return LUA_ErrInvalid(L, "mobj_t");
if (sound_id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1);
if (!lua_isnil(L, 1))
if (!GetValidSoundOrigin(L, &origin))
return LUA_ErrInvalid(L, "mobj_t/sector_t");
S_StopSoundByID(origin, sound_id);
return 0;
@ -2887,11 +2946,12 @@ static int lib_sSetMusicPosition(lua_State *L)
static int lib_sOriginPlaying(lua_State *L)
{
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
void *origin = NULL;
//NOHUD
INLEVEL
if (!origin)
return LUA_ErrInvalid(L, "mobj_t");
if (!GetValidSoundOrigin(L, &origin))
return LUA_ErrInvalid(L, "mobj_t/sector_t");
lua_pushboolean(L, S_OriginPlaying(origin));
return 1;
}
@ -2908,14 +2968,15 @@ static int lib_sIdPlaying(lua_State *L)
static int lib_sSoundPlaying(lua_State *L)
{
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
void *origin = NULL;
sfxenum_t id = luaL_checkinteger(L, 2);
//NOHUD
INLEVEL
if (!origin)
return LUA_ErrInvalid(L, "mobj_t");
if (id >= NUMSFX)
return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1);
if (!GetValidSoundOrigin(L, &origin))
return LUA_ErrInvalid(L, "mobj_t/sector_t");
lua_pushboolean(L, S_SoundPlaying(origin, id));
return 1;
}
@ -3560,6 +3621,7 @@ static luaL_Reg lib[] = {
{"P_CheckHoopPosition",lib_pCheckHoopPosition},
{"P_RadiusAttack",lib_pRadiusAttack},
{"P_FloorzAtPos",lib_pFloorzAtPos},
{"P_CeilingzAtPos",lib_pCeilingzAtPos},
{"P_DoSpring",lib_pDoSpring},
// p_inter

View file

@ -1,6 +1,6 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2016 by Iestyn "Monster Iestyn" Jealous.
// Copyright (C) 2016-2020 by Iestyn "Monster Iestyn" Jealous.
// Copyright (C) 2016-2020 by Sonic Team Junior.
//
// This program is free software distributed under the
@ -13,6 +13,7 @@
#include "doomdef.h"
#include "p_local.h"
#include "r_main.h" // validcount
#include "p_polyobj.h"
#include "lua_script.h"
#include "lua_libs.h"
//#include "lua_hud.h" // hud_running errors
@ -20,6 +21,7 @@
static const char *const search_opt[] = {
"objects",
"lines",
"polyobjs",
NULL};
// a quickly-made function pointer typedef used by lib_searchBlockmap...
@ -167,6 +169,55 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
return 0; // Everything was checked.
}
// Helper function for "polyobjs" search
static UINT8 lib_searchBlockmap_PolyObjs(lua_State *L, INT32 x, INT32 y, mobj_t *thing)
{
INT32 offset;
polymaplink_t *plink; // haleyjd 02/22/06
if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight)
return 0;
offset = y*bmapwidth + x;
// haleyjd 02/22/06: consider polyobject lines
plink = polyblocklinks[offset];
while (plink)
{
polyobj_t *po = plink->po;
if (po->validcount != validcount) // if polyobj hasn't been checked
{
po->validcount = validcount;
lua_pushvalue(L, 1);
LUA_PushUserdata(L, thing, META_MOBJ);
LUA_PushUserdata(L, po, META_POLYOBJ);
if (lua_pcall(gL, 2, 1, 0)) {
if (!blockfuncerror || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
blockfuncerror = true;
return 0; // *shrugs*
}
if (!lua_isnil(gL, -1))
{ // if nil, continue
if (lua_toboolean(gL, -1))
return 2; // stop whole search
else
return 1; // stop block search
}
lua_pop(gL, 1);
if (P_MobjWasRemoved(thing))
return 2;
}
plink = (polymaplink_t *)(plink->link.next);
}
return 0; // Everything was checked.
}
// The searchBlockmap function
// arguments: searchBlockmap(searchtype, function, mobj, [x1, x2, y1, y2])
// return value:
@ -195,6 +246,9 @@ static int lib_searchBlockmap(lua_State *L)
case 1: // "lines"
searchFunc = lib_searchBlockmap_Lines;
break;
case 2: // "polyobjs"
searchFunc = lib_searchBlockmap_PolyObjs;
break;
}
// the mobj we are searching around, the "calling" mobj we could say

View file

@ -236,15 +236,14 @@ static int lib_comAddCommand(lua_State *L)
static int lib_comBufAddText(lua_State *L)
{
int n = lua_gettop(L); /* number of arguments */
player_t *plr;
player_t *plr = NULL;
if (n < 2)
return luaL_error(L, "COM_BufAddText requires two arguments: player and text.");
NOHUD
lua_settop(L, 2);
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!plr)
return LUA_ErrInvalid(L, "player_t");
if (plr != &players[consoleplayer])
if (!lua_isnoneornil(L, 1))
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (plr && plr != &players[consoleplayer])
return 0;
COM_BufAddTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE);
return 0;
@ -253,15 +252,14 @@ static int lib_comBufAddText(lua_State *L)
static int lib_comBufInsertText(lua_State *L)
{
int n = lua_gettop(L); /* number of arguments */
player_t *plr;
player_t *plr = NULL;
if (n < 2)
return luaL_error(L, "COM_BufInsertText requires two arguments: player and text.");
NOHUD
lua_settop(L, 2);
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!plr)
return LUA_ErrInvalid(L, "player_t");
if (plr != &players[consoleplayer])
if (!lua_isnoneornil(L, 1))
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (plr && plr != &players[consoleplayer])
return 0;
COM_BufInsertTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE);
return 0;
@ -434,6 +432,46 @@ static int lib_cvFindVar(lua_State *L)
return 1;
}
static int CVarSetFunction
(
lua_State *L,
void (*Set)(consvar_t *, const char *),
void (*SetValue)(consvar_t *, INT32)
){
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR);
switch (lua_type(L, 2))
{
case LUA_TSTRING:
(*Set)(cvar, lua_tostring(L, 2));
break;
case LUA_TNUMBER:
(*SetValue)(cvar, (INT32)lua_tonumber(L, 2));
break;
default:
return luaL_typerror(L, 1, "string or number");
}
return 0;
}
static int lib_cvSet(lua_State *L)
{
return CVarSetFunction(L, CV_Set, CV_SetValue);
}
static int lib_cvStealthSet(lua_State *L)
{
return CVarSetFunction(L, CV_StealthSet, CV_StealthSetValue);
}
static int lib_cvAddValue(lua_State *L)
{
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR);
CV_AddValue(cvar, (INT32)luaL_checknumber(L, 2));
return 0;
}
// CONS_Printf for a single player
// Use 'print' in baselib for a global message.
static int lib_consPrintf(lua_State *L)
@ -474,6 +512,9 @@ static luaL_Reg lib[] = {
{"COM_BufInsertText", lib_comBufInsertText},
{"CV_RegisterVar", lib_cvRegisterVar},
{"CV_FindVar", lib_cvFindVar},
{"CV_Set", lib_cvSet},
{"CV_StealthSet", lib_cvStealthSet},
{"CV_AddValue", lib_cvAddValue},
{"CONS_Printf", lib_consPrintf},
{NULL, NULL}
};

View file

@ -59,11 +59,14 @@ enum hook {
hook_PlayerThink,
hook_ShouldJingleContinue,
hook_GameQuit,
hook_PlayerCmd,
hook_MAX // last hook
};
extern const char *const hookNames[];
extern boolean hook_cmd_running;
void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load)
void LUAh_MapLoad(void); // Hook for map load
void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer
@ -113,4 +116,5 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_
#endif
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing
void LUAh_GameQuit(void); // Hook for game quitting
void LUAh_GameQuit(void); // Hook for game quitting
boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart)

View file

@ -23,6 +23,10 @@
#include "lua_hook.h"
#include "lua_hud.h" // hud_running errors
#include "m_perfstats.h"
#include "d_netcmd.h" // for cv_perfstats
#include "i_system.h" // I_GetTimeMicros
static UINT8 hooksAvailable[(hook_MAX/8)+1];
const char *const hookNames[hook_MAX+1] = {
@ -71,6 +75,7 @@ const char *const hookNames[hook_MAX+1] = {
"PlayerThink",
"ShouldJingleContinue",
"GameQuit",
"PlayerCmd",
NULL
};
@ -259,6 +264,9 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which)
I_Assert(mo->type < NUMMOBJTYPES);
if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type]))
return false;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -268,6 +276,7 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which)
if (hookp->type != which)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, mo, META_MOBJ);
PushHook(gL, hookp);
@ -289,6 +298,7 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which)
if (hookp->type != which)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, mo, META_MOBJ);
PushHook(gL, hookp);
@ -324,6 +334,7 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which)
if (hookp->type != which)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, plr, META_PLAYER);
PushHook(gL, hookp);
@ -455,6 +466,9 @@ void LUAh_PreThinkFrame(void)
void LUAh_ThinkFrame(void)
{
hook_p hookp;
// variables used by perf stats
int hook_index = 0;
int time_taken = 0;
if (!gL || !(hooksAvailable[hook_ThinkFrame/8] & (1<<(hook_ThinkFrame%8))))
return;
@ -465,6 +479,8 @@ void LUAh_ThinkFrame(void)
if (hookp->type != hook_ThinkFrame)
continue;
if (cv_perfstats.value == 3)
time_taken = I_GetTimeMicros();
PushHook(gL, hookp);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
@ -472,6 +488,16 @@ void LUAh_ThinkFrame(void)
lua_pop(gL, 1);
hookp->error = true;
}
if (cv_perfstats.value == 3)
{
lua_Debug ar;
time_taken = I_GetTimeMicros() - time_taken;
// we need the function, let's just retrieve it again
PushHook(gL, hookp);
lua_getinfo(gL, ">S", &ar);
PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src);
hook_index++;
}
}
lua_pop(gL, 1); // Pop error handler
@ -513,6 +539,9 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which)
I_Assert(thing1->type < NUMMOBJTYPES);
if (!(mobjcollidehooks[MT_NULL] || mobjcollidehooks[thing1->type]))
return 0;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -522,6 +551,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which)
if (hookp->type != which)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, thing1, META_MOBJ);
@ -552,6 +582,7 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which)
if (hookp->type != which)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, thing1, META_MOBJ);
@ -590,6 +621,9 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which)
I_Assert(thing->type < NUMMOBJTYPES);
if (!(mobjcollidehooks[MT_NULL] || mobjcollidehooks[thing->type]))
return 0;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -599,6 +633,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which)
if (hookp->type != which)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, thing, META_MOBJ);
@ -629,6 +664,7 @@ UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which)
if (hookp->type != which)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, thing, META_MOBJ);
@ -668,12 +704,16 @@ boolean LUAh_MobjThinker(mobj_t *mo)
I_Assert(mo->type < NUMMOBJTYPES);
if (!(mobjthinkerhooks[MT_NULL] || mobjthinkerhooks[mo->type]))
return false;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
// Look for all generic mobj thinker hooks
for (hookp = mobjthinkerhooks[MT_NULL]; hookp; hookp = hookp->next)
{
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, mo, META_MOBJ);
PushHook(gL, hookp);
@ -692,6 +732,7 @@ boolean LUAh_MobjThinker(mobj_t *mo)
for (hookp = mobjthinkerhooks[mo->type]; hookp; hookp = hookp->next)
{
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, mo, META_MOBJ);
PushHook(gL, hookp);
@ -718,10 +759,13 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher)
hook_p hookp;
boolean hooked = false;
if (!gL || !(hooksAvailable[hook_TouchSpecial/8] & (1<<(hook_TouchSpecial%8))))
return 0;
return false;
I_Assert(special->type < NUMMOBJTYPES);
if (!(mobjhooks[MT_NULL] || mobjhooks[special->type]))
return false;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -731,6 +775,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher)
if (hookp->type != hook_TouchSpecial)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, special, META_MOBJ);
@ -756,6 +801,7 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher)
if (hookp->type != hook_TouchSpecial)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, special, META_MOBJ);
@ -790,6 +836,9 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
I_Assert(target->type < NUMMOBJTYPES);
if (!(mobjhooks[MT_NULL] || mobjhooks[target->type]))
return 0;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -799,6 +848,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
if (hookp->type != hook_ShouldDamage)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, target, META_MOBJ);
@ -834,6 +884,7 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
{
if (hookp->type != hook_ShouldDamage)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, target, META_MOBJ);
@ -875,10 +926,13 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
hook_p hookp;
boolean hooked = false;
if (!gL || !(hooksAvailable[hook_MobjDamage/8] & (1<<(hook_MobjDamage%8))))
return 0;
return false;
I_Assert(target->type < NUMMOBJTYPES);
if (!(mobjhooks[MT_NULL] || mobjhooks[target->type]))
return false;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -888,6 +942,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
if (hookp->type != hook_MobjDamage)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, target, META_MOBJ);
@ -919,6 +974,7 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
if (hookp->type != hook_MobjDamage)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, target, META_MOBJ);
@ -955,10 +1011,13 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8
hook_p hookp;
boolean hooked = false;
if (!gL || !(hooksAvailable[hook_MobjDeath/8] & (1<<(hook_MobjDeath%8))))
return 0;
return false;
I_Assert(target->type < NUMMOBJTYPES);
if (!(mobjhooks[MT_NULL] || mobjhooks[target->type]))
return false;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -968,6 +1027,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8
if (hookp->type != hook_MobjDeath)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, target, META_MOBJ);
@ -997,6 +1057,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8
if (hookp->type != hook_MobjDeath)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, target, META_MOBJ);
@ -1189,6 +1250,7 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
if (strcmp(hookp->s.str, line->stringargs[0]))
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, line, META_LINE);
@ -1354,6 +1416,9 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing)
if (!gL || !(hooksAvailable[hook_MapThingSpawn/8] & (1<<(hook_MapThingSpawn%8))))
return false;
if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type]))
return false;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -1363,6 +1428,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing)
if (hookp->type != hook_MapThingSpawn)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, mo, META_MOBJ);
@ -1388,6 +1454,7 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing)
if (hookp->type != hook_MapThingSpawn)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, mo, META_MOBJ);
@ -1420,6 +1487,9 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj)
if (!gL || !(hooksAvailable[hook_FollowMobj/8] & (1<<(hook_FollowMobj%8))))
return 0;
if (!(mobjhooks[MT_NULL] || mobjhooks[mobj->type]))
return 0;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
@ -1429,6 +1499,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj)
if (hookp->type != hook_FollowMobj)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, player, META_PLAYER);
@ -1454,6 +1525,7 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj)
if (hookp->type != hook_FollowMobj)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, player, META_PLAYER);
@ -1494,6 +1566,7 @@ UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj)
if (hookp->type != hook_PlayerCanDamage)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, player, META_PLAYER);
@ -1793,6 +1866,49 @@ void LUAh_GameQuit(void)
hookp->error = true;
}
}
lua_pop(gL, 1); // Pop error handler
}
// Hook for building player's ticcmd struct (Ported from SRB2Kart)
boolean hook_cmd_running = false;
boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd)
{
hook_p hookp;
boolean hooked = false;
if (!gL || !(hooksAvailable[hook_PlayerCmd/8] & (1<<(hook_PlayerCmd%8))))
return false;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
hook_cmd_running = true;
for (hookp = roothook; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PlayerCmd)
continue;
if (lua_gettop(gL) == 1)
{
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, cmd, META_TICCMD);
}
PushHook(gL, hookp);
lua_pushvalue(gL, -3);
lua_pushvalue(gL, -3);
if (lua_pcall(gL, 2, 1, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
lua_settop(gL, 0);
hook_cmd_running = false;
return hooked;
}

View file

@ -992,6 +992,19 @@ static int libd_getColormap(lua_State *L)
return 1;
}
static int libd_getStringColormap(lua_State *L)
{
INT32 flags = luaL_checkinteger(L, 1);
UINT8* colormap = NULL;
HUDONLY
colormap = V_GetStringColormap(flags & V_CHARCOLORMASK);
if (colormap) {
LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use!
return 1;
}
return 0;
}
static int libd_fadeScreen(lua_State *L)
{
UINT16 color = luaL_checkinteger(L, 1);
@ -1142,6 +1155,7 @@ static luaL_Reg lib_draw[] = {
{"getSpritePatch", libd_getSpritePatch},
{"getSprite2Patch", libd_getSprite2Patch},
{"getColormap", libd_getColormap},
{"getStringColormap", libd_getStringColormap},
// drawing
{"draw", libd_draw},
{"drawScaled", libd_drawScaled},

View file

@ -17,7 +17,7 @@
#include "p_mobj.h"
#include "p_local.h"
#include "z_zone.h"
#include "r_patch.h"
#include "r_picformats.h"
#include "r_things.h"
#include "r_draw.h" // R_GetColorByName
#include "doomstat.h" // luabanks[]
@ -25,6 +25,7 @@
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
#include "lua_hook.h" // hook_cmd_running errors
extern CV_PossibleValue_t Color_cons_t[];
extern UINT8 skincolor_modified[];
@ -165,6 +166,8 @@ static int lib_setSpr2default(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter spr2defaults[] in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter spr2defaults[] in CMD building code!");
// todo: maybe allow setting below first freeslot..? step 1 is toggling this, step 2 is testing to see whether it's net-safe
#ifdef SETALLSPR2DEFAULTS
@ -371,6 +374,8 @@ static int lib_setSpriteInfo(lua_State *L)
return luaL_error(L, "Do not alter spriteinfo_t from within a hook or coroutine!");
if (hud_running)
return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter spriteinfo_t in CMD building code!");
lua_remove(L, 1);
{
@ -455,6 +460,8 @@ static int spriteinfo_set(lua_State *L)
return luaL_error(L, "Do not alter spriteinfo_t from within a hook or coroutine!");
if (hud_running)
return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter spriteinfo_t in CMD building code!");
I_Assert(sprinfo != NULL);
@ -533,6 +540,8 @@ static int pivotlist_set(lua_State *L)
return luaL_error(L, "Do not alter spriteframepivot_t from within a hook or coroutine!");
if (hud_running)
return luaL_error(L, "Do not alter spriteframepivot_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter spriteframepivot_t in CMD building code!");
I_Assert(pivotlist != NULL);
@ -587,6 +596,8 @@ static int framepivot_set(lua_State *L)
return luaL_error(L, "Do not alter spriteframepivot_t from within a hook or coroutine!");
if (hud_running)
return luaL_error(L, "Do not alter spriteframepivot_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter spriteframepivot_t in CMD building code!");
I_Assert(framepivot != NULL);
@ -686,6 +697,8 @@ static int lib_setState(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter states in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter states in CMD building code!");
// clear the state to start with, in case of missing table elements
memset(state,0,sizeof(state_t));
@ -906,6 +919,8 @@ static int state_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter states in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter states in CMD building code!");
if (fastcmp(field,"sprite")) {
value = luaL_checknumber(L, 3);
@ -1006,6 +1021,8 @@ static int lib_setMobjInfo(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter mobjinfo in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter mobjinfo in CMD building code!");
// clear the mobjinfo to start with, in case of missing table elements
memset(info,0,sizeof(mobjinfo_t));
@ -1173,6 +1190,8 @@ static int mobjinfo_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter mobjinfo in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter mobjinfo in CMD building code!");
I_Assert(info != NULL);
I_Assert(info >= mobjinfo);
@ -1295,6 +1314,8 @@ static int lib_setSfxInfo(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter sfxinfo in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter sfxinfo in CMD building code!");
lua_pushnil(L);
while (lua_next(L, 1)) {
@ -1376,6 +1397,8 @@ static int sfxinfo_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter S_sfx in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter S_sfx in CMD building code!");
I_Assert(sfx != NULL);
@ -1443,6 +1466,8 @@ static int lib_setluabanks(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter luabanks[] in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter luabanks[] in CMD building code!");
lua_remove(L, 1); // don't care about luabanks[] dummy userdata.
@ -1523,6 +1548,8 @@ static int lib_setSkinColor(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter skincolors in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter skincolors in CMD building code!");
// clear the skincolor to start with, in case of missing table elements
memset(info,0,sizeof(skincolor_t));
@ -1542,8 +1569,10 @@ static int lib_setSkinColor(lua_State *L)
strlcpy(info->name, n, MAXCOLORNAME+1);
if (strlen(n) > MAXCOLORNAME)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; clipped to %s.\n", n, MAXCOLORNAME, info->name);
#if 0
if (strchr(info->name, ' ') != NULL)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name);
#endif
if (info->name[0] != '\0') // don't check empty string for dupe
{
@ -1633,8 +1662,10 @@ static int skincolor_set(lua_State *L)
strlcpy(info->name, n, MAXCOLORNAME+1);
if (strlen(n) > MAXCOLORNAME)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; clipped to %s.\n", n, MAXCOLORNAME, info->name);
#if 0
if (strchr(info->name, ' ') != NULL)
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name);
#endif
if (info->name[0] != '\0') // don't check empty string for dupe
{
@ -1707,6 +1738,8 @@ static int colorramp_set(lua_State *L)
return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' index %d out of range (0 - %d)", n, COLORRAMPSIZE-1);
if (hud_running)
return luaL_error(L, "Do not alter skincolor_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter skincolor_t in CMD building code!");
colorramp[n] = i;
skincolor_modified[cnum] = true;
return 0;

View file

@ -50,6 +50,8 @@ extern lua_State *gL;
#define META_VECTOR3 "VECTOR3_T"
#define META_MAPHEADER "MAPHEADER_T*"
#define META_POLYOBJ "POLYOBJ_T*"
#define META_CVAR "CONSVAR_T*"
#define META_SECTORLINES "SECTOR_T*LINES"
@ -58,6 +60,8 @@ extern lua_State *gL;
#define META_LINESTRINGARGS "LINE_T*STRINGARGS"
#define META_THINGARGS "MAPTHING_T*ARGS"
#define META_THINGSTRINGARGS "MAPTHING_T*STRINGARGS"
#define META_POLYOBJVERTICES "POLYOBJ_T*VERTICES"
#define META_POLYOBJLINES "POLYOBJ_T*LINES"
#ifdef HAVE_LUA_SEGS
#define META_NODEBBOX "NODE_T*BBOX"
#define META_NODECHILDREN "NODE_T*CHILDREN"
@ -88,5 +92,6 @@ int LUA_PlayerLib(lua_State *L);
int LUA_SkinLib(lua_State *L);
int LUA_ThinkerLib(lua_State *L);
int LUA_MapLib(lua_State *L);
int LUA_PolyObjLib(lua_State *L);
int LUA_BlockmapLib(lua_State *L);
int LUA_HudLib(lua_State *L);

View file

@ -16,11 +16,13 @@
#include "p_setup.h"
#include "z_zone.h"
#include "p_slopes.h"
#include "p_polyobj.h"
#include "r_main.h"
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
#include "lua_hook.h" // hook_cmd_running errors
#include "dehacked.h"
#include "fastcmp.h"
@ -67,6 +69,7 @@ enum subsector_e {
subsector_sector,
subsector_numlines,
subsector_firstline,
subsector_polyList
};
static const char *const subsector_opt[] = {
@ -74,6 +77,7 @@ static const char *const subsector_opt[] = {
"sector",
"numlines",
"firstline",
"polyList",
NULL};
enum line_e {
@ -97,6 +101,7 @@ enum line_e {
line_backsector,
line_firsttag,
line_nexttag,
line_polyobj,
line_text,
line_callcount
};
@ -122,6 +127,7 @@ static const char *const line_opt[] = {
"backsector",
"firsttag",
"nexttag",
"polyobj",
"text",
"callcount",
NULL};
@ -234,6 +240,7 @@ enum seg_e {
seg_linedef,
seg_frontsector,
seg_backsector,
seg_polyseg
};
static const char *const seg_opt[] = {
@ -247,6 +254,7 @@ static const char *const seg_opt[] = {
"linedef",
"frontsector",
"backsector",
"polyseg",
NULL};
enum node_e {
@ -336,9 +344,9 @@ static const char *const vector_opt[] = {
static const char *const array_opt[] ={"iterate",NULL};
static const char *const valid_opt[] ={"valid",NULL};
///////////////////////////////////
// sector list iterate functions //
///////////////////////////////////
/////////////////////////////////////////////
// sector/subsector list iterate functions //
/////////////////////////////////////////////
// iterates through a sector's thinglist!
static int lib_iterateSectorThinglist(lua_State *L)
@ -410,6 +418,41 @@ static int lib_iterateSectorFFloors(lua_State *L)
return 0;
}
// iterates through a subsector's polyList! (for polyobj_t)
static int lib_iterateSubSectorPolylist(lua_State *L)
{
polyobj_t *state = NULL;
polyobj_t *po = NULL;
INLEVEL
if (lua_gettop(L) < 2)
return luaL_error(L, "Don't call subsector.polyList() directly, use it as 'for polyobj in subsector.polyList do <block> end'.");
if (!lua_isnil(L, 1))
state = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
else
return 0; // no polylist to iterate through sorry!
lua_settop(L, 2);
lua_remove(L, 1); // remove state now.
if (!lua_isnil(L, 1))
{
po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
po = (polyobj_t *)(po->link.next);
}
else
po = state; // state is used as the "start" of the polylist
if (po)
{
LUA_PushUserdata(L, po, META_POLYOBJ);
return 1;
}
return 0;
}
static int sector_iterate(lua_State *L)
{
lua_pushvalue(L, lua_upvalueindex(1)); // iterator function, or the "generator"
@ -458,7 +501,7 @@ static int sectorlines_get(lua_State *L)
// get the "linecount" by shifting our retrieved memory address of "lines" to where "linecount" is in the sector_t, then dereferencing the result
// we need this to determine the array's actual size, and therefore also the maximum value allowed as an index
// this only works if seclines is actually a pointer to a sector's lines member in memory, oh boy
numoflines = (size_t)(*(size_t *)(((size_t)seclines) - (offsetof(sector_t, lines) - offsetof(sector_t, linecount))));
numoflines = *(size_t *)FIELDFROM (sector_t, seclines, lines,/* -> */linecount);
/* OLD HACK
// check first linedef to figure which of its sectors owns this sector->lines pointer
@ -492,7 +535,7 @@ static int sectorlines_num(lua_State *L)
return luaL_error(L, "accessed sector_t.lines doesn't exist anymore.");
// see comments in the _get function above
numoflines = (size_t)(*(size_t *)(((size_t)seclines) - (offsetof(sector_t, lines) - offsetof(sector_t, linecount))));
numoflines = *(size_t *)FIELDFROM (sector_t, seclines, lines,/* -> */linecount);
lua_pushinteger(L, numoflines);
return 1;
}
@ -597,6 +640,8 @@ static int sector_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter sector_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter sector_t in CMD building code!");
switch(field)
{
@ -696,6 +741,11 @@ static int subsector_get(lua_State *L)
case subsector_firstline:
lua_pushinteger(L, subsector->firstline);
return 1;
case subsector_polyList: // polyList
lua_pushcfunction(L, lib_iterateSubSectorPolylist);
LUA_PushUserdata(L, subsector->polyList, META_POLYOBJ);
lua_pushcclosure(L, sector_iterate, 2); // push lib_iterateSubSectorPolylist and subsector->polyList as upvalues for the function
return 1;
}
return 0;
}
@ -839,6 +889,9 @@ static int line_get(lua_State *L)
case line_nexttag:
lua_pushinteger(L, line->nexttag);
return 1;
case line_polyobj:
LUA_PushUserdata(L, line->polyobj, META_POLYOBJ);
return 1;
case line_text:
lua_pushstring(L, line->text);
return 1;
@ -1101,6 +1154,9 @@ static int seg_get(lua_State *L)
case seg_backsector:
LUA_PushUserdata(L, seg->backsector, META_SECTOR);
return 1;
case seg_polyseg:
LUA_PushUserdata(L, seg->polyseg, META_POLYOBJ);
return 1;
}
return 0;
}
@ -1802,6 +1858,8 @@ static int ffloor_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter ffloor_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter ffloor_t in CMD building code!");
switch(field)
{
@ -1926,6 +1984,8 @@ static int slope_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter pslope_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter pslope_t in CMD building code!");
switch(field) // todo: reorganize this shit
{

View file

@ -20,6 +20,7 @@
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
#include "lua_hook.h" // hook_cmd_running errors
static const char *const array_opt[] ={"iterate",NULL};
@ -437,6 +438,8 @@ static int mobj_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter mobj_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter mobj_t in CMD building code!");
switch(field)
{
@ -878,6 +881,8 @@ static int mapthing_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter mapthing_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter mapthing_t in CMD building code!");
if(fastcmp(field,"x"))
mt->x = (INT16)luaL_checkinteger(L, 3);

View file

@ -20,6 +20,7 @@
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
#include "lua_hook.h" // hook_cmd_running errors
static int lib_iteratePlayers(lua_State *L)
{
@ -400,6 +401,8 @@ static int player_set(lua_State *L)
if (hud_running)
return luaL_error(L, "Do not alter player_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter player_t in CMD building code!");
if (fastcmp(field,"mo") || fastcmp(field,"realmo")) {
mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
@ -770,6 +773,8 @@ static int power_set(lua_State *L)
return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", (INT16)p);
if (hud_running)
return luaL_error(L, "Do not alter player_t in HUD rendering code!");
if (hook_cmd_running)
return luaL_error(L, "Do not alter player_t in CMD building code!");
powers[p] = i;
return 0;
}

486
src/lua_polyobjlib.c Normal file
View file

@ -0,0 +1,486 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2020 by Iestyn "Monster Iestyn" Jealous.
// Copyright (C) 2020 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file lua_polyobjlib.c
/// \brief polyobject library for Lua scripting
#include "doomdef.h"
#include "fastcmp.h"
#include "p_local.h"
#include "p_polyobj.h"
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
#define NOHUD if (hud_running)\
return luaL_error(L, "HUD rendering code should not call this function!");
enum polyobj_e {
// properties
polyobj_valid = 0,
polyobj_id,
polyobj_parent,
polyobj_vertices,
polyobj_lines,
polyobj_sector,
polyobj_angle,
polyobj_damage,
polyobj_thrust,
polyobj_flags,
polyobj_translucency,
polyobj_triggertag,
// special functions - utility
polyobj_pointInside,
polyobj_mobjTouching,
polyobj_mobjInside,
// special functions - manipulation
polyobj_moveXY,
polyobj_rotate
};
static const char *const polyobj_opt[] = {
// properties
"valid",
"id",
"parent",
"vertices",
"lines",
"sector",
"angle",
"damage",
"thrust",
"flags",
"translucency",
"triggertag",
// special functions - utility
"pointInside",
"mobjTouching",
"mobjInside",
// special functions - manipulation
"moveXY",
"rotate",
NULL};
static const char *const valid_opt[] ={"valid",NULL};
////////////////////////
// polyobj.vertices[] //
////////////////////////
// polyobj.vertices, i -> polyobj.vertices[i]
// polyobj.vertices.valid, for validity checking
//
// see sectorlines_get in lua_maplib.c
//
static int polyobjvertices_get(lua_State *L)
{
vertex_t ***polyverts = *((vertex_t ****)luaL_checkudata(L, 1, META_POLYOBJVERTICES));
size_t i;
size_t numofverts = 0;
lua_settop(L, 2);
if (!lua_isnumber(L, 2))
{
int field = luaL_checkoption(L, 2, NULL, valid_opt);
if (!polyverts || !(*polyverts))
{
if (field == 0) {
lua_pushboolean(L, 0);
return 1;
}
return luaL_error(L, "accessed polyobj_t.vertices doesn't exist anymore.");
} else if (field == 0) {
lua_pushboolean(L, 1);
return 1;
}
}
numofverts = *(size_t *)FIELDFROM (polyobj_t, polyverts, vertices,/* -> */numVertices);
if (!numofverts)
return luaL_error(L, "no vertices found!");
i = (size_t)lua_tointeger(L, 2);
if (i >= numofverts)
return 0;
LUA_PushUserdata(L, (*polyverts)[i], META_VERTEX);
return 1;
}
// #(polyobj.vertices) -> polyobj.numVertices
static int polyobjvertices_num(lua_State *L)
{
vertex_t ***polyverts = *((vertex_t ****)luaL_checkudata(L, 1, META_POLYOBJVERTICES));
size_t numofverts = 0;
if (!polyverts || !(*polyverts))
return luaL_error(L, "accessed polyobj_t.vertices doesn't exist anymore.");
numofverts = *(size_t *)FIELDFROM (polyobj_t, polyverts, vertices,/* -> */numVertices);
lua_pushinteger(L, numofverts);
return 1;
}
/////////////////////
// polyobj.lines[] //
/////////////////////
// polyobj.lines, i -> polyobj.lines[i]
// polyobj.lines.valid, for validity checking
//
// see sectorlines_get in lua_maplib.c
//
static int polyobjlines_get(lua_State *L)
{
line_t ***polylines = *((line_t ****)luaL_checkudata(L, 1, META_POLYOBJLINES));
size_t i;
size_t numoflines = 0;
lua_settop(L, 2);
if (!lua_isnumber(L, 2))
{
int field = luaL_checkoption(L, 2, NULL, valid_opt);
if (!polylines || !(*polylines))
{
if (field == 0) {
lua_pushboolean(L, 0);
return 1;
}
return luaL_error(L, "accessed polyobj_t.lines doesn't exist anymore.");
} else if (field == 0) {
lua_pushboolean(L, 1);
return 1;
}
}
numoflines = *(size_t *)FIELDFROM (polyobj_t, polylines, lines,/* -> */numLines);
if (!numoflines)
return luaL_error(L, "no lines found!");
i = (size_t)lua_tointeger(L, 2);
if (i >= numoflines)
return 0;
LUA_PushUserdata(L, (*polylines)[i], META_LINE);
return 1;
}
// #(polyobj.lines) -> polyobj.numLines
static int polyobjlines_num(lua_State *L)
{
line_t ***polylines = *((line_t ****)luaL_checkudata(L, 1, META_POLYOBJLINES));
size_t numoflines = 0;
if (!polylines || !(*polylines))
return luaL_error(L, "accessed polyobj_t.lines doesn't exist anymore.");
numoflines = *(size_t *)FIELDFROM (polyobj_t, polylines, lines,/* -> */numLines);
lua_pushinteger(L, numoflines);
return 1;
}
/////////////////////////////////
// polyobj_t function wrappers //
/////////////////////////////////
// special functions - utility
static int lib_polyobj_PointInside(lua_State *L)
{
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
INLEVEL
if (!po)
return LUA_ErrInvalid(L, "polyobj_t");
lua_pushboolean(L, P_PointInsidePolyobj(po, x, y));
return 1;
}
static int lib_polyobj_MobjTouching(lua_State *L)
{
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
INLEVEL
if (!po)
return LUA_ErrInvalid(L, "polyobj_t");
if (!mo)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_MobjTouchingPolyobj(po, mo));
return 1;
}
static int lib_polyobj_MobjInside(lua_State *L)
{
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
INLEVEL
if (!po)
return LUA_ErrInvalid(L, "polyobj_t");
if (!mo)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_MobjInsidePolyobj(po, mo));
return 1;
}
// special functions - manipulation
static int lib_polyobj_moveXY(lua_State *L)
{
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
boolean checkmobjs = lua_opttrueboolean(L, 4);
NOHUD
INLEVEL
if (!po)
return LUA_ErrInvalid(L, "polyobj_t");
lua_pushboolean(L, Polyobj_moveXY(po, x, y, checkmobjs));
return 1;
}
static int lib_polyobj_rotate(lua_State *L)
{
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
angle_t delta = luaL_checkangle(L, 2);
UINT8 turnthings = (UINT8)luaL_optinteger(L, 3, 0); // don't turn anything by default? (could change this if not desired)
boolean checkmobjs = lua_opttrueboolean(L, 4);
NOHUD
INLEVEL
if (!po)
return LUA_ErrInvalid(L, "polyobj_t");
lua_pushboolean(L, Polyobj_rotate(po, delta, turnthings, checkmobjs));
return 1;
}
///////////////
// polyobj_t //
///////////////
static int polyobj_get(lua_State *L)
{
polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
enum polyobj_e field = luaL_checkoption(L, 2, NULL, polyobj_opt);
if (!polyobj) {
if (field == polyobj_valid) {
lua_pushboolean(L, false);
return 1;
}
return LUA_ErrInvalid(L, "polyobj_t");
}
switch (field)
{
// properties
case polyobj_valid:
lua_pushboolean(L, true);
break;
case polyobj_id:
lua_pushinteger(L, polyobj->id);
break;
case polyobj_parent:
lua_pushinteger(L, polyobj->parent);
break;
case polyobj_vertices: // vertices
LUA_PushUserdata(L, &polyobj->vertices, META_POLYOBJVERTICES); // push the address of the "vertices" member in the struct, to allow our hacks to work
break;
case polyobj_lines: // lines
LUA_PushUserdata(L, &polyobj->lines, META_POLYOBJLINES); // push the address of the "lines" member in the struct, to allow our hacks to work
break;
case polyobj_sector: // shortcut that exists only in Lua!
LUA_PushUserdata(L, polyobj->lines[0]->backsector, META_SECTOR);
break;
case polyobj_angle:
lua_pushangle(L, polyobj->angle);
break;
case polyobj_damage:
lua_pushinteger(L, polyobj->damage);
break;
case polyobj_thrust:
lua_pushfixed(L, polyobj->thrust);
break;
case polyobj_flags:
lua_pushinteger(L, polyobj->flags);
break;
case polyobj_translucency:
lua_pushinteger(L, polyobj->translucency);
break;
case polyobj_triggertag:
lua_pushinteger(L, polyobj->triggertag);
break;
// special functions - utility
case polyobj_pointInside:
lua_pushcfunction(L, lib_polyobj_PointInside);
break;
case polyobj_mobjTouching:
lua_pushcfunction(L, lib_polyobj_MobjTouching);
break;
case polyobj_mobjInside:
lua_pushcfunction(L, lib_polyobj_MobjInside);
break;
// special functions - manipulation
case polyobj_moveXY:
lua_pushcfunction(L, lib_polyobj_moveXY);
break;
case polyobj_rotate:
lua_pushcfunction(L, lib_polyobj_rotate);
break;
}
return 1;
}
static int polyobj_set(lua_State *L)
{
polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
enum polyobj_e field = luaL_checkoption(L, 2, NULL, polyobj_opt);
if (!polyobj)
return LUA_ErrInvalid(L, "polyobj_t");
if (hud_running)
return luaL_error(L, "Do not alter polyobj_t in HUD rendering code!");
switch (field)
{
default:
return luaL_error(L, LUA_QL("polyobj_t") " field " LUA_QS " cannot be modified.", polyobj_opt[field]);
case polyobj_angle:
return luaL_error(L, LUA_QL("polyobj_t") " field " LUA_QS " should not be set directly. Use the function " LUA_QL("polyobj:rotate(angle)") " instead.", polyobj_opt[field]);
case polyobj_parent:
polyobj->parent = luaL_checkinteger(L, 3);
break;
case polyobj_flags:
polyobj->flags = luaL_checkinteger(L, 3);
break;
case polyobj_translucency:
polyobj->translucency = luaL_checkinteger(L, 3);
break;
}
return 0;
}
static int polyobj_num(lua_State *L)
{
polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
if (!polyobj)
return luaL_error(L, "accessed polyobj_t doesn't exist anymore.");
lua_pushinteger(L, polyobj-PolyObjects);
return 1;
}
///////////////////
// PolyObjects[] //
///////////////////
static int lib_iteratePolyObjects(lua_State *L)
{
INT32 i = -1;
if (lua_gettop(L) < 2)
{
//return luaL_error(L, "Don't call PolyObjects.iterate() directly, use it as 'for polyobj in PolyObjects.iterate do <block> end'.");
lua_pushcfunction(L, lib_iteratePolyObjects);
return 1;
}
lua_settop(L, 2);
lua_remove(L, 1); // state is unused.
if (!lua_isnil(L, 1))
i = (INT32)(*((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ)) - PolyObjects);
for (i++; i < numPolyObjects; i++)
{
LUA_PushUserdata(L, &PolyObjects[i], META_POLYOBJ);
return 1;
}
return 0;
}
static int lib_PolyObject_getfornum(lua_State *L)
{
INT32 id = (INT32)luaL_checkinteger(L, 1);
if (!numPolyObjects)
return 0; // if there's no PolyObjects then bail out here
LUA_PushUserdata(L, Polyobj_GetForNum(id), META_POLYOBJ);
return 1;
}
static int lib_getPolyObject(lua_State *L)
{
const char *field;
INT32 i;
// find PolyObject by number
if (lua_type(L, 2) == LUA_TNUMBER)
{
i = luaL_checkinteger(L, 2);
if (i < 0 || i >= numPolyObjects)
return luaL_error(L, "PolyObjects[] index %d out of range (0 - %d)", i, numPolyObjects-1);
LUA_PushUserdata(L, &PolyObjects[i], META_POLYOBJ);
return 1;
}
field = luaL_checkstring(L, 2);
// special function iterate
if (fastcmp(field,"iterate"))
{
lua_pushcfunction(L, lib_iteratePolyObjects);
return 1;
}
// find PolyObject by ID
else if (fastcmp(field,"GetForNum")) // name could probably be better
{
lua_pushcfunction(L, lib_PolyObject_getfornum);
return 1;
}
return 0;
}
static int lib_numPolyObjects(lua_State *L)
{
lua_pushinteger(L, numPolyObjects);
return 1;
}
int LUA_PolyObjLib(lua_State *L)
{
luaL_newmetatable(L, META_POLYOBJVERTICES);
lua_pushcfunction(L, polyobjvertices_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, polyobjvertices_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_POLYOBJLINES);
lua_pushcfunction(L, polyobjlines_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, polyobjlines_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_POLYOBJ);
lua_pushcfunction(L, polyobj_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, polyobj_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, polyobj_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1);
lua_newuserdata(L, 0);
lua_createtable(L, 0, 2);
lua_pushcfunction(L, lib_getPolyObject);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, lib_numPolyObjects);
lua_setfield(L, -2, "__len");
lua_setmetatable(L, -2);
lua_setglobal(L, "PolyObjects");
return 0;
}

View file

@ -24,6 +24,7 @@
#include "p_saveg.h"
#include "p_local.h"
#include "p_slopes.h" // for P_SlopeById
#include "p_polyobj.h" // polyobj_t, PolyObjects
#ifdef LUA_ALLOW_BYTECODE
#include "d_netfil.h" // for LUA_DumpFile
#endif
@ -50,6 +51,7 @@ static lua_CFunction liblist[] = {
LUA_SkinLib, // skin_t, skins[]
LUA_ThinkerLib, // thinker_t
LUA_MapLib, // line_t, side_t, sector_t, subsector_t
LUA_PolyObjLib, // polyobj_t
LUA_BlockmapLib, // blockmap stuff
LUA_HudLib, // HUD stuff
NULL
@ -774,6 +776,12 @@ void LUA_InvalidateLevel(void)
LUA_InvalidateUserdata(&sides[i]);
for (i = 0; i < numvertexes; i++)
LUA_InvalidateUserdata(&vertexes[i]);
for (i = 0; i < (size_t)numPolyObjects; i++)
{
LUA_InvalidateUserdata(&PolyObjects[i]);
LUA_InvalidateUserdata(&PolyObjects[i].vertices);
LUA_InvalidateUserdata(&PolyObjects[i].lines);
}
#ifdef HAVE_LUA_SEGS
for (i = 0; i < numsegs; i++)
LUA_InvalidateUserdata(&segs[i]);
@ -832,6 +840,7 @@ enum
ARCH_NODE,
#endif
ARCH_FFLOOR,
ARCH_POLYOBJ,
ARCH_SLOPE,
ARCH_MAPHEADER,
ARCH_SKINCOLOR,
@ -858,6 +867,7 @@ static const struct {
{META_NODE, ARCH_NODE},
#endif
{META_FFLOOR, ARCH_FFLOOR},
{META_POLYOBJ, ARCH_POLYOBJ},
{META_SLOPE, ARCH_SLOPE},
{META_MAPHEADER, ARCH_MAPHEADER},
{META_SKINCOLOR, ARCH_SKINCOLOR},
@ -1126,6 +1136,17 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex)
}
break;
}
case ARCH_POLYOBJ:
{
polyobj_t *polyobj = *((polyobj_t **)lua_touserdata(gL, myindex));
if (!polyobj)
WRITEUINT8(save_p, ARCH_NULL);
else {
WRITEUINT8(save_p, ARCH_POLYOBJ);
WRITEUINT16(save_p, polyobj-PolyObjects);
}
break;
}
case ARCH_SLOPE:
{
pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex));
@ -1381,6 +1402,9 @@ static UINT8 UnArchiveValue(int TABLESINDEX)
LUA_PushUserdata(gL, rover, META_FFLOOR);
break;
}
case ARCH_POLYOBJ:
LUA_PushUserdata(gL, &PolyObjects[READUINT16(save_p)], META_POLYOBJ);
break;
case ARCH_SLOPE:
LUA_PushUserdata(gL, P_SlopeById(READUINT16(save_p)), META_SLOPE);
break;

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