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:
terminx 2010-01-21 10:02:04 +00:00
parent f3802b7897
commit addf597188
21 changed files with 242 additions and 2419 deletions

View file

@ -245,8 +245,6 @@ endif
include Makefile.deps include Makefile.deps
duke3d_h+=$(EINC)/mmulti_unstable.h
.PHONY: enginelib editorlib .PHONY: enginelib editorlib
enginelib editorlib: enginelib editorlib:
-mkdir -p $(EOBJ) -mkdir -p $(EOBJ)

View file

@ -143,8 +143,6 @@ ifeq (1,$(POLYMER))
ENGINEOBJS+= $(OBJ)/polymer.$o ENGINEOBJS+= $(OBJ)/polymer.$o
endif endif
ENGINEOBJS+= $(OBJ)/mmulti_unstable.$o
EDITOROBJS=$(OBJ)/build.$o \ EDITOROBJS=$(OBJ)/build.$o \
$(OBJ)/config.$o $(OBJ)/config.$o

View file

@ -20,7 +20,6 @@ $(OBJ)/kplib.$o: $(SRC)/kplib.c $(INC)/compat.h
$(OBJ)/quicklz.$o: $(SRC)/quicklz.c $(INC)/quicklz.h $(OBJ)/quicklz.$o: $(SRC)/quicklz.c $(INC)/quicklz.h
$(OBJ)/lzwnew.$o: $(SRC)/lzwnew.c $(OBJ)/lzwnew.$o: $(SRC)/lzwnew.c
$(OBJ)/md4.$o: $(SRC)/md4.c $(INC)/md4.h $(INC)/compat.h $(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)/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)/pragmas.$o: $(SRC)/pragmas.c $(INC)/compat.h
$(OBJ)/scriptfile.$o: $(SRC)/scriptfile.c $(INC)/scriptfile.h $(INC)/cache1d.h $(INC)/compat.h $(OBJ)/scriptfile.$o: $(SRC)/scriptfile.c $(INC)/scriptfile.h $(INC)/cache1d.h $(INC)/compat.h

View file

@ -75,7 +75,6 @@ ENGINEOBJS= \
$(OBJ)\quicklz.$o \ $(OBJ)\quicklz.$o \
$(OBJ)\lzwnew.$o \ $(OBJ)\lzwnew.$o \
$(OBJ)\md4.$o \ $(OBJ)\md4.$o \
$(OBJ)\mmulti_unstable.$o \
$(OBJ)\osd.$o \ $(OBJ)\osd.$o \
$(OBJ)\pragmas.$o \ $(OBJ)\pragmas.$o \
$(OBJ)\scriptfile.$o \ $(OBJ)\scriptfile.$o \

View file

@ -301,6 +301,9 @@ extern char noclip;
EXTERN int32_t editorzrange[2]; EXTERN int32_t editorzrange[2];
EXTERN int32_t myconnectindex, numplayers;
EXTERN int32_t connecthead, connectpoint2[MAXPLAYERS];
static inline int32_t getrendermode(void) static inline int32_t getrendermode(void)
{ {
#ifndef POLYMOST #ifndef POLYMOST

View file

@ -49,6 +49,8 @@
#define FALSE 0 #define FALSE 0
#endif #endif
#define WITHKPLIB
// Define this to rewrite all 'B' versions to library functions. This // 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 // 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 // link directly. Platforms like PalmOS which don't have a standard C

View file

@ -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

View file

@ -5,8 +5,6 @@
// This file has been modified from Ken Silverman's original release // This file has been modified from Ken Silverman's original release
// by Jonathon Fowler (jonof@edgenetwk.com) // by Jonathon Fowler (jonof@edgenetwk.com)
#define WITHKPLIB
#include "compat.h" #include "compat.h"
#include "cache1d.h" #include "cache1d.h"
#include "pragmas.h" #include "pragmas.h"
@ -212,18 +210,17 @@ void suckcache(intptr_t *suckptr)
void agecache(void) void agecache(void)
{ {
int32_t cnt; int32_t cnt = (cacnum>>4);
char ch;
if (agecount >= cacnum) agecount = cacnum-1; if (agecount >= cacnum) agecount = cacnum-1;
if (agecount < 0) return; if (agecount < 0 || !cnt) return;
for (cnt=(cacnum>>4); cnt>=0; cnt--) for (; cnt>=0; cnt--)
{ {
ch = (*cac[agecount].lock); if ((((*cac[agecount].lock)-2)&255) < 198)
if (((ch-2)&255) < 198) (*cac[agecount].lock)--;
(*cac[agecount].lock) = ch-1;
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 kopen4load(char *filename, char searchfirst)
{ {
int32_t j, k, fil, newhandle; int32_t j, k, fil, newhandle = MAXOPENFILES-1;
char bad, *gfileptr; char bad, *gfileptr;
intptr_t i; intptr_t i;
newhandle = MAXOPENFILES-1;
while (filehan[newhandle] != -1) while (filehan[newhandle] != -1)
{ {
newhandle--; newhandle--;
@ -592,14 +588,13 @@ int32_t kopen4load(char *filename, char searchfirst)
} }
} }
if (searchfirst == 0) if (searchfirst == 0 && (fil = openfrompath(filename,BO_BINARY|BO_RDONLY,S_IREAD)) >= 0)
if ((fil = openfrompath(filename,BO_BINARY|BO_RDONLY,S_IREAD)) >= 0) {
{ filegrp[newhandle] = 255;
filegrp[newhandle] = 255; filehan[newhandle] = fil;
filehan[newhandle] = fil; filepos[newhandle] = 0;
filepos[newhandle] = 0; return(newhandle);
return(newhandle); }
}
for (; toupperlookup[*filename] == '/'; filename++); for (; toupperlookup[*filename] == '/'; filename++);
@ -638,7 +633,7 @@ int32_t kopen4load(char *filename, char searchfirst)
} }
if (bad) continue; if (bad) continue;
if (j<13 && gfileptr[j]) continue; // JBF: because e1l1.map might exist before e1l1 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; filegrp[newhandle] = k;
filehan[newhandle] = i; 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 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)); if (groupnum == 255) return(Bread(filenum,buffer,leng));
#ifdef WITHKPLIB #ifdef WITHKPLIB
else if (groupnum == 254) else if (groupnum == 254)

View file

@ -7908,6 +7908,7 @@ int32_t loadpics(char *filename, int32_t askedsize)
artsize += ((dasiz+15)&0xfffffff0); artsize += ((dasiz+15)&0xfffffff0);
} }
#ifdef WITHKPLIB
if (filegrp[fil] == 254) // from zip if (filegrp[fil] == 254) // from zip
{ {
i = kfilelength(fil); i = kfilelength(fil);
@ -7915,6 +7916,7 @@ int32_t loadpics(char *filename, int32_t askedsize)
klseek(fil, 0, BSEEK_SET); klseek(fil, 0, BSEEK_SET);
kread(fil, artptrs[numtilefiles], i); kread(fil, artptrs[numtilefiles], i);
} }
#endif
kclose(fil); kclose(fil);
} }
numtilefiles++; numtilefiles++;
@ -7965,6 +7967,7 @@ void loadtile(int16_t tilenume)
if ((unsigned)tilenume >= (unsigned)MAXTILES) return; if ((unsigned)tilenume >= (unsigned)MAXTILES) return;
if ((dasiz = tilesizx[tilenume]*tilesizy[tilenume]) <= 0) return; if ((dasiz = tilesizx[tilenume]*tilesizy[tilenume]) <= 0) return;
#ifdef WITHKPLIB
if (artptrs[(i = tilefilenum[tilenume])]) // from zip if (artptrs[(i = tilefilenum[tilenume])]) // from zip
{ {
waloff[tilenume] = (intptr_t)(artptrs[i] + tilefileoffs[tilenume]); 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); // OSD_Printf("loaded tile %d from zip\n", tilenume);
return; return;
} }
#endif
if (i != artfilnum) if (i != artfilnum)
{ {
@ -7992,7 +7996,11 @@ void loadtile(int16_t tilenume)
if (faketilesiz[tilenume]) if (faketilesiz[tilenume])
{ {
if (faketilesiz[tilenume] == -1) if (faketilesiz[tilenume] == -1)
{
walock[tilenume] = 255; // permanent tile
allocache(&waloff[tilenume],dasiz,&walock[tilenume]);
Bmemset((char *)waloff[tilenume],0,dasiz); Bmemset((char *)waloff[tilenume],0,dasiz);
}
else if (faketiledata[tilenume] != NULL) else if (faketiledata[tilenume] != NULL)
{ {
walock[tilenume] = 255; // permanent tile walock[tilenume] = 255; // permanent tile

File diff suppressed because it is too large Load diff

View file

@ -32,6 +32,7 @@ DEALINGS IN THE SOFTWARE.
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4100) /* unreferenced formal parameter */ #pragma warning(disable:4100) /* unreferenced formal parameter */
#pragma warning(disable:4127) /* conditional expression is constant */ #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 */ #pragma warning(disable:4706) /* assignment within conditional expression */
#endif #endif
@ -42,7 +43,8 @@ DEALINGS IN THE SOFTWARE.
#define ENABLE_LARGE_PAGES 1 #define ENABLE_LARGE_PAGES 1
#define ENABLE_FAST_HEAP_DETECTION 1 #define ENABLE_FAST_HEAP_DETECTION 1
#define NDEBUG 1 #define NDEBUG 1
#define THREADCACHEMAX 32768
#define THREADCACHEMAXBINS ((15-4)*2)
/*#define ENABLE_TOLERANT_NEDMALLOC 1*/ /*#define ENABLE_TOLERANT_NEDMALLOC 1*/
/*#define ENABLE_FAST_HEAP_DETECTION 1*/ /*#define ENABLE_FAST_HEAP_DETECTION 1*/
/*#define NEDMALLOC_DEBUG 1*/ /*#define NEDMALLOC_DEBUG 1*/
@ -54,10 +56,14 @@ DEALINGS IN THE SOFTWARE.
// #define NOINLINE // #define NOINLINE
#endif #endif
#include "nedmalloc.h" #include "nedmalloc.h"
#ifdef WIN32 #if defined(WIN32)
#include <malloc.h> #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 #endif
#if USE_ALLOCATOR==1 #if USE_ALLOCATOR==1
#define MSPACES 1 #define MSPACES 1
@ -79,7 +85,8 @@ DEALINGS IN THE SOFTWARE.
#undef DEBUG #undef DEBUG
#undef _DEBUG #undef _DEBUG
#if NEDMALLOC_DEBUG #if NEDMALLOC_DEBUG
#define _DEBUG #define _DEBUG
#define DEBUG 1
#else #else
#define DEBUG 0 #define DEBUG 0
#endif #endif
@ -96,9 +103,10 @@ DEALINGS IN THE SOFTWARE.
#endif #endif
/*#define USE_SPIN_LOCKS 0*/ /*#define USE_SPIN_LOCKS 0*/
#include "malloc.c.h" #include "malloc.c.h"
#ifdef NDEBUG /* Disable assert checking on release builds */ #ifdef NDEBUG /* Disable assert checking on release builds */
#undef DEBUG #undef DEBUG
#elif !NEDMALLOC_DEBUG #elif !NEDMALLOC_DEBUG
#ifdef __GNUC__ #ifdef __GNUC__
#warning DEBUG is defined so allocator will run with assert checking! Define NDEBUG to run at full speed. #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 #endif
/* The maximum size to be allocated from the thread cache */ /* The maximum size to be allocated from the thread cache */
#ifndef THREADCACHEMAX #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 #endif
#ifndef THREADCACHEMAXBINS
#ifdef FINEGRAINEDBINS #ifdef FINEGRAINEDBINS
/* The number of cache entries for finer grained bins. This is (topbitpos(THREADCACHEMAX)-4)*2 */ /* 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 #else
/* The number of cache entries. This is (topbitpos(THREADCACHEMAX)-4) */ /* The number of cache entries. This is (topbitpos(THREADCACHEMAX)-4) */
#define THREADCACHEMAXBINS (15-4) #define THREADCACHEMAXBINS (13-4)
#endif
#endif #endif
/* Point at which the free space in a thread cache is garbage collected */ /* Point at which the free space in a thread cache is garbage collected */
#ifndef THREADCACHEMAXFREESPACE #ifndef THREADCACHEMAXFREESPACE
#define THREADCACHEMAXFREESPACE (512*1024*4) #define THREADCACHEMAXFREESPACE (512*1024)
#endif #endif
#if USE_LOCKS
#ifdef WIN32 #ifdef WIN32
#define TLSVAR DWORD #define TLSVAR DWORD
#define TLSALLOC(k) (*(k)=TlsAlloc(), TLS_OUT_OF_INDEXES==*(k)) #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 TLSGET(k) pthread_getspecific(k)
#define TLSSET(k, a) pthread_setspecific(k, a) #define TLSSET(k, a) pthread_setspecific(k, a)
#endif #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(__cplusplus)
#if !defined(NO_NED_NAMESPACE) #if !defined(NO_NED_NAMESPACE)
@ -177,32 +201,46 @@ static size_t mspacecounter=(size_t) 0xdeadbeef;
static void *RESTRICT leastusedaddress; static void *RESTRICT leastusedaddress;
static size_t largestusedblock; static size_t largestusedblock;
#endif #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; void *RESTRICT ret=0;
size_t _alignment=alignment; size_t _alignment=alignment;
#if USE_MAGIC_HEADERS #if USE_MAGIC_HEADERS
size_t *_ret=0; size_t *_ret=0;
size+=alignment+3*sizeof(size_t); size+=alignment+3*sizeof(size_t);
_alignment=0; _alignment=0;
#endif #endif
#if USE_ALLOCATOR==0 #if USE_ALLOCATOR==0
ret=_alignment ? ret=sysmalloc(size); /* magic headers takes care of 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);
#elif USE_ALLOCATOR==1 #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 #ifndef ENABLE_FAST_HEAP_DETECTION
if(ret) if(ret)
{ {
size_t truesize=chunksize(mem2chunk(ret)); size_t truesize=chunksize(mem2chunk(ret));
if(!leastusedaddress || (void *)((mstate) mspace)->least_addr<leastusedaddress) leastusedaddress=(void *)((mstate) mspace)->least_addr; 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; 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; void *RESTRICT ret=0;
#if USE_MAGIC_HEADERS #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); size+=alignment+3*sizeof(size_t);
#endif #endif
#if USE_ALLOCATOR==0 #if USE_ALLOCATOR==0
ret=calloc(1, size); ret=syscalloc(1, size);
#elif USE_ALLOCATOR==1 #elif USE_ALLOCATOR==1
ret=mspace_calloc((mstate) mspace, 1, size); ret=mspace_calloc((mstate) mspace, 1, size);
#ifndef ENABLE_FAST_HEAP_DETECTION #ifndef ENABLE_FAST_HEAP_DETECTION
@ -254,7 +292,7 @@ static FORCEINLINE void *CallCalloc(void *RESTRICT mspace, size_t size, size_t a
return ret; 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; void *RESTRICT ret=0;
#if USE_MAGIC_HEADERS #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); printf("*** nedmalloc frees system allocated block %p\n", mem);
#endif #endif
memcpy(ret, mem, oldsize<newsize ? oldsize : newsize); memcpy(ret, mem, oldsize<newsize ? oldsize : newsize);
free(mem); sysfree(mem);
} }
return ret; return ret;
} }
@ -285,7 +323,7 @@ static FORCEINLINE void *CallRealloc(void *RESTRICT mspace, void *RESTRICT mem,
mem=(void *)(++_mem); mem=(void *)(++_mem);
#endif #endif
#if USE_ALLOCATOR==0 #if USE_ALLOCATOR==0
ret=realloc(mem, newsize); ret=sysrealloc(mem, newsize);
#elif USE_ALLOCATOR==1 #elif USE_ALLOCATOR==1
ret=mspace_realloc((mstate) mspace, mem, newsize); ret=mspace_realloc((mstate) mspace, mem, newsize);
#ifndef ENABLE_FAST_HEAP_DETECTION #ifndef ENABLE_FAST_HEAP_DETECTION
@ -327,7 +365,7 @@ static FORCEINLINE void CallFree(void *RESTRICT mspace, void *RESTRICT mem, int
#if defined(DEBUG) #if defined(DEBUG)
printf("*** nedmalloc frees system allocated block %p\n", mem); printf("*** nedmalloc frees system allocated block %p\n", mem);
#endif #endif
free(mem); sysfree(mem);
return; return;
} }
#if USE_MAGIC_HEADERS #if USE_MAGIC_HEADERS
@ -338,7 +376,7 @@ static FORCEINLINE void CallFree(void *RESTRICT mspace, void *RESTRICT mem, int
mem=(void *)(++_mem); mem=(void *)(++_mem);
#endif #endif
#if USE_ALLOCATOR==0 #if USE_ALLOCATOR==0
free(mem); sysfree(mem);
#elif USE_ALLOCATOR==1 #elif USE_ALLOCATOR==1
mspace_free((mstate) mspace, mem); mspace_free((mstate) mspace, mem);
#endif #endif
@ -412,7 +450,7 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC
return fm; return fm;
} }
#else #else
#ifdef _MSC_VER #ifdef WIN32
__try __try
#endif #endif
{ {
@ -455,7 +493,7 @@ static NEDMALLOCNOALIASATTR mstate nedblkmstate(void *RESTRICT mem) THROWSPEC
return fm; return fm;
} }
} }
#ifdef _MSC_VER #ifdef WIN32
__except(1) { } __except(1) { }
#endif #endif
#endif #endif
@ -495,36 +533,25 @@ NEDMALLOCNOALIASATTR size_t nedblksize(int *RESTRICT isforeign, void *RESTRICT m
#endif #endif
#endif #endif
#if defined(ENABLE_TOLERANT_NEDMALLOC) || USE_ALLOCATOR==0 #if defined(ENABLE_TOLERANT_NEDMALLOC) || USE_ALLOCATOR==0
#ifdef WIN32 return sysblksize(mem);
/* 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
#endif #endif
} }
return 0; 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 * 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 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 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 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 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); } NEDMALLOCNOALIASATTR int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim((nedpool *) 0, pad); }
void nedmalloc_stats() THROWSPEC { nedpmalloc_stats((nedpool *) 0); } void nedmalloc_stats() THROWSPEC { nedpmalloc_stats((nedpool *) 0); }
NEDMALLOCNOALIASATTR size_t nedmalloc_footprint() THROWSPEC { return nedpmalloc_footprint((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_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_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc((nedpool *) 0, elems, sizes, chunks); }
struct threadcacheblk_t; struct threadcacheblk_t;
typedef struct threadcacheblk_t threadcacheblk; typedef struct threadcacheblk_t threadcacheblk;
@ -552,7 +579,9 @@ typedef struct threadcache_t
} threadcache; } threadcache;
struct nedpool_t struct nedpool_t
{ {
#if USE_LOCKS
MLOCK_T mutex; MLOCK_T mutex;
#endif
void *uservalue; void *uservalue;
int threads; /* Max entries in m to use */ int threads; /* Max entries in m to use */
threadcache *caches[THREADCACHEMAXCACHES]; threadcache *caches[THREADCACHEMAXCACHES];
@ -709,27 +738,40 @@ static NOINLINE threadcache *AllocCache(nedpool *RESTRICT p) THROWSPEC
{ {
threadcache *tc=0; threadcache *tc=0;
int n, end; int n, end;
#if USE_LOCKS
ACQUIRE_LOCK(&p->mutex); ACQUIRE_LOCK(&p->mutex);
#endif
for(n=0; n<THREADCACHEMAXCACHES && p->caches[n]; n++); for(n=0; n<THREADCACHEMAXCACHES && p->caches[n]; n++);
if(THREADCACHEMAXCACHES==n) if(THREADCACHEMAXCACHES==n)
{ /* List exhausted, so disable for this thread */ { /* List exhausted, so disable for this thread */
#if USE_LOCKS
RELEASE_LOCK(&p->mutex); RELEASE_LOCK(&p->mutex);
#endif
return 0; return 0;
} }
tc=p->caches[n]=(threadcache *) CallCalloc(p->m[0], sizeof(threadcache), 0); tc=p->caches[n]=(threadcache *) CallCalloc(p->m[0], sizeof(threadcache), 0);
if(!tc) if(!tc)
{ {
#if USE_LOCKS
RELEASE_LOCK(&p->mutex); RELEASE_LOCK(&p->mutex);
#endif
return 0; return 0;
} }
#ifdef FULLSANITYCHECKS #ifdef FULLSANITYCHECKS
tc->magic1=*(unsigned int *)"NEDMALC1"; tc->magic1=*(unsigned int *)"NEDMALC1";
tc->magic2=*(unsigned int *)"NEDMALC2"; tc->magic2=*(unsigned int *)"NEDMALC2";
#endif #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++); for(end=0; p->m[end]; end++);
tc->mymspace=abs(tc->threadid) % end; tc->mymspace=abs(tc->threadid) % end;
#if USE_LOCKS
RELEASE_LOCK(&p->mutex); RELEASE_LOCK(&p->mutex);
#endif
if(TLSSET(p->mycache, (void *)(size_t)(n+1))) abort(); if(TLSSET(p->mycache, (void *)(size_t)(n+1))) abort();
return tc; 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 static NOINLINE void ReleaseFreeInCache(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace) THROWSPEC
{ {
unsigned int age=THREADCACHEMAXFREESPACE/8192; unsigned int age=THREADCACHEMAXFREESPACE/8192;
#if USE_LOCKS
/*ACQUIRE_LOCK(&p->m[mymspace]->mutex);*/ /*ACQUIRE_LOCK(&p->m[mymspace]->mutex);*/
#endif
while(age && tc->freeInCache>=THREADCACHEMAXFREESPACE) while(age && tc->freeInCache>=THREADCACHEMAXFREESPACE)
{ {
RemoveCacheEntries(p, tc, age); RemoveCacheEntries(p, tc, age);
/*printf("*** Removing cache entries older than %u (%u)\n", age, (unsigned int) tc->freeInCache);*/ /*printf("*** Removing cache entries older than %u (%u)\n", age, (unsigned int) tc->freeInCache);*/
age>>=1; age>>=1;
} }
#if USE_LOCKS
/*RELEASE_LOCK(&p->m[mymspace]->mutex);*/ /*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 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; idx<<=1;
if(size>bestsize) if(size>bestsize)
{ {
unsigned int biggerbestsize=(bestsize+bestsize)<<1; unsigned int biggerbestsize=bestsize+bestsize<<1;
if(size>=biggerbestsize) if(size>=biggerbestsize)
{ {
idx++; idx++;
@ -904,7 +950,9 @@ static NOINLINE int InitPool(nedpool *RESTRICT p, size_t capacity, int threads)
ensure_initialization(); ensure_initialization();
ACQUIRE_MALLOC_GLOBAL_LOCK(); ACQUIRE_MALLOC_GLOBAL_LOCK();
if(p->threads) goto done; if(p->threads) goto done;
#if USE_LOCKS
if(INITIAL_LOCK(&p->mutex)) goto err; if(INITIAL_LOCK(&p->mutex)) goto err;
#endif
if(TLSALLOC(&p->mycache)) goto err; if(TLSALLOC(&p->mycache)) goto err;
#if USE_ALLOCATOR==0 #if USE_ALLOCATOR==0
p->m[0]=(mstate) mspacecounter++; 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 unlocked one and if we fail, we create a new one so long as we don't
exceed p->threads */ exceed p->threads */
int n, end; 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; if(TRY_LOCK(&p->m[n]->mutex)) goto found;
} }
@ -983,6 +1033,7 @@ static NOINLINE mstate FindMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc,
badexit: badexit:
ACQUIRE_LOCK(&p->m[*lastUsed]->mutex); ACQUIRE_LOCK(&p->m[*lastUsed]->mutex);
return p->m[*lastUsed]; return p->m[*lastUsed];
#endif
found: found:
*lastUsed=n; *lastUsed=n;
if(tc) if(tc)
@ -1004,7 +1055,9 @@ typedef struct PoolList_t
nedpool *list[16]; nedpool *list[16];
#endif #endif
} PoolList; } PoolList;
#if USE_LOCKS
static MLOCK_T poollistlock; static MLOCK_T poollistlock;
#endif
static PoolList *poollist; static PoolList *poollist;
NEDMALLOCPTRATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC 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; PoolList *newpoollist=0;
if(!(newpoollist=(PoolList *) nedpcalloc(0, 1, sizeof(PoolList)+sizeof(nedpool *)))) return 0; if(!(newpoollist=(PoolList *) nedpcalloc(0, 1, sizeof(PoolList)+sizeof(nedpool *)))) return 0;
#if USE_LOCKS
INITIAL_LOCK(&poollistlock); INITIAL_LOCK(&poollistlock);
ACQUIRE_LOCK(&poollistlock); ACQUIRE_LOCK(&poollistlock);
#endif
poollist=newpoollist; poollist=newpoollist;
poollist->size=sizeof(poollist->list)/sizeof(nedpool *); poollist->size=sizeof(poollist->list)/sizeof(nedpool *);
} }
#if USE_LOCKS
else else
ACQUIRE_LOCK(&poollistlock); ACQUIRE_LOCK(&poollistlock);
#endif
if(poollist->length==poollist->size) if(poollist->length==poollist->size)
{ {
PoolList *newpoollist=0; PoolList *newpoollist=0;
@ -1039,13 +1096,19 @@ NEDMALLOCPTRATTR nedpool *nedcreatepool(size_t capacity, int threads) THROWSPEC
} }
poollist->list[poollist->length++]=ret; poollist->list[poollist->length++]=ret;
badexit: badexit:
RELEASE_LOCK(&poollistlock); {
#if USE_LOCKS
RELEASE_LOCK(&poollistlock);
#endif
}
return ret; return ret;
} }
void neddestroypool(nedpool *p) THROWSPEC void neddestroypool(nedpool *p) THROWSPEC
{ {
unsigned int n; unsigned int n;
#if USE_LOCKS
ACQUIRE_LOCK(&p->mutex); ACQUIRE_LOCK(&p->mutex);
#endif
DestroyCaches(p); DestroyCaches(p);
for(n=0; p->m[n]; n++) for(n=0; p->m[n]; n++)
{ {
@ -1054,10 +1117,14 @@ void neddestroypool(nedpool *p) THROWSPEC
#endif #endif
p->m[n]=0; p->m[n]=0;
} }
#if USE_LOCKS
RELEASE_LOCK(&p->mutex); RELEASE_LOCK(&p->mutex);
#endif
if(TLSFREE(p->mycache)) abort(); if(TLSFREE(p->mycache)) abort();
nedpfree(0, p); nedpfree(0, p);
#if USE_LOCKS
ACQUIRE_LOCK(&poollistlock); ACQUIRE_LOCK(&poollistlock);
#endif
assert(poollist); assert(poollist);
for(n=0; n<poollist->length && poollist->list[n]!=p; n++); for(n=0; n<poollist->length && poollist->list[n]!=p; n++);
assert(n!=poollist->length); assert(n!=poollist->length);
@ -1068,13 +1135,17 @@ void neddestroypool(nedpool *p) THROWSPEC
nedpfree(0, poollist); nedpfree(0, poollist);
poollist=0; poollist=0;
} }
#if USE_LOCKS
RELEASE_LOCK(&poollistlock); RELEASE_LOCK(&poollistlock);
#endif
} }
void neddestroysyspool() THROWSPEC void neddestroysyspool() THROWSPEC
{ {
nedpool *p=&syspool; nedpool *p=&syspool;
int n; int n;
#if USE_LOCKS
ACQUIRE_LOCK(&p->mutex); ACQUIRE_LOCK(&p->mutex);
#endif
DestroyCaches(p); DestroyCaches(p);
for(n=0; p->m[n]; n++) for(n=0; p->m[n]; n++)
{ {
@ -1089,18 +1160,26 @@ void neddestroysyspool() THROWSPEC
for(n=0; n<MAXTHREADSINPOOL+1; n++) for(n=0; n<MAXTHREADSINPOOL+1; n++)
p->m[n]=(mstate)(size_t)(sizeof(size_t)>4 ? 0xdeadbeefdeadbeefULL : 0xdeadbeefUL); p->m[n]=(mstate)(size_t)(sizeof(size_t)>4 ? 0xdeadbeefdeadbeefULL : 0xdeadbeefUL);
if(TLSFREE(p->mycache)) abort(); if(TLSFREE(p->mycache)) abort();
#if USE_LOCKS
RELEASE_LOCK(&p->mutex); RELEASE_LOCK(&p->mutex);
#endif
} }
nedpool **nedpoollist() THROWSPEC nedpool **nedpoollist() THROWSPEC
{ {
nedpool **ret=0; nedpool **ret=0;
if(poollist) if(poollist)
{ {
#if USE_LOCKS
ACQUIRE_LOCK(&poollistlock); ACQUIRE_LOCK(&poollistlock);
#endif
if(!(ret=(nedpool **) nedmalloc((poollist->length+1)*sizeof(nedpool *)))) goto badexit; if(!(ret=(nedpool **) nedmalloc((poollist->length+1)*sizeof(nedpool *)))) goto badexit;
memcpy(ret, poollist->list, (poollist->length+1)*sizeof(nedpool *)); memcpy(ret, poollist->list, (poollist->length+1)*sizeof(nedpool *));
badexit: badexit:
RELEASE_LOCK(&poollistlock); {
#if USE_LOCKS
RELEASE_LOCK(&poollistlock);
#endif
}
} }
return ret; return ret;
} }
@ -1158,19 +1237,28 @@ void neddisablethreadcache(nedpool *p) THROWSPEC
nedtrimthreadcache(p, 1); nedtrimthreadcache(p, 1);
} }
#if USE_LOCKS && USE_ALLOCATOR==1
#define GETMSPACE(m,p,tc,ms,s,action) \ #define GETMSPACE(m,p,tc,ms,s,action) \
do \ do \
{ \ { \
mstate m = GetMSpace((p),(tc),(ms),(s)); \ mstate m = GetMSpace((p),(tc),(ms),(s)); \
action; \ action; \
if(USE_ALLOCATOR==1) { RELEASE_LOCK(&m->mutex); } \ RELEASE_LOCK(&m->mutex); \
} while (0) } 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 static FORCEINLINE mstate GetMSpace(nedpool *RESTRICT p, threadcache *RESTRICT tc, int mymspace, size_t size) THROWSPEC
{ /* Returns a locked and ready for use mspace */ { /* Returns a locked and ready for use mspace */
mstate m=p->m[mymspace]; mstate m=p->m[mymspace];
assert(m); 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); if(!TRY_LOCK(&p->m[mymspace]->mutex)) m=FindMSpace(p, tc, &mymspace, size);
/*assert(IS_LOCKED(&p->m[mymspace]->mutex));*/ /*assert(IS_LOCKED(&p->m[mymspace]->mutex));*/
#endif #endif
@ -1214,7 +1302,9 @@ static FORCEINLINE void GetThreadCache(nedpool *RESTRICT *RESTRICT p, threadcach
} }
else GetThreadCache_cold2(p, tc, mymspace, mycache); else GetThreadCache_cold2(p, tc, mymspace, mycache);
assert(*mymspace>=0); assert(*mymspace>=0);
#if USE_LOCKS
assert(!(*tc) || (long)(size_t)CURRENT_THREAD==(*tc)->threadid); assert(!(*tc) || (long)(size_t)CURRENT_THREAD==(*tc)->threadid);
#endif
#ifdef FULLSANITYCHECKS #ifdef FULLSANITYCHECKS
if(*tc) if(*tc)
{ {
@ -1440,8 +1530,6 @@ NEDMALLOCPTRATTR void **nedpindependent_calloc(nedpool *p, size_t elemsno, size_
#endif #endif
return ret; return ret;
} }
#if 0
NEDMALLOCPTRATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC NEDMALLOCPTRATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **chunks) THROWSPEC
{ {
void **ret; void **ret;
@ -1461,7 +1549,6 @@ NEDMALLOCPTRATTR void **nedpindependent_comalloc(nedpool *p, size_t elems, size_
#endif #endif
return ret; return ret;
} }
#endif // 0
// cheap replacement for strdup so we aren't feeding system allocated blocks into nedmalloc // cheap replacement for strdup so we aren't feeding system allocated blocks into nedmalloc

View file

@ -8,7 +8,6 @@
#include "baselayer.h" #include "baselayer.h"
#include "cache1d.h" #include "cache1d.h"
#include "pragmas.h" #include "pragmas.h"
#include "mmulti_unstable.h"
symbol_t *symbols = NULL; symbol_t *symbols = NULL;
static symbol_t *addnewsymbol(const char *name); static symbol_t *addnewsymbol(const char *name);

View file

@ -38,7 +38,6 @@
#include "build.h" #include "build.h"
#include "a.h" #include "a.h"
#include "osd.h" #include "osd.h"
#include "mmulti_unstable.h"
// undefine to restrict windowed resolutions to conventional sizes // undefine to restrict windowed resolutions to conventional sizes
#define ANY_WINDOWED_SIZE #define ANY_WINDOWED_SIZE
@ -911,10 +910,7 @@ DWORD WINAPI ProcessMouse(LPVOID lpThreadParameter)
(LPDIDEVICEOBJECTDATA)&didod[0], &dwElements, 0); (LPDIDEVICEOBJECTDATA)&didod[0], &dwElements, 0);
if (!dwElements || result != DI_OK) if (!dwElements || result != DI_OK)
{
Sleep(100);
continue; continue;
}
do do
{ {
@ -4206,7 +4202,7 @@ static inline BOOL CheckWinVersion(void)
// we don't like anything older than Windows 2000, but the BUILD_WIN9X // we don't like anything older than Windows 2000, but the BUILD_WIN9X
// variable allows attempting to run on 9x (for masochists and sodomites) // 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; if (osv.dwMajorVersion >= 5) return TRUE;

View file

@ -39,8 +39,6 @@ extern "C" {
#include "cache1d.h" #include "cache1d.h"
#include "pragmas.h" #include "pragmas.h"
#include "mmulti_unstable.h"
#include "baselayer.h" #include "baselayer.h"
#include "function.h" #include "function.h"
@ -53,6 +51,16 @@ extern ENetHost * g_netServer;
extern ENetHost * g_netClient; extern ENetHost * g_netClient;
extern ENetPeer * g_netClientPeer; 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 APPNAME "EDuke32"
#define VERSION " 2.0.0devel" #define VERSION " 2.0.0devel"
// this is checked against http://eduke32.com/VERSION // this is checked against http://eduke32.com/VERSION

View file

@ -593,7 +593,7 @@ void Net_Connect(const char * srvaddr)
address.port = atoi((addrstr = strtok(NULL, ":")) == NULL ? "23513" : addrstr); address.port = atoi((addrstr = strtok(NULL, ":")) == NULL ? "23513" : addrstr);
// use 2 channels for easy packet sorting at a lower level than the game later // 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) if (g_netClientPeer == NULL)
{ {
@ -705,7 +705,7 @@ static void Net_SendVersion(ENetPeer * client)
buf[2] = (uint8_t)atoi(s_buildDate); buf[2] = (uint8_t)atoi(s_buildDate);
buf[3] = myconnectindex; 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) void Net_SendClientInfo(void)
@ -740,9 +740,9 @@ void Net_SendClientInfo(void)
buf[l++] = myconnectindex; buf[l++] = myconnectindex;
if (g_netClient) 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) 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) void Net_SendUserMapName(void)
@ -764,9 +764,9 @@ void Net_SendUserMapName(void)
packbuf[j++] = myconnectindex; packbuf[j++] = myconnectindex;
if (g_netClient) 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) 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) 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; packbuf[12] = myconnectindex;
if (g_netClient) 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) 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; static mapstate_t *g_multiMapState = NULL;
@ -812,7 +812,7 @@ static void Net_SendChallenge(void)
buf[l++] = myconnectindex; 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) void P_Disconnected(int32_t i)
@ -895,12 +895,12 @@ void Net_SyncPlayer(ENetEvent * event)
packbuf[3] = ud.multimode; packbuf[3] = ud.multimode;
packbuf[4] = i; packbuf[4] = i;
packbuf[5] = myconnectindex; 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[0] = PACKET_PLAYER_INDEX;
packbuf[1] = i; packbuf[1] = i;
packbuf[2] = myconnectindex; 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_SendClientInfo();
Net_SendUserMapName(); Net_SendUserMapName();
@ -931,10 +931,10 @@ void Net_SyncPlayer(ENetEvent * event)
j = qlz_compress((char *)g_multiMapState, buf, sizeof(mapstate_t), state_compress); j = qlz_compress((char *)g_multiMapState, buf, sizeof(mapstate_t), state_compress);
while (j > 1024) 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; 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(buf);
Bfree(g_multiMapState); Bfree(g_multiMapState);
g_multiMapState = NULL; g_multiMapState = NULL;
@ -1451,7 +1451,7 @@ process:
packbuf[11] = ud.noexits; packbuf[11] = ud.noexits;
packbuf[12] = myconnectindex; 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 // a player connecting is a good time to mark everything as needing to be updated
Bmemset(spritecrc, 0, sizeof(spritecrc)); Bmemset(spritecrc, 0, sizeof(spritecrc));
@ -1541,7 +1541,7 @@ void Net_ParseClientPacket(ENetEvent * event)
{ {
packbuf[0] = PACKET_PLAYER_READY; packbuf[0] = PACKET_PLAYER_READY;
packbuf[1] = myconnectindex; 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++; g_player[other].playerreadyflag++;
return; return;
@ -1725,7 +1725,7 @@ void Net_ParseClientPacket(ENetEvent * event)
packbuf[11] = ud.noexits; packbuf[11] = ud.noexits;
packbuf[12] = myconnectindex; 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 // a player connecting is a good time to mark everything as needing to be updated
Bmemset(spritecrc, 0, sizeof(spritecrc)); Bmemset(spritecrc, 0, sizeof(spritecrc));
@ -1791,11 +1791,10 @@ void Net_GetPackets(void)
Net_ParseClientPacket(&event); Net_ParseClientPacket(&event);
// broadcast takes care of enet_packet_destroy itself // 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 // 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 == CHAN_GAMESTATE && event.packet->data[0] > PACKET_BROADCAST) || event.channelID == CHAN_CHAT)
if (event.channelID == 0 && event.packet->data[0] > PACKET_BROADCAST)
{ {
event.peer->state = ENET_PEER_STATE_DISCONNECTED; 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; event.peer->state = ENET_PEER_STATE_CONNECTED;
} }
else enet_packet_destroy(event.packet); else enet_packet_destroy(event.packet);
@ -1812,7 +1811,7 @@ void Net_GetPackets(void)
packbuf[0] = PACKET_PLAYER_DISCONNECTED; packbuf[0] = PACKET_PLAYER_DISCONNECTED;
packbuf[1] = (intptr_t)event.peer->data; packbuf[1] = (intptr_t)event.peer->data;
packbuf[2] = myconnectindex; 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); initprintf ("%s disconnected.\n", g_player[(intptr_t)event.peer->data].user_name);
event.peer->data = NULL; event.peer->data = NULL;
@ -1839,8 +1838,8 @@ void Net_GetPackets(void)
event.peer -> data, event.peer -> data,
event.channelID); event.channelID);
// channelID 1 is the map state transfer from the server // mapstate transfer from the server... all packets but the last are exactly 1 kB
if (event.channelID == 1) if (event.channelID == CHAN_SYNC)
{ {
static int32_t datasiz = 0; static int32_t datasiz = 0;
static char * buf = NULL; static char * buf = NULL;
@ -1871,7 +1870,7 @@ void Net_GetPackets(void)
packbuf[0] = PACKET_REQUEST_GAMESTATE; packbuf[0] = PACKET_REQUEST_GAMESTATE;
packbuf[1] = myconnectindex; 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 else
{ {
@ -2225,7 +2224,7 @@ void Net_UpdateClients(void)
packbuf[j++] = myconnectindex; 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++; movefifosendplc++;
} }
@ -3804,8 +3803,8 @@ static void Net_EnterMessage(void)
tempbuf[1] = 255; tempbuf[1] = 255;
tempbuf[j+2] = myconnectindex; tempbuf[j+2] = myconnectindex;
j++; j++;
if (g_netServer) enet_host_broadcast(g_netServer, 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, 0, enet_packet_create(tempbuf, j+2, ENET_PACKET_FLAG_UNSEQUENCED)); else if (g_netClient) enet_peer_send(g_netClientPeer, CHAN_CHAT, enet_packet_create(tempbuf, j+2, 0));
G_AddUserQuote(recbuf); G_AddUserQuote(recbuf);
quotebot += 8; quotebot += 8;
l = G_GameTextLen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,recbuf)); l = G_GameTextLen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,recbuf));
@ -8978,9 +8977,9 @@ static void G_HandleLocalKeys(void)
tempbuf[3] = myconnectindex; tempbuf[3] = myconnectindex;
if (g_netClient) 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) 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"); G_AddUserQuote("VOTE CAST");
@ -9224,9 +9223,9 @@ static void G_HandleLocalKeys(void)
tempbuf[i++] = myconnectindex; tempbuf[i++] = myconnectindex;
if (g_netClient) 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) 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; pus = NUMPAGES;
pub = NUMPAGES; pub = NUMPAGES;
@ -9249,9 +9248,9 @@ static void G_HandleLocalKeys(void)
tempbuf[2] = myconnectindex; tempbuf[2] = myconnectindex;
if (g_netClient) 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) 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; pus = NUMPAGES;
@ -12655,7 +12654,7 @@ static int32_t G_DoMoveThings(void)
packbuf[j++] = myconnectindex; 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++; movefifosendplc++;
} }

View file

@ -2792,7 +2792,7 @@ nullquote:
packbuf[1] = vm.g_p; packbuf[1] = vm.g_p;
packbuf[2] = 0; 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); P_UpdateScreenPal(g_player[vm.g_p].ps);

View file

@ -1462,9 +1462,9 @@ void M_DisplayMenus(void)
tempbuf[2] = myconnectindex; tempbuf[2] = myconnectindex;
if (g_netClient) 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) 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(); Net_GetPackets();
@ -5074,9 +5074,9 @@ VOLUME_ALL_40x:
tempbuf[1] = myconnectindex; tempbuf[1] = myconnectindex;
if (g_netClient) 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) 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; voting = -1;
} }
@ -5133,9 +5133,9 @@ VOLUME_ALL_40x:
tempbuf[3] = myconnectindex; tempbuf[3] = myconnectindex;
if (g_netClient) 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) 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"); Bsprintf(ScriptQuotes[116],"VOTE FAILED");
P_DoQuote(116,g_player[myconnectindex].ps); P_DoQuote(116,g_player[myconnectindex].ps);
@ -5285,9 +5285,9 @@ VOLUME_ALL_40x:
tempbuf[4] = myconnectindex; tempbuf[4] = myconnectindex;
if (g_netClient) 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) 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)) if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM))
ud.m_noexits = 0; ud.m_noexits = 0;

View file

@ -129,7 +129,7 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm)
tempbuf[2] = ud.m_volume_number; tempbuf[2] = ud.m_volume_number;
tempbuf[3] = ud.m_level_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)) if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM))
ud.m_noexits = 0; ud.m_noexits = 0;
@ -283,7 +283,7 @@ static int32_t osdcmd_map(const osdfuncparm_t *parm)
tempbuf[2] = ud.m_volume_number; tempbuf[2] = ud.m_volume_number;
tempbuf[3] = ud.m_level_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)) if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM))
ud.m_noexits = 0; ud.m_noexits = 0;

View file

@ -3846,7 +3846,7 @@ void P_FragPlayer(int32_t snum)
packbuf[3] = ActorExtra[p->i].picnum; packbuf[3] = ActorExtra[p->i].picnum;
packbuf[4] = myconnectindex; 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));
} }
} }

View file

@ -1583,7 +1583,7 @@ void Net_WaitForServer(void)
packbuf[1] = myconnectindex; packbuf[1] = myconnectindex;
if (g_netClientPeer) 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(); handleevents();
Net_GetPackets(); Net_GetPackets();

View file

@ -582,7 +582,6 @@ int32_t G_LoadPlayer(int32_t spot)
ready2send = 1; ready2send = 1;
mmulti_flushpackets();
clearfifo(); clearfifo();
Net_WaitForServer(); Net_WaitForServer();