mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
More nedmalloc updates, possibly fix win32 mouse death at ~10 fps or less, fix dummytile crash, more untested multiplayer changes... different enet channels for different types of traffic in order to eliminate latency due to the occasional reliable packet getting dropped, therefore causing a hitch in the flow of unreliable movement packets on the same channel, remove mmulti API from engine in favor of having everything in game land
git-svn-id: https://svn.eduke32.com/eduke32@1592 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
f3802b7897
commit
addf597188
21 changed files with 242 additions and 2419 deletions
|
@ -245,8 +245,6 @@ endif
|
|||
|
||||
include Makefile.deps
|
||||
|
||||
duke3d_h+=$(EINC)/mmulti_unstable.h
|
||||
|
||||
.PHONY: enginelib editorlib
|
||||
enginelib editorlib:
|
||||
-mkdir -p $(EOBJ)
|
||||
|
|
|
@ -143,8 +143,6 @@ ifeq (1,$(POLYMER))
|
|||
ENGINEOBJS+= $(OBJ)/polymer.$o
|
||||
endif
|
||||
|
||||
ENGINEOBJS+= $(OBJ)/mmulti_unstable.$o
|
||||
|
||||
EDITOROBJS=$(OBJ)/build.$o \
|
||||
$(OBJ)/config.$o
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ $(OBJ)/kplib.$o: $(SRC)/kplib.c $(INC)/compat.h
|
|||
$(OBJ)/quicklz.$o: $(SRC)/quicklz.c $(INC)/quicklz.h
|
||||
$(OBJ)/lzwnew.$o: $(SRC)/lzwnew.c
|
||||
$(OBJ)/md4.$o: $(SRC)/md4.c $(INC)/md4.h $(INC)/compat.h
|
||||
$(OBJ)/mmulti_unstable.$o: $(SRC)/mmulti_unstable.c $(INC)/mmulti_unstable.h
|
||||
$(OBJ)/osd.$o: $(SRC)/osd.c $(INC)/build.h $(INC)/osd.h $(INC)/compat.h $(INC)/baselayer.h
|
||||
$(OBJ)/pragmas.$o: $(SRC)/pragmas.c $(INC)/compat.h
|
||||
$(OBJ)/scriptfile.$o: $(SRC)/scriptfile.c $(INC)/scriptfile.h $(INC)/cache1d.h $(INC)/compat.h
|
||||
|
|
|
@ -75,7 +75,6 @@ ENGINEOBJS= \
|
|||
$(OBJ)\quicklz.$o \
|
||||
$(OBJ)\lzwnew.$o \
|
||||
$(OBJ)\md4.$o \
|
||||
$(OBJ)\mmulti_unstable.$o \
|
||||
$(OBJ)\osd.$o \
|
||||
$(OBJ)\pragmas.$o \
|
||||
$(OBJ)\scriptfile.$o \
|
||||
|
|
|
@ -301,6 +301,9 @@ extern char noclip;
|
|||
|
||||
EXTERN int32_t editorzrange[2];
|
||||
|
||||
EXTERN int32_t myconnectindex, numplayers;
|
||||
EXTERN int32_t connecthead, connectpoint2[MAXPLAYERS];
|
||||
|
||||
static inline int32_t getrendermode(void)
|
||||
{
|
||||
#ifndef POLYMOST
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define WITHKPLIB
|
||||
|
||||
// Define this to rewrite all 'B' versions to library functions. This
|
||||
// is for platforms which give us a standard sort of C library so we
|
||||
// link directly. Platforms like PalmOS which don't have a standard C
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef _MMULTI_UNSTABLE_H_
|
||||
#define _MMULTI_UNSTABLE_H_
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
void callcommit(void);
|
||||
int32_t getcrc(char *buffer, int32_t bufleng);
|
||||
void mmulti_initmultiplayers(int32_t argc, char **argv);
|
||||
void mmulti_sendpacket(int32_t other, char *bufptr, int32_t messleng);
|
||||
void mmulti_setpackettimeout(int32_t datimeoutcount, int32_t daresendagaincount);
|
||||
void mmulti_uninitmultiplayers(void);
|
||||
void mmulti_sendlogon(void);
|
||||
void mmulti_sendlogoff(void);
|
||||
int32_t mmulti_getoutputcirclesize(void);
|
||||
int32_t mmulti_getpacket(int32_t *other, char *bufptr);
|
||||
void mmulti_flushpackets(void);
|
||||
void mmulti_generic(int32_t other, char *bufptr, int32_t messleng, int32_t command);
|
||||
|
||||
extern int32_t natfree, numplayers;
|
||||
|
||||
#endif
|
||||
|
|
@ -5,8 +5,6 @@
|
|||
// This file has been modified from Ken Silverman's original release
|
||||
// by Jonathon Fowler (jonof@edgenetwk.com)
|
||||
|
||||
#define WITHKPLIB
|
||||
|
||||
#include "compat.h"
|
||||
#include "cache1d.h"
|
||||
#include "pragmas.h"
|
||||
|
@ -212,18 +210,17 @@ void suckcache(intptr_t *suckptr)
|
|||
|
||||
void agecache(void)
|
||||
{
|
||||
int32_t cnt;
|
||||
char ch;
|
||||
int32_t cnt = (cacnum>>4);
|
||||
|
||||
if (agecount >= cacnum) agecount = cacnum-1;
|
||||
if (agecount < 0) return;
|
||||
for (cnt=(cacnum>>4); cnt>=0; cnt--)
|
||||
if (agecount < 0 || !cnt) return;
|
||||
for (; cnt>=0; cnt--)
|
||||
{
|
||||
ch = (*cac[agecount].lock);
|
||||
if (((ch-2)&255) < 198)
|
||||
(*cac[agecount].lock) = ch-1;
|
||||
if ((((*cac[agecount].lock)-2)&255) < 198)
|
||||
(*cac[agecount].lock)--;
|
||||
|
||||
agecount--; if (agecount < 0) agecount = cacnum-1;
|
||||
agecount--;
|
||||
if (agecount < 0) agecount = cacnum-1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -577,11 +574,10 @@ void uninitgroupfile(void)
|
|||
|
||||
int32_t kopen4load(char *filename, char searchfirst)
|
||||
{
|
||||
int32_t j, k, fil, newhandle;
|
||||
int32_t j, k, fil, newhandle = MAXOPENFILES-1;
|
||||
char bad, *gfileptr;
|
||||
intptr_t i;
|
||||
|
||||
newhandle = MAXOPENFILES-1;
|
||||
while (filehan[newhandle] != -1)
|
||||
{
|
||||
newhandle--;
|
||||
|
@ -592,14 +588,13 @@ int32_t kopen4load(char *filename, char searchfirst)
|
|||
}
|
||||
}
|
||||
|
||||
if (searchfirst == 0)
|
||||
if ((fil = openfrompath(filename,BO_BINARY|BO_RDONLY,S_IREAD)) >= 0)
|
||||
{
|
||||
filegrp[newhandle] = 255;
|
||||
filehan[newhandle] = fil;
|
||||
filepos[newhandle] = 0;
|
||||
return(newhandle);
|
||||
}
|
||||
if (searchfirst == 0 && (fil = openfrompath(filename,BO_BINARY|BO_RDONLY,S_IREAD)) >= 0)
|
||||
{
|
||||
filegrp[newhandle] = 255;
|
||||
filehan[newhandle] = fil;
|
||||
filepos[newhandle] = 0;
|
||||
return(newhandle);
|
||||
}
|
||||
|
||||
for (; toupperlookup[*filename] == '/'; filename++);
|
||||
|
||||
|
@ -638,7 +633,7 @@ int32_t kopen4load(char *filename, char searchfirst)
|
|||
}
|
||||
if (bad) continue;
|
||||
if (j<13 && gfileptr[j]) continue; // JBF: because e1l1.map might exist before e1l1
|
||||
if (j==13 && filename[j]) continue; // JBF: int32_t file name
|
||||
if (j==13 && filename[j]) continue; // JBF: long file name
|
||||
|
||||
filegrp[newhandle] = k;
|
||||
filehan[newhandle] = i;
|
||||
|
@ -652,10 +647,10 @@ int32_t kopen4load(char *filename, char searchfirst)
|
|||
|
||||
int32_t kread(int32_t handle, void *buffer, int32_t leng)
|
||||
{
|
||||
int32_t i, filenum, groupnum;
|
||||
int32_t i;
|
||||
int32_t filenum = filehan[handle];
|
||||
int32_t groupnum = filegrp[handle];
|
||||
|
||||
filenum = filehan[handle];
|
||||
groupnum = filegrp[handle];
|
||||
if (groupnum == 255) return(Bread(filenum,buffer,leng));
|
||||
#ifdef WITHKPLIB
|
||||
else if (groupnum == 254)
|
||||
|
|
|
@ -7908,6 +7908,7 @@ int32_t loadpics(char *filename, int32_t askedsize)
|
|||
artsize += ((dasiz+15)&0xfffffff0);
|
||||
}
|
||||
|
||||
#ifdef WITHKPLIB
|
||||
if (filegrp[fil] == 254) // from zip
|
||||
{
|
||||
i = kfilelength(fil);
|
||||
|
@ -7915,6 +7916,7 @@ int32_t loadpics(char *filename, int32_t askedsize)
|
|||
klseek(fil, 0, BSEEK_SET);
|
||||
kread(fil, artptrs[numtilefiles], i);
|
||||
}
|
||||
#endif
|
||||
kclose(fil);
|
||||
}
|
||||
numtilefiles++;
|
||||
|
@ -7965,6 +7967,7 @@ void loadtile(int16_t tilenume)
|
|||
if ((unsigned)tilenume >= (unsigned)MAXTILES) return;
|
||||
if ((dasiz = tilesizx[tilenume]*tilesizy[tilenume]) <= 0) return;
|
||||
|
||||
#ifdef WITHKPLIB
|
||||
if (artptrs[(i = tilefilenum[tilenume])]) // from zip
|
||||
{
|
||||
waloff[tilenume] = (intptr_t)(artptrs[i] + tilefileoffs[tilenume]);
|
||||
|
@ -7972,6 +7975,7 @@ void loadtile(int16_t tilenume)
|
|||
// OSD_Printf("loaded tile %d from zip\n", tilenume);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (i != artfilnum)
|
||||
{
|
||||
|
@ -7992,7 +7996,11 @@ void loadtile(int16_t tilenume)
|
|||
if (faketilesiz[tilenume])
|
||||
{
|
||||
if (faketilesiz[tilenume] == -1)
|
||||
{
|
||||
walock[tilenume] = 255; // permanent tile
|
||||
allocache(&waloff[tilenume],dasiz,&walock[tilenume]);
|
||||
Bmemset((char *)waloff[tilenume],0,dasiz);
|
||||
}
|
||||
else if (faketiledata[tilenume] != NULL)
|
||||
{
|
||||
walock[tilenume] = 255; // permanent tile
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -32,6 +32,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
#pragma warning(push)
|
||||
#pragma warning(disable:4100) /* unreferenced formal parameter */
|
||||
#pragma warning(disable:4127) /* conditional expression is constant */
|
||||
#pragma warning(disable:4232) /* address of dllimport is not static, identity not guaranteed */
|
||||
#pragma warning(disable:4706) /* assignment within conditional expression */
|
||||
#endif
|
||||
|
||||
|
@ -42,7 +43,8 @@ DEALINGS IN THE SOFTWARE.
|
|||
#define ENABLE_LARGE_PAGES 1
|
||||
#define ENABLE_FAST_HEAP_DETECTION 1
|
||||
#define NDEBUG 1
|
||||
|
||||
#define THREADCACHEMAX 32768
|
||||
#define THREADCACHEMAXBINS ((15-4)*2)
|
||||
/*#define ENABLE_TOLERANT_NEDMALLOC 1*/
|
||||
/*#define ENABLE_FAST_HEAP_DETECTION 1*/
|
||||
/*#define NEDMALLOC_DEBUG 1*/
|
||||
|
@ -54,10 +56,14 @@ DEALINGS IN THE SOFTWARE.
|
|||
// #define NOINLINE
|
||||
#endif
|
||||
|
||||
|
||||
#include "nedmalloc.h"
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32)
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
/* Sadly we can't include <malloc.h> as it causes a redefinition error */
|
||||
extern size_t malloc_usable_size(void *);
|
||||
#endif
|
||||
#if USE_ALLOCATOR==1
|
||||
#define MSPACES 1
|
||||
|
@ -79,7 +85,8 @@ DEALINGS IN THE SOFTWARE.
|
|||
#undef DEBUG
|
||||
#undef _DEBUG
|
||||
#if NEDMALLOC_DEBUG
|
||||
#define _DEBUG
|
||||
#define _DEBUG
|
||||
#define DEBUG 1
|
||||
#else
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
|
@ -96,9 +103,10 @@ DEALINGS IN THE SOFTWARE.
|
|||
#endif
|
||||
/*#define USE_SPIN_LOCKS 0*/
|
||||
|
||||
|
||||
#include "malloc.c.h"
|
||||
#ifdef NDEBUG /* Disable assert checking on release builds */
|
||||
#undef DEBUG
|
||||
#ifdef NDEBUG /* Disable assert checking on release builds */
|
||||
#undef DEBUG
|
||||
#elif !NEDMALLOC_DEBUG
|
||||
#ifdef __GNUC__
|
||||
#warning DEBUG is defined so allocator will run with assert checking! Define NDEBUG to run at full speed.
|
||||
|
@ -117,21 +125,30 @@ DEALINGS IN THE SOFTWARE.
|
|||
#endif
|
||||
/* The maximum size to be allocated from the thread cache */
|
||||
#ifndef THREADCACHEMAX
|
||||
#define THREADCACHEMAX 32768
|
||||
#define THREADCACHEMAX 8192
|
||||
#elif THREADCACHEMAX && !defined(THREADCACHEMAXBINS)
|
||||
#ifdef __GNUC__
|
||||
#warning If you are changing THREADCACHEMAX, do you also need to change THREADCACHEMAXBINS=(topbitpos(THREADCACHEMAX)-4)?
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma message(__FILE__ ": WARNING: If you are changing THREADCACHEMAX, do you also need to change THREADCACHEMAXBINS=(topbitpos(THREADCACHEMAX)-4)?")
|
||||
#endif
|
||||
#endif
|
||||
#ifndef THREADCACHEMAXBINS
|
||||
#ifdef FINEGRAINEDBINS
|
||||
/* The number of cache entries for finer grained bins. This is (topbitpos(THREADCACHEMAX)-4)*2 */
|
||||
#define THREADCACHEMAXBINS ((15-4)*2)
|
||||
#define THREADCACHEMAXBINS ((13-4)*2)
|
||||
#else
|
||||
/* The number of cache entries. This is (topbitpos(THREADCACHEMAX)-4) */
|
||||
#define THREADCACHEMAXBINS (15-4)
|
||||
#define THREADCACHEMAXBINS (13-4)
|
||||
#endif
|
||||
#endif
|
||||
/* Point at which the free space in a thread cache is garbage collected */
|
||||
#ifndef THREADCACHEMAXFREESPACE
|
||||
#define THREADCACHEMAXFREESPACE (512*1024*4)
|
||||
#define THREADCACHEMAXFREESPACE (512*1024)
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_LOCKS
|
||||
#ifdef WIN32
|
||||
#define TLSVAR DWORD
|
||||
#define TLSALLOC(k) (*(k)=TlsAlloc(), TLS_OUT_OF_INDEXES==*(k))
|
||||
|
@ -155,6 +172,13 @@ static LPVOID ChkedTlsGetValue(DWORD idx)
|
|||
#define TLSGET(k) pthread_getspecific(k)
|
||||
#define TLSSET(k, a) pthread_setspecific(k, a)
|
||||
#endif
|
||||
#else /* Probably if you're not using locks then you don't want ANY pthread stuff at all */
|
||||
#define TLSVAR void *
|
||||
#define TLSALLOC(k) (*k=0)
|
||||
#define TLSFREE(k) (k=0)
|
||||
#define TLSGET(k) k
|
||||
#define TLSSET(k, a) (k=a, 0)
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if !defined(NO_NED_NAMESPACE)
|
||||
|
@ -177,32 +201,46 @@ static size_t mspacecounter=(size_t) 0xdeadbeef;
|
|||
static void *RESTRICT leastusedaddress;
|
||||
static size_t largestusedblock;
|
||||
#endif
|
||||
/* Used to redirect system allocator ops if needed */
|
||||
extern void *(*sysmalloc)(size_t);
|
||||
extern void *(*syscalloc)(size_t, size_t);
|
||||
extern void *(*sysrealloc)(void *, size_t);
|
||||
extern void (*sysfree)(void *);
|
||||
extern size_t (*sysblksize)(void *);
|
||||
|
||||
static FORCEINLINE void *CallMalloc(void *RESTRICT mspace, size_t size, size_t alignment) THROWSPEC
|
||||
void *(*sysmalloc)(size_t)=malloc;
|
||||
void *(*syscalloc)(size_t, size_t)=calloc;
|
||||
void *(*sysrealloc)(void *, size_t)=realloc;
|
||||
void (*sysfree)(void *)=free;
|
||||
size_t (*sysblksize)(void *)=
|
||||
#ifdef WIN32
|
||||
/* This is the MSVCRT equivalent */
|
||||
_msize;
|
||||
#elif defined(__linux__)
|
||||
/* This is the glibc/ptmalloc2/dlmalloc equivalent. */
|
||||
malloc_usable_size;
|
||||
#elif defined(__FreeBSD__) || defined(__APPLE__)
|
||||
/* This is the BSD libc equivalent. */
|
||||
malloc_size;
|
||||
#else
|
||||
#error Cannot tolerate the memory allocator of an unknown system!
|
||||
#endif
|
||||
|
||||
static FORCEINLINE NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *CallMalloc(void *RESTRICT mspace, size_t size, size_t alignment) THROWSPEC
|
||||
{
|
||||
void *RESTRICT ret=0;
|
||||
size_t _alignment=alignment;
|
||||
void *RESTRICT ret=0;
|
||||
size_t _alignment=alignment;
|
||||
#if USE_MAGIC_HEADERS
|
||||
size_t *_ret=0;
|
||||
size+=alignment+3*sizeof(size_t);
|
||||
_alignment=0;
|
||||
size_t *_ret=0;
|
||||
size+=alignment+3*sizeof(size_t);
|
||||
_alignment=0;
|
||||
#endif
|
||||
#if USE_ALLOCATOR==0
|
||||
ret=_alignment ?
|
||||
#ifdef WIN32
|
||||
/* This is the MSVCRT equivalent */
|
||||
_aligned_malloc(size, _alignment)
|
||||
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
|
||||
/* This is the glibc/ptmalloc2/dlmalloc/BSD libc equivalent. */
|
||||
memalign(_alignment, size)
|
||||
#else
|
||||
#error Cannot aligned allocate with the memory allocator of an unknown system!
|
||||
#endif
|
||||
: malloc(size);
|
||||
ret=sysmalloc(size); /* magic headers takes care of alignment */
|
||||
#elif USE_ALLOCATOR==1
|
||||
ret=_alignment ? mspace_memalign((mstate) mspace, _alignment, size) : mspace_malloc((mstate) mspace, size);
|
||||
ret=_alignment ? mspace_memalign((mstate) mspace, _alignment, size) : mspace_malloc((mstate) mspace, size);
|
||||
#ifndef ENABLE_FAST_HEAP_DETECTION
|
||||
if(ret)
|
||||
if(ret)
|
||||
{
|
||||
size_t truesize=chunksize(mem2chunk(ret));
|
||||
if(!leastusedaddress || (void *)((mstate) mspace)->least_addr<leastusedaddress) leastusedaddress=(void *)((mstate) mspace)->least_addr;
|
||||
|
@ -222,7 +260,7 @@ static FORCEINLINE void *CallMalloc(void *RESTRICT mspace, size_t size, size_t a
|
|||
return ret;
|
||||
}
|
||||
|
||||
static FORCEINLINE void *CallCalloc(void *RESTRICT mspace, size_t size, size_t alignment) THROWSPEC
|
||||
static FORCEINLINE NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *CallCalloc(void *RESTRICT mspace, size_t size, size_t alignment) THROWSPEC
|
||||
{
|
||||
void *RESTRICT ret=0;
|
||||
#if USE_MAGIC_HEADERS
|
||||
|
@ -230,7 +268,7 @@ static FORCEINLINE void *CallCalloc(void *RESTRICT mspace, size_t size, size_t a
|
|||
size+=alignment+3*sizeof(size_t);
|
||||
#endif
|
||||
#if USE_ALLOCATOR==0
|
||||
ret=calloc(1, size);
|
||||
ret=syscalloc(1, size);
|
||||
#elif USE_ALLOCATOR==1
|
||||
ret=mspace_calloc((mstate) mspace, 1, size);
|
||||
#ifndef ENABLE_FAST_HEAP_DETECTION
|
||||
|
@ -254,7 +292,7 @@ static FORCEINLINE void *CallCalloc(void *RESTRICT mspace, size_t size, size_t a
|
|||
return ret;
|
||||
}
|
||||
|
||||
static FORCEINLINE void *CallRealloc(void *RESTRICT mspace, void *RESTRICT mem, int isforeign, size_t oldsize, size_t newsize) THROWSPEC
|
||||
static FORCEINLINE NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void *CallRealloc(void *RESTRICT mspace, void *RESTRICT mem, int isforeign, size_t oldsize, size_t newsize) THROWSPEC
|
||||
{
|
||||
void *RESTRICT ret=0;
|
||||
#if USE_MAGIC_HEADERS
|
||||
|
@ -272,7 +310,7 @@ static FORCEINLINE void *CallRealloc(void *RESTRICT mspace, void *RESTRICT mem,
|
|||
printf("*** nedmalloc frees system allocated block %p\n", mem);
|
||||
#endif
|
||||
memcpy(ret, mem, oldsize<newsize ? oldsize : newsize);
|
||||
free(mem);
|
||||
sysfree(mem);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -285,7 +323,7 @@ static FORCEINLINE void *CallRealloc(void *RESTRICT mspace, void *RESTRICT mem,
|
|||
mem=(void *)(++_mem);
|
||||
#endif
|
||||
#if USE_ALLOCATOR==0
|
||||
ret=realloc(mem, newsize);
|
||||
ret=sysrealloc(mem, newsize);
|
||||
#elif USE_ALLOCATOR==1
|
||||
ret=mspace_realloc((mstate) mspace, mem, newsize);
|
||||
#ifndef ENABLE_FAST_HEAP_DETECTION
|
||||
|
@ -327,7 +365,7 @@ static FORCEINLINE void CallFree(void *RESTRICT mspace, void *RESTRICT mem, int
|
|||
#if defined(DEBUG)
|
||||
printf("*** nedmalloc frees system allocated block %p\n", mem);
|
||||
#endif
|
||||
free(mem);
|
||||
sysfree(mem);
|
||||
return;
|
||||
}
|
||||
#if USE_MAGIC_HEADERS
|
||||
|
@ -338,7 +376,7 @@ static FORCEINLINE void CallFree(void *RESTRICT mspace, void *RESTRICT mem, int
|
|||
mem=(void *)(++_mem);
|
||||
#endif
|
||||
#if USE_ALLOCATOR==0
|
||||
free(mem);
|
||||
sysfree(mem);
|
||||
#elif USE_ALLOCATOR==1
|
||||
mspace_free((mstate) mspace, mem);
|
||||
#endif
|
||||
|
@ -412,7 +450,7 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC
|
|||
return fm;
|
||||
}
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#ifdef WIN32
|
||||
__try
|
||||
#endif
|
||||
{
|
||||
|
@ -455,7 +493,7 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC
|
|||
return fm;
|
||||
}
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
#ifdef WIN32
|
||||
__except(1) { }
|
||||
#endif
|
||||
#endif
|
||||
|
@ -495,36 +533,25 @@ NEDMALLOCNOALIASATTR size_t nedblksize(int *RESTRICT isforeign, void *RESTRICT m
|
|||
#endif
|
||||
#endif
|
||||
#if defined(ENABLE_TOLERANT_NEDMALLOC) || USE_ALLOCATOR==0
|
||||
#ifdef WIN32
|
||||
/* This is the MSVCRT equivalent */
|
||||
return _msize(mem);
|
||||
#elif defined(__linux__)
|
||||
/* This is the glibc/ptmalloc2/dlmalloc equivalent. */
|
||||
return malloc_usable_size(mem);
|
||||
#elif defined(__FreeBSD__) || defined(__APPLE__)
|
||||
/* This is the BSD libc equivalent. */
|
||||
return malloc_size(mem);
|
||||
#else
|
||||
#error Cannot tolerate the memory allocator of an unknown system!
|
||||
#endif
|
||||
return sysblksize(mem);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
NEDMALLOCNOALIASATTR void nedsetvalue(void *v) THROWSPEC { nedpsetvalue((nedpool *) 0, v); }
|
||||
NEDMALLOCNOALIASATTR void nedsetvalue(void *v) THROWSPEC { nedpsetvalue((nedpool *) 0, v); }
|
||||
NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedmalloc(size_t size) THROWSPEC { return nedpmalloc((nedpool *) 0, size); }
|
||||
NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedcalloc(size_t no, size_t size) THROWSPEC { return nedpcalloc((nedpool *) 0, no, size); }
|
||||
NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedcalloc(size_t no, size_t size) THROWSPEC { return nedpcalloc((nedpool *) 0, no, size); }
|
||||
NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedrealloc(void *mem, size_t size) THROWSPEC { return nedprealloc((nedpool *) 0, mem, size); }
|
||||
NEDMALLOCNOALIASATTR void nedfree(void *mem) THROWSPEC { nedpfree((nedpool *) 0, mem); }
|
||||
NEDMALLOCNOALIASATTR void nedfree(void *mem) THROWSPEC { nedpfree((nedpool *) 0, mem); }
|
||||
NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void * nedmemalign(size_t alignment, size_t bytes) THROWSPEC { return nedpmemalign((nedpool *) 0, alignment, bytes); }
|
||||
NEDMALLOCNOALIASATTR struct nedmallinfo nedmallinfo(void) THROWSPEC { return nedpmallinfo((nedpool *) 0); }
|
||||
NEDMALLOCNOALIASATTR int nedmallopt(int parno, int value) THROWSPEC { return nedpmallopt((nedpool *) 0, parno, value); }
|
||||
NEDMALLOCNOALIASATTR int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim((nedpool *) 0, pad); }
|
||||
void nedmalloc_stats() THROWSPEC { nedpmalloc_stats((nedpool *) 0); }
|
||||
NEDMALLOCNOALIASATTR int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim((nedpool *) 0, pad); }
|
||||
void nedmalloc_stats() THROWSPEC { nedpmalloc_stats((nedpool *) 0); }
|
||||
NEDMALLOCNOALIASATTR size_t nedmalloc_footprint() THROWSPEC { return nedpmalloc_footprint((nedpool *) 0); }
|
||||
NEDMALLOCPTRATTR void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC { return nedpindependent_calloc((nedpool *) 0, elemsno, elemsize, chunks); }
|
||||
// NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc((nedpool *) 0, elems, sizes, chunks); }
|
||||
NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC { return nedpindependent_calloc((nedpool *) 0, elemsno, elemsize, chunks); }
|
||||
NEDMALLOCNOALIASATTR NEDMALLOCPTRATTR void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc((nedpool *) 0, elems, sizes, chunks); }
|
||||
|
||||
struct threadcacheblk_t;
|
||||
typedef struct threadcacheblk_t threadcacheblk;
|
||||
|
@ -552,7 +579,9 @@ typedef struct threadcache_t
|
|||
} threadcache;
|
||||
struct nedpool_t
|
||||
{
|
||||
#if USE_LOCKS
|
||||
MLOCK_T mutex;
|
||||
#endif
|
||||
void *uservalue;
|
||||
int threads; /* Max entries in m to use */
|
||||
threadcache *caches[THREADCACHEMAXCACHES];
|
||||
|
@ -709,27 +738,40 @@ static NOINLINE threadcache *AllocCache(nedpool *RESTRICT p) THROWSPEC
|
|||
{
|
||||
threadcache *tc=0;
|
||||
int n, end;
|
||||
#if USE_LOCKS
|
||||
ACQUIRE_LOCK(&p->mutex);
|
||||
#endif
|
||||
for(n=0; n<THREADCACHEMAXCACHES && p->caches[n]; n++);
|
||||
if(THREADCACHEMAXCACHES==n)
|
||||
{ /* List exhausted, so disable for this thread */
|
||||
#if USE_LOCKS
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
tc=p->caches[n]=(threadcache *) CallCalloc(p->m[0], sizeof(threadcache), 0);
|
||||
if(!tc)
|
||||
{
|
||||
#if USE_LOCKS
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#ifdef FULLSANITYCHECKS
|
||||
tc->magic1=*(unsigned int *)"NEDMALC1";
|
||||
tc->magic2=*(unsigned int *)"NEDMALC2";
|
||||
#endif
|
||||
tc->threadid=(long)(size_t)CURRENT_THREAD;
|
||||
tc->threadid=
|
||||
#if USE_LOCKS
|
||||
(long)(size_t)CURRENT_THREAD;
|
||||
#else
|
||||
1;
|
||||
#endif
|
||||
for(end=0; p->m[end]; end++);
|
||||
tc->mymspace=abs(tc->threadid) % end;
|
||||
#if USE_LOCKS
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
#endif
|
||||
if(TLSSET(p->mycache, (void *)(size_t)(n+1))) abort();
|
||||
return tc;
|
||||
}
|
||||
|
@ -824,14 +866,18 @@ static void *threadcache_malloc(nedpool *RESTRICT p, threadcache *RESTRICT tc, s
|
|||
static NOINLINE void ReleaseFreeInCache(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace) THROWSPEC
|
||||
{
|
||||
unsigned int age=THREADCACHEMAXFREESPACE/8192;
|
||||
#if USE_LOCKS
|
||||
/*ACQUIRE_LOCK(&p->m[mymspace]->mutex);*/
|
||||
#endif
|
||||
while(age && tc->freeInCache>=THREADCACHEMAXFREESPACE)
|
||||
{
|
||||
RemoveCacheEntries(p, tc, age);
|
||||
/*printf("*** Removing cache entries older than %u (%u)\n", age, (unsigned int) tc->freeInCache);*/
|
||||
age>>=1;
|
||||
}
|
||||
#if USE_LOCKS
|
||||
/*RELEASE_LOCK(&p->m[mymspace]->mutex);*/
|
||||
#endif
|
||||
}
|
||||
static void threadcache_free(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace, void *RESTRICT mem, size_t size) THROWSPEC
|
||||
{
|
||||
|
@ -853,7 +899,7 @@ static void threadcache_free(nedpool *RESTRICT p, threadcache *RESTRICT tc, int
|
|||
idx<<=1;
|
||||
if(size>bestsize)
|
||||
{
|
||||
unsigned int biggerbestsize=(bestsize+bestsize)<<1;
|
||||
unsigned int biggerbestsize=bestsize+bestsize<<1;
|
||||
if(size>=biggerbestsize)
|
||||
{
|
||||
idx++;
|
||||
|
@ -904,7 +950,9 @@ static NOINLINE int InitPool(nedpool *RESTRICT p, size_t capacity, int threads)
|
|||
ensure_initialization();
|
||||
ACQUIRE_MALLOC_GLOBAL_LOCK();
|
||||
if(p->threads) goto done;
|
||||
#if USE_LOCKS
|
||||
if(INITIAL_LOCK(&p->mutex)) goto err;
|
||||
#endif
|
||||
if(TLSALLOC(&p->mycache)) goto err;
|
||||
#if USE_ALLOCATOR==0
|
||||
p->m[0]=(mstate) mspacecounter++;
|
||||
|
@ -941,7 +989,9 @@ static NOINLINE mstate FindMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc,
|
|||
unlocked one and if we fail, we create a new one so long as we don't
|
||||
exceed p->threads */
|
||||
int n, end;
|
||||
for(n=end=*lastUsed+1; p->m[n]; end=++n)
|
||||
n=end=*lastUsed+1;
|
||||
#if USE_LOCKS
|
||||
for(; p->m[n]; end=++n)
|
||||
{
|
||||
if(TRY_LOCK(&p->m[n]->mutex)) goto found;
|
||||
}
|
||||
|
@ -983,6 +1033,7 @@ static NOINLINE mstate FindMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc,
|
|||
badexit:
|
||||
ACQUIRE_LOCK(&p->m[*lastUsed]->mutex);
|
||||
return p->m[*lastUsed];
|
||||
#endif
|
||||
found:
|
||||
*lastUsed=n;
|
||||
if(tc)
|
||||
|
@ -1004,7 +1055,9 @@ typedef struct PoolList_t
|
|||
nedpool *list[16];
|
||||
#endif
|
||||
} PoolList;
|
||||
#if USE_LOCKS
|
||||
static MLOCK_T poollistlock;
|
||||
#endif
|
||||
static PoolList *poollist;
|
||||
NEDMALLOCPTRATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC
|
||||
{
|
||||
|
@ -1013,13 +1066,17 @@ NEDMALLOCPTRATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC
|
|||
{
|
||||
PoolList *newpoollist=0;
|
||||
if(!(newpoollist=(PoolList *) nedpcalloc(0, 1, sizeof(PoolList)+sizeof(nedpool *)))) return 0;
|
||||
#if USE_LOCKS
|
||||
INITIAL_LOCK(&poollistlock);
|
||||
ACQUIRE_LOCK(&poollistlock);
|
||||
#endif
|
||||
poollist=newpoollist;
|
||||
poollist->size=sizeof(poollist->list)/sizeof(nedpool *);
|
||||
}
|
||||
#if USE_LOCKS
|
||||
else
|
||||
ACQUIRE_LOCK(&poollistlock);
|
||||
#endif
|
||||
if(poollist->length==poollist->size)
|
||||
{
|
||||
PoolList *newpoollist=0;
|
||||
|
@ -1039,13 +1096,19 @@ NEDMALLOCPTRATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC
|
|||
}
|
||||
poollist->list[poollist->length++]=ret;
|
||||
badexit:
|
||||
RELEASE_LOCK(&poollistlock);
|
||||
{
|
||||
#if USE_LOCKS
|
||||
RELEASE_LOCK(&poollistlock);
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
void neddestroypool(nedpool *p) THROWSPEC
|
||||
{
|
||||
unsigned int n;
|
||||
#if USE_LOCKS
|
||||
ACQUIRE_LOCK(&p->mutex);
|
||||
#endif
|
||||
DestroyCaches(p);
|
||||
for(n=0; p->m[n]; n++)
|
||||
{
|
||||
|
@ -1054,10 +1117,14 @@ void neddestroypool(nedpool *p) THROWSPEC
|
|||
#endif
|
||||
p->m[n]=0;
|
||||
}
|
||||
#if USE_LOCKS
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
#endif
|
||||
if(TLSFREE(p->mycache)) abort();
|
||||
nedpfree(0, p);
|
||||
#if USE_LOCKS
|
||||
ACQUIRE_LOCK(&poollistlock);
|
||||
#endif
|
||||
assert(poollist);
|
||||
for(n=0; n<poollist->length && poollist->list[n]!=p; n++);
|
||||
assert(n!=poollist->length);
|
||||
|
@ -1068,13 +1135,17 @@ void neddestroypool(nedpool *p) THROWSPEC
|
|||
nedpfree(0, poollist);
|
||||
poollist=0;
|
||||
}
|
||||
#if USE_LOCKS
|
||||
RELEASE_LOCK(&poollistlock);
|
||||
#endif
|
||||
}
|
||||
void neddestroysyspool() THROWSPEC
|
||||
{
|
||||
nedpool *p=&syspool;
|
||||
int n;
|
||||
#if USE_LOCKS
|
||||
ACQUIRE_LOCK(&p->mutex);
|
||||
#endif
|
||||
DestroyCaches(p);
|
||||
for(n=0; p->m[n]; n++)
|
||||
{
|
||||
|
@ -1089,18 +1160,26 @@ void neddestroysyspool() THROWSPEC
|
|||
for(n=0; n<MAXTHREADSINPOOL+1; n++)
|
||||
p->m[n]=(mstate)(size_t)(sizeof(size_t)>4 ? 0xdeadbeefdeadbeefULL : 0xdeadbeefUL);
|
||||
if(TLSFREE(p->mycache)) abort();
|
||||
#if USE_LOCKS
|
||||
RELEASE_LOCK(&p->mutex);
|
||||
#endif
|
||||
}
|
||||
nedpool **nedpoollist() THROWSPEC
|
||||
{
|
||||
nedpool **ret=0;
|
||||
if(poollist)
|
||||
{
|
||||
#if USE_LOCKS
|
||||
ACQUIRE_LOCK(&poollistlock);
|
||||
#endif
|
||||
if(!(ret=(nedpool **) nedmalloc((poollist->length+1)*sizeof(nedpool *)))) goto badexit;
|
||||
memcpy(ret, poollist->list, (poollist->length+1)*sizeof(nedpool *));
|
||||
badexit:
|
||||
RELEASE_LOCK(&poollistlock);
|
||||
{
|
||||
#if USE_LOCKS
|
||||
RELEASE_LOCK(&poollistlock);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1158,19 +1237,28 @@ void neddisablethreadcache(nedpool *p) THROWSPEC
|
|||
nedtrimthreadcache(p, 1);
|
||||
}
|
||||
|
||||
#if USE_LOCKS && USE_ALLOCATOR==1
|
||||
#define GETMSPACE(m,p,tc,ms,s,action) \
|
||||
do \
|
||||
{ \
|
||||
mstate m = GetMSpace((p),(tc),(ms),(s)); \
|
||||
action; \
|
||||
if(USE_ALLOCATOR==1) { RELEASE_LOCK(&m->mutex); } \
|
||||
RELEASE_LOCK(&m->mutex); \
|
||||
} while (0)
|
||||
#else
|
||||
#define GETMSPACE(m,p,tc,ms,s,action) \
|
||||
do \
|
||||
{ \
|
||||
mstate m = GetMSpace((p),(tc),(ms),(s)); \
|
||||
action; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
static FORCEINLINE mstate GetMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace, size_t size) THROWSPEC
|
||||
{ /* Returns a locked and ready for use mspace */
|
||||
mstate m=p->m[mymspace];
|
||||
assert(m);
|
||||
#if USE_ALLOCATOR==1
|
||||
#if USE_LOCKS && USE_ALLOCATOR==1
|
||||
if(!TRY_LOCK(&p->m[mymspace]->mutex)) m=FindMSpace(p, tc, &mymspace, size);
|
||||
/*assert(IS_LOCKED(&p->m[mymspace]->mutex));*/
|
||||
#endif
|
||||
|
@ -1214,7 +1302,9 @@ static FORCEINLINE void GetThreadCache(nedpool *RESTRICT *RESTRICT p, threadcach
|
|||
}
|
||||
else GetThreadCache_cold2(p, tc, mymspace, mycache);
|
||||
assert(*mymspace>=0);
|
||||
#if USE_LOCKS
|
||||
assert(!(*tc) || (long)(size_t)CURRENT_THREAD==(*tc)->threadid);
|
||||
#endif
|
||||
#ifdef FULLSANITYCHECKS
|
||||
if(*tc)
|
||||
{
|
||||
|
@ -1440,8 +1530,6 @@ NEDMALLOCPTRATTR void **nedpindependent_calloc(nedpool *p, size_t elemsno, size_
|
|||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NEDMALLOCPTRATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC
|
||||
{
|
||||
void **ret;
|
||||
|
@ -1461,7 +1549,6 @@ NEDMALLOCPTRATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_
|
|||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
// cheap replacement for strdup so we aren't feeding system allocated blocks into nedmalloc
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "baselayer.h"
|
||||
#include "cache1d.h"
|
||||
#include "pragmas.h"
|
||||
#include "mmulti_unstable.h"
|
||||
|
||||
symbol_t *symbols = NULL;
|
||||
static symbol_t *addnewsymbol(const char *name);
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "build.h"
|
||||
#include "a.h"
|
||||
#include "osd.h"
|
||||
#include "mmulti_unstable.h"
|
||||
|
||||
// undefine to restrict windowed resolutions to conventional sizes
|
||||
#define ANY_WINDOWED_SIZE
|
||||
|
@ -911,10 +910,7 @@ DWORD WINAPI ProcessMouse(LPVOID lpThreadParameter)
|
|||
(LPDIDEVICEOBJECTDATA)&didod[0], &dwElements, 0);
|
||||
|
||||
if (!dwElements || result != DI_OK)
|
||||
{
|
||||
Sleep(100);
|
||||
continue;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -4206,7 +4202,7 @@ static inline BOOL CheckWinVersion(void)
|
|||
// we don't like anything older than Windows 2000, but the BUILD_WIN9X
|
||||
// variable allows attempting to run on 9x (for masochists and sodomites)
|
||||
|
||||
if (!GetVersionEx(&osv)) return FALSE;
|
||||
if (!GetVersionEx((LPOSVERSIONINFOA)&osv)) return FALSE;
|
||||
|
||||
if (osv.dwMajorVersion >= 5) return TRUE;
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ extern "C" {
|
|||
#include "cache1d.h"
|
||||
#include "pragmas.h"
|
||||
|
||||
#include "mmulti_unstable.h"
|
||||
|
||||
#include "baselayer.h"
|
||||
|
||||
#include "function.h"
|
||||
|
@ -53,6 +51,16 @@ extern ENetHost * g_netServer;
|
|||
extern ENetHost * g_netClient;
|
||||
extern ENetPeer * g_netClientPeer;
|
||||
|
||||
enum netchan_t
|
||||
{
|
||||
CHAN_MOVE, // unreliable movement packets
|
||||
CHAN_GAMESTATE, // gamestate changes... frags, respawns, player names, etc
|
||||
CHAN_SYNC, // client join sync packets
|
||||
CHAN_CHAT, // chat and RTS
|
||||
CHAN_MISC, // whatever else
|
||||
CHAN_MAX
|
||||
};
|
||||
|
||||
#define APPNAME "EDuke32"
|
||||
#define VERSION " 2.0.0devel"
|
||||
// this is checked against http://eduke32.com/VERSION
|
||||
|
|
|
@ -593,7 +593,7 @@ void Net_Connect(const char * srvaddr)
|
|||
address.port = atoi((addrstr = strtok(NULL, ":")) == NULL ? "23513" : addrstr);
|
||||
|
||||
// use 2 channels for easy packet sorting at a lower level than the game later
|
||||
g_netClientPeer = enet_host_connect (g_netClient, &address, 2);
|
||||
g_netClientPeer = enet_host_connect (g_netClient, &address, CHAN_MAX);
|
||||
|
||||
if (g_netClientPeer == NULL)
|
||||
{
|
||||
|
@ -705,7 +705,7 @@ static void Net_SendVersion(ENetPeer * client)
|
|||
buf[2] = (uint8_t)atoi(s_buildDate);
|
||||
buf[3] = myconnectindex;
|
||||
|
||||
enet_peer_send(client, 0, enet_packet_create(&buf[0], 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(client, CHAN_GAMESTATE, enet_packet_create(&buf[0], 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
|
||||
void Net_SendClientInfo(void)
|
||||
|
@ -740,9 +740,9 @@ void Net_SendClientInfo(void)
|
|||
buf[l++] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(&buf[0], l, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(&buf[0], l, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(&buf[0], l, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(&buf[0], l, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
|
||||
void Net_SendUserMapName(void)
|
||||
|
@ -764,9 +764,9 @@ void Net_SendUserMapName(void)
|
|||
packbuf[j++] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(packbuf, j, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(packbuf, j, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(packbuf, j, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, j, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
|
||||
void Net_NewGame(int32_t volume, int32_t level)
|
||||
|
@ -786,9 +786,9 @@ void Net_NewGame(int32_t volume, int32_t level)
|
|||
packbuf[12] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
|
||||
static mapstate_t *g_multiMapState = NULL;
|
||||
|
@ -812,7 +812,7 @@ static void Net_SendChallenge(void)
|
|||
|
||||
buf[l++] = myconnectindex;
|
||||
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(&buf[0], l, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(&buf[0], l, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
|
||||
void P_Disconnected(int32_t i)
|
||||
|
@ -895,12 +895,12 @@ void Net_SyncPlayer(ENetEvent * event)
|
|||
packbuf[3] = ud.multimode;
|
||||
packbuf[4] = i;
|
||||
packbuf[5] = myconnectindex;
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(packbuf, 6, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, 6, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
packbuf[0] = PACKET_PLAYER_INDEX;
|
||||
packbuf[1] = i;
|
||||
packbuf[2] = myconnectindex;
|
||||
enet_peer_send(event->peer, 0, enet_packet_create(packbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
Net_SendClientInfo();
|
||||
Net_SendUserMapName();
|
||||
|
@ -931,10 +931,10 @@ void Net_SyncPlayer(ENetEvent * event)
|
|||
j = qlz_compress((char *)g_multiMapState, buf, sizeof(mapstate_t), state_compress);
|
||||
while (j > 1024)
|
||||
{
|
||||
enet_peer_send(event->peer, 1, enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, 1024, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(event->peer, CHAN_SYNC, enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, 1024, ENET_PACKET_FLAG_RELIABLE));
|
||||
j -= 1024;
|
||||
}
|
||||
enet_peer_send(event->peer, 1, enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, j, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(event->peer, CHAN_SYNC, enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, j, ENET_PACKET_FLAG_RELIABLE));
|
||||
Bfree(buf);
|
||||
Bfree(g_multiMapState);
|
||||
g_multiMapState = NULL;
|
||||
|
@ -1451,7 +1451,7 @@ process:
|
|||
packbuf[11] = ud.noexits;
|
||||
packbuf[12] = myconnectindex;
|
||||
|
||||
enet_peer_send(event->peer, 0, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
// a player connecting is a good time to mark everything as needing to be updated
|
||||
Bmemset(spritecrc, 0, sizeof(spritecrc));
|
||||
|
@ -1541,7 +1541,7 @@ void Net_ParseClientPacket(ENetEvent * event)
|
|||
{
|
||||
packbuf[0] = PACKET_PLAYER_READY;
|
||||
packbuf[1] = myconnectindex;
|
||||
enet_peer_send(event->peer, 0, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
g_player[other].playerreadyflag++;
|
||||
return;
|
||||
|
@ -1725,7 +1725,7 @@ void Net_ParseClientPacket(ENetEvent * event)
|
|||
packbuf[11] = ud.noexits;
|
||||
packbuf[12] = myconnectindex;
|
||||
|
||||
enet_peer_send(event->peer, 0, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
// a player connecting is a good time to mark everything as needing to be updated
|
||||
Bmemset(spritecrc, 0, sizeof(spritecrc));
|
||||
|
@ -1791,11 +1791,10 @@ void Net_GetPackets(void)
|
|||
Net_ParseClientPacket(&event);
|
||||
// broadcast takes care of enet_packet_destroy itself
|
||||
// we set the state to disconnected so enet_host_broadcast doesn't send the player back his own packets
|
||||
// SLAVE_TO_MASTER packets are channelID 1, so they aren't broadcast anywhere
|
||||
if (event.channelID == 0 && event.packet->data[0] > PACKET_BROADCAST)
|
||||
if ((event.channelID == CHAN_GAMESTATE && event.packet->data[0] > PACKET_BROADCAST) || event.channelID == CHAN_CHAT)
|
||||
{
|
||||
event.peer->state = ENET_PEER_STATE_DISCONNECTED;
|
||||
enet_host_broadcast(g_netServer, 0, event.packet);
|
||||
enet_host_broadcast(g_netServer, event.channelID, event.packet);
|
||||
event.peer->state = ENET_PEER_STATE_CONNECTED;
|
||||
}
|
||||
else enet_packet_destroy(event.packet);
|
||||
|
@ -1812,7 +1811,7 @@ void Net_GetPackets(void)
|
|||
packbuf[0] = PACKET_PLAYER_DISCONNECTED;
|
||||
packbuf[1] = (intptr_t)event.peer->data;
|
||||
packbuf[2] = myconnectindex;
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(packbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
initprintf ("%s disconnected.\n", g_player[(intptr_t)event.peer->data].user_name);
|
||||
event.peer->data = NULL;
|
||||
|
@ -1839,8 +1838,8 @@ void Net_GetPackets(void)
|
|||
event.peer -> data,
|
||||
event.channelID);
|
||||
|
||||
// channelID 1 is the map state transfer from the server
|
||||
if (event.channelID == 1)
|
||||
// mapstate transfer from the server... all packets but the last are exactly 1 kB
|
||||
if (event.channelID == CHAN_SYNC)
|
||||
{
|
||||
static int32_t datasiz = 0;
|
||||
static char * buf = NULL;
|
||||
|
@ -1871,7 +1870,7 @@ void Net_GetPackets(void)
|
|||
|
||||
packbuf[0] = PACKET_REQUEST_GAMESTATE;
|
||||
packbuf[1] = myconnectindex;
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(&packbuf[0], 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(&packbuf[0], 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2225,7 +2224,7 @@ void Net_UpdateClients(void)
|
|||
|
||||
packbuf[j++] = myconnectindex;
|
||||
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(packbuf, j, 0));
|
||||
enet_host_broadcast(g_netServer, CHAN_MOVE, enet_packet_create(packbuf, j, 0));
|
||||
|
||||
movefifosendplc++;
|
||||
}
|
||||
|
@ -3804,8 +3803,8 @@ static void Net_EnterMessage(void)
|
|||
tempbuf[1] = 255;
|
||||
tempbuf[j+2] = myconnectindex;
|
||||
j++;
|
||||
if (g_netServer) enet_host_broadcast(g_netServer, 0, enet_packet_create(tempbuf, j+2, ENET_PACKET_FLAG_UNSEQUENCED));
|
||||
else if (g_netClient) enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, j+2, ENET_PACKET_FLAG_UNSEQUENCED));
|
||||
if (g_netServer) enet_host_broadcast(g_netServer, CHAN_CHAT, enet_packet_create(tempbuf, j+2, 0));
|
||||
else if (g_netClient) enet_peer_send(g_netClientPeer, CHAN_CHAT, enet_packet_create(tempbuf, j+2, 0));
|
||||
G_AddUserQuote(recbuf);
|
||||
quotebot += 8;
|
||||
l = G_GameTextLen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,recbuf));
|
||||
|
@ -8978,9 +8977,9 @@ static void G_HandleLocalKeys(void)
|
|||
tempbuf[3] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
|
||||
G_AddUserQuote("VOTE CAST");
|
||||
|
@ -9224,9 +9223,9 @@ static void G_HandleLocalKeys(void)
|
|||
tempbuf[i++] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, i, ENET_PACKET_FLAG_UNSEQUENCED));
|
||||
enet_peer_send(g_netClientPeer, CHAN_CHAT, enet_packet_create(tempbuf, i, 0));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(tempbuf, i, ENET_PACKET_FLAG_UNSEQUENCED));
|
||||
enet_host_broadcast(g_netServer, CHAN_CHAT, enet_packet_create(tempbuf, i, 0));
|
||||
|
||||
pus = NUMPAGES;
|
||||
pub = NUMPAGES;
|
||||
|
@ -9249,9 +9248,9 @@ static void G_HandleLocalKeys(void)
|
|||
tempbuf[2] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, 3, ENET_PACKET_FLAG_UNSEQUENCED));
|
||||
enet_peer_send(g_netClientPeer, CHAN_CHAT, enet_packet_create(tempbuf, 3, 0));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(tempbuf, 3, ENET_PACKET_FLAG_UNSEQUENCED));
|
||||
enet_host_broadcast(g_netServer, CHAN_CHAT, enet_packet_create(tempbuf, 3, 0));
|
||||
}
|
||||
|
||||
pus = NUMPAGES;
|
||||
|
@ -12655,7 +12654,7 @@ static int32_t G_DoMoveThings(void)
|
|||
|
||||
packbuf[j++] = myconnectindex;
|
||||
|
||||
enet_peer_send(g_netClientPeer, 1, enet_packet_create(packbuf, j, 0));
|
||||
enet_peer_send(g_netClientPeer, CHAN_MOVE, enet_packet_create(packbuf, j, 0));
|
||||
|
||||
movefifosendplc++;
|
||||
}
|
||||
|
|
|
@ -2792,7 +2792,7 @@ nullquote:
|
|||
packbuf[1] = vm.g_p;
|
||||
packbuf[2] = 0;
|
||||
|
||||
enet_host_broadcast(g_netServer, 0 , enet_packet_create(packbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE , enet_packet_create(packbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
}
|
||||
P_UpdateScreenPal(g_player[vm.g_p].ps);
|
||||
|
|
|
@ -1462,9 +1462,9 @@ void M_DisplayMenus(void)
|
|||
tempbuf[2] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(tempbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 3, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
Net_GetPackets();
|
||||
|
||||
|
@ -5074,9 +5074,9 @@ VOLUME_ALL_40x:
|
|||
tempbuf[1] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(tempbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
voting = -1;
|
||||
}
|
||||
|
@ -5133,9 +5133,9 @@ VOLUME_ALL_40x:
|
|||
tempbuf[3] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
Bsprintf(ScriptQuotes[116],"VOTE FAILED");
|
||||
P_DoQuote(116,g_player[myconnectindex].ps);
|
||||
|
@ -5285,9 +5285,9 @@ VOLUME_ALL_40x:
|
|||
tempbuf[4] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, 5, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 5, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(tempbuf, 5, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 5, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM))
|
||||
ud.m_noexits = 0;
|
||||
|
|
|
@ -129,7 +129,7 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm)
|
|||
tempbuf[2] = ud.m_volume_number;
|
||||
tempbuf[3] = ud.m_level_number;
|
||||
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM))
|
||||
ud.m_noexits = 0;
|
||||
|
@ -283,7 +283,7 @@ static int32_t osdcmd_map(const osdfuncparm_t *parm)
|
|||
tempbuf[2] = ud.m_volume_number;
|
||||
tempbuf[3] = ud.m_level_number;
|
||||
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM))
|
||||
ud.m_noexits = 0;
|
||||
|
|
|
@ -3846,7 +3846,7 @@ void P_FragPlayer(int32_t snum)
|
|||
packbuf[3] = ActorExtra[p->i].picnum;
|
||||
packbuf[4] = myconnectindex;
|
||||
|
||||
enet_host_broadcast(g_netServer, 0, enet_packet_create(packbuf, 5, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, 5, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1583,7 +1583,7 @@ void Net_WaitForServer(void)
|
|||
packbuf[1] = myconnectindex;
|
||||
|
||||
if (g_netClientPeer)
|
||||
enet_peer_send(g_netClientPeer, 0, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
handleevents();
|
||||
Net_GetPackets();
|
||||
|
|
|
@ -582,7 +582,6 @@ int32_t G_LoadPlayer(int32_t spot)
|
|||
|
||||
ready2send = 1;
|
||||
|
||||
mmulti_flushpackets();
|
||||
clearfifo();
|
||||
Net_WaitForServer();
|
||||
|
||||
|
|
Loading…
Reference in a new issue